drivers: use PCI registration macro
authorDavid Marchand <david.marchand@6wind.com>
Tue, 20 Sep 2016 12:41:20 +0000 (18:11 +0530)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 3 Oct 2016 14:33:23 +0000 (16:33 +0200)
Simplify crypto and ethdev pci drivers init by using newly introduced
init macros and helpers.
Those drivers then don't need to register as "rte_driver"s anymore.

Exceptions:
- virtio and mlx* use RTE_INIT directly as they have custom initialization
  steps.
- VDEV devices are not modified - they continue to use PMD_REGISTER_DRIVER.

Update documentation for replacing an example referring to
PMD_REGISTER_DRIVER.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
28 files changed:
doc/guides/prog_guide/dev_kit_build_system.rst
drivers/crypto/qat/rte_qat_cryptodev.c
drivers/net/bnx2x/bnx2x_ethdev.c
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/cxgbe/cxgbe_ethdev.c
drivers/net/e1000/em_ethdev.c
drivers/net/e1000/igb_ethdev.c
drivers/net/ena/ena_ethdev.c
drivers/net/enic/enic_ethdev.c
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/i40e/i40e_ethdev_vf.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/mlx4/mlx4.c
drivers/net/mlx5/mlx5.c
drivers/net/nfp/nfp_net.c
drivers/net/qede/qede_ethdev.c
drivers/net/szedata2/rte_eth_szedata2.c
drivers/net/thunderx/nicvf_ethdev.c
drivers/net/virtio/virtio_ethdev.c
drivers/net/vmxnet3/vmxnet3_ethdev.c
lib/librte_cryptodev/rte_cryptodev.c
lib/librte_cryptodev/rte_cryptodev_pmd.h
lib/librte_cryptodev/rte_cryptodev_version.map
lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h
lib/librte_ether/rte_ether_version.map
mk/internal/rte.compile-pre.mk

index 952146e..05358d0 100644 (file)
@@ -264,7 +264,7 @@ instance the macro:
 
 .. code-block:: c
 
-   PMD_REGISTER_DRIVER(drv, name)
+   DRIVER_REGISTER_PCI(name, drv)
 
 Creates the following symbol:
 
index 1e9e0ba..170ae78 100644 (file)
@@ -116,23 +116,13 @@ static struct rte_cryptodev_driver rte_qat_pmd = {
        .pci_drv = {
                .id_table = pci_id_qat_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+               .probe = rte_cryptodev_pci_probe,
+               .remove = rte_cryptodev_pci_remove,
        },
        .cryptodev_init = crypto_qat_dev_init,
        .dev_private_size = sizeof(struct qat_pmd_private),
 };
 
-static int
-rte_qat_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-       return rte_cryptodev_pmd_driver_register(&rte_qat_pmd, PMD_PDEV);
-}
-
-static struct rte_driver pmd_qat_drv = {
-       .type = PMD_PDEV,
-       .init = rte_qat_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(pmd_qat_drv, CRYPTODEV_NAME_QAT_SYM_PMD);
+DRIVER_REGISTER_PCI(CRYPTODEV_NAME_QAT_SYM_PMD, rte_qat_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(CRYPTODEV_NAME_QAT_SYM_PMD, pci_id_qat_map);
 
index dcd2d77..7d9ecdf 100644 (file)
@@ -621,6 +621,8 @@ static struct eth_driver rte_bnx2x_pmd = {
                .name = "rte_bnx2x_pmd",
                .id_table = pci_id_bnx2x_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_bnx2x_dev_init,
        .dev_private_size = sizeof(struct bnx2x_softc),
@@ -634,38 +636,14 @@ static struct eth_driver rte_bnx2xvf_pmd = {
                .name = "rte_bnx2xvf_pmd",
                .id_table = pci_id_bnx2xvf_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_bnx2xvf_dev_init,
        .dev_private_size = sizeof(struct bnx2x_softc),
 };
 
-static int rte_bnx2x_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-       rte_eth_driver_register(&rte_bnx2x_pmd);
-
-       return 0;
-}
-
-static int rte_bnx2xvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-       rte_eth_driver_register(&rte_bnx2xvf_pmd);
-
-       return 0;
-}
-
-static struct rte_driver rte_bnx2x_driver = {
-       .type = PMD_PDEV,
-       .init = rte_bnx2x_pmd_init,
-};
-
-static struct rte_driver rte_bnx2xvf_driver = {
-       .type = PMD_PDEV,
-       .init = rte_bnx2xvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_bnx2x_driver, net_bnx2x);
+DRIVER_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_bnx2x, pci_id_bnx2x_map);
-PMD_REGISTER_DRIVER(rte_bnx2xvf_driver, net_bnx2xvf);
+DRIVER_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
index f4eedfd..d389fc8 100644 (file)
@@ -1048,23 +1048,13 @@ static struct eth_driver bnxt_rte_pmd = {
                    .name = "rte_" DRV_MODULE_NAME "_pmd",
                    .id_table = bnxt_pci_id_map,
                    .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+                   .probe = rte_eth_dev_pci_probe,
+                   .remove = rte_eth_dev_pci_remove
                    },
        .eth_dev_init = bnxt_dev_init,
        .eth_dev_uninit = bnxt_dev_uninit,
        .dev_private_size = sizeof(struct bnxt),
 };
 
-static int bnxt_rte_pmd_init(const char *name, const char *params __rte_unused)
-{
-       RTE_LOG(INFO, PMD, "bnxt_rte_pmd_init() called for %s\n", name);
-       rte_eth_driver_register(&bnxt_rte_pmd);
-       return 0;
-}
-
-static struct rte_driver bnxt_pmd_drv = {
-       .type = PMD_PDEV,
-       .init = bnxt_rte_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(bnxt_pmd_drv, net_bnxt);
+DRIVER_REGISTER_PCI(net_bnxt, bnxt_rte_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_bnxt, bnxt_pci_id_map);
index 7b7bfdf..bb929a9 100644 (file)
@@ -1042,30 +1042,12 @@ static struct eth_driver rte_cxgbe_pmd = {
                .name = "rte_cxgbe_pmd",
                .id_table = cxgb4_pci_tbl,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_cxgbe_dev_init,
        .dev_private_size = sizeof(struct port_info),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI CXGBE devices.
- */
-static int rte_cxgbe_pmd_init(const char *name __rte_unused,
-                             const char *params __rte_unused)
-{
-       CXGBE_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_cxgbe_pmd);
-       return 0;
-}
-
-static struct rte_driver rte_cxgbe_driver = {
-       .type = PMD_PDEV,
-       .init = rte_cxgbe_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_cxgbe_driver, net_cxgbe);
+DRIVER_REGISTER_PCI(net_cxgbe, rte_cxgbe_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_cxgbe, cxgb4_pci_tbl);
-
index c5bf294..d4914a5 100644 (file)
@@ -395,19 +395,14 @@ static struct eth_driver rte_em_pmd = {
                .id_table = pci_id_em_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
                        RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_em_dev_init,
        .eth_dev_uninit = eth_em_dev_uninit,
        .dev_private_size = sizeof(struct e1000_adapter),
 };
 
-static int
-rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-       rte_eth_driver_register(&rte_em_pmd);
-       return 0;
-}
-
 static int
 em_hw_init(struct e1000_hw *hw)
 {
@@ -1799,10 +1794,5 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
        return 0;
 }
 
