Add two helper macros 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index b2bec02f3ea0..50640fdc84e1 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -9,6 +9,8 @@ #ifndef LINUX_PCI_TPH_H #define LINUX_PCI_TPH_H +#include + /* * According to the ECN for PCI Firmware Spec, Steering Tag can be different * depending on the memory type: Volatile Memory or Persistent Memory. When a @@ -21,6 +23,18 @@ enum tph_mem_type { }; #ifdef CONFIG_PCIE_TPH +/** + * pcie_std_tph_supported - check standard TPH requester support + * @pdev: PCI device + */ +#define pcie_std_tph_supported(pdev) \ + ((pdev)->tph_max_type >= PCI_TPH_REQ_TPH_ONLY) +/** + * pcie_ext_tph_supported - check extended TPH requester support + * @pdev: PCI device + */ +#define pcie_ext_tph_supported(pdev) \ + ((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, @@ -33,6 +47,8 @@ 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 +#define pcie_std_tph_supported(pdev) false +#define pcie_ext_tph_supported(pdev) false static inline int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag) { return -EINVAL; } -- 2.17.1