[openib-general] [PATCH] add HW specific data to libibverbs modify QP, SRQ response

Ralph Campbell ralphc at pathscale.com
Thu Jun 15 11:31:20 PDT 2006


I am working on a ipathverbs.so version of ibv_poll_cq(),
ibv_post_recv(), and ibv_post_srq_recv() which mmaps the
queue into user space.  I found that I needed to modify the
core libibverbs and kernel uverbs code in order to return
the information I need from ib_ipath to the ipathverbs.so
library.  This patch adds those generic code changes.
A subsequent patch will add the InfiniPath specific changes.

Note that I didn't include matching changes to ehca since
I don't have HW to test with but I can try to make a patch
that allows it compile if requested to.

Signed-off-by: Ralph Campbell <ralph.campbell at qlogic.com>

Index: src/userspace/libibverbs/src/cmd.c
===================================================================
--- src/userspace/libibverbs/src/cmd.c	(revision 8021)
+++ src/userspace/libibverbs/src/cmd.c	(working copy)
@@ -384,6 +384,23 @@
 	return 0;
 }
 
+int ibv_cmd_resize_cq_resp(struct ibv_cq *cq, int cqe,
+			   struct ibv_resize_cq *cmd, size_t cmd_size,
+			   struct ibv_resize_cq_resp *resp, size_t resp_size)
+{
+
+	IBV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, resp, resp_size);
+	cmd->cq_handle = cq->handle;
+	cmd->cqe       = cqe;
+
+	if (write(cq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+		return errno;
+
+	cq->cqe = resp->cqe;
+
+	return 0;
+}
+
 static int ibv_cmd_destroy_cq_v1(struct ibv_cq *cq)
 {
 	struct ibv_destroy_cq_v1 cmd;
Index: src/userspace/libibverbs/src/libibverbs.map
===================================================================
--- src/userspace/libibverbs/src/libibverbs.map	(revision 8021)
+++ src/userspace/libibverbs/src/libibverbs.map	(working copy)
@@ -48,6 +48,7 @@
 		ibv_cmd_poll_cq;
 		ibv_cmd_req_notify_cq;
 		ibv_cmd_resize_cq;
+		ibv_cmd_resize_cq_resp;
 		ibv_cmd_destroy_cq;
 		ibv_cmd_create_srq;
 		ibv_cmd_modify_srq;
Index: src/userspace/libibverbs/include/infiniband/driver.h
===================================================================
--- src/userspace/libibverbs/include/infiniband/driver.h	(revision 8021)
+++ src/userspace/libibverbs/include/infiniband/driver.h	(working copy)
@@ -96,6 +96,9 @@
 int ibv_cmd_req_notify_cq(struct ibv_cq *cq, int solicited_only);
 int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
 		      struct ibv_resize_cq *cmd, size_t cmd_size);
+int ibv_cmd_resize_cq_resp(struct ibv_cq *cq, int cqe,
+			   struct ibv_resize_cq *cmd, size_t cmd_size,
+			   struct ibv_resize_cq_resp *resp, size_t resp_size);
 int ibv_cmd_destroy_cq(struct ibv_cq *cq);
 
 int ibv_cmd_create_srq(struct ibv_pd *pd,
Index: src/userspace/libibverbs/include/infiniband/kern-abi.h
===================================================================
--- src/userspace/libibverbs/include/infiniband/kern-abi.h	(revision 8021)
+++ src/userspace/libibverbs/include/infiniband/kern-abi.h	(working copy)
@@ -355,6 +355,8 @@
 
 struct ibv_resize_cq_resp {
 	__u32 cqe;
+	__u32 reserved;
+	__u64 driver_data[0];
 };
 
 struct ibv_destroy_cq {
Index: src/linux-kernel/infiniband/core/uverbs_cmd.c
===================================================================
--- src/linux-kernel/infiniband/core/uverbs_cmd.c	(revision 8021)
+++ src/linux-kernel/infiniband/core/uverbs_cmd.c	(working copy)
@@ -1258,6 +1258,7 @@
 			    int out_len)
 {
 	struct ib_uverbs_modify_qp cmd;
+	struct ib_udata            udata;
 	struct ib_qp              *qp;
 	struct ib_qp_attr         *attr;
 	int                        ret;
@@ -1265,6 +1266,9 @@
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
+	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
+		   out_len);
+
 	attr = kmalloc(sizeof *attr, GFP_KERNEL);
 	if (!attr)
 		return -ENOMEM;
@@ -1321,7 +1325,7 @@
 	attr->alt_ah_attr.ah_flags 	    = cmd.alt_dest.is_global ? IB_AH_GRH : 0;
 	attr->alt_ah_attr.port_num 	    = cmd.alt_dest.port_num;
 
-	ret = ib_modify_qp(qp, attr, cmd.attr_mask);
+	ret = qp->device->modify_qp(qp, attr, cmd.attr_mask, &udata);
 
 	put_qp_read(qp);
 
@@ -2031,6 +2035,7 @@
 			     int out_len)
 {
 	struct ib_uverbs_modify_srq cmd;
+	struct ib_udata             udata;
 	struct ib_srq              *srq;
 	struct ib_srq_attr          attr;
 	int                         ret;
@@ -2038,6 +2043,9 @@
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
 
+	INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
+		   out_len);
+
 	srq = idr_read_srq(cmd.srq_handle, file->ucontext);
 	if (!srq)
 		return -EINVAL;
@@ -2045,7 +2053,7 @@
 	attr.max_wr    = cmd.max_wr;
 	attr.srq_limit = cmd.srq_limit;
 
-	ret = ib_modify_srq(srq, &attr, cmd.attr_mask);
+	ret = srq->device->modify_srq(srq, &attr, cmd.attr_mask, &udata);
 
 	put_srq_read(srq);
 
Index: src/linux-kernel/infiniband/core/verbs.c
===================================================================
--- src/linux-kernel/infiniband/core/verbs.c	(revision 8021)
+++ src/linux-kernel/infiniband/core/verbs.c	(working copy)
@@ -231,7 +231,7 @@
 		  struct ib_srq_attr *srq_attr,
 		  enum ib_srq_attr_mask srq_attr_mask)
 {
-	return srq->device->modify_srq(srq, srq_attr, srq_attr_mask);
+	return srq->device->modify_srq(srq, srq_attr, srq_attr_mask, NULL);
 }
 EXPORT_SYMBOL(ib_modify_srq);
 
