[ofa-general] RE: [PATCH 1/1 v2] librdmacm: add support for create qp expanded (with changelog this time)

Ron Livne ronli at voltaire.com
Sun Aug 3 03:36:24 PDT 2008


Hi,


>+int rdma_create_qp_expanded(struct rdma_cm_id *id, struct ibv_pd *pd,
>+				struct ibv_qp_init_attr *qp_init_attr,
>+				uint32_t create_flags);
>Can we eliminate expanded and just use 'create_flags'?

If I'll eliminate the expanded parameter,
I'll have to call ibv_create_qp_expanded with create_flags = 0.
This is not a good idea because it will not be compatible with an older
kernel.

Ron

-----Original Message-----
From: Sean Hefty [mailto:sean.hefty at intel.com] 
Sent: Thursday, July 31, 2008 8:13 PM
To: Ron Livne
Cc: general at lists.openfabrics.org; Olga Shern
Subject: RE: [PATCH 1/1 v2] librdmacm: add support for create qp
expanded (with changelog this time)

thanks - I will set this aside until all necessary changes are in
libibverbs.

>Adds a new function: int rdma_create_qp_expanded
>which uses the ibv_create_qp_expanded function in libibverbs and uses
>it similarly to ibv_create_qp, with the difference of creation flags.
>
>Changes in v2:
>Added compatibility to old libibverbs.
>
>Signed-off-by: Ron Livne <ronli at voltaire.com>
>
>diff --git a/include/rdma/rdma_cma.h b/include/rdma/rdma_cma.h
>index a516ab8..34c6b9f 100644
>--- a/include/rdma/rdma_cma.h
>+++ b/include/rdma/rdma_cma.h
>@@ -296,6 +296,10 @@ int rdma_resolve_route(struct rdma_cm_id *id, int
>timeout_ms);
> int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
> 		   struct ibv_qp_init_attr *qp_init_attr);
>
>+int rdma_create_qp_expanded(struct rdma_cm_id *id, struct ibv_pd *pd,
>+				struct ibv_qp_init_attr *qp_init_attr,
>+				uint32_t create_flags);
>+
> /**
>  * rdma_destroy_qp - Deallocate a QP.
>  * @id: RDMA identifier.
>diff --git a/src/cma.c b/src/cma.c
>index ecb41bc..4e2da76 100644
>--- a/src/cma.c
>+++ b/src/cma.c
>@@ -783,33 +783,49 @@ static int ucma_init_ud_qp(struct cma_id_private
>*id_priv, struct ibv_qp *qp)
> 	return ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE |
IBV_QP_SQ_PSN);
> }
>
>-int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
>-		   struct ibv_qp_init_attr *qp_init_attr)
>+static int rdma_create_qp_common(struct rdma_cm_id *id, struct ibv_pd
*pd,
>+                                struct ibv_qp_init_attr *qp_init_attr,
>+                                uint32_t create_flags, int expanded)

Can we eliminate expanded and just use 'create_flags'? 

The patch uses spaces in place of tabs, but I can fix that up.

> {
>-	struct cma_id_private *id_priv;
>-	struct ibv_qp *qp;
>-	int ret;
>-
>-	id_priv = container_of(id, struct cma_id_private, id);
>-	if (id->verbs != pd->context)
>-		return -EINVAL;
>-
>-	qp = ibv_create_qp(pd, qp_init_attr);
>-	if (!qp)
>-		return -ENOMEM;
>+        struct cma_id_private *id_priv;
>+        struct ibv_qp *qp;
>+        int ret;
>+
>+        id_priv = container_of(id, struct cma_id_private, id);
>+        if (id->verbs != pd->context)
>+                return -EINVAL;
>+
>+        qp = expanded ?
>+		ibv_create_qp_expanded(pd, qp_init_attr, create_flags) :
>+		ibv_create_qp(pd, qp_init_attr);
>+        if (!qp)
>+                return -ENOMEM;
>+
>+        if (ucma_is_ud_ps(id->ps))
>+                ret = ucma_init_ud_qp(id_priv, qp);
>+        else
>+                ret = ucma_init_conn_qp(id_priv, qp);
>+        if (ret)
>+                goto err;
>+
>+        id->qp = qp;
>+        return 0;
>+err:
>+        ibv_destroy_qp(qp);
>+        return ret;
>+}
>
>-	if (ucma_is_ud_ps(id->ps))
>-		ret = ucma_init_ud_qp(id_priv, qp);
>-	else
>-		ret = ucma_init_conn_qp(id_priv, qp);
>-	if (ret)
>-		goto err;
>+int rdma_create_qp_expanded(struct rdma_cm_id *id, struct ibv_pd *pd,
>+				struct ibv_qp_init_attr *qp_init_attr,
>+				uint32_t create_flags)
>+{
>+	return rdma_create_qp_common(id, pd, qp_init_attr, create_flags,
1);
>+}
>
>-	id->qp = qp;
>-	return 0;
>-err:
>-	ibv_destroy_qp(qp);
>-	return ret;
>+int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
>+				struct ibv_qp_init_attr *qp_init_attr)
>+{
>+	return rdma_create_qp_common(id, pd, qp_init_attr, 0, 0);
> }
>
> void rdma_destroy_qp(struct rdma_cm_id *id)
>diff --git a/src/librdmacm.map b/src/librdmacm.map
>index cb94efe..b237eda 100644
>--- a/src/librdmacm.map
>+++ b/src/librdmacm.map
>@@ -28,5 +28,6 @@ RDMACM_1.0 {
> 		rdma_get_local_addr;
> 		rdma_get_peer_addr;
> 		rdma_migrate_id;
>+		rdma_create_qp_expanded;
> 	local: *;
> };




More information about the general mailing list