1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2020 Intel Corporation 3 */ 4 5 #ifndef _RTE_TELEMETRY_INTERNAL_H_ 6 #define _RTE_TELEMETRY_INTERNAL_H_ 7 8 #include <rte_compat.h> 9 #include <rte_os.h> 10 #include "rte_telemetry.h" 11 12 /** 13 * @internal 14 * 15 * @file 16 * RTE Telemetry Legacy and internal definitions 17 * 18 ***/ 19 20 /** 21 * @internal 22 * Value representing if data is required for the command 23 */ 24 enum rte_telemetry_legacy_data_req { 25 DATA_NOT_REQ = 0, 26 DATA_REQ 27 }; 28 29 /** 30 * This telemetry callback is used when registering a legacy telemetry command. 31 * It handles getting and formatting stats to be returned to telemetry when 32 * requested. Stats up to buf_len in length are put in the buffer. 33 * 34 * @param cmd 35 * The cmd that was requested by the client. 36 * @param params 37 * Contains data required by the callback function. 38 * @param buffer 39 * A buffer to hold the formatted response. 40 * @param buf_len 41 * Length of the buffer. 42 * 43 * @return 44 * Length of buffer used on success. 45 * @return 46 * Negative integer on error. 47 */ 48 typedef int (*telemetry_legacy_cb)(const char *cmd, const char *params, 49 char *buffer, int buf_len); 50 51 /** 52 * @internal 53 * Counter for the number of registered legacy callbacks 54 */ 55 extern int num_legacy_callbacks; 56 57 /** 58 * @internal 59 * Used for handling data received over the legacy telemetry socket. 60 * 61 * @return 62 * Void. 63 */ 64 void * 65 legacy_client_handler(void *sock_id); 66 67 /** 68 * @internal 69 * 70 * Used when registering a command and callback function with 71 * telemetry legacy support. 72 * 73 * @return 74 * 0 on success. 75 * @return 76 * -EINVAL for invalid parameters failure. 77 * @return 78 * -ENOENT if max callbacks limit has been reached. 79 */ 80 __rte_internal 81 int 82 rte_telemetry_legacy_register(const char *cmd, 83 enum rte_telemetry_legacy_data_req data_req, 84 telemetry_legacy_cb fn); 85 86 /** 87 * @internal 88 * Log function type, to allow passing as parameter if necessary 89 */ 90 typedef int (*rte_log_fn)(uint32_t level, uint32_t logtype, const char *format, ...); 91 92 /** 93 * @internal 94 * Initialize Telemetry. 95 * 96 * @param runtime_dir 97 * The runtime directory of DPDK. 98 * @param cpuset 99 * The CPU set to be used for setting the thread affinity. 100 * @param log_fn 101 * Function pointer to the rte_log function for logging use 102 * @param registered_logtype 103 * The registered log type to use for logging 104 * 105 * @return 106 * 0 on success. 107 * @return 108 * -1 on failure. 109 */ 110 __rte_internal 111 int 112 rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset, 113 rte_log_fn log_fn, uint32_t registered_logtype); 114 115 #endif 116