dm: PTM: Get # of children of a pci bridge or pci bus

Add functionality to build and cache pci hierarchy, which are mainly
    used to retrieve # of children of pci bridge or pci bus.

    get_device_count_on_bus(): get # of child devices on a pci bus
    get_device_count_on_bridge(): recursively get # of child devices on a pci bridge
    scan_pci(): build and cache pci hierarchy
    pci_find_root_port(): find root port of a pci device
    clean_pci_cache(): free pci cache
    scan_pci_test(): test of scan pci hierarchy (disabled)

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Rong Liu
2021-04-28 21:15:08 +00:00
committed by wenlingz
parent d3185f8a0c
commit a7b0d9848f
2 changed files with 238 additions and 0 deletions

View File

@@ -11,10 +11,18 @@
#include <stdbool.h>
#include "pciaccess.h"
struct pci_device_info;
int pci_find_cap(struct pci_device *pdev, const int cap_id);
int pci_find_ext_cap(struct pci_device *pdev, int cap_id);
int pci_get_pcie_type(struct pci_device *dev);
bool is_root_port(struct pci_device *pdev);
bool is_bridge(struct pci_device *pdev);
int get_device_count_on_bus(int bus);
int get_device_count_on_bridge(const struct pci_device_info *bridge_info);
int scan_pci(void);
struct pci_device * pci_find_root_port(const struct pci_device *pdev);
void clean_pci_cache(void);
#endif