};
enum verbs_srq_mask {
- IBV_SRQ_TYPE = 1 << 0,
- IBV_SRQ_XRCD = 1 << 1,
- IBV_SRQ_CQ = 1 << 2,
- IBV_SRQ_NUM = 1 << 3,
- IBV_SRQ_RESERVED = 1 << 4
+ VERBS_SRQ_TYPE = 1 << 0,
+ VERBS_SRQ_XRCD = 1 << 1,
+ VERBS_SRQ_CQ = 1 << 2,
+ VERBS_SRQ_NUM = 1 << 3,
+ VERBS_SRQ_RESERVED = 1 << 4
};
struct verbs_srq {
int ibv_read_sysfs_file(const char *dir, const char *file,
char *buf, size_t size);
+static inline uint32_t verbs_get_srq_num(struct ibv_srq *srq)
+{
+ struct verbs_srq *vsrq = container_of(srq, struct verbs_srq, srq);
+ return (vsrq->comp_mask & VERBS_SRQ_NUM) ? vsrq->srq_num : 0;
+}
+
#endif /* INFINIBAND_DRIVER_H */
int (*drv_new_func1) (); new corresponding provider call of func1
int (*lib_new_func1) (); New library call func1
*/
+ uint32_t (*get_srq_num)(struct ibv_srq *srq);
struct ibv_srq * (*create_srq_ex)(struct ibv_pd *pd,
struct ibv_srq_init_attr_ex *srq_init_attr_ex);
struct ibv_xrcd * (*open_xrcd)(struct ibv_context *context,
struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
struct ibv_srq_init_attr *srq_init_attr);
-struct ibv_srq *ibv_create_srq_ex(struct ibv_pd *pd,
- struct ibv_srq_init_attr_ex *srq_init_attr_ex);
+static inline struct ibv_srq *
+ibv_create_srq_ex(struct ibv_pd *pd, struct ibv_srq_init_attr_ex *srq_init_attr_ex)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(pd->context, create_srq_ex);
+ return vctx ? vctx->create_srq_ex(pd, srq_init_attr_ex) : NULL;
+}
/**
* ibv_modify_srq - Modifies the attributes for the specified SRQ.
*/
int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr);
+static inline struct ibv_srq *
+ibv_get_srq_num(struct ibv_srq *srq)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(pd->context, get_srq_num);
+ return vctx ? vctx->get_srq_num(srq) : NULL;
+}
+
/**
* ibv_destroy_srq - Destroys the specified SRQ.
* @srq: The SRQ to destroy.
srq->srq_num = resp->srqn;
}
+ srq->comp_mask |= IBV_SRQ_INIT_ATTR_TYPE;
+ srq->srq_type = (srq_init_attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) ?
+ srq_init_attr_ex->srq_type : IBV_SRQT_BASIC;
+ if (srq_init_attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_XRCD) {
+ srq->comp_mask |= IBV_SRQ_XRCD;
+ srq->xrcd = srq_init_attr_ex->xrcd;
+ }
+ if (srq_init_attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_CQ) {
+ srq->comp_mask |= IBV_SRQ_CQ;
+ srq->cq = srq_init_attr_ex->cq;
+ }
+
attr_ex->attr.max_wr = resp->max_wr;
attr_ex->attr.max_sge = resp->max_sge;
struct ibv_srq *__ibv_create_srq(struct ibv_pd *pd,
struct ibv_srq_init_attr *srq_init_attr)
{
- struct ibv_srq_init_attr_ex srq_init_attr_ex;
struct ibv_srq *srq;
- memcpy(&srq_init_attr_ex, srq_init_attr, sizeof *srq_init_attr);
- srq_init_attr_ex.comp_mask = 0;
- srq = ibv_create_srq_ex(pd, &srq_init_attr_ex);
- if (srq)
- memcpy(srq_init_attr, &srq_init_attr_ex, sizeof *srq_init_attr);
+ srq = pd->context->ops.create_srq(pd, srq_init_attr);
+ if (srq) {
+ srq->context = pd->context;
+ srq->srq_context = srq_init_attr_ex->srq_context;
+ srq->pd = pd;
+ srq->events_completed = 0;
+ pthread_mutex_init(&srq->mutex, NULL);
+ pthread_cond_init(&srq->cond, NULL);
+ }
return srq;
}