]> git.droids-corp.org - dpdk.git/commitdiff
ethdev: replace bus specific struct with generic dev
authorFerruh Yigit <ferruh.yigit@intel.com>
Mon, 9 Apr 2018 12:09:38 +0000 (13:09 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Apr 2018 22:41:44 +0000 (00:41 +0200)
Public struct rte_eth_dev_info has a "struct rte_pci_device" field in it
although it is common for all ethdev in all buses.

Replacing pci specific struct with generic device struct and updating
places that are using pci device in a way to get this information from
generic device.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Reviewed-by: David Marchand <david.marchand@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
37 files changed:
app/test-pmd/config.c
app/test-pmd/testpmd.h
doc/guides/rel_notes/release_18_05.rst
drivers/net/ark/ark_ethdev.c
drivers/net/avf/avf_ethdev.c
drivers/net/avp/avp_ethdev.c
drivers/net/axgbe/axgbe_ethdev.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/kni/rte_eth_kni.c
drivers/net/liquidio/lio_ethdev.c
drivers/net/mlx4/mlx4_ethdev.c
drivers/net/mlx5/mlx5_ethdev.c
drivers/net/nfp/nfp_net.c
drivers/net/octeontx/octeontx_ethdev.c
drivers/net/qede/qede_ethdev.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/szedata2/rte_eth_szedata2.c
drivers/net/tap/rte_eth_tap.c
drivers/net/thunderx/nicvf_ethdev.c
drivers/net/virtio/virtio_ethdev.c
drivers/net/vmxnet3/vmxnet3_ethdev.c
examples/ethtool/lib/rte_ethtool.c
examples/ip_pipeline/kni.c
examples/kni/main.c
lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h
test/test/test_kni.c

index 4bb255c6229cf4c9a3aa2bdab4ece09ffdb80ca3..dd051f5ca4b80a4b0433f826641772daa91f448a 100644 (file)
@@ -754,6 +754,8 @@ vlan_id_is_invalid(uint16_t vlan_id)
 static int
 port_reg_off_is_invalid(portid_t port_id, uint32_t reg_off)
 {
+       const struct rte_pci_device *pci_dev;
+       const struct rte_bus *bus;
        uint64_t pci_len;
 
        if (reg_off & 0x3) {
@@ -762,7 +764,21 @@ port_reg_off_is_invalid(portid_t port_id, uint32_t reg_off)
                       (unsigned)reg_off);
                return 1;
        }
-       pci_len = ports[port_id].dev_info.pci_dev->mem_resource[0].len;
+
+       if (!ports[port_id].dev_info.device) {
+               printf("Invalid device\n");
+               return 0;
+       }
+
+       bus = rte_bus_find_by_device(ports[port_id].dev_info.device);
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(ports[port_id].dev_info.device);
+       } else {
+               printf("Not a PCI device\n");
+               return 1;
+       }
+
+       pci_len = pci_dev->mem_resource[0].len;
        if (reg_off >= pci_len) {
                printf("Port %d: register offset %u (0x%X) out of port PCI "
                       "resource (length=%"PRIu64")\n",
index 8fde68d00c3791c786b25e71bcc30ff4db3bbcd6..98d84da84292ce2a3fec7b813c5ad993a2f48956 100644 (file)
@@ -502,12 +502,25 @@ mbuf_pool_find(unsigned int sock_id)
 static inline uint32_t
 port_pci_reg_read(struct rte_port *port, uint32_t reg_off)
 {
+       const struct rte_pci_device *pci_dev;
+       const struct rte_bus *bus;
        void *reg_addr;
        uint32_t reg_v;
 
-       reg_addr = (void *)
-               ((char *)port->dev_info.pci_dev->mem_resource[0].addr +
-                       reg_off);
+       if (!port->dev_info.device) {
+               printf("Invalid device\n");
+               return 0;
+       }
+
+       bus = rte_bus_find_by_device(port->dev_info.device);
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(port->dev_info.device);
+       } else {
+               printf("Not a PCI device\n");
+               return 0;
+       }
+
+       reg_addr = ((char *)pci_dev->mem_resource[0].addr + reg_off);
        reg_v = *((volatile uint32_t *)reg_addr);
        return rte_le_to_cpu_32(reg_v);
 }
@@ -518,11 +531,24 @@ port_pci_reg_read(struct rte_port *port, uint32_t reg_off)
 static inline void
 port_pci_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t reg_v)
 {
+       const struct rte_pci_device *pci_dev;
+       const struct rte_bus *bus;
        void *reg_addr;
 
-       reg_addr = (void *)
-               ((char *)port->dev_info.pci_dev->mem_resource[0].addr +
-                       reg_off);
+       if (!port->dev_info.device) {
+               printf("Invalid device\n");
+               return;
+       }
+
+       bus = rte_bus_find_by_device(port->dev_info.device);
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(port->dev_info.device);
+       } else {
+               printf("Not a PCI device\n");
+               return;
+       }
+
+       reg_addr = ((char *)pci_dev->mem_resource[0].addr + reg_off);
        *((volatile uint32_t *)reg_addr) = rte_cpu_to_le_32(reg_v);
 }
 
