brintos

brintos / linux-shallow public Read only

0
0
Text · 4.0 KiB · d45af55 Raw
127 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef _TELEMETRY_H3#define _TELEMETRY_H4 5/* Telemetry types */6#define PMT_TELEM_TELEMETRY	07#define PMT_TELEM_CRASHLOG	18 9struct telem_endpoint;10struct pci_dev;11 12struct telem_header {13	u8	access_type;14	u16	size;15	u32	guid;16	u32	base_offset;17};18 19struct telem_endpoint_info {20	struct pci_dev		*pdev;21	struct telem_header	header;22};23 24/**25 * pmt_telem_get_next_endpoint() - Get next device id for a telemetry endpoint26 * @start:  starting devid to look from27 *28 * This functions can be used in a while loop predicate to retrieve the devid29 * 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 examine31 * endpoint info and register to receive a pointer to the endpoint. The pointer32 * is then usable in the telemetry read calls to access the telemetry data.33 *34 * Return:35 * * devid       - devid of the next present endpoint from start36 * * 0           - when no more endpoints are present after start37 */38unsigned long pmt_telem_get_next_endpoint(unsigned long start);39 40/**41 * pmt_telem_register_endpoint() - Register a telemetry endpoint42 * @devid: device id/handle of the telemetry endpoint43 *44 * Increments the kref usage counter for the endpoint.45 *46 * Return:47 * * endpoint    - On success returns pointer to the telemetry endpoint48 * * -ENXIO      - telemetry endpoint not found49 */50struct telem_endpoint *pmt_telem_register_endpoint(int devid);51 52/**53 * pmt_telem_unregister_endpoint() - Unregister a telemetry endpoint54 * @ep:   ep structure to populate.55 *56 * Decrements the kref usage counter for the endpoint.57 */58void pmt_telem_unregister_endpoint(struct telem_endpoint *ep);59 60/**61 * pmt_telem_get_endpoint_info() - Get info for an endpoint from its devid62 * @devid:  device id/handle of the telemetry endpoint63 * @info:   Endpoint info structure to be populated64 *65 * Return:66 * * 0           - Success67 * * -ENXIO      - telemetry endpoint not found for the devid68 * * -EINVAL     - @info is NULL69 */70int pmt_telem_get_endpoint_info(int devid, struct telem_endpoint_info *info);71 72/**73 * pmt_telem_find_and_register_endpoint() - Get a telemetry endpoint from74 * pci_dev device, guid and pos75 * @pdev:   PCI device inside the Intel vsec76 * @guid:   GUID of the telemetry space77 * @pos:    Instance of the guid78 *79 * Return:80 * * endpoint    - On success returns pointer to the telemetry endpoint81 * * -ENXIO      - telemetry endpoint not found82 */83struct telem_endpoint *pmt_telem_find_and_register_endpoint(struct pci_dev *pcidev,84				u32 guid, u16 pos);85 86/**87 * pmt_telem_read() - Read qwords from counter sram using sample id88 * @ep:     Telemetry endpoint to be read89 * @id:     The beginning sample id of the metric(s) to be read90 * @data:   Allocated qword buffer91 * @count:  Number of qwords requested92 *93 * Callers must ensure reads are aligned. When the call returns -ENODEV,94 * the device has been removed and callers should unregister the telemetry95 * endpoint.96 *97 * Return:98 * * 0           - Success99 * * -ENODEV     - The device is not present.100 * * -EINVAL     - The offset is out bounds101 * * -EPIPE      - The device was removed during the read. Data written102 *                 but should be considered invalid.103 */104int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count);105 106/**107 * pmt_telem_read32() - Read qwords from counter sram using sample id108 * @ep:     Telemetry endpoint to be read109 * @id:     The beginning sample id of the metric(s) to be read110 * @data:   Allocated dword buffer111 * @count:  Number of dwords requested112 *113 * Callers must ensure reads are aligned. When the call returns -ENODEV,114 * the device has been removed and callers should unregister the telemetry115 * endpoint.116 *117 * Return:118 * * 0           - Success119 * * -ENODEV     - The device is not present.120 * * -EINVAL     - The offset is out bounds121 * * -EPIPE      - The device was removed during the read. Data written122 *                 but should be considered invalid.123 */124int pmt_telem_read32(struct telem_endpoint *ep, u32 id, u32 *data, u32 count);125 126#endif127