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