-struct rte_driver em_pmd_drv = {
-       .type = PMD_PDEV,
-       .init = rte_em_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(em_pmd_drv, net_e1000_em);
+DRIVER_REGISTER_PCI(net_e1000_em, rte_em_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_e1000_em, pci_id_em_map);
index f7cfa18..c54c8e8 100644 (file)
@@ -1082,6 +1082,8 @@ static struct eth_driver rte_igb_pmd = {
                .id_table = pci_id_igb_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
                        RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_igb_dev_init,
        .eth_dev_uninit = eth_igb_dev_uninit,
@@ -1096,19 +1098,14 @@ static struct eth_driver rte_igbvf_pmd = {
                .name = "rte_igbvf_pmd",
                .id_table = pci_id_igbvf_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_igbvf_dev_init,
        .eth_dev_uninit = eth_igbvf_dev_uninit,
        .dev_private_size = sizeof(struct e1000_adapter),
 };
 
-static int
-rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-       rte_eth_driver_register(&rte_igb_pmd);
-       return 0;
-}
-
 static void
 igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
 {
@@ -1120,20 +1117,6 @@ igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
        E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 }
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices.
- */
-static int
-rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_igbvf_pmd);
-       return 0;
-}
-
 static int
 igb_check_mq_mode(struct rte_eth_dev *dev)
 {
@@ -5084,16 +5067,6 @@ eth_igb_set_eeprom(struct rte_eth_dev *dev,
        return nvm->ops.write(hw,  first, length, data);
 }
 
-static struct rte_driver pmd_igb_drv = {
-       .type = PMD_PDEV,
-       .init = rte_igb_pmd_init,
-};
-
-static struct rte_driver pmd_igbvf_drv = {
-       .type = PMD_PDEV,
-       .init = rte_igbvf_pmd_init,
-};
-
 static int
 eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
@@ -5255,7 +5228,7 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
        E1000_WRITE_FLUSH(hw);
 }
 
-PMD_REGISTER_DRIVER(pmd_igb_drv, net_e1000_igb);
+DRIVER_REGISTER_PCI(net_e1000_igb, rte_igb_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_e1000_igb, pci_id_igb_map);
-PMD_REGISTER_DRIVER(pmd_igbvf_drv, net_e1000_igb_vf);
+DRIVER_REGISTER_PCI(net_e1000_igb_vf, rte_igbvf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_e1000_igb_vf, pci_id_igbvf_map);
index f2e7c34..85c5086 100644 (file)
@@ -1689,23 +1689,12 @@ static struct eth_driver rte_ena_pmd = {
                .name = "rte_ena_pmd",
                .id_table = pci_id_ena_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_ena_dev_init,
        .dev_private_size = sizeof(struct ena_adapter),
 };
 
