【问题标题】:How to get bus/device/number from struct pci_dev?如何从 struct pci_dev 获取总线/设备/编号?
【发布时间】:2018-12-17 16:41:44
【问题描述】:

https://elixir.bootlin.com/linux/latest/source/include/linux/pci.h#L286

在

struct pci_dev,

我只能看到总线和函数:

struct pci_bus  *bus;   

和

unsigned int    devfn;  

似乎没有设备(B/D/F)信息?

和

struct pci_slot *slot;

在我的测试中,*slot 指向 NULL,为什么?

【问题讨论】:

    标签: linux driver pci


    【解决方案1】:

    我找到了:

    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 包含位 7:3 中的设备号和位 2:0 中的功能号。总线号在 bus->number 中。所以 BDF 是

          bus->number << 8 | devfn
      

      我不知道插槽;也许您正在查看的设备是集成设备?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-02-09
        • 1970-01-01
        • 2014-01-25
        • 1970-01-01
        • 1970-01-01
        • 2023-03-06
        • 2010-09-11
        • 1970-01-01
        相关资源
        最近更新 更多