trace: save bootup timestamp
[dpdk.git] / lib / librte_eal / common / eal_trace.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2020 Marvell International Ltd.
3  */
4
5 #ifndef __EAL_TRACE_H
6 #define __EAL_TRACE_H
7
8 #include <rte_cycles.h>
9 #include <rte_spinlock.h>
10 #include <rte_trace.h>
11 #include <rte_trace_point.h>
12 #include <rte_uuid.h>
13
14 #define trace_err(fmt, args...) \
15         RTE_LOG(ERR, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args)
16
17 #define trace_crit(fmt, args...) \
18         RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args)
19
20 #define TRACE_PREFIX_LEN 12
21 #define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)
22 #define TRACE_CTF_FIELD_SIZE 384
23 #define TRACE_POINT_NAME_SIZE 64
24
25 struct trace_point {
26         STAILQ_ENTRY(trace_point) next;
27         rte_trace_point_t *handle;
28         char name[TRACE_POINT_NAME_SIZE];
29         char ctf_field[TRACE_CTF_FIELD_SIZE];
30 };
31
32 struct trace {
33         char dir[PATH_MAX];
34         int dir_offset;
35         int register_errno;
36         bool status;
37         enum rte_trace_mode mode;
38         rte_uuid_t uuid;
39         uint32_t buff_len;
40         uint32_t nb_trace_points;
41         uint64_t epoch_sec;
42         uint64_t epoch_nsec;
43         uint64_t uptime_ticks;
44         rte_spinlock_t lock;
45 };
46
47 /* Helper functions */
48 static inline uint16_t
49 trace_id_get(rte_trace_point_t *trace)
50 {
51         return (*trace & __RTE_TRACE_FIELD_ID_MASK) >>
52                 __RTE_TRACE_FIELD_ID_SHIFT;
53 }
54
55 /* Trace object functions */
56 struct trace *trace_obj_get(void);
57
58 /* Trace point list functions */
59 STAILQ_HEAD(trace_point_head, trace_point);
60 struct trace_point_head *trace_list_head_get(void);
61
62 /* Util functions */
63 bool trace_has_duplicate_entry(void);
64 void trace_uuid_generate(void);
65 int trace_mkdir(void);
66 int trace_epoch_time_save(void);
67
68 /* EAL interface */
69 int eal_trace_init(void);
70 void eal_trace_fini(void);
71
72 #endif /* __EAL_TRACE_H */