-static int
-rte_ena_pmd_init(const char *name __rte_unused,
-                const char *params __rte_unused)
-{
-       rte_eth_driver_register(&rte_ena_pmd);
-       return 0;
-};
-
-struct rte_driver ena_pmd_drv = {
-       .type = PMD_PDEV,
-       .init = rte_ena_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(ena_pmd_drv, net_ena);
+DRIVER_REGISTER_PCI(net_ena, rte_ena_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map);
index 6cbecb1..9006197 100644 (file)
@@ -616,29 +616,12 @@ static struct eth_driver rte_enic_pmd = {
                .name = "rte_enic_pmd",
                .id_table = pci_id_enic_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_enicpmd_dev_init,
        .dev_private_size = sizeof(struct enic),
 };
 
-/* Driver initialization routine.
- * Invoked once at EAL init time.
- * Register as the [Poll Mode] Driver of Cisco ENIC device.
- */
-static int
-rte_enic_pmd_init(__rte_unused const char *name,
-        __rte_unused const char *params)
-{
-       ENICPMD_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_enic_pmd);
-       return 0;
-}
-
-static struct rte_driver rte_enic_driver = {
-       .type = PMD_PDEV,
-       .init = rte_enic_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_enic_driver, net_enic);
+DRIVER_REGISTER_PCI(net_enic, rte_enic_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_enic, pci_id_enic_map);
index 0ecc167..8d55c43 100644 (file)
@@ -3059,30 +3059,13 @@ static struct eth_driver rte_pmd_fm10k = {
                .id_table = pci_id_fm10k_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
                        RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_fm10k_dev_init,
        .eth_dev_uninit = eth_fm10k_dev_uninit,
        .dev_private_size = sizeof(struct fm10k_adapter),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI FM10K devices.
- */
-static int
-rte_pmd_fm10k_init(__rte_unused const char *name,
-       __rte_unused const char *params)
-{
-       PMD_INIT_FUNC_TRACE();
-       rte_eth_driver_register(&rte_pmd_fm10k);
-       return 0;
-}
-
-static struct rte_driver rte_fm10k_driver = {
-       .type = PMD_PDEV,
-       .init = rte_pmd_fm10k_init,
-};
-
-PMD_REGISTER_DRIVER(rte_fm10k_driver, net_fm10k);
+DRIVER_REGISTER_PCI(net_fm10k, rte_pmd_fm10k.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_fm10k, pci_id_fm10k_map);
index b04c833..56bd2c6 100644 (file)
@@ -667,6 +667,8 @@ static struct eth_driver rte_i40e_pmd = {
                .id_table = pci_id_i40e_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
                        RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_i40e_dev_init,
        .eth_dev_uninit = eth_i40e_dev_uninit,
@@ -701,27 +703,7 @@ rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev,
        return 0;
 }
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI IXGBE devices.
- */
-static int
-rte_i40e_pmd_init(const char *name __rte_unused,
-                 const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-       rte_eth_driver_register(&rte_i40e_pmd);
-
-       return 0;
-}
-
-static struct rte_driver rte_i40e_driver = {
-       .type = PMD_PDEV,
-       .init = rte_i40e_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40e_driver, net_i40e);
+DRIVER_REGISTER_PCI(net_i40e, rte_i40e_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_i40e, pci_id_i40e_map);
 
 /*
index 2e1c64a..8177626 100644 (file)
@@ -1557,34 +1557,15 @@ static struct eth_driver rte_i40evf_pmd = {
                .name = "rte_i40evf_pmd",
                .id_table = pci_id_i40evf_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = i40evf_dev_init,
        .eth_dev_uninit = i40evf_dev_uninit,
        .dev_private_size = sizeof(struct i40e_adapter),
 };
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI Fortville devices.
- */
-static int
-rte_i40evf_pmd_init(const char *name __rte_unused,
-                   const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_i40evf_pmd);
-
-       return 0;
-}
-
-static struct rte_driver rte_i40evf_driver = {
-       .type = PMD_PDEV,
-       .init = rte_i40evf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40evf_driver, net_i40e_vf);
+DRIVER_REGISTER_PCI(net_i40e_vf, rte_i40evf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_i40e_vf, pci_id_i40evf_map);
 
 static int
index 73a406b..4b9e3d4 100644 (file)
@@ -1566,6 +1566,8 @@ static struct eth_driver rte_ixgbe_pmd = {
                .id_table = pci_id_ixgbe_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
                        RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_ixgbe_dev_init,
        .eth_dev_uninit = eth_ixgbe_dev_uninit,
@@ -1580,40 +1582,14 @@ static struct eth_driver rte_ixgbevf_pmd = {
                .name = "rte_ixgbevf_pmd",
                .id_table = pci_id_ixgbevf_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_ixgbevf_dev_init,
        .eth_dev_uninit = eth_ixgbevf_dev_uninit,
        .dev_private_size = sizeof(struct ixgbe_adapter),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI IXGBE devices.
- */
-static int
-rte_ixgbe_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_ixgbe_pmd);
-       return 0;
-}
-
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI niantic devices.
- */
-static int
-rte_ixgbevf_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_ixgbevf_pmd);
-       return 0;
-}
-
 static int
 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
@@ -7409,17 +7385,7 @@ ixgbevf_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
        ixgbevf_dev_interrupt_action(dev);
 }
 
