[ewg] [PATCH 1/4]libibverbs: add new verb: ibv_create_qp_flags

Ron Livne ronli at voltaire.com
Thu Dec 11 01:01:32 PST 2008


This patch adds a new verb to the libibverbs:
struct ibv_qp *ibv_create_qp_flags(struct ibv_pd *pd,
				struct ibv_qp_init_attr *qp_init_attr,
				uint32_t create_flags);
which works similarly to ibv_create_qp, except for that it now
takes another argument: uint32_t create_flags
these creation flags must be aligned with those in the ib_verbs.h
in the kernel.

Signed-off-by: Ron Livne <ronli at voltaire.com>

diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h
index 67a3bf8..fa74909 100644
--- a/include/infiniband/driver.h
+++ b/include/infiniband/driver.h
@@ -112,6 +112,11 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
 		      struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
 		      struct ibv_create_qp *cmd, size_t cmd_size,
 		      struct ibv_create_qp_resp *resp, size_t resp_size);
+int ibv_cmd_create_qp_flags(struct ibv_pd *pd,
+			struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
+			uint32_t create_flags,
+			struct ibv_create_qp_flags *cmd, size_t cmd_size,
+			struct ibv_create_qp_resp *resp, size_t resp_size);
 int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
 		     enum ibv_qp_attr_mask attr_mask,
 		     struct ibv_qp_init_attr *qp_init_attr,
diff --git a/include/infiniband/kern-abi.h b/include/infiniband/kern-abi.h
index 0db083a..9a3a27b 100644
--- a/include/infiniband/kern-abi.h
+++ b/include/infiniband/kern-abi.h
@@ -85,7 +85,8 @@ enum {
 	IB_USER_VERBS_CMD_MODIFY_SRQ,
 	IB_USER_VERBS_CMD_QUERY_SRQ,
 	IB_USER_VERBS_CMD_DESTROY_SRQ,
-	IB_USER_VERBS_CMD_POST_SRQ_RECV
+	IB_USER_VERBS_CMD_POST_SRQ_RECV,
+	IB_USER_VERBS_CMD_CREATE_QP_FLAGS
 };

 /*
@@ -451,6 +452,30 @@ struct ibv_create_qp {
 	__u64 driver_data[0];
 };

+struct ibv_create_qp_flags {
+	__u32 command;
+	__u16 in_words;
+	__u16 out_words;
+	__u64 response;
+	__u64 user_handle;
+	__u32 pd_handle;
+	__u32 send_cq_handle;
+	__u32 recv_cq_handle;
+	__u32 srq_handle;
+	__u32 max_send_wr;
+	__u32 max_recv_wr;
+	__u32 max_send_sge;
+	__u32 max_recv_sge;
+	__u32 max_inline_data;
+	__u8  sq_sig_all;
+	__u8  qp_type;
+	__u8  is_srq;
+	__u8  reserved;
+	__u32 reserved1;
+	__u32 create_flags;
+	__u64 driver_data[0];
+};
+
 struct ibv_create_qp_resp {
 	__u32 qp_handle;
 	__u32 qpn;
@@ -803,6 +828,7 @@ enum {
 	 * trick opcodes in IBV_INIT_CMD() doesn't break.
 	 */
 	IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1,
