Commit 4ceb5916 authored by oai's avatar oai

log utility configuration enhancement

parent 4843960f
......@@ -56,8 +56,8 @@
#include "common/config/config_userapi.h"
RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc);
RCconfig_S1(MessageDef *msg_p, uint32_t i);
int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc);
int RCconfig_S1(MessageDef *msg_p, uint32_t i);
static int enb_check_band_frequencies(char* lib_config_file_name_pP,
......
......@@ -51,28 +51,7 @@
#define ENB_CONF_STRING_OTG_APP_TYPE "app_type"
#define ENB_CONF_STRING_OTG_BG_TRAFFIC "bg_traffic"
// per eNB configuration
#define ENB_CONFIG_STRING_LOG_CONFIG "log_config"
#define ENB_CONFIG_STRING_GLOBAL_LOG_LEVEL "global_log_level"
#define ENB_CONFIG_STRING_GLOBAL_LOG_VERBOSITY "global_log_verbosity"
#define ENB_CONFIG_STRING_HW_LOG_LEVEL "hw_log_level"
#define ENB_CONFIG_STRING_HW_LOG_VERBOSITY "hw_log_verbosity"
#define ENB_CONFIG_STRING_PHY_LOG_LEVEL "phy_log_level"
#define ENB_CONFIG_STRING_PHY_LOG_VERBOSITY "phy_log_verbosity"
#define ENB_CONFIG_STRING_MAC_LOG_LEVEL "mac_log_level"
#define ENB_CONFIG_STRING_MAC_LOG_VERBOSITY "mac_log_verbosity"
#define ENB_CONFIG_STRING_RLC_LOG_LEVEL "rlc_log_level"
#define ENB_CONFIG_STRING_RLC_LOG_VERBOSITY "rlc_log_verbosity"
#define ENB_CONFIG_STRING_PDCP_LOG_LEVEL "pdcp_log_level"
#define ENB_CONFIG_STRING_PDCP_LOG_VERBOSITY "pdcp_log_verbosity"
#define ENB_CONFIG_STRING_RRC_LOG_LEVEL "rrc_log_level"
#define ENB_CONFIG_STRING_RRC_LOG_VERBOSITY "rrc_log_verbosity"
#define ENB_CONFIG_STRING_GTPU_LOG_LEVEL "gtpu_log_level"
#define ENB_CONFIG_STRING_GTPU_LOG_VERBOSITY "gtpu_log_verbosity"
#define ENB_CONFIG_STRING_UDP_LOG_LEVEL "udp_log_level"
#define ENB_CONFIG_STRING_UDP_LOG_VERBOSITY "udp_log_verbosity"
#define ENB_CONFIG_STRING_OSA_LOG_LEVEL "osa_log_level"
#define ENB_CONFIG_STRING_OSA_LOG_VERBOSITY "osa_log_verbosity"
......
......@@ -33,7 +33,7 @@
#define COMPONENT_LOG
#define COMPONENT_LOG_IF
#include <ctype.h>
#include "log.h"
#include "vcd_signal_dumper.h"
#include "assertions.h"
......@@ -53,7 +53,7 @@
# define FIFO_PRINTF_NO 62
# define FIFO_PRINTF_SIZE 65536
#endif
#include "common/config/config_userapi.h"
// main log variables
log_t *g_log;
......@@ -103,6 +103,61 @@ static char *log_level_highlight_end[] = {LOG_RESET, LOG_RESET, LOG_RESET, LOG
static log_instance_type_t log_instance_type;
#endif
/* get log parameters from configuration file */
void log_getconfig(log_t *g_log) {
char *gloglevel = NULL;
char *glogverbo = NULL;
int level,verbosity;
paramdef_t logparams_defaults[] = LOG_GLOBALPARAMS_DESC;
paramdef_t logparams_level[MAX_LOG_COMPONENTS];
paramdef_t logparams_verbosity[MAX_LOG_COMPONENTS];
paramdef_t logparams_logfile[MAX_LOG_COMPONENTS];
config_get( logparams_defaults,sizeof(logparams_defaults)/sizeof(paramdef_t),CONFIG_STRING_LOG_PREFIX);
memset(logparams_level, 0, sizeof(paramdef_t)*MAX_LOG_COMPONENTS);
memset(logparams_verbosity,0, sizeof(paramdef_t)*MAX_LOG_COMPONENTS);
memset(logparams_logfile, 0, sizeof(paramdef_t)*MAX_LOG_COMPONENTS);
for (int i=MIN_LOG_COMPONENTS; i < MAX_LOG_COMPONENTS; i++) {
if(g_log->log_component[i].name == NULL) {
g_log->log_component[i].name = malloc(16);
sprintf((char *)g_log->log_component[i].name,"comp%i?",i);
logparams_logfile[i].paramflags = PARAMFLAG_DONOTREAD;
logparams_level[i].paramflags = PARAMFLAG_DONOTREAD;
logparams_verbosity[i].paramflags = PARAMFLAG_DONOTREAD;
}
sprintf(logparams_level[i].optname, LOG_CONFIG_LEVEL_FORMAT, g_log->log_component[i].name);
sprintf(logparams_verbosity[i].optname,LOG_CONFIG_VERBOSITY_FORMAT, g_log->log_component[i].name);
sprintf(logparams_logfile[i].optname, LOG_CONFIG_LOGFILE_FORMAT, g_log->log_component[i].name);
/* workaround: all log options in existing configuration files use lower case component names
where component names include uppercase char in log.h.... */
for (int j=0 ; j<strlen(logparams_level[i].optname); j++)
logparams_level[i].optname[j] = tolower(logparams_level[i].optname[j]);
for (int j=0 ; j<strlen(logparams_level[i].optname); j++)
logparams_verbosity[i].optname[j] = tolower(logparams_verbosity[i].optname[j]);
for (int j=0 ; j<strlen(logparams_level[i].optname); j++)
logparams_logfile[i].optname[j] = tolower(logparams_logfile[i].optname[j]);
/* */
logparams_level[i].defstrval = gloglevel;
logparams_verbosity[i].defstrval = glogverbo;
logparams_level[i].type = TYPE_STRING;
logparams_verbosity[i].type = TYPE_STRING;
logparams_logfile[i].type = TYPE_UINT;
logparams_logfile[i].paramflags = logparams_logfile[i].paramflags|PARAMFLAG_BOOL;
}
config_get( logparams_level, MAX_LOG_COMPONENTS,CONFIG_STRING_LOG_PREFIX);
config_get( logparams_verbosity,MAX_LOG_COMPONENTS,CONFIG_STRING_LOG_PREFIX);
config_get( logparams_logfile, MAX_LOG_COMPONENTS,CONFIG_STRING_LOG_PREFIX);
for (int i=MIN_LOG_COMPONENTS; i < MAX_LOG_COMPONENTS; i++) {
verbosity = map_str_to_int(log_verbosity_names,*(logparams_verbosity[i].strptr));
level = map_str_to_int(log_level_names, *(logparams_level[i].strptr));
set_comp_log(i, level,verbosity,1);
set_component_filelog(*(logparams_logfile[i].uptr));
}
}
int logInit (void)
{
#ifdef USER_MODE
......@@ -441,7 +496,7 @@ int logInit (void)
openlog(g_log->log_component[EMU].name, LOG_PID, g_log->config.facility);
#endif // ! defined(CN_BUILD)
}
log_getconfig(g_log);
if (g_log->filelog) {
gfd = open(g_log->filelog_name, O_WRONLY | O_CREAT, 0666);
}
......@@ -1319,8 +1374,8 @@ int set_comp_log(int component, int level, int verbosity, int interval)
void set_glog(int level, int verbosity)
{
g_log->level = level;
g_log->flag = verbosity;
if( g_log->level >= 0) g_log->level = level;
if( g_log->flag >= 0) g_log->flag = verbosity;
}
void set_glog_syslog(int enable)
{
......
......@@ -268,8 +268,9 @@ int set_comp_log(int component, int level, int verbosity, int interval);
int set_log(int component, int level, int interval);
void set_glog(int level, int verbosity);
void set_log_syslog(int enable);
void set_log_onlinelog(int enable);
void set_log_filelog(int enable);
void set_glog_onlinelog(int enable);
void set_glog_filelog(int enable);
void set_component_filelog(int comp);
int map_str_to_int(mapping *map, const char *str);
char *map_int_to_str(mapping *map, int val);
......@@ -297,7 +298,28 @@ void *log_thread_function(void * list);
#endif
/* @}*/
/*----------------macro definitions for reading log configuration from the config module */
#define CONFIG_STRING_LOG_PREFIX "log_config"
#define LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL "global_log_level"
#define LOG_CONFIG_STRING_GLOBAL_LOG_VERBOSITY "global_log_verbosity"
#define LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE "global_log_online"
#define LOG_CONFIG_STRING_GLOBAL_LOG_INFILE "global_log_infile"
#define LOG_CONFIG_LEVEL_FORMAT "%s_log_level"
#define LOG_CONFIG_VERBOSITY_FORMAT "%s_log_verbosity"
#define LOG_CONFIG_LOGFILE_FORMAT "%s_log_infile"
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* LOG globalconfiguration parameters */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define LOG_GLOBALPARAMS_DESC { \
{LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, NULL, 0, strptr:(char **)&gloglevel, defstrval:log_level_names[2].name, TYPE_STRING, sizeof(gloglevel)}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_VERBOSITY,NULL, 0, strptr:(char **)&glogverbo, defstrval:log_verbosity_names[2].name, TYPE_STRING, sizeof(glogverbo)}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, NULL, 0, iptr:&(g_log->onlinelog), defintval:1, TYPE_INT, 0, }, \
{LOG_CONFIG_STRING_GLOBAL_LOG_INFILE, NULL, 0, iptr:&(g_log->filelog), defintval:0, TYPE_INT, 0, }, \
}
/*----------------------------------------------------------------------------------*/
/** @defgroup _debugging debugging macros
* @ingroup _macro
* @brief Macro used to call logIt function with different message levels
......
......@@ -99,7 +99,7 @@ void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP);
void *udp_eNB_task(void *args_p);
int udp_enb_init();
int udp_enb_init(void);
/* @brief Retrieve the descriptor associated with the task_id
*/
static
......
......@@ -93,6 +93,6 @@ void *udp_eNB_task(void *args_p);
* \param enb_config_p configuration of eNB
* @returns always 0
*/
int udp_enb_init();
int udp_enb_init(void);
#endif /* UDP_ENB_TASK_H_ */
......@@ -184,7 +184,7 @@ char ref[128] = "internal";
char channels[128] = "0";
int rx_input_level_dBm;
static int online_log_messages=0;
#ifdef XFORMS
extern int otg_enabled;
static char do_forms=0;
......@@ -207,33 +207,7 @@ extern void print_opp_meas(void);
int transmission_mode=1;
int16_t glog_level = LOG_INFO;
int16_t glog_verbosity = LOG_MED;
int16_t hw_log_level = LOG_INFO;
int16_t hw_log_verbosity = LOG_MED;
int16_t phy_log_level = LOG_DEBUG;
int16_t phy_log_verbosity = LOG_MED;
int16_t mac_log_level = LOG_DEBUG;
int16_t mac_log_verbosity = LOG_MED;
int16_t rlc_log_level = LOG_INFO;
int16_t rlc_log_verbosity = LOG_MED;
int16_t pdcp_log_level = LOG_INFO;
int16_t pdcp_log_verbosity = LOG_MED;
int16_t rrc_log_level = LOG_INFO;
int16_t rrc_log_verbosity = LOG_MED;
int16_t opt_log_level = LOG_INFO;
int16_t opt_log_verbosity = LOG_MED;
# if defined(ENABLE_USE_MME)
int16_t gtpu_log_level = LOG_DEBUG;
int16_t gtpu_log_verbosity = LOG_MED;
int16_t udp_log_level = LOG_DEBUG;
int16_t udp_log_verbosity = LOG_MED;
#endif
#if defined (ENABLE_SECURITY)
int16_t osa_log_level = LOG_INFO;
int16_t osa_log_verbosity = LOG_MED;
#endif
/* struct for ethernet specific parameters given in eNB conf file */
eth_params_t *eth_params;
......@@ -583,7 +557,11 @@ static void get_options(void) {
int tddflag;
char *loopfile=NULL;
int dumpframe;
uint32_t online_log_messages;
uint32_t glog_level, glog_verbosity;
paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ;
paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ;
config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
......@@ -597,6 +575,18 @@ static void get_options(void) {
opt_type = OPT_WIRESHARK;
printf("Enabling OPT for wireshark for local interface");
}
config_process_cmdline( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL);
if(config_isparamset(cmdline_logparams,CMDLINE_ONLINELOG_IDX)) {
set_glog_onlinelog(online_log_messages);
}
if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) {
set_glog(glog_level, -1);
}
if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) {
set_glog(-1, glog_verbosity);
}
if (UE_flag > 0) {
paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC;
paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC;
......@@ -930,8 +920,7 @@ int main( int argc, char **argv )
T_init(T_port, T_wait, T_dont_fork);
#endif
// initialize the log (see log.h for details)
set_glog(glog_level, glog_verbosity);
//randominit (0);
set_taus_seed (0);
......@@ -956,37 +945,6 @@ int main( int argc, char **argv )
} else {
printf("configuring for RAU/RRU\n");
set_comp_log(HW, hw_log_level, hw_log_verbosity, 1);
set_comp_log(PHY, phy_log_level, phy_log_verbosity, 1);
if (opt_enabled == 1 )
set_comp_log(OPT, opt_log_level, opt_log_verbosity, 1);
set_comp_log(MAC, mac_log_level, mac_log_verbosity, 1);
set_comp_log(RLC, rlc_log_level, rlc_log_verbosity, 1);
set_comp_log(PDCP, pdcp_log_level, pdcp_log_verbosity, 1);
set_comp_log(RRC, rrc_log_level, rrc_log_verbosity, 1);
#if defined(ENABLE_ITTI)
set_comp_log(EMU, LOG_INFO, LOG_MED, 1);
# if defined(ENABLE_USE_MME)
set_comp_log(UDP_, udp_log_level, udp_log_verbosity, 1);
set_comp_log(GTPU, gtpu_log_level, gtpu_log_verbosity, 1);
set_comp_log(S1AP, LOG_DEBUG, LOG_HIGH, 1);
set_comp_log(SCTP, LOG_INFO, LOG_HIGH, 1);
# endif
#if defined(ENABLE_SECURITY)
set_comp_log(OSA, osa_log_level, osa_log_verbosity, 1);
#endif
#endif
#ifdef LOCALIZATION
set_comp_log(LOCALIZE, LOG_DEBUG, LOG_LOW, 1);
set_component_filelog(LOCALIZE);
#endif
set_comp_log(ENB_APP, LOG_INFO, LOG_HIGH, 1);
set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1);
if (online_log_messages == 1) {
set_component_filelog(RRC);
set_component_filelog(PDCP);
}
}
if (ouput_vcd) {
......@@ -1166,7 +1124,7 @@ int main( int argc, char **argv )
LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity);
#endif
openair0_cfg[0].log_level = glog_level;
#if defined(ENABLE_ITTI)
......
......@@ -68,8 +68,6 @@
#define CONFIG_HLP_CHOFF "Channel id offset"
#define CONFIG_HLP_SOFTS "Enable soft scope and L1 and L2 stats (Xforms)\n"
#define CONFIG_HLP_EXMCAL "Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"
#define CONFIG_HLP_LOGL "Set the global log level, valide options: (9:trace, 8/7:debug, 6:info, 4:warn, 3:error)\n"
#define CONFIG_HLP_LOGV "Set the global log verbosity \n"
#define CONFIG_HLP_ITTIL "Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n"
#define CONFIG_HLP_DLMCS "Set the maximum downlink MCS\n"
#define CONFIG_HLP_STMON "Enable processing timing measurement of lte softmodem on per subframe basis \n"
......@@ -81,7 +79,6 @@
#define CONFIG_HLP_L2MONW "Enable L2 wireshark messages on localhost \n"
#define CONFIG_HLP_L2MONP "Enable L2 pcap messages on localhost \n"
#define CONFIG_HLP_VCD "Enable VCD (generated file will is named openair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n"
#define CONFIG_HLP_FLOG "Enable PDCP RCP online log file\n"
#define CONFIG_HLP_TQFS "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n"
#define CONFIG_HLP_TPORT "tracer port\n"
#define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n"
......@@ -168,13 +165,28 @@ extern int16_t dlsch_demod_shift;
{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \
{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \
{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \
{"R" , CONFIG_HLP_FLOG, PARAMFLAG_BOOL, iptr:&online_log_messages, defintval:0, TYPE_INT, 0}, \
{"g" , CONFIG_HLP_LOGL, 0, i16ptr:&glog_level, defintval:1, TYPE_INT16, 0}, \
{"G" , CONFIG_HLP_LOGV, 0, i16ptr:&glog_verbosity, defintval:0, TYPE_INT16, 0}, \
{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \
{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0} \
}
#define CONFIG_HLP_FLOG "Enable online log \n"
#define CONFIG_HLP_LOGL "Set the global log level, valide options: (9:trace, 8/7:debug, 6:info, 4:warn, 3:error)\n"
#define CONFIG_HLP_LOGV "Set the global log verbosity \n"
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters for LOG utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_LOGPARAMS_DESC { \
{"R" , CONFIG_HLP_FLOG, 0, uptr:&online_log_messages, defintval:1, TYPE_INT, 0}, \
{"g" , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \
{"G" , CONFIG_HLP_LOGV, 0, uptr:&glog_verbosity, defintval:0, TYPE_UINT16, 0}, \
}
#define CMDLINE_ONLINELOG_IDX 0
#define CMDLINE_GLOGLEVEL_IDX 1
#define CMDLINE_GLOGVERBO_IDX 2
extern int T_port;
extern int T_wait;
extern int T_dont_fork;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment