diff options
Diffstat (limited to 'gxp-telemetry.h')
-rw-r--r-- | gxp-telemetry.h | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/gxp-telemetry.h b/gxp-telemetry.h index f481577..80436ba 100644 --- a/gxp-telemetry.h +++ b/gxp-telemetry.h @@ -7,22 +7,33 @@ #ifndef __GXP_TELEMETRY_H__ #define __GXP_TELEMETRY_H__ +#include <linux/eventfd.h> #include <linux/refcount.h> #include <linux/types.h> #include "gxp.h" #include "gxp-internal.h" +struct gxp_telemetry_work { + struct work_struct work; + struct gxp_dev *gxp; + uint core; +}; + struct gxp_telemetry_manager { struct buffer_data { + u32 host_status; 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; + struct gxp_telemetry_work notification_works[GXP_NUM_CORES]; + wait_queue_head_t waitq; + struct eventfd_ctx *logging_efd; + struct eventfd_ctx *tracing_efd; }; /** @@ -77,4 +88,47 @@ int gxp_telemetry_enable(struct gxp_dev *gxp, u8 type); */ int gxp_telemetry_disable(struct gxp_dev *gxp, u8 type); +/** + * gxp_telemetry_register_eventfd() - Register an eventfd to be signaled when + * telemetry notifications arrive while the + * specified @type of telemetry is enabled + * @gxp: The GXP device to register the eventfd for + * @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING` + * @fd: A file descriptor for an eventfd from user-space + * + * If another eventfd has already been registered for the given @type, the old + * eventfd will be unregistered and replaced. + * + * Return: + * * 0 - Success + * * -EBADF - @fd is not a valid file descriptor (via `eventfd_ctx_fdget()`) + * * -EINVAL - Invalid @type or @fd is not an eventfd + */ +int gxp_telemetry_register_eventfd(struct gxp_dev *gxp, u8 type, int fd); + +/** + * gxp_telemetry_unregister_eventfd() - Unregister and release a reference to + * a previously registered eventfd + * @gxp: The GXP device to unregister the eventfd for + * @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING` + * + * Return: + * * 0 - Success + * * -EINVAL - The @type provided is not valid + */ +int gxp_telemetry_unregister_eventfd(struct gxp_dev *gxp, u8 type); + +/** + * gxp_telemetry_get_notification_handler() - Get the notification handler work + * for the specified core + * @gxp: The GXP device to obtain the handler for + * @core: The physical core number to obtain the handler + * + * Return: A pointer to the work_struct for the @core's notification handler if + * successful. NULL if telemetry has not been initialized or @core is + * invalid. + */ +struct work_struct *gxp_telemetry_get_notification_handler(struct gxp_dev *gxp, + uint core); + #endif /* __GXP_TELEMETRY_H__ */ |