From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 610AE558C for ; Tue, 10 Jan 2017 19:03:39 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 10 Jan 2017 10:03:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,344,1477983600"; d="scan'208";a="211783396" Received: from sivswdev02.ir.intel.com ([10.237.217.46]) by fmsmga004.fm.intel.com with ESMTP; 10 Jan 2017 10:02:58 -0800 From: Ferruh Yigit To: dev@dpdk.org Cc: Stephen Hemminger , Shreyansh Jain , Jan Blunck , Ferruh Yigit Date: Tue, 10 Jan 2017 18:02:50 +0000 Message-Id: <20170110180250.10625-2-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20170110180250.10625-1-ferruh.yigit@intel.com> References: <20170110180250.10625-1-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH 2/2] separate bus and functionality driver structs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2017 18:03:40 -0000 Signed-off-by: Ferruh Yigit --- drivers/net/bnx2x/bnx2x_ethdev.c | 44 ++++++++++++++--------------- drivers/net/cxgbe/cxgbe_ethdev.c | 22 +++++++-------- drivers/net/e1000/em_ethdev.c | 26 ++++++++--------- drivers/net/e1000/igb_ethdev.c | 50 ++++++++++++++++----------------- drivers/net/ena/ena_ethdev.c | 22 +++++++-------- drivers/net/enic/enic_ethdev.c | 22 +++++++-------- drivers/net/fm10k/fm10k_ethdev.c | 26 ++++++++--------- drivers/net/i40e/i40e_ethdev.c | 26 ++++++++--------- drivers/net/i40e/i40e_ethdev_vf.c | 24 ++++++++-------- drivers/net/ixgbe/ixgbe_ethdev.c | 50 ++++++++++++++++----------------- lib/librte_eal/common/eal_common_pci.c | 4 +-- lib/librte_eal/common/include/rte_pci.h | 3 +- lib/librte_ether/rte_ethdev.c | 26 +++++++++++++---- lib/librte_ether/rte_ethdev.h | 7 +++-- 14 files changed, 183 insertions(+), 169 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index 2dbd782..bb1937e 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -618,42 +618,42 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev) return bnx2x_common_dev_init(eth_dev, 1); } -static struct eth_driver rte_bnx2x_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .id_table = pci_id_bnx2x_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, +static struct eth_driver rte_bnx2x_pmd_eth_drv = { + .eth_dev_init = eth_bnx2x_dev_init, + .dev_private_size = sizeof(struct bnx2x_softc), +}; + +static struct rte_pci_driver rte_bnx2x_pmd_pci_drv = { + .driver = { .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), + .id_table = pci_id_bnx2x_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, + .func_drv = &rte_bnx2x_pmd_eth_drv.driver, }; /* * virtual function driver struct */ -static struct eth_driver rte_bnx2xvf_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .id_table = pci_id_bnx2xvf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING, +static struct eth_driver rte_bnx2xvf_pmd_eth_drv = { + .eth_dev_init = eth_bnx2xvf_dev_init, + .dev_private_size = sizeof(struct bnx2x_softc), +}; + +static struct rte_pci_driver rte_bnx2xvf_pmd_pci_drv = { + .driver = { .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), + .id_table = pci_id_bnx2xvf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .func_drv = &rte_bnx2xvf_pmd_eth_drv.driver, }; -RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_bnx2x, pci_id_bnx2x_map); RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio"); -RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map); RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio"); diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 7718d02..df9a324 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -1039,21 +1039,21 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev) return err; } -static struct eth_driver rte_cxgbe_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .id_table = cxgb4_pci_tbl, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, +static struct eth_driver rte_cxgbe_pmd_eth_drv = { + .eth_dev_init = eth_cxgbe_dev_init, + .dev_private_size = sizeof(struct port_info), +}; + +static struct rte_pci_driver rte_cxgbe_pmd_pci_drv = { + .driver = { .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), + .id_table = cxgb4_pci_tbl, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, + .func_drv = &rte_cxgbe_pmd_eth_drv.driver, }; -RTE_PMD_REGISTER_PCI(net_cxgbe, rte_cxgbe_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_cxgbe, rte_cxgbe_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_cxgbe, cxgb4_pci_tbl); RTE_PMD_REGISTER_KMOD_DEP(net_cxgbe, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index 8758aaa..fa5f650 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -415,23 +415,23 @@ eth_em_dev_uninit(struct rte_eth_dev *eth_dev) return 0; } -static struct eth_driver rte_em_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .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, - }, +static struct eth_driver rte_em_pmd_eth_drv = { .eth_dev_init = eth_em_dev_init, .eth_dev_uninit = eth_em_dev_uninit, .dev_private_size = sizeof(struct e1000_adapter), }; +static struct rte_pci_driver rte_em_pmd_pci_drv = { + .driver = { + .probe = rte_eth_dev_pci_probe, + .remove = rte_eth_dev_pci_remove, + }, + .id_table = pci_id_em_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC | + RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_em_pmd_eth_drv.driver, +}; + static int em_hw_init(struct e1000_hw *hw) { @@ -1851,6 +1851,6 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev, return 0; } -RTE_PMD_REGISTER_PCI(net_e1000_em, rte_em_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_e1000_em, rte_em_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_e1000_em, pci_id_em_map); RTE_PMD_REGISTER_KMOD_DEP(net_e1000_em, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 76d73cd..9563c46 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -1082,42 +1082,42 @@ eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev) return 0; } -static struct eth_driver rte_igb_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .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, - }, +static struct eth_driver rte_igb_pmd_eth_drv = { .eth_dev_init = eth_igb_dev_init, .eth_dev_uninit = eth_igb_dev_uninit, .dev_private_size = sizeof(struct e1000_adapter), }; -/* - * virtual function driver struct - */ -static struct eth_driver rte_igbvf_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .id_table = pci_id_igbvf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE, +static struct rte_pci_driver rte_igb_pmd_pci_drv = { + .driver = { .probe = rte_eth_dev_pci_probe, .remove = rte_eth_dev_pci_remove, }, + .id_table = pci_id_igb_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC | + RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_igb_pmd_eth_drv.driver, +}; + +/* + * virtual function driver struct + */ +static struct eth_driver rte_igbvf_pmd_eth_drv = { .eth_dev_init = eth_igbvf_dev_init, .eth_dev_uninit = eth_igbvf_dev_uninit, .dev_private_size = sizeof(struct e1000_adapter), }; +static struct rte_pci_driver rte_igbvf_pmd_pci_drv = { + .driver = { + .probe = rte_eth_dev_pci_probe, + .remove = rte_eth_dev_pci_remove, + }, + .id_table = pci_id_igbvf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_igbvf_pmd_eth_drv.driver, +}; + static void igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev) { @@ -5261,9 +5261,9 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev) E1000_WRITE_FLUSH(hw); } -RTE_PMD_REGISTER_PCI(net_e1000_igb, rte_igb_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_e1000_igb, rte_igb_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_e1000_igb, pci_id_igb_map); RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb, "* igb_uio | uio_pci_generic | vfio"); -RTE_PMD_REGISTER_PCI(net_e1000_igb_vf, rte_igbvf_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_e1000_igb_vf, rte_igbvf_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_e1000_igb_vf, pci_id_igbvf_map); RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb_vf, "* igb_uio | vfio"); diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index ecdd015..ad5b0a9 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -1756,21 +1756,21 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, return sent_idx; } -static struct eth_driver rte_ena_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .id_table = pci_id_ena_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING, +static struct eth_driver rte_ena_pmd_eth_drv = { + .eth_dev_init = eth_ena_dev_init, + .dev_private_size = sizeof(struct ena_adapter), +}; + +static struct rte_pci_driver rte_ena_pmd_pci_drv = { + .driver = { .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), + .id_table = pci_id_ena_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .func_drv = &rte_ena_pmd_eth_drv.driver, }; -RTE_PMD_REGISTER_PCI(net_ena, rte_ena_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_ena, rte_ena_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map); RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 00cf67b..0cb6400 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -634,21 +634,21 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev) return enic_probe(enic); } -static struct eth_driver rte_enic_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .id_table = pci_id_enic_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, +static struct eth_driver rte_enic_pmd_eth_drv = { + .eth_dev_init = eth_enicpmd_dev_init, + .dev_private_size = sizeof(struct enic), +}; + +static struct rte_pci_driver rte_enic_pmd_pci_drv = { + .driver = { .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), + .id_table = pci_id_enic_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, + .func_drv = &rte_enic_pmd_eth_drv.driver, }; -RTE_PMD_REGISTER_PCI(net_enic, rte_enic_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_enic, rte_enic_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_enic, pci_id_enic_map); RTE_PMD_REGISTER_KMOD_DEP(net_enic, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 9760fb7..4c84484 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -3077,23 +3077,23 @@ static const struct rte_pci_id pci_id_fm10k_map[] = { { .vendor_id = 0, /* sentinel */ }, }; -static struct eth_driver rte_pmd_fm10k = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .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, - }, +static struct eth_driver rte_pmd_fm10k_eth_drv = { .eth_dev_init = eth_fm10k_dev_init, .eth_dev_uninit = eth_fm10k_dev_uninit, .dev_private_size = sizeof(struct fm10k_adapter), }; -RTE_PMD_REGISTER_PCI(net_fm10k, rte_pmd_fm10k.pci_drv); +static struct rte_pci_driver rte_pmd_fm10k_pci_drv = { + .driver = { + .probe = rte_eth_dev_pci_probe, + .remove = rte_eth_dev_pci_remove, + }, + .id_table = pci_id_fm10k_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC | + RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_pmd_fm10k_eth_drv.driver, +}; + +RTE_PMD_REGISTER_PCI(net_fm10k, rte_pmd_fm10k_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_fm10k, pci_id_fm10k_map); RTE_PMD_REGISTER_KMOD_DEP(net_fm10k, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 24683a9..9443c51 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -623,23 +623,23 @@ static const struct rte_i40e_xstats_name_off rte_i40e_txq_prio_strings[] = { #define I40E_NB_TXQ_PRIO_XSTATS (sizeof(rte_i40e_txq_prio_strings) / \ sizeof(rte_i40e_txq_prio_strings[0])) -static struct eth_driver rte_i40e_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .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, - }, +static struct eth_driver rte_i40e_pmd_eth_drv = { .eth_dev_init = eth_i40e_dev_init, .eth_dev_uninit = eth_i40e_dev_uninit, .dev_private_size = sizeof(struct i40e_adapter), }; +static struct rte_pci_driver rte_i40e_pmd_pci_drv = { + .driver = { + .probe = rte_eth_dev_pci_probe, + .remove = rte_eth_dev_pci_remove, + }, + .id_table = pci_id_i40e_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC | + RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_i40e_pmd_eth_drv.driver, +}; + static inline int rte_i40e_dev_atomic_read_link_status(struct rte_eth_dev *dev, struct rte_eth_link *link) @@ -668,7 +668,7 @@ rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev, return 0; } -RTE_PMD_REGISTER_PCI(net_i40e, rte_i40e_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_i40e, rte_i40e_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_i40e, pci_id_i40e_map); RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 7b97ed3..c548955 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1533,23 +1533,23 @@ i40evf_dev_uninit(struct rte_eth_dev *eth_dev) /* * virtual function driver struct */ -static struct eth_driver rte_i40evf_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .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, - }, +static struct eth_driver rte_i40evf_pmd_eth_drv = { .eth_dev_init = i40evf_dev_init, .eth_dev_uninit = i40evf_dev_uninit, .dev_private_size = sizeof(struct i40e_adapter), }; -RTE_PMD_REGISTER_PCI(net_i40e_vf, rte_i40evf_pmd.pci_drv); +static struct rte_pci_driver rte_i40evf_pmd_pci_drv = { + .driver = { + .probe = rte_eth_dev_pci_probe, + .remove = rte_eth_dev_pci_remove, + }, + .id_table = pci_id_i40evf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_i40evf_pmd_eth_drv.driver, +}; + +RTE_PMD_REGISTER_PCI(net_i40e_vf, rte_i40evf_pmd_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_i40e_vf, pci_id_i40evf_map); RTE_PMD_REGISTER_KMOD_DEP(net_i40e_vf, "* igb_uio | vfio"); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index b17ed1a..520b2af 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1550,42 +1550,42 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev) return 0; } -static struct eth_driver rte_ixgbe_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .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, - }, +static struct eth_driver rte_ixgbe_eth_drv = { .eth_dev_init = eth_ixgbe_dev_init, .eth_dev_uninit = eth_ixgbe_dev_uninit, .dev_private_size = sizeof(struct ixgbe_adapter), }; -/* - * virtual function driver struct - */ -static struct eth_driver rte_ixgbevf_pmd = { - .pci_drv = { - .driver = { - .probe = rte_eal_pci_probe, - .remove = rte_eal_pci_remove, - }, - .id_table = pci_id_ixgbevf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE, +static struct rte_pci_driver rte_ixgbe_pci_drv = { + .driver = { .probe = rte_eth_dev_pci_probe, .remove = rte_eth_dev_pci_remove, }, + .id_table = pci_id_ixgbe_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC | + RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_ixgbe_eth_drv.driver, +}; + +/* + * virtual function driver struct + */ +static struct eth_driver rte_ixgbevf_eth_drv = { .eth_dev_init = eth_ixgbevf_dev_init, .eth_dev_uninit = eth_ixgbevf_dev_uninit, .dev_private_size = sizeof(struct ixgbe_adapter), }; +static struct rte_pci_driver rte_ixgbevf_pci_drv = { + .driver = { + .probe = rte_eth_dev_pci_probe, + .remove = rte_eth_dev_pci_remove, + }, + .id_table = pci_id_ixgbevf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE, + .func_drv = &rte_ixgbevf_eth_drv.driver, +}; + static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) { @@ -7695,9 +7695,9 @@ ixgbevf_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle, ixgbevf_dev_interrupt_action(dev); } -RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map); RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio"); -RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pci_drv); RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map); RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio"); diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 2d5a399..ea2f598 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -220,7 +220,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, dev->driver = dr; /* call the driver probe() function */ - ret = dr->probe(dr, dev); + ret = dr->driver.probe(&dr->driver, &dev->device); if (ret) { RTE_LOG(DEBUG, EAL, "Driver (%s) probe failed.\n", dr->driver.name); @@ -252,7 +252,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr, RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n", dev->id.vendor_id, dev->id.device_id, dr->driver.name); - if (dr->remove && (dr->remove(dev) < 0)) + if (dr->driver.remove && (dr->driver.remove(&dev->device) < 0)) return -1; /* negative value is an error */ /* clear driver structure */ diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 1647672..949ed3e 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -200,8 +200,7 @@ typedef int (pci_remove_t)(struct rte_pci_device *); struct rte_pci_driver { TAILQ_ENTRY(rte_pci_driver) next; /**< Next in list. */ struct rte_driver driver; /**< Inherit core driver. */ - pci_probe_t *probe; /**< Device Probe function. */ - pci_remove_t *remove; /**< Device Remove function. */ + struct rte_driver *func_drv; const struct rte_pci_id *id_table; /**< ID table, NULL terminated. */ uint32_t drv_flags; /**< Flags contolling handling of device. */ }; diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 917557a..3369864 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -236,16 +236,23 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) } int -rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, - struct rte_pci_device *pci_dev) +rte_eth_dev_pci_probe(struct rte_driver *drv, + struct rte_device *dev) { - struct eth_driver *eth_drv; + struct rte_pci_driver *pci_drv; + struct rte_pci_device *pci_dev; + struct eth_driver *eth_drv; struct rte_eth_dev *eth_dev; char ethdev_name[RTE_ETH_NAME_MAX_LEN]; + struct rte_driver *func_drv; int diag; - eth_drv = (struct eth_driver *)pci_drv; + pci_drv = container_of(drv, struct rte_pci_driver, driver); + pci_dev = container_of(dev, struct rte_pci_device, device); + + func_drv = pci_drv->func_drv; + eth_drv = container_of(func_drv, struct eth_driver, driver); rte_eal_pci_device_name(&pci_dev->addr, ethdev_name, sizeof(ethdev_name)); @@ -281,13 +288,19 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, } int -rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) +rte_eth_dev_pci_remove(struct rte_device *dev) { + struct rte_pci_device *pci_dev; + struct rte_pci_driver *pci_drv; const struct eth_driver *eth_drv; struct rte_eth_dev *eth_dev; char ethdev_name[RTE_ETH_NAME_MAX_LEN]; + struct rte_driver *func_drv; int ret; + pci_dev = container_of(dev, struct rte_pci_device, device); + pci_drv = pci_dev->driver; + if (pci_dev == NULL) return -EINVAL; @@ -298,7 +311,8 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) if (eth_dev == NULL) return -ENODEV; - eth_drv = (const struct eth_driver *)pci_dev->driver; + func_drv = pci_drv->func_drv; + eth_drv = container_of(func_drv, struct eth_driver, driver); /* Invoke PMD device uninit function */ if (*eth_drv->eth_dev_uninit) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index ded43d7..203210d 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1862,6 +1862,7 @@ struct eth_driver { eth_dev_init_t eth_dev_init; /**< Device init function. */ eth_dev_uninit_t eth_dev_uninit; /**< Device uninit function. */ unsigned int dev_private_size; /**< Size of device private data. */ + struct rte_driver driver; }; /** @@ -4382,15 +4383,15 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name); * Wrapper for use by pci drivers as a .probe function to attach to a ethdev * interface. */ -int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, - struct rte_pci_device *pci_dev); +int rte_eth_dev_pci_probe(struct rte_driver *drv, + struct rte_device *dev); /** * @internal * Wrapper for use by pci drivers as a .remove function to detach a ethdev * interface. */ -int rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev); +int rte_eth_dev_pci_remove(struct rte_device *dev); #ifdef __cplusplus } -- 2.9.3