[ofa-general] [PATCH] perftest: send_lat/bw: Attach to multicast group when QP is in INIT

Hoang-Nam Nguyen hnguyen at linux.vnet.ibm.com
Tue May 12 03:00:41 PDT 2009


Subject: [PATCH] perftest: send_lat/bw: Attach to multicast group when QP is in INIT

If multicast is enabled, the current code of send_lat/bw attaches the QP
to a multicast group while it's still in RESET state.
Since the IB spec does not strictly specify the QP state for this operation
and ehca's current firmware does not allow attaching in RESET, this patch
moves the attach_mcast() function call after QP has been modified to INIT.

See also discussion thread http://lists.openfabrics.org/pipermail/general/2009-May/059450.html

Signed-off-by: Hoang-Nam Nguyen <hnguyen at de.ibm.com>
---
 send_bw.c  |   29 +++++++++++++++--------------
 send_lat.c |   30 +++++++++++++++---------------
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/send_bw.c b/send_bw.c
index afabfa4..9a10ff3 100755
--- a/send_bw.c
+++ b/send_bw.c
@@ -421,20 +421,6 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev,
 			return NULL;
 		}
 
-		if ((user_parm->connection_type==UD) && (user_parm->use_mcg) && (!user_parm->servername || user_parm->duplex)) {
-			union ibv_gid gid;
-			uint8_t mcg_gid[16] = MCG_GID;
-
-			/* use the local QP number as part of the mcg */
-			mcg_gid[11] = (user_parm->servername) ? 0 : 1;
-			*(uint32_t *)(&mcg_gid[12]) = ctx->qp->qp_num;
-			memcpy(gid.raw, mcg_gid, 16);
-
-			if (ibv_attach_mcast(ctx->qp, &gid, MCG_LID)) {
-				fprintf(stderr, "Couldn't attach QP to mcg\n");
-				return NULL;
-			}
-		}
 	}
 
 	{
@@ -457,6 +443,21 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev,
 				fprintf(stderr, "Failed to modify UD QP to INIT\n");
 				return NULL;
 			}
+
+			if ((user_parm->use_mcg) && (!user_parm->servername || user_parm->duplex)) {
+				union ibv_gid gid;
+				uint8_t mcg_gid[16] = MCG_GID;
+
+				/* use the local QP number as part of the mcg */
+				mcg_gid[11] = (user_parm->servername) ? 0 : 1;
+				*(uint32_t *)(&mcg_gid[12]) = ctx->qp->qp_num;
+				memcpy(gid.raw, mcg_gid, 16);
+
+				if (ibv_attach_mcast(ctx->qp, &gid, MCG_LID)) {
+					fprintf(stderr, "Couldn't attach QP to mcg\n");
+					return NULL;
+				}
+			}
 		} else if (ibv_modify_qp(ctx->qp, &attr,
 					 IBV_QP_STATE              |
 					 IBV_QP_PKEY_INDEX         |
diff --git a/send_lat.c b/send_lat.c
index 1f21652..e1a1156 100755
--- a/send_lat.c
+++ b/send_lat.c
@@ -425,21 +425,6 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
 			fprintf(stderr, "Couldn't create QP\n");
 			return NULL;
 		}
-
-		if ((user_parm->connection_type==UD) && (user_parm->use_mcg)) {
-			union ibv_gid gid;
-			uint8_t mcg_gid[16] = MCG_GID;
-
-			/* use the local QP number as part of the mcg */
-			mcg_gid[11] = (user_parm->servername) ? 0 : 1;
-			*(uint32_t *)(&mcg_gid[12]) = ctx->qp->qp_num;
-			memcpy(gid.raw, mcg_gid, 16);
-
-			if (ibv_attach_mcast(ctx->qp, &gid, MCG_LID)) {
-				fprintf(stderr, "Couldn't attach QP to mcg\n");
-				return NULL;
-			}
-		}
 	}
 
 	{
@@ -463,6 +448,21 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
 				fprintf(stderr, "Failed to modify UD QP to INIT\n");
 				return NULL;
 			}
+
+			if (user_parm->use_mcg) {
+				union ibv_gid gid;
+				uint8_t mcg_gid[16] = MCG_GID;
+
+				/* use the local QP number as part of the mcg */
+				mcg_gid[11] = (user_parm->servername) ? 0 : 1;
+				*(uint32_t *)(&mcg_gid[12]) = ctx->qp->qp_num;
+				memcpy(gid.raw, mcg_gid, 16);
+
+				if (ibv_attach_mcast(ctx->qp, &gid, MCG_LID)) {
+					fprintf(stderr, "Couldn't attach QP to mcg\n");
+					return NULL;
+				}
+			}
 		} else if (ibv_modify_qp(ctx->qp, &attr,
 					 IBV_QP_STATE              |
 					 IBV_QP_PKEY_INDEX         |
-- 
1.5.5






More information about the general mailing list