[PATCH rdma-core 1/2] Extend verbs_device_ops to get vendor attr as part of alloc_context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 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(-)

diff --git a/libibverbs/device.c b/libibverbs/device.c
index 448795a..c794d13 100644
--- a/libibverbs/device.c
+++ b/libibverbs/device.c
@@ -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);
diff --git a/libibverbs/driver.h b/libibverbs/driver.h
index 50962f8..7e88b35 100644
--- a/libibverbs/driver.h
+++ b/libibverbs/driver.h
@@ -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);
diff --git a/libibverbs/libibverbs.map.in b/libibverbs/libibverbs.map.in
index 80ef2a1..bc8481a 100644
--- a/libibverbs/libibverbs.map.in
+++ b/libibverbs/libibverbs.map.in
@@ -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;
diff --git a/providers/bnxt_re/main.c b/providers/bnxt_re/main.c
index 54e3cc3..178caa7 100644
--- a/providers/bnxt_re/main.c
+++ b/providers/bnxt_re/main.c
@@ -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)
diff --git a/providers/cxgb3/iwch.c b/providers/cxgb3/iwch.c
index a92403d..1de2cb0 100644
--- a/providers/cxgb3/iwch.c
+++ b/providers/cxgb3/iwch.c
@@ -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)
diff --git a/providers/cxgb4/dev.c b/providers/cxgb4/dev.c
index 943b7f0..20d5466 100644
--- a/providers/cxgb4/dev.c
+++ b/providers/cxgb4/dev.c
@@ -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)
diff --git a/providers/hfi1verbs/hfiverbs.c b/providers/hfi1verbs/hfiverbs.c
index 2c70e48..a206d41 100644
--- a/providers/hfi1verbs/hfiverbs.c
+++ b/providers/hfi1verbs/hfiverbs.c
@@ -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)
diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
index 7536646..f39c691 100644
--- a/providers/hns/hns_roce_u.c
+++ b/providers/hns/hns_roce_u.c
@@ -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)
diff --git a/providers/i40iw/i40iw_umain.c b/providers/i40iw/i40iw_umain.c
index 467709f..d4aa640 100644
--- a/providers/i40iw/i40iw_umain.c
+++ b/providers/i40iw/i40iw_umain.c
@@ -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)
diff --git a/providers/ipathverbs/ipathverbs.c b/providers/ipathverbs/ipathverbs.c
index 95715d9..76a9c32 100644
--- a/providers/ipathverbs/ipathverbs.c
+++ b/providers/ipathverbs/ipathverbs.c
@@ -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)
diff --git a/providers/mlx4/mlx4.c b/providers/mlx4/mlx4.c
index a0d3505..d314ea1 100644
--- a/providers/mlx4/mlx4.c
+++ b/providers/mlx4/mlx4.c
@@ -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)
diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c
index d4521e7..766b61f 100644
--- a/providers/mlx5/mlx5.c
+++ b/providers/mlx5/mlx5.c
@@ -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)
diff --git a/providers/mthca/mthca.c b/providers/mthca/mthca.c
index 9ffc979..4e4d3cd 100644
--- a/providers/mthca/mthca.c
+++ b/providers/mthca/mthca.c
@@ -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)
diff --git a/providers/nes/nes_umain.c b/providers/nes/nes_umain.c
index dce46e6..979766d 100644
--- a/providers/nes/nes_umain.c
+++ b/providers/nes/nes_umain.c
@@ -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,
diff --git a/providers/ocrdma/ocrdma_main.c b/providers/ocrdma/ocrdma_main.c
index c3df474..ad96d77 100644
--- a/providers/ocrdma/ocrdma_main.c
+++ b/providers/ocrdma/ocrdma_main.c
@@ -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)
diff --git a/providers/qedr/qelr_main.c b/providers/qedr/qelr_main.c
index 40742fb..4461799 100644
--- a/providers/qedr/qelr_main.c
+++ b/providers/qedr/qelr_main.c
@@ -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)
diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c
index b9b6c6f..4481e11 100644
--- a/providers/rxe/rxe.c
+++ b/providers/rxe/rxe.c
@@ -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)
diff --git a/providers/vmw_pvrdma/pvrdma_main.c b/providers/vmw_pvrdma/pvrdma_main.c
index 2c79094..ba88fe8 100644
--- a/providers/vmw_pvrdma/pvrdma_main.c
+++ b/providers/vmw_pvrdma/pvrdma_main.c
@@ -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)
-- 
1.8.3.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux