Compare commits

...

8 Commits

10 changed files with 1060 additions and 310 deletions

View File

@@ -258,7 +258,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ggdb2 -Wl,-rpath -Wl,${C
# these changes are related to hardcoded path to include .h files
set(debugOpt "-ggdb2 -DMALLOC_CHECK_=3 -fno-delete-null-pointer-checks")
set(CMAKE_C_FLAGS_DEBUG "${debugOpt} -O0")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${debugOpt} -O2")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${debugOpt} -O2 ")
set(CMAKE_C_FLAGS_RELEASE "-O3")
# Enable assert() for RelWithDebInfo builds
@@ -322,6 +322,7 @@ add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs
add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace")
add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace")
add_boolean_option(DEBUG_CONSOLE False "disables stdout/stderr buffering")
set(JSONLOGS $ENV{JSONLOGS})
set (OCP_ITTI ${OPENAIR_DIR}/common/utils/ocp_itti)
add_library(ITTI
@@ -1188,6 +1189,10 @@ add_library(UTIL
${OPENAIR_DIR}/common/utils/backtrace.c
${OPENAIR_DIR}/common/utils/time_meas.c
)
if (${JSONLOGS})
target_compile_definitions(UTIL PUBLIC -DOAI_LOG_JSON)
endif()
set(SECU_OSA_SRC
${OPENAIR2_DIR}/UTIL/OSA/osa_key_deriver.c
@@ -2541,7 +2546,15 @@ add_executable(test5Gnas
)
target_link_libraries (test5Gnas LIB_5GNAS_GNB CONFIG_LIB minimal_lib )
add_executable(tstlog
${OPENAIR_DIR}/common/utils/LOG/tst-log.cpp
${OPENAIR_DIR}/common/utils/minimal_stub.c
${T_SOURCE}
)
target_link_libraries (tstlog pthread rt dl ${T_LIB} CONFIG_LIB UTIL)
if (${JSONLOGS})
target_link_libraries (tstlog uuid)
endif()
# lte-softmodem is both eNB and UE implementation
###################################################
@@ -2584,6 +2597,9 @@ target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES})
target_link_libraries (lte-softmodem pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-softmodem ${T_LIB})
if (${JSONLOGS})
target_link_libraries (lte-softmodem uuid})
endif()
add_executable(ocp-enb
@@ -2620,6 +2636,9 @@ target_link_libraries (ocp-enb
${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB}
-Wl,--end-group z dl)
target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB})
if (${JSONLOGS})
target_link_libraries (ocp-enb uuid)
endif()
add_executable(oairu
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
@@ -2640,6 +2659,9 @@ target_link_libraries (oairu
-Wl,--end-group z dl)
target_link_libraries (oairu pthread m CONFIG_LIB rt ${CMAKE_DL_LIBS} ${T_LIB})
if (${JSONLOGS})
target_link_libraries (oairu uuid)
endif()
# lte-uesoftmodem is UE implementation
@@ -2682,6 +2704,9 @@ target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES})
target_link_libraries (lte-uesoftmodem pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${T_LIB})
if (${JSONLOGS})
target_link_libraries (lte-uesoftmodem uuid)
endif()
# nr-softmodem
###################################################
@@ -2723,6 +2748,9 @@ target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES})
target_link_libraries (nr-softmodem pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (nr-softmodem ${T_LIB})
if (${JSONLOGS})
target_link_libraries (nr-softmodem uuid)
endif()
add_dependencies( nr-softmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc )
@@ -2764,6 +2792,9 @@ target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES})
target_link_libraries (nr-uesoftmodem pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (nr-uesoftmodem ${T_LIB})
if (${JSONLOGS})
target_link_libraries (nr-uesoftmodem uuid)
endif()
add_dependencies( nr-uesoftmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc )
if (CUDA_FOUND)
@@ -2788,6 +2819,9 @@ target_link_libraries (dlsim_tm4
-Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY ITTI -Wl,--end-group
pthread m rt CONFIG_LIB ${ATLAS_LIBRARIES} ${T_LIB}
)
if (${JSONLOGS})
target_link_libraries (dlsim_tm4 uuid)
endif()
add_executable(rftest
${OPENAIR_DIR}/openair1/PHY/TOOLS/calibration_test.c
@@ -2796,7 +2830,10 @@ add_executable(rftest
${OPENAIR_DIR}/executables/softmodem-common.c
${SHLIB_LOADER_SOURCES}
)
target_link_libraries(rftest minimal_lib CONFIG_LIB PHY_NR_COMMON UTIL pthread dl m forms ${T_LIB} )
target_link_libraries(rftest minimal_lib CONFIG_LIB PHY_NR_COMMON UTIL pthread dl m forms ${T_LIB})
if (${JSONLOGS})
target_link_libraries (rftest uuid)
endif()
add_executable(polartest
${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c
@@ -2808,6 +2845,9 @@ target_link_libraries(polartest
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE CONFIG_LIB -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} dl
)
if (${JSONLOGS})
target_link_libraries (polartest uuid)
endif()
add_executable(smallblocktest
${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c
@@ -2821,6 +2861,9 @@ target_link_libraries(smallblocktest
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} dl
)
if (${JSONLOGS})
target_link_libraries (smallblocktest uuid)
endif()
add_executable(ldpctest
@@ -2838,6 +2881,9 @@ target_link_libraries(ldpctest
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} dl
)
if (${JSONLOGS})
target_link_libraries (ldpctest uuid)
endif()
add_executable(nr_dlschsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c
@@ -2850,6 +2896,9 @@ target_link_libraries(nr_dlschsim
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI dl
)
if (${JSONLOGS})
target_link_libraries (nr_dlschsim uuid)
endif()
add_executable(nr_pbchsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c
@@ -2861,6 +2910,9 @@ target_link_libraries(nr_pbchsim
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI dl
)
if (${JSONLOGS})
target_link_libraries (nr_pbchsim uuid)
endif()
#PUCCH ---> Prashanth
add_executable(nr_pucchsim
@@ -2874,6 +2926,9 @@ target_link_libraries(nr_pucchsim
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI dl
)
if (${JSONLOGS})
target_link_libraries (nr_pucchsim uuid)
endif()
add_executable(nr_dlsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c
@@ -2891,6 +2946,9 @@ target_link_libraries(nr_dlsim
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN NGAP_GNB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -lz -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI ${OPENSSL_LIBRARIES} dl
)
if (${JSONLOGS})
target_link_libraries (nr_dlsim uuid)
endif()
target_compile_definitions(nr_dlsim PUBLIC -DPHYSICAL_SIMULATOR)
add_executable(nr_prachsim
@@ -2907,6 +2965,9 @@ add_executable(nr_prachsim
target_link_libraries(nr_prachsim
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN NGAP_GNB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -lz -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI ${OPENSSL_LIBRARIES} dl)
if (${JSONLOGS})
target_link_libraries (nr_prachsim uuid)
endif()
add_executable(nr_ulschsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c
@@ -2920,6 +2981,9 @@ target_link_libraries(nr_ulschsim
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI dl
)
if (${JSONLOGS})
target_link_libraries (nr_ulschsim uuid)
endif()
add_executable(nr_ulsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c
@@ -2937,6 +3001,9 @@ target_link_libraries(nr_ulsim
-Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN NGAP_GNB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -lz -Wl,--end-group
m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI ${OPENSSL_LIBRARIES} dl
)
if (${JSONLOGS})
target_link_libraries (nr_ulsim uuid)
endif()
target_compile_definitions(nr_ulsim PUBLIC -DPHYSICAL_SIMULATOR)
foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
@@ -2955,6 +3022,9 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr
-Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_NR_COMMON PHY PHY_UE PHY_RU ITTI -Wl,--end-group
pthread m rt CONFIG_LIB ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} dl
)
if (${JSONLOGS})
target_link_libraries (${myExe} uuid)
endif()
endforeach(myExe)
@@ -2976,6 +3046,9 @@ foreach(myExe s1ap
target_link_libraries (test_${myExe}
-Wl,--start-group SECU_CN UTIL -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} CONFIG_LIB
)
if (${JSONLOGS})
target_link_libraries (test_${myExe} uuid)
endif()
endforeach(myExe)
# to be added
@@ -3114,6 +3187,9 @@ target_link_libraries (nr-ittisim ${LIBXML2_LIBRARIES})
target_link_libraries (nr-ittisim pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (nr-ittisim ${LIB_LMS_LIBRARIES})
target_link_libraries (nr-ittisim ${T_LIB})
if (${JSONLOGS})
target_link_libraries (nr-ittisim uuid)
endif()
add_dependencies( nr-ittisim ldpc_orig ldpc_optim ldpc_optim8seg ldpc )

View File

@@ -59,6 +59,7 @@ BUILD_ECLIPSE=0
NR="False"
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope"
RU=0
JSONLOGS=0
CMAKE_C_FLAGS=()
CMAKE_CXX_FLAGS=()
@@ -76,7 +77,7 @@ Options:
--clean-kernel
Erase previously installed features in kernel: iptables, drivers, ...
--cmake-opt
Pass the supplied option verbatim to cmake.
Pass the supplied option verbatim to cmake. If -DOAI_LOG_JSON is specified, it activates JSON formatting for logs.
-d | --build-dir
Sets build directory (will be <oai-root>/cmake_targets/<build-dir>/build)
-I | --install-external-packages
@@ -172,6 +173,8 @@ Options:
Enable the address sanitizer on all targets
--ittiSIM
Makes the itti simulator
--target NAME
add NAME to the list of targets to be built. To specify more targets, you can call multiple times this option. I.e. '--target tstlog --target gNB'
-h | --help
Print this help
@@ -184,7 +187,7 @@ Usage (regular):
function main() {
execlist=""
until [ -z "$1" ]
do
case "$1" in
@@ -202,8 +205,15 @@ function main() {
clean_kernel
echo_info "Erased iptables config and removed modules from kernel"
shift;;
--cmake-opt)
CMAKE_CMD="$CMAKE_CMD $2"
--cmake-opt)
if [ "$2" == "-DOAI_LOG_JSON" ]; then
JSONLOGS=1
export JSONLOGS=1
echo_info "Activated JSON formatting for logs"
else
CMAKE_CMD="$CMAKE_CMD $2"
fi
shift 2;;
-d | --build-dir)
BUILD_DIR=$2
@@ -452,11 +462,15 @@ function main() {
CMAKE_CMD="$CMAKE_CMD -DITTI_SIM=True"
echo_info "Will compile itti simulator"
shift;;
--target)
execlist="$execlist $2"
echo_info "Added '$2' to the list of targets"
shift 2;;
-h | --help)
print_help
exit 1;;
*)
print_help
*)
print_help
echo_fatal "Unknown option $1"
break;;
esac
@@ -585,8 +599,7 @@ function main() {
echo_info "Installing optional packages"
check_install_additional_tools
fi
execlist=""
if [ "$eNB" = "1" ] ; then
execlist="$execlist lte-softmodem"
fi

View File

@@ -626,6 +626,7 @@ check_install_additional_tools (){
nscd \
bc \
ntp"
if [ $JSONLOGS -eq 1 ]; then PACKAGE_LIST="$PACKAGE_LIST uuid-dev"; fi
elif [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then
PACKAGE_LIST="\
check \
@@ -654,6 +655,7 @@ check_install_additional_tools (){
python-netifaces \
scipy \
python-matplotlib"
if [ $JSONLOGS -eq 1 ]; then PACKAGE_LIST="$PACKAGE_LIST libuuid-devel"; fi
elif [[ "$OS_DISTRO" == "fedora" ]]; then
PACKAGE_LIST=" \
check \
@@ -682,6 +684,7 @@ check_install_additional_tools (){
python-netifaces \
python-scipy \
python-matplotlib"
if [ $JSONLOGS -eq 1 ]; then PACKAGE_LIST="$PACKAGE_LIST libuuid-devel"; fi
fi
$SUDO $INSTALLER install -y $PACKAGE_LIST $optional_packages

View File

@@ -58,6 +58,10 @@
#define CONFIG_HELP (1<<20) // print help message
#define CONFIG_ABORT (1<<21) // config failed,abort execution
#define CONFIG_NOOOPT (1<<22) // no -O option found when parsing command line
#ifdef __cplusplus
extern "C" {
#endif
typedef int(*configmodule_initfunc_t)(char *cfgP[],int numP);
typedef int(*configmodule_getfunc_t)(paramdef_t *,int numparams, char *prefix);
typedef int(*configmodule_getlistfunc_t)(paramlist_def_t *, paramdef_t *,int numparams, char *prefix);
@@ -114,6 +118,8 @@ extern configmodule_interface_t *cfgptr;
extern configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags);
extern void end_configmodule(void);
#define CONFIG_PRINTF_ERROR(f, x... ) if (isLogInitDone ()) { LOG_E(ENB_APP,f,x);} else {printf(f,x);}; if ( !CONFIG_ISFLAGSET(CONFIG_NOABORTONCHKF) ) exit_fun("exit because configuration failed\n");
#ifdef __cplusplus
}
#endif
#endif /* INCLUDE_CONFIG_LOADCONFIGMODULE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -56,7 +56,7 @@
/*----------------------------------------------------------------------------*/
#include <assert.h>
#ifdef NDEBUG
#warning assert is disabled
#warning assert is disabled
#endif
#define NUM_ELEMENTS(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
#define CHECK_INDEX(ARRAY, INDEX) assert((INDEX) < NUM_ELEMENTS(ARRAY))
@@ -129,6 +129,7 @@ extern "C" {
#define FLAG_FILE_LINE 0x0040
#define FLAG_TIME 0x0100
#define FLAG_THREAD_ID 0x0200
#define FLAG_CORR_ID 0x0400 /*!< \brief: activate correlation ID in json formatted logs*/
#define FLAG_INITIALIZED 0x8000
#define SET_LOG_OPTION(O) g_log->flag = (g_log->flag | O)
@@ -267,7 +268,7 @@ typedef struct {
int level;
int savedlevel;
int flag;
int filelog;
int filelog; // flag set to 1 when using a sink of type file, stdout if set to 0
char *filelog_name;
FILE *stream;
log_vprint_func_t vprint;
@@ -284,6 +285,11 @@ typedef struct {
char *filelog_name;
uint64_t debug_mask;
uint64_t dump_mask;
unsigned char global_logfile;
FILE *global_logfilep;
off_t rotation_size;// in bytes, 0 means disabled
unsigned int rotation_time;// in seconds. 0 means disabled
time_t rotation_start_time; // timestamp in seconds since Unix-Epoch
} log_t;
@@ -301,36 +307,64 @@ extern "C" {
#endif
/*--- INCLUDES ---------------------------------------------------------------*/
# include "log_if.h"
/*----------------------------------------------------------------------------*/
/**
* Initialize the logging framework allocating internal memory for API global structure 'g_log', setting defaults and
* reading parameters from the configuration file (if exists) and command line. There is no environment variable handling.
* In order of priority, logs are disabled thanks to loglevel OAILOG_DISABLE and sink to file per component. Internally it
* leverages log API function log_getconfig().
*
* @return: 0 (successful), !=0 (error), exit(1) if memory failure
*/
int logInit (void);
void logTerm (void);
int isLogInitDone (void);
int register_log_component(char *name, char *fext,int compidx);
void logRecord_mt(const char *file, const char *func, int line,int comp, int level, const char *format, ...) __attribute__ ((format (printf, 6, 7)));
void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args );
void log_dump(int component, void *buffer, int buffsize,int datatype, const char *format, ... );
int set_log(int component, int level);
void set_glog(int level);
/**
* set log level for log component and check also if the stream associated is open. If it is not, give priority to file sink
* type of log stream
* @return: 0(success), !=-0(failure)
*/
int set_log(int component, int level);
/*
* @return: 0(success), !=-0(failure)
*/
int set_glog(int level);
void set_glog_onlinelog(int enable);
void set_glog_filelog(int enable);
void set_component_filelog(int comp);
/**
* Set sink logging type globally. Sinks are of 2 types: stdout or file. You choose among them using ENABLE parameter
*
* @param enable if param is != 0, all the logs will be redirected to a global file, else logs will be redirected to stdout
* @return: 0(success), !=-0(failure)
*/
int set_glog_filelog(int enable);
/*
* @return: 0(success), !=-0(failure)
*/
int set_component_filelog(int comp);
void close_component_filelog(int comp);
void set_component_consolelog(int comp);
void logTerm (void);
void logClean (void);
int map_str_to_int(mapping *map, const char *str);
char *map_int_to_str(mapping *map, int val);
void logClean (void);
int is_newline( char *str, int size);
int register_log_component(char *name, char *fext, int compidx);
#define LOG_MEM_SIZE 100*1024*1024
#define LOG_MEM_FILE "./logmem.log"
void flush_mem_to_file(void);
int logInit_log_mem(void);
void close_log_mem(void);
typedef struct {
char* buf_p;
char *buf_p;
int buf_index;
int enable_flag;
} log_mem_cnt_t;
@@ -364,7 +398,7 @@ typedef struct {
#define MATLAB_CSHORT_BRACKET1 13
#define MATLAB_CSHORT_BRACKET2 14
#define MATLAB_CSHORT_BRACKET3 15
int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, unsigned int format, int multiVec);
/*----------------macro definitions for reading log configuration from the config module */
@@ -372,8 +406,11 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
#define LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL "global_log_level"
#define LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE "global_log_online"
// LOG_CONFIG_STRING_GLOBAL_LOG_INFILE: it is unused inside this log library.
#define LOG_CONFIG_STRING_GLOBAL_LOG_INFILE "global_log_infile"
#define LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS "global_log_options"
#define LOG_CONFIG_STRING_GLOBAL_LOG_ROT_SIZE "global_log_rotation_size"
#define LOG_CONFIG_STRING_GLOBAL_LOG_ROT_TIME "global_log_rotation_time"
#define LOG_CONFIG_LEVEL_FORMAT "%s_log_level"
#define LOG_CONFIG_LOGFILE_FORMAT "%s_log_infile"
@@ -393,14 +430,15 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
/* optname help paramflags XXXptr defXXXval type numelt */
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define LOG_GLOBALPARAMS_DESC { \
{LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all componemts\n", 0, strptr:(char **)&gloglevel, defstrval:log_level_names[3].name, TYPE_STRING, 0}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, "Default console output option, for all components\n", 0, iptr:&(consolelog), defintval:1, TYPE_INT, 0}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0} \
{LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all components\n", 0, strptr:(char **)&gloglevel, defstrval:log_level_names[6].name, TYPE_STRING, 0}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, "Default console output option, for all components\n", 0, iptr:&(consolelog), defintval:0, TYPE_INT, 0}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_ROT_SIZE, "Log Rotation: maximum log size in MB for file rotation (0 to disable/default)\n", 0, uptr:&(rotationsize), defuintval:0, TYPE_UINT, 0},\
{LOG_CONFIG_STRING_GLOBAL_LOG_ROT_TIME, "Log Rotation: maximum elapsed time in seconds for file rotation (0 to disable/default)\n", 0, uptr:&(rotationtime), defuintval:0, TYPE_UINT, 0} \
}
#define LOG_OPTIONS_IDX 2
/*----------------------------------------------------------------------------------*/
/** @defgroup _debugging debugging macros
* @ingroup _macro
@@ -447,7 +485,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
# define LOG_M(file, vector, data, len, dec, format) do { write_file_matlab(file, vector, data, len, dec, format, 0);} while(0)
# define LOG_VAR(A,B) A B
# define T_ACTIVE(a) (0)
# define T_ACTIVE(a) (0)
# endif /* T_TRACER */
/* avoid warnings for variables only used in LOG macro's but set outside debug section */

View File

@@ -0,0 +1,43 @@
/* vim settings :setf config
* Configuration file for log system integration tests
*
* This file adheres to the libconfig grammar format that you can find in https://hyperrealm.github.io/libconfig/libconfig_manual.html
* Parameters below are specific to log system and are defined in log.h
* Caveats:
* Support for new json unified format has to be explicitly enabled on compilation flag(-DOAI_LOG_JSON) of log library
*
* If you do not put this section log_config, the program will not log anything.
*/
log_config :
{
# Set the log level for all the components. It will also force log redirection to a file sink if global_log_online
# is not set or set to 0
global_log_level = "debug";
# set log level per component. If the corresponding '*_log_infile' is not present, it will check the 'global_log_level'
# to decide where to log
hw_log_level = "info";
# Activation of log redirection to file sink per component. By default it is deactivated.
# Syntax: <component>_log_infile = boolean_val(0|1)
# Example: hw_log_infile = 1
# Activation of stdout logs globally for all the components. By default it is deactivated.
# If some components has log to file activated it will honour that component setting
# Syntax: global_log_online = boolean_val(0|1)
# Log formatting options for printing, globally or per component. By default, the formatting includes the
# component name and colors.
# Syntax: global_log_options: list of attributes
# where attributes can be: nocolor, level, thread, line_num, function, time, thread_id, correlation_id.
global_log_options = ("level","nocolor","time");
# Set the maximum log size in MB for triggering logfile rotation. By default it is disabled.
# Syntax: global_log_rotation_size: uint_val, 0 means disabled
global_log_rotation_size = 1;
# Set the maximum elapsed time in seconds for triggering file rotation. By default it is disabled.
# Syntax: global_log_rotation_time: uint_val, 0 means disabled
global_log_rotation_time = 1;
};

View File

@@ -0,0 +1,243 @@
/*
* unit tests to evaluate integration of Log library.
*
* Example of running commandline: ./tstlog [--run_test=testname] [BOOST Test options]
* I.e.: ./tstlog --run_test=test_log_rotation_1 --report_level=detailed
*/
#define BOOST_TEST_MODULE tstlog
#include <boost/test/included/unit_test.hpp>
#include <iostream>
#include <fstream>
#undef T_TRACER
#include "log.h"
#include "common/config/config_load_configmodule.h"
using namespace boost::unit_test;
volatile int oai_exit;//the definition of this variable is needed by log.c:flush_mem_to_file() and it is declared in log.c
const char *global_oai_logfile="/tmp/openair.log";
const char *hw_logfile="/tmp/HW.";
const char *phy_logfile="/tmp/PHY.log";
std::list<int> known_bugged_comp = {19, 24, 40};
std::string conf1="\
log_config :\n\
{\n\
global_log_level = \"debug\";\n\
hw_log_level = \"info\";\n\
global_log_options = (\"level\",\"nocolor\",\"time\");\n\
global_log_rotation_size = 1;\n\
global_log_rotation_time = 1;\n\
};\n";
std::string conf2="\
log_config :\n\
{\n\
global_log_options = (\"level\",\"nocolor\",\"time\");\n\
global_log_rotation_size = 1;\n\
global_log_rotation_time = 1;\n\
};\n";
std::string conf3="\
log_config :\n\
{\n\
global_log_options = (\"level\",\"nocolor\",\"time\", \"correlation_id\");\n\
global_log_rotation_size = 0;\n\
global_log_rotation_time = 0;\n\
};\n";
std::string conf4="\
log_config :\n\
{\n\
global_log_level =\"info\";\n\
global_log_infile = 1; # warn: this parameter is silently discarded from configuration parser \n\
global_log_online = 0;\n\
};\n";
#define TMPLOCALCONF "tstlog.conf.tmp"
const char *argv[4] = {"tstlog", "-O", TMPLOCALCONF, NULL};
int argc=3;
void log_comp_tostr(unsigned int i) {
std::cout << "Component [" << i << "- " << g_log->log_component[i].name << "]: stream "<< g_log->log_component[i].stream
<< ", level:" << g_log->log_component[i].level << ", filelog: " << g_log->log_component[i].filelog << std::endl;
}
bool search_in_file(std::string fname, std::string match) {
std::ifstream f(fname);
if (!f)
return false;
std::string t;
while (getline(f, t))
if (t.find(match, 0) != t.npos)
return true;
f.close();
return false;
}
void create_test_conf_file(std::string confcontent) {
std::remove(TMPLOCALCONF);
std::ofstream file(TMPLOCALCONF);
file << confcontent;
}
BOOST_AUTO_TEST_CASE(test_log_rotation_1) {
// This test will be using global log file (/tmp/openair.log), simulating time expiring for log rotation.
// It is a test for single thread logging
create_test_conf_file(conf1);
std::remove(global_oai_logfile);
std::remove(hw_logfile);
BOOST_TEST_REQUIRE ((load_configmodule(argc, const_cast<char **>(argv), 0) != NULL), "Configuration module init failed");
BOOST_TEST ((logInit() == 0), true);
/*
* Sanity check for some field of global structure of log API.
* Expected: all components log to DEBUG level on global file, except for component 28 (HW) that will have its file and log at info level
*/
BOOST_TEST (((g_log->global_logfile == 0) && (g_log->global_logfilep == NULL)), true);
for (int i=MIN_LOG_COMPONENTS; i < MAX_LOG_PREDEF_COMPONENTS; i++) {
auto itr = std::find(known_bugged_comp.begin(), known_bugged_comp.end(), i);
if (itr != known_bugged_comp.end())
continue;
bool sts = ((g_log->log_component[i].filelog == 1) &&
(g_log->log_component[i].name != NULL) &&
(g_log->log_component[i].stream != g_log->global_logfilep));
sts = (i == 28) ? sts && (g_log->log_component[i].level == OAILOG_INFO) : sts && (g_log->log_component[i].level == OAILOG_DEBUG);
if (sts == false) {
std::cout << "Failure at this component:";
log_comp_tostr(i);
}
BOOST_TEST (sts, true);
}
BOOST_TEST((set_glog(OAILOG_DEBUG) == 0), true);
BOOST_TEST((set_glog_filelog(true) == 0), true); // force dump to default logfile /tmp/openair.log.
BOOST_TEST (((g_log->global_logfile == 1) && (g_log->global_logfilep != NULL)), true);
LOG_I(HW, "First test for a string");
BOOST_TEST(set_glog(OAILOG_ERR) == 0, true);
LOG_I(HW, "You should not see this line");
BOOST_TEST((set_glog(OAILOG_DEBUG) == 0), true);
char string_truncation[1600];
memset(string_truncation, 's', 1599);
memset(&string_truncation[1599], '\0', 1);
LOG_I(HW, "%s", string_truncation);
sleep(5);// let's have log rotation
LOG_I(HW, "Spurious line terminator should not appear\n");
bool sts = search_in_file(hw_logfile, "\n");
if (sts == true) {
std::cout << "Offending line:";
std::ifstream f(hw_logfile);
if (f.is_open())
std::cout << f.rdbuf();
}
BOOST_TEST(sts == false);
logClean();
logTerm();
end_configmodule();
std::remove(TMPLOCALCONF);
}
BOOST_AUTO_TEST_CASE(test_log_rotation_2) {
// test using component log file (tmp/PHY.log), simulating time expiring for log rotation
// It is a test for single thread logging
create_test_conf_file(conf1);
std::remove(phy_logfile);
BOOST_TEST_REQUIRE ((load_configmodule(argc, const_cast<char **>(argv), 0) != NULL), "Configuration module init failed");
BOOST_TEST (logInit() == 0, true);
BOOST_TEST(set_glog(OAILOG_DEBUG) == 0, true);
BOOST_TEST(set_component_filelog(0) == 0, true);
LOG_I(PHY, "Second test for a string that should be moved to backup file");
sleep(5);
LOG_I(PHY, "this should go to a brand new file");
BOOST_TEST( search_in_file(phy_logfile, "this should go to a brand new file") == true);
BOOST_TEST( search_in_file(phy_logfile, "Second test for a string that should be moved to backup file") == false);
logClean();
logTerm();
end_configmodule();
std::remove(TMPLOCALCONF);
}
BOOST_AUTO_TEST_CASE(test_log_defaults) {
// testing log default values. You should not see anylog, not on console, not on file. It is a test for single thread logging
create_test_conf_file(conf2);
std::remove(phy_logfile);
BOOST_TEST_REQUIRE ((load_configmodule(argc, const_cast<char **>(argv), 0) != NULL), "Configuration module init failed");
BOOST_TEST (logInit() == 0, true);
LOG_I(PHY, "you should not see any log");
BOOST_TEST( search_in_file(phy_logfile, "you should not see any log") == false);
logClean();
logTerm();
end_configmodule();
std::remove(TMPLOCALCONF);
}
BOOST_AUTO_TEST_CASE(test_log_defaults_2) {
/* Test log default values. You should not see anylog, not on console, not on file. It is a test for single thread logging */
create_test_conf_file(conf3);
std::remove(phy_logfile);
BOOST_TEST_REQUIRE ((load_configmodule(argc, const_cast<char **>(argv), 0) != NULL), "Configuration module init failed");
BOOST_TEST (logInit() == 0, true);
BOOST_TEST(set_log(0, OAILOG_INFO) == 0, true);
LOG_I(PHY, "you should see this log to file");
BOOST_TEST( search_in_file(phy_logfile, "you should see this log to file") == true);
LOG_I(HW, "you should not see this log at all");
//XXX: TODO: intercept console output and general log file and validate this finding with BOOST_TEST() macro.
logClean();
logTerm();
end_configmodule();
std::remove(TMPLOCALCONF);
}
BOOST_AUTO_TEST_CASE(test_log_discarded_options) {
/* Test global log activation to file. You are expected to see only logs in their component file.
* To have logs to just one global file you need to call set_glog_filelog().
*/
create_test_conf_file(conf4);
std::remove(phy_logfile);
std::remove(global_oai_logfile);
BOOST_TEST_REQUIRE ((load_configmodule(argc, const_cast<char **>(argv), 0) != NULL), "Configuration module init failed");
BOOST_TEST(logInit() == 0, true);
/*
* Sanity check for some field of global structure of log API.
* Expected: all components log to DEBUG level and have their own file sink
*/
BOOST_TEST (((g_log->global_logfile == 0) && (g_log->global_logfilep == NULL)), true);
for (int i=MIN_LOG_COMPONENTS; i < MAX_LOG_PREDEF_COMPONENTS; i++) {
auto itr = std::find(known_bugged_comp.begin(), known_bugged_comp.end(), i);
if (itr != known_bugged_comp.end())
continue;
bool sts = ((g_log->log_component[i].filelog == 1) &&
(g_log->log_component[i].name != NULL) &&
(g_log->log_component[i].stream != g_log->global_logfilep) &&
(g_log->log_component[i].stream != NULL) &&
(g_log->log_component[i].stream != stdout) &&
(g_log->log_component[i].level == OAILOG_INFO));
if (sts == false) {
std::cout << "Failure at this component:";
log_comp_tostr(i);
}
BOOST_TEST (sts, true);
}
LOG_I(PHY, "test_log_discarded_options");
BOOST_TEST(search_in_file(phy_logfile, "test_log_discarded_options") == true);
BOOST_TEST(search_in_file(global_oai_logfile, "test_log_discarded_options") == false);
logClean();
logTerm();
end_configmodule();
std::remove(TMPLOCALCONF);
}

View File

@@ -314,22 +314,21 @@ int create_gNB_tasks(uint32_t gnb_nb) {
}
if (AMF_MODE_ENABLED) {
char* gnb_ipv4_address_for_NGU = NULL;
uint32_t gnb_port_for_NGU = 0;
char* gnb_ipv4_address_for_S1U = NULL;
uint32_t gnb_port_for_S1U = 0;
char *gnb_ipv4_address_for_NGU = NULL;
uint32_t gnb_port_for_NGU = 0;
char *gnb_ipv4_address_for_S1U = NULL;
uint32_t gnb_port_for_S1U = 0;
paramdef_t NETParams[] = GNBNETPARAMS_DESC;
char aprefix[MAX_OPTNAME_SIZE*2 + 8];
sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
for(int i = GNB_INTERFACE_NAME_FOR_NG_AMF_IDX; i <= GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX; i++) {
if( NETParams[i].strptr == NULL) {
LOG_E(NGAP, "No configuration in the file.\n");
NGAP_CONF_MODE = 0;
LOG_E(NGAP, "No configuration in the file.\n");
NGAP_CONF_MODE = 0;
} else {
LOG_D(NGAP, "Configuration in the file: %s.\n",*NETParams[i].strptr);
LOG_D(NGAP, "Configuration in the file: %s.\n",*NETParams[i].strptr);
}
}
@@ -342,7 +341,6 @@ int create_gNB_tasks(uint32_t gnb_nb) {
} else {
LOG_I(NGAP, "Ngap task not created\n");
}
}
}
@@ -586,9 +584,9 @@ static void wait_nfapi_init(char *thread_name) {
void init_pdcp(void) {
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT:
LINK_ENB_PDCP_TO_GTPV1U_BIT;
PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT:
LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (!get_softmodem_params()->nsa) {
if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) {
pdcp_layer_init();
@@ -617,11 +615,13 @@ int main( int argc, char **argv ) {
mode = normal_txrx;
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs);
logInit();
if (logInit())
exit_fun("[SOFTMODEM] Error, logging configuration init failed\n");
set_latency_target();
printf("Reading in command-line options\n");
get_options ();
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
@@ -654,12 +654,15 @@ int main( int argc, char **argv ) {
itti_init(TASK_MAX, tasks_info);
// initialize mscgen log after ITTI
init_opt();
if(PDCP_USE_NETLINK && !IS_SOFTMODEM_NOS1) {
netlink_init();
if (get_softmodem_params()->nsa) {
init_pdcp();
}
}
#ifndef PACKAGE_VERSION
# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
#endif
@@ -671,7 +674,6 @@ int main( int argc, char **argv ) {
// don't create if node doesn't connect to RRC/S1/GTP
int ret=create_gNB_tasks(1);
AssertFatal(ret==0,"cannot create ITTI tasks\n");
/* Start the agent. If it is turned off in the configuration, it won't start */
/*
RCconfig_nr_flexran();
@@ -733,6 +735,7 @@ int main( int argc, char **argv ) {
wait_gNBs();
printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU);
int sl_ahead=6;
if (RC.nb_RU >0) {
printf("Initializing RU threads\n");
init_NR_RU(get_softmodem_params()->rf_config_file);
@@ -740,10 +743,10 @@ int main( int argc, char **argv ) {
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
RC.ru[ru_id]->rf_map.card=0;
RC.ru[ru_id]->rf_map.chain=CC_id+chain_offset;
if (ru_id==0) sl_ahead = RC.ru[ru_id]->sl_ahead;
if (ru_id==0) sl_ahead = RC.ru[ru_id]->sl_ahead;
else AssertFatal(RC.ru[ru_id]->sl_ahead != RC.ru[0]->sl_ahead,"RU %d has different sl_ahead %d than RU 0 %d\n",ru_id,RC.ru[ru_id]->sl_ahead,RC.ru[0]->sl_ahead);
}
}
config_sync_var=0;
@@ -760,7 +763,8 @@ int main( int argc, char **argv ) {
// once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration)
printf("ALL RUs ready - init gNBs\n");
for (int idx=0;idx<RC.nb_nr_L1_inst;idx++) RC.gNB[idx]->if_inst->sl_ahead = sl_ahead;
for (int idx=0; idx<RC.nb_nr_L1_inst; idx++) RC.gNB[idx]->if_inst->sl_ahead = sl_ahead;
if(IS_SOFTMODEM_DOSCOPE) {
sleep(1);
scopeParms_t p;
@@ -788,9 +792,7 @@ int main( int argc, char **argv ) {
}
printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
// We have to set PARAMFLAG_NOFREE on right paramters before re-enabling end_configmodule()
//end_configmodule();
printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
// wait for end of program

View File

@@ -190,17 +190,21 @@ int create_tasks_nrue(uint32_t ue_nb) {
if (ue_nb > 0) {
LOG_I(NR_RRC,"create TASK_RRC_NRUE \n");
if (itti_create_task (TASK_RRC_NRUE, rrc_nrue_task, NULL) < 0) {
LOG_E(NR_RRC, "Create task for RRC UE failed\n");
return -1;
}
if (get_softmodem_params()->nsa) {
init_connections_with_lte_ue();
if (itti_create_task (TASK_RRC_NSA_NRUE, recv_msgs_from_lte_ue, NULL) < 0) {
LOG_E(NR_RRC, "Create task for RRC NSA nr-UE failed\n");
return -1;
}
}
if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) {
LOG_E(NR_RRC, "Create task for NAS UE failed\n");
return -1;
@@ -243,65 +247,68 @@ uint64_t set_nrUE_optmask(uint64_t bitmask) {
nrUE_params_t *get_nrUE_params(void) {
return &nrUE_params;
}
/* initialie thread pools used for NRUE processing paralleliation */
/* initialie thread pools used for NRUE processing paralleliation */
void init_tpools(uint8_t nun_dlsch_threads) {
char params[NR_RX_NB_TH*NR_NB_TH_SLOT*3+1]={0};
char params[NR_RX_NB_TH*NR_NB_TH_SLOT*3+1]= {0};
for (int i=0; i<NR_RX_NB_TH*NR_NB_TH_SLOT; i++) {
memcpy(params+(i*3),"-1,",3);
}
if (getenv("noThreads")) {
initTpool("n", &(nrUE_params.Tpool), false);
init_dlsch_tpool(0);
} else {
initTpool(params, &(nrUE_params.Tpool), false);
init_dlsch_tpool( nun_dlsch_threads);
}
initTpool("n", &(nrUE_params.Tpool), false);
init_dlsch_tpool(0);
} else {
initTpool(params, &(nrUE_params.Tpool), false);
init_dlsch_tpool( nun_dlsch_threads);
}
}
static void get_options(void) {
nrUE_params.ofdm_offset_divisor = 8;
paramdef_t cmdline_params[] =CMDLINE_NRUEPARAMS_DESC ;
int numparams = sizeof(cmdline_params)/sizeof(paramdef_t);
config_process_cmdline( cmdline_params,numparams,NULL);
if (vcdflag > 0)
ouput_vcd = 1;
}
// set PHY vars from command line
void set_options(int CC_id, PHY_VARS_NR_UE *UE){
void set_options(int CC_id, PHY_VARS_NR_UE *UE) {
NR_DL_FRAME_PARMS *fp = &UE->frame_parms;
paramdef_t cmdline_params[] = CMDLINE_NRUE_PHYPARAMS_DESC ;
int numparams = sizeof(cmdline_params)/sizeof(paramdef_t);
UE->mode = normal_txrx;
config_get(cmdline_params,numparams,NULL);
int pindex = config_paramidx_fromname(cmdline_params,numparams, CALIBRX_OPT);
if ( (cmdline_params[pindex].paramflags & PARAMFLAG_PARAMSET) != 0) UE->mode = rx_calib_ue;
pindex = config_paramidx_fromname(cmdline_params,numparams, CALIBRXMED_OPT);
if ( (cmdline_params[pindex].paramflags & PARAMFLAG_PARAMSET) != 0) UE->mode = rx_calib_ue_med;
pindex = config_paramidx_fromname(cmdline_params,numparams, CALIBRXBYP_OPT);
pindex = config_paramidx_fromname(cmdline_params,numparams, CALIBRXBYP_OPT);
if ( (cmdline_params[pindex].paramflags & PARAMFLAG_PARAMSET) != 0) UE->mode = rx_calib_ue_byp;
pindex = config_paramidx_fromname(cmdline_params,numparams, DBGPRACH_OPT);
pindex = config_paramidx_fromname(cmdline_params,numparams, DBGPRACH_OPT);
if (cmdline_params[pindex].uptr)
if ( *(cmdline_params[pindex].uptr) > 0) UE->mode = debug_prach;
pindex = config_paramidx_fromname(cmdline_params,numparams,NOL2CONNECT_OPT );
pindex = config_paramidx_fromname(cmdline_params,numparams,NOL2CONNECT_OPT );
if (cmdline_params[pindex].uptr)
if ( *(cmdline_params[pindex].uptr) > 0) UE->mode = no_L2_connect;
pindex = config_paramidx_fromname(cmdline_params,numparams,CALIBPRACH_OPT );
if (cmdline_params[pindex].uptr)
if ( *(cmdline_params[pindex].uptr) > 0) UE->mode = calib_prach_tx;
pindex = config_paramidx_fromname(cmdline_params,numparams,DUMPFRAME_OPT );
if ((cmdline_params[pindex].paramflags & PARAMFLAG_PARAMSET) != 0)
UE->mode = rx_dump_frame;
@@ -309,28 +316,24 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){
tx_max_power[CC_id] = tx_max_power[0];
rx_gain[0][CC_id] = rx_gain[0][0];
tx_gain[0][CC_id] = tx_gain[0][0];
// Set UE variables
UE->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off;
UE->tx_total_gain_dB = (int)tx_gain[CC_id][0];
UE->tx_power_max_dBm = tx_max_power[CC_id];
UE->rf_map.card = card_offset;
UE->rf_map.chain = CC_id + chain_offset;
LOG_I(PHY,"Set UE mode %d, UE_fo_compensation %d, UE_scan_carrier %d, UE_no_timing_correction %d \n, do_prb_interpolation %d\n",
UE->mode, UE->UE_fo_compensation, UE->UE_scan_carrier, UE->no_timing_correction, UE->prb_interpolation);
UE->mode, UE->UE_fo_compensation, UE->UE_scan_carrier, UE->no_timing_correction, UE->prb_interpolation);
// Set FP variables
if (tddflag){
if (tddflag) {
fp->frame_type = TDD;
LOG_I(PHY, "Set UE frame_type %d\n", fp->frame_type);
}
LOG_I(PHY, "Set UE nb_rx_antenna %d, nb_tx_antenna %d, threequarter_fs %d, ssb_start_subcarrier %d\n", fp->nb_antennas_rx, fp->nb_antennas_tx, fp->threequarter_fs, fp->ssb_start_subcarrier);
fp->ofdm_offset_divisor = nrUE_params.ofdm_offset_divisor;
}
void init_openair0(void) {
@@ -356,23 +359,18 @@ void init_openair0(void) {
openair0_cfg[card].time_source = get_softmodem_params()->timing_source;
openair0_cfg[card].tx_num_channels = min(4, frame_parms->nb_antennas_tx);
openair0_cfg[card].rx_num_channels = min(4, frame_parms->nb_antennas_rx);
LOG_I(PHY, "HW: Configuring card %d, sample_rate %f, tx/rx num_channels %d/%d, duplex_mode %s\n",
card,
openair0_cfg[card].sample_rate,
openair0_cfg[card].tx_num_channels,
openair0_cfg[card].rx_num_channels,
duplex_mode[openair0_cfg[card].duplex_mode]);
card,
openair0_cfg[card].sample_rate,
openair0_cfg[card].tx_num_channels,
openair0_cfg[card].rx_num_channels,
duplex_mode[openair0_cfg[card].duplex_mode]);
nr_get_carrier_frequencies(PHY_vars_UE_g[0][0], &dl_carrier, &ul_carrier);
nr_rf_card_config_freq(&openair0_cfg[card], ul_carrier, dl_carrier, freq_off);
nr_rf_card_config_gain(&openair0_cfg[card], rx_gain_off);
openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file;
if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args;
}
}
@@ -386,9 +384,11 @@ static void init_pdcp(int ue_id) {
if (IS_SOFTMODEM_NOKRNMOD) {
pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT;
}
if (get_softmodem_params()->nsa && rlc_module_init(0) != 0) {
LOG_I(RLC, "Problem at RLC initiation \n");
}
pdcp_layer_init();
nr_pdcp_module_init(pdcp_initmask, ue_id);
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req);
@@ -403,15 +403,16 @@ void *rrc_enb_process_msg(void *notUsed) {
int main( int argc, char **argv ) {
int set_exe_prio = 1;
if (checkIfFedoraDistribution())
if (checkIfGenericKernelOnFedora())
if (checkIfInsideContainer())
set_exe_prio = 0;
if (set_exe_prio)
set_priority(79);
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1)
{
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
fprintf(stderr, "mlockall: %s\n", strerror(errno));
return EXIT_FAILURE;
}
@@ -423,16 +424,18 @@ int main( int argc, char **argv ) {
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
set_softmodem_sighandler();
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
memset(openair0_cfg,0,sizeof(openair0_config_t)*MAX_CARDS);
memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs);
// initialize logging
logInit();
if (logInit())
exit_fun("[SOFTMODEM] Error, logging configuration init failed\n");
// get options and fill parameters from configuration file
get_options (); //Command-line options specific for NRUE
get_common_options(SOFTMODEM_5GUE_BIT);
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
#if T_TRACER
@@ -441,10 +444,8 @@ int main( int argc, char **argv ) {
init_tpools(nrUE_params.nr_dlsch_parallel);
//randominit (0);
set_taus_seed (0);
cpuf=get_cpu_freq_GHz();
itti_init(TASK_MAX, tasks_info);
init_opt() ;
load_nrLDPClib(NULL);
@@ -452,22 +453,20 @@ int main( int argc, char **argv ) {
vcd_signal_dumper_init("/tmp/openair_dump_nrUE.vcd");
}
#ifndef PACKAGE_VERSION
#ifndef PACKAGE_VERSION
# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
#endif
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
init_NR_UE(1,uecap_file,rrc_config_path);
int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1;
uint16_t node_number = get_softmodem_params()->node_number;
ue_id_g = (node_number == 0) ? 0 : node_number - 2;
AssertFatal(ue_id_g >= 0, "UE id is expected to be nonnegative.\n");
if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa || get_softmodem_params()->nsa) {
if(node_number == 0) {
init_pdcp(0);
}
else {
} else {
init_pdcp(mode_offset + ue_id_g);
}
}
@@ -476,6 +475,7 @@ int main( int argc, char **argv ) {
NB_INST=1;
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE **));
PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE *)*MAX_NUM_CCs);
if (get_softmodem_params()->emulate_l1) {
RCconfig_nr_ue_L1();
init_bler_table();
@@ -495,7 +495,6 @@ int main( int argc, char **argv ) {
PHY_vars_UE_g[0][CC_id] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE));
UE[CC_id] = PHY_vars_UE_g[0][CC_id];
memset(UE[CC_id],0,sizeof(PHY_VARS_NR_UE));
set_options(CC_id, UE[CC_id]);
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
@@ -507,15 +506,13 @@ int main( int argc, char **argv ) {
uplink_frequency_offset[CC_id][0],
get_softmodem_params()->numerology,
nr_band);
}
else{
} else {
if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL)
mac->if_module->phy_config_request(&mac->phy_config);
fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config;
nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config,
*mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]);
*mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]);
}
init_symbol_rotation(&UE[CC_id]->frame_parms);
@@ -563,8 +560,8 @@ int main( int argc, char **argv ) {
// Read in each MCS file and build BLER-SINR-TB table
static void init_bler_table(void) {
memset(nr_bler_data, 0, sizeof(nr_bler_data));
const char *awgn_results_dir = getenv("AWGN_RESULTS_DIR");
if (!awgn_results_dir) {
LOG_W(NR_MAC, "No $AWGN_RESULTS_DIR\n");
return;
@@ -574,15 +571,18 @@ static void init_bler_table(void) {
char fName[1024];
snprintf(fName, sizeof(fName), "%s/mcs%d_awgn_5G.csv", awgn_results_dir, i);
FILE *pFile = fopen(fName, "r");
if (!pFile) {
LOG_E(NR_MAC, "%s: open %s: %s\n", __func__, fName, strerror(errno));
continue;
}
size_t bufSize = 1024;
char * line = NULL;
char * token;
char * temp = NULL;
char *line = NULL;
char *token;
char *temp = NULL;
int nlines = 0;
while (getline(&line, &bufSize, pFile) > 0) {
if (!strncmp(line, "SNR", 3)) {
continue;
@@ -595,6 +595,7 @@ static void init_bler_table(void) {
token = strtok_r(line, ";", &temp);
int ncols = 0;
while (token != NULL) {
if (ncols > NUM_BLER_COL) {
LOG_E(NR_MAC, "BLER FILE ERROR - num of cols greater than expected\n");
@@ -603,11 +604,12 @@ static void init_bler_table(void) {
nr_bler_data[i].bler_table[nlines][ncols] = strtof(token, NULL);
ncols++;
token = strtok_r(NULL, ";", &temp);
}
nlines++;
}
nr_bler_data[i].length = nlines;
fclose(pFile);
}