[openib-general] [PATCH v3 5/6] librdmacm source file changes.
Krishna Kumar
krkumar2 at in.ibm.com
Thu Aug 3 01:38:05 PDT 2006
Convert librdmacm source files to use the new libibverbs API.
Signed-off-by: Krishna Kumar <krkumar2 at in.ibm.com>
diff -ruNp ORG/librdmacm/configure.in NEW/librdmacm/configure.in
--- ORG/librdmacm/configure.in 2006-07-30 21:18:17.000000000 -0700
+++ NEW/librdmacm/configure.in 2006-08-03 00:02:57.000000000 -0700
@@ -25,8 +25,8 @@ AC_CHECK_SIZEOF(long)
dnl Checks for libraries
if test "$disable_libcheck" != "yes"
then
-AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
- AC_MSG_ERROR([ibv_get_device_list() not found. librdmacm requires libibverbs.]))
+AC_CHECK_LIB(ibverbs, rdmav_get_device_list, [],
+ AC_MSG_ERROR([rdmav_get_device_list() not found. librdmacm requires libibverbs.]))
fi
dnl Checks for header files.
diff -ruNp ORG/librdmacm/src/cma.c NEW/librdmacm/src/cma.c
--- ORG/librdmacm/src/cma.c 2006-07-30 21:18:17.000000000 -0700
+++ NEW/librdmacm/src/cma.c 2006-08-03 17:23:08.000000000 -0700
@@ -103,7 +103,7 @@ do {
} while (0)
struct cma_device {
- struct ibv_context *verbs;
+ struct rdmav_context *verbs;
uint64_t guid;
int port_cnt;
};
@@ -130,7 +130,7 @@ static void ucma_cleanup(void)
{
if (cma_dev_cnt) {
while (cma_dev_cnt)
- ibv_close_device(cma_dev_array[--cma_dev_cnt].verbs);
+ rdmav_close_device(cma_dev_array[--cma_dev_cnt].verbs);
free(cma_dev_array);
cma_dev_cnt = 0;
@@ -141,7 +141,7 @@ static int check_abi_version(void)
{
char value[8];
- if (ibv_read_sysfs_file(ibv_get_sysfs_path(),
+ if (rdmav_read_sysfs_file(rdmav_get_sysfs_path(),
"class/misc/rdma_cm/abi_version",
value, sizeof value) < 0) {
/*
@@ -167,9 +167,9 @@ static int check_abi_version(void)
static int ucma_init(void)
{
- struct ibv_device **dev_list = NULL;
+ struct rdmav_device **dev_list = NULL;
struct cma_device *cma_dev;
- struct ibv_device_attr attr;
+ struct rdmav_device_attr attr;
int i, ret;
pthread_mutex_lock(&mut);
@@ -180,7 +180,7 @@ static int ucma_init(void)
if (ret)
goto err;
- dev_list = ibv_get_device_list(&cma_dev_cnt);
+ dev_list = rdmav_get_device_list(&cma_dev_cnt);
if (!dev_list) {
printf("CMA: unable to get RDMA device list\n");
ret = -ENODEV;
@@ -196,15 +196,15 @@ static int ucma_init(void)
for (i = 0; dev_list[i]; ++i) {
cma_dev = &cma_dev_array[i];
- cma_dev->guid = ibv_get_device_guid(dev_list[i]);
- cma_dev->verbs = ibv_open_device(dev_list[i]);
+ cma_dev->guid = rdmav_get_device_guid(dev_list[i]);
+ cma_dev->verbs = rdmav_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 = rdmav_query_device(cma_dev->verbs, &attr);
if (ret) {
printf("CMA: unable to query RDMA device\n");
goto err;
@@ -219,13 +219,13 @@ err:
ucma_cleanup();
pthread_mutex_unlock(&mut);
if (dev_list)
- ibv_free_device_list(dev_list);
+ rdmav_free_device_list(dev_list);
return ret;
}
-struct ibv_context **rdma_get_devices(int *num_devices)
+struct rdmav_context **rdma_get_devices(int *num_devices)
{
- struct ibv_context **devs = NULL;
+ struct rdmav_context **devs = NULL;
int i;
if (!cma_dev_cnt && ucma_init())
@@ -244,7 +244,7 @@ out:
return devs;
}
-void rdma_free_devices(struct ibv_context **list)
+void rdma_free_devices(struct rdmav_context **list)
{
free(list);
}
@@ -479,7 +479,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],
+ rdmav_copy_path_rec_from_kern(&id->route.path_rec[i],
&resp->ib_route[i]);
}
@@ -578,11 +578,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 rdmav_qp_attr *qp_attr,
int *qp_attr_mask)
{
struct ucma_abi_init_qp_attr *cmd;
- struct ibv_kern_qp_attr *resp;
+ struct rdmav_kern_qp_attr *resp;
struct cma_id_private *id_priv;
void *msg;
int ret, size;
@@ -596,59 +596,59 @@ 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);
+ rdmav_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 rdmav_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 = RDMAV_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 = rdmav_modify_qp(id->qp, &qp_attr, qp_attr_mask);
if (ret)
return ret;
- qp_attr.qp_state = IBV_QPS_RTR;
+ qp_attr.qp_state = RDMAV_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 rdmav_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 rdmav_qp_attr qp_attr;
int qp_attr_mask, ret;
- qp_attr.qp_state = IBV_QPS_RTS;
+ qp_attr.qp_state = RDMAV_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 rdmav_modify_qp(id->qp, &qp_attr, qp_attr_mask);
}
static int ucma_modify_qp_err(struct rdma_cm_id *id)
{
- struct ibv_qp_attr qp_attr;
+ struct rdmav_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 = RDMAV_QPS_ERR;
+ return rdmav_modify_qp(id->qp, &qp_attr, RDMAV_QP_STATE);
}
static int ucma_find_pkey(struct cma_device *cma_dev, uint8_t port_num,
@@ -658,7 +658,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 = rdmav_query_pkey(cma_dev->verbs, port_num, i, &chk_pkey);
if (!ret && pkey == chk_pkey) {
*pkey_index = (uint16_t) i;
return 0;
@@ -668,9 +668,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 rdmav_qp *qp)
{
- struct ibv_qp_attr qp_attr;
+ struct rdmav_qp_attr qp_attr;
struct ib_addr *ibaddr;
int ret;
@@ -681,15 +681,15 @@ 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 = RDMAV_QPS_INIT;
+ qp_attr.qp_access_flags = RDMAV_ACCESS_LOCAL_WRITE;
+ return rdmav_modify_qp(qp, &qp_attr, RDMAV_QP_STATE | RDMAV_QP_ACCESS_FLAGS |
+ RDMAV_QP_PKEY_INDEX | RDMAV_QP_PORT);
}
-static int ucma_init_ud_qp(struct cma_id_private *id_priv, struct ibv_qp *qp)
+static int ucma_init_ud_qp(struct cma_id_private *id_priv, struct rdmav_qp *qp)
{
- struct ibv_qp_attr qp_attr;
+ struct rdmav_qp_attr qp_attr;
struct ib_addr *ibaddr;
int ret;
@@ -700,35 +700,35 @@ static int ucma_init_ud_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_state = RDMAV_QPS_INIT;
qp_attr.qkey = ntohs(rdma_get_src_port(&id_priv->id));
- ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_PKEY_INDEX |
- IBV_QP_PORT | IBV_QP_QKEY);
+ ret = rdmav_modify_qp(qp, &qp_attr, RDMAV_QP_STATE | RDMAV_QP_PKEY_INDEX |
+ RDMAV_QP_PORT | RDMAV_QP_QKEY);
if (ret)
return ret;
- qp_attr.qp_state = IBV_QPS_RTR;
- ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE);
+ qp_attr.qp_state = RDMAV_QPS_RTR;
+ ret = rdmav_modify_qp(qp, &qp_attr, RDMAV_QP_STATE);
if (ret)
return ret;
- qp_attr.qp_state = IBV_QPS_RTS;
+ qp_attr.qp_state = RDMAV_QPS_RTS;
qp_attr.sq_psn = 0;
- return ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN);
+ return rdmav_modify_qp(qp, &qp_attr, RDMAV_QP_STATE | RDMAV_QP_SQ_PSN);
}
-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 rdmav_pd *pd,
+ struct rdmav_qp_init_attr *qp_init_attr)
{
struct cma_id_private *id_priv;
- struct ibv_qp *qp;
+ struct rdmav_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;
@@ -742,19 +742,19 @@ 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,
uint32_t qp_num,
- enum ibv_qp_type qp_type, uint8_t srq)
+ enum rdmav_qp_type qp_type, uint8_t srq)
{
dst->qp_num = qp_num;
dst->qp_type = qp_type;
@@ -934,7 +934,7 @@ int rdma_leave_multicast(struct rdma_cm_
struct cma_id_private *id_priv;
void *msg;
int ret, size, addrlen;
- struct ibv_ah_attr ah_attr;
+ struct rdmav_ah_attr ah_attr;
uint32_t qp_info;
addrlen = ucma_addrlen(addr);
@@ -951,7 +951,7 @@ int rdma_leave_multicast(struct rdma_cm_
if (ret)
goto out;
- ret = ibv_detach_mcast(id->qp, &ah_attr.grh.dgid, ah_attr.dlid);
+ ret = rdmav_detach_mcast(id->qp, &ah_attr.grh.dgid, ah_attr.dlid);
if (ret)
goto out;
}
@@ -1075,7 +1075,7 @@ static void ucma_process_mcast(struct rd
{
struct ucma_abi_join_mcast kmc_data;
struct rdma_multicast_data *mc_data;
- struct ibv_ah_attr ah_attr;
+ struct rdmav_ah_attr ah_attr;
uint32_t qp_info;
kmc_data = *(struct ucma_abi_join_mcast *) evt->private_data;
@@ -1093,7 +1093,7 @@ static void ucma_process_mcast(struct rd
if (evt->status)
goto err;
- evt->status = ibv_attach_mcast(id->qp, &ah_attr.grh.dgid, ah_attr.dlid);
+ evt->status = rdmav_attach_mcast(id->qp, &ah_attr.grh.dgid, ah_attr.dlid);
if (evt->status)
goto err;
return;
@@ -1243,7 +1243,7 @@ int rdma_set_option(struct rdma_cm_id *i
}
int rdma_get_dst_attr(struct rdma_cm_id *id, struct sockaddr *addr,
- struct ibv_ah_attr *ah_attr, uint32_t *remote_qpn,
+ struct rdmav_ah_attr *ah_attr, uint32_t *remote_qpn,
uint32_t *remote_qkey)
{
struct ucma_abi_dst_attr_resp *resp;
@@ -1265,7 +1265,7 @@ int rdma_get_dst_attr(struct rdma_cm_id
if (ret != size)
return (ret > 0) ? -ENODATA : ret;
- ibv_copy_ah_attr_from_kern(ah_attr, &resp->ah_attr);
+ rdmav_copy_ah_attr_from_kern(ah_attr, &resp->ah_attr);
*remote_qpn = resp->remote_qpn;
*remote_qkey = resp->remote_qkey;
return 0;
More information about the general
mailing list