1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell International Ltd.
8 #include <rte_cycles.h>
10 #include <rte_malloc.h>
11 #include <rte_spinlock.h>
12 #include <rte_trace.h>
13 #include <rte_trace_point.h>
16 #include "eal_private.h"
17 #include "eal_thread.h"
19 #define trace_err(fmt, args...) \
20 RTE_LOG(ERR, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args)
22 #define trace_crit(fmt, args...) \
23 RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args)
25 #define TRACE_PREFIX_LEN 12
26 #define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)
27 #define TRACE_CTF_FIELD_SIZE 384
28 #define TRACE_POINT_NAME_SIZE 64
29 #define TRACE_CTF_MAGIC 0xC1FC1FC1
33 STAILQ_ENTRY(trace_point) next;
34 rte_trace_point_t *handle;
35 char name[TRACE_POINT_NAME_SIZE];
36 char ctf_field[TRACE_CTF_FIELD_SIZE];
44 struct thread_mem_meta {
46 enum trace_area_e area;
54 enum rte_trace_mode mode;
57 uint32_t nb_trace_points;
58 uint32_t nb_trace_mem_list;
59 struct thread_mem_meta *lcore_meta;
62 uint64_t uptime_ticks;
64 uint32_t ctf_meta_offset_freq;
65 uint32_t ctf_meta_offset_freq_off_s;
66 uint32_t ctf_meta_offset_freq_off;
67 uint16_t ctf_fixup_done;
71 /* Helper functions */
72 static inline uint16_t
73 trace_id_get(rte_trace_point_t *trace)
75 return (*trace & __RTE_TRACE_FIELD_ID_MASK) >>
76 __RTE_TRACE_FIELD_ID_SHIFT;
80 trace_mem_sz(uint32_t len)
82 return len + sizeof(struct __rte_trace_header);
85 /* Trace object functions */
86 struct trace *trace_obj_get(void);
88 /* Trace point list functions */
89 STAILQ_HEAD(trace_point_head, trace_point);
90 struct trace_point_head *trace_list_head_get(void);
93 const char *trace_mode_to_string(enum rte_trace_mode mode);
94 const char *trace_area_to_string(enum trace_area_e area);
95 bool trace_has_duplicate_entry(void);
96 void trace_uuid_generate(void);
97 int trace_metadata_create(void);
98 void trace_metadata_destroy(void);
99 int trace_mkdir(void);
100 int trace_epoch_time_save(void);
101 void trace_mem_per_thread_free(void);
104 int eal_trace_init(void);
105 void eal_trace_fini(void);
107 #endif /* __EAL_TRACE_H */