From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D9CDA034F; Sun, 28 Mar 2021 15:13:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80D1940042; Sun, 28 Mar 2021 15:13:07 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 9CCF740040 for ; Sun, 28 Mar 2021 15:13:05 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 28 Mar 2021 16:13:04 +0300 Received: from nvidia.com ([172.27.8.64]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 12SDD3jk019987; Sun, 28 Mar 2021 16:13:03 +0300 From: Xueming Li To: Cc: dev@dpdk.org, Dmitry Kozlyuk , Kinsella Ray Date: Sun, 28 Mar 2021 21:12:22 +0800 Message-Id: <20210328131222.16584-1-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316124520.19726-1-xuemingl@nvidia.com> References: <20210316124520.19726-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1] eal: update all buses default scan mode 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 parsing EAL allowed or blocked device arguments, only device bus being parsed got default scan mode updated. If the devargs was vdev, PCI bus default scan mode not touched, all PCI bus devices will got probed even none appear in allowed list. This patch update all buses default scan mode when parsing first devargs. Signed-off-by: Xueming Li --- lib/librte_eal/common/eal_common_bus.c | 15 +++++++++++++++ lib/librte_eal/common/eal_common_devargs.c | 13 +++++-------- lib/librte_eal/common/eal_private.h | 8 ++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index baa5b532af..d5818a456e 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -277,3 +277,18 @@ rte_bus_sigbus_handler(const void *failure_addr) return ret; } + +void +rte_bus_scan_mode_update(enum rte_bus_scan_mode mode) +{ + struct rte_bus *bus; + static bool mode_set; + + if (mode_set) + return; + TAILQ_FOREACH(bus, &rte_bus_list, next) { + if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) + bus->conf.scan_mode = mode; + } + mode_set = true; +} diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index fcf3d9a3cc..3aedcb5c09 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -301,7 +301,6 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) { struct rte_devargs *devargs = NULL; - struct rte_bus *bus = NULL; const char *dev = devargs_str; /* use calloc instead of rte_zmalloc as it's called early at init */ @@ -312,15 +311,13 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) if (rte_devargs_parse(devargs, dev)) goto fail; devargs->type = devtype; - bus = devargs->bus; if (devargs->type == RTE_DEVTYPE_BLOCKED) devargs->policy = RTE_DEV_BLOCKED; - if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { - if (devargs->policy == RTE_DEV_ALLOWED) - bus->conf.scan_mode = RTE_BUS_SCAN_ALLOWLIST; - else if (devargs->policy == RTE_DEV_BLOCKED) - bus->conf.scan_mode = RTE_BUS_SCAN_BLOCKLIST; - } + + if (devargs->policy == RTE_DEV_ALLOWED) + rte_bus_scan_mode_update(RTE_BUS_SCAN_ALLOWLIST); + else if (devargs->policy == RTE_DEV_BLOCKED) + rte_bus_scan_mode_update(RTE_BUS_SCAN_BLOCKLIST); TAILQ_INSERT_TAIL(&devargs_list, devargs, next); return 0; diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index b8a0d20021..ddd6769849 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -452,6 +452,14 @@ int rte_eal_memory_detach(void); */ struct rte_bus *rte_bus_find_by_device_name(const char *str); +/** + * Update all buses scan mode if not set, used by EAL parameter parsing. + * + * @param mode + * Bus scan mode to be set. + */ +void rte_bus_scan_mode_update(enum rte_bus_scan_mode mode); + /** * Create the unix channel for primary/secondary communication. * -- 2.25.1