1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
6 #include <rte_compat.h>
8 #ifndef _RTE_TELEMETRY_H_
9 #define _RTE_TELEMETRY_H_
11 /** Maximum number of telemetry callbacks. */
12 #define TELEMETRY_MAX_CALLBACKS 64
13 /** Maximum length for string used in object. */
14 #define RTE_TEL_MAX_STRING_LEN 64
15 /** Maximum length of string. */
16 #define RTE_TEL_MAX_SINGLE_STRING_LEN 8192
17 /** Maximum number of dictionary entries. */
18 #define RTE_TEL_MAX_DICT_ENTRIES 256
19 /** Maximum number of array entries. */
20 #define RTE_TEL_MAX_ARRAY_ENTRIES 512
24 * @b EXPERIMENTAL: all functions in this file may change without prior notice
29 * The telemetry library provides a method to retrieve statistics from
30 * DPDK by sending a request message over a socket. DPDK will send
31 * a JSON encoded response containing telemetry data.
34 /** opaque structure used internally for managing data from callbacks */
38 * The types of data that can be managed in arrays or dicts.
39 * For arrays, this must be specified at creation time, while for
40 * dicts this is specified implicitly each time an element is added
41 * via calling a type-specific function.
43 enum rte_tel_value_type {
44 RTE_TEL_STRING_VAL, /** a string value */
45 RTE_TEL_INT_VAL, /** a signed 32-bit int value */
46 RTE_TEL_U64_VAL, /** an unsigned 64-bit int value */
50 * This telemetry callback is used when registering a telemetry command.
51 * It handles getting and formatting information to be returned to telemetry
55 * The cmd that was requested by the client.
57 * Contains data required by the callback function.
59 * The information to be returned to the caller.
62 * Length of buffer used on success.
64 * Negative integer on error.
66 typedef int (*telemetry_cb)(const char *cmd, const char *params,
67 struct rte_tel_data *info);
70 * Used for handling data received over a telemetry socket.
73 * ID for the socket to be used by the handler.
78 typedef void * (*handler)(void *sock_id);
82 * @b EXPERIMENTAL: this API may change without prior notice
84 * Initialize Telemetry
87 * 0 on successful initialisation.
89 * -ENOMEM on memory allocation error
91 * -EPERM on unknown error failure
93 * -EALREADY if Telemetry is already initialised.
97 rte_telemetry_init(void);
101 * @b EXPERIMENTAL: this API may change without prior notice
103 * Clean up and free memory.
112 rte_telemetry_cleanup(void);
116 * @b EXPERIMENTAL: this API may change without prior notice
118 * Runs various tests to ensure telemetry initialisation and register/unregister
119 * functions are working correctly.
122 * 0 on success when all tests have passed
124 * -1 on failure when the test has failed
128 rte_telemetry_selftest(void);
131 * Used when registering a command and callback function with telemetry.
134 * The command to register with telemetry.
136 * Callback function to be called when the command is requested.
138 * Help text for the command.
143 * -EINVAL for invalid parameters failure.
145 * -ENOENT if max callbacks limit has been reached.
149 rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help);
152 * Initialize new version of Telemetry.
161 rte_telemetry_new_init(void);