* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / include / nr5g_fapi_log.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2021 Intel.
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19 /**
20  * @file This file consist of fapi logging macro.
21  *
22  **/
23
24 #ifndef NR5G_FAPI_LOG_H_
25 #define NR5G_FAPI_LOG_H_
26
27 #include <stdio.h>
28
29 #define NR5G_FAPI_STATS_FNAME "FapiStats.txt"
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 typedef enum _nr5g_fapi_log_types_t {
37     NONE_LOG = 0,
38     INFO_LOG,                    // default
39     DEBUG_LOG,
40     ERROR_LOG,
41     TRACE_LOG,
42 } nr5g_fapi_log_types_t;
43
44 extern nr5g_fapi_log_types_t nr5g_fapi_log_level_g;
45 // get_logger_type_str is utility function, returns logging lever string.
46 char *get_logger_type_str(
47     nr5g_fapi_log_types_t e);
48
49 void nr5g_fapi_set_log_level(
50     nr5g_fapi_log_types_t new_level);
51
52 nr5g_fapi_log_types_t nr5g_fapi_get_log_level(
53     );
54
55 // NR5G_FAPI__LOG utility Macro for logging.
56 #define NR5G_FAPI_LOG(TYPE, MSG) do { \
57     if(TYPE == ERROR_LOG) { \
58         printf("[%s]", get_logger_type_str(TYPE)); \
59         printf MSG ;\
60         printf("\n");\
61     }   \
62     else \
63     { \
64         if((nr5g_fapi_log_level_g > NONE_LOG) && (TYPE <= nr5g_fapi_log_level_g)) { \
65             printf("[%s]", get_logger_type_str(TYPE)); \
66             printf MSG ;\
67             printf("\n");\
68         }   \
69     } \
70 } while(0)
71
72 typedef struct _nr5g_fapi_performance_statistic {
73     uint64_t min_cycle;
74     uint64_t max_cycle;
75     uint64_t avg_cycle;
76     uint32_t count;
77 } nr5g_fapi_performance_statistic_t;
78
79 extern nr5g_fapi_log_types_t nr5g_fapi_log_level_g;
80 extern nr5g_fapi_performance_statistic_t fapi_statis_info_wls_get_dl;
81 extern nr5g_fapi_performance_statistic_t fapi_statis_info_parse_dl;
82 extern nr5g_fapi_performance_statistic_t fapi_statis_info_wls_send_dl;
83 extern nr5g_fapi_performance_statistic_t fapi_statis_info_wls_get_ul;
84 extern nr5g_fapi_performance_statistic_t fapi_statis_info_parse_ul;
85 extern nr5g_fapi_performance_statistic_t fapi_statis_info_wls_send_ul;
86 extern uint64_t tick_total_wls_get_per_tti_dl;
87 extern uint64_t tick_total_parse_per_tti_dl;
88 extern uint64_t tick_total_wls_send_per_tti_dl;
89 extern uint64_t tick_total_wls_get_per_tti_ul;
90 extern uint64_t tick_total_parse_per_tti_ul;
91 extern uint64_t tick_total_wls_send_per_tti_ul;
92 extern uint16_t g_statistic_start_flag;
93
94 uint16_t nr5g_fapi_statistic_info_set(
95     nr5g_fapi_performance_statistic_t * fapi_statis_info,
96     uint64_t * tick_val_in,
97     uint16_t start_flag);
98
99 uint16_t nr5g_fapi_statistic_info_init(
100     );
101
102 uint16_t nr5g_fapi_statistic_info_print(
103     );
104 uint16_t nr5g_fapi_statistic_info_set_all(
105     );
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif                          // NR5G_FAPI_LOG_H_