[dpdk-users] Getting pci id using port id with latest DPDK

Shreyansh Jain shreyansh.jain at nxp.com
Thu Mar 23 10:16:56 CET 2017

> -----Original Message-----
> From: users [mailto:users-bounces at dpdk.org] On Behalf Of Mike Shang
> Sent: Thursday, March 23, 2017 1:17 PM
> To: users at dpdk.org
> Subject: [dpdk-users] Getting pci id using port id with latest DPDK
> Hi,
> I have legacy code that needs to get pci id using port id in order to make
> different config for different pci device. In the past, we can do that with
> a simple call to rte_eth_dev_info_get() and look into the pci_dev file in
> rte_eth_dev_info structure. But with latest DPDK, rte_eth_dev_info_get() no
> longer fills pci_dev after this commit (
> http://dpdk.org/browse/dpdk/commit/lib/librte_ether/rte_ethdev.c?id=ae34410a8
> a8aff1b8382e16fcc89353648355be0
> ) Looks like the developers wanted to decouple pci device from a general
> device.
Yes, that is right. The idea is to remove 'PCI' dependency on the librte layer and push that as drivers' scope (anywhere other than generic lib layer). (At least from those APIs which are not PCI specific)

> Under such condition, how can I get the needed pci id from port id ? I scan
> all function listed in rte_ethdev.h but didn't find such function. Maybe
> there an indirect to do that? as a last resort, I can patch the dpdk source
> code to make rte_eth_dev_info_get() fill pci_dev again but that may be the
> last thing I would consider.....

You are saying that for the device you are using this field is not populated? For example, if you look at drivers/net/ixgbe/ixgbe_ethdev.c:

3313 static void                                                                     
3314 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)  
3315 {                                                                               
3316         struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);                 
3317         struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);  
3318         struct rte_eth_conf *dev_conf = &dev->data->dev_conf;                   
3320         dev_info->pci_dev = pci_dev;

dev_info->pci_dev is being filled by the IXGBE driver.

Can you confirm which driver you are using which doesn't fill this information?

(I am on top of tree: 84aac97b4)

Also, see the commit ae34410a8a8aff1b8382e16fcc89353648355be0

commit ae34410a8a8aff1b8382e16fcc89353648355be0
Author: Jan Blunck <jblunck at infradead.org>
Date:   Fri Dec 23 16:58:10 2016 +0100

    ethdev: move info filling of PCI into drivers
    Only the drivers itself can decide if it could fill PCI information fields
    of dev_info.
    Signed-off-by: Jan Blunck <jblunck at infradead.org>
    Acked-by: Shreyansh Jain <shreyansh.jain at nxp.com>
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index fd95136..7237bcc 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -431,6 +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->max_rx_queues  = sc->max_rx_queues;
        dev_info->max_tx_queues  = sc->max_tx_queues;


More information about the users mailing list