-static struct rte_driver rte_ixgbe_driver = {
-       .type = PMD_PDEV,
-       .init = rte_ixgbe_pmd_init,
-};
-
-static struct rte_driver rte_ixgbevf_driver = {
-       .type = PMD_PDEV,
-       .init = rte_ixgbevf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_ixgbe_driver, net_ixgbe);
+DRIVER_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
-PMD_REGISTER_DRIVER(rte_ixgbevf_driver, net_ixgbe_vf);
+DRIVER_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
index ab7ed23..18da84a 100644 (file)
@@ -5922,12 +5922,10 @@ static struct eth_driver mlx4_driver = {
 /**
  * Driver initialization routine.
  */
-static int
-rte_mlx4_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx4_pmd_init);
+static void
+rte_mlx4_pmd_init(void)
 {
-       (void)name;
-       (void)args;
-
        RTE_BUILD_BUG_ON(sizeof(wr_id_t) != sizeof(uint64_t));
        /*
         * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
@@ -5938,13 +5936,7 @@ rte_mlx4_pmd_init(const char *name, const char *args)
        setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
        ibv_fork_init();
        rte_eal_pci_register(&mlx4_driver.pci_drv);
-       return 0;
 }
 
-static struct rte_driver rte_mlx4_driver = {
-       .type = PMD_PDEV,
-       .init = rte_mlx4_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx4_driver, net_mlx4);
+DRIVER_EXPORT_NAME(net_mlx4, __COUNTER__);
 DRIVER_REGISTER_PCI_TABLE(net_mlx4, mlx4_pci_id_map);
index 9113121..4eaabcd 100644 (file)
@@ -739,11 +739,10 @@ static struct eth_driver mlx5_driver = {
 /**
  * Driver initialization routine.
  */
-static int
-rte_mlx5_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx5_pmd_init);
+static void
+rte_mlx5_pmd_init(void)
 {
-       (void)name;
-       (void)args;
        /*
         * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
         * huge pages. Calling ibv_fork_init() during init allows
@@ -753,13 +752,7 @@ rte_mlx5_pmd_init(const char *name, const char *args)
        setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
        ibv_fork_init();
        rte_eal_pci_register(&mlx5_driver.pci_drv);
-       return 0;
 }
 
-static struct rte_driver rte_mlx5_driver = {
-       .type = PMD_PDEV,
-       .init = rte_mlx5_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx5_driver, net_mlx5);
+DRIVER_EXPORT_NAME(net_mlx5, __COUNTER__);
 DRIVER_REGISTER_PCI_TABLE(net_mlx5, mlx5_pci_id_map);
index 8421925..e140074 100644 (file)
@@ -2464,29 +2464,14 @@ static struct eth_driver rte_nfp_net_pmd = {
                .id_table = pci_id_nfp_net_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
                             RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = nfp_net_init,
        .dev_private_size = sizeof(struct nfp_net_adapter),
 };
 
-static int
-nfp_net_pmd_init(const char *name __rte_unused,
-                const char *params __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-       PMD_INIT_LOG(INFO, "librte_pmd_nfp_net version %s\n",
-                    NFP_NET_PMD_VERSION);
-
-       rte_eth_driver_register(&rte_nfp_net_pmd);
-       return 0;
-}
-
-static struct rte_driver rte_nfp_net_driver = {
-       .type = PMD_PDEV,
-       .init = nfp_net_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nfp_net_driver, net_nfp);
+DRIVER_REGISTER_PCI(net_nfp, rte_nfp_net_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_nfp, pci_id_nfp_net_map);
 
 /*
index 3b2d8ea..696a32b 100644 (file)
@@ -1482,7 +1482,9 @@ static struct eth_driver rte_qedevf_pmd = {
                    .id_table = pci_id_qedevf_map,
                    .drv_flags =
                    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-                   },
+                   .probe = rte_eth_dev_pci_probe,
+                   .remove = rte_eth_dev_pci_remove,
+                  },
        .eth_dev_init = qedevf_eth_dev_init,
        .eth_dev_uninit = qedevf_eth_dev_uninit,
        .dev_private_size = sizeof(struct qede_dev),
@@ -1494,41 +1496,15 @@ static struct eth_driver rte_qede_pmd = {
                    .id_table = pci_id_qede_map,
                    .drv_flags =
                    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-                   },
+                   .probe = rte_eth_dev_pci_probe,
+                   .remove = rte_eth_dev_pci_remove,
+                  },
        .eth_dev_init = qede_eth_dev_init,
        .eth_dev_uninit = qede_eth_dev_uninit,
        .dev_private_size = sizeof(struct qede_dev),
 };
 
-static int
-rte_qedevf_pmd_init(const char *name __rte_unused,
-                   const char *params __rte_unused)
-{
-       rte_eth_driver_register(&rte_qedevf_pmd);
-
-       return 0;
-}
-
-static int
-rte_qede_pmd_init(const char *name __rte_unused,
-                 const char *params __rte_unused)
-{
-       rte_eth_driver_register(&rte_qede_pmd);
-
-       return 0;
-}
-
-static struct rte_driver rte_qedevf_driver = {
-       .type = PMD_PDEV,
-       .init = rte_qede_pmd_init
-};
-
-static struct rte_driver rte_qede_driver = {
-       .type = PMD_PDEV,
-       .init = rte_qedevf_pmd_init
-};
-
-PMD_REGISTER_DRIVER(rte_qede_driver, net_qede);
+DRIVER_REGISTER_PCI(net_qede, rte_qede_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_qede, pci_id_qede_map);
-PMD_REGISTER_DRIVER(rte_qedevf_driver, net_qede_vf);
+DRIVER_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_qede_vf, pci_id_qedevf_map);
index f665248..9302200 100644 (file)
@@ -1574,31 +1574,13 @@ static struct eth_driver szedata2_eth_driver = {
        .pci_drv = {
                .name     = RTE_SZEDATA2_PCI_DRIVER_NAME,
                .id_table = rte_szedata2_pci_id_table,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init     = rte_szedata2_eth_dev_init,
        .eth_dev_uninit   = rte_szedata2_eth_dev_uninit,
        .dev_private_size = sizeof(struct pmd_internals),
 };
 
-static int
-rte_szedata2_init(const char *name __rte_unused,
-               const char *args __rte_unused)
-{
-       rte_eth_driver_register(&szedata2_eth_driver);
-       return 0;
-}
-
-static int
-rte_szedata2_uninit(const char *name __rte_unused)
-{
-       return 0;
-}
-
-static struct rte_driver rte_szedata2_driver = {
-       .type = PMD_PDEV,
-       .init = rte_szedata2_init,
-       .uninit = rte_szedata2_uninit,
-};
-
-PMD_REGISTER_DRIVER(rte_szedata2_driver, RTE_SZEDATA2_DRIVER_NAME);
+DRIVER_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
index 637794c..9ccf59e 100644 (file)
@@ -1762,26 +1762,12 @@ static struct eth_driver rte_nicvf_pmd = {
                .name = "rte_nicvf_pmd",
                .id_table = pci_id_nicvf_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = nicvf_eth_dev_init,
        .dev_private_size = sizeof(struct nicvf),
 };
 
-static int
-rte_nicvf_pmd_init(const char *name __rte_unused, const char *para __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-       PMD_INIT_LOG(INFO, "librte_pmd_thunderx nicvf version %s",
-                       THUNDERX_NICVF_PMD_VERSION);
-
-       rte_eth_driver_register(&rte_nicvf_pmd);
-       return 0;
-}
-
-static struct rte_driver rte_nicvf_driver = {
-       .type = PMD_PDEV,
-       .init = rte_nicvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nicvf_driver, net_thunderx);
+DRIVER_REGISTER_PCI(net_thunderx, rte_nicvf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_thunderx, pci_id_nicvf_map);
index ef0d6ee..1c2bf01 100644 (file)
@@ -1307,29 +1307,24 @@ static struct eth_driver rte_virtio_pmd = {
                .name = "rte_virtio_pmd",
                .id_table = pci_id_virtio_map,
                .drv_flags = RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_virtio_dev_init,
        .eth_dev_uninit = eth_virtio_dev_uninit,
        .dev_private_size = sizeof(struct virtio_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI virtio devices.
- * Returns 0 on success.
- */
-static int
-rte_virtio_pmd_init(const char *name __rte_unused,
-                   const char *param __rte_unused)
+RTE_INIT(rte_virtio_pmd_init);
+static void
+rte_virtio_pmd_init(void)
 {
        if (rte_eal_iopl_init() != 0) {
                PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
-               return -1;
+               return;
        }
 
-       rte_eth_driver_register(&rte_virtio_pmd);
-       return 0;
+       rte_eal_pci_register(&rte_virtio_pmd.pci_drv);
 }
 
 /*
@@ -1563,10 +1558,5 @@ __rte_unused uint8_t is_rx)
        return 0;
 }
 
-static struct rte_driver rte_virtio_driver = {
-       .type = PMD_PDEV,
-       .init = rte_virtio_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_virtio_driver, net_virtio);
+DRIVER_EXPORT_NAME(net_virtio, __COUNTER__);
 DRIVER_REGISTER_PCI_TABLE(net_virtio, pci_id_virtio_map);
index e6873aa..f15cda5 100644 (file)
@@ -331,26 +331,14 @@ static struct eth_driver rte_vmxnet3_pmd = {
                .name = "rte_vmxnet3_pmd",
                .id_table = pci_id_vmxnet3_map,
                .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+               .probe = rte_eth_dev_pci_probe,
+               .remove = rte_eth_dev_pci_remove,
        },
        .eth_dev_init = eth_vmxnet3_dev_init,
        .eth_dev_uninit = eth_vmxnet3_dev_uninit,
        .dev_private_size = sizeof(struct vmxnet3_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of Virtual PCI VMXNET3 devices.
- */
-static int
-rte_vmxnet3_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       rte_eth_driver_register(&rte_vmxnet3_pmd);
-       return 0;
-}
-
 static int
 vmxnet3_dev_configure(struct rte_eth_dev *dev)
 {
@@ -948,10 +936,5 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
 }
 #endif
 
