File Index
Files and directories
Sign in
FILE

intel_vsec.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/intel_vsec.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _INTEL_VSEC_H
  3#define _INTEL_VSEC_H
  4
  5#include <linux/auxiliary_bus.h>
  6#include <linux/bits.h>
  7#include <linux/err.h>
  8#include <linux/intel_pmt_features.h>
  9
 10/*
 11 * VSEC_CAP_UNUSED is reserved. It exists to prevent zero initialized
 12 * intel_vsec devices from being automatically set to a known
 13 * capability with ID 0
 14 */
 15#define VSEC_CAP_UNUSED		BIT(0)
 16#define VSEC_CAP_TELEMETRY	BIT(1)
 17#define VSEC_CAP_WATCHER	BIT(2)
 18#define VSEC_CAP_CRASHLOG	BIT(3)
 19#define VSEC_CAP_SDSI		BIT(4)
 20#define VSEC_CAP_TPMI		BIT(5)
 21#define VSEC_CAP_DISCOVERY	BIT(6)
 22#define VSEC_FEATURE_COUNT	7
 23
 24/* Intel DVSEC offsets */
 25#define INTEL_DVSEC_ENTRIES		0xA
 26#define INTEL_DVSEC_SIZE		0xB
 27#define INTEL_DVSEC_TABLE		0xC
 28#define INTEL_DVSEC_TABLE_BAR(x)	((x) & GENMASK(2, 0))
 29#define INTEL_DVSEC_TABLE_OFFSET(x)	((x) & GENMASK(31, 3))
 30#define TABLE_OFFSET_SHIFT		3
 31
 32struct pci_dev;
 33struct resource;
 34
 35enum intel_vsec_id {
 36	VSEC_ID_TELEMETRY	= 2,
 37	VSEC_ID_WATCHER		= 3,
 38	VSEC_ID_CRASHLOG	= 4,
 39	VSEC_ID_DISCOVERY	= 12,
 40	VSEC_ID_SDSI		= 65,
 41	VSEC_ID_TPMI		= 66,
 42};
 43
 44/**
 45 * struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers.
 46 * @rev:         Revision ID of the VSEC/DVSEC register space
 47 * @length:      Length of the VSEC/DVSEC register space
 48 * @id:          ID of the feature
 49 * @num_entries: Number of instances of the feature
 50 * @entry_size:  Size of the discovery table for each feature
 51 * @tbir:        BAR containing the discovery tables
 52 * @offset:      BAR offset of start of the first discovery table
 53 */
 54struct intel_vsec_header {
 55	u8	rev;
 56	u16	length;
 57	u16	id;
 58	u8	num_entries;
 59	u8	entry_size;
 60	u8	tbir;
 61	u32	offset;
 62};
 63
 64enum intel_vsec_quirks {
 65	/* Watcher feature not supported */
 66	VSEC_QUIRK_NO_WATCHER	= BIT(0),
 67
 68	/* Crashlog feature not supported */
 69	VSEC_QUIRK_NO_CRASHLOG	= BIT(1),
 70
 71	/* Use shift instead of mask to read discovery table offset */
 72	VSEC_QUIRK_TABLE_SHIFT	= BIT(2),
 73
 74	/* DVSEC not present (provided in driver data) */
 75	VSEC_QUIRK_NO_DVSEC	= BIT(3),
 76
 77	/* Platforms requiring quirk in the auxiliary driver */
 78	VSEC_QUIRK_EARLY_HW     = BIT(4),
 79};
 80
 81/**
 82 * struct pmt_callbacks - Callback infrastructure for PMT devices
 83 * @read_telem: when specified, called by client driver to access PMT
 84 * data (instead of direct copy).
 85 * * pdev:  PCI device reference for the callback's use
 86 * * guid:  ID of data to acccss
 87 * * data:  buffer for the data to be copied
 88 * * off:   offset into the requested buffer
 89 * * count: size of buffer
 90 */
 91struct pmt_callbacks {
 92	int (*read_telem)(struct pci_dev *pdev, u32 guid, u64 *data, loff_t off, u32 count);
 93};
 94
 95struct vsec_feature_dependency {
 96	unsigned long feature;
 97	unsigned long supplier_bitmap;
 98};
 99
