[openib-general] [PATCH v3 6/6] librdmacm examples changes.

Krishna Kumar krkumar2 at in.ibm.com
Thu Aug 3 01:38:12 PDT 2006


Convert librdmacm examples to use the new API.

Signed-off-by: Krishna Kumar <krkumar2 at in.ibm.com>

diff -ruNp ORG/librdmacm/examples/cmatose.c NEW/librdmacm/examples/cmatose.c
--- ORG/librdmacm/examples/cmatose.c	2006-07-30 21:18:17.000000000 -0700
+++ NEW/librdmacm/examples/cmatose.c	2006-08-03 17:32:36.000000000 -0700
@@ -62,9 +62,9 @@ struct cmatest_node {
 	int			id;
 	struct rdma_cm_id	*cma_id;
 	int			connected;
-	struct ibv_pd		*pd;
-	struct ibv_cq		*cq;
-	struct ibv_mr		*mr;
+	struct rdmav_pd		*pd;
+	struct rdmav_cq		*cq;
+	struct rdmav_mr		*mr;
 	void			*mem;
 };
 
@@ -100,8 +100,8 @@ static int create_message(struct cmatest
 		printf("failed message allocation\n");
 		return -1;
 	}
-	node->mr = ibv_reg_mr(node->pd, node->mem, message_size,
-			     IBV_ACCESS_LOCAL_WRITE);
+	node->mr = rdmav_reg_mr(node->pd, node->mem, message_size,
+			     RDMAV_ACCESS_LOCAL_WRITE);
 	if (!node->mr) {
 		printf("failed to reg MR\n");
 		goto err;
@@ -114,10 +114,10 @@ err:
 
 static int init_node(struct cmatest_node *node)
 {
-	struct ibv_qp_init_attr init_qp_attr;
+	struct rdmav_qp_init_attr init_qp_attr;
 	int cqe, ret;
 
-	node->pd = ibv_alloc_pd(node->cma_id->verbs);
+	node->pd = rdmav_alloc_pd(node->cma_id->verbs);
 	if (!node->pd) {
 		ret = -ENOMEM;
 		printf("cmatose: unable to allocate PD\n");
@@ -125,7 +125,7 @@ static int init_node(struct cmatest_node
 	}
 
 	cqe = message_count ? message_count * 2 : 2;
-	node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
+	node->cq = rdmav_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
 	if (!node->cq) {
 		ret = -ENOMEM;
 		printf("cmatose: unable to create CQ\n");
@@ -139,7 +139,7 @@ static int init_node(struct cmatest_node
 	init_qp_attr.cap.max_recv_sge = 1;
 	init_qp_attr.qp_context = node;
 	init_qp_attr.sq_sig_all = 1;
-	init_qp_attr.qp_type = IBV_QPT_RC;
+	init_qp_attr.qp_type = RDMAV_QPT_RC;
 	init_qp_attr.send_cq = node->cq;
 	init_qp_attr.recv_cq = node->cq;
 	ret = rdma_create_qp(node->cma_id, node->pd, &init_qp_attr);
@@ -159,8 +159,8 @@ out:
 
 static int post_recvs(struct cmatest_node *node)
 {
-	struct ibv_recv_wr recv_wr, *recv_failure;
-	struct ibv_sge sge;
+	struct rdmav_recv_wr recv_wr, *recv_failure;
+	struct rdmav_sge sge;
 	int i, ret = 0;
 
 	if (!message_count)
@@ -176,7 +176,7 @@ static int post_recvs(struct cmatest_nod
 	sge.addr = (uintptr_t) node->mem;
 
 	for (i = 0; i < message_count && !ret; i++ ) {
-		ret = ibv_post_recv(node->cma_id->qp, &recv_wr, &recv_failure);
+		ret = rdmav_post_recv(node->cma_id->qp, &recv_wr, &recv_failure);
 		if (ret) {
 			printf("failed to post receives: %d\n", ret);
 			break;
@@ -187,8 +187,8 @@ static int post_recvs(struct cmatest_nod
 
 static int post_sends(struct cmatest_node *node)
 {
-	struct ibv_send_wr send_wr, *bad_send_wr;
-	struct ibv_sge sge;
+	struct rdmav_send_wr send_wr, *bad_send_wr;
+	struct rdmav_sge sge;
 	int i, ret = 0;
 
 	if (!node->connected || !message_count)
@@ -197,7 +197,7 @@ static int post_sends(struct cmatest_nod
 	send_wr.next = NULL;
 	send_wr.sg_list = &sge;
 	send_wr.num_sge = 1;
-	send_wr.opcode = IBV_WR_SEND;
+	send_wr.opcode = RDMAV_WR_SEND;
 	send_wr.send_flags = 0;
 	send_wr.wr_id = (unsigned long)node;
 
@@ -206,7 +206,7 @@ static int post_sends(struct cmatest_nod
 	sge.addr = (uintptr_t) node->mem;
 
 	for (i = 0; i < message_count && !ret; i++) {
-		ret = ibv_post_send(node->cma_id->qp, &send_wr, &bad_send_wr);
+		ret = rdmav_post_send(node->cma_id->qp, &send_wr, &bad_send_wr);
 		if (ret) 
 			printf("failed to post sends: %d\n", ret);
 	}
@@ -350,15 +350,15 @@ static void destroy_node(struct cmatest_
 		rdma_destroy_qp(node->cma_id);
 
 	if (node->cq)
-		ibv_destroy_cq(node->cq);
+		rdmav_destroy_cq(node->cq);
 
 	if (node->mem) {
-		ibv_dereg_mr(node->mr);
+		rdmav_dereg_mr(node->mr);
 		free(node->mem);
 	}
 
 	if (node->pd)
-		ibv_dealloc_pd(node->pd);
+		rdmav_dealloc_pd(node->pd);
 
 	/* Destroy the RDMA ID after all device resources */
 	rdma_destroy_id(node->cma_id);
@@ -404,7 +404,7 @@ static void destroy_nodes(void)
 
 static int poll_cqs(void)
 {
-	struct ibv_wc wc[8];
+	struct rdmav_wc wc[8];
 	int done, i, ret;
 
 	for (i = 0; i < connections; i++) {
@@ -412,7 +412,7 @@ static int poll_cqs(void)
 			continue;
 
 		for (done = 0; done < message_count; done += ret) {
-			ret = ibv_poll_cq(test.nodes[i].cq, 8, wc);
+			ret = rdmav_poll_cq(test.nodes[i].cq, 8, wc);
 			if (ret < 0) {
 				printf("cmatose: failed polling CQ: %d\n", ret);
 				return ret;
diff -ruNp ORG/librdmacm/examples/mckey.c NEW/librdmacm/examples/mckey.c
--- ORG/librdmacm/examples/mckey.c	2006-07-30 21:18:17.000000000 -0700
+++ NEW/librdmacm/examples/mckey.c	2006-08-03 17:32:41.000000000 -0700
@@ -50,10 +50,10 @@ struct cmatest_node {
 	int			id;
 	struct rdma_cm_id	*cma_id;
 	int			connected;
-	struct ibv_pd		*pd;
-	struct ibv_cq		*cq;
-	struct ibv_mr		*mr;
-	struct ibv_ah		*ah;
+	struct rdmav_pd		*pd;
+	struct rdmav_cq		*cq;
+	struct rdmav_mr		*mr;
+	struct rdmav_ah		*ah;
 	uint32_t		remote_qpn;
 	uint32_t		remote_qkey;
 	void			*mem;
@@ -85,14 +85,14 @@ static int create_message(struct cmatest
 	if (!message_count)
 		return 0;
 
-	node->mem = malloc(message_size + sizeof(struct ibv_grh));
+	node->mem = malloc(message_size + sizeof(struct rdmav_grh));
 	if (!node->mem) {
 		printf("failed message allocation\n");
 		return -1;
 	}
-	node->mr = ibv_reg_mr(node->pd, node->mem,
-			      message_size + sizeof(struct ibv_grh),
-			      IBV_ACCESS_LOCAL_WRITE);
+	node->mr = rdmav_reg_mr(node->pd, node->mem,
+			      message_size + sizeof(struct rdmav_grh),
+			      RDMAV_ACCESS_LOCAL_WRITE);
 	if (!node->mr) {
 		printf("failed to reg MR\n");
 		goto err;
@@ -105,10 +105,10 @@ err:
 
 static int init_node(struct cmatest_node *node)
 {
-	struct ibv_qp_init_attr init_qp_attr;
+	struct rdmav_qp_init_attr init_qp_attr;
 	int cqe, ret;
 
-	node->pd = ibv_alloc_pd(node->cma_id->verbs);
+	node->pd = rdmav_alloc_pd(node->cma_id->verbs);
 	if (!node->pd) {
 		ret = -ENOMEM;
 		printf("mckey: unable to allocate PD\n");
@@ -116,7 +116,7 @@ static int init_node(struct cmatest_node
 	}
 
 	cqe = message_count ? message_count * 2 : 2;
-	node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
+	node->cq = rdmav_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
 	if (!node->cq) {
 		ret = -ENOMEM;
 		printf("mckey: unable to create CQ\n");
@@ -130,7 +130,7 @@ static int init_node(struct cmatest_node
 	init_qp_attr.cap.max_recv_sge = 1;
 	init_qp_attr.qp_context = node;
 	init_qp_attr.sq_sig_all = 0;
-	init_qp_attr.qp_type = IBV_QPT_UD;
+	init_qp_attr.qp_type = RDMAV_QPT_UD;
 	init_qp_attr.send_cq = node->cq;
 	init_qp_attr.recv_cq = node->cq;
 	ret = rdma_create_qp(node->cma_id, node->pd, &init_qp_attr);
@@ -150,8 +150,8 @@ out:
 
 static int post_recvs(struct cmatest_node *node)
 {
-	struct ibv_recv_wr recv_wr, *recv_failure;
-	struct ibv_sge sge;
+	struct rdmav_recv_wr recv_wr, *recv_failure;
+	struct rdmav_sge sge;
 	int i, ret = 0;
 
 	if (!message_count)
@@ -162,12 +162,12 @@ static int post_recvs(struct cmatest_nod
 	recv_wr.num_sge = 1;
 	recv_wr.wr_id = (uintptr_t) node;
 
-	sge.length = message_size + sizeof(struct ibv_grh);
+	sge.length = message_size + sizeof(struct rdmav_grh);
 	sge.lkey = node->mr->lkey;
 	sge.addr = (uintptr_t) node->mem;
 
 	for (i = 0; i < message_count && !ret; i++ ) {
-		ret = ibv_post_recv(node->cma_id->qp, &recv_wr, &recv_failure);
+		ret = rdmav_post_recv(node->cma_id->qp, &recv_wr, &recv_failure);
 		if (ret) {
 			printf("failed to post receives: %d\n", ret);
 			break;
@@ -178,8 +178,8 @@ static int post_recvs(struct cmatest_nod
 
 static int post_sends(struct cmatest_node *node, int signal_flag)
 {
-	struct ibv_send_wr send_wr, *bad_send_wr;
-	struct ibv_sge sge;
+	struct rdmav_send_wr send_wr, *bad_send_wr;
+	struct rdmav_sge sge;
 	int i, ret = 0;
 
 	if (!node->connected || !message_count)
@@ -188,8 +188,8 @@ static int post_sends(struct cmatest_nod
 	send_wr.next = NULL;
 	send_wr.sg_list = &sge;
 	send_wr.num_sge = 1;
-	send_wr.opcode = IBV_WR_SEND_WITH_IMM;
-	send_wr.send_flags = IBV_SEND_INLINE | signal_flag;
+	send_wr.opcode = RDMAV_WR_SEND_WITH_IMM;
+	send_wr.send_flags = RDMAV_SEND_INLINE | signal_flag;
 	send_wr.wr_id = (unsigned long)node;
 	send_wr.imm_data = htonl(node->cma_id->qp->qp_num);
 
@@ -197,12 +197,12 @@ static int post_sends(struct cmatest_nod
 	send_wr.wr.ud.remote_qpn = node->remote_qpn;
 	send_wr.wr.ud.remote_qkey = node->remote_qkey;
 
-	sge.length = message_size - sizeof(struct ibv_grh);
+	sge.length = message_size - sizeof(struct rdmav_grh);
 	sge.lkey = node->mr->lkey;
 	sge.addr = (uintptr_t) node->mem;
 
 	for (i = 0; i < message_count && !ret; i++) {
-		ret = ibv_post_send(node->cma_id->qp, &send_wr, &bad_send_wr);
+		ret = rdmav_post_send(node->cma_id->qp, &send_wr, &bad_send_wr);
 		if (ret) 
 			printf("failed to post sends: %d\n", ret);
 	}
@@ -241,7 +241,7 @@ err:
 
 static int join_handler(struct cmatest_node *node)
 {
-	struct ibv_ah_attr ah_attr;
+	struct rdmav_ah_attr ah_attr;
 	int ret;
 
 	ret = rdma_get_dst_attr(node->cma_id, test.dst_addr, &ah_attr,
@@ -251,7 +251,7 @@ static int join_handler(struct cmatest_n
 		goto err;
 	}
 
-	node->ah = ibv_create_ah(node->pd, &ah_attr);
+	node->ah = rdmav_create_ah(node->pd, &ah_attr);
 	if (!node->ah) {
 		printf("mckey: failure creating address handle\n");
 		goto err;
@@ -299,21 +299,21 @@ static void destroy_node(struct cmatest_
 		return;
 
 	if (node->ah)
-		ibv_destroy_ah(node->ah);
+		rdmav_destroy_ah(node->ah);
 
 	if (node->cma_id->qp)
 		rdma_destroy_qp(node->cma_id);
 
 	if (node->cq)
-		ibv_destroy_cq(node->cq);
+		rdmav_destroy_cq(node->cq);
 
 	if (node->mem) {
-		ibv_dereg_mr(node->mr);
+		rdmav_dereg_mr(node->mr);
 		free(node->mem);
 	}
 
 	if (node->pd)
-		ibv_dealloc_pd(node->pd);
+		rdmav_dealloc_pd(node->pd);
 
 	/* Destroy the RDMA ID after all device resources */
 	rdma_destroy_id(node->cma_id);
@@ -356,7 +356,7 @@ static void destroy_nodes(void)
 
 static int poll_cqs(void)
 {
-	struct ibv_wc wc[8];
+	struct rdmav_wc wc[8];
 	int done, i, ret;
 
 	for (i = 0; i < connections; i++) {
@@ -364,7 +364,7 @@ static int poll_cqs(void)
 			continue;
 
 		for (done = 0; done < message_count; done += ret) {
-			ret = ibv_poll_cq(test.nodes[i].cq, 8, wc);
+			ret = rdmav_poll_cq(test.nodes[i].cq, 8, wc);
 			if (ret < 0) {
 				printf("mckey: failed polling CQ: %d\n", ret);
 				return ret;
diff -ruNp ORG/librdmacm/examples/rping.c NEW/librdmacm/examples/rping.c
--- ORG/librdmacm/examples/rping.c	2006-07-30 21:18:17.000000000 -0700
+++ NEW/librdmacm/examples/rping.c	2006-08-03 17:32:45.000000000 -0700
@@ -111,32 +111,32 @@ struct rping_rdma_info {
 struct rping_cb {
 	int server;			/* 0 iff client */
 	pthread_t cqthread;
-	struct ibv_comp_channel *channel;
-	struct ibv_cq *cq;
-	struct ibv_pd *pd;
-	struct ibv_qp *qp;
+	struct rdmav_comp_channel *channel;
+	struct rdmav_cq *cq;
+	struct rdmav_pd *pd;
+	struct rdmav_qp *qp;
 
-	struct ibv_recv_wr rq_wr;	/* recv work request record */
-	struct ibv_sge recv_sgl;	/* recv single SGE */
+	struct rdmav_recv_wr rq_wr;	/* recv work request record */
+	struct rdmav_sge recv_sgl;	/* recv single SGE */
 	struct rping_rdma_info recv_buf;/* malloc'd buffer */
-	struct ibv_mr *recv_mr;		/* MR associated with this buffer */
+	struct rdmav_mr *recv_mr;		/* MR associated with this buffer */
 
-	struct ibv_send_wr sq_wr;	/* send work requrest record */
-	struct ibv_sge send_sgl;
+	struct rdmav_send_wr sq_wr;	/* send work requrest record */
+	struct rdmav_sge send_sgl;
 	struct rping_rdma_info send_buf;/* single send buf */
-	struct ibv_mr *send_mr;
+	struct rdmav_mr *send_mr;
 
-	struct ibv_send_wr rdma_sq_wr;	/* rdma work request record */
-	struct ibv_sge rdma_sgl;	/* rdma single SGE */
+	struct rdmav_send_wr rdma_sq_wr;	/* rdma work request record */
+	struct rdmav_sge rdma_sgl;	/* rdma single SGE */
 	char *rdma_buf;			/* used as rdma sink */
-	struct ibv_mr *rdma_mr;
+	struct rdmav_mr *rdma_mr;
 
 	uint32_t remote_rkey;		/* remote guys RKEY */
 	uint64_t remote_addr;		/* remote guys TO */
 	uint32_t remote_len;		/* remote guys LEN */
 
 	char *start_buf;		/* rdma read src */
-	struct ibv_mr *start_mr;
+	struct rdmav_mr *start_mr;
 
 	enum test_state state;		/* used for cond/signalling */
 	sem_t sem;
@@ -232,7 +232,7 @@ static int rping_cma_event_handler(struc
 	return ret;
 }
 
-static int server_recv(struct rping_cb *cb, struct ibv_wc *wc)
+static int server_recv(struct rping_cb *cb, struct rdmav_wc *wc)
 {
 	if (wc->byte_len != sizeof(cb->recv_buf)) {
 		fprintf(stderr, "Received bogus data, size %d\n", wc->byte_len);
@@ -253,7 +253,7 @@ static int server_recv(struct rping_cb *
 	return 0;
 }
 
-static int client_recv(struct rping_cb *cb, struct ibv_wc *wc)
+static int client_recv(struct rping_cb *cb, struct rdmav_wc *wc)
 {
 	if (wc->byte_len != sizeof(cb->recv_buf)) {
 		fprintf(stderr, "Received bogus data, size %d\n", wc->byte_len);
@@ -270,39 +270,39 @@ static int client_recv(struct rping_cb *
 
 static int rping_cq_event_handler(struct rping_cb *cb)
 {
-	struct ibv_wc wc;
-	struct ibv_recv_wr *bad_wr;
+	struct rdmav_wc wc;
+	struct rdmav_recv_wr *bad_wr;
 	int ret;
 
-	while ((ret = ibv_poll_cq(cb->cq, 1, &wc)) == 1) {
+	while ((ret = rdmav_poll_cq(cb->cq, 1, &wc)) == 1) {
 		ret = 0;
 
 		if (wc.status) {
 			fprintf(stderr, "cq completion failed status %d\n",
 				wc.status);
-			if (wc.status != IBV_WC_WR_FLUSH_ERR)
+			if (wc.status != RDMAV_WC_WR_FLUSH_ERR)
 				ret = -1;
 			goto error;
 		}
 
 		switch (wc.opcode) {
-		case IBV_WC_SEND:
+		case RDMAV_WC_SEND:
 			DEBUG_LOG("send completion\n");
 			break;
 
-		case IBV_WC_RDMA_WRITE:
+		case RDMAV_WC_RDMA_WRITE:
 			DEBUG_LOG("rdma write completion\n");
 			cb->state = RDMA_WRITE_COMPLETE;
 			sem_post(&cb->sem);
 			break;
 
-		case IBV_WC_RDMA_READ:
+		case RDMAV_WC_RDMA_READ:
 			DEBUG_LOG("rdma read completion\n");
 			cb->state = RDMA_READ_COMPLETE;
 			sem_post(&cb->sem);
 			break;
 
-		case IBV_WC_RECV:
+		case RDMAV_WC_RECV:
 			DEBUG_LOG("recv completion\n");
 			ret = cb->server ? server_recv(cb, &wc) :
 					   client_recv(cb, &wc);
@@ -311,7 +311,7 @@ static int rping_cq_event_handler(struct
 				goto error;
 			}
 
-			ret = ibv_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
+			ret = rdmav_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
 			if (ret) {
 				fprintf(stderr, "post recv error: %d\n", ret);
 				goto error;
@@ -374,14 +374,14 @@ static void rping_setup_wr(struct rping_
 	cb->send_sgl.length = sizeof cb->send_buf;
 	cb->send_sgl.lkey = cb->send_mr->lkey;
 
-	cb->sq_wr.opcode = IBV_WR_SEND;
-	cb->sq_wr.send_flags = IBV_SEND_SIGNALED;
+	cb->sq_wr.opcode = RDMAV_WR_SEND;
+	cb->sq_wr.send_flags = RDMAV_SEND_SIGNALED;
 	cb->sq_wr.sg_list = &cb->send_sgl;
 	cb->sq_wr.num_sge = 1;
 
 	cb->rdma_sgl.addr = (uint64_t) (unsigned long) cb->rdma_buf;
 	cb->rdma_sgl.lkey = cb->rdma_mr->lkey;
-	cb->rdma_sq_wr.send_flags = IBV_SEND_SIGNALED;
+	cb->rdma_sq_wr.send_flags = RDMAV_SEND_SIGNALED;
 	cb->rdma_sq_wr.sg_list = &cb->rdma_sgl;
 	cb->rdma_sq_wr.num_sge = 1;
 }
@@ -392,14 +392,14 @@ static int rping_setup_buffers(struct rp
 
 	DEBUG_LOG("rping_setup_buffers called on cb %p\n", cb);
 
-	cb->recv_mr = ibv_reg_mr(cb->pd, &cb->recv_buf, sizeof cb->recv_buf,
-				 IBV_ACCESS_LOCAL_WRITE);
+	cb->recv_mr = rdmav_reg_mr(cb->pd, &cb->recv_buf, sizeof cb->recv_buf,
+				 RDMAV_ACCESS_LOCAL_WRITE);
 	if (!cb->recv_mr) {
 		fprintf(stderr, "recv_buf reg_mr failed\n");
 		return errno;
 	}
 
-	cb->send_mr = ibv_reg_mr(cb->pd, &cb->send_buf, sizeof cb->send_buf, 0);
+	cb->send_mr = rdmav_reg_mr(cb->pd, &cb->send_buf, sizeof cb->send_buf, 0);
 	if (!cb->send_mr) {
 		fprintf(stderr, "send_buf reg_mr failed\n");
 		ret = errno;
@@ -413,10 +413,10 @@ static int rping_setup_buffers(struct rp
 		goto err2;
 	}
 
-	cb->rdma_mr = ibv_reg_mr(cb->pd, cb->rdma_buf, cb->size,
-				 IBV_ACCESS_LOCAL_WRITE |
-				 IBV_ACCESS_REMOTE_READ |
-				 IBV_ACCESS_REMOTE_WRITE);
+	cb->rdma_mr = rdmav_reg_mr(cb->pd, cb->rdma_buf, cb->size,
+				 RDMAV_ACCESS_LOCAL_WRITE |
+				 RDMAV_ACCESS_REMOTE_READ |
+				 RDMAV_ACCESS_REMOTE_WRITE);
 	if (!cb->rdma_mr) {
 		fprintf(stderr, "rdma_buf reg_mr failed\n");
 		ret = errno;
@@ -431,10 +431,10 @@ static int rping_setup_buffers(struct rp
 			goto err4;
 		}
 
-		cb->start_mr = ibv_reg_mr(cb->pd, cb->start_buf, cb->size,
-					  IBV_ACCESS_LOCAL_WRITE | 
-					  IBV_ACCESS_REMOTE_READ |
-					  IBV_ACCESS_REMOTE_WRITE);
+		cb->start_mr = rdmav_reg_mr(cb->pd, cb->start_buf, cb->size,
+					  RDMAV_ACCESS_LOCAL_WRITE | 
+					  RDMAV_ACCESS_REMOTE_READ |
+					  RDMAV_ACCESS_REMOTE_WRITE);
 		if (!cb->start_mr) {
 			fprintf(stderr, "start_buf reg_mr failed\n");
 			ret = errno;
@@ -449,32 +449,32 @@ static int rping_setup_buffers(struct rp
 err5:
 	free(cb->start_buf);
 err4:
-	ibv_dereg_mr(cb->rdma_mr);
+	rdmav_dereg_mr(cb->rdma_mr);
 err3:
 	free(cb->rdma_buf);
 err2:
-	ibv_dereg_mr(cb->send_mr);
+	rdmav_dereg_mr(cb->send_mr);
 err1:
-	ibv_dereg_mr(cb->recv_mr);
+	rdmav_dereg_mr(cb->recv_mr);
 	return ret;
 }
 
 static void rping_free_buffers(struct rping_cb *cb)
 {
 	DEBUG_LOG("rping_free_buffers called on cb %p\n", cb);
-	ibv_dereg_mr(cb->recv_mr);
-	ibv_dereg_mr(cb->send_mr);
-	ibv_dereg_mr(cb->rdma_mr);
+	rdmav_dereg_mr(cb->recv_mr);
+	rdmav_dereg_mr(cb->send_mr);
+	rdmav_dereg_mr(cb->rdma_mr);
 	free(cb->rdma_buf);
 	if (!cb->server) {
-		ibv_dereg_mr(cb->start_mr);
+		rdmav_dereg_mr(cb->start_mr);
 		free(cb->start_buf);
 	}
 }
 
 static int rping_create_qp(struct rping_cb *cb)
 {
-	struct ibv_qp_init_attr init_attr;
+	struct rdmav_qp_init_attr init_attr;
 	int ret;
 
 	memset(&init_attr, 0, sizeof(init_attr));
@@ -482,7 +482,7 @@ static int rping_create_qp(struct rping_
 	init_attr.cap.max_recv_wr = 2;
 	init_attr.cap.max_recv_sge = 1;
 	init_attr.cap.max_send_sge = 1;
-	init_attr.qp_type = IBV_QPT_RC;
+	init_attr.qp_type = RDMAV_QPT_RC;
 	init_attr.send_cq = cb->cq;
 	init_attr.recv_cq = cb->cq;
 
@@ -501,43 +501,43 @@ static int rping_create_qp(struct rping_
 
 static void rping_free_qp(struct rping_cb *cb)
 {
-	ibv_destroy_qp(cb->qp);
-	ibv_destroy_cq(cb->cq);
-	ibv_destroy_comp_channel(cb->channel);
-	ibv_dealloc_pd(cb->pd);
+	rdmav_destroy_qp(cb->qp);
+	rdmav_destroy_cq(cb->cq);
+	rdmav_destroy_comp_channel(cb->channel);
+	rdmav_dealloc_pd(cb->pd);
 }
 
 static int rping_setup_qp(struct rping_cb *cb, struct rdma_cm_id *cm_id)
 {
 	int ret;
 
-	cb->pd = ibv_alloc_pd(cm_id->verbs);
+	cb->pd = rdmav_alloc_pd(cm_id->verbs);
 	if (!cb->pd) {
-		fprintf(stderr, "ibv_alloc_pd failed\n");
+		fprintf(stderr, "rdmav_alloc_pd failed\n");
 		return errno;
 	}
 	DEBUG_LOG("created pd %p\n", cb->pd);
 
-	cb->channel = ibv_create_comp_channel(cm_id->verbs);
+	cb->channel = rdmav_create_comp_channel(cm_id->verbs);
 	if (!cb->channel) {
-		fprintf(stderr, "ibv_create_comp_channel failed\n");
+		fprintf(stderr, "rdmav_create_comp_channel failed\n");
 		ret = errno;
 		goto err1;
 	}
 	DEBUG_LOG("created channel %p\n", cb->channel);
 
-	cb->cq = ibv_create_cq(cm_id->verbs, RPING_SQ_DEPTH * 2, cb,
+	cb->cq = rdmav_create_cq(cm_id->verbs, RPING_SQ_DEPTH * 2, cb,
 				cb->channel, 0);
 	if (!cb->cq) {
-		fprintf(stderr, "ibv_create_cq failed\n");
+		fprintf(stderr, "rdmav_create_cq failed\n");
 		ret = errno;
 		goto err2;
 	}
 	DEBUG_LOG("created cq %p\n", cb->cq);
 
-	ret = ibv_req_notify_cq(cb->cq, 0);
+	ret = rdmav_req_notify_cq(cb->cq, 0);
 	if (ret) {
-		fprintf(stderr, "ibv_create_cq failed\n");
+		fprintf(stderr, "rdmav_create_cq failed\n");
 		ret = errno;
 		goto err3;
 	}
@@ -551,11 +551,11 @@ static int rping_setup_qp(struct rping_c
 	return 0;
 
 err3:
-	ibv_destroy_cq(cb->cq);
+	rdmav_destroy_cq(cb->cq);
 err2:
-	ibv_destroy_comp_channel(cb->channel);
+	rdmav_destroy_comp_channel(cb->channel);
 err1:
-	ibv_dealloc_pd(cb->pd);
+	rdmav_dealloc_pd(cb->pd);
 	return ret;
 }
 
@@ -581,14 +581,14 @@ static void *cm_thread(void *arg)
 static void *cq_thread(void *arg)
 {
 	struct rping_cb *cb = arg;
-	struct ibv_cq *ev_cq;
+	struct rdmav_cq *ev_cq;
 	void *ev_ctx;
 	int ret;
 	
 	DEBUG_LOG("cq_thread started.\n");
 
 	while (1) {	
-		ret = ibv_get_cq_event(cb->channel, &ev_cq, &ev_ctx);
+		ret = rdmav_get_cq_event(cb->channel, &ev_cq, &ev_ctx);
 		if (ret) {
 			fprintf(stderr, "Failed to get cq event!\n");
 			exit(ret);
@@ -597,19 +597,19 @@ static void *cq_thread(void *arg)
 			fprintf(stderr, "Unkown CQ!\n");
 			exit(-1);
 		}
-		ret = ibv_req_notify_cq(cb->cq, 0);
+		ret = rdmav_req_notify_cq(cb->cq, 0);
 		if (ret) {
 			fprintf(stderr, "Failed to set notify!\n");
 			exit(ret);
 		}
 		ret = rping_cq_event_handler(cb);
-		ibv_ack_cq_events(cb->cq, 1);
+		rdmav_ack_cq_events(cb->cq, 1);
 		if (ret)
 			exit(ret);
 	}
 }
 
-static void rping_format_send(struct rping_cb *cb, char *buf, struct ibv_mr *mr)
+static void rping_format_send(struct rping_cb *cb, char *buf, struct rdmav_mr *mr)
 {
 	struct rping_rdma_info *info = &cb->send_buf;
 
@@ -623,7 +623,7 @@ static void rping_format_send(struct rpi
 
 static int rping_test_server(struct rping_cb *cb)
 {
-	struct ibv_send_wr *bad_wr;
+	struct rdmav_send_wr *bad_wr;
 	int ret;
 
 	while (1) {
@@ -639,12 +639,12 @@ static int rping_test_server(struct rpin
 		DEBUG_LOG("server received sink adv\n");
 
 		/* Issue RDMA Read. */
-		cb->rdma_sq_wr.opcode = IBV_WR_RDMA_READ;
+		cb->rdma_sq_wr.opcode = RDMAV_WR_RDMA_READ;
 		cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
 		cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
 		cb->rdma_sq_wr.sg_list->length = cb->remote_len;
 
-		ret = ibv_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+		ret = rdmav_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
 		if (ret) {
 			fprintf(stderr, "post send error %d\n", ret);
 			break;
@@ -666,7 +666,7 @@ static int rping_test_server(struct rpin
 			printf("server ping data: %s\n", cb->rdma_buf);
 
 		/* Tell client to continue */
-		ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+		ret = rdmav_post_send(cb->qp, &cb->sq_wr, &bad_wr);
 		if (ret) {
 			fprintf(stderr, "post send error %d\n", ret);
 			break;
@@ -684,7 +684,7 @@ static int rping_test_server(struct rpin
 		DEBUG_LOG("server received sink adv\n");
 
 		/* RDMA Write echo data */
-		cb->rdma_sq_wr.opcode = IBV_WR_RDMA_WRITE;
+		cb->rdma_sq_wr.opcode = RDMAV_WR_RDMA_WRITE;
 		cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
 		cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
 		cb->rdma_sq_wr.sg_list->length = strlen(cb->rdma_buf) + 1;
@@ -693,7 +693,7 @@ static int rping_test_server(struct rpin
 			  cb->rdma_sq_wr.sg_list->addr,
 			  cb->rdma_sq_wr.sg_list->length);
 
-		ret = ibv_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+		ret = rdmav_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
 		if (ret) {
 			fprintf(stderr, "post send error %d\n", ret);
 			break;
@@ -710,7 +710,7 @@ static int rping_test_server(struct rpin
 		DEBUG_LOG("server rdma write complete \n");
 
 		/* Tell client to begin again */
-		ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+		ret = rdmav_post_send(cb->qp, &cb->sq_wr, &bad_wr);
 		if (ret) {
 			fprintf(stderr, "post send error %d\n", ret);
 			break;
@@ -757,7 +757,7 @@ static int rping_bind_server(struct rpin
 
 static int rping_run_server(struct rping_cb *cb)
 {
-	struct ibv_recv_wr *bad_wr;
+	struct rdmav_recv_wr *bad_wr;
 	int ret;
 
 	ret = rping_bind_server(cb);
@@ -776,9 +776,9 @@ static int rping_run_server(struct rping
 		goto err1;
 	}
 
-	ret = ibv_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
+	ret = rdmav_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
 	if (ret) {
-		fprintf(stderr, "ibv_post_recv failed: %d\n", ret);
+		fprintf(stderr, "rdmav_post_recv failed: %d\n", ret);
 		goto err2;
 	}
 
@@ -804,7 +804,7 @@ err1:
 static int rping_test_client(struct rping_cb *cb)
 {
 	int ping, start, cc, i, ret = 0;
-	struct ibv_send_wr *bad_wr;
+	struct rdmav_send_wr *bad_wr;
 	unsigned char c;
 
 	start = 65;
@@ -825,7 +825,7 @@ static int rping_test_client(struct rpin
 		cb->start_buf[cb->size - 1] = 0;
 
 		rping_format_send(cb, cb->start_buf, cb->start_mr);
-		ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+		ret = rdmav_post_send(cb->qp, &cb->sq_wr, &bad_wr);
 		if (ret) {
 			fprintf(stderr, "post send error %d\n", ret);
 			break;
@@ -841,7 +841,7 @@ static int rping_test_client(struct rpin
 		}
 
 		rping_format_send(cb, cb->rdma_buf, cb->rdma_mr);
-		ret = ibv_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+		ret = rdmav_post_send(cb->qp, &cb->sq_wr, &bad_wr);
 		if (ret) {
 			fprintf(stderr, "post send error %d\n", ret);
 			break;
@@ -926,7 +926,7 @@ static int rping_bind_client(struct rpin
 
 static int rping_run_client(struct rping_cb *cb)
 {
-	struct ibv_recv_wr *bad_wr;
+	struct rdmav_recv_wr *bad_wr;
 	int ret;
 
 	ret = rping_bind_client(cb);
@@ -945,9 +945,9 @@ static int rping_run_client(struct rping
 		goto err1;
 	}
 
-	ret = ibv_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
+	ret = rdmav_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
 	if (ret) {
-		fprintf(stderr, "ibv_post_recv failed: %d\n", ret);
+		fprintf(stderr, "rdmav_post_recv failed: %d\n", ret);
 		goto err2;
 	}
 
diff -ruNp ORG/librdmacm/examples/udaddy.c NEW/librdmacm/examples/udaddy.c
--- ORG/librdmacm/examples/udaddy.c	2006-07-30 21:18:17.000000000 -0700
+++ NEW/librdmacm/examples/udaddy.c	2006-08-03 17:32:51.000000000 -0700
@@ -55,10 +55,10 @@ struct cmatest_node {
 	int			id;
 	struct rdma_cm_id	*cma_id;
 	int			connected;
-	struct ibv_pd		*pd;
-	struct ibv_cq		*cq;
-	struct ibv_mr		*mr;
-	struct ibv_ah		*ah;
+	struct rdmav_pd		*pd;
+	struct rdmav_cq		*cq;
+	struct rdmav_mr		*mr;
+	struct rdmav_ah		*ah;
 	uint32_t		remote_qpn;
 	uint32_t		remote_qkey;
 	void			*mem;
@@ -90,14 +90,14 @@ static int create_message(struct cmatest
 	if (!message_count)
 		return 0;
 
-	node->mem = malloc(message_size + sizeof(struct ibv_grh));
+	node->mem = malloc(message_size + sizeof(struct rdmav_grh));
 	if (!node->mem) {
 		printf("failed message allocation\n");
 		return -1;
 	}
-	node->mr = ibv_reg_mr(node->pd, node->mem,
-			      message_size + sizeof(struct ibv_grh),
-			      IBV_ACCESS_LOCAL_WRITE);
+	node->mr = rdmav_reg_mr(node->pd, node->mem,
+			      message_size + sizeof(struct rdmav_grh),
+			      RDMAV_ACCESS_LOCAL_WRITE);
 	if (!node->mr) {
 		printf("failed to reg MR\n");
 		goto err;
@@ -110,10 +110,10 @@ err:
 
 static int init_node(struct cmatest_node *node)
 {
-	struct ibv_qp_init_attr init_qp_attr;
+	struct rdmav_qp_init_attr init_qp_attr;
 	int cqe, ret;
 
-	node->pd = ibv_alloc_pd(node->cma_id->verbs);
+	node->pd = rdmav_alloc_pd(node->cma_id->verbs);
 	if (!node->pd) {
 		ret = -ENOMEM;
 		printf("udaddy: unable to allocate PD\n");
@@ -121,7 +121,7 @@ static int init_node(struct cmatest_node
 	}
 
 	cqe = message_count ? message_count * 2 : 2;
-	node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
+	node->cq = rdmav_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
 	if (!node->cq) {
 		ret = -ENOMEM;
 		printf("udaddy: unable to create CQ\n");
@@ -135,7 +135,7 @@ static int init_node(struct cmatest_node
 	init_qp_attr.cap.max_recv_sge = 1;
 	init_qp_attr.qp_context = node;
 	init_qp_attr.sq_sig_all = 0;
-	init_qp_attr.qp_type = IBV_QPT_UD;
+	init_qp_attr.qp_type = RDMAV_QPT_UD;
 	init_qp_attr.send_cq = node->cq;
 	init_qp_attr.recv_cq = node->cq;
 	ret = rdma_create_qp(node->cma_id, node->pd, &init_qp_attr);
@@ -155,8 +155,8 @@ out:
 
 static int post_recvs(struct cmatest_node *node)
 {
-	struct ibv_recv_wr recv_wr, *recv_failure;
-	struct ibv_sge sge;
+	struct rdmav_recv_wr recv_wr, *recv_failure;
+	struct rdmav_sge sge;
 	int i, ret = 0;
 
 	if (!message_count)
@@ -167,12 +167,12 @@ static int post_recvs(struct cmatest_nod
 	recv_wr.num_sge = 1;
 	recv_wr.wr_id = (uintptr_t) node;
 
-	sge.length = message_size + sizeof(struct ibv_grh);
+	sge.length = message_size + sizeof(struct rdmav_grh);
 	sge.lkey = node->mr->lkey;
 	sge.addr = (uintptr_t) node->mem;
 
 	for (i = 0; i < message_count && !ret; i++ ) {
-		ret = ibv_post_recv(node->cma_id->qp, &recv_wr, &recv_failure);
+		ret = rdmav_post_recv(node->cma_id->qp, &recv_wr, &recv_failure);
 		if (ret) {
 			printf("failed to post receives: %d\n", ret);
 			break;
@@ -183,8 +183,8 @@ static int post_recvs(struct cmatest_nod
 
 static int post_sends(struct cmatest_node *node, int signal_flag)
 {
-	struct ibv_send_wr send_wr, *bad_send_wr;
-	struct ibv_sge sge;
+	struct rdmav_send_wr send_wr, *bad_send_wr;
+	struct rdmav_sge sge;
 	int i, ret = 0;
 
 	if (!node->connected || !message_count)
@@ -193,8 +193,8 @@ static int post_sends(struct cmatest_nod
 	send_wr.next = NULL;
 	send_wr.sg_list = &sge;
 	send_wr.num_sge = 1;
-	send_wr.opcode = IBV_WR_SEND_WITH_IMM;
-	send_wr.send_flags = IBV_SEND_INLINE | signal_flag;
+	send_wr.opcode = RDMAV_WR_SEND_WITH_IMM;
+	send_wr.send_flags = RDMAV_SEND_INLINE | signal_flag;
 	send_wr.wr_id = (unsigned long)node;
 	send_wr.imm_data = htonl(node->cma_id->qp->qp_num);
 
@@ -202,12 +202,12 @@ static int post_sends(struct cmatest_nod
 	send_wr.wr.ud.remote_qpn = node->remote_qpn;
 	send_wr.wr.ud.remote_qkey = node->remote_qkey;
 
-	sge.length = message_size - sizeof(struct ibv_grh);
+	sge.length = message_size - sizeof(struct rdmav_grh);
 	sge.lkey = node->mr->lkey;
 	sge.addr = (uintptr_t) node->mem;
 
 	for (i = 0; i < message_count && !ret; i++) {
-		ret = ibv_post_send(node->cma_id->qp, &send_wr, &bad_send_wr);
+		ret = rdmav_post_send(node->cma_id->qp, &send_wr, &bad_send_wr);
 		if (ret) 
 			printf("failed to post sends: %d\n", ret);
 	}
@@ -305,7 +305,7 @@ err1:
 
 static int resolved_handler(struct cmatest_node *node)
 {
-	struct ibv_ah_attr ah_attr;
+	struct rdmav_ah_attr ah_attr;
 	int ret;
 
 	ret = rdma_get_dst_attr(node->cma_id, test.dst_addr, &ah_attr,
@@ -315,7 +315,7 @@ static int resolved_handler(struct cmate
 		goto err;
 	}
 
-	node->ah = ibv_create_ah(node->pd, &ah_attr);
+	node->ah = rdmav_create_ah(node->pd, &ah_attr);
 	if (!node->ah) {
 		printf("udaddy: failure creating address handle\n");
 		goto err;
@@ -371,21 +371,21 @@ static void destroy_node(struct cmatest_
 		return;
 
 	if (node->ah)
-		ibv_destroy_ah(node->ah);
+		rdmav_destroy_ah(node->ah);
 
 	if (node->cma_id->qp)
 		rdma_destroy_qp(node->cma_id);
 
 	if (node->cq)
-		ibv_destroy_cq(node->cq);
+		rdmav_destroy_cq(node->cq);
 
 	if (node->mem) {
-		ibv_dereg_mr(node->mr);
+		rdmav_dereg_mr(node->mr);
 		free(node->mem);
 	}
 
 	if (node->pd)
-		ibv_dealloc_pd(node->pd);
+		rdmav_dealloc_pd(node->pd);
 
 	/* Destroy the RDMA ID after all device resources */
 	rdma_destroy_id(node->cma_id);
@@ -429,9 +429,9 @@ static void destroy_nodes(void)
 	free(test.nodes);
 }
 
-static void create_reply_ah(struct cmatest_node *node, struct ibv_wc *wc)
+static void create_reply_ah(struct cmatest_node *node, struct rdmav_wc *wc)
 {
-	node->ah = ibv_create_ah_from_wc(node->pd, wc, node->mem,
+	node->ah = rdmav_create_ah_from_wc(node->pd, wc, node->mem,
 					 node->cma_id->port_num);
 	node->remote_qpn = ntohl(wc->imm_data);
 	node->remote_qkey = ntohs(rdma_get_dst_port(node->cma_id));
@@ -439,7 +439,7 @@ static void create_reply_ah(struct cmate
 
 static int poll_cqs(void)
 {
-	struct ibv_wc wc[8];
+	struct rdmav_wc wc[8];
 	int done, i, ret;
 
 	for (i = 0; i < connections; i++) {
@@ -447,7 +447,7 @@ static int poll_cqs(void)
 			continue;
 
 		for (done = 0; done < message_count; done += ret) {
-			ret = ibv_poll_cq(test.nodes[i].cq, 8, wc);
+			ret = rdmav_poll_cq(test.nodes[i].cq, 8, wc);
 			if (ret < 0) {
 				printf("udaddy: failed polling CQ: %d\n", ret);
 				return ret;
@@ -511,7 +511,7 @@ static int run_server(void)
 
 		printf("sending replies\n");
 		for (i = 0; i < connections; i++) {
-			ret = post_sends(&test.nodes[i], IBV_SEND_SIGNALED);
+			ret = post_sends(&test.nodes[i], RDMAV_SEND_SIGNALED);
 			if (ret)
 				goto out;
 		}




More information about the general mailing list