[openib-general] [PATCH] IB/libipathverbs - Fix compatibility with old ib_ipath kernel drivers

Ralph Campbell ralphc at pathscale.com
Wed Aug 23 18:32:45 PDT 2006


This patch makes libipathverbs backward compatible with old ib_ipath kernel drivers.

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

Index: src/userspace/libipathverbs/src/verbs.c
===================================================================
--- src/userspace/libipathverbs/src/verbs.c	(revision 9095)
+++ src/userspace/libipathverbs/src/verbs.c	(working copy)
@@ -177,6 +177,29 @@ struct ibv_cq *ipath_create_cq(struct ib
 	return &cq->ibv_cq;
 }
 
+struct ibv_cq *ipath_create_cq_v1(struct ibv_context *context, int cqe,
+				  struct ibv_comp_channel *channel,
+				  int comp_vector)
+{
+	struct ibv_cq		   *cq;
+	struct ibv_create_cq	    cmd;
+	struct ibv_create_cq_resp   resp;
+	int			    ret;
+
+	cq = malloc(sizeof *cq);
+	if (!cq)
+		return NULL;
+
+	ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector,
+				cq, &cmd, sizeof cmd, &resp, sizeof resp);
+	if (ret) {
+		free(cq);
+		return NULL;
+	}
+
+	return cq;
+}
+
 int ipath_resize_cq(struct ibv_cq *ibcq, int cqe)
 {
 	struct ipath_cq		       *cq = to_icq(ibcq);
@@ -207,6 +230,15 @@ int ipath_resize_cq(struct ibv_cq *ibcq,
 	return 0;
 }
 
+int ipath_resize_cq_v1(struct ibv_cq *ibcq, int cqe)
+{
+	struct ibv_resize_cq		cmd;
+	struct ibv_resize_cq_resp	resp;
+
+	return ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd,
+				 &resp, sizeof resp);
+}
+
 int ipath_destroy_cq(struct ibv_cq *ibcq)
 {
 	struct ipath_cq *cq = to_icq(ibcq);
@@ -222,6 +254,16 @@ int ipath_destroy_cq(struct ibv_cq *ibcq
 	return 0;
 }
 
+int ipath_destroy_cq_v1(struct ibv_cq *ibcq)
+{
+	int ret;
+
+	ret = ibv_cmd_destroy_cq(ibcq);
+	if (!ret)
+		free(ibcq);
+	return ret;
+}
+
 int ipath_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
 {
 	struct ipath_cq *cq = to_icq(ibcq);
@@ -290,6 +332,28 @@ struct ibv_qp *ipath_create_qp(struct ib
 	return &qp->ibv_qp;
 }
 
+struct ibv_qp *ipath_create_qp_v1(struct ibv_pd *pd,
+				  struct ibv_qp_init_attr *attr)
+{
+	struct ibv_create_qp	     cmd;
+	struct ibv_create_qp_resp    resp;
+	struct ibv_qp		    *qp;
+	int			     ret;
+
+	qp = malloc(sizeof *qp);
+	if (!qp)
+		return NULL;
+
+	ret = ibv_cmd_create_qp(pd, qp, attr, &cmd, sizeof cmd,
+				&resp, sizeof resp);
+	if (ret) {
+		free(qp);
+		return NULL;
+	}
+
+	return qp;
+}
+
 int ipath_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)
@@ -330,6 +394,16 @@ int ipath_destroy_qp(struct ibv_qp *ibqp
 	return 0;
 }
 
+int ipath_destroy_qp_v1(struct ibv_qp *ibqp)
+{
+	int ret;
+
+	ret = ibv_cmd_destroy_qp(ibqp);
+	if (!ret)
+		free(ibqp);
+	return ret;
+}
+
 static int post_recv(struct ipath_rq *rq, struct ibv_recv_wr *wr,
 		     struct ibv_recv_wr **bad_wr)
 {
@@ -412,6 +486,28 @@ struct ibv_srq *ipath_create_srq(struct 
 	return &srq->ibv_srq;
 }
 
+struct ibv_srq *ipath_create_srq_v1(struct ibv_pd *pd,
+				    struct ibv_srq_init_attr *attr)
+{
+	struct ibv_srq *srq;
+	struct ibv_create_srq cmd;
+	struct ibv_create_srq_resp resp;
+	int ret;
+
+	srq = malloc(sizeof *srq);
+	if (srq == NULL)
+		return NULL;
+
+	ret = ibv_cmd_create_srq(pd, srq, attr, &cmd, sizeof cmd,
+				 &resp, sizeof resp);
+	if (ret) {
+		free(srq);
+		return NULL;
+	}
+
+	return srq;
+}
+
 int ipath_modify_srq(struct ibv_srq *ibsrq,
 		     struct ibv_srq_attr *attr, 
 		     enum ibv_srq_attr_mask attr_mask)
@@ -456,6 +552,16 @@ int ipath_modify_srq(struct ibv_srq *ibs
 	return 0;
 }
 
+int ipath_modify_srq_v1(struct ibv_srq *ibsrq,
+			struct ibv_srq_attr *attr, 
+			enum ibv_srq_attr_mask attr_mask)
+{
+	struct ibv_modify_srq cmd;
+
+	return ibv_cmd_modify_srq(ibsrq, attr, attr_mask,
+				  &cmd, sizeof cmd);
+}
+
 int ipath_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr)
 {
 	struct ibv_query_srq cmd;
@@ -481,6 +587,16 @@ int ipath_destroy_srq(struct ibv_srq *ib
 	return 0;
 }
 
+int ipath_destroy_srq_v1(struct ibv_srq *ibsrq)
+{
+	int ret;
+
+	ret = ibv_cmd_destroy_srq(ibsrq);
+	if (!ret)
+		free(ibsrq);
+	return ret;
+}
+
 int ipath_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr,
 			struct ibv_recv_wr **bad_wr)
 {
Index: src/userspace/libipathverbs/src/ipathverbs.c
===================================================================
--- src/userspace/libipathverbs/src/ipathverbs.c	(revision 9095)
+++ src/userspace/libipathverbs/src/ipathverbs.c	(working copy)
@@ -134,8 +134,16 @@ static struct ibv_context *ipath_alloc_c
 	context->ibv_ctx.ops = ipath_ctx_ops;
 	dev = to_idev(ibdev);
 	if (dev->abi_version == 1) {
+		context->ibv_ctx.ops.create_cq     = ipath_create_cq_v1;
 		context->ibv_ctx.ops.poll_cq       = ibv_cmd_poll_cq;
+		context->ibv_ctx.ops.resize_cq     = ipath_resize_cq_v1;
+		context->ibv_ctx.ops.destroy_cq    = ipath_destroy_cq_v1;
+		context->ibv_ctx.ops.create_srq    = ipath_create_srq_v1;
+		context->ibv_ctx.ops.destroy_srq   = ipath_destroy_srq_v1;
+		context->ibv_ctx.ops.modify_srq    = ipath_modify_srq_v1;
 		context->ibv_ctx.ops.post_srq_recv = ibv_cmd_post_srq_recv;
+		context->ibv_ctx.ops.create_qp     = ipath_create_qp_v1;
+		context->ibv_ctx.ops.destroy_qp    = ipath_destroy_qp_v1;
 		context->ibv_ctx.ops.post_recv     = ibv_cmd_post_recv;
 	}
 	return &context->ibv_ctx;
Index: src/userspace/libipathverbs/src/ipathverbs.h
===================================================================
--- src/userspace/libipathverbs/src/ipathverbs.h	(revision 9095)
+++ src/userspace/libipathverbs/src/ipathverbs.h	(working copy)
@@ -41,6 +41,7 @@
 #include <endian.h>
 #include <byteswap.h>
 #include <pthread.h>
+#include <stddef.h>
 
 #include <infiniband/driver.h>
 #include <infiniband/arch.h>
@@ -202,15 +203,26 @@ struct ibv_cq *ipath_create_cq(struct ib
 			       struct ibv_comp_channel *channel,
 			       int comp_vector);
 
+struct ibv_cq *ipath_create_cq_v1(struct ibv_context *context, int cqe,
+				  struct ibv_comp_channel *channel,
+				  int comp_vector);
+
 int ipath_resize_cq(struct ibv_cq *cq, int cqe);
 
+int ipath_resize_cq_v1(struct ibv_cq *cq, int cqe);
+
 int ipath_destroy_cq(struct ibv_cq *cq);
 
+int ipath_destroy_cq_v1(struct ibv_cq *cq);
+
 int ipath_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
 
 struct ibv_qp *ipath_create_qp(struct ibv_pd *pd,
 			       struct ibv_qp_init_attr *attr);
 
+struct ibv_qp *ipath_create_qp_v1(struct ibv_pd *pd,
+				  struct ibv_qp_init_attr *attr);
+
 int ipath_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);
@@ -220,6 +232,8 @@ int ipath_modify_qp(struct ibv_qp *qp, s
 
 int ipath_destroy_qp(struct ibv_qp *qp);
 
+int ipath_destroy_qp_v1(struct ibv_qp *qp);
+
 int ipath_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
 		    struct ibv_send_wr **bad_wr);
 
@@ -229,14 +243,23 @@ int ipath_post_recv(struct ibv_qp *ibqp,
 struct ibv_srq *ipath_create_srq(struct ibv_pd *pd,
 				 struct ibv_srq_init_attr *attr);
 
+struct ibv_srq *ipath_create_srq_v1(struct ibv_pd *pd,
+				    struct ibv_srq_init_attr *attr);
+
 int ipath_modify_srq(struct ibv_srq *srq,
 		     struct ibv_srq_attr *attr, 
 		     enum ibv_srq_attr_mask attr_mask);
 
+int ipath_modify_srq_v1(struct ibv_srq *srq,
+			struct ibv_srq_attr *attr, 
+			enum ibv_srq_attr_mask attr_mask);
+
 int ipath_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr);
 
 int ipath_destroy_srq(struct ibv_srq *srq);
 
+int ipath_destroy_srq_v1(struct ibv_srq *srq);
+
 int ipath_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
 			struct ibv_recv_wr **bad_wr);
 






More information about the general mailing list