From patchwork Thu Feb 9 16:59:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Walker, Benjamin" X-Patchwork-Id: 20329 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D1AB6FA8F; Thu, 9 Feb 2017 18:00:22 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 3E3FDFA83 for ; Thu, 9 Feb 2017 18:00:06 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP; 09 Feb 2017 09:00:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,137,1484035200"; d="scan'208"; a="1092813786" Received: from bwalker-desk.ch.intel.com ([143.182.136.68]) by orsmga001.jf.intel.com with ESMTP; 09 Feb 2017 09:00:05 -0800 From: Ben Walker To: dev@dpdk.org Cc: Ben Walker Date: Thu, 9 Feb 2017 09:59:58 -0700 Message-Id: <20170209165959.28082-2-benjamin.walker@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170209165959.28082-1-benjamin.walker@intel.com> References: <1479931644-78960-4-git-send-email-benjamin.walker@intel.com> <20170209165959.28082-1-benjamin.walker@intel.com> Subject: [dpdk-dev] [PATCH v3 2/3] pci: Move driver registration above pci scan X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The user needs to register drivers before scanning, so it makes the most sense to put the registration functions above the scan function in the header file. Signed-off-by: Ben Walker --- Only rebased onto latest master with the rest of this series. No changes. lib/librte_eal/common/include/rte_pci.h | 56 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 8557e47..5640896 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -362,6 +362,34 @@ rte_eal_compare_pci_addr(const struct rte_pci_addr *addr, } /** + * Register a PCI driver. + * + * @param driver + * A pointer to a rte_pci_driver structure describing the driver + * to be registered. + */ +void rte_eal_pci_register(struct rte_pci_driver *driver); + +/** Statically register a PCI driver at start up */ +#define RTE_PMD_REGISTER_PCI(nm, pci_drv) \ +RTE_INIT(pciinitfn_ ##nm); \ +static void pciinitfn_ ##nm(void) \ +{\ + (pci_drv).driver.name = RTE_STR(nm);\ + rte_eal_pci_register(&pci_drv); \ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +/** + * Unregister a PCI driver. + * + * @param driver + * A pointer to a rte_pci_driver structure describing the driver + * to be unregistered. + */ +void rte_eal_pci_unregister(struct rte_pci_driver *driver); + +/** * Scan the content of the PCI bus, and the devices in the devices * list * @@ -480,34 +508,6 @@ int rte_eal_pci_detach(const struct rte_pci_addr *addr); void rte_eal_pci_dump(FILE *f); /** - * Register a PCI driver. - * - * @param driver - * A pointer to a rte_pci_driver structure describing the driver - * to be registered. - */ -void rte_eal_pci_register(struct rte_pci_driver *driver); - -/** Helper for PCI device registration from driver (eth, crypto) instance */ -#define RTE_PMD_REGISTER_PCI(nm, pci_drv) \ -RTE_INIT(pciinitfn_ ##nm); \ -static void pciinitfn_ ##nm(void) \ -{\ - (pci_drv).driver.name = RTE_STR(nm);\ - rte_eal_pci_register(&pci_drv); \ -} \ -RTE_PMD_EXPORT_NAME(nm, __COUNTER__) - -/** - * Unregister a PCI driver. - * - * @param driver - * A pointer to a rte_pci_driver structure describing the driver - * to be unregistered. - */ -void rte_eal_pci_unregister(struct rte_pci_driver *driver); - -/** * Read PCI config space. * * @param device