| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 
|---|
| 2 | /* | 
|---|
| 3 | * TPH (TLP Processing Hints) | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright (C) 2024 Advanced Micro Devices, Inc. | 
|---|
| 6 | *     Eric Van Tassell <Eric.VanTassell@amd.com> | 
|---|
| 7 | *     Wei Huang <wei.huang2@amd.com> | 
|---|
| 8 | */ | 
|---|
| 9 | #ifndef LINUX_PCI_TPH_H | 
|---|
| 10 | #define LINUX_PCI_TPH_H | 
|---|
| 11 |  | 
|---|
| 12 | /* | 
|---|
| 13 | * According to the ECN for PCI Firmware Spec, Steering Tag can be different | 
|---|
| 14 | * depending on the memory type: Volatile Memory or Persistent Memory. When a | 
|---|
| 15 | * caller query about a target's Steering Tag, it must provide the target's | 
|---|
| 16 | * tph_mem_type. ECN link: https://members.pcisig.com/wg/PCI-SIG/document/15470. | 
|---|
| 17 | */ | 
|---|
| 18 | enum tph_mem_type { | 
|---|
| 19 | TPH_MEM_TYPE_VM,	/* volatile memory */ | 
|---|
| 20 | TPH_MEM_TYPE_PM		/* persistent memory */ | 
|---|
| 21 | }; | 
|---|
| 22 |  | 
|---|
| 23 | #ifdef CONFIG_PCIE_TPH | 
|---|
| 24 | int pcie_tph_set_st_entry(struct pci_dev *pdev, | 
|---|
| 25 | unsigned int index, u16 tag); | 
|---|
| 26 | int pcie_tph_get_cpu_st(struct pci_dev *dev, | 
|---|
| 27 | enum tph_mem_type mem_type, | 
|---|
| 28 | unsigned int cpu_uid, u16 *tag); | 
|---|
| 29 | void pcie_disable_tph(struct pci_dev *pdev); | 
|---|
| 30 | int pcie_enable_tph(struct pci_dev *pdev, int mode); | 
|---|
| 31 | u16 pcie_tph_get_st_table_size(struct pci_dev *pdev); | 
|---|
| 32 | #else | 
|---|
| 33 | static inline int pcie_tph_set_st_entry(struct pci_dev *pdev, | 
|---|
| 34 | unsigned int index, u16 tag) | 
|---|
| 35 | { return -EINVAL; } | 
|---|
| 36 | static inline int pcie_tph_get_cpu_st(struct pci_dev *dev, | 
|---|
| 37 | enum tph_mem_type mem_type, | 
|---|
| 38 | unsigned int cpu_uid, u16 *tag) | 
|---|
| 39 | { return -EINVAL; } | 
|---|
| 40 | static inline void pcie_disable_tph(struct pci_dev *pdev) { } | 
|---|
| 41 | static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) | 
|---|
| 42 | { return -EINVAL; } | 
|---|
| 43 | #endif | 
|---|
| 44 |  | 
|---|
| 45 | #endif /* LINUX_PCI_TPH_H */ | 
|---|
| 46 |  | 
|---|