X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_telemetry%2Frte_telemetry.h;h=4693275c24ff457e6fbfa2b7ee01baf34d5a4c53;hb=af270529adb9b6f995192979f78a3e3fc9f52562;hp=66290a3fdf579e852f0eb58326384de5f7626a7a;hpb=6dd571fd07c3b79b0176f5aba3ae99cfbee582dd;p=dpdk.git diff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h index 66290a3fdf..4693275c24 100644 --- a/lib/librte_telemetry/rte_telemetry.h +++ b/lib/librte_telemetry/rte_telemetry.h @@ -3,6 +3,7 @@ */ #include +#include #include #ifndef _RTE_TELEMETRY_H_ @@ -20,11 +21,13 @@ #define RTE_TEL_MAX_ARRAY_ENTRIES 512 /** - * @warning - * @b EXPERIMENTAL: all functions in this file may change without prior notice - * * @file - * RTE Telemetry + * + * RTE Telemetry. + * + * @warning + * @b EXPERIMENTAL: + * All functions in this file may be changed or removed without prior notice. * * The telemetry library provides a method to retrieve statistics from * DPDK by sending a request message over a socket. DPDK will send @@ -44,88 +47,227 @@ enum rte_tel_value_type { RTE_TEL_STRING_VAL, /** a string value */ RTE_TEL_INT_VAL, /** a signed 32-bit int value */ RTE_TEL_U64_VAL, /** an unsigned 64-bit int value */ + RTE_TEL_CONTAINER, /** a container struct */ }; /** - * This telemetry callback is used when registering a telemetry command. - * It handles getting and formatting information to be returned to telemetry - * when requested. - * - * @param cmd - * The cmd that was requested by the client. - * @param params - * Contains data required by the callback function. - * @param info - * The information to be returned to the caller. + * Start an array of the specified type for returning from a callback * + * @param d + * The data structure passed to the callback + * @param type + * The type of the array of data * @return - * Length of buffer used on success. - * @return - * Negative integer on error. + * 0 on success, negative errno on error */ -typedef int (*telemetry_cb)(const char *cmd, const char *params, - struct rte_tel_data *info); +__rte_experimental +int +rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type); /** - * Used for handling data received over a telemetry socket. + * Start a dictionary of values for returning from a callback * - * @param sock_id - * ID for the socket to be used by the handler. + * @param d + * The data structure passed to the callback + * @return + * 0 on success, negative errno on error + */ +__rte_experimental +int +rte_tel_data_start_dict(struct rte_tel_data *d); + +/** + * Set a string for returning from a callback * + * @param d + * The data structure passed to the callback + * @param str + * The string to be returned in the data structure * @return - * Void. + * 0 on success, negative errno on error, E2BIG on string truncation */ -typedef void * (*handler)(void *sock_id); +__rte_experimental +int +rte_tel_data_string(struct rte_tel_data *d, const char *str); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice + * Add a string to an array. + * The array must have been started by rte_tel_data_start_array() with + * RTE_TEL_STRING_VAL as the type parameter. * - * Initialize Telemetry + * @param d + * The data structure passed to the callback + * @param str + * The string to be returned in the array + * @return + * 0 on success, negative errno on error, E2BIG on string truncation + */ +__rte_experimental +int +rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str); + +/** + * Add an int to an array. + * The array must have been started by rte_tel_data_start_array() with + * RTE_TEL_INT_VAL as the type parameter. * + * @param d + * The data structure passed to the callback + * @param x + * The number to be returned in the array * @return - * 0 on successful initialisation. + * 0 on success, negative errno on error + */ +__rte_experimental +int +rte_tel_data_add_array_int(struct rte_tel_data *d, int x); + +/** + * Add a uint64_t to an array. + * The array must have been started by rte_tel_data_start_array() with + * RTE_TEL_U64_VAL as the type parameter. + * + * @param d + * The data structure passed to the callback + * @param x + * The number to be returned in the array * @return - * -ENOMEM on memory allocation error + * 0 on success, negative errno on error + */ +__rte_experimental +int +rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x); + +/** + * Add a container to an array. A container is an existing telemetry data + * array. The array the container is to be added to must have been started by + * rte_tel_data_start_array() with RTE_TEL_CONTAINER as the type parameter. + * The container type must be an array of type uint64_t/int/string. + * + * @param d + * The data structure passed to the callback + * @param val + * The pointer to the container to be stored in the array. + * @param keep + * Flag to indicate that the container memory should not be automatically + * freed by the telemetry library once it has finished with the data. + * 1 = keep, 0 = free. * @return - * -EPERM on unknown error failure + * 0 on success, negative errno on error + */ +__rte_experimental +int +rte_tel_data_add_array_container(struct rte_tel_data *d, + struct rte_tel_data *val, int keep); + +/** + * Add a string value to a dictionary. + * The dict must have been started by rte_tel_data_start_dict(). + * + * @param d + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict + * @param val + * The string to be stored in the dict * @return - * -EALREADY if Telemetry is already initialised. + * 0 on success, negative errno on error, E2BIG on string truncation of + * either name or value. */ __rte_experimental -int32_t -rte_telemetry_init(void); +int +rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name, + const char *val); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice + * Add an int value to a dictionary. + * The dict must have been started by rte_tel_data_start_dict(). * - * Clean up and free memory. + * @param d + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict + * @param val + * The number to be stored in the dict + * @return + * 0 on success, negative errno on error, E2BIG on string truncation of name. + */ +__rte_experimental +int +rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val); + +/** + * Add a uint64_t value to a dictionary. + * The dict must have been started by rte_tel_data_start_dict(). * + * @param d + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict + * @param val + * The number to be stored in the dict * @return - * 0 on success + * 0 on success, negative errno on error, E2BIG on string truncation of name. + */ +__rte_experimental +int +rte_tel_data_add_dict_u64(struct rte_tel_data *d, + const char *name, uint64_t val); + +/** + * Add a container to a dictionary. A container is an existing telemetry data + * array. The dict the container is to be added to must have been started by + * rte_tel_data_start_dict(). The container must be an array of type + * uint64_t/int/string. + * + * @param d + * The data structure passed to the callback + * @param name + * The name the value is to be stored under in the dict. + * @param val + * The pointer to the container to be stored in the dict. + * @param keep + * Flag to indicate that the container memory should not be automatically + * freed by the telemetry library once it has finished with the data. + * 1 = keep, 0 = free. * @return - * -EPERM on failure + * 0 on success, negative errno on error */ __rte_experimental -int32_t -rte_telemetry_cleanup(void); +int +rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name, + struct rte_tel_data *val, int keep); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice + * This telemetry callback is used when registering a telemetry command. + * It handles getting and formatting information to be returned to telemetry + * when requested. * - * Runs various tests to ensure telemetry initialisation and register/unregister - * functions are working correctly. + * @param cmd + * The cmd that was requested by the client. + * @param params + * Contains data required by the callback function. + * @param info + * The information to be returned to the caller. * * @return - * 0 on success when all tests have passed + * Length of buffer used on success. * @return - * -1 on failure when the test has failed + * Negative integer on error. */ -__rte_experimental -int32_t -rte_telemetry_selftest(void); +typedef int (*telemetry_cb)(const char *cmd, const char *params, + struct rte_tel_data *info); + +/** + * Used for handling data received over a telemetry socket. + * + * @param sock_id + * ID for the socket to be used by the handler. + * + * @return + * Void. + */ +typedef void * (*handler)(void *sock_id); /** * Used when registering a command and callback function with telemetry. @@ -149,7 +291,16 @@ int rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help); /** - * Initialize new version of Telemetry. + * @internal + * Initialize Telemetry. + * + * @param runtime_dir + * The runtime directory of DPDK. + * @param cpuset + * The CPU set to be used for setting the thread affinity. + * @param err_str + * This err_str pointer should point to NULL on entry. In the case of an error + * or warning, it will be non-NULL on exit. * * @return * 0 on success. @@ -158,5 +309,30 @@ rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help); */ __rte_experimental int -rte_telemetry_new_init(void); +rte_telemetry_init(const char *runtime_dir, rte_cpuset_t *cpuset, + const char **err_str); + +/** + * Get a pointer to a container with memory allocated. The container is to be + * used embedded within an existing telemetry dict/array. + * + * @return + * Pointer to a container. + */ +__rte_experimental +struct rte_tel_data * +rte_tel_data_alloc(void); + +/** + * @internal + * Free a container that has memory allocated. + * + * @param data + * Pointer to container. + *. + */ +__rte_experimental +void +rte_tel_data_free(struct rte_tel_data *data); + #endif