@@ -35,6 +35,7 @@
#include "ibverbs.h"
#include <sys/ioctl.h>
+#include <infiniband/driver.h>
#include <rdma/ib_user_ioctl_cmds.h>
@@ -125,12 +126,15 @@ static void finalize_attrs(struct ibv_command_buffer *cmd)
int execute_ioctl(struct ibv_context *context, struct ibv_command_buffer *cmd)
{
+ struct verbs_context *vctx = verbs_get_ctx(context);
+
prepare_attrs(cmd);
cmd->hdr.length = sizeof(cmd->hdr) +
sizeof(cmd->hdr.attrs[0]) * cmd->hdr.num_attrs;
cmd->hdr.reserved1 = 0;
cmd->hdr.reserved2 = 0;
+ cmd->hdr.driver_id = vctx->priv->driver_id;
if (ioctl(context->cmd_fd, RDMA_VERBS_IOCTL, &cmd->hdr))
return errno;
@@ -186,7 +186,8 @@ __lib_ibv_create_cq_ex(struct ibv_context *context,
* failure path of this function.
*/
int verbs_init_context(struct verbs_context *context_ex,
- struct ibv_device *device, int cmd_fd)
+ struct ibv_device *device, int cmd_fd,
+ uint32_t driver_id)
{
struct ibv_context *context = &context_ex->context;
@@ -224,6 +225,7 @@ int verbs_init_context(struct verbs_context *context_ex,
return -1;
}
+ context_ex->priv->driver_id = driver_id;
verbs_set_ops(context_ex, &verbs_dummy_ops);
return 0;
@@ -236,7 +238,8 @@ int verbs_init_context(struct verbs_context *context_ex,
*/
void *_verbs_init_and_alloc_context(struct ibv_device *device, int cmd_fd,
size_t alloc_size,
- struct verbs_context *context_offset)
+ struct verbs_context *context_offset,
+ uint32_t driver_id)
{
void *drv_context;
struct verbs_context *context;
@@ -250,7 +253,7 @@ void *_verbs_init_and_alloc_context(struct ibv_device *device, int cmd_fd,
context = drv_context + (uintptr_t)context_offset;
- if (verbs_init_context(context, device, cmd_fd))
+ if (verbs_init_context(context, device, cmd_fd, driver_id))
goto err_free;
return drv_context;
@@ -41,6 +41,7 @@
#include <ccan/list.h>
#include <config.h>
#include <stdbool.h>
+#include <rdma/rdma_user_ioctl_cmds.h>
struct verbs_device;
@@ -300,15 +301,18 @@ void verbs_register_driver(const struct verbs_device_ops *ops);
void *_verbs_init_and_alloc_context(struct ibv_device *device, int cmd_fd,
size_t alloc_size,
- struct verbs_context *context_offset);
+ struct verbs_context *context_offset,
+ uint32_t driver_id);
-#define verbs_init_and_alloc_context(ibdev, cmd_fd, drv_ctx_ptr, ctx_memb) \
+#define verbs_init_and_alloc_context(ibdev, cmd_fd, drv_ctx_ptr, ctx_memb, \
+ driver_id) \
((typeof(drv_ctx_ptr))_verbs_init_and_alloc_context( \
ibdev, cmd_fd, sizeof(*drv_ctx_ptr), \
- &((typeof(drv_ctx_ptr))NULL)->ctx_memb))
+ &((typeof(drv_ctx_ptr))NULL)->ctx_memb, (driver_id)))
int verbs_init_context(struct verbs_context *context_ex,
- struct ibv_device *device, int cmd_fd);
+ struct ibv_device *device, int cmd_fd,
+ uint32_t driver_id);
void verbs_uninit_context(struct verbs_context *context);
void verbs_set_ops(struct verbs_context *vctx,
const struct verbs_context_ops *ops);
@@ -62,6 +62,7 @@ struct verbs_ex_private {
struct ibv_cq_init_attr_ex *init_attr);
uint64_t unsupported_ioctls;
+ uint32_t driver_id;
};
#define IBV_INIT_CMD(cmd, size, opcode) \
@@ -117,7 +117,8 @@ static struct verbs_context *bnxt_re_alloc_context(struct ibv_device *vdev,
struct bnxt_re_dev *dev = to_bnxt_re_dev(vdev);
struct bnxt_re_context *cntx;
- cntx = verbs_init_and_alloc_context(vdev, cmd_fd, cntx, ibvctx);
+ cntx = verbs_init_and_alloc_context(vdev, cmd_fd, cntx, ibvctx,
+ RDMA_DRIVER_BNXT_RE);
if (!cntx)
return NULL;
@@ -125,7 +125,8 @@ static struct verbs_context *iwch_alloc_context(struct ibv_device *ibdev,
struct iwch_alloc_ucontext_resp resp;
struct iwch_device *rhp = to_iwch_dev(ibdev);
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_CXGB3);
if (!context)
return NULL;
@@ -115,7 +115,8 @@ static struct verbs_context *c4iw_alloc_context(struct ibv_device *ibdev,
uint64_t raw_fw_ver;
struct ibv_device_attr attr;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_CXGB4);
if (!context)
return NULL;
@@ -144,7 +144,8 @@ static struct verbs_context *hfi1_alloc_context(struct ibv_device *ibdev,
struct ib_uverbs_get_context_resp resp;
struct hfi1_device *dev;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_HFI1);
if (!context)
return NULL;
@@ -71,7 +71,8 @@ static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
struct hns_roce_alloc_ucontext_resp resp;
struct hns_roce_device *hr_dev = to_hr_dev(ibdev);
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_HNS);
if (!context)
return NULL;
@@ -134,7 +134,8 @@ static struct verbs_context *i40iw_ualloc_context(struct ibv_device *ibdev,
struct i40iw_get_context cmd;
struct i40iw_ualloc_ucontext_resp resp;
- iwvctx = verbs_init_and_alloc_context(ibdev, cmd_fd, iwvctx, ibv_ctx);
+ iwvctx = verbs_init_and_alloc_context(ibdev, cmd_fd, iwvctx, ibv_ctx,
+ RDMA_DRIVER_I40IW);
if (!iwvctx)
return NULL;
@@ -143,7 +143,8 @@ static struct verbs_context *ipath_alloc_context(struct ibv_device *ibdev,
struct ib_uverbs_get_context_resp resp;
struct ipath_device *dev;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_QIB);
if (!context)
return NULL;
@@ -177,7 +177,8 @@ static struct verbs_context *mlx4_alloc_context(struct ibv_device *ibdev,
struct verbs_context *verbs_ctx;
struct ibv_device_attr_ex dev_attrs;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_MLX4);
if (!context)
return NULL;
@@ -974,7 +974,8 @@ static struct verbs_context *mlx5_alloc_context(struct ibv_device *ibdev,
int bfi;
int num_sys_page_map;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_MLX5);
if (!context)
return NULL;
@@ -137,7 +137,8 @@ static struct verbs_context *mthca_alloc_context(struct ibv_device *ibdev,
struct mthca_alloc_ucontext_resp resp;
int i;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_MTHCA);
if (!context)
return NULL;
@@ -109,7 +109,8 @@ static struct verbs_context *nes_ualloc_context(struct ibv_device *ibdev,
page_size = sysconf(_SC_PAGESIZE);
- nesvctx = verbs_init_and_alloc_context(ibdev, cmd_fd, nesvctx, ibv_ctx);
+ nesvctx = verbs_init_and_alloc_context(ibdev, cmd_fd, nesvctx, ibv_ctx,
+ RDMA_DRIVER_NES);
if (!nesvctx)
return NULL;
@@ -112,7 +112,8 @@ static struct verbs_context *ocrdma_alloc_context(struct ibv_device *ibdev,
struct ocrdma_get_context cmd;
struct ocrdma_alloc_ucontext_resp resp;
- ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx);
+ ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx,
+ RDMA_DRIVER_OCRDMA);
if (!ctx)
return NULL;
@@ -162,7 +162,8 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
struct qelr_get_context cmd;
struct qelr_alloc_ucontext_resp resp;
- ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx);
+ ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx,
+ RDMA_DRIVER_QEDR);
if (!ctx)
return NULL;
@@ -862,7 +862,8 @@ static struct verbs_context *rxe_alloc_context(struct ibv_device *ibdev,
struct ibv_get_context cmd;
struct ib_uverbs_get_context_resp resp;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_RXE);
if (!context)
return NULL;
@@ -147,7 +147,8 @@ static struct verbs_context *pvrdma_alloc_context(struct ibv_device *ibdev,
{
struct pvrdma_context *context;
- context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx);
+ context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
+ RDMA_DRIVER_VMW_PVRDMA);
if (!context)
return NULL;