Add two helper functions for TPH capability checking: - pcie_std_tph_supported(): check basic standard TPH support - pcie_ext_tph_supported(): check extended TPH requester support They rely on the cached tph_max_type value validated during probe, and provide consistent capability queries for subsequent VFIO TPH virtualization code. Stub definitions are added for !CONFIG_PCIE_TPH. Signed-off-by: Chengwen Feng --- include/linux/pci-tph.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index 04c93822ee6d..5defe407ef75 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -23,6 +23,24 @@ enum tph_mem_type { }; #ifdef CONFIG_PCIE_TPH +/** + * pcie_std_tph_supported - check standard TPH requester support + * @pdev: PCI device + */ +static inline bool pcie_std_tph_supported(struct pci_dev *pdev) +{ + return pdev->tph_max_type >= PCI_TPH_REQ_TPH_ONLY; +} + +/** + * pcie_ext_tph_supported - check extended TPH requester support + * @pdev: PCI device + */ +static inline bool pcie_ext_tph_supported(struct pci_dev *pdev) +{ + return pdev->tph_max_type == PCI_TPH_REQ_EXT_TPH; +} + int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag); int pcie_tph_get_cpu_st_ext(struct pci_dev *dev, enum tph_mem_type mem_type, @@ -35,6 +53,10 @@ int pcie_enable_tph(struct pci_dev *pdev, u8 mode); u16 pcie_tph_get_st_table_size(struct pci_dev *pdev); u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev); #else +static inline bool pcie_std_tph_supported(struct pci_dev *pdev) +{ return false; } +static inline bool pcie_ext_tph_supported(struct pci_dev *pdev) +{ return false; } static inline int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag) { return -EINVAL; } -- 2.17.1