-static struct rte_driver rte_vmxnet3_driver = {
-       .type = PMD_PDEV,
-       .init = rte_vmxnet3_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_vmxnet3_driver, net_vmxnet3);
+DRIVER_REGISTER_PCI(net_vmxnet3, rte_vmxnet3_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(net_vmxnet3, pci_id_vmxnet3_map);
index caa9db8..f591711 100644 (file)
@@ -532,29 +532,6 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
        return 0;
 }
 
-int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
-               enum pmd_type type)
-{
-       /* Call crypto device initialization directly if device is virtual */
-       if (type == PMD_VDEV)
-               return rte_cryptodev_pci_probe(
-                               (struct rte_pci_driver *)cryptodrv,
-                               NULL);
-
-       /*
-        * Register PCI driver for physical device intialisation during
-        * PCI probing
-        */
-       cryptodrv->pci_drv.probe = rte_cryptodev_pci_probe;
-       cryptodrv->pci_drv.remove = rte_cryptodev_pci_remove;
-
-       rte_eal_pci_register(&cryptodrv->pci_drv);
-
-       return 0;
-}
-
-
 uint16_t
 rte_cryptodev_queue_pair_count(uint8_t dev_id)
 {
index 450a376..abfe2dc 100644 (file)
@@ -493,36 +493,6 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 extern int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
 
-
-/**
- * Register a Crypto [Poll Mode] driver.
- *
- * Function invoked by the initialization function of a Crypto driver
- * to simultaneously register itself as Crypto Poll Mode Driver and to either:
- *
- *     a - register itself as PCI driver if the crypto device is a physical
- *             device, by invoking the rte_eal_pci_register() function to
- *             register the *pci_drv* structure embedded in the *crypto_drv*
- *             structure, after having stored the address of the
- *             rte_cryptodev_init() function in the *probe* field of the
- *             *pci_drv* structure.
- *
- *             During the PCI probing phase, the rte_cryptodev_init()
- *             function is invoked for each PCI [device] matching the
- *             embedded PCI identifiers provided by the driver.
- *
- *     b, complete the initialization sequence if the device is a virtual
- *             device by calling the rte_cryptodev_init() directly passing a
- *             NULL parameter for the rte_pci_device structure.
- *
- *   @param crypto_drv crypto_driver structure associated with the crypto
- *                                     driver.
- *   @param type               pmd type
- */
-extern int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
-               enum pmd_type type);
-
 /**
  * Executes all the user application registered callbacks for the specific
  * device.
index dd0b378..9dde0e7 100644 (file)
@@ -14,7 +14,6 @@ DPDK_16.04 {
        rte_cryptodev_info_get;
        rte_cryptodev_pmd_allocate;
        rte_cryptodev_pmd_callback_process;
-       rte_cryptodev_pmd_driver_register;
        rte_cryptodev_pmd_release_device;
        rte_cryptodev_pmd_virtual_dev_init;
        rte_cryptodev_sym_session_create;
index 42d7d5e..0b9f701 100644 (file)
@@ -339,28 +339,6 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
        return 0;
 }
 
-/**
- * Register an Ethernet [Poll Mode] driver.
- *
- * Function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver.
- * Invokes the rte_eal_pci_register() function to register the *pci_drv*
- * structure embedded in the *eth_drv* structure, after having stored the
- * address of the rte_eth_dev_init() function in the *probe* field of
- * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_init() function is
- * invoked for each PCI [Ethernet device] matching the embedded PCI
- * identifiers provided by the driver.
- */
-void
-rte_eth_driver_register(struct eth_driver *eth_drv)
-{
-       eth_drv->pci_drv.probe = rte_eth_dev_pci_probe;
-       eth_drv->pci_drv.remove = rte_eth_dev_pci_remove;
-       rte_eal_pci_register(&eth_drv->pci_drv);
-}
-
 int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
