diff options
Diffstat (limited to 'gxp-telemetry.h')
-rw-r--r-- | gxp-telemetry.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/gxp-telemetry.h b/gxp-telemetry.h new file mode 100644 index 0000000..f481577 --- /dev/null +++ b/gxp-telemetry.h @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * GXP telemetry support + * + * Copyright (C) 2021 Google LLC + */ +#ifndef __GXP_TELEMETRY_H__ +#define __GXP_TELEMETRY_H__ + +#include <linux/refcount.h> +#include <linux/types.h> + +#include "gxp.h" +#include "gxp-internal.h" + +struct gxp_telemetry_manager { + struct buffer_data { + void *buffers[GXP_NUM_CORES]; + dma_addr_t buffer_daddrs[GXP_NUM_CORES]; + u32 size; + refcount_t ref_count; + bool enabled; + } *logging_buff_data, *tracing_buff_data; + /* Protects logging_buff_data and tracing_buff_data */ + struct mutex lock; +}; + +/** + * gxp_telemetry_init() - Initialize telemetry support + * @gxp: The GXP device to initialize telemetry support for + * + * Return: + * * 0 - Success + * * -ENOMEM - Insufficient memory is available to initialize support + */ +int gxp_telemetry_init(struct gxp_dev *gxp); + +/** + * gxp_telemetry_mmap_buffers() - Allocate a telemetry buffer for each core and + * map them to their core and the user-space vma + * @gxp: The GXP device to create the buffers for + * @type: EIther `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING` + * @vma: The vma from user-space which all cores' buffers will be mapped into + * + * Return: + * * 0 - Success + * * -ENODEV - Telemetry support has not been initialized. Must explicitly + * check this, since this function is called based on user-input. + * * -EBUSY - The requested telemetry @type is already in use + * * -EINVAL - Either the vma size is not aligned or @type is not valid + * * -ENOMEM - Insufficient memory is available to allocate and map the buffers + */ +int gxp_telemetry_mmap_buffers(struct gxp_dev *gxp, u8 type, + struct vm_area_struct *vma); + +/** + * gxp_telemetry_enable() - Enable logging or tracing for all DSP cores + * @gxp: The GXP device to enable either logging or tracing for + * @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING` + * + * Return: + * * 0 - Success + * * -EINVAL - The @type provided is not valid + * * -ENXIO - Buffers for @type have not been created/mapped yet + */ +int gxp_telemetry_enable(struct gxp_dev *gxp, u8 type); + +/** + * gxp_telemetry_disable() - Disable logging or tracing for all DSP cores + * @gxp: The GXP device to disable either logging or tracing for + * @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING` + * + * Return: + * * 0 - Success + * * -EINVAL - The @type provided is not valid + * * -ENXIO - Buffers for @type have not been created/mapped yet + */ +int gxp_telemetry_disable(struct gxp_dev *gxp, u8 type); + +#endif /* __GXP_TELEMETRY_H__ */ |