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 C0FFBDE3 for ; Tue, 26 Apr 2016 19:40:46 +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 1av6yU-0002mT-B7; Tue, 26 Apr 2016 13:40:41 -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:50 -0400 Message-Id: <1461692391-30093-4-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 3/4] pmd: Modify drivers to export appropriate information 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:47 -0000 For the PMD's which support pci devices, add the appropriate pci table pointer to the rte_driver structure so external applications can find it. Also note, some modifications to the em/igb and i40e drivers. These are done to support an artifact of the use of the __COUNTER__ macro in PMD_REGISTER_DRIVER. The __COUNTER__ macro evaluates to a string integer that gets incremented each time it expands. While that offers a great predictable indexing feature, it resets for each compilation unit (as would be expected). However, for the two aforementioned DSO's they register multiple drivers in multiple compilation units, which leads to multiple definitions of variables. I would make the argument that a single DSO should support only a single driver (which is analgous to how kernel modules work in linux and bsd), and if there is common code between multiple modules, that common code should be built into a archive and linked to each separate DSO. However, that is a significant amount of work, and so here, I instead modified the affected DSO's to simply register all drivers in the same compilation unit. Signed-off-by: Neil Horman CC: David Marchand CC: Stephen Hemminger CC: "Richardson, Bruce" CC: Panu Matilainen CC: Thomas Monjalon --- drivers/crypto/qat/rte_qat_cryptodev.c | 1 + drivers/net/bnx2x/bnx2x_ethdev.c | 2 ++ drivers/net/cxgbe/cxgbe_ethdev.c | 1 + drivers/net/e1000/Makefile | 1 + drivers/net/e1000/em_ethdev.c | 13 +++------ drivers/net/e1000/igb_ethdev.c | 24 ++++++----------- drivers/net/e1000/pmds.c | 48 +++++++++++++++++++++++++++++++++ drivers/net/ena/ena_ethdev.c | 1 + drivers/net/enic/enic_ethdev.c | 1 + drivers/net/fm10k/fm10k_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev.c | 14 ++++++++++ drivers/net/i40e/i40e_ethdev_vf.c | 14 ++++------ drivers/net/ixgbe/ixgbe_ethdev.c | 2 ++ drivers/net/mlx4/mlx4.c | 1 + drivers/net/mlx5/mlx5.c | 1 + drivers/net/nfp/nfp_net.c | 1 + drivers/net/szedata2/rte_eth_szedata2.c | 1 + drivers/net/virtio/virtio_ethdev.c | 1 + drivers/net/vmxnet3/vmxnet3_ethdev.c | 1 + 19 files changed, 95 insertions(+), 34 deletions(-) create mode 100644 drivers/net/e1000/pmds.c diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c index a7912f5..20426e8 100644 --- a/drivers/crypto/qat/rte_qat_cryptodev.c +++ b/drivers/crypto/qat/rte_qat_cryptodev.c @@ -135,6 +135,7 @@ rte_qat_pmd_init(const char *name __rte_unused, const char *params __rte_unused) static struct rte_driver pmd_qat_drv = { .type = PMD_PDEV, .init = rte_qat_pmd_init, + .pci_table = pci_id_qat_map, }; PMD_REGISTER_DRIVER(pmd_qat_drv); diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index 071b44f..ba7d009 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -543,11 +543,13 @@ static int rte_bnx2xvf_pmd_init(const char *name __rte_unused, const char *param static struct rte_driver rte_bnx2x_driver = { .type = PMD_PDEV, .init = rte_bnx2x_pmd_init, + .pci_table = pci_id_bnx2x_map, }; static struct rte_driver rte_bnx2xvf_driver = { .type = PMD_PDEV, .init = rte_bnx2xvf_pmd_init, + .pci_table = pci_id_bnx2xvf_map, }; PMD_REGISTER_DRIVER(rte_bnx2x_driver); diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 04eddaf..c047096 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -892,6 +892,7 @@ static struct rte_driver rte_cxgbe_driver = { .name = "cxgbe_driver", .type = PMD_PDEV, .init = rte_cxgbe_pmd_init, + .pci_table = cxgb4_pci_tbl, }; PMD_REGISTER_DRIVER(rte_cxgbe_driver); diff --git a/drivers/net/e1000/Makefile b/drivers/net/e1000/Makefile index f4879e6..058faff 100644 --- a/drivers/net/e1000/Makefile +++ b/drivers/net/e1000/Makefile @@ -93,6 +93,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IGB_PMD) += igb_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_IGB_PMD) += igb_pf.c SRCS-$(CONFIG_RTE_LIBRTE_EM_PMD) += em_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_EM_PMD) += em_rxtx.c +SRCS-y += pmds.c # this lib depends upon: DEPDIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += lib/librte_eal lib/librte_ether diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index 653be09..62bd811 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -60,7 +60,8 @@ #define PMD_ROUNDUP(x,y) (((x) + (y) - 1)/(y) * (y)) - +int +rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused); static int eth_em_configure(struct rte_eth_dev *dev); static int eth_em_start(struct rte_eth_dev *dev); static void eth_em_stop(struct rte_eth_dev *dev); @@ -136,7 +137,7 @@ static enum e1000_fc_mode em_fc_setting = e1000_fc_full; /* * The set of PCI devices this driver supports */ -static const struct rte_pci_id pci_id_em_map[] = { +const struct rte_pci_id pci_id_em_map[] = { #define RTE_PCI_DEV_ID_DECL_EM(vend, dev) {RTE_PCI_DEVICE(vend, dev)}, #include "rte_pci_dev_ids.h" @@ -374,7 +375,7 @@ static struct eth_driver rte_em_pmd = { .dev_private_size = sizeof(struct e1000_adapter), }; -static int +int rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused) { rte_eth_driver_register(&rte_em_pmd); @@ -1772,9 +1773,3 @@ 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); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index f0921ee..047e592 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -86,6 +86,10 @@ #define E1000_INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT) #define E1000_TSAUXC_DISABLE_SYSTIME 0x80000000 +int +rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused); +int +rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused); static int eth_igb_configure(struct rte_eth_dev *dev); static int eth_igb_start(struct rte_eth_dev *dev); static void eth_igb_stop(struct rte_eth_dev *dev); @@ -281,7 +285,7 @@ static enum e1000_fc_mode igb_fc_setting = e1000_fc_full; /* * The set of PCI devices this driver supports */ -static const struct rte_pci_id pci_id_igb_map[] = { +const struct rte_pci_id pci_id_igb_map[] = { #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {RTE_PCI_DEVICE(vend, dev)}, #include "rte_pci_dev_ids.h" @@ -292,7 +296,7 @@ static const struct rte_pci_id pci_id_igb_map[] = { /* * The set of PCI devices this driver supports (for 82576&I350 VF) */ -static const struct rte_pci_id pci_id_igbvf_map[] = { +const struct rte_pci_id pci_id_igbvf_map[] = { #define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev) {RTE_PCI_DEVICE(vend, dev)}, #include "rte_pci_dev_ids.h" @@ -995,7 +999,7 @@ static struct eth_driver rte_igbvf_pmd = { .dev_private_size = sizeof(struct e1000_adapter), }; -static int +int rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused) { rte_eth_driver_register(&rte_igb_pmd); @@ -1018,7 +1022,7 @@ igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev) * Invoked one at EAL init time. * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices. */ -static int +int rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused) { PMD_INIT_FUNC_TRACE(); @@ -4802,16 +4806,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) { @@ -4973,5 +4967,3 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev) E1000_WRITE_FLUSH(hw); } -PMD_REGISTER_DRIVER(pmd_igb_drv); -PMD_REGISTER_DRIVER(pmd_igbvf_drv); diff --git a/drivers/net/e1000/pmds.c b/drivers/net/e1000/pmds.c new file mode 100644 index 0000000..e4645d0 --- /dev/null +++ b/drivers/net/e1000/pmds.c @@ -0,0 +1,48 @@ +#include +#include + +#if RTE_LIBRTE_IGB_PMD +extern int +rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused); +extern int +rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused); + +extern const struct rte_pci_id pci_id_igb_map[]; +extern const struct rte_pci_id pci_id_igbvf_map[]; + +struct rte_driver __attribute__((used)) pmd_igb_drv = { + .type = PMD_PDEV, + .name = "igb_pmd", + .init = rte_igb_pmd_init, + .pci_table = pci_id_igb_map, +}; + +struct rte_driver __attribute__((used)) pmd_igbvf_drv = { + .type = PMD_PDEV, + .name = "igbvf_pmd", + .init = rte_igbvf_pmd_init, + .pci_table = pci_id_igbvf_map, +}; + +PMD_REGISTER_DRIVER(pmd_igb_drv); +PMD_REGISTER_DRIVER(pmd_igbvf_drv); +#endif + +#if RTE_LIBRTE_EM_PMD +extern int +rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused); + +/* + * * The set of PCI devices this driver supports + * */ +extern const struct rte_pci_id pci_id_em_map[]; + +static struct rte_driver __attribute__((used)) em_pmd_drv = { + .type = PMD_PDEV, + .name = "em_pmd", + .init = rte_em_pmd_init, + .pci_table = pci_id_em_map, +}; + +PMD_REGISTER_DRIVER(em_pmd_drv); +#endif diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index e157587..edefd2a 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -1448,6 +1448,7 @@ struct rte_driver ena_pmd_drv = { .name = "ena_driver", .type = PMD_PDEV, .init = rte_ena_pmd_init, + .pci_table = pci_id_ena_map, }; PMD_REGISTER_DRIVER(ena_pmd_drv); diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 6bea940..d88e648 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -682,6 +682,7 @@ rte_enic_pmd_init(__rte_unused const char *name, static struct rte_driver rte_enic_driver = { .type = PMD_PDEV, .init = rte_enic_pmd_init, + .pci_table = pci_id_enic_map, }; PMD_REGISTER_DRIVER(rte_enic_driver); diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index c2d377f..3e00479 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -3053,6 +3053,7 @@ rte_pmd_fm10k_init(__rte_unused const char *name, static struct rte_driver rte_fm10k_driver = { .type = PMD_PDEV, .init = rte_pmd_fm10k_init, + .pci_table = pci_id_fm10k_map, }; PMD_REGISTER_DRIVER(rte_fm10k_driver); diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index d8b6bd7..3c7ab13 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -693,9 +693,23 @@ rte_i40e_pmd_init(const char *name __rte_unused, static struct rte_driver rte_i40e_driver = { .type = PMD_PDEV, .init = rte_i40e_pmd_init, + .pci_table = pci_id_i40e_map, +}; + +extern int +rte_i40evf_pmd_init(const char *name __rte_unused, + const char *params __rte_unused); + +extern const struct rte_pci_id pci_id_i40evf_map[]; + +struct rte_driver rte_i40evf_driver = { + .type = PMD_PDEV, + .init = rte_i40evf_pmd_init, + .pci_table = pci_id_i40evf_map, }; PMD_REGISTER_DRIVER(rte_i40e_driver); +PMD_REGISTER_DRIVER(rte_i40evf_driver); /* * Initialize registers for flexible payload, which should be set by NVM. diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 2bce69b..3c6b57c 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -101,6 +101,9 @@ enum i40evf_aq_result { I40EVF_MSG_CMD, /* Read async command result */ }; +int +rte_i40evf_pmd_init(const char *name __rte_unused, + const char *params __rte_unused); static int i40evf_dev_configure(struct rte_eth_dev *dev); static int i40evf_dev_start(struct rte_eth_dev *dev); static void i40evf_dev_stop(struct rte_eth_dev *dev); @@ -1088,7 +1091,7 @@ i40evf_get_link_status(struct rte_eth_dev *dev, struct rte_eth_link *link) return 0; } -static const struct rte_pci_id pci_id_i40evf_map[] = { +const struct rte_pci_id pci_id_i40evf_map[] = { #define RTE_PCI_DEV_ID_DECL_I40EVF(vend, dev) {RTE_PCI_DEVICE(vend, dev)}, #include "rte_pci_dev_ids.h" { .vendor_id = 0, /* sentinel */ }, @@ -1544,7 +1547,7 @@ static struct eth_driver rte_i40evf_pmd = { * Invoked one at EAL init time. * Register itself as the [Virtual Poll Mode] Driver of PCI Fortville devices. */ -static int +int rte_i40evf_pmd_init(const char *name __rte_unused, const char *params __rte_unused) { @@ -1555,13 +1558,6 @@ rte_i40evf_pmd_init(const char *name __rte_unused, return 0; } -static struct rte_driver rte_i40evf_driver = { - .type = PMD_PDEV, - .init = rte_i40evf_pmd_init, -}; - -PMD_REGISTER_DRIVER(rte_i40evf_driver); - static int i40evf_dev_configure(struct rte_eth_dev *dev) { diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index eec607c..b41108c 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -7134,11 +7134,13 @@ ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev) static struct rte_driver rte_ixgbe_driver = { .type = PMD_PDEV, .init = rte_ixgbe_pmd_init, + .pci_table = pci_id_ixgbe_map, }; static struct rte_driver rte_ixgbevf_driver = { .type = PMD_PDEV, .init = rte_ixgbevf_pmd_init, + .pci_table = pci_id_ixgbevf_map, }; PMD_REGISTER_DRIVER(rte_ixgbe_driver); diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 4f21dbe..c7991a0 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -5815,6 +5815,7 @@ static struct rte_driver rte_mlx4_driver = { .type = PMD_PDEV, .name = MLX4_DRIVER_NAME, .init = rte_mlx4_pmd_init, + .pci_table = mlx4_pci_id_map, }; PMD_REGISTER_DRIVER(rte_mlx4_driver) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 041cfc3..8825feb 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -670,6 +670,7 @@ static struct rte_driver rte_mlx5_driver = { .type = PMD_PDEV, .name = MLX5_DRIVER_NAME, .init = rte_mlx5_pmd_init, + .pci_table = mlx5_pci_id_map, }; PMD_REGISTER_DRIVER(rte_mlx5_driver) diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index bc0a3d8..0280b81 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -2480,6 +2480,7 @@ nfp_net_pmd_init(const char *name __rte_unused, static struct rte_driver rte_nfp_net_driver = { .type = PMD_PDEV, .init = nfp_net_pmd_init, + .pci_table = pci_id_nfp_net_map, }; PMD_REGISTER_DRIVER(rte_nfp_net_driver); diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index 78c43b0..7af758a 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -1599,6 +1599,7 @@ static struct rte_driver rte_szedata2_driver = { .name = RTE_SZEDATA2_DRIVER_NAME, .init = rte_szedata2_init, .uninit = rte_szedata2_uninit, + .pci_table = rte_szedata2_pci_id_table, }; PMD_REGISTER_DRIVER(rte_szedata2_driver); diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 63a368a..93b2562 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1456,6 +1456,7 @@ __rte_unused uint8_t is_rx) static struct rte_driver rte_virtio_driver = { .type = PMD_PDEV, .init = rte_virtio_pmd_init, + .pci_table = pci_id_virtio_map, }; PMD_REGISTER_DRIVER(rte_virtio_driver); diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 29b469c..83420c8 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -952,6 +952,7 @@ vmxnet3_process_events(struct vmxnet3_hw *hw) static struct rte_driver rte_vmxnet3_driver = { .type = PMD_PDEV, .init = rte_vmxnet3_pmd_init, + .pci_table = pci_id_vmxnet3_map, }; PMD_REGISTER_DRIVER(rte_vmxnet3_driver); -- 2.5.5