100/**
101 * struct intel_vsec_platform_info - Platform specific data
102 * @parent:    parent device in the auxbus chain
103 * @headers:   list of headers to define the PMT client devices to create
104 * @deps:      array of feature dependencies
105 * @priv_data: private data, usable by parent devices, currently a callback
106 * @caps:      bitmask of PMT capabilities for the given headers
107 * @quirks:    bitmask of VSEC device quirks
108 * @base_addr: allow a base address to be specified (rather than derived)
109 * @num_deps:  Count feature dependencies
110 */
111struct intel_vsec_platform_info {
112	struct device *parent;
113	struct intel_vsec_header **headers;
114	const struct vsec_feature_dependency *deps;
115	void *priv_data;
116	unsigned long caps;
117	unsigned long quirks;
118	u64 base_addr;
119	int num_deps;
120};
121
122/**
123 * struct intel_vsec_device - Auxbus specific device information
124 * @auxdev:        auxbus device struct for auxbus access
125 * @pcidev:        pci device associated with the device
126 * @resource:      any resources shared by the parent
127 * @ida:           id reference
128 * @num_resources: number of resources
129 * @id:            xarray id
130 * @priv_data:     any private data needed
131 * @priv_data_size: size of private data area
132 * @quirks:        specified quirks
133 * @base_addr:     base address of entries (if specified)
134 * @cap_id:        the enumerated id of the vsec feature
135 */
136struct intel_vsec_device {
137	struct auxiliary_device auxdev;
138	struct pci_dev *pcidev;
139	struct resource *resource;
140	struct ida *ida;
141	int num_resources;
142	int id; /* xa */
143	void *priv_data;
144	size_t priv_data_size;
145	unsigned long quirks;
146	u64 base_addr;
147	unsigned long cap_id;
148};
149
150/**
151 * struct oobmsm_plat_info - Platform information for a device instance
152 * @cdie_mask:       Mask of all compute dies in the partition
153 * @package_id:      CPU Package id
154 * @partition:       Package partition id when multiple VSEC PCI devices per package
155 * @segment:         PCI segment ID
156 * @bus_number:      PCI bus number
157 * @device_number:   PCI device number
158 * @function_number: PCI function number
159 *
160 * Structure to store platform data for a OOBMSM device instance.
161 */
162struct oobmsm_plat_info {
163	u16 cdie_mask;
164	u8 package_id;
165	u8 partition;
166	u8 segment;
167	u8 bus_number;
168	u8 device_number;
169	u8 function_number;
170};
171
172struct telemetry_region {
173	struct oobmsm_plat_info	plat_info;
174	void __iomem		*addr;
175	size_t			size;
176	u32			guid;
177	u32			num_rmids;
178};
179
180struct pmt_feature_group {
181	enum pmt_feature_id	id;
182	int			count;
183	struct kref		kref;
184	struct telemetry_region	regions[];
185};
186
187int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
188		       struct intel_vsec_device *intel_vsec_dev,
189		       const char *name);
190
191static inline struct intel_vsec_device *dev_to_ivdev(struct device *dev)
192{
193	return container_of(dev, struct intel_vsec_device, auxdev.dev);
194}
195
196static inline struct intel_vsec_device *auxdev_to_ivdev(struct auxiliary_device *auxdev)
197{
198	return container_of(auxdev, struct intel_vsec_device, auxdev);
199}
200
201#if IS_ENABLED(CONFIG_INTEL_VSEC)
202int intel_vsec_register(struct pci_dev *pdev,
203			 struct intel_vsec_platform_info *info);
204int intel_vsec_set_mapping(struct oobmsm_plat_info *plat_info,
205			   struct intel_vsec_device *vsec_dev);
206struct oobmsm_plat_info *intel_vsec_get_mapping(struct pci_dev *pdev);
207#else
208static inline int intel_vsec_register(struct pci_dev *pdev,
209				       struct intel_vsec_platform_info *info)
210{
211	return -ENODEV;
212}
213static inline int intel_vsec_set_mapping(struct oobmsm_plat_info *plat_info,
214					 struct intel_vsec_device *vsec_dev)
215{
216	return -ENODEV;
217}
218static inline struct oobmsm_plat_info *intel_vsec_get_mapping(struct pci_dev *pdev)
219{
220	return ERR_PTR(-ENODEV);
221}
222#endif
223
224#if IS_ENABLED(CONFIG_INTEL_PMT_TELEMETRY)
225struct pmt_feature_group *
226intel_pmt_get_regions_by_feature(enum pmt_feature_id id);
227
228void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group);
229#else
230static inline struct pmt_feature_group *
231intel_pmt_get_regions_by_feature(enum pmt_feature_id id)
232{
233	return ERR_PTR(-ENODEV);
234}
235
236static inline void
237intel_pmt_put_feature_group(struct pmt_feature_group *feature_group) {}
238#endif
239
240#endif
~/ Read-only file preview.