From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radu Nicolau Subject: [RFC][PATCH 2/5] pci: allow shared device instances. Date: Tue, 9 May 2017 15:57:56 +0100 Message-ID: <1494341879-18718-3-git-send-email-radu.nicolau@intel.com> References: <1494341879-18718-1-git-send-email-radu.nicolau@intel.com> Cc: Radu Nicolau To: dev@dpdk.org Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1863F68A9 for ; Tue, 9 May 2017 17:01:02 +0200 (CEST) In-Reply-To: <1494341879-18718-1-git-send-email-radu.nicolau@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Updated PCI initialization code to allow devices to be shared across multiple PMDs. Signed-off-by: Radu Nicolau --- 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