How to get bus/device/number from struct pci_dev?

为君一笑 提交于 2019-12-14 03:08:11

问题


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?

and

struct pci_slot *slot;

In my test, the *slot point to NULL, why ?


回答1:


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




回答2:


Devfn contains the device number in bits 7:3 and the function number in bits 2:0. The bus number is in bus->number. So the BDF is

    bus->number << 8 | devfn

I don’t know about slot; perhaps the device you are looking at is an integrated device?



来源:https://stackoverflow.com/questions/53809842/how-to-get-bus-device-number-from-struct-pci-dev

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!