]> git.droids-corp.org - dpdk.git/commitdiff
ethdev: decouple from PCI device
authorJan Blunck <jblunck@infradead.org>
Fri, 23 Dec 2016 15:58:11 +0000 (16:58 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 25 Dec 2016 22:30:19 +0000 (23:30 +0100)
This makes struct rte_eth_dev independent of struct rte_pci_device by
replacing it with a pointer to the generic struct rte_device.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
28 files changed:
app/test/virtual_pmd.c
drivers/net/bnx2x/bnx2x_ethdev.c
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bonding/rte_eth_bond_args.c
drivers/net/cxgbe/cxgbe_ethdev.c
drivers/net/cxgbe/cxgbe_main.c
drivers/net/e1000/e1000_ethdev.h
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.h
drivers/net/i40e/i40e_ethdev_vf.c
drivers/net/ixgbe/ixgbe_ethdev.h
drivers/net/mlx4/mlx4.c
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5_ethdev.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/virtio/virtio_user_ethdev.c
drivers/net/vmxnet3/vmxnet3_ethdev.c
lib/librte_eal/common/include/rte_pci.h
lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h

index 2517208afdd6fcbf8890e98c9b434939ea8afd22..6e4dcd8f9656de4d823dd028b52755f1e12f49b7 100644 (file)
@@ -622,8 +622,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
        dev_private->dev_ops = virtual_ethdev_default_dev_ops;
        eth_dev->dev_ops = &dev_private->dev_ops;
 
-       eth_dev->pci_dev = pci_dev;
-       eth_dev->pci_dev->device.driver = &eth_drv->pci_drv.driver;
+       pci_dev->device.driver = &eth_drv->pci_drv.driver;
+       eth_dev->device = &pci_dev->device;
 
        eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success;
        eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_success;
index 7237bcca42dc3d1d987a21bd3c0018955b132d38..2735fd0ff43394943c78b5a09bed45045575726f 100644 (file)
@@ -431,7 +431,7 @@ static void
 bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_info *dev_info)
 {
        struct bnx2x_softc *sc = dev->data->dev_private;
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
        dev_info->max_rx_queues  = sc->max_rx_queues;
        dev_info->max_tx_queues  = sc->max_tx_queues;
        dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
@@ -517,7 +517,7 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
        PMD_INIT_FUNC_TRACE();
 
        eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
 
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
index 778323b441cc42fd653d4d0c2fd238c506773c56..7518b6b78472eb1f9ec8a731bb4fe7551b3aca87 100644 (file)
@@ -303,7 +303,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
        struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
        uint16_t max_vnics, i, j, vpool, vrxq;
 
-       dev_info->pci_dev = eth_dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
 
        /* MAC Specifics */
        dev_info->max_mac_addrs = MAX_NUM_MAC_ADDR;
@@ -1014,7 +1014,7 @@ static bool bnxt_vf_pciid(uint16_t id)
 static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 {
        struct bnxt *bp = eth_dev->data->dev_private;
-       struct rte_pci_device *pci_dev = eth_dev->pci_dev;
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        int rc;
 
        /* enable device (incl. PCI PM wakeup), and bus-mastering */
@@ -1048,7 +1048,7 @@ init_err_disable:
 static int
 bnxt_dev_init(struct rte_eth_dev *eth_dev)
 {
-       struct rte_pci_device *pci_dev = eth_dev->pci_dev;
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        static int version_printed;
        struct bnxt *bp;
        int rc;
index 02ecde6483a7fd750b4551e03c6d674c6148d999..3dca273d4ff54dc555aad1b1383056e395b81407 100644 (file)
@@ -54,15 +54,23 @@ const char *pmd_bond_init_valid_arguments[] = {
 static inline int
 find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
 {
+       struct rte_pci_device *pci_dev;
        struct rte_pci_addr *eth_pci_addr;
        unsigned i;
 
        for (i = 0; i < rte_eth_dev_count(); i++) {
 
-               if (rte_eth_devices[i].pci_dev == NULL)
+               /* Currently populated by rte_eth_copy_pci_info().
+                *
+                * TODO: Once the PCI bus has arrived we should have a better
+                * way to test for being a PCI device or not.
+                */
+               if (rte_eth_devices[i].data->kdrv == RTE_KDRV_UNKNOWN ||
+                   rte_eth_devices[i].data->kdrv == RTE_KDRV_NONE)
                        continue;
 
-               eth_pci_addr = &(rte_eth_devices[i].pci_dev->addr);
+               pci_dev = RTE_DEV_TO_PCI(rte_eth_devices[i].device);
+               eth_pci_addr = &pci_dev->addr;
 
                if (pci_addr->bus == eth_pci_addr->bus &&
                        pci_addr->devid == eth_pci_addr->devid &&
index 70b66b0180ef54306bdf804eaa7cb4e3636c90bc..64345e37b7c883a8bb5386358691c6c6a77c51c2 100644 (file)
@@ -147,7 +147,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
                .nb_align = 1,
        };
 
-       device_info->pci_dev = eth_dev->pci_dev;
+       device_info->pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
 
        device_info->min_rx_bufsize = CXGBE_MIN_RX_BUFSIZE;
        device_info->max_rx_pktlen = CXGBE_MAX_RX_PKTLEN;
@@ -1007,7 +1007,7 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return 0;
 
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
 
        snprintf(name, sizeof(name), "cxgbeadapter%d", eth_dev->data->port_id);
        adapter = rte_zmalloc(name, sizeof(*adapter), 0);
index 9e8402b46608f35896d4c5cc88653e4e45deb498..7ccf43419c882ad8f4e749350993b2092ffed3c9 100644 (file)
@@ -1163,14 +1163,14 @@ int cxgbe_probe(struct adapter *adapter)
                pi->eth_dev->data = data;
 
 allocate_mac:
-               pi->eth_dev->pci_dev = adapter->pdev;
+               pi->eth_dev->device = &adapter->pdev->device;
                pi->eth_dev->data->dev_private = pi;
                pi->eth_dev->driver = adapter->eth_dev->driver;
                pi->eth_dev->dev_ops = adapter->eth_dev->dev_ops;
                pi->eth_dev->tx_pkt_burst = adapter->eth_dev->tx_pkt_burst;
                pi->eth_dev->rx_pkt_burst = adapter->eth_dev->rx_pkt_burst;
 
-               rte_eth_copy_pci_info(pi->eth_dev, pi->eth_dev->pci_dev);
+               rte_eth_copy_pci_info(pi->eth_dev, adapter->pdev);
 
                pi->eth_dev->data->mac_addrs = rte_zmalloc(name,
                                                           ETHER_ADDR_LEN, 0);
index 134f8b915aac54ffe8d8c44584930adb43dcc05b..e5cfbcb697681b81b05908a28ccaecc61ae846f3 100644 (file)
@@ -287,7 +287,7 @@ struct e1000_adapter {
        (&((struct e1000_adapter *)adapter)->filter)
 
 #define E1000_DEV_TO_PCI(eth_dev) \
-       (eth_dev->pci_dev)
+       RTE_DEV_TO_PCI((eth_dev)->device)
 /*
  * RX/TX IGB function prototypes
  */
index 6d071d99b0b12123a015268699c11999321734be..436acbb5c0e3c324a0988ef6d1fefd729c4d52e3 100644 (file)
@@ -1049,7 +1049,7 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
        dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
        dev_info->max_rx_pktlen = em_get_max_pktlen(hw);
        dev_info->max_mac_addrs = hw->mac.rar_entry_count;
index 59a8bfd26c8fbf8df3aa46b22d38cdcded01c62e..4a15447914bcc380546daa438dda238379f440ca 100644 (file)
@@ -1985,7 +1985,7 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
        dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
        dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
        dev_info->max_mac_addrs = hw->mac.rar_entry_count;
@@ -2114,7 +2114,7 @@ eth_igbvf_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
        dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
        dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
        dev_info->max_mac_addrs = hw->mac.rar_entry_count;
index 020c02a2d8d1a5a42a8f3b744af930747f32d481..dcee8ed057f3bf9e6a265652cbc6f753d502f947 100644 (file)
@@ -1278,7 +1278,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return 0;
 
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        adapter->pdev = pci_dev;
 
        PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d\n",
@@ -1436,7 +1436,7 @@ static void ena_infos_get(struct rte_eth_dev *dev,
        ena_dev = &adapter->ena_dev;
        ena_assert_msg(ena_dev != NULL, "Uninitialized device");
 
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        dev_info->speed_capa =
                        ETH_LINK_SPEED_1G   |
index ae6f39402e10bee5b047fef1d029ddaebbde5464..e5ceb98e614915a5928193f7e63b72ba77b5ddd8 100644 (file)
@@ -459,7 +459,7 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
        struct enic *enic = pmd_priv(eth_dev);
 
        ENICPMD_FUNC_TRACE();
-       device_info->pci_dev = eth_dev->pci_dev;
+       device_info->pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        /* Scattered Rx uses two receive queues per rx queue exposed to dpdk */
        device_info->max_rx_queues = enic->conf_rq_count / 2;
        device_info->max_tx_queues = enic->conf_wq_count;
@@ -622,7 +622,7 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->rx_pkt_burst = &enic_recv_pkts;
        eth_dev->tx_pkt_burst = &enic_xmit_pkts;
 
-       pdev = eth_dev->pci_dev;
+       pdev = RTE_DEV_TO_PCI(eth_dev->device);
        rte_eth_copy_pci_info(eth_dev, pdev);
        enic->pdev = pdev;
        addr = &pdev->addr;
index a97a4836574ca003cd73e6a1319e1923b769204e..b8257e46828fe0100f112a33cce6d99ba081c7d0 100644 (file)
@@ -677,7 +677,7 @@ fm10k_dev_tx_init(struct rte_eth_dev *dev)
                /* Enable use of FTAG bit in TX descriptor, PFVTCTL
                 * register is read-only for VF.
                 */
-               if (fm10k_check_ftag(dev->pci_dev->device.devargs)) {
+               if (fm10k_check_ftag(dev->device->devargs)) {
                        if (hw->mac.type == fm10k_mac_pf) {
                                FM10K_WRITE_REG(hw, FM10K_PFVTCTL(i),
                                                FM10K_PFVTCTL_FTAG_DESC_ENABLE);
@@ -711,7 +711,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct fm10k_macvlan_filter_info *macvlan;
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
        struct rte_intr_handle *intr_handle = &pdev->intr_handle;
        int i, ret;
        struct fm10k_rx_queue *rxq;
@@ -1172,7 +1172,7 @@ static void
 fm10k_dev_stop(struct rte_eth_dev *dev)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
        struct rte_intr_handle *intr_handle = &pdev->intr_handle;
        int i;
 
@@ -1389,7 +1389,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
        struct rte_eth_dev_info *dev_info)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
 
        PMD_INIT_FUNC_TRACE();
 
@@ -2337,7 +2337,7 @@ static int
 fm10k_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
 
        /* Enable ITR */
        if (hw->mac.type == fm10k_mac_pf)
@@ -2354,7 +2354,7 @@ static int
 fm10k_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
 
        /* Disable ITR */
        if (hw->mac.type == fm10k_mac_pf)
@@ -2370,7 +2370,7 @@ static int
 fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
        struct rte_intr_handle *intr_handle = &pdev->intr_handle;
        uint32_t intr_vector, vec;
        uint16_t queue_id;
@@ -2744,7 +2744,7 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)
        int use_sse = 1;
        uint16_t tx_ftag_en = 0;
 
-       if (fm10k_check_ftag(dev->pci_dev->device.devargs))
+       if (fm10k_check_ftag(dev->device->devargs))
                tx_ftag_en = 1;
 
        for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -2775,7 +2775,7 @@ fm10k_set_rx_function(struct rte_eth_dev *dev)
        uint16_t i, rx_using_sse;
        uint16_t rx_ftag_en = 0;
 
-       if (fm10k_check_ftag(dev->pci_dev->device.devargs))
+       if (fm10k_check_ftag(dev->device->devargs))
                rx_ftag_en = 1;
 
        /* In order to allow Vector Rx there are a few configuration
@@ -2834,7 +2834,7 @@ static int
 eth_fm10k_dev_init(struct rte_eth_dev *dev)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
        struct rte_intr_handle *intr_handle = &pdev->intr_handle;
        int diag, i;
        struct fm10k_macvlan_filter_info *macvlan;
@@ -3013,7 +3013,7 @@ static int
 eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = dev->pci_dev;
+       struct rte_pci_device *pdev = RTE_DEV_TO_PCI(dev->device);
        struct rte_intr_handle *intr_handle = &pdev->intr_handle;
        PMD_INIT_FUNC_TRACE();
 
index da8dd7ef8829f6d4f4505e120ddb066f6ee72ee6..cbbba9f536f1f67cc7072c49b39347c9407971ad 100644 (file)
@@ -618,7 +618,7 @@ void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
        struct rte_eth_txq_info *qinfo);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
-       (eth_dev->pci_dev)
+       RTE_DEV_TO_PCI((eth_dev)->device)
 
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
index 5b8c376df41d2413cd2f0961c1ce9b02dbb20c0a..0dc0af521d60aae223b8d00db6d5cc263e070f3a 100644 (file)
@@ -2225,7 +2225,7 @@ i40evf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 
        memset(dev_info, 0, sizeof(*dev_info));
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
        dev_info->max_rx_queues = vf->vsi_res->num_queue_pairs;
        dev_info->max_tx_queues = vf->vsi_res->num_queue_pairs;
        dev_info->min_rx_bufsize = I40E_BUF_SIZE_MIN;
index a0e02aab8bc0cf3fb4b551caef0acb2666c71728..80350c252d8abfc433d9090c207599f2d7e8fea0 100644 (file)
@@ -292,7 +292,7 @@ struct ixgbe_adapter {
 };
 
 #define IXGBE_DEV_TO_PCI(eth_dev) \
-       (eth_dev->pci_dev)
+       RTE_DEV_TO_PCI((eth_dev)->device)
 
 #define IXGBE_DEV_PRIVATE_TO_HW(adapter)\
        (&((struct ixgbe_adapter *)adapter)->hw)
index ebcc9cbbf9c4c44ff4b59a79525c9f92b501148e..eb06f56a086b086c55e3b21ba26ca4074e42f954 100644 (file)
@@ -4421,7 +4421,7 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
        unsigned int max;
        char ifname[IF_NAMESIZE];
 
-       info->pci_dev = dev->pci_dev;
+       info->pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        if (priv == NULL)
                return;
@@ -5838,7 +5838,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                        eth_dev->data->dev_private = priv;
                        eth_dev->data->mac_addrs = priv->mac;
                }
-               eth_dev->pci_dev = pci_dev;
+               eth_dev->device = &pci_dev->device;
 
                rte_eth_copy_pci_info(eth_dev, pci_dev);
 
index ca123e41f0c8869b03109b510216c9f9f5112db0..b97b6d16a00e665cc0eaa5a62b8f42dacce04082 100644 (file)
@@ -655,7 +655,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                        eth_dev->data->mac_addrs = priv->mac;
                }
 
-               eth_dev->pci_dev = pci_dev;
+               eth_dev->device = &pci_dev->device;
                rte_eth_copy_pci_info(eth_dev, pci_dev);
                eth_dev->driver = &mlx5_driver;
                priv->dev = eth_dev;
index da1a3ca8150031267ef43dd39476815e8e649545..65228d5f98af183c60c7874a5d1a23cf42f063b2 100644 (file)
@@ -562,7 +562,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
        unsigned int max;
        char ifname[IF_NAMESIZE];
 
-       info->pci_dev = dev->pci_dev;
+       info->pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        priv_lock(priv);
        /* FIXME: we should ask the device for these values. */
index 590ecb2c78e27992997ec8d2ffeaed75e7957367..e85315f109edfc557a8f4e939bf1b70ad5c4a212 100644 (file)
@@ -723,7 +723,7 @@ nfp_net_close(struct rte_eth_dev *dev)
        PMD_INIT_LOG(DEBUG, "Close\n");
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       pci_dev = dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        /*
         * We assume that the DPDK application is stopping all the
@@ -1008,7 +1008,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
        dev_info->driver_name = dev->driver->pci_drv.driver.name;
        dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
        dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
@@ -1125,7 +1125,7 @@ nfp_net_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx)
 static void
 nfp_net_dev_link_status_print(struct rte_eth_dev *dev)
 {
-       struct rte_pci_device *pci_dev = dev->pci_dev;
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
        struct rte_eth_link link;
 
        memset(&link, 0, sizeof(link));
@@ -1159,7 +1159,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
        struct rte_pci_device *pci_dev;
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       pci_dev = dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        if (hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) {
                /* If MSI-X auto-masking is used, clear the entry */
@@ -2336,7 +2336,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return 0;
 
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
        hw->device_id = pci_dev->id.device_id;
index 9133fca0c521a81915295efc21ee7a164e6b7c05..e91e627c9dc851235e6605393f97cb7ea4f5f81c 100644 (file)
@@ -651,7 +651,7 @@ qede_dev_info_get(struct rte_eth_dev *eth_dev,
 
        PMD_INIT_FUNC_TRACE(edev);
 
-       dev_info->pci_dev = eth_dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        dev_info->min_rx_bufsize = (uint32_t)(ETHER_MIN_MTU +
                                              QEDE_ETH_OVERHEAD);
        dev_info->max_rx_pktlen = (uint32_t)ETH_TX_MAX_NON_LSO_PKT_LEN;
@@ -810,7 +810,7 @@ static void qede_poll_sp_sb_cb(void *param)
 
 static void qede_dev_close(struct rte_eth_dev *eth_dev)
 {
-       struct rte_pci_device *pci_dev = eth_dev->pci_dev;
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
        struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
        int rc;
@@ -1405,7 +1405,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf)
        /* Extract key data structures */
        adapter = eth_dev->data->dev_private;
        edev = &adapter->edev;
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        pci_addr = pci_dev->addr;
 
        PMD_INIT_FUNC_TRACE(edev);
index a6c2e3b69f4e4e67db7785d44aa5236d8516b707..fe7a6b3b2ac31c68cf1e37394d7bc74790e2b0ae 100644 (file)
@@ -1031,7 +1031,7 @@ eth_dev_info(struct rte_eth_dev *dev,
                struct rte_eth_dev_info *dev_info)
 {
        struct pmd_internals *internals = dev->data->dev_private;
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
        dev_info->if_index = 0;
        dev_info->max_mac_addrs = 1;
        dev_info->max_rx_pktlen = (uint32_t)-1;
@@ -1430,7 +1430,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
        struct szedata *szedata_temp;
        int ret;
        uint32_t szedata2_index;
-       struct rte_pci_device *pci_dev = dev->pci_dev;
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
        struct rte_pci_addr *pci_addr = &pci_dev->addr;
        struct rte_mem_resource *pci_rsc =
                &pci_dev->mem_resource[PCI_RESOURCE_NUMBER];
@@ -1553,7 +1553,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
 static int
 rte_szedata2_eth_dev_uninit(struct rte_eth_dev *dev)
 {
-       struct rte_pci_device *pci_dev = dev->pci_dev;
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
        struct rte_pci_addr *pci_addr = &pci_dev->addr;
 
        rte_free(dev->data->mac_addrs);
index df91289e5114d6134e8db03409924dcb54d3e97b..1060319781dd0375c86ef0280eeedf708ed4b5ad 100644 (file)
@@ -1335,10 +1335,11 @@ static void
 nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct nicvf *nic = nicvf_pmd_priv(dev);
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        PMD_INIT_FUNC_TRACE();
 
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        dev_info->min_rx_bufsize = ETHER_MIN_MTU;
        dev_info->max_rx_pktlen = NIC_HW_MAX_FRS;
@@ -1347,7 +1348,7 @@ nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        dev_info->max_tx_queues =
                        (uint16_t)MAX_SND_QUEUES_PER_QS * (MAX_SQS_PER_VF + 1);
        dev_info->max_mac_addrs = 1;
-       dev_info->max_vfs = dev->pci_dev->max_vfs;
+       dev_info->max_vfs = pci_dev->max_vfs;
 
        dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP;
        dev_info->tx_offload_capa =
@@ -1977,7 +1978,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
                }
        }
 
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
        nic->device_id = pci_dev->id.device_id;
index 6949b3996c76a6f6536d6f1b1dedf113943fa721..b11bee637125df127a03afc828da2f0c3c28865d 100644 (file)
@@ -1321,7 +1321,8 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
         * virtio_user_eth_dev_alloc() before eth_virtio_dev_init() is called.
         */
        if (!hw->virtio_user_dev) {
-               ret = vtpci_init(eth_dev->pci_dev, hw, &dev_flags);
+               ret = vtpci_init(RTE_DEV_TO_PCI(eth_dev->device), hw,
+                                &dev_flags);
                if (ret)
                        return ret;
        }
index 406beeace64310f4a042753cf158b556c1270a1d..8cb983c3ec4c5a4a0e21c173f3a9e2447a06b630 100644 (file)
@@ -310,7 +310,6 @@ virtio_user_eth_dev_alloc(const char *name)
        data->numa_node = SOCKET_ID_ANY;
        data->kdrv = RTE_KDRV_NONE;
        data->dev_flags = RTE_ETH_DEV_DETACHABLE;
-       eth_dev->pci_dev = NULL;
        eth_dev->driver = NULL;
        return eth_dev;
 }
index 5fe1d3f2d5c8b8a9fd292ac4d3f48f2f61f21078..9c4d93c1c430044392979badb25528b73ed83b3c 100644 (file)
@@ -237,7 +237,7 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->dev_ops = &vmxnet3_eth_dev_ops;
        eth_dev->rx_pkt_burst = &vmxnet3_recv_pkts;
        eth_dev->tx_pkt_burst = &vmxnet3_xmit_pkts;
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
 
        /*
         * for secondary processes, we don't initialize any further as primary
@@ -709,7 +709,7 @@ static void
 vmxnet3_dev_info_get(struct rte_eth_dev *dev,
                     struct rte_eth_dev_info *dev_info)
 {
-       dev_info->pci_dev = dev->pci_dev;
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        dev_info->max_rx_queues = VMXNET3_MAX_RX_QUEUES;
        dev_info->max_tx_queues = VMXNET3_MAX_TX_QUEUES;
index fbc4311ebd40e862551c2adb413e7033380de7c4..87cad596baa07050016ff4599e222721e3114bdc 100644 (file)
@@ -160,6 +160,12 @@ struct rte_pci_device {
        enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
 };
 
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_pci_device.
+ */
+#define RTE_DEV_TO_PCI(ptr) container_of(ptr, struct rte_pci_device, device)
+
 /** Any PCI device identifier (vendor, device, ...) */
 #define PCI_ANY_ID (0xffff)
 #define RTE_CLASS_ANY_ID (0xffffff)
index 8e02d2e01fd905dfe066762f70028fee2b641614..280f0db17706071fe59d4860b7dde2c50eec13b2 100644 (file)
@@ -261,7 +261,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
                if (eth_dev->data->dev_private == NULL)
                        rte_panic("Cannot allocate memzone for private port data\n");
        }
-       eth_dev->pci_dev = pci_dev;
+       eth_dev->device = &pci_dev->device;
        eth_dev->intr_handle = &pci_dev->intr_handle;
        eth_dev->driver = eth_drv;
 
@@ -313,7 +313,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
        if (rte_eal_process_type() == RTE_PROC_PRIMARY)
                rte_free(eth_dev->data->dev_private);
 
-       eth_dev->pci_dev = NULL;
+       eth_dev->device = NULL;
        eth_dev->driver = NULL;
        eth_dev->data = NULL;
 
@@ -2625,7 +2625,7 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
        const struct rte_memzone *mz;
 
        snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                dev->driver->pci_drv.driver.name, ring_name,
+                dev->data->drv_name, ring_name,
                 dev->data->port_id, queue_id);
 
        mz = rte_memzone_lookup(z_name);
index e1eae6585185a31be5208d2f74276fe4d0439212..fb517544b0bc338e2ccaf188fea2f6d54db70f2d 100644 (file)
@@ -1624,7 +1624,7 @@ struct rte_eth_dev {
        struct rte_eth_dev_data *data;  /**< Pointer to device data */
        const struct eth_driver *driver;/**< Driver for this device */
        const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
-       struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
+       struct rte_device *device; /**< Backing device */
        struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
        /** User application callbacks for NIC interrupts */
        struct rte_eth_dev_cb_list link_intr_cbs;