[openib-general] [PATCH 2/6] libibverbs source files changes.
Krishna Kumar
krkumar2 at in.ibm.com
Thu Jul 27 21:50:15 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-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/cmd.c 2006-07-27 15:34:44.000000000 +0530
@@ -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 rdma_cmd_get_context_v2(struct rdma_context *context,
+ struct rdma_get_context *new_cmd,
size_t new_cmd_size,
- struct ibv_get_context_resp *resp,
+ struct rdma_get_context_resp *resp,
size_t resp_size)
{
- struct ibv_abi_compat_v2 *t;
- struct ibv_get_context_v2 *cmd;
+ struct rdma_abi_compat_v2 *t;
+ struct rdma_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);
+ RDMA_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 rdma_cmd_get_context(struct rdma_context *context,
+ struct rdma_get_context *cmd,
+ size_t cmd_size, struct rdma_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 rdma_cmd_get_context_v2(context, cmd, cmd_size, resp,
+ resp_size);
- IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
+ RDMA_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,26 @@ 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 ibv_cmd_get_context(struct ibv_context *context,
+ struct ibv_get_context *cmd,
+ size_t cmd_size, struct ibv_get_context_resp *resp,
+ size_t resp_size)
+{
+ return rdma_cmd_get_context((struct rdma_context *) context,
+ (struct rdma_get_context *) cmd,
+ cmd_size,
+ (struct rdma_get_context_resp *) resp,
+ resp_size);
+}
+
+int rdma_cmd_query_device(struct rdma_context *context,
+ struct rdma_device_attr *device_attr,
uint64_t *raw_fw_ver,
- struct ibv_query_device *cmd, size_t cmd_size)
+ struct rdma_query_device *cmd, size_t cmd_size)
{
- struct ibv_query_device_resp resp;
+ struct rdma_query_device_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_DEVICE, &resp, sizeof resp);
+ RDMA_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 +171,25 @@ 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 ibv_cmd_query_device(struct ibv_context *context,
+ struct ibv_device_attr *device_attr,
+ uint64_t *raw_fw_ver,
+ struct ibv_query_device *cmd, size_t cmd_size)
+{
+ return rdma_cmd_query_device((struct rdma_context *) context,
+ (struct rdma_device_attr *) device_attr,
+ raw_fw_ver,
+ (struct rdma_query_device *) cmd,
+ cmd_size);
+}
+
+int rdma_cmd_query_port(struct rdma_context *context, uint8_t port_num,
+ struct rdma_port_attr *port_attr,
+ struct rdma_query_port *cmd, size_t cmd_size)
{
- struct ibv_query_port_resp resp;
+ struct rdma_query_port_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_PORT, &resp, sizeof resp);
+ RDMA_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 +218,21 @@ 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 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)
{
- IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_PD, resp, resp_size);
+ return rdma_cmd_query_port((struct rdma_context *) context,
+ port_num,
+ (struct rdma_port_attr *) port_attr,
+ (struct rdma_query_port *) cmd, cmd_size);
+}
+
+int rdma_cmd_alloc_pd(struct rdma_context *context, struct rdma_pd *pd,
+ struct rdma_alloc_pd *cmd, size_t cmd_size,
+ struct rdma_alloc_pd_resp *resp, size_t resp_size)
+{
+ RDMA_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 +242,21 @@ int ibv_cmd_alloc_pd(struct ibv_context
return 0;
}
-int ibv_cmd_dealloc_pd(struct ibv_pd *pd)
+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)
+{
+ return rdma_cmd_alloc_pd((struct rdma_context *) context,
+ (struct rdma_pd *) pd,
+ (struct rdma_alloc_pd *) cmd, cmd_size,
+ (struct rdma_alloc_pd_resp *) resp, resp_size);
+}
+
+int rdma_cmd_dealloc_pd(struct rdma_pd *pd)
{
- struct ibv_dealloc_pd cmd;
+ struct rdma_dealloc_pd cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DEALLOC_PD);
+ RDMA_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 +265,19 @@ 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 ibv_cmd_dealloc_pd(struct ibv_pd *pd)
+{
+ return rdma_cmd_dealloc_pd((struct rdma_pd *) pd);
+}
+
+int rdma_cmd_reg_mr(struct rdma_pd *pd, void *addr, size_t length,
+ uint64_t hca_va, enum rdma_access_flags access,
+ struct rdma_mr *mr, struct rdma_reg_mr *cmd,
size_t cmd_size)
{
- struct ibv_reg_mr_resp resp;
+ struct rdma_reg_mr_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, REG_MR, &resp, sizeof resp);
+ RDMA_INIT_CMD_RESP(cmd, cmd_size, REG_MR, &resp, sizeof resp);
cmd->start = (uintptr_t) addr;
cmd->length = length;
@@ -243,11 +295,21 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, vo
return 0;
}
-int ibv_cmd_dereg_mr(struct ibv_mr *mr)
+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,
+ size_t cmd_size)
+{
+ return rdma_cmd_reg_mr((struct rdma_pd *) pd, addr, length,
+ hca_va, access, (struct rdma_mr *) mr,
+ (struct rdma_reg_mr *) cmd, cmd_size);
+}
+
+int rdma_cmd_dereg_mr(struct rdma_mr *mr)
{
- struct ibv_dereg_mr cmd;
+ struct rdma_dereg_mr cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DEREG_MR);
+ RDMA_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 +318,27 @@ 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)
+int ibv_cmd_dereg_mr(struct ibv_mr *mr)
{
- struct ibv_create_cq_v2 *cmd;
+ return rdma_cmd_dereg_mr((struct rdma_mr *) mr);
+}
+
+static int rdma_cmd_create_cq_v2(struct rdma_context *context, int cqe,
+ struct rdma_cq *cq,
+ struct rdma_create_cq *new_cmd,
+ size_t new_cmd_size,
+ struct rdma_create_cq_resp *resp,
+ size_t resp_size)
+{
+ struct rdma_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);
+ RDMA_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 +352,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 rdma_cmd_create_cq(struct rdma_context *context, int cqe,
+ struct rdma_comp_channel *channel,
+ int comp_vector, struct rdma_cq *cq,
+ struct rdma_create_cq *cmd, size_t cmd_size,
+ struct rdma_create_cq_resp *resp, size_t resp_size)
{
if (abi_ver <= 2)
- return ibv_cmd_create_cq_v2(context, cqe, cq,
+ return rdma_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);
+ RDMA_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 +378,34 @@ 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 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)
+{
+ return rdma_cmd_create_cq((struct rdma_context *) context, cqe,
+ (struct rdma_comp_channel *) channel,
+ comp_vector, (struct rdma_cq *) cq,
+ (struct rdma_create_cq *) cmd, cmd_size,
+ (struct rdma_create_cq_resp *) resp,
+ resp_size);
+}
+
+int rdma_cmd_poll_cq(struct rdma_cq *ibcq, int ne, struct rdma_wc *wc)
{
- struct ibv_poll_cq cmd;
- struct ibv_poll_cq_resp *resp;
+ struct rdma_poll_cq cmd;
+ struct rdma_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 rdma_kern_wc);
resp = malloc(rsize);
if (!resp)
return -1;
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, POLL_CQ, resp, rsize);
+ RDMA_INIT_CMD_RESP(&cmd, sizeof cmd, POLL_CQ, resp, rsize);
cmd.cq_handle = ibcq->handle;
cmd.ne = ne;
@@ -353,11 +437,17 @@ out:
return ret;
}
-int ibv_cmd_req_notify_cq(struct ibv_cq *ibcq, int solicited_only)
+int ibv_cmd_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
+{
+ return rdma_cmd_poll_cq((struct rdma_cq *) ibcq, ne,
+ (struct rdma_wc *) wc);
+}
+
+int rdma_cmd_req_notify_cq(struct rdma_cq *ibcq, int solicited_only)
{
- struct ibv_req_notify_cq cmd;
+ struct rdma_req_notify_cq cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, REQ_NOTIFY_CQ);
+ RDMA_INIT_CMD(&cmd, sizeof cmd, REQ_NOTIFY_CQ);
cmd.cq_handle = ibcq->handle;
cmd.solicited = !!solicited_only;
@@ -367,12 +457,18 @@ 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 ibv_cmd_req_notify_cq(struct ibv_cq *ibcq, int solicited_only)
+{
+ return rdma_cmd_req_notify_cq((struct rdma_cq *) ibcq,
+ solicited_only);
+}
+
+int rdma_cmd_resize_cq(struct rdma_cq *cq, int cqe,
+ struct rdma_resize_cq *cmd, size_t cmd_size)
{
- struct ibv_resize_cq_resp resp;
+ struct rdma_resize_cq_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, &resp, sizeof resp);
+ RDMA_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, &resp, sizeof resp);
cmd->cq_handle = cq->handle;
cmd->cqe = cqe;
@@ -384,11 +480,18 @@ int ibv_cmd_resize_cq(struct ibv_cq *cq,
return 0;
}
-static int ibv_cmd_destroy_cq_v1(struct ibv_cq *cq)
+int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
+ struct ibv_resize_cq *cmd, size_t cmd_size)
+{
+ return rdma_cmd_resize_cq((struct rdma_cq *) cq, cqe,
+ (struct rdma_resize_cq *) cmd, cmd_size);
+}
+
+static int rdma_cmd_destroy_cq_v1(struct rdma_cq *cq)
{
- struct ibv_destroy_cq_v1 cmd;
+ struct rdma_destroy_cq_v1 cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_CQ);
+ RDMA_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 +500,15 @@ static int ibv_cmd_destroy_cq_v1(struct
return 0;
}
-int ibv_cmd_destroy_cq(struct ibv_cq *cq)
+int rdma_cmd_destroy_cq(struct rdma_cq *cq)
{
- struct ibv_destroy_cq cmd;
- struct ibv_destroy_cq_resp resp;
+ struct rdma_destroy_cq cmd;
+ struct rdma_destroy_cq_resp resp;
if (abi_ver == 1)
- return ibv_cmd_destroy_cq_v1(cq);
+ return rdma_cmd_destroy_cq_v1(cq);
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_CQ, &resp, sizeof resp);
+ RDMA_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 +523,17 @@ 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 ibv_cmd_destroy_cq(struct ibv_cq *cq)
+{
+ return rdma_cmd_destroy_cq((struct rdma_cq *) cq);
+}
+
+int rdma_cmd_create_srq(struct rdma_pd *pd,
+ struct rdma_srq *srq, struct rdma_srq_init_attr *attr,
+ struct rdma_create_srq *cmd, size_t cmd_size,
+ struct rdma_create_srq_resp *resp, size_t resp_size)
{
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_SRQ, resp, resp_size);
+ RDMA_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 +549,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 rdma_create_srq_resp_v5 *resp_v5 =
+ (struct rdma_create_srq_resp_v5 *) resp;
memmove((void *) resp + sizeof *resp,
(void *) resp_v5 + sizeof *resp_v5,
@@ -452,20 +560,34 @@ 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,
+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)
+{
+ return rdma_cmd_create_srq((struct rdma_pd *) pd,
+ (struct rdma_srq *) srq,
+ (struct rdma_srq_init_attr *) attr,
+ (struct rdma_create_srq *) cmd, cmd_size,
+ (struct rdma_create_srq_resp *) resp,
+ resp_size);
+}
+
+static int rdma_cmd_modify_srq_v3(struct rdma_srq *srq,
+ struct rdma_srq_attr *srq_attr,
+ enum rdma_srq_attr_mask srq_attr_mask,
+ struct rdma_modify_srq *new_cmd,
size_t new_cmd_size)
{
- struct ibv_modify_srq_v3 *cmd;
+ struct rdma_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);
+ RDMA_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
cmd->srq_handle = srq->handle;
cmd->attr_mask = srq_attr_mask;
@@ -480,16 +602,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 rdma_cmd_modify_srq(struct rdma_srq *srq,
+ struct rdma_srq_attr *srq_attr,
+ enum rdma_srq_attr_mask srq_attr_mask,
+ struct rdma_modify_srq *cmd, size_t cmd_size)
{
if (abi_ver == 3)
- return ibv_cmd_modify_srq_v3(srq, srq_attr, srq_attr_mask,
+ return rdma_cmd_modify_srq_v3(srq, srq_attr, srq_attr_mask,
cmd, cmd_size);
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
+ RDMA_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
cmd->srq_handle = srq->handle;
cmd->attr_mask = srq_attr_mask;
@@ -502,12 +624,23 @@ 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 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)
{
- struct ibv_query_srq_resp resp;
+ return rdma_cmd_modify_srq((struct rdma_srq *) srq,
+ (struct rdma_srq_attr *) srq_attr,
+ srq_attr_mask,
+ (struct rdma_modify_srq *) cmd, cmd_size);
+}
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_SRQ, &resp, sizeof resp);
+int rdma_cmd_query_srq(struct rdma_srq *srq, struct rdma_srq_attr *srq_attr,
+ struct rdma_query_srq *cmd, size_t cmd_size)
+{
+ struct rdma_query_srq_resp resp;
+
+ RDMA_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 +653,19 @@ int ibv_cmd_query_srq(struct ibv_srq *sr
return 0;
}
-static int ibv_cmd_destroy_srq_v1(struct ibv_srq *srq)
+int ibv_cmd_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr,
+ struct ibv_query_srq *cmd, size_t cmd_size)
+{
+ return rdma_cmd_query_srq((struct rdma_srq *) srq,
+ (struct rdma_srq_attr *) srq_attr,
+ (struct rdma_query_srq *) cmd, cmd_size);
+}
+
+static int rdma_cmd_destroy_srq_v1(struct rdma_srq *srq)
{
- struct ibv_destroy_srq_v1 cmd;
+ struct rdma_destroy_srq_v1 cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_SRQ);
+ RDMA_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 +674,15 @@ static int ibv_cmd_destroy_srq_v1(struct
return 0;
}
-int ibv_cmd_destroy_srq(struct ibv_srq *srq)
+int rdma_cmd_destroy_srq(struct rdma_srq *srq)
{
- struct ibv_destroy_srq cmd;
- struct ibv_destroy_srq_resp resp;
+ struct rdma_destroy_srq cmd;
+ struct rdma_destroy_srq_resp resp;
if (abi_ver == 1)
- return ibv_cmd_destroy_srq_v1(srq);
+ return rdma_cmd_destroy_srq_v1(srq);
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_SRQ, &resp, sizeof resp);
+ RDMA_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 +696,17 @@ 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 ibv_cmd_destroy_srq(struct ibv_srq *srq)
+{
+ return rdma_cmd_destroy_srq((struct rdma_srq *) srq);
+}
+
+int rdma_cmd_create_qp(struct rdma_pd *pd,
+ struct rdma_qp *qp, struct rdma_qp_init_attr *attr,
+ struct rdma_create_qp *cmd, size_t cmd_size,
+ struct rdma_create_qp_resp *resp, size_t resp_size)
{
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
+ RDMA_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
cmd->user_handle = (uintptr_t) qp;
cmd->pd_handle = pd->handle;
@@ -591,15 +737,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 rdma_create_qp_resp_v4 *resp_v4 =
+ (struct rdma_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 rdma_create_qp_resp_v3 *resp_v3 =
+ (struct rdma_create_qp_resp_v3 *) resp;
memmove((void *) resp + sizeof *resp,
(void *) resp_v3 + sizeof *resp_v3,
@@ -609,14 +755,27 @@ 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 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)
{
- struct ibv_query_qp_resp resp;
+ return rdma_cmd_create_qp((struct rdma_pd *) pd,
+ (struct rdma_qp *) qp,
+ (struct rdma_qp_init_attr *) attr,
+ (struct rdma_create_qp *) cmd, cmd_size,
+ (struct rdma_create_qp_resp *) resp,
+ resp_size);
+}
+
+int rdma_cmd_query_qp(struct rdma_qp *qp, struct rdma_qp_attr *attr,
+ enum rdma_qp_attr_mask attr_mask,
+ struct rdma_qp_init_attr *init_attr,
+ struct rdma_query_qp *cmd, size_t cmd_size)
+{
+ struct rdma_query_qp_resp resp;
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp);
+ RDMA_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp);
cmd->qp_handle = qp->handle;
cmd->attr_mask = attr_mask;
@@ -689,11 +848,22 @@ 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 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)
+{
+ return rdma_cmd_query_qp((struct rdma_qp *) qp,
+ (struct rdma_qp_attr *) attr, attr_mask,
+ (struct rdma_qp_init_attr *) init_attr,
+ (struct rdma_query_qp *) cmd, cmd_size);
+}
+
+int rdma_cmd_modify_qp(struct rdma_qp *qp, struct rdma_qp_attr *attr,
+ enum rdma_qp_attr_mask attr_mask,
+ struct rdma_modify_qp *cmd, size_t cmd_size)
{
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_QP);
+ RDMA_INIT_CMD(cmd, cmd_size, MODIFY_QP);
cmd->qp_handle = qp->handle;
cmd->attr_mask = attr_mask;
@@ -749,11 +919,21 @@ int ibv_cmd_modify_qp(struct ibv_qp *qp,
return 0;
}
-static int ibv_cmd_destroy_qp_v1(struct ibv_qp *qp)
+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)
+{
+ return rdma_cmd_modify_qp((struct rdma_qp *) qp,
+ (struct rdma_qp_attr *) attr,
+ attr_mask, (struct rdma_modify_qp *) cmd,
+ cmd_size);
+}
+
+static int rdma_cmd_destroy_qp_v1(struct rdma_qp *qp)
{
- struct ibv_destroy_qp_v1 cmd;
+ struct rdma_destroy_qp_v1 cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_QP);
+ RDMA_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 +942,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 rdma_cmd_post_send(struct rdma_qp *ibqp, struct rdma_send_wr *wr,
+ struct rdma_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 rdma_post_send *cmd;
+ struct rdma_post_send_resp resp;
+ struct rdma_send_wr *i;
+ struct rdma_kern_send_wr *n, *tmp;
+ struct rdma_sge *s;
unsigned wr_count = 0;
unsigned sge_count = 0;
int cmd_size;
@@ -783,14 +963,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);
+ RDMA_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 rdma_kern_send_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct rdma_sge *) (n + wr_count);
tmp = n;
for (i = wr; i; i = i->next) {
@@ -799,21 +979,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 == RDMA_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 RDMA_WR_RDMA_WRITE:
+ case RDMA_WR_RDMA_WRITE_WITH_IMM:
+ case RDMA_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 RDMA_WR_ATOMIC_CMP_AND_SWP:
+ case RDMA_WR_ATOMIC_FETCH_AND_ADD:
tmp->wr.atomic.remote_addr =
i->wr.atomic.remote_addr;
tmp->wr.atomic.compare_add =
@@ -849,14 +1029,22 @@ 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 ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_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;
+ return rdma_cmd_post_send((struct rdma_qp *) ibqp,
+ (struct rdma_send_wr *) wr,
+ (struct rdma_send_wr **) bad_wr);
+}
+
+int rdma_cmd_post_recv(struct rdma_qp *ibqp, struct rdma_recv_wr *wr,
+ struct rdma_recv_wr **bad_wr)
+{
+ struct rdma_post_recv *cmd;
+ struct rdma_post_recv_resp resp;
+ struct rdma_recv_wr *i;
+ struct rdma_kern_recv_wr *n, *tmp;
+ struct rdma_sge *s;
unsigned wr_count = 0;
unsigned sge_count = 0;
int cmd_size;
@@ -870,14 +1058,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);
+ RDMA_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 rdma_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct rdma_sge *) (n + wr_count);
tmp = n;
for (i = wr; i; i = i->next) {
@@ -907,14 +1095,22 @@ 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,
+int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
struct ibv_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;
+ return rdma_cmd_post_recv((struct rdma_qp *) ibqp,
+ (struct rdma_recv_wr *) wr,
+ (struct rdma_recv_wr **) bad_wr);
+}
+
+int rdma_cmd_post_srq_recv(struct rdma_srq *srq, struct rdma_recv_wr *wr,
+ struct rdma_recv_wr **bad_wr)
+{
+ struct rdma_post_srq_recv *cmd;
+ struct rdma_post_srq_recv_resp resp;
+ struct rdma_recv_wr *i;
+ struct rdma_kern_recv_wr *n, *tmp;
+ struct rdma_sge *s;
unsigned wr_count = 0;
unsigned sge_count = 0;
int cmd_size;
@@ -928,14 +1124,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);
+ RDMA_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 rdma_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct rdma_sge *) (n + wr_count);
tmp = n;
for (i = wr; i; i = i->next) {
@@ -965,13 +1161,21 @@ 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 ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ return rdma_cmd_post_srq_recv((struct rdma_srq *) srq,
+ (struct rdma_recv_wr *) wr,
+ (struct rdma_recv_wr **) bad_wr);
+}
+
+int rdma_cmd_create_ah(struct rdma_pd *pd, struct rdma_ah *ah,
+ struct rdma_ah_attr *attr)
{
- struct ibv_create_ah cmd;
- struct ibv_create_ah_resp resp;
+ struct rdma_create_ah cmd;
+ struct rdma_create_ah_resp resp;
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_AH, &resp, sizeof resp);
+ RDMA_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 +1198,18 @@ int ibv_cmd_create_ah(struct ibv_pd *pd,
return 0;
}
-int ibv_cmd_destroy_ah(struct ibv_ah *ah)
+int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah,
+ struct ibv_ah_attr *attr)
+{
+ return rdma_cmd_create_ah((struct rdma_pd *) pd, (struct rdma_ah *) ah,
+ (struct rdma_ah_attr *) attr);
+}
+
+int rdma_cmd_destroy_ah(struct rdma_ah *ah)
{
- struct ibv_destroy_ah cmd;
+ struct rdma_destroy_ah cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_AH);
+ RDMA_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 +1218,20 @@ int ibv_cmd_destroy_ah(struct ibv_ah *ah
return 0;
}
-int ibv_cmd_destroy_qp(struct ibv_qp *qp)
+int ibv_cmd_destroy_ah(struct ibv_ah *ah)
+{
+ return rdma_cmd_destroy_ah((struct rdma_ah *) ah);
+}
+
+int rdma_cmd_destroy_qp(struct rdma_qp *qp)
{
- struct ibv_destroy_qp cmd;
- struct ibv_destroy_qp_resp resp;
+ struct rdma_destroy_qp cmd;
+ struct rdma_destroy_qp_resp resp;
if (abi_ver == 1)
- return ibv_cmd_destroy_qp_v1(qp);
+ return rdma_cmd_destroy_qp_v1(qp);
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_QP, &resp, sizeof resp);
+ RDMA_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 +1245,16 @@ 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 ibv_cmd_destroy_qp(struct ibv_qp *qp)
{
- struct ibv_attach_mcast cmd;
+ return rdma_cmd_destroy_qp((struct rdma_qp *) qp);
+}
+
+int rdma_cmd_attach_mcast(struct rdma_qp *qp, union rdma_gid *gid, uint16_t lid)
+{
+ struct rdma_attach_mcast cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, ATTACH_MCAST);
+ RDMA_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 +1265,17 @@ 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 ibv_cmd_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+{
+ return rdma_cmd_attach_mcast((struct rdma_qp *) qp,
+ (union rdma_gid *) gid, lid);
+}
+
+int rdma_cmd_detach_mcast(struct rdma_qp *qp, union rdma_gid *gid, uint16_t lid)
{
- struct ibv_detach_mcast cmd;
+ struct rdma_detach_mcast cmd;
- IBV_INIT_CMD(&cmd, sizeof cmd, DETACH_MCAST);
+ RDMA_INIT_CMD(&cmd, sizeof cmd, DETACH_MCAST);
memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
cmd.qp_handle = qp->handle;
cmd.mlid = lid;
@@ -1058,3 +1285,9 @@ int ibv_cmd_detach_mcast(struct ibv_qp *
return 0;
}
+
+int ibv_cmd_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+{
+ return rdma_cmd_detach_mcast((struct rdma_qp *) qp,
+ (union rdma_gid *) gid, lid);
+}
diff -ruNp ORG/libibverbs/src/device.c NEW/libibverbs/src/device.c
--- ORG/libibverbs/src/device.c 2006-07-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/device.c 2006-07-27 15:34:44.000000000 +0530
@@ -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 rdma_device **device_list;
-struct ibv_device **ibv_get_device_list(int *num)
+struct rdma_device **rdma_get_device_list(int *num)
{
- struct ibv_device **l;
+ struct rdma_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 rdma_device *));
for (i = 0; i < num_devices; ++i)
l[i] = device_list[i];
@@ -76,24 +76,40 @@ struct ibv_device **ibv_get_device_list(
return l;
}
-void ibv_free_device_list(struct ibv_device **list)
+struct ibv_device **ibv_get_device_list(int *num)
+{
+ return (struct ibv_device **) rdma_get_device_list(num);
+}
+
+void rdma_free_device_list(struct rdma_device **list)
{
free(list);
}
-const char *ibv_get_device_name(struct ibv_device *device)
+void ibv_free_device_list(struct ibv_device **list)
+{
+ rdma_free_device_list((struct rdma_device **) list);
+
+}
+
+const char *rdma_get_device_name(struct rdma_device *device)
{
return device->name;
}
-uint64_t ibv_get_device_guid(struct ibv_device *device)
+const char *ibv_get_device_name(struct ibv_device *device)
+{
+ return rdma_get_device_name((struct rdma_device *) device);
+}
+
+uint64_t rdma_get_device_guid(struct rdma_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 (rdma_read_sysfs_file(device->ibdev_path, "node_guid",
attr, sizeof attr) < 0)
return 0;
@@ -107,11 +123,16 @@ uint64_t ibv_get_device_guid(struct ibv_
return htonll(guid);
}
-struct ibv_context *ibv_open_device(struct ibv_device *device)
+uint64_t ibv_get_device_guid(struct ibv_device *device)
+{
+ return rdma_get_device_guid((struct rdma_device *) device);
+}
+
+struct rdma_context *rdma_open_device(struct rdma_device *device)
{
char *devpath;
int cmd_fd;
- struct ibv_context *context;
+ struct rdma_context *context;
asprintf(&devpath, "/dev/infiniband/%s", device->dev_name);
@@ -140,14 +161,20 @@ err:
return NULL;
}
-int ibv_close_device(struct ibv_context *context)
+struct ibv_context *ibv_open_device(struct ibv_device *device)
+{
+ return (struct ibv_context *)
+ rdma_open_device((struct rdma_device *) device);
+}
+
+int rdma_close_device(struct rdma_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 rdma_abi_compat_v2 *t = context->abi_compat;
cq_fd = t->channel.fd;
free(context->abi_compat);
}
@@ -162,10 +189,15 @@ int ibv_close_device(struct ibv_context
return 0;
}
-int ibv_get_async_event(struct ibv_context *context,
- struct ibv_async_event *event)
+int ibv_close_device(struct ibv_context *context)
+{
+ return rdma_close_device((struct rdma_context *) context);
+}
+
+int rdma_get_async_event(struct rdma_context *context,
+ struct rdma_async_event *event)
{
- struct ibv_kern_async_event ev;
+ struct rdma_kern_async_event ev;
if (read(context->async_fd, &ev, sizeof ev) != sizeof ev)
return -1;
@@ -173,23 +205,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 RDMA_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 RDMA_EVENT_QP_FATAL:
+ case RDMA_EVENT_QP_REQ_ERR:
+ case RDMA_EVENT_QP_ACCESS_ERR:
+ case RDMA_EVENT_COMM_EST:
+ case RDMA_EVENT_SQ_DRAINED:
+ case RDMA_EVENT_PATH_MIG:
+ case RDMA_EVENT_PATH_MIG_ERR:
+ case RDMA_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 RDMA_EVENT_SRQ_ERR:
+ case RDMA_EVENT_SRQ_LIMIT_REACHED:
event->element.srq = (void *) (uintptr_t) ev.element;
break;
@@ -201,12 +233,19 @@ int ibv_get_async_event(struct ibv_conte
return 0;
}
-void ibv_ack_async_event(struct ibv_async_event *event)
+int ibv_get_async_event(struct ibv_context *context,
+ struct ibv_async_event *event)
+{
+ return rdma_get_async_event((struct rdma_context *) context,
+ (struct rdma_async_event *) event);
+}
+
+void rdma_ack_async_event(struct rdma_async_event *event)
{
switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
+ case RDMA_EVENT_CQ_ERR:
{
- struct ibv_cq *cq = event->element.cq;
+ struct rdma_cq *cq = event->element.cq;
pthread_mutex_lock(&cq->mutex);
++cq->async_events_completed;
@@ -216,16 +255,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 RDMA_EVENT_QP_FATAL:
+ case RDMA_EVENT_QP_REQ_ERR:
+ case RDMA_EVENT_QP_ACCESS_ERR:
+ case RDMA_EVENT_COMM_EST:
+ case RDMA_EVENT_SQ_DRAINED:
+ case RDMA_EVENT_PATH_MIG:
+ case RDMA_EVENT_PATH_MIG_ERR:
+ case RDMA_EVENT_QP_LAST_WQE_REACHED:
{
- struct ibv_qp *qp = event->element.qp;
+ struct rdma_qp *qp = event->element.qp;
pthread_mutex_lock(&qp->mutex);
++qp->events_completed;
@@ -235,10 +274,10 @@ void ibv_ack_async_event(struct ibv_asyn
return;
}
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
+ case RDMA_EVENT_SRQ_ERR:
+ case RDMA_EVENT_SRQ_LIMIT_REACHED:
{
- struct ibv_srq *srq = event->element.srq;
+ struct rdma_srq *srq = event->element.srq;
pthread_mutex_lock(&srq->mutex);
++srq->events_completed;
@@ -252,3 +291,8 @@ void ibv_ack_async_event(struct ibv_asyn
return;
}
}
+
+void ibv_ack_async_event(struct ibv_async_event *event)
+{
+ rdma_ack_async_event((struct rdma_async_event *) event);
+}
diff -ruNp ORG/libibverbs/src/ibverbs.h NEW/libibverbs/src/ibverbs.h
--- ORG/libibverbs/src/ibverbs.h 2006-07-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/ibverbs.h 1970-01-01 05:30:00.000000000 +0530
@@ -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-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/init.c 2006-07-27 15:34:44.000000000 +0530
@@ -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 rdma_driver *driver_list;
static void load_driver(char *so_path)
{
void *dlhandle;
- ibv_driver_init_func init_func;
- struct ibv_driver *driver;
+ rdma_driver_init_func init_func;
+ struct rdma_driver *driver;
dlhandle = dlopen(so_path, RTLD_NOW);
if (!dlhandle) {
@@ -122,11 +126,11 @@ static void find_drivers(char *dir)
globfree(&so_glob);
}
-static struct ibv_device *init_drivers(const char *class_path,
+static struct rdma_device *init_drivers(const char *class_path,
const char *dev_name)
{
- struct ibv_driver *driver;
- struct ibv_device *dev;
+ struct rdma_driver *driver;
+ struct rdma_device *dev;
int abi_ver = 0;
char sys_path[IBV_SYSFS_PATH_MAX];
char ibdev_name[IBV_SYSFS_NAME_MAX];
@@ -135,10 +139,12 @@ static struct ibv_device *init_drivers(c
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 (rdma_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 (rdma_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 +157,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, IBV_SYSFS_PATH_MAX,
+ "%s/class/infiniband/%s",
+ rdma_get_sysfs_path(), ibdev_name);
strcpy(dev->dev_name, dev_name);
strcpy(dev->name, ibdev_name);
@@ -172,7 +179,7 @@ static int check_abi_version(const char
{
char value[8];
- if (ibv_read_sysfs_file(path, "class/infiniband_verbs/abi_version",
+ if (rdma_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;
@@ -191,21 +198,21 @@ static int check_abi_version(const char
return 0;
}
-HIDDEN int ibverbs_init(struct ibv_device ***list)
+HIDDEN int rdmaverbs_init(struct rdma_device ***list)
{
const char *sysfs_path;
char *wr_path, *dir;
char class_path[IBV_SYSFS_PATH_MAX];
DIR *class_dir;
struct dirent *dent;
- struct ibv_device *device;
- struct ibv_device **new_list;
+ struct rdma_device *device;
+ struct rdma_device **new_list;
int num_devices = 0;
int list_size = 0;
*list = NULL;
- if (ibv_init_mem_map())
+ if (rdma_init_mem_map())
return 0;
find_drivers(default_path);
@@ -215,12 +222,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 +247,7 @@ HIDDEN int ibverbs_init(struct ibv_devic
*/
load_driver(NULL);
- sysfs_path = ibv_get_sysfs_path();
+ sysfs_path = rdma_get_sysfs_path();
if (!sysfs_path) {
fprintf(stderr, PFX "Fatal: couldn't find sysfs mount.\n");
return 0;
@@ -258,7 +275,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 rdma_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-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/libibverbs.map 1970-01-01 05:30:00.000000000 +0530
@@ -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 1970-01-01 05:30:00.000000000 +0530
+++ NEW/libibverbs/src/librdmaverbs.map 2006-07-27 15:34:44.000000000 +0530
@@ -0,0 +1,154 @@
+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;
+
+ rdma_get_device_list;
+ rdma_free_device_list;
+ rdma_get_device_name;
+ rdma_get_device_guid;
+ rdma_open_device;
+ rdma_close_device;
+ rdma_get_async_event;
+ rdma_ack_async_event;
+ rdma_query_device;
+ rdma_query_port;
+ rdma_query_gid;
+ rdma_query_pkey;
+ rdma_alloc_pd;
+ rdma_dealloc_pd;
+ rdma_reg_mr;
+ rdma_dereg_mr;
+ rdma_create_comp_channel;
+ rdma_destroy_comp_channel;
+ rdma_create_cq;
+ rdma_resize_cq;
+ rdma_destroy_cq;
+ rdma_get_cq_event;
+ rdma_ack_cq_events;
+ rdma_create_srq;
+ rdma_modify_srq;
+ rdma_query_srq;
+ rdma_destroy_srq;
+ rdmav_create_qp;
+ rdma_query_qp;
+ rdma_modify_qp;
+ rdmav_destroy_qp;
+ rdma_create_ah;
+ rdma_init_ah_from_wc;
+ rdma_create_ah_from_wc;
+ rdma_destroy_ah;
+ rdma_attach_mcast;
+ rdma_detach_mcast;
+ rdma_cmd_get_context;
+ rdma_cmd_query_device;
+ rdma_cmd_query_port;
+ rdma_cmd_query_gid;
+ rdma_cmd_query_pkey;
+ rdma_cmd_alloc_pd;
+ rdma_cmd_dealloc_pd;
+ rdma_cmd_reg_mr;
+ rdma_cmd_dereg_mr;
+ rdma_cmd_create_cq;
+ rdma_cmd_poll_cq;
+ rdma_cmd_req_notify_cq;
+ rdma_cmd_resize_cq;
+ rdma_cmd_destroy_cq;
+ rdma_cmd_create_srq;
+ rdma_cmd_modify_srq;
+ rdma_cmd_query_srq;
+ rdma_cmd_destroy_srq;
+ rdma_cmd_create_qp;
+ rdma_cmd_query_qp;
+ rdma_cmd_modify_qp;
+ rdma_cmd_destroy_qp;
+ rdma_cmd_post_send;
+ rdma_cmd_post_recv;
+ rdma_cmd_post_srq_recv;
+ rdma_cmd_create_ah;
+ rdma_cmd_destroy_ah;
+ rdma_cmd_attach_mcast;
+ rdma_cmd_detach_mcast;
+ rdma_copy_qp_attr_from_kern;
+ rdma_copy_ah_attr_from_kern;
+ rdma_copy_path_rec_from_kern;
+ rdma_copy_path_rec_to_kern;
+ rdma_rate_to_mult;
+ mult_to_rdma_rate;
+ rdma_get_sysfs_path;
+ rdma_read_sysfs_file;
+
+ local: *;
+};
diff -ruNp ORG/libibverbs/src/marshall.c NEW/libibverbs/src/marshall.c
--- ORG/libibverbs/src/marshall.c 2006-07-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/marshall.c 2006-07-27 15:34:44.000000000 +0530
@@ -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 rdma_copy_ah_attr_from_kern(struct rdma_ah_attr *dst,
+ struct rdma_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,15 @@ 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 ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
+ struct ibv_kern_ah_attr *src)
+{
+ rdma_copy_ah_attr_from_kern((struct rdma_ah_attr *) dst,
+ (struct rdma_kern_ah_attr *) src);
+}
+
+void rdma_copy_qp_attr_from_kern(struct rdma_qp_attr *dst,
+ struct rdma_kern_qp_attr *src)
{
dst->cur_qp_state = src->cur_qp_state;
dst->path_mtu = src->path_mtu;
@@ -73,8 +80,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);
+ rdma_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
+ rdma_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 +98,15 @@ 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 ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
+ struct ibv_kern_qp_attr *src)
+{
+ return rdma_copy_qp_attr_from_kern((struct rdma_qp_attr *) dst,
+ (struct rdma_kern_qp_attr *) src);
+}
+
+void rdma_copy_path_rec_from_kern(struct rdma_sa_path_rec *dst,
+ struct rdma_kern_path_rec *src)
{
memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
@@ -116,8 +130,15 @@ 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 ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
+ struct ibv_kern_path_rec *src)
+{
+ return rdma_copy_path_rec_from_kern((struct rdma_sa_path_rec *) dst,
+ (struct rdma_kern_path_rec *) src);
+}
+
+void rdma_copy_path_rec_to_kern(struct rdma_kern_path_rec *dst,
+ struct rdma_sa_path_rec *src)
{
memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
@@ -140,3 +161,10 @@ void ibv_copy_path_rec_to_kern(struct ib
dst->preference = src->preference;
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)
+{
+ return rdma_copy_path_rec_to_kern((struct rdma_kern_path_rec *) dst,
+ (struct rdma_sa_path_rec *) src);
+}
diff -ruNp ORG/libibverbs/src/memory.c NEW/libibverbs/src/memory.c
--- ORG/libibverbs/src/memory.c 2006-07-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/memory.c 2006-07-27 15:34:44.000000000 +0530
@@ -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 rdma_mem_node {
+ struct rdma_mem_node *prev, *next;
uintptr_t start, end;
int refcnt;
};
static struct {
- struct ibv_mem_node *first;
+ struct rdma_mem_node *first;
pthread_mutex_t mutex;
uintptr_t page_size;
} mem_map;
-int ibv_init_mem_map(void)
+int rdma_init_mem_map(void)
{
- struct ibv_mem_node *node = NULL;
+ struct rdma_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 rdma_mem_node *__mm_find_first(uintptr_t start, uintptr_t end)
{
- struct ibv_mem_node *node = mem_map.first;
+ struct rdma_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 rdma_mem_node *__mm_prev(struct rdma_mem_node *node)
{
return node->prev;
}
-static struct ibv_mem_node *__mm_next(struct ibv_mem_node *node)
+static struct rdma_mem_node *__mm_next(struct rdma_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 rdma_mem_node *node,
+ struct rdma_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 rdma_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 rdma_lock_range(void *base, size_t size)
{
uintptr_t start, end;
- struct ibv_mem_node *node, *tmp;
+ struct rdma_mem_node *node, *tmp;
int ret = 0;
if (!size)
@@ -202,10 +202,15 @@ out:
return ret;
}
-int ibv_unlock_range(void *base, size_t size)
+int ibv_lock_range(void *base, size_t size)
+{
+ return rdma_lock_range(base, size);
+}
+
+int rdma_unlock_range(void *base, size_t size)
{
uintptr_t start, end;
- struct ibv_mem_node *node, *tmp;
+ struct rdma_mem_node *node, *tmp;
int ret = 0;
if (!size)
@@ -256,3 +261,8 @@ out:
return ret;
}
+
+int ibv_unlock_range(void *base, size_t size)
+{
+ return rdma_unlock_range(base, size);
+}
diff -ruNp ORG/libibverbs/src/rdmaverbs.h NEW/libibverbs/src/rdmaverbs.h
--- ORG/libibverbs/src/rdmaverbs.h 1970-01-01 05:30:00.000000000 +0530
+++ NEW/libibverbs/src/rdmaverbs.h 2006-07-27 15:34:44.000000000 +0530
@@ -0,0 +1,125 @@
+/*
+ * 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 SRC_RDMA_VERBS_H
+#define SRC_RDMA_VERBS_H
+
+#include <pthread.h>
+
+#include <infiniband/driver.h>
+
+#define HIDDEN __attribute__((visibility ("hidden")))
+
+#define INIT __attribute__((constructor))
+#define FINI __attribute__((destructor))
+
+#ifndef PFX
+#define PFX "librdmaverbs: "
+#endif
+
+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;
+
+#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)
+
+/* Generic RDMA declarations follow */
+
+struct rdma_driver {
+ rdma_driver_init_func init_func;
+ struct rdma_driver *next;
+};
+
+struct rdma_abi_compat_v2 {
+ struct rdma_comp_channel channel;
+ pthread_mutex_t in_use;
+};
+
+extern HIDDEN int abi_ver;
+
+extern HIDDEN int rdmaverbs_init(struct rdma_device ***list);
+
+extern HIDDEN int rdma_init_mem_map(void);
+extern HIDDEN int rdma_lock_range(void *base, size_t size);
+extern HIDDEN int rdma_unlock_range(void *base, size_t size);
+
+#define RDMA_INIT_CMD(cmd, size, opcode) \
+ do { \
+ if (abi_ver > 2) \
+ (cmd)->command = RDMA_USER_VERBS_CMD_##opcode; \
+ else \
+ (cmd)->command = RDMA_USER_VERBS_CMD_##opcode##_V2; \
+ (cmd)->in_words = (size) / 4; \
+ (cmd)->out_words = 0; \
+ } while (0)
+
+#define RDMA_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \
+ do { \
+ if (abi_ver > 2) \
+ (cmd)->command = RDMA_USER_VERBS_CMD_##opcode; \
+ else \
+ (cmd)->command = RDMA_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-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/sysfs.c 2006-07-27 15:34:44.000000000 +0530
@@ -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 *rdma_get_sysfs_path(void)
{
char *env = NULL;
@@ -77,7 +77,12 @@ const char *ibv_get_sysfs_path(void)
return sysfs_path;
}
-int ibv_read_sysfs_file(const char *dir, const char *file,
+const char *ibv_get_sysfs_path(void)
+{
+ return rdma_get_sysfs_path();
+}
+
+int rdma_read_sysfs_file(const char *dir, const char *file,
char *buf, size_t size)
{
char *path;
@@ -102,3 +107,9 @@ int ibv_read_sysfs_file(const char *dir,
return len;
}
+
+int ibv_read_sysfs_file(const char *dir, const char *file,
+ char *buf, size_t size)
+{
+ return rdma_read_sysfs_file(dir, file, buf, size);
+}
diff -ruNp ORG/libibverbs/src/verbs.c NEW/libibverbs/src/verbs.c
--- ORG/libibverbs/src/verbs.c 2006-07-27 15:34:18.000000000 +0530
+++ NEW/libibverbs/src/verbs.c 2006-07-27 15:34:44.000000000 +0530
@@ -44,9 +44,9 @@
#include <errno.h>
#include <string.h>
-#include "ibverbs.h"
+#include "rdmaverbs.h"
-int ibv_rate_to_mult(enum ibv_rate rate)
+int rdma_rate_to_mult(enum rdma_rate rate)
{
switch (rate) {
case IBV_RATE_2_5_GBPS: return 1;
@@ -62,7 +62,12 @@ int ibv_rate_to_mult(enum ibv_rate rate)
}
}
-enum ibv_rate mult_to_ibv_rate(int mult)
+int ibv_rate_to_mult(enum ibv_rate rate)
+{
+ return rdma_rate_to_mult(rate);
+}
+
+enum rdma_rate mult_to_rdma_rate(int mult)
{
switch (mult) {
case 1: return IBV_RATE_2_5_GBPS;
@@ -78,20 +83,39 @@ enum ibv_rate mult_to_ibv_rate(int mult)
}
}
+enum ibv_rate mult_to_ibv_rate(int mult)
+{
+ return mult_to_rdma_rate(mult);
+}
+
+int rdma_query_device(struct rdma_context *context,
+ struct rdma_device_attr *device_attr)
+{
+ return context->ops.query_device(context, device_attr);
+}
+
int ibv_query_device(struct ibv_context *context,
struct ibv_device_attr *device_attr)
{
- return context->ops.query_device(context, device_attr);
+ return rdma_query_device((struct rdma_context *) context,
+ (struct rdma_device_attr *) device_attr);
+}
+
+int rdma_query_port(struct rdma_context *context, uint8_t port_num,
+ struct rdma_port_attr *port_attr)
+{
+ return context->ops.query_port(context, port_num, port_attr);
}
int ibv_query_port(struct ibv_context *context, uint8_t port_num,
struct ibv_port_attr *port_attr)
{
- return context->ops.query_port(context, port_num, port_attr);
+ return rdma_query_port((struct rdma_context *) context, port_num,
+ (struct rdma_port_attr *) port_attr);
}
-int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
- int index, union ibv_gid *gid)
+int rdma_query_gid(struct rdma_context *context, uint8_t port_num,
+ int index, union rdma_gid *gid)
{
char name[24];
char attr[41];
@@ -100,7 +124,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 (rdma_read_sysfs_file(context->device->ibdev_path, name,
attr, sizeof attr) < 0)
return -1;
@@ -114,7 +138,14 @@ int ibv_query_gid(struct ibv_context *co
return 0;
}
-int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
+int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid)
+{
+ return rdma_query_gid((struct rdma_context *) context, port_num, index,
+ (union rdma_gid *) gid);
+}
+
+int rdma_query_pkey(struct rdma_context *context, uint8_t port_num,
int index, uint16_t *pkey)
{
char name[24];
@@ -123,7 +154,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 (rdma_read_sysfs_file(context->device->ibdev_path, name,
attr, sizeof attr) < 0)
return -1;
@@ -134,9 +165,16 @@ int ibv_query_pkey(struct ibv_context *c
return 0;
}
-struct ibv_pd *ibv_alloc_pd(struct ibv_context *context)
+int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
+ int index, uint16_t *pkey)
+{
+ return rdma_query_pkey((struct rdma_context *) context, port_num, index,
+ pkey);
+}
+
+struct rdma_pd *rdma_alloc_pd(struct rdma_context *context)
{
- struct ibv_pd *pd;
+ struct rdma_pd *pd;
pd = context->ops.alloc_pd(context);
if (pd)
@@ -145,15 +183,25 @@ struct ibv_pd *ibv_alloc_pd(struct ibv_c
return pd;
}
-int ibv_dealloc_pd(struct ibv_pd *pd)
+struct ibv_pd *ibv_alloc_pd(struct ibv_context *context)
+{
+ return (struct ibv_pd *) rdma_alloc_pd((struct rdma_context *) context);
+}
+
+int rdma_dealloc_pd(struct rdma_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)
+int ibv_dealloc_pd(struct ibv_pd *pd)
+{
+ return rdma_dealloc_pd((struct rdma_pd *) pd);
+}
+
+struct rdma_mr *rdma_reg_mr(struct rdma_pd *pd, void *addr,
+ size_t length, enum rdma_access_flags access)
{
- struct ibv_mr *mr;
+ struct rdma_mr *mr;
mr = pd->context->ops.reg_mr(pd, addr, length, access);
if (mr) {
@@ -164,14 +212,26 @@ struct ibv_mr *ibv_reg_mr(struct ibv_pd
return mr;
}
-int ibv_dereg_mr(struct ibv_mr *mr)
+struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, enum ibv_access_flags access)
+{
+ return (struct ibv_mr *) rdma_reg_mr((struct rdma_pd *) pd, addr,
+ length, access);
+}
+
+int rdma_dereg_mr(struct rdma_mr *mr)
{
return mr->context->ops.dereg_mr(mr);
}
-static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context)
+int ibv_dereg_mr(struct ibv_mr *mr)
{
- struct ibv_abi_compat_v2 *t = context->abi_compat;
+ return rdma_dereg_mr((struct rdma_mr *) mr);
+}
+
+static struct rdma_comp_channel *rdma_create_comp_channel_v2(struct rdma_context *context)
+{
+ struct rdma_abi_compat_v2 *t = context->abi_compat;
static int warned;
if (!pthread_mutex_trylock(&t->in_use))
@@ -187,14 +247,14 @@ static struct ibv_comp_channel *ibv_crea
return NULL;
}
-struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context)
+struct rdma_comp_channel *rdma_create_comp_channel(struct rdma_context *context)
{
- struct ibv_comp_channel *channel;
- struct ibv_create_comp_channel cmd;
- struct ibv_create_comp_channel_resp resp;
+ struct rdma_comp_channel *channel;
+ struct rdma_create_comp_channel cmd;
+ struct rdma_create_comp_channel_resp resp;
if (abi_ver <= 2)
- return ibv_create_comp_channel_v2(context);
+ return rdma_create_comp_channel_v2(context);
channel = malloc(sizeof *channel);
if (!channel)
@@ -211,17 +271,22 @@ struct ibv_comp_channel *ibv_create_comp
return channel;
}
-static int ibv_destroy_comp_channel_v2(struct ibv_comp_channel *channel)
+struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context)
+{
+ return (struct ibv_comp_channel *) rdma_create_comp_channel((struct rdma_context *) context);
+}
+
+static int rdma_destroy_comp_channel_v2(struct rdma_comp_channel *channel)
{
- struct ibv_abi_compat_v2 *t = (struct ibv_abi_compat_v2 *) channel;
+ struct rdma_abi_compat_v2 *t = (struct rdma_abi_compat_v2 *) channel;
pthread_mutex_unlock(&t->in_use);
return 0;
}
-int ibv_destroy_comp_channel(struct ibv_comp_channel *channel)
+int rdma_destroy_comp_channel(struct rdma_comp_channel *channel)
{
if (abi_ver <= 2)
- return ibv_destroy_comp_channel_v2(channel);
+ return rdma_destroy_comp_channel_v2(channel);
close(channel->fd);
free(channel);
@@ -229,10 +294,17 @@ 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)
+int ibv_destroy_comp_channel(struct ibv_comp_channel *channel)
{
- struct ibv_cq *cq = context->ops.create_cq(context, cqe, channel,
+ return rdma_destroy_comp_channel((struct rdma_comp_channel *) channel);
+}
+
+struct rdma_cq *rdma_create_cq(struct rdma_context *context, int cqe,
+ void *cq_context,
+ struct rdma_comp_channel *channel,
+ int comp_vector)
+{
+ struct rdma_cq *cq = context->ops.create_cq(context, cqe, channel,
comp_vector);
if (cq) {
@@ -247,7 +319,17 @@ struct ibv_cq *ibv_create_cq(struct ibv_
return cq;
}
-int ibv_resize_cq(struct ibv_cq *cq, int cqe)
+struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe,
+ void *cq_context,
+ struct ibv_comp_channel *channel, int comp_vector)
+{
+ return (struct ibv_cq *) rdma_create_cq((struct rdma_context *) context,
+ cqe, cq_context, (struct
+ rdma_comp_channel *) channel,
+ comp_vector);
+}
+
+int rdma_resize_cq(struct rdma_cq *cq, int cqe)
{
if (!cq->context->ops.resize_cq)
return ENOSYS;
@@ -255,21 +337,30 @@ 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 ibv_resize_cq(struct ibv_cq *cq, int cqe)
+{
+ return rdma_resize_cq((struct rdma_cq *) cq, cqe);
+}
+
+int rdma_destroy_cq(struct rdma_cq *cq)
{
return cq->context->ops.destroy_cq(cq);
}
+int ibv_destroy_cq(struct ibv_cq *cq)
+{
+ return rdma_destroy_cq((struct rdma_cq *) cq);
+}
-int ibv_get_cq_event(struct ibv_comp_channel *channel,
- struct ibv_cq **cq, void **cq_context)
+int rdma_get_cq_event(struct rdma_comp_channel *channel,
+ struct rdma_cq **cq, void **cq_context)
{
- struct ibv_comp_event ev;
+ struct rdma_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 rdma_cq *) (uintptr_t) ev.cq_handle;
*cq_context = (*cq)->cq_context;
if ((*cq)->context->ops.cq_event)
@@ -278,7 +369,14 @@ int ibv_get_cq_event(struct ibv_comp_cha
return 0;
}
-void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
+int ibv_get_cq_event(struct ibv_comp_channel *channel,
+ struct ibv_cq **cq, void **cq_context)
+{
+ return rdma_get_cq_event((struct rdma_comp_channel *) channel,
+ (struct rdma_cq **) cq, cq_context);
+}
+
+void rdma_ack_cq_events(struct rdma_cq *cq, unsigned int nevents)
{
pthread_mutex_lock(&cq->mutex);
cq->comp_events_completed += nevents;
@@ -286,10 +384,15 @@ 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)
+void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
+{
+ rdma_ack_cq_events((struct rdma_cq *) cq, nevents);
+}
+
+struct rdma_srq *rdma_create_srq(struct rdma_pd *pd,
+ struct rdma_srq_init_attr *srq_init_attr)
{
- struct ibv_srq *srq;
+ struct rdma_srq *srq;
if (!pd->context->ops.create_srq)
return NULL;
@@ -307,27 +410,55 @@ struct ibv_srq *ibv_create_srq(struct ib
return srq;
}
+struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *srq_init_attr)
+{
+ return (struct ibv_srq *) rdma_create_srq((struct rdma_pd *) pd,
+ (struct rdma_srq_init_attr *)
+ srq_init_attr);
+}
+
+int rdma_modify_srq(struct rdma_srq *srq,
+ struct rdma_srq_attr *srq_attr,
+ enum rdma_srq_attr_mask srq_attr_mask)
+{
+ return srq->context->ops.modify_srq(srq, srq_attr, srq_attr_mask);
+}
+
int ibv_modify_srq(struct ibv_srq *srq,
struct ibv_srq_attr *srq_attr,
enum ibv_srq_attr_mask srq_attr_mask)
{
- return srq->context->ops.modify_srq(srq, srq_attr, srq_attr_mask);
+ return rdma_modify_srq((struct rdma_srq *) srq,
+ (struct rdma_srq_attr *) srq_attr,
+ srq_attr_mask);
}
-int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr)
+int rdma_query_srq(struct rdma_srq *srq, struct rdma_srq_attr *srq_attr)
{
return srq->context->ops.query_srq(srq, srq_attr);
}
-int ibv_destroy_srq(struct ibv_srq *srq)
+int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr)
+{
+ return rdma_query_srq((struct rdma_srq *) srq,
+ (struct rdma_srq_attr *) srq_attr);
+}
+
+int rdma_destroy_srq(struct rdma_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)
+int ibv_destroy_srq(struct ibv_srq *srq)
+{
+ return rdma_destroy_srq((struct rdma_srq *) srq);
+}
+
+struct rdma_qp *rdmav_create_qp(struct rdma_pd *pd,
+ struct rdma_qp_init_attr *qp_init_attr)
{
- struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
+ struct rdma_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
if (qp) {
qp->context = pd->context;
@@ -345,9 +476,16 @@ 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)
+struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *qp_init_attr)
+{
+ return (struct ibv_qp *) rdmav_create_qp((struct rdma_pd *) pd,
+ (struct rdma_qp_init_attr *) qp_init_attr);
+}
+
+int rdma_query_qp(struct rdma_qp *qp, struct rdma_qp_attr *attr,
+ enum rdma_qp_attr_mask attr_mask,
+ struct rdma_qp_init_attr *init_attr)
{
int ret;
@@ -361,8 +499,17 @@ int ibv_query_qp(struct ibv_qp *qp, stru
return 0;
}
-int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask)
+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)
+{
+ return rdma_query_qp((struct rdma_qp *) qp,
+ (struct rdma_qp_attr *) attr, attr_mask,
+ (struct rdma_qp_init_attr *) init_attr);
+}
+
+int rdma_modify_qp(struct rdma_qp *qp, struct rdma_qp_attr *attr,
+ enum rdma_qp_attr_mask attr_mask)
{
int ret;
@@ -376,14 +523,26 @@ int ibv_modify_qp(struct ibv_qp *qp, str
return 0;
}
-int ibv_destroy_qp(struct ibv_qp *qp)
+int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ enum ibv_qp_attr_mask attr_mask)
+{
+ return rdma_modify_qp((struct rdma_qp *) qp,
+ (struct rdma_qp_attr *) attr, attr_mask);
+}
+
+int rdmav_destroy_qp(struct rdma_qp *qp)
{
return qp->context->ops.destroy_qp(qp);
}
-struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
+int ibv_destroy_qp(struct ibv_qp *qp)
{
- struct ibv_ah *ah = pd->context->ops.create_ah(pd, attr);
+ return rdmav_destroy_qp((struct rdma_qp *) qp);
+}
+
+struct rdma_ah *rdma_create_ah(struct rdma_pd *pd, struct rdma_ah_attr *attr)
+{
+ struct rdma_ah *ah = pd->context->ops.create_ah(pd, attr);
if (ah) {
ah->context = pd->context;
@@ -393,22 +552,28 @@ 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)
+struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
+{
+ return (struct ibv_ah *) rdma_create_ah((struct rdma_pd *) pd,
+ (struct rdma_ah_attr *) attr);
+}
+
+static int rdma_find_gid_index(struct rdma_context *context, uint8_t port_num,
+ union rdma_gid *gid)
{
- union ibv_gid sgid;
+ union rdma_gid sgid;
int i = 0, ret;
do {
- ret = ibv_query_gid(context, port_num, i++, &sgid);
+ ret = rdma_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 rdma_init_ah_from_wc(struct rdma_context *context, uint8_t port_num,
+ struct rdma_wc *wc, struct rdma_grh *grh,
+ struct rdma_ah_attr *ah_attr)
{
uint32_t flow_class;
int ret;
@@ -423,7 +588,7 @@ int ibv_init_ah_from_wc(struct ibv_conte
ah_attr->is_global = 1;
ah_attr->grh.dgid = grh->sgid;
- ret = ibv_find_gid_index(context, port_num, &grh->dgid);
+ ret = rdma_find_gid_index(context, port_num, &grh->dgid);
if (ret < 0)
return ret;
@@ -436,30 +601,66 @@ 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)
+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)
+{
+ return rdma_init_ah_from_wc((struct rdma_context *) context, port_num,
+ (struct rdma_wc *) wc,
+ (struct rdma_grh *) grh,
+ (struct rdma_ah_attr *) ah_attr);
+}
+
+struct rdma_ah *rdma_create_ah_from_wc(struct rdma_pd *pd, struct rdma_wc *wc,
+ struct rdma_grh *grh, uint8_t port_num)
{
- struct ibv_ah_attr ah_attr;
+ struct rdma_ah_attr ah_attr;
int ret;
- ret = ibv_init_ah_from_wc(pd->context, port_num, wc, grh, &ah_attr);
+ ret = rdma_init_ah_from_wc(pd->context, port_num, wc, grh, &ah_attr);
if (ret)
return NULL;
- return ibv_create_ah(pd, &ah_attr);
+ return rdma_create_ah(pd, &ah_attr);
}
-int ibv_destroy_ah(struct ibv_ah *ah)
+struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
+ struct ibv_grh *grh, uint8_t port_num)
+{
+ return (struct ibv_ah *) rdma_create_ah_from_wc((struct rdma_pd *) pd,
+ (struct rdma_wc *) wc,
+ (struct rdma_grh *) grh,
+ port_num);
+}
+
+int rdma_destroy_ah(struct rdma_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 ibv_destroy_ah(struct ibv_ah *ah)
+{
+ return rdma_destroy_ah((struct rdma_ah *) ah);
+}
+
+int rdma_attach_mcast(struct rdma_qp *qp, union rdma_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 ibv_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+{
+ return rdma_attach_mcast((struct rdma_qp *) qp, (union rdma_gid *) gid,
+ lid);
+}
+
+int rdma_detach_mcast(struct rdma_qp *qp, union rdma_gid *gid, uint16_t lid)
{
return qp->context->ops.detach_mcast(qp, gid, lid);
}
+
+int ibv_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+{
+ return rdma_detach_mcast((struct rdma_qp *) qp, (union rdma_gid *) gid,
+ lid);
+}
More information about the general
mailing list