[openib-general] [PATCH v3 2/6] libibverbs source files changes.
Krishna Kumar
krkumar2 at in.ibm.com
Thu Aug 3 01:37:40 PDT 2006
Source files in libibverbs defining the new API.
Signed-off-by: Krishna Kumar <krkumar2 at in.ibm.com>
diff -ruNp ORG/libibverbs/src/cmd.c NEW/libibverbs/src/cmd.c
--- ORG/libibverbs/src/cmd.c 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/cmd.c 2006-08-03 17:29:24.000000000 -0700
@@ -45,16 +45,16 @@
#include <alloca.h>
#include <string.h>
-#include "ibverbs.h"
+#include "rdmaverbs.h"
-static int ibv_cmd_get_context_v2(struct ibv_context *context,
- struct ibv_get_context *new_cmd,
+static int rdmav_cmd_get_context_v2(struct rdmav_context *context,
+ struct rdmav_get_context *new_cmd,
size_t new_cmd_size,
- struct ibv_get_context_resp *resp,
+ struct rdmav_get_context_resp *resp,
size_t resp_size)
{
- struct ibv_abi_compat_v2 *t;
- struct ibv_get_context_v2 *cmd;
+ struct rdmav_abi_compat_v2 *t;
+ struct rdmav_get_context_v2 *cmd;
size_t cmd_size;
uint32_t cq_fd;
@@ -65,9 +65,10 @@ static int ibv_cmd_get_context_v2(struct
cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd;
cmd = alloca(cmd_size);
- memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd);
+ memcpy(cmd->driver_data, new_cmd->driver_data,
+ new_cmd_size - sizeof *new_cmd);
- IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
cmd->cq_fd_tab = (uintptr_t) &cq_fd;
if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
@@ -81,14 +82,16 @@ static int ibv_cmd_get_context_v2(struct
return 0;
}
-int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
- size_t cmd_size, struct ibv_get_context_resp *resp,
+int rdmav_cmd_get_context(struct rdmav_context *context,
+ struct rdmav_get_context *cmd,
+ size_t cmd_size, struct rdmav_get_context_resp *resp,
size_t resp_size)
{
if (abi_ver <= 2)
- return ibv_cmd_get_context_v2(context, cmd, cmd_size, resp, resp_size);
+ return rdmav_cmd_get_context_v2(context, cmd, cmd_size, resp,
+ resp_size);
- IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
return errno;
@@ -99,14 +102,14 @@ int ibv_cmd_get_context(struct ibv_conte
return 0;
}
-int ibv_cmd_query_device(struct ibv_context *context,
- struct ibv_device_attr *device_attr,
+int rdmav_cmd_query_device(struct rdmav_context *context,
+ struct rdmav_device_attr *device_attr,
uint64_t *raw_fw_ver,
- struct ibv_query_device *cmd, size_t cmd_size)
+ struct rdmav_query_device *cmd, size_t cmd_size)
{
- struct ibv_query_device_resp resp;
+ struct rdmav_query_device_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_DEVICE, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, QUERY_DEVICE, &resp, sizeof resp);
if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
return errno;
@@ -156,13 +159,13 @@ int ibv_cmd_query_device(struct ibv_cont
return 0;
}
-int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr,
- struct ibv_query_port *cmd, size_t cmd_size)
+int rdmav_cmd_query_port(struct rdmav_context *context, uint8_t port_num,
+ struct rdmav_port_attr *port_attr,
+ struct rdmav_query_port *cmd, size_t cmd_size)
{
- struct ibv_query_port_resp resp;
+ struct rdmav_query_port_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_PORT, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, QUERY_PORT, &resp, sizeof resp);
cmd->port_num = port_num;
if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
@@ -191,11 +194,11 @@ int ibv_cmd_query_port(struct ibv_contex
return 0;
}
-int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd,
- struct ibv_alloc_pd *cmd, size_t cmd_size,
- struct ibv_alloc_pd_resp *resp, size_t resp_size)
+int rdmav_cmd_alloc_pd(struct rdmav_context *context, struct rdmav_pd *pd,
+ struct rdmav_alloc_pd *cmd, size_t cmd_size,
+ struct rdmav_alloc_pd_resp *resp, size_t resp_size)
{
- IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_PD, resp, resp_size);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_PD, resp, resp_size);
if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
return errno;
@@ -205,11 +208,11 @@ int ibv_cmd_alloc_pd(struct ibv_context
return 0;
}
-int ibv_cmd_dealloc_pd(struct ibv_pd *pd)
+int rdmav_cmd_dealloc_pd(struct rdmav_pd *pd)
{
- struct ibv_dealloc_pd cmd;
+ struct rdmav_dealloc_pd cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DEALLOC_PD);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, DEALLOC_PD);
cmd.pd_handle = pd->handle;
if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -218,14 +221,14 @@ int ibv_cmd_dealloc_pd(struct ibv_pd *pd
return 0;
}
-int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
- uint64_t hca_va, enum ibv_access_flags access,
- struct ibv_mr *mr, struct ibv_reg_mr *cmd,
+int rdmav_cmd_reg_mr(struct rdmav_pd *pd, void *addr, size_t length,
+ uint64_t hca_va, enum rdmav_access_flags access,
+ struct rdmav_mr *mr, struct rdmav_reg_mr *cmd,
size_t cmd_size)
{
- struct ibv_reg_mr_resp resp;
+ struct rdmav_reg_mr_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, REG_MR, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, REG_MR, &resp, sizeof resp);
cmd->start = (uintptr_t) addr;
cmd->length = length;
@@ -243,11 +246,11 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, vo
return 0;
}
-int ibv_cmd_dereg_mr(struct ibv_mr *mr)
+int rdmav_cmd_dereg_mr(struct rdmav_mr *mr)
{
- struct ibv_dereg_mr cmd;
+ struct rdmav_dereg_mr cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DEREG_MR);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, DEREG_MR);
cmd.mr_handle = mr->handle;
if (write(mr->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -256,19 +259,22 @@ int ibv_cmd_dereg_mr(struct ibv_mr *mr)
return 0;
}
-static int ibv_cmd_create_cq_v2(struct ibv_context *context, int cqe,
- struct ibv_cq *cq,
- struct ibv_create_cq *new_cmd, size_t new_cmd_size,
- struct ibv_create_cq_resp *resp, size_t resp_size)
+static int rdmav_cmd_create_cq_v2(struct rdmav_context *context, int cqe,
+ struct rdmav_cq *cq,
+ struct rdmav_create_cq *new_cmd,
+ size_t new_cmd_size,
+ struct rdmav_create_cq_resp *resp,
+ size_t resp_size)
{
- struct ibv_create_cq_v2 *cmd;
+ struct rdmav_create_cq_v2 *cmd;
size_t cmd_size;
cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd;
cmd = alloca(cmd_size);
- memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd);
+ memcpy(cmd->driver_data, new_cmd->driver_data,
+ new_cmd_size - sizeof *new_cmd);
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size);
cmd->user_handle = (uintptr_t) cq;
cmd->cqe = cqe;
cmd->event_handler = 0;
@@ -282,17 +288,17 @@ static int ibv_cmd_create_cq_v2(struct i
return 0;
}
-int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector, struct ibv_cq *cq,
- struct ibv_create_cq *cmd, size_t cmd_size,
- struct ibv_create_cq_resp *resp, size_t resp_size)
+int rdmav_cmd_create_cq(struct rdmav_context *context, int cqe,
+ struct rdmav_comp_channel *channel,
+ int comp_vector, struct rdmav_cq *cq,
+ struct rdmav_create_cq *cmd, size_t cmd_size,
+ struct rdmav_create_cq_resp *resp, size_t resp_size)
{
if (abi_ver <= 2)
- return ibv_cmd_create_cq_v2(context, cqe, cq,
+ return rdmav_cmd_create_cq_v2(context, cqe, cq,
cmd, cmd_size, resp, resp_size);
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size);
cmd->user_handle = (uintptr_t) cq;
cmd->cqe = cqe;
cmd->comp_vector = comp_vector;
@@ -308,20 +314,20 @@ int ibv_cmd_create_cq(struct ibv_context
return 0;
}
-int ibv_cmd_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
+int rdmav_cmd_poll_cq(struct rdmav_cq *ibcq, int ne, struct rdmav_wc *wc)
{
- struct ibv_poll_cq cmd;
- struct ibv_poll_cq_resp *resp;
+ struct rdmav_poll_cq cmd;
+ struct rdmav_poll_cq_resp *resp;
int i;
int rsize;
int ret;
- rsize = sizeof *resp + ne * sizeof(struct ibv_kern_wc);
+ rsize = sizeof *resp + ne * sizeof(struct rdmav_kern_wc);
resp = malloc(rsize);
if (!resp)
return -1;
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, POLL_CQ, resp, rsize);
+ RDMAV_INIT_CMD_RESP(&cmd, sizeof cmd, POLL_CQ, resp, rsize);
cmd.cq_handle = ibcq->handle;
cmd.ne = ne;
@@ -353,11 +359,11 @@ out:
return ret;
}
-int ibv_cmd_req_notify_cq(struct ibv_cq *ibcq, int solicited_only)
+int rdmav_cmd_req_notify_cq(struct rdmav_cq *ibcq, int solicited_only)
{
- struct ibv_req_notify_cq cmd;
+ struct rdmav_req_notify_cq cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, REQ_NOTIFY_CQ);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, REQ_NOTIFY_CQ);
cmd.cq_handle = ibcq->handle;
cmd.solicited = !!solicited_only;
@@ -367,12 +373,12 @@ int ibv_cmd_req_notify_cq(struct ibv_cq
return 0;
}
-int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
- struct ibv_resize_cq *cmd, size_t cmd_size)
+int rdmav_cmd_resize_cq(struct rdmav_cq *cq, int cqe,
+ struct rdmav_resize_cq *cmd, size_t cmd_size)
{
- struct ibv_resize_cq_resp resp;
+ struct rdmav_resize_cq_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, &resp, sizeof resp);
cmd->cq_handle = cq->handle;
cmd->cqe = cqe;
@@ -384,11 +390,11 @@ int ibv_cmd_resize_cq(struct ibv_cq *cq,
return 0;
}
-static int ibv_cmd_destroy_cq_v1(struct ibv_cq *cq)
+static int rdmav_cmd_destroy_cq_v1(struct rdmav_cq *cq)
{
- struct ibv_destroy_cq_v1 cmd;
+ struct rdmav_destroy_cq_v1 cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_CQ);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, DESTROY_CQ);
cmd.cq_handle = cq->handle;
if (write(cq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -397,15 +403,15 @@ static int ibv_cmd_destroy_cq_v1(struct
return 0;
}
-int ibv_cmd_destroy_cq(struct ibv_cq *cq)
+int rdmav_cmd_destroy_cq(struct rdmav_cq *cq)
{
- struct ibv_destroy_cq cmd;
- struct ibv_destroy_cq_resp resp;
+ struct rdmav_destroy_cq cmd;
+ struct rdmav_destroy_cq_resp resp;
if (abi_ver == 1)
- return ibv_cmd_destroy_cq_v1(cq);
+ return rdmav_cmd_destroy_cq_v1(cq);
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_CQ, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_CQ, &resp, sizeof resp);
cmd.cq_handle = cq->handle;
if (write(cq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -420,12 +426,12 @@ int ibv_cmd_destroy_cq(struct ibv_cq *cq
return 0;
}
-int ibv_cmd_create_srq(struct ibv_pd *pd,
- struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
- struct ibv_create_srq *cmd, size_t cmd_size,
- struct ibv_create_srq_resp *resp, size_t resp_size)
+int rdmav_cmd_create_srq(struct rdmav_pd *pd,
+ struct rdmav_srq *srq, struct rdmav_srq_init_attr *attr,
+ struct rdmav_create_srq *cmd, size_t cmd_size,
+ struct rdmav_create_srq_resp *resp, size_t resp_size)
{
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_SRQ, resp, resp_size);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, CREATE_SRQ, resp, resp_size);
cmd->user_handle = (uintptr_t) srq;
cmd->pd_handle = pd->handle;
cmd->max_wr = attr->attr.max_wr;
@@ -441,8 +447,8 @@ int ibv_cmd_create_srq(struct ibv_pd *pd
attr->attr.max_wr = resp->max_wr;
attr->attr.max_sge = resp->max_sge;
} else {
- struct ibv_create_srq_resp_v5 *resp_v5 =
- (struct ibv_create_srq_resp_v5 *) resp;
+ struct rdmav_create_srq_resp_v5 *resp_v5 =
+ (struct rdmav_create_srq_resp_v5 *) resp;
memmove((void *) resp + sizeof *resp,
(void *) resp_v5 + sizeof *resp_v5,
@@ -452,20 +458,21 @@ int ibv_cmd_create_srq(struct ibv_pd *pd
return 0;
}
-static int ibv_cmd_modify_srq_v3(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- enum ibv_srq_attr_mask srq_attr_mask,
- struct ibv_modify_srq *new_cmd,
+static int rdmav_cmd_modify_srq_v3(struct rdmav_srq *srq,
+ struct rdmav_srq_attr *srq_attr,
+ enum rdmav_srq_attr_mask srq_attr_mask,
+ struct rdmav_modify_srq *new_cmd,
size_t new_cmd_size)
{
- struct ibv_modify_srq_v3 *cmd;
+ struct rdmav_modify_srq_v3 *cmd;
size_t cmd_size;
cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd;
cmd = alloca(cmd_size);
- memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd);
+ memcpy(cmd->driver_data, new_cmd->driver_data,
+ new_cmd_size - sizeof *new_cmd);
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
+ RDMAV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
cmd->srq_handle = srq->handle;
cmd->attr_mask = srq_attr_mask;
@@ -480,16 +487,16 @@ static int ibv_cmd_modify_srq_v3(struct
return 0;
}
-int ibv_cmd_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- enum ibv_srq_attr_mask srq_attr_mask,
- struct ibv_modify_srq *cmd, size_t cmd_size)
+int rdmav_cmd_modify_srq(struct rdmav_srq *srq,
+ struct rdmav_srq_attr *srq_attr,
+ enum rdmav_srq_attr_mask srq_attr_mask,
+ struct rdmav_modify_srq *cmd, size_t cmd_size)
{
if (abi_ver == 3)
- return ibv_cmd_modify_srq_v3(srq, srq_attr, srq_attr_mask,
+ return rdmav_cmd_modify_srq_v3(srq, srq_attr, srq_attr_mask,
cmd, cmd_size);
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
+ RDMAV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
cmd->srq_handle = srq->handle;
cmd->attr_mask = srq_attr_mask;
@@ -502,12 +509,12 @@ int ibv_cmd_modify_srq(struct ibv_srq *s
return 0;
}
-int ibv_cmd_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr,
- struct ibv_query_srq *cmd, size_t cmd_size)
+int rdmav_cmd_query_srq(struct rdmav_srq *srq, struct rdmav_srq_attr *srq_attr,
+ struct rdmav_query_srq *cmd, size_t cmd_size)
{
- struct ibv_query_srq_resp resp;
+ struct rdmav_query_srq_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_SRQ, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, QUERY_SRQ, &resp, sizeof resp);
cmd->srq_handle = srq->handle;
if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
@@ -520,11 +527,11 @@ int ibv_cmd_query_srq(struct ibv_srq *sr
return 0;
}
-static int ibv_cmd_destroy_srq_v1(struct ibv_srq *srq)
+static int rdmav_cmd_destroy_srq_v1(struct rdmav_srq *srq)
{
- struct ibv_destroy_srq_v1 cmd;
+ struct rdmav_destroy_srq_v1 cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_SRQ);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, DESTROY_SRQ);
cmd.srq_handle = srq->handle;
if (write(srq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -533,15 +540,15 @@ static int ibv_cmd_destroy_srq_v1(struct
return 0;
}
-int ibv_cmd_destroy_srq(struct ibv_srq *srq)
+int rdmav_cmd_destroy_srq(struct rdmav_srq *srq)
{
- struct ibv_destroy_srq cmd;
- struct ibv_destroy_srq_resp resp;
+ struct rdmav_destroy_srq cmd;
+ struct rdmav_destroy_srq_resp resp;
if (abi_ver == 1)
- return ibv_cmd_destroy_srq_v1(srq);
+ return rdmav_cmd_destroy_srq_v1(srq);
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_SRQ, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_SRQ, &resp, sizeof resp);
cmd.srq_handle = srq->handle;
if (write(srq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -555,12 +562,12 @@ int ibv_cmd_destroy_srq(struct ibv_srq *
return 0;
}
-int ibv_cmd_create_qp(struct ibv_pd *pd,
- struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
- struct ibv_create_qp *cmd, size_t cmd_size,
- struct ibv_create_qp_resp *resp, size_t resp_size)
+int rdmav_cmd_create_qp(struct rdmav_pd *pd,
+ struct rdmav_qp *qp, struct rdmav_qp_init_attr *attr,
+ struct rdmav_create_qp *cmd, size_t cmd_size,
+ struct rdmav_create_qp_resp *resp, size_t resp_size)
{
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
cmd->user_handle = (uintptr_t) qp;
cmd->pd_handle = pd->handle;
@@ -591,15 +598,15 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
}
if (abi_ver == 4) {
- struct ibv_create_qp_resp_v4 *resp_v4 =
- (struct ibv_create_qp_resp_v4 *) resp;
+ struct rdmav_create_qp_resp_v4 *resp_v4 =
+ (struct rdmav_create_qp_resp_v4 *) resp;
memmove((void *) resp + sizeof *resp,
(void *) resp_v4 + sizeof *resp_v4,
resp_size - sizeof *resp);
} else if (abi_ver <= 3) {
- struct ibv_create_qp_resp_v3 *resp_v3 =
- (struct ibv_create_qp_resp_v3 *) resp;
+ struct rdmav_create_qp_resp_v3 *resp_v3 =
+ (struct rdmav_create_qp_resp_v3 *) resp;
memmove((void *) resp + sizeof *resp,
(void *) resp_v3 + sizeof *resp_v3,
@@ -609,14 +616,14 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
return 0;
}
-int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_qp_init_attr *init_attr,
- struct ibv_query_qp *cmd, size_t cmd_size)
+int rdmav_cmd_query_qp(struct rdmav_qp *qp, struct rdmav_qp_attr *attr,
+ enum rdmav_qp_attr_mask attr_mask,
+ struct rdmav_qp_init_attr *init_attr,
+ struct rdmav_query_qp *cmd, size_t cmd_size)
{
- struct ibv_query_qp_resp resp;
+ struct rdmav_query_qp_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp);
cmd->qp_handle = qp->handle;
cmd->attr_mask = attr_mask;
@@ -689,11 +696,11 @@ int ibv_cmd_query_qp(struct ibv_qp *qp,
return 0;
}
-int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_modify_qp *cmd, size_t cmd_size)
+int rdmav_cmd_modify_qp(struct rdmav_qp *qp, struct rdmav_qp_attr *attr,
+ enum rdmav_qp_attr_mask attr_mask,
+ struct rdmav_modify_qp *cmd, size_t cmd_size)
{
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_QP);
+ RDMAV_INIT_CMD(cmd, cmd_size, MODIFY_QP);
cmd->qp_handle = qp->handle;
cmd->attr_mask = attr_mask;
@@ -749,11 +756,11 @@ int ibv_cmd_modify_qp(struct ibv_qp *qp,
return 0;
}
-static int ibv_cmd_destroy_qp_v1(struct ibv_qp *qp)
+static int rdmav_cmd_destroy_qp_v1(struct rdmav_qp *qp)
{
- struct ibv_destroy_qp_v1 cmd;
+ struct rdmav_destroy_qp_v1 cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_QP);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, DESTROY_QP);
cmd.qp_handle = qp->handle;
if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -762,14 +769,14 @@ static int ibv_cmd_destroy_qp_v1(struct
return 0;
}
-int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr)
+int rdmav_cmd_post_send(struct rdmav_qp *ibqp, struct rdmav_send_wr *wr,
+ struct rdmav_send_wr **bad_wr)
{
- struct ibv_post_send *cmd;
- struct ibv_post_send_resp resp;
- struct ibv_send_wr *i;
- struct ibv_kern_send_wr *n, *tmp;
- struct ibv_sge *s;
+ struct rdmav_post_send *cmd;
+ struct rdmav_post_send_resp resp;
+ struct rdmav_send_wr *i;
+ struct rdmav_kern_send_wr *n, *tmp;
+ struct rdmav_sge *s;
unsigned wr_count = 0;
unsigned sge_count = 0;
int cmd_size;
@@ -783,14 +790,14 @@ int ibv_cmd_post_send(struct ibv_qp *ibq
cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
cmd = alloca(cmd_size);
- IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SEND, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, POST_SEND, &resp, sizeof resp);
cmd->qp_handle = ibqp->handle;
cmd->wr_count = wr_count;
cmd->sge_count = sge_count;
cmd->wqe_size = sizeof *n;
- n = (struct ibv_kern_send_wr *) ((void *) cmd + sizeof *cmd);
- s = (struct ibv_sge *) (n + wr_count);
+ n = (struct rdmav_kern_send_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct rdmav_sge *) (n + wr_count);
tmp = n;
for (i = wr; i; i = i->next) {
@@ -799,21 +806,21 @@ int ibv_cmd_post_send(struct ibv_qp *ibq
tmp->opcode = i->opcode;
tmp->send_flags = i->send_flags;
tmp->imm_data = i->imm_data;
- if (ibqp->qp_type == IBV_QPT_UD) {
+ if (ibqp->qp_type == RDMAV_QPT_UD) {
tmp->wr.ud.ah = i->wr.ud.ah->handle;
tmp->wr.ud.remote_qpn = i->wr.ud.remote_qpn;
tmp->wr.ud.remote_qkey = i->wr.ud.remote_qkey;
} else {
switch(i->opcode) {
- case IBV_WR_RDMA_WRITE:
- case IBV_WR_RDMA_WRITE_WITH_IMM:
- case IBV_WR_RDMA_READ:
+ case RDMAV_WR_RDMA_WRITE:
+ case RDMAV_WR_RDMA_WRITE_WITH_IMM:
+ case RDMAV_WR_RDMA_READ:
tmp->wr.rdma.remote_addr =
i->wr.rdma.remote_addr;
tmp->wr.rdma.rkey = i->wr.rdma.rkey;
break;
- case IBV_WR_ATOMIC_CMP_AND_SWP:
- case IBV_WR_ATOMIC_FETCH_AND_ADD:
+ case RDMAV_WR_ATOMIC_CMP_AND_SWP:
+ case RDMAV_WR_ATOMIC_FETCH_AND_ADD:
tmp->wr.atomic.remote_addr =
i->wr.atomic.remote_addr;
tmp->wr.atomic.compare_add =
@@ -849,14 +856,14 @@ int ibv_cmd_post_send(struct ibv_qp *ibq
return ret;
}
-int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
+int rdmav_cmd_post_recv(struct rdmav_qp *ibqp, struct rdmav_recv_wr *wr,
+ struct rdmav_recv_wr **bad_wr)
{
- struct ibv_post_recv *cmd;
- struct ibv_post_recv_resp resp;
- struct ibv_recv_wr *i;
- struct ibv_kern_recv_wr *n, *tmp;
- struct ibv_sge *s;
+ struct rdmav_post_recv *cmd;
+ struct rdmav_post_recv_resp resp;
+ struct rdmav_recv_wr *i;
+ struct rdmav_kern_recv_wr *n, *tmp;
+ struct rdmav_sge *s;
unsigned wr_count = 0;
unsigned sge_count = 0;
int cmd_size;
@@ -870,14 +877,14 @@ int ibv_cmd_post_recv(struct ibv_qp *ibq
cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
cmd = alloca(cmd_size);
- IBV_INIT_CMD_RESP(cmd, cmd_size, POST_RECV, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, POST_RECV, &resp, sizeof resp);
cmd->qp_handle = ibqp->handle;
cmd->wr_count = wr_count;
cmd->sge_count = sge_count;
cmd->wqe_size = sizeof *n;
- n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
- s = (struct ibv_sge *) (n + wr_count);
+ n = (struct rdmav_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct rdmav_sge *) (n + wr_count);
tmp = n;
for (i = wr; i; i = i->next) {
@@ -907,14 +914,14 @@ int ibv_cmd_post_recv(struct ibv_qp *ibq
return ret;
}
-int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
+int rdmav_cmd_post_srq_recv(struct rdmav_srq *srq, struct rdmav_recv_wr *wr,
+ struct rdmav_recv_wr **bad_wr)
{
- struct ibv_post_srq_recv *cmd;
- struct ibv_post_srq_recv_resp resp;
- struct ibv_recv_wr *i;
- struct ibv_kern_recv_wr *n, *tmp;
- struct ibv_sge *s;
+ struct rdmav_post_srq_recv *cmd;
+ struct rdmav_post_srq_recv_resp resp;
+ struct rdmav_recv_wr *i;
+ struct rdmav_kern_recv_wr *n, *tmp;
+ struct rdmav_sge *s;
unsigned wr_count = 0;
unsigned sge_count = 0;
int cmd_size;
@@ -928,14 +935,14 @@ int ibv_cmd_post_srq_recv(struct ibv_srq
cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
cmd = alloca(cmd_size);
- IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SRQ_RECV, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(cmd, cmd_size, POST_SRQ_RECV, &resp, sizeof resp);
cmd->srq_handle = srq->handle;
cmd->wr_count = wr_count;
cmd->sge_count = sge_count;
cmd->wqe_size = sizeof *n;
- n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
- s = (struct ibv_sge *) (n + wr_count);
+ n = (struct rdmav_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct rdmav_sge *) (n + wr_count);
tmp = n;
for (i = wr; i; i = i->next) {
@@ -965,13 +972,13 @@ int ibv_cmd_post_srq_recv(struct ibv_srq
return ret;
}
-int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah,
- struct ibv_ah_attr *attr)
+int rdmav_cmd_create_ah(struct rdmav_pd *pd, struct rdmav_ah *ah,
+ struct rdmav_ah_attr *attr)
{
- struct ibv_create_ah cmd;
- struct ibv_create_ah_resp resp;
+ struct rdmav_create_ah cmd;
+ struct rdmav_create_ah_resp resp;
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_AH, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_AH, &resp, sizeof resp);
cmd.user_handle = (uintptr_t) ah;
cmd.pd_handle = pd->handle;
cmd.attr.dlid = attr->dlid;
@@ -994,11 +1001,11 @@ int ibv_cmd_create_ah(struct ibv_pd *pd,
return 0;
}
-int ibv_cmd_destroy_ah(struct ibv_ah *ah)
+int rdmav_cmd_destroy_ah(struct rdmav_ah *ah)
{
- struct ibv_destroy_ah cmd;
+ struct rdmav_destroy_ah cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_AH);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, DESTROY_AH);
cmd.ah_handle = ah->handle;
if (write(ah->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -1007,15 +1014,15 @@ int ibv_cmd_destroy_ah(struct ibv_ah *ah
return 0;
}
-int ibv_cmd_destroy_qp(struct ibv_qp *qp)
+int rdmav_cmd_destroy_qp(struct rdmav_qp *qp)
{
- struct ibv_destroy_qp cmd;
- struct ibv_destroy_qp_resp resp;
+ struct rdmav_destroy_qp cmd;
+ struct rdmav_destroy_qp_resp resp;
if (abi_ver == 1)
- return ibv_cmd_destroy_qp_v1(qp);
+ return rdmav_cmd_destroy_qp_v1(qp);
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_QP, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_QP, &resp, sizeof resp);
cmd.qp_handle = qp->handle;
if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
@@ -1029,11 +1036,11 @@ int ibv_cmd_destroy_qp(struct ibv_qp *qp
return 0;
}
-int ibv_cmd_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int rdmav_cmd_attach_mcast(struct rdmav_qp *qp, union rdmav_gid *gid, uint16_t lid)
{
- struct ibv_attach_mcast cmd;
+ struct rdmav_attach_mcast cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, ATTACH_MCAST);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, ATTACH_MCAST);
memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
cmd.qp_handle = qp->handle;
cmd.mlid = lid;
@@ -1044,11 +1051,11 @@ int ibv_cmd_attach_mcast(struct ibv_qp *
return 0;
}
-int ibv_cmd_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int rdmav_cmd_detach_mcast(struct rdmav_qp *qp, union rdmav_gid *gid, uint16_t lid)
{
- struct ibv_detach_mcast cmd;
+ struct rdmav_detach_mcast cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DETACH_MCAST);
+ RDMAV_INIT_CMD(&cmd, sizeof cmd, DETACH_MCAST);
memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
cmd.qp_handle = qp->handle;
cmd.mlid = lid;
diff -ruNp ORG/libibverbs/src/device.c NEW/libibverbs/src/device.c
--- ORG/libibverbs/src/device.c 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/device.c 2006-08-02 23:57:31.000000000 -0700
@@ -48,23 +48,23 @@
#include <infiniband/arch.h>
-#include "ibverbs.h"
+#include "rdmaverbs.h"
static pthread_mutex_t device_list_lock = PTHREAD_MUTEX_INITIALIZER;
static int num_devices;
-static struct ibv_device **device_list;
+static struct rdmav_device **device_list;
-struct ibv_device **ibv_get_device_list(int *num)
+struct rdmav_device **rdmav_get_device_list(int *num)
{
- struct ibv_device **l;
+ struct rdmav_device **l;
int i;
pthread_mutex_lock(&device_list_lock);
if (!num_devices)
- num_devices = ibverbs_init(&device_list);
+ num_devices = rdmaverbs_init(&device_list);
- l = calloc(num_devices + 1, sizeof (struct ibv_device *));
+ l = calloc(num_devices + 1, sizeof (struct rdmav_device *));
for (i = 0; i < num_devices; ++i)
l[i] = device_list[i];
@@ -76,24 +76,30 @@ struct ibv_device **ibv_get_device_list(
return l;
}
-void ibv_free_device_list(struct ibv_device **list)
+/* XXX - to be removed when all apps are converted to new API */
+struct rdmav_device **ibv_get_device_list(int *num)
+{
+ return rdmav_get_device_list(num);
+}
+
+void rdmav_free_device_list(struct rdmav_device **list)
{
free(list);
}
-const char *ibv_get_device_name(struct ibv_device *device)
+const char *rdmav_get_device_name(struct rdmav_device *device)
{
return device->name;
}
-uint64_t ibv_get_device_guid(struct ibv_device *device)
+uint64_t rdmav_get_device_guid(struct rdmav_device *device)
{
char attr[24];
uint64_t guid = 0;
uint16_t parts[4];
int i;
- if (ibv_read_sysfs_file(device->ibdev_path, "node_guid",
+ if (rdmav_read_sysfs_file(device->ibdev_path, "node_guid",
attr, sizeof attr) < 0)
return 0;
@@ -107,11 +113,11 @@ uint64_t ibv_get_device_guid(struct ibv_
return htonll(guid);
}
-struct ibv_context *ibv_open_device(struct ibv_device *device)
+struct rdmav_context *rdmav_open_device(struct rdmav_device *device)
{
char *devpath;
int cmd_fd;
- struct ibv_context *context;
+ struct rdmav_context *context;
asprintf(&devpath, "/dev/infiniband/%s", device->dev_name);
@@ -140,14 +146,14 @@ err:
return NULL;
}
-int ibv_close_device(struct ibv_context *context)
+int rdmav_close_device(struct rdmav_context *context)
{
int async_fd = context->async_fd;
int cmd_fd = context->cmd_fd;
int cq_fd = -1;
if (abi_ver <= 2) {
- struct ibv_abi_compat_v2 *t = context->abi_compat;
+ struct rdmav_abi_compat_v2 *t = context->abi_compat;
cq_fd = t->channel.fd;
free(context->abi_compat);
}
@@ -162,10 +168,10 @@ int ibv_close_device(struct ibv_context
return 0;
}
-int ibv_get_async_event(struct ibv_context *context,
- struct ibv_async_event *event)
+int rdmav_get_async_event(struct rdmav_context *context,
+ struct rdmav_async_event *event)
{
- struct ibv_kern_async_event ev;
+ struct rdmav_kern_async_event ev;
if (read(context->async_fd, &ev, sizeof ev) != sizeof ev)
return -1;
@@ -173,23 +179,23 @@ int ibv_get_async_event(struct ibv_conte
event->event_type = ev.event_type;
switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
+ case RDMAV_EVENT_CQ_ERR:
event->element.cq = (void *) (uintptr_t) ev.element;
break;
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_COMM_EST:
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
+ case RDMAV_EVENT_QP_FATAL:
+ case RDMAV_EVENT_QP_REQ_ERR:
+ case RDMAV_EVENT_QP_ACCESS_ERR:
+ case RDMAV_EVENT_COMM_EST:
+ case RDMAV_EVENT_SQ_DRAINED:
+ case RDMAV_EVENT_PATH_MIG:
+ case RDMAV_EVENT_PATH_MIG_ERR:
+ case RDMAV_EVENT_QP_LAST_WQE_REACHED:
event->element.qp = (void *) (uintptr_t) ev.element;
break;
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
+ case RDMAV_EVENT_SRQ_ERR:
+ case RDMAV_EVENT_SRQ_LIMIT_REACHED:
event->element.srq = (void *) (uintptr_t) ev.element;
break;
@@ -201,12 +207,12 @@ int ibv_get_async_event(struct ibv_conte
return 0;
}
-void ibv_ack_async_event(struct ibv_async_event *event)
+void rdmav_ack_async_event(struct rdmav_async_event *event)
{
switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
+ case RDMAV_EVENT_CQ_ERR:
{
- struct ibv_cq *cq = event->element.cq;
+ struct rdmav_cq *cq = event->element.cq;
pthread_mutex_lock(&cq->mutex);
++cq->async_events_completed;
@@ -216,16 +222,16 @@ void ibv_ack_async_event(struct ibv_asyn
return;
}
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_COMM_EST:
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
+ case RDMAV_EVENT_QP_FATAL:
+ case RDMAV_EVENT_QP_REQ_ERR:
+ case RDMAV_EVENT_QP_ACCESS_ERR:
+ case RDMAV_EVENT_COMM_EST:
+ case RDMAV_EVENT_SQ_DRAINED:
+ case RDMAV_EVENT_PATH_MIG:
+ case RDMAV_EVENT_PATH_MIG_ERR:
+ case RDMAV_EVENT_QP_LAST_WQE_REACHED:
{
- struct ibv_qp *qp = event->element.qp;
+ struct rdmav_qp *qp = event->element.qp;
pthread_mutex_lock(&qp->mutex);
++qp->events_completed;
@@ -235,10 +241,10 @@ void ibv_ack_async_event(struct ibv_asyn
return;
}
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
+ case RDMAV_EVENT_SRQ_ERR:
+ case RDMAV_EVENT_SRQ_LIMIT_REACHED:
{
- struct ibv_srq *srq = event->element.srq;
+ struct rdmav_srq *srq = event->element.srq;
pthread_mutex_lock(&srq->mutex);
++srq->events_completed;
diff -ruNp ORG/libibverbs/src/ibverbs.h NEW/libibverbs/src/ibverbs.h
--- ORG/libibverbs/src/ibverbs.h 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/ibverbs.h 1969-12-31 16:00:00.000000000 -0800
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id: ibverbs.h 4466 2005-12-14 20:44:36Z roland $
- */
-
-#ifndef IB_VERBS_H
-#define IB_VERBS_H
-
-#include <pthread.h>
-
-#include <infiniband/driver.h>
-
-#define HIDDEN __attribute__((visibility ("hidden")))
-
-#define INIT __attribute__((constructor))
-#define FINI __attribute__((destructor))
-
-#define PFX "libibverbs: "
-
-struct ibv_driver {
- ibv_driver_init_func init_func;
- struct ibv_driver *next;
-};
-
-struct ibv_abi_compat_v2 {
- struct ibv_comp_channel channel;
- pthread_mutex_t in_use;
-};
-
-extern HIDDEN int abi_ver;
-
-extern HIDDEN int ibverbs_init(struct ibv_device ***list);
-
-extern HIDDEN int ibv_init_mem_map(void);
-extern HIDDEN int ibv_lock_range(void *base, size_t size);
-extern HIDDEN int ibv_unlock_range(void *base, size_t size);
-
-#define IBV_INIT_CMD(cmd, size, opcode) \
- do { \
- if (abi_ver > 2) \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
- else \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
- (cmd)->in_words = (size) / 4; \
- (cmd)->out_words = 0; \
- } while (0)
-
-#define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \
- do { \
- if (abi_ver > 2) \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
- else \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
- (cmd)->in_words = (size) / 4; \
- (cmd)->out_words = (outsize) / 4; \
- (cmd)->response = (uintptr_t) (out); \
- } while (0)
-
-#endif /* IB_VERBS_H */
diff -ruNp ORG/libibverbs/src/init.c NEW/libibverbs/src/init.c
--- ORG/libibverbs/src/init.c 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/init.c 2006-08-02 18:24:49.000000000 -0700
@@ -46,24 +46,28 @@
#include <sys/types.h>
#include <dirent.h>
-#include "ibverbs.h"
+#include "rdmaverbs.h"
#ifndef OPENIB_DRIVER_PATH_ENV
# define OPENIB_DRIVER_PATH_ENV "OPENIB_DRIVER_PATH"
#endif
+#ifndef LIBRDMAVERBS_DRIVER_PATH_ENV
+# define LIBRDMAVERBS_DRIVER_PATH_ENV "LIBRDMAVERBS_DRIVER_PATH"
+#endif
+
HIDDEN int abi_ver;
static char default_path[] = DRIVER_PATH;
static const char *user_path;
-static struct ibv_driver *driver_list;
+static struct rdmav_driver *driver_list;
static void load_driver(char *so_path)
{
void *dlhandle;
- ibv_driver_init_func init_func;
- struct ibv_driver *driver;
+ rdmav_driver_init_func init_func;
+ struct rdmav_driver *driver;
dlhandle = dlopen(so_path, RTLD_NOW);
if (!dlhandle) {
@@ -81,7 +85,8 @@ static void load_driver(char *so_path)
driver = malloc(sizeof *driver);
if (!driver) {
- fprintf(stderr, PFX "Fatal: couldn't allocate driver for %s\n", so_path);
+ fprintf(stderr, PFX "Fatal: couldn't allocate driver for %s\n",
+ so_path);
dlclose(dlhandle);
return;
}
@@ -122,23 +127,25 @@ static void find_drivers(char *dir)
globfree(&so_glob);
}
-static struct ibv_device *init_drivers(const char *class_path,
+static struct rdmav_device *init_drivers(const char *class_path,
const char *dev_name)
{
- struct ibv_driver *driver;
- struct ibv_device *dev;
+ struct rdmav_driver *driver;
+ struct rdmav_device *dev;
int abi_ver = 0;
- char sys_path[IBV_SYSFS_PATH_MAX];
- char ibdev_name[IBV_SYSFS_NAME_MAX];
+ char sys_path[RDMAV_SYSFS_PATH_MAX];
+ char ibdev_name[RDMAV_SYSFS_NAME_MAX];
char value[8];
snprintf(sys_path, sizeof sys_path, "%s/%s",
class_path, dev_name);
- if (ibv_read_sysfs_file(sys_path, "abi_version", value, sizeof value) > 0)
+ if (rdmav_read_sysfs_file(sys_path, "abi_version", value,
+ sizeof value) > 0)
abi_ver = strtol(value, NULL, 10);
- if (ibv_read_sysfs_file(sys_path, "ibdev", ibdev_name, sizeof ibdev_name) < 0) {
+ if (rdmav_read_sysfs_file(sys_path, "ibdev", ibdev_name,
+ sizeof ibdev_name) < 0) {
fprintf(stderr, PFX "Warning: no ibdev class attr for %s\n",
sys_path);
return NULL;
@@ -151,8 +158,9 @@ static struct ibv_device *init_drivers(c
dev->driver = driver;
strcpy(dev->dev_path, sys_path);
- snprintf(dev->ibdev_path, IBV_SYSFS_PATH_MAX, "%s/class/infiniband/%s",
- ibv_get_sysfs_path(), ibdev_name);
+ snprintf(dev->ibdev_path, RDMAV_SYSFS_PATH_MAX,
+ "%s/class/infiniband/%s",
+ rdmav_get_sysfs_path(), ibdev_name);
strcpy(dev->dev_name, dev_name);
strcpy(dev->name, ibdev_name);
@@ -172,7 +180,7 @@ static int check_abi_version(const char
{
char value[8];
- if (ibv_read_sysfs_file(path, "class/infiniband_verbs/abi_version",
+ if (rdmav_read_sysfs_file(path, "class/infiniband_verbs/abi_version",
value, sizeof value) < 0) {
fprintf(stderr, PFX "Fatal: couldn't read uverbs ABI version.\n");
return -1;
@@ -180,32 +188,32 @@ static int check_abi_version(const char
abi_ver = strtol(value, NULL, 10);
- if (abi_ver < IB_USER_VERBS_MIN_ABI_VERSION ||
- abi_ver > IB_USER_VERBS_MAX_ABI_VERSION) {
+ if (abi_ver < RDMAV_USER_VERBS_MIN_ABI_VERSION ||
+ abi_ver > RDMAV_USER_VERBS_MAX_ABI_VERSION) {
fprintf(stderr, PFX "Fatal: kernel ABI version %d "
"doesn't match library version %d.\n",
- abi_ver, IB_USER_VERBS_MAX_ABI_VERSION);
+ abi_ver, RDMAV_USER_VERBS_MAX_ABI_VERSION);
return -1;
}
return 0;
}
-HIDDEN int ibverbs_init(struct ibv_device ***list)
+HIDDEN int rdmaverbs_init(struct rdmav_device ***list)
{
const char *sysfs_path;
char *wr_path, *dir;
- char class_path[IBV_SYSFS_PATH_MAX];
+ char class_path[RDMAV_SYSFS_PATH_MAX];
DIR *class_dir;
struct dirent *dent;
- struct ibv_device *device;
- struct ibv_device **new_list;
+ struct rdmav_device *device;
+ struct rdmav_device **new_list;
int num_devices = 0;
int list_size = 0;
*list = NULL;
- if (ibv_init_mem_map())
+ if (rdmav_init_mem_map())
return 0;
find_drivers(default_path);
@@ -215,12 +223,22 @@ HIDDEN int ibverbs_init(struct ibv_devic
* environment if we're not running SUID.
*/
if (getuid() == geteuid()) {
- user_path = getenv(OPENIB_DRIVER_PATH_ENV);
+ const char *user_path_extra;
+
+ user_path = getenv(LIBRDMAVERBS_DRIVER_PATH_ENV);
if (user_path) {
wr_path = strdupa(user_path);
while ((dir = strsep(&wr_path, ";:")))
find_drivers(dir);
}
+
+ /* for backwards compatibility */
+ user_path_extra = getenv(OPENIB_DRIVER_PATH_ENV);
+ if (user_path_extra) {
+ wr_path = strdupa(user_path_extra);
+ while ((dir = strsep(&wr_path, ";:")))
+ find_drivers(dir);
+ }
}
/*
@@ -230,7 +248,7 @@ HIDDEN int ibverbs_init(struct ibv_devic
*/
load_driver(NULL);
- sysfs_path = ibv_get_sysfs_path();
+ sysfs_path = rdmav_get_sysfs_path();
if (!sysfs_path) {
fprintf(stderr, PFX "Fatal: couldn't find sysfs mount.\n");
return 0;
@@ -258,7 +276,7 @@ HIDDEN int ibverbs_init(struct ibv_devic
if (list_size <= num_devices) {
list_size = list_size ? list_size * 2 : 1;
- new_list = realloc(*list, list_size * sizeof (struct ibv_device *));
+ new_list = realloc(*list, list_size * sizeof (struct rdmav_device *));
if (!new_list)
goto out;
*list = new_list;
diff -ruNp ORG/libibverbs/src/libibverbs.map NEW/libibverbs/src/libibverbs.map
--- ORG/libibverbs/src/libibverbs.map 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/libibverbs.map 1969-12-31 16:00:00.000000000 -0800
@@ -1,79 +0,0 @@
-IBVERBS_1.0 {
- global:
- ibv_get_device_list;
- ibv_free_device_list;
- ibv_get_device_name;
- ibv_get_device_guid;
- ibv_open_device;
- ibv_close_device;
- ibv_get_async_event;
- ibv_ack_async_event;
- ibv_query_device;
- ibv_query_port;
- ibv_query_gid;
- ibv_query_pkey;
- ibv_alloc_pd;
- ibv_dealloc_pd;
- ibv_reg_mr;
- ibv_dereg_mr;
- ibv_create_comp_channel;
- ibv_destroy_comp_channel;
- ibv_create_cq;
- ibv_resize_cq;
- ibv_destroy_cq;
- ibv_get_cq_event;
- ibv_ack_cq_events;
- ibv_create_srq;
- ibv_modify_srq;
- ibv_query_srq;
- ibv_destroy_srq;
- ibv_create_qp;
- ibv_query_qp;
- ibv_modify_qp;
- ibv_destroy_qp;
- ibv_create_ah;
- ibv_init_ah_from_wc;
- ibv_create_ah_from_wc;
- ibv_destroy_ah;
- ibv_attach_mcast;
- ibv_detach_mcast;
- ibv_cmd_get_context;
- ibv_cmd_query_device;
- ibv_cmd_query_port;
- ibv_cmd_query_gid;
- ibv_cmd_query_pkey;
- ibv_cmd_alloc_pd;
- ibv_cmd_dealloc_pd;
- ibv_cmd_reg_mr;
- ibv_cmd_dereg_mr;
- ibv_cmd_create_cq;
- ibv_cmd_poll_cq;
- ibv_cmd_req_notify_cq;
- ibv_cmd_resize_cq;
- ibv_cmd_destroy_cq;
- ibv_cmd_create_srq;
- ibv_cmd_modify_srq;
- ibv_cmd_query_srq;
- ibv_cmd_destroy_srq;
- ibv_cmd_create_qp;
- ibv_cmd_query_qp;
- ibv_cmd_modify_qp;
- ibv_cmd_destroy_qp;
- ibv_cmd_post_send;
- ibv_cmd_post_recv;
- ibv_cmd_post_srq_recv;
- ibv_cmd_create_ah;
- ibv_cmd_destroy_ah;
- ibv_cmd_attach_mcast;
- ibv_cmd_detach_mcast;
- ibv_copy_qp_attr_from_kern;
- ibv_copy_ah_attr_from_kern;
- ibv_copy_path_rec_from_kern;
- ibv_copy_path_rec_to_kern;
- ibv_rate_to_mult;
- mult_to_ibv_rate;
- ibv_get_sysfs_path;
- ibv_read_sysfs_file;
-
- local: *;
-};
diff -ruNp ORG/libibverbs/src/librdmaverbs.map NEW/libibverbs/src/librdmaverbs.map
--- ORG/libibverbs/src/librdmaverbs.map 1969-12-31 16:00:00.000000000 -0800
+++ NEW/libibverbs/src/librdmaverbs.map 2006-08-02 23:50:50.000000000 -0700
@@ -0,0 +1,80 @@
+RDMAVERBS_1.0 {
+ global:
+ ibv_get_device_list;
+ rdmav_get_device_list;
+ rdmav_free_device_list;
+ rdmav_get_device_name;
+ rdmav_get_device_guid;
+ rdmav_open_device;
+ rdmav_close_device;
+ rdmav_get_async_event;
+ rdmav_ack_async_event;
+ rdmav_query_device;
+ rdmav_query_port;
+ rdmav_query_gid;
+ rdmav_query_pkey;
+ rdmav_alloc_pd;
+ rdmav_dealloc_pd;
+ rdmav_reg_mr;
+ rdmav_dereg_mr;
+ rdmav_create_comp_channel;
+ rdmav_destroy_comp_channel;
+ rdmav_create_cq;
+ rdmav_resize_cq;
+ rdmav_destroy_cq;
+ rdmav_get_cq_event;
+ rdmav_ack_cq_events;
+ rdmav_create_srq;
+ rdmav_modify_srq;
+ rdmav_query_srq;
+ rdmav_destroy_srq;
+ rdmav_create_qp;
+ rdmav_query_qp;
+ rdmav_modify_qp;
+ rdmav_destroy_qp;
+ rdmav_create_ah;
+ rdmav_init_ah_from_wc;
+ rdmav_create_ah_from_wc;
+ rdmav_destroy_ah;
+ rdmav_attach_mcast;
+ rdmav_detach_mcast;
+ rdmav_cmd_get_context;
+ rdmav_cmd_query_device;
+ rdmav_cmd_query_port;
+ rdmav_cmd_query_gid;
+ rdmav_cmd_query_pkey;
+ rdmav_cmd_alloc_pd;
+ rdmav_cmd_dealloc_pd;
+ rdmav_cmd_reg_mr;
+ rdmav_cmd_dereg_mr;
+ rdmav_cmd_create_cq;
+ rdmav_cmd_poll_cq;
+ rdmav_cmd_req_notify_cq;
+ rdmav_cmd_resize_cq;
+ rdmav_cmd_destroy_cq;
+ rdmav_cmd_create_srq;
+ rdmav_cmd_modify_srq;
+ rdmav_cmd_query_srq;
+ rdmav_cmd_destroy_srq;
+ rdmav_cmd_create_qp;
+ rdmav_cmd_query_qp;
+ rdmav_cmd_modify_qp;
+ rdmav_cmd_destroy_qp;
+ rdmav_cmd_post_send;
+ rdmav_cmd_post_recv;
+ rdmav_cmd_post_srq_recv;
+ rdmav_cmd_create_ah;
+ rdmav_cmd_destroy_ah;
+ rdmav_cmd_attach_mcast;
+ rdmav_cmd_detach_mcast;
+ rdmav_copy_qp_attr_from_kern;
+ rdmav_copy_ah_attr_from_kern;
+ rdmav_copy_path_rec_from_kern;
+ rdmav_copy_path_rec_to_kern;
+ rdmav_rate_to_mult;
+ mult_to_rdmav_rate;
+ rdmav_get_sysfs_path;
+ rdmav_read_sysfs_file;
+
+ local: *;
+};
diff -ruNp ORG/libibverbs/src/marshall.c NEW/libibverbs/src/marshall.c
--- ORG/libibverbs/src/marshall.c 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/marshall.c 2006-08-02 18:24:49.000000000 -0700
@@ -38,8 +38,8 @@
#include <infiniband/marshall.h>
-void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
- struct ibv_kern_ah_attr *src)
+void rdmav_copy_ah_attr_from_kern(struct rdmav_ah_attr *dst,
+ struct rdmav_kern_ah_attr *src)
{
memcpy(dst->grh.dgid.raw, src->grh.dgid, sizeof dst->grh.dgid);
dst->grh.flow_label = src->grh.flow_label;
@@ -55,8 +55,8 @@ void ibv_copy_ah_attr_from_kern(struct i
dst->port_num = src->port_num;
}
-void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
- struct ibv_kern_qp_attr *src)
+void rdmav_copy_qp_attr_from_kern(struct rdmav_qp_attr *dst,
+ struct rdmav_kern_qp_attr *src)
{
dst->cur_qp_state = src->cur_qp_state;
dst->path_mtu = src->path_mtu;
@@ -73,8 +73,8 @@ void ibv_copy_qp_attr_from_kern(struct i
dst->cap.max_recv_sge = src->max_recv_sge;
dst->cap.max_inline_data = src->max_inline_data;
- ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
- ibv_copy_ah_attr_from_kern(&dst->alt_ah_attr, &src->alt_ah_attr);
+ rdmav_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
+ rdmav_copy_ah_attr_from_kern(&dst->alt_ah_attr, &src->alt_ah_attr);
dst->pkey_index = src->pkey_index;
dst->alt_pkey_index = src->alt_pkey_index;
@@ -91,8 +91,8 @@ void ibv_copy_qp_attr_from_kern(struct i
dst->alt_timeout = src->alt_timeout;
}
-void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
- struct ibv_kern_path_rec *src)
+void rdmav_copy_path_rec_from_kern(struct rdmav_sa_path_rec *dst,
+ struct rdmav_kern_path_rec *src)
{
memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
@@ -116,8 +116,8 @@ void ibv_copy_path_rec_from_kern(struct
dst->packet_life_time_selector = src->packet_life_time_selector;
}
-void ibv_copy_path_rec_to_kern(struct ibv_kern_path_rec *dst,
- struct ibv_sa_path_rec *src)
+void rdmav_copy_path_rec_to_kern(struct rdmav_kern_path_rec *dst,
+ struct rdmav_sa_path_rec *src)
{
memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
diff -ruNp ORG/libibverbs/src/memory.c NEW/libibverbs/src/memory.c
--- ORG/libibverbs/src/memory.c 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/memory.c 2006-08-02 18:24:49.000000000 -0700
@@ -41,7 +41,7 @@
#include <stdlib.h>
#include <stdint.h>
-#include "ibverbs.h"
+#include "rdmaverbs.h"
/*
* We keep a linked list of page ranges that have been locked along with a
@@ -51,21 +51,21 @@
* to avoid the O(n) cost of registering/unregistering memory.
*/
-struct ibv_mem_node {
- struct ibv_mem_node *prev, *next;
+struct rdmav_mem_node {
+ struct rdmav_mem_node *prev, *next;
uintptr_t start, end;
int refcnt;
};
static struct {
- struct ibv_mem_node *first;
+ struct rdmav_mem_node *first;
pthread_mutex_t mutex;
uintptr_t page_size;
} mem_map;
-int ibv_init_mem_map(void)
+int rdmav_init_mem_map(void)
{
- struct ibv_mem_node *node = NULL;
+ struct rdmav_mem_node *node = NULL;
node = malloc(sizeof *node);
if (!node)
@@ -94,9 +94,9 @@ fail:
return -1;
}
-static struct ibv_mem_node *__mm_find_first(uintptr_t start, uintptr_t end)
+static struct rdmav_mem_node *__mm_find_first(uintptr_t start, uintptr_t end)
{
- struct ibv_mem_node *node = mem_map.first;
+ struct rdmav_mem_node *node = mem_map.first;
while (node) {
if ((node->start <= start && node->end >= start) ||
@@ -108,18 +108,18 @@ static struct ibv_mem_node *__mm_find_fi
return node;
}
-static struct ibv_mem_node *__mm_prev(struct ibv_mem_node *node)
+static struct rdmav_mem_node *__mm_prev(struct rdmav_mem_node *node)
{
return node->prev;
}
-static struct ibv_mem_node *__mm_next(struct ibv_mem_node *node)
+static struct rdmav_mem_node *__mm_next(struct rdmav_mem_node *node)
{
return node->next;
}
-static void __mm_add(struct ibv_mem_node *node,
- struct ibv_mem_node *new)
+static void __mm_add(struct rdmav_mem_node *node,
+ struct rdmav_mem_node *new)
{
new->prev = node;
new->next = node->next;
@@ -128,7 +128,7 @@ static void __mm_add(struct ibv_mem_node
new->next->prev = new;
}
-static void __mm_remove(struct ibv_mem_node *node)
+static void __mm_remove(struct rdmav_mem_node *node)
{
/* Never have to remove the first node, so we can use prev */
node->prev->next = node->next;
@@ -136,10 +136,10 @@ static void __mm_remove(struct ibv_mem_n
node->next->prev = node->prev;
}
-int ibv_lock_range(void *base, size_t size)
+int rdmav_lock_range(void *base, size_t size)
{
uintptr_t start, end;
- struct ibv_mem_node *node, *tmp;
+ struct rdmav_mem_node *node, *tmp;
int ret = 0;
if (!size)
@@ -202,10 +202,10 @@ out:
return ret;
}
-int ibv_unlock_range(void *base, size_t size)
+int rdmav_unlock_range(void *base, size_t size)
{
uintptr_t start, end;
- struct ibv_mem_node *node, *tmp;
+ struct rdmav_mem_node *node, *tmp;
int ret = 0;
if (!size)
diff -ruNp ORG/libibverbs/src/rdmaverbs.h NEW/libibverbs/src/rdmaverbs.h
--- ORG/libibverbs/src/rdmaverbs.h 1969-12-31 16:00:00.000000000 -0800
+++ NEW/libibverbs/src/rdmaverbs.h 2006-08-03 17:29:42.000000000 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id:
+ */
+
+#ifndef SRC_RDMA_VERBS_H
+#define SRC_RDMA_VERBS_H
+
+#include <pthread.h>
+
+#include <infiniband/driver.h>
+#include <infiniband/deprecate.h>
+
+#define HIDDEN __attribute__((visibility ("hidden")))
+
+#define INIT __attribute__((constructor))
+#define FINI __attribute__((destructor))
+
+#ifndef PFX
+#define PFX "librdmaverbs: "
+#endif
+
+struct rdmav_driver {
+ rdmav_driver_init_func init_func;
+ struct rdmav_driver *next;
+};
+
+struct rdmav_abi_compat_v2 {
+ struct rdmav_comp_channel channel;
+ pthread_mutex_t in_use;
+};
+
+extern HIDDEN int abi_ver;
+
+extern HIDDEN int rdmaverbs_init(struct rdmav_device ***list);
+
+extern HIDDEN int rdmav_init_mem_map(void);
+extern HIDDEN int rdmav_lock_range(void *base, size_t size);
+extern HIDDEN int rdmav_unlock_range(void *base, size_t size);
+
+#define RDMAV_INIT_CMD(cmd, size, opcode) \
+ do { \
+ if (abi_ver > 2) \
+ (cmd)->command = RDMAV_USER_VERBS_CMD_##opcode; \
+ else \
+ (cmd)->command = RDMAV_USER_VERBS_CMD_##opcode##_V2; \
+ (cmd)->in_words = (size) / 4; \
+ (cmd)->out_words = 0; \
+ } while (0)
+
+#define RDMAV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \
+ do { \
+ if (abi_ver > 2) \
+ (cmd)->command = RDMAV_USER_VERBS_CMD_##opcode; \
+ else \
+ (cmd)->command = RDMAV_USER_VERBS_CMD_##opcode##_V2; \
+ (cmd)->in_words = (size) / 4; \
+ (cmd)->out_words = (outsize) / 4; \
+ (cmd)->response = (uintptr_t) (out); \
+ } while (0)
+
+#endif /* SRC_RDMA_VERBS_H */
diff -ruNp ORG/libibverbs/src/sysfs.c NEW/libibverbs/src/sysfs.c
--- ORG/libibverbs/src/sysfs.c 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/sysfs.c 2006-08-02 18:24:49.000000000 -0700
@@ -44,11 +44,11 @@
#include <fcntl.h>
#include <string.h>
-#include "ibverbs.h"
+#include "rdmaverbs.h"
static char *sysfs_path;
-const char *ibv_get_sysfs_path(void)
+const char *rdmav_get_sysfs_path(void)
{
char *env = NULL;
@@ -65,7 +65,7 @@ const char *ibv_get_sysfs_path(void)
if (env) {
int len;
- sysfs_path = strndup(env, IBV_SYSFS_PATH_MAX);
+ sysfs_path = strndup(env, RDMAV_SYSFS_PATH_MAX);
len = strlen(sysfs_path);
while (len > 0 && sysfs_path[len - 1] == '/') {
--len;
@@ -77,7 +77,7 @@ const char *ibv_get_sysfs_path(void)
return sysfs_path;
}
-int ibv_read_sysfs_file(const char *dir, const char *file,
+int rdmav_read_sysfs_file(const char *dir, const char *file,
char *buf, size_t size)
{
char *path;
diff -ruNp ORG/libibverbs/src/verbs.c NEW/libibverbs/src/verbs.c
--- ORG/libibverbs/src/verbs.c 2006-07-30 21:18:16.000000000 -0700
+++ NEW/libibverbs/src/verbs.c 2006-08-02 18:24:49.000000000 -0700
@@ -44,54 +44,54 @@
#include <errno.h>
#include <string.h>
-#include "ibverbs.h"
+#include "rdmaverbs.h"
-int ibv_rate_to_mult(enum ibv_rate rate)
+int rdmav_rate_to_mult(enum rdmav_rate rate)
{
switch (rate) {
- case IBV_RATE_2_5_GBPS: return 1;
- case IBV_RATE_5_GBPS: return 2;
- case IBV_RATE_10_GBPS: return 4;
- case IBV_RATE_20_GBPS: return 8;
- case IBV_RATE_30_GBPS: return 12;
- case IBV_RATE_40_GBPS: return 16;
- case IBV_RATE_60_GBPS: return 24;
- case IBV_RATE_80_GBPS: return 32;
- case IBV_RATE_120_GBPS: return 48;
+ case RDMAV_RATE_2_5_GBPS: return 1;
+ case RDMAV_RATE_5_GBPS: return 2;
+ case RDMAV_RATE_10_GBPS: return 4;
+ case RDMAV_RATE_20_GBPS: return 8;
+ case RDMAV_RATE_30_GBPS: return 12;
+ case RDMAV_RATE_40_GBPS: return 16;
+ case RDMAV_RATE_60_GBPS: return 24;
+ case RDMAV_RATE_80_GBPS: return 32;
+ case RDMAV_RATE_120_GBPS: return 48;
default: return -1;
}
}
-enum ibv_rate mult_to_ibv_rate(int mult)
+enum rdmav_rate mult_to_rdmav_rate(int mult)
{
switch (mult) {
- case 1: return IBV_RATE_2_5_GBPS;
- case 2: return IBV_RATE_5_GBPS;
- case 4: return IBV_RATE_10_GBPS;
- case 8: return IBV_RATE_20_GBPS;
- case 12: return IBV_RATE_30_GBPS;
- case 16: return IBV_RATE_40_GBPS;
- case 24: return IBV_RATE_60_GBPS;
- case 32: return IBV_RATE_80_GBPS;
- case 48: return IBV_RATE_120_GBPS;
- default: return IBV_RATE_MAX;
+ case 1: return RDMAV_RATE_2_5_GBPS;
+ case 2: return RDMAV_RATE_5_GBPS;
+ case 4: return RDMAV_RATE_10_GBPS;
+ case 8: return RDMAV_RATE_20_GBPS;
+ case 12: return RDMAV_RATE_30_GBPS;
+ case 16: return RDMAV_RATE_40_GBPS;
+ case 24: return RDMAV_RATE_60_GBPS;
+ case 32: return RDMAV_RATE_80_GBPS;
+ case 48: return RDMAV_RATE_120_GBPS;
+ default: return RDMAV_RATE_MAX;
}
}
-int ibv_query_device(struct ibv_context *context,
- struct ibv_device_attr *device_attr)
+int rdmav_query_device(struct rdmav_context *context,
+ struct rdmav_device_attr *device_attr)
{
return context->ops.query_device(context, device_attr);
}
-int ibv_query_port(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr)
+int rdmav_query_port(struct rdmav_context *context, uint8_t port_num,
+ struct rdmav_port_attr *port_attr)
{
return context->ops.query_port(context, port_num, port_attr);
}
-int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
- int index, union ibv_gid *gid)
+int rdmav_query_gid(struct rdmav_context *context, uint8_t port_num,
+ int index, union rdmav_gid *gid)
{
char name[24];
char attr[41];
@@ -100,7 +100,7 @@ int ibv_query_gid(struct ibv_context *co
snprintf(name, sizeof name, "ports/%d/gids/%d", port_num, index);
- if (ibv_read_sysfs_file(context->device->ibdev_path, name,
+ if (rdmav_read_sysfs_file(context->device->ibdev_path, name,
attr, sizeof attr) < 0)
return -1;
@@ -114,7 +114,7 @@ int ibv_query_gid(struct ibv_context *co
return 0;
}
-int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
+int rdmav_query_pkey(struct rdmav_context *context, uint8_t port_num,
int index, uint16_t *pkey)
{
char name[24];
@@ -123,7 +123,7 @@ int ibv_query_pkey(struct ibv_context *c
snprintf(name, sizeof name, "ports/%d/pkeys/%d", port_num, index);
- if (ibv_read_sysfs_file(context->device->ibdev_path, name,
+ if (rdmav_read_sysfs_file(context->device->ibdev_path, name,
attr, sizeof attr) < 0)
return -1;
@@ -134,9 +134,9 @@ int ibv_query_pkey(struct ibv_context *c
return 0;
}
-struct ibv_pd *ibv_alloc_pd(struct ibv_context *context)
+struct rdmav_pd *rdmav_alloc_pd(struct rdmav_context *context)
{
- struct ibv_pd *pd;
+ struct rdmav_pd *pd;
pd = context->ops.alloc_pd(context);
if (pd)
@@ -145,15 +145,15 @@ struct ibv_pd *ibv_alloc_pd(struct ibv_c
return pd;
}
-int ibv_dealloc_pd(struct ibv_pd *pd)
+int rdmav_dealloc_pd(struct rdmav_pd *pd)
{
return pd->context->ops.dealloc_pd(pd);
}
-struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, enum ibv_access_flags access)
+struct rdmav_mr *rdmav_reg_mr(struct rdmav_pd *pd, void *addr,
+ size_t length, enum rdmav_access_flags access)
{
- struct ibv_mr *mr;
+ struct rdmav_mr *mr;
mr = pd->context->ops.reg_mr(pd, addr, length, access);
if (mr) {
@@ -164,14 +164,14 @@ struct ibv_mr *ibv_reg_mr(struct ibv_pd
return mr;
}
-int ibv_dereg_mr(struct ibv_mr *mr)
+int rdmav_dereg_mr(struct rdmav_mr *mr)
{
return mr->context->ops.dereg_mr(mr);
}
-static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context)
+static struct rdmav_comp_channel *rdmav_create_comp_channel_v2(struct rdmav_context *context)
{
- struct ibv_abi_compat_v2 *t = context->abi_compat;
+ struct rdmav_abi_compat_v2 *t = context->abi_compat;
static int warned;
if (!pthread_mutex_trylock(&t->in_use))
@@ -187,20 +187,20 @@ static struct ibv_comp_channel *ibv_crea
return NULL;
}
-struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context)
+struct rdmav_comp_channel *rdmav_create_comp_channel(struct rdmav_context *context)
{
- struct ibv_comp_channel *channel;
- struct ibv_create_comp_channel cmd;
- struct ibv_create_comp_channel_resp resp;
+ struct rdmav_comp_channel *channel;
+ struct rdmav_create_comp_channel cmd;
+ struct rdmav_create_comp_channel_resp resp;
if (abi_ver <= 2)
- return ibv_create_comp_channel_v2(context);
+ return rdmav_create_comp_channel_v2(context);
channel = malloc(sizeof *channel);
if (!channel)
return NULL;
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_COMP_CHANNEL, &resp, sizeof resp);
+ RDMAV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_COMP_CHANNEL, &resp, sizeof resp);
if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) {
free(channel);
return NULL;
@@ -211,17 +211,17 @@ struct ibv_comp_channel *ibv_create_comp
return channel;
}
-static int ibv_destroy_comp_channel_v2(struct ibv_comp_channel *channel)
+static int rdmav_destroy_comp_channel_v2(struct rdmav_comp_channel *channel)
{
- struct ibv_abi_compat_v2 *t = (struct ibv_abi_compat_v2 *) channel;
+ struct rdmav_abi_compat_v2 *t = (struct rdmav_abi_compat_v2 *) channel;
pthread_mutex_unlock(&t->in_use);
return 0;
}
-int ibv_destroy_comp_channel(struct ibv_comp_channel *channel)
+int rdmav_destroy_comp_channel(struct rdmav_comp_channel *channel)
{
if (abi_ver <= 2)
- return ibv_destroy_comp_channel_v2(channel);
+ return rdmav_destroy_comp_channel_v2(channel);
close(channel->fd);
free(channel);
@@ -229,10 +229,12 @@ int ibv_destroy_comp_channel(struct ibv_
return 0;
}
-struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe, void *cq_context,
- struct ibv_comp_channel *channel, int comp_vector)
+struct rdmav_cq *rdmav_create_cq(struct rdmav_context *context, int cqe,
+ void *cq_context,
+ struct rdmav_comp_channel *channel,
+ int comp_vector)
{
- struct ibv_cq *cq = context->ops.create_cq(context, cqe, channel,
+ struct rdmav_cq *cq = context->ops.create_cq(context, cqe, channel,
comp_vector);
if (cq) {
@@ -247,7 +249,7 @@ struct ibv_cq *ibv_create_cq(struct ibv_
return cq;
}
-int ibv_resize_cq(struct ibv_cq *cq, int cqe)
+int rdmav_resize_cq(struct rdmav_cq *cq, int cqe)
{
if (!cq->context->ops.resize_cq)
return ENOSYS;
@@ -255,21 +257,20 @@ int ibv_resize_cq(struct ibv_cq *cq, int
return cq->context->ops.resize_cq(cq, cqe);
}
-int ibv_destroy_cq(struct ibv_cq *cq)
+int rdmav_destroy_cq(struct rdmav_cq *cq)
{
return cq->context->ops.destroy_cq(cq);
}
-
-int ibv_get_cq_event(struct ibv_comp_channel *channel,
- struct ibv_cq **cq, void **cq_context)
+int rdmav_get_cq_event(struct rdmav_comp_channel *channel,
+ struct rdmav_cq **cq, void **cq_context)
{
- struct ibv_comp_event ev;
+ struct rdmav_comp_event ev;
if (read(channel->fd, &ev, sizeof ev) != sizeof ev)
return -1;
- *cq = (struct ibv_cq *) (uintptr_t) ev.cq_handle;
+ *cq = (struct rdmav_cq *) (uintptr_t) ev.cq_handle;
*cq_context = (*cq)->cq_context;
if ((*cq)->context->ops.cq_event)
@@ -278,7 +279,7 @@ int ibv_get_cq_event(struct ibv_comp_cha
return 0;
}
-void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
+void rdmav_ack_cq_events(struct rdmav_cq *cq, unsigned int nevents)
{
pthread_mutex_lock(&cq->mutex);
cq->comp_events_completed += nevents;
@@ -286,10 +287,10 @@ void ibv_ack_cq_events(struct ibv_cq *cq
pthread_mutex_unlock(&cq->mutex);
}
-struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *srq_init_attr)
+struct rdmav_srq *rdmav_create_srq(struct rdmav_pd *pd,
+ struct rdmav_srq_init_attr *srq_init_attr)
{
- struct ibv_srq *srq;
+ struct rdmav_srq *srq;
if (!pd->context->ops.create_srq)
return NULL;
@@ -307,27 +308,27 @@ struct ibv_srq *ibv_create_srq(struct ib
return srq;
}
-int ibv_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- enum ibv_srq_attr_mask srq_attr_mask)
+int rdmav_modify_srq(struct rdmav_srq *srq,
+ struct rdmav_srq_attr *srq_attr,
+ enum rdmav_srq_attr_mask srq_attr_mask)
{
return srq->context->ops.modify_srq(srq, srq_attr, srq_attr_mask);
}
-int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr)
+int rdmav_query_srq(struct rdmav_srq *srq, struct rdmav_srq_attr *srq_attr)
{
return srq->context->ops.query_srq(srq, srq_attr);
}
-int ibv_destroy_srq(struct ibv_srq *srq)
+int rdmav_destroy_srq(struct rdmav_srq *srq)
{
return srq->context->ops.destroy_srq(srq);
}
-struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
- struct ibv_qp_init_attr *qp_init_attr)
+struct rdmav_qp *rdmav_create_qp(struct rdmav_pd *pd,
+ struct rdmav_qp_init_attr *qp_init_attr)
{
- struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
+ struct rdmav_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
if (qp) {
qp->context = pd->context;
@@ -345,9 +346,9 @@ struct ibv_qp *ibv_create_qp(struct ibv_
return qp;
}
-int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_qp_init_attr *init_attr)
+int rdmav_query_qp(struct rdmav_qp *qp, struct rdmav_qp_attr *attr,
+ enum rdmav_qp_attr_mask attr_mask,
+ struct rdmav_qp_init_attr *init_attr)
{
int ret;
@@ -355,14 +356,14 @@ int ibv_query_qp(struct ibv_qp *qp, stru
if (ret)
return ret;
- if (attr_mask & IBV_QP_STATE)
+ if (attr_mask & RDMAV_QP_STATE)
qp->state = attr->qp_state;
return 0;
}
-int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask)
+int rdmav_modify_qp(struct rdmav_qp *qp, struct rdmav_qp_attr *attr,
+ enum rdmav_qp_attr_mask attr_mask)
{
int ret;
@@ -370,20 +371,20 @@ int ibv_modify_qp(struct ibv_qp *qp, str
if (ret)
return ret;
- if (attr_mask & IBV_QP_STATE)
+ if (attr_mask & RDMAV_QP_STATE)
qp->state = attr->qp_state;
return 0;
}
-int ibv_destroy_qp(struct ibv_qp *qp)
+int rdmav_destroy_qp(struct rdmav_qp *qp)
{
return qp->context->ops.destroy_qp(qp);
}
-struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
+struct rdmav_ah *rdmav_create_ah(struct rdmav_pd *pd, struct rdmav_ah_attr *attr)
{
- struct ibv_ah *ah = pd->context->ops.create_ah(pd, attr);
+ struct rdmav_ah *ah = pd->context->ops.create_ah(pd, attr);
if (ah) {
ah->context = pd->context;
@@ -393,22 +394,22 @@ struct ibv_ah *ibv_create_ah(struct ibv_
return ah;
}
-static int ibv_find_gid_index(struct ibv_context *context, uint8_t port_num,
- union ibv_gid *gid)
+static int rdmav_find_gid_index(struct rdmav_context *context, uint8_t port_num,
+ union rdmav_gid *gid)
{
- union ibv_gid sgid;
+ union rdmav_gid sgid;
int i = 0, ret;
do {
- ret = ibv_query_gid(context, port_num, i++, &sgid);
+ ret = rdmav_query_gid(context, port_num, i++, &sgid);
} while (!ret && memcmp(&sgid, gid, sizeof *gid));
return ret ? ret : i - 1;
}
-int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
- struct ibv_wc *wc, struct ibv_grh *grh,
- struct ibv_ah_attr *ah_attr)
+int rdmav_init_ah_from_wc(struct rdmav_context *context, uint8_t port_num,
+ struct rdmav_wc *wc, struct rdmav_grh *grh,
+ struct rdmav_ah_attr *ah_attr)
{
uint32_t flow_class;
int ret;
@@ -419,11 +420,11 @@ int ibv_init_ah_from_wc(struct ibv_conte
ah_attr->src_path_bits = wc->dlid_path_bits;
ah_attr->port_num = port_num;
- if (wc->wc_flags & IBV_WC_GRH) {
+ if (wc->wc_flags & RDMAV_WC_GRH) {
ah_attr->is_global = 1;
ah_attr->grh.dgid = grh->sgid;
- ret = ibv_find_gid_index(context, port_num, &grh->dgid);
+ ret = rdmav_find_gid_index(context, port_num, &grh->dgid);
if (ret < 0)
return ret;
@@ -436,30 +437,30 @@ int ibv_init_ah_from_wc(struct ibv_conte
return 0;
}
-struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
- struct ibv_grh *grh, uint8_t port_num)
+struct rdmav_ah *rdmav_create_ah_from_wc(struct rdmav_pd *pd, struct rdmav_wc *wc,
+ struct rdmav_grh *grh, uint8_t port_num)
{
- struct ibv_ah_attr ah_attr;
+ struct rdmav_ah_attr ah_attr;
int ret;
- ret = ibv_init_ah_from_wc(pd->context, port_num, wc, grh, &ah_attr);
+ ret = rdmav_init_ah_from_wc(pd->context, port_num, wc, grh, &ah_attr);
if (ret)
return NULL;
- return ibv_create_ah(pd, &ah_attr);
+ return rdmav_create_ah(pd, &ah_attr);
}
-int ibv_destroy_ah(struct ibv_ah *ah)
+int rdmav_destroy_ah(struct rdmav_ah *ah)
{
return ah->context->ops.destroy_ah(ah);
}
-int ibv_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int rdmav_attach_mcast(struct rdmav_qp *qp, union rdmav_gid *gid, uint16_t lid)
{
return qp->context->ops.attach_mcast(qp, gid, lid);
}
-int ibv_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int rdmav_detach_mcast(struct rdmav_qp *qp, union rdmav_gid *gid, uint16_t lid)
{
return qp->context->ops.detach_mcast(qp, gid, lid);
}
More information about the general
mailing list