1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _INTEL_PMT_CLASS_H 3 #define _INTEL_PMT_CLASS_H 4 5 #include <linux/intel_vsec.h> 6 #include <linux/xarray.h> 7 #include <linux/types.h> 8 #include <linux/bits.h> 9 #include <linux/err.h> 10 #include <linux/io.h> 11 12 #include "telemetry.h" 13 14 /* PMT access types */ 15 #define ACCESS_BARID 2 16 #define ACCESS_LOCAL 3 17 18 /* PMT discovery base address/offset register layout */ 19 #define GET_BIR(v) ((v) & GENMASK(2, 0)) 20 #define GET_ADDRESS(v) ((v) & GENMASK(31, 3)) 21 22 struct pci_dev; 23 extern struct class intel_pmt_class; 24 25 struct telem_endpoint { 26 struct pci_dev *pcidev; 27 struct telem_header header; 28 struct pmt_callbacks *cb; 29 void __iomem *base; 30 bool present; 31 struct kref kref; 32 }; 33 34 struct intel_pmt_header { 35 u32 base_offset; 36 u32 size; 37 u32 guid; 38 u8 access_type; 39 }; 40 41 struct intel_pmt_entry { 42 struct telem_endpoint *ep; 43 struct intel_pmt_header header; 44 struct bin_attribute pmt_bin_attr; 45 struct kobject *kobj; 46 void __iomem *disc_table; 47 void __iomem *base; 48 struct pmt_callbacks *cb; 49 unsigned long base_addr; 50 size_t size; 51 u64 feature_flags; 52 u32 guid; 53 u32 num_rmids; /* Number of Resource Monitoring IDs */ 54 int devid; 55 }; 56 57 struct intel_pmt_namespace { 58 const char *name; 59 struct xarray *xa; 60 const struct attribute_group *attr_grp; 61 int (*pmt_header_decode)(struct intel_pmt_entry *entry, 62 struct device *dev); 63 int (*pmt_add_endpoint)(struct intel_vsec_device *ivdev, 64 struct intel_pmt_entry *entry); 65 }; 66 67 int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf, 68 void __iomem *addr, loff_t off, u32 count); 69 bool intel_pmt_is_early_client_hw(struct device *dev); 70 int intel_pmt_dev_create(struct intel_pmt_entry *entry, 71 struct intel_pmt_namespace *ns, 72 struct intel_vsec_device *dev, int idx); 73 void intel_pmt_dev_destroy(struct intel_pmt_entry *entry, 74 struct intel_pmt_namespace *ns); 75 #if IS_ENABLED(CONFIG_INTEL_PMT_DISCOVERY) 76 void intel_pmt_get_features(struct intel_pmt_entry *entry); 77 #else 78 static inline void intel_pmt_get_features(struct intel_pmt_entry *entry) {} 79 #endif 80 81 #endif 82