VMware vSphere

 View Only
  • 1.  How to get all pci devices

    Posted Jun 26, 2014 10:14 AM

    Hi all,

    Environment: VMware ESXi 5.5.0 (VMKernel Release Build 1331820), ddk-5.5.0-1331820

    1.Use command "lspci -v", I can find a lot of pci devices (more than 15);

    2.Use the kernel api "pci_get_device" in my test driver code,that only print a little pci devices(only 4).

    Part of codes follow list:

    while ((pDev = pci_get_device_all(PCI_ANY_ID, PCI_ANY_ID, pDev)) != NULL)

    {

        printk("find bus number %02x, vendor %04x, device %04x\n",

                            pDev->bus->number, pDev->vendor, pDev->device);

        continue;

        ...

    }

    Anybody can help me resolve this problem? Thank you!



  • 2.  RE: How to get all pci devices

    Posted Feb 06, 2015 06:18 AM

    Hi,

    Just try with "pci_get_device" function.Link: https://www.kernel.org/doc/htmldocs/kernel-api/API-pci-get-device.html

    In code,write as

    struct pci_dev *pdev = NULL;

    while((pdev=pci_get_device(PCI_ANY_ID,PCI_ANY_ID,pdev))!=NULL)

    {

    printk("Device found vendor_id=0x%x and device_id=0x%x...\n",pdev->vendor,pdev->device);

    }

    Hope it'll give all device.