我想将检测到的与每个端口相关联的设备信息(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);
}
但是在struct struct rte_eth_dev_info中,字段rte_pci_device * pci_dev已替换为struct rte_device * device字段。 因此,我如何从rte_device获取rte_pci_device详细信息。
答案 0 :(得分:0)
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()
宏。宏返回指向struct rte_pci_device
的指针,该指针具有PCI地址。