From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 647AEA09FD; Fri, 18 Dec 2020 16:17:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 091B4CADA; Fri, 18 Dec 2020 16:17:12 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 2A291CAD2 for ; Fri, 18 Dec 2020 16:17:10 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 17:17:05 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BIFH4qf010856; Fri, 18 Dec 2020 17:17:05 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 15:16:52 +0000 Message-Id: <1608304614-13908-8-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608304614-13908-1-git-send-email-xuemingl@nvidia.com> References: <1608304614-13908-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 7/9] bus/pci: add new global device syntax support 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" 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