+	IB_USER_VERBS_CMD_CREATE_QP_FLAGS_V2 = -1,
 };

 struct ibv_destroy_cq_v1 {
diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
index a04cc62..fe586f1 100644
--- a/include/infiniband/verbs.h
+++ b/include/infiniband/verbs.h
@@ -625,6 +625,12 @@ struct ibv_device {
 	char			ibdev_path[IBV_SYSFS_PATH_MAX];
 };

+struct ibv_more_ops {
+	struct ibv_qp *         (*create_qp_flags)(struct ibv_pd *pd,
+						struct ibv_qp_init_attr *attr,
+						uint32_t create_flags);
+};
+
 struct ibv_context_ops {
 	int			(*query_device)(struct ibv_context *context,
 					      struct ibv_device_attr *device_attr);
@@ -691,6 +697,7 @@ struct ibv_context {
 	int			num_comp_vectors;
 	pthread_mutex_t		mutex;
 	void		       *abi_compat;
+	struct ibv_more_ops    *more_ops;
 };

 /**
@@ -963,6 +970,13 @@ struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
 			     struct ibv_qp_init_attr *qp_init_attr);

 /**
+ * ibv_create_qp_flags - Create a queue pair with creation flags.
+ */
+struct ibv_qp *ibv_create_qp_flags(struct ibv_pd *pd,
+				struct ibv_qp_init_attr *qp_init_attr,
+				uint32_t create_flags);
+
+/**
  * ibv_modify_qp - Modify a queue pair.
  */
 int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
diff --git a/src/cmd.c b/src/cmd.c
index 66d7134..1b778e1 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -592,31 +592,12 @@ int ibv_cmd_destroy_srq(struct ibv_srq *srq)
 	return 0;
 }

-int ibv_cmd_create_qp(struct ibv_pd *pd,
-		      struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
-		      struct ibv_create_qp *cmd, size_t cmd_size,
-		      struct ibv_create_qp_resp *resp, size_t resp_size)
+static int cmd_create_qp_common(struct ibv_pd *pd,
+					struct ibv_qp *qp,
+					struct ibv_qp_init_attr *attr,
+					struct ibv_create_qp_resp *resp,
+					size_t resp_size)
 {
-	IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
-
-	cmd->user_handle     = (uintptr_t) qp;
-	cmd->pd_handle 	     = pd->handle;
-	cmd->send_cq_handle  = attr->send_cq->handle;
-	cmd->recv_cq_handle  = attr->recv_cq->handle;
-	cmd->srq_handle      = attr->srq ? attr->srq->handle : 0;
-	cmd->max_send_wr     = attr->cap.max_send_wr;
-	cmd->max_recv_wr     = attr->cap.max_recv_wr;
-	cmd->max_send_sge    = attr->cap.max_send_sge;
-	cmd->max_recv_sge    = attr->cap.max_recv_sge;
-	cmd->max_inline_data = attr->cap.max_inline_data;
-	cmd->sq_sig_all	     = attr->sq_sig_all;
-	cmd->qp_type 	     = attr->qp_type;
-	cmd->is_srq 	     = !!attr->srq;
-	cmd->reserved	     = 0;
-
-	if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
-		return errno;
-
 	VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);

 	qp->handle 		  = resp->qp_handle;
@@ -650,6 +631,64 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
 	return 0;
 }

