[dpdk-dev] [RFC PATCH 1/4] pmd: Modify PMD_REGISTER_DRIVER to emit a marker symbol

Neil Horman nhorman at tuxdriver.com
Tue Apr 26 19:39:48 CEST 2016


modify PMD_REGISTER_DRIVER so that, when building as a DSO, PMD's emit an
additional set of symbols named this_pmd_driver<n>, where <n> 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 <nhorman at tuxdriver.com>
CC: David Marchand <david.marchand at 6wind.com>
CC: Stephen Hemminger <stephen at networkplumber.org>
CC: "Richardson, Bruce" <bruce.richardson at intel.com>
CC: Panu Matilainen <pmatilai at redhat.com>
CC: Thomas Monjalon <thomas.monjalon at 6wind.com>
---
 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 <sys/queue.h>
 
 #include <rte_log.h>
+#include <rte_config.h>
+#include <rte_common.h>
+#include <rte_pci.h>
 
 __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



More information about the dev mailing list