[openib-general] [IWARP BRANCH] [PATCH 2/3] Fix rdma_lat and rdma_bw to work with the new stack and libraries

Pradipta Kumar Banerjee bpradip at in.ibm.com
Tue Jun 27 10:58:28 PDT 2006


This patch fixes the broken rdma_bw by using the correct function signature for
rdma_get_cm_event.

old function signature - int rdma_get_cm_event(struct rdma_cm_event **event)
new function signature - int rdma_get_cm_event(struct rdma_event_channel *channel,
                        struct rdma_cm_event **event)


Signed-off-by: Pradipta Kumar Banerjee <bpradip at in.ibm.com>

---

Index: rdma_bw.c
=============================================================================
--- ../perftest-org/rdma_bw.c	2006-06-22 18:28:13.000000000 +0530
+++ rdma_bw.c	2006-06-22 18:40:01.000000000 +0530
@@ -51,6 +51,7 @@
 #include <arpa/inet.h>
 #include <byteswap.h>
 #include <time.h>
+#include <errno.h>
 
 #include <infiniband/verbs.h>
 #include <rdma/rdma_cma.h>
@@ -75,6 +76,7 @@ struct pingpong_context {
 	struct ibv_sge      list;
 	struct ibv_send_wr  wr;
 	struct rdma_cm_id  *cm_id;
+	struct rdma_event_channel *cm_channel;		
 };
 
 struct pingpong_dest {
@@ -545,11 +547,12 @@ static void pp_close_cma(struct pingpong
 		}
 	}
 	
-	rdma_get_cm_event(&event);
+	rdma_get_cm_event(ctx->cm_channel, &event);
 	if (event->event != RDMA_CM_EVENT_DISCONNECTED)
 		printf("unexpected event during disconnect %d\n", event->event);
 	rdma_ack_cm_event(event);
 	rdma_destroy_id(ctx->cm_id);
+	rdma_destroy_event_channel(ctx->cm_channel);
 }
 
 static struct pingpong_context *pp_server_connect_cma(unsigned short port, int size, int tx_depth,
@@ -562,13 +565,22 @@ static struct pingpong_context *pp_serve
 	int ret;
 	struct sockaddr_in sin;
 	struct rdma_cm_id *child_cm_id;
+	struct rdma_event_channel *channel;
 	struct pingpong_context *ctx;
 
 	printf("%s starting server\n", __FUNCTION__);
-	ret = rdma_create_id(&listen_id, NULL);
+	channel = rdma_create_event_channel();
+	if (!channel) {
+		ret = errno;
+		fprintf(stderr, "%s rdma_create_event_channel failed with error %d\n",
+							 __FUNCTION__, ret);
+		return NULL;
+        }
+
+	ret = rdma_create_id(channel, &listen_id, NULL);
 	if (ret) {
 		fprintf(stderr, "%s rdma_create_id failed %d\n", __FUNCTION__, ret);
-		return NULL;
+		goto err3;
 	}
 
 	sin.sin_addr.s_addr = 0;
@@ -586,7 +598,7 @@ static struct pingpong_context *pp_serve
 		goto err2;
 	}
 
-	ret = rdma_get_cm_event(&event);
+	ret = rdma_get_cm_event(channel, &event);
 	if (ret) 
 		goto err2;
 
@@ -612,6 +624,7 @@ static struct pingpong_context *pp_serve
 		goto err0;
 	}
 
+	ctx->cm_channel = channel;
 	my_dest->qpn = 0;
 	my_dest->psn = 0xbb;
 	my_dest->rkey = ctx->mr->rkey;
@@ -627,7 +640,7 @@ static struct pingpong_context *pp_serve
 		goto err0;
 	}
 	rdma_ack_cm_event(event);
-	ret = rdma_get_cm_event(&event);
+	ret = rdma_get_cm_event(channel, &event);
 	if (ret) {
 		fprintf(stderr,"rdma_get_cm_event error %d\n", ret);
 		rdma_destroy_id(child_cm_id);
@@ -646,8 +659,10 @@ err0:
 err1:
 	rdma_ack_cm_event(event);
 err2:
-	rdma_destroy_id(listen_id);
 	fprintf(stderr,"%s NOT connected!\n", __FUNCTION__);
+	rdma_destroy_id(listen_id);
+err3:
+	rdma_destroy_event_channel(channel);
 	return NULL;
 }
 
@@ -683,6 +698,7 @@ static struct pingpong_context *pp_clien
 	int ret;
 	struct sockaddr_in sin;
 	struct rdma_cm_id *cm_id;
+	struct rdma_event_channel *channel;
 	struct pingpong_context *ctx;
 
 	fprintf(stderr,"%s starting client\n", __FUNCTION__);
@@ -691,10 +707,18 @@ static struct pingpong_context *pp_clien
 		return NULL;
 	}
 
-	ret = rdma_create_id(&cm_id, NULL);
+	channel = rdma_create_event_channel();
+	if (!channel) {
+		ret = errno;
+		fprintf(stderr, "%s rdma_create_event_channel failed with error %d\n",
+						__FUNCTION__, ret);
+		return NULL;
+	}
+
+	ret = rdma_create_id(channel, &cm_id, NULL);
 	if (ret) {
 		fprintf(stderr,"%s rdma_create_id failed %d\n", __FUNCTION__, ret);
-		return NULL;
+		goto err3;
 	}
 
 	sin.sin_family = PF_INET;
@@ -705,7 +729,7 @@ static struct pingpong_context *pp_clien
 		goto err2;
 	}
 
-	ret = rdma_get_cm_event(&event);
+	ret = rdma_get_cm_event(channel, &event);
 	if (ret) 
 		goto err2;
 
@@ -722,7 +746,7 @@ static struct pingpong_context *pp_clien
 		goto err2;
 	}
 
-	ret = rdma_get_cm_event(&event);
+	ret = rdma_get_cm_event(channel, &event);
 	if (ret) 
 		goto err2;
 
@@ -740,6 +764,7 @@ static struct pingpong_context *pp_clien
 		goto err2;
 	}
 
+	ctx->cm_channel = channel;
 	my_dest->qpn = 0;
 	my_dest->psn = 0xaa;
 	my_dest->rkey = ctx->mr->rkey;
@@ -756,7 +781,7 @@ static struct pingpong_context *pp_clien
 		goto err2;
 	}
 
-	ret = rdma_get_cm_event(&event);
+	ret = rdma_get_cm_event(channel, &event);
 	if (ret) 
 		goto err2;
 
@@ -779,6 +804,8 @@ err1:
 err2:
 	fprintf(stderr,"NOT connected!\n");
 	rdma_destroy_id(cm_id);
+err3:
+	rdma_destroy_event_channel(channel);
 	return NULL;
 }
 




More information about the general mailing list