From patchwork Wed Jan 6 16:17:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86059 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 (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ED3CBA09FF; Wed, 6 Jan 2021 17:18:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C435140E15; Wed, 6 Jan 2021 17:18:10 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 5C45B140E04 for ; Wed, 6 Jan 2021 17:18:05 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 6 Jan 2021 18:18:01 +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 106GI0Mo017451; Wed, 6 Jan 2021 18:18:01 +0200 From: Xueming Li To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Viacheslav Ovsiienko Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Wed, 6 Jan 2021 16:17:35 +0000 Message-Id: <1609949855-23817-10-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1609949855-23817-1-git-send-email-xuemingl@nvidia.com> References: <1609949855-23817-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v2 9/9] eal: allow PCI device with different representors 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 on probed first devargs, ignored other allowed devices with different representor arguments. This patch iterates all devargs and try them all after PCI bus scan. Signed-off-by: Xueming Li --- lib/librte_eal/common/eal_common_bus.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index baa5b532af..47c0243647 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,20 @@ rte_bus_probe(void) vbus->name); } + /* For devargs with same name but different arguments, try them all. */ + RTE_EAL_DEVARGS_FOREACH("pci", 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) + ret = -ENOTSUP; + if (!ret && rte_dev_is_probed(dev)) + RTE_LOG(ERR, EAL, "device probed %s %s", da->name, + da->args); + } + return 0; }