From patchwork Wed Jan 13 13:44:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86468 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F1C9AA04B5; Wed, 13 Jan 2021 14:46:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 415EF140D9E; Wed, 13 Jan 2021 14:45:22 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 61CF5140D64 for ; Wed, 13 Jan 2021 14:45:19 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 13 Jan 2021 15:45:14 +0200 Received: from nvidia.com ([172.27.8.145]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10DDinBF024044; Wed, 13 Jan 2021 15:45:12 +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: Wed, 13 Jan 2021 21:44:22 +0800 Message-Id: <20210113134422.15723-10-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 9/9] eal: probe devices of same PCI but different devargs 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" When probing same PCI device with different representor arguments, PCI bus only probed first devargs, ignored other allowed devices with different representor arguments. This patch iterates all devargs and try them all after bus scan. Signed-off-by: Xueming Li --- lib/librte_eal/common/eal_common_bus.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index baa5b532af..9f88a0fe6e 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "eal_private.h" @@ -56,12 +57,22 @@ rte_bus_scan(void) return 0; } +static int +cmp_dev_name(const struct rte_device *dev, const void *_name) +{ + const char *name = _name; + + return strcmp(dev->name, name); +} + /* Probe all devices of all buses */ int rte_bus_probe(void) { int ret; struct rte_bus *bus, *vbus = NULL; + struct rte_devargs *da; + struct rte_device *dev; TAILQ_FOREACH(bus, &rte_bus_list, next) { if (!strcmp(bus->name, "vdev")) { @@ -82,6 +93,18 @@ rte_bus_probe(void) vbus->name); } + /* For devargs with same name but different arguments, try them all. */ + RTE_EAL_DEVARGS_FOREACH(NULL, da) { + dev = da->bus->find_device(NULL, cmp_dev_name, da->name); + if (!dev || !rte_dev_is_probed(dev) || dev->devargs == da) + continue; + dev->devargs = da; + ret = dev->bus->plug(dev); + if (ret == 0) + RTE_LOG(DEBUG, EAL, "device probed %s %s", da->name, + da->args); + } + return 0; }