@@ -547,7 +547,7 @@
 		 struct ib_qp_attr *qp_attr,
 		 int qp_attr_mask)
 {
-	return qp->device->modify_qp(qp, qp_attr, qp_attr_mask);
+	return qp->device->modify_qp(qp, qp_attr, qp_attr_mask, NULL);
 }
 EXPORT_SYMBOL(ib_modify_qp);
 
Index: src/linux-kernel/infiniband/include/rdma/ib_user_verbs.h
===================================================================
--- src/linux-kernel/infiniband/include/rdma/ib_user_verbs.h	(revision 8021)
+++ src/linux-kernel/infiniband/include/rdma/ib_user_verbs.h	(working copy)
@@ -275,6 +275,8 @@
 
 struct ib_uverbs_resize_cq_resp {
 	__u32 cqe;
+	__u32 reserved;
+	__u64 driver_data[0];
 };
 
 struct ib_uverbs_poll_cq {
Index: src/linux-kernel/infiniband/include/rdma/ib_verbs.h
===================================================================
--- src/linux-kernel/infiniband/include/rdma/ib_verbs.h	(revision 8021)
+++ src/linux-kernel/infiniband/include/rdma/ib_verbs.h	(working copy)
@@ -911,7 +911,8 @@
 						 struct ib_udata *udata);
 	int                        (*modify_srq)(struct ib_srq *srq,
 						 struct ib_srq_attr *srq_attr,
-						 enum ib_srq_attr_mask srq_attr_mask);
+						 enum ib_srq_attr_mask srq_attr_mask,
+						 struct ib_udata *udata);
 	int                        (*query_srq)(struct ib_srq *srq,
 						struct ib_srq_attr *srq_attr);
 	int                        (*destroy_srq)(struct ib_srq *srq);
