1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2020 Intel Corporation 3 */ 4 5 #ifndef _RTE_TELEMETRY_LEGACY_H_ 6 #define _RTE_TELEMETRY_LEGACY_H_ 7 8 #include <rte_compat.h> 9 #include "rte_telemetry.h" 10 11 /** 12 * @internal 13 * @warning 14 * @b EXPERIMENTAL: this API may change without prior notice 15 16 * @file 17 * RTE Telemetry Legacy 18 * 19 ***/ 20 21 /** 22 * @internal 23 * Value representing if data is required for the command 24 */ 25 enum rte_telemetry_legacy_data_req { 26 DATA_NOT_REQ = 0, 27 DATA_REQ 28 }; 29 30 /** 31 * This telemetry callback is used when registering a legacy telemetry command. 32 * It handles getting and formatting stats to be returned to telemetry when 33 * requested. Stats up to buf_len in length are put in the buffer. 34 * 35 * @param cmd 36 * The cmd that was requested by the client. 37 * @param params 38 * Contains data required by the callback function. 39 * @param buffer 40 * A buffer to hold the formatted response. 41 * @param buf_len 42 * Length of the buffer. 43 * 44 * @return 45 * Length of buffer used on success. 46 * @return 47 * Negative integer on error. 48 */ 49 typedef int (*telemetry_legacy_cb)(const char *cmd, const char *params, 50 char *buffer, int buf_len); 51 52 /** 53 * @internal 54 * Counter for the number of registered legacy callbacks 55 */ 56 extern int num_legacy_callbacks; 57 58 /** 59 * @internal 60 * Used for handling data received over the legacy telemetry socket. 61 * 62 * @return 63 * Void. 64 */ 65 void * 66 legacy_client_handler(void *sock_id); 67 68 /** 69 * @internal 70 * 71 * Used when registering a command and callback function with 72 * telemetry legacy support. 73 * 74 * @return 75 * 0 on success. 76 * @return 77 * -EINVAL for invalid parameters failure. 78 * @return 79 * -ENOENT if max callbacks limit has been reached. 80 */ 81 __rte_experimental 82 int 83 rte_telemetry_legacy_register(const char *cmd, 84 enum rte_telemetry_legacy_data_req data_req, 85 telemetry_legacy_cb fn); 86 87 #endif 88