]> git.droids-corp.org - dpdk.git/commitdiff
bus: fix driver registration
authorThomas Monjalon <thomas@monjalon.net>
Fri, 7 Jul 2017 00:03:07 +0000 (02:03 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 8 Jul 2017 20:27:01 +0000 (22:27 +0200)
The bus name was stored with embedded double quotes.
Indeed the bus name is given with a string in a macro,
which is not used elsewhere.
These macros are useless because the buses are drivers,
so they must not have any API for the application writer.
The registration can be done with a hardcoded value without quotes.

There is another (small) benefit of not using macros for driver names:
it is to have a meaningful constructor function name.
For instance, it was businitfn_PCI_BUS_NAME instead of businitfn_pci.

The bus registration macro is also changed to use
the new RTE_INIT_PRIO macro, similar to RTE_INIT used for other drivers.
The priority is the highest (101) in order to be sure that the bus driver
is registered before its device drivers.

Fixes: 0fd1a0eaae19 ("pci: add bus driver")
Fixes: fea892e35f21 ("bus/vdev: use standard bus registration")
Fixes: 7e7df6d0a41d ("bus/fslmc: introduce fsl-mc bus driver")
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
drivers/bus/fslmc/fslmc_bus.c
drivers/bus/fslmc/rte_fslmc.h
lib/librte_eal/common/eal_common_bus.c
lib/librte_eal/common/eal_common_dev.c
lib/librte_eal/common/eal_common_pci.c
lib/librte_eal/common/eal_common_vdev.c
lib/librte_eal/common/include/rte_bus.h
lib/librte_eal/common/include/rte_eal.h
lib/librte_eal/common/include/rte_pci.h
lib/librte_eal/common/include/rte_vdev.h

index 88b969c073a0fecae00dfca0976cbb6b13c5aeba..c5f255425870b283f4e6460d5f1039b40a4bf702 100644 (file)
@@ -159,4 +159,4 @@ struct rte_fslmc_bus rte_fslmc_bus = {
        .driver_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.driver_list),
 };
 
-RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
+RTE_REGISTER_BUS(fslmc, rte_fslmc_bus.bus);
index 040ab958832ecbdcc933722d2b57446efc172828..8f35278155cc6d5c3ecc0e3a1c860f3906621f56 100644 (file)
@@ -56,9 +56,6 @@ extern "C" {
 #include <rte_dev.h>
 #include <rte_bus.h>
 
-/** Name of FSLMC Bus */
-#define FSLMC_BUS_NAME "FSLMC"
-
 struct rte_dpaa2_driver;
 
 /* DPAA2 Device and Driver lists for FSLMC bus */
index 997009d2b8d0ee8354274f14edbe94bb9b295c18..96eb4fd52a62791546dcbde103db9511c0d4ce87 100644 (file)
@@ -92,7 +92,7 @@ rte_bus_probe(void)
        struct rte_bus *bus, *vbus = NULL;
 
        TAILQ_FOREACH(bus, &rte_bus_list, next) {
-               if (!strcmp(bus->name, "virtual")) {
+               if (!strcmp(bus->name, "vdev")) {
                        vbus = bus;
                        continue;
                }
index 4ee52fdad4c0138de352e6e0d6c0f24395dca021..32e12b5b9f3f99ce9579a4dfa70600fbbbf23116 100644 (file)
@@ -74,7 +74,7 @@ int rte_eal_dev_attach(const char *name, const char *devargs)
                return -EINVAL;
        }
 
-       ret = rte_eal_hotplug_add("PCI", name, devargs);
+       ret = rte_eal_hotplug_add("pci", name, devargs);
        if (ret && ret != -EINVAL)
                return ret;
 
index 15991b5e96400489e336691e61cb64875974f689..f3830a142ad4df11a443c99f56d8741009b90331 100644 (file)
@@ -547,4 +547,4 @@ struct rte_pci_bus rte_pci_bus = {
        .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
 };
 
-RTE_REGISTER_BUS(PCI_BUS_NAME, rte_pci_bus.bus);
+RTE_REGISTER_BUS(pci, rte_pci_bus.bus);
index 9ec62f4d4deab06b66df9241046f25337b32859b..b3570f9a8310a3015963f088d16a102c76c6e0d2 100644 (file)
@@ -372,4 +372,4 @@ static struct rte_bus rte_vdev_bus = {
        .unplug = vdev_unplug,
 };
 
-RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus);
+RTE_REGISTER_BUS(vdev, rte_vdev_bus);
index 2f1c911f7eb118f05d916f2948f7ae1b52aa91fa..773b0d7af42eb1c6e5a1ee0a65980456d20ccf2b 100644 (file)
@@ -256,7 +256,8 @@ struct rte_bus *rte_bus_find_by_name(const char *busname);
  * The constructor has higher priority than PMD constructors.
  */
 #define RTE_REGISTER_BUS(nm, bus) \
-static void __attribute__((constructor(101), used)) businitfn_ ##nm(void) \
+RTE_INIT_PRIO(businitfn_ ##nm, 101); \
+static void businitfn_ ##nm(void) \
 {\
        (bus).name = RTE_STR(nm);\
        rte_bus_register(&bus); \
index abf020bf99a3a23a2d7025c5e8cbe892efd2c74c..6b7c5ca92b14b768ef955c67f3ead4786c247a83 100644 (file)
@@ -286,6 +286,9 @@ static inline int rte_gettid(void)
 #define RTE_INIT(func) \
 static void __attribute__((constructor, used)) func(void)
 
+#define RTE_INIT_PRIO(func, prio) \
+static void __attribute__((constructor(prio), used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
index e416714b32ff3b9995834815adf0fa011a7cae91..406d91828a3465c690235d6050e7602ee85a0afe 100644 (file)
@@ -77,9 +77,6 @@ const char *pci_get_sysfs_path(void);
 /** Maximum number of PCI resources. */
 #define PCI_MAX_RESOURCE 6
 
-/** Name of PCI Bus */
-#define PCI_BUS_NAME "PCI"
-
 /* Forward declarations */
 struct rte_pci_device;
 struct rte_pci_driver;
index 2d02c68d734a5fe1144a91a238b6acd23cc1f5e3..e6b678ea32cd656d860251dec966247fcf7fd66b 100644 (file)
@@ -41,8 +41,6 @@ extern "C" {
 #include <rte_dev.h>
 #include <rte_devargs.h>
 
-#define VIRTUAL_BUS_NAME "virtual"
-
 struct rte_vdev_device {
        TAILQ_ENTRY(rte_vdev_device) next;      /**< Next attached vdev */
        struct rte_device device;               /**< Inherit core device */