[英]How to get bus/device/number from struct pci_dev?
https://elixir.bootlin.com/linux/latest/source/include/linux/pci.h#L286 https://elixir.bootlin.com/linux/latest/source/include/linux/pci.h#L286
In 在
struct pci_dev,
I can only see bus and function: 我只能看到总线和功能:
struct pci_bus *bus;
and 和
unsigned int devfn;
seems no device (of B/D/F) information? 似乎没有(B / D / F)的设备信息?
and 和
struct pci_slot *slot;
In my test, the *slot point to NULL, why ? 在我的测试中,*插槽指向NULL,为什么?
I found: 我发现:
device = PCI_SLOT(pdev->devfn);
fn = PCI_FUNC(pdev->devfn);
https://elixir.bootlin.com/linux/v3.5/source/include/linux/pci.h#L31 https://elixir.bootlin.com/linux/v3.5/source/include/linux/pci.h#L31
Devfn contains the device number in bits 7:3 and the function number in bits 2:0. Devfn在第7:3位包含设备编号,在第2:0位包含功能编号。 The bus number is in bus->number.
总线号在bus-> number中。 So the BDF is
所以BDF是
bus->number << 8 | devfn
I don't know about slot; 我不知道广告位; perhaps the device you are looking at is an integrated device?
也许您正在查看的设备是集成设备?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.