[v2,9/9] eal: allow PCI device with different representors

Message ID 1609949855-23817-10-git-send-email-xuemingl@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series support SubFunction representor |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing fail Testing issues
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues

Commit Message

Xueming Li Jan. 6, 2021, 4:17 p.m. UTC
  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 <xuemingl@nvidia.com>
---
 lib/librte_eal/common/eal_common_bus.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
  

Patch

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 <rte_debug.h>
 #include <rte_string_fns.h>
 #include <rte_errno.h>
+#include <rte_devargs.h>
 
 #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;
 }