From patchwork Mon Sep 17 15:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10602935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93FCD17E0 for ; Mon, 17 Sep 2018 15:17:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 854DB2A09A for ; Mon, 17 Sep 2018 15:17:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 794DF2A0A5; Mon, 17 Sep 2018 15:17:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86B702A09B for ; Mon, 17 Sep 2018 15:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728718AbeIQUpY (ORCPT ); Mon, 17 Sep 2018 16:45:24 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:44284 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726885AbeIQUpY (ORCPT ); Mon, 17 Sep 2018 16:45:24 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 17 Sep 2018 17:21:51 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w8HFHU1M018633; Mon, 17 Sep 2018 18:17:30 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id w8HFHU9D021536; Mon, 17 Sep 2018 18:17:30 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w8HFHU9p021534; Mon, 17 Sep 2018 18:17:30 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 1/2] Extend verbs_device_ops to get vendor attr as part of alloc_context Date: Mon, 17 Sep 2018 18:17:10 +0300 Message-Id: <1537197431-21441-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1537197431-21441-1-git-send-email-yishaih@mellanox.com> References: <1537197431-21441-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) From patchwork Mon Sep 17 15:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10602933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 750821508 for ; Mon, 17 Sep 2018 15:17:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B9B2A0A5 for ; Mon, 17 Sep 2018 15:17:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C3722A0A7; Mon, 17 Sep 2018 15:17:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFB232A09A for ; Mon, 17 Sep 2018 15:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbeIQUpY (ORCPT ); Mon, 17 Sep 2018 16:45:24 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:44281 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728158AbeIQUpY (ORCPT ); Mon, 17 Sep 2018 16:45:24 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 17 Sep 2018 17:21:51 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w8HFHU0v018643; Mon, 17 Sep 2018 18:17:30 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id w8HFHUQc021540; Mon, 17 Sep 2018 18:17:30 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w8HFHU8j021539; Mon, 17 Sep 2018 18:17:30 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 2/2] mlx5: Enable allocating a DEVX context Date: Mon, 17 Sep 2018 18:17:11 +0300 Message-Id: <1537197431-21441-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1537197431-21441-1-git-send-email-yishaih@mellanox.com> References: <1537197431-21441-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce mlx5dv_open_device() API to Enable allocating a DEVX context. Signed-off-by: Yishai Hadas --- debian/ibverbs-providers.symbols | 1 + providers/mlx5/libmlx5.map | 1 + providers/mlx5/man/CMakeLists.txt | 1 + providers/mlx5/man/mlx5dv_open_device.3.md | 57 ++++++++++++++++++++++++++++++ providers/mlx5/mlx5.c | 21 ++++++++++- providers/mlx5/mlx5dv.h | 12 +++++++ 6 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 providers/mlx5/man/mlx5dv_open_device.3.md diff --git a/debian/ibverbs-providers.symbols b/debian/ibverbs-providers.symbols index 98b4e16..23b0bbf 100644 --- a/debian/ibverbs-providers.symbols +++ b/debian/ibverbs-providers.symbols @@ -27,3 +27,4 @@ libmlx5.so.1 ibverbs-providers #MINVER# mlx5dv_create_flow@MLX5_1.6 20 mlx5dv_create_flow_action_modify_header@MLX5_1.7 21 mlx5dv_create_flow_action_packet_reformat@MLX5_1.7 21 + mlx5dv_open_device@MLX5_1.7 21 diff --git a/providers/mlx5/libmlx5.map b/providers/mlx5/libmlx5.map index ca697b4..a178af6 100644 --- a/providers/mlx5/libmlx5.map +++ b/providers/mlx5/libmlx5.map @@ -45,4 +45,5 @@ MLX5_1.7 { global: mlx5dv_create_flow_action_modify_header; mlx5dv_create_flow_action_packet_reformat; + mlx5dv_open_device; } MLX5_1.6; diff --git a/providers/mlx5/man/CMakeLists.txt b/providers/mlx5/man/CMakeLists.txt index e6f69b5..502bbd4 100644 --- a/providers/mlx5/man/CMakeLists.txt +++ b/providers/mlx5/man/CMakeLists.txt @@ -4,6 +4,7 @@ rdma_man_pages( mlx5dv_flow_action_esp.3.md mlx5dv_get_clock_info.3 mlx5dv_init_obj.3 + mlx5dv_open_device.3.md mlx5dv_query_device.3 mlx5dv_ts_to_ns.3 mlx5dv.7 diff --git a/providers/mlx5/man/mlx5dv_open_device.3.md b/providers/mlx5/man/mlx5dv_open_device.3.md new file mode 100644 index 0000000..8a5876b --- /dev/null +++ b/providers/mlx5/man/mlx5dv_open_device.3.md @@ -0,0 +1,57 @@ +--- +layout: page +title: mlx5dv_open_device +section: 3 +tagline: Verbs +--- + +# NAME + +mlx5dv_open_device - Open an RDMA device context for the mlx5 provider + +# SYNOPSIS + +```c +#include + +struct ibv_context * +mlx5dv_open_device(struct ibv_device *device, struct mlx5dv_context_attr *attr); +``` + +# DESCRIPTION + +Open an RDMA device context with specific mlx5 provider attributes. + +# ARGUMENTS + +*device* +: RDMA device to open. + +## *attr* argument + +```c +struct mlx5dv_context_attr { + uint32_t flags; + uint64_t comp_mask; +}; +``` + +*flags* +: A bitwise OR of the various values described below. + + *MLX5DV_CONTEXT_FLAGS_DEVX*: + Allocate a DEVX context + +*comp_mask* +: Bitmask specifying what fields in the structure are valid + +# RETURN VALUE +Returns a pointer to the allocated device context, or NULL if the request fails. + +# SEE ALSO + +*ibv_open_device(3)* + +# AUTHOR + +Yishai Hadas diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c index 766b61f..57e56c6 100644 --- a/providers/mlx5/mlx5.c +++ b/providers/mlx5/mlx5.c @@ -1000,6 +1000,12 @@ static void adjust_uar_info(struct mlx5_device *mdev, context->num_uars_per_page = resp.num_uars_per_page; } +struct ibv_context * +mlx5dv_open_device(struct ibv_device *device, struct mlx5dv_context_attr *attr) +{ + return verbs_open_device(device, attr); +} + static struct verbs_context *mlx5_alloc_context(struct ibv_device *ibdev, int cmd_fd, void *vendor_attr) @@ -1020,9 +1026,12 @@ static struct verbs_context *mlx5_alloc_context(struct ibv_device *ibdev, int k; int bfi; int num_sys_page_map; + struct mlx5dv_context_attr *ctx_attr = vendor_attr; - if (vendor_attr) + if (ctx_attr && ctx_attr->comp_mask) { + errno = EINVAL; return NULL; + } context = verbs_init_and_alloc_context(ibdev, cmd_fd, context, ibv_ctx, RDMA_DRIVER_MLX5); @@ -1063,6 +1072,16 @@ static struct verbs_context *mlx5_alloc_context(struct ibv_device *ibdev, req.num_low_latency_bfregs = low_lat_uuars; req.max_cqe_version = MLX5_CQE_VERSION_V1; req.lib_caps |= MLX5_LIB_CAP_4K_UAR; + if (ctx_attr && ctx_attr->flags) { + + if (!check_comp_mask(ctx_attr->flags, + MLX5DV_CONTEXT_FLAGS_DEVX)) { + errno = EINVAL; + goto err_free; + } + + req.flags = MLX5_IB_ALLOC_UCTX_DEVX; + } if (mlx5_cmd_get_context(context, &req, sizeof(req), &resp, sizeof(resp))) diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h index bb9aaaa..69af319 100644 --- a/providers/mlx5/mlx5dv.h +++ b/providers/mlx5/mlx5dv.h @@ -996,6 +996,18 @@ static inline uint64_t mlx5dv_ts_to_ns(struct mlx5dv_clock_info *clock_info, return nsec; } +enum mlx5dv_context_attr_flags { + MLX5DV_CONTEXT_FLAGS_DEVX = 1 << 0, +}; + +struct mlx5dv_context_attr { + uint32_t flags; /* Use enum mlx5dv_context_attr_flags */ + uint64_t comp_mask; +}; + +struct ibv_context * +mlx5dv_open_device(struct ibv_device *device, struct mlx5dv_context_attr *attr); + #ifdef __cplusplus } #endif