199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2018 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _RTE_TELEMETRY_H_ 699a2dd95SBruce Richardson #define _RTE_TELEMETRY_H_ 799a2dd95SBruce Richardson 8f7b74387SHuisong Li #include <stdint.h> 982c33481SHuisong Li #include <rte_compat.h> 10b2fafe2dSBruce Richardson #include <rte_common.h> 11f7b74387SHuisong Li 12719834a6SMattias Rönnblom #ifdef __cplusplus 13719834a6SMattias Rönnblom extern "C" { 14719834a6SMattias Rönnblom #endif 15719834a6SMattias Rönnblom 1699a2dd95SBruce Richardson /** Maximum length for string used in object. */ 17d2671e64SRadu Nicolau #define RTE_TEL_MAX_STRING_LEN 128 1899a2dd95SBruce Richardson /** Maximum length of string. */ 1999a2dd95SBruce Richardson #define RTE_TEL_MAX_SINGLE_STRING_LEN 8192 2099a2dd95SBruce Richardson /** Maximum number of dictionary entries. */ 2199a2dd95SBruce Richardson #define RTE_TEL_MAX_DICT_ENTRIES 256 2299a2dd95SBruce Richardson /** Maximum number of array entries. */ 2399a2dd95SBruce Richardson #define RTE_TEL_MAX_ARRAY_ENTRIES 512 2499a2dd95SBruce Richardson 2599a2dd95SBruce Richardson /** 2699a2dd95SBruce Richardson * @file 2799a2dd95SBruce Richardson * 2899a2dd95SBruce Richardson * RTE Telemetry. 2999a2dd95SBruce Richardson * 3099a2dd95SBruce Richardson * The telemetry library provides a method to retrieve statistics from 3199a2dd95SBruce Richardson * DPDK by sending a request message over a socket. DPDK will send 3299a2dd95SBruce Richardson * a JSON encoded response containing telemetry data. 333e4c5be9SThomas Monjalon */ 3499a2dd95SBruce Richardson 3599a2dd95SBruce Richardson /** opaque structure used internally for managing data from callbacks */ 3699a2dd95SBruce Richardson struct rte_tel_data; 3799a2dd95SBruce Richardson 3899a2dd95SBruce Richardson /** 3999a2dd95SBruce Richardson * The types of data that can be managed in arrays or dicts. 4099a2dd95SBruce Richardson * For arrays, this must be specified at creation time, while for 4199a2dd95SBruce Richardson * dicts this is specified implicitly each time an element is added 4299a2dd95SBruce Richardson * via calling a type-specific function. 4399a2dd95SBruce Richardson */ 4499a2dd95SBruce Richardson enum rte_tel_value_type { 4599a2dd95SBruce Richardson RTE_TEL_STRING_VAL, /** a string value */ 4621fc3d76SRobin Jarry RTE_TEL_INT_VAL, /** a signed 64-bit int value */ 472d2c55e4SBruce Richardson RTE_TEL_UINT_VAL, /** an unsigned 64-bit int value */ 4899a2dd95SBruce Richardson RTE_TEL_CONTAINER, /** a container struct */ 4999a2dd95SBruce Richardson }; 5099a2dd95SBruce Richardson 512d2c55e4SBruce Richardson #define RTE_TEL_U64_VAL RTE_TEL_UINT_VAL 522d2c55e4SBruce Richardson 5399a2dd95SBruce Richardson /** 5499a2dd95SBruce Richardson * Start an array of the specified type for returning from a callback 5599a2dd95SBruce Richardson * 5699a2dd95SBruce Richardson * @param d 5799a2dd95SBruce Richardson * The data structure passed to the callback 5899a2dd95SBruce Richardson * @param type 5999a2dd95SBruce Richardson * The type of the array of data 6099a2dd95SBruce Richardson * @return 6199a2dd95SBruce Richardson * 0 on success, negative errno on error 6299a2dd95SBruce Richardson */ 6399a2dd95SBruce Richardson int 6499a2dd95SBruce Richardson rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type); 6599a2dd95SBruce Richardson 6699a2dd95SBruce Richardson /** 6799a2dd95SBruce Richardson * Start a dictionary of values for returning from a callback 6899a2dd95SBruce Richardson * 692537fb0cSBruce Richardson * Dictionaries consist of key-values pairs to be returned, where the keys, 702537fb0cSBruce Richardson * or names, are strings and the values can be any of the types supported by telemetry. 712537fb0cSBruce Richardson * Name strings may only contain alphanumeric characters as well as '_' or '/' 722537fb0cSBruce Richardson * 7399a2dd95SBruce Richardson * @param d 7499a2dd95SBruce Richardson * The data structure passed to the callback 7599a2dd95SBruce Richardson * @return 7699a2dd95SBruce Richardson * 0 on success, negative errno on error 7799a2dd95SBruce Richardson */ 7899a2dd95SBruce Richardson int 7999a2dd95SBruce Richardson rte_tel_data_start_dict(struct rte_tel_data *d); 8099a2dd95SBruce Richardson 8199a2dd95SBruce Richardson /** 8299a2dd95SBruce Richardson * Set a string for returning from a callback 8399a2dd95SBruce Richardson * 8499a2dd95SBruce Richardson * @param d 8599a2dd95SBruce Richardson * The data structure passed to the callback 8699a2dd95SBruce Richardson * @param str 8799a2dd95SBruce Richardson * The string to be returned in the data structure 8899a2dd95SBruce Richardson * @return 8999a2dd95SBruce Richardson * 0 on success, negative errno on error, E2BIG on string truncation 9099a2dd95SBruce Richardson */ 9199a2dd95SBruce Richardson int 9299a2dd95SBruce Richardson rte_tel_data_string(struct rte_tel_data *d, const char *str); 9399a2dd95SBruce Richardson 9499a2dd95SBruce Richardson /** 9599a2dd95SBruce Richardson * Add a string to an array. 9699a2dd95SBruce Richardson * The array must have been started by rte_tel_data_start_array() with 9799a2dd95SBruce Richardson * RTE_TEL_STRING_VAL as the type parameter. 9899a2dd95SBruce Richardson * 9999a2dd95SBruce Richardson * @param d 10099a2dd95SBruce Richardson * The data structure passed to the callback 10199a2dd95SBruce Richardson * @param str 10299a2dd95SBruce Richardson * The string to be returned in the array 10399a2dd95SBruce Richardson * @return 10499a2dd95SBruce Richardson * 0 on success, negative errno on error, E2BIG on string truncation 10599a2dd95SBruce Richardson */ 10699a2dd95SBruce Richardson int 10799a2dd95SBruce Richardson rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str); 10899a2dd95SBruce Richardson 10999a2dd95SBruce Richardson /** 11099a2dd95SBruce Richardson * Add an int to an array. 11199a2dd95SBruce Richardson * The array must have been started by rte_tel_data_start_array() with 11299a2dd95SBruce Richardson * RTE_TEL_INT_VAL as the type parameter. 11399a2dd95SBruce Richardson * 11499a2dd95SBruce Richardson * @param d 11599a2dd95SBruce Richardson * The data structure passed to the callback 11699a2dd95SBruce Richardson * @param x 11799a2dd95SBruce Richardson * The number to be returned in the array 11899a2dd95SBruce Richardson * @return 11999a2dd95SBruce Richardson * 0 on success, negative errno on error 12099a2dd95SBruce Richardson */ 12199a2dd95SBruce Richardson int 1228e639c7cSBruce Richardson rte_tel_data_add_array_int(struct rte_tel_data *d, int64_t x); 12399a2dd95SBruce Richardson 12499a2dd95SBruce Richardson /** 125cc4f33d9SBruce Richardson * Add an unsigned value to an array. 126cc4f33d9SBruce Richardson * The array must have been started by rte_tel_data_start_array() with 127cc4f33d9SBruce Richardson * RTE_TEL_UINT_VAL as the type parameter. 128cc4f33d9SBruce Richardson * 129cc4f33d9SBruce Richardson * @param d 130cc4f33d9SBruce Richardson * The data structure passed to the callback 131cc4f33d9SBruce Richardson * @param x 132cc4f33d9SBruce Richardson * The number to be returned in the array 133cc4f33d9SBruce Richardson * @return 134cc4f33d9SBruce Richardson * 0 on success, negative errno on error 135cc4f33d9SBruce Richardson */ 136cc4f33d9SBruce Richardson int 137cc4f33d9SBruce Richardson rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x); 138cc4f33d9SBruce Richardson 139cc4f33d9SBruce Richardson /** 14099a2dd95SBruce Richardson * Add a uint64_t to an array. 14199a2dd95SBruce Richardson * The array must have been started by rte_tel_data_start_array() with 1422d2c55e4SBruce Richardson * RTE_TEL_UINT_VAL as the type parameter. 14399a2dd95SBruce Richardson * 14499a2dd95SBruce Richardson * @param d 14599a2dd95SBruce Richardson * The data structure passed to the callback 14699a2dd95SBruce Richardson * @param x 14799a2dd95SBruce Richardson * The number to be returned in the array 14899a2dd95SBruce Richardson * @return 14999a2dd95SBruce Richardson * 0 on success, negative errno on error 15099a2dd95SBruce Richardson */ 15199a2dd95SBruce Richardson int 152b2fafe2dSBruce Richardson rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x) 153b2fafe2dSBruce Richardson __rte_deprecated_msg("use 'rte_tel_data_add_array_uint' instead"); 15499a2dd95SBruce Richardson 15599a2dd95SBruce Richardson /** 15699a2dd95SBruce Richardson * Add a container to an array. A container is an existing telemetry data 15799a2dd95SBruce Richardson * array. The array the container is to be added to must have been started by 15899a2dd95SBruce Richardson * rte_tel_data_start_array() with RTE_TEL_CONTAINER as the type parameter. 15999a2dd95SBruce Richardson * The container type must be an array of type uint64_t/int/string. 16099a2dd95SBruce Richardson * 16199a2dd95SBruce Richardson * @param d 16299a2dd95SBruce Richardson * The data structure passed to the callback 16399a2dd95SBruce Richardson * @param val 16499a2dd95SBruce Richardson * The pointer to the container to be stored in the array. 16599a2dd95SBruce Richardson * @param keep 16699a2dd95SBruce Richardson * Flag to indicate that the container memory should not be automatically 16799a2dd95SBruce Richardson * freed by the telemetry library once it has finished with the data. 16899a2dd95SBruce Richardson * 1 = keep, 0 = free. 16999a2dd95SBruce Richardson * @return 17099a2dd95SBruce Richardson * 0 on success, negative errno on error 17199a2dd95SBruce Richardson */ 17299a2dd95SBruce Richardson int 17399a2dd95SBruce Richardson rte_tel_data_add_array_container(struct rte_tel_data *d, 17499a2dd95SBruce Richardson struct rte_tel_data *val, int keep); 17599a2dd95SBruce Richardson 17699a2dd95SBruce Richardson /** 17782c33481SHuisong Li * Convert an unsigned integer to hexadecimal encoded strings 17882c33481SHuisong Li * and add this string to an array. 17982c33481SHuisong Li * The array must have been started by rte_tel_data_start_array() 18082c33481SHuisong Li * with RTE_TEL_STRING_VAL as the type parameter. 18182c33481SHuisong Li * 18282c33481SHuisong Li * @param d 18382c33481SHuisong Li * The data structure passed to the callback. 18482c33481SHuisong Li * @param val 18582c33481SHuisong Li * The number to be returned in the array as a hexadecimal encoded strings. 18682c33481SHuisong Li * @param display_bitwidth 18782c33481SHuisong Li * The display bit width of the 'val'. If 'display_bitwidth' is zero, the 18882c33481SHuisong Li * value is stored in the array as no-padding zero hexadecimal encoded string, 18982c33481SHuisong Li * or the value is stored as padding zero to specified hexadecimal width. 19082c33481SHuisong Li * @return 19182c33481SHuisong Li * 0 on success, negative errno on error. 19282c33481SHuisong Li */ 19382c33481SHuisong Li __rte_experimental 19482c33481SHuisong Li int 19582c33481SHuisong Li rte_tel_data_add_array_uint_hex(struct rte_tel_data *d, uint64_t val, 19682c33481SHuisong Li uint8_t display_bitwidth); 19782c33481SHuisong Li 19882c33481SHuisong Li /** 19999a2dd95SBruce Richardson * Add a string value to a dictionary. 20099a2dd95SBruce Richardson * The dict must have been started by rte_tel_data_start_dict(). 20199a2dd95SBruce Richardson * 20299a2dd95SBruce Richardson * @param d 20399a2dd95SBruce Richardson * The data structure passed to the callback 20499a2dd95SBruce Richardson * @param name 20599a2dd95SBruce Richardson * The name the value is to be stored under in the dict 2062537fb0cSBruce Richardson * Must contain only alphanumeric characters or the symbols: '_' or '/' 20799a2dd95SBruce Richardson * @param val 20899a2dd95SBruce Richardson * The string to be stored in the dict 20999a2dd95SBruce Richardson * @return 21099a2dd95SBruce Richardson * 0 on success, negative errno on error, E2BIG on string truncation of 21199a2dd95SBruce Richardson * either name or value. 21299a2dd95SBruce Richardson */ 21399a2dd95SBruce Richardson int 21499a2dd95SBruce Richardson rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name, 21599a2dd95SBruce Richardson const char *val); 21699a2dd95SBruce Richardson 21799a2dd95SBruce Richardson /** 21899a2dd95SBruce Richardson * Add an int value to a dictionary. 21999a2dd95SBruce Richardson * The dict must have been started by rte_tel_data_start_dict(). 22099a2dd95SBruce Richardson * 22199a2dd95SBruce Richardson * @param d 22299a2dd95SBruce Richardson * The data structure passed to the callback 22399a2dd95SBruce Richardson * @param name 22499a2dd95SBruce Richardson * The name the value is to be stored under in the dict 2252537fb0cSBruce Richardson * Must contain only alphanumeric characters or the symbols: '_' or '/' 22699a2dd95SBruce Richardson * @param val 22799a2dd95SBruce Richardson * The number to be stored in the dict 22899a2dd95SBruce Richardson * @return 22999a2dd95SBruce Richardson * 0 on success, negative errno on error, E2BIG on string truncation of name. 23099a2dd95SBruce Richardson */ 23199a2dd95SBruce Richardson int 2328e639c7cSBruce Richardson rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int64_t val); 23399a2dd95SBruce Richardson 23499a2dd95SBruce Richardson /** 235cc4f33d9SBruce Richardson * Add an unsigned value to a dictionary. 236cc4f33d9SBruce Richardson * The dict must have been started by rte_tel_data_start_dict(). 237cc4f33d9SBruce Richardson * 238cc4f33d9SBruce Richardson * @param d 239cc4f33d9SBruce Richardson * The data structure passed to the callback 240cc4f33d9SBruce Richardson * @param name 241cc4f33d9SBruce Richardson * The name the value is to be stored under in the dict 242cc4f33d9SBruce Richardson * Must contain only alphanumeric characters or the symbols: '_' or '/' 243cc4f33d9SBruce Richardson * @param val 244cc4f33d9SBruce Richardson * The number to be stored in the dict 245cc4f33d9SBruce Richardson * @return 246cc4f33d9SBruce Richardson * 0 on success, negative errno on error, E2BIG on string truncation of name. 247cc4f33d9SBruce Richardson */ 248cc4f33d9SBruce Richardson int 249cc4f33d9SBruce Richardson rte_tel_data_add_dict_uint(struct rte_tel_data *d, 250cc4f33d9SBruce Richardson const char *name, uint64_t val); 251cc4f33d9SBruce Richardson 252cc4f33d9SBruce Richardson /** 25399a2dd95SBruce Richardson * Add a uint64_t value to a dictionary. 25499a2dd95SBruce Richardson * The dict must have been started by rte_tel_data_start_dict(). 25599a2dd95SBruce Richardson * 25699a2dd95SBruce Richardson * @param d 25799a2dd95SBruce Richardson * The data structure passed to the callback 25899a2dd95SBruce Richardson * @param name 25999a2dd95SBruce Richardson * The name the value is to be stored under in the dict 2602537fb0cSBruce Richardson * Must contain only alphanumeric characters or the symbols: '_' or '/' 26199a2dd95SBruce Richardson * @param val 26299a2dd95SBruce Richardson * The number to be stored in the dict 26399a2dd95SBruce Richardson * @return 26499a2dd95SBruce Richardson * 0 on success, negative errno on error, E2BIG on string truncation of name. 26599a2dd95SBruce Richardson */ 26699a2dd95SBruce Richardson int 26799a2dd95SBruce Richardson rte_tel_data_add_dict_u64(struct rte_tel_data *d, 268b2fafe2dSBruce Richardson const char *name, uint64_t val) 269b2fafe2dSBruce Richardson __rte_deprecated_msg("use 'rte_tel_data_add_dict_uint' instead"); 27099a2dd95SBruce Richardson 27199a2dd95SBruce Richardson /** 27299a2dd95SBruce Richardson * Add a container to a dictionary. A container is an existing telemetry data 27399a2dd95SBruce Richardson * array. The dict the container is to be added to must have been started by 27499a2dd95SBruce Richardson * rte_tel_data_start_dict(). The container must be an array of type 27599a2dd95SBruce Richardson * uint64_t/int/string. 27699a2dd95SBruce Richardson * 27799a2dd95SBruce Richardson * @param d 27899a2dd95SBruce Richardson * The data structure passed to the callback 27999a2dd95SBruce Richardson * @param name 28099a2dd95SBruce Richardson * The name the value is to be stored under in the dict. 2812537fb0cSBruce Richardson * Must contain only alphanumeric characters or the symbols: '_' or '/' 28299a2dd95SBruce Richardson * @param val 28399a2dd95SBruce Richardson * The pointer to the container to be stored in the dict. 28499a2dd95SBruce Richardson * @param keep 28599a2dd95SBruce Richardson * Flag to indicate that the container memory should not be automatically 28699a2dd95SBruce Richardson * freed by the telemetry library once it has finished with the data. 28799a2dd95SBruce Richardson * 1 = keep, 0 = free. 28899a2dd95SBruce Richardson * @return 28999a2dd95SBruce Richardson * 0 on success, negative errno on error 29099a2dd95SBruce Richardson */ 29199a2dd95SBruce Richardson int 29299a2dd95SBruce Richardson rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name, 29399a2dd95SBruce Richardson struct rte_tel_data *val, int keep); 29499a2dd95SBruce Richardson 29599a2dd95SBruce Richardson /** 29682c33481SHuisong Li * Convert an unsigned integer to hexadecimal encoded strings 29782c33481SHuisong Li * and add this string to an dictionary. 29882c33481SHuisong Li * The dict must have been started by rte_tel_data_start_dict(). 29982c33481SHuisong Li * 30082c33481SHuisong Li * @param d 30182c33481SHuisong Li * The data structure passed to the callback. 30282c33481SHuisong Li * @param name 30382c33481SHuisong Li * The name of the value is to be stored in the dict. 30482c33481SHuisong Li * Must contain only alphanumeric characters or the symbols: '_' or '/'. 30582c33481SHuisong Li * @param val 30682c33481SHuisong Li * The number to be stored in the dict as a hexadecimal encoded strings. 30782c33481SHuisong Li * @param display_bitwidth 30882c33481SHuisong Li * The display bit width of the 'val'. If 'display_bitwidth' is zero, the 30982c33481SHuisong Li * value is stored in the array as no-padding zero hexadecimal encoded string, 31082c33481SHuisong Li * or the value is stored as padding zero to specified hexadecimal width. 31182c33481SHuisong Li * @return 31282c33481SHuisong Li * 0 on success, negative errno on error. 31382c33481SHuisong Li */ 31482c33481SHuisong Li __rte_experimental 31582c33481SHuisong Li int 31682c33481SHuisong Li rte_tel_data_add_dict_uint_hex(struct rte_tel_data *d, const char *name, 31782c33481SHuisong Li uint64_t val, uint8_t display_bitwidth); 31882c33481SHuisong Li 31982c33481SHuisong Li /** 32099a2dd95SBruce Richardson * This telemetry callback is used when registering a telemetry command. 32199a2dd95SBruce Richardson * It handles getting and formatting information to be returned to telemetry 32299a2dd95SBruce Richardson * when requested. 32399a2dd95SBruce Richardson * 32499a2dd95SBruce Richardson * @param cmd 32599a2dd95SBruce Richardson * The cmd that was requested by the client. 32699a2dd95SBruce Richardson * @param params 32799a2dd95SBruce Richardson * Contains data required by the callback function. 32899a2dd95SBruce Richardson * @param info 32999a2dd95SBruce Richardson * The information to be returned to the caller. 33099a2dd95SBruce Richardson * 33199a2dd95SBruce Richardson * @return 33299a2dd95SBruce Richardson * Length of buffer used on success. 33399a2dd95SBruce Richardson * @return 33499a2dd95SBruce Richardson * Negative integer on error. 33599a2dd95SBruce Richardson */ 33699a2dd95SBruce Richardson typedef int (*telemetry_cb)(const char *cmd, const char *params, 33799a2dd95SBruce Richardson struct rte_tel_data *info); 33899a2dd95SBruce Richardson 33999a2dd95SBruce Richardson /** 340*ceb5914cSRobin Jarry * This telemetry callback is used when registering a telemetry command with 341*ceb5914cSRobin Jarry * rte_telemetry_register_cmd_arg(). 342*ceb5914cSRobin Jarry * 343*ceb5914cSRobin Jarry * It handles getting and formatting information to be returned to telemetry 344*ceb5914cSRobin Jarry * when requested. 345*ceb5914cSRobin Jarry * 346*ceb5914cSRobin Jarry * @param cmd 347*ceb5914cSRobin Jarry * The cmd that was requested by the client. 348*ceb5914cSRobin Jarry * @param params 349*ceb5914cSRobin Jarry * Contains data required by the callback function. 350*ceb5914cSRobin Jarry * @param arg 351*ceb5914cSRobin Jarry * The opaque value that was passed to rte_telemetry_register_cmd_arg(). 352*ceb5914cSRobin Jarry * @param info 353*ceb5914cSRobin Jarry * The information to be returned to the caller. 354*ceb5914cSRobin Jarry * 355*ceb5914cSRobin Jarry * @return 356*ceb5914cSRobin Jarry * Length of buffer used on success. 357*ceb5914cSRobin Jarry * @return 358*ceb5914cSRobin Jarry * Negative integer on error. 359*ceb5914cSRobin Jarry */ 360*ceb5914cSRobin Jarry typedef int (*telemetry_arg_cb)(const char *cmd, const char *params, void *arg, 361*ceb5914cSRobin Jarry struct rte_tel_data *info); 362*ceb5914cSRobin Jarry 363*ceb5914cSRobin Jarry /** 36499a2dd95SBruce Richardson * Used for handling data received over a telemetry socket. 36599a2dd95SBruce Richardson * 36699a2dd95SBruce Richardson * @param sock_id 36799a2dd95SBruce Richardson * ID for the socket to be used by the handler. 36899a2dd95SBruce Richardson * 36999a2dd95SBruce Richardson * @return 37099a2dd95SBruce Richardson * Void. 37199a2dd95SBruce Richardson */ 37299a2dd95SBruce Richardson typedef void * (*handler)(void *sock_id); 37399a2dd95SBruce Richardson 37499a2dd95SBruce Richardson /** 37599a2dd95SBruce Richardson * Used when registering a command and callback function with telemetry. 37699a2dd95SBruce Richardson * 37799a2dd95SBruce Richardson * @param cmd 37899a2dd95SBruce Richardson * The command to register with telemetry. 37999a2dd95SBruce Richardson * @param fn 38099a2dd95SBruce Richardson * Callback function to be called when the command is requested. 38199a2dd95SBruce Richardson * @param help 38299a2dd95SBruce Richardson * Help text for the command. 38399a2dd95SBruce Richardson * 38499a2dd95SBruce Richardson * @return 38599a2dd95SBruce Richardson * 0 on success. 38699a2dd95SBruce Richardson * @return 38799a2dd95SBruce Richardson * -EINVAL for invalid parameters failure. 38899a2dd95SBruce Richardson * @return 38964307fadSDavid Marchand * -ENOMEM for mem allocation failure. 39099a2dd95SBruce Richardson */ 39199a2dd95SBruce Richardson int 39299a2dd95SBruce Richardson rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help); 39399a2dd95SBruce Richardson 394*ceb5914cSRobin Jarry /** 395*ceb5914cSRobin Jarry * Used when registering a command and callback function with telemetry. 396*ceb5914cSRobin Jarry * 397*ceb5914cSRobin Jarry * @param cmd 398*ceb5914cSRobin Jarry * The command to register with telemetry. 399*ceb5914cSRobin Jarry * @param fn 400*ceb5914cSRobin Jarry * Callback function to be called when the command is requested. 401*ceb5914cSRobin Jarry * @param arg 402*ceb5914cSRobin Jarry * An opaque value that will be passed to the callback function. 403*ceb5914cSRobin Jarry * @param help 404*ceb5914cSRobin Jarry * Help text for the command. 405*ceb5914cSRobin Jarry * 406*ceb5914cSRobin Jarry * @return 407*ceb5914cSRobin Jarry * 0 on success. 408*ceb5914cSRobin Jarry * @return 409*ceb5914cSRobin Jarry * -EINVAL for invalid parameters failure. 410*ceb5914cSRobin Jarry * @return 411*ceb5914cSRobin Jarry * -ENOMEM for mem allocation failure. 412*ceb5914cSRobin Jarry */ 413*ceb5914cSRobin Jarry __rte_experimental 414*ceb5914cSRobin Jarry int 415*ceb5914cSRobin Jarry rte_telemetry_register_cmd_arg(const char *cmd, telemetry_arg_cb fn, void *arg, const char *help); 41699a2dd95SBruce Richardson 41799a2dd95SBruce Richardson /** 41899a2dd95SBruce Richardson * Get a pointer to a container with memory allocated. The container is to be 41999a2dd95SBruce Richardson * used embedded within an existing telemetry dict/array. 42099a2dd95SBruce Richardson * 42199a2dd95SBruce Richardson * @return 42299a2dd95SBruce Richardson * Pointer to a container. 42399a2dd95SBruce Richardson */ 42499a2dd95SBruce Richardson struct rte_tel_data * 42599a2dd95SBruce Richardson rte_tel_data_alloc(void); 42699a2dd95SBruce Richardson 42799a2dd95SBruce Richardson /** 42899a2dd95SBruce Richardson * @internal 42999a2dd95SBruce Richardson * Free a container that has memory allocated. 43099a2dd95SBruce Richardson * 43199a2dd95SBruce Richardson * @param data 43299a2dd95SBruce Richardson * Pointer to container. 433448e01f1SStephen Hemminger * If data is NULL, no operation is performed. 43499a2dd95SBruce Richardson */ 43599a2dd95SBruce Richardson void 43699a2dd95SBruce Richardson rte_tel_data_free(struct rte_tel_data *data); 43799a2dd95SBruce Richardson 438cf8e6263SBrian Dooley #ifdef __cplusplus 439cf8e6263SBrian Dooley } 440cf8e6263SBrian Dooley #endif 441cf8e6263SBrian Dooley 44299a2dd95SBruce Richardson #endif 443