]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Refresh of srq_ex
authorSean Hefty <sean.hefty@intel.com>
Wed, 26 Sep 2012 16:46:59 +0000 (09:46 -0700)
committerSean Hefty <sean.hefty@intel.com>
Wed, 26 Sep 2012 16:46:59 +0000 (09:46 -0700)
include/infiniband/driver.h
include/infiniband/verbs.h
src/cmd.c
src/verbs.c

index 54c15083971c83a0c087f617e41d71074de3e081..53e7ed07490de9c1a9ea0d121d545031c3072f30 100644 (file)
@@ -65,11 +65,11 @@ struct verbs_xrcd {
 };
 
 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 {
@@ -181,4 +181,10 @@ const char *ibv_get_sysfs_path(void);
 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 */
index e1dcda8ec68aa1726d97b8d200f2f21d22c2f489..2c43131a4e304abcd09fd854beac8225e7db643d 100644 (file)
@@ -758,6 +758,7 @@ struct verbs_context {
        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,
@@ -1041,8 +1042,12 @@ static inline int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only)
 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.
@@ -1068,6 +1073,13 @@ int ibv_modify_srq(struct ibv_srq *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.
index ed54efb49a31c8603f1d6b9ae8d97a59616f29c5..0407cf07ecee07331aec516eb759ffe9641c3add 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -512,6 +512,18 @@ int ibv_cmd_create_srq_ex(struct ibv_pd *pd,
                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;
 
index 559608171857d2ec5bcff9d078139adaae06f53a..eb98f2429a3652095cac2673ea008e95cd3c3aea 100644 (file)
@@ -400,14 +400,17 @@ default_symver(__ibv_create_srq_ex, ibv_create_srq_ex);
 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;
 }