index 11c3a75..5f78a9b 100644 (file)
@@ -1874,18 +1874,6 @@ struct eth_driver {
        unsigned int dev_private_size;    /**< Size of device private data. */
 };
 
-/**
- * @internal
- * A function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver (PMD).
- *
- * @param eth_drv
- *   The pointer to the *eth_driver* structure associated with
- *   the Ethernet driver.
- */
-void rte_eth_driver_register(struct eth_driver *eth_drv);
-
 /**
  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
  * the bitmap link_speeds of the struct rte_eth_conf
index 17e7448..72be66d 100644 (file)
@@ -78,7 +78,6 @@ DPDK_2.2 {
        rte_eth_dev_vlan_filter;
        rte_eth_dev_wd_timeout_store;
        rte_eth_dma_zone_reserve;
-       rte_eth_driver_register;
        rte_eth_led_off;
        rte_eth_led_on;
        rte_eth_link;
index 7a1a62a..a42ef03 100644 (file)
@@ -87,7 +87,7 @@ endif
 PMDINFO_GEN = $(RTE_SDK_BIN)/app/dpdk-pmdinfogen $@ $@.pmd.c
 PMDINFO_CC = $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@.pmd.o $@.pmd.c
 PMDINFO_LD = $(CROSS)ld $(LDFLAGS) -r -o $@.o $@.pmd.o $@
-PMDINFO_TO_O = if grep -q 'PMD_REGISTER_DRIVER(.*)' $<; then \
+PMDINFO_TO_O = if grep -q 'DRIVER_REGISTER_.*(.*)' $<; then \
        echo "$(if $V,$(PMDINFO_GEN),  PMDINFO $@.pmd.c)" && \
        $(PMDINFO_GEN) && \
        echo "$(if $V,$(PMDINFO_CC),  CC $@.pmd.o)" && \