[英]How do I obtain rte_pci_device details from rte_device in dpdk 18.08
I want to compare the detected device information ( dev_info of type struct rte_eth_dev_info dev_info ) associated with each port with configured pci device address details ( of type struct rte_pci_addr pciaddr). 我想将检测到的与每个端口关联的设备信息(struct rte_eth_dev_info dev_info类型的dev_info)与配置的pci设备地址详细信息(struct rte_pci_addr类型的pciaddr)进行比较。
for (port = 0; port < nb_sys_ports; port++) {
rte_eth_dev_info_get(port, &dev_info);
}
But In struct struct rte_eth_dev_info, field rte_pci_device *pci_dev has been replaced with field struct rte_device *device. 但是在struct struct rte_eth_dev_info中,字段rte_pci_device * pci_dev已被替换为struct rte_device * device。 So how do I obtain the rte_pci_device details from rte_device.
因此,我如何从rte_device获取rte_pci_device详细信息。
DPDK supports now non-PCI buses, so it's a bit more complicated. DPDK现在支持非PCI总线,因此有点复杂。 But still, there are few examples.
但是,仍然没有几个例子。 Here is a snippet from the Ethtool :
这是Ethtool的片段:
struct rte_pci_device *pci_dev;
rte_eth_dev_info_get(port_id, &dev_info);
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",
pci_dev->addr.domain, pci_dev->addr.bus,
pci_dev->addr.devid, pci_dev->addr.function);
}
Basically, we get the bus of the DPDK port. 基本上,我们获得了DPDK端口的总线。 If it's a PCI, it's safe to use
RTE_DEV_TO_PCI()
macro. 如果是PCI,则可以安全使用
RTE_DEV_TO_PCI()
宏。 The macro returns a pointer to struct rte_pci_device
, which has the PCI address. 该宏返回指向
struct rte_pci_device
的指针,该指针具有PCI地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.