xref: /dpdk/lib/telemetry/telemetry_internal.h (revision 68150b90bda5e8f81ad1b1bad82be653b1d42a81)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2020 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_TELEMETRY_INTERNAL_H_
699a2dd95SBruce Richardson #define _RTE_TELEMETRY_INTERNAL_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson #include <rte_compat.h>
999a2dd95SBruce Richardson #include <rte_os.h>
1099a2dd95SBruce Richardson #include "rte_telemetry.h"
1199a2dd95SBruce Richardson 
1299a2dd95SBruce Richardson /**
1399a2dd95SBruce Richardson  * @internal
1499a2dd95SBruce Richardson  *
1599a2dd95SBruce Richardson  * @file
1699a2dd95SBruce Richardson  * RTE Telemetry Legacy and internal definitions
173e4c5be9SThomas Monjalon  */
1899a2dd95SBruce Richardson 
1999a2dd95SBruce Richardson /**
2099a2dd95SBruce Richardson  * @internal
2199a2dd95SBruce Richardson  * Value representing if data is required for the command
2299a2dd95SBruce Richardson  */
2399a2dd95SBruce Richardson enum rte_telemetry_legacy_data_req {
2499a2dd95SBruce Richardson 	DATA_NOT_REQ = 0,
2599a2dd95SBruce Richardson 	DATA_REQ
2699a2dd95SBruce Richardson };
2799a2dd95SBruce Richardson 
2899a2dd95SBruce Richardson /**
2999a2dd95SBruce Richardson  * This telemetry callback is used when registering a legacy telemetry command.
3099a2dd95SBruce Richardson  * It handles getting and formatting stats to be returned to telemetry when
3199a2dd95SBruce Richardson  * requested. Stats up to buf_len in length are put in the buffer.
3299a2dd95SBruce Richardson  *
3399a2dd95SBruce Richardson  * @param cmd
3499a2dd95SBruce Richardson  * The cmd that was requested by the client.
3599a2dd95SBruce Richardson  * @param params
3699a2dd95SBruce Richardson  * Contains data required by the callback function.
3799a2dd95SBruce Richardson  * @param buffer
3899a2dd95SBruce Richardson  * A buffer to hold the formatted response.
3999a2dd95SBruce Richardson  * @param buf_len
4099a2dd95SBruce Richardson  * Length of the buffer.
4199a2dd95SBruce Richardson  *
4299a2dd95SBruce Richardson  * @return
4399a2dd95SBruce Richardson  * Length of buffer used on success.
4499a2dd95SBruce Richardson  * @return
4599a2dd95SBruce Richardson  * Negative integer on error.
4699a2dd95SBruce Richardson  */
4799a2dd95SBruce Richardson typedef int (*telemetry_legacy_cb)(const char *cmd, const char *params,
4899a2dd95SBruce Richardson 		char *buffer, int buf_len);
4999a2dd95SBruce Richardson 
5099a2dd95SBruce Richardson /**
5199a2dd95SBruce Richardson  * @internal
5299a2dd95SBruce Richardson  * Counter for the number of registered legacy callbacks
5399a2dd95SBruce Richardson  */
5499a2dd95SBruce Richardson extern int num_legacy_callbacks;
5599a2dd95SBruce Richardson 
5699a2dd95SBruce Richardson /**
5799a2dd95SBruce Richardson  * @internal
5899a2dd95SBruce Richardson  * Used for handling data received over the legacy telemetry socket.
5999a2dd95SBruce Richardson  *
6099a2dd95SBruce Richardson  * @return
6199a2dd95SBruce Richardson  * Void.
6299a2dd95SBruce Richardson  */
6399a2dd95SBruce Richardson void *
6499a2dd95SBruce Richardson legacy_client_handler(void *sock_id);
6599a2dd95SBruce Richardson 
6699a2dd95SBruce Richardson /**
6799a2dd95SBruce Richardson  * @internal
6899a2dd95SBruce Richardson  *
6999a2dd95SBruce Richardson  * Used when registering a command and callback function with
7099a2dd95SBruce Richardson  * telemetry legacy support.
7199a2dd95SBruce Richardson  *
7299a2dd95SBruce Richardson  * @return
7399a2dd95SBruce Richardson  *  0 on success.
7499a2dd95SBruce Richardson  * @return
7599a2dd95SBruce Richardson  *  -EINVAL for invalid parameters failure.
7699a2dd95SBruce Richardson  *  @return
7799a2dd95SBruce Richardson  *  -ENOENT if max callbacks limit has been reached.
7899a2dd95SBruce Richardson  */
7999a2dd95SBruce Richardson __rte_internal
8099a2dd95SBruce Richardson int
8199a2dd95SBruce Richardson rte_telemetry_legacy_register(const char *cmd,
8299a2dd95SBruce Richardson 		enum rte_telemetry_legacy_data_req data_req,
8399a2dd95SBruce Richardson 		telemetry_legacy_cb fn);
8499a2dd95SBruce Richardson 
8599a2dd95SBruce Richardson /**
8699a2dd95SBruce Richardson  * @internal
8799a2dd95SBruce Richardson  * Log function type, to allow passing as parameter if necessary
8899a2dd95SBruce Richardson  */
8999a2dd95SBruce Richardson typedef int (*rte_log_fn)(uint32_t level, uint32_t logtype, const char *format, ...);
9099a2dd95SBruce Richardson 
9199a2dd95SBruce Richardson /**
9299a2dd95SBruce Richardson  * @internal
9399a2dd95SBruce Richardson  * Initialize Telemetry.
9499a2dd95SBruce Richardson  *
9599a2dd95SBruce Richardson  * @param runtime_dir
9699a2dd95SBruce Richardson  * The runtime directory of DPDK.
9799a2dd95SBruce Richardson  * @param cpuset
9899a2dd95SBruce Richardson  * The CPU set to be used for setting the thread affinity.
9999a2dd95SBruce Richardson  * @param log_fn
10099a2dd95SBruce Richardson  * Function pointer to the rte_log function for logging use
10199a2dd95SBruce Richardson  * @param registered_logtype
10299a2dd95SBruce Richardson  * The registered log type to use for logging
10399a2dd95SBruce Richardson  *
10499a2dd95SBruce Richardson  * @return
10599a2dd95SBruce Richardson  *  0 on success.
10699a2dd95SBruce Richardson  * @return
10799a2dd95SBruce Richardson  *  -1 on failure.
10899a2dd95SBruce Richardson  */
10999a2dd95SBruce Richardson __rte_internal
11099a2dd95SBruce Richardson int
111*68150b90SBruce Richardson rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset);
11299a2dd95SBruce Richardson 
11399a2dd95SBruce Richardson #endif
114