From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id A622F2A1A for ; Tue, 26 Apr 2016 19:40:26 +0200 (CEST) Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1av6yA-0002ln-9B; Tue, 26 Apr 2016 13:40:23 -0400 From: Neil Horman To: dev@dpdk.org Cc: David Marchand , Stephen Hemminger , bruce.richardson@intel.com, Panu Matilainen , Thomas Monjalon , Neil Horman Date: Tue, 26 Apr 2016 13:39:48 -0400 Message-Id: <1461692391-30093-2-git-send-email-nhorman@tuxdriver.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461692391-30093-1-git-send-email-nhorman@tuxdriver.com> References: <1461692391-30093-1-git-send-email-nhorman@tuxdriver.com> X-Spam-Score: -1.0 (-) X-Spam-Status: No Subject: [dpdk-dev] [RFC PATCH 1/4] pmd: Modify PMD_REGISTER_DRIVER to emit a marker symbol X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2016 17:40:26 -0000 modify PMD_REGISTER_DRIVER so that, when building as a DSO, PMD's emit an additional set of symbols named this_pmd_driver, where is an incrementing counter. This gives well known symbol names that external apps can search for when looking up PMD information. These new symbols are aliased to the passed in rte_driver_struct, which future apps can use to interrogate the PMD's for useful information Also modify the rte_driver struct to add a union that can hold pmd type specific information. Currently, only PMD_PDEV uses this to store a pointer to the PMD's pci id table. Signed-off-by: Neil Horman CC: David Marchand CC: Stephen Hemminger CC: "Richardson, Bruce" CC: Panu Matilainen CC: Thomas Monjalon --- lib/librte_eal/common/include/rte_dev.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index f1b5507..a81d901 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -50,6 +50,9 @@ extern "C" { #include #include +#include +#include +#include __attribute__((format(printf, 2, 0))) static inline void @@ -131,6 +134,9 @@ struct rte_driver { const char *name; /**< Driver name. */ rte_dev_init_t *init; /**< Device init. function. */ rte_dev_uninit_t *uninit; /**< Device uninit. function. */ + union { + const struct rte_pci_id *pci_table; + }; }; /** @@ -178,12 +184,27 @@ int rte_eal_vdev_init(const char *name, const char *args); */ int rte_eal_vdev_uninit(const char *name); +#ifdef RTE_BUILD_SHARED_LIB +#define DRIVER_EXPORT_NAME(name, idx) name##idx +#define DECLARE_DRIVER_EXPORT(src, idx)\ +extern struct rte_driver DRIVER_EXPORT_NAME(this_pmd_driver, idx)\ + __attribute__((alias(RTE_STR(src)))) + +#define PMD_REGISTER_DRIVER(d)\ +void devinitfn_ ##d(void);\ +void __attribute__((constructor, used)) devinitfn_ ##d(void)\ +{\ + rte_eal_driver_register(&d);\ +}\ +DECLARE_DRIVER_EXPORT(d, __COUNTER__) +#else #define PMD_REGISTER_DRIVER(d)\ void devinitfn_ ##d(void);\ void __attribute__((constructor, used)) devinitfn_ ##d(void)\ {\ rte_eal_driver_register(&d);\ } +#endif #ifdef __cplusplus } -- 2.5.5