[dpdk-dev] [PATCH 20/22] pci: allow drivers to be bound several times to the same PCI device

Thomas Monjalon thomas.monjalon at 6wind.com
Wed Mar 20 17:05:08 CET 2013


From: Adrien Mazarguil <adrien.mazarguil at 6wind.com>

Drivers with the flag RTE_PCI_DRV_MULTIPLE enabled will be bound several
times to the same device until they return an error.

These drivers must internally keep track of each device state in order for
this to work reliably.

This flag is currently required for Ethernet adapters with several physical
ports but a single address on the PCI bus.

It is currently used by librte_pmd_mlx4 that we are developping.

Acked-by: Ivan Boule <ivan.boule at 6wind.com>
Acked-by: Damien Millescamps <damien.millescamps at 6wind.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
---
 lib/librte_eal/common/eal_common_pci.c  |   14 ++++++++++++--
 lib/librte_eal/common/include/rte_pci.h |    3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 73d8fb3..3a6ab70 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -75,6 +76,10 @@ static int is_blacklisted(struct rte_pci_device *dev)
  * If vendor/device ID match, call the devinit() function of all
  * registered driver for the given device. Return -1 if no driver is
  * found for this device.
+ * For drivers with the RTE_PCI_DRV_MULTIPLE flag enabled, register
+ * the same device multiple times until failure to do so.
+ * It is required for non-Intel NIC drivers provided by third-parties such
+ * as 6WIND.
  */
 static int
 pci_probe_all_drivers(struct rte_pci_device *dev)
@@ -83,8 +88,13 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
 
 	dev->blacklisted = !!is_blacklisted(dev);
 	TAILQ_FOREACH(dr, &driver_list, next) {
-		if (rte_eal_pci_probe_one_driver(dr, dev) == 0)
-			return 0;
+		if (rte_eal_pci_probe_one_driver(dr, dev))
+			continue;
+		/* initialize subsequent driver instances for this device */
+		if (dr->drv_flags & RTE_PCI_DRV_MULTIPLE)
+			while (rte_eal_pci_probe_one_driver(dr, dev) == 0)
+				;
+		return 0;
 	}
 	return -1;
 }
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index b465995..1007f51 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  * 
  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013 6WIND.
  *   All rights reserved.
  * 
  *   Redistribution and use in source and binary forms, with or without 
@@ -154,6 +155,8 @@ struct rte_pci_driver {
 
 /**< Device needs igb_uio kernel module */
 #define RTE_PCI_DRV_NEED_IGB_UIO 0x0001
+/**< Device driver must be registered several times until failure */
+#define RTE_PCI_DRV_MULTIPLE 0x0002
 
 /**
  * Probe the PCI bus for registered drivers.
-- 
1.7.2.5




More information about the dev mailing list