]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
rdma/core: Add XRC SRQ type
authorSean Hefty <sean.hefty@intel.com>
Tue, 24 May 2011 02:42:29 +0000 (19:42 -0700)
committerSean Hefty <sean.hefty@intel.com>
Mon, 22 Aug 2011 18:39:58 +0000 (11:39 -0700)
XRC defines an SRQ that is specifically used by XRC connections.
Expand the SRQ code to support XRC SRQs.  An XRC SRQ is currently
restricted to only XRC use according to the IB XRC Annex.

Portions of this patch were derived from work by
Jack Morgenstein <jackm@dev.mellanox.co.il>

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
drivers/infiniband/core/verbs.c
include/rdma/ib_verbs.h

index cbe85ddaf89804b76b9761c555c70665196aa495..25c1c1ea44603e21fcd3343e6f901da49b23f1b9 100644 (file)
@@ -251,6 +251,12 @@ struct ib_srq *ib_create_srq(struct ib_pd *pd,
                srq->event_handler = srq_init_attr->event_handler;
                srq->srq_context   = srq_init_attr->srq_context;
                srq->srq_type      = srq_init_attr->srq_type;
+               if (srq->srq_type == IB_SRQT_XRC) {
+                       srq->ext.xrc.xrcd = srq_init_attr->ext.xrc.xrcd;
+                       srq->ext.xrc.cq   = srq_init_attr->ext.xrc.cq;
+                       atomic_inc(&srq->ext.xrc.xrcd->usecnt);
+                       atomic_inc(&srq->ext.xrc.cq->usecnt);
+               }
                atomic_inc(&pd->usecnt);
                atomic_set(&srq->usecnt, 0);
        }
@@ -280,16 +286,29 @@ EXPORT_SYMBOL(ib_query_srq);
 int ib_destroy_srq(struct ib_srq *srq)
 {
        struct ib_pd *pd;
+       enum ib_srq_type srq_type;
+       struct ib_xrcd *uninitialized_var(xrcd);
+       struct ib_cq *uninitialized_var(cq);
        int ret;
 
        if (atomic_read(&srq->usecnt))
                return -EBUSY;
 
        pd = srq->pd;
+       srq_type = srq->srq_type;
+       if (srq_type == IB_SRQT_XRC) {
+               xrcd = srq->ext.xrc.xrcd;
+               cq = srq->ext.xrc.cq;
+       }
 
        ret = srq->device->destroy_srq(srq);
-       if (!ret)
+       if (!ret) {
                atomic_dec(&pd->usecnt);
+               if (srq_type == IB_SRQT_XRC) {
+                       atomic_dec(&xrcd->usecnt);
+                       atomic_dec(&cq->usecnt);
+               }
+       }
 
        return ret;
 }
index 1374a6614282fd6992f76f06befd8b4081b858d6..2a85461bc07a41646805f869ec12a9503b50ff02 100644 (file)
@@ -523,7 +523,8 @@ enum ib_cq_notify_flags {
 };
 
 enum ib_srq_type {
-       IB_SRQT_BASIC
+       IB_SRQT_BASIC,
+       IB_SRQT_XRC
 };
 
 enum ib_srq_attr_mask {
@@ -542,6 +543,13 @@ struct ib_srq_init_attr {
        void                   *srq_context;
        struct ib_srq_attr      attr;
        enum ib_srq_type        srq_type;
+
+       union {
+               struct {
+                       struct ib_xrcd *xrcd;
+                       struct ib_cq   *cq;
+               } xrc;
+       } ext;
 };
 
 struct ib_qp_cap {
@@ -894,6 +902,14 @@ struct ib_srq {
        void                   *srq_context;
        enum ib_srq_type        srq_type;
        atomic_t                usecnt;
+
+       union {
+               struct {
+                       struct ib_xrcd *xrcd;
+                       struct ib_cq   *cq;
+                       u32             srq_num;
+               } xrc;
+       } ext;
 };
 
 struct ib_qp {