[dpdk-dev] [RFC][PATCH 2/5] pci: allow shared device instances.
Radu Nicolau
radu.nicolau at intel.com
Tue May 9 16:57:56 CEST 2017
Updated PCI initialization code to allow devices to be shared across multiple PMDs.
Signed-off-by: Radu Nicolau <radu.nicolau at intel.com>
---
lib/librte_eal/common/eal_common_pci.c | 15 ++++++++++++---
lib/librte_eal/common/include/rte_pci.h | 18 ++++++++++++++----
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index b749991..8fdc38f 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -203,7 +203,7 @@ static int
rte_pci_probe_one_driver(struct rte_pci_driver *dr,
struct rte_pci_device *dev)
{
- int ret;
+ int ret = 1;
struct rte_pci_addr *loc;
if ((dr == NULL) || (dev == NULL))
@@ -254,6 +254,11 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
rte_pci_unmap_device(dev);
}
+ if (!dr->id_table->shared || ret) {
+ return ret;
+ }
+ /* else continue to parse the table for another match */
+
return ret;
}
@@ -303,6 +308,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
{
struct rte_pci_driver *dr = NULL;
int rc = 0;
+ int res = 1;
if (dev == NULL)
return -1;
@@ -319,9 +325,12 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
if (rc > 0)
/* positive value means driver doesn't support it */
continue;
- return 0;
+ if (dr->id_table->shared)
+ res = 0;
+ else
+ return 0;
}
- return 1;
+ return res;
}
/*
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index ab64c63..3a66ef4 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -135,6 +135,7 @@ struct rte_pci_id {
uint16_t device_id; /**< Device ID or PCI_ANY_ID. */
uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or PCI_ANY_ID. */
uint16_t subsystem_device_id; /**< Subsystem device ID or PCI_ANY_ID. */
+ uint8_t shared; /**< Device can be shared by multiple drivers. */
};
/**
@@ -187,22 +188,31 @@ struct rte_pci_device {
#ifdef __cplusplus
/** C++ macro used to help building up tables of device IDs */
-#define RTE_PCI_DEVICE(vend, dev) \
+#define _RTE_PCI_DEVICE_SH(vend, dev, sh) \
RTE_CLASS_ANY_ID, \
(vend), \
(dev), \
PCI_ANY_ID, \
- PCI_ANY_ID
+ PCI_ANY_ID, \
+ (sh)
#else
/** Macro used to help building up tables of device IDs */
-#define RTE_PCI_DEVICE(vend, dev) \
+#define _RTE_PCI_DEVICE_SH(vend, dev, sh) \
.class_id = RTE_CLASS_ANY_ID, \
.vendor_id = (vend), \
.device_id = (dev), \
.subsystem_vendor_id = PCI_ANY_ID, \
- .subsystem_device_id = PCI_ANY_ID
+ .subsystem_device_id = PCI_ANY_ID, \
+ .shared = (sh)
#endif
+#define RTE_PCI_DEVICE(vend, dev) \
+ _RTE_PCI_DEVICE_SH((vend), (dev), 0)
+#define RTE_PCI_DEVICE_SH(vend, dev) \
+ _RTE_PCI_DEVICE_SH((vend), (dev), 1)
+
+struct rte_pci_driver;
+
/**
* Initialisation function for the driver called during PCI probing.
*/
--
2.7.4
More information about the dev
mailing list