+int ibv_cmd_create_qp(struct ibv_pd *pd,
+		      struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
+		      struct ibv_create_qp *cmd, size_t cmd_size,
+		      struct ibv_create_qp_resp *resp, size_t resp_size)
+{
+	IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
+
+	cmd->user_handle     = (uintptr_t) qp;
+	cmd->pd_handle 	     = pd->handle;
+	cmd->send_cq_handle  = attr->send_cq->handle;
+	cmd->recv_cq_handle  = attr->recv_cq->handle;
+	cmd->srq_handle      = attr->srq ? attr->srq->handle : 0;
+	cmd->max_send_wr     = attr->cap.max_send_wr;
+	cmd->max_recv_wr     = attr->cap.max_recv_wr;
+	cmd->max_send_sge    = attr->cap.max_send_sge;
+	cmd->max_recv_sge    = attr->cap.max_recv_sge;
+	cmd->max_inline_data = attr->cap.max_inline_data;
+	cmd->sq_sig_all	     = attr->sq_sig_all;
+	cmd->qp_type 	     = attr->qp_type;
+	cmd->is_srq 	     = !!attr->srq;
+	cmd->reserved	     = 0;
+
+	if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
+		return errno;
+
+	return cmd_create_qp_common(pd, qp, attr, resp, resp_size);
+}
+
+int ibv_cmd_create_qp_flags(struct ibv_pd *pd,
+			struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
+			uint32_t create_flags,
+			struct ibv_create_qp_flags *cmd, size_t cmd_size,
+			struct ibv_create_qp_resp *resp, size_t resp_size)
+{
+	IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP_FLAGS, resp, resp_size);
+
+	cmd->create_flags    = create_flags;
+	cmd->user_handle     = (uintptr_t) qp;
+	cmd->pd_handle 	     = pd->handle;
+	cmd->send_cq_handle  = attr->send_cq->handle;
+	cmd->recv_cq_handle  = attr->recv_cq->handle;
+	cmd->srq_handle      = attr->srq ? attr->srq->handle : 0;
+	cmd->max_send_wr     = attr->cap.max_send_wr;
+	cmd->max_recv_wr     = attr->cap.max_recv_wr;
+	cmd->max_send_sge    = attr->cap.max_send_sge;
+	cmd->max_recv_sge    = attr->cap.max_recv_sge;
+	cmd->max_inline_data = attr->cap.max_inline_data;
+	cmd->sq_sig_all	     = attr->sq_sig_all;
+	cmd->qp_type 	     = attr->qp_type;
+	cmd->is_srq 	     = !!attr->srq;
+	cmd->reserved	     = 0;
+
+	if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
+		return errno;
+
+	return cmd_create_qp_common(pd, qp, attr, resp, resp_size);
+}
+
 int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
 		     enum ibv_qp_attr_mask attr_mask,
 		     struct ibv_qp_init_attr *init_attr,
diff --git a/src/libibverbs.map b/src/libibverbs.map
index 1827da0..bdb70a0 100644
--- a/src/libibverbs.map
+++ b/src/libibverbs.map
@@ -96,4 +96,6 @@ IBVERBS_1.1 {
 		ibv_port_state_str;
 		ibv_event_type_str;
 		ibv_wc_status_str;
+		ibv_create_qp_flags;
+		ibv_cmd_create_qp_flags;
 } IBVERBS_1.0;
diff --git a/src/verbs.c b/src/verbs.c
index 9e370ce..8ec171d 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -395,11 +395,10 @@ int __ibv_destroy_srq(struct ibv_srq *srq)
 }
 default_symver(__ibv_destroy_srq, ibv_destroy_srq);

-struct ibv_qp *__ibv_create_qp(struct ibv_pd *pd,
-			       struct ibv_qp_init_attr *qp_init_attr)
+static struct ibv_qp *create_qp_common(struct ibv_pd *pd,
+				struct ibv_qp_init_attr *qp_init_attr,
+				struct ibv_qp *qp)
 {
-	struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
-
 	if (qp) {
 		qp->context    	     = pd->context;
 		qp->qp_context 	     = qp_init_attr->qp_context;
@@ -416,8 +415,25 @@ struct ibv_qp *__ibv_create_qp(struct ibv_pd *pd,

 	return qp;
 }
+
+struct ibv_qp *__ibv_create_qp(struct ibv_pd *pd,
+			       struct ibv_qp_init_attr *qp_init_attr)
+{
+	struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
+
+	return create_qp_common(pd, qp_init_attr, qp);
+}
 default_symver(__ibv_create_qp, ibv_create_qp);

+struct ibv_qp *ibv_create_qp_flags(struct ibv_pd *pd,
+				struct ibv_qp_init_attr *qp_init_attr,
+				uint32_t create_flags)
+{
+	struct ibv_qp *qp = pd->context->more_ops->create_qp_flags(pd, qp_init_attr, create_flags);
+
+	return create_qp_common(pd, qp_init_attr, qp);
+}
+
 int __ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
 		   enum ibv_qp_attr_mask attr_mask,
 		   struct ibv_qp_init_attr *init_attr)



More information about the ewg mailing list