numam-dpdk/lib/librte_telemetry/telemetry_data.h
Ciara Power c933bb5177 telemetry: support array values in data object
Arrays of type uint64_t/int/string can now be included within an array
or dict. One level of embedded containers is supported. This is
necessary to allow for instances such as the ethdev queue stats to be
reported as a list of uint64_t values, rather than having multiple dict
entries with one uint64_t value for each queue stat.

The memory management APIs provided by telemetry simplify the memory
allocation/free aspect of the embedded container. The rte_tel_data_alloc
function is called in the library/app callback to return a pointer to a
container that has been allocated memory. When adding this container
to an array/dict, a parameter is passed to indicate if the memory
should be freed by telemetry after use. This will allow reuse of the
allocated memory if the library/app wishes to do so.

Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-10-06 22:55:00 +02:00

54 lines
1.5 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2020 Intel Corporation
*/
#ifndef _TELEMETRY_DATA_H_
#define _TELEMETRY_DATA_H_
#include <inttypes.h>
#include "rte_telemetry.h"
enum tel_container_types {
RTE_TEL_NULL, /** null, used as error value */
RTE_TEL_STRING, /** basic string type, no included data */
RTE_TEL_DICT, /** name-value pairs, of individual value type */
RTE_TEL_ARRAY_STRING, /** array of string values only */
RTE_TEL_ARRAY_INT, /** array of signed, 32-bit int values */
RTE_TEL_ARRAY_U64, /** array of unsigned 64-bit int values */
RTE_TEL_ARRAY_CONTAINER, /** array of container structs */
};
struct container {
struct rte_tel_data *data;
int keep;
};
/* each type here must have an equivalent enum in the value types enum in
* telemetry.h and an array type defined above, and have appropriate
* type assignment in the RTE_TEL_data_start_array() function
*/
union tel_value {
char sval[RTE_TEL_MAX_STRING_LEN];
int ival;
uint64_t u64val;
struct container container;
};
struct tel_dict_entry {
char name[RTE_TEL_MAX_STRING_LEN];
enum rte_tel_value_type type;
union tel_value value;
};
struct rte_tel_data {
enum tel_container_types type;
unsigned int data_len; /* for array or object, how many items */
union {
char str[RTE_TEL_MAX_SINGLE_STRING_LEN];
struct tel_dict_entry dict[RTE_TEL_MAX_DICT_ENTRIES];
union tel_value array[RTE_TEL_MAX_ARRAY_ENTRIES];
} data; /* data container */
};
#endif