index fb00f0c07f75693ede84ac002ace1793a9e19166..3731ffdd7c50759ec93d9eeb6fddd38a4fa3920d 100644 (file)
@@ -114,6 +114,9 @@ API Changes
   memory footprint which helps in better cache utilization when large number
   of meter objects are used.
 
+* ethdev, in struct ``struct rte_eth_dev_info``, field ``rte_pci_device *pci_dev``
+  replaced with field ``struct rte_device *device``.
+
 
 ABI Changes
 -----------
index ff87c20e25ad3ab81929d860248198f6c7768f99..c9d541921cfcc6bd76cedf0535122187c0325e98 100644 (file)
@@ -771,7 +771,6 @@ eth_ark_dev_info_get(struct rte_eth_dev *dev,
                                ETH_LINK_SPEED_40G |
                                ETH_LINK_SPEED_50G |
                                ETH_LINK_SPEED_100G);
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 }
 
 static int
index ff900651e10323b074bae6c701265127ab7072e2..5409130074c493b8c18fb93e12cf6755df1d31b6 100644 (file)
@@ -507,7 +507,6 @@ avf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 
        memset(dev_info, 0, sizeof(*dev_info));
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
        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 = AVF_BUF_SIZE_MIN;
index a07a288edf92f4e6d6418c844f0223c77438aa50..5b3c4cebf01d07a941febe700ca8b9029a6912fd 100644 (file)
@@ -2172,7 +2172,6 @@ avp_dev_info_get(struct rte_eth_dev *eth_dev,
 {
        struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        dev_info->max_rx_queues = avp->max_rx_queues;
        dev_info->max_tx_queues = avp->max_tx_queues;
        dev_info->min_rx_bufsize = AVP_MIN_RX_BUFSIZE;
index a9a9fb57080cbadd31715377c0d250fcabe15c7d..7a3ba2e7b87cc974d1a5275ede128c49a9f57fba 100644 (file)
@@ -349,12 +349,10 @@ axgbe_dev_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
-axgbe_dev_info_get(struct rte_eth_dev *dev,
-                  struct rte_eth_dev_info *dev_info)
+axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct axgbe_port *pdata = dev->data->dev_private;
 
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
        dev_info->max_rx_queues = pdata->rx_ring_count;
        dev_info->max_tx_queues = pdata->tx_ring_count;
        dev_info->min_rx_bufsize = AXGBE_RX_MIN_BUF_SIZE;
index 934d87fcd2ef05fc57f482de26d0a649bfd104b4..e08ef779fda574e51e59acc645d9c5f040e927a9 100644 (file)
@@ -449,7 +449,6 @@ static void
 bnx2x_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct bnx2x_softc *sc = dev->data->dev_private;
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
        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;
index 193a43a12328e2e22bf537fcfdddedbdbbc7e0f1..54348de26e64f763c1ef676e0a5c0eba0d61ca5e 100644 (file)
@@ -404,8 +404,6 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
        uint16_t max_vnics, i, j, vpool, vrxq;
        unsigned int max_rx_rings;
 
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-
        /* MAC Specifics */
        dev_info->max_mac_addrs = bp->max_l2_ctx;
        dev_info->max_hash_mac_addrs = 0;
index 581a1f33a29997db925ce6a2d0277967795b5f4c..24c9a9323a50ea7b74a3b8fc81fc8201a92f4ba7 100644 (file)
@@ -134,8 +134,6 @@ void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
                .nb_align = 1,
        };
 
-       device_info->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-
        device_info->min_rx_bufsize = CXGBE_MIN_RX_BUFSIZE;
        device_info->max_rx_pktlen = CXGBE_MAX_RX_PKTLEN;
        device_info->max_rx_queues = max_queues;
index ffdc7fd57e5f724cfe4642e2a252d10a1610f745..d95b701c7b7c886ffc02bf201a472a25a288cdf6 100644 (file)
@@ -1073,7 +1073,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
        dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
        dev_info->max_rx_pktlen = em_get_max_pktlen(dev);
        dev_info->max_mac_addrs = hw->mac.rar_entry_count;
index 8d4226676622e7ef82e6f75ccba1fb5c9780cd24..87235714667c41cf6ae175559343e2548507cf20 100644 (file)
@@ -2144,7 +2144,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
        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;
@@ -2269,7 +2268,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
        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 f7bfc7ae96003c72f69b2da5d5328373ed81066a..ab4e2af91bc12b1bd3bd3a0d8fc61ed5f2ac658d 100644 (file)
@@ -1531,8 +1531,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
-
        dev_info->speed_capa =
                        ETH_LINK_SPEED_1G   |
                        ETH_LINK_SPEED_2_5G |
index 03f0c2547499ab2d7ceedde2f9cdb90e93fb91f5..801f4704c3e0b5182f02de1faf4cd5473d7680f5 100644 (file)
@@ -471,7 +471,6 @@ 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 = RTE_ETH_DEV_TO_PCI(eth_dev);
        /* 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;
index 61de4d772a37360bfcb6d6b7faba6b301ddfb6d7..34affd1cc99087577094b5cde64fb6a6bd4b8524 100644 (file)
@@ -1404,7 +1404,6 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 
        PMD_INIT_FUNC_TRACE();
 
-       dev_info->pci_dev            = pdev;
        dev_info->min_rx_bufsize     = FM10K_MIN_RX_BUF_SIZE;
        dev_info->max_rx_pktlen      = FM10K_MAX_PKT_SIZE;
        dev_info->max_rx_queues      = hw->mac.max_queues;
index 858033104c02cfcf64816b42dc7e1da019a34a27..f1e6c3d3d2d5532a2fa36e63154b2627c8fd60cd 100644 (file)
@@ -3212,7 +3212,6 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        struct i40e_vsi *vsi = pf->main_vsi;
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 
-       dev_info->pci_dev = pci_dev;
        dev_info->max_rx_queues = vsi->nb_qps;
        dev_info->max_tx_queues = vsi->nb_qps;
        dev_info->min_rx_bufsize = I40E_BUF_SIZE_MIN;
index 2908c87e00510b8c5819423b7853bf0bc3a4af3d..f6d7f40b1459313557cabad6b1d6e080be060704 100644 (file)
@@ -2183,7 +2183,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
        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 752a17af0a7b38fe565087d6f00a826ebf85e1ce..0b776071778a9f1915a150bf7ad9259b002a12ec 100644 (file)
@@ -3595,7 +3595,6 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
 
-       dev_info->pci_dev = pci_dev;
        dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
        dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
        if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
@@ -3714,7 +3713,6 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
        struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       dev_info->pci_dev = pci_dev;
        dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
        dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
        dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
index dc4e65f5d924c2dd6f8c3509f182322580e5b1d0..c10e970c21e2e6e3548c41f2c99bf57bc0c9e7c2 100644 (file)
@@ -201,7 +201,6 @@ eth_kni_dev_info(struct rte_eth_dev *dev __rte_unused,
        dev_info->max_rx_queues = KNI_MAX_QUEUE_PER_PORT;
        dev_info->max_tx_queues = KNI_MAX_QUEUE_PER_PORT;
        dev_info->min_rx_bufsize = 0;
-       dev_info->pci_dev = NULL;
 }
 
 static int
index eeb8350e4da8832a1a195e7b25d613711871c725..a13a566f9af4b074fbfe510902f21345a86f6af8 100644 (file)
@@ -373,8 +373,6 @@ lio_dev_info_get(struct rte_eth_dev *eth_dev,
        struct lio_device *lio_dev = LIO_DEV(eth_dev);
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
-       devinfo->pci_dev = pci_dev;
-
        switch (pci_dev->id.subsystem_device_id) {
        /* CN23xx 10G cards */
        case PCI_SUBSYS_DEV_ID_CN2350_210:
index 6a54534c1c8cad66009bffc231bb2014b7b9e71c..09e24b2b013733f1ad6a67e998f0f1bcd15af0ac 100644 (file)
@@ -556,7 +556,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
        /* FIXME: we should ask the device for these values. */
        info->min_rx_bufsize = 32;
        info->max_rx_pktlen = 65536;
index 19bf4d4637cc9448d0436a6979cbb6b41dc490e4..ef44cc91fc1c7761cbc0aacd6e47335d2a921ed5 100644 (file)
@@ -432,7 +432,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
        /* FIXME: we should ask the device for these values. */
        info->min_rx_bufsize = 32;
        info->max_rx_pktlen = 65536;
index 606cd3dc2c572475e9e676385636d7bf8d78de84..e030bbf9f3451e80b687ff5435abbabdd618a2bc 100644 (file)
@@ -1253,7 +1253,6 @@ 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 = RTE_ETH_DEV_TO_PCI(dev);
        dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
        dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
        dev_info->min_rx_bufsize = ETHER_MIN_MTU;
index 1406e4e19d95992f04ce56350da658989450555e..f829e0ca985cc0162fbf8c59a0814d813209dbc6 100644 (file)
@@ -616,7 +616,6 @@ octeontx_dev_info(struct rte_eth_dev *dev,
        dev_info->max_rx_queues = 1;
        dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
        dev_info->min_rx_bufsize = 0;
-       dev_info->pci_dev = NULL;
 
        dev_info->default_rxconf = (struct rte_eth_rxconf) {
                .rx_free_thresh = 0,
index a4e9e753e6ff460f5daed03dfd2d59634a32c2e4..13c2a3b87b9aa8c1abba04f9d8d9ba4a0683e561 100644 (file)
@@ -1549,7 +1549,6 @@ qede_dev_info_get(struct rte_eth_dev *eth_dev,
 
        PMD_INIT_FUNC_TRACE(edev);
 
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        dev_info->min_rx_bufsize = (uint32_t)QEDE_MIN_RX_BUFF_SIZE;
        dev_info->max_rx_pktlen = (uint32_t)ETH_TX_MAX_NON_LSO_PKT_LEN;
        dev_info->rx_desc_lim = qede_rx_desc_lim;
index 2af898e08a5c8979c62a7e7ee9293190c7f6d434..6631c5a7ebb96475866e82d99a9bdd430c9a3f1e 100644 (file)
@@ -89,7 +89,6 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
        sfc_log_init(sa, "entry");
 
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
        dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX;
 
        /* Autonegotiation may be disabled */
index fb9aac04b5d57189cb456b90c851de25c94849b1..41a6fb42731b0e8305e14f7f2a0741438e2bf5ff 100644 (file)
@@ -1015,7 +1015,6 @@ eth_dev_info(struct rte_eth_dev *dev,
 {
        struct pmd_internals *internals = dev->data->dev_private;
 
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
        dev_info->if_index = 0;
        dev_info->max_mac_addrs = 1;
        dev_info->max_rx_pktlen = (uint32_t)-1;
index 61d6465581b6a053d460e824b14fb1663d85c0e5..54c7c2b0fe7e6cfa146f4c647d427cce6819b0e6 100644 (file)
@@ -760,7 +760,6 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        dev_info->max_rx_queues = RTE_PMD_TAP_MAX_QUEUES;
        dev_info->max_tx_queues = RTE_PMD_TAP_MAX_QUEUES;
        dev_info->min_rx_bufsize = 0;
-       dev_info->pci_dev = NULL;
        dev_info->speed_capa = tap_dev_speed_capa();
        dev_info->rx_queue_offload_capa = tap_rx_offload_get_queue_capa();
        dev_info->rx_offload_capa = tap_rx_offload_get_port_capa() |
index 067f2243bca9601d31c1a40aa0c5d5986a955b39..75e9d16c5e6abb5a7cc8d2e45b0a099f3de4c537 100644 (file)
@@ -1400,8 +1400,6 @@ nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
        PMD_INIT_FUNC_TRACE();
 
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-
        /* Autonegotiation may be disabled */
        dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
        dev_info->speed_capa |= ETH_LINK_SPEED_10M | ETH_LINK_SPEED_100M |
index bf2c81b8f62541b1fafc65c9f2d2489bd1c4cfb6..da022e940ed1b658f1638309792361b4d4ba6fa2 100644 (file)
@@ -2064,7 +2064,6 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
        dev_info->speed_capa = ETH_LINK_SPEED_10G; /* fake value */
 
-       dev_info->pci_dev = dev->device ? RTE_ETH_DEV_TO_PCI(dev) : NULL;
        dev_info->max_rx_queues =
                RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES);
        dev_info->max_tx_queues =
index 104664a521a056a63f8c4c86513a6dc3fa666be7..93d9de1ca60df3a755aeacdcb170427cd2b1b6f6 100644 (file)
@@ -1023,11 +1023,9 @@ vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 }
 
 static void
-vmxnet3_dev_info_get(struct rte_eth_dev *dev,
+vmxnet3_dev_info_get(struct rte_eth_dev *dev __rte_unused,
                     struct rte_eth_dev_info *dev_info)
 {
-       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-
        dev_info->max_rx_queues = VMXNET3_MAX_RX_QUEUES;
        dev_info->max_tx_queues = VMXNET3_MAX_TX_QUEUES;
        dev_info->min_rx_bufsize = 1518 + RTE_PKTMBUF_HEADROOM;
index 90dfbb739637d34c5eef7541381163ac9cc7eaf9..d519a50db953a6c799736c47e8f198c3734c550d 100644 (file)
@@ -22,6 +22,8 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
 {
        struct rte_eth_dev_info dev_info;
        struct rte_dev_reg_info reg_info;
+       const struct rte_pci_device *pci_dev;
+       const struct rte_bus *bus = NULL;
        int n;
        int ret;
 
@@ -46,15 +48,17 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
        snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
                rte_version());
        /* TODO: replace bus_info by rte_devargs.name */
-       if (dev_info.pci_dev)
+       if (dev_info.device)
+               bus = rte_bus_find_by_device(dev_info.device);
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(dev_info.device);
                snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
                        "%04x:%02x:%02x.%x",
-                       dev_info.pci_dev->addr.domain,
-                       dev_info.pci_dev->addr.bus,
-                       dev_info.pci_dev->addr.devid,
-                       dev_info.pci_dev->addr.function);
-       else
+                       pci_dev->addr.domain, pci_dev->addr.bus,
+                       pci_dev->addr.devid, pci_dev->addr.function);
+       } else {
                snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "N/A");
+       }
 
        memset(&reg_info, 0, sizeof(reg_info));
        rte_eth_dev_get_reg_info(port_id, &reg_info);
index ebc8c7904ef610ae17c63810bfbfdebfe8359885..712775338274778b18b0b879bdfdc14655575d91 100644 (file)
@@ -106,6 +106,8 @@ kni_create(const char *name, struct kni_params *params)
        struct mempool *mempool;
        struct link *link;
        struct rte_kni *k;
+       const struct rte_pci_device *pci_dev;
+       const struct rte_bus *bus = NULL;
 
        /* Check input params */
        if ((name == NULL) ||
@@ -128,8 +130,13 @@ kni_create(const char *name, struct kni_params *params)
        kni_conf.core_id = params->thread_id;
        kni_conf.group_id = link->port_id;
        kni_conf.mbuf_size = mempool->buffer_size;
-       kni_conf.addr = dev_info.pci_dev->addr;
-       kni_conf.id = dev_info.pci_dev->id;
+       if (dev_info.device)
+               bus = rte_bus_find_by_device(dev_info.device);
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(dev_info.device);
+               kni_conf.addr = pci_dev->addr;
+               kni_conf.id = pci_dev->id;
+       }
 
        memset(&kni_ops, 0, sizeof(kni_ops));
        kni_ops.port_id = link->port_id;
index 0d9980ee1e02974fd03e1bef5ed06ae2dd365cc5..aebfedd598514e2a62e360a410a3a433561a3925 100644 (file)
@@ -834,13 +834,18 @@ kni_alloc(uint16_t port_id)
                if (i == 0) {
                        struct rte_kni_ops ops;
                        struct rte_eth_dev_info dev_info;
+                       const struct rte_pci_device *pci_dev;
+                       const struct rte_bus *bus = NULL;
 
                        memset(&dev_info, 0, sizeof(dev_info));
                        rte_eth_dev_info_get(port_id, &dev_info);
 
-                       if (dev_info.pci_dev) {
-                               conf.addr = dev_info.pci_dev->addr;
-                               conf.id = dev_info.pci_dev->id;
+                       if (dev_info.device)
+                               bus = rte_bus_find_by_device(dev_info.device);
+                       if (bus && !strcmp(bus->name, "pci")) {
+                               pci_dev = RTE_DEV_TO_PCI(dev_info.device);
+                               conf.addr = pci_dev->addr;
+                               conf.id = pci_dev->id;
                        }
                        /* Get the interface default mac address */
                        rte_eth_macaddr_get(port_id,
index d0cf0e7a3d2b9e5a2d05e944fbc3d01cb9a652cf..a364af3408ce232c2813ed7c406d7c276db8bcb8 100644 (file)
@@ -2395,6 +2395,7 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
        memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
        dev_info->rx_desc_lim = lim;
        dev_info->tx_desc_lim = lim;
+       dev_info->device = dev->device;
 
        RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
        (*dev->dev_ops->dev_infos_get)(dev, dev_info);
index 5e13dca6ab3c61661240fff5b96d0cf60d04769c..784c6faa4297a23e5b0d7b22641e273c7f187296 100644 (file)
@@ -992,7 +992,7 @@ struct rte_pci_device;
  * Ethernet device information
  */
 struct rte_eth_dev_info {
-       struct rte_pci_device *pci_dev; /**< Device PCI information. */
+       struct rte_device *device; /** Generic device information */
        const char *driver_name; /**< Device Driver name. */
        unsigned int if_index; /**< Index to bound host interface, or 0 if none.
                Use if_indextoname() to translate into an interface name. */
index e4839cdb74740856086eba876c5a8c078945258c..3d1be56a982d421e03149865f3bd49c10e98f715 100644 (file)
@@ -357,6 +357,8 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp)
        struct rte_kni_conf conf;
        struct rte_eth_dev_info info;
        struct rte_kni_ops ops;
+       const struct rte_pci_device *pci_dev;
+       const struct rte_bus *bus = NULL;
 
        if (!mp)
                return -1;
@@ -366,8 +368,13 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp)
        memset(&ops, 0, sizeof(ops));
 
        rte_eth_dev_info_get(port_id, &info);
-       conf.addr = info.pci_dev->addr;
-       conf.id = info.pci_dev->id;
+       if (info.device)
+               bus = rte_bus_find_by_device(info.device);
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(info.device);
+               conf.addr = pci_dev->addr;
+               conf.id = pci_dev->id;
+       }
        snprintf(conf.name, sizeof(conf.name), TEST_KNI_PORT);
 
        /* core id 1 configured for kernel thread */
@@ -465,6 +472,8 @@ test_kni(void)
        struct rte_kni_conf conf;
        struct rte_eth_dev_info info;
        struct rte_kni_ops ops;
+       const struct rte_pci_device *pci_dev;
+       const struct rte_bus *bus;
 
        /* Initialize KNI subsytem */
        rte_kni_init(KNI_TEST_MAX_PORTS);
@@ -523,8 +532,15 @@ test_kni(void)
        memset(&conf, 0, sizeof(conf));
        memset(&ops, 0, sizeof(ops));
        rte_eth_dev_info_get(port_id, &info);
-       conf.addr = info.pci_dev->addr;
-       conf.id = info.pci_dev->id;
+       if (info.device)
+               bus = rte_bus_find_by_device(info.device);
+       else
+               bus = NULL;
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(info.device);
+               conf.addr = pci_dev->addr;
+               conf.id = pci_dev->id;
+       }
        conf.group_id = port_id;
        conf.mbuf_size = MAX_PACKET_SZ;
 
@@ -552,8 +568,15 @@ test_kni(void)
        memset(&info, 0, sizeof(info));
        memset(&ops, 0, sizeof(ops));
        rte_eth_dev_info_get(port_id, &info);
-       conf.addr = info.pci_dev->addr;
-       conf.id = info.pci_dev->id;
+       if (info.device)
+               bus = rte_bus_find_by_device(info.device);
+       else
+               bus = NULL;
+       if (bus && !strcmp(bus->name, "pci")) {
+               pci_dev = RTE_DEV_TO_PCI(info.device);
+               conf.addr = pci_dev->addr;
+               conf.id = pci_dev->id;
+       }
        conf.group_id = port_id;
        conf.mbuf_size = MAX_PACKET_SZ;