[openib-general] [PATCH 1/2] perftest: Modified perftest utils to work with new stack and libraries

Pradipta Kumar Banerjee bpradip at in.ibm.com
Mon Jun 26 03:27:16 PDT 2006


This is the patch for rdma_lat.c 

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

---

Index: rdma_lat.c
=============================================================================
--- ../perftest-org/rdma_lat.c	2006-06-22 18:28:13.000000000 +0530
+++ rdma_lat.c	2006-06-22 18:36:12.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>
@@ -83,6 +84,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 {
@@ -612,11 +614,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,
@@ -629,17 +632,26 @@ 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);
-	if (ret) {
-		fprintf(stderr, "%s rdma_create_id failed %d\n", __FUNCTION__, ret);
+	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);
+		goto err3;
+	}
+	memset(&sin, 0, sizeof(sin));
 	sin.sin_addr.s_addr = 0;
-	sin.sin_family = PF_INET;
+	sin.sin_family = AF_INET;
 	sin.sin_port = htons(port);
 	ret = rdma_bind_addr(listen_id, (struct sockaddr *)&sin);
 	if (ret) {
@@ -653,7 +665,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;
 
@@ -678,7 +690,8 @@ static struct pingpong_context *pp_serve
 		fprintf(stderr,"%s pp_init_cma_ctx failed\n", __FUNCTION__);
 		goto err0;
 	}
-
+	
+	ctx->cm_channel = channel;
 	my_dest->qpn = 0;
 	my_dest->psn = 0xbb;
 	my_dest->rkey = ctx->mr->rkey;
@@ -694,7 +707,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);
@@ -713,8 +726,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;
 }
 
@@ -750,6 +765,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__);
@@ -758,10 +774,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;
@@ -772,7 +796,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;
 
@@ -789,7 +813,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;
 
@@ -806,7 +830,8 @@ static struct pingpong_context *pp_clien
 		fprintf(stderr,"%s pp_init_cma_ctx failed\n", __FUNCTION__);
 		goto err2;
 	}
-
+	
+	ctx->cm_channel = channel;
 	my_dest->qpn = 0;
 	my_dest->psn = 0xaa;
 	my_dest->rkey = ctx->mr->rkey;
@@ -823,7 +848,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;
 
@@ -845,8 +870,10 @@ static struct pingpong_context *pp_clien
 err1:
 	rdma_ack_cm_event(event);
 err2:
-	fprintf(stderr,"NOT connected!\n");
+	fprintf(stderr,"%s NOT connected!\n", __FUNCTION__);
 	rdma_destroy_id(cm_id);
+err3:
+	rdma_destroy_event_channel(channel);
 	return NULL;
 }
 




More information about the general mailing list