如何在 dpdk 18.08 中从 rte_device 获取 rte_pci_device 详细信息
How do I obtain rte_pci_device details from rte_device in dpdk 18.08
我想比较检测到的设备信息( dev_info 类型 struct rte_eth_dev_info dev_info )与配置的 pci 设备地址详细信息(类型 struct [=] 关联的每个端口20=] pciaddr)。
for (port = 0; port < nb_sys_ports; port++) {
rte_eth_dev_info_get(port, &dev_info);
}
但是在struct struct rte_eth_dev_info中,字段rte_pci_device *pci_dev已经被struct rte_device *device字段替换了。
那么如何从 rte_device.
获取 rte_pci_device 详细信息
DPDK现在支持非PCI总线,所以有点复杂。但是,仍然很少有例子。这是 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);
}
基本上,我们得到了DPDK端口的总线。如果是 PCI,使用 RTE_DEV_TO_PCI()
宏是安全的。宏 returns 指向 struct rte_pci_device
的指针,它具有 PCI 地址。
我想比较检测到的设备信息( dev_info 类型 struct rte_eth_dev_info dev_info )与配置的 pci 设备地址详细信息(类型 struct [=] 关联的每个端口20=] pciaddr)。
for (port = 0; port < nb_sys_ports; port++) {
rte_eth_dev_info_get(port, &dev_info);
}
但是在struct struct rte_eth_dev_info中,字段rte_pci_device *pci_dev已经被struct rte_device *device字段替换了。 那么如何从 rte_device.
获取 rte_pci_device 详细信息DPDK现在支持非PCI总线,所以有点复杂。但是,仍然很少有例子。这是 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);
}
基本上,我们得到了DPDK端口的总线。如果是 PCI,使用 RTE_DEV_TO_PCI()
宏是安全的。宏 returns 指向 struct rte_pci_device
的指针,它具有 PCI 地址。