[openib-general] [RFC] [PATCH 6/7] librdmacm changes to use new API
Krishna Kumar
krkumar2 at in.ibm.com
Mon Jul 10 03:28:22 PDT 2006
Changes the librdmacm library to use the librdmaverbs data types
and verb API's. The example programs are also modified to use the
new verb API's.
Signed-of-by: Krishna Kumar <krkumar2 at in.ibm.com>
diff -ruNp ORG/librdmacm/configure.in NEW/librdmacm/configure.in
--- ORG/librdmacm/configure.in 2006-07-09 22:12:17.000000000 -0700
+++ NEW/librdmacm/configure.in 2006-07-10 18:07:45.000000000 -0700
@@ -27,8 +27,8 @@ if test "$disable_libcheck" != "yes"
then
AC_CHECK_LIB(sysfs, sysfs_open_class, [],
AC_MSG_ERROR([sysfs_open_class() not found. librdmacm requires
libsysfs.]))
-AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
- AC_MSG_ERROR([ibv_get_device_list() not found. librdmacm requires
libibverbs.]))
+AC_CHECK_LIB(rdmaverbs, rdma_get_device_list, [],
+ AC_MSG_ERROR([rdma_get_device_list() not found. librdmacm requires
librdmaverbs.]))
fi
dnl Checks for header files.
@@ -36,8 +36,8 @@ if test "$disable_libcheck" != "yes"
then
AC_CHECK_HEADER(sysfs/libsysfs.h, [],
AC_MSG_ERROR([<sysfs/libsysfs.h> not found. librdmacm requires
libsysfs.]))
-AC_CHECK_HEADER(infiniband/verbs.h, [],
- AC_MSG_ERROR([<infiniband/verbs.h> not found. Is libibverbs
installed?]))
+AC_CHECK_HEADER(rdma/verbs.h, [],
+ AC_MSG_ERROR([<rdma/verbs.h> not found. Is librdmaverbs
installed?]))
fi
AC_HEADER_STDC
diff -ruNp ORG/librdmacm/examples/cmatose.c
NEW/librdmacm/examples/cmatose.c
--- ORG/librdmacm/examples/cmatose.c 2006-07-09 22:12:17.000000000 -0700
+++ NEW/librdmacm/examples/cmatose.c 2006-07-10 18:07:45.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 rdma_pd *pd;
+ struct rdma_cq *cq;
+ struct rdma_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 = rdma_reg_mr(node->pd, node->mem, message_size,
+ RDMA_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 rdma_qp_init_attr init_qp_attr;
int cqe, ret;
- node->pd = ibv_alloc_pd(node->cma_id->verbs);
+ node->pd = rdma_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 = rdma_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 = RDMA_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 rdma_recv_wr recv_wr, *recv_failure;
+ struct rdma_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 = rdma_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 rdma_send_wr send_wr, *bad_send_wr;
+ struct rdma_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 = RDMA_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 = rdma_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);
+ rdma_destroy_cq(node->cq);
if (node->mem) {
- ibv_dereg_mr(node->mr);
+ rdma_dereg_mr(node->mr);
free(node->mem);
}
if (node->pd)
- ibv_dealloc_pd(node->pd);
+ rdma_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 rdma_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 = rdma_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/query.c NEW/librdmacm/examples/query.c
--- ORG/librdmacm/examples/query.c 2006-07-09 22:12:17.000000000 -0700
+++ NEW/librdmacm/examples/query.c 2006-07-10 18:07:45.000000000 -0700
@@ -83,8 +83,8 @@ int main(int argc, char *argv[])
}
printf("node_type=%d\n",
- ibv_get_transport_type(cm_id->verbs));
+ rdma_get_transport_type(cm_id->verbs));
printf("transport_type=%d\n",
- ibv_get_transport_type(cm_id->verbs));
+ rdma_get_transport_type(cm_id->verbs));
return 0;
}
diff -ruNp ORG/librdmacm/examples/rping.c NEW/librdmacm/examples/rping.c
--- ORG/librdmacm/examples/rping.c 2006-07-09 22:12:17.000000000 -0700
+++ NEW/librdmacm/examples/rping.c 2006-07-10 18:07: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 rdma_comp_channel *channel;
+ struct rdma_cq *cq;
+ struct rdma_pd *pd;
+ struct rdma_qp *qp;
- struct ibv_recv_wr rq_wr; /* recv work request record */
- struct ibv_sge recv_sgl; /* recv single SGE */
+ struct rdma_recv_wr rq_wr; /* recv work request record */
+ struct rdma_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 rdma_mr *recv_mr; /* MR associated with this buffer */
- struct ibv_send_wr sq_wr; /* send work requrest record */
- struct ibv_sge send_sgl;
+ struct rdma_send_wr sq_wr; /* send work requrest record */
+ struct rdma_sge send_sgl;
struct rping_rdma_info send_buf;/* single send buf */
- struct ibv_mr *send_mr;
+ struct rdma_mr *send_mr;
- struct ibv_send_wr rdma_sq_wr; /* rdma work request record */
- struct ibv_sge rdma_sgl; /* rdma single SGE */
+ struct rdma_send_wr rdma_sq_wr; /* rdma work request record */
+ struct rdma_sge rdma_sgl; /* rdma single SGE */
char *rdma_buf; /* used as rdma sink */
- struct ibv_mr *rdma_mr;
+ struct rdma_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 rdma_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 rdma_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 rdma_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 rdma_wc wc;
+ struct rdma_recv_wr *bad_wr;
int ret;
- while ((ret = ibv_poll_cq(cb->cq, 1, &wc)) == 1) {
+ while ((ret = rdma_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 != RDMA_WC_WR_FLUSH_ERR)
ret = -1;
goto error;
}
switch (wc.opcode) {
- case IBV_WC_SEND:
+ case RDMA_WC_SEND:
DEBUG_LOG("send completion\n");
break;
- case IBV_WC_RDMA_WRITE:
+ case RDMA_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 RDMA_WC_RDMA_READ:
DEBUG_LOG("rdma read completion\n");
cb->state = RDMA_READ_COMPLETE;
sem_post(&cb->sem);
break;
- case IBV_WC_RECV:
+ case RDMA_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 = rdma_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 = RDMA_WR_SEND;
+ cb->sq_wr.send_flags = RDMA_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 = RDMA_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 = rdma_reg_mr(cb->pd, &cb->recv_buf, sizeof cb->recv_buf,
+ RDMA_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 = rdma_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 = rdma_reg_mr(cb->pd, cb->rdma_buf, cb->size,
+ RDMA_ACCESS_LOCAL_WRITE |
+ RDMA_ACCESS_REMOTE_READ |
+ RDMA_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 = rdma_reg_mr(cb->pd, cb->start_buf, cb->size,
+ RDMA_ACCESS_LOCAL_WRITE |
+ RDMA_ACCESS_REMOTE_READ |
+ RDMA_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);
+ rdma_dereg_mr(cb->rdma_mr);
err3:
free(cb->rdma_buf);
err2:
- ibv_dereg_mr(cb->send_mr);
+ rdma_dereg_mr(cb->send_mr);
err1:
- ibv_dereg_mr(cb->recv_mr);
+ rdma_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);
+ rdma_dereg_mr(cb->recv_mr);
+ rdma_dereg_mr(cb->send_mr);
+ rdma_dereg_mr(cb->rdma_mr);
free(cb->rdma_buf);
if (!cb->server) {
- ibv_dereg_mr(cb->start_mr);
+ rdma_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 rdma_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 = RDMA_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);
+ rdma_destroy_cq(cb->cq);
+ rdma_destroy_comp_channel(cb->channel);
+ rdma_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 = rdma_alloc_pd(cm_id->verbs);
if (!cb->pd) {
- fprintf(stderr, "ibv_alloc_pd failed\n");
+ fprintf(stderr, "rdma_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 = rdma_create_comp_channel(cm_id->verbs);
if (!cb->channel) {
- fprintf(stderr, "ibv_create_comp_channel failed\n");
+ fprintf(stderr, "rdma_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 = rdma_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, "rdma_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 = rdma_req_notify_cq(cb->cq, 0);
if (ret) {
- fprintf(stderr, "ibv_create_cq failed\n");
+ fprintf(stderr, "rdma_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);
+ rdma_destroy_cq(cb->cq);
err2:
- ibv_destroy_comp_channel(cb->channel);
+ rdma_destroy_comp_channel(cb->channel);
err1:
- ibv_dealloc_pd(cb->pd);
+ rdma_dealloc_pd(cb->pd);
return ret;
}
@@ -581,35 +581,35 @@ static void *cm_thread(void *arg)
static void *cq_thread(void *arg)
{
struct rping_cb *cb = arg;
- struct ibv_cq *ev_cq;
+ struct rdma_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 = rdma_get_cq_event(cb->channel, &ev_cq, &ev_ctx);
if (ret) {
fprintf(stderr, "Failed to get cq event!\n");
exit(ret);
}
if (ev_cq != cb->cq) {
- fprintf(stderr, "Unkown CQ!\n");
+ fprintf(stderr, "Unknown CQ!\n");
exit(-1);
}
- ret = ibv_req_notify_cq(cb->cq, 0);
+ ret = rdma_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);
+ rdma_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
rdma_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 rdma_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 = RDMA_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 = rdma_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 = rdma_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 = RDMA_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 = rdma_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 = rdma_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 rdma_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 = rdma_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
if (ret) {
- fprintf(stderr, "ibv_post_recv failed: %d\n", ret);
+ fprintf(stderr, "rdma_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 rdma_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 = rdma_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 = rdma_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 rdma_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 = rdma_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
if (ret) {
- fprintf(stderr, "ibv_post_recv failed: %d\n", ret);
+ fprintf(stderr, "rdma_post_recv failed: %d\n", ret);
goto err2;
}
diff -ruNp ORG/librdmacm/include/rdma/rdma_cma.h
NEW/librdmacm/include/rdma/rdma_cma.h
--- ORG/librdmacm/include/rdma/rdma_cma.h 2006-07-09 22:12:15.000000000
-0700
+++ NEW/librdmacm/include/rdma/rdma_cma.h 2006-07-10 18:07:45.000000000
-0700
@@ -32,8 +32,8 @@
#include <netinet/in.h>
#include <sys/socket.h>
-#include <infiniband/verbs.h>
-#include <infiniband/sa.h>
+#include <rdma/verbs.h>
+#include <rdma/sa.h>
/*
* Upon receiving a device removal event, users must destroy the
associated
@@ -62,12 +62,12 @@ enum {
/* IB specific option names for get/set. */
enum {
- IB_PATH_OPTIONS = 1,
+ RDMA_PATH_OPTIONS = 1,
};
struct ib_addr {
- union ibv_gid sgid;
- union ibv_gid dgid;
+ union rdma_gid sgid;
+ union rdma_gid dgid;
uint16_t pkey;
};
@@ -81,7 +81,7 @@ struct rdma_addr {
struct rdma_route {
struct rdma_addr addr;
- struct ibv_sa_path_rec *path_rec;
+ struct rdma_sa_path_rec *path_rec;
int num_paths;
};
@@ -90,10 +90,10 @@ struct rdma_event_channel {
};
struct rdma_cm_id {
- struct ibv_context *verbs;
+ struct rdma_context *verbs;
struct rdma_event_channel *channel;
void *context;
- struct ibv_qp *qp;
+ struct rdma_qp *qp;
struct rdma_route route;
uint8_t port_num;
};
@@ -179,8 +179,8 @@ int rdma_resolve_route(struct rdma_cm_id
* QPs allocated to an rdma_cm_id will automatically be transitioned by
the CMA
* through their states.
*/
-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(struct rdma_cm_id *id, struct rdma_pd *pd,
+ struct rdma_qp_init_attr *qp_init_attr);
/**
* rdma_destroy_qp - Deallocate the QP associated with the specified
RDMA
diff -ruNp ORG/librdmacm/include/rdma/rdma_cma_abi.h
NEW/librdmacm/include/rdma/rdma_cma_abi.h
--- ORG/librdmacm/include/rdma/rdma_cma_abi.h 2006-07-09
22:12:15.000000000 -0700
+++ NEW/librdmacm/include/rdma/rdma_cma_abi.h 2006-07-10
18:07:45.000000000 -0700
@@ -33,7 +33,7 @@
#ifndef RDMA_CMA_ABI_H
#define RDMA_CMA_ABI_H
-#include <infiniband/sa-kern-abi.h>
+#include <rdma/sa-kern-abi.h>
/*
* This file must be kept in sync with the kernel's version of
rdma_user_cm.h
@@ -113,7 +113,7 @@ struct ucma_abi_query_route {
struct ucma_abi_query_route_resp {
__u64 node_guid;
- struct ibv_kern_path_rec ib_route[2];
+ struct rdma_kern_path_rec ib_route[2];
struct sockaddr_in6 src_addr;
struct sockaddr_in6 dst_addr;
__u32 num_paths;
diff -ruNp ORG/librdmacm/src/cma.c NEW/librdmacm/src/cma.c
--- ORG/librdmacm/src/cma.c 2006-07-09 22:12:15.000000000 -0700
+++ NEW/librdmacm/src/cma.c 2006-07-10 18:07:45.000000000 -0700
@@ -51,7 +51,7 @@
#include <sysfs/libsysfs.h>
-#include <infiniband/marshall.h>
+#include <rdma/marshall.h>
#include <rdma/rdma_cma.h>
#include <rdma/rdma_cma_abi.h>
@@ -102,7 +102,7 @@ do {
} while (0)
struct cma_device {
- struct ibv_context *verbs;
+ struct rdma_context *verbs;
uint64_t guid;
int port_cnt;
};
@@ -117,7 +117,7 @@ struct cma_id_private {
uint32_t handle;
};
-static struct ibv_device **dev_list;
+static struct rdma_device **dev_list;
static struct dlist *cma_dev_list;
static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
static int ucma_initialized;
@@ -132,7 +132,7 @@ static void ucma_cleanup(void)
if (cma_dev_list) {
dlist_for_each_data(cma_dev_list, cma_dev, struct cma_device)
- ibv_close_device(cma_dev->verbs);
+ rdma_close_device(cma_dev->verbs);
dlist_destroy(cma_dev_list);
cma_dev_list = NULL;
@@ -184,7 +184,7 @@ static int ucma_init(void)
{
int i;
struct cma_device *cma_dev;
- struct ibv_device_attr attr;
+ struct rdma_device_attr attr;
int ret;
pthread_mutex_lock(&mut);
@@ -201,7 +201,7 @@ static int ucma_init(void)
goto err;
}
- dev_list = ibv_get_device_list(NULL);
+ dev_list = rdma_get_device_list(NULL);
if (!dev_list) {
printf("CMA: unable to get RDMA device liste\n");
ret = -ENODEV;
@@ -215,15 +215,15 @@ static int ucma_init(void)
goto err;
}
- cma_dev->guid = ibv_get_device_guid(dev_list[i]);
- cma_dev->verbs = ibv_open_device(dev_list[i]);
+ cma_dev->guid = rdma_get_device_guid(dev_list[i]);
+ cma_dev->verbs = rdma_open_device(dev_list[i]);
if (!cma_dev->verbs) {
printf("CMA: unable to open RDMA device\n");
ret = -ENODEV;
goto err;
}
- ret = ibv_query_device(cma_dev->verbs, &attr);
+ ret = rdma_query_device(cma_dev->verbs, &attr);
if (ret) {
printf("CMA: unable to query RDMA device\n");
goto err;
@@ -240,7 +240,7 @@ err:
ucma_cleanup();
pthread_mutex_unlock(&mut);
if (dev_list)
- ibv_free_device_list(dev_list);
+ rdma_free_device_list(dev_list);
return ret;
}
@@ -429,7 +429,7 @@ static int ucma_query_route(struct rdma_
id->route.num_paths = resp->num_paths;
for (i = 0; i < resp->num_paths; i++)
- ibv_copy_path_rec_from_kern(&id->route.path_rec[i],
+ rdma_copy_path_rec_from_kern(&id->route.path_rec[i],
&resp->ib_route[i]);
}
@@ -528,11 +528,11 @@ int rdma_resolve_route(struct rdma_cm_id
return 0;
}
-static int rdma_init_qp_attr(struct rdma_cm_id *id, struct ibv_qp_attr
*qp_attr,
+static int rdma_init_qp_attr(struct rdma_cm_id *id, struct rdma_qp_attr
*qp_attr,
int *qp_attr_mask)
{
struct ucma_abi_init_qp_attr *cmd;
- struct ibv_kern_qp_attr *resp;
+ struct rdma_kern_qp_attr *resp;
struct cma_id_private *id_priv;
void *msg;
int ret, size;
@@ -546,70 +546,70 @@ static int rdma_init_qp_attr(struct rdma
if (ret != size)
return (ret > 0) ? -ENODATA : ret;
- ibv_copy_qp_attr_from_kern(qp_attr, resp);
+ rdma_copy_qp_attr_from_kern(qp_attr, resp);
*qp_attr_mask = resp->qp_attr_mask;
return 0;
}
static int ucma_modify_qp_rtr(struct rdma_cm_id *id)
{
- struct ibv_qp_attr qp_attr;
+ struct rdma_qp_attr qp_attr;
int qp_attr_mask, ret;
if (!id->qp)
return -EINVAL;
/* Need to update QP attributes from default values. */
- qp_attr.qp_state = IBV_QPS_INIT;
+ qp_attr.qp_state = RDMA_QPS_INIT;
ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
if (ret)
return ret;
- ret = ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask);
+ ret = rdma_modify_qp(id->qp, &qp_attr, qp_attr_mask);
if (ret)
return ret;
- qp_attr.qp_state = IBV_QPS_RTR;
+ qp_attr.qp_state = RDMA_QPS_RTR;
ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
if (ret)
return ret;
- return ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask);
+ return rdma_modify_qp(id->qp, &qp_attr, qp_attr_mask);
}
static int ucma_modify_qp_rts(struct rdma_cm_id *id)
{
- struct ibv_qp_attr qp_attr;
+ struct rdma_qp_attr qp_attr;
int qp_attr_mask, ret;
- qp_attr.qp_state = IBV_QPS_RTS;
+ qp_attr.qp_state = RDMA_QPS_RTS;
ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
if (ret)
return ret;
- return ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask);
+ return rdma_modify_qp(id->qp, &qp_attr, qp_attr_mask);
}
static int ucma_modify_qp_sqd(struct rdma_cm_id *id)
{
- struct ibv_qp_attr qp_attr;
+ struct rdma_qp_attr qp_attr;
if (!id->qp)
return 0;
- qp_attr.qp_state = IBV_QPS_SQD;
- return ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE);
+ qp_attr.qp_state = RDMA_QPS_SQD;
+ return rdma_modify_qp(id->qp, &qp_attr, RDMA_QP_STATE);
}
static int ucma_modify_qp_err(struct rdma_cm_id *id)
{
- struct ibv_qp_attr qp_attr;
+ struct rdma_qp_attr qp_attr;
if (!id->qp)
return 0;
- qp_attr.qp_state = IBV_QPS_ERR;
- return ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE);
+ qp_attr.qp_state = RDMA_QPS_ERR;
+ return rdma_modify_qp(id->qp, &qp_attr, RDMA_QP_STATE);
}
static int ucma_find_pkey(struct cma_device *cma_dev, uint8_t port_num,
@@ -619,7 +619,7 @@ static int ucma_find_pkey(struct cma_dev
uint16_t chk_pkey;
for (i = 0, ret = 0; !ret; i++) {
- ret = ibv_query_pkey(cma_dev->verbs, port_num, i, &chk_pkey);
+ ret = rdma_query_pkey(cma_dev->verbs, port_num, i, &chk_pkey);
if (!ret && pkey == chk_pkey) {
*pkey_index = (uint16_t) i;
return 0;
@@ -629,9 +629,9 @@ static int ucma_find_pkey(struct cma_dev
return -EINVAL;
}
-static int ucma_init_ib_qp(struct cma_id_private *id_priv, struct
ibv_qp *qp)
+static int ucma_init_ib_qp(struct cma_id_private *id_priv, struct
rdma_qp *qp)
{
- struct ibv_qp_attr qp_attr;
+ struct rdma_qp_attr qp_attr;
struct ib_addr *ibaddr;
int ret;
@@ -642,24 +642,24 @@ static int ucma_init_ib_qp(struct cma_id
return ret;
qp_attr.port_num = id_priv->id.port_num;
- qp_attr.qp_state = IBV_QPS_INIT;
- qp_attr.qp_access_flags = IBV_ACCESS_LOCAL_WRITE;
- return ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_ACCESS_FLAGS
|
- IBV_QP_PKEY_INDEX | IBV_QP_PORT);
+ qp_attr.qp_state = RDMA_QPS_INIT;
+ qp_attr.qp_access_flags = RDMA_ACCESS_LOCAL_WRITE;
+ return rdma_modify_qp(qp, &qp_attr, RDMA_QP_STATE |
RDMA_QP_ACCESS_FLAGS |
+ RDMA_QP_PKEY_INDEX | RDMA_QP_PORT);
}
-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(struct rdma_cm_id *id, struct rdma_pd *pd,
+ struct rdma_qp_init_attr *qp_init_attr)
{
struct cma_id_private *id_priv;
- struct ibv_qp *qp;
+ struct rdma_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);
+ qp = rdmav_create_qp(pd, qp_init_attr);
if (!qp)
return -ENOMEM;
@@ -670,18 +670,18 @@ int rdma_create_qp(struct rdma_cm_id *id
id->qp = qp;
return 0;
err:
- ibv_destroy_qp(qp);
+ rdmav_destroy_qp(qp);
return ret;
}
void rdma_destroy_qp(struct rdma_cm_id *id)
{
- ibv_destroy_qp(id->qp);
+ rdmav_destroy_qp(id->qp);
}
static void ucma_copy_conn_param_to_kern(struct ucma_abi_conn_param
*dst,
struct rdma_conn_param *src,
- struct ibv_qp *qp)
+ struct rdma_qp *qp)
{
dst->qp_num = qp->qp_num;
dst->qp_type = qp->qp_type;
@@ -797,11 +797,11 @@ int rdma_disconnect(struct rdma_cm_id *i
void *msg;
int ret, size;
- switch (ibv_get_transport_type(id->verbs)) {
- case IBV_TRANSPORT_IB:
+ switch (rdma_get_transport_type(id->verbs)) {
+ case RDMA_TRANSPORT_IB:
ret = ucma_modify_qp_err(id);
break;
- case IBV_TRANSPORT_IWARP:
+ case RDMA_TRANSPORT_IWARP:
ret = ucma_modify_qp_sqd(id);
break;
default:
--- ORG/librdmaverbs/Makefile.am 1969-12-31 16:00:00.000000000 -0800
+++ NEW/librdmaverbs/Makefile.am 2006-07-10 22:08:54.000000000 -0700
@@ -0,0 +1,40 @@
+# $Id: Makefile.am 7631 2006-06-02 19:53:25Z swise $
+
+INCLUDES = -I$(srcdir)/include
+
+lib_LTLIBRARIES = src/librdmaverbs.la
+
+AM_CFLAGS = -g -Wall -D_GNU_SOURCE
+
+src_librdmaverbs_la_CFLAGS = -g -Wall -D_GNU_SOURCE -DDRIVER_PATH=
\"$(libdir)/rdma\"
+
+if HAVE_LD_VERSION_SCRIPT
+ librdmaverbs_version_script = -Wl,--version-script=
$(srcdir)/src/librdmaverbs.map
+else
+ librdmaverbs_version_script =
+endif
+
+src_librdmaverbs_la_SOURCES = src/cmd.c src/device.c src/init.c
src/marshall.c \
+ src/memory.c src/sysfs.c src/verbs.c
+src_librdmaverbs_la_LDFLAGS = -version-info 2 -export-dynamic \
+ $(librdmaverbs_version_script)
+src_librdmaverbs_la_DEPENDENCIES = $(srcdir)/src/librdmaverbs.map
+
+librdmaverbsincludedir = $(includedir)/rdma
+
+librdmaverbsinclude_HEADERS = include/rdma/arch.h include/rdma/driver.h
\
+ include/rdma/kern-abi.h include/rdma/opcode.h include/rdma/verbs.h
\
+ include/rdma/sa-kern-abi.h include/rdma/sa.h
include/rdma/marshall.h
+
+DEBIAN = debian/changelog debian/compat debian/control debian/copyright
\
+ debian/ibverbs-utils.install debian/librdmaverbs2.install \
+ debian/librdmaverbs2.postinst debian/librdmaverbs-dev.install \
+ debian/rules
+
+EXTRA_DIST = include/rdma/driver.h include/rdma/kern-abi.h \
+ include/rdma/opcode.h include/rdma/verbs.h include/rdma/marshall.h
\
+ include/rdma/sa-kern-abi.h include/rdma/sa.h \
+ src/rdmaverbs.h src/librdmaverbs.map librdmaverbs.spec.in
+
+dist-hook: librdmaverbs.spec
+ cp librdmaverbs.spec $(distdir)
More information about the general
mailing list