#ifndef FI_EQ_H
#define FI_EQ_H
#ifndef _WIN32
#include <pthread.h>
#endif
#include <rdma/fabric.h>
#include <rdma/fi_errno.h>
#ifdef __cplusplus
extern "C" {
#endif
enum fi_wait_obj {
FI_WAIT_NONE,
FI_WAIT_UNSPEC,
FI_WAIT_SET,
FI_WAIT_FD,
FI_WAIT_MUTEX_COND
};
struct fi_wait_attr {
enum fi_wait_obj wait_obj;
uint64_t flags;
};
struct fi_ops_wait {
size_t size;
int (*wait)(struct fid_wait *waitset, int timeout);
};
struct fid_wait {
struct fid fid;
struct fi_ops_wait *ops;
};
#ifndef _WIN32
struct fi_mutex_cond {
pthread_mutex_t *mutex;
pthread_cond_t *cond;
};
#endif
struct fi_poll_attr {
uint64_t flags;
};
struct fi_ops_poll {
size_t size;
int (*poll)(struct fid_poll *pollset, void **context, int count);
int (*poll_add)(struct fid_poll *pollset, struct fid *event_fid,
uint64_t flags);
int (*poll_del)(struct fid_poll *pollset, struct fid *event_fid,
uint64_t flags);
};
struct fid_poll {
struct fid fid;
struct fi_ops_poll *ops;
};
struct fi_eq_attr {
size_t size;
uint64_t flags;
enum fi_wait_obj wait_obj;
int signaling_vector;
struct fid_wait *wait_set;
};
enum {
FI_NOTIFY,
FI_CONNREQ,
FI_CONNECTED,
FI_SHUTDOWN,
FI_MR_COMPLETE,
FI_AV_COMPLETE,
FI_JOIN_COMPLETE,
};
struct fi_eq_entry {
fid_t fid;
void *context;
uint64_t data;
};
struct fi_eq_err_entry {
fid_t fid;
void *context;
uint64_t data;
int err;
int prov_errno;
void *err_data;
size_t err_data_size;
};
struct fi_eq_cm_entry {
fid_t fid;
struct fi_info *info;
uint8_t data[];
};
struct fi_ops_eq {
size_t size;
ssize_t (*read)(struct fid_eq *eq, uint32_t *event,
void *buf, size_t len, uint64_t flags);
ssize_t (*readerr)(struct fid_eq *eq, struct fi_eq_err_entry *buf,
uint64_t flags);
ssize_t (*write)(struct fid_eq *eq, uint32_t event,
const void *buf, size_t len, uint64_t flags);
ssize_t (*sread)(struct fid_eq *eq, uint32_t *event,
void *buf, size_t len, int timeout, uint64_t flags);
const char * (*strerror)(struct fid_eq *eq, int prov_errno,
const void *err_data, char *buf, size_t len);
};
struct fid_eq {
struct fid fid;
struct fi_ops_eq *ops;
};
enum fi_cq_format {
FI_CQ_FORMAT_UNSPEC,
FI_CQ_FORMAT_CONTEXT,
FI_CQ_FORMAT_MSG,
FI_CQ_FORMAT_DATA,
FI_CQ_FORMAT_TAGGED,
};
struct fi_cq_entry {
void *op_context;
};
struct fi_cq_msg_entry {
void *op_context;
uint64_t flags;
size_t len;
};
struct fi_cq_data_entry {
void *op_context;
uint64_t flags;
size_t len;
void *buf;
uint64_t data;
};
struct fi_cq_tagged_entry {
void *op_context;
uint64_t flags;
size_t len;
void *buf;
uint64_t data;
uint64_t tag;
};
struct fi_cq_err_entry {
void *op_context;
uint64_t flags;
size_t len;
void *buf;
uint64_t data;
uint64_t tag;
size_t olen;
int err;
int prov_errno;
void *err_data;
size_t err_data_size;
};
enum fi_cq_wait_cond {
FI_CQ_COND_NONE,
FI_CQ_COND_THRESHOLD
};
struct fi_cq_attr {
size_t size;
uint64_t flags;
enum fi_cq_format format;
enum fi_wait_obj wait_obj;
int signaling_vector;
enum fi_cq_wait_cond wait_cond;
struct fid_wait *wait_set;
};
struct fi_ops_cq {
size_t size;
ssize_t (*read)(struct fid_cq *cq, void *buf, size_t count);
ssize_t (*readfrom)(struct fid_cq *cq, void *buf, size_t count,
fi_addr_t *src_addr);
ssize_t (*readerr)(struct fid_cq *cq, struct fi_cq_err_entry *buf,
uint64_t flags);
ssize_t (*sread)(struct fid_cq *cq, void *buf, size_t count,
const void *cond, int timeout);
ssize_t (*sreadfrom)(struct fid_cq *cq, void *buf, size_t count,
fi_addr_t *src_addr, const void *cond, int timeout);
int (*signal)(struct fid_cq *cq);
const char * (*strerror)(struct fid_cq *cq, int prov_errno,
const void *err_data, char *buf, size_t len);
};
struct fid_cq {
struct fid fid;
struct fi_ops_cq *ops;
};
enum fi_cntr_events {
FI_CNTR_EVENTS_COMP
};
struct fi_cntr_attr {
enum fi_cntr_events events;
enum fi_wait_obj wait_obj;
struct fid_wait *wait_set;
uint64_t flags;
};
struct fi_ops_cntr {
size_t size;
uint64_t (*read)(struct fid_cntr *cntr);
uint64_t (*readerr)(struct fid_cntr *cntr);
int (*add)(struct fid_cntr *cntr, uint64_t value);
int (*set)(struct fid_cntr *cntr, uint64_t value);
int (*wait)(struct fid_cntr *cntr, uint64_t threshold, int timeout);
int (*adderr)(struct fid_cntr *cntr, uint64_t value);
int (*seterr)(struct fid_cntr *cntr, uint64_t value);
};
struct fid_cntr {
struct fid fid;
struct fi_ops_cntr *ops;
};
#ifdef FABRIC_DIRECT
#include <rdma/fi_direct_eq.h>
#endif
#ifndef FABRIC_DIRECT_EQ
static inline int
fi_trywait(struct fid_fabric *fabric, struct fid **fids, int count)
{
return fabric->ops->trywait(fabric, fids, count);
}
static inline int
fi_wait(struct fid_wait *waitset, int timeout)
{
return waitset->ops->wait(waitset, timeout);
}
static inline int
fi_poll(struct fid_poll *pollset, void **context, int count)
{
return pollset->ops->poll(pollset, context, count);
}
static inline int
fi_poll_add(struct fid_poll *pollset, struct fid *event_fid, uint64_t flags)
{
return pollset->ops->poll_add(pollset, event_fid, flags);
}
static inline int
fi_poll_del(struct fid_poll *pollset, struct fid *event_fid, uint64_t flags)
{
return pollset->ops->poll_del(pollset, event_fid, flags);
}
static inline int
fi_eq_open(struct fid_fabric *fabric, struct fi_eq_attr *attr,
struct fid_eq **eq, void *context)
{
return fabric->ops->eq_open(fabric, attr, eq, context);
}
static inline ssize_t
fi_eq_read(struct fid_eq *eq, uint32_t *event, void *buf,
size_t len, uint64_t flags)
{
return eq->ops->read(eq, event, buf, len, flags);
}
static inline ssize_t
fi_eq_readerr(struct fid_eq *eq, struct fi_eq_err_entry *buf, uint64_t flags)
{
return eq->ops->readerr(eq, buf, flags);
}
static inline ssize_t
fi_eq_write(struct fid_eq *eq, uint32_t event, const void *buf,
size_t len, uint64_t flags)
{
return eq->ops->write(eq, event, buf, len, flags);
}
static inline ssize_t
fi_eq_sread(struct fid_eq *eq, uint32_t *event, void *buf, size_t len,
int timeout, uint64_t flags)
{
return eq->ops->sread(eq, event, buf, len, timeout, flags);
}
static inline const char *
fi_eq_strerror(struct fid_eq *eq, int prov_errno, const void *err_data,
char *buf, size_t len)
{
return eq->ops->strerror(eq, prov_errno, err_data, buf, len);
}
static inline ssize_t fi_cq_read(struct fid_cq *cq, void *buf, size_t count)
{
return cq->ops->read(cq, buf, count);
}
static inline ssize_t
fi_cq_readfrom(struct fid_cq *cq, void *buf, size_t count, fi_addr_t *src_addr)
{
return cq->ops->readfrom(cq, buf, count, src_addr);
}
static inline ssize_t
fi_cq_readerr(struct fid_cq *cq, struct fi_cq_err_entry *buf, uint64_t flags)
{
return cq->ops->readerr(cq, buf, flags);
}
static inline ssize_t
fi_cq_sread(struct fid_cq *cq, void *buf, size_t count, const void *cond, int timeout)
{
return cq->ops->sread(cq, buf, count, cond, timeout);
}
static inline ssize_t
fi_cq_sreadfrom(struct fid_cq *cq, void *buf, size_t count,
fi_addr_t *src_addr, const void *cond, int timeout)
{
return cq->ops->sreadfrom(cq, buf, count, src_addr, cond, timeout);
}
static inline int fi_cq_signal(struct fid_cq *cq)
{
return cq->ops->signal(cq);
}
static inline const char *
fi_cq_strerror(struct fid_cq *cq, int prov_errno, const void *err_data,
char *buf, size_t len)
{
return cq->ops->strerror(cq, prov_errno, err_data, buf, len);
}
static inline uint64_t fi_cntr_read(struct fid_cntr *cntr)
{
return cntr->ops->read(cntr);
}
static inline uint64_t fi_cntr_readerr(struct fid_cntr *cntr)
{
return cntr->ops->readerr(cntr);
}
static inline int fi_cntr_add(struct fid_cntr *cntr, uint64_t value)
{
return cntr->ops->add(cntr, value);
}
static inline int fi_cntr_adderr(struct fid_cntr *cntr, uint64_t value)
{
return FI_CHECK_OP(cntr->ops, struct fi_ops_cntr, adderr) ?
cntr->ops->adderr(cntr, value) : -FI_ENOSYS;
}
static inline int fi_cntr_set(struct fid_cntr *cntr, uint64_t value)
{
return cntr->ops->set(cntr, value);
}
static inline int fi_cntr_seterr(struct fid_cntr *cntr, uint64_t value)
{
return FI_CHECK_OP(cntr->ops, struct fi_ops_cntr, seterr) ?
cntr->ops->seterr(cntr, value) : -FI_ENOSYS;
}
static inline int
fi_cntr_wait(struct fid_cntr *cntr, uint64_t threshold, int timeout)
{
return cntr->ops->wait(cntr, threshold, timeout);
}
#endif
#ifdef __cplusplus
}
#endif
#endif