From patchwork Mon Jan 20 17:03:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 64970 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D80B9A0526; Mon, 20 Jan 2020 18:09:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F2E381C0D1; Mon, 20 Jan 2020 18:04:12 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id DCC211BFB3 for ; Mon, 20 Jan 2020 18:03:14 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from asafp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 20 Jan 2020 19:03:14 +0200 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 00KH3BGq024424; Mon, 20 Jan 2020 19:03:14 +0200 From: Matan Azrad To: dev@dpdk.org Cc: Maxime Coquelin , Thomas Monjalon Date: Mon, 20 Jan 2020 17:03:05 +0000 Message-Id: <1579539790-3882-34-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1579539790-3882-1-git-send-email-matan@mellanox.com> References: <1579539790-3882-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH v1 33/38] mlx5: skip probing according to the vDPA mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Both, net/mlx5 PMD and vdpa/mlx5 drivers can probe the same Mellanox devices. Skip net/mlx5 PMD probing while the device is in vDPA mode selected by the device devargs provided by the user: vdpa=1. Skip vdpa/mlx5 PMD probing while the device is not in vDPA mode selected by the device devargs provided by the user: vdpa=1. Signed-off-by: Matan Azrad --- drivers/common/mlx5/Makefile | 2 +- drivers/common/mlx5/meson.build | 2 +- drivers/common/mlx5/mlx5_common.c | 36 +++++++++++++++++++++++++ drivers/common/mlx5/mlx5_common.h | 3 +++ drivers/common/mlx5/rte_common_mlx5_version.map | 1 + drivers/net/mlx5/mlx5.c | 7 ++++- drivers/vdpa/mlx5/mlx5_vdpa.c | 7 ++++- 7 files changed, 54 insertions(+), 4 deletions(-) diff --git a/drivers/common/mlx5/Makefile b/drivers/common/mlx5/Makefile index 82403a2..aeacce3 100644 --- a/drivers/common/mlx5/Makefile +++ b/drivers/common/mlx5/Makefile @@ -42,7 +42,7 @@ else LDLIBS += -libverbs -lmlx5 endif -LDLIBS += -lrte_eal -lrte_pci +LDLIBS += -lrte_eal -lrte_pci -lrte_kvargs # A few warnings cannot be avoided in external headers. CFLAGS += -Wno-error=cast-qual -DNDEBUG -UPEDANTIC diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build index 74419c6..8291a92 100644 --- a/drivers/common/mlx5/meson.build +++ b/drivers/common/mlx5/meson.build @@ -37,7 +37,7 @@ endforeach if build allow_experimental_apis = true - deps += ['hash', 'pci', 'net', 'eal'] + deps += ['hash', 'pci', 'net', 'eal', 'kvargs'] ext_deps += libs sources = files( 'mlx5_devx_cmds.c', diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 2381208..f756b6b 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -71,6 +71,42 @@ return 0; } +static int +mlx5_vdpa_check_handler(__rte_unused const char *key, const char *value, + __rte_unused void *opaque) +{ + if (strcmp(value, "1")) + return -1; + return 0; +} + +int +mlx5_vdpa_mode_selected(struct rte_devargs *devargs) +{ + struct rte_kvargs *kvlist; + const char *key = "vdpa"; + int ret = 0; + + if (devargs == NULL) + return 0; + + kvlist = rte_kvargs_parse(devargs->args, NULL); + if (kvlist == NULL) + return 0; + + if (!rte_kvargs_count(kvlist, key)) + goto exit; + + /* Vdpa mode selected when there's a key-value pair: vdpa=1. */ + if (rte_kvargs_process(kvlist, key, mlx5_vdpa_check_handler, NULL) < 0) + goto exit; + ret = 1; + +exit: + rte_kvargs_free(kvlist); + return ret; +} + #ifdef RTE_IBVERBS_LINK_DLOPEN /** diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 9d464d4..aeaa7b9 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "mlx5_prm.h" @@ -149,5 +151,6 @@ enum mlx5_cqe_status { } int mlx5_dev_to_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr); +int mlx5_vdpa_mode_selected(struct rte_devargs *devargs); #endif /* RTE_PMD_MLX5_COMMON_H_ */ diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map index 37a6902..16b9b34 100644 --- a/drivers/common/mlx5/rte_common_mlx5_version.map +++ b/drivers/common/mlx5/rte_common_mlx5_version.map @@ -24,4 +24,5 @@ DPDK_20.02 { mlx5_devx_get_out_command_status; mlx5_dev_to_pci_addr; + mlx5_vdpa_mode_selected; }; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 75175c9..27cea8b 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2956,7 +2956,12 @@ struct mlx5_flow_id_pool * struct mlx5_dev_config dev_config; int ret; - if (rte_eal_process_type() == RTE_PROC_PRIMARY) + if (mlx5_vdpa_mode_selected(pci_dev->device.devargs)) { + DRV_LOG(DEBUG, "Skip probing - should be probed by the vdpa" + " driver."); + return 1; + } + if (rte_eal_process_type() == RTE_PROC_PRIMARY) mlx5_pmd_socket_init(); ret = mlx5_init_once(); if (ret) { diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index f27a1a4..2ceef18 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -243,7 +243,7 @@ */ static int mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, - struct rte_pci_device *pci_dev __rte_unused) + struct rte_pci_device *pci_dev) { struct ibv_device **ibv_list; struct ibv_device *ibv_match = NULL; @@ -252,6 +252,11 @@ struct mlx5_hca_attr attr; int ret; + if (!mlx5_vdpa_mode_selected(pci_dev->device.devargs)) { + DRV_LOG(DEBUG, "Skip mlx5 vdpa probing - no \"vdpa=1\" in" + " devargs."); + return 1; + } errno = 0; ibv_list = mlx5_glue->get_device_list(&ret); if (!ibv_list) {