1 /* SPDX-License-Identifier: GPL-2.0 */
6 #define PMT_TELEM_TELEMETRY 0
7 #define PMT_TELEM_CRASHLOG 1
19 struct telem_endpoint_info
{
21 struct telem_header header
;
25 * pmt_telem_get_next_endpoint() - Get next device id for a telemetry endpoint
26 * @start: starting devid to look from
28 * This functions can be used in a while loop predicate to retrieve the devid
29 * of all available telemetry endpoints. Functions pmt_telem_get_next_endpoint()
30 * and pmt_telem_register_endpoint() can be used inside of the loop to examine
31 * endpoint info and register to receive a pointer to the endpoint. The pointer
32 * is then usable in the telemetry read calls to access the telemetry data.
35 * * devid - devid of the next present endpoint from start
36 * * 0 - when no more endpoints are present after start
38 unsigned long pmt_telem_get_next_endpoint(unsigned long start
);
41 * pmt_telem_register_endpoint() - Register a telemetry endpoint
42 * @devid: device id/handle of the telemetry endpoint
44 * Increments the kref usage counter for the endpoint.
47 * * endpoint - On success returns pointer to the telemetry endpoint
48 * * -ENXIO - telemetry endpoint not found
50 struct telem_endpoint
*pmt_telem_register_endpoint(int devid
);
53 * pmt_telem_unregister_endpoint() - Unregister a telemetry endpoint
54 * @ep: ep structure to populate.
56 * Decrements the kref usage counter for the endpoint.
58 void pmt_telem_unregister_endpoint(struct telem_endpoint
*ep
);
61 * pmt_telem_get_endpoint_info() - Get info for an endpoint from its devid
62 * @devid: device id/handle of the telemetry endpoint
63 * @info: Endpoint info structure to be populated
67 * * -ENXIO - telemetry endpoint not found for the devid
68 * * -EINVAL - @info is NULL
70 int pmt_telem_get_endpoint_info(int devid
, struct telem_endpoint_info
*info
);
73 * pmt_telem_find_and_register_endpoint() - Get a telemetry endpoint from
74 * pci_dev device, guid and pos
75 * @pdev: PCI device inside the Intel vsec
76 * @guid: GUID of the telemetry space
77 * @pos: Instance of the guid
80 * * endpoint - On success returns pointer to the telemetry endpoint
81 * * -ENXIO - telemetry endpoint not found
83 struct telem_endpoint
*pmt_telem_find_and_register_endpoint(struct pci_dev
*pcidev
,
87 * pmt_telem_read() - Read qwords from counter sram using sample id
88 * @ep: Telemetry endpoint to be read
89 * @id: The beginning sample id of the metric(s) to be read
90 * @data: Allocated qword buffer
91 * @count: Number of qwords requested
93 * Callers must ensure reads are aligned. When the call returns -ENODEV,
94 * the device has been removed and callers should unregister the telemetry
99 * * -ENODEV - The device is not present.
100 * * -EINVAL - The offset is out bounds
101 * * -EPIPE - The device was removed during the read. Data written
102 * but should be considered invalid.
104 int pmt_telem_read(struct telem_endpoint
*ep
, u32 id
, u64
*data
, u32 count
);
107 * pmt_telem_read32() - Read qwords from counter sram using sample id
108 * @ep: Telemetry endpoint to be read
109 * @id: The beginning sample id of the metric(s) to be read
110 * @data: Allocated dword buffer
111 * @count: Number of dwords requested
113 * Callers must ensure reads are aligned. When the call returns -ENODEV,
114 * the device has been removed and callers should unregister the telemetry
119 * * -ENODEV - The device is not present.
120 * * -EINVAL - The offset is out bounds
121 * * -EPIPE - The device was removed during the read. Data written
122 * but should be considered invalid.
124 int pmt_telem_read32(struct telem_endpoint
*ep
, u32 id
, u32
*data
, u32 count
);