@@ -266,9 +266,7 @@ static void set_lib_ops(struct verbs_context *vctx)
vctx->create_cq_ex = __lib_ibv_create_cq_ex;
}
-LATEST_SYMVER_FUNC(ibv_open_device, 1_1, "IBVERBS_1.1",
- struct ibv_context *,
- struct ibv_device *device)
+struct ibv_context *verbs_open_device(struct ibv_device *device, void *vendor_attr)
{
struct verbs_device *verbs_device = verbs_get_device(device);
char *devpath;
@@ -292,7 +290,7 @@ LATEST_SYMVER_FUNC(ibv_open_device, 1_1, "IBVERBS_1.1",
* cmd_fd ownership is transferred into alloc_context, if it fails
* then it closes cmd_fd and returns NULL
*/
- context_ex = verbs_device->ops->alloc_context(device, cmd_fd);
+ context_ex = verbs_device->ops->alloc_context(device, cmd_fd, vendor_attr);
if (!context_ex)
return NULL;
@@ -301,6 +299,13 @@ LATEST_SYMVER_FUNC(ibv_open_device, 1_1, "IBVERBS_1.1",
return &context_ex->context;
}
+LATEST_SYMVER_FUNC(ibv_open_device, 1_1, "IBVERBS_1.1",
+ struct ibv_context *,
+ struct ibv_device *device)
+{
+ return verbs_open_device(device, NULL);
+}
+
void verbs_uninit_context(struct verbs_context *context_ex)
{
free(context_ex->priv);
@@ -187,7 +187,8 @@ struct verbs_device_ops {
bool (*match_device)(struct verbs_sysfs_dev *sysfs_dev);
struct verbs_context *(*alloc_context)(struct ibv_device *device,
- int cmd_fd);
+ int cmd_fd,
+ void *vendor_attr);
void (*free_context)(struct ibv_context *context);
struct verbs_device *(*alloc_device)(struct verbs_sysfs_dev *sysfs_dev);
@@ -383,6 +384,8 @@ void verbs_init_cq(struct ibv_cq *cq, struct ibv_context *context,
struct ibv_comp_channel *channel,
void *cq_context);
+struct ibv_context *verbs_open_device(struct ibv_device *device,
+ void *vendor_attr);
int ibv_cmd_get_context(struct verbs_context *context,
struct ibv_get_context *cmd, size_t cmd_size,
struct ib_uverbs_get_context_resp *resp, size_t resp_size);
@@ -178,6 +178,7 @@ IBVERBS_PRIVATE_@IBVERBS_PABI_VERSION@ {
ibv_query_gid_type;
ibv_register_driver;
verbs_allow_disassociate_destroy;
+ verbs_open_device;
verbs_register_driver_@IBVERBS_PABI_VERSION@;
verbs_set_ops;
verbs_uninit_context;
@@ -110,13 +110,17 @@ static const struct verbs_context_ops bnxt_re_cntx_ops = {
/* Context Init functions */
static struct verbs_context *bnxt_re_alloc_context(struct ibv_device *vdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct ibv_get_context cmd;
struct ubnxt_re_cntx_resp resp;
struct bnxt_re_dev *dev = to_bnxt_re_dev(vdev);
struct bnxt_re_context *cntx;
+ if (vendor_attr)
+ return NULL;
+
cntx = verbs_init_and_alloc_context(vdev, cmd_fd, cntx, ibvctx,
RDMA_DRIVER_BNXT_RE);
if (!cntx)
@@ -118,13 +118,17 @@ unsigned long iwch_page_shift;
unsigned long iwch_page_mask;
static struct verbs_context *iwch_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct iwch_context *context;
struct ibv_get_context cmd;
struct uiwch_alloc_ucontext_resp resp;
struct iwch_device *rhp = to_iwch_dev(ibdev);
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_CXGB3);
if (!context)
@@ -106,7 +106,8 @@ static const struct verbs_context_ops c4iw_ctx_t4_ops = {
};
static struct verbs_context *c4iw_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct c4iw_context *context;
struct ibv_get_context cmd;
@@ -116,6 +117,9 @@ static struct verbs_context *c4iw_alloc_context(struct ibv_device *ibdev,
uint64_t raw_fw_ver;
struct ibv_device_attr attr;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_CXGB4);
if (!context)
@@ -137,13 +137,17 @@ static const struct verbs_context_ops hfi1_ctx_v1_ops = {
};
static struct verbs_context *hfi1_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct hfi1_context *context;
struct ibv_get_context cmd;
struct ib_uverbs_get_context_resp resp;
struct hfi1_device *dev;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_HFI1);
if (!context)
@@ -78,7 +78,8 @@ static const struct verbs_context_ops hns_common_ops = {
};
static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
int i;
struct ibv_get_context cmd;
@@ -87,6 +88,9 @@ 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);
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_HNS);
if (!context)
@@ -127,13 +127,17 @@ static const struct verbs_context_ops i40iw_uctx_ops = {
*/
static struct verbs_context *i40iw_ualloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct ibv_pd *ibv_pd;
struct i40iw_uvcontext *iwvctx;
struct i40iw_get_context cmd;
struct i40iw_get_context_resp resp;
+ if (vendor_attr)
+ return NULL;
+
iwvctx = verbs_init_and_alloc_context(ibdev, cmd_fd, iwvctx, ibv_ctx,
RDMA_DRIVER_I40IW);
if (!iwvctx)
@@ -136,13 +136,17 @@ static const struct verbs_context_ops ipath_ctx_v1_ops = {
};
static struct verbs_context *ipath_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct ipath_context *context;
struct ibv_get_context cmd;
struct ib_uverbs_get_context_resp resp;
struct ipath_device *dev;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_QIB);
if (!context)
@@ -155,7 +155,8 @@ static int mlx4_map_internal_clock(struct mlx4_device *mdev,
}
static struct verbs_context *mlx4_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct mlx4_context *context;
struct ibv_get_context cmd;
@@ -167,6 +168,9 @@ static struct verbs_context *mlx4_alloc_context(struct ibv_device *ibdev,
struct verbs_context *verbs_ctx;
struct ibv_device_attr_ex dev_attrs;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_MLX4);
if (!context)
@@ -1001,7 +1001,8 @@ static void adjust_uar_info(struct mlx5_device *mdev,
}
static struct verbs_context *mlx5_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct mlx5_context *context;
struct mlx5_alloc_ucontext req;
@@ -1020,6 +1021,9 @@ static struct verbs_context *mlx5_alloc_context(struct ibv_device *ibdev,
int bfi;
int num_sys_page_map;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_MLX5);
if (!context)
@@ -130,13 +130,17 @@ static const struct verbs_context_ops mthca_ctx_tavor_ops = {
};
static struct verbs_context *mthca_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct mthca_context *context;
struct ibv_get_context cmd;
struct umthca_alloc_ucontext_resp resp;
int i;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_MTHCA);
if (!context)
@@ -98,7 +98,8 @@ static const struct verbs_context_ops nes_uctx_no_db_ops = {
* nes_ualloc_context
*/
static struct verbs_context *nes_ualloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct ibv_pd *ibv_pd;
struct nes_uvcontext *nesvctx;
@@ -107,6 +108,9 @@ static struct verbs_context *nes_ualloc_context(struct ibv_device *ibdev,
char value[16];
uint32_t nes_drv_opt = 0;
+ if (vendor_attr)
+ return NULL;
+
page_size = sysconf(_SC_PAGESIZE);
nesvctx = verbs_init_and_alloc_context(ibdev, cmd_fd, nesvctx, ibv_ctx,
@@ -106,12 +106,16 @@ static void ocrdma_uninit_device(struct verbs_device *verbs_device)
* ocrdma_alloc_context
*/
static struct verbs_context *ocrdma_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct ocrdma_devctx *ctx;
struct uocrdma_get_context cmd;
struct uocrdma_get_context_resp resp;
+ if (vendor_attr)
+ return NULL;
+
ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx,
RDMA_DRIVER_OCRDMA);
if (!ctx)
@@ -161,12 +161,16 @@ static void qelr_set_debug_mask(void)
}
static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct qelr_devctx *ctx;
struct qelr_get_context cmd;
struct qelr_get_context_resp resp;
+ if (vendor_attr)
+ return NULL;
+
ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx,
RDMA_DRIVER_QEDR);
if (!ctx)
@@ -855,12 +855,16 @@ static const struct verbs_context_ops rxe_ctx_ops = {
};
static struct verbs_context *rxe_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct rxe_context *context;
struct ibv_get_context cmd;
struct ib_uverbs_get_context_resp resp;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_RXE);
if (!context)
@@ -143,10 +143,14 @@ static void pvrdma_free_context_shared(struct pvrdma_context *context,
}
static struct verbs_context *pvrdma_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
+ int cmd_fd,
+ void *vendor_attr)
{
struct pvrdma_context *context;
+ if (vendor_attr)
+ return NULL;
+
context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx,
RDMA_DRIVER_VMW_PVRDMA);
if (!context)
Extend verbs_device_ops to get vendor attr as part of alloc_context, this functionality is used in downstream patch by mlx5 driver to allocate a DEVX context. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> --- libibverbs/device.c | 13 +++++++++---- libibverbs/driver.h | 5 ++++- libibverbs/libibverbs.map.in | 1 + providers/bnxt_re/main.c | 6 +++++- providers/cxgb3/iwch.c | 6 +++++- providers/cxgb4/dev.c | 6 +++++- providers/hfi1verbs/hfiverbs.c | 6 +++++- providers/hns/hns_roce_u.c | 6 +++++- providers/i40iw/i40iw_umain.c | 6 +++++- providers/ipathverbs/ipathverbs.c | 6 +++++- providers/mlx4/mlx4.c | 6 +++++- providers/mlx5/mlx5.c | 6 +++++- providers/mthca/mthca.c | 6 +++++- providers/nes/nes_umain.c | 6 +++++- providers/ocrdma/ocrdma_main.c | 6 +++++- providers/qedr/qelr_main.c | 6 +++++- providers/rxe/rxe.c | 6 +++++- providers/vmw_pvrdma/pvrdma_main.c | 6 +++++- 18 files changed, 89 insertions(+), 20 deletions(-)