[ofa-general] [PATCH 8/8] core: Add xrc support for kernel-space apps
Jack Morgenstein
jackm at dev.mellanox.co.il
Wed Jan 23 02:00:36 PST 2008
IB/core: implement XRC for kernel-space applications.
Changes: none
Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>
Index: infiniband/include/rdma/ib_verbs.h
===================================================================
--- infiniband.orig/include/rdma/ib_verbs.h 2008-01-22 20:18:46.000000000 +0200
+++ infiniband/include/rdma/ib_verbs.h 2008-01-22 20:19:38.000000000 +0200
@@ -667,6 +667,7 @@ struct ib_send_wr {
u8 port_num; /* valid for DR SMPs on switch only */
} ud;
} wr;
+ u32 xrc_remote_srq_num; /* valid for XRC sends only */
};
struct ib_recv_wr {
@@ -799,6 +800,7 @@ struct ib_srq {
void (*event_handler)(struct ib_event *, void *);
void *srq_context;
atomic_t usecnt;
+ u32 xrc_srq_num;
};
struct ib_qp {
@@ -1266,8 +1268,28 @@ int ib_query_ah(struct ib_ah *ah, struct
int ib_destroy_ah(struct ib_ah *ah);
/**
- * ib_create_srq - Creates a SRQ associated with the specified protection
- * domain.
+ * ib_create_xrc_srq - Creates an XRC SRQ associated with the specified
+ * protection domain, cq, and xrc domain.
+ * @pd: The protection domain associated with the SRQ.
+ * @xrc_cq: The cq to be associated with the XRC SRQ.
+ * @xrcd: The XRC domain to be associated with the XRC SRQ.
+ * @srq_init_attr: A list of initial attributes required to create the
+ * XRC SRQ. If XRC SRQ creation succeeds, then the attributes are updated
+ * to the actual capabilities of the created XRC SRQ.
+ *
+ * srq_attr->max_wr and srq_attr->max_sge are read the determine the
+ * requested size of the XRC SRQ, and set to the actual values allocated
+ * on return. If ib_create_xrc_srq() succeeds, then max_wr and max_sge
+ * will always be at least as large as the requested values.
+ */
+struct ib_srq *ib_create_xrc_srq(struct ib_pd *pd,
+ struct ib_cq *xrc_cq,
+ struct ib_xrcd *xrcd,
+ struct ib_srq_init_attr *srq_init_attr);
+
+/**
+ * ib_create_srq - Creates an SRQ associated with the specified
+ * protection domain.
* @pd: The protection domain associated with the SRQ.
* @srq_init_attr: A list of initial attributes required to create the
* SRQ. If SRQ creation succeeds, then the attributes are updated to
@@ -1898,8 +1920,14 @@ int ib_detach_mcast(struct ib_qp *qp, un
/**
* ib_dealloc_xrcd - Deallocates an extended reliably connected domain.
- * @pd: The xrc domain to deallocate.
+ * @xrcd: The xrc domain to deallocate.
*/
int ib_dealloc_xrcd(struct ib_xrcd *xrcd);
+/**
+ * ib_alloc_xrcd - Allocates an extended reliably connected domain.
+ * @device: The device on which to allocate the xrcd.
+ */
+struct ib_xrcd * ib_alloc_xrcd(struct ib_device *device);
+
#endif /* IB_VERBS_H */
Index: infiniband/drivers/infiniband/core/verbs.c
===================================================================
--- infiniband.orig/drivers/infiniband/core/verbs.c 2008-01-22 20:16:45.000000000 +0200
+++ infiniband/drivers/infiniband/core/verbs.c 2008-01-22 20:19:38.000000000 +0200
@@ -246,6 +246,36 @@ struct ib_srq *ib_create_srq(struct ib_p
}
EXPORT_SYMBOL(ib_create_srq);
+struct ib_srq *ib_create_xrc_srq(struct ib_pd *pd,
+ struct ib_cq *xrc_cq,
+ struct ib_xrcd *xrcd,
+ struct ib_srq_init_attr *srq_init_attr)
+{
+ struct ib_srq *srq;
+
+ if (!pd->device->create_xrc_srq)
+ return ERR_PTR(-ENOSYS);
+
+ srq = pd->device->create_xrc_srq(pd, xrc_cq, xrcd, srq_init_attr, NULL);
+
+ if (!IS_ERR(srq)) {
+ srq->device = pd->device;
+ srq->pd = pd;
+ srq->uobject = NULL;
+ srq->event_handler = srq_init_attr->event_handler;
+ srq->srq_context = srq_init_attr->srq_context;
+ srq->xrc_cq = xrc_cq;
+ srq->xrcd = xrcd;
+ atomic_inc(&pd->usecnt);
+ atomic_inc(&xrcd->usecnt);
+ atomic_inc(&xrc_cq->usecnt);
+ atomic_set(&srq->usecnt, 0);
+ }
+
+ return srq;
+}
+EXPORT_SYMBOL(ib_create_xrc_srq);
+
int ib_modify_srq(struct ib_srq *srq,
struct ib_srq_attr *srq_attr,
enum ib_srq_attr_mask srq_attr_mask)
@@ -308,12 +338,15 @@ struct ib_qp *ib_create_qp(struct ib_pd
qp->event_handler = qp_init_attr->event_handler;
qp->qp_context = qp_init_attr->qp_context;
qp->qp_type = qp_init_attr->qp_type;
- qp->xrcd = NULL;
+ qp->xrcd = qp->qp_type == IB_QPT_XRC ?
+ qp_init_attr->xrc_domain : NULL;
atomic_inc(&pd->usecnt);
atomic_inc(&qp_init_attr->send_cq->usecnt);
atomic_inc(&qp_init_attr->recv_cq->usecnt);
if (qp_init_attr->srq)
atomic_inc(&qp_init_attr->srq->usecnt);
+ if (qp->qp_type == IB_QPT_XRC)
+ atomic_inc(&qp->xrcd->usecnt);
}
return qp;
@@ -645,6 +678,7 @@ int ib_destroy_qp(struct ib_qp *qp)
struct ib_cq *scq, *rcq;
struct ib_srq *srq;
struct ib_xrcd *xrcd;
+ enum ib_qp_type qp_type = qp->qp_type;
int ret;
pd = qp->pd;
@@ -660,7 +694,7 @@ int ib_destroy_qp(struct ib_qp *qp)
atomic_dec(&rcq->usecnt);
if (srq)
atomic_dec(&srq->usecnt);
- if (xrcd)
+ if (qp_type == IB_QPT_XRC)
atomic_dec(&xrcd->usecnt);
}
@@ -923,4 +957,22 @@ int ib_dealloc_xrcd(struct ib_xrcd *xrcd
}
EXPORT_SYMBOL(ib_dealloc_xrcd);
+struct ib_xrcd * ib_alloc_xrcd(struct ib_device *device)
+{
+ struct ib_xrcd *xrcd;
+
+ if (!device->alloc_xrcd)
+ return ERR_PTR(-ENOSYS);
+
+ xrcd = device->alloc_xrcd(device, NULL, NULL);
+ if (!IS_ERR(xrcd)) {
+ xrcd->device = device;
+ xrcd->inode = NULL;
+ xrcd->uobject = NULL;
+ atomic_set(&xrcd->usecnt, 0);
+ }
+ return xrcd;
+}
+EXPORT_SYMBOL(ib_alloc_xrcd);
+
More information about the general
mailing list