summaryrefslogtreecommitdiff
path: root/lib/telemetry/telemetry_data.h
blob: 205509c5a2b9ea3798072abbd5e2c3593c3b26f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2020 Intel Corporation
 */

#ifndef _TELEMETRY_DATA_H_
#define _TELEMETRY_DATA_H_

#include "rte_telemetry.h"

enum tel_container_types {
	TEL_NULL,            /** null, used as error value */
	TEL_STRING,          /** basic string type, no included data */
	TEL_DICT,            /** name-value pairs, of individual value type */
	TEL_ARRAY_STRING,    /** array of string values only */
	TEL_ARRAY_INT,       /** array of signed, 32-bit int values */
	TEL_ARRAY_UINT,      /** array of unsigned 64-bit int values */
	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];
	int64_t ival;
	uint64_t uval;
	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