@@ -923,7 +924,8 @@
 						struct ib_udata *udata);
 	int                        (*modify_qp)(struct ib_qp *qp,
 						struct ib_qp_attr *qp_attr,
-						int qp_attr_mask);
+						int qp_attr_mask,
+						struct ib_udata *udata);
 	int                        (*query_qp)(struct ib_qp *qp,
 					       struct ib_qp_attr *qp_attr,
 					       int qp_attr_mask,
Index: src/linux-kernel/infiniband/hw/mthca/mthca_dev.h
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_dev.h	(revision 8021)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_dev.h	(working copy)
@@ -506,7 +506,7 @@
 		    struct ib_srq_attr *attr, struct mthca_srq *srq);
 void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq);
 int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
-		     enum ib_srq_attr_mask attr_mask);
+		     enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
 int mthca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
 int mthca_max_srq_sge(struct mthca_dev *dev);
 void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
@@ -521,7 +521,8 @@
 		    enum ib_event_type event_type);
 int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
 		   struct ib_qp_init_attr *qp_init_attr);
-int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask);
+int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
+		    struct ib_udata *udata);
 int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			  struct ib_send_wr **bad_wr);
 int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
Index: src/linux-kernel/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_qp.c	(revision 8021)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_qp.c	(working copy)
@@ -522,7 +522,8 @@
 	return 0;
 }
 
-int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
+int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
+		    struct ib_udata *udata)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
 	struct mthca_qp *qp = to_mqp(ibqp);
Index: src/linux-kernel/infiniband/hw/mthca/mthca_srq.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_srq.c	(revision 8021)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_srq.c	(working copy)
@@ -357,7 +357,7 @@
 }
 
 int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
-		     enum ib_srq_attr_mask attr_mask)
+		     enum ib_srq_attr_mask attr_mask, struct ib_udata *udata)
 {
 	struct mthca_dev *dev = to_mdev(ibsrq->device);
 	struct mthca_srq *srq = to_msrq(ibsrq);
Index: src/linux-kernel/infiniband/hw/ipath/ipath_verbs.h
===================================================================
--- src/linux-kernel/infiniband/hw/ipath/ipath_verbs.h	(revision 8021)
+++ src/linux-kernel/infiniband/hw/ipath/ipath_verbs.h	(working copy)
@@ -577,7 +577,7 @@
 int ipath_destroy_qp(struct ib_qp *ibqp);
 
 int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
-		    int attr_mask);
+		    int attr_mask, struct ib_udata *udata);
 
 int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 		   int attr_mask, struct ib_qp_init_attr *init_attr);
@@ -636,7 +636,8 @@
 				struct ib_udata *udata);
 
 int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
-		     enum ib_srq_attr_mask attr_mask);
+		     enum ib_srq_attr_mask attr_mask,
+		     struct ib_udata *udata);
 
 int ipath_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
 
Index: src/linux-kernel/infiniband/hw/ipath/ipath_qp.c
===================================================================
--- src/linux-kernel/infiniband/hw/ipath/ipath_qp.c	(revision 8021)
+++ src/linux-kernel/infiniband/hw/ipath/ipath_qp.c	(working copy)
@@ -425,11 +425,12 @@
  * @ibqp: the queue pair who's attributes we're modifying
  * @attr: the new attributes
  * @attr_mask: the mask of attributes to modify
+ * @udata: not used by the InfiniPath verbs driver
  *
  * Returns 0 on success, otherwise returns an errno.
  */
 int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
-		    int attr_mask)
+		    int attr_mask, struct ib_udata *udata)
 {
 	struct ipath_ibdev *dev = to_idev(ibqp->device);
 	struct ipath_qp *qp = to_iqp(ibqp);
Index: src/linux-kernel/infiniband/hw/ipath/ipath_srq.c
===================================================================
--- src/linux-kernel/infiniband/hw/ipath/ipath_srq.c	(revision 8021)
+++ src/linux-kernel/infiniband/hw/ipath/ipath_srq.c	(working copy)
@@ -187,9 +187,10 @@
  * @ibsrq: the SRQ to modify
  * @attr: the new attributes of the SRQ
  * @attr_mask: indicates which attributes to modify
+ * @udata: not used by the InfiniPath verbs driver
  */
 int ipath_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
-		     enum ib_srq_attr_mask attr_mask)
+		     enum ib_srq_attr_mask attr_mask, struct ib_udata *udata)
 {
 	struct ipath_srq *srq = to_isrq(ibsrq);
 	unsigned long flags;



-- 
Ralph Campbell <ralphc at pathscale.com>





More information about the general mailing list