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 54A2F45D44; Tue, 19 Nov 2024 16:57:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 274204029B; Tue, 19 Nov 2024 16:57:53 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id CC2D14028A; Tue, 19 Nov 2024 16:57:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732031872; x=1763567872; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=appLAKHq8azyHkdB71Cr/uVAygj/CMSwifrrwijk1xM=; b=DLMIsFvK2jumYzQGhZ37f1Za5cYsLlCdVeaGYEenzOOYB640JlVZ8TkS tbQXaRLidcSvaIW1qNcyJ3ou94DikKQy6tEMLxFHb7vq4OEhW8PShhlKy b+/ScVKUPMIUGrHeq8H2lhZndEat1xzlbWKJ+D8lAQE3Na4Cjt2eiuIo4 Ba+ddEkltRth46LO0ZfDT4ciX3Lh0kjvfzqs3Lg8oN/U5hdt35G+SDxvf wCSuFHZ4G+UNYGJ44gqYiY3Bs+Hd3a/o8iZkbu5OuPLq0UBhoPu4phj70 BSOGNidiTBCtgjjusSyhB39jFxQLmm154zDFu3w/NqCMj7JV+bbRMWXdT Q==; X-CSE-ConnectionGUID: K81E9/sKSzCeiF8PTBia5w== X-CSE-MsgGUID: bHY4xzP9T4+/9N5DXnycMg== X-IronPort-AV: E=McAfee;i="6700,10204,11261"; a="31453785" X-IronPort-AV: E=Sophos;i="6.12,166,1728975600"; d="scan'208";a="31453785" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2024 07:57:51 -0800 X-CSE-ConnectionGUID: JihQr8AVS/eRWvhJh47f7Q== X-CSE-MsgGUID: 1NlBUk7XT4+yCbfqsM9d5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,166,1728975600"; d="scan'208";a="94525886" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.25]) by orviesa005.jf.intel.com with ESMTP; 19 Nov 2024 07:57:49 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Yuanhan Liu Subject: [PATCH] ethdev: allow using devices with shortened PCI addresses Date: Tue, 19 Nov 2024 15:57:22 +0000 Message-ID: <20241119155723.2307189-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 When using a secondary process, e.g. pdump, not all PCI devices will be probed correctly if the primary process has allowlisted devices using the shortened syntax, omitting the initial "0000:" domain. This is due to the strcmp failing to match a full address with a shortened one. Fix this issue by comparing the device names/addresses normally and then having a special case second comparison for devices which start with "0000:". Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") Cc: stable@dpdk.org Signed-off-by: Bruce Richardson --- lib/ethdev/ethdev_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c index 9afef06431..e5590076c1 100644 --- a/lib/ethdev/ethdev_driver.c +++ b/lib/ethdev/ethdev_driver.c @@ -156,6 +156,7 @@ rte_eth_dev_attach_secondary(const char *name) uint16_t i; struct rte_eth_dev *eth_dev = NULL; + /* Synchronize port attachment to primary port creation and release. */ rte_spinlock_lock(rte_mcfg_ethdev_get_lock()); @@ -165,6 +166,11 @@ rte_eth_dev_attach_secondary(const char *name) for (i = 0; i < RTE_MAX_ETHPORTS; i++) { if (strcmp(eth_dev_shared_data->data[i].name, name) == 0) break; + + /* for PCI devices, allow specifying name without a leading "0000:" */ + if (strncmp(name, "0000:", 5) == 0 && /* is PCI address */ + strcmp(eth_dev_shared_data->data[i].name, &name[5]) == 0) + break; } if (i == RTE_MAX_ETHPORTS) { RTE_ETHDEV_LOG_LINE(ERR, -- 2.43.0