From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B85C6A0524; Fri, 8 Jan 2021 15:56:20 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF6B9141038; Fri, 8 Jan 2021 15:55:28 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id B04C9141037 for ; Fri, 8 Jan 2021 15:55:26 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 8 Jan 2021 16:55:22 +0200 Received: from nvidia.com ([172.27.8.145]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 108Et0X3013726; Fri, 8 Jan 2021 16:55:20 +0200 From: Xueming Li To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso Date: Fri, 8 Jan 2021 22:54:41 +0800 Message-Id: <20210108145441.23320-8-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> References: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 7/7] bus/pci: add new global device syntax support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" With new global device syntax, this patch tries to get PCI BDF firstly from bus "addr" argument, fallback to name if not found. Example: -w bus=pci,addr=82:00.0/class=eth/driver=mlx5,dv_flow_en=1 Signed-off-by: Xueming Li --- drivers/bus/pci/pci_common.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 9b8d769287..f6fc80abe8 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "private.h" @@ -48,9 +49,20 @@ pci_devargs_lookup(const struct rte_pci_addr *pci_addr) { struct rte_devargs *devargs; struct rte_pci_addr addr; + struct rte_kvargs *kvlist = NULL; + const char *name; RTE_EAL_DEVARGS_FOREACH("pci", devargs) { - devargs->bus->parse(devargs->name, &addr); + name = NULL; + if (devargs->bus_str) { + kvlist = rte_kvargs_parse(devargs->bus_str, NULL); + name = rte_kvargs_get(kvlist, "id"); + } + if (!name) + name = devargs->name; + devargs->bus->parse(name, &addr); + if (kvlist) + rte_kvargs_free(kvlist); if (!rte_pci_addr_cmp(pci_addr, &addr)) return devargs; } @@ -71,11 +83,11 @@ pci_name_set(struct rte_pci_device *dev) /* When using a blocklist, only blocked devices will have * an rte_devargs. Allowed devices won't have one. */ - if (devargs != NULL) + if (devargs != NULL && strlen(devargs->name)) /* If an rte_devargs exists, the generic rte_device uses the * given name as its name. */ - dev->device.name = dev->device.devargs->name; + dev->device.name = devargs->name; else /* Otherwise, it uses the internal, canonical form. */ dev->device.name = dev->name; -- 2.25.1