diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index b3eac341a9185e4ab0683aac12da219b3edcc547..5b9ba3d093c87b22fff8042e622cf183cfda56d6 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -112,7 +112,7 @@ function start_basic_sim_ue { rm $1 local i="0" - echo "ifconfig oip1 | egrep -c \"inet addr\"" > $1 + echo "ifconfig oaitun_ue1 | egrep -c \"inet addr\"" > $1 while [ $i -lt 10 ] do sleep 5 @@ -134,7 +134,7 @@ function start_basic_sim_ue { } function get_ue_ip_addr { - echo "ifconfig oip1 | egrep \"inet addr\" | sed -e 's#^.*inet addr:##' -e 's# P-t-P:.*\$##'" > $1 + echo "ifconfig oaitun_ue1 | egrep \"inet addr\" | sed -e 's#^.*inet addr:##' -e 's# P-t-P:.*\$##'" > $1 UE_IP_ADDR=`ssh -o StrictHostKeyChecking=no ubuntu@$2 < $1` echo "UE IP Address for EPC is : $UE_IP_ADDR" rm $1 @@ -149,9 +149,9 @@ function ping_ue_ip_addr { } function ping_epc_ip_addr { - echo "echo \"COMMAND IS: ping -I oip1 -c 20 $3\" > $4" > $1 + echo "echo \"COMMAND IS: ping -I oaitun_ue1 -c 20 $3\" > $4" > $1 echo "rm -f $4" >> $1 - echo "ping -I oip1 -c 20 $3 | tee -a $4" >> $1 + echo "ping -I oaitun_ue1 -c 20 $3 | tee -a $4" >> $1 cat $1 ssh -o StrictHostKeyChecking=no ubuntu@$2 < $1 rm -f $1 @@ -618,9 +618,9 @@ function start_l2_sim_ue { UE_SYNC=1 echo "L2-SIM UE is sync'ed w/ eNB" fi - # Checking oip1 interface has now an IP address + # Checking oaitun_ue1 interface has now an IP address i="0" - echo "ifconfig oip1 | egrep -c \"inet addr\"" > $1 + echo "ifconfig oaitun_ue1 | egrep -c \"inet addr\"" > $1 while [ $i -lt 10 ] do sleep 5 @@ -636,10 +636,10 @@ function start_l2_sim_ue { if [ $i -lt 50 ] then UE_SYNC=0 - echo "L2-SIM UE oip1 is NOT sync'ed w/ EPC" + echo "L2-SIM UE oaitun_ue1 is NOT sync'ed w/ EPC" else UE_SYNC=1 - echo "L2-SIM UE oip1 is sync'ed w/ EPC" + echo "L2-SIM UE oaitun_ue1 is sync'ed w/ EPC" fi sleep 10 } diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index ecb9b314f25f4918490333fe0dffe690f97011be..6c176a75c24a1c1945d84791e377d12aed305b59 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -250,7 +250,7 @@ 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(DISABLE_LOG_X False "Deactivate all LOG_* macros") add_boolean_option(USRP_REC_PLAY False "Enable USRP record playback mode") -add_boolean_option(UE_NAS_USE_TUN False "Enable UE NAS TUN device instead of ue_ip.ko") +#add_boolean_option(UE_NAS_USE_TUN False "Enable UE NAS TUN device instead of ue_ip.ko") add_boolean_option(BASIC_SIMULATOR False "Has to be True when building the basic simulator, False otherwise") add_boolean_option(DEBUG_CONSOLE False "makes debugging easier, disables stdout/stderr buffering") @@ -595,7 +595,6 @@ Message("CPU_Affinity flag is ${CPU_AFFINITY}") ############################################################## # ???!!! TO BE DOCUMENTED OPTIONS !!!??? ############################################################## -add_boolean_option(ENABLE_SECURITY True "Enable LTE integrity and ciphering between RRC UE and eNB") add_boolean_option(ENABLE_USE_MME True "eNB connected to MME (INTERFACE S1-C), not standalone eNB") add_boolean_option(NO_RRM True "DO WE HAVE A RADIO RESSOURCE MANAGER: NO") add_boolean_option(RRC_DEFAULT_RAB_IS_AM False "set the RLC mode to AM for the default bearer") @@ -693,10 +692,10 @@ add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGE ########################## # PDCP LAYER OPTIONS ########################## -add_boolean_option(PDCP_USE_NETLINK False "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") -add_boolean_option(PDCP_USE_NETLINK_QUEUES False "When PDCP_USE_NETLINK is true, incoming IP packets are stored in queues") -add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver") -add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)") +#add_boolean_option(PDCP_USE_NETLINK False "For eNB, PDCP communicate with a NETLINK socket if connected to network driver, else could use a RT-FIFO") +#add_boolean_option(PDCP_USE_NETLINK_QUEUES False "When PDCP_USE_NETLINK is true, incoming IP packets are stored in queues") +#add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver") +#add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)") ########################## # RRC LAYER OPTIONS @@ -1994,26 +1993,29 @@ add_executable(lte-softmodem-nos1 ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c + ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c + ${GTPU_need_ITTI} ${XFORMS_SOURCE} ${XFORMS_SOURCE_SOFTMODEM} ${T_SOURCE} ${CONFIG_SOURCES} ${SHLIB_LOADER_SOURCES} ) + add_dependencies(lte-softmodem-nos1 rrc_flag s1ap_flag x2_flag) + target_link_libraries (lte-softmodem-nos1 -Wl,--start-group - RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 ${RAL_LIB} ${ITTI_LIB} - ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 + RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB - -Wl,--end-group z dl ) + -Wl,--end-group z dl) target_link_libraries (lte-softmodem-nos1 ${LIBXML2_LIBRARIES}) -target_link_libraries (lte-softmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) -target_link_libraries (lte-softmodem-nos1 ${LIB_LMS_LIBRARIES}) +target_link_libraries (lte-softmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) +target_link_libraries (lte-softmodem-nos1 ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-softmodem-nos1 ${T_LIB}) - # lte-uesoftmodem is UE implementation ####################################### @@ -2027,6 +2029,8 @@ add_executable(lte-uesoftmodem ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c + ${OPENAIR2_DIR}/RRC/NAS/nas_config.c + ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c @@ -2070,6 +2074,7 @@ add_executable(lte-uesoftmodem-nos1 ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c + ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${XFORMS_SOURCE} @@ -2080,18 +2085,18 @@ add_executable(lte-uesoftmodem-nos1 ) add_dependencies(lte-uesoftmodem-nos1 rrc_flag s1ap_flag x2_flag) + target_link_libraries (lte-uesoftmodem-nos1 -Wl,--start-group - RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE SIMU ${RAL_LIB} ${ITTI_LIB} - ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} + RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE SIMU + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB - -Wl,--end-group z dl ) + -Wl,--end-group z dl) target_link_libraries (lte-uesoftmodem-nos1 ${LIBXML2_LIBRARIES}) -target_link_libraries (lte-uesoftmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) -target_link_libraries (lte-uesoftmodem-nos1 ${LIB_LMS_LIBRARIES}) +target_link_libraries (lte-uesoftmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES}) +target_link_libraries (lte-uesoftmodem-nos1 ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-uesoftmodem-nos1 ${T_LIB}) - # USIM process ################# #add_executable(usim diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 2728cac9b1721298ccad67a1867709cfd71defde..d14bd3ec6edd36fa031d252cf2a4aea6d845a6e1 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -547,9 +547,9 @@ function main() { mkdir -p $DIR/$lte_build_dir/build cmake_file=$DIR/$lte_build_dir/CMakeLists.txt echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file - if [ "$NOS1" = "1" ] ; then - cat $DIR/$lte_build_dir/CMakeLists.template >> $cmake_file - fi +# if [ "$NOS1" = "1" ] ; then +# cat $DIR/$lte_build_dir/CMakeLists.template >> $cmake_file +# fi echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file echo "set ( XFORMS $XFORMS )" >> $cmake_file @@ -936,7 +936,7 @@ fi echo "set (LINUX True )" >> $cmake_file echo "set (PDCP_USE_NETLINK True )" >> $cmake_file echo "set (BASIC_SIMULATOR \"True\" )" >> $cmake_file - echo "set (UE_NAS_USE_TUN \"True\" )" >> $cmake_file +# echo "set (UE_NAS_USE_TUN \"True\" )" >> $cmake_file echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt)' >> $cmake_file echo_info "Build UE" diff --git a/cmake_targets/epc_test/CMakeLists.template b/cmake_targets/epc_test/CMakeLists.template index e046bb75391a178a605ed390cbb13a91b05bcbd7..7a097fffb027f81f94a210f50f8ea37939639bee 100644 --- a/cmake_targets/epc_test/CMakeLists.template +++ b/cmake_targets/epc_test/CMakeLists.template @@ -9,7 +9,6 @@ set ( EMIT_ASN_DEBUG False ) set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING True ) set ( ENABLE_NEW_MULTICAST True ) -set ( ENABLE_SECURITY True ) set ( ENABLE_STANDALONE_EPC False) set ( ENABLE_USE_CPU_EXECUTION_TIME True ) set ( ENABLE_USE_MME True ) diff --git a/cmake_targets/oaisim_build_oai/CMakeLists.template b/cmake_targets/oaisim_build_oai/CMakeLists.template index 22faac75b5855fd33b2fb6630c5dde36e8fe83a4..cffbddc93c5b5170dcb83896f2af5c90c5ef311a 100644 --- a/cmake_targets/oaisim_build_oai/CMakeLists.template +++ b/cmake_targets/oaisim_build_oai/CMakeLists.template @@ -8,7 +8,6 @@ set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING True ) set ( ENABLE_NEW_MULTICAST True ) set ( ENABLE_RAL False ) -set ( ENABLE_SECURITY True ) set ( ENABLE_STANDALONE_EPC False) set ( ENABLE_USE_CPU_EXECUTION_TIME True ) set ( ENABLE_USE_MME True ) diff --git a/cmake_targets/oaisim_mme_build_oai/CMakeLists.template b/cmake_targets/oaisim_mme_build_oai/CMakeLists.template index b18b23ee9abf72e93a74a9d70a9edede932a0b8c..eac29006da6ad83a48c6b3256fbe564fba59ade4 100644 --- a/cmake_targets/oaisim_mme_build_oai/CMakeLists.template +++ b/cmake_targets/oaisim_mme_build_oai/CMakeLists.template @@ -8,7 +8,6 @@ set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING False ) set ( ENABLE_NEW_MULTICAST False ) set ( ENABLE_RAL False ) -set ( ENABLE_SECURITY False ) set ( ENABLE_STANDALONE_EPC False ) set ( ENABLE_USE_CPU_EXECUTION_TIME False ) set ( ENABLE_USE_MME False ) diff --git a/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template b/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template index bc416cff55fef58c4a19492585c07addd4f60115..343e9280902b4074740fbea0d0fb3b1427394e17 100644 --- a/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template +++ b/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template @@ -7,7 +7,6 @@ set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING False ) set ( ENABLE_NEW_MULTICAST True ) set ( ENABLE_RAL False ) -set ( ENABLE_SECURITY False ) set ( ENABLE_STANDALONE_EPC False) set ( ENABLE_USE_CPU_EXECUTION_TIME True ) set ( ENABLE_USE_MME False ) diff --git a/cmake_targets/s1c_mme_test/CMakeLists.template b/cmake_targets/s1c_mme_test/CMakeLists.template index 9f1ff3e36015965cf5403c37472f259f32d29a25..e62df04bc6f345783c35f0d8749a7af523e1e68f 100644 --- a/cmake_targets/s1c_mme_test/CMakeLists.template +++ b/cmake_targets/s1c_mme_test/CMakeLists.template @@ -9,7 +9,6 @@ set ( ENABLE_NAS_UE_LOGGING True ) set ( ENABLE_NEW_MULTICAST True ) set ( ENABLE_PDCP_NETLINK_FIFO False ) set ( ENABLE_RAL False ) -set ( ENABLE_SECURITY True ) set ( ENABLE_STANDALONE_EPC False) set ( ENABLE_USE_CPU_EXECUTION_TIME True ) set ( ENABLE_USE_MME True ) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 7a2f2b99f44862db82e43a41e8db1ed797745533..98987ca66e6ea84e451618e4556f29414a2f327b 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -303,8 +303,8 @@ void log_getconfig(log_t *g_log) { logparams_dump[i].numelt = 0; } - config_get( logparams_debug,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX); - config_get( logparams_dump,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX); + config_get( logparams_debug,(sizeof(log_maskmap)/sizeof(mapping)) - 1,CONFIG_STRING_LOG_PREFIX); + config_get( logparams_dump,(sizeof(log_maskmap)/sizeof(mapping)) - 1,CONFIG_STRING_LOG_PREFIX); config_check_unknown_cmdlineopt(CONFIG_STRING_LOG_PREFIX); /* set the debug mask according to the debug parameters values */ @@ -385,7 +385,6 @@ int logInit (void) { register_log_component("OCG","",OCG); register_log_component("PERF","",PERF); register_log_component("OIP","",OIP); - register_log_component("CLI","",CLI); register_log_component("MSC","log",MSC); register_log_component("OCM","log",OCM); register_log_component("HW","",HW); @@ -408,6 +407,8 @@ int logInit (void) { register_log_component("X2AP","",X2AP); register_log_component("LOADER","log",LOADER); register_log_component("ASN","log",ASN); + register_log_component("NFAPI_PNF","log",NFAPI_PNF); + register_log_component("NFAPI_VNF","log",NFAPI_VNF); for (int i=0 ; log_level_names[i].name != NULL ; i++) g_log->level2string[i] = toupper(log_level_names[i].name[0]); // uppercased first letter of level name @@ -438,7 +439,7 @@ char *log_getthreadname(char *threadname, int bufsize) { static int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) { char threadname[PR_SET_NAME]; - return snprintf(log_buffer, buffsize , "%s%s[%s]%c %s %s%s", + return snprintf(log_buffer, buffsize, "%s%s[%s]%c %s %s%s", log_level_highlight_end[level], ( (g_log->flag & FLAG_NOCOLOR)?"":log_level_highlight_start[level]), g_log->log_component[comp].name, @@ -452,11 +453,17 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, int le char log_buffer[MAX_LOG_TOTAL]; va_list args; va_start(args, format); - log_header(log_buffer,MAX_LOG_TOTAL ,comp, level,format); + log_header(log_buffer,MAX_LOG_TOTAL,comp, level,format); g_log->log_component[comp].vprint(g_log->log_component[comp].stream,log_buffer, args); va_end(args); } +void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args ) { + char log_buffer[MAX_LOG_TOTAL]; + log_header(log_buffer,MAX_LOG_TOTAL,comp, level,format); + g_log->log_component[comp].vprint(g_log->log_component[comp].stream,log_buffer, args); +} + void log_dump(int component, void *buffer, int buffsize,int datatype, const char *format, ... ) { va_list args; char *wbuf; @@ -474,7 +481,7 @@ void log_dump(int component, void *buffer, int buffsize,int datatype, const char if (wbuf != NULL) { va_start(args, format); - int pos=log_header(wbuf,MAX_LOG_TOTAL ,component, OAILOG_INFO,""); + int pos=log_header(wbuf,MAX_LOG_TOTAL,component, OAILOG_INFO,""); int pos2=vsprintf(wbuf+pos,format, args); pos=pos+pos2; va_end(args); diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 5d8ad06bec03c5f92698397f01f58a8cae62b145..1ecb68732a2a021ccdfc9b6c67cb0a94e3aeb7f6 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -198,7 +198,6 @@ typedef enum { NAS, PERF, OIP, - CLI, MSC, OCM, UDP_, @@ -218,6 +217,8 @@ typedef enum { X2AP, LOADER, ASN, + NFAPI_VNF, + NFAPI_PNF, MAX_LOG_PREDEF_COMPONENTS, } comp_name_t; @@ -286,6 +287,7 @@ extern "C" { int logInit (void); int isLogInitDone (void); 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); @@ -365,9 +367,9 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int # define LOG_I(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} else { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ;}} while (0) # define LOG_D(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} else { T(T_LEGACY_ ## c ## _DEBUG, T_PRINTF(x)) ;}} while (0) # define LOG_T(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} else { T(T_LEGACY_ ## c ## _TRACE, T_PRINTF(x)) ;}} while (0) +# define VLOG(c,l, f, args) do { if (T_stdout) { if( g_log->log_component[c].level >= l ) vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, l, f, args) ;} } while (0) /* macro used to dump a buffer or a message as in openair2/RRC/LTE/RRC_eNB.c, replaces LOG_F macro */ # define LOG_DUMPMSG(c, f, b, s, x...) do { if(g_log->dump_mask & f) log_dump(c, b, s, LOG_DUMP_CHAR, x) ;} while (0) /* */ -# define nfapi_log(FILE, FNC, LN, COMP, LVL, F...) do { if (T_stdout) { logRecord_mt(__FILE__, __FUNCTION__, __LINE__,COMP, LVL, F) ;}} while (0) /* */ /* bitmask dependant macros, to isolate debugging code */ # define LOG_DEBUGFLAG(D) (g_log->debug_mask & D) diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 9d1bd0bbd01251e7bf97a11362c6f8bb9e86d1ec..7fa24f5535804ddb0a27d7d279fe93af8c113d7a 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -800,6 +800,47 @@ ID = LEGACY_SIM_TRACE GROUP = ALL:LEGACY_SIM:LEGACY_GROUP_TRACE:LEGACY FORMAT = string,log +ID = LEGACY_NFAPI_VNF_INFO + DESC = NFAPI_VNF legacy logs - info level + GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_VNF_ERROR + DESC = NFAPI_VNF legacy logs - error level + GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_VNF_WARNING + DESC = NFAPI_VNF legacy logs - warning level + GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_WARNING:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_VNF_DEBUG + DESC = NFAPI_VNF legacy logs - debug level + GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_VNF_TRACE + DESC = NFAPI_VNF legacy logs - trace level + GROUP = ALL:LEGACY_NFAPI_VNF:LEGACY_GROUP_TRACE:LEGACY + FORMAT = string,log + +ID = LEGACY_NFAPI_PNF_INFO + DESC = NFAPI_PNF legacy logs - info level + GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_PNF_ERROR + DESC = NFAPI_PNF legacy logs - error level + GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_PNF_WARNING + DESC = NFAPI_PNF legacy logs - warning level + GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_WARNING:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_PNF_DEBUG + DESC = NFAPI_PNF legacy logs - debug level + GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log +ID = LEGACY_NFAPI_PNF_TRACE + DESC = NFAPI_PNF legacy logs - trace level + GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_TRACE:LEGACY + FORMAT = string,log # this is a bad hack but I won't fix (function util_print_hex_octets # in openairinterface5g/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c # does funky things with the LOG_x macros but we work on the C pre-processor @@ -845,27 +886,7 @@ ID = LEGACY_componentP_TRACE GROUP = ALL:LEGACY_componentP:LEGACY_GROUP_TRACE:LEGACY FORMAT = string,log -#needed? -ID = LEGACY_CLI_INFO - DESC = CLI legacy logs - info level - GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_INFO:LEGACY - FORMAT = string,log -ID = LEGACY_CLI_ERROR - DESC = CLI legacy logs - error level - GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_ERROR:LEGACY - FORMAT = string,log -ID = LEGACY_CLI_WARNING - DESC = CLI legacy logs - warning level - GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_WARNING:LEGACY - FORMAT = string,log -ID = LEGACY_CLI_DEBUG - DESC = CLI legacy logs - debug level - GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_DEBUG:LEGACY - FORMAT = string,log -ID = LEGACY_CLI_TRACE - DESC = CLI legacy logs - trace level - GROUP = ALL:LEGACY_CLI:LEGACY_GROUP_TRACE:LEGACY - FORMAT = string,log + ################# #### UE LOGS #### diff --git a/common/utils/T/tracer/hacks/Makefile b/common/utils/T/tracer/hacks/Makefile index f49e437bf542f823e1b71ac85653ae2736c01876..af2663e48f575eb1b0eb011acd15a5073b915486 100644 --- a/common/utils/T/tracer/hacks/Makefile +++ b/common/utils/T/tracer/hacks/Makefile @@ -3,7 +3,7 @@ CFLAGS=-Wall -g -pthread -DT_TRACER -I. -I.. LIBS=-lX11 -lm -lpng -lXft -all: dump_nack_signal time_meas timeplot +all: dump_nack_signal time_meas timeplot multi-rru-clean dump_nack_signal: ../utils.o ../database.o ../config.o ../event.o \ dump_nack_signal.o @@ -16,6 +16,9 @@ time_meas: ../utils.o ../database.o ../config.o ../event.o \ timplot: timeplot.o $(CC) $(CFLAGS) -o timeplot $^ $(LIBS) +multi-rru-clean: ../utils.o ../database.o ../event.o ../config.o multi-rru-clean.o + $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + .PHONY: all %.o: %.c diff --git a/common/utils/T/tracer/hacks/multi-rru-clean.c b/common/utils/T/tracer/hacks/multi-rru-clean.c new file mode 100644 index 0000000000000000000000000000000000000000..c85dc0de7f5ceadcfee64207ec64b49b50ddd8c9 --- /dev/null +++ b/common/utils/T/tracer/hacks/multi-rru-clean.c @@ -0,0 +1,230 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "database.h" +#include "utils.h" +#include "event.h" +#include "../T_defs.h" + +void usage(void) +{ + printf( + "usage: <number of tags> <input record file> <output curated record file>\n" + "options:\n" + " -d <database file> this option is mandatory\n" + ); + exit(1); +} + +#define ERR printf("ERROR: read file %s failed\n", input_filename) + +typedef struct { + OBUF b; + struct timespec t; + int filled; + int error; +} cache_t; + +void clear_cache(int n, cache_t *c) +{ + int i; + for (i = 0; i < n; i++) { + c[i].filled = 0; + c[i].error = 0; + c[i].b.osize = 0; + } +} + +void store_in_cache(cache_t *c, int pos, OBUF *b) +{ + int i; + for (i = 0; i < b->osize; i++) + PUTC(&c[pos].b, b->obuf[i]); +} + +int get_field(database_event_format *f, char *field, char *type) +{ + int i; + for (i = 0; i < f->count; i++) + if (!strcmp(f->name[i], field)) { + if (strcmp(f->type[i], type)) break; + return i; + } + printf("bad field %s, check that it exists and has type '%s'\n",field,type); + exit(1); +} + +void process_cache(FILE *out, cache_t *c, int n, int frame, int subframe) +{ + int i; + struct tm *t; + + for (i = 0; i < n; i++) + if (c[i].filled == 0 || c[i].error == 1) + goto error; + + for (i = 0; i < n; i++) + fwrite(c[i].b.obuf, c[i].b.osize, 1, out); + + clear_cache(n, c); + return; + +error: + printf("ERROR: incorrect data at frame %d subframe %d", frame, subframe); + for (i = 0; i < n; i++) if (c[i].filled) { + t = localtime(&c[i].t.tv_sec); + printf(" [tag %d time %2.2d:%2.2d:%2.2d.%9.9ld]", i, + t->tm_hour, t->tm_min, t->tm_sec, c[i].t.tv_nsec); + } + printf("\n"); + clear_cache(n, c); +} + +int main(int n, char **v) +{ + char *database_filename = NULL; + void *database; + int channel_estimate_id; + int number_of_tags = -1; + char *input_filename = NULL; + char *output_filename = NULL; + int i; + FILE *in; + FILE *out; + database_event_format f; + int frame_arg; + int subframe_arg; + int tag_arg; + + cache_t *cache; + int cur_frame = -1; + int cur_subframe = -1; + int frame; + int subframe; + int tag; + + for (i = 1; i < n; i++) { + if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage(); + if (!strcmp(v[i], "-d")) { if (i > n-2) usage(); + database_filename = v[++i]; continue; } + if (number_of_tags == -1) { number_of_tags = atoi(v[i]); + if (number_of_tags <= 0) {usage();} continue; } + if (input_filename == NULL) { input_filename = v[i]; continue; } + if (output_filename == NULL) { output_filename = v[i]; continue; } + usage(); + } + + if (database_filename == NULL) { + printf("ERROR: provide a database file (-d)\n"); + exit(1); + } + + if (output_filename == NULL || input_filename == NULL || number_of_tags == -1) + usage(); + + database = parse_database(database_filename); + + channel_estimate_id = event_id_from_name(database, "CALIBRATION_CHANNEL_ESTIMATES"); + f = get_format(database, channel_estimate_id); + + frame_arg = get_field(&f, "frame", "int"); + subframe_arg = get_field(&f, "subframe", "int"); + tag_arg = get_field(&f, "tag", "int"); + + in = fopen(input_filename, "r"); + if (in == NULL) { perror(input_filename); abort(); } + out = fopen(output_filename, "w"); + if (out == NULL) { perror(output_filename); abort(); } + + cache = calloc(number_of_tags, sizeof(cache_t)); + if (cache == NULL) { perror("malloc"); exit(1); } + + clear_cache(number_of_tags, cache); + + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + + while (1) { + int type; + int32_t length; + char *v; + int vpos = 0; + struct timespec t; + char *buf; + + /* read event from file */ + if (fread(&length, 4, 1, in) != 1) break; + if (ebuf.omaxsize < length) { + ebuf.omaxsize = (length + 65535) & ~65535; + ebuf.obuf = realloc(ebuf.obuf, ebuf.omaxsize); + if (ebuf.obuf == NULL) { printf("out of memory\n"); exit(1); } + } + v = ebuf.obuf; + memcpy(v+vpos, &length, 4); + vpos += 4; +#ifdef T_SEND_TIME + if (length < sizeof(struct timespec)) { ERR; break; } + if (fread(&t, sizeof(struct timespec), 1, in) != 1) { ERR; break; } + memcpy(v+vpos, &t, sizeof(struct timespec)); + vpos += sizeof(struct timespec); + length -= sizeof(struct timespec); +#endif + if (length < sizeof(int)) { ERR; break; } + if (fread(&type, sizeof(int), 1, in) != 1) { ERR; break; } + memcpy(v+vpos, &type, sizeof(int)); + vpos += sizeof(int); + length -= sizeof(int); + if (length) if (fread(v+vpos, length, 1, in) != 1) { ERR; break; } + buf = v + vpos; + vpos += length; + ebuf.osize = vpos; + + if (type != channel_estimate_id) continue; + + event e; +#ifdef T_SEND_TIME + e = new_event(t, type, length, buf, database); +#else + e = new_event(type, length, buf, database); +#endif + + frame = e.e[frame_arg].i; + subframe = e.e[subframe_arg].i; + tag = e.e[tag_arg].i; + + if (tag < 0 || tag >= number_of_tags) { + struct tm *tt; + tt = localtime(&t.tv_sec); + printf("ERROR: invalid tag (%d), skipping event for frame %d subframe %d (time %2.2d:%2.2d:%2.2d.%9.9ld)\n", + tag, frame, subframe, + tt->tm_hour, tt->tm_min, tt->tm_sec, t.tv_nsec); + continue; + } + + if (cur_frame != frame || cur_subframe != subframe) + if (cur_frame != -1) + process_cache(out, cache, number_of_tags, cur_frame, cur_subframe); + + cur_frame = frame; + cur_subframe = subframe; + + if (cache[tag].filled) { + struct tm *tt; + tt = localtime(&t.tv_sec); + printf("ERROR: tag %d present twice at frame %d subframe %d (time %2.2d:%2.2d:%2.2d.%9.9ld)\n", + tag, frame, subframe, + tt->tm_hour, tt->tm_min, tt->tm_sec, t.tv_nsec); + cache[tag].error = 1; + continue; + } + + store_in_cache(cache, tag, &ebuf); + cache[tag].filled = 1; + cache[tag].t = t; + } + + if (fclose(in)) perror(input_filename); + if (fclose(out)) perror(output_filename); + free(cache); + + return 0; +} diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 78c058ad007229b775a8558b3eb22c7f4ef00432..62c5cc27754cf1c2b707b6f37f1a5bdf3bbbf743 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -57,7 +57,7 @@ extern RAN_CONTEXT_t RC; #define _GNU_SOURCE -extern void phy_init_RU(RU_t*); +extern void phy_init_RU(RU_t *); extern int config_sync_var; extern pthread_cond_t nfapi_sync_cond; @@ -78,7 +78,7 @@ extern void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, nfapi_d extern uint8_t nfapi_mode; -nfapi_tx_request_pdu_t* tx_request_pdu[1023][10][10]; // [frame][subframe][max_num_pdus] +nfapi_tx_request_pdu_t *tx_request_pdu[1023][10][10]; // [frame][subframe][max_num_pdus] uint8_t tx_pdus[32][8][4096]; @@ -90,11 +90,11 @@ nfapi_pnf_param_response_t g_pnf_param_resp; nfapi_pnf_p7_config_t *p7_config_g = NULL; -void* pnf_allocate(size_t size) { +void *pnf_allocate(size_t size) { return malloc(size); } -void pnf_deallocate(void* ptr) { +void pnf_deallocate(void *ptr) { free(ptr); } @@ -109,36 +109,36 @@ typedef struct { } udp_data; typedef struct { - uint16_t index; - uint16_t id; - uint8_t rfs[2]; - uint8_t excluded_rfs[2]; + uint16_t index; + uint16_t id; + uint8_t rfs[2]; + uint8_t excluded_rfs[2]; - udp_data udp; + udp_data udp; - char local_addr[80]; - int local_port; + char local_addr[80]; + int local_port; - char* remote_addr; - int remote_port; + char *remote_addr; + int remote_port; - uint8_t duplex_mode; - uint16_t dl_channel_bw_support; - uint16_t ul_channel_bw_support; - uint8_t num_dl_layers_supported; - uint8_t num_ul_layers_supported; - uint16_t release_supported; - uint8_t nmm_modes_supported; + uint8_t duplex_mode; + uint16_t dl_channel_bw_support; + uint16_t ul_channel_bw_support; + uint8_t num_dl_layers_supported; + uint8_t num_ul_layers_supported; + uint16_t release_supported; + uint8_t nmm_modes_supported; - uint8_t dl_ues_per_subframe; - uint8_t ul_ues_per_subframe; + uint8_t dl_ues_per_subframe; + uint8_t ul_ues_per_subframe; - uint8_t first_subframe_ind; + uint8_t first_subframe_ind; - // timing information recevied from the vnf - uint8_t timing_window; - uint8_t timing_info_mode; - uint8_t timing_info_period; + // timing information recevied from the vnf + uint8_t timing_window; + uint8_t timing_info_mode; + uint8_t timing_info_period; } phy_info; @@ -158,36 +158,36 @@ typedef struct { typedef struct { - int release; - phy_info phys[2]; - rf_info rfs[2]; - - uint8_t sync_mode; - uint8_t location_mode; - uint8_t location_coordinates[6]; - uint32_t dl_config_timing; - uint32_t ul_config_timing; - uint32_t tx_timing; - uint32_t hi_dci0_timing; - - uint16_t max_phys; - uint16_t max_total_bw; - uint16_t max_total_dl_layers; - uint16_t max_total_ul_layers; - uint8_t shared_bands; - uint8_t shared_pa; - int16_t max_total_power; - uint8_t oui; - - uint8_t wireshark_test_mode; + int release; + phy_info phys[2]; + rf_info rfs[2]; + + uint8_t sync_mode; + uint8_t location_mode; + uint8_t location_coordinates[6]; + uint32_t dl_config_timing; + uint32_t ul_config_timing; + uint32_t tx_timing; + uint32_t hi_dci0_timing; + + uint16_t max_phys; + uint16_t max_total_bw; + uint16_t max_total_dl_layers; + uint16_t max_total_ul_layers; + uint8_t shared_bands; + uint8_t shared_pa; + int16_t max_total_power; + uint8_t oui; + + uint8_t wireshark_test_mode; } pnf_info; typedef struct { uint16_t phy_id; - nfapi_pnf_config_t* config; - phy_info* phy; - nfapi_pnf_p7_config_t* p7_config; + nfapi_pnf_config_t *config; + phy_info *phy; + nfapi_pnf_p7_config_t *p7_config; } pnf_phy_user_data_t; static pnf_info pnf; @@ -195,32 +195,34 @@ static pthread_t pnf_start_pthread; int nfapitooai_level(int nfapi_level) { switch(nfapi_level) { - case NFAPI_TRACE_ERROR: - return LOG_ERR; - case NFAPI_TRACE_WARN: - return LOG_WARNING; + case NFAPI_TRACE_ERROR: + return LOG_ERR; + + case NFAPI_TRACE_WARN: + return LOG_WARNING; + case NFAPI_TRACE_NOTE: - return LOG_INFO; - case NFAPI_TRACE_INFO: - return LOG_DEBUG; - } + return LOG_INFO; + + case NFAPI_TRACE_INFO: + return LOG_DEBUG; + } + return LOG_ERR; } -void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) { +void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) { va_list args; - va_start(args, message); - nfapi_log("FILE>", "FUNC", 999, PHY, nfapitooai_level(nfapi_level), message, args); + VLOG( NFAPI_PNF, nfapitooai_level(nfapi_level), message, args); va_end(args); } void pnf_set_thread_priority(int priority) { - pthread_attr_t ptAttr; - struct sched_param schedParam; schedParam.__sched_priority = priority; + if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) { printf("failed to set SCHED_RR\n"); } @@ -230,36 +232,29 @@ void pnf_set_thread_priority(int priority) { } pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED); - struct sched_param thread_params; thread_params.sched_priority = 20; + if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) { printf("failed to set sched param\n"); } } -void* pnf_p7_thread_start(void* ptr) { +void *pnf_p7_thread_start(void *ptr) { NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P7 THREAD %s\n", __FUNCTION__); - pnf_set_thread_priority(79); - - nfapi_pnf_p7_config_t* config = (nfapi_pnf_p7_config_t*)ptr; + nfapi_pnf_p7_config_t *config = (nfapi_pnf_p7_config_t *)ptr; nfapi_pnf_p7_start(config); - return 0; } -int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req) { - +int pnf_param_request(nfapi_pnf_config_t *config, nfapi_pnf_param_request_t *req) { printf("[PNF] pnf param request\n"); - nfapi_pnf_param_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE; resp.error_code = NFAPI_MSG_OK; - - pnf_info* pnf = (pnf_info*)(config->user_data); - + pnf_info *pnf = (pnf_info *)(config->user_data); resp.pnf_param_general.tl.tag = NFAPI_PNF_PARAM_GENERAL_TAG; resp.pnf_param_general.nfapi_sync_mode = pnf->sync_mode; resp.pnf_param_general.location_mode = pnf->location_mode; @@ -274,25 +269,25 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_param_general.shared_bands = pnf->shared_bands; resp.pnf_param_general.shared_pa = pnf->shared_pa; resp.pnf_param_general.maximum_total_power = pnf->max_total_power; - resp.pnf_phy.tl.tag = NFAPI_PNF_PHY_TAG; resp.pnf_phy.number_of_phys = 1; for(int i = 0; i < 1; ++i) { - resp.pnf_phy.phy[i].phy_config_index = pnf->phys[i].index; + resp.pnf_phy.phy[i].phy_config_index = pnf->phys[i].index; resp.pnf_phy.phy[i].downlink_channel_bandwidth_supported = pnf->phys[i].dl_channel_bw_support; resp.pnf_phy.phy[i].uplink_channel_bandwidth_supported = pnf->phys[i].ul_channel_bw_support; resp.pnf_phy.phy[i].number_of_dl_layers_supported = pnf->phys[i].num_dl_layers_supported; resp.pnf_phy.phy[i].number_of_ul_layers_supported = pnf->phys[i].num_ul_layers_supported; resp.pnf_phy.phy[i].maximum_3gpp_release_supported = pnf->phys[i].release_supported; resp.pnf_phy.phy[i].nmm_modes_supported = pnf->phys[i].nmm_modes_supported; - resp.pnf_phy.phy[i].number_of_rfs = 2; + for(int j = 0; j < 1; ++j) { resp.pnf_phy.phy[i].rf_config[j].rf_config_index = pnf->phys[i].rfs[j]; } resp.pnf_phy.phy[i].number_of_rf_exclusions = 0; + for(int j = 0; j < 0; ++j) { resp.pnf_phy.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j]; } @@ -302,9 +297,9 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_rf.number_of_rfs = 2; for(int i = 0; i < 2; ++i) { - resp.pnf_rf.rf[i].rf_config_index = pnf->rfs[i].index; + resp.pnf_rf.rf[i].rf_config_index = pnf->rfs[i].index; resp.pnf_rf.rf[i].band = pnf->rfs[i].band; - resp.pnf_rf.rf[i].maximum_transmit_power = pnf->rfs[i].max_transmit_power; + resp.pnf_rf.rf[i].maximum_transmit_power = pnf->rfs[i].max_transmit_power; resp.pnf_rf.rf[i].minimum_transmit_power = pnf->rfs[i].min_transmit_power; resp.pnf_rf.rf[i].number_of_antennas_suppported = pnf->rfs[i].num_antennas_supported; resp.pnf_rf.rf[i].minimum_downlink_frequency = pnf->rfs[i].min_downlink_frequency; @@ -317,9 +312,8 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_phy_rel10.tl.tag = NFAPI_PNF_PHY_REL10_TAG; resp.pnf_phy_rel10.number_of_phys = 1; - for(int i = 0; i < 1; ++i) - { - resp.pnf_phy_rel10.phy[i].phy_config_index = pnf->phys[i].index; + for(int i = 0; i < 1; ++i) { + resp.pnf_phy_rel10.phy[i].phy_config_index = pnf->phys[i].index; resp.pnf_phy_rel10.phy[i].transmission_mode_7_supported = 0; resp.pnf_phy_rel10.phy[i].transmission_mode_8_supported = 1; resp.pnf_phy_rel10.phy[i].two_antenna_ports_for_pucch = 0; @@ -334,7 +328,7 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_phy_rel11.number_of_phys = 1; for(int i = 0; i < 1; ++i) { - resp.pnf_phy_rel11.phy[i].phy_config_index = pnf->phys[i].index; + resp.pnf_phy_rel11.phy[i].phy_config_index = pnf->phys[i].index; resp.pnf_phy_rel11.phy[i].edpcch_supported = 0; resp.pnf_phy_rel11.phy[i].multi_ack_csi_reporting = 1; resp.pnf_phy_rel11.phy[i].pucch_tx_diversity = 0; @@ -348,7 +342,7 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_phy_rel12.number_of_phys = 1; for(int i = 0; i < 1; ++i) { - resp.pnf_phy_rel12.phy[i].phy_config_index = pnf->phys[i].index; + resp.pnf_phy_rel12.phy[i].phy_config_index = pnf->phys[i].index; resp.pnf_phy_rel12.phy[i].csi_subframe_set = 0; resp.pnf_phy_rel12.phy[i].enhanced_4tx_codebook = 2; resp.pnf_phy_rel12.phy[i].drs_supported = 0; @@ -363,7 +357,7 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_phy_rel13.number_of_phys = 1; for(int i = 0; i < 1; ++i) { - resp.pnf_phy_rel13.phy[i].phy_config_index = pnf->phys[i].index; + resp.pnf_phy_rel13.phy[i].phy_config_index = pnf->phys[i].index; resp.pnf_phy_rel13.phy[i].pucch_format4_supported = 0; resp.pnf_phy_rel13.phy[i].pucch_format5_supported = 1; resp.pnf_phy_rel13.phy[i].more_than_5_ca_support = 0; @@ -380,14 +374,15 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_phy_rel13_nb_iot.number_of_phys = 1; for(int i = 0; i < 1; ++i) { - resp.pnf_phy_rel13_nb_iot.phy[i].phy_config_index = pnf->phys[i].index; - + resp.pnf_phy_rel13_nb_iot.phy[i].phy_config_index = pnf->phys[i].index; resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rfs = 1; + for(int j = 0; j < 1; ++j) { resp.pnf_phy_rel13_nb_iot.phy[i].rf_config[j].rf_config_index = pnf->phys[i].rfs[j]; } resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rf_exclusions = 1; + for(int j = 0; j < 1; ++j) { resp.pnf_phy_rel13_nb_iot.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j]; } @@ -400,51 +395,39 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req } nfapi_pnf_pnf_param_resp(config, &resp); - return 0; } -int pnf_config_request(nfapi_pnf_config_t* config, nfapi_pnf_config_request_t* req) { - +int pnf_config_request(nfapi_pnf_config_t *config, nfapi_pnf_config_request_t *req) { printf("[PNF] pnf config request\n"); - - pnf_info* pnf = (pnf_info*)(config->user_data); - + pnf_info *pnf = (pnf_info *)(config->user_data); phy_info *phy = pnf->phys; phy->id = req->pnf_phy_rf_config.phy_rf_config[0].phy_id; printf("[PNF] pnf config request assigned phy_id %d to phy_config_index %d\n", phy->id, req->pnf_phy_rf_config.phy_rf_config[0].phy_config_index); - nfapi_pnf_config_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE; resp.error_code = NFAPI_MSG_OK; nfapi_pnf_pnf_config_resp(config, &resp); printf("[PNF] Sent pnf_config_resp\n"); - return 0; } -void nfapi_send_pnf_start_resp(nfapi_pnf_config_t* config, uint16_t phy_id) { - +void nfapi_send_pnf_start_resp(nfapi_pnf_config_t *config, uint16_t phy_id) { printf("Sending NFAPI_START_RESPONSE config:%p phy_id:%d\n", config, phy_id); - nfapi_start_response_t start_resp; memset(&start_resp, 0, sizeof(start_resp)); start_resp.header.message_id = NFAPI_START_RESPONSE; start_resp.header.phy_id = phy_id; start_resp.error_code = NFAPI_MSG_OK; - nfapi_pnf_start_resp(config, &start_resp); } -int pnf_start_request(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req) { - +int pnf_start_request(nfapi_pnf_config_t *config, nfapi_pnf_start_request_t *req) { printf("Received NFAPI_PNF_START_REQUEST\n"); - - pnf_info* pnf = (pnf_info*)(config->user_data); - + pnf_info *pnf = (pnf_info *)(config->user_data); // start all phys that have been configured - phy_info* phy = pnf->phys; + phy_info *phy = pnf->phys; if(phy->id != 0) { nfapi_pnf_start_response_t resp; @@ -454,79 +437,62 @@ int pnf_start_request(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req nfapi_pnf_pnf_start_resp(config, &resp); printf("[PNF] Sent NFAPI_PNF_START_RESP\n"); } + return 0; } -int pnf_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_stop_request_t* req) { - +int pnf_stop_request(nfapi_pnf_config_t *config, nfapi_pnf_stop_request_t *req) { printf("[PNF] Received NFAPI_PNF_STOP_REQ\n"); - nfapi_pnf_stop_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_PNF_STOP_RESPONSE; resp.error_code = NFAPI_MSG_OK; nfapi_pnf_pnf_stop_resp(config, &resp); printf("[PNF] Sent NFAPI_PNF_STOP_REQ\n"); - return 0; } -int param_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_param_request_t* req) { - +int param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_param_request_t *req) { printf("[PNF] Received NFAPI_PARAM_REQUEST phy_id:%d\n", req->header.phy_id); - //pnf_info* pnf = (pnf_info*)(config->user_data); - nfapi_param_response_t nfapi_resp; - - pnf_info* pnf = (pnf_info*)(config->user_data); - + pnf_info *pnf = (pnf_info *)(config->user_data); memset(&nfapi_resp, 0, sizeof(nfapi_resp)); nfapi_resp.header.message_id = NFAPI_PARAM_RESPONSE; nfapi_resp.header.phy_id = req->header.phy_id; nfapi_resp.error_code = 0; // DJP - what value??? - struct sockaddr_in pnf_p7_sockaddr; - pnf_p7_sockaddr.sin_addr.s_addr = inet_addr(pnf->phys[0].local_addr); nfapi_resp.nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG; memcpy(nfapi_resp.nfapi_config.p7_pnf_address_ipv4.address, &pnf_p7_sockaddr.sin_addr.s_addr, 4); nfapi_resp.num_tlv++; - // P7 PNF Port nfapi_resp.nfapi_config.p7_pnf_port.tl.tag = NFAPI_NFAPI_P7_PNF_PORT_TAG; nfapi_resp.nfapi_config.p7_pnf_port.value = 32123; // DJP - hard code alert!!!! FIXME TODO nfapi_resp.num_tlv++; - nfapi_pnf_param_resp(config, &nfapi_resp); - printf("[PNF] Sent NFAPI_PARAM_RESPONSE phy_id:%d number_of_tlvs:%u\n", req->header.phy_id, nfapi_resp.num_tlv); - printf("[PNF] param request .. exit\n"); - return 0; } -int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_config_request_t* req) { - +int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_config_request_t *req) { printf("[PNF] Received NFAPI_CONFIG_REQ phy_id:%d\n", req->header.phy_id); - - pnf_info* pnf = (pnf_info*)(config->user_data); + pnf_info *pnf = (pnf_info *)(config->user_data); uint8_t num_tlv = 0; //struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - // In the case of nfapi_mode = 3 (UE = PNF) we should not have dependency on any eNB var. So we aim // to keep only the necessary just to keep the nfapi FSM rolling by sending a dummy response. LTE_DL_FRAME_PARMS *fp; + if (nfapi_mode!=3) { - struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - fp = &eNB->frame_parms; - } - else{ - fp = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); + struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; + fp = &eNB->frame_parms; + } else { + fp = (LTE_DL_FRAME_PARMS *) malloc(sizeof(LTE_DL_FRAME_PARMS)); } - phy_info* phy_info = pnf->phys; + phy_info *phy_info = pnf->phys; if(req->nfapi_config.timing_window.tl.tag == NFAPI_NFAPI_TIMING_WINDOW_TAG) { phy_info->timing_window = req->nfapi_config.timing_window.value; @@ -576,9 +542,8 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap fp->dl_CarrierFreq = from_earfcn(fp->eutra_band, req->nfapi_config.earfcn.value); fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_uldl_offset(fp->eutra_band) * 1e5); num_tlv++; - - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() earfcn:%u dl_carrierFreq:%u ul_CarrierFreq:%u band:%u N_RB_DL:%u\n", - __FUNCTION__, req->nfapi_config.earfcn.value, fp->dl_CarrierFreq, fp->ul_CarrierFreq, pnf->rfs[0].band, fp->N_RB_DL); + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() earfcn:%u dl_carrierFreq:%u ul_CarrierFreq:%u band:%u N_RB_DL:%u\n", + __FUNCTION__, req->nfapi_config.earfcn.value, fp->dl_CarrierFreq, fp->ul_CarrierFreq, pnf->rfs[0].band, fp->N_RB_DL); } if (req->subframe_config.duplex_mode.tl.tag == NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG) { @@ -683,28 +648,22 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap } if(nfapi_mode!=3) { - printf("[PNF] CONFIG_REQUEST[num_tlv:%d] TLVs processed:%d\n", req->num_tlv, num_tlv); - - printf("[PNF] Simulating PHY CONFIG - DJP\n"); - PHY_Config_t phy_config; - phy_config.Mod_id = 0; - phy_config.CC_id=0; - phy_config.cfg = req; - - phy_config_request(&phy_config); - - dump_frame_parms(fp); + printf("[PNF] CONFIG_REQUEST[num_tlv:%d] TLVs processed:%d\n", req->num_tlv, num_tlv); + printf("[PNF] Simulating PHY CONFIG - DJP\n"); + PHY_Config_t phy_config; + phy_config.Mod_id = 0; + phy_config.CC_id=0; + phy_config.cfg = req; + phy_config_request(&phy_config); + dump_frame_parms(fp); } phy_info->remote_port = req->nfapi_config.p7_vnf_port.value; - struct sockaddr_in vnf_p7_sockaddr; memcpy(&vnf_p7_sockaddr.sin_addr.s_addr, &(req->nfapi_config.p7_vnf_address_ipv4.address[0]), 4); phy_info->remote_addr = inet_ntoa(vnf_p7_sockaddr.sin_addr); - - printf("[PNF] %d vnf p7 %s:%d timing %d %d %d\n", phy_info->id, phy_info->remote_addr, phy_info->remote_port, - phy_info->timing_window, phy_info->timing_info_mode, phy_info->timing_info_period); - + printf("[PNF] %d vnf p7 %s:%d timing %d %d %d\n", phy_info->id, phy_info->remote_addr, phy_info->remote_port, + phy_info->timing_window, phy_info->timing_info_mode, phy_info->timing_info_period); nfapi_config_response_t nfapi_resp; memset(&nfapi_resp, 0, sizeof(nfapi_resp)); nfapi_resp.header.message_id = NFAPI_CONFIG_RESPONSE; @@ -712,71 +671,54 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap nfapi_resp.error_code = 0; // DJP - some value resp->error_code; nfapi_pnf_config_resp(config, &nfapi_resp); printf("[PNF] Sent NFAPI_CONFIG_RESPONSE phy_id:%d\n", phy_info->id); + if(nfapi_mode ==3) - free(fp); + free(fp); return 0; } -nfapi_p7_message_header_t* pnf_phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t* msg_size) { - +nfapi_p7_message_header_t *pnf_phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t *msg_size) { if(message_id == P7_VENDOR_EXT_REQ) { (*msg_size) = sizeof(vendor_ext_p7_req); - return (nfapi_p7_message_header_t*)malloc(sizeof(vendor_ext_p7_req)); + return (nfapi_p7_message_header_t *)malloc(sizeof(vendor_ext_p7_req)); } return 0; } -void pnf_phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header) { - +void pnf_phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) { free(header); } -int pnf_phy_hi_dci0_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) { - +int pnf_phy_hi_dci0_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_hi_dci0_request_t *req) { if (req->hi_dci0_request_body.number_of_dci == 0 && req->hi_dci0_request_body.number_of_hi == 0) LOG_D(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi); //phy_info* phy = (phy_info*)(pnf_p7->user_data); - struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; L1_rxtx_proc_t *proc = &eNB->proc.L1_proc; for (int i=0; i<req->hi_dci0_request_body.number_of_dci + req->hi_dci0_request_body.number_of_hi; i++) { - //LOG_D(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); - if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) { - //LOG_D(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_DCI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); - nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = &req->hi_dci0_request_body.hi_dci0_pdu_list[i]; - handle_nfapi_hi_dci0_dci_pdu(eNB,NFAPI_SFNSF2SFN(req->sfn_sf),NFAPI_SFNSF2SF(req->sfn_sf),proc,hi_dci0_req_pdu); - eNB->pdcch_vars[NFAPI_SFNSF2SF(req->sfn_sf)&1].num_dci++; - } else if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) { - LOG_D(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); - nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = &req->hi_dci0_request_body.hi_dci0_pdu_list[i]; - handle_nfapi_hi_dci0_hi_pdu(eNB, NFAPI_SFNSF2SFN(req->sfn_sf),NFAPI_SFNSF2SF(req->sfn_sf), proc, hi_dci0_req_pdu); - } else { - LOG_E(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); - } } return 0; } -int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) { - +int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { if (RC.ru == 0) { return -1; } @@ -789,65 +731,51 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request return -3; } - if (sync_var != 0) { + if (sync_var != 0) { NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() Main system not up - is this a dummy subframe?\n", __FUNCTION__); return -4; } int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); int sf = NFAPI_SFNSF2SF(req->sfn_sf); - struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; L1_rxtx_proc_t *proc = &eNB->proc.L1_proc; - nfapi_dl_config_request_pdu_t* dl_config_pdu_list = req->dl_config_request_body.dl_config_pdu_list; + nfapi_dl_config_request_pdu_t *dl_config_pdu_list = req->dl_config_request_body.dl_config_pdu_list; LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[sf&1]; - pdcch_vars->num_pdcch_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; pdcch_vars->num_dci = 0; - if (req->dl_config_request_body.number_dci || + if (req->dl_config_request_body.number_dci || req->dl_config_request_body.number_pdu || req->dl_config_request_body.number_pdsch_rnti) - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d sfn_sf:%d pdcch:%u dl_cfg[dci:%u pdus:%d pdsch_rnti:%d] pcfich:%u\n", - __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, - NFAPI_SFNSF2DEC(req->sfn_sf), - req->dl_config_request_body.number_pdcch_ofdm_symbols, - req->dl_config_request_body.number_dci, - req->dl_config_request_body.number_pdu, - req->dl_config_request_body.number_pdsch_rnti, - req->dl_config_request_body.transmission_power_pcfich); - - for (int i=0;i<req->dl_config_request_body.number_pdu;i++) { - + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d sfn_sf:%d pdcch:%u dl_cfg[dci:%u pdus:%d pdsch_rnti:%d] pcfich:%u\n", + __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, + NFAPI_SFNSF2DEC(req->sfn_sf), + req->dl_config_request_body.number_pdcch_ofdm_symbols, + req->dl_config_request_body.number_dci, + req->dl_config_request_body.number_pdu, + req->dl_config_request_body.number_pdsch_rnti, + req->dl_config_request_body.transmission_power_pcfich); + + for (int i=0; i<req->dl_config_request_body.number_pdu; i++) { NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d pdcch_vars->num_dci:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size,pdcch_vars->num_dci); if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) { - handle_nfapi_dci_dl_pdu(eNB,NFAPI_SFNSF2SFN(req->sfn_sf),NFAPI_SFNSF2SF(req->sfn_sf),proc,&dl_config_pdu_list[i]); - pdcch_vars->num_dci++; // Is actually number of DCI PDUs - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() pdcch_vars->num_dci:%d\n", __FUNCTION__, pdcch_vars->num_dci); - } else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) { - nfapi_dl_config_bch_pdu *bch_pdu = &dl_config_pdu_list[i].bch_pdu; uint16_t pdu_index = bch_pdu->bch_pdu_rel8.pdu_index; if (tx_request_pdu[sfn][sf][pdu_index] != NULL) { - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PDU:%d BCH: pdu_index:%u pdu_length:%d sdu_length:%d BCH_SDU:%x,%x,%x\n", __FUNCTION__, i, pdu_index, bch_pdu->bch_pdu_rel8.length, tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_length, sdu[0], sdu[1], sdu[2]); - handle_nfapi_bch_pdu(eNB, proc, &dl_config_pdu_list[i], tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_data); - eNB->pbch_configured=1; - } else { - - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() BCH NULL TX PDU SFN/SF:%d PDU_INDEX:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pdu_index); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() BCH NULL TX PDU SFN/SF:%d PDU_INDEX:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pdu_index); } } else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { - nfapi_dl_config_dlsch_pdu *dlsch_pdu = &dl_config_pdu_list[i].dlsch_pdu; nfapi_dl_config_dlsch_pdu_rel8_t *rel8_pdu = &dlsch_pdu->dlsch_pdu_rel8; nfapi_tx_request_pdu_t *tx_pdu = tx_request_pdu[sfn][sf][rel8_pdu->pdu_index]; @@ -859,23 +787,19 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request LTE_eNB_DLSCH_t *dlsch0 = eNB->dlsch[UE_id][0]; //LTE_eNB_DLSCH_t *dlsch1 = eNB->dlsch[UE_id][1]; int harq_pid = dlsch0->harq_ids[sfn%2][sf]; + if(harq_pid >= dlsch0->Mdlharq) { LOG_E(PHY,"pnf_phy_dl_config_req illegal harq_pid %d\n", harq_pid); return(-1); } + uint8_t *dlsch_sdu = tx_pdus[UE_id][harq_pid]; - memcpy(dlsch_sdu, tx_pdu->segments[0].segment_data, tx_pdu->segments[0].segment_length); - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() DLSCH:pdu_index:%d handle_nfapi_dlsch_pdu(eNB, proc_rxtx, dlsch_pdu, transport_blocks:%d sdu:%p) eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols:%d\n", __FUNCTION__, rel8_pdu->pdu_index, rel8_pdu->transport_blocks, dlsch_sdu, eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols); - handle_nfapi_dlsch_pdu( eNB, sfn,sf, &eNB->proc.L1_proc, &dl_config_pdu_list[i], rel8_pdu->transport_blocks-1, dlsch_sdu); - } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() DLSCH NULL TX PDU SFN/SF:%d PDU_INDEX:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), rel8_pdu->pdu_index); } - } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_config_pdu_list[i].pdu_type); } @@ -887,8 +811,7 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request return 0; } -int pnf_phy_tx_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) { - +int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { uint16_t sfn = NFAPI_SFNSF2SFN(req->sfn_sf); uint16_t sf = NFAPI_SFNSF2SF(req->sfn_sf); @@ -898,15 +821,14 @@ int pnf_phy_tx_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) { if (req->tx_request_body.tl.tag==NFAPI_TX_REQUEST_BODY_TAG) { for (int i=0; i<req->tx_request_body.number_of_pdus; i++) { LOG_D(PHY,"%s() SFN/SF:%d%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n", - __FUNCTION__, - sfn, sf, - req->tx_request_body.number_of_pdus, - i, - req->tx_request_body.tx_pdu_list[i].pdu_length, - req->tx_request_body.tx_pdu_list[i].pdu_index, - req->tx_request_body.tx_pdu_list[i].num_segments - ); - + __FUNCTION__, + sfn, sf, + req->tx_request_body.number_of_pdus, + i, + req->tx_request_body.tx_pdu_list[i].pdu_length, + req->tx_request_body.tx_pdu_list[i].pdu_index, + req->tx_request_body.tx_pdu_list[i].num_segments + ); tx_request_pdu[sfn][sf][i] = &req->tx_request_body.tx_pdu_list[i]; } } @@ -914,15 +836,14 @@ int pnf_phy_tx_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) { return 0; } -int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) { - - if (0)LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n", - __FUNCTION__, - NFAPI_SFNSF2DEC(req->sfn_sf), - req->ul_config_request_body.number_of_pdus, - req->ul_config_request_body.rach_prach_frequency_resources, - req->ul_config_request_body.srs_present - ); +int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) { + if (0)LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n", + __FUNCTION__, + NFAPI_SFNSF2DEC(req->sfn_sf), + req->ul_config_request_body.number_of_pdus, + req->ul_config_request_body.rach_prach_frequency_resources, + req->ul_config_request_body.srs_present + ); if (RC.ru == 0) { return -1; @@ -936,32 +857,29 @@ int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request return -3; } - if (sync_var != 0) { + if (sync_var != 0) { NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() Main system not up - is this a dummy subframe?\n", __FUNCTION__); return -4; } uint16_t curr_sfn = NFAPI_SFNSF2SFN(req->sfn_sf); uint16_t curr_sf = NFAPI_SFNSF2SF(req->sfn_sf); - struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; L1_rxtx_proc_t *proc = &eNB->proc.L1_proc; - nfapi_ul_config_request_pdu_t* ul_config_pdu_list = req->ul_config_request_body.ul_config_pdu_list; + nfapi_ul_config_request_pdu_t *ul_config_pdu_list = req->ul_config_request_body.ul_config_pdu_list; - for (int i=0;i<req->ul_config_request_body.number_of_pdus;i++) { + for (int i=0; i<req->ul_config_request_body.number_of_pdus; i++) { //LOG_D(PHY, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, ul_config_pdu_list[i].pdu_size); - if ( - ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE || - ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE || - ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE || - ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE || - ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE || - ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE || - ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE - ) { + ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE || + ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE || + ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE || + ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE || + ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE || + ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE || + ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE + ) { //LOG_D(PHY, "%s() handle_nfapi_ul_pdu() for PDU:%d\n", __FUNCTION__, i); - handle_nfapi_ul_pdu(eNB,proc,&ul_config_pdu_list[i],curr_sfn,curr_sf,req->ul_config_request_body.srs_present); } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", __FUNCTION__, i, ul_config_pdu_list[i].pdu_type); @@ -971,54 +889,59 @@ int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request return 0; } -int pnf_phy_lbt_dl_config_req(nfapi_pnf_p7_config_t* config, nfapi_lbt_dl_config_request_t* req) { +int pnf_phy_lbt_dl_config_req(nfapi_pnf_p7_config_t *config, nfapi_lbt_dl_config_request_t *req) { //printf("[PNF] lbt dl config request\n"); return 0; } -int pnf_phy_vendor_ext(nfapi_pnf_p7_config_t* config, nfapi_p7_message_header_t* msg) { +int pnf_phy_vendor_ext(nfapi_pnf_p7_config_t *config, nfapi_p7_message_header_t *msg) { if(msg->message_id == P7_VENDOR_EXT_REQ) { //vendor_ext_p7_req* req = (vendor_ext_p7_req*)msg; //printf("[PNF] vendor request (1:%d 2:%d)\n", req->dummy1, req->dummy2); } else { printf("[PNF] unknown vendor ext\n"); } + return 0; } -int pnf_phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* codex) { +int pnf_phy_pack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *codex) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); if(header->message_id == P7_VENDOR_EXT_IND) { - vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)(header); + vendor_ext_p7_ind *ind = (vendor_ext_p7_ind *)(header); + if(!push16(ind->error_code, ppWritePackedMsg, end)) return 0; return 1; } + return -1; } -int pnf_phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t* codec) { +int pnf_phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t *codec) { if(header->message_id == P7_VENDOR_EXT_REQ) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); - vendor_ext_p7_req* req = (vendor_ext_p7_req*)(header); + vendor_ext_p7_req *req = (vendor_ext_p7_req *)(header); + if(!(pull16(ppReadPackedMessage, &req->dummy1, end) && - pull16(ppReadPackedMessage, &req->dummy2, end))) + pull16(ppReadPackedMessage, &req->dummy2, end))) return 0; + return 1; } + return -1; } -int pnf_phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t* end, void** ve, nfapi_p7_codec_config_t* config) { +int pnf_phy_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p7_codec_config_t *config) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "pnf_phy_unpack_vendor_extension_tlv\n"); - - switch(tl->tag) - { + switch(tl->tag) { case VENDOR_EXT_TLV_1_TAG: *ve = malloc(sizeof(vendor_ext_tlv_1)); - if(!pull32(ppReadPackedMessage, &((vendor_ext_tlv_1*)(*ve))->dummy, end)) - return 0; + + if(!pull32(ppReadPackedMessage, &((vendor_ext_tlv_1 *)(*ve))->dummy, end)) + return 0; return 1; break; @@ -1027,22 +950,21 @@ int pnf_phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMe return -1; } -int pnf_phy_pack_vendor_extention_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p7_codec_config_t* config) { +int pnf_phy_pack_vendor_extention_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) { //printf("%s\n", __FUNCTION__); (void)ve; (void)ppWritePackedMsg; return -1; } -int pnf_sim_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* config) { +int pnf_sim_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p4_p5_codec_config_t *config) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "pnf_sim_unpack_vendor_extension_tlv\n"); - - switch(tl->tag) - { + switch(tl->tag) { case VENDOR_EXT_TLV_2_TAG: *ve = malloc(sizeof(vendor_ext_tlv_2)); - if(!pull32(ppReadPackedMessage, &((vendor_ext_tlv_2*)(*ve))->dummy, end)) - return 0; + + if(!pull32(ppReadPackedMessage, &((vendor_ext_tlv_2 *)(*ve))->dummy, end)) + return 0; return 1; break; @@ -1051,7 +973,7 @@ int pnf_sim_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMe return -1; } -int pnf_sim_pack_vendor_extention_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) { +int pnf_sim_pack_vendor_extention_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { //printf("%s\n", __FUNCTION__); (void)ve; (void)ppWritePackedMsg; @@ -1063,41 +985,29 @@ nfapi_tx_request_t dummy_tx_req; nfapi_pnf_p7_subframe_buffer_t dummy_subframe; -int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_start_request_t* req) { - +int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_start_request_t *req) { printf("[PNF] Received NFAPI_START_REQ phy_id:%d\n", req->header.phy_id); - nfapi_set_trace_level(NFAPI_TRACE_INFO); - - pnf_info* pnf = (pnf_info*)(config->user_data); - - phy_info* phy_info = pnf->phys; - - nfapi_pnf_p7_config_t* p7_config = nfapi_pnf_p7_config_create(); - + pnf_info *pnf = (pnf_info *)(config->user_data); + phy_info *phy_info = pnf->phys; + nfapi_pnf_p7_config_t *p7_config = nfapi_pnf_p7_config_create(); p7_config->phy_id = phy->phy_id; - p7_config->remote_p7_port = phy_info->remote_port; p7_config->remote_p7_addr = phy_info->remote_addr; p7_config->local_p7_port = 32123; // DJP - good grief cannot seem to get the right answer phy_info->local_port; //DJP p7_config->local_p7_addr = (char*)phy_info->local_addr.c_str(); p7_config->local_p7_addr = phy_info->local_addr; - printf("[PNF] P7 remote:%s:%d local:%s:%d\n", p7_config->remote_p7_addr, p7_config->remote_p7_port, p7_config->local_p7_addr, p7_config->local_p7_port); - p7_config->user_data = phy_info; - p7_config->malloc = &pnf_allocate; p7_config->free = &pnf_deallocate; p7_config->codec_config.allocate = &pnf_allocate; p7_config->codec_config.deallocate = &pnf_deallocate; - p7_config->trace = &pnf_nfapi_trace; - phy->user_data = p7_config; - p7_config->subframe_buffer_size = phy_info->timing_window; printf("subframe_buffer_size configured using phy_info->timing_window:%d\n", phy_info->timing_window); + if(phy_info->timing_info_mode & 0x1) { p7_config->timing_info_mode_periodic = 1; p7_config->timing_info_period = phy_info->timing_info_period; @@ -1113,107 +1023,89 @@ int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi p7_config->tx_req = &pnf_phy_tx_req; p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; - if (nfapi_mode==3) { - p7_config->dl_config_req = &memcpy_dl_config_req; - p7_config->ul_config_req = &memcpy_ul_config_req; - p7_config->hi_dci0_req = &memcpy_hi_dci0_req; - p7_config->tx_req = &memcpy_tx_req; - } - else { - p7_config->dl_config_req = &pnf_phy_dl_config_req; - p7_config->ul_config_req = &pnf_phy_ul_config_req; - p7_config->hi_dci0_req = &pnf_phy_hi_dci0_req; - p7_config->tx_req = &pnf_phy_tx_req; - } - p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; - - memset(&dummy_dl_config_req, 0, sizeof(dummy_dl_config_req)); - dummy_dl_config_req.dl_config_request_body.tl.tag=NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - dummy_dl_config_req.dl_config_request_body.number_pdcch_ofdm_symbols=1; - dummy_dl_config_req.dl_config_request_body.number_dci=0; - dummy_dl_config_req.dl_config_request_body.number_pdu=0; - dummy_dl_config_req.dl_config_request_body.number_pdsch_rnti=0; - dummy_dl_config_req.dl_config_request_body.transmission_power_pcfich=6000; - dummy_dl_config_req.dl_config_request_body.dl_config_pdu_list=0; - - memset(&dummy_tx_req, 0, sizeof(dummy_tx_req)); - dummy_tx_req.tx_request_body.number_of_pdus=0; - dummy_tx_req.tx_request_body.tl.tag=NFAPI_TX_REQUEST_BODY_TAG; - - dummy_subframe.dl_config_req = &dummy_dl_config_req; - dummy_subframe.tx_req = 0;//&dummy_tx_req; - - dummy_subframe.ul_config_req=0; - dummy_subframe.hi_dci0_req=0; - dummy_subframe.lbt_dl_config_req=0; - - p7_config->dummy_subframe = dummy_subframe; - - p7_config->vendor_ext = &pnf_phy_vendor_ext; - - p7_config->allocate_p7_vendor_ext = &pnf_phy_allocate_p7_vendor_ext; - p7_config->deallocate_p7_vendor_ext = &pnf_phy_deallocate_p7_vendor_ext; - - p7_config->codec_config.unpack_p7_vendor_extension = &pnf_phy_unpack_p7_vendor_extension; - p7_config->codec_config.pack_p7_vendor_extension = &pnf_phy_pack_p7_vendor_extension; - p7_config->codec_config.unpack_vendor_extension_tlv = &pnf_phy_unpack_vendor_extension_tlv; - p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv; - - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__); - pthread_t p7_thread; - pthread_create(&p7_thread, NULL, &pnf_p7_thread_start, p7_config); - - //((pnf_phy_user_data_t*)(phy_info->fapi->user_data))->p7_config = p7_config; - - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__); - l1_north_init_eNB(); - - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] DJP - HACK - Set p7_config global ready for subframe ind%s\n", __FUNCTION__); - p7_config_g = p7_config; - - // Need to wait for main thread to create RU structures - while(config_sync_var<0) - { - usleep(5000000); - printf("[PNF] waiting for OAI to be configured (eNB/RU)\n"); - } - printf("[PNF] OAI eNB/RU configured\n"); - - //printf("[PNF] About to call phy_init_RU() for RC.ru[0]:%p\n", RC.ru[0]); - //phy_init_RU(RC.ru[0]); - - printf("[PNF] About to call init_eNB_afterRU()\n"); - - if (nfapi_mode != 3) { - init_eNB_afterRU(); - } - - // Signal to main thread that it can carry on - otherwise RU will startup too quickly and it is not initialised - { - pthread_mutex_lock(&nfapi_sync_mutex); - nfapi_sync_var=0; - pthread_cond_broadcast(&nfapi_sync_cond); - pthread_mutex_unlock(&nfapi_sync_mutex); - } - - while(sync_var<0) - { - usleep(5000000); - printf("[PNF] waiting for OAI to be started\n"); - } + if (nfapi_mode==3) { + p7_config->dl_config_req = &memcpy_dl_config_req; + p7_config->ul_config_req = &memcpy_ul_config_req; + p7_config->hi_dci0_req = &memcpy_hi_dci0_req; + p7_config->tx_req = &memcpy_tx_req; + } else { + p7_config->dl_config_req = &pnf_phy_dl_config_req; + p7_config->ul_config_req = &pnf_phy_ul_config_req; + p7_config->hi_dci0_req = &pnf_phy_hi_dci0_req; + p7_config->tx_req = &pnf_phy_tx_req; + } - printf("[PNF] Sending PNF_START_RESP\n"); - nfapi_send_pnf_start_resp(config, p7_config->phy_id); + p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; + memset(&dummy_dl_config_req, 0, sizeof(dummy_dl_config_req)); + dummy_dl_config_req.dl_config_request_body.tl.tag=NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + dummy_dl_config_req.dl_config_request_body.number_pdcch_ofdm_symbols=1; + dummy_dl_config_req.dl_config_request_body.number_dci=0; + dummy_dl_config_req.dl_config_request_body.number_pdu=0; + dummy_dl_config_req.dl_config_request_body.number_pdsch_rnti=0; + dummy_dl_config_req.dl_config_request_body.transmission_power_pcfich=6000; + dummy_dl_config_req.dl_config_request_body.dl_config_pdu_list=0; + memset(&dummy_tx_req, 0, sizeof(dummy_tx_req)); + dummy_tx_req.tx_request_body.number_of_pdus=0; + dummy_tx_req.tx_request_body.tl.tag=NFAPI_TX_REQUEST_BODY_TAG; + dummy_subframe.dl_config_req = &dummy_dl_config_req; + dummy_subframe.tx_req = 0;//&dummy_tx_req; + dummy_subframe.ul_config_req=0; + dummy_subframe.hi_dci0_req=0; + dummy_subframe.lbt_dl_config_req=0; + p7_config->dummy_subframe = dummy_subframe; + p7_config->vendor_ext = &pnf_phy_vendor_ext; + p7_config->allocate_p7_vendor_ext = &pnf_phy_allocate_p7_vendor_ext; + p7_config->deallocate_p7_vendor_ext = &pnf_phy_deallocate_p7_vendor_ext; + p7_config->codec_config.unpack_p7_vendor_extension = &pnf_phy_unpack_p7_vendor_extension; + p7_config->codec_config.pack_p7_vendor_extension = &pnf_phy_pack_p7_vendor_extension; + p7_config->codec_config.unpack_vendor_extension_tlv = &pnf_phy_unpack_vendor_extension_tlv; + p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv; + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__); + pthread_t p7_thread; + pthread_create(&p7_thread, NULL, &pnf_p7_thread_start, p7_config); + //((pnf_phy_user_data_t*)(phy_info->fapi->user_data))->p7_config = p7_config; + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__); + l1_north_init_eNB(); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] DJP - HACK - Set p7_config global ready for subframe ind%s\n", __FUNCTION__); + p7_config_g = p7_config; + + // Need to wait for main thread to create RU structures + while(config_sync_var<0) { + usleep(5000000); + printf("[PNF] waiting for OAI to be configured (eNB/RU)\n"); + } + + printf("[PNF] OAI eNB/RU configured\n"); + //printf("[PNF] About to call phy_init_RU() for RC.ru[0]:%p\n", RC.ru[0]); + //phy_init_RU(RC.ru[0]); + printf("[PNF] About to call init_eNB_afterRU()\n"); + + if (nfapi_mode != 3) { + init_eNB_afterRU(); + } + + // Signal to main thread that it can carry on - otherwise RU will startup too quickly and it is not initialised + { + pthread_mutex_lock(&nfapi_sync_mutex); + nfapi_sync_var=0; + pthread_cond_broadcast(&nfapi_sync_cond); + pthread_mutex_unlock(&nfapi_sync_mutex); + } - printf("[PNF] Sending first P7 subframe ind\n"); - nfapi_pnf_p7_subframe_ind(p7_config, p7_config->phy_id, 0); // DJP - SFN_SF set to zero - correct??? - printf("[PNF] Sent first P7 subframe ind\n"); + while(sync_var<0) { + usleep(5000000); + printf("[PNF] waiting for OAI to be started\n"); + } + printf("[PNF] Sending PNF_START_RESP\n"); + nfapi_send_pnf_start_resp(config, p7_config->phy_id); + printf("[PNF] Sending first P7 subframe ind\n"); + nfapi_pnf_p7_subframe_ind(p7_config, p7_config->phy_id, 0); // DJP - SFN_SF set to zero - correct??? + printf("[PNF] Sent first P7 subframe ind\n"); return 0; } -int measurement_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_measurement_request_t* req) { - +int measurement_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_measurement_request_t *req) { nfapi_measurement_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_MEASUREMENT_RESPONSE; @@ -1223,15 +1115,13 @@ int measurement_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, return 0; } -int rssi_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_rssi_request_t* req) { - +int rssi_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_rssi_request_t *req) { nfapi_rssi_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_RSSI_RESPONSE; resp.header.phy_id = req->header.phy_id; resp.error_code = NFAPI_P4_MSG_OK; nfapi_pnf_rssi_resp(config, &resp); - nfapi_rssi_indication_t ind; memset(&ind, 0, sizeof(ind)); ind.header.message_id = NFAPI_RSSI_INDICATION; @@ -1241,19 +1131,16 @@ int rssi_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_ ind.rssi_indication_body.number_of_rssi = 1; ind.rssi_indication_body.rssi[0] = -42; nfapi_pnf_rssi_ind(config, &ind); - return 0; } -int cell_search_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_cell_search_request_t* req) { - +int cell_search_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_cell_search_request_t *req) { nfapi_cell_search_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_CELL_SEARCH_RESPONSE; resp.header.phy_id = req->header.phy_id; resp.error_code = NFAPI_P4_MSG_OK; nfapi_pnf_cell_search_resp(config, &resp); - nfapi_cell_search_indication_t ind; memset(&ind, 0, sizeof(ind)); ind.header.message_id = NFAPI_CELL_SEARCH_INDICATION; @@ -1269,160 +1156,135 @@ int cell_search_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, ind.lte_cell_search_indication.lte_found_cells[0].rsrq = 123; ind.lte_cell_search_indication.lte_found_cells[0].frequency_offset = 123; break; - case NFAPI_RAT_TYPE_UTRAN: - { - ind.utran_cell_search_indication.tl.tag = NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG; - ind.utran_cell_search_indication.number_of_utran_cells_found = 1; - ind.utran_cell_search_indication.utran_found_cells[0].psc = 89; - ind.utran_cell_search_indication.utran_found_cells[0].rscp = 89; - ind.utran_cell_search_indication.utran_found_cells[0].ecno = 89; - ind.utran_cell_search_indication.utran_found_cells[0].frequency_offset = -89; - } - break; - case NFAPI_RAT_TYPE_GERAN: - { - ind.geran_cell_search_indication.tl.tag = NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG; - ind.geran_cell_search_indication.number_of_gsm_cells_found = 1; - ind.geran_cell_search_indication.gsm_found_cells[0].bsic = 23; - ind.geran_cell_search_indication.gsm_found_cells[0].rxlev = 23; - ind.geran_cell_search_indication.gsm_found_cells[0].rxqual = 23; - ind.geran_cell_search_indication.gsm_found_cells[0].frequency_offset = -23; - ind.geran_cell_search_indication.gsm_found_cells[0].sfn_offset = 230; - - } - break; + case NFAPI_RAT_TYPE_UTRAN: { + ind.utran_cell_search_indication.tl.tag = NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG; + ind.utran_cell_search_indication.number_of_utran_cells_found = 1; + ind.utran_cell_search_indication.utran_found_cells[0].psc = 89; + ind.utran_cell_search_indication.utran_found_cells[0].rscp = 89; + ind.utran_cell_search_indication.utran_found_cells[0].ecno = 89; + ind.utran_cell_search_indication.utran_found_cells[0].frequency_offset = -89; + } + break; + + case NFAPI_RAT_TYPE_GERAN: { + ind.geran_cell_search_indication.tl.tag = NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG; + ind.geran_cell_search_indication.number_of_gsm_cells_found = 1; + ind.geran_cell_search_indication.gsm_found_cells[0].bsic = 23; + ind.geran_cell_search_indication.gsm_found_cells[0].rxlev = 23; + ind.geran_cell_search_indication.gsm_found_cells[0].rxqual = 23; + ind.geran_cell_search_indication.gsm_found_cells[0].frequency_offset = -23; + ind.geran_cell_search_indication.gsm_found_cells[0].sfn_offset = 230; + } + break; } ind.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; ind.pnf_cell_search_state.length = 3; - - nfapi_pnf_cell_search_ind(config, &ind); - + nfapi_pnf_cell_search_ind(config, &ind); return 0; } -int broadcast_detect_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_broadcast_detect_request_t* req) -{ +int broadcast_detect_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_broadcast_detect_request_t *req) { nfapi_broadcast_detect_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_BROADCAST_DETECT_RESPONSE; resp.header.phy_id = req->header.phy_id; resp.error_code = NFAPI_P4_MSG_OK; nfapi_pnf_broadcast_detect_resp(config, &resp); - nfapi_broadcast_detect_indication_t ind; memset(&ind, 0, sizeof(ind)); ind.header.message_id = NFAPI_BROADCAST_DETECT_INDICATION; ind.header.phy_id = req->header.phy_id; ind.error_code = NFAPI_P4_MSG_OK; - switch(req->rat_type) - { - case NFAPI_RAT_TYPE_LTE: - { - ind.lte_broadcast_detect_indication.tl.tag = NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG; - ind.lte_broadcast_detect_indication.number_of_tx_antenna = 1; - ind.lte_broadcast_detect_indication.mib_length = 4; - //ind.lte_broadcast_detect_indication.mib... - ind.lte_broadcast_detect_indication.sfn_offset = 77; - - } - break; - case NFAPI_RAT_TYPE_UTRAN: - { - ind.utran_broadcast_detect_indication.tl.tag = NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG; - ind.utran_broadcast_detect_indication.mib_length = 4; - //ind.utran_broadcast_detect_indication.mib... - // ind.utran_broadcast_detect_indication.sfn_offset; DJP - nonsense line + switch(req->rat_type) { + case NFAPI_RAT_TYPE_LTE: { + ind.lte_broadcast_detect_indication.tl.tag = NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG; + ind.lte_broadcast_detect_indication.number_of_tx_antenna = 1; + ind.lte_broadcast_detect_indication.mib_length = 4; + //ind.lte_broadcast_detect_indication.mib... + ind.lte_broadcast_detect_indication.sfn_offset = 77; + } + break; - } - break; + case NFAPI_RAT_TYPE_UTRAN: { + ind.utran_broadcast_detect_indication.tl.tag = NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG; + ind.utran_broadcast_detect_indication.mib_length = 4; + //ind.utran_broadcast_detect_indication.mib... + // ind.utran_broadcast_detect_indication.sfn_offset; DJP - nonsense line + } + break; } ind.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG; ind.pnf_cell_broadcast_state.length = 3; - - nfapi_pnf_broadcast_detect_ind(config, &ind); - + nfapi_pnf_broadcast_detect_ind(config, &ind); return 0; } -int system_information_schedule_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_system_information_schedule_request_t* req) -{ +int system_information_schedule_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_system_information_schedule_request_t *req) { nfapi_system_information_schedule_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE; resp.header.phy_id = req->header.phy_id; resp.error_code = NFAPI_P4_MSG_OK; nfapi_pnf_system_information_schedule_resp(config, &resp); - nfapi_system_information_schedule_indication_t ind; memset(&ind, 0, sizeof(ind)); ind.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION; ind.header.phy_id = req->header.phy_id; ind.error_code = NFAPI_P4_MSG_OK; - ind.lte_system_information_indication.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG; ind.lte_system_information_indication.sib_type = 3; ind.lte_system_information_indication.sib_length = 5; //ind.lte_system_information_indication.sib... - - nfapi_pnf_system_information_schedule_ind(config, &ind); - + nfapi_pnf_system_information_schedule_ind(config, &ind); return 0; } -int system_information_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_system_information_request_t* req) -{ +int system_information_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_system_information_request_t *req) { nfapi_system_information_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_SYSTEM_INFORMATION_RESPONSE; resp.header.phy_id = req->header.phy_id; resp.error_code = NFAPI_P4_MSG_OK; nfapi_pnf_system_information_resp(config, &resp); - nfapi_system_information_indication_t ind; memset(&ind, 0, sizeof(ind)); ind.header.message_id = NFAPI_SYSTEM_INFORMATION_INDICATION; ind.header.phy_id = req->header.phy_id; ind.error_code = NFAPI_P4_MSG_OK; - switch(req->rat_type) - { - case NFAPI_RAT_TYPE_LTE: - { - ind.lte_system_information_indication.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG; - ind.lte_system_information_indication.sib_type = 1; - ind.lte_system_information_indication.sib_length = 3; - //ind.lte_system_information_indication.sib... - } - break; - case NFAPI_RAT_TYPE_UTRAN: - { - ind.utran_system_information_indication.tl.tag = NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG; - ind.utran_system_information_indication.sib_length = 3; - //ind.utran_system_information_indication.sib... + switch(req->rat_type) { + case NFAPI_RAT_TYPE_LTE: { + ind.lte_system_information_indication.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG; + ind.lte_system_information_indication.sib_type = 1; + ind.lte_system_information_indication.sib_length = 3; + //ind.lte_system_information_indication.sib... + } + break; - } - break; - case NFAPI_RAT_TYPE_GERAN: - { - ind.geran_system_information_indication.tl.tag = NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG; - ind.geran_system_information_indication.si_length = 3; - //ind.geran_system_information_indication.si... + case NFAPI_RAT_TYPE_UTRAN: { + ind.utran_system_information_indication.tl.tag = NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG; + ind.utran_system_information_indication.sib_length = 3; + //ind.utran_system_information_indication.sib... + } + break; - } - break; + case NFAPI_RAT_TYPE_GERAN: { + ind.geran_system_information_indication.tl.tag = NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG; + ind.geran_system_information_indication.si_length = 3; + //ind.geran_system_information_indication.si... + } + break; } - nfapi_pnf_system_information_ind(config, &ind); - + nfapi_pnf_system_information_ind(config, &ind); return 0; } -int nmm_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nmm_stop_request_t* req) -{ +int nmm_stop_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi_nmm_stop_request_t *req) { nfapi_nmm_stop_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_NMM_STOP_RESPONSE; @@ -1432,108 +1294,94 @@ int nmm_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nf return 0; } -int vendor_ext(nfapi_pnf_config_t* config, nfapi_p4_p5_message_header_t* msg) -{ +int vendor_ext(nfapi_pnf_config_t *config, nfapi_p4_p5_message_header_t *msg) { NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P5 %s %p\n", __FUNCTION__, msg); - switch(msg->message_id) - { - case P5_VENDOR_EXT_REQ: - { - vendor_ext_p5_req* req = (vendor_ext_p5_req*)msg; - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P5 Vendor Ext Req (%d %d)\n", req->dummy1, req->dummy2); - // send back the P5_VENDOR_EXT_RSP - vendor_ext_p5_rsp rsp; - memset(&rsp, 0, sizeof(rsp)); - rsp.header.message_id = P5_VENDOR_EXT_RSP; - rsp.error_code = NFAPI_MSG_OK; - nfapi_pnf_vendor_extension(config, &rsp.header, sizeof(vendor_ext_p5_rsp)); - } - break; + switch(msg->message_id) { + case P5_VENDOR_EXT_REQ: { + vendor_ext_p5_req *req = (vendor_ext_p5_req *)msg; + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P5 Vendor Ext Req (%d %d)\n", req->dummy1, req->dummy2); + // send back the P5_VENDOR_EXT_RSP + vendor_ext_p5_rsp rsp; + memset(&rsp, 0, sizeof(rsp)); + rsp.header.message_id = P5_VENDOR_EXT_RSP; + rsp.error_code = NFAPI_MSG_OK; + nfapi_pnf_vendor_extension(config, &rsp.header, sizeof(vendor_ext_p5_rsp)); + } + break; } return 0; } -nfapi_p4_p5_message_header_t* pnf_sim_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t* msg_size) { - +nfapi_p4_p5_message_header_t *pnf_sim_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t *msg_size) { if(message_id == P5_VENDOR_EXT_REQ) { (*msg_size) = sizeof(vendor_ext_p5_req); - return (nfapi_p4_p5_message_header_t*)malloc(sizeof(vendor_ext_p5_req)); + return (nfapi_p4_p5_message_header_t *)malloc(sizeof(vendor_ext_p5_req)); } return 0; } -void pnf_sim_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t* header) { +void pnf_sim_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t *header) { free(header); } -int pnf_sim_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) { +int pnf_sim_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); if(header->message_id == P5_VENDOR_EXT_RSP) { - vendor_ext_p5_rsp* rsp = (vendor_ext_p5_rsp*)(header); + vendor_ext_p5_rsp *rsp = (vendor_ext_p5_rsp *)(header); return (!push16(rsp->error_code, ppWritePackedMsg, end)); } + return 0; } -int pnf_sim_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) { +int pnf_sim_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); if(header->message_id == P5_VENDOR_EXT_REQ) { - vendor_ext_p5_req* req = (vendor_ext_p5_req*)(header); + vendor_ext_p5_req *req = (vendor_ext_p5_req *)(header); return (!(pull16(ppReadPackedMessage, &req->dummy1, end) && - pull16(ppReadPackedMessage, &req->dummy2, end))); - + pull16(ppReadPackedMessage, &req->dummy2, end))); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s (%d %d)\n", __FUNCTION__, req->dummy1, req->dummy2); } + return 0; } /*------------------------------------------------------------------------------*/ -void* pnf_start_thread(void* ptr) { - +void *pnf_start_thread(void *ptr) { NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] IN PNF NFAPI start thread %s\n", __FUNCTION__); - - nfapi_pnf_config_t *config = (nfapi_pnf_config_t*)ptr; - + nfapi_pnf_config_t *config = (nfapi_pnf_config_t *)ptr; struct sched_param sp; sp.sched_priority = 20; pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp); - nfapi_pnf_start(config); - - return (void*)0; + return (void *)0; } void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) { - printf("%s() PNF\n\n\n\n\n\n", __FUNCTION__); if(nfapi_mode!=3) { - nfapi_mode = 1; // PNF! + nfapi_mode = 1; // PNF! } - nfapi_pnf_config_t* config = nfapi_pnf_config_create(); - + nfapi_pnf_config_t *config = nfapi_pnf_config_create(); config->vnf_ip_addr = vnf_ip_addr; config->vnf_p5_port = vnf_p5_port; - pnf.phys[0].udp.enabled = 1; pnf.phys[0].udp.rx_port = pnf_p7_port; pnf.phys[0].udp.tx_port = vnf_p7_port; strcpy(pnf.phys[0].udp.tx_addr, vnf_ip_addr); - strcpy(pnf.phys[0].local_addr, pnf_ip_addr); - - printf("%s() VNF:%s:%d PNF_PHY[addr:%s UDP:tx_addr:%s:%d rx:%d]\n", - __FUNCTION__, - config->vnf_ip_addr, config->vnf_p5_port, - pnf.phys[0].local_addr, - pnf.phys[0].udp.tx_addr, pnf.phys[0].udp.tx_port, - pnf.phys[0].udp.rx_port); - + printf("%s() VNF:%s:%d PNF_PHY[addr:%s UDP:tx_addr:%s:%d rx:%d]\n", + __FUNCTION__, + config->vnf_ip_addr, config->vnf_p5_port, + pnf.phys[0].local_addr, + pnf.phys[0].udp.tx_addr, pnf.phys[0].udp.tx_port, + pnf.phys[0].udp.rx_port); config->pnf_param_req = &pnf_param_request; config->pnf_config_req = &pnf_config_request; config->pnf_start_req = &pnf_start_request; @@ -1541,7 +1389,6 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, config->param_req = ¶m_request; config->config_req = &config_request; config->start_req = &start_request; - config->measurement_req = &measurement_request; config->rssi_req = &rssi_request; config->cell_search_req = &cell_search_request; @@ -1549,45 +1396,31 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, config->system_information_schedule_req = &system_information_schedule_request; config->system_information_req = &system_information_request; config->nmm_stop_req = &nmm_stop_request; - config->vendor_ext = &vendor_ext; - config->trace = &pnf_nfapi_trace; - config->user_data = &pnf; - // To allow custom vendor extentions to be added to nfapi config->codec_config.unpack_vendor_extension_tlv = &pnf_sim_unpack_vendor_extension_tlv; config->codec_config.pack_vendor_extension_tlv = &pnf_sim_pack_vendor_extention_tlv; - config->allocate_p4_p5_vendor_ext = &pnf_sim_allocate_p4_p5_vendor_ext; config->deallocate_p4_p5_vendor_ext = &pnf_sim_deallocate_p4_p5_vendor_ext; - config->codec_config.unpack_p4_p5_vendor_extension = &pnf_sim_unpack_p4_p5_vendor_extension; config->codec_config.pack_p4_p5_vendor_extension = &pnf_sim_pack_p4_p5_vendor_extension; - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating PNF NFAPI start thread %s\n", __FUNCTION__); pthread_create(&pnf_start_pthread, NULL, &pnf_start_thread, config); - pthread_setname_np(pnf_start_pthread, "NFAPI_PNF"); } void oai_subframe_ind(uint16_t sfn, uint16_t sf) { - //LOG_D(PHY,"%s(sfn:%d, sf:%d)\n", __FUNCTION__, sfn, sf); - //TODO FIXME - HACK - DJP - using a global to bodge it in - + //TODO FIXME - HACK - DJP - using a global to bodge it in if (p7_config_g != NULL && sync_var==0) { - uint16_t sfn_sf_tx = sfn<<4 | sf; - if ((sfn % 100 == 0) && sf==0) - { + if ((sfn % 100 == 0) && sf==0) { struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] %s %d.%d (sfn:%u sf:%u) SFN/SF(TX):%u\n", __FUNCTION__, ts.tv_sec, ts.tv_nsec, sfn, sf, NFAPI_SFNSF2DEC(sfn_sf_tx)); } @@ -1603,21 +1436,15 @@ void oai_subframe_ind(uint16_t sfn, uint16_t sf) { } int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) { - rach_ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! - LOG_D(PHY, "%s() sfn_sf:%d preambles:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(rach_ind->sfn_sf), rach_ind->rach_indication_body.number_of_preambles); - return nfapi_pnf_p7_rach_ind(p7_config_g, rach_ind); } int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind) { - harq_ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! harq_ind->header.message_id = NFAPI_HARQ_INDICATION; - LOG_D(PHY, "%s() sfn_sf:%d number_of_harqs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(harq_ind->sfn_sf), harq_ind->harq_indication_body.number_of_harqs); - int retval = nfapi_pnf_p7_harq_ind(p7_config_g, harq_ind); if (retval != 0) @@ -1627,48 +1454,32 @@ int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind) { } int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind) { - crc_ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! crc_ind->header.message_id = NFAPI_CRC_INDICATION; - //LOG_D(PHY, "%s() sfn_sf:%d number_of_crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(crc_ind->sfn_sf), crc_ind->crc_indication_body.number_of_crcs); - return nfapi_pnf_p7_crc_ind(p7_config_g, crc_ind); } int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *ind) { - ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! ind->header.message_id = NFAPI_RX_CQI_INDICATION; - //LOG_D(PHY, "%s() sfn_sf:%d number_of_cqis:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis); - return nfapi_pnf_p7_cqi_ind(p7_config_g, ind); } int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind) { - ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! ind->header.message_id = NFAPI_RX_ULSCH_INDICATION; - int retval = nfapi_pnf_p7_rx_ind(p7_config_g, ind); - //LOG_D(PHY,"%s() SFN/SF:%d pdus:%d retval:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, retval); - //free(ind.rx_indication_body.rx_pdu_list); - return retval; } int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind) { - ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! - int retval = nfapi_pnf_p7_sr_ind(p7_config_g, ind); - //LOG_D(PHY,"%s() SFN/SF:%d srs:%d retval:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs, retval); - //free(ind.rx_indication_body.rx_pdu_list); - return retval; } diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 2597c9e8deb477d00e0d0fa0fd25aeb4f502ab0c..4823a872a7efd9bc06f078887e0cadc579382c95 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -606,7 +606,7 @@ void vnf_deallocate(void *ptr) { void vnf_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) { va_list args; va_start(args, message); - nfapi_log("FILE>", "FUNC", 999, PHY, nfapitooai_level(nfapi_level), message, args); + VLOG( NFAPI_VNF, nfapitooai_level(nfapi_level), message, args); va_end(args); } diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 230eeac726fb3039ca23bdc88ba3839be4e2c0c4..358a561c21ca9d52e9471c047287546e4591a435 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -39,13 +39,14 @@ #include <fcntl.h> #include <errno.h> #include "platform_constants.h" -#ifdef UE_NAS_USE_TUN + #include <sys/ioctl.h> #include <sys/socket.h> #include <linux/if.h> #include <linux/if_tun.h> #include "openairinterface5g_limits.h" -#endif + +#include "pdcp.h" char nl_rx_buf[NL_MAX_PAYLOAD]; @@ -54,20 +55,16 @@ struct nlmsghdr *nas_nlh_tx = NULL; struct nlmsghdr *nas_nlh_rx = NULL; struct iovec nas_iov_tx; struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; -#ifdef UE_NAS_USE_TUN -int nas_sock_fd[NUMBER_OF_UE_MAX]; -#else -int nas_sock_fd; -#endif + +int nas_sock_fd[MAX_MOBILES_PER_ENB]; + struct msghdr nas_msg_tx; struct msghdr nas_msg_rx; #define GRAAL_NETLINK_ID 31 -#ifdef UE_NAS_USE_TUN -static int tun_alloc(char *dev) -{ +static int tun_alloc(char *dev) { struct ifreq ifr; int fd, err; @@ -77,66 +74,58 @@ static int tun_alloc(char *dev) } memset(&ifr, 0, sizeof(ifr)); - /* Flags: IFF_TUN - TUN device (no Ethernet headers) * IFF_TAP - TAP device * * IFF_NO_PI - Do not provide packet information */ ifr.ifr_flags = IFF_TUN | IFF_NO_PI; + if( *dev ) - strncpy(ifr.ifr_name, dev, IFNAMSIZ); + strncpy(ifr.ifr_name, dev, IFNAMSIZ); - if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){ - close(fd); - return err; + if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) { + close(fd); + return err; } + strcpy(dev, ifr.ifr_name); return fd; } -int netlink_init(void) -{ - int i; +int netlink_init_tun(void) { int ret; - char ifname[64]; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - sprintf(ifname, "oip%d", i+1); + + for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { + sprintf(ifname, "oaitun_ue%d",i+1); nas_sock_fd[i] = tun_alloc(ifname); if (nas_sock_fd[i] == -1) { - printf("[NETLINK] Error opening socket %d (%d:%s)\n",nas_sock_fd[i],errno, strerror(errno)); + printf("[NETLINK] Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); exit(1); } - printf("[NETLINK]Opened socket with fd %d\n",nas_sock_fd[i]); - -#if !defined(PDCP_USE_NETLINK_QUEUES) + printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_fd[i]); ret = fcntl(nas_sock_fd[i],F_SETFL,O_NONBLOCK); if (ret == -1) { printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); -#if defined(LINK_ENB_PDCP_TO_IP_DRIVER) - exit(1); -#endif - } -#endif + if (LINK_ENB_PDCP_TO_IP_DRIVER) { + exit(1); + } + } memset(&nas_src_addr, 0, sizeof(nas_src_addr)); nas_src_addr.nl_family = AF_NETLINK; nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ nas_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(nas_sock_fd[i], (struct sockaddr*)&nas_src_addr, sizeof(nas_src_addr)); - - - + ret = bind(nas_sock_fd[i], (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); nas_dest_addr.nl_family = AF_NETLINK; nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ nas_dest_addr.nl_groups = 0; /* unicast */ - // TX PART nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); @@ -144,7 +133,6 @@ int netlink_init(void) nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */ nas_nlh_tx->nlmsg_flags = 0; - nas_iov_tx.iov_base = (void *)nas_nlh_tx; nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len; memset(&nas_msg_tx,0,sizeof(nas_msg_tx)); @@ -152,61 +140,50 @@ int netlink_init(void) nas_msg_tx.msg_namelen = sizeof(nas_dest_addr); nas_msg_tx.msg_iov = &nas_iov_tx; nas_msg_tx.msg_iovlen = 1; - - // RX PART memset(&nas_msg_rx,0,sizeof(nas_msg_rx)); nas_msg_rx.msg_name = (void *)&nas_src_addr; nas_msg_rx.msg_namelen = sizeof(nas_src_addr); nas_msg_rx.msg_iov = &nas_iov_rx; nas_msg_rx.msg_iovlen = 1; - } + } /* for */ return 1; } -#else /* UE_NAS_USE_TUN */ -int netlink_init(void) -{ +int netlink_init(void) { int ret; + nas_sock_fd[0] = socket(PF_NETLINK, SOCK_RAW,GRAAL_NETLINK_ID); - nas_sock_fd = socket(PF_NETLINK, SOCK_RAW,GRAAL_NETLINK_ID); + if (nas_sock_fd[0] == -1) { + printf("[NETLINK] Error opening socket %d (%d:%s)\n",nas_sock_fd[0],errno, strerror(errno)); - if (nas_sock_fd == -1) { - printf("[NETLINK] Error opening socket %d (%d:%s)\n",nas_sock_fd,errno, strerror(errno)); -#if defined(LINK_ENB_PDCP_TO_IP_DRIVER) - exit(1); -#endif + if (LINK_ENB_PDCP_TO_IP_DRIVER) { + exit(1); + } } - printf("[NETLINK]Opened socket with fd %d\n",nas_sock_fd); - -#if !defined(PDCP_USE_NETLINK_QUEUES) - ret = fcntl(nas_sock_fd,F_SETFL,O_NONBLOCK); + printf("[NETLINK]Opened socket with fd %d\n",nas_sock_fd[0]); + ret = fcntl(nas_sock_fd[0],F_SETFL,O_NONBLOCK); if (ret == -1) { printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); -#if defined(LINK_ENB_PDCP_TO_IP_DRIVER) - exit(1); -#endif - } -#endif + if (LINK_ENB_PDCP_TO_IP_DRIVER) { + exit(1); + } + } memset(&nas_src_addr, 0, sizeof(nas_src_addr)); nas_src_addr.nl_family = AF_NETLINK; nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ nas_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(nas_sock_fd, (struct sockaddr*)&nas_src_addr, sizeof(nas_src_addr)); - - - + ret = bind(nas_sock_fd[0], (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr)); memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); nas_dest_addr.nl_family = AF_NETLINK; nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ nas_dest_addr.nl_groups = 0; /* unicast */ - // TX PART nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); @@ -214,7 +191,6 @@ int netlink_init(void) nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */ nas_nlh_tx->nlmsg_flags = 0; - nas_iov_tx.iov_base = (void *)nas_nlh_tx; nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len; memset(&nas_msg_tx,0,sizeof(nas_msg_tx)); @@ -222,16 +198,12 @@ int netlink_init(void) nas_msg_tx.msg_namelen = sizeof(nas_dest_addr); nas_msg_tx.msg_iov = &nas_iov_tx; nas_msg_tx.msg_iovlen = 1; - - // RX PART memset(&nas_msg_rx,0,sizeof(nas_msg_rx)); nas_msg_rx.msg_name = (void *)&nas_src_addr; nas_msg_rx.msg_namelen = sizeof(nas_src_addr); nas_msg_rx.msg_iov = &nas_iov_rx; nas_msg_rx.msg_iovlen = 1; - - return(nas_sock_fd); + return(nas_sock_fd[0]); } -#endif /* UE_NAS_USE_TUN */ diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index 25b3265757d74b9ff471021211afefc31c7790e0..6d54bfb24cd9d3a2f2c682c93a8001ef54c40fb9 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -34,7 +34,7 @@ #define EMU_PROTO_H_ void init_bypass (void); -void bypass_init ( unsigned int (*tx_handlerP) (unsigned char,char*, unsigned int*, unsigned int*),unsigned int (*rx_handlerP) (unsigned char,char*,unsigned int)); +void bypass_init ( unsigned int (*tx_handlerP) (unsigned char,char *, unsigned int *, unsigned int *),unsigned int (*rx_handlerP) (unsigned char,char *,unsigned int)); int bypass_rx_data(unsigned int frame, unsigned int last_slot, unsigned int next_slot, uint8_t is_master); void bypass_signal_mac_phy(unsigned int frame, unsigned int last_slot, @@ -43,7 +43,7 @@ void bypass_tx_data (emu_transport_info_t Type, unsigned int frame, unsigned int void emulation_tx_rx(void); -unsigned int emul_tx_handler(unsigned char Mode,char *Tx_buffer,unsigned int* Nbytes,unsigned int *Nb_flows); +unsigned int emul_tx_handler(unsigned char Mode,char *Tx_buffer,unsigned int *Nbytes,unsigned int *Nb_flows); unsigned int emul_rx_handler(unsigned char Mode,char *rx_buffer, unsigned int Nbytes); unsigned int emul_rx_data(void); @@ -62,5 +62,6 @@ int multicast_link_read_data_from_sock(uint8_t eNB_flag); void clear_eNB_transport_info(uint8_t); void clear_UE_transport_info(uint8_t); int netlink_init(void); +int netlink_init_tun(void); #endif /* EMU_PROTO_H_ */ diff --git a/openair2/COMMON/nas_messages_def.h b/openair2/COMMON/nas_messages_def.h index 34d6d64a1fbd736c63851658a7dfa7135c7d3976..ee3b97e7a98dd0a085a9f958c212a77cdd55d5fb 100644 --- a/openair2/COMMON/nas_messages_def.h +++ b/openair2/COMMON/nas_messages_def.h @@ -26,7 +26,6 @@ * Author: winckel */ -#if defined(ENABLE_USE_MME) && defined(ENABLE_NAS_UE_LOGGING) //-------------------------------------------------------------------------------------------// // Messages for NAS logging MESSAGE_DEF(NAS_DL_EMM_RAW_MSG, MESSAGE_PRIORITY_MED, nas_raw_msg_t, nas_dl_emm_raw_msg) @@ -46,4 +45,4 @@ MESSAGE_DEF(NAS_DL_ESM_PROTECTED_MSG, MESSAGE_PRIORITY_MED, nas_esm_ MESSAGE_DEF(NAS_UL_ESM_PROTECTED_MSG, MESSAGE_PRIORITY_MED, nas_esm_protected_msg_t, nas_ul_esm_protected_msg) //-------------------------------------------------------------------------------------------// -#endif /* ENABLE_USE_MME */ + diff --git a/openair2/COMMON/nas_messages_types.h b/openair2/COMMON/nas_messages_types.h index 5cb1927aca782c5dc1a1f5eff27e7b86d6171c27..8f0e54f85c5c4e4d132ef9eb4e354cfb31393f25 100644 --- a/openair2/COMMON/nas_messages_types.h +++ b/openair2/COMMON/nas_messages_types.h @@ -29,7 +29,7 @@ #ifndef NAS_MESSAGES_TYPES_H_ #define NAS_MESSAGES_TYPES_H_ -# if defined(ENABLE_USE_MME) && defined(ENABLE_NAS_UE_LOGGING) + #include "nas_message.h" @@ -142,5 +142,4 @@ typedef struct nas_esm_protected_msg_s { ESM_msg choice; } nas_esm_protected_msg_t; -# endif /* ENABLE_USE_MME */ #endif /* NAS_MESSAGES_TYPES_H_ */ diff --git a/openair2/ENB_APP/NB_IoT_config.c b/openair2/ENB_APP/NB_IoT_config.c index 272fa48b3e09079df1b4ca8a8533eff3f52dd9d1..26ba8989e17ae258a29d8490c6ad0e956e5cb03b 100644 --- a/openair2/ENB_APP/NB_IoT_config.c +++ b/openair2/ENB_APP/NB_IoT_config.c @@ -33,13 +33,9 @@ #include "log.h" #include "log_extern.h" #include "assertions.h" -#if defined(ENABLE_ITTI) - #include "intertask_interface.h" - #if defined(ENABLE_USE_MME) - #include "s1ap_eNB.h" - #include "sctp_eNB_task.h" - #endif -#endif +#include "intertask_interface.h" +#include "s1ap_eNB.h" +#include "sctp_eNB_task.h" #include "SystemInformationBlockType2.h" #include "PHY/phy_extern.h" diff --git a/openair2/ENB_APP/RRC_config_tools.c b/openair2/ENB_APP/RRC_config_tools.c index e778439d3d2420c887bd6605891bb62c06ff78aa..c0cd1b5a6f9e7984adf09c3d9b7a13145e265af2 100644 --- a/openair2/ENB_APP/RRC_config_tools.c +++ b/openair2/ENB_APP/RRC_config_tools.c @@ -24,7 +24,7 @@ ------------------- AUTHOR : Francois TABURET COMPANY : NOKIA BellLabs France - EMAIL : francois.taburet@nokia-bell-labs.com + EMAIL : francois.taburet@nokia-bell-labs.com */ @@ -33,13 +33,9 @@ #include "common/utils/LOG/log.h" #include "assertions.h" -#if defined(ENABLE_ITTI) -# include "intertask_interface.h" -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -# include "sctp_eNB_task.h" -# endif -#endif +#include "intertask_interface.h" +#include "s1ap_eNB.h" +#include "sctp_eNB_task.h" #include "LTE_SystemInformationBlockType2.h" #include "common/config/config_userapi.h" #include "RRC_config_tools.h" @@ -84,8 +80,7 @@ int config_check_band_frequencies( int ind, int16_t band, uint32_t downlink_frequency, int32_t uplink_frequency_offset, - uint32_t frame_type) -{ + uint32_t frame_type) { int errors = 0; if (band > 0) { @@ -94,21 +89,18 @@ int config_check_band_frequencies( int ind, for (band_index = 0; band_index < sizeof (eutra_bands) / sizeof (eutra_bands[0]); band_index++) { if (band == eutra_bands[band_index].band) { uint32_t uplink_frequency = downlink_frequency + uplink_frequency_offset; - AssertError (eutra_bands[band_index].dl_min < downlink_frequency, errors ++, "enb %d downlink frequency %u too low (%u) for band %d!", ind, downlink_frequency, eutra_bands[band_index].dl_min, band); AssertError (downlink_frequency < eutra_bands[band_index].dl_max, errors ++, "enb %d downlink frequency %u too high (%u) for band %d!", ind, downlink_frequency, eutra_bands[band_index].dl_max, band); - AssertError (eutra_bands[band_index].ul_min < uplink_frequency, errors ++, "enb %d uplink frequency %u too low (%u) for band %d!", ind, uplink_frequency, eutra_bands[band_index].ul_min, band); AssertError (uplink_frequency < eutra_bands[band_index].ul_max, errors ++, "enb %d uplink frequency %u too high (%u) for band %d!", ind, uplink_frequency, eutra_bands[band_index].ul_max, band); - AssertError (eutra_bands[band_index].frame_type == frame_type, errors ++, "enb %d invalid frame type (%d/%d) for band %d!", ind, eutra_bands[band_index].frame_type, frame_type, band); @@ -116,7 +108,6 @@ int config_check_band_frequencies( int ind, } } - return errors; } diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 35871b15d266e061ecc819ec1d62dac0bbd69321..8d128c03e22655cdb2031e9372238f4defcb205b 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -37,36 +37,27 @@ #include "common/utils/LOG/log.h" -#if defined(ENABLE_ITTI) # include "intertask_interface.h" -# if defined(ENABLE_USE_MME) # include "s1ap_eNB.h" # include "sctp_eNB_task.h" # include "gtpv1u_eNB_task.h" -/* temporary warning removale while implementing noS1 */ -/* as config option */ -# else -# ifdef EPC_MODE_ENABLED -# undef EPC_MODE_ENABLED -# endif -# define EPC_MODE_ENABLED 0 -# endif + # include "x2ap_eNB.h" # include "x2ap_messages_types.h" # define X2AP_ENB_REGISTER_RETRY_DELAY 10 #include "openair1/PHY/INIT/phy_init.h" extern unsigned char NB_eNB_INST; -#endif + extern RAN_CONTEXT_t RC; -#if defined(ENABLE_ITTI) + /*------------------------------------------------------------------------------*/ -# if defined(ENABLE_USE_MME) + # define ENB_REGISTER_RETRY_DELAY 10 -# endif + #include "targets/RT/USER/lte-softmodem.h" @@ -96,28 +87,21 @@ static void configure_phy(module_id_t enb_id, const Enb_properties_array_t* enb_ */ /*------------------------------------------------------------------------------*/ -static void configure_rrc(uint32_t enb_id) -{ +static void configure_rrc(uint32_t enb_id) { MessageDef *msg_p = NULL; // int CC_id; - msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ); if (RC.rrc[enb_id]) { RCconfig_RRC(msg_p,enb_id, RC.rrc[enb_id]); - - LOG_I(ENB_APP,"Sending configuration message to RRC task\n"); itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); - - } - else AssertFatal(0,"RRC context for eNB %d not allocated\n",enb_id); + } else AssertFatal(0,"RRC context for eNB %d not allocated\n",enb_id); } /*------------------------------------------------------------------------------*/ -# if defined(ENABLE_USE_MME) -static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)//, const Enb_properties_array_t *enb_properties) -{ + +static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end) { //, const Enb_properties_array_t *enb_properties) uint32_t enb_id; MessageDef *msg_p; uint32_t register_enb_pending = 0; @@ -126,43 +110,32 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)//, { /* note: there is an implicit relationship between the data structure and the message name */ msg_p = itti_alloc_new_message (TASK_ENB_APP, S1AP_REGISTER_ENB_REQ); - RCconfig_S1(msg_p, enb_id); if (enb_id == 0) RCconfig_gtpu(); LOG_I(ENB_APP,"default drx %d\n",((S1AP_REGISTER_ENB_REQ(msg_p)).default_drx)); - LOG_I(ENB_APP,"[eNB %d] eNB_app_register for instance %d\n", enb_id, ENB_MODULE_ID_TO_INSTANCE(enb_id)); - itti_send_msg_to_task (TASK_S1AP, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); - register_enb_pending++; } } return register_enb_pending; } -# endif -#endif + /*------------------------------------------------------------------------------*/ -static uint32_t eNB_app_register_x2(uint32_t enb_id_start, uint32_t enb_id_end) -{ +static uint32_t eNB_app_register_x2(uint32_t enb_id_start, uint32_t enb_id_end) { uint32_t enb_id; MessageDef *msg_p; uint32_t register_enb_x2_pending = 0; for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - { - msg_p = itti_alloc_new_message (TASK_ENB_APP, X2AP_REGISTER_ENB_REQ); - RCconfig_X2(msg_p, enb_id); - itti_send_msg_to_task (TASK_X2AP, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); - register_enb_x2_pending++; } } @@ -171,17 +144,13 @@ static uint32_t eNB_app_register_x2(uint32_t enb_id_start, uint32_t enb_id_end) } /*------------------------------------------------------------------------------*/ -void *eNB_app_task(void *args_p) -{ -#if defined(ENABLE_ITTI) - uint32_t enb_nb = RC.nb_inst; +void *eNB_app_task(void *args_p) { + uint32_t enb_nb = RC.nb_inst; uint32_t enb_id_start = 0; uint32_t enb_id_end = enb_id_start + enb_nb; -# if defined(ENABLE_USE_MME) uint32_t register_enb_pending=0; uint32_t registered_enb; long enb_register_retry_timer_id; -# endif uint32_t x2_register_enb_pending; uint32_t x2_registered_enb; long x2_enb_register_retry_timer_id; @@ -191,15 +160,10 @@ void *eNB_app_task(void *args_p) int result; /* for no gcc warnings */ (void)instance; - itti_mark_task_ready (TASK_ENB_APP); - LOG_I(PHY, "%s() Task ready initialise structures\n", __FUNCTION__); - RCconfig_L1(); - RCconfig_macrlc(); - LOG_I(PHY, "%s() RC.nb_L1_inst:%d\n", __FUNCTION__, RC.nb_L1_inst); if (RC.nb_L1_inst>0) AssertFatal(l1_north_init_eNB()==0,"could not initialize L1 north interface\n"); @@ -207,28 +171,22 @@ void *eNB_app_task(void *args_p) AssertFatal (enb_nb <= RC.nb_inst, "Number of eNB is greater than eNB defined in configuration file (%d/%d)!", enb_nb, RC.nb_inst); - LOG_I(ENB_APP,"Allocating eNB_RRC_INST for %d instances\n",RC.nb_inst); - RC.rrc = (eNB_RRC_INST **)malloc(RC.nb_inst*sizeof(eNB_RRC_INST *)); LOG_I(PHY, "%s() RC.nb_inst:%d RC.rrc:%p\n", __FUNCTION__, RC.nb_inst, RC.rrc); for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - RC.rrc[enb_id] = (eNB_RRC_INST*)malloc(sizeof(eNB_RRC_INST)); + RC.rrc[enb_id] = (eNB_RRC_INST *)malloc(sizeof(eNB_RRC_INST)); LOG_I(PHY, "%s() Creating RRC instance RC.rrc[%d]:%p (%d of %d)\n", __FUNCTION__, enb_id, RC.rrc[enb_id], enb_id+1, enb_id_end); memset((void *)RC.rrc[enb_id],0,sizeof(eNB_RRC_INST)); configure_rrc(enb_id); } -# if defined(ENABLE_USE_MME) - /* Try to register each eNB */ + if (EPC_MODE_ENABLED) { + /* Try to register each eNB */ registered_enb = 0; register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p); -#else - /* Start L2L1 task */ - msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE); - itti_send_msg_to_task(TASK_L2L1, INSTANCE_DEFAULT, msg_p); -#endif + } /* Try to register each eNB with each other */ x2_registered_enb = 0; @@ -237,158 +195,146 @@ void *eNB_app_task(void *args_p) do { // Wait for a message itti_receive_msg (TASK_ENB_APP, &msg_p); - instance = ITTI_MSG_INSTANCE (msg_p); switch (ITTI_MSG_ID(msg_p)) { - case TERMINATE_MESSAGE: - LOG_W(ENB_APP, " *** Exiting ENB_APP thread\n"); - itti_exit_task (); - break; - - case MESSAGE_TEST: - LOG_I(ENB_APP, "Received %s\n", ITTI_MSG_NAME(msg_p)); - break; - - case SOFT_RESTART_MESSAGE: - handle_reconfiguration(instance); - break; - - case S1AP_REGISTER_ENB_CNF: -# if defined(ENABLE_USE_MME) - LOG_I(ENB_APP, "[eNB %d] Received %s: associated MME %d\n", instance, ITTI_MSG_NAME (msg_p), - S1AP_REGISTER_ENB_CNF(msg_p).nb_mme); - - DevAssert(register_enb_pending > 0); - register_enb_pending--; - - /* Check if at least eNB is registered with one MME */ - if (S1AP_REGISTER_ENB_CNF(msg_p).nb_mme > 0) { - registered_enb++; - } - - /* Check if all register eNB requests have been processed */ - if (register_enb_pending == 0) { - if (registered_enb == enb_nb) { - /* If all eNB are registered, start L2L1 task */ - MessageDef *msg_init_p; - - msg_init_p = itti_alloc_new_message (TASK_ENB_APP, INITIALIZE_MESSAGE); - itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p); - - } else { - LOG_W(ENB_APP, " %d eNB not associated with a MME, retrying registration in %d seconds ...\n", - enb_nb - registered_enb, ENB_REGISTER_RETRY_DELAY); - - /* Restart the eNB registration process in ENB_REGISTER_RETRY_DELAY seconds */ - if (timer_setup (ENB_REGISTER_RETRY_DELAY, 0, TASK_ENB_APP, INSTANCE_DEFAULT, TIMER_ONE_SHOT, - NULL, &enb_register_retry_timer_id) < 0) { - LOG_E(ENB_APP, " Can not start eNB register retry timer, use \"sleep\" instead!\n"); - - sleep(ENB_REGISTER_RETRY_DELAY); - /* Restart the registration process */ - registered_enb = 0; - register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p); - } - } - } -#endif - break; - - case S1AP_DEREGISTERED_ENB_IND: - if (EPC_MODE_ENABLED) { - LOG_W(ENB_APP, "[eNB %d] Received %s: associated MME %d\n", instance, ITTI_MSG_NAME (msg_p), - S1AP_DEREGISTERED_ENB_IND(msg_p).nb_mme); - - /* TODO handle recovering of registration */ - } - break; - - case TIMER_HAS_EXPIRED: -# if defined(ENABLE_USE_MME) - LOG_I(ENB_APP, " Received %s: timer_id %ld\n", ITTI_MSG_NAME (msg_p), TIMER_HAS_EXPIRED(msg_p).timer_id); - - if (TIMER_HAS_EXPIRED (msg_p).timer_id == enb_register_retry_timer_id) { - /* Restart the registration process */ - registered_enb = 0; - register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p); - } - - if (TIMER_HAS_EXPIRED (msg_p).timer_id == x2_enb_register_retry_timer_id) { - /* Restart the registration process */ - x2_registered_enb = 0; - x2_register_enb_pending = eNB_app_register_x2 (enb_id_start, enb_id_end); - } -# endif - break; - - case X2AP_DEREGISTERED_ENB_IND: - LOG_W(ENB_APP, "[eNB %d] Received %s: associated eNB %d\n", instance, ITTI_MSG_NAME (msg_p), - X2AP_DEREGISTERED_ENB_IND(msg_p).nb_x2); - - /* TODO handle recovering of registration */ - break; - - case X2AP_REGISTER_ENB_CNF: - LOG_I(ENB_APP, "[eNB %d] Received %s: associated eNB %d\n", instance, ITTI_MSG_NAME (msg_p), - X2AP_REGISTER_ENB_CNF(msg_p).nb_x2); - - DevAssert(x2_register_enb_pending > 0); - x2_register_enb_pending--; - - /* Check if at least eNB is registered with one target eNB */ - if (X2AP_REGISTER_ENB_CNF(msg_p).nb_x2 > 0) { - x2_registered_enb++; - } - - /* Check if all register eNB requests have been processed */ - if (x2_register_enb_pending == 0) { - if (x2_registered_enb == enb_nb) { - /* If all eNB are registered, start RRC HO task */ - - }else { - uint32_t x2_not_associated = enb_nb - x2_registered_enb; - - LOG_W(ENB_APP, " %d eNB %s not associated with the target\n", - x2_not_associated, x2_not_associated > 1 ? "are" : "is"); - // timer to retry - /* Restart the eNB registration process in ENB_REGISTER_RETRY_DELAY seconds */ - if (timer_setup (X2AP_ENB_REGISTER_RETRY_DELAY, 0, TASK_ENB_APP, - INSTANCE_DEFAULT, TIMER_ONE_SHOT, NULL, - &x2_enb_register_retry_timer_id) < 0) { - LOG_E(ENB_APP, " Can not start eNB X2AP register: retry timer, use \"sleep\" instead!\n"); - - sleep(X2AP_ENB_REGISTER_RETRY_DELAY); + case TERMINATE_MESSAGE: + LOG_W(ENB_APP, " *** Exiting ENB_APP thread\n"); + itti_exit_task (); + break; + + case MESSAGE_TEST: + LOG_I(ENB_APP, "Received %s\n", ITTI_MSG_NAME(msg_p)); + break; + + case SOFT_RESTART_MESSAGE: + handle_reconfiguration(instance); + break; + + case S1AP_REGISTER_ENB_CNF: + if (EPC_MODE_ENABLED) { + LOG_I(ENB_APP, "[eNB %d] Received %s: associated MME %d\n", instance, ITTI_MSG_NAME (msg_p), + S1AP_REGISTER_ENB_CNF(msg_p).nb_mme); + DevAssert(register_enb_pending > 0); + register_enb_pending--; + + /* Check if at least eNB is registered with one MME */ + if (S1AP_REGISTER_ENB_CNF(msg_p).nb_mme > 0) { + registered_enb++; + } + + /* Check if all register eNB requests have been processed */ + if (register_enb_pending == 0) { + if (registered_enb == enb_nb) { + /* If all eNB are registered, start L2L1 task */ + MessageDef *msg_init_p; + msg_init_p = itti_alloc_new_message (TASK_ENB_APP, INITIALIZE_MESSAGE); + itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p); + } else { + LOG_W(ENB_APP, " %d eNB not associated with a MME, retrying registration in %d seconds ...\n", + enb_nb - registered_enb, ENB_REGISTER_RETRY_DELAY); + + /* Restart the eNB registration process in ENB_REGISTER_RETRY_DELAY seconds */ + if (timer_setup (ENB_REGISTER_RETRY_DELAY, 0, TASK_ENB_APP, INSTANCE_DEFAULT, TIMER_ONE_SHOT, + NULL, &enb_register_retry_timer_id) < 0) { + LOG_E(ENB_APP, " Can not start eNB register retry timer, use \"sleep\" instead!\n"); + sleep(ENB_REGISTER_RETRY_DELAY); + /* Restart the registration process */ + registered_enb = 0; + register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p); + } + } + } + } /* if (EPC_MODE_ENABLED) */ + + break; + + case S1AP_DEREGISTERED_ENB_IND: + if (EPC_MODE_ENABLED) { + LOG_W(ENB_APP, "[eNB %d] Received %s: associated MME %d\n", instance, ITTI_MSG_NAME (msg_p), + S1AP_DEREGISTERED_ENB_IND(msg_p).nb_mme); + /* TODO handle recovering of registration */ + } + + break; + + case TIMER_HAS_EXPIRED: + if (EPC_MODE_ENABLED) { + LOG_I(ENB_APP, " Received %s: timer_id %ld\n", ITTI_MSG_NAME (msg_p), TIMER_HAS_EXPIRED(msg_p).timer_id); + + if (TIMER_HAS_EXPIRED (msg_p).timer_id == enb_register_retry_timer_id) { + /* Restart the registration process */ + registered_enb = 0; + register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);//, enb_properties_p); + } + + if (TIMER_HAS_EXPIRED (msg_p).timer_id == x2_enb_register_retry_timer_id) { /* Restart the registration process */ x2_registered_enb = 0; x2_register_enb_pending = eNB_app_register_x2 (enb_id_start, enb_id_end); } + } /* if (EPC_MODE_ENABLED) */ + + break; + + case X2AP_DEREGISTERED_ENB_IND: + LOG_W(ENB_APP, "[eNB %d] Received %s: associated eNB %d\n", instance, ITTI_MSG_NAME (msg_p), + X2AP_DEREGISTERED_ENB_IND(msg_p).nb_x2); + /* TODO handle recovering of registration */ + break; + + case X2AP_REGISTER_ENB_CNF: + LOG_I(ENB_APP, "[eNB %d] Received %s: associated eNB %d\n", instance, ITTI_MSG_NAME (msg_p), + X2AP_REGISTER_ENB_CNF(msg_p).nb_x2); + DevAssert(x2_register_enb_pending > 0); + x2_register_enb_pending--; + + /* Check if at least eNB is registered with one target eNB */ + if (X2AP_REGISTER_ENB_CNF(msg_p).nb_x2 > 0) { + x2_registered_enb++; } - } - break; + /* Check if all register eNB requests have been processed */ + if (x2_register_enb_pending == 0) { + if (x2_registered_enb == enb_nb) { + /* If all eNB are registered, start RRC HO task */ + } else { + uint32_t x2_not_associated = enb_nb - x2_registered_enb; + LOG_W(ENB_APP, " %d eNB %s not associated with the target\n", + x2_not_associated, x2_not_associated > 1 ? "are" : "is"); + + // timer to retry + /* Restart the eNB registration process in ENB_REGISTER_RETRY_DELAY seconds */ + if (timer_setup (X2AP_ENB_REGISTER_RETRY_DELAY, 0, TASK_ENB_APP, + INSTANCE_DEFAULT, TIMER_ONE_SHOT, NULL, + &x2_enb_register_retry_timer_id) < 0) { + LOG_E(ENB_APP, " Can not start eNB X2AP register: retry timer, use \"sleep\" instead!\n"); + sleep(X2AP_ENB_REGISTER_RETRY_DELAY); + /* Restart the registration process */ + x2_registered_enb = 0; + x2_register_enb_pending = eNB_app_register_x2 (enb_id_start, enb_id_end); + } + } + } - default: - LOG_E(ENB_APP, "Received unexpected message %s\n", ITTI_MSG_NAME (msg_p)); - break; + break; + + default: + LOG_E(ENB_APP, "Received unexpected message %s\n", ITTI_MSG_NAME (msg_p)); + break; } result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); } while (1); -#endif - - return NULL; } -void handle_reconfiguration(module_id_t mod_id) -{ +void handle_reconfiguration(module_id_t mod_id) { struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); flexran_agent_info_t *flexran = RC.flexran[mod_id]; - LOG_I(ENB_APP, "lte-softmodem soft-restart requested\n"); if (ENB_WAIT == flexran->node_ctrl_state) { @@ -411,8 +357,10 @@ void handle_reconfiguration(module_id_t mod_id) LOG_I(ENB_APP, " * eNB %d: Waiting for FlexRAN RTController command *\n", mod_id); pthread_mutex_lock(&flexran->mutex_node_ctrl); flexran->node_ctrl_state = ENB_WAIT; + while (ENB_NORMAL_OPERATION != flexran->node_ctrl_state) pthread_cond_wait(&flexran->cond_node_ctrl, &flexran->mutex_node_ctrl); + pthread_mutex_unlock(&flexran->mutex_node_ctrl); } @@ -424,11 +372,13 @@ void handle_reconfiguration(module_id_t mod_id) clock_gettime(CLOCK_MONOTONIC, &end); end.tv_sec -= start.tv_sec; + if (end.tv_nsec >= start.tv_nsec) { end.tv_nsec -= start.tv_nsec; } else { end.tv_sec -= 1; end.tv_nsec = end.tv_nsec - start.tv_nsec + 1000000000; } + LOG_I(ENB_APP, "lte-softmodem restart succeeded in %ld.%ld s\n", end.tv_sec, end.tv_nsec / 1000000); } diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 5e830af0098d3ac3ee16bd1249a263b47dd03ea8..478f14f07c7a239174b54df7852768a5d21c90c6 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -35,15 +35,9 @@ #include "enb_config.h" #include "UTIL/OTG/otg.h" #include "UTIL/OTG/otg_externs.h" -#if defined(ENABLE_ITTI) - #include "intertask_interface.h" - #if defined(ENABLE_USE_MME) - #include "s1ap_eNB.h" - #include "sctp_eNB_task.h" - #else - #define EPC_MODE_ENABLED 0 - #endif -#endif +#include "intertask_interface.h" +#include "s1ap_eNB.h" +#include "sctp_eNB_task.h" #include "sctp_default_values.h" #include "LTE_SystemInformationBlockType2.h" #include "LAYER2/MAC/mac_extern.h" @@ -82,17 +76,6 @@ void RCconfig_flexran() { int32_t Nid_cell = 0; uint16_t Nid_cell_tr = 0; uint32_t enb_id = 0; - - /* - int32_t srb1_timer_poll_retransmit = 0; - int32_t srb1_timer_reordering = 0; - int32_t srb1_timer_status_prohibit = 0; - int32_t srb1_poll_pdu = 0; - int32_t srb1_poll_byte = 0; - int32_t srb1_max_retx_threshold = 0; - */ - - /* get number of eNBs */ paramdef_t ENBSParams[] = ENBSPARAMS_DESC; config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL); @@ -103,7 +86,7 @@ void RCconfig_flexran() { /* for Nid_cell */ checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK; ccparams_lte_t ccparams_lte; - memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t)); + memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t)); paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte); paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0}; @@ -187,9 +170,9 @@ void RCconfig_flexran() { /* assume for the moment the monolithic case, i.e. agent can provide information for all layers */ RC.flexran[i]->capability_mask = FLEXRAN_CAP_LOPHY | FLEXRAN_CAP_HIPHY - | FLEXRAN_CAP_LOMAC | FLEXRAN_CAP_HIMAC - | FLEXRAN_CAP_RLC | FLEXRAN_CAP_PDCP - | FLEXRAN_CAP_SDAP | FLEXRAN_CAP_RRC; + | FLEXRAN_CAP_LOMAC | FLEXRAN_CAP_HIMAC + | FLEXRAN_CAP_RLC | FLEXRAN_CAP_PDCP + | FLEXRAN_CAP_SDAP | FLEXRAN_CAP_RRC; } } @@ -293,7 +276,6 @@ void RCconfig_macrlc() { mac_top_init_eNB(); RC.nb_mac_CC = (int *)malloc(RC.nb_macrlc_inst*sizeof(int)); - for (j=0; j<RC.nb_macrlc_inst; j++) { RC.mac[j]->puSch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCH10xSNR_IDX ].iptr); RC.mac[j]->puCch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCH10xSNR_IDX ].iptr); @@ -352,7 +334,6 @@ void RCconfig_macrlc() { } int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { - int num_enbs = 0; int j,k = 0; int32_t enb_id = 0; @@ -360,36 +341,27 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { ccparams_lte_t ccparams_lte; ccparams_sidelink_t SLconfig; ccparams_eMTC_t eMTCconfig; - - memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t)); - memset((void*)&SLconfig,0,sizeof(ccparams_sidelink_t)); - memset((void*)&eMTCconfig,0,sizeof(ccparams_eMTC_t)); - - + memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t)); + memset((void *)&SLconfig,0,sizeof(ccparams_sidelink_t)); + memset((void *)&eMTCconfig,0,sizeof(ccparams_eMTC_t)); paramdef_t ENBSParams[] = ENBSPARAMS_DESC; paramdef_t ENBParams[] = ENBPARAMS_DESC; paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0}; checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK; paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte); paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0}; - paramdef_t eMTCParams[] = EMTCPARAMS_DESC((&eMTCconfig)); checkedparam_t config_check_eMTCparams[] = EMTCPARAMS_CHECK; - srb1_params_t srb1_params; - memset((void*)&srb1_params,0,sizeof(srb1_params_t)); + memset((void *)&srb1_params,0,sizeof(srb1_params_t)); paramdef_t SRB1Params[] = SRB1PARAMS_DESC(srb1_params); - - paramdef_t SLParams[] = CCPARAMS_SIDELINK_DESC(SLconfig); - /* map parameter checking array instances to parameter definition array instances */ for (int I=0; I< ( sizeof(CCsParams)/ sizeof(paramdef_t) ) ; I++) { CCsParams[I].chkPptr = &(config_check_CCparams[I]); } - for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) { eMTCParams[I].chkPptr = &(config_check_eMTCparams[I]); } @@ -489,7 +461,6 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath); //printf("Component carrier %d\n",component_carrier); nb_cc++; - RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = ccparams_lte.tdd_config; AssertFatal (ccparams_lte.tdd_config <= LTE_TDD_Config__subframeAssignment_sa6, "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!", @@ -498,6 +469,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { AssertFatal (ccparams_lte.tdd_config_s <= LTE_TDD_Config__specialSubframePatterns_ssp8, "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!", RC.config_file_name, i, ccparams_lte.tdd_config_s, LTE_TDD_Config__specialSubframePatterns_ssp8); + if (!ccparams_lte.prefix_type) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n", @@ -532,8 +504,6 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = ccparams_lte.eutra_band; RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) ccparams_lte.downlink_frequency; RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) ccparams_lte.uplink_frequency_offset; - - RRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= ccparams_lte.Nid_cell; if (ccparams_lte.Nid_cell>503) { @@ -544,12 +514,12 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= ccparams_lte.N_RB_DL; - if ((ccparams_lte.N_RB_DL!=6) && - (ccparams_lte.N_RB_DL!=15) && - (ccparams_lte.N_RB_DL!=25) && - (ccparams_lte.N_RB_DL!=50) && - (ccparams_lte.N_RB_DL!=75) && - (ccparams_lte.N_RB_DL!=100)) { + if ((ccparams_lte.N_RB_DL!=6) && + (ccparams_lte.N_RB_DL!=15) && + (ccparams_lte.N_RB_DL!=25) && + (ccparams_lte.N_RB_DL!=50) && + (ccparams_lte.N_RB_DL!=75) && + (ccparams_lte.N_RB_DL!=100)) { AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n", RC.config_file_name, i, ccparams_lte.N_RB_DL); @@ -573,16 +543,13 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { AssertFatal(0, "error calling enb_check_band_frequencies\n"); } - if ((ccparams_lte.nb_antenna_ports <1) || (ccparams_lte.nb_antenna_ports > 2)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n", RC.config_file_name, i, ccparams_lte.nb_antenna_ports); RRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = ccparams_lte.nb_antenna_ports; - - // Radio Resource Configuration (SIB2) - + // Radio Resource Configuration (SIB2) RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_root = ccparams_lte.prach_root; if ((ccparams_lte.prach_root <0) || (ccparams_lte.prach_root > 1023)) @@ -612,50 +579,49 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_zero_correlation = ccparams_lte.prach_zero_correlation; - if ((ccparams_lte.prach_zero_correlation <0) || - (ccparams_lte.prach_zero_correlation > 15)) + if ((ccparams_lte.prach_zero_correlation <0) || + (ccparams_lte.prach_zero_correlation > 15)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_zero_correlation choice: 0..15!\n", RC.config_file_name, i, ccparams_lte.prach_zero_correlation); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_freq_offset = ccparams_lte.prach_freq_offset; - if ((ccparams_lte.prach_freq_offset <0) || - (ccparams_lte.prach_freq_offset > 94)) + if ((ccparams_lte.prach_freq_offset <0) || + (ccparams_lte.prach_freq_offset > 94)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 0..94!\n", RC.config_file_name, i, ccparams_lte.prach_freq_offset); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_delta_shift = ccparams_lte.pucch_delta_shift-1; - if ((ccparams_lte.pucch_delta_shift <1) || - (ccparams_lte.pucch_delta_shift > 3)) + if ((ccparams_lte.pucch_delta_shift <1) || + (ccparams_lte.pucch_delta_shift > 3)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_delta_shift choice: 1..3!\n", RC.config_file_name, i, ccparams_lte.pucch_delta_shift); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nRB_CQI = ccparams_lte.pucch_nRB_CQI; - if ((ccparams_lte.pucch_nRB_CQI <0) || - (ccparams_lte.pucch_nRB_CQI > 98)) + if ((ccparams_lte.pucch_nRB_CQI <0) || + (ccparams_lte.pucch_nRB_CQI > 98)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nRB_CQI choice: 0..98!\n", RC.config_file_name, i, ccparams_lte.pucch_nRB_CQI); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nCS_AN = ccparams_lte.pucch_nCS_AN; - if ((ccparams_lte.pucch_nCS_AN <0) || - (ccparams_lte.pucch_nCS_AN > 7)) + if ((ccparams_lte.pucch_nCS_AN <0) || + (ccparams_lte.pucch_nCS_AN > 7)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n", RC.config_file_name, i, ccparams_lte.pucch_nCS_AN); - //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_n1_AN = ccparams_lte.pucch_n1_AN; - if ((ccparams_lte.pucch_n1_AN <0) || - (ccparams_lte.pucch_n1_AN > 2047)) + if ((ccparams_lte.pucch_n1_AN <0) || + (ccparams_lte.pucch_n1_AN > 2047)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_n1_AN choice: 0..2047!\n", RC.config_file_name, i, ccparams_lte.pucch_n1_AN); @@ -663,24 +629,24 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { //#endif RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_referenceSignalPower = ccparams_lte.pdsch_referenceSignalPower; - if ((ccparams_lte.pdsch_referenceSignalPower <-60) || - (ccparams_lte.pdsch_referenceSignalPower > 50)) + if ((ccparams_lte.pdsch_referenceSignalPower <-60) || + (ccparams_lte.pdsch_referenceSignalPower > 50)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_referenceSignalPower choice:-60..50!\n", RC.config_file_name, i, ccparams_lte.pdsch_referenceSignalPower); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_p_b = ccparams_lte.pdsch_p_b; - if ((ccparams_lte.pdsch_p_b <0) || - (ccparams_lte.pdsch_p_b > 3)) + if ((ccparams_lte.pdsch_p_b <0) || + (ccparams_lte.pdsch_p_b > 3)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_p_b choice: 0..3!\n", RC.config_file_name, i, ccparams_lte.pdsch_p_b); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_n_SB = ccparams_lte.pusch_n_SB; - if ((ccparams_lte.pusch_n_SB <1) || - (ccparams_lte.pusch_n_SB > 4)) + if ((ccparams_lte.pusch_n_SB <1) || + (ccparams_lte.pusch_n_SB > 4)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_n_SB choice: 1..4!\n", RC.config_file_name, i, ccparams_lte.pusch_n_SB); @@ -689,11 +655,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d define %s: interSubframe,intraAndInterSubframe!\n", RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE); - else if (strcmp(ccparams_lte.pusch_hoppingMode,"interSubFrame")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame; - } - else if (strcmp(ccparams_lte.pusch_hoppingMode,"intraAndInterSubFrame")==0) { + } else if (strcmp(ccparams_lte.pusch_hoppingMode,"intraAndInterSubFrame")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame; } else AssertFatal (0, @@ -702,8 +666,8 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingOffset = ccparams_lte.pusch_hoppingOffset; - if ((ccparams_lte.pusch_hoppingOffset<0) || - (ccparams_lte.pusch_hoppingOffset>98)) + if ((ccparams_lte.pusch_hoppingOffset<0) || + (ccparams_lte.pusch_hoppingOffset>98)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingOffset choice: 0..98!\n", RC.config_file_name, i, ccparams_lte.pusch_hoppingMode); @@ -714,11 +678,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM); else if (strcmp(ccparams_lte.pusch_enable64QAM, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = TRUE; - } - else if (strcmp(ccparams_lte.pusch_enable64QAM, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.pusch_enable64QAM, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = FALSE; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n", RC.config_file_name, i, ccparams_lte.pusch_enable64QAM); @@ -729,11 +691,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN); else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled = TRUE; - } - else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled= FALSE; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n", RC.config_file_name, i, ccparams_lte.pusch_groupHoppingEnabled); @@ -741,7 +701,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupAssignment = ccparams_lte.pusch_groupAssignment; if ((ccparams_lte.pusch_groupAssignment<0)|| - (ccparams_lte.pusch_groupAssignment>29)) + (ccparams_lte.pusch_groupAssignment>29)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_groupAssignment choice: 0..29!\n", RC.config_file_name, i, ccparams_lte.pusch_groupAssignment); @@ -752,8 +712,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN); else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = TRUE; - } - else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = FALSE; } else AssertFatal (0, @@ -762,13 +721,12 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_nDMRS1= ccparams_lte.pusch_nDMRS1; //cyclic_shift in RRC! - if ((ccparams_lte.pusch_nDMRS1 <0) || - (ccparams_lte.pusch_nDMRS1>7)) + if ((ccparams_lte.pusch_nDMRS1 <0) || + (ccparams_lte.pusch_nDMRS1>7)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n", RC.config_file_name, i, ccparams_lte.pusch_nDMRS1); - if (strcmp(ccparams_lte.phich_duration,"NORMAL")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration= LTE_PHICH_Config__phich_Duration_normal; } else if (strcmp(ccparams_lte.phich_duration,"EXTENDED")==0) { @@ -780,17 +738,13 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { if (strcmp(ccparams_lte.phich_resource,"ONESIXTH")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_oneSixth ; - } - else if (strcmp(ccparams_lte.phich_resource,"HALF")==0) { + } else if (strcmp(ccparams_lte.phich_resource,"HALF")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_half; - } - else if (strcmp(ccparams_lte.phich_resource,"ONE")==0) { + } else if (strcmp(ccparams_lte.phich_resource,"ONE")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_one; - } - else if (strcmp(ccparams_lte.phich_resource,"TWO")==0) { + } else if (strcmp(ccparams_lte.phich_resource,"TWO")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_two; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n", RC.config_file_name, i, ccparams_lte.phich_resource); @@ -801,11 +755,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { if (strcmp(ccparams_lte.srs_enable, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= TRUE; - } - else if (strcmp(ccparams_lte.srs_enable, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.srs_enable, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= FALSE; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n", RC.config_file_name, i, ccparams_lte.srs_enable); @@ -813,23 +765,22 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { if (RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable== TRUE) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_BandwidthConfig= ccparams_lte.srs_BandwidthConfig; - if ((ccparams_lte.srs_BandwidthConfig < 0) || - (ccparams_lte.srs_BandwidthConfig >7)) + if ((ccparams_lte.srs_BandwidthConfig < 0) || + (ccparams_lte.srs_BandwidthConfig >7)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value %d for srs_BandwidthConfig choice: 0...7\n", RC.config_file_name, i, ccparams_lte.srs_BandwidthConfig); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_SubframeConfig= ccparams_lte.srs_SubframeConfig; - if ((ccparams_lte.srs_SubframeConfig<0) || - (ccparams_lte.srs_SubframeConfig>15)) + if ((ccparams_lte.srs_SubframeConfig<0) || + (ccparams_lte.srs_SubframeConfig>15)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n", RC.config_file_name, i, ccparams_lte.srs_SubframeConfig); if (strcmp(ccparams_lte.srs_ackNackST, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= TRUE; - } - else if (strcmp(ccparams_lte.srs_ackNackST, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.srs_ackNackST, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= FALSE; } else AssertFatal (0, @@ -838,11 +789,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { if (strcmp(ccparams_lte.srs_MaxUpPts, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= TRUE; - } - else if (strcmp(ccparams_lte.srs_MaxUpPts, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.srs_MaxUpPts, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= FALSE; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n", RC.config_file_name, i, ccparams_lte.srs_MaxUpPts); @@ -850,8 +799,8 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_p0_Nominal= ccparams_lte.pusch_p0_Nominal; - if ((ccparams_lte.pusch_p0_Nominal<-126) || - (ccparams_lte.pusch_p0_Nominal>24)) + if ((ccparams_lte.pusch_p0_Nominal<-126) || + (ccparams_lte.pusch_p0_Nominal>24)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n", RC.config_file_name, i, ccparams_lte.pusch_p0_Nominal); @@ -860,26 +809,19 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al0; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al04; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al05; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al06; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al07; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al08; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al09; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al1; } @@ -888,26 +830,19 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al0; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al04; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al05; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al06; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al07; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al08; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al09; - } - else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al1; } @@ -919,58 +854,49 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_p0_Nominal= ccparams_lte.pucch_p0_Nominal; - if ((ccparams_lte.pucch_p0_Nominal<-127) || - (ccparams_lte.pucch_p0_Nominal>-96)) + if ((ccparams_lte.pucch_p0_Nominal<-127) || + (ccparams_lte.pucch_p0_Nominal>-96)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_p0_Nominal choice: -127..-96 !\n", RC.config_file_name, i, ccparams_lte.pucch_p0_Nominal); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].msg3_delta_Preamble= ccparams_lte.msg3_delta_Preamble; - if ((ccparams_lte.msg3_delta_Preamble<-1) || - (ccparams_lte.msg3_delta_Preamble>6)) + if ((ccparams_lte.msg3_delta_Preamble<-1) || + (ccparams_lte.msg3_delta_Preamble>6)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for msg3_delta_Preamble choice: -1..6 !\n", RC.config_file_name, i, ccparams_lte.msg3_delta_Preamble); if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1); if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF3")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF3")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF5")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF5")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1b); if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF1")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2; } else AssertFatal (0, @@ -979,37 +905,31 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2a); if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0; - } - else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2b); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_numberOfRA_Preambles= (ccparams_lte.rach_numberOfRA_Preambles/4)-1; - if ((ccparams_lte.rach_numberOfRA_Preambles <4) || - (ccparams_lte.rach_numberOfRA_Preambles>64) || - ((ccparams_lte.rach_numberOfRA_Preambles&3)!=0)) + if ((ccparams_lte.rach_numberOfRA_Preambles <4) || + (ccparams_lte.rach_numberOfRA_Preambles>64) || + ((ccparams_lte.rach_numberOfRA_Preambles&3)!=0)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_numberOfRA_Preambles choice: 4,8,12,...,64!\n", RC.config_file_name, i, ccparams_lte.rach_numberOfRA_Preambles); @@ -1018,62 +938,54 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preamblesGroupAConfig= TRUE; RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_sizeOfRA_PreamblesGroupA= (ccparams_lte.rach_sizeOfRA_PreamblesGroupA/4)-1; - if ((ccparams_lte.rach_numberOfRA_Preambles <4) || - (ccparams_lte.rach_numberOfRA_Preambles>60) || - ((ccparams_lte.rach_numberOfRA_Preambles&3)!=0)) + if ((ccparams_lte.rach_numberOfRA_Preambles <4) || + (ccparams_lte.rach_numberOfRA_Preambles>60) || + ((ccparams_lte.rach_numberOfRA_Preambles&3)!=0)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_sizeOfRA_PreamblesGroupA choice: 4,8,12,...,60!\n", RC.config_file_name, i, ccparams_lte.rach_sizeOfRA_PreamblesGroupA); switch (ccparams_lte.rach_messageSizeGroupA) { - case 56: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56; - break; - - case 144: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144; - break; - - case 208: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208; - break; - - case 256: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256; - break; - - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n", - RC.config_file_name, i, ccparams_lte.rach_messageSizeGroupA); - break; + case 56: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56; + break; + + case 144: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144; + break; + + case 208: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208; + break; + + case 256: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256; + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n", + RC.config_file_name, i, ccparams_lte.rach_messageSizeGroupA); + break; } if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"minusinfinity")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity; - } - else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB0")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0; - } - else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB5")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB5")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5; - } - else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB8")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB8")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8; - } - else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB10")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB10")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10; - } - else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB12")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB12")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12; - } - else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB15")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB15")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15; - } - else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB18")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB18")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n", RC.config_file_name, i, ccparams_lte.rach_messagePowerOffsetGroupB); @@ -1086,18 +998,18 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleInitialReceivedTargetPower= (ccparams_lte.rach_preambleInitialReceivedTargetPower+120)/2; - if ((ccparams_lte.rach_preambleInitialReceivedTargetPower<-120) || - (ccparams_lte.rach_preambleInitialReceivedTargetPower>-90) || - ((ccparams_lte.rach_preambleInitialReceivedTargetPower&1)!=0)) + if ((ccparams_lte.rach_preambleInitialReceivedTargetPower<-120) || + (ccparams_lte.rach_preambleInitialReceivedTargetPower>-90) || + ((ccparams_lte.rach_preambleInitialReceivedTargetPower&1)!=0)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleInitialReceivedTargetPower choice: -120,-118,...,-90 !\n", RC.config_file_name, i, ccparams_lte.rach_preambleInitialReceivedTargetPower); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_powerRampingStep= ccparams_lte.rach_powerRampingStep/2; - if ((ccparams_lte.rach_powerRampingStep<0) || - (ccparams_lte.rach_powerRampingStep>6) || - ((ccparams_lte.rach_powerRampingStep&1)!=0)) + if ((ccparams_lte.rach_powerRampingStep<0) || + (ccparams_lte.rach_powerRampingStep>6) || + ((ccparams_lte.rach_powerRampingStep&1)!=0)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_powerRampingStep choice: 0,2,4,6 !\n", RC.config_file_name, i, ccparams_lte.rach_powerRampingStep); @@ -1105,205 +1017,196 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { switch (ccparams_lte.rach_preambleTransMax) { #if (LTE_RRC_VERSION < MAKE_VERSION(14, 0, 0)) - case 3: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3; - break; + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3; + break; - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4; - break; + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4; + break; - case 5: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5; - break; + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5; + break; - case 6: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6; - break; + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6; + break; - case 7: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7; - break; + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7; + break; - case 8: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8; - break; + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8; + break; - case 10: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10; - break; + case 10: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10; + break; - case 20: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20; - break; + case 20: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20; + break; - case 50: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50; - break; + case 50: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50; + break; - case 100: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100; - break; + case 100: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100; + break; - case 200: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200; - break; + case 200: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200; + break; #else - case 3: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n3; - break; - - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n4; - break; + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n3; + break; - case 5: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n5; - break; + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n4; + break; - case 6: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n6; - break; + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n5; + break; - case 7: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n7; - break; + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n6; + break; - case 8: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n8; - break; + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n7; + break; - case 10: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n10; - break; + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n8; + break; - case 20: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n20; - break; + case 10: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n10; + break; - case 50: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n50; - break; + case 20: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n20; + break; - case 100: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n100; - break; + case 50: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n50; + break; - case 200: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n200; - break; + case 100: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n100; + break; + case 200: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n200; + break; #endif - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n", - RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); - break; + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n", + RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); + break; } RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_raResponseWindowSize= (ccparams_lte.rach_raResponseWindowSize==10)?7:ccparams_lte.rach_raResponseWindowSize-2; if ((ccparams_lte.rach_raResponseWindowSize<0)|| - (ccparams_lte.rach_raResponseWindowSize==9)|| - (ccparams_lte.rach_raResponseWindowSize>10)) + (ccparams_lte.rach_raResponseWindowSize==9)|| + (ccparams_lte.rach_raResponseWindowSize>10)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_raResponseWindowSize choice: 2,3,4,5,6,7,8,10!\n", RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_macContentionResolutionTimer= (ccparams_lte.rach_macContentionResolutionTimer/8)-1; - if ((ccparams_lte.rach_macContentionResolutionTimer<8) || - (ccparams_lte.rach_macContentionResolutionTimer>64) || - ((ccparams_lte.rach_macContentionResolutionTimer&7)!=0)) + if ((ccparams_lte.rach_macContentionResolutionTimer<8) || + (ccparams_lte.rach_macContentionResolutionTimer>64) || + ((ccparams_lte.rach_macContentionResolutionTimer&7)!=0)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_macContentionResolutionTimer choice: 8,16,...,56,64!\n", RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_maxHARQ_Msg3Tx= ccparams_lte.rach_maxHARQ_Msg3Tx; - if ((ccparams_lte.rach_maxHARQ_Msg3Tx<0) || - (ccparams_lte.rach_maxHARQ_Msg3Tx>8)) + if ((ccparams_lte.rach_maxHARQ_Msg3Tx<0) || + (ccparams_lte.rach_maxHARQ_Msg3Tx>8)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n", RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); switch (ccparams_lte.pcch_defaultPagingCycle) { - case 32: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32; - break; - - case 64: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf64; - break; - - case 128: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf128; - break; - - case 256: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf256; - break; - - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n", - RC.config_file_name, i, ccparams_lte.pcch_defaultPagingCycle); - break; + case 32: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32; + break; + + case 64: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf64; + break; + + case 128: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf128; + break; + + case 256: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf256; + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n", + RC.config_file_name, i, ccparams_lte.pcch_defaultPagingCycle); + break; } if (strcmp(ccparams_lte.pcch_nB, "fourT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_fourT; - } - else if (strcmp(ccparams_lte.pcch_nB, "twoT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "twoT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_twoT; - } - else if (strcmp(ccparams_lte.pcch_nB, "oneT") == 0) { - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneT; - } - else if (strcmp(ccparams_lte.pcch_nB, "halfT") == 0) { - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_halfT; - } - else if (strcmp(ccparams_lte.pcch_nB, "quarterT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneT") == 0) { + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneT; + } else if (strcmp(ccparams_lte.pcch_nB, "halfT") == 0) { + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_halfT; + } else if (strcmp(ccparams_lte.pcch_nB, "quarterT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_quarterT; - } - else if (strcmp(ccparams_lte.pcch_nB, "oneEighthT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneEighthT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneEighthT; - } - else if (strcmp(ccparams_lte.pcch_nB, "oneSixteenthT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneSixteenthT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneSixteenthT; - } - else if (strcmp(ccparams_lte.pcch_nB, "oneThirtySecondT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneThirtySecondT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneThirtySecondT; - } - else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n", RC.config_file_name, i, ccparams_lte.pcch_nB); switch (ccparams_lte.bcch_modificationPeriodCoeff) { - case 2: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n2; - break; - - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n4; - break; - - case 8: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n8; - break; - - case 16: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n16; - break; - - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16", - RC.config_file_name, i, ccparams_lte.bcch_modificationPeriodCoeff); - break; + case 2: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n2; + break; + + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n4; + break; + + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n8; + break; + + case 16: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n16; + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16", + RC.config_file_name, i, ccparams_lte.bcch_modificationPeriodCoeff); + break; } RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t300= ccparams_lte.ue_TimersAndConstants_t300; @@ -1314,410 +1217,406 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_n311= ccparams_lte.ue_TimersAndConstants_n311; switch (ccparams_lte.ue_TransmissionMode) { - case 1: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; - break; - - case 2: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; - break; - - case 3: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm3; - break; - - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4; - break; - - case 5: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5; - break; - - case 6: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6; - break; - - case 7: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm7; - break; - - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7", - RC.config_file_name, i, ccparams_lte.ue_TransmissionMode); - break; + case 1: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; + break; + + case 2: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; + break; + + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm3; + break; + + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4; + break; + + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5; + break; + + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6; + break; + + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm7; + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7", + RC.config_file_name, i, ccparams_lte.ue_TransmissionMode); + break; } RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_multiple_max= ccparams_lte.ue_multiple_max; switch (ccparams_lte.N_RB_DL) { - case 25: - if ((ccparams_lte.ue_multiple_max < 1) || - (ccparams_lte.ue_multiple_max > 4)) - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..4!\n", - RC.config_file_name, i, ccparams_lte.ue_multiple_max); - - break; - - case 50: - if ((ccparams_lte.ue_multiple_max < 1) || - (ccparams_lte.ue_multiple_max > 8)) - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..8!\n", - RC.config_file_name, i, ccparams_lte.ue_multiple_max); - - break; - - case 100: - if ((ccparams_lte.ue_multiple_max < 1) || - (ccparams_lte.ue_multiple_max > 16)) - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..16!\n", - RC.config_file_name, i, ccparams_lte.ue_multiple_max); - - break; - - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n", - RC.config_file_name, i, ccparams_lte.N_RB_DL); - break; - } + case 25: + if ((ccparams_lte.ue_multiple_max < 1) || + (ccparams_lte.ue_multiple_max > 4)) + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..4!\n", + RC.config_file_name, i, ccparams_lte.ue_multiple_max); - // eMBMS configuration - RRC_CONFIGURATION_REQ(msg_p).eMBMS_configured = 0; - printf("No eMBMS configuration, skipping it\n"); + break; - // eMTC configuration - char brparamspath[MAX_OPTNAME_SIZE*2 + 16]; - sprintf(brparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_EMTC_PARAMETERS); - config_get(eMTCParams, sizeof(eMTCParams)/sizeof(paramdef_t), brparamspath); - RRC_CONFIGURATION_REQ(msg_p).eMTC_configured = eMTCconfig.eMTC_configured&1; + case 50: + if ((ccparams_lte.ue_multiple_max < 1) || + (ccparams_lte.ue_multiple_max > 8)) + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..8!\n", + RC.config_file_name, i, ccparams_lte.ue_multiple_max); - if (eMTCconfig.eMTC_configured > 0) fill_eMTC_configuration(msg_p,&eMTCconfig, i,j,RC.config_file_name,brparamspath); - else printf("No eMTC configuration, skipping it\n"); - + break; - // Sidelink configuration - char SLparamspath[MAX_OPTNAME_SIZE*2 + 16]; - sprintf(SLparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_SL_PARAMETERS); - config_get( SLParams, sizeof(SLParams)/sizeof(paramdef_t), SLparamspath); + case 100: + if ((ccparams_lte.ue_multiple_max < 1) || + (ccparams_lte.ue_multiple_max > 16)) + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..16!\n", + RC.config_file_name, i, ccparams_lte.ue_multiple_max); - // Sidelink Resource pool information - RRC_CONFIGURATION_REQ (msg_p).SL_configured=SLconfig.sidelink_configured&1; - if (SLconfig.sidelink_configured==1) fill_SL_configuration(msg_p,&SLconfig,i,j,RC.config_file_name); - else printf("No SL configuration skipping it\n"); - } - } + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n", + RC.config_file_name, i, ccparams_lte.N_RB_DL); + break; + } + + // eMBMS configuration + RRC_CONFIGURATION_REQ(msg_p).eMBMS_configured = 0; + printf("No eMBMS configuration, skipping it\n"); + // eMTC configuration + char brparamspath[MAX_OPTNAME_SIZE*2 + 16]; + sprintf(brparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_EMTC_PARAMETERS); + config_get(eMTCParams, sizeof(eMTCParams)/sizeof(paramdef_t), brparamspath); + RRC_CONFIGURATION_REQ(msg_p).eMTC_configured = eMTCconfig.eMTC_configured&1; + + if (eMTCconfig.eMTC_configured > 0) fill_eMTC_configuration(msg_p,&eMTCconfig, i,j,RC.config_file_name,brparamspath); + else printf("No eMTC configuration, skipping it\n"); + + // Sidelink configuration + char SLparamspath[MAX_OPTNAME_SIZE*2 + 16]; + sprintf(SLparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_SL_PARAMETERS); + config_get( SLParams, sizeof(SLParams)/sizeof(paramdef_t), SLparamspath); + // Sidelink Resource pool information + RRC_CONFIGURATION_REQ (msg_p).SL_configured=SLconfig.sidelink_configured&1; + + if (SLconfig.sidelink_configured==1) fill_SL_configuration(msg_p,&SLconfig,i,j,RC.config_file_name); + else printf("No SL configuration skipping it\n"); + } + } char srb1path[MAX_OPTNAME_SIZE*2 + 8]; sprintf(srb1path,"%s.%s",enbpath,ENB_CONFIG_STRING_SRB1); config_get( SRB1Params,sizeof(SRB1Params)/sizeof(paramdef_t), srb1path); + switch (srb1_params.srb1_max_retx_threshold) { + case 1: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t1; + break; + + case 2: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t2; + break; + + case 3: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t3; + break; + + case 4: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t4; + break; + + case 6: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t6; + break; + + case 8: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; + break; + + case 16: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t16; + break; + + case 32: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t32; + break; + + default: + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_max_retx_threshold %u!\n", + RC.config_file_name, i, srb1_params.srb1_max_retx_threshold); + } + + switch (srb1_params.srb1_poll_pdu) { + case 4: + rrc->srb1_poll_pdu = LTE_PollPDU_p4; + break; + + case 8: + rrc->srb1_poll_pdu = LTE_PollPDU_p8; + break; + + case 16: + rrc->srb1_poll_pdu = LTE_PollPDU_p16; + break; + + case 32: + rrc->srb1_poll_pdu = LTE_PollPDU_p32; + break; + + case 64: + rrc->srb1_poll_pdu = LTE_PollPDU_p64; + break; + + case 128: + rrc->srb1_poll_pdu = LTE_PollPDU_p128; + break; + + case 256: + rrc->srb1_poll_pdu = LTE_PollPDU_p256; + break; + + default: + if (srb1_params.srb1_poll_pdu >= 10000) + rrc->srb1_poll_pdu = LTE_PollPDU_pInfinity; + else + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_pdu %u!\n", + RC.config_file_name, i, srb1_params.srb1_poll_pdu); + } + + rrc->srb1_poll_byte = srb1_params.srb1_poll_byte; + + switch (srb1_params.srb1_poll_byte) { + case 25: + rrc->srb1_poll_byte = LTE_PollByte_kB25; + break; + + case 50: + rrc->srb1_poll_byte = LTE_PollByte_kB50; + break; + + case 75: + rrc->srb1_poll_byte = LTE_PollByte_kB75; + break; + + case 100: + rrc->srb1_poll_byte = LTE_PollByte_kB100; + break; + + case 125: + rrc->srb1_poll_byte = LTE_PollByte_kB125; + break; + + case 250: + rrc->srb1_poll_byte = LTE_PollByte_kB250; + break; + + case 375: + rrc->srb1_poll_byte = LTE_PollByte_kB375; + break; + + case 500: + rrc->srb1_poll_byte = LTE_PollByte_kB500; + break; + + case 750: + rrc->srb1_poll_byte = LTE_PollByte_kB750; + break; + + case 1000: + rrc->srb1_poll_byte = LTE_PollByte_kB1000; + break; - switch (srb1_params.srb1_max_retx_threshold) { - case 1: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t1; - break; - - case 2: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t2; - break; - - case 3: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t3; - break; - - case 4: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t4; - break; - - case 6: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t6; - break; - - case 8: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; - break; - - case 16: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t16; - break; - - case 32: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t32; - break; - - default: - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_max_retx_threshold %u!\n", - RC.config_file_name, i, srb1_params.srb1_max_retx_threshold); - } - - switch (srb1_params.srb1_poll_pdu) { - case 4: - rrc->srb1_poll_pdu = LTE_PollPDU_p4; - break; - - case 8: - rrc->srb1_poll_pdu = LTE_PollPDU_p8; - break; - - case 16: - rrc->srb1_poll_pdu = LTE_PollPDU_p16; - break; - - case 32: - rrc->srb1_poll_pdu = LTE_PollPDU_p32; - break; - - case 64: - rrc->srb1_poll_pdu = LTE_PollPDU_p64; - break; - - case 128: - rrc->srb1_poll_pdu = LTE_PollPDU_p128; - break; - - case 256: - rrc->srb1_poll_pdu = LTE_PollPDU_p256; - break; - - default: - if (srb1_params.srb1_poll_pdu >= 10000) - rrc->srb1_poll_pdu = LTE_PollPDU_pInfinity; - else - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_pdu %u!\n", - RC.config_file_name, i, srb1_params.srb1_poll_pdu); - } - - rrc->srb1_poll_byte = srb1_params.srb1_poll_byte; - - switch (srb1_params.srb1_poll_byte) { - case 25: - rrc->srb1_poll_byte = LTE_PollByte_kB25; - break; - - case 50: - rrc->srb1_poll_byte = LTE_PollByte_kB50; - break; - - case 75: - rrc->srb1_poll_byte = LTE_PollByte_kB75; - break; - - case 100: - rrc->srb1_poll_byte = LTE_PollByte_kB100; - break; - - case 125: - rrc->srb1_poll_byte = LTE_PollByte_kB125; - break; - - case 250: - rrc->srb1_poll_byte = LTE_PollByte_kB250; - break; - - case 375: - rrc->srb1_poll_byte = LTE_PollByte_kB375; - break; - - case 500: - rrc->srb1_poll_byte = LTE_PollByte_kB500; - break; - - case 750: - rrc->srb1_poll_byte = LTE_PollByte_kB750; - break; - - case 1000: - rrc->srb1_poll_byte = LTE_PollByte_kB1000; - break; - - case 1250: - rrc->srb1_poll_byte = LTE_PollByte_kB1250; - break; - - case 1500: - rrc->srb1_poll_byte = LTE_PollByte_kB1500; - break; - - case 2000: - rrc->srb1_poll_byte = LTE_PollByte_kB2000; - break; - - case 3000: - rrc->srb1_poll_byte = LTE_PollByte_kB3000; - break; - - default: - if (srb1_params.srb1_poll_byte >= 10000) - rrc->srb1_poll_byte = LTE_PollByte_kBinfinity; - else - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_byte %u!\n", - RC.config_file_name, i, srb1_params.srb1_poll_byte); - } - - if (srb1_params.srb1_timer_poll_retransmit <= 250) { - rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 5)/5; - } else if (srb1_params.srb1_timer_poll_retransmit <= 500) { - rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 300)/50 + 50; - } else { - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_poll_retransmit %u!\n", - RC.config_file_name, i, srb1_params.srb1_timer_poll_retransmit); - } - - if (srb1_params.srb1_timer_status_prohibit <= 250) { - rrc->srb1_timer_status_prohibit = srb1_params.srb1_timer_status_prohibit/5; - } else if ((srb1_params.srb1_timer_poll_retransmit >= 300) && (srb1_params.srb1_timer_poll_retransmit <= 500)) { - rrc->srb1_timer_status_prohibit = (srb1_params.srb1_timer_status_prohibit - 300)/50 + 51; - } else { - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_status_prohibit %u!\n", - RC.config_file_name, i, srb1_params.srb1_timer_status_prohibit); - } - - switch (srb1_params.srb1_timer_reordering) { - case 0: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms0; - break; - - case 5: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms5; - break; - - case 10: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms10; - break; - - case 15: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms15; - break; - - case 20: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms20; - break; - - case 25: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms25; - break; - - case 30: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms30; - break; - - case 35: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms35; - break; - - case 40: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms40; - break; - - case 45: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms45; - break; - - case 50: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms50; - break; - - case 55: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms55; - break; - - case 60: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms60; - break; - - case 65: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms65; - break; - - case 70: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms70; - break; - - case 75: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms75; - break; - - case 80: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms80; - break; - - case 85: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms85; - break; - - case 90: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms90; - break; - - case 95: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms95; - break; - - case 100: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms100; - break; - - case 110: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms110; - break; - - case 120: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms120; - break; - - case 130: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms130; - break; - - case 140: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms140; - break; - - case 150: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms150; - break; - - case 160: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms160; - break; - - case 170: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms170; - break; - - case 180: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms180; - break; - - case 190: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms190; - break; - - case 200: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms200; - break; - - default: - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_reordering %u!\n", - RC.config_file_name, i, srb1_params.srb1_timer_reordering); - } + case 1250: + rrc->srb1_poll_byte = LTE_PollByte_kB1250; + break; + + case 1500: + rrc->srb1_poll_byte = LTE_PollByte_kB1500; + break; + + case 2000: + rrc->srb1_poll_byte = LTE_PollByte_kB2000; + break; + + case 3000: + rrc->srb1_poll_byte = LTE_PollByte_kB3000; + break; + + default: + if (srb1_params.srb1_poll_byte >= 10000) + rrc->srb1_poll_byte = LTE_PollByte_kBinfinity; + else + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_byte %u!\n", + RC.config_file_name, i, srb1_params.srb1_poll_byte); + } + + if (srb1_params.srb1_timer_poll_retransmit <= 250) { + rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 5)/5; + } else if (srb1_params.srb1_timer_poll_retransmit <= 500) { + rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 300)/50 + 50; + } else { + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_poll_retransmit %u!\n", + RC.config_file_name, i, srb1_params.srb1_timer_poll_retransmit); + } + + if (srb1_params.srb1_timer_status_prohibit <= 250) { + rrc->srb1_timer_status_prohibit = srb1_params.srb1_timer_status_prohibit/5; + } else if ((srb1_params.srb1_timer_poll_retransmit >= 300) && (srb1_params.srb1_timer_poll_retransmit <= 500)) { + rrc->srb1_timer_status_prohibit = (srb1_params.srb1_timer_status_prohibit - 300)/50 + 51; + } else { + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_status_prohibit %u!\n", + RC.config_file_name, i, srb1_params.srb1_timer_status_prohibit); + } + + switch (srb1_params.srb1_timer_reordering) { + case 0: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms0; + break; + + case 5: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms5; + break; + + case 10: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms10; + break; + + case 15: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms15; + break; + + case 20: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms20; + break; + + case 25: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms25; + break; + + case 30: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms30; + break; + + case 35: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms35; + break; + + case 40: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms40; + break; + + case 45: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms45; + break; + + case 50: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms50; + break; + + case 55: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms55; + break; + + case 60: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms60; + break; + + case 65: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms65; + break; + + case 70: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms70; + break; + + case 75: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms75; + break; + + case 80: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms80; + break; + + case 85: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms85; + break; + + case 90: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms90; + break; + + case 95: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms95; + break; + + case 100: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms100; + break; + + case 110: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms110; + break; + + case 120: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms120; + break; + + case 130: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms130; + break; + + case 140: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms140; + break; + + case 150: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms150; + break; + + case 160: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms160; + break; + + case 170: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms170; + break; + + case 180: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms180; + break; + + case 190: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms190; + break; + + case 200: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms200; + break; + + default: + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_reordering %u!\n", + RC.config_file_name, i, srb1_params.srb1_timer_reordering); + } } } } return 0; - } int RCconfig_gtpu(void ) { @@ -1769,12 +1668,8 @@ int RCconfig_S1( const char *active_enb[MAX_ENB]; char *address = NULL; char *cidr = NULL; - ccparams_lte_t ccparams_lte; - - memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t)); - - + memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t)); // for no gcc warnings (void)my_int; memset((char *)active_enb, 0, MAX_ENB * sizeof(char *)); @@ -1909,7 +1804,7 @@ int RCconfig_S1( default: { LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \ - Default DRX set to 32 in MME configuration\n", + Default DRX set to 32 in MME configuration\n", ccparams_lte.pcch_defaultPagingCycle); S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; } @@ -2002,18 +1897,13 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { int enb_id; char *address = NULL; char *cidr = NULL; - ccparams_lte_t ccparams_lte; - - memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t)); - - + memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t)); paramdef_t ENBSParams[] = ENBSPARAMS_DESC; paramdef_t ENBParams[] = ENBPARAMS_DESC; paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0}; /* get global parameters, defined outside any section in the config file */ config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL); - checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK; paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte); paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0}; @@ -2023,225 +1913,208 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { CCsParams[I].chkPptr = &(config_check_CCparams[I]); } - /*#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - if (strcasecmp( *(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr), ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE) == 0) { - asn_debug = 0; - asn1_xer_print = 0; - } else if (strcasecmp( *(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr), ENB_CONFIG_STRING_ASN1_VERBOSITY_INFO) == 0) { - asn_debug = 1; - asn1_xer_print = 1; - } else if (strcasecmp(*(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr) , ENB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING) == 0) { - asn_debug = 1; - asn1_xer_print = 2; - } else { - asn_debug = 0; - asn1_xer_print = 0; - } - #endif */ AssertFatal(i < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt, - "Failed to parse config file %s, %uth attribute %s \n", - RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS); + "Failed to parse config file %s, %uth attribute %s \n", + RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS); if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) { // Output a list of all eNBs. config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL); - + if (ENBParamList.numelt > 0) { for (k = 0; k < ENBParamList.numelt; k++) { - if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) { - // Calculate a default eNB ID -# if defined(ENABLE_USE_MME) - uint32_t hash; - hash = s1ap_generate_eNB_id (); - enb_id = k + (hash & 0xFFFF8); -# else - enb_id = k; -# endif - } else { - enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr); - } - - // search if in active list - for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { - if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) { - paramdef_t PLMNParams[] = PLMNPARAMS_DESC; - paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0}; - /* map parameter checking array instances to parameter definition array instances */ - checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK; - - for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) - PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); - - paramdef_t X2Params[] = X2PARAMS_DESC; - paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0}; - paramdef_t SCTPParams[] = SCTPPARAMS_DESC; - paramdef_t NETParams[] = NETPARAMS_DESC; - /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */ - /* this is most probably a problem with the config module */ - char aprefix[MAX_OPTNAME_SIZE*80 + 8]; - sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); - /* Some default/random parameters */ - X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id; - - if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB; - } else if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB; - } else { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", - RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); - } - - X2AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); - X2AP_REGISTER_ENB_REQ (msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; - config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); - - if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) - AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", - PLMNParamList.numelt); - - - if (PLMNParamList.numelt > 1) - LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n"); - - X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; - X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr; - X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr; - AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3 - || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100, - "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", - X2AP_REGISTER_ENB_REQ(msg_p).mnc); - /* CC params */ - config_getlist(&CCsParamList, NULL, 0, aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt; - - if (CCsParamList.numelt > 0) { - //char ccspath[MAX_OPTNAME_SIZE*2 + 16]; - for (J = 0; J < CCsParamList.numelt ; J++) { - sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J); - config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = ccparams_lte.eutra_band; - X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) ccparams_lte.downlink_frequency; - X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) ccparams_lte.uplink_frequency_offset; - X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= ccparams_lte.Nid_cell; - - if (ccparams_lte.Nid_cell>503) { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n", - RC.config_file_name, k, ccparams_lte.Nid_cell); - } - - X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= ccparams_lte.N_RB_DL; - - if ((ccparams_lte.N_RB_DL!=6) && (ccparams_lte.N_RB_DL!=15) && (ccparams_lte.N_RB_DL!=25) && (ccparams_lte.N_RB_DL!=50) && (ccparams_lte.N_RB_DL!=75) && (ccparams_lte.N_RB_DL!=100)) { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n", - RC.config_file_name, k, ccparams_lte.N_RB_DL); - } - - if (strcmp(ccparams_lte.frame_type, "FDD") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD; - } else if (strcmp(ccparams_lte.frame_type, "TDD") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD; - } else { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n", - RC.config_file_name, k, ccparams_lte.frame_type); - } - - X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL); - X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL); - } - } - - sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); - config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix); - AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS, - "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n", - X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS); - X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0; - - for (l = 0; l < X2ParamList.numelt; l++) { - X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1; - strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr)); - strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr)); - - if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; - } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; - } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; - } - } - - - // SCTP SETTING - X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; - X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; -# if defined(ENABLE_USE_MME) - sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); - config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); - X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); -#endif - sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); - // NETWORK_INTERFACES - config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr); - - if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) { - LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n"); - exit(1); - } - - cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr); - address = strtok(cidr, "/"); - X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0; - X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1; - strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address); - } - } + if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) { + // Calculate a default eNB ID + if (EPC_MODE_ENABLED) { + uint32_t hash; + hash = s1ap_generate_eNB_id (); + enb_id = k + (hash & 0xFFFF8); + } else { + enb_id = k; + } + } else { + enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr); + } + + // search if in active list + for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { + if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) { + paramdef_t PLMNParams[] = PLMNPARAMS_DESC; + paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0}; + /* map parameter checking array instances to parameter definition array instances */ + checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK; + + for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) + PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); + + paramdef_t X2Params[] = X2PARAMS_DESC; + paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0}; + paramdef_t SCTPParams[] = SCTPPARAMS_DESC; + paramdef_t NETParams[] = NETPARAMS_DESC; + /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */ + /* this is most probably a problem with the config module */ + char aprefix[MAX_OPTNAME_SIZE*80 + 8]; + sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); + /* Some default/random parameters */ + X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id; + + if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB; + } else if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB; + } else { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", + RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); + } + + X2AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); + X2AP_REGISTER_ENB_REQ (msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; + config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); + + if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) + AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", + PLMNParamList.numelt); + + if (PLMNParamList.numelt > 1) + LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n"); + + X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; + X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr; + X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr; + AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3 + || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100, + "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", + X2AP_REGISTER_ENB_REQ(msg_p).mnc); + /* CC params */ + config_getlist(&CCsParamList, NULL, 0, aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt; + + if (CCsParamList.numelt > 0) { + //char ccspath[MAX_OPTNAME_SIZE*2 + 16]; + for (J = 0; J < CCsParamList.numelt ; J++) { + sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J); + config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = ccparams_lte.eutra_band; + X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) ccparams_lte.downlink_frequency; + X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) ccparams_lte.uplink_frequency_offset; + X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= ccparams_lte.Nid_cell; + + if (ccparams_lte.Nid_cell>503) { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n", + RC.config_file_name, k, ccparams_lte.Nid_cell); + } + + X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= ccparams_lte.N_RB_DL; + + if ((ccparams_lte.N_RB_DL!=6) && (ccparams_lte.N_RB_DL!=15) && (ccparams_lte.N_RB_DL!=25) && (ccparams_lte.N_RB_DL!=50) && (ccparams_lte.N_RB_DL!=75) && (ccparams_lte.N_RB_DL!=100)) { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n", + RC.config_file_name, k, ccparams_lte.N_RB_DL); + } + + if (strcmp(ccparams_lte.frame_type, "FDD") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD; + } else if (strcmp(ccparams_lte.frame_type, "TDD") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD; + } else { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n", + RC.config_file_name, k, ccparams_lte.frame_type); + } + + X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL); + X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL); + } + } + + sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); + config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix); + AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS, + "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n", + X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS); + X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0; + + for (l = 0; l < X2ParamList.numelt; l++) { + X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1; + strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr)); + strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr)); + + if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; + } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; + } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; + } + } + + // SCTP SETTING + X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; + X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; + + if (EPC_MODE_ENABLED) { + sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); + config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); + X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); + } + + sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); + // NETWORK_INTERFACES + config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr); + + if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) { + LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n"); + exit(1); + } + + cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr); + address = strtok(cidr, "/"); + X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0; + X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1; + strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address); + } + } } } } - + return 0; } int RCconfig_parallel(void) { char *parallel_conf = NULL; char *worker_conf = NULL; - - paramdef_t ThreadParams[] = THREAD_CONF_DESC; paramlist_def_t THREADParamList = {THREAD_CONFIG_STRING_THREAD_STRUCT,NULL,0}; config_getlist( &THREADParamList,NULL,0,NULL); - if(parallel_config == NULL){ + if(parallel_config == NULL) { if(THREADParamList.numelt>0) { config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL); parallel_conf = strdup(*(THREADParamList.paramarray[0][THREAD_PARALLEL_IDX].strptr)); } else { parallel_conf = strdup("PARALLEL_RU_L1_TRX_SPLIT"); } + set_parallel_conf(parallel_conf); } - if(worker_config == NULL){ + if(worker_config == NULL) { if(THREADParamList.numelt>0) { config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL); worker_conf = strdup(*(THREADParamList.paramarray[0][THREAD_WORKER_IDX].strptr)); } else { worker_conf = strdup("WORKER_ENABLE"); } + set_worker_conf(worker_conf); } - - return 0; } @@ -2255,13 +2128,12 @@ void RCConfig(void) { /* get global parameters, defined outside any section in the config file */ printf("Getting ENBSParams\n"); config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL); -# if defined(ENABLE_USE_MME) - EPC_MODE_ENABLED = ((*ENBSParams[ENB_NOS1_IDX].uptr) == 0); -#endif + //EPC_MODE_ENABLED = ((*ENBSParams[ENB_NOS1_IDX].uptr) == 0); RC.nb_inst = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; if (RC.nb_inst > 0) { RC.nb_CC = (int *)malloc((1+RC.nb_inst)*sizeof(int)); + for (int i=0; i<RC.nb_inst; i++) { sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,i); config_getlist( &CCsParamList,NULL,0, aprefix); diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c index 1168ed265abde1667da8f9e28f5395c96d093bc4..bf4af9f5a9225aed83d6720a6cf1345c59da0056 100644 --- a/openair2/LAYER2/MAC/main_ue.c +++ b/openair2/LAYER2/MAC/main_ue.c @@ -45,114 +45,89 @@ #include "common/ran_context.h" extern FILL_UL_INFO_MUTEX_t fill_ul_mutex; extern uint8_t nfapi_mode; -extern void openair_rrc_top_init_ue( int eMBMS_active, char* uecap_xer, uint8_t cba_group_active, uint8_t HO_active); - -void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync) //init as MR -{ - LOG_D(MAC, "[UE %d] Frame %d: PHY Sync to eNB_index %d successful \n", - module_idP, frameP, eNB_index); -#if defined(ENABLE_USE_MME) - int mme_enabled = 1; -#else - int mme_enabled = 0; -#endif - - if (first_sync == 1 && !(mme_enabled == 1)) { - //layer2_init_UE(module_idP); - openair_rrc_ue_init(module_idP, eNB_index); - } else { - rrc_in_sync_ind(module_idP, frameP, eNB_index); - } +extern void openair_rrc_top_init_ue( int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); + +void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync) { //init as MR + LOG_D(MAC, "[UE %d] Frame %d: PHY Sync to eNB_index %d successful \n", + module_idP, frameP, eNB_index); + + if (first_sync == 1 && !(EPC_MODE_ENABLED)) { + //layer2_init_UE(module_idP); + openair_rrc_ue_init(module_idP, eNB_index); + } else { + rrc_in_sync_ind(module_idP, frameP, eNB_index); + } } void mac_UE_out_of_sync_ind(module_id_t module_idP, frame_t frameP, - uint16_t eNB_index) -{ - - // Mac_rlc_xface->mac_out_of_sync_ind(Mod_id, frameP, eNB_index); + uint16_t eNB_index) { + // Mac_rlc_xface->mac_out_of_sync_ind(Mod_id, frameP, eNB_index); } int mac_top_init_ue(int eMBMS_active, char *uecap_xer, - uint8_t cba_group_active, uint8_t HO_active) -{ - - int i; - - LOG_I(MAC, "[MAIN] Init function start:Nb_UE_INST=%d\n", NB_UE_INST); - - if (NB_UE_INST > 0) { - UE_mac_inst = - (UE_MAC_INST *) malloc16(NB_UE_INST * sizeof(UE_MAC_INST)); - - AssertFatal(UE_mac_inst != NULL, - "[MAIN] Can't ALLOCATE %zu Bytes for %d UE_MAC_INST with size %zu \n", - NB_UE_INST * sizeof(UE_MAC_INST), NB_UE_INST, - sizeof(UE_MAC_INST)); - - LOG_D(MAC, "[MAIN] ALLOCATE %zu Bytes for %d UE_MAC_INST @ %p\n", - NB_UE_INST * sizeof(UE_MAC_INST), NB_UE_INST, UE_mac_inst); - - bzero(UE_mac_inst, NB_UE_INST * sizeof(UE_MAC_INST)); - - for (i = 0; i < NB_UE_INST; i++) { - ue_init_mac(i); - } - } else { - UE_mac_inst = NULL; - } - - // mutex below are used for multiple UE's L2 FAPI simulation. - if (nfapi_mode == 3){ - pthread_mutex_init(&fill_ul_mutex.rx_mutex,NULL); - pthread_mutex_init(&fill_ul_mutex.crc_mutex,NULL); - pthread_mutex_init(&fill_ul_mutex.sr_mutex,NULL); - pthread_mutex_init(&fill_ul_mutex.harq_mutex,NULL); - pthread_mutex_init(&fill_ul_mutex.cqi_mutex,NULL); - pthread_mutex_init(&fill_ul_mutex.rach_mutex,NULL); + uint8_t cba_group_active, uint8_t HO_active) { + int i; + LOG_I(MAC, "[MAIN] Init function start:Nb_UE_INST=%d\n", NB_UE_INST); + + if (NB_UE_INST > 0) { + UE_mac_inst = + (UE_MAC_INST *) malloc16(NB_UE_INST * sizeof(UE_MAC_INST)); + AssertFatal(UE_mac_inst != NULL, + "[MAIN] Can't ALLOCATE %zu Bytes for %d UE_MAC_INST with size %zu \n", + NB_UE_INST * sizeof(UE_MAC_INST), NB_UE_INST, + sizeof(UE_MAC_INST)); + LOG_D(MAC, "[MAIN] ALLOCATE %zu Bytes for %d UE_MAC_INST @ %p\n", + NB_UE_INST * sizeof(UE_MAC_INST), NB_UE_INST, UE_mac_inst); + bzero(UE_mac_inst, NB_UE_INST * sizeof(UE_MAC_INST)); + + for (i = 0; i < NB_UE_INST; i++) { + ue_init_mac(i); } - - LOG_I(MAC, "[MAIN] calling RRC\n"); - openair_rrc_top_init_ue(eMBMS_active, uecap_xer, cba_group_active, - HO_active); - - - LOG_I(MAC, "[MAIN][INIT] Init function finished\n"); - - return (0); - + } else { + UE_mac_inst = NULL; + } + + // mutex below are used for multiple UE's L2 FAPI simulation. + if (nfapi_mode == 3) { + pthread_mutex_init(&fill_ul_mutex.rx_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.crc_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.sr_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.harq_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.cqi_mutex,NULL); + pthread_mutex_init(&fill_ul_mutex.rach_mutex,NULL); + } + + LOG_I(MAC, "[MAIN] calling RRC\n"); + openair_rrc_top_init_ue(eMBMS_active, uecap_xer, cba_group_active, + HO_active); + LOG_I(MAC, "[MAIN][INIT] Init function finished\n"); + return (0); } -int rlcmac_init_global_param_ue(void) -{ - - - LOG_I(MAC, "[MAIN] CALLING RLC_MODULE_INIT...\n"); - - if (rlc_module_init() != 0) { - return (-1); - } - - pdcp_layer_init(); +int rlcmac_init_global_param_ue(void) { + LOG_I(MAC, "[MAIN] CALLING RLC_MODULE_INIT...\n"); - LOG_I(MAC, "[MAIN] Init Global Param Done\n"); + if (rlc_module_init() != 0) { + return (-1); + } - return 0; + pdcp_layer_init(); + LOG_I(MAC, "[MAIN] Init Global Param Done\n"); + return 0; } int l2_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, - uint8_t HO_active) -{ - LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n"); - // NB_NODE=2; - // NB_INST=2; - - rlcmac_init_global_param_ue(); - LOG_I(MAC, "[MAIN] init UE MAC functions \n"); - mac_top_init_ue(eMBMS_active, uecap_xer, cba_group_active, HO_active); - return (1); + uint8_t HO_active) { + LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n"); + // NB_NODE=2; + // NB_INST=2; + rlcmac_init_global_param_ue(); + LOG_I(MAC, "[MAIN] init UE MAC functions \n"); + mac_top_init_ue(eMBMS_active, uecap_xer, cba_group_active, HO_active); + return (1); } diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index bca5ef0ae8afbb42d8302f6a6da07508d3f90303..7d77cb62c3ab07e49166c1cead754d4a1f00b2bb 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -2573,8 +2573,12 @@ ue_scheduler(const module_id_t module_idP, // data to/from NETLINK is treated in pdcp_run. // one socket is used in multiple UE's L2 FAPI simulator and // only first UE need to do this. - if(module_idP == 0){ + if (UE_NAS_USE_TUN) { pdcp_run(&ctxt); + } else { + if(module_idP == 0){ + pdcp_run(&ctxt); + } } //#endif UE_mac_inst[module_idP].txFrame = txFrameP; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index a5ec0b7a21608dcf706e944e1a29e017b0bff470..76e36dca9a0438a951d6718ed30515ead6140656 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -28,7 +28,6 @@ */ #define PDCP_C -//#define DEBUG_PDCP_FIFO_FLUSH_SDU #define MBMS_MULTICAST_OUT @@ -50,23 +49,17 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "msc.h" #include "targets/COMMON/openairinterface5g_limits.h" -#if defined(ENABLE_SECURITY) - #include "UTIL/OSA/osa_defs.h" -#endif +#include "SIMULATION/ETH_TRANSPORT/proto.h" +#include "UTIL/OSA/osa_defs.h" -#if defined(ENABLE_ITTI) - #include "intertask_interface.h" -#endif +# include "intertask_interface.h" -#if defined(LINK_ENB_PDCP_TO_GTPV1U) - #include "gtpv1u_eNB_task.h" - #include "gtpv1u.h" -#endif + +# include "gtpv1u_eNB_task.h" +# include "gtpv1u.h" extern int otg_enabled; -#if defined(ENABLE_USE_MME) - extern uint8_t nfapi_mode; -#endif +extern uint8_t nfapi_mode; #include "common/ran_context.h" extern RAN_CONTEXT_t RC; hash_table_t *pdcp_coll_p = NULL; @@ -82,6 +75,13 @@ hash_table_t *pdcp_coll_p = NULL; static int mbms_socket = -1; #endif + +/* pdcp module parameters and related functions*/ +static pdcp_params_t pdcp_params= {0}; + +uint64_t get_pdcp_optmask(void) { + return pdcp_params.optmask; +} //----------------------------------------------------------------------------- /* * If PDCP_UNIT_TEST is set here then data flow between PDCP and RLC is broken @@ -98,11 +98,9 @@ boolean_t pdcp_data_req( const confirm_t confirmP, const sdu_size_t sdu_buffer_sizeP, unsigned char *const sdu_buffer_pP, - const pdcp_transmission_mode_t modeP -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,const uint32_t *const sourceL2Id - ,const uint32_t *const destinationL2Id -#endif + const pdcp_transmission_mode_t modeP, + const uint32_t *const sourceL2Id, + const uint32_t *const destinationL2Id ) //----------------------------------------------------------------------------- { @@ -179,26 +177,21 @@ boolean_t pdcp_data_req( if (pdcp_pdu_p != NULL) { memcpy(&pdcp_pdu_p->data[0], sdu_buffer_pP, sdu_buffer_sizeP); -#if defined(DEBUG_PDCP_PAYLOAD) - rlc_util_print_hex_octets(PDCP, - (unsigned char *)&pdcp_pdu_p->data[0], - sdu_buffer_sizeP); -#endif - LOG_D(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP); + + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { + rlc_util_print_hex_octets(PDCP, + (unsigned char *)&pdcp_pdu_p->data[0], + sdu_buffer_sizeP); + LOG_UI(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP); + } + rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP, confirmP, sdu_buffer_sizeP, pdcp_pdu_p -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,NULL, NULL -#endif ); } else { rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES; - LOG_W(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", + LOG_E(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", PROTOCOL_CTXT_ARGS(ctxt_pP)); -#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, PROTOCOL_CTXT_FMT"[RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", - PROTOCOL_CTXT_ARGS(ctxt_pP), - rb_idP); -#endif } } else { // calculate the pdcp header and trailer size @@ -299,8 +292,6 @@ boolean_t pdcp_data_req( pdcp_pdu_p->data[pdcp_header_len + sdu_buffer_sizeP + i] = 0x00;// pdu_header.mac_i[i]; } -#if defined(ENABLE_SECURITY) - if ((pdcp_p->security_activated != 0) && (((pdcp_p->cipheringAlgorithm) != 0) || ((pdcp_p->integrityProtAlgorithm) != 0))) { @@ -326,7 +317,6 @@ boolean_t pdcp_data_req( } } -#endif /* Print octets of outgoing data in hexadecimal form */ LOG_D(PDCP, "Following content with size %d will be sent over RLC (PDCP PDU header is the first two bytes)\n", pdcp_pdu_size); @@ -341,14 +331,11 @@ boolean_t pdcp_data_req( stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req); } -#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - AssertFatal(0, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", - ctxt_pP->frame, - (ctxt_pP->enb_flag) ? "eNB" : "UE", - ctxt_pP->enb_module_id, - ctxt_pP->ue_module_id, - rb_idP); -#endif + LOG_E(PDCP, "[FRAME %5u][%s][PDCP][MOD %u][RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", + ctxt_pP->frame, + (ctxt_pP->enb_flag) ? "eNB" : "UE", + ctxt_pP->module_id, + rb_idP); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return FALSE; } @@ -361,10 +348,8 @@ boolean_t pdcp_data_req( "[MSG] PDCP DL %s PDU on rb_id %d\n",(srb_flagP)? "CONTROL" : "DATA", rb_idP); LOG_D(PDCP, "Before rlc_data_req 2, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP); rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,sourceL2Id ,destinationL2Id -#endif ); } @@ -450,11 +435,12 @@ pdcp_data_ind( hashtable_rc_t h_rc; uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 :0; uint16_t pdcp_uid=0; - uint8_t oo_flag=0; -#if defined(LINK_ENB_PDCP_TO_GTPV1U) MessageDef *message_p = NULL; uint8_t *gtpu_buffer_p = NULL; -#endif + uint32_t rx_hfn_for_count; + int pdcp_sn_for_count; + int security_ok; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_IN); LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)sdu_buffer_pP->data,sdu_buffer_sizeP, "[MSG] PDCP UL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP); @@ -485,7 +471,7 @@ pdcp_data_ind( LOG_D(PDCP, "Data indication notification for PDCP entity from UE %x to eNB %u " "and radio bearer ID %d rlc sdu size %d ctxt_pP->enb_flag %d\n", ctxt_pP->rnti, - ctxt_pP->module_id , + ctxt_pP->module_id, rb_idP, sdu_buffer_sizeP, ctxt_pP->enb_flag); @@ -542,10 +528,10 @@ pdcp_data_ind( } else { // DRB pdcp_tailer_len = 0; - if (pdcp_p->seq_num_size == PDCP_SN_7BIT) { + if (pdcp_p->seq_num_size == 7) { pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_SHORT_SN_HEADER_SIZE; sequence_number = pdcp_get_sequence_number_of_pdu_with_short_sn((unsigned char *)sdu_buffer_pP->data); - } else if (pdcp_p->seq_num_size == PDCP_SN_12BIT) { + } else if (pdcp_p->seq_num_size == 12) { pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; sequence_number = pdcp_get_sequence_number_of_pdu_with_long_sn((unsigned char *)sdu_buffer_pP->data); } else { @@ -554,6 +540,7 @@ pdcp_data_ind( PROTOCOL_PDCP_CTXT_FMT"wrong sequence number (%d) for this pdcp entity \n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), pdcp_p->seq_num_size); + exit(1); } //uint8_t dc = pdcp_get_dc_filed((unsigned char*)sdu_buffer_pP->data); @@ -579,6 +566,8 @@ pdcp_data_ind( return FALSE; } +#if 0 + /* Removed by Cedric */ if (pdcp_is_rx_seq_number_valid(sequence_number, pdcp_p, srb_flagP) == TRUE) { LOG_T(PDCP, "Incoming PDU has a sequence number (%d) in accordance with RX window\n", sequence_number); /* if (dc == PDCP_DATA_PDU ) @@ -586,8 +575,8 @@ pdcp_data_ind( else LOG_D(PDCP, "Passing piggybacked SDU to RRC ...\n");*/ } else { - oo_flag=1; - LOG_W(PDCP, + Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; + LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT"Incoming PDU has an unexpected sequence number (%d), RX window synchronisation have probably been lost!\n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), sequence_number); @@ -599,10 +588,18 @@ pdcp_data_ind( free_mem_block(sdu_buffer_pP, __func__); return FALSE; } +#endif // SRB1/2: control-plane data if (srb_flagP) { -#if defined(ENABLE_SECURITY) + /* process as described in 36.323 5.1.2.2 */ + if (sequence_number < pdcp_p->next_pdcp_rx_sn) { + rx_hfn_for_count = pdcp_p->rx_hfn + 1; + pdcp_sn_for_count = sequence_number; + } else { + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + } if (pdcp_p->security_activated == 1) { if (ctxt_pP->enb_flag == ENB_FLAG_NO) { @@ -611,23 +608,45 @@ pdcp_data_ind( start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); } - pdcp_validate_security(ctxt_pP, - pdcp_p, - srb_flagP, - rb_idP, - pdcp_header_len, - sequence_number, - sdu_buffer_pP->data, - sdu_buffer_sizeP - pdcp_tailer_len); + security_ok = pdcp_validate_security(ctxt_pP, + pdcp_p, + srb_flagP, + rb_idP, + pdcp_header_len, + rx_hfn_for_count, + pdcp_sn_for_count, + sdu_buffer_pP->data, + sdu_buffer_sizeP - pdcp_tailer_len) == 0; if (ctxt_pP->enb_flag == ENB_FLAG_NO) { stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); } else { stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); } + } else { + security_ok = 1; + } + + if (security_ok == 0) { + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDCP SRB PDU\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + LOG_W(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer_pP, __func__); + /* TODO: indicate integrity verification failure to upper layer */ + return FALSE; + } + + if (sequence_number < pdcp_p->next_pdcp_rx_sn) + pdcp_p->rx_hfn++; + + pdcp_p->next_pdcp_rx_sn = sequence_number + 1; + + if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) { + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->rx_hfn++; } -#endif //rrc_lite_data_ind(module_id, //Modified MW - L2 Interface MSC_LOG_TX_MESSAGE( (ctxt_pP->enb_flag == ENB_FLAG_NO)? MSC_PDCP_UE:MSC_PDCP_ENB, @@ -651,40 +670,168 @@ pdcp_data_ind( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); return TRUE; - } + } /* if (srb_flagP) */ /* * DRBs */ payload_offset=pdcp_header_len;// PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; -#if defined(ENABLE_SECURITY) - if (pdcp_p->security_activated == 1) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + switch (pdcp_p->rlc_mode) { + case RLC_MODE_AM: { + /* process as described in 36.323 5.1.2.1.2 */ + int reordering_window; + + if (pdcp_p->seq_num_size == 7) + reordering_window = REORDERING_WINDOW_SN_7BIT; + else + reordering_window = REORDERING_WINDOW_SN_12BIT; + + if (sequence_number - pdcp_p->last_submitted_pdcp_rx_sn > reordering_window || + (pdcp_p->last_submitted_pdcp_rx_sn - sequence_number >= 0 && + pdcp_p->last_submitted_pdcp_rx_sn - sequence_number < reordering_window)) { + /* TODO: specs say to decipher and do header decompression */ + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"discard PDU, out of\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + LOG_W(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer_pP, __func__); + /* TODO: indicate integrity verification failure to upper layer */ + return FALSE; + + } else if (pdcp_p->next_pdcp_rx_sn - sequence_number > reordering_window) { + pdcp_p->rx_hfn++; + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + pdcp_p->next_pdcp_rx_sn = sequence_number + 1; + + } else if (sequence_number - pdcp_p->next_pdcp_rx_sn >= reordering_window) { + rx_hfn_for_count = pdcp_p->rx_hfn - 1; + pdcp_sn_for_count = sequence_number; + + } else if (sequence_number >= pdcp_p->next_pdcp_rx_sn) { + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + pdcp_p->next_pdcp_rx_sn = sequence_number + 1; + if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) { + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->rx_hfn++; + } + + } else { /* sequence_number < pdcp_p->next_pdcp_rx_sn */ + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + } + + if (pdcp_p->security_activated == 1) { + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } + + security_ok = pdcp_validate_security(ctxt_pP, + pdcp_p, + srb_flagP, + rb_idP, + pdcp_header_len, + rx_hfn_for_count, + pdcp_sn_for_count, + sdu_buffer_pP->data, + sdu_buffer_sizeP - pdcp_tailer_len) == 0; + + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } } else { - start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + security_ok = 1; } - pdcp_validate_security( - ctxt_pP, - pdcp_p, - srb_flagP, - rb_idP, - pdcp_header_len, - sequence_number, - sdu_buffer_pP->data, - sdu_buffer_sizeP - pdcp_tailer_len); + if (security_ok == 0) { + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/AM PDU\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + LOG_W(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer_pP, __func__); + /* TODO: indicate integrity verification failure to upper layer */ + return FALSE; + } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + /* TODO: specs say we have to store this PDU in a list and then deliver + * stored packets to upper layers according to a well defined + * procedure. The code below that deals with delivery is today + * too complex to do this properly, so we only send the current + * received packet. This is not correct and has to be fixed + * some day. + * In the meantime, let's pretend the last submitted PDCP SDU + * is the current one. + * TODO: we also have to deal with re-establishment PDU (control PDUs) + * that contain no SDU. + */ + + pdcp_p->last_submitted_pdcp_rx_sn = sequence_number; + + break; + } /* case RLC_MODE_AM */ + + case RLC_MODE_UM: + /* process as described in 36.323 5.1.2.1.3 */ + if (sequence_number < pdcp_p->next_pdcp_rx_sn) { + pdcp_p->rx_hfn++; + } + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + pdcp_p->next_pdcp_rx_sn = sequence_number + 1; + if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) { + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->rx_hfn++; + } + + if (pdcp_p->security_activated == 1) { + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } + + security_ok = pdcp_validate_security(ctxt_pP, + pdcp_p, + srb_flagP, + rb_idP, + pdcp_header_len, + rx_hfn_for_count, + pdcp_sn_for_count, + sdu_buffer_pP->data, + sdu_buffer_sizeP - pdcp_tailer_len) == 0; + + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } } else { - stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + security_ok = 1; } - } -#endif - } else { + if (security_ok == 0) { + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/UM PDU\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + LOG_W(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer_pP, __func__); + /* TODO: indicate integrity verification failure to upper layer */ + return FALSE; + } + + break; + + default: + LOG_E(PDCP, "bad RLC mode, cannot happen.\n"); + exit(1); + } /* switch (pdcp_p->rlc_mode) */ + } else { /* MBMS_flagP == 0 */ payload_offset=0; } @@ -709,36 +856,36 @@ pdcp_data_ind( * from its second byte (skipping 0th and 1st octets, i.e. * PDCP header) */ -#if defined(LINK_ENB_PDCP_TO_GTPV1U) - - if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) { - MSC_LOG_TX_MESSAGE( - MSC_PDCP_ENB, - MSC_GTPU_ENB, - NULL,0, - "0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u", - ctxt_pP->rnti, - rb_id + 4, - sdu_buffer_sizeP - payload_offset); - //LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset); - gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, - sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX); - AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); - memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset); - message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ); - AssertFatal(message_p != NULL, "OUT OF MEMORY"); - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4; - itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); - packet_forwarded = TRUE; + + if (LINK_ENB_PDCP_TO_GTPV1U) { + if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) { + MSC_LOG_TX_MESSAGE( + MSC_PDCP_ENB, + MSC_GTPU_ENB, + NULL,0, + "0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u", + ctxt_pP->rnti, + rb_id + 4, + sdu_buffer_sizeP - payload_offset); + //LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset); + gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, + sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX); + AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); + memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset); + message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ); + AssertFatal(message_p != NULL, "OUT OF MEMORY"); + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4; + itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); + packet_forwarded = TRUE; + } + } else { + packet_forwarded = FALSE; } -#else - packet_forwarded = FALSE; -#endif #ifdef MBMS_MULTICAST_OUT if ((MBMS_flagP != 0) && (mbms_socket != -1)) { @@ -773,39 +920,45 @@ pdcp_data_ind( // set ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst for IP layer here if (ctxt_pP->enb_flag == ENB_FLAG_NO) { ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id; -#if defined(ENABLE_USE_MME) - /* for the UE compiled in S1 mode, we need 1 here - * for the UE compiled in noS1 mode, we need 0 - * TODO: be sure of this - */ - if (nfapi_mode == 3) { + if (EPC_MODE_ENABLED) { + /* for the UE compiled in S1 mode, we need 1 here + * for the UE compiled in noS1 mode, we need 0 + * TODO: be sure of this + */ + if (nfapi_mode == 3) { #ifdef UESIM_EXPANSION - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0; + + if (UE_NAS_USE_TUN) { + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + } else { + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0; + } + #else - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; #endif - } else { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1; + } else { // nfapi_mode + if (UE_NAS_USE_TUN) { + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + } else { + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1; + } + } // nfapi_mode } - -#endif } else { ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * LTE_maxDRB); ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; } - // new_sdu_p->data->inst is set again in UE case so move to above. - //Panos: Commented this out because it cancels the assignment in #if defined(ENABLE_USE_MME) case - //((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id; -#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU - static uint32_t pdcp_inst = 0; - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++; - LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size); -#endif - //((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1; //pdcp_inst++; - memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], \ - &sdu_buffer_pP->data[payload_offset], \ + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { + static uint32_t pdcp_inst = 0; + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++; + LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size); + } + + memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], + &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset); list_add_tail_eurecom (new_sdu_p, sdu_list_p); } @@ -833,20 +986,9 @@ pdcp_data_ind( Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; - - if (oo_flag == 1 ) - Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; -#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - else { - AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", - PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); - } - -#endif } free_mem_block(sdu_buffer_pP, __func__); @@ -928,7 +1070,6 @@ pdcp_run ( pdcp_enb[ctxt_pP->module_id].subframe= ctxt_pP->subframe; pdcp_update_stats(ctxt_pP); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN); -#if defined(ENABLE_ITTI) MessageDef *msg_p; int result; protocol_ctxt_t ctxt; @@ -965,10 +1106,8 @@ pdcp_run ( RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).sdu_size, RRC_DCCH_DATA_REQ (msg_p).sdu_p, - RRC_DCCH_DATA_REQ (msg_p).mode -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , NULL, NULL -#endif + RRC_DCCH_DATA_REQ (msg_p).mode, + NULL, NULL ); if (result != TRUE) @@ -1005,13 +1144,8 @@ pdcp_run ( } } while(msg_p != NULL); -#endif // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer -#if defined(LINK_ENB_PDCP_TO_GTPV1U) - - if (ctxt_pP->enb_flag == ENB_FLAG_NO) -#endif - { + if (LINK_ENB_PDCP_TO_GTPV1U && ctxt_pP->enb_flag == ENB_FLAG_NO) { pdcp_fifo_read_input_sdus(ctxt_pP); } @@ -1125,11 +1259,9 @@ rrc_pdcp_config_asn1_req ( const uint8_t security_modeP, uint8_t *const kRRCenc_pP, uint8_t *const kRRCint_pP, - uint8_t *const kUPenc_pP -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - ,LTE_PMCH_InfoList_r9_t *const pmch_InfoList_r9_pP -#endif - ,rb_id_t *const defaultDRB + uint8_t *const kUPenc_pP, + LTE_PMCH_InfoList_r9_t *const pmch_InfoList_r9_pP, + rb_id_t *const defaultDRB ) //----------------------------------------------------------------------------- { @@ -1152,11 +1284,9 @@ rrc_pdcp_config_asn1_req ( hashtable_rc_t h_rc; hash_key_t key_defaultDRB = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_defaultDRB_rc; -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) int i,j; LTE_MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; LTE_MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL; -#endif LOG_T(PDCP, PROTOCOL_CTXT_FMT" %s() SRB2ADD %p DRB2ADD %p DRB2RELEASE %p\n", PROTOCOL_CTXT_ARGS(ctxt_pP), __FUNCTION__, @@ -1446,8 +1576,6 @@ rrc_pdcp_config_asn1_req ( } } -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - if (pmch_InfoList_r9_pP != NULL) { for (i=0; i<pmch_InfoList_r9_pP->list.count; i++) { mbms_SessionInfoList_r9_p = &(pmch_InfoList_r9_pP->list.array[i]->mbms_SessionInfoList_r9); @@ -1509,7 +1637,6 @@ rrc_pdcp_config_asn1_req ( } } -#endif return 0; } @@ -1569,22 +1696,23 @@ pdcp_config_req_asn1 ( pdcp_pP->status_report = rb_reportP; if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) { - pdcp_pP->seq_num_size = PDCP_SN_12BIT; + pdcp_pP->seq_num_size = 12; + pdcp_pP->maximum_pdcp_rx_sn = (1 << 12) - 1; } else if (rb_snP == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) { - pdcp_pP->seq_num_size = PDCP_SN_7BIT; + pdcp_pP->seq_num_size = 7; + pdcp_pP->maximum_pdcp_rx_sn = (1 << 7) - 1; } else { - pdcp_pP->seq_num_size = PDCP_SN_5BIT; + pdcp_pP->seq_num_size = 5; + pdcp_pP->maximum_pdcp_rx_sn = (1 << 5) - 1; } pdcp_pP->rlc_mode = rlc_modeP; pdcp_pP->next_pdcp_tx_sn = 0; pdcp_pP->next_pdcp_rx_sn = 0; - pdcp_pP->next_pdcp_rx_sn_before_integrity = 0; pdcp_pP->tx_hfn = 0; pdcp_pP->rx_hfn = 0; pdcp_pP->last_submitted_pdcp_rx_sn = 4095; pdcp_pP->first_missing_pdu = -1; - pdcp_pP->rx_hfn_offset = 0; LOG_I(PDCP, PROTOCOL_PDCP_CTXT_FMT" Action ADD LCID %d (%s id %d) " "configured with SN size %d bits and RLC %s\n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), @@ -1673,7 +1801,6 @@ pdcp_config_req_asn1 ( memset(pdcp_pP, 0, sizeof(pdcp_t)); break; -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) case CONFIG_ACTION_MBMS_ADD: case CONFIG_ACTION_MBMS_MODIFY: @@ -1693,7 +1820,6 @@ pdcp_config_req_asn1 ( } break; -#endif case CONFIG_ACTION_SET_SECURITY_MODE: pdcp_config_set_security( @@ -1904,39 +2030,28 @@ rrc_pdcp_config_req ( //----------------------------------------------------------------------------- -int -pdcp_module_init ( - void -) -//----------------------------------------------------------------------------- -{ -#ifdef PDCP_USE_RT_FIFO - int ret; - ret=rtf_create(PDCP2NW_DRIVER_FIFO,32768); - - if (ret < 0) { - LOG_E(PDCP, "Cannot create PDCP2NW_DRIVER_FIFO fifo %d (ERROR %d)\n", PDCP2NW_DRIVER_FIFO, ret); - return -1; - } else { - LOG_D(PDCP, "Created PDCP2NAS fifo %d\n", PDCP2NW_DRIVER_FIFO); - rtf_reset(PDCP2NW_DRIVER_FIFO); +uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { + /* temporary enforce netlink when UE_NAS_USE_TUN is set, + this is while switching from noS1 as build option + to noS1 as config option */ + if ( pdcp_optmask & UE_NAS_USE_TUN_BIT) { + pdcp_params.optmask = pdcp_params.optmask | PDCP_USE_NETLINK_BIT ; } - ret=rtf_create(NW_DRIVER2PDCP_FIFO,32768); + pdcp_params.optmask = pdcp_params.optmask | pdcp_optmask ; + LOG_I(PDCP, "pdcp init,%s %s\n", + ((LINK_ENB_PDCP_TO_GTPV1U)?"usegtp":""), + ((PDCP_USE_NETLINK)?"usenetlink":"")); - if (ret < 0) { - LOG_E(PDCP, "Cannot create NW_DRIVER2PDCP_FIFO fifo %d (ERROR %d)\n", NW_DRIVER2PDCP_FIFO, ret); - return -1; - } else { - LOG_D(PDCP, "Created NW_DRIVER2PDCP_FIFO fifo %d\n", NW_DRIVER2PDCP_FIFO); - rtf_reset(NW_DRIVER2PDCP_FIFO); + if (PDCP_USE_NETLINK) { + if(UE_NAS_USE_TUN) { + netlink_init_tun(); + } else { + netlink_init(); + } } - pdcp_2_nas_irq = 0; - pdcp_input_sdu_remaining_size_to_read=0; - pdcp_input_sdu_size_read=0; -#endif - return 0; + return pdcp_params.optmask ; } //----------------------------------------------------------------------------- @@ -1970,10 +2085,6 @@ pdcp_free ( void pdcp_module_cleanup (void) //----------------------------------------------------------------------------- { -#ifdef PDCP_USE_RT_FIFO - rtf_destroy(NW_DRIVER2PDCP_FIFO); - rtf_destroy(PDCP2NW_DRIVER_FIFO); -#endif } //----------------------------------------------------------------------------- @@ -1982,10 +2093,8 @@ void pdcp_layer_init(void) { module_id_t instance; int i,j; -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) mbms_session_id_t session_id; mbms_service_id_t service_id; -#endif /* * Initialize SDU list */ @@ -1994,30 +2103,23 @@ void pdcp_layer_init(void) AssertFatal(pdcp_coll_p != NULL, "UNRECOVERABLE error, PDCP hashtable_create failed"); for (instance = 0; instance < MAX_MOBILES_PER_ENB; instance++) { -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - for (service_id = 0; service_id < LTE_maxServiceCount; service_id++) { for (session_id = 0; session_id < LTE_maxSessionPerPMCH; session_id++) { memset(&pdcp_mbms_array_ue[instance][service_id][session_id], 0, sizeof(pdcp_mbms_t)); } } -#endif pdcp_eNB_UE_instance_to_rnti[instance] = NOT_A_RNTI; } pdcp_eNB_UE_instance_to_rnti_index = 0; for (instance = 0; instance < NUMBER_OF_eNB_MAX; instance++) { -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - for (service_id = 0; service_id < LTE_maxServiceCount; service_id++) { for (session_id = 0; session_id < LTE_maxSessionPerPMCH; session_id++) { memset(&pdcp_mbms_array_eNB[instance][service_id][session_id], 0, sizeof(pdcp_mbms_t)); } } - -#endif } #ifdef MBMS_MULTICAST_OUT @@ -2080,7 +2182,3 @@ void pdcp_layer_cleanup (void) #endif } - -#ifdef PDCP_USE_RT_FIFO - EXPORT_SYMBOL(pdcp_2_nas_irq); -#endif //PDCP_USE_RT_FIFO diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 69157b639837bf146ef29b8306f997597314809b..8f30608cd8a8504a21953606834aaa0279227f1a 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -26,7 +26,7 @@ * \version 1.0 */ -/** @defgroup _pdcp PDCP +/** @defgroup _pdcp PDCP * @ingroup _oai2 * @{ */ @@ -35,8 +35,8 @@ # define __PDCP_H__ //----------------------------------------------------------------------------- #ifndef NON_ACCESS_STRATUM -#include "UTIL/MEM/mem_block.h" -#include "UTIL/LISTS/list.h" + #include "UTIL/MEM/mem_block.h" + #include "UTIL/LISTS/list.h" #endif //NON_ACCESS_STRATUM //----------------------------------------------------------------------------- #include "RRC/LTE/rrc_defs.h" @@ -47,10 +47,23 @@ #include "LTE_SRB-ToAddMod.h" #include "LTE_SRB-ToAddModList.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) -#include "LTE_MBMS-SessionInfoList-r9.h" -#include "LTE_PMCH-InfoList-r9.h" + #include "LTE_MBMS-SessionInfoList-r9.h" + #include "LTE_PMCH-InfoList-r9.h" #endif +#define PDCP_USE_NETLINK_BIT (1<< 11) +#define LINK_ENB_PDCP_TO_IP_DRIVER_BIT (1<< 13) +#define LINK_ENB_PDCP_TO_GTPV1U_BIT (1<< 14) +#define UE_NAS_USE_TUN_BIT (1<< 15) +typedef struct { + uint64_t optmask; +} pdcp_params_t; + +#define PDCP_USE_NETLINK ( get_pdcp_optmask() & PDCP_USE_NETLINK_BIT) +#define LINK_ENB_PDCP_TO_IP_DRIVER ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_IP_DRIVER_BIT) +#define LINK_ENB_PDCP_TO_GTPV1U ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_GTPV1U_BIT) +#define UE_NAS_USE_TUN ( get_pdcp_optmask() & UE_NAS_USE_TUN_BIT) +uint64_t get_pdcp_optmask(void); extern pthread_t pdcp_thread; extern pthread_attr_t pdcp_thread_attr; @@ -61,8 +74,8 @@ extern int pdcp_instance_cnt; #define PROTOCOL_PDCP_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u] " #define PROTOCOL_PDCP_CTXT_ARGS(CTXT_Pp, pDCP_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ - (pDCP_Pp->is_srb) ? "SRB" : "DRB",\ - pDCP_Pp->rb_id + (pDCP_Pp->is_srb) ? "SRB" : "DRB",\ + pDCP_Pp->rb_id int init_pdcp_thread(void); void cleanup_pdcp_thread(void); @@ -95,7 +108,7 @@ uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]; uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]; uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]; -void pdcp_update_perioidical_stats(const protocol_ctxt_t* const ctxt_pP); +void pdcp_update_perioidical_stats(const protocol_ctxt_t *const ctxt_pP); /*Packet Probing for agent PDCP*/ @@ -106,12 +119,12 @@ typedef struct pdcp_enb_s { uint16_t uid[MAX_MOBILES_PER_ENB]; rnti_t rnti[MAX_MOBILES_PER_ENB]; uint16_t num_ues; - + uint64_t sfn; frame_t frame; sub_frame_t subframe; - -} pdcp_enb_t; + +} pdcp_enb_t; pdcp_enb_t pdcp_enb[MAX_NUM_CCs]; @@ -136,7 +149,7 @@ typedef struct pdcp_s { boolean_t is_ue; boolean_t is_srb; - /* Configured security algorithms */ + /* Configured security algorithms */ uint8_t cipheringAlgorithm; uint8_t integrityProtAlgorithm; @@ -164,13 +177,12 @@ typedef struct pdcp_s { */ pdcp_sn_t next_pdcp_tx_sn; pdcp_sn_t next_pdcp_rx_sn; - pdcp_sn_t next_pdcp_rx_sn_before_integrity; + pdcp_sn_t maximum_pdcp_rx_sn; /* * TX and RX Hyper Frame Numbers */ pdcp_hfn_t tx_hfn; pdcp_hfn_t rx_hfn; - pdcp_hfn_offset_t rx_hfn_offset; // related to sn mismatch /* * SN of the last PDCP SDU delivered to upper layers @@ -224,19 +236,19 @@ typedef struct pdcp_mbms_s { * @ingroup _pdcp */ boolean_t pdcp_data_req( - protocol_ctxt_t* ctxt_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_id, - const mui_t muiP, - const confirm_t confirmP, \ - const sdu_size_t sdu_buffer_size, - unsigned char* const sdu_buffer, - const pdcp_transmission_mode_t mode + protocol_ctxt_t *ctxt_pP, + const srb_flag_t srb_flagP, + const rb_id_t rb_id, + const mui_t muiP, + const confirm_t confirmP, \ + const sdu_size_t sdu_buffer_size, + unsigned char *const sdu_buffer, + const pdcp_transmission_mode_t mode #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,const uint32_t * const sourceL2Id - ,const uint32_t * const destinationL2Id + ,const uint32_t *const sourceL2Id + ,const uint32_t *const destinationL2Id #endif - ); +); /*! \fn boolean_t pdcp_data_ind(const protocol_ctxt_t* const, srb_flag_t, MBMS_flag_t, rb_id_t, sdu_size_t, mem_block_t*, boolean_t) * \brief This functions handles data transfer indications coming from RLC @@ -252,12 +264,12 @@ boolean_t pdcp_data_req( * @ingroup _pdcp */ boolean_t pdcp_data_ind( - const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_id, - const sdu_size_t sdu_buffer_size, - mem_block_t* const sdu_buffer); + const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, + mem_block_t *const sdu_buffer); /*! \fn void rrc_pdcp_config_req(const protocol_ctxt_t* const ,uint32_t,rb_id_t,uint8_t) * \brief This functions initializes relevant PDCP entity @@ -270,11 +282,11 @@ boolean_t pdcp_data_ind( * @ingroup _pdcp */ void rrc_pdcp_config_req ( - const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, - const uint32_t actionP, - const rb_id_t rb_idP, - const uint8_t security_modeP); + const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const uint32_t actionP, + const rb_id_t rb_idP, + const uint8_t security_modeP); /*! \fn bool rrc_pdcp_config_asn1_req (const protocol_ctxt_t* const , SRB_ToAddModList_t* srb2add_list, DRB_ToAddModList_t* drb2add_list, DRB_ToReleaseList_t* drb2release_list) * \brief Function for RRC to configure a Radio Bearer. @@ -291,19 +303,19 @@ void rrc_pdcp_config_req ( * \return A status about the processing, OK or error code. */ boolean_t rrc_pdcp_config_asn1_req ( - const protocol_ctxt_t* const ctxt_pP, - LTE_SRB_ToAddModList_t *const srb2add_list, - LTE_DRB_ToAddModList_t *const drb2add_list, - LTE_DRB_ToReleaseList_t *const drb2release_list, - const uint8_t security_modeP, - uint8_t *const kRRCenc, - uint8_t *const kRRCint, - uint8_t *const kUPenc + const protocol_ctxt_t *const ctxt_pP, + LTE_SRB_ToAddModList_t *const srb2add_list, + LTE_DRB_ToAddModList_t *const drb2add_list, + LTE_DRB_ToReleaseList_t *const drb2release_list, + const uint8_t security_modeP, + uint8_t *const kRRCenc, + uint8_t *const kRRCint, + uint8_t *const kUPenc #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 + ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 #endif - ,rb_id_t *const defaultDRB - ); + ,rb_id_t *const defaultDRB +); /*! \fn boolean_t pdcp_config_req_asn1 (const protocol_ctxt_t* const ctxt_pP, srb_flag_t srb_flagP, uint32_t action, rb_id_t rb_id, uint8_t rb_sn, uint8_t rb_report, uint16_t header_compression_profile, uint8_t security_mode) * \brief Function for RRC to configure a Radio Bearer. @@ -326,36 +338,36 @@ boolean_t rrc_pdcp_config_asn1_req ( * \return A status about the processing, OK or error code. */ boolean_t pdcp_config_req_asn1 ( - const protocol_ctxt_t* const ctxt_pP, - pdcp_t *const pdcp_pP, - const srb_flag_t srb_flagP, - const rlc_mode_t rlc_mode, - const uint32_t action, - const uint16_t lc_id, - const uint16_t mch_id, - const rb_id_t rb_id, - const uint8_t rb_sn, - const uint8_t rb_report, - const uint16_t header_compression_profile, - const uint8_t security_mode, - uint8_t *const kRRCenc, - uint8_t *const kRRCint, - uint8_t *const kUPenc); + const protocol_ctxt_t *const ctxt_pP, + pdcp_t *const pdcp_pP, + const srb_flag_t srb_flagP, + const rlc_mode_t rlc_mode, + const uint32_t action, + const uint16_t lc_id, + const uint16_t mch_id, + const rb_id_t rb_id, + const uint8_t rb_sn, + const uint8_t rb_report, + const uint16_t header_compression_profile, + const uint8_t security_mode, + uint8_t *const kRRCenc, + uint8_t *const kRRCint, + uint8_t *const kUPenc); /*! \fn void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP) * \brief Function (for RRC) to add a new UE in PDCP module * \param[in] ctxt_pP Running context. * \return A status about the processing, OK or error code. */ -void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP); - +void pdcp_add_UE(const protocol_ctxt_t *const ctxt_pP); + /*! \fn boolean_t pdcp_remove_UE(const protocol_ctxt_t* const ctxt_pP) -* \brief Function for RRC to remove UE from PDCP module hashtable +* \brief Function for RRC to remove UE from PDCP module hashtable * \param[in] ctxt_pP Running context. * \return A status about the processing, OK or error code. */ boolean_t pdcp_remove_UE( - const protocol_ctxt_t* const ctxt_pP); + const protocol_ctxt_t *const ctxt_pP); /*! \fn void rrc_pdcp_config_release( const protocol_ctxt_t* const, rb_id_t) * \brief This functions is unused @@ -375,22 +387,18 @@ boolean_t pdcp_remove_UE( * @ingroup _pdcp */ void pdcp_run ( - const protocol_ctxt_t* const ctxt_pP); -int pdcp_module_init (void); + const protocol_ctxt_t *const ctxt_pP); +uint64_t pdcp_module_init (uint64_t pdcp_optmask); void pdcp_module_cleanup (void); void pdcp_layer_init (void); void pdcp_layer_cleanup (void); -#if defined(PDCP_USE_NETLINK_QUEUES) -int pdcp_netlink_init (void); - -#endif #define PDCP2NW_DRIVER_FIFO 21 #define NW_DRIVER2PDCP_FIFO 22 -int pdcp_fifo_flush_sdus ( const protocol_ctxt_t* const ctxt_pP); -int pdcp_fifo_read_input_sdus_remaining_bytes ( const protocol_ctxt_t* const ctxt_pP); -int pdcp_fifo_read_input_sdus ( const protocol_ctxt_t* const ctxt_pP); -void pdcp_fifo_read_input_sdus_from_otg ( const protocol_ctxt_t* const ctxt_pP); +int pdcp_fifo_flush_sdus ( const protocol_ctxt_t *const ctxt_pP); +int pdcp_fifo_read_input_sdus_remaining_bytes ( const protocol_ctxt_t *const ctxt_pP); +int pdcp_fifo_read_input_sdus ( const protocol_ctxt_t *const ctxt_pP); +void pdcp_fifo_read_input_sdus_from_otg ( const protocol_ctxt_t *const ctxt_pP); //----------------------------------------------------------------------------- @@ -439,26 +447,26 @@ struct sockaddr_in pdcp_sin; void pdcp_pc5_socket_init(void); typedef struct { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t traffic_type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; + rb_id_t rb_id; + sdu_size_t data_size; + signed int inst; + ip_traffic_type_t traffic_type; + uint32_t sourceL2Id; + uint32_t destinationL2Id; } __attribute__((__packed__)) pc5s_header_t; //new PC5S-message typedef struct { - unsigned char bytes[PC5_SIGNALLING_PAYLOAD_SIZE]; + unsigned char bytes[PC5_SIGNALLING_PAYLOAD_SIZE]; } __attribute__((__packed__)) PC5SignallingMessage ; //example of PC5-S messages typedef struct { - pc5s_header_t pc5s_header; - union { - uint8_t status; - PC5SignallingMessage pc5_signalling_message; - } pc5sPrimitive; + pc5s_header_t pc5s_header; + union { + uint8_t status; + PC5SignallingMessage pc5_signalling_message; + } pc5sPrimitive; } __attribute__((__packed__)) sidelink_pc5s_element; @@ -479,29 +487,18 @@ typedef struct { #define REORDERING_WINDOW_SN_7BIT 64 #define REORDERING_WINDOW_SN_12BIT 2048 -/* - * SN size - */ -#define PDCP_SN_5BIT 5 -#define PDCP_SN_7BIT 7 -#define PDCP_SN_12BIT 12 - - signed int pdcp_2_nas_irq; pdcp_stats_t UE_pdcp_stats[MAX_MOBILES_PER_ENB]; pdcp_stats_t eNB_pdcp_stats[NUMBER_OF_eNB_MAX]; -//pdcp_t pdcp_array_srb_ue[MAX_MOBILES_PER_ENB][2]; -//pdcp_t pdcp_array_drb_ue[MAX_MOBILES_PER_ENB][maxDRB]; -//pdcp_t pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][2]; -//pdcp_t pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][maxDRB]; + // for UE code conly rnti_t pdcp_UE_UE_module_id_to_rnti[MAX_MOBILES_PER_ENB]; rnti_t pdcp_eNB_UE_instance_to_rnti[MAX_MOBILES_PER_ENB]; // for noS1 mode unsigned int pdcp_eNB_UE_instance_to_rnti_index; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) -pdcp_mbms_t pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][LTE_maxServiceCount][LTE_maxSessionPerPMCH]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h -pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][LTE_maxServiceCount][LTE_maxSessionPerPMCH]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h + pdcp_mbms_t pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][LTE_maxServiceCount][LTE_maxSessionPerPMCH]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h + pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][LTE_maxServiceCount][LTE_maxSessionPerPMCH]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h #endif sdu_size_t pdcp_output_sdu_bytes_to_write; sdu_size_t pdcp_output_header_bytes_to_write; @@ -514,33 +511,33 @@ sdu_size_t pdcp_input_sdu_size_read; sdu_size_t pdcp_input_sdu_remaining_size_to_read; #define PDCP_COLL_KEY_VALUE(mODULE_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ - ((hash_key_t)mODULE_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(rB_iD)) << 25) | \ - (((hash_key_t)(iS_sRB)) << 33) | \ - (((hash_key_t)(0x55)) << 34)) + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(rB_iD)) << 25) | \ + (((hash_key_t)(iS_sRB)) << 33) | \ + (((hash_key_t)(0x55)) << 34)) // hash key to the same PDCP as indexed by PDCP_COLL_KEY_VALUE(... rB_iD, iS_sRB=0) where rB_iD // is the default DRB ID. The hidden code 0x55 indicates the key is indexed by (rB_iD,is_sRB) // whereas the hidden code 0xaa indicates the key is for default DRB only #define PDCP_COLL_KEY_DEFAULT_DRB_VALUE(mODULE_iD, rNTI, iS_eNB) \ - ((hash_key_t)mODULE_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(0xff)) << 25) | \ - (((hash_key_t)(0x00)) << 33) | \ - (((hash_key_t)(0xaa)) << 34)) + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(0xff)) << 25) | \ + (((hash_key_t)(0x00)) << 33) | \ + (((hash_key_t)(0xaa)) << 34)) // service id max val is maxServiceCount = 16 (asn1_constants.h) #define PDCP_COLL_KEY_MBMS_VALUE(mODULE_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \ - ((hash_key_t)mODULE_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(sERVICE_ID)) << 32) | \ - (((hash_key_t)(sESSION_ID)) << 37) | \ - (((hash_key_t)(0x0000000000000001)) << 63)) + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(sERVICE_ID)) << 32) | \ + (((hash_key_t)(sESSION_ID)) << 37) | \ + (((hash_key_t)(0x0000000000000001)) << 63)) extern hash_table_t *pdcp_coll_p; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 906fbaba5a4f626cb2457c89f9687138f88b36b0..a55cf906a0f94593ab9e9a55c2d8b02b4c8729ec 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -30,8 +30,8 @@ */ #define PDCP_FIFO_C -#define PDCP_DEBUG 1 -//#define DEBUG_PDCP_FIFO_FLUSH_SDU + + extern int otg_enabled; @@ -62,7 +62,7 @@ extern int otg_enabled; #include "assertions.h" -#ifdef PDCP_USE_NETLINK + #include <sys/socket.h> #include <linux/netlink.h> #include "NETWORK_DRIVER/UE_IP/constant.h" @@ -73,1153 +73,697 @@ extern struct nlmsghdr *nas_nlh_tx; extern struct nlmsghdr *nas_nlh_rx; extern struct iovec nas_iov_tx; extern struct iovec nas_iov_rx; -#ifdef UE_NAS_USE_TUN + extern int nas_sock_fd[MAX_MOBILES_PER_ENB]; -#else -extern int nas_sock_fd; -#endif + extern struct msghdr nas_msg_tx; extern struct msghdr nas_msg_rx; -unsigned char pdcp_read_state_g = 0; + extern uint8_t nfapi_mode; #ifdef UESIM_EXPANSION -extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; -#endif + extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; #endif extern Packet_OTG_List_t *otg_pdcp_buffer; -#if defined(LINK_ENB_PDCP_TO_GTPV1U) + + # include "gtpv1u_eNB_task.h" # include "gtpv1u_eNB_defs.h" -#endif -extern int gtpv1u_new_data_req( uint8_t enb_module_idP, rnti_t ue_rntiP, uint8_t rab_idP, uint8_t *buffer_pP, uint32_t buf_lenP, uint32_t buf_offsetP); -/* Prevent de-queueing the same PDCP SDU from the queue twice - * by multiple threads. This has happened in TDD when thread-odd - * is flushing a PDCP SDU after UE_RX() processing; whereas - * thread-even is at a special-subframe, skips the UE_RX() process - * and goes straight to the PDCP SDU flushing. The 2nd flushing - * dequeues the same SDU again causing unexpected behavior. - * - * comment out the MACRO below to disable this protection - */ -#define PDCP_SDU_FLUSH_LOCK - -#ifdef PDCP_SDU_FLUSH_LOCK -static pthread_mutex_t mtex = PTHREAD_MUTEX_INITIALIZER; -#endif +extern int gtpv1u_new_data_req( uint8_t enb_module_idP, rnti_t ue_rntiP, uint8_t rab_idP, uint8_t *buffer_pP, uint32_t buf_lenP, uint32_t buf_offsetP); -pdcp_data_req_header_t pdcp_read_header_g; +void debug_pdcp_pc5s_sdu(sidelink_pc5s_element *sl_pc5s_msg, char *title) { + LOG_I(PDCP,"%s: \nPC5S message, header traffic_type: %d)\n", title, sl_pc5s_msg->pc5s_header.traffic_type); + LOG_I(PDCP,"PC5S message, header rb_id: %d)\n", sl_pc5s_msg->pc5s_header.rb_id); + LOG_I(PDCP,"PC5S message, header data_size: %d)\n", sl_pc5s_msg->pc5s_header.data_size); + LOG_I(PDCP,"PC5S message, header inst: %d)\n", sl_pc5s_msg->pc5s_header.inst); + LOG_I(PDCP,"PC5-S message, sourceL2Id: 0x%08x\n)\n", sl_pc5s_msg->pc5s_header.sourceL2Id); + LOG_I(PDCP,"PC5-S message, destinationL1Id: 0x%08x\n)\n", sl_pc5s_msg->pc5s_header.destinationL2Id); +} //----------------------------------------------------------------------------- -int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) -{ - //----------------------------------------------------------------------------- - - //#if defined(PDCP_USE_NETLINK) && defined(LINUX) - int ret = 0; - //#endif - -#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU -#define THREAD_NAME_LEN 16 - static char threadname[THREAD_NAME_LEN]; - ret = pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN); - if (ret != 0) - { - perror("pthread_getname_np : "); - exit_fun("Error getting thread name"); - } -#undef THREAD_NAME_LEN -#endif - -#ifdef PDCP_SDU_FLUSH_LOCK - ret = pthread_mutex_trylock(&mtex); - if (ret == EBUSY) { -#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU - LOG_W(PDCP, "[%s] at SFN/SF=%d/%d wait for PDCP FIFO to be unlocked\n", - threadname, ctxt_pP->frame, ctxt_pP->subframe); -#endif - if (pthread_mutex_lock(&mtex)) { - exit_fun("PDCP_SDU_FLUSH_LOCK lock error!"); - } -#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU - LOG_I(PDCP, "[%s] at SFN/SF=%d/%d PDCP FIFO is unlocked\n", - threadname, ctxt_pP->frame, ctxt_pP->subframe); -#endif - } else if (ret != 0) { - exit_fun("PDCP_SDU_FLUSH_LOCK trylock error!"); - } - -#endif - - mem_block_t *sdu_p = list_get_head (&pdcp_sdu_list); - int bytes_wrote = 0; - int pdcp_nb_sdu_sent = 0; - uint8_t cont = 1; -#if defined(LINK_ENB_PDCP_TO_GTPV1U) - //MessageDef *message_p = NULL; -#endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 1 ); - while (sdu_p && cont) { - -#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU - LOG_D(PDCP, "[%s] SFN/SF=%d/%d inst=%d size=%d\n", - threadname, ctxt_pP->frame, ctxt_pP->subframe, - ((pdcp_data_ind_header_t*) sdu_p->data)->inst, - ((pdcp_data_ind_header_t *) sdu_p->data)->data_size); -#else - // Raphael: was suppressed by Raymond --> should be suppressed? - // value of sdu_p->data->inst is set in pdcp_data_ind - // it's necessary to set 1 in case of UE with S1. - //if (ctxt_pP->enb_flag){ - // ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; - //} -#endif - -#if defined(LINK_ENB_PDCP_TO_GTPV1U) - - if (ctxt_pP->enb_flag) { - AssertFatal(0, "Now execution should not go here"); - LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size); - gtpv1u_new_data_req( - ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p, - ctxt_pP->rnti,//rb_id/LTE_maxDRB, TO DO UE ID - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4, - &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]), - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, - 0); - - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu_p = list_get_head (&pdcp_sdu_list); - LOG_D(OTG,"After GTPV1U\n"); - continue; // loop again - } - -#endif /* defined(ENABLE_USE_MME) */ -#ifdef PDCP_DEBUG - LOG_I(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n", - ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); -#endif //PDCP_DEBUG - cont = 0; - -//TTN - for D2D (PC5S) -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - sidelink_pc5s_element *sl_pc5s_msg_recv = NULL; - char send_buf[BUFSIZE]; - int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; - - if (rb_id == 10) { //hardcoded for PC5-Signaling - //if ((rb_id == 28) | (rb_id == 29) | (rb_id == 30)) - -#ifdef PDCP_DEBUG - sl_pc5s_msg_recv = calloc(1, sizeof(sidelink_pc5s_element)); - memcpy((void*)sl_pc5s_msg_recv, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element)); - LOG_D(PDCP,"Received PC5S message, header traffic_type: %d)\n", sl_pc5s_msg_recv->pc5s_header.traffic_type); - LOG_D(PDCP,"Received PC5S message, header rb_id: %d)\n", sl_pc5s_msg_recv->pc5s_header.rb_id); - LOG_D(PDCP,"Received PC5S message, header data_size: %d)\n", sl_pc5s_msg_recv->pc5s_header.data_size); - LOG_D(PDCP,"Received PC5S message, header inst: %d)\n", sl_pc5s_msg_recv->pc5s_header.inst); - LOG_D(PDCP,"Received PC5-S message, sourceL2Id: 0x%08x\n)\n", sl_pc5s_msg_recv->pc5s_header.sourceL2Id); - LOG_D(PDCP,"Received PC5-S message, destinationL1Id: 0x%08x\n)\n", sl_pc5s_msg_recv->pc5s_header.destinationL2Id); - free(sl_pc5s_msg_recv); -#endif - memset(send_buf, 0, BUFSIZE); - memcpy((void *)send_buf, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element)); - - int prose_addr_len = sizeof(prose_pdcp_addr); - int n = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); - if (n < 0) { - LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n"); - exit(EXIT_FAILURE); - } - } -#endif - - if (!pdcp_output_sdu_bytes_to_write) { - if (!pdcp_output_header_bytes_to_write) { - pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t); - } - -#ifdef PDCP_USE_RT_FIFO - bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, - &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), - pdcp_output_header_bytes_to_write); - -#else -#ifdef PDCP_USE_NETLINK -#ifdef LINUX - memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), - pdcp_output_header_bytes_to_write); - nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write; -#endif //LINUX -#endif //PDCP_USE_NETLINK - - bytes_wrote = pdcp_output_header_bytes_to_write; -#endif //PDCP_USE_RT_FIFO - -#ifdef PDCP_DEBUG - LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n", - ctxt_pP->frame, - bytes_wrote); -#endif //PDCP_DEBUG - - if (bytes_wrote > 0) { - pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote; - - if (!pdcp_output_header_bytes_to_write) { // continue with sdu - pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; - AssertFatal(pdcp_output_sdu_bytes_to_write >= 0, "invalid data_size!"); - -#ifdef PDCP_USE_RT_FIFO - bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); -#else - -#ifdef PDCP_USE_NETLINK -#ifdef LINUX - memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu_p->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); - nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_SIZE, pdcp_output_sdu_bytes_to_write); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 1 ); -#ifdef UE_NAS_USE_TUN - ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); -#else - ret = sendmsg(nas_sock_fd,&nas_msg_tx,0); -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 0 ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_ERR, ret ); - - if (ret<0) { - LOG_E(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno); - MSC_LOG_TX_MESSAGE_FAILED( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id, - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size); - AssertFatal(1==0,"sendmsg failed for nas_sock_fd\n"); - break; - } else { - MSC_LOG_TX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id, - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size); - } - -#endif // LINUX -#endif //PDCP_USE_NETLINK - bytes_wrote= pdcp_output_sdu_bytes_to_write; -#endif // PDCP_USE_RT_FIFO - -#ifdef PDCP_DEBUG - LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n", - ctxt_pP->frame, - ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, - bytes_wrote, - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); -#endif //PDCP_DEBUG - - if (bytes_wrote > 0) { - pdcp_output_sdu_bytes_to_write -= bytes_wrote; - - if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU - // LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP); - LOG_D(PDCP, - "[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n", - ctxt_pP->frame, - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id, - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, - ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); - - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu_p = list_get_head (&pdcp_sdu_list); - } else { - LOG_D(PDCP, "1 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write); - AssertFatal(pdcp_output_sdu_bytes_to_write > 0, "pdcp_output_sdu_bytes_to_write cannot be negative!"); - } - } else { - LOG_W(PDCP, "2: RADIO->IP SEND SDU CONGESTION!\n"); - } - } else { - LOG_W(PDCP, "3: RADIO->IP SEND SDU CONGESTION!\n"); - } - } else { - LOG_D(PDCP, "4 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote); - } - } else { - // continue writing sdu -#ifdef PDCP_USE_RT_FIFO - bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, - (uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])), - pdcp_output_sdu_bytes_to_write); -#else // PDCP_USE_RT_FIFO - bytes_wrote = pdcp_output_sdu_bytes_to_write; -#endif // PDCP_USE_RT_FIFO - LOG_D(PDCP, "THINH 2 bytes_wrote = %d\n", bytes_wrote); - - if (bytes_wrote > 0) { - pdcp_output_sdu_bytes_to_write -= bytes_wrote; - - if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU - //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n"); - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu_p = list_get_head (&pdcp_sdu_list); - // LOG_D(PDCP, "rb sent a sdu from rab\n"); - } else { - LOG_D(PDCP, "5 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write); - } - } else { - LOG_D(PDCP, "6 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote); - } +int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { + mem_block_t *sdu_p; + int pdcp_nb_sdu_sent = 0; + int ret=0; + + while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL && ((pdcp_data_ind_header_t *)(sdu_p->data))->inst == ctxt_pP->module_id) { + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; + int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; + int sizeToWrite= sizeof (pdcp_data_ind_header_t) + + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; + + if (rb_id == 10) { //hardcoded for PC5-Signaling + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { + debug_pdcp_pc5s_sdu((sidelink_pc5s_element *)&(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), + "pdcp_fifo_flush_sdus received aPC5S message"); } - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 0 ); - -#ifdef PDCP_USE_RT_FIFO - if ((pdcp_nb_sdu_sent)) { - if ((pdcp_2_nas_irq > 0)) { -#ifdef PDCP_DEBUG - LOG_D(PDCP, "Frame %d : Trigger NAS RX interrupt\n", - ctxt_pP->frame); -#endif //PDCP_DEBUG - rt_pend_linux_srq (pdcp_2_nas_irq); - - } else { - LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n", - ctxt_pP->frame, - pdcp_2_nas_irq); - } - } - -#endif //PDCP_USE_RT_FIFO - -#ifdef PDCP_SDU_FLUSH_LOCK - if (pthread_mutex_unlock(&mtex)) exit_fun("PDCP_SDU_FLUSH_LOCK unlock error!"); -#endif + ret = sendto(pdcp_pc5_sockfd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), + sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr,sizeof(prose_pdcp_addr) ); + } else if (UE_NAS_USE_TUN) { + ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); + } else if (PDCP_USE_NETLINK) {//UE_NAS_USE_TUN + memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) sdu_p->data, sizeToWrite); + nas_nlh_tx->nlmsg_len = sizeToWrite; + ret = sendmsg(nas_sock_fd[0],&nas_msg_tx,0); + } // PDCP_USE_NETLINK + + AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); + list_remove_head (&pdcp_sdu_list); + free_mem_block (sdu_p, __func__); + pdcp_nb_sdu_sent ++; + } - return pdcp_nb_sdu_sent; + return pdcp_nb_sdu_sent; } //----------------------------------------------------------------------------- -int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) -{ -#ifdef UE_NAS_USE_TUN - protocol_ctxt_t ctxt = *ctxt_pP; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - pdcp_t* pdcp_p = NULL; - int len; - rb_id_t rab_id = DEFAULT_RAB_ID; - - do { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); - len = read(nas_sock_fd[ctxt_pP->module_id], &nl_rx_buf, NL_MAX_PAYLOAD); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); - - if (len<=0) continue; - LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - if (h_rc == HASH_TABLE_OK) { - LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", - ctxt.frame, ctxt.instance, len, rab_id); - - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", - ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, - ctxt.rnti, rab_id); - MSC_LOG_RX_MESSAGE((ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ctxt.instance, rab_id, rab_id, len); - - pdcp_data_req(&ctxt, SRB_FLAG_NO, rab_id, RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, len, (unsigned char *)nl_rx_buf, - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , NULL, NULL -#endif - ); - } else { - MSC_LOG_RX_DISCARDED_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ctxt.instance, rab_id, rab_id, len); - LOG_D(PDCP, - "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", - ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, - ctxt.rnti, rab_id, key); - } - } while (len > 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); - return len; - -#else /* UE_NAS_USE_TUN */ - -#ifdef PDCP_USE_NETLINK - protocol_ctxt_t ctxt_cpy = *ctxt_pP; - protocol_ctxt_t ctxt; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - struct pdcp_netlink_element_s* data_p = NULL; - /* avoid gcc warnings */ - (void)data_p; - module_id_t ue_id = 0; - pdcp_t* pdcp_p = NULL; - -//TTN for D2D (PC5S) -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - int prose_addr_len; - char send_buf[BUFSIZE], receive_buf[BUFSIZE]; - //int optval; - int bytes_received; - sidelink_pc5s_element *sl_pc5s_msg_recv = NULL; - sidelink_pc5s_element *sl_pc5s_msg_send = NULL; - //uint32_t sourceL2Id; - //uint32_t groupL2Id; - //module_id_t module_id = 0; - pc5s_header_t *pc5s_header; -#endif - -# if defined(PDCP_USE_NETLINK_QUEUES) - rb_id_t rab_id = 0; - - pdcp_transmission_mode_t pdcp_mode = PDCP_TRANSMISSION_MODE_UNKNOWN; - +int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) { + pdcp_data_req_header_t pdcp_read_header_g; + + if (UE_NAS_USE_TUN) { + protocol_ctxt_t ctxt = *ctxt_pP; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + pdcp_t *pdcp_p = NULL; + int len; + rb_id_t rab_id = DEFAULT_RAB_ID; + + do { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); + len = read(nas_sock_fd[ctxt_pP->module_id], &nl_rx_buf, NL_MAX_PAYLOAD); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); - while (pdcp_netlink_dequeue_element(ctxt_pP, &data_p) != 0) { - DevAssert(data_p != NULL); - rab_id = data_p->pdcp_read_header.rb_id % LTE_maxDRB; - // ctxt_pP->rnti is NOT_A_RNTI - ctxt_cpy.rnti = pdcp_module_id_to_rnti[ctxt_cpy.module_id][data_p->pdcp_read_header.inst]; - key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_cpy.rnti, ctxt_pP->enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + if (len<=0) continue; - if (h_rc != HASH_TABLE_OK) { - LOG_W(PDCP, PROTOCOL_CTXT_FMT" Dropped IP PACKET cause no PDCP instanciated\n", - PROTOCOL_CTXT_ARGS(ctxt_pP)); - free(data_p->data); - free(data_p); - data_p = NULL; - continue; - } + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - CHECK_CTXT_ARGS(&ctxt_cpy); - - AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB); - - if (rab_id != 0) { - LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " - "/ %d Bytes --->][PDCP][MOD %u][RB %u]\n", - ctxt_cpy.frame, - (ctxt_cpy.enb_flag) ? "eNB" : "UE", - data_p->pdcp_read_header.inst, - data_p->pdcp_read_header.rb_id, - data_p->pdcp_read_header.data_size, - ctxt_cpy.module_id, - rab_id); -#ifdef OAI_NW_DRIVER_TYPE_ETHERNET - - if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_MULTICAST) /*TRAFFIC_IPV6_TYPE_MULTICAST */ || - (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_MULTICAST) /*TRAFFIC_IPV4_TYPE_MULTICAST */ || - (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_BROADCAST) /*TRAFFIC_IPV4_TYPE_BROADCAST */ ) { -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - PDCP_TRANSMISSION_MODE_TRANSPARENT; -#else - pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; -#endif - } else if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_UNICAST) /* TRAFFIC_IPV6_TYPE_UNICAST */ || - (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_UNICAST) /*TRAFFIC_IPV4_TYPE_UNICAST*/ ) { - pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; - } else { - pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; - LOG_W(PDCP,"unknown IP traffic type \n"); - } - -#else // OAI_NW_DRIVER_TYPE_ETHERNET NASMESH driver does not curreenlty support multicast traffic - pdcp_mode = PDCP_TRANSMISSION_MODE_DATA; -#endif - pdcp_data_req(&ctxt_cpy, - SRB_FLAG_NO, - rab_id % LTE_maxDRB, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data_p->pdcp_read_header.data_size, - data_p->data, - pdcp_mode -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,NULL, NULL -#endif - ); - } else if (ctxt_cpy.enb_flag) { - /* rb_id = 0, thus interpreated as broadcast and transported as - * multiple unicast is a broadcast packet, we have to send this - * packet on all default RABS of all connected UEs - */ - LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID first_ue_local %u nb_ue_local %u\n", oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local); - - for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { - if (pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { - LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID UE %d\n", ue_id); - ctxt.module_id = ctxt_cpy.module_id; - ctxt.rnti = ctxt_cpy.pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ctxt_cpy.enb_flag; - - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data_p->pdcp_read_header.data_size, - data_p->data, - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,NULL, NULL -#endif + if (h_rc == HASH_TABLE_OK) { + LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", + ctxt.frame, ctxt.instance, len, rab_id); + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, + ctxt.rnti, rab_id); + MSC_LOG_RX_MESSAGE((ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt.instance, rab_id, rab_id, len); + pdcp_data_req(&ctxt, SRB_FLAG_NO, rab_id, RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, len, (unsigned char *)nl_rx_buf, + PDCP_TRANSMISSION_MODE_DATA + , NULL, NULL ); - } - } } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - pdcp_data_req( - &ctxt_cpy, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data_p->pdcp_read_header.data_size, - data_p->data, - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,NULL, NULL -#endif - ); + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt.instance, rab_id, rab_id, len); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, + ctxt.rnti, rab_id, key); } - - free(data_p->data); - free(data_p); - data_p = NULL; - } - - return 0; -# else /* PDCP_USE_NETLINK_QUEUES*/ - int len = 1; - int msg_len; - rb_id_t rab_id = 0; - int rlc_data_req_flag = 3; - - -//TTN for D2D (PC5S) -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - prose_addr_len = sizeof(prose_pdcp_addr); - // receive a message from ProSe App - memset(receive_buf, 0, BUFSIZE); - bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0, - (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len); - // if (bytes_received < 0){ - // LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n"); - // exit(EXIT_FAILURE); - // } - if (bytes_received > 0) { - pc5s_header = calloc(1, sizeof(pc5s_header_t)); - memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t)); - - if (pc5s_header->traffic_type == TRAFFIC_PC5S_SESSION_INIT){ - //send reply to ProSe app - LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n"); - memset(send_buf, 0, BUFSIZE); - sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element)); - sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT; - sl_pc5s_msg_send->pc5sPrimitive.status = 1; - - memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element)); - int prose_addr_len = sizeof(prose_pdcp_addr); - int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); - if (bytes_sent < 0) { + } while (len > 0); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); + return len; + } else { /* UE_NAS_USE_TUN */ + if (PDCP_USE_NETLINK) { + protocol_ctxt_t ctxt_cpy = *ctxt_pP; + protocol_ctxt_t ctxt; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + struct pdcp_netlink_element_s *data_p = NULL; + /* avoid gcc warnings */ + (void)data_p; + module_id_t ue_id = 0; + pdcp_t *pdcp_p = NULL; + //TTN for D2D (PC5S) + int prose_addr_len; + char send_buf[BUFSIZE], receive_buf[BUFSIZE]; + //int optval; + int bytes_received; + sidelink_pc5s_element *sl_pc5s_msg_recv = NULL; + sidelink_pc5s_element *sl_pc5s_msg_send = NULL; + //uint32_t sourceL2Id; + //uint32_t groupL2Id; + //module_id_t module_id = 0; + pc5s_header_t *pc5s_header; + static unsigned char pdcp_read_state_g =0; + int len = 1; + int msg_len; + rb_id_t rab_id = 0; + int rlc_data_req_flag = 3; + //TTN for D2D (PC5S) + prose_addr_len = sizeof(prose_pdcp_addr); + // receive a message from ProSe App + memset(receive_buf, 0, BUFSIZE); + bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0, + (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len); + + // if (bytes_received < 0){ + // LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n"); + // exit(EXIT_FAILURE); + // } + if (bytes_received > 0) { + pc5s_header = calloc(1, sizeof(pc5s_header_t)); + memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t)); + + if (pc5s_header->traffic_type == TRAFFIC_PC5S_SESSION_INIT) { + //send reply to ProSe app + LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n"); + memset(send_buf, 0, BUFSIZE); + sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element)); + sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT; + sl_pc5s_msg_send->pc5sPrimitive.status = 1; + memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element)); + int prose_addr_len = sizeof(prose_pdcp_addr); + int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); + + if (bytes_sent < 0) { LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n"); exit(EXIT_FAILURE); - } - } else if (pc5s_header->traffic_type == TRAFFIC_PC5S_SIGNALLING) { //if containing PC5-S message -> send to other UE - LOG_D(PDCP,"Received PC5-S message ... send to the other UE\n"); -#ifdef PDCP_DEBUG - LOG_D(PDCP,"Received PC5-S message, traffic_type: %d)\n", pc5s_header->traffic_type); - LOG_D(PDCP,"Received PC5-S message, rbid: %d)\n", pc5s_header->rb_id); - LOG_D(PDCP,"Received PC5-S message, data_size: %d)\n", pc5s_header->data_size); - LOG_D(PDCP,"Received PC5-S message, inst: %d)\n", pc5s_header->inst); - LOG_D(PDCP,"Received PC5-S message,sourceL2Id: 0x%08x\n)\n", pc5s_header->sourceL2Id); - LOG_D(PDCP,"Received PC5-S message,destinationL1Id: 0x%08x\n)\n", pc5s_header->destinationL2Id); - -#endif - + } + } else if (pc5s_header->traffic_type == TRAFFIC_PC5S_SIGNALLING) { //if containing PC5-S message -> send to other UE + LOG_D(PDCP,"Received PC5-S message ... send to the other UE\n"); + LOG_D(PDCP,"Received PC5-S message, traffic_type: %d)\n", pc5s_header->traffic_type); + LOG_D(PDCP,"Received PC5-S message, rbid: %d)\n", pc5s_header->rb_id); + LOG_D(PDCP,"Received PC5-S message, data_size: %d)\n", pc5s_header->data_size); + LOG_D(PDCP,"Received PC5-S message, inst: %d)\n", pc5s_header->inst); + LOG_D(PDCP,"Received PC5-S message,sourceL2Id: 0x%08x\n)\n", pc5s_header->sourceL2Id); + LOG_D(PDCP,"Received PC5-S message,destinationL1Id: 0x%08x\n)\n", pc5s_header->destinationL2Id); #ifdef OAI_EMU - // overwrite function input parameters, because only one netlink socket for all instances - if (pc5s_header->inst < oai_emulation.info.nb_enb_local) { + // overwrite function input parameters, because only one netlink socket for all instances + if (pc5s_header->inst < oai_emulation.info.nb_enb_local) { ctxt.frame = ctxt_cpy.frame; ctxt.enb_flag = ENB_FLAG_YES; ctxt.module_id = pc5s_header.inst + oai_emulation.info.first_enb_local; ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pc5s_header->rb_id / LTE_maxDRB + oai_emulation.info.first_ue_local]; rab_id = pc5s_header->rb_id % LTE_maxDRB; - } else { + } else { ctxt.frame = ctxt_cpy.frame; ctxt.enb_flag = ENB_FLAG_NO; ctxt.module_id = pc5s_header->inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; rab_id = pc5s_header->rb_id % LTE_maxDRB; - } + } - CHECK_CTXT_ARGS(&ctxt); - AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB); - /*LGpdcp_read_header.inst = (pc5s_header.inst >= oai_emulation.info.nb_enb_local) ? \ - pc5s_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : - pc5s_header.inst + oai_emulation.info.first_enb_local;*/ + CHECK_CTXT_ARGS(&ctxt); + AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB); + /*LGpdcp_read_header.inst = (pc5s_header.inst >= oai_emulation.info.nb_enb_local) ? \ + pc5s_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : + pc5s_header.inst + oai_emulation.info.first_enb_local;*/ #else // OAI_EMU - /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ - // pc5s_header.inst = 0; - //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ctxt_cpy.enb_flag; - - LOG_I(PDCP, "[PDCP] pc5s_header->rb_id = %d\n", pc5s_header->rb_id); + /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ + // pc5s_header.inst = 0; + //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; + LOG_I(PDCP, "[PDCP] pc5s_header->rb_id = %d\n", pc5s_header->rb_id); - if (ctxt_cpy.enb_flag) { + if (ctxt_cpy.enb_flag) { ctxt.module_id = 0; rab_id = pc5s_header->rb_id % LTE_maxDRB; ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index]; - } else { + } else { ctxt.module_id = 0; rab_id = pc5s_header->rb_id % LTE_maxDRB; ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - } + } + #endif - //UE - if (!ctxt.enb_flag) { + //UE + if (!ctxt.enb_flag) { if (rab_id != 0) { - if (rab_id == UE_IP_DEFAULT_RAB_ID) { - LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } else { - rab_id = rab_id % LTE_maxDRB; - LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } - - if (h_rc == HASH_TABLE_OK) { - rab_id = pdcp_p->rb_id; -#ifdef PDCP_DEBUG - LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", - ctxt.frame, - pc5s_header->inst, - bytes_received, - pc5s_header->rb_id); - - LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", - ctxt.frame, - pc5s_header->inst, - pc5s_header->rb_id, - pc5s_header->data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); -#endif - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pc5s_header->inst, - pc5s_header->rb_id, - rab_id, - pc5s_header->data_size); - - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pc5s_header->data_size, - (unsigned char *)receive_buf, - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,&pc5s_header->sourceL2Id - ,&pc5s_header->destinationL2Id -#endif - ); - } else { - MSC_LOG_RX_DISCARDED_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pc5s_header->inst, - pc5s_header->rb_id, - rab_id, - pc5s_header->data_size); - LOG_D(PDCP, - "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", - ctxt.frame, - pc5s_header->inst, - pc5s_header->rb_id, - pc5s_header->data_size, - ctxt.module_id, - ctxt.rnti, - rab_id, - key); - } + if (rab_id == UE_IP_DEFAULT_RAB_ID) { + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } else { + rab_id = rab_id % LTE_maxDRB; + LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } + + if (h_rc == HASH_TABLE_OK) { + rab_id = pdcp_p->rb_id; + LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", + ctxt.frame, + pc5s_header->inst, + bytes_received, + pc5s_header->rb_id); + LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header->inst, + pc5s_header->rb_id, + rab_id, + pc5s_header->data_size); + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pc5s_header->data_size, + (unsigned char *)receive_buf, + PDCP_TRANSMISSION_MODE_DATA, + &pc5s_header->sourceL2Id, + &pc5s_header->destinationL2Id + ); + } else { + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header->inst, + pc5s_header->rb_id, + rab_id, + pc5s_header->data_size); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + rab_id, + key); + } } else { //if (rab_id == 0) - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pc5s_header->inst, - pc5s_header->rb_id, - pc5s_header->data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL,0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pc5s_header->inst, - pc5s_header->rb_id, - DEFAULT_RAB_ID, - pc5s_header->data_size); - - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pc5s_header->data_size, - (unsigned char *)receive_buf, - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,&pc5s_header->sourceL2Id - ,&pc5s_header->destinationL2Id -#endif - ); + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL,0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header->inst, + pc5s_header->rb_id, + DEFAULT_RAB_ID, + pc5s_header->data_size); + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pc5s_header->data_size, + (unsigned char *)receive_buf, + PDCP_TRANSMISSION_MODE_DATA, + &pc5s_header->sourceL2Id, + &pc5s_header->destinationL2Id + ); } - } + } + free (sl_pc5s_msg_recv); free (sl_pc5s_msg_send); + } } - } - -#endif - while ((len > 0) && (rlc_data_req_flag !=0)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); - len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); + while ((len > 0) && (rlc_data_req_flag !=0)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); + len = recvmsg(nas_sock_fd[0], &nas_msg_rx, 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); - if (len<=0) { - // nothing in pdcp NAS socket - //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); - } else { + if (len<=0) { + // nothing in pdcp NAS socket + //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); + } else { + msg_len = len; - msg_len = len; - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; + for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; NLMSG_OK (nas_nlh_rx, msg_len); nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, msg_len)) { - if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); - //return; + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); + //return; } if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); } if (pdcp_read_state_g == 0) { - if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { - pdcp_read_state_g = 1; //get - memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n", - pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id ); - } else { - LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", - nas_nlh_rx->nlmsg_len); - } + if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { + pdcp_read_state_g = 1; //get + memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); + LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n", + pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id ); + } else { + LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", + nas_nlh_rx->nlmsg_len); + } } else { - pdcp_read_state_g = 0; - // print_active_requests() -#ifdef PDCP_DEBUG - LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n", - nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); -#endif - + pdcp_read_state_g = 0; + // print_active_requests() + LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n", + nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); #ifdef OAI_EMU - - // overwrite function input parameters, because only one netlink socket for all instances - if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) { - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ENB_FLAG_YES; - ctxt.module_id = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local; - ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_read_header_g.rb_id / LTE_maxDRB + oai_emulation.info.first_ue_local]; - rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; - } else { - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ENB_FLAG_NO; - ctxt.module_id = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; - ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; - } - - CHECK_CTXT_ARGS(&ctxt); - AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB); - /*LGpdcp_read_header.inst = (pdcp_read_header_g.inst >= oai_emulation.info.nb_enb_local) ? \ - pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : - pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/ + // overwrite function input parameters, because only one netlink socket for all instances + if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) { + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ENB_FLAG_YES; + ctxt.module_id = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local; + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_read_header_g.rb_id / LTE_maxDRB + oai_emulation.info.first_ue_local]; + rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; + } else { + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ENB_FLAG_NO; + ctxt.module_id = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; + rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; + } + + CHECK_CTXT_ARGS(&ctxt); + AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB); #else // OAI_EMU - /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ - // pdcp_read_header_g.inst = 0; - //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ctxt_cpy.enb_flag; - -#ifdef PDCP_DEBUG - LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d, source L2Id = 0x%08x, destination L2Id = 0x%08x \n", pdcp_read_header_g.rb_id, pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id); -#endif - if (ctxt_cpy.enb_flag) { - ctxt.module_id = 0; - rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; - ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_read_header_g.rb_id / LTE_maxDRB]; - } else { - if (nfapi_mode == 3) { + /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ + // pdcp_read_header_g.inst = 0; + //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; + LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d, source L2Id = 0x%08x, destination L2Id = 0x%08x \n", pdcp_read_header_g.rb_id, pdcp_read_header_g.sourceL2Id, + pdcp_read_header_g.destinationL2Id); + + if (ctxt_cpy.enb_flag) { + ctxt.module_id = 0; + rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; + ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_read_header_g.rb_id / LTE_maxDRB]; + } else { + if (nfapi_mode == 3) { #ifdef UESIM_EXPANSION - ctxt.module_id = inst_pdcp_list[pdcp_read_header_g.inst]; + ctxt.module_id = inst_pdcp_list[pdcp_read_header_g.inst]; #else - ctxt.module_id = pdcp_read_header_g.inst; + ctxt.module_id = pdcp_read_header_g.inst; #endif - } else { - ctxt.module_id = 0; - } - rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; - ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - } + } else { + ctxt.module_id = 0; + } -#endif + rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; + } - if (ctxt.enb_flag) { - if (rab_id != 0) { - rab_id = rab_id % LTE_maxDRB; - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - - - if (h_rc == HASH_TABLE_OK) { -#ifdef PDCP_DEBUG - LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", - ctxt.frame, - pdcp_read_header_g.inst, - len, - nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); #endif - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", - ctxt_cpy.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - - pdcp_data_req(&ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,NULL, NULL -#endif - ); - } else { - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - } - } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast - // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs - //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES - for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { - if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { - ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,NULL, NULL -#endif - ); - } - } + if (ctxt.enb_flag) { + if (rab_id != 0) { + rab_id = rab_id % LTE_maxDRB; + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + + if (h_rc == HASH_TABLE_OK) { + LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + ctxt.frame, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", + ctxt_cpy.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + pdcp_data_req(&ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA + ,NULL, NULL + ); + } else { + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); } - } else { // enb_flag - if (rab_id != 0) { - if (rab_id == UE_IP_DEFAULT_RAB_ID) { - LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } else { - rab_id = rab_id % LTE_maxDRB; - LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } - - if (h_rc == HASH_TABLE_OK) { - rab_id = pdcp_p->rb_id; -#ifdef PDCP_DEBUG - LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", - ctxt.frame, - pdcp_read_header_g.inst, - len, - nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); - - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); -#endif - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - if(nfapi_mode == 3){ - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,NULL - ,NULL -#endif - ); - }else{ - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,&pdcp_read_header_g.sourceL2Id - ,&pdcp_read_header_g.destinationL2Id -#endif - ); - } - } else { - MSC_LOG_RX_DISCARDED_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - LOG_D(PDCP, - "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id, - key); - } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL,0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - DEFAULT_RAB_ID, - pdcp_read_header_g.data_size); - if(nfapi_mode == 3){ - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,NULL - ,NULL -#endif - ); - }else{ - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,&pdcp_read_header_g.sourceL2Id - ,&pdcp_read_header_g.destinationL2Id -#endif - ); - } + } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast + // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs + //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES + for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { + if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA + ,NULL, NULL + ); + } + } + } + } else { // enb_flag + if (rab_id != 0) { + if (rab_id == UE_IP_DEFAULT_RAB_ID) { + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } else { + rab_id = rab_id % LTE_maxDRB; + LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); } - } + if (h_rc == HASH_TABLE_OK) { + rab_id = pdcp_p->rb_id; + LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + ctxt.frame, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + + if(nfapi_mode == 3) { + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA, + NULL, + NULL + ); + } else { + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA, + &pdcp_read_header_g.sourceL2Id, + &pdcp_read_header_g.destinationL2Id + ); + } + } else { + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id, + key); + } + } else { + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL,0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + DEFAULT_RAB_ID, + pdcp_read_header_g.data_size); + + if(nfapi_mode == 3) { + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA, + NULL, + NULL + ); + } else { + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA, + &pdcp_read_header_g.sourceL2Id, + &pdcp_read_header_g.destinationL2Id + ); + } + } + } } - } - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); - } + } + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); + } - return len; -# endif -#else // neither PDCP_USE_NETLINK nor PDCP_USE_RT_FIFO - return 0; -#endif // PDCP_USE_NETLINK -#endif /* #else UE_NAS_USE_TUN */ + return len; + } else { /* PDCP_USE_NETLINK */ + return 0; + } // else PDCP_USE_NETLINK + } /* #else UE_NAS_USE_TUN */ } -void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) { - - +void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t *const ctxt_pP) { module_id_t dst_id; // dst for otg protocol_ctxt_t ctxt; + // we need to add conditions to avoid transmitting data when the UE is not RRC connected. if ((otg_enabled==1) && (ctxt_pP->enb_flag == ENB_FLAG_YES)) { // generate DL traffic - PROTOCOL_CTXT_SET_BY_MODULE_ID( &ctxt, ctxt_pP->module_id, @@ -1236,39 +780,35 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) } //TTN for D2D (PC5S) -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void pdcp_pc5_socket_init() { - //pthread_attr_t attr; - //struct sched_param sched_param; - int optval; // flag value for setsockopt - //int n; // message byte size - - //create PDCP socket - pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (pdcp_pc5_sockfd < 0){ - LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - optval = 1; - setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR, - (const void *)&optval , sizeof(int)); - - fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK); - - bzero((char *) &pdcp_sin, sizeof(pdcp_sin)); - pdcp_sin.sin_family = AF_INET; - pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY); - pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO); - // associate the parent socket with a port - if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin, - sizeof(pdcp_sin)) < 0) { - LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n"); - exit(1); - } + //pthread_attr_t attr; + //struct sched_param sched_param; + int optval; // flag value for setsockopt + //int n; // message byte size + //create PDCP socket + pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0); + + if (pdcp_pc5_sockfd < 0) { + LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno)); + exit(EXIT_FAILURE); + } + optval = 1; + setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR, + (const void *)&optval, sizeof(int)); + fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK); + bzero((char *) &pdcp_sin, sizeof(pdcp_sin)); + pdcp_sin.sin_family = AF_INET; + pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY); + pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO); + + // associate the parent socket with a port + if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin, + sizeof(pdcp_sin)) < 0) { + LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n"); + exit(1); + } } -#endif diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c index 472c46c94a46d6825eefb7d4ca1ef831a1abdf55..f47694c2e31a8928f74b7266052022d8482d15cf 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c @@ -43,7 +43,7 @@ /* Bugfix for version of GCC = 4.4.3 (Ubuntu 10.04) */ #if GCC_VERSION <= 40403 -# include <sys/socket.h> + #include <sys/socket.h> #endif #include <linux/netlink.h> @@ -70,7 +70,7 @@ extern struct iovec nas_iov_rx; extern int nas_sock_fd; extern struct msghdr nas_msg_rx; -#if defined(PDCP_USE_NETLINK_QUEUES) + static pthread_t pdcp_netlink_thread; /* We use lock-free queues between the User-plane driver running in kernel-space @@ -93,41 +93,37 @@ pdcp_netlink_init( ) //----------------------------------------------------------------------------- { - int i; int nb_inst_enb; int nb_inst_ue; pthread_attr_t attr; struct sched_param sched_param; - reset_meas(&ip_pdcp_stats_tmp); nb_inst_enb = 1; nb_inst_ue = 1; -#if defined(LINK_ENB_PDCP_TO_GTPV1U) - nb_inst_enb = 0; - LOG_I(PDCP, "[NETLINK] Creating 0 queues for eNB Netlink -> PDCP communication\n"); -#else -#warning " LG: When there will be handover in, there will problems because dim is based on local nums of ues" - pdcp_netlink_queue_enb = calloc(nb_inst_enb, sizeof(struct lfds611_queue_state*)); - pdcp_netlink_nb_element_enb = malloc(nb_inst_enb * sizeof(uint32_t)); - LOG_I(PDCP, "[NETLINK] Creating %d queues for eNB Netlink -> PDCP communication\n", nb_inst_enb); + if (LINK_ENB_PDCP_TO_GTPV1U) { + nb_inst_enb = 0; + LOG_I(PDCP, "[NETLINK] Creating 0 queues for eNB Netlink -> PDCP communication\n"); + } else { + /* #warning " LG: When there will be handover in, there will problems because dim is based on local nums of ues" */ + pdcp_netlink_queue_enb = calloc(nb_inst_enb, sizeof(struct lfds611_queue_state *)); + pdcp_netlink_nb_element_enb = malloc(nb_inst_enb * sizeof(uint32_t)); + LOG_I(PDCP, "[NETLINK] Creating %d queues for eNB Netlink -> PDCP communication\n", nb_inst_enb); - for (i = 0; i < nb_inst_enb; i++) { - pdcp_netlink_nb_element_enb[i] = 0; + for (i = 0; i < nb_inst_enb; i++) { + pdcp_netlink_nb_element_enb[i] = 0; - if (lfds611_queue_new(&pdcp_netlink_queue_enb[i], PDCP_QUEUE_NB_ELEMENTS) < 0) { - LOG_E(PDCP, "Failed to create new FIFO for eNB Netlink -> PDCP communcation instance %d\n", i); - exit(EXIT_FAILURE); + if (lfds611_queue_new(&pdcp_netlink_queue_enb[i], PDCP_QUEUE_NB_ELEMENTS) < 0) { + LOG_E(PDCP, "Failed to create new FIFO for eNB Netlink -> PDCP communcation instance %d\n", i); + exit(EXIT_FAILURE); + } } } -#endif - if (nb_inst_ue > 0) { - pdcp_netlink_queue_ue = calloc(nb_inst_ue, sizeof(struct lfds611_queue_state*)); + pdcp_netlink_queue_ue = calloc(nb_inst_ue, sizeof(struct lfds611_queue_state *)); pdcp_netlink_nb_element_ue = malloc(nb_inst_ue * sizeof(uint32_t)); - LOG_I(PDCP, "[NETLINK] Creating %d queues for UE Netlink -> PDCP communication\n", nb_inst_ue); for (i = 0; i < nb_inst_ue; i++) { @@ -148,7 +144,6 @@ pdcp_netlink_init( } sched_param.sched_priority = 10; - pthread_attr_setschedpolicy(&attr, SCHED_RR); pthread_attr_setschedparam(&attr, &sched_param); @@ -171,21 +166,21 @@ pdcp_netlink_init( //----------------------------------------------------------------------------- int pdcp_netlink_dequeue_element( - const protocol_ctxt_t* const ctxt_pP, - struct pdcp_netlink_element_s** data_ppP + const protocol_ctxt_t *const ctxt_pP, + struct pdcp_netlink_element_s **data_ppP ) //----------------------------------------------------------------------------- { int ret = 0; if (ctxt_pP->enb_flag) { - ret = lfds611_queue_dequeue(pdcp_netlink_queue_enb[ctxt_pP->module_id], (void**)data_ppP); + ret = lfds611_queue_dequeue(pdcp_netlink_queue_enb[ctxt_pP->module_id], (void **)data_ppP); if (ret != 0) { LOG_D(PDCP,"[NETLINK]De-queueing packet for eNB instance %d\n", ctxt_pP->module_id); } } else { - ret = lfds611_queue_dequeue(pdcp_netlink_queue_ue[ctxt_pP->module_id], (void**)data_ppP); + ret = lfds611_queue_dequeue(pdcp_netlink_queue_ue[ctxt_pP->module_id], (void **)data_ppP); if (ret != 0) { LOG_D(PDCP, "[NETLINK]De-queueing packet for UE instance %d\n", ctxt_pP->module_id); @@ -209,8 +204,8 @@ void *pdcp_netlink_thread_fct(void *arg) memset(nl_rx_buf, 0, NL_MAX_PAYLOAD); LOG_I(PDCP, "[NETLINK_THREAD] binding to fd %d\n",nas_sock_fd); MSC_START_USE(); - while (1) { + while (1) { len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); if (len == 0) { @@ -248,7 +243,7 @@ void *pdcp_netlink_thread_fct(void *arg) new_data_p->pdcp_read_header.data_size); } else { LOG_E(PDCP, "[NETLINK_THREAD] WRONG size %d should be sizeof " - "%d ((pdcp_data_req_header_t) + sizeof(struct nlmsghdr))\n", + "%lu ((pdcp_data_req_header_t) + sizeof(struct nlmsghdr))\n", nas_nlh_rx->nlmsg_len, sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)); } @@ -262,12 +257,11 @@ void *pdcp_netlink_thread_fct(void *arg) if (eNB_flag) { if (pdcp_netlink_nb_element_enb[module_id] > PDCP_QUEUE_NB_ELEMENTS) { - LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in eNB pdcp queue (%d)\n", - module_id, pdcp_netlink_nb_element_enb); + LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in eNB pdcp queue (%lu)\n", + module_id, (intptr_t)pdcp_netlink_nb_element_enb); } LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for eNB module id %d\n", module_id); - /* Enqueue the element in the right queue */ lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_enb[module_id], new_data_p); stop_meas(&ip_pdcp_stats_tmp); @@ -275,12 +269,11 @@ void *pdcp_netlink_thread_fct(void *arg) } else { if (pdcp_netlink_nb_element_ue[module_id] > PDCP_QUEUE_NB_ELEMENTS) { - LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in UE pdcp queue (%d)\n", - module_id, pdcp_netlink_nb_element_ue); + LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in UE pdcp queue (%lu)\n", + module_id, (intptr_t)pdcp_netlink_nb_element_ue); } LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for UE module id %d\n", module_id); - /* Enqueue the element in the right queue */ lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_ue[module_id], new_data_p); stop_meas(&ip_pdcp_stats_tmp); @@ -293,4 +286,4 @@ void *pdcp_netlink_thread_fct(void *arg) return NULL; } -#endif + diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h index 8e57f84b0a9e9fa86ec72144b219a2b9714304f3..8b5ebe7287c52ddbb15409edceec218569127b0d 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h @@ -173,7 +173,6 @@ int pdcp_netlink_dequeue_element(const protocol_ctxt_t* const ctxt_pP, void pdcp_config_set_security(const protocol_ctxt_t* const ctxt_pP, pdcp_t *pdcp_pP, rb_id_t rb_idP, uint16_t lc_idP, uint8_t security_modeP, uint8_t *kRRCenc_pP, uint8_t *kRRCint_pP, uint8_t *kUPenc_pP); -#if defined(ENABLE_SECURITY) int pdcp_apply_security(const protocol_ctxt_t* const ctxt_pP, pdcp_t *pdcp_entity, srb_flag_t srb_flagP, @@ -188,10 +187,10 @@ int pdcp_validate_security(const protocol_ctxt_t* const ctxt_pP, srb_flag_t srb_flagP, rb_id_t rb_id, uint8_t pdcp_header_len, - uint16_t current_sn, + uint32_t hfn, + int sn, uint8_t *pdcp_pdu_buffer, uint16_t sdu_buffer_size); -#endif /* defined(ENABLE_SECURITY) */ #endif /** @}*/ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c index 83293a709de2b7e60b13c02f8cd97821d8fe4dc6..1528373e9883f9bab3e8faee3e605576b58df036 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c @@ -40,13 +40,6 @@ #include "msc.h" #include "pdcp_primitives.h" -#if defined(ENABLE_SECURITY) - -static -uint32_t pdcp_get_next_count_tx(pdcp_t *const pdcp_pP, const srb_flag_t srb_flagP, const uint16_t pdcp_sn); -static -uint32_t pdcp_get_next_count_rx(pdcp_t *const pdcp_pP, const srb_flag_t srb_flagP, const uint16_t pdcp_sn); - //----------------------------------------------------------------------------- static uint32_t pdcp_get_next_count_tx( @@ -79,26 +72,25 @@ static uint32_t pdcp_get_next_count_rx( pdcp_t * const pdcp_pP, const srb_flag_t srb_flagP, - const uint16_t pdcp_sn) + const uint32_t hfn, + const int sn) { uint32_t count; /* For RX COUNT = RX_HFN << length of SN | pdcp SN of received PDU */ if (srb_flagP) { /* 5 bits length SN */ - count = (((pdcp_pP->rx_hfn + pdcp_pP->rx_hfn_offset) << 5) | (pdcp_sn & 0x001F)); + count = (hfn << 5) | (sn & 0x001F); } else { - if (pdcp_pP->seq_num_size == LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) { + if (pdcp_pP->seq_num_size == 7) { /* 7 bits length SN */ - count = (((pdcp_pP->rx_hfn + pdcp_pP->rx_hfn_offset) << 7) | (pdcp_sn & 0x007F)); + count = (hfn << 7) | (sn & 0x007F); } else { // default /* 12 bits length SN */ - count = (((pdcp_pP->rx_hfn + pdcp_pP->rx_hfn_offset) << 12) | (pdcp_sn & 0x0FFF)); + count = (hfn << 12) | (sn & 0x0FFF); } } - // reset the hfn offset - pdcp_pP->rx_hfn_offset =0; LOG_D(PDCP, "[OSA] RX COUNT = 0x%08x\n", count); return count; @@ -182,7 +174,8 @@ pdcp_validate_security( const srb_flag_t srb_flagP, const rb_id_t rb_id, const uint8_t pdcp_header_len, - const uint16_t current_sn, + const uint32_t hfn, + const int sn, uint8_t *const pdcp_pdu_buffer, const uint16_t sdu_buffer_size ) @@ -201,7 +194,7 @@ pdcp_validate_security( decrypt_params.direction = (pdcp_pP->is_ue == 1) ? SECU_DIRECTION_DOWNLINK : SECU_DIRECTION_UPLINK ; decrypt_params.bearer = rb_id - 1; - decrypt_params.count = pdcp_get_next_count_rx(pdcp_pP, srb_flagP, current_sn); + decrypt_params.count = pdcp_get_next_count_rx(pdcp_pP, srb_flagP, hfn, sn); decrypt_params.message = &pdcp_pdu_buffer[pdcp_header_len]; decrypt_params.blength = (sdu_buffer_size - pdcp_header_len) << 3; decrypt_params.key_length = 16; @@ -246,5 +239,3 @@ pdcp_validate_security( return 0; } - -#endif /* ENABLE_SECURITY */ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c index c6deb4944172b214c69d5f16df7025eb3a717dde..cdc583ef217873df5f794f6f9359136d1c2a1a33 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c @@ -140,152 +140,6 @@ boolean_t pdcp_advance_rx_window(pdcp_t* pdcp_entity) return TRUE; } -/** - * Checks if incoming PDU has a sequence number in accordance with the RX window - * @return 1 if SN is okay, 0 otherwise - * XXX Reordering window should also be handled here - */ -boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_flag_t srb_flagP) -{ - - uint16_t reordering_window = 0; - - LOG_D(PDCP, "Incoming RX Sequence number is %04d\n", seq_num); - - if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE || pdcp_is_seq_num_valid(seq_num, pdcp_entity->seq_num_size) == FALSE) { - return FALSE; - } - - /* - * Mark received sequence numbers to keep track of missing ones - * (and to build PDCP Control PDU for PDCP status report) - */ - if (pdcp_mark_current_pdu_as_received(seq_num, pdcp_entity) == TRUE) { - LOG_D(PDCP, "Received sequence number successfuly marked\n"); - } else { - LOG_W(PDCP, "Cannot mark received sequence number on the bitmap!\n"); - } - - /* - * RX Procedures for SRB and DRBs as described in sec 5.1.2 of 36.323 - */ - - if (srb_flagP) { // SRB - - if (seq_num < pdcp_entity->next_pdcp_rx_sn) { - // decipher and verify the integrity of the PDU (if applicable) using COUNT based on RX_HFN + 1 and the received PDCP SN - pdcp_entity->rx_hfn++; - pdcp_entity->rx_hfn_offset = 0; - } else { - // decipher and verify the integrity of the PDU (if applicable) using COUNT based using COUNT based on RX_HFN and the received PDCP SN - pdcp_entity->rx_hfn_offset = 0; - } - - // Assume that integrity verification is applicable and the integrity verification is passed successfully; - // or assume that integrity verification is not applicable: - - // same the old next_pdcp_rx_sn to revert otherwise - pdcp_entity->next_pdcp_rx_sn_before_integrity = pdcp_entity->next_pdcp_rx_sn; - - if (seq_num != pdcp_entity->next_pdcp_rx_sn) { - LOG_D(PDCP,"Re-adjusting the sequence number to %d\n", seq_num); - } - - //set Next_PDCP_RX_SN to the received PDCP SN +1 ; - pdcp_entity->next_pdcp_rx_sn = seq_num; - pdcp_advance_rx_window(pdcp_entity); // + 1, and check if it is larger than Maximum_PDCP_SN: - - } else { // DRB - - if (pdcp_entity->seq_num_size == PDCP_SN_7BIT) { - reordering_window = REORDERING_WINDOW_SN_7BIT; - } else { - reordering_window = REORDERING_WINDOW_SN_12BIT; - } - - switch (pdcp_entity->rlc_mode) { - case RLC_MODE_AM: - if ((seq_num - pdcp_entity->last_submitted_pdcp_rx_sn > reordering_window) || - ((0 <= pdcp_entity->last_submitted_pdcp_rx_sn - seq_num) && - (pdcp_entity->last_submitted_pdcp_rx_sn - seq_num < reordering_window) )) { - - if (seq_num > pdcp_entity->next_pdcp_rx_sn) { - /* - * decipher the PDCP PDU as specified in the subclause 5.6, using COUNT based on RX_HFN - 1 and the received PDCP SN; - */ - pdcp_entity->rx_hfn_offset = -1; - } else { - /* - * decipher the PDCP PDU as specified in the subclause 5.6, using COUNT based on RX_HFN and the received PDCP SN; - */ - pdcp_entity->rx_hfn_offset = 0; - } - - // discard this PDCP SDU; - LOG_W(PDCP, "Out of the reordering window (Incoming SN:%d, Expected SN:%d): discard this PDCP SDU\n", - seq_num, pdcp_entity->next_pdcp_rx_sn); - return FALSE; - } else if (pdcp_entity->next_pdcp_rx_sn - seq_num > reordering_window) { - pdcp_entity->rx_hfn++; - // use COUNT based on RX_HFN and the received PDCP SN for deciphering the PDCP PDU; - pdcp_entity->rx_hfn_offset = 0; - pdcp_entity->next_pdcp_rx_sn++; - } else if (seq_num - pdcp_entity->next_pdcp_rx_sn >= reordering_window ) { - // use COUNT based on RX_HFN – 1 and the received PDCP SN for deciphering the PDCP PDU; - pdcp_entity->rx_hfn_offset = -1; - } else if (seq_num >= pdcp_entity->next_pdcp_rx_sn ) { - // use COUNT based on RX_HFN and the received PDCP SN for deciphering the PDCP PDU; - pdcp_entity->rx_hfn_offset = 0; - //set Next_PDCP_RX_SN to the received PDCP SN +1 ; - pdcp_entity->next_pdcp_rx_sn = seq_num; - pdcp_advance_rx_window(pdcp_entity); // + 1, anc check if it is larger than Maximum_PDCP_SN: - LOG_D(PDCP,"Re-adjusting the sequence number to %d\n", seq_num); - } else if (seq_num < pdcp_entity->next_pdcp_rx_sn) { - // use COUNT based on RX_HFN and the received PDCP SN for deciphering the PDCP PDU; - pdcp_entity->rx_hfn_offset = 0; - } - - break; - - case RLC_MODE_UM : - if (seq_num < pdcp_entity->next_pdcp_rx_sn) { - pdcp_entity->rx_hfn++; - } - - // decipher the PDCP Data PDU using COUNT based on RX_HFN and the received PDCP SN as specified in the subclause 5.6; - //set Next_PDCP_RX_SN to the received PDCP SN +1 ; - pdcp_entity->next_pdcp_rx_sn = seq_num; - pdcp_advance_rx_window(pdcp_entity); // + 1, and check if it is larger than Maximum_PDCP_SN: - - break; - - case RLC_MODE_TM : - default: - LOG_W(PDCP,"RLC mode %d not supported\n",pdcp_entity->rlc_mode); - return FALSE; - } - } - - /* - if (seq_num == pdcp_entity->next_pdcp_rx_sn) { - LOG_I(PDCP, "Next expected SN (%d) arrived, advancing RX window\n", seq_num); - - return pdcp_advance_rx_window(pdcp_entity); - } else { - LOG_E(PDCP, "Incoming SN is not the one we expected to receive! (Incoming:%d, Expected:%d)\n", \ - seq_num, pdcp_entity->next_pdcp_rx_sn); - - - // Update first missing PDU (used in PDCP Control PDU for PDCP status report, see 6.2.6) - if (pdcp_entity->first_missing_pdu != -1) - pdcp_entity->first_missing_pdu = pdcp_entity->next_pdcp_rx_sn; - - return FALSE; - } - */ - return TRUE; -} - boolean_t pdcp_mark_current_pdu_as_received(uint16_t seq_num, pdcp_t* pdcp_entity) { /* diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.h index ec59a4b4fe8dca5190bd26118b0e0209af2f8b8e..172c9810e69c29ad81f911f6b61a72759cf9812e 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.h @@ -59,11 +59,6 @@ uint16_t pdcp_get_next_tx_seq_number(pdcp_t* pdcp_entity); * Advances the RX window state of given PDCP entity upon successfull receipt of a SDU */ boolean_t pdcp_advance_rx_window(pdcp_t* pdcp_entity); -/** - * Checks if incoming PDU has a sequence number in accordance with the RX window - * @return TRUE if it is valid, FALSE otherwise - */ -boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_flag_t srb_flagP); /** * Updates missing PDU bitmap with incoming sequence number * @return TRUE if successful, FALSE otherwise diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index 74e22194f9c7fc2308721b941bf50fce5e4b8600..309facf34bba27d22f14c742ece2a8cf5ea9373b 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -375,7 +375,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, //DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); if(sdu_sizeP <= 0) { - LOG_E(RLC, "sdu_sizeP %d, file %s, line %d\n", sdu_sizeP, __FILE__ ,__LINE__); + LOG_E(RLC, "sdu_sizeP %d, file %s, line %d\n", sdu_sizeP, __FILE__,__LINE__); return RLC_OP_STATUS_BAD_PARAMETER; } @@ -564,8 +564,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, } #else - } - else { /* MBMS_flag != 0 */ + } else { /* MBMS_flag != 0 */ free_mem_block(sdu_pP, __func__); LOG_E(RLC, "MBMS_flag != 0 while Rel10/Rel14 is not defined...\n"); //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : parameter module_id out of bounds :%d\n", __FILE__, __LINE__, module_idP); @@ -616,7 +615,7 @@ void rlc_data_conf (const protocol_ctxt_t *const ctxt_pP, //----------------------------------------------------------------------------- if (srb_flagP) { if (rlc_rrc_data_conf != NULL) { - rlc_rrc_data_conf (ctxt_pP, rb_idP , muiP, statusP); + rlc_rrc_data_conf (ctxt_pP, rb_idP, muiP, statusP); } } } @@ -640,8 +639,6 @@ rlc_module_init (void) { } for (module_id1=0; module_id1 < MAX_MOBILES_PER_ENB; module_id1++) { -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - for (k=0; k < RLC_MAX_MBMS_LC; k++) { rlc_mbms_lcid2service_session_id_ue[module_id1][k].service_id = 0; rlc_mbms_lcid2service_session_id_ue[module_id1][k].session_id = 0; @@ -650,23 +647,15 @@ rlc_module_init (void) { for (k=0; k < NB_RB_MBMS_MAX; k++) { rlc_mbms_rbid2lcid_ue[module_id1][k] = RLC_LC_UNALLOCATED; } - -#endif } - for (module_id1=0; module_id1 < NUMBER_OF_eNB_MAX; module_id1++) { -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - - for (k=0; k < RLC_MAX_MBMS_LC; k++) { - rlc_mbms_lcid2service_session_id_eNB[module_id1][k].service_id = 0; - rlc_mbms_lcid2service_session_id_eNB[module_id1][k].session_id = 0; - } - - for (k=0; k < NB_RB_MBMS_MAX; k++) { - rlc_mbms_rbid2lcid_eNB[module_id1][k] = RLC_LC_UNALLOCATED; - } + for (k=0; k < RLC_MAX_MBMS_LC; k++) { + rlc_mbms_lcid2service_session_id_eNB[0][k].service_id = 0; + rlc_mbms_lcid2service_session_id_eNB[0][k].session_id = 0; + } -#endif + for (k=0; k < NB_RB_MBMS_MAX; k++) { + rlc_mbms_rbid2lcid_eNB[0][k] = RLC_LC_UNALLOCATED; } pool_buffer_init(); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index b8cfad9cca032c03722dd66bedcea0ebdababd09..09c051a62dc43b1920c9a7d7cfd5501fad0b7d19 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -3724,7 +3724,6 @@ do_RRCConnectionReestablishment( rrc->carrier[CC_id].dl_CarrierFreq, earfcn_dl, is_rel8_only == true ? "true": "false"); -#if defined(ENABLE_SECURITY) if (ue_context_pP->ue_context.nh_ncc >= 0) { derive_keNB_star(ue_context_pP->ue_context.nh, pci, earfcn_dl, is_rel8_only, KeNB_star); @@ -3738,9 +3737,6 @@ do_RRCConnectionReestablishment( // copy KeNB_star to ue_context_pP->ue_context.kenb memcpy (ue_context_pP->ue_context.kenb, KeNB_star, 32); ue_context_pP->ue_context.kenb_ncc = 0; -#else - rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0; -#endif rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nonCriticalExtension = NULL; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { diff --git a/openair2/RRC/LTE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h index 160d92a610888b1c0e194c3e1d62db6109084e85..26eca6d781fd246814f65eaa3a8189b530c07595 100644 --- a/openair2/RRC/LTE/defs_NB_IoT.h +++ b/openair2/RRC/LTE/defs_NB_IoT.h @@ -63,24 +63,12 @@ #include "LTE_UE-Capability-NB-r13.h" //equivalent of UE-EUTRA-Capability.h //------------------- -#if defined(ENABLE_ITTI) # include "intertask_interface.h" -#endif - -/* TODO: be sure this include is correct. - * It solves a problem of compilation of the RRH GW, - * issue #186. - */ -#if !defined(ENABLE_ITTI) -# include "as_message.h" -#endif - -#if defined(ENABLE_USE_MME) # include "commonDef.h" -#endif + #if ENABLE_RAL -# include "collection/hashtable/obj_hashtable.h" + #include "collection/hashtable/obj_hashtable.h" #endif @@ -104,12 +92,12 @@ typedef struct uid_linear_allocator_NB_IoT_s { //left as they are --> used in LAYER2/epenair2_proc.c and UE side typedef enum UE_STATE_NB_IoT_e { - RRC_INACTIVE_NB_IoT=0, - RRC_IDLE_NB_IoT, - RRC_SI_RECEIVED_NB_IoT, - RRC_CONNECTED_NB_IoT, - RRC_RECONFIGURED_NB_IoT, - RRC_HO_EXECUTION_NB_IoT //maybe not needed? + RRC_INACTIVE_NB_IoT=0, + RRC_IDLE_NB_IoT, + RRC_SI_RECEIVED_NB_IoT, + RRC_CONNECTED_NB_IoT, + RRC_RECONFIGURED_NB_IoT, + RRC_HO_EXECUTION_NB_IoT //maybe not needed? } UE_STATE_NB_IoT_t; @@ -250,20 +238,20 @@ typedef struct eNB_RRC_UE_NB_IoT_s { * * SRB_configList --> is used for the actual list of SRBs that is managed/that should be send over the RRC message * SRB_configList2--> refers to all the SRBs configured for that specific transaction identifier - * this because in a single transaction one or more SRBs could be established - * and you want to keep memory on what happen for every transaction + * this because in a single transaction one or more SRBs could be established + * and you want to keep memory on what happen for every transaction * Transaction ID (xid): is used to associate the proper RRC....Complete message received by the UE to the corresponding - * message previously sent by the eNB (e.g. RRCConnectionSetup -- RRCConnectionSetupComplete) - * this because it could happen that more messages are transmitted at the same time + * message previously sent by the eNB (e.g. RRCConnectionSetup -- RRCConnectionSetupComplete) + * this because it could happen that more messages are transmitted at the same time */ - LTE_SRB_ToAddModList_NB_r13_t* SRB_configList;//for SRB1 and SRB1bis - LTE_SRB_ToAddModList_NB_r13_t* SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; - LTE_DRB_ToAddModList_NB_r13_t* DRB_configList; //for all the DRBs - LTE_DRB_ToAddModList_NB_r13_t* DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; //for the configured DRBs of a xid - uint8_t DRB_active[2];//in LTE was 8 --> at most 2 for NB-IoT + LTE_SRB_ToAddModList_NB_r13_t *SRB_configList;//for SRB1 and SRB1bis + LTE_SRB_ToAddModList_NB_r13_t *SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + LTE_DRB_ToAddModList_NB_r13_t *DRB_configList; //for all the DRBs + LTE_DRB_ToAddModList_NB_r13_t *DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; //for the configured DRBs of a xid + uint8_t DRB_active[2];//in LTE was 8 --> at most 2 for NB-IoT - struct LTE_PhysicalConfigDedicated_NB_r13* physicalConfigDedicated_NB_IoT; - LTE_MAC_MainConfig_NB_r13_t* mac_MainConfig_NB_IoT; + struct LTE_PhysicalConfigDedicated_NB_r13 *physicalConfigDedicated_NB_IoT; + LTE_MAC_MainConfig_NB_r13_t *mac_MainConfig_NB_IoT; //No SPS(semi-persistent scheduling) in NB-IoT //No Measurement report in NB-IoT @@ -273,10 +261,8 @@ typedef struct eNB_RRC_UE_NB_IoT_s { SRB_INFO_TABLE_ENTRY_NB_IoT Srb1; SRB_INFO_TABLE_ENTRY_NB_IoT Srb1bis; -#if defined(ENABLE_SECURITY) /* KeNB as derived from KASME received from EPC */ uint8_t kenb[32]; -#endif /* Used integrity/ciphering algorithms--> maintained the same for NB-IoT */ e_LTE_CipheringAlgorithm_r12 ciphering_algorithm; //Specs. TS 36.331 V14.1.0 pag 432 Change position of chipering enumerative w.r.t previous version @@ -315,7 +301,7 @@ typedef struct eNB_RRC_UE_NB_IoT_s { transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB]; - //Which timers are referring to? + //Which timers are referring to? uint32_t ul_failure_timer; uint32_t ue_release_timer; //threshold of the release timer--> set in RRCConnectionRelease @@ -352,13 +338,13 @@ typedef struct rrc_eNB_ue_context_NB_IoT_s { typedef struct { // buffer that contains the encoded messages - uint8_t *MIB_NB_IoT; - uint8_t sizeof_MIB_NB_IoT; + uint8_t *MIB_NB_IoT; + uint8_t sizeof_MIB_NB_IoT; uint8_t *SIB1_NB_IoT; uint8_t sizeof_SIB1_NB_IoT; - uint8_t *SIB23_NB_IoT; - uint8_t sizeof_SIB23_NB_IoT; + uint8_t *SIB23_NB_IoT; + uint8_t sizeof_SIB23_NB_IoT; //not actually implemented in OAI @@ -372,18 +358,18 @@ typedef struct { uint8_t sizeof_SIB16_NB_IoT; //TS 36.331 V14.2.1 -// uint8_t *SIB15_NB; -// uint8_t sizeof_SIB15_NB; -// uint8_t *SIB20_NB; -// uint8_t sizeof_SIB20_NB; -// uint8_t *SIB22_NB; -// uint8_t sizeof_SIB22_NB; + // uint8_t *SIB15_NB; + // uint8_t sizeof_SIB15_NB; + // uint8_t *SIB20_NB; + // uint8_t sizeof_SIB20_NB; + // uint8_t *SIB22_NB; + // uint8_t sizeof_SIB22_NB; //implicit parameters needed int Ncp; //cyclic prefix for DL - int Ncp_UL; //cyclic prefix for UL + int Ncp_UL; //cyclic prefix for UL int p_eNB; //number of tx antenna port - int p_rx_eNB; //number of receiving antenna ports + int p_rx_eNB; //number of receiving antenna ports uint32_t dl_CarrierFreq; //detected by the UE uint32_t ul_CarrierFreq; //detected by the UE uint16_t physCellId; //not stored in the MIB-NB but is getting through NPSS/NSSS @@ -393,12 +379,12 @@ typedef struct { LTE_BCCH_DL_SCH_Message_NB_t siblock1_NB_IoT; //SIB1-NB LTE_BCCH_DL_SCH_Message_NB_t systemInformation_NB_IoT; //SI - LTE_SystemInformationBlockType1_NB_t *sib1_NB_IoT; - LTE_SystemInformationBlockType2_NB_r13_t *sib2_NB_IoT; - LTE_SystemInformationBlockType3_NB_r13_t *sib3_NB_IoT; + LTE_SystemInformationBlockType1_NB_t *sib1_NB_IoT; + LTE_SystemInformationBlockType2_NB_r13_t *sib2_NB_IoT; + LTE_SystemInformationBlockType3_NB_r13_t *sib3_NB_IoT; //not implemented yet - LTE_SystemInformationBlockType4_NB_r13_t *sib4_NB_IoT; - LTE_SystemInformationBlockType5_NB_r13_t *sib5_NB_IoT; + LTE_SystemInformationBlockType4_NB_r13_t *sib4_NB_IoT; + LTE_SystemInformationBlockType5_NB_r13_t *sib5_NB_IoT; LTE_SystemInformationBlockType14_NB_r13_t *sib14_NB_IoT; LTE_SystemInformationBlockType16_NB_r13_t *sib16_NB_IoT; @@ -414,9 +400,9 @@ typedef struct { SystemInformationBlockType20_NB_r14_t *sib20; SystemInformationBlockType22_NB_r14_t *sib22; - uint8_t SCPTM_flag; - uint8_t sizeof_SC_MCHH_MESS[]; - SC_MCCH_Message_NB_t scptm;*/ + uint8_t SCPTM_flag; + uint8_t sizeof_SC_MCHH_MESS[]; + SC_MCCH_Message_NB_t scptm;*/ } rrc_eNB_carrier_data_NB_IoT_t; @@ -463,9 +449,9 @@ typedef struct eNB_RRC_INST_NB_IoT_s { //not needed for the moment typedef struct OAI_UECapability_NB_IoT_s { - uint8_t sdu[MAX_UE_CAPABILITY_SIZE_NB_IoT]; - uint8_t sdu_size; -////NB-IoT------ + uint8_t sdu[MAX_UE_CAPABILITY_SIZE_NB_IoT]; + uint8_t sdu_size; + ////NB-IoT------ LTE_UE_Capability_NB_r13_t UE_Capability_NB_IoT; //replace the UE_EUTRA_Capability of LTE } OAI_UECapability_NB_IoT_t; @@ -476,17 +462,15 @@ typedef struct OAI_UECapability_NB_IoT_s { typedef struct UE_RRC_INST_NB_IoT_s { Rrc_State_NB_IoT_t RrcState; Rrc_Sub_State_NB_IoT_t RrcSubState; -# if defined(ENABLE_USE_MME) plmn_t plmnID; Byte_t rat; as_nas_info_t initialNasMsg; -# endif OAI_UECapability_NB_IoT_t *UECap; uint8_t *UECapability; uint8_t UECapability_size; UE_RRC_INFO_NB_IoT Info[NB_SIG_CNX_UE]; - + SRB_INFO_NB_IoT Srb0[NB_SIG_CNX_UE]; SRB_INFO_TABLE_ENTRY_NB_IoT Srb1[NB_CNX_UE]; SRB_INFO_TABLE_ENTRY_NB_IoT Srb2[NB_CNX_UE]; @@ -513,7 +497,7 @@ typedef struct UE_RRC_INST_NB_IoT_s { SystemInformationBlockType10_t *sib10[NB_CNX_UE]; SystemInformationBlockType11_t *sib11[NB_CNX_UE]; -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t MBMS_flag; uint8_t *MCCH_MESSAGE[NB_CNX_UE]; uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE]; @@ -521,11 +505,11 @@ typedef struct UE_RRC_INST_NB_IoT_s { MBSFNAreaConfiguration_r9_t *mcch_message[NB_CNX_UE]; SystemInformationBlockType12_r9_t *sib12[NB_CNX_UE]; SystemInformationBlockType13_r9_t *sib13[NB_CNX_UE]; -#endif -#ifdef CBA + #endif + #ifdef CBA uint8_t num_active_cba_groups; uint16_t cba_rnti[NUM_MAX_CBA_GROUP]; -#endif + #endif uint8_t num_srb; struct SRB_ToAddMod *SRB1_config[NB_CNX_UE]; struct SRB_ToAddMod *SRB2_config[NB_CNX_UE]; @@ -551,14 +535,14 @@ typedef struct UE_RRC_INST_NB_IoT_s { float rsrq_db[7]; float rsrp_db_filtered[7]; float rsrq_db_filtered[7]; -#if ENABLE_RAL + #if ENABLE_RAL obj_hash_table_t *ral_meas_thresholds; ral_transaction_id_t scan_transaction_id; -#endif -#if defined(ENABLE_SECURITY) + #endif + #if defined(ENABLE_SECURITY) // KeNB as computed from parameters within USIM card // uint8_t kenb[32]; -#endif + #endif // Used integrity/ciphering algorithms // CipheringAlgorithm_r12_t ciphering_algorithm; diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index 49f9e1674051dbaa753e388ebc1749e9f063dff2..cddd409922bf7676c325083593bb626a49f1f5c4 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -69,17 +69,14 @@ #include "rrc_UE_ral.h" #endif -#if defined(ENABLE_SECURITY) - #include "UTIL/OSA/osa_defs.h" -#endif +#include "UTIL/OSA/osa_defs.h" #include "pdcp.h" #include "plmn_data.h" #include "msc.h" -#if defined(ENABLE_ITTI) - #include "intertask_interface.h" -#endif +#include "intertask_interface.h" + #include "SIMULATION/TOOLS/sim.h" // for taus @@ -156,12 +153,11 @@ uint8_t rrc_ue_generate_SidelinkUEInformation( const protocol_ctxt_t *const ctxt /*------------------------------------------------------------------------------*/ -/* to avoid gcc warnings when compiling with certain options */ -#if defined(ENABLE_USE_MME) || ENABLE_RAL + static Rrc_State_t rrc_get_state (module_id_t ue_mod_idP) { return UE_rrc_inst[ue_mod_idP].RrcState; } -#endif + static Rrc_Sub_State_t rrc_get_sub_state (module_id_t ue_mod_idP) { return UE_rrc_inst[ue_mod_idP].RrcSubState; @@ -181,27 +177,25 @@ static int rrc_set_state (module_id_t ue_mod_idP, Rrc_State_t state) { //----------------------------------------------------------------------------- static int rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_t subState ) { -#if (defined(ENABLE_ITTI) && (defined(ENABLE_USE_MME) || ENABLE_RAL)) - - switch (UE_rrc_inst[ue_mod_idP].RrcState) { - case RRC_STATE_INACTIVE: - AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST), - "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState); - break; + if (EPC_MODE_ENABLED) { + switch (UE_rrc_inst[ue_mod_idP].RrcState) { + case RRC_STATE_INACTIVE: + AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST), + "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState); + break; - case RRC_STATE_IDLE: - AssertFatal ((RRC_SUB_STATE_IDLE_FIRST <= subState) && (subState <= RRC_SUB_STATE_IDLE_LAST), - "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState); - break; + case RRC_STATE_IDLE: + AssertFatal ((RRC_SUB_STATE_IDLE_FIRST <= subState) && (subState <= RRC_SUB_STATE_IDLE_LAST), + "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState); + break; - case RRC_STATE_CONNECTED: - AssertFatal ((RRC_SUB_STATE_CONNECTED_FIRST <= subState) && (subState <= RRC_SUB_STATE_CONNECTED_LAST), - "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState); - break; + case RRC_STATE_CONNECTED: + AssertFatal ((RRC_SUB_STATE_CONNECTED_FIRST <= subState) && (subState <= RRC_SUB_STATE_CONNECTED_LAST), + "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[ue_mod_idP].RrcState); + break; + } } -#endif - if (UE_rrc_inst[ue_mod_idP].RrcSubState != subState) { UE_rrc_inst[ue_mod_idP].RrcSubState = subState; return (1); @@ -233,7 +227,7 @@ openair_rrc_on_ue( } //----------------------------------------------------------------------------- -static void init_SI_UE( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) { +static void init_SI_UE( protocol_ctxt_t const *ctxt_pP, const uint8_t eNB_index ) { UE_rrc_inst[ctxt_pP->module_id].sizeof_SIB1[eNB_index] = 0; UE_rrc_inst[ctxt_pP->module_id].sizeof_SI[eNB_index] = 0; UE_rrc_inst[ctxt_pP->module_id].SIB1[eNB_index] = (uint8_t *)malloc16_clear( 32 ); @@ -428,7 +422,6 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index ) { //----------------------------------------------------------------------------- void openair_rrc_ue_init_security( const protocol_ctxt_t *const ctxt_pP ) { -#if defined(ENABLE_SECURITY) // uint8_t *kRRCenc; // uint8_t *kRRCint; char ascii_buffer[65]; @@ -442,7 +435,6 @@ void openair_rrc_ue_init_security( const protocol_ctxt_t *const ctxt_pP ) { LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT"[OSA] kenb = %s\n", PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), ascii_buffer); -#endif } //----------------------------------------------------------------------------- @@ -534,9 +526,9 @@ void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t *const ctxt_pP, mui_t rrc_mui=0; -#if !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)) + /* NAS Attach request with IMSI */ -static const char const nas_attach_req_imsi[] = { +static const char nas_attach_req_imsi[] = { 0x07, 0x41, /* EPS Mobile identity = IMSI */ 0x71, 0x08, 0x29, 0x80, 0x43, 0x21, 0x43, 0x65, 0x87, @@ -548,7 +540,7 @@ static const char const nas_attach_req_imsi[] = { 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2, 0x01, 0x27, 0x11, }; -#endif /* !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)) */ + //----------------------------------------------------------------------------- void @@ -596,13 +588,15 @@ static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t *c uint8_t size; const char *nas_msg; int nas_msg_length; -#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - nas_msg = (char *) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; - nas_msg_length = UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; -#else - nas_msg = nas_attach_req_imsi; - nas_msg_length = sizeof(nas_attach_req_imsi); -#endif + + if (EPC_MODE_ENABLED) { + nas_msg = (char *) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; + nas_msg_length = UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; + } else { + nas_msg = nas_attach_req_imsi; + nas_msg_length = sizeof(nas_attach_req_imsi); + } + size = do_RRCConnectionSetupComplete(ctxt_pP->module_id, buffer, Transaction_id, nas_msg_length, nas_msg); LOG_I(RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionSetupComplete (bytes%d, eNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame, size, eNB_index); @@ -800,15 +794,14 @@ rrc_ue_establish_drb( //----------------------------------------------------------------------------- { // add descriptor from RRC PDU -#ifdef PDCP_USE_NETLINK int oip_ifup=0,ip_addr_offset3=0,ip_addr_offset4=0; /* avoid gcc warnings */ (void)oip_ifup; (void)ip_addr_offset3; (void)ip_addr_offset4; -#endif LOG_I(RRC,"[UE %d] Frame %d: processing RRCConnectionReconfiguration: reconfiguring DRB %ld/LCID %d\n", ue_mod_idP, frameP, DRB_config->drb_Identity, (int)*DRB_config->logicalChannelIdentity); + /* rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, UNDEF_SECURITY_MODE); @@ -817,33 +810,34 @@ rrc_ue_establish_drb( (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, RADIO_ACCESS_BEARER,Rlc_info_um); */ -#ifdef PDCP_USE_NETLINK + if(PDCP_USE_NETLINK) { # if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) && !defined(OAI_USRP) && !defined(OAI_BLADERF) && !defined(ETHERNET) && !defined(LINK_ENB_PDCP_TO_GTPV1U) - ip_addr_offset3 = 0; - ip_addr_offset4 = 1; - LOG_I(OIP,"[UE %d] trying to bring up the OAI interface oai%d, IP 10.0.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, - ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); - oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP, // interface_id - ip_addr_offset3+ue_mod_idP+1, // third_octet - ip_addr_offset4+ue_mod_idP+1); // fourth_octet - - if (oip_ifup == 0 ) { // interface is up --> send a config the DRB - LOG_I(OIP,"[UE %d] Config the oai%d to send/receive pkt on DRB %ld to/from the protocol stack\n", - ue_mod_idP, - ip_addr_offset3+ue_mod_idP, - (long int)((eNB_index * maxDRB) + DRB_config->drb_Identity)); - rb_conf_ipv4(0,//add - ue_mod_idP,//cx align with the UE index - ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index - (eNB_index * maxDRB) + DRB_config->drb_Identity,//rb - 0,//dscp - ipv4_address(ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1),//saddr - ipv4_address(ip_addr_offset3+ue_mod_idP+1,eNB_index+1));//daddr - LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index); - } + ip_addr_offset3 = 0; + ip_addr_offset4 = 1; + LOG_I(OIP,"[UE %d] trying to bring up the OAI interface oai%d, IP 10.0.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, + ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); + oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP, // interface_id + ip_addr_offset3+ue_mod_idP+1, // third_octet + ip_addr_offset4+ue_mod_idP+1); // fourth_octet + + if (oip_ifup == 0 ) { // interface is up --> send a config the DRB + LOG_I(OIP,"[UE %d] Config the oai%d to send/receive pkt on DRB %ld to/from the protocol stack\n", + ue_mod_idP, + ip_addr_offset3+ue_mod_idP, + (long int)((eNB_index * maxDRB) + DRB_config->drb_Identity)); + rb_conf_ipv4(0,//add + ue_mod_idP,//cx align with the UE index + ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index + (eNB_index * maxDRB) + DRB_config->drb_Identity,//rb + 0,//dscp + ipv4_address(ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1),//saddr + ipv4_address(ip_addr_offset3+ue_mod_idP+1,eNB_index+1));//daddr + LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index); + } # endif -#endif + } + return(0); } @@ -1309,12 +1303,10 @@ rrc_ue_process_radioResourceConfigDedicated( if (radioResourceConfigDedicated->srb_ToAddModList) { uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; -#if defined(ENABLE_SECURITY) derive_key_rrc_enc(UE_rrc_inst[ctxt_pP->module_id].ciphering_algorithm, UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCenc); derive_key_rrc_int(UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm, UE_rrc_inst[ctxt_pP->module_id].kenb, &kRRCint); -#endif // Refresh SRBs rrc_pdcp_config_asn1_req(ctxt_pP, radioResourceConfigDedicated->srb_ToAddModList, @@ -1487,10 +1479,8 @@ rrc_ue_process_radioResourceConfigDedicated( } uint8_t *kUPenc = NULL; -#if defined(ENABLE_SECURITY) derive_key_up_enc(UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm, UE_rrc_inst[ctxt_pP->module_id].kenb, &kUPenc); -#endif MSC_LOG_TX_MESSAGE( MSC_RRC_UE, MSC_PDCP_UE, @@ -1665,7 +1655,6 @@ rrc_ue_process_securityModeCommand( ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure; } -#if defined(ENABLE_SECURITY) uint8_t *kRRCenc = NULL; uint8_t *kUPenc = NULL; uint8_t *kRRCint = NULL; @@ -1715,8 +1704,6 @@ rrc_ue_process_securityModeCommand( LOG_I(RRC, "Could not get PDCP instance where key=0x%ld\n", key); } -#endif //#if defined(ENABLE_SECURITY) - if (securityModeCommand->criticalExtensions.present == LTE_SecurityModeCommand__criticalExtensions_PR_c1) { if (securityModeCommand->criticalExtensions.choice.c1.present != LTE_SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) LOG_W(RRC,"securityModeCommand->criticalExtensions.choice.c1.present (%d) != SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8\n", @@ -1906,7 +1893,6 @@ rrc_ue_process_rrcConnectionReconfiguration( ); } */ -#if defined(ENABLE_ITTI) /* Check if there is dedicated NAS information to forward to NAS */ if (rrcConnectionReconfiguration_r8->dedicatedInfoNASList != NULL) { @@ -1970,7 +1956,6 @@ rrc_ue_process_rrcConnectionReconfiguration( LOG_I(RRC, "Sending RRC_RAL_CONNECTION_REESTABLISHMENT_IND to mRAL\n"); itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p); } -#endif #endif } // c1 present } // critical extensions present @@ -2134,9 +2119,7 @@ rrc_ue_decode_dcch( // asn_dec_rval_t dec_rval; // int i; uint8_t target_eNB_index=0xFF; -#if defined(ENABLE_ITTI) MessageDef *msg_p; -#endif if (Srb_id != 1) { LOG_E(RRC,"[UE %d] Frame %d: Received message on DL-DCCH (SRB%d), should not have ...\n", @@ -2166,7 +2149,6 @@ rrc_ue_decode_dcch( break; case LTE_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: { -#if defined(ENABLE_ITTI) LTE_DLInformationTransfer_t *dlInformationTransfer = &dl_dcch_msg->message.choice.c1.choice.dlInformationTransfer; if ((dlInformationTransfer->criticalExtensions.present == LTE_DLInformationTransfer__criticalExtensions_PR_c1) @@ -2189,7 +2171,6 @@ rrc_ue_decode_dcch( itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); } -#endif break; } @@ -2244,7 +2225,6 @@ rrc_ue_decode_dcch( UE_rrc_inst[ctxt_pP->module_id].Info[target_eNB_index].State = RRC_RECONFIGURED; LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n", ctxt_pP->module_id, target_eNB_index); -#if defined(ENABLE_ITTI) #if ENABLE_RAL { MessageDef *message_ral_p = NULL; @@ -2289,7 +2269,6 @@ rrc_ue_decode_dcch( LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND to mRAL\n"); itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p); } -#endif #endif } else { rrc_ue_generate_RRCConnectionReconfigurationComplete( @@ -2300,7 +2279,6 @@ rrc_ue_decode_dcch( LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n", ctxt_pP->module_id, eNB_indexP); -#if defined(ENABLE_ITTI) #if ENABLE_RAL { MessageDef *message_ral_p = NULL; @@ -2345,7 +2323,6 @@ rrc_ue_decode_dcch( LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_IND to mRAL\n"); itti_send_msg_to_task (TASK_RAL_UE, ctxt_pP->instance, message_ral_p); } -#endif #endif } @@ -2369,7 +2346,6 @@ rrc_ue_decode_dcch( break; case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease: -#if defined(ENABLE_ITTI) msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND); if ((dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.present @@ -2385,7 +2361,6 @@ rrc_ue_decode_dcch( msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_CONNECTION_RELEASE_IND); RRC_RAL_CONNECTION_RELEASE_IND(msg_p).ue_id = ctxt_pP->module_id; itti_send_msg_to_task(TASK_RAL_UE, ctxt_pP->instance, msg_p); -#endif #endif break; @@ -2682,13 +2657,16 @@ int decode_BCCH_DLSCH_Message( } } - if ((rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) -#if defined(ENABLE_USE_MME) - && (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) -#endif - ) { - rrc_ue_generate_RRCConnectionRequest(ctxt_pP, 0); - rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_CONNECTING ); + // if ((rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) + //#if defined(ENABLE_USE_MME) + // && (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) + //#endif + // ) { + if (rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) { + if ( (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) || (!EPC_MODE_ENABLED)) { + rrc_ue_generate_RRCConnectionRequest(ctxt_pP, 0); + rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_CONNECTING ); + } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT ); @@ -2873,8 +2851,9 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, LOG_I(RRC,"Setting SIStatus bit 0 to 1\n"); UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1; UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag; -#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - { + + //#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) + if (EPC_MODE_ENABLED) { int cell_valid = 0; if (sib1->cellAccessRelatedInfo.cellBarred == LTE_SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred) { @@ -2922,7 +2901,7 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, cell_valid = 1; break; } - } + } /* for plmn = 0;... */ } if (cell_valid == 0) { @@ -2932,8 +2911,8 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, itti_send_msg_to_task(TASK_PHY_UE, ctxt_pP->instance, msg_p); LOG_E(RRC, "Synched with a cell, but PLMN doesn't match our SIM, the message PHY_FIND_NEXT_CELL_REQ is sent but lost in current UE implementation! \n"); } - } -#endif + }/* EPC_MODE_ENABLED */ + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SIB1, VCD_FUNCTION_OUT ); return 0; } @@ -3500,8 +3479,7 @@ int decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) { #endif LOG_D( RRC, "[UE] (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count %d\n", (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count ); - } - else { + } else { LOG_D( RRC, "[UE] Unknown criticalExtension version (not Rel8)\n" ); return -1; } @@ -3560,10 +3538,9 @@ int decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) { if (UE_rrc_inst[ctxt_pP->module_id].MBMS_flag < 3) // see -Q option #endif -#if !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)) - rrc_ue_generate_RRCConnectionRequest( ctxt_pP, eNB_index ); - -#endif + if (EPC_MODE_ENABLED) { + rrc_ue_generate_RRCConnectionRequest( ctxt_pP, eNB_index ); + } if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_IDLE) { LOG_I( RRC, "[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n", ctxt_pP->module_id ); @@ -3827,7 +3804,7 @@ int decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) { sib1->schedulingInfoList.list.count); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI , VCD_FUNCTION_OUT); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_OUT); return 0; } @@ -4095,7 +4072,7 @@ uint8_t check_trigger_meas_event( uint8_t eNB_offset; // uint8_t currentCellIndex = frame_parms->Nid_cell; uint8_t tmp_offset; - LOG_I(RRC,"[UE %d] ofn(%ld) ocn(%ld) hys(%ld) ofs(%ld) ocs(%ld) a3_offset(%ld) ttt(%ld) rssi %3.1f\n", + LOG_D(RRC,"[UE %d] ofn(%ld) ocn(%ld) hys(%ld) ofs(%ld) ocs(%ld) a3_offset(%ld) ttt(%ld) rssi %3.1f\n", ue_mod_idP, ofn,ocn,hys,ofs,ocs,a3_offset,ttt, 10*log10(get_RSSI(ue_mod_idP,0))-get_rx_total_gain_dB(ue_mod_idP,0)); @@ -4291,7 +4268,6 @@ void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_index, f #endif // rel10 -#if defined(ENABLE_ITTI) //----------------------------------------------------------------------------- void *rrc_ue_task( void *args_p ) { MessageDef *msg_p; @@ -4315,6 +4291,7 @@ void *rrc_ue_task( void *args_p ) { break; case MESSAGE_TEST: + LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; /* MAC messages */ @@ -4419,7 +4396,6 @@ void *rrc_ue_task( void *args_p ) { result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND (msg_p).sdu_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); break; -# if defined(ENABLE_USE_MME) case NAS_KENB_REFRESH_REQ: memcpy((void *)UE_rrc_inst[ue_mod_id].kenb, (void *)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb)); @@ -4570,7 +4546,6 @@ void *rrc_ue_task( void *args_p ) { break; } -# endif # if ENABLE_RAL case RRC_RAL_SCAN_REQ: @@ -4722,7 +4697,7 @@ void *rrc_ue_task( void *args_p ) { msg_p = NULL; } } -#endif + @@ -5028,7 +5003,7 @@ rrc_control_socket_init() { // error("ERROR: Failed on opening socket"); optval = 1; setsockopt(ctrl_sock_fd, SOL_SOCKET, SO_REUSEADDR, - (const void *)&optval , sizeof(int)); + (const void *)&optval, sizeof(int)); //build the server's address bzero((char *) &rrc_ctrl_socket_addr, sizeof(rrc_ctrl_socket_addr)); rrc_ctrl_socket_addr.sin_family = AF_INET; diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index 6b616546bf4ac133478b5e626f145a47d72a559f..38fc7b7262ced788cd273a94fa97c96acea93abd 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -284,21 +284,14 @@ void *send_UE_status_notification(void *); #include "rrc_rrm_interface.h" #endif -#if defined(ENABLE_ITTI) - #include "intertask_interface.h" -#endif -/* TODO: be sure this include is correct. - * It solves a problem of compilation of the RRH GW, - * issue #186. - */ -#if !defined(ENABLE_ITTI) - #include "as_message.h" -#endif +#include "intertask_interface.h" + + + + +#include "commonDef.h" -#if defined(ENABLE_USE_MME) - #include "commonDef.h" -#endif //-------- typedef unsigned int uid_t; @@ -431,7 +424,7 @@ typedef struct UE_S_TMSI_s { m_tmsi_t m_tmsi; } __attribute__ ((__packed__)) UE_S_TMSI; -#if defined(ENABLE_ITTI) + typedef enum e_rab_satus_e { E_RAB_STATUS_NEW, E_RAB_STATUS_DONE, // from the eNB perspective @@ -448,7 +441,7 @@ typedef struct e_rab_param_s { s1ap_Cause_t cause; uint8_t cause_value; } __attribute__ ((__packed__)) e_rab_param_t; -#endif + /* Intermediate structure for Handover management. Associated per-UE in eNB_RRC_INST */ typedef struct HANDOVER_INFO_s { @@ -554,13 +547,11 @@ typedef struct eNB_RRC_UE_s { int UE_Capability_size; ImsiMobileIdentity_t imsi; -#if defined(ENABLE_SECURITY) /* KeNB as derived from KASME received from EPC */ uint8_t kenb[32]; int8_t kenb_ncc; uint8_t nh[32]; int8_t nh_ncc; -#endif /* Used integrity/ciphering algorithms */ LTE_CipheringAlgorithm_r12_t ciphering_algorithm; e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; @@ -569,7 +560,7 @@ typedef struct eNB_RRC_UE_s { rnti_t rnti; uint64_t random_ue_identity; -#if defined(ENABLE_ITTI) + /* Information from UE RRC ConnectionRequest */ UE_S_TMSI Initialue_identity_s_TMSI; LTE_EstablishmentCause_t establishment_cause; @@ -613,7 +604,6 @@ typedef struct eNB_RRC_UE_s { uint32_t enb_gtp_teid[S1AP_MAX_E_RAB]; transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB]; -#endif uint32_t ul_failure_timer; uint32_t ue_release_timer; uint32_t ue_release_timer_thres; @@ -725,10 +715,7 @@ typedef struct eNB_RRC_INST_s { #endif //RRC configuration -#if defined(ENABLE_ITTI) RrcConfigurationReq configuration; -#endif - // other RAN parameters int srb1_timer_poll_retransmit; int srb1_poll_pdu; @@ -749,11 +736,9 @@ typedef struct OAI_UECapability_s { typedef struct UE_RRC_INST_s { Rrc_State_t RrcState; Rrc_Sub_State_t RrcSubState; -# if defined(ENABLE_USE_MME) plmn_t plmnID; Byte_t rat; as_nas_info_t initialNasMsg; -# endif OAI_UECapability_t *UECap; uint8_t *UECapability; uint8_t UECapability_size; @@ -838,12 +823,10 @@ typedef struct UE_RRC_INST_s { float rsrq_db[7]; float rsrp_db_filtered[7]; float rsrq_db_filtered[7]; -#if defined(ENABLE_SECURITY) /* KeNB as computed from parameters within USIM card */ uint8_t kenb[32]; uint8_t nh[32]; int8_t nh_ncc; -#endif /* Used integrity/ciphering algorithms */ LTE_CipheringAlgorithm_r12_t ciphering_algorithm; diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 5a30ad4822f48fc1b6a412538cdbdbe0497f707f..3503956b108746292fbb28eacea58b1fe0c821d4 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -75,32 +75,15 @@ #include "OCG.h" #include "OCG_extern.h" -#if defined(ENABLE_SECURITY) - #include "UTIL/OSA/osa_defs.h" -#endif - -#if defined(ENABLE_USE_MME) - #include "rrc_eNB_S1AP.h" - #include "rrc_eNB_GTPV1U.h" - #if defined(ENABLE_ITTI) - #else - #include "../../S1AP/s1ap_eNB.h" - #endif - /* temporary warning removale while implementing noS1 */ - /* as config option */ -#else - #ifdef EPC_MODE_ENABLED - #undef EPC_MODE_ENABLED - #endif - #define EPC_MODE_ENABLED 0 -#endif +#include "UTIL/OSA/osa_defs.h" + +#include "rrc_eNB_S1AP.h" +#include "rrc_eNB_GTPV1U.h" #include "pdcp.h" #include "gtpv1u_eNB_task.h" -#if defined(ENABLE_ITTI) - #include "intertask_interface.h" -#endif +#include "intertask_interface.h" #if ENABLE_RAL #include "rrc_eNB_ral.h" @@ -144,9 +127,9 @@ openair_rrc_on( //----------------------------------------------------------------------------- static void init_SI( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const int CC_id, - RrcConfigurationReq * configuration + RrcConfigurationReq *configuration ) //----------------------------------------------------------------------------- { @@ -169,81 +152,72 @@ init_SI( #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition = configuration->pbch_repetition[CC_id]; #endif - LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", - configuration->N_RB_DL[CC_id], - (int)configuration->radioresourceconfig[CC_id].phich_resource, - (int)configuration->radioresourceconfig[CC_id].phich_duration); + LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", + configuration->N_RB_DL[CC_id], + (int)configuration->radioresourceconfig[CC_id].phich_resource, + (int)configuration->radioresourceconfig[CC_id].phich_duration); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LOG_I(RRC, "configuration->schedulingInfoSIB1_BR_r13[CC_id] %d\n",(int)configuration->schedulingInfoSIB1_BR_r13[CC_id]); #endif do_MIB(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id], - configuration->N_RB_DL[CC_id], - (int)configuration->radioresourceconfig[CC_id].phich_resource, - (int)configuration->radioresourceconfig[CC_id].phich_duration, - 0 + configuration->N_RB_DL[CC_id], + (int)configuration->radioresourceconfig[CC_id].phich_resource, + (int)configuration->radioresourceconfig[CC_id].phich_duration, + 0 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,configuration->schedulingInfoSIB1_BR_r13[CC_id] + ,configuration->schedulingInfoSIB1_BR_r13[CC_id] #endif - ); - - - + ); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = 0; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = 0; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1 = (uint8_t *) malloc16(32); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1!=NULL,PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB1 allocated\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = do_SIB1(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],ctxt_pP->module_id,CC_id #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,FALSE + ,FALSE #endif - , configuration - ); - + , configuration + ); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 != 255,"FATAL, RC.rrc[enb_mod_idP].carrier[CC_id].sizeof_SIB1 == 255"); - - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1_BR = 0; + if (configuration->schedulingInfoSIB1_BR_r13[CC_id]>0) { - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1_BR = (uint8_t*) malloc16(32); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1_BR = (uint8_t *) malloc16(32); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1_BR = do_SIB1(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],ctxt_pP->module_id,CC_id - ,TRUE - , configuration - ); + ,TRUE + , configuration + ); } + #endif - - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t*) malloc16(64); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t *) malloc16(64); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23!=NULL,"cannot allocate memory for SIB"); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = do_SIB23( - ctxt_pP->module_id, - CC_id + ctxt_pP->module_id, + CC_id #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,FALSE + ,FALSE #endif - , configuration - ); - + , configuration + ); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 != 255,"FATAL, RC.rrc[mod].carrier[CC_id].sizeof_SIB23 == 255"); - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23_BR = 0; + if (configuration->schedulingInfoSIB1_BR_r13[CC_id]>0) { - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23_BR = (uint8_t*) malloc16(64); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23_BR = (uint8_t *) malloc16(64); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23_BR!=NULL,"cannot allocate memory for SIB"); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23_BR = do_SIB23( - ctxt_pP->module_id, - CC_id -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,TRUE -#endif - ,configuration - ); + ctxt_pP->module_id, + CC_id, + TRUE, + configuration + ); } -#endif +#endif LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n", PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.n_SB = %ld\n", @@ -275,10 +249,9 @@ init_SI( (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.cyclicShift = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.cyclicShift); - + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.cyclicShift); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag > 0) { @@ -300,8 +273,6 @@ init_SI( RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); } - - // SIB13 for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) { LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN sync area %d/%d (partial)\n", @@ -315,85 +286,77 @@ init_SI( PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); } - } - else memset((void*)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); + } else memset((void *)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); //TTN - SIB 18 if (configuration->SL_configured>0) { for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count; j++) { LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - j+1, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); - + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); } - - - for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count; j++) { LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - j+1, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); - + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); } } #endif // (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - - LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n", PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); @@ -401,32 +364,28 @@ init_SI( if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) && (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR!=NULL)) { - - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v8.9)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v9.2)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v11.3)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v12.5)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v13.10)\n"); - sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension; - - // Basic Asserts for CE_level0 PRACH configuration - - LTE_RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR = &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon; - struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach=radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - - LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - AssertFatal(prach_ParametersListCE_r13->list.count>0,"prach_ParametersListCE_r13 is empty\n"); - LTE_PRACH_ParametersCE_r13_t *p = prach_ParametersListCE_r13->list.array[0]; - AssertFatal(p->prach_StartingSubframe_r13 != NULL, "prach_StartingSubframe_r13 celevel0 is null\n"); - AssertFatal((1<<p->numRepetitionPerPreambleAttempt_r13)<=(2<<*p->prach_StartingSubframe_r13), - "prachce0->numReptitionPerPreambleAttempt_r13 %d > prach_StartingSubframe_r13 %d\n", - 1<<p->numRepetitionPerPreambleAttempt_r13, - 2<<*p->prach_StartingSubframe_r13); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v8.9)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v9.2)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v11.3)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v12.5)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v13.10)\n"); + sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension; + // Basic Asserts for CE_level0 PRACH configuration + LTE_RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR = &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon; + struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach=radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; + LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; + AssertFatal(prach_ParametersListCE_r13->list.count>0,"prach_ParametersListCE_r13 is empty\n"); + LTE_PRACH_ParametersCE_r13_t *p = prach_ParametersListCE_r13->list.array[0]; + AssertFatal(p->prach_StartingSubframe_r13 != NULL, "prach_StartingSubframe_r13 celevel0 is null\n"); + AssertFatal((1<<p->numRepetitionPerPreambleAttempt_r13)<=(2<<*p->prach_StartingSubframe_r13), + "prachce0->numReptitionPerPreambleAttempt_r13 %d > prach_StartingSubframe_r13 %d\n", + 1<<p->numRepetitionPerPreambleAttempt_r13, + 2<<*p->prach_StartingSubframe_r13); } #endif @@ -537,10 +496,8 @@ init_MCCH( (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif (struct LTE_PhysicalConfigDedicated *)NULL, -#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (LTE_SCellToAddMod_r10_t *)NULL, //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif (LTE_MeasObjectToAddMod_t **) NULL, (LTE_MAC_MainConfig_t *) NULL, 0, @@ -550,12 +507,10 @@ init_MCCH( (LTE_MobilityControlInfo_t *)NULL, (LTE_SchedulingInfoList_t *) NULL, 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) -#endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL @@ -587,9 +542,7 @@ static void init_MBMS( NULL, // key rrc encryption NULL, // key rrc integrity NULL // key encryption -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) -#endif ,NULL); rrc_rlc_config_asn1_req(&ctxt, NULL, // LTE_SRB_ToAddModList @@ -843,10 +796,9 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.measConfig = NULL; } +#if 0 //HANDOVER_INFO *handover_info; -#if defined(ENABLE_SECURITY) //uint8_t kenb[32]; -#endif //e_SecurityAlgorithmConfig__cipheringAlgorithm ciphering_algorithm; //e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; //uint8_t Status; @@ -865,6 +817,7 @@ rrc_eNB_free_mem_UE_context( //transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; //rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB]; #endif +#endif } //----------------------------------------------------------------------------- @@ -1443,63 +1396,67 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( ue_context_pP->ue_context.Srb1.Active = 1; //ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2; -#if defined(ENABLE_USE_MME) - hashtable_rc_t h_rc; - int j; - rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL; - uint16_t ue_initial_id = ue_context_pP->ue_context.ue_initial_id; - uint32_t eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - eNB_RRC_INST *rrc_instance_p = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]; - - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&rrc_ue_s1ap_ids_p); - - if (h_rc == HASH_TABLE_OK) { - rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; + + if (EPC_MODE_ENABLED) { + hashtable_rc_t h_rc; + int j; + rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL; + uint16_t ue_initial_id = ue_context_pP->ue_context.ue_initial_id; + uint32_t eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; + eNB_RRC_INST *rrc_instance_p = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]; + + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&rrc_ue_s1ap_ids_p); + + if (h_rc == HASH_TABLE_OK) { + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; + } } - } - if (ue_initial_id != 0) { - h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void **)&rrc_ue_s1ap_ids_p); + if (ue_initial_id != 0) { + h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void **)&rrc_ue_s1ap_ids_p); - if (h_rc == HASH_TABLE_OK) { - rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; + if (h_rc == HASH_TABLE_OK) { + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; + } } - } - gtpv1u_enb_create_tunnel_req_t create_tunnel_req; - /* Save e RAB information for later */ - memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); - - for ( j = 0, i = 0; i < NB_RB_MAX; i++) { - if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED || ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_DONE) { - create_tunnel_req.eps_bearer_id[j] = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; - create_tunnel_req.sgw_S1u_teid[j] = ue_context_pP->ue_context.e_rab[i].param.gtp_teid; - memcpy(&create_tunnel_req.sgw_addr[j], - &ue_context_pP->ue_context.e_rab[i].param.sgw_addr, - sizeof(transport_layer_addr_t)); - j++; + gtpv1u_enb_create_tunnel_req_t create_tunnel_req; + /* Save e RAB information for later */ + memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); + + for ( j = 0, i = 0; i < NB_RB_MAX; i++) { + if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED || ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_DONE) { + create_tunnel_req.eps_bearer_id[j] = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + create_tunnel_req.sgw_S1u_teid[j] = ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + memcpy(&create_tunnel_req.sgw_addr[j], + &ue_context_pP->ue_context.e_rab[i].param.sgw_addr, + sizeof(transport_layer_addr_t)); + j++; + } } - } - create_tunnel_req.rnti = ctxt_pP->rnti; // warning put zero above - create_tunnel_req.num_tunnels = j; - gtpv1u_update_s1u_tunnel( - ctxt_pP->instance, - &create_tunnel_req, - reestablish_rnti); -#endif + create_tunnel_req.rnti = ctxt_pP->rnti; // warning put zero above + create_tunnel_req.num_tunnels = j; + gtpv1u_update_s1u_tunnel( + ctxt_pP->instance, + &create_tunnel_req, + reestablish_rnti); + } /* EPC_MODE_ENABLED */ + /* Update RNTI in ue_context */ ue_context_pP->ue_id_rnti = ctxt_pP->rnti; // here ue_id_rnti is just a key, may be something else ue_context_pP->ue_context.rnti = ctxt_pP->rnti; -#if defined(ENABLE_USE_MME) - uint8_t send_security_mode_command = FALSE; - rrc_pdcp_config_security( - ctxt_pP, - ue_context_pP, - send_security_mode_command); - LOG_D(RRC, "set security successfully \n"); -#endif + + if (EPC_MODE_ENABLED) { + uint8_t send_security_mode_command = FALSE; + rrc_pdcp_config_security( + ctxt_pP, + ue_context_pP, + send_security_mode_command); + LOG_D(RRC, "set security successfully \n"); + } + // Measurement ID list MeasId_list = CALLOC(1, sizeof(*MeasId_list)); memset((void *)MeasId_list, 0, sizeof(*MeasId_list)); @@ -1752,7 +1709,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif -#if defined(ENABLE_ITTI) /* Initialize NAS list */ dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); @@ -1786,7 +1742,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( dedicatedInfoNASList = NULL; } -#endif // send LTE_RRCConnectionReconfiguration memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCConnectionReconfiguration(ctxt_pP, @@ -1821,7 +1776,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); -#if defined(ENABLE_ITTI) /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { @@ -1832,8 +1786,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } } -#endif - if(size==65535) { LOG_E(RRC,"RRC decode err!!! do_RRCConnectionReconfiguration\n"); put_UE_in_freelist(ctxt_pP->module_id, reestablish_rnti, 0); @@ -2029,7 +1981,6 @@ rrc_eNB_generate_RRCConnectionRelease( uint8_t qci_to_priority[9]= {2,4,3,5,1,6,7,8,9}; // TBD: this directive can be remived if we create a similar e_rab_param_t structure in RRC context -#if defined(ENABLE_ITTI) //----------------------------------------------------------------------------- void rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, @@ -2242,7 +2193,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *co #endif ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Connection Reconfiguration\n"); -#if defined(ENABLE_ITTI) /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { @@ -2253,7 +2203,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *co } } -#endif LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); @@ -2494,7 +2443,6 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *cons ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); -#if defined(ENABLE_ITTI) /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_modify_e_rabs; i++) { @@ -2505,7 +2453,6 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *cons } } -#endif LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); @@ -2610,7 +2557,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ ue_context_pP->ue_context.e_rab_release_command_flag = 1; LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); -#if defined(ENABLE_ITTI) /* Free all NAS PDUs */ if (nas_length > 0) { @@ -2618,7 +2564,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ free(nas_buffer); } -#endif LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); @@ -2644,7 +2589,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ buffer, PDCP_TRANSMISSION_MODE_CONTROL); } -#endif //----------------------------------------------------------------------------- void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, @@ -2883,62 +2827,57 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons //TODO: change TM for secondary CC in SCelltoaddmodlist if (*physicalConfigDedicated) { if ((*physicalConfigDedicated)->antennaInfo) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode; LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode); + if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm3) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; - } - else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; - } - else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; - } - else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; + } else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; + } else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; + } else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; } - } - else { + } else { LOG_E(RRC,"antenna_info not present in physical_config_dedicated. Not reconfiguring!\n"); } if ((*physicalConfigDedicated)->cqi_ReportConfig) { - if ((rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) || - (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) || - (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6)) { - //feedback mode needs to be set as well - //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable - printf("setting cqi reporting mode to rm31\n"); + (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) || + (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6)) { + //feedback mode needs to be set as well + //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable + printf("setting cqi reporting mode to rm31\n"); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31; #else @@ -3003,19 +2942,18 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1; MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6; MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL; // Default is 15 or 0dB -// MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList = -// (LTE_CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); -// CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; -// -// // Add adjacent cell lists (6 per eNB) -// for (i = 0; i < 6; i++) { -// CellToAdd = (LTE_CellsToAddMod_t *) CALLOC(1, sizeof(*CellToAdd)); -// CellToAdd->cellIndex = i + 1; -// CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); -// CellToAdd->cellIndividualOffset = LTE_Q_OffsetRange_dB0; -// ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); -// } - + // MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList = + // (LTE_CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); + // CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; + // + // // Add adjacent cell lists (6 per eNB) + // for (i = 0; i < 6; i++) { + // CellToAdd = (LTE_CellsToAddMod_t *) CALLOC(1, sizeof(*CellToAdd)); + // CellToAdd->cellIndex = i + 1; + // CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); + // CellToAdd->cellIndividualOffset = LTE_Q_OffsetRange_dB0; + // ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); + // } ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; // Report Configurations for periodical, A1-A5 events @@ -3054,7 +2992,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1); - //if (ho_state == 1 /*HO_MEASURMENT */ ) { LOG_I(RRC, "[eNB %d] frame %d: requesting A2, A3, A4, and A5 event reporting\n", ctxt_pP->module_id, ctxt_pP->frame); @@ -3180,8 +3117,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,(void *)rrc_inst->sps_Config[ue_mod_idP],sizeof(SPS_Config_t)); #endif //} - -#if defined(ENABLE_ITTI) /* Initialize NAS list */ dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); @@ -3214,7 +3149,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons dedicatedInfoNASList = NULL; } -#endif memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, @@ -3224,14 +3158,14 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, (struct LTE_SPS_Config *)NULL, // *sps_Config, (struct LTE_PhysicalConfigDedicated *)*physicalConfigDedicated, -//#ifdef EXMIMO_IOT -// NULL, NULL, NULL,NULL, -//#else + //#ifdef EXMIMO_IOT + // NULL, NULL, NULL,NULL, + //#else (LTE_MeasObjectToAddModList_t *)MeasObj_list, (LTE_ReportConfigToAddModList_t *)ReportConfig_list, (LTE_QuantityConfig_t *)quantityConfig, (LTE_MeasIdToAddModList_t *)MeasId_list, -//#endif + //#endif (LTE_MAC_MainConfig_t *)mac_MainConfig, (LTE_MeasGapConfig_t *)NULL, (LTE_MobilityControlInfo_t *)NULL, @@ -3248,7 +3182,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); -#if defined(ENABLE_ITTI) /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { @@ -3259,7 +3192,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons } } -#endif LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE id %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); @@ -3527,61 +3459,55 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt if ((*physicalConfigDedicated)->antennaInfo) { (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode; LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode); + if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm3) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; } else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; - } - else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) { - - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; + } else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; + } else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; } - - else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; - - } - } - else { + } else { LOG_E(RRC,"antenna_info not present in physical_config_dedicated. Not reconfiguring!\n"); } if ((*physicalConfigDedicated)->cqi_ReportConfig) { if ((rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) || - (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) || - (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6)) { - - //feedback mode needs to be set as well - //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable - printf("setting cqi reporting mode to rm31\n"); + (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) || + (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6)) { + //feedback mode needs to be set as well + //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable + printf("setting cqi reporting mode to rm31\n"); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31; #else @@ -3684,7 +3610,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = LTE_FilterCoefficient_fc4; *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = LTE_FilterCoefficient_fc4; -#if defined(ENABLE_ITTI) /* Initialize NAS list */ dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); @@ -3717,7 +3642,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt dedicatedInfoNASList = NULL; } -#endif memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, @@ -3751,7 +3675,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); -#if defined(ENABLE_ITTI) /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { @@ -3762,7 +3685,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt } } -#endif LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE id %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); @@ -5599,60 +5521,9 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0] = 0x22; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused = 0; - // CQI ReportConfig - /* - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic)); - assign_enum(physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic, - CQI_ReportConfig__cqi_ReportModeAperiodic_rm30); // HLC CQI, no PMI - physicalConfigDedicated2->cqi_ReportConfig->nomPDSCH_RS_EPRE_Offset = 0; // 0 dB - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic)); - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = CQI_ReportPeriodic_PR_setup; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0; // n2_pucch - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0; // Icqi/pmi - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI; // subband CQI - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4; - - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0; - */ - //soundingRS-UL-ConfigDedicated - /* - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup; - assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth, - SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0); - assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth, - SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0); - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=1; - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb=0; - assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift, - SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0); - */ //AntennaInfoDedicated physicalConfigDedicated2->antennaInfo = CALLOC(1, sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->antennaInfo->present = LTE_PhysicalConfigDedicated__antennaInfo_PR_explicitValue; - //assign_enum(&physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode, - // LTE_AntennaInfoDedicated__transmissionMode_tm2); - /* - switch (transmission_mode){ - case 1: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; - break; - case 2: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; - break; - case 4: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4; - break; - case 5: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5; - break; - case 6: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6; - break; - } - */ physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.present = LTE_AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release; physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0; @@ -6262,24 +6133,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( } #endif -/* - void ue_rrc_process_rrcConnectionReconfiguration(uint8_t enb_mod_idP,frame_t frameP, - LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration, - uint8_t CH_index) { - - if (rrcConnectionReconfiguration->criticalExtensions.present == LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1) - if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { - - if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated) { - rrc_ue_process_radioResourceConfigDedicated(enb_mod_idP,frameP,CH_index, - LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated); - - } - - // check other fields for - } - } -*/ //----------------------------------------------------------------------------- /* @@ -6295,13 +6148,11 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( //----------------------------------------------------------------------------- { int i, drb_id; -#ifdef PDCP_USE_NETLINK int oip_ifup = 0; int dest_ip_offset = 0; /* avoid gcc warnings */ (void)oip_ifup; (void)dest_ip_offset; -#endif uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; @@ -6312,7 +6163,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( LTE_DRB_Identity_t *drb_id_p = NULL; T(T_ENB_RRC_CONNECTION_RECONFIGURATION_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); -#if defined(ENABLE_SECURITY) /* Derive the keys from kenb */ if (DRB_configList != NULL) { @@ -6324,7 +6174,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ue_context_pP->ue_context.kenb, &kRRCenc); derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, ue_context_pP->ue_context.kenb, &kRRCint); -#endif // Refresh SRBs/DRBs MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, @@ -6423,38 +6272,40 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( LOG_D(RRC, "[eNB %d] Frame %d: Establish RLC UM Bidirectional, DRB %d Active\n", ctxt_pP->module_id, ctxt_pP->frame, (int)DRB_configList->list.array[i]->drb_Identity); -#if defined(PDCP_USE_NETLINK) && !defined(LINK_ENB_PDCP_TO_GTPV1U) - // can mean also IPV6 since ether -> ipv6 autoconf + + if (PDCP_USE_NETLINK && (!LINK_ENB_PDCP_TO_GTPV1U)) { + // can mean also IPV6 since ether -> ipv6 autoconf # if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) && !defined(OAI_USRP) && !defined(OAI_BLADERF) && !defined(ETHERNET) - LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n", - ctxt_pP->module_id, - ctxt_pP->module_id); - oip_ifup = nas_config( - ctxt_pP->module_id, // interface index - ctxtReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA_pP->module_id + 1, // thrid octet - ctxt_pP->module_id + 1); // fourth octet - - if (oip_ifup == 0) { // interface is up --> send a config the DRB - module_id_t ue_module_id; - dest_ip_offset = 8; - LOG_I(OIP, - "[eNB %d] Config the oai%d to send/receive pkt on DRB %ld to/from the protocol stack\n", - ctxt_pP->module_id, ctxt_pP->module_id, - (long int)((ue_context_pP->local_uid * maxDRB) + DRB_configList->list.array[i]->drb_Identity)); - ue_module_id = oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[ctxt_pP->module_id][ue_context_pP->local_uid]; - rb_conf_ipv4(0, //add - ue_module_id, //cx - ctxt_pP->module_id, //inst - (ue_module_id * maxDRB) + DRB_configList->list.array[i]->drb_Identity, // RB - 0, //dscp - ipv4_address(ctxt_pP->module_id + 1, ctxt_pP->module_id + 1), //saddr - ipv4_address(ctxt_pP->module_id + 1, dest_ip_offset + ue_module_id + 1)); //daddr - LOG_D(RRC, "[eNB %d] State = Attached (UE rnti %x module id %u)\n", - ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ue_module_id); - } + LOG_I(OIP, "[eNB %d] trying to bring up the OAI interface oai%d\n", + ctxt_pP->module_id, + ctxt_pP->module_id); + oip_ifup = nas_config( + ctxt_pP->module_id, // interface index + ctxtReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA_pP->module_id + 1, // thrid octet + ctxt_pP->module_id + 1); // fourth octet + + if (oip_ifup == 0) { // interface is up --> send a config the DRB + module_id_t ue_module_id; + dest_ip_offset = 8; + LOG_I(OIP, + "[eNB %d] Config the oai%d to send/receive pkt on DRB %ld to/from the protocol stack\n", + ctxt_pP->module_id, ctxt_pP->module_id, + (long int)((ue_context_pP->local_uid * maxDRB) + DRB_configList->list.array[i]->drb_Identity)); + ue_module_id = oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[ctxt_pP->module_id][ue_context_pP->local_uid]; + rb_conf_ipv4(0, //add + ue_module_id, //cx + ctxt_pP->module_id, //inst + (ue_module_id * maxDRB) + DRB_configList->list.array[i]->drb_Identity, // RB + 0, //dscp + ipv4_address(ctxt_pP->module_id + 1, ctxt_pP->module_id + 1), //saddr + ipv4_address(ctxt_pP->module_id + 1, dest_ip_offset + ue_module_id + 1)); //daddr + LOG_D(RRC, "[eNB %d] State = Attached (UE rnti %x module id %u)\n", + ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ue_module_id); + } # endif -#endif + } + LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (DRB) ---> MAC_eNB\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); @@ -6578,126 +6429,124 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionSetup(const protocol_ctxt_t *const ctxt_pP, - rrc_eNB_ue_context_t *const ue_context_pP, - const int CC_id - ) + rrc_eNB_ue_context_t *const ue_context_pP, + const int CC_id + ) //----------------------------------------------------------------------------- { - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) boolean_t is_mtc = ctxt_pP->brOption; #endif - LTE_LogicalChannelConfig_t *SRB1_logicalChannelConfig; //,*SRB2_logicalChannelConfig; LTE_SRB_ToAddModList_t **SRB_configList; LTE_SRB_ToAddMod_t *SRB1_config; - int cnt; T(T_ENB_RRC_CONNECTION_SETUP, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); SRB_configList = &ue_context_pP->ue_context.SRB_configList; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (is_mtc) { RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionSetup_BR(ctxt_pP, - ue_context_pP, - CC_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, - (const uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 - rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), - SRB_configList, - &ue_context_pP->ue_context.physicalConfigDedicated); - } else + ue_context_pP, + CC_id, + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, + (const uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), + SRB_configList, + &ue_context_pP->ue_context.physicalConfigDedicated); + } else #endif { RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionSetup(ctxt_pP, - ue_context_pP, - CC_id, - (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, - (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 - rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), - SRB_configList, - &ue_context_pP->ue_context.physicalConfigDedicated); + ue_context_pP, + CC_id, + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, + (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), + SRB_configList, + &ue_context_pP->ue_context.physicalConfigDedicated); LOG_DUMPMSG(RRC,DEBUG_RRC, - (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, - "[MSG] RRC Connection Setup\n"); - + (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, + "[MSG] RRC Connection Setup\n"); + // configure SRB1/SRB2, PhysicalConfigDedicated, LTE_MAC_MainConfig for UE - + if (*SRB_configList != NULL) { for (cnt = 0; cnt < (*SRB_configList)->list.count; cnt++) { - if ((*SRB_configList)->list.array[cnt]->srb_Identity == 1) { - SRB1_config = (*SRB_configList)->list.array[cnt]; - - if (SRB1_config->logicalChannelConfig) { - if (SRB1_config->logicalChannelConfig->present == - LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { - SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue; - } else { - SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; - } - } else { - SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; - } - - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - rrc_mac_config_req_eNB( - ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + if ((*SRB_configList)->list.array[cnt]->srb_Identity == 1) { + SRB1_config = (*SRB_configList)->list.array[cnt]; + + if (SRB1_config->logicalChannelConfig) { + if (SRB1_config->logicalChannelConfig->present == + LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { + SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue; + } else { + SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; + } + } else { + SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; + } + + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_mac_config_req_eNB( + ctxt_pP->module_id, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - ue_context_pP->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + ue_context_pP->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - ue_context_pP->ue_context.physicalConfigDedicated, + ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - 1, - SRB1_logicalChannelConfig, - ue_context_pP->ue_context.measGapConfig, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); - break; - } + ); + break; + } } } - + MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, // LG WARNING - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, - MSC_AS_TIME_FMT" LTE_RRCConnectionSetup UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_pP->ue_context.rnti, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); + MSC_RRC_ENB, + MSC_RRC_UE, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, // LG WARNING + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, + MSC_AS_TIME_FMT" LTE_RRCConnectionSetup UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionSetup (bytes %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); + PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionSetup (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); //ue_context_pP->ue_context.ue_release_timer_thres=100; // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE ue_context_pP->ue_context.ue_release_timer=1; @@ -6705,18 +6554,13 @@ void rrc_eNB_generate_RRCConnectionSetup(const protocol_ctxt_t *const ctxt_pP, ue_context_pP->ue_context.ue_release_timer_thres=1000; } } - -#if defined(ENABLE_ITTI) + + //----------------------------------------------------------------------------- char openair_rrc_eNB_configuration( - const module_id_t enb_mod_idP, - RrcConfigurationReq *configuration - ) -#else -char openair_rrc_eNB_init( - const module_id_t enb_mod_idP - ) -#endif + const module_id_t enb_mod_idP, + RrcConfigurationReq *configuration +) //----------------------------------------------------------------------------- { protocol_ctxt_t ctxt; @@ -6735,24 +6579,7 @@ char openair_rrc_eNB_init( #endif AssertFatal(RC.rrc[enb_mod_idP] != NULL, "RC.rrc not initialized!"); AssertFatal(MAX_MOBILES_PER_ENB < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); -#ifdef ENABLE_ITTI AssertFatal(configuration!=NULL,"configuration input is null\n"); -#endif - // for (j = 0; j < MAX_MOBILES_PER_ENB; j++) - // RC.rrc[ctxt.module_id].Info.UE[j].Status = RRC_IDLE; //CH_READY; - // - //#if defined(ENABLE_USE_MME) - // // Connect eNB to MME - // if (EPC_MODE_ENABLED <= 0) - //#endif - // { - // /* Init security parameters */ - // for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { - // RC.rrc[ctxt.module_id].ciphering_algorithm[j] = SecurityAlgorithmConfig__cipheringAlgorithm_eea0; - // RC.rrc[ctxt.module_id].integrity_algorithm[j] = SecurityAlgorithmConfig__integrityProtAlgorithm_eia2; - // rrc_eNB_init_security(enb_mod_idP, j); - // } - // } RC.rrc[ctxt.module_id]->Nb_ue = 0; for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { @@ -6810,9 +6637,7 @@ char openair_rrc_eNB_init( for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { init_SI(&ctxt, CC_id -#if defined(ENABLE_ITTI) , configuration -#endif ); for (int ue_id = 0; ue_id < MAX_MOBILES_PER_ENB; ue_id++) { @@ -6932,25 +6757,6 @@ rrc_eNB_decode_ccch( ((rrcConnectionReestablishmentRequest->reestablishmentCause == LTE_ReestablishmentCause_otherFailure) ? "Other Failure" : (rrcConnectionReestablishmentRequest->reestablishmentCause == LTE_ReestablishmentCause_handoverFailure) ? "Handover Failure" : "reconfigurationFailure")); - /*{ - uint64_t c_rnti = 0; - - memcpy(((uint8_t *) & c_rnti) + 3, rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.buf, - rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.size); - ue_mod_id = rrc_eNB_get_UE_index(enb_mod_idP, c_rnti); - } - - if ((RC.rrc[enb_mod_idP]->phyCellId == rrcConnectionReestablishmentRequest.UE_identity.physCellId) && - (ue_mod_id != UE_INDEX_INVALID)){ - rrc_eNB_generate_RRCConnectionReestablishment(enb_mod_idP, frameP, ue_mod_id); - }else { - rrc_eNB_generate_RRCConnectionReestablishmentReject(enb_mod_idP, frameP, ue_mod_id); - } - */ - /* reject all reestablishment attempts for the moment */ - // rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, - // rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti), - // CC_id); { uint16_t c_rnti = 0; @@ -7059,16 +6865,11 @@ rrc_eNB_decode_ccch( LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n", i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]); -#if defined(ENABLE_ITTI) ue_context_p->ue_context.reestablishment_cause = rrcConnectionReestablishmentRequest->reestablishmentCause; LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection reestablishment request from UE physCellId %ld cause %ld\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), rrcConnectionReestablishmentRequest->ue_Identity.physCellId, ue_context_p->ue_context.reestablishment_cause); -#else - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection restablishment request for UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); -#endif #ifndef NO_RRM send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id)); #else @@ -7112,18 +6913,14 @@ rrc_eNB_decode_ccch( NULL, NULL, NULL -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (LTE_PMCH_InfoList_r9_t *) NULL -#endif ,NULL); rrc_rlc_config_asn1_req(ctxt_pP, ue_context_p->ue_context.SRB_configList, (LTE_DRB_ToAddModList_t *) NULL, (LTE_DRB_ToReleaseList_t *) NULL -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (LTE_PMCH_InfoList_r9_t *) NULL, 0,0 -# endif ); #endif //NO_RRM } @@ -7249,7 +7046,6 @@ rrc_eNB_decode_ccch( ue_context_p); if (ue_context_p != NULL) { -#if defined(ENABLE_ITTI) ue_context_p->ue_context.establishment_cause = rrcConnectionRequest->establishmentCause; ue_context_p->ue_context.reestablishment_cause = LTE_ReestablishmentCause_spare1; @@ -7267,12 +7063,6 @@ rrc_eNB_decode_ccch( ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, ue_context_p->ue_context.establishment_cause); -#else - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection for UE random UE identity (0x%" PRIx64 ")\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p->ue_context.random_ue_identity); -#endif - if (stmsi_received == 0) RC.rrc[ctxt_pP->module_id]->Nb_ue++; } else { @@ -7558,58 +7348,65 @@ rrc_eNB_decode_dcch( } } -#if defined(ENABLE_ITTI) -#if defined(ENABLE_USE_MME) - - if (dedicated_DRB == 1) { - // rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, - // ue_context_p, - // ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { - rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(ctxt_pP, - ue_context_p, - ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - ue_context_p->ue_context.nb_of_modify_e_rabs = 0; - ue_context_p->ue_context.nb_of_failed_e_rabs = 0; - memset(ue_context_p->ue_context.modify_e_rab, 0, sizeof(ue_context_p->ue_context.modify_e_rab)); - - for(int i = 0; i < NB_RB_MAX; i++) { - ue_context_p->ue_context.modify_e_rab[i].xid = -1; - } - } else if(ue_context_p->ue_context.e_rab_release_command_flag == 1) { - xid = ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier; - ue_context_p->ue_context.e_rab_release_command_flag = 0; - //gtp tunnel delete - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; + if (EPC_MODE_ENABLED) { + if (dedicated_DRB == 1) { + // rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, + // ue_context_p, + // ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { + rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(ctxt_pP, + ue_context_p, + ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + ue_context_p->ue_context.nb_of_modify_e_rabs = 0; + ue_context_p->ue_context.nb_of_failed_e_rabs = 0; + memset(ue_context_p->ue_context.modify_e_rab, 0, sizeof(ue_context_p->ue_context.modify_e_rab)); - for(i = 0; i < NB_RB_MAX; i++) { - if(xid == ue_context_p->ue_context.e_rab[i].xid) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; - ue_context_p->ue_context.enb_gtp_teid[i] = 0; - memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); - ue_context_p->ue_context.enb_gtp_ebi[i] = 0; + for(int i = 0; i < NB_RB_MAX; i++) { + ue_context_p->ue_context.modify_e_rab[i].xid = -1; + } + } else if(ue_context_p->ue_context.e_rab_release_command_flag == 1) { + xid = ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier; + ue_context_p->ue_context.e_rab_release_command_flag = 0; + //gtp tunnel delete + msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); + memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; + + for(i = 0; i < NB_RB_MAX; i++) { + if(xid == ue_context_p->ue_context.e_rab[i].xid) { + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; + ue_context_p->ue_context.enb_gtp_teid[i] = 0; + memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); + ue_context_p->ue_context.enb_gtp_ebi[i] = 0; + } } - } - itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p); - //S1AP_E_RAB_RELEASE_RESPONSE - rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(ctxt_pP, - ue_context_p, - xid); - } else { - rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, - ue_context_p, - ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - } - } else if(dedicated_DRB == 0) { - if(ue_context_p->ue_context.reestablishment_cause == LTE_ReestablishmentCause_spare1) { - rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, - ue_context_p); - } else { - ue_context_p->ue_context.reestablishment_cause = LTE_ReestablishmentCause_spare1; + itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p); + //S1AP_E_RAB_RELEASE_RESPONSE + rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(ctxt_pP, + ue_context_p, + xid); + } else { + rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, + ue_context_p, + ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + } + } else if(dedicated_DRB == 0) { + if(ue_context_p->ue_context.reestablishment_cause == LTE_ReestablishmentCause_spare1) { + rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, + ue_context_p); + } else { + ue_context_p->ue_context.reestablishment_cause = LTE_ReestablishmentCause_spare1; + for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + } else { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + } + } + } + } else if(dedicated_DRB == 2) { for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; @@ -7617,37 +7414,20 @@ rrc_eNB_decode_dcch( ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; } } - } - } else if(dedicated_DRB == 2) { - for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; - } else { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; - } - } - } else if(dedicated_DRB == 3) { //x2 path switch - for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; - } else { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + } else if(dedicated_DRB == 3) { //x2 path switch + for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + } else { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + } } - } - LOG_I(RRC,"issue rrc_eNB_send_PATH_SWITCH_REQ \n"); - rrc_eNB_send_PATH_SWITCH_REQ(ctxt_pP,ue_context_p); - } - -#endif -#else // establish a dedicated bearer - - if (dedicated_DRB == 0 ) { - // ue_context_p->ue_context.e_rab[0].status = E_RAB_STATUS_ESTABLISHED; - rrc_eNB_reconfigure_DRBs(ctxt_pP,ue_context_p); - } + LOG_I(RRC,"issue rrc_eNB_send_PATH_SWITCH_REQ \n"); + rrc_eNB_send_PATH_SWITCH_REQ(ctxt_pP,ue_context_p); + } + } /* EPC_MODE_ENABLED */ -#endif break; case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete: @@ -8079,7 +7859,6 @@ rrc_eNB_decode_dcch( return 0; } -#if defined(ENABLE_ITTI) void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *ue_context_pP) { int i; @@ -8196,7 +7975,6 @@ void *rrc_enb_process_itti_msg(void *notUsed) { } break; -# if defined(ENABLE_USE_MME) /* Messages from S1AP */ case S1AP_DOWNLINK_NAS: @@ -8254,7 +8032,6 @@ void *rrc_enb_process_itti_msg(void *notUsed) { LOG_I(RRC, "[eNB %d] received path switch ack %s\n", instance, msg_name_p); rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK(msg_p, msg_name_p, instance); break; -# endif case X2AP_HANDOVER_REQ: LOG_I(RRC, "[eNB %d] target eNB Receives X2 HO Req %s at frame %d subframe %d\n", instance, msg_name_p, @@ -8312,7 +8089,6 @@ rrc_enb_task( (void) rrc_enb_process_itti_msg(NULL); } } -#endif /*------------------------------------------------------------------------------*/ void @@ -8705,13 +8481,12 @@ rrc_rx_tx( LOG_I(RRC, "Removing UE %x instance, because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n", ue_context_p->ue_context.rnti, ue_context_p->ue_context.ue_release_timer_thres_s1); -#if defined(ENABLE_USE_MME) -#if defined(ENABLE_ITTI) - rrc_eNB_generate_RRCConnectionRelease(ctxt_pP, ue_context_p); -#endif -#else - ue_to_be_removed = ue_context_p; -#endif + + if (EPC_MODE_ENABLED) + rrc_eNB_generate_RRCConnectionRelease(ctxt_pP, ue_context_p); + else + ue_to_be_removed = ue_context_p; + ue_context_p->ue_context.ue_release_timer_s1 = 0; break; // break RB_FOREACH } // end if timer_s1 timeout @@ -8743,47 +8518,46 @@ rrc_rx_tx( (rrc_release_info.RRC_release_ctrl[release_num].rnti == ue_context_p->ue_context.rnti)) { ue_context_p->ue_context.ue_release_timer_rrc = 1; ue_context_p->ue_context.ue_release_timer_thres_rrc = 100; -#if defined(ENABLE_USE_MME) -#if defined(ENABLE_ITTI) - int e_rab = 0; - MessageDef *msg_complete_p = NULL; - MessageDef *msg_delete_tunnels_p = NULL; - uint32_t eNB_ue_s1ap_id = ue_context_p->ue_context.eNB_ue_s1ap_id; - - if (rrc_release_info.RRC_release_ctrl[release_num].flag == 4) { // if timer_s1 == 0 - MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_S1AP_ENB, NULL, 0, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", - eNB_ue_s1ap_id); - msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); - S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - itti_send_msg_to_task(TASK_S1AP, ctxt_pP->module_id, msg_complete_p); - } - MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_GTPU_ENB, NULL,0, "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ", eNB_ue_s1ap_id); - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - // do not wait response - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - - for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = - ue_context_p->ue_context.enb_gtp_ebi[e_rab]; - // erase data - ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; - memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); - ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; - } + if (EPC_MODE_ENABLED) { + int e_rab = 0; + MessageDef *msg_complete_p = NULL; + MessageDef *msg_delete_tunnels_p = NULL; + uint32_t eNB_ue_s1ap_id = ue_context_p->ue_context.eNB_ue_s1ap_id; + + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 4) { // if timer_s1 == 0 + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_S1AP_ENB, NULL, 0, + "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", + eNB_ue_s1ap_id); + msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); + S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; + itti_send_msg_to_task(TASK_S1AP, ctxt_pP->module_id, msg_complete_p); + } + + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_GTPU_ENB, NULL,0, "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ", eNB_ue_s1ap_id); + msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); + memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); + // do not wait response + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->module_id, msg_delete_tunnels_p); - struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; - rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[ctxt_pP->module_id], 0, eNB_ue_s1ap_id); + for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = + ue_context_p->ue_context.enb_gtp_ebi[e_rab]; + // erase data + ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; + memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); + ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; + } - if (rrc_ue_s1ap_ids != NULL) { - rrc_eNB_S1AP_remove_ue_ids(RC.rrc[ctxt_pP->module_id], rrc_ue_s1ap_ids); - } + itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->module_id, msg_delete_tunnels_p); + struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; + rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[ctxt_pP->module_id], 0, eNB_ue_s1ap_id); + + if (rrc_ue_s1ap_ids != NULL) { + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[ctxt_pP->module_id], rrc_ue_s1ap_ids); + } + } /* EPC_MODE_ENABLED */ -#endif -#endif rrc_release_info.RRC_release_ctrl[release_num].flag = 0; rrc_release_info.num_UEs--; break; // break for (release_num) diff --git a/openair2/RRC/LTE/rrc_eNB_GTPV1U.c b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c index 135c6fea8d82e5279036ad7c11ae08df8d3d8683..c8b18bb7d1848a2d96fd175f86e9a8f26238c8b6 100644 --- a/openair2/RRC/LTE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c @@ -27,75 +27,64 @@ * \email: lionel.gauthier@eurecom.fr */ -#if defined(ENABLE_USE_MME) # include "rrc_defs.h" # include "rrc_extern.h" # include "RRC/LTE/MESSAGES/asn1_msg.h" # include "rrc_eNB_GTPV1U.h" # include "rrc_eNB_UE_context.h" # include "msc.h" - -# if defined(ENABLE_ITTI) -# include "asn1_conversions.h" -# include "intertask_interface.h" -# endif - +# include "asn1_conversions.h" +# include "intertask_interface.h" # include "common/ran_context.h" extern RAN_CONTEXT_t RC; int rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( - const protocol_ctxt_t* const ctxt_pP, - const gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP, + const protocol_ctxt_t *const ctxt_pP, + const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, uint8_t *inde_list -) -{ +) { rnti_t rnti; int i; - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; if (create_tunnel_resp_pP) { LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RX CREATE_TUNNEL_RESP num tunnels %u \n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), create_tunnel_resp_pP->num_tunnels); - rnti = create_tunnel_resp_pP->rnti; ue_context_p = rrc_eNB_get_ue_context( RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti); for (i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) { - -// ue_context_p->ue_context.enb_gtp_teid[i+ue_context_p->ue_context.setup_e_rabs] = create_tunnel_resp_pP->enb_S1u_teid[i]; -// ue_context_p->ue_context.enb_gtp_addrs[i+ue_context_p->ue_context.setup_e_rabs] = create_tunnel_resp_pP->enb_addr; -// ue_context_p->ue_context.enb_gtp_ebi[i+ue_context_p->ue_context.setup_e_rabs] = create_tunnel_resp_pP->eps_bearer_id[i]; ue_context_p->ue_context.enb_gtp_teid[inde_list[i]] = create_tunnel_resp_pP->enb_S1u_teid[i]; ue_context_p->ue_context.enb_gtp_addrs[inde_list[i]] = create_tunnel_resp_pP->enb_addr; ue_context_p->ue_context.enb_gtp_ebi[inde_list[i]] = create_tunnel_resp_pP->eps_bearer_id[i]; - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, msg index %u, id %u, gtp addr len %d \n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), create_tunnel_resp_pP->enb_S1u_teid[i], - ue_context_p->ue_context.enb_gtp_teid[inde_list[i]], + ue_context_p->ue_context.enb_gtp_teid[inde_list[i]], inde_list[i], - i, + i, create_tunnel_resp_pP->eps_bearer_id[i], - create_tunnel_resp_pP->enb_addr.length); + create_tunnel_resp_pP->enb_addr.length); } - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_GTPU_ENB, - NULL,0, - MSC_AS_TIME_FMT" CREATE_TUNNEL_RESP RNTI %"PRIx16" ntuns %u ebid %u enb-s1u teid %u", - 0,0,rnti, - create_tunnel_resp_pP->num_tunnels, - ue_context_p->ue_context.enb_gtp_ebi[0], - ue_context_p->ue_context.enb_gtp_teid[0]); - (void)rnti; /* avoid gcc warning "set but not used" */ + + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_GTPU_ENB, + NULL,0, + MSC_AS_TIME_FMT" CREATE_TUNNEL_RESP RNTI %"PRIx16" ntuns %u ebid %u enb-s1u teid %u", + 0,0,rnti, + create_tunnel_resp_pP->num_tunnels, + ue_context_p->ue_context.enb_gtp_ebi[0], + ue_context_p->ue_context.enb_gtp_teid[0]); + (void)rnti; /* avoid gcc warning "set but not used" */ return 0; } else { return -1; } } -#endif + diff --git a/openair2/RRC/LTE/rrc_eNB_GTPV1U.h b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h index aedbdeac5e12bdd510ad5d286f3d82bf4cab83f2..0cd3f3c51264e428e4f128ef847015eeacc1195e 100644 --- a/openair2/RRC/LTE/rrc_eNB_GTPV1U.h +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h @@ -30,10 +30,6 @@ #ifndef RRC_ENB_GTPV1U_H_ #define RRC_ENB_GTPV1U_H_ -# if defined(ENABLE_USE_MME) - - -# if defined(ENABLE_ITTI) /*! \fn rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t* const ctxt_pP, const gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP) *\brief Process GTPV1U_ENB_CREATE_TUNNEL_RESP message received from GTPV1U, retrieve the enb teid created. @@ -42,11 +38,10 @@ *\return 0 when successful, -1 if the UE index can not be retrieved. */ int rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( - const protocol_ctxt_t* const ctxt_pP, - const gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP, + const protocol_ctxt_t *const ctxt_pP, + const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, uint8_t *inde_list ); -# endif -# endif /* defined(ENABLE_USE_MME) */ + #endif /* RRC_ENB_GTPV1U_H_ */ diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 5bfa8c443b7e4a47bdb834d4e734bc81cbbdf813..e07a4bd5d2c43cb85427975113ffad0e1659ff41 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -27,7 +27,7 @@ * \company Eurecom * \email: navid.nikaein@eurecom.fr */ -#if defined(ENABLE_USE_MME) + # include "rrc_defs.h" # include "rrc_extern.h" # include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" @@ -41,20 +41,14 @@ # include "s1ap_eNB_defs.h" # include "s1ap_eNB_management_procedures.h" # include "s1ap_eNB_ue_context.h" +#include "asn1_conversions.h" +#include "intertask_interface.h" +#include "pdcp.h" +#include "pdcp_primitives.h" +#include "s1ap_eNB.h" -#if defined(ENABLE_ITTI) - #include "asn1_conversions.h" - #include "intertask_interface.h" - #include "pdcp.h" - #include "pdcp_primitives.h" - #include "s1ap_eNB.h" -#else - #include "../../S1AP/s1ap_eNB.h" -#endif -#if defined(ENABLE_SECURITY) - #include "UTIL/OSA/osa_defs.h" -#endif +#include "UTIL/OSA/osa_defs.h" #include "msc.h" #include "LTE_UERadioAccessCapabilityInformation.h" @@ -71,7 +65,7 @@ extern RAN_CONTEXT_t RC; extern int gtpv1u_delete_s1u_tunnel( const instance_t instanceP, - const gtpv1u_enb_delete_tunnel_req_t * const req_pP); + const gtpv1u_enb_delete_tunnel_req_t *const req_pP); /* Value to indicate an invalid UE initial id */ static const uint16_t UE_INITIAL_ID_INVALID = 0; @@ -164,7 +158,7 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c } } -# if defined(ENABLE_ITTI) + //------------------------------------------------------------------------------ /* * Get the UE S1 struct containing hashtables S1_id/UE_id. @@ -222,8 +216,7 @@ rrc_eNB_S1AP_get_ue_ids( result2->ue_initial_id, result->eNB_ue_s1ap_id, result2->eNB_ue_s1ap_id); - - // Still return *result + // Still return *result } } } // end if if (eNB_ue_s1ap_id > 0) @@ -231,7 +224,6 @@ rrc_eNB_S1AP_get_ue_ids( LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in initial_id2_s1ap_ids ue_initial_id %"PRIu16"\n", rrc_instance_pP - RC.rrc[0], ue_initial_id); - return NULL; /* * At the moment this is written, this case shouldn't (cannot) happen and is equivalent to an error. @@ -260,8 +252,7 @@ rrc_eNB_S1AP_get_ue_ids( ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, eNB_ue_s1ap_id); // get s1ap_eNB_ue_context } else { LOG_E(S1AP, "[eNB instance %d] Couldn't find the eNB S1AP context\n", - instance); - + instance); return NULL; } @@ -285,7 +276,6 @@ rrc_eNB_S1AP_get_ue_ids( LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", even when looking at S1AP context\n", rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id); - return NULL; } } // end if (h_rc != HASH_TABLE_OK) @@ -306,7 +296,6 @@ rrc_eNB_S1AP_remove_ue_ids( ) //------------------------------------------------------------------------------ { - hashtable_rc_t h_rc; if (rrc_instance_pP == NULL) { @@ -318,8 +307,10 @@ rrc_eNB_S1AP_remove_ue_ids( LOG_E(RRC, "Trying to free a NULL S1AP UE IDs\n"); return; } + const uint16_t ue_initial_id = ue_ids_pP->ue_initial_id; const uint32_t eNB_ue_s1ap_id = ue_ids_pP->eNB_ue_s1ap_id; + if (eNB_ue_s1ap_id > 0) { h_rc = hashtable_remove(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id); @@ -493,7 +484,6 @@ static void process_eNB_security_key ( ) //------------------------------------------------------------------------------ { -#if defined(ENABLE_SECURITY) char ascii_buffer[65]; uint8_t i; /* Saves the security key */ @@ -507,7 +497,6 @@ static void process_eNB_security_key ( ascii_buffer[2 * i] = '\0'; LOG_I (RRC, "[eNB %d][UE %x] Saved security key %s\n", ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ascii_buffer); -#endif } @@ -520,7 +509,6 @@ rrc_pdcp_config_security( ) //------------------------------------------------------------------------------ { -#if defined(ENABLE_SECURITY) LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; @@ -578,8 +566,6 @@ rrc_pdcp_config_security( PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), DCCH); } - -#endif } //------------------------------------------------------------------------------ @@ -628,7 +614,6 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } -# endif //------------------------------------------------------------------------------ void @@ -639,7 +624,6 @@ rrc_eNB_send_S1AP_UPLINK_NAS( ) //------------------------------------------------------------------------------ { -#if defined(ENABLE_ITTI) { LTE_ULInformationTransfer_t *ulInformationTransfer = &ul_dcch_msg->message.choice.c1.choice.ulInformationTransfer; @@ -650,7 +634,7 @@ rrc_eNB_send_S1AP_UPLINK_NAS( == LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) { /* This message hold a dedicated info NAS payload, forward it to NAS */ struct LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType = - &ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType; + &ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType; uint32_t pdu_length; uint8_t *pdu_buffer; MessageDef *msg_p; @@ -666,36 +650,6 @@ rrc_eNB_send_S1AP_UPLINK_NAS( itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } } -#else - { - LTE_ULInformationTransfer_t *ulInformationTransfer; - ulInformationTransfer = - &ul_dcch_msg->message.choice.c1.choice. - ulInformationTransfer; - - if (ulInformationTransfer->criticalExtensions.present == - LTE_ULInformationTransfer__criticalExtensions_PR_c1) { - if (ulInformationTransfer->criticalExtensions.choice.c1.present == - LTE_ULInformationTransfer__criticalExtensions__c1_PR_ulInformationTransfer_r8) { - ULInformationTransfer_r8_IEs_t - *ulInformationTransferR8; - ulInformationTransferR8 = - &ulInformationTransfer->criticalExtensions.choice. - c1.choice.ulInformationTransfer_r8; - - if (ulInformationTransferR8->dedicatedInfoType.present == - LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS) { - extract_imsi(ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, - ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size, - ue_context_pP); - s1ap_eNB_new_data_request (mod_id, ue_index, - ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, - ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size); - } - } - } - } -#endif } //------------------------------------------------------------------------------ @@ -758,7 +712,6 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( //------------------------------------------------------------------------------ { eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; -#if defined(ENABLE_ITTI) { MessageDef *message_p = NULL; rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL; @@ -846,13 +799,11 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code = BIT_STRING_to_uint8 (&r_mme->mmec); S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id = BIT_STRING_to_uint16 (&r_mme->mmegi); - ue_context_pP->ue_context.ue_gummei.mcc = S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc; ue_context_pP->ue_context.ue_gummei.mnc = S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc; ue_context_pP->ue_context.ue_gummei.mnc_len = S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc_len; ue_context_pP->ue_context.ue_gummei.mme_code = S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code; ue_context_pP->ue_context.ue_gummei.mme_group_id = S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id; - MSC_LOG_TX_MESSAGE(MSC_S1AP_ENB, MSC_S1AP_MME, (const char *)&message_p->ittiMsg.s1ap_nas_first_req, @@ -870,20 +821,9 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( } // end "Fill UE identities with available information" sub-part itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, message_p); } -#else - { - s1ap_eNB_new_data_request ( - ctxt_pP->module_id, - ue_context_pP, - rrcConnectionSetupComplete->dedicatedInfoNAS. - buf, - rrcConnectionSetupComplete->dedicatedInfoNAS. - size); - } -#endif } -# if defined(ENABLE_ITTI) + //------------------------------------------------------------------------------ int rrc_eNB_process_S1AP_DOWNLINK_NAS( @@ -1010,7 +950,6 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; ue_context_p->ue_context.mme_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).mme_ue_s1ap_id; - /* Save e RAB information for later */ { int i; @@ -1799,7 +1738,6 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance uint32_t T; /* DRX cycle */ for (uint16_t tai_size = 0; tai_size < S1AP_PAGING_IND(msg_p).tai_size; tai_size++) { - LOG_D(RRC,"[eNB %d] In S1AP_PAGING_IND: MCC %d, MNC %d, TAC %d\n", instance, S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc, S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc, S1AP_PAGING_IND(msg_p).tac[tai_size]); @@ -1821,7 +1759,8 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance /* set T = min(Tc,Tue) */ T = Tc < Tue ? Ttab[Tc] : Ttab[Tue]; /* set pcch_nB = PCCH-Config->nB */ - pcch_nB = (uint32_t)RC.rrc[instance]->configuration.radioresourceconfig[CC_id].pcch_nB; + pcch_nB = (uint32_t)RC.rrc[instance]->configuration.radioresourceconfig[CC_id].pcch_nB; + switch (pcch_nB) { case LTE_PCCH_Config__nB_fourT: Ns = 4; @@ -1947,143 +1886,116 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance } /*NN: careful about the typcast of xid (long -> uint8_t*/ -int rrc_eNB_send_PATH_SWITCH_REQ(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP){ - +int rrc_eNB_send_PATH_SWITCH_REQ(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP) { MessageDef *msg_p = NULL; int e_rab = 0; int e_rabs_done = 0; - - rrc_ue_s1ap_ids_t* rrc_ue_s1ap_ids_p = NULL; + rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL; hashtable_rc_t h_rc; - gtpv1u_enb_create_tunnel_req_t create_tunnel_req; gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; - uint8_t inde_list[ue_context_pP->ue_context.nb_of_e_rabs]; memset(inde_list, 0, ue_context_pP->ue_context.nb_of_e_rabs*sizeof(uint8_t)); - msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_PATH_SWITCH_REQ); - ue_context_pP->ue_context.ue_initial_id = get_next_ue_initial_id (ctxt_pP->module_id); S1AP_PATH_SWITCH_REQ (msg_p).ue_initial_id = ue_context_pP->ue_context.ue_initial_id; - rrc_ue_s1ap_ids_p = malloc(sizeof(*rrc_ue_s1ap_ids_p)); rrc_ue_s1ap_ids_p->ue_initial_id = ue_context_pP->ue_context.ue_initial_id; rrc_ue_s1ap_ids_p->eNB_ue_s1ap_id = UE_INITIAL_ID_INVALID; rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; - h_rc = hashtable_insert(RC.rrc[ctxt_pP->module_id]->initial_id2_s1ap_ids, - (hash_key_t)ue_context_pP->ue_context.ue_initial_id, - rrc_ue_s1ap_ids_p); + (hash_key_t)ue_context_pP->ue_context.ue_initial_id, + rrc_ue_s1ap_ids_p); + if (h_rc != HASH_TABLE_OK) { LOG_E(S1AP, "[eNB %d] Error while hashtable_insert in initial_id2_s1ap_ids ue_initial_id %u\n", - ctxt_pP->module_id, ue_context_pP->ue_context.ue_initial_id); + ctxt_pP->module_id, ue_context_pP->ue_context.ue_initial_id); } S1AP_PATH_SWITCH_REQ (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - S1AP_PATH_SWITCH_REQ (msg_p).mme_ue_s1ap_id = ue_context_pP->ue_context.mme_ue_s1ap_id; - S1AP_PATH_SWITCH_REQ (msg_p).ue_gummei.mcc = ue_context_pP->ue_context.ue_gummei.mcc; S1AP_PATH_SWITCH_REQ (msg_p).ue_gummei.mnc = ue_context_pP->ue_context.ue_gummei.mnc; S1AP_PATH_SWITCH_REQ (msg_p).ue_gummei.mnc_len = ue_context_pP->ue_context.ue_gummei.mnc_len; S1AP_PATH_SWITCH_REQ (msg_p).ue_gummei.mme_code = ue_context_pP->ue_context.ue_gummei.mme_code; S1AP_PATH_SWITCH_REQ (msg_p).ue_gummei.mme_group_id = ue_context_pP->ue_context.ue_gummei.mme_group_id; - S1AP_PATH_SWITCH_REQ (msg_p).security_capabilities.encryption_algorithms=ue_context_pP->ue_context.security_capabilities.encryption_algorithms; S1AP_PATH_SWITCH_REQ (msg_p).security_capabilities.integrity_algorithms=ue_context_pP->ue_context.security_capabilities.integrity_algorithms; - LOG_I (RRC,"Path switch request: nb nb_of_e_rabs %u status %u\n", - ue_context_pP->ue_context.nb_of_e_rabs, - ue_context_pP->ue_context.e_rab[e_rab].status); + ue_context_pP->ue_context.nb_of_e_rabs, + ue_context_pP->ue_context.e_rab[e_rab].status); + memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); - memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); // the context for UE to be handovered is obtained through ho_req message for (e_rab = 0; e_rab < ue_context_pP->ue_context.nb_of_e_rabs ; e_rab++) { - if (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED) { - create_tunnel_req.eps_bearer_id[e_rabs_done] = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; create_tunnel_req.sgw_S1u_teid[e_rabs_done] = ue_context_pP->ue_context.e_rab[e_rab].param.gtp_teid; memcpy(&create_tunnel_req.sgw_addr[e_rabs_done], &ue_context_pP->ue_context.e_rab[e_rab].param.sgw_addr, sizeof(transport_layer_addr_t)); - inde_list[e_rabs_done] = e_rab; e_rabs_done++; } } S1AP_PATH_SWITCH_REQ (msg_p).nb_of_e_rabs = e_rabs_done; - create_tunnel_req.rnti = ue_context_pP->ue_context.rnti; create_tunnel_req.num_tunnels = e_rabs_done; - gtpv1u_create_s1u_tunnel( - ctxt_pP->instance, - &create_tunnel_req, - &create_tunnel_resp); - + ctxt_pP->instance, + &create_tunnel_req, + &create_tunnel_resp); rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( - ctxt_pP, - &create_tunnel_resp, - &inde_list[0]); + ctxt_pP, + &create_tunnel_resp, + &inde_list[0]); for (e_rab = 0; e_rab < e_rabs_done; e_rab++) { - - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].e_rab_id = create_tunnel_resp.eps_bearer_id[e_rab]; - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].gtp_teid = create_tunnel_resp.enb_S1u_teid[e_rab]; - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr = create_tunnel_resp.enb_addr; - - LOG_I (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d): nb_of_e_rabs %d, e_rab_id %d, teid: %u, addr: %d.%d.%d.%d \n ", - e_rabs_done, e_rab, ue_context_pP->ue_context.e_rab[inde_list[e_rab]].status, - ue_context_pP->ue_context.nb_of_e_rabs, - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].e_rab_id, - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].gtp_teid, - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[0], - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[1], - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[2], - S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[3]); + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].e_rab_id = create_tunnel_resp.eps_bearer_id[e_rab]; + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].gtp_teid = create_tunnel_resp.enb_S1u_teid[e_rab]; + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr = create_tunnel_resp.enb_addr; + LOG_I (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d): nb_of_e_rabs %d, e_rab_id %d, teid: %u, addr: %d.%d.%d.%d \n ", + e_rabs_done, e_rab, ue_context_pP->ue_context.e_rab[inde_list[e_rab]].status, + ue_context_pP->ue_context.nb_of_e_rabs, + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].e_rab_id, + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].gtp_teid, + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[0], + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[1], + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[2], + S1AP_PATH_SWITCH_REQ (msg_p).e_rabs_tobeswitched[e_rab].eNB_addr.buffer[3]); } - // NN: add conditions for e_rabs_failed - if (e_rabs_done > 0) { - - LOG_I(RRC,"S1AP_PATH_SWITCH_REQ: sending the message: nb_of_erabstobeswitched %d, total e_rabs %d, index %d\n", - ue_context_pP->ue_context.nb_of_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab); - - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - (const char *)&S1AP_PATH_SWITCH_REQ (msg_p), - sizeof(s1ap_path_switch_req_t), - MSC_AS_TIME_FMT" PATH_SWITCH_REQ UE %X eNB_ue_s1ap_id %u e_rabs:%u succ", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_pP->ue_id_rnti, - S1AP_PATH_SWITCH_REQ (msg_p).eNB_ue_s1ap_id, - e_rabs_done); - - - itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); - } + // NN: add conditions for e_rabs_failed + if (e_rabs_done > 0) { + LOG_I(RRC,"S1AP_PATH_SWITCH_REQ: sending the message: nb_of_erabstobeswitched %d, total e_rabs %d, index %d\n", + ue_context_pP->ue_context.nb_of_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab); + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_S1AP_ENB, + (const char *)&S1AP_PATH_SWITCH_REQ (msg_p), + sizeof(s1ap_path_switch_req_t), + MSC_AS_TIME_FMT" PATH_SWITCH_REQ UE %X eNB_ue_s1ap_id %u e_rabs:%u succ", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_id_rnti, + S1AP_PATH_SWITCH_REQ (msg_p).eNB_ue_s1ap_id, + e_rabs_done); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); + } return 0; } -int rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK (MessageDef *msg_p, const char *msg_name, instance_t instance) -{ +int rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK (MessageDef *msg_p, const char *msg_name, instance_t instance) { uint16_t ue_initial_id; uint32_t eNB_ue_s1ap_id; //gtpv1u_enb_create_tunnel_req_t create_tunnel_req; //gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; - gtpv1u_enb_delete_tunnel_req_t delete_tunnel_req; - - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; int i; - ue_initial_id = S1AP_PATH_SWITCH_REQ_ACK (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_PATH_SWITCH_REQ_ACK (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); @@ -2093,29 +2005,23 @@ int rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK (MessageDef *msg_p, const char *msg if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ //MessageDef *msg_fail_p = NULL; - LOG_W(RRC, "[eNB %d] In S1AP_PATH_SWITCH_REQ_ACK: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id); - //msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_PATH_SWITCH_REQ_ACK_FAIL); //S1AP_PATH_SWITCH_REQ_ACK (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - // TODO add failure cause when defined! - //itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); return (-1); } else { - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_PATH_SWITCH_REQ_ACK (msg_p).eNB_ue_s1ap_id; ue_context_p->ue_context.mme_ue_s1ap_id = S1AP_PATH_SWITCH_REQ_ACK (msg_p).mme_ue_s1ap_id; - /* Save e RAB information for later */ { for (i = 0; - i < ue_context_p->ue_context.setup_e_rabs; // go over total number of e_rabs received through x2_ho_req msg - i++) { - // assume that we are releasing all the DRBs - ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_TORELEASE; + i < ue_context_p->ue_context.setup_e_rabs; // go over total number of e_rabs received through x2_ho_req msg + i++) { + // assume that we are releasing all the DRBs + ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_TORELEASE; } //memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); @@ -2124,40 +2030,38 @@ int rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK (MessageDef *msg_p, const char *msg // keep the previous bearer // the index for the rec for (i = 0; - i < 1;//nb_e_rabs_tobeswitched; // go over total number of e_rabs received through x2_ho_req msg - i++) { + i < 1;//nb_e_rabs_tobeswitched; // go over total number of e_rabs received through x2_ho_req msg + i++) { LOG_I(RRC,"Bearer re-established with ID: %d\n", ue_context_p->ue_context.e_rab[i].param.e_rab_id); - /* Harmonize with enb_gtp_teid, enb_gtp_addrs, and enb_gtp_rbi vars in the top level structure */ - ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_REESTABLISHED; - //ue_context_p->ue_context.e_rab[i].param.e_rab_id = S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobeswitched[i].e_rab_id; - //ue_context_p->ue_context.e_rab[i].param.sgw_addr= S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobeswitched[i].sgw_addr; - //ue_context_p->ue_context.e_rab[i].param.gtp_teid = S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobeswitched[i].gtp_teid; - /* Tunnel must have been already created in X2_HO_REQ procedure */ + /* Harmonize with enb_gtp_teid, enb_gtp_addrs, and enb_gtp_rbi vars in the top level structure */ + ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_REESTABLISHED; + //ue_context_p->ue_context.e_rab[i].param.e_rab_id = S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobeswitched[i].e_rab_id; + //ue_context_p->ue_context.e_rab[i].param.sgw_addr= S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobeswitched[i].sgw_addr; + //ue_context_p->ue_context.e_rab[i].param.gtp_teid = S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobeswitched[i].gtp_teid; + /* Tunnel must have been already created in X2_HO_REQ procedure */ } ue_context_p->ue_context.setup_e_rabs=i; ue_context_p->ue_context.nb_of_e_rabs=i; } - ue_context_p->ue_context.ue_ambr=S1AP_PATH_SWITCH_REQ_ACK (msg_p).ue_ambr; - - ue_context_p->ue_context.nb_release_of_e_rabs = S1AP_PATH_SWITCH_REQ_ACK (msg_p).nb_e_rabs_tobereleased; - memset(&delete_tunnel_req, 0 , sizeof(delete_tunnel_req)); + memset(&delete_tunnel_req, 0, sizeof(delete_tunnel_req)); + for (i = 0; - i < ue_context_p->ue_context.nb_release_of_e_rabs; - i++) { + i < ue_context_p->ue_context.nb_release_of_e_rabs; + i++) { LOG_I(RRC,"Bearer released with ID: %d\n", ue_context_p->ue_context.e_rab[i].param.e_rab_id); ue_context_p->ue_context.e_rabs_tobereleased[i]=S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobereleased[i].e_rab_id; delete_tunnel_req.eps_bearer_id[i] = S1AP_PATH_SWITCH_REQ_ACK (msg_p).e_rabs_tobereleased[i].e_rab_id; - } - if (ue_context_p->ue_context.nb_release_of_e_rabs>0){ + + if (ue_context_p->ue_context.nb_release_of_e_rabs>0) { delete_tunnel_req.rnti= ue_context_p->ue_context.rnti; delete_tunnel_req.num_erab= ue_context_p->ue_context.nb_release_of_e_rabs; /* this could also be done through ITTI message */ gtpv1u_delete_s1u_tunnel(instance, - &delete_tunnel_req); + &delete_tunnel_req); /* TBD: release the DRB not admitted */ //rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(&ctxt, ue_context_p, 0); } @@ -2165,12 +2069,9 @@ int rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK (MessageDef *msg_p, const char *msg /* Security key */ ue_context_p->ue_context.next_hop_chain_count=S1AP_PATH_SWITCH_REQ_ACK (msg_p).next_hop_chain_count; memcpy ( ue_context_p->ue_context.next_security_key, - S1AP_PATH_SWITCH_REQ_ACK (msg_p).next_security_key, - SECURITY_KEY_LENGTH); - + S1AP_PATH_SWITCH_REQ_ACK (msg_p).next_security_key, + SECURITY_KEY_LENGTH); return (0); } } -# endif /* defined(ENABLE_ITTI) */ -#endif /* defined(ENABLE_USE_MME) */ diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.h b/openair2/RRC/LTE/rrc_eNB_S1AP.h index dc6caf15263f8e61752ff8515998d71517d94e59..33a0caabc8923fd533d101e6f2645c815436abda 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.h +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.h @@ -31,13 +31,10 @@ #ifndef RRC_ENB_S1AP_H_ #define RRC_ENB_S1AP_H_ -# if defined(ENABLE_USE_MME) - #include "LTE_UL-DCCH-Message.h" /* Up link procedures */ -# if defined(ENABLE_ITTI) typedef struct rrc_ue_s1ap_ids_s { /* Tree related data */ RB_ENTRY(rrc_ue_s1ap_ids_s) entries; @@ -52,38 +49,38 @@ typedef struct rrc_ue_s1ap_ids_s { int rrc_eNB_S1AP_compare_ue_ids( - struct rrc_ue_s1ap_ids_s* c1_pP, - struct rrc_ue_s1ap_ids_s* c2_pP + struct rrc_ue_s1ap_ids_s *c1_pP, + struct rrc_ue_s1ap_ids_s *c2_pP ); struct rrc_rnti_tree_s; RB_PROTOTYPE(rrc_rnti_tree_s, rrc_ue_s1ap_ids_s, entries, rrc_eNB_S1AP_compare_ue_ids); -struct rrc_ue_s1ap_ids_s* +struct rrc_ue_s1ap_ids_s * rrc_eNB_S1AP_get_ue_ids( - eNB_RRC_INST* const rrc_instance_pP, + eNB_RRC_INST *const rrc_instance_pP, const uint16_t ue_initial_id, const uint32_t eNB_ue_s1ap_id ); void rrc_eNB_S1AP_remove_ue_ids( - eNB_RRC_INST* const rrc_instance_pP, - struct rrc_ue_s1ap_ids_s* const ue_ids_pP + eNB_RRC_INST *const rrc_instance_pP, + struct rrc_ue_s1ap_ids_s *const ue_ids_pP ); void -rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state - ); +rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + const uint8_t ho_state + ); int -rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state - ); +rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + const uint8_t ho_state + ); /*! \fn void rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(uint8_t mod_id, uint8_t ue_index) *\brief create a S1AP_INITIAL_CONTEXT_SETUP_RESP for S1AP. @@ -92,8 +89,8 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons */ void rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ); /*! \fn void rrc_eNB_send_S1AP_UPLINK_NAS(const protocol_ctxt_t * const ctxt_pP, eNB_RRC_UE_t * const ue_context_pP, UL_DCCH_Message_t * const ul_dcch_msg) @@ -104,9 +101,9 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( */ void rrc_eNB_send_S1AP_UPLINK_NAS( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_UL_DCCH_Message_t* const ul_dcch_msg + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_UL_DCCH_Message_t *const ul_dcch_msg ); /*! \fn void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(const protocol_ctxt_t * const ctxt_pP, eNB_RRC_UE_t * const ue_context_pP, UL_DCCH_Message_t *ul_dcch_msg) @@ -116,9 +113,9 @@ rrc_eNB_send_S1AP_UPLINK_NAS( *\param ul_dcch_msg The message receive by RRC holding the NAS message. */ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_UL_DCCH_Message_t* ul_dcch_msg + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_UL_DCCH_Message_t *ul_dcch_msg ); /*! \fn rrc_eNB_send_S1AP_NAS_FIRST_REQ(const protocol_ctxt_t* const ctxt_pP,eNB_RRC_UE_t *const ue_context_pP, RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete) @@ -130,9 +127,9 @@ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( */ void rrc_eNB_send_S1AP_NAS_FIRST_REQ( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete ); @@ -146,7 +143,7 @@ the UE-associated S1-logical connection over the S1 interface. . */ void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( const module_id_t enb_mod_idP, - const rrc_eNB_ue_context_t* const ue_context_pP, + const rrc_eNB_ue_context_t *const ue_context_pP, const s1ap_Cause_t causeP, const long cause_valueP ); @@ -186,10 +183,10 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name *\brief send a S1AP dedicated E_RAB setup response *\param ctxt_pP contxt infirmation *\param e_contxt_pP ue specific context at the eNB - *\param xid transaction identifier + *\param xid transaction identifier *\return 0 when successful, -1 if the UE index can not be retrieved. */ -int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, uint8_t xid ); +int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t xid ); /*! \fn rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance); *\brief process a S1AP dedicated E_RAB modify request message received from S1AP. @@ -207,7 +204,7 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam *\param xid transaction identifier *\return 0 when successful, -1 if the UE index can not be retrieved. */ -int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, uint8_t xid ); +int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t xid ); /*! \fn rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) *\brief process a S1AP_UE_CTXT_MODIFICATION_REQ message received from S1AP. @@ -247,8 +244,8 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance void rrc_pdcp_config_security( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const uint8_t send_security_mode_command ); /*! \fn rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *msg_name, instance_t instance); @@ -267,12 +264,10 @@ int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *ms *\param xid transaction identifier *\return 0 when successful, -1 if the UE index can not be retrieved. */ -int rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, uint8_t xid ); +int rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t xid ); -int rrc_eNB_send_PATH_SWITCH_REQ(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP); +int rrc_eNB_send_PATH_SWITCH_REQ(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP); int rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK (MessageDef *msg_p, const char *msg_name, instance_t instance); -# endif -# endif /* defined(ENABLE_USE_MME) */ #endif /* RRC_ENB_S1AP_H_ */ diff --git a/openair2/RRC/LTE/rrc_proto.h b/openair2/RRC/LTE/rrc_proto.h index 831f8d11ac6ab5497a700883216bbfa2d5d669e6..6a69ecd2726fdb1cf5b50e4f95e4f358315ad012 100644 --- a/openair2/RRC/LTE/rrc_proto.h +++ b/openair2/RRC/LTE/rrc_proto.h @@ -39,13 +39,13 @@ int rrc_init_global_param(void); int L3_xface_init(void); void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active,uint8_t HO_enabled); -#if defined(ENABLE_ITTI) + char openair_rrc_eNB_configuration( const module_id_t enb_mod_idP, - RrcConfigurationReq* configuration + RrcConfigurationReq *configuration ); -#endif + char openair_rrc_eNB_init( const module_id_t module_idP); @@ -55,21 +55,21 @@ char openair_rrc_ue_init( void rrc_config_buffer(SRB_INFO *srb_info, uint8_t Lchan_type, uint8_t Role); void openair_rrc_on( - const protocol_ctxt_t* const ctxt_pP); + const protocol_ctxt_t *const ctxt_pP); void openair_rrc_on_ue( - const protocol_ctxt_t* const ctxt_pP); + const protocol_ctxt_t *const ctxt_pP); void rrc_top_cleanup(void); -/** \brief Function to update eNB timers every subframe. +/** \brief Function to update eNB timers every subframe. @param ctxt_pP running context @param enb_index @param CC_id */ RRC_status_t rrc_rx_tx( - protocol_ctxt_t* const ctxt_pP, + protocol_ctxt_t *const ctxt_pP, const int CC_id ); @@ -80,7 +80,7 @@ rrc_rx_tx( */ RRC_status_t rrc_rx_tx_ue( - protocol_ctxt_t* const ctxt_pP, + protocol_ctxt_t *const ctxt_pP, const uint8_t enb_index, const int CC_id ); @@ -91,7 +91,7 @@ rrc_rx_tx_ue( \param ctxt_pP Running context \param Srb_info Pointer to SRB_INFO structure (SRB0) \param eNB_index Index of corresponding eNB/CH*/ -int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* const Srb_info, const uint8_t eNB_index ); +int rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *const Srb_info, const uint8_t eNB_index ); /** \brief Decodes a DL-DCCH message and invokes appropriate routine to handle the message \param ctxt_pP Running context @@ -100,17 +100,17 @@ int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* co \param eNB_index Index of corresponding eNB/CH*/ void rrc_ue_decode_dcch( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, - const uint8_t* const Buffer, + const uint8_t *const Buffer, const uint8_t eNB_indexP ); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int decode_SL_Discovery_Message( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, - const uint8_t* Sdu, + const uint8_t *Sdu, const uint8_t Sdu_len); #endif @@ -119,7 +119,7 @@ int decode_SL_Discovery_Message( \param eNB_index Index of corresponding eNB/CH*/ void rrc_ue_generate_RRCConnectionRequest( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ); @@ -129,8 +129,8 @@ rrc_ue_generate_RRCConnectionRequest( \param eNB_index Index of corresponding eNB/CH*/ void rrc_ue_process_rrcConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, - LTE_RRCConnectionReconfiguration_t* rrcConnectionReconfiguration, + const protocol_ctxt_t *const ctxt_pP, + LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration, uint8_t eNB_index ); @@ -164,9 +164,9 @@ int32_t rrc_ue_establish_drb(module_id_t module_idP,frame_t frameP,uint8_t eNB_ */ void rrc_ue_process_mobilityControlInfo( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, - struct LTE_MobilityControlInfo* const mobilityControlInfo + struct LTE_MobilityControlInfo *const mobilityControlInfo ); /** \brief Process a measConfig Message and configure PHY/MAC @@ -175,9 +175,9 @@ rrc_ue_process_mobilityControlInfo( \param measConfig Pointer to MeasConfig IE from configuration*/ void rrc_ue_process_measConfig( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, - LTE_MeasConfig_t* const measConfig + LTE_MeasConfig_t *const measConfig ); /** \brief Process a RadioResourceConfigDedicated Message and configure PHY/MAC @@ -185,7 +185,7 @@ rrc_ue_process_measConfig( \param eNB_index Index of corresponding CH/eNB \param radioResourceConfigDedicated Pointer to RadioResourceConfigDedicated IE from configuration*/ void rrc_ue_process_radioResourceConfigDedicated( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index, LTE_RadioResourceConfigDedicated_t *radioResourceConfigDedicated); @@ -202,8 +202,8 @@ void rrc_ue_process_sidelink_radioResourceConfig( uint8_t eNB_index, LTE_SystemInformationBlockType18_r12_t *sib18, LTE_SystemInformationBlockType19_r12_t *sib19, - LTE_SL_CommConfig_r12_t* sl_CommConfig, - LTE_SL_DiscConfig_r12_t* sl_DiscConfig); + LTE_SL_CommConfig_r12_t *sl_CommConfig, + LTE_SL_DiscConfig_r12_t *sl_DiscConfig); /** \brief Init control socket to listen to incoming packets from ProSe App * @@ -223,8 +223,8 @@ uint8_t rrc_eNB_get_next_transaction_identifier(module_id_t module_idP); \param Srb_info Pointer to SRB0 information structure (buffer, etc.)*/ int rrc_eNB_decode_ccch( - protocol_ctxt_t* const ctxt_pP, - const SRB_INFO* const Srb_info, + protocol_ctxt_t *const ctxt_pP, + const SRB_INFO *const Srb_info, const int CC_id ); @@ -234,9 +234,9 @@ rrc_eNB_decode_ccch( \param sdu_size Size of incoming SDU*/ int rrc_eNB_decode_dcch( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, - const uint8_t* const Rx_sdu, + const uint8_t *const Rx_sdu, const sdu_size_t sdu_sizeP ); @@ -245,8 +245,8 @@ rrc_eNB_decode_dcch( \param ue_context_pP UE context*/ void rrc_eNB_generate_RRCConnectionSetup( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ); @@ -256,8 +256,8 @@ rrc_eNB_generate_RRCConnectionSetup( \param CC_id Component Carrier ID*/ void rrc_eNB_generate_RRCConnectionReestablishmentReject( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ); @@ -267,9 +267,9 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject( \param rrcConnectionSetupComplete Pointer to RRCConnectionSetupComplete message*/ void rrc_eNB_process_RRCConnectionSetupComplete( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, - LTE_RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, + LTE_RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete ); /**\brief Process the RRCConnectionReconfigurationComplete based on information coming from UE @@ -280,8 +280,8 @@ rrc_eNB_process_RRCConnectionSetupComplete( */ void rrc_eNB_process_RRCConnectionReconfigurationComplete( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, const uint8_t xid ); @@ -290,41 +290,41 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( \param ue_context_pP UE context of UE receiving the message*/ void rrc_eNB_generate_RRCConnectionRelease( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ); void rrc_eNB_generate_defaultRRCConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const uint8_t ho_state ); void flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state, - agent_reconf_rrc * trig_param - ); + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + const uint8_t ho_state, + agent_reconf_rrc *trig_param +); void -rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t* buffer, - int *_size - //const uint8_t ho_state - ); +rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t *buffer, + int *_size + //const uint8_t ho_state + ); void -rrc_eNB_configure_rbs_handover(struct rrc_eNB_ue_context_s* ue_context_p, protocol_ctxt_t* const ctxt_pP); +rrc_eNB_configure_rbs_handover(struct rrc_eNB_ue_context_s *ue_context_p, protocol_ctxt_t *const ctxt_pP); int freq_to_arfcn10(int band, unsigned long freq); void rrc_eNB_generate_dedeicatedRRCConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const uint8_t ho_state ); @@ -333,18 +333,18 @@ rrc_eNB_generate_dedeicatedRRCConnectionReconfiguration( \param ue_context_pP UE context of UE receiving the message*/ void rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, uint8_t xid, uint32_t nas_length, - uint8_t* nas_buffer + uint8_t *nas_buffer ); -void -rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP); +void +rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP); + -#if defined(ENABLE_ITTI) void rrc_enb_init(void); void *rrc_enb_process_itti_msg(void *); @@ -356,7 +356,7 @@ void *rrc_enb_task(void *args_p); /**\brief RRC UE task. \param void *args_p Pointer on arguments to start the task. */ void *rrc_ue_task(void *args_p); -#endif + void rrc_eNB_process_handoverPreparationInformation(int mod_id, x2ap_handover_req_t *m); @@ -366,9 +366,9 @@ void rrc_eNB_process_handoverPreparationInformation(int mod_id, x2ap_handover_re \param ue_module_idP Index of UE transmitting the messages*/ void rrc_eNB_generate_RRCConnectionReconfiguration_handover( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t* const nas_pdu, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t *const nas_pdu, const uint32_t nas_length ); @@ -379,10 +379,10 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( \param n_discoveryMessages Number of discovery messages*/ int rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_SL_DestinationInfoList_r12_t *destinationInfoList, - int n_discoveryMessages + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_SL_DestinationInfoList_r12_t *destinationInfoList, + int n_discoveryMessages ); /** \brief process the received SidelinkUEInformation message at eNB @@ -390,9 +390,9 @@ rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( \param sidelinkUEInformation sidelinkUEInformation message from UE*/ uint8_t rrc_eNB_process_SidelinkUEInformation( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, - LTE_SidelinkUEInformation_r12_t* sidelinkUEInformation + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, + LTE_SidelinkUEInformation_r12_t *sidelinkUEInformation ); /** \brief Get a Resource Pool to transmit SL communication @@ -400,9 +400,9 @@ rrc_eNB_process_SidelinkUEInformation( \param ue_context_pP UE context \param destinationInfoList Pointer to the list of SL destinations*/ LTE_SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_SL_DestinationInfoList_r12_t *destinationInfoList + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_SL_DestinationInfoList_r12_t *destinationInfoList ); /** \brief Get a Resource Pool for Discovery @@ -410,9 +410,9 @@ LTE_SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( \param ue_context_pP UE context \param n_discoveryMessages Number of discovery messages*/ LTE_SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - int n_discoveryMessages + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + int n_discoveryMessages ); /** \brief Process request from control socket @@ -428,7 +428,7 @@ mac_rrc_data_req( const frame_t frameP, const rb_id_t Srb_id, const uint8_t Nb_tb, - uint8_t* const buffer_pP, + uint8_t *const buffer_pP, const uint8_t mbsfn_sync_area ); @@ -440,11 +440,11 @@ mac_rrc_data_ind( const sub_frame_t sub_frameP, const rnti_t rntiP, const rb_id_t srb_idP, - const uint8_t* sduP, + const uint8_t *sduP, const sdu_size_t sdu_lenP, const uint8_t mbsfn_sync_areaP #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , const boolean_t brOption + , const boolean_t brOption #endif ); @@ -455,7 +455,7 @@ mac_rrc_data_req_ue( const frame_t frameP, const rb_id_t Srb_id, const uint8_t Nb_tb, - uint8_t* const buffer_pP, + uint8_t *const buffer_pP, const mac_enb_index_t eNB_indexP, const uint8_t mbsfn_sync_area ); @@ -468,7 +468,7 @@ mac_rrc_data_ind_ue( const sub_frame_t sub_frameP, const rnti_t rntiP, const rb_id_t srb_idP, - const uint8_t* sduP, + const uint8_t *sduP, const sdu_size_t sdu_lenP, const mac_enb_index_t eNB_indexP, const uint8_t mbsfn_sync_areaP @@ -477,84 +477,84 @@ mac_rrc_data_ind_ue( void mac_sync_ind( module_id_t Mod_instP, uint8_t status); void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, - const int CC_id, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rnti); + const int CC_id, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rnti); void mac_eNB_rrc_uplane_failure(const module_id_t Mod_instP, - const int CC_id, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rnti); + const int CC_id, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rnti); -void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, - const int CC_id, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rnti); +void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, + const int CC_id, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rnti); uint8_t rrc_data_req( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t rb_idP, const mui_t muiP, const confirm_t confirmP, const sdu_size_t sdu_size, - uint8_t* const buffer_pP, + uint8_t *const buffer_pP, const pdcp_transmission_mode_t modeP ); uint8_t rrc_data_req_ue( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t rb_idP, const mui_t muiP, const confirm_t confirmP, const sdu_size_t sdu_sizeP, - uint8_t* const buffer_pP, + uint8_t *const buffer_pP, const pdcp_transmission_mode_t modeP ); void rrc_data_ind( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, const sdu_size_t sdu_sizeP, - const uint8_t* const buffer_pP + const uint8_t *const buffer_pP ); void rrc_in_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB_index); void rrc_out_of_sync_ind(module_id_t module_idP, frame_t frameP, unsigned short eNB_index); -int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t* const Sdu, const uint8_t Sdu_len, const uint8_t mbsfn_sync_area ); +int decode_MCCH_Message( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, const uint8_t *const Sdu, const uint8_t Sdu_len, const uint8_t mbsfn_sync_area ); int decode_BCCH_DLSCH_Message( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, - uint8_t* const Sdu, + uint8_t *const Sdu, const uint8_t Sdu_len, const uint8_t rsrq, const uint8_t rsrp ); int decode_PCCH_DLSCH_Message( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, - uint8_t* const Sdu, + uint8_t *const Sdu, const uint8_t Sdu_len); void ue_meas_filtering( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ); void ue_measurement_report_triggering( - protocol_ctxt_t* const ctxt_pP, + protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ); @@ -572,35 +572,35 @@ mac_UE_get_rrc_status( void rrc_eNB_generate_UECapabilityEnquiry( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ); void rrc_eNB_generate_SecurityModeCommand( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ); void rrc_eNB_process_MeasurementReport( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, - const LTE_MeasResults_t* const measResults2 + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, + const LTE_MeasResults_t *const measResults2 ); void rrc_eNB_generate_HandoverPreparationInformation( //const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t* buffer, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t *buffer, int *_size //LTE_PhysCellId_t targetPhyId ); void check_handovers( - protocol_ctxt_t* const ctxt_pP + protocol_ctxt_t *const ctxt_pP ); //void rrc_ue_process_ueCapabilityEnquiry(uint8_t module_idP,uint32_t frame,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index); @@ -612,7 +612,6 @@ rrc_ue_process_securityModeCommand( ); */ -#if !defined(ENABLE_USE_MME) void rrc_eNB_emulation_notify_ue_module_id( const module_id_t ue_module_idP, const rnti_t rntiP, @@ -620,20 +619,20 @@ void rrc_eNB_emulation_notify_ue_module_id( const uint8_t cell_identity_byte1P, const uint8_t cell_identity_byte2P, const uint8_t cell_identity_byte3P); -#endif + void rrc_eNB_free_mem_UE_context( - const protocol_ctxt_t* const ctxt_pP, - struct rrc_eNB_ue_context_s* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + struct rrc_eNB_ue_context_s *const ue_context_pP ); void rrc_eNB_free_UE( - const module_id_t enb_mod_idP, - const struct rrc_eNB_ue_context_s* const ue_context_pP + const module_id_t enb_mod_idP, + const struct rrc_eNB_ue_context_s *const ue_context_pP ); long binary_search_int(int elements[], long numElem, int value); @@ -643,10 +642,10 @@ long binary_search_float(float elements[], long numElem, float value); void openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active); void openair_rrc_top_init_ue( - int eMBMS_active, - char* uecap_xer, - uint8_t cba_group_active, - uint8_t HO_active + int eMBMS_active, + char *uecap_xer, + uint8_t cba_group_active, + uint8_t HO_active ); pthread_mutex_t rrc_release_freelist; RRC_release_list_t rrc_release_info; diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h index 0495b139ce363e548346c83d9d22213ea32647e3..34190f7d15839e2a0c3a83e9bcc9d501fbf7fb25 100644 --- a/openair2/UTIL/OCG/OCG.h +++ b/openair2/UTIL/OCG/OCG.h @@ -39,10 +39,8 @@ #include "PHY/defs_common.h" #include "PHY/impl_defs_top.h" #include "platform_types.h" - -#if defined(ENABLE_USE_MME) # include "s1ap_eNB.h" -#endif + #ifdef __cplusplus extern "C" @@ -135,8 +133,7 @@ The following diagram is based on graphviz (http://www.graphviz.org/), you need * \enddot */ -enum -{ +enum { STATE_START_OCG, /*!< \brief initiate OCG */ STATE_GET_OPT, /*!< \brief get options of OCG command */ STATE_DETECT_FILE, /*!< \brief detect the configuration file in folder USER_XML_FOLDER */ @@ -571,7 +568,7 @@ typedef struct { } Layer; typedef struct { - char * level; + char *level; char *verbosity; int interval; } Log_Emu; @@ -598,8 +595,8 @@ typedef struct { Log_Emu log_emu; Packet_Trace packet_trace; Seed seed; - char * curve; - char * background_stats; + char *curve; + char *background_stats; // CLI tags are in Info //char g_log_level[20]; } Emulation_Config; @@ -677,7 +674,7 @@ typedef struct { unsigned char cba_group_active; unsigned char cba_backoff; unsigned char handover_active; - char * otg_traffic; + char *otg_traffic; unsigned char otg_bg_traffic_enabled; unsigned char omg_model_rn; unsigned char omg_model_enb; @@ -705,7 +702,7 @@ typedef struct { node_function_t node_function[MAX_NUM_CCs]; node_timing_t node_timing[MAX_NUM_CCs]; unsigned char frame_type[MAX_NUM_CCs]; //! LTE frame type (TDD=1, FDD=0). \note this should be converted to \ref lte_frame_type_t (header file reorganization needed) - char * frame_type_name[MAX_NUM_CCs]; + char *frame_type_name[MAX_NUM_CCs]; unsigned char tdd_config[MAX_NUM_CCs]; unsigned char tdd_config_S[MAX_NUM_CCs]; unsigned char extended_prefix_flag[MAX_NUM_CCs]; @@ -713,10 +710,7 @@ typedef struct { unsigned char transmission_mode[MAX_NUM_CCs]; int max_predefined_traffic_config_index; int max_customized_traffic_config_index; - -#if defined(ENABLE_USE_MME) s1ap_eNB_config_t s1ap_config; -#endif /* Per-Slot ISR * Interval between two ISR = 500usec diff --git a/openair2/X2AP/x2ap_eNB_generate_messages.c b/openair2/X2AP/x2ap_eNB_generate_messages.c index b9a2dae04ce18069c79dbad880ba19fe1f2ffaf1..76d6053b59a1fb3a242a8730e3dface21a4eecda 100644 --- a/openair2/X2AP/x2ap_eNB_generate_messages.c +++ b/openair2/X2AP/x2ap_eNB_generate_messages.c @@ -619,7 +619,7 @@ int x2ap_eNB_generate_x2_handover_request_ack (x2ap_eNB_data_t *x2ap_eNB_data_p, ie = (X2AP_HandoverRequestAcknowledge_IEs_t *)calloc(1, sizeof(X2AP_HandoverRequestAcknowledge_IEs_t)); ie->id = X2AP_ProtocolIE_ID_id_New_eNB_UE_X2AP_ID; ie->criticality = X2AP_Criticality_ignore; - ie->value.present = X2AP_HandoverRequestAcknowledge_IEs__value_PR_UE_X2AP_ID_1; + ie->value.present = X2AP_HandoverRequestAcknowledge_IEs__value_PR_UE_X2AP_ID; ie->value.choice.UE_X2AP_ID = 0; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); @@ -708,7 +708,7 @@ int x2ap_eNB_generate_x2_ue_context_release (x2ap_eNB_data_t *x2ap_eNB_data_p) ie = (X2AP_UEContextRelease_IEs_t *)calloc(1, sizeof(X2AP_UEContextRelease_IEs_t)); ie->id = X2AP_ProtocolIE_ID_id_New_eNB_UE_X2AP_ID; ie->criticality = X2AP_Criticality_reject; - ie->value.present = X2AP_UEContextRelease_IEs__value_PR_UE_X2AP_ID_1; + ie->value.present = X2AP_UEContextRelease_IEs__value_PR_UE_X2AP_ID; ie->value.choice.UE_X2AP_ID = 0; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); diff --git a/openair3/NAS/COMMON/EMM/MSG/emm_msg.c b/openair3/NAS/COMMON/EMM/MSG/emm_msg.c index b9c9b93a9caf3625076d3351b7d0e35ba2261980..cd55a3fffb9e1de70685bd89c33d2c5f26e438b5 100644 --- a/openair3/NAS/COMMON/EMM/MSG/emm_msg.c +++ b/openair3/NAS/COMMON/EMM/MSG/emm_msg.c @@ -44,9 +44,8 @@ Description Defines EPS Mobility Management messages #include "TLVDecoder.h" #include "TLVEncoder.h" -#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE))) -# include "nas_itti_messaging.h" -#endif + +#include "nas_itti_messaging.h" /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -83,25 +82,18 @@ static int _emm_msg_encode_header(const emm_msg_header_t *header, ** Others: None ** ** ** ***************************************************************************/ -int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len) -{ +int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len) { LOG_FUNC_IN; - int header_result; int decode_result; - -#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE))) uint8_t *buffer_log = buffer; uint32_t len_log = len; int down_link; - # if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME))) down_link = 0; # else down_link = 1; # endif -#endif - /* First decode the EMM message header */ header_result = _emm_msg_decode_header(&msg->header, buffer, len); @@ -113,144 +105,143 @@ int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len) buffer += header_result; len -= header_result; - LOG_TRACE(INFO, "EMM-MSG - Message Type 0x%02x", msg->header.message_type); switch(msg->header.message_type) { - case EMM_INFORMATION: - decode_result = decode_emm_information(&msg->emm_information, buffer, len); - break; - - case UPLINK_NAS_TRANSPORT: - decode_result = decode_uplink_nas_transport(&msg->uplink_nas_transport, buffer, - len); - break; - - case AUTHENTICATION_REJECT: - decode_result = decode_authentication_reject(&msg->authentication_reject, - buffer, len); - break; - - case AUTHENTICATION_FAILURE: - decode_result = decode_authentication_failure(&msg->authentication_failure, - buffer, len); - break; - - case DETACH_ACCEPT: - decode_result = decode_detach_accept(&msg->detach_accept, buffer, len); - break; - - case SERVICE_REJECT: - decode_result = decode_service_reject(&msg->service_reject, buffer, len); - break; - - case AUTHENTICATION_REQUEST: - decode_result = decode_authentication_request(&msg->authentication_request, - buffer, len); - break; - - case TRACKING_AREA_UPDATE_REQUEST: - decode_result = decode_tracking_area_update_request( - &msg->tracking_area_update_request, buffer, len); - break; - - case ATTACH_REQUEST: - decode_result = decode_attach_request(&msg->attach_request, buffer, len); - break; - - case EMM_STATUS: - decode_result = decode_emm_status(&msg->emm_status, buffer, len); - break; - - case IDENTITY_RESPONSE: - decode_result = decode_identity_response(&msg->identity_response, buffer, len); - break; - - case IDENTITY_REQUEST: - decode_result = decode_identity_request(&msg->identity_request, buffer, len); - break; - - case GUTI_REALLOCATION_COMMAND: - decode_result = decode_guti_reallocation_command(&msg->guti_reallocation_command, - buffer, len); - break; - - case TRACKING_AREA_UPDATE_REJECT: - decode_result = decode_tracking_area_update_reject( - &msg->tracking_area_update_reject, buffer, len); - break; - - case ATTACH_ACCEPT: - decode_result = decode_attach_accept(&msg->attach_accept, buffer, len); - break; - - case SECURITY_MODE_COMPLETE: - decode_result = decode_security_mode_complete(&msg->security_mode_complete, - buffer, len); - break; - - case TRACKING_AREA_UPDATE_ACCEPT: - decode_result = decode_tracking_area_update_accept( - &msg->tracking_area_update_accept, buffer, len); - break; - - case ATTACH_REJECT: - decode_result = decode_attach_reject(&msg->attach_reject, buffer, len); - break; - - case ATTACH_COMPLETE: - decode_result = decode_attach_complete(&msg->attach_complete, buffer, len); - break; - - case TRACKING_AREA_UPDATE_COMPLETE: - decode_result = decode_tracking_area_update_complete( - &msg->tracking_area_update_complete, buffer, len); - break; - - case CS_SERVICE_NOTIFICATION: - decode_result = decode_cs_service_notification(&msg->cs_service_notification, - buffer, len); - break; - - case SECURITY_MODE_REJECT: - decode_result = decode_security_mode_reject(&msg->security_mode_reject, buffer, - len); - break; - - case DETACH_REQUEST: - decode_result = decode_detach_request(&msg->detach_request, buffer, len); - break; - - case GUTI_REALLOCATION_COMPLETE: - decode_result = decode_guti_reallocation_complete( - &msg->guti_reallocation_complete, buffer, len); - break; - - case SECURITY_MODE_COMMAND: - decode_result = decode_security_mode_command(&msg->security_mode_command, - buffer, len); - break; - - case DOWNLINK_NAS_TRANSPORT: - decode_result = decode_downlink_nas_transport(&msg->downlink_nas_transport, - buffer, len); - break; - - case EXTENDED_SERVICE_REQUEST: - decode_result = decode_extended_service_request(&msg->extended_service_request, - buffer, len); - break; - - case AUTHENTICATION_RESPONSE: - decode_result = decode_authentication_response(&msg->authentication_response, - buffer, len); - break; - - default: - LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x", - msg->header.message_type); - decode_result = TLV_DECODE_WRONG_MESSAGE_TYPE; - /* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */ + case EMM_INFORMATION: + decode_result = decode_emm_information(&msg->emm_information, buffer, len); + break; + + case UPLINK_NAS_TRANSPORT: + decode_result = decode_uplink_nas_transport(&msg->uplink_nas_transport, buffer, + len); + break; + + case AUTHENTICATION_REJECT: + decode_result = decode_authentication_reject(&msg->authentication_reject, + buffer, len); + break; + + case AUTHENTICATION_FAILURE: + decode_result = decode_authentication_failure(&msg->authentication_failure, + buffer, len); + break; + + case DETACH_ACCEPT: + decode_result = decode_detach_accept(&msg->detach_accept, buffer, len); + break; + + case SERVICE_REJECT: + decode_result = decode_service_reject(&msg->service_reject, buffer, len); + break; + + case AUTHENTICATION_REQUEST: + decode_result = decode_authentication_request(&msg->authentication_request, + buffer, len); + break; + + case TRACKING_AREA_UPDATE_REQUEST: + decode_result = decode_tracking_area_update_request( + &msg->tracking_area_update_request, buffer, len); + break; + + case ATTACH_REQUEST: + decode_result = decode_attach_request(&msg->attach_request, buffer, len); + break; + + case EMM_STATUS: + decode_result = decode_emm_status(&msg->emm_status, buffer, len); + break; + + case IDENTITY_RESPONSE: + decode_result = decode_identity_response(&msg->identity_response, buffer, len); + break; + + case IDENTITY_REQUEST: + decode_result = decode_identity_request(&msg->identity_request, buffer, len); + break; + + case GUTI_REALLOCATION_COMMAND: + decode_result = decode_guti_reallocation_command(&msg->guti_reallocation_command, + buffer, len); + break; + + case TRACKING_AREA_UPDATE_REJECT: + decode_result = decode_tracking_area_update_reject( + &msg->tracking_area_update_reject, buffer, len); + break; + + case ATTACH_ACCEPT: + decode_result = decode_attach_accept(&msg->attach_accept, buffer, len); + break; + + case SECURITY_MODE_COMPLETE: + decode_result = decode_security_mode_complete(&msg->security_mode_complete, + buffer, len); + break; + + case TRACKING_AREA_UPDATE_ACCEPT: + decode_result = decode_tracking_area_update_accept( + &msg->tracking_area_update_accept, buffer, len); + break; + + case ATTACH_REJECT: + decode_result = decode_attach_reject(&msg->attach_reject, buffer, len); + break; + + case ATTACH_COMPLETE: + decode_result = decode_attach_complete(&msg->attach_complete, buffer, len); + break; + + case TRACKING_AREA_UPDATE_COMPLETE: + decode_result = decode_tracking_area_update_complete( + &msg->tracking_area_update_complete, buffer, len); + break; + + case CS_SERVICE_NOTIFICATION: + decode_result = decode_cs_service_notification(&msg->cs_service_notification, + buffer, len); + break; + + case SECURITY_MODE_REJECT: + decode_result = decode_security_mode_reject(&msg->security_mode_reject, buffer, + len); + break; + + case DETACH_REQUEST: + decode_result = decode_detach_request(&msg->detach_request, buffer, len); + break; + + case GUTI_REALLOCATION_COMPLETE: + decode_result = decode_guti_reallocation_complete( + &msg->guti_reallocation_complete, buffer, len); + break; + + case SECURITY_MODE_COMMAND: + decode_result = decode_security_mode_command(&msg->security_mode_command, + buffer, len); + break; + + case DOWNLINK_NAS_TRANSPORT: + decode_result = decode_downlink_nas_transport(&msg->downlink_nas_transport, + buffer, len); + break; + + case EXTENDED_SERVICE_REQUEST: + decode_result = decode_extended_service_request(&msg->extended_service_request, + buffer, len); + break; + + case AUTHENTICATION_RESPONSE: + decode_result = decode_authentication_response(&msg->authentication_response, + buffer, len); + break; + + default: + LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x", + msg->header.message_type); + decode_result = TLV_DECODE_WRONG_MESSAGE_TYPE; + /* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */ } if (decode_result < 0) { @@ -284,24 +275,17 @@ int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len) ** Others: None ** ** ** ***************************************************************************/ -int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len) -{ +int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len) { LOG_FUNC_IN; - int header_result; int encode_result; - -#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE))) uint8_t *buffer_log = buffer; int down_link; - # if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME))) down_link = 1; # else down_link = 0; # endif -#endif - /* First encode the EMM message header */ header_result = _emm_msg_encode_header(&msg->header, buffer, len); @@ -315,144 +299,144 @@ int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len) len -= header_result; switch(msg->header.message_type) { - case EMM_INFORMATION: - encode_result = encode_emm_information(&msg->emm_information, buffer, len); - break; - - case UPLINK_NAS_TRANSPORT: - encode_result = encode_uplink_nas_transport(&msg->uplink_nas_transport, buffer, - len); - break; - - case AUTHENTICATION_REJECT: - encode_result = encode_authentication_reject(&msg->authentication_reject, - buffer, len); - break; - - case AUTHENTICATION_FAILURE: - encode_result = encode_authentication_failure(&msg->authentication_failure, - buffer, len); - break; - - case DETACH_ACCEPT: - encode_result = encode_detach_accept(&msg->detach_accept, buffer, len); - break; - - case SERVICE_REJECT: - encode_result = encode_service_reject(&msg->service_reject, buffer, len); - break; - - case AUTHENTICATION_REQUEST: - encode_result = encode_authentication_request(&msg->authentication_request, - buffer, len); - break; - - case TRACKING_AREA_UPDATE_REQUEST: - encode_result = encode_tracking_area_update_request( - &msg->tracking_area_update_request, buffer, len); - break; - - case ATTACH_REQUEST: - encode_result = encode_attach_request(&msg->attach_request, buffer, len); - break; - - case EMM_STATUS: - encode_result = encode_emm_status(&msg->emm_status, buffer, len); - break; - - case IDENTITY_RESPONSE: - encode_result = encode_identity_response(&msg->identity_response, buffer, len); - break; - - case IDENTITY_REQUEST: - encode_result = encode_identity_request(&msg->identity_request, buffer, len); - break; - - case GUTI_REALLOCATION_COMMAND: - encode_result = encode_guti_reallocation_command(&msg->guti_reallocation_command, - buffer, len); - break; - - case TRACKING_AREA_UPDATE_REJECT: - encode_result = encode_tracking_area_update_reject( - &msg->tracking_area_update_reject, buffer, len); - break; - - case ATTACH_ACCEPT: - encode_result = encode_attach_accept(&msg->attach_accept, buffer, len); - break; - - case SECURITY_MODE_COMPLETE: - encode_result = encode_security_mode_complete(&msg->security_mode_complete, - buffer, len); - break; - - case TRACKING_AREA_UPDATE_ACCEPT: - encode_result = encode_tracking_area_update_accept( - &msg->tracking_area_update_accept, buffer, len); - break; - - case ATTACH_REJECT: - encode_result = encode_attach_reject(&msg->attach_reject, buffer, len); - break; - - case ATTACH_COMPLETE: - encode_result = encode_attach_complete(&msg->attach_complete, buffer, len); - break; - - case TRACKING_AREA_UPDATE_COMPLETE: - encode_result = encode_tracking_area_update_complete( - &msg->tracking_area_update_complete, buffer, len); - break; - - case CS_SERVICE_NOTIFICATION: - encode_result = encode_cs_service_notification(&msg->cs_service_notification, - buffer, len); - break; - - case SECURITY_MODE_REJECT: - encode_result = encode_security_mode_reject(&msg->security_mode_reject, buffer, - len); - break; - - case DETACH_REQUEST: - encode_result = encode_detach_request(&msg->detach_request, buffer, len); - break; - - case GUTI_REALLOCATION_COMPLETE: - encode_result = encode_guti_reallocation_complete( - &msg->guti_reallocation_complete, buffer, len); - break; - - case SECURITY_MODE_COMMAND: - encode_result = encode_security_mode_command(&msg->security_mode_command, - buffer, len); - break; - - case DOWNLINK_NAS_TRANSPORT: - encode_result = encode_downlink_nas_transport(&msg->downlink_nas_transport, - buffer, len); - break; - - case EXTENDED_SERVICE_REQUEST: - encode_result = encode_extended_service_request(&msg->extended_service_request, - buffer, len); - break; - - case AUTHENTICATION_RESPONSE: - encode_result = encode_authentication_response(&msg->authentication_response, - buffer, len); - break; - - case SERVICE_REQUEST: - encode_result = encode_service_request(&msg->service_request, buffer, len); - break; - - default: - LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x", - msg->header.message_type); - encode_result = TLV_ENCODE_WRONG_MESSAGE_TYPE; - /* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */ + case EMM_INFORMATION: + encode_result = encode_emm_information(&msg->emm_information, buffer, len); + break; + + case UPLINK_NAS_TRANSPORT: + encode_result = encode_uplink_nas_transport(&msg->uplink_nas_transport, buffer, + len); + break; + + case AUTHENTICATION_REJECT: + encode_result = encode_authentication_reject(&msg->authentication_reject, + buffer, len); + break; + + case AUTHENTICATION_FAILURE: + encode_result = encode_authentication_failure(&msg->authentication_failure, + buffer, len); + break; + + case DETACH_ACCEPT: + encode_result = encode_detach_accept(&msg->detach_accept, buffer, len); + break; + + case SERVICE_REJECT: + encode_result = encode_service_reject(&msg->service_reject, buffer, len); + break; + + case AUTHENTICATION_REQUEST: + encode_result = encode_authentication_request(&msg->authentication_request, + buffer, len); + break; + + case TRACKING_AREA_UPDATE_REQUEST: + encode_result = encode_tracking_area_update_request( + &msg->tracking_area_update_request, buffer, len); + break; + + case ATTACH_REQUEST: + encode_result = encode_attach_request(&msg->attach_request, buffer, len); + break; + + case EMM_STATUS: + encode_result = encode_emm_status(&msg->emm_status, buffer, len); + break; + + case IDENTITY_RESPONSE: + encode_result = encode_identity_response(&msg->identity_response, buffer, len); + break; + + case IDENTITY_REQUEST: + encode_result = encode_identity_request(&msg->identity_request, buffer, len); + break; + + case GUTI_REALLOCATION_COMMAND: + encode_result = encode_guti_reallocation_command(&msg->guti_reallocation_command, + buffer, len); + break; + + case TRACKING_AREA_UPDATE_REJECT: + encode_result = encode_tracking_area_update_reject( + &msg->tracking_area_update_reject, buffer, len); + break; + + case ATTACH_ACCEPT: + encode_result = encode_attach_accept(&msg->attach_accept, buffer, len); + break; + + case SECURITY_MODE_COMPLETE: + encode_result = encode_security_mode_complete(&msg->security_mode_complete, + buffer, len); + break; + + case TRACKING_AREA_UPDATE_ACCEPT: + encode_result = encode_tracking_area_update_accept( + &msg->tracking_area_update_accept, buffer, len); + break; + + case ATTACH_REJECT: + encode_result = encode_attach_reject(&msg->attach_reject, buffer, len); + break; + + case ATTACH_COMPLETE: + encode_result = encode_attach_complete(&msg->attach_complete, buffer, len); + break; + + case TRACKING_AREA_UPDATE_COMPLETE: + encode_result = encode_tracking_area_update_complete( + &msg->tracking_area_update_complete, buffer, len); + break; + + case CS_SERVICE_NOTIFICATION: + encode_result = encode_cs_service_notification(&msg->cs_service_notification, + buffer, len); + break; + + case SECURITY_MODE_REJECT: + encode_result = encode_security_mode_reject(&msg->security_mode_reject, buffer, + len); + break; + + case DETACH_REQUEST: + encode_result = encode_detach_request(&msg->detach_request, buffer, len); + break; + + case GUTI_REALLOCATION_COMPLETE: + encode_result = encode_guti_reallocation_complete( + &msg->guti_reallocation_complete, buffer, len); + break; + + case SECURITY_MODE_COMMAND: + encode_result = encode_security_mode_command(&msg->security_mode_command, + buffer, len); + break; + + case DOWNLINK_NAS_TRANSPORT: + encode_result = encode_downlink_nas_transport(&msg->downlink_nas_transport, + buffer, len); + break; + + case EXTENDED_SERVICE_REQUEST: + encode_result = encode_extended_service_request(&msg->extended_service_request, + buffer, len); + break; + + case AUTHENTICATION_RESPONSE: + encode_result = encode_authentication_response(&msg->authentication_response, + buffer, len); + break; + + case SERVICE_REQUEST: + encode_result = encode_service_request(&msg->service_request, buffer, len); + break; + + default: + LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x", + msg->header.message_type); + encode_result = TLV_ENCODE_WRONG_MESSAGE_TYPE; + /* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */ } if (encode_result < 0) { @@ -495,8 +479,7 @@ int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len) ** ** ***************************************************************************/ static int _emm_msg_decode_header(emm_msg_header_t *header, - const uint8_t *buffer, uint32_t len) -{ + const uint8_t *buffer, uint32_t len) { int size = 0; /* Check the buffer length */ @@ -538,8 +521,7 @@ static int _emm_msg_decode_header(emm_msg_header_t *header, ** ** ***************************************************************************/ static int _emm_msg_encode_header(const emm_msg_header_t *header, - uint8_t *buffer, uint32_t len) -{ + uint8_t *buffer, uint32_t len) { int size = 0; /* Check the buffer length */ @@ -558,7 +540,6 @@ static int _emm_msg_encode_header(const emm_msg_header_t *header, ENCODE_U8(buffer + size, *(uint8_t *)(header), size); /* Encode the message type */ ENCODE_U8(buffer + size, header->message_type, size); - return (size); } diff --git a/openair3/NAS/UE/API/USER/user_api.h b/openair3/NAS/UE/API/USER/user_api.h index e554b4ef0b7c6d3ab7dd6c3910da6e4a6a7c8dd7..1056a6b7f42d9ad3cf76c9b87183ed4bc65abe2e 100644 --- a/openair3/NAS/UE/API/USER/user_api.h +++ b/openair3/NAS/UE/API/USER/user_api.h @@ -44,7 +44,7 @@ Description Implements the API used by the NAS layer running in the UE #include "networkDef.h" #include "at_command.h" #include "user_api_defs.h" -#include "user_defs.h" +#include "../../user_defs.h" /****************************************************************************/ /********************* G L O B A L C O N S T A N T S *******************/ @@ -58,13 +58,13 @@ Description Implements the API used by the NAS layer running in the UE /****************** E X P O R T E D F U N C T I O N S ******************/ /****************************************************************************/ -int user_api_initialize(user_api_id_t *user_api_id, const char* host, const char* port, const char* devname, const char* devparams); +int user_api_initialize(user_api_id_t *user_api_id, const char *host, const char *port, const char *devname, const char *devparams); -int user_api_emm_callback(user_api_id_t *user_api_id, Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT, const char* data, size_t size); +int user_api_emm_callback(user_api_id_t *user_api_id, Stat_t stat, tac_t tac, ci_t ci, AcT_t AcT, const char *data, size_t size); int user_api_esm_callback(user_api_id_t *user_api_id, int cid, network_pdn_state_t state); int user_api_get_fd(user_api_id_t *user_api_id); -const void* user_api_get_data(user_at_commands_t *commands, int index); +const void *user_api_get_data(user_at_commands_t *commands, int index); int user_api_read_data(user_api_id_t *user_api_id); int user_api_set_data(user_api_id_t *user_api_id, char *message); @@ -72,6 +72,6 @@ int user_api_send_data(user_api_id_t *user_api_id, int length); void user_api_close(user_api_id_t *user_api_id); int user_api_decode_data(user_api_id_t *user_api_id, user_at_commands_t *commands, int length); -int user_api_encode_data(user_api_id_t *user_api_id, const void* data, int add_success_code); +int user_api_encode_data(user_api_id_t *user_api_id, const void *data, int add_success_code); #endif /* __USER_API_H__ */ diff --git a/openair3/NAS/UE/EMM/emm_main.h b/openair3/NAS/UE/EMM/emm_main.h index 055127b15d41fd6d4a10b1c2ac487a35dd9f9357..d30f778e3b7f7d2114e5d23c81da0cb393babcb2 100644 --- a/openair3/NAS/UE/EMM/emm_main.h +++ b/openair3/NAS/UE/EMM/emm_main.h @@ -41,7 +41,7 @@ Description Defines the EPS Mobility Management procedure call manager, #include "commonDef.h" #include "networkDef.h" -#include "user_defs.h" +#include "../user_defs.h" /****************************************************************************/ /********************* G L O B A L C O N S T A N T S *******************/ @@ -58,7 +58,7 @@ Description Defines the EPS Mobility Management procedure call manager, * EPS Mobility Management sublayer */ typedef int (*emm_indication_callback_t) (user_api_id_t *user_api_id, Stat_t, tac_t, ci_t, AcT_t, - const char*, size_t); + const char *, size_t); /****************************************************************************/ /******************** G L O B A L V A R I A B L E S ********************/ diff --git a/openair3/NAS/UE/ESM/esm_ebr.h b/openair3/NAS/UE/ESM/esm_ebr.h index dece5c3645bfe0d4218a65e0eb99ee3fc709bf0e..6de4a048a49ef7b32bc073a00a90b3df373a72fe 100644 --- a/openair3/NAS/UE/ESM/esm_ebr.h +++ b/openair3/NAS/UE/ESM/esm_ebr.h @@ -45,7 +45,7 @@ Description Defines functions used to handle state of EPS bearer contexts #include "esmData.h" #include "nas_timer.h" -#include "user_defs.h" +#include "../user_defs.h" /****************************************************************************/ /********************* G L O B A L C O N S T A N T S *******************/ diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c index 7404cd8b8a83a751e21fad46eca07033e41afcac..5830518df0f8b8bfd40b2ba9a3d846d326109b14 100644 --- a/openair3/NAS/UE/ESM/esm_ebr_context.c +++ b/openair3/NAS/UE/ESM/esm_ebr_context.c @@ -48,21 +48,17 @@ Description Defines functions used to handle EPS bearer contexts. #include "emm_sap.h" #include "system.h" - -#if defined(ENABLE_ITTI) -# include "assertions.h" -#endif +#include "assertions.h" +#include "pdcp.h" #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> -#ifdef PDCP_USE_NETLINK #ifdef UESIM_EXPANSION #include "openairinterface5g_limits.h" extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; #endif -#endif extern uint8_t nfapi_mode; /****************************************************************************/ @@ -107,18 +103,13 @@ static int _esm_ebr_context_check_precedence(const network_tft_t *, int esm_ebr_context_create( esm_data_t *esm_data, int ueid, int pid, int ebi, int is_default, - const network_qos_t *qos, const network_tft_t *tft) -{ + const network_qos_t *qos, const network_tft_t *tft) { int bid = 0; esm_data_context_t *esm_ctx = NULL; esm_pdn_t *pdn = NULL; - LOG_FUNC_IN; - esm_ctx = esm_data; - bid = ESM_DATA_EPS_BEARER_MAX; - LOG_TRACE(INFO, "ESM-PROC - Create new %s EPS bearer context (ebi=%d) " "for PDN connection (pid=%d)", (is_default)? "default" : "dedicated", ebi, pid); @@ -166,7 +157,7 @@ int esm_ebr_context_create( esm_bearer_t *ebr = (esm_bearer_t *)malloc(sizeof(esm_bearer_t)); if (ebr != NULL) { - memset(ebr, 0 , sizeof(esm_bearer_t)); + memset(ebr, 0, sizeof(esm_bearer_t)); /* Increment the total number of active EPS bearers */ esm_ctx->n_ebrs += 1; /* Increment the number of EPS bearer for this PDN connection */ @@ -207,147 +198,153 @@ int esm_ebr_context_create( // LG ADD TEMP { - char *tmp = NULL; - char ipv4_addr[INET_ADDRSTRLEN]; - //char ipv6_addr[INET6_ADDRSTRLEN]; - char *netmask = NULL; - char broadcast[INET_ADDRSTRLEN]; - struct in_addr in_addr; - char command_line[500]; - int res = -1; - - switch (pdn->type) { - case NET_PDN_TYPE_IPV4V6: - //ipv6_addr[0] = pdn->ip_addr[4]; - /* TODO? */ - - // etc - case NET_PDN_TYPE_IPV4: - // in_addr is in network byte order - in_addr.s_addr = pdn->ip_addr[0] << 24 | - ((pdn->ip_addr[1] << 16) & 0x00FF0000) | - ((pdn->ip_addr[2] << 8) & 0x0000FF00) | - ( pdn->ip_addr[3] & 0x000000FF); - - in_addr.s_addr = htonl(in_addr.s_addr); - - tmp = inet_ntoa(in_addr); - //AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(ipv4_addr, tmp); - - if (IN_CLASSA(ntohl(in_addr.s_addr))) { - netmask = "255.0.0.0"; - in_addr.s_addr = pdn->ip_addr[0] << 24 | - ((255 << 16) & 0x00FF0000) | - ((255 << 8) & 0x0000FF00) | - ( 255 & 0x000000FF); - in_addr.s_addr = htonl(in_addr.s_addr); - tmp = inet_ntoa(in_addr); - // AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(broadcast, tmp); - } else if (IN_CLASSB(ntohl(in_addr.s_addr))) { - netmask = "255.255.0.0"; - in_addr.s_addr = pdn->ip_addr[0] << 24 | - ((pdn->ip_addr[1] << 16) & 0x00FF0000) | - ((255 << 8) & 0x0000FF00) | - ( 255 & 0x000000FF); - in_addr.s_addr = htonl(in_addr.s_addr); - tmp = inet_ntoa(in_addr); - // AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(broadcast, tmp); - } else if (IN_CLASSC(ntohl(in_addr.s_addr))) { - netmask = "255.255.255.0"; - in_addr.s_addr = pdn->ip_addr[0] << 24 | + char *tmp = NULL; + char ipv4_addr[INET_ADDRSTRLEN]; + //char ipv6_addr[INET6_ADDRSTRLEN]; + char *netmask = NULL; + char broadcast[INET_ADDRSTRLEN]; + struct in_addr in_addr; + char command_line[500]; + int res = -1; + + switch (pdn->type) { + case NET_PDN_TYPE_IPV4V6: + + //ipv6_addr[0] = pdn->ip_addr[4]; + /* TODO? */ + + // etc + case NET_PDN_TYPE_IPV4: + // in_addr is in network byte order + in_addr.s_addr = pdn->ip_addr[0] << 24 | ((pdn->ip_addr[1] << 16) & 0x00FF0000) | ((pdn->ip_addr[2] << 8) & 0x0000FF00) | - ( 255 & 0x000000FF); - in_addr.s_addr = htonl(in_addr.s_addr); - tmp = inet_ntoa(in_addr); - // AssertFatal(tmp , - // "error in PDN IPv4 address %x", - // in_addr.s_addr); - strcpy(broadcast, tmp); - } else { - netmask = "255.255.255.255"; - strcpy(broadcast, ipv4_addr); - } - - if(nfapi_mode ==3){ + ( pdn->ip_addr[3] & 0x000000FF); + in_addr.s_addr = htonl(in_addr.s_addr); + tmp = inet_ntoa(in_addr); + //AssertFatal(tmp , + // "error in PDN IPv4 address %x", + // in_addr.s_addr); + strcpy(ipv4_addr, tmp); + + if (IN_CLASSA(ntohl(in_addr.s_addr))) { + netmask = "255.0.0.0"; + in_addr.s_addr = pdn->ip_addr[0] << 24 | + ((255 << 16) & 0x00FF0000) | + ((255 << 8) & 0x0000FF00) | + ( 255 & 0x000000FF); + in_addr.s_addr = htonl(in_addr.s_addr); + tmp = inet_ntoa(in_addr); + // AssertFatal(tmp , + // "error in PDN IPv4 address %x", + // in_addr.s_addr); + strcpy(broadcast, tmp); + } else if (IN_CLASSB(ntohl(in_addr.s_addr))) { + netmask = "255.255.0.0"; + in_addr.s_addr = pdn->ip_addr[0] << 24 | + ((pdn->ip_addr[1] << 16) & 0x00FF0000) | + ((255 << 8) & 0x0000FF00) | + ( 255 & 0x000000FF); + in_addr.s_addr = htonl(in_addr.s_addr); + tmp = inet_ntoa(in_addr); + // AssertFatal(tmp , + // "error in PDN IPv4 address %x", + // in_addr.s_addr); + strcpy(broadcast, tmp); + } else if (IN_CLASSC(ntohl(in_addr.s_addr))) { + netmask = "255.255.255.0"; + in_addr.s_addr = pdn->ip_addr[0] << 24 | + ((pdn->ip_addr[1] << 16) & 0x00FF0000) | + ((pdn->ip_addr[2] << 8) & 0x0000FF00) | + ( 255 & 0x000000FF); + in_addr.s_addr = htonl(in_addr.s_addr); + tmp = inet_ntoa(in_addr); + // AssertFatal(tmp , + // "error in PDN IPv4 address %x", + // in_addr.s_addr); + strcpy(broadcast, tmp); + } else { + netmask = "255.255.255.255"; + strcpy(broadcast, ipv4_addr); + } + + if(nfapi_mode ==3) { // this is for L2 FAPI simulator. // change for multiple UE's like 256UEs. // if it's made too many tables , OS may crush so we use one table. -#ifdef PDCP_USE_NETLINK + if(PDCP_USE_NETLINK) { #ifdef UESIM_EXPANSION - uint16_t inst_nic = (pdn->ip_addr[3] & 0x000000FF) - 2; - res = sprintf(command_line, - "ifconfig oip%d %s netmask %s broadcast %s up && " - "ip rule add from %s/24 table %d && " - "ip rule add to %s/24 table %d && " - "ip route add default dev oip%d table %d", - inst_nic + 1, ipv4_addr, netmask, broadcast, - ipv4_addr, 201, - ipv4_addr, 201, - inst_nic + 1, 201); - - inst_pdcp_list[inst_nic] = ueid; + uint16_t inst_nic = (pdn->ip_addr[3] & 0x000000FF) - 2; + res = sprintf(command_line, + "ifconfig %s%d %s netmask %s broadcast %s up && " + "ip rule add from %s/24 table %d && " + "ip rule add to %s/24 table %d && " + "ip route add default dev %s%d table %d", + UE_NAS_USE_TUN?"oaitun_ue":"oip", + inst_nic + 1, ipv4_addr, netmask, broadcast, + ipv4_addr, 201, + ipv4_addr, 201, + UE_NAS_USE_TUN?"oaitun_ue":"oip", + inst_nic + 1, 201); + inst_pdcp_list[inst_nic] = ueid; #else - res = sprintf(command_line, - "ifconfig oip%d %s netmask %s broadcast %s up && " - "ip rule add from %s/32 table %d && " - "ip rule add to %s/32 table %d && " - "ip route add default dev oip%d table %d", - ueid + 1, ipv4_addr, netmask, broadcast, - ipv4_addr, ueid + 201, - ipv4_addr, ueid + 201, - ueid + 1, ueid + 201); + res = sprintf(command_line, + "ifconfig %s%d %s netmask %s broadcast %s up && " + "ip rule add from %s/32 table %d && " + "ip rule add to %s/32 table %d && " + "ip route add default dev %s%d table %d", + UE_NAS_USE_TUN?"oaitun_ue":"oip", + ueid + 1, ipv4_addr, netmask, broadcast, + ipv4_addr, ueid + 201, + ipv4_addr, ueid + 201, + UE_NAS_USE_TUN?"oaitun_ue":"oip", + ueid + 1, ueid + 201); #endif -#endif - } else { - res = sprintf(command_line, - "ifconfig oip%d %s netmask %s broadcast %s up && " - "ip rule add from %s/32 table %d && " - "ip rule add to %s/32 table %d && " - "ip route add default dev oip%d table %d", - ueid + 1, ipv4_addr, netmask, broadcast, - ipv4_addr, ueid + 201, - ipv4_addr, ueid + 201, - ueid + 1, ueid + 201); - } - if ( res<0 ) { + } // PDCP_USE_NETLINK + } else { + res = sprintf(command_line, + "ifconfig %s%d %s netmask %s broadcast %s up && " + "ip rule add from %s/32 table %d && " + "ip rule add to %s/32 table %d && " + "ip route add default dev %s%d table %d", + UE_NAS_USE_TUN?"oaitun_ue":"oip", + ueid + 1, ipv4_addr, netmask, broadcast, + ipv4_addr, ueid + 201, + ipv4_addr, ueid + 201, + UE_NAS_USE_TUN?"oaitun_ue":"oip", + ueid + 1, ueid + 201); + } + + if ( res<0 ) { LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string"); - } - LOG_TRACE(INFO, "ESM-PROC - executing %s ", - command_line); - - /* Calling system() here disrupts UE's realtime processing in some cases. - * This may be because of the call to fork(), which, for some - * unidentified reason, interacts badly with other (realtime) threads. - * background_system() is a replacement mechanism relying on a - * background process that does the system() and reports result to - * the parent process (lte-softmodem, oaisim, ...). The background - * process is created very early in the life of the parent process. - * The processes interact through standard pipes. See - * common/utils/system.c for details. - */ - if (background_system(command_line) != 0) - LOG_TRACE(ERROR, "ESM-PROC - failed command '%s'", command_line); - - break; - - case NET_PDN_TYPE_IPV6: - break; - - default: - break; - } - } - // AssertFatal(0, "Forced stop in NAS UE"); + } + + LOG_TRACE(INFO, "ESM-PROC - executing %s ", + command_line); + + /* Calling system() here disrupts UE's realtime processing in some cases. + * This may be because of the call to fork(), which, for some + * unidentified reason, interacts badly with other (realtime) threads. + * background_system() is a replacement mechanism relying on a + * background process that does the system() and reports result to + * the parent process (lte-softmodem, oaisim, ...). The background + * process is created very early in the life of the parent process. + * The processes interact through standard pipes. See + * common/utils/system.c for details. + */ + if (background_system(command_line) != 0) + LOG_TRACE(ERROR, "ESM-PROC - failed command '%s'", command_line); + + break; + + case NET_PDN_TYPE_IPV6: + break; + + default: + break; + } + } + // AssertFatal(0, "Forced stop in NAS UE"); } /* Return the EPS bearer identity of the default EPS bearer @@ -382,16 +379,13 @@ int esm_ebr_context_create( ** ** ***************************************************************************/ int esm_ebr_context_release(nas_user_t *user, - int ebi, int *pid, int *bid) -{ + int ebi, int *pid, int *bid) { int found = FALSE; esm_pdn_t *pdn = NULL; esm_data_context_t *esm_ctx; esm_ebr_data_t *esm_ebr_data = user->esm_ebr_data; user_api_id_t *user_api_id = user->user_api_id; - LOG_FUNC_IN; - esm_ctx = user->esm_data; if (ebi != ESM_EBI_UNASSIGNED) { @@ -496,7 +490,6 @@ int esm_ebr_context_release(nas_user_t *user, */ for (i = 1; pdn->n_bearers > 0; i++) { if (pdn->bearer[i]) { - LOG_TRACE(WARNING, "ESM-PROC - Release EPS bearer context " "(ebi=%d)", pdn->bearer[i]->ebi); @@ -507,11 +500,9 @@ int esm_ebr_context_release(nas_user_t *user, /* Set the EPS bearer context state to INACTIVE */ esm_ebr_set_status(user_api_id, esm_ebr_data, pdn->bearer[i]->ebi, - ESM_EBR_INACTIVE, TRUE); - + ESM_EBR_INACTIVE, TRUE); /* Release EPS bearer data */ esm_ebr_release(esm_ebr_data, pdn->bearer[i]->ebi); - // esm_ebr_release() /* Release dedicated EPS bearer data */ free(pdn->bearer[i]); @@ -533,7 +524,6 @@ int esm_ebr_context_release(nas_user_t *user, } } - /* 3GPP TS 24.301, section 6.4.4.6 * If the UE locally deactivated all EPS bearer contexts, the UE * shall perform a local detach and enter state EMM-DEREGISTERED. @@ -582,10 +572,8 @@ int esm_ebr_context_release(nas_user_t *user, ** Others: None ** ** ** ***************************************************************************/ -int esm_ebr_context_get_pid(esm_data_t *esm_data, int ebi) -{ +int esm_ebr_context_get_pid(esm_data_t *esm_data, int ebi) { LOG_FUNC_IN; - int pid; for (pid = 0; pid < ESM_DATA_PDN_MAX; pid++) { @@ -633,10 +621,8 @@ int esm_ebr_context_get_pid(esm_data_t *esm_data, int ebi) ***************************************************************************/ int esm_ebr_context_check_tft(esm_data_t *esm_data, int pid, int ebi, const network_tft_t *tft, - esm_ebr_context_tft_t operation) -{ + esm_ebr_context_tft_t operation) { LOG_FUNC_IN; - int rc = RETURNerror; int i; @@ -702,8 +688,7 @@ int esm_ebr_context_check_tft(esm_data_t *esm_data, int pid, int ebi, ** ** ***************************************************************************/ static int _esm_ebr_context_check_identifiers(const network_tft_t *tft1, - const network_tft_t *tft2) -{ + const network_tft_t *tft2) { int i; int j; @@ -744,8 +729,7 @@ static int _esm_ebr_context_check_identifiers(const network_tft_t *tft1, ** ** ***************************************************************************/ static int _esm_ebr_context_check_precedence(const network_tft_t *tft1, - const network_tft_t *tft2) -{ + const network_tft_t *tft2) { int i; int j; diff --git a/openair3/NAS/UE/nas_itti_messaging.c b/openair3/NAS/UE/nas_itti_messaging.c index 0c5a2fec1fa67f828a1b13292d0d1473f1352e33..55566700d7bb513eca99e64c295caa6c46d40672 100644 --- a/openair3/NAS/UE/nas_itti_messaging.c +++ b/openair3/NAS/UE/nas_itti_messaging.c @@ -27,8 +27,9 @@ # define TASK_ORIGIN TASK_NAS_UE + #if (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) ) -static const uint8_t emm_message_ids[] = { +__attribute__ ((unused)) static const uint8_t emm_message_ids[] = { ATTACH_REQUEST, ATTACH_ACCEPT, ATTACH_COMPLETE, @@ -60,7 +61,7 @@ static const uint8_t emm_message_ids[] = { CS_SERVICE_NOTIFICATION, }; -static const uint8_t esm_message_ids[] = { +__attribute__ ((unused)) static const uint8_t esm_message_ids[] = { ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT, diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 3cb7d23467c3622617799de692350efe2eaddde4..4fc2551e15ec4eb5ef6d84d29c9bd88d8c7f5f17 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -19,28 +19,17 @@ * contact@openairinterface.org */ -#if defined(ENABLE_ITTI) # include "intertask_interface.h" # include "create_tasks.h" # include "common/utils/LOG/log.h" # include "targets/RT/USER/lte-softmodem.h" #ifdef OPENAIR2 - #if defined(ENABLE_USE_MME) - #include "sctp_eNB_task.h" - #include "x2ap_eNB.h" - #include "s1ap_eNB.h" - #include "nas_ue_task.h" - #include "udp_eNB_task.h" - #include "gtpv1u_eNB_task.h" - /* temporary warning removale while implementing noS1 */ - /* as config option */ - #else - #ifdef EPC_MODE_ENABLED - #undef EPC_MODE_ENABLED - #endif - #define EPC_MODE_ENABLED 0 - #endif + #include "sctp_eNB_task.h" + #include "x2ap_eNB.h" + #include "s1ap_eNB.h" + #include "udp_eNB_task.h" + #include "gtpv1u_eNB_task.h" #if ENABLE_RAL #include "lteRALue.h" #include "lteRALenb.h" @@ -62,8 +51,6 @@ int create_tasks(uint32_t enb_nb) { } } -# if defined(ENABLE_USE_MME) - if (EPC_MODE_ENABLED) { if (enb_nb > 0) { if (itti_create_task (TASK_X2AP, x2ap_task, NULL) < 0) { @@ -95,8 +82,6 @@ int create_tasks(uint32_t enb_nb) { } } /* if (EPC_MODE_ENABLED) */ -#endif - if (enb_nb > 0) { LOG_I(RRC,"Creating RRC eNB Task\n"); @@ -109,4 +94,4 @@ int create_tasks(uint32_t enb_nb) { itti_wait_ready(0); return 0; } -#endif + diff --git a/targets/COMMON/create_tasks_ue.c b/targets/COMMON/create_tasks_ue.c index 601b342ee88f9d5fec96182c4658fb735eaa9d5a..06f36641e73e695bc015c4fc7068b043e3a55a51 100644 --- a/targets/COMMON/create_tasks_ue.c +++ b/targets/COMMON/create_tasks_ue.c @@ -19,19 +19,16 @@ * contact@openairinterface.org */ -#if defined(ENABLE_ITTI) # include "intertask_interface.h" # include "create_tasks.h" # include "common/utils/LOG/log.h" #ifdef OPENAIR2 - #if defined(ENABLE_USE_MME) - #include "sctp_eNB_task.h" - #include "s1ap_eNB.h" - #include "nas_ue_task.h" - #include "udp_eNB_task.h" - #include "gtpv1u_eNB_task.h" - #endif + #include "sctp_eNB_task.h" + #include "s1ap_eNB.h" + #include "openair3/NAS/UE/nas_ue_task.h" + #include "udp_eNB_task.h" + #include "gtpv1u_eNB_task.h" #if ENABLE_RAL #include "lteRALue.h" #include "lteRALenb.h" @@ -43,24 +40,25 @@ int create_tasks_ue(uint32_t ue_nb) { LOG_D(ENB_APP, "%s(ue_nb:%d)\n", __FUNCTION__, ue_nb); itti_wait_ready(1); -# if defined(ENABLE_USE_MME) + + if (EPC_MODE_ENABLED) { # if defined(NAS_BUILT_IN_UE) - if (ue_nb > 0) { - nas_user_container_t *users = calloc(1, sizeof(*users)); + if (ue_nb > 0) { + nas_user_container_t *users = calloc(1, sizeof(*users)); - if (users == NULL) abort(); + if (users == NULL) abort(); - users->count = ue_nb; + users->count = ue_nb; - if (itti_create_task (TASK_NAS_UE, nas_ue_task, users) < 0) { - LOG_E(NAS, "Create task for NAS UE failed\n"); - return -1; + if (itti_create_task (TASK_NAS_UE, nas_ue_task, users) < 0) { + LOG_E(NAS, "Create task for NAS UE failed\n"); + return -1; + } } - } # endif -# endif + } /* EPC_MODE_ENABLED */ if (ue_nb > 0) { if (itti_create_task (TASK_RRC_UE, rrc_ue_task, NULL) < 0) { @@ -72,4 +70,4 @@ int create_tasks_ue(uint32_t ue_nb) { itti_wait_ready(0); return 0; } -#endif + diff --git a/targets/Makefile.common b/targets/Makefile.common index ac0771770ba8c4737370a8f7670a71be2dc1b01e..ecd5f3821a8e3fabd538948d73b25bee6a6b69df 100644 --- a/targets/Makefile.common +++ b/targets/Makefile.common @@ -45,7 +45,6 @@ ifeq ($(OPENSSL_FOUND), 0) @(warning "openssl library is not installed on your system, openssl lib needed, continuing with security disabled") SECU=0 else -CFLAGS += -DENABLE_SECURITY LIBS += $(OPENSSL_LIBS) $(NETTLE_LIBS) endif endif diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8584fd1d1cbc1ab565c75982e1076a39beba79ee..bcc9e8cfc50f81ad5f4148bc96dbeec471803703 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -80,14 +80,8 @@ #include "UTIL/OTG/otg_extern.h" #endif -#if defined(ENABLE_ITTI) - #if defined(ENABLE_USE_MME) - #include "s1ap_eNB.h" - #ifdef PDCP_USE_NETLINK - #include "SIMULATION/ETH_TRANSPORT/proto.h" - #endif - #endif -#endif +#include "s1ap_eNB.h" +#include "SIMULATION/ETH_TRANSPORT/proto.h" #include "T.h" @@ -104,11 +98,6 @@ struct timing_info_t { // Fix per CC openair rf/if device update // extern openair0_device openair0; - -#if defined(ENABLE_ITTI) - extern volatile int start_eNB; - extern volatile int start_UE; -#endif extern volatile int oai_exit; extern int transmission_mode; @@ -161,16 +150,16 @@ extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name) { start_meas(&softmodem_stats_rxtx_sf); //L1_rxtx_proc_t *L1_proc_tx = &eNB->proc.L1_proc_tx; - // ******************************************************************* - #if defined(PRE_SCD_THREAD) - RU_t *ru = RC.ru[0]; + RU_t *ru = RC.ru[0]; #endif + if (eNB ==NULL) { - LOG_D(PHY,"%s:%d: rxtx invalid argument, eNB pointer is NULL",__FILE__,__LINE__); - return -1; + LOG_D(PHY,"%s:%d: rxtx invalid argument, eNB pointer is NULL",__FILE__,__LINE__); + return -1; } + if (nfapi_mode == 1) { // I am a PNF and I need to let nFAPI know that we have a (sub)frame tick uint16_t frame = proc->frame_rx; @@ -224,42 +213,41 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, 1 ); - #if defined(PRE_SCD_THREAD) - if (nfapi_mode == 2){ - new_dlsch_ue_select_tbl_in_use = dlsch_ue_select_tbl_in_use; - dlsch_ue_select_tbl_in_use = !dlsch_ue_select_tbl_in_use; - -// L2-emulator can work only one eNB. -// memcpy(&pre_scd_eNB_UE_stats,&RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.eNB_UE_stats, sizeof(eNB_UE_STATS)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); -// memcpy(&pre_scd_activeUE, &RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.active, sizeof(boolean_t)*NUMBER_OF_UE_MAX); - memcpy(&pre_scd_eNB_UE_stats,&RC.mac[0]->UE_list.eNB_UE_stats, sizeof(eNB_UE_STATS)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); - memcpy(&pre_scd_activeUE, &RC.mac[0]->UE_list.active, sizeof(boolean_t)*NUMBER_OF_UE_MAX); - - if (pthread_mutex_lock(&ru->proc.mutex_pre_scd)!= 0) { - LOG_E( PHY, "[eNB] error locking proc mutex for eNB pre scd\n"); - exit_fun("error locking mutex_time"); - } - ru->proc.instance_pre_scd++; + if (nfapi_mode == 2) { + new_dlsch_ue_select_tbl_in_use = dlsch_ue_select_tbl_in_use; + dlsch_ue_select_tbl_in_use = !dlsch_ue_select_tbl_in_use; + // L2-emulator can work only one eNB. + // memcpy(&pre_scd_eNB_UE_stats,&RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.eNB_UE_stats, sizeof(eNB_UE_STATS)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); + // memcpy(&pre_scd_activeUE, &RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.active, sizeof(boolean_t)*NUMBER_OF_UE_MAX); + memcpy(&pre_scd_eNB_UE_stats,&RC.mac[0]->UE_list.eNB_UE_stats, sizeof(eNB_UE_STATS)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); + memcpy(&pre_scd_activeUE, &RC.mac[0]->UE_list.active, sizeof(boolean_t)*NUMBER_OF_UE_MAX); + + if (pthread_mutex_lock(&ru->proc.mutex_pre_scd)!= 0) { + LOG_E( PHY, "[eNB] error locking proc mutex for eNB pre scd\n"); + exit_fun("error locking mutex_time"); + } - if (ru->proc.instance_pre_scd == 0) { - if (pthread_cond_signal(&ru->proc.cond_pre_scd) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB pre scd\n" ); - exit_fun( "ERROR pthread_cond_signal cond_pre_scd" ); - } - }else{ - LOG_E( PHY, "[eNB] frame %d subframe %d rxtx busy instance_pre_scd %d\n", - proc->frame_rx,proc->subframe_rx,ru->proc.instance_pre_scd ); - } + ru->proc.instance_pre_scd++; - if (pthread_mutex_unlock(&ru->proc.mutex_pre_scd)!= 0) { - LOG_E( PHY, "[eNB] error unlocking mutex_pre_scd mutex for eNB pre scd\n"); - exit_fun("error unlocking mutex_pre_scd"); + if (ru->proc.instance_pre_scd == 0) { + if (pthread_cond_signal(&ru->proc.cond_pre_scd) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB pre scd\n" ); + exit_fun( "ERROR pthread_cond_signal cond_pre_scd" ); } + } else { + LOG_E( PHY, "[eNB] frame %d subframe %d rxtx busy instance_pre_scd %d\n", + proc->frame_rx,proc->subframe_rx,ru->proc.instance_pre_scd ); } -#endif + if (pthread_mutex_unlock(&ru->proc.mutex_pre_scd)!= 0) { + LOG_E( PHY, "[eNB] error unlocking mutex_pre_scd mutex for eNB pre scd\n"); + exit_fun("error unlocking mutex_pre_scd"); + } + } + +#endif pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.frame = proc->frame_rx; eNB->UL_INFO.subframe = proc->subframe_rx; @@ -324,9 +312,8 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name } -static void* L1_thread_tx(void* param) { - - L1_proc_t *eNB_proc = (L1_proc_t*)param; +static void *L1_thread_tx(void *param) { + L1_proc_t *eNB_proc = (L1_proc_t *)param; L1_rxtx_proc_t *proc = &eNB_proc->L1_proc_tx; PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; char thread_name[100]; @@ -337,7 +324,8 @@ static void* L1_thread_tx(void* param) { while (!oai_exit) { if (wait_on_condition(&proc->mutex,&proc->cond,&proc->instance_cnt,thread_name)<0) break; - if (oai_exit) break; + + if (oai_exit) break; // ***************************************** // TX processing for subframe n+4 @@ -349,8 +337,6 @@ static void* L1_thread_tx(void* param) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_ENB,proc->frame_tx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx); phy_procedures_eNB_TX(eNB, proc, 1); - - pthread_mutex_lock( &proc->mutex ); proc->instance_cnt = -1; @@ -359,6 +345,7 @@ static void* L1_thread_tx(void* param) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); } + pthread_mutex_unlock( &proc->mutex ); wakeup_txfh(proc,eNB); } @@ -372,29 +359,25 @@ static void* L1_thread_tx(void* param) { * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* L1_thread( void* param ) { - +static void *L1_thread( void *param ) { static int eNB_thread_rxtx_status; //L1_proc_t *eNB_proc = (L1_proc_t*)param; L1_rxtx_proc_t *proc; // Working - if(nfapi_mode ==2){ - proc = (L1_rxtx_proc_t*)param; - } - else{ - L1_proc_t *eNB_proc = (L1_proc_t*)param; + if(nfapi_mode ==2) { + proc = (L1_rxtx_proc_t *)param; + } else { + L1_proc_t *eNB_proc = (L1_proc_t *)param; proc = &eNB_proc->L1_proc; } PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; - char thread_name[100]; cpu_set_t cpuset; CPU_ZERO(&cpuset); // set default return value eNB_thread_rxtx_status = 0; - sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.L1_proc == proc ? 0 : 1); thread_top_init(thread_name,1,470000,500000,500000); pthread_setname_np( pthread_self(),"rxtx processing"); @@ -420,10 +403,12 @@ static void* L1_thread( void* param ) { } if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) phy_procedures_eNB_TX(eNB, proc, 1); + if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break; - if (nfapi_mode!=2){ - if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB); - else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) wakeup_txfh(proc,eNB); + + if (nfapi_mode!=2) { + if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB); + else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) wakeup_txfh(proc,eNB); } } // while !oai_exit @@ -433,8 +418,7 @@ static void* L1_thread( void* param ) { return &eNB_thread_rxtx_status; } -void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru) -{ +void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru) { L1_proc_t *proc = &eNB->proc; L1_rxtx_proc_t *L1_proc = &proc->L1_proc; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; @@ -444,7 +428,6 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t if (!oai_exit) { T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); - L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); L1_proc->frame_rx = ru_proc->frame_rx; L1_proc->subframe_rx = ru_proc->subframe_rx; @@ -452,6 +435,7 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t L1_proc->subframe_tx = (L1_proc->subframe_rx + sf_ahead)%10; if (rxtx(eNB,L1_proc,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); + ru_proc->timestamp_tx = L1_proc->timestamp_tx; ru_proc->subframe_tx = L1_proc->subframe_tx; ru_proc->frame_tx = L1_proc->frame_tx; @@ -459,11 +443,8 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t } int wakeup_txfh(L1_rxtx_proc_t *proc,PHY_VARS_eNB *eNB) { - RU_t *ru; RU_proc_t *ru_proc; - - struct timespec wait; wait.tv_sec=0; wait.tv_nsec=5000000L; @@ -472,19 +453,22 @@ int wakeup_txfh(L1_rxtx_proc_t *proc,PHY_VARS_eNB *eNB) { LOG_E(PHY,"Frame %d, subframe %d: TX FH not ready\n", proc->frame_tx, proc->subframe_tx); return(-1); } + pthread_mutex_lock(&eNB->proc.mutex_RU_tx); eNB->proc.RU_mask_tx = 0; pthread_mutex_unlock(&eNB->proc.mutex_RU_tx); + if (release_thread(&proc->mutex_RUs,&proc->instance_cnt_RUs,"wakeup_txfh")<0) return(-1); - for(int i=0; i<eNB->num_RU; i++) - { + for(int i=0; i<eNB->num_RU; i++) { ru = eNB->RU_list[i]; ru_proc = &ru->proc; + if (ru_proc->instance_cnt_eNBs == 0) { LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc->frame_rx, proc->subframe_rx); return(-1); } + if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", ru_proc->subframe_rx&1,ru_proc->instance_cnt_eNBs ); exit_fun( "error locking mutex_eNB" ); @@ -496,14 +480,13 @@ int wakeup_txfh(L1_rxtx_proc_t *proc,PHY_VARS_eNB *eNB) { ru_proc->subframe_tx = proc->subframe_tx; ru_proc->frame_tx = proc->frame_tx; - // the thread can now be woken up if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - + pthread_mutex_unlock( &ru_proc->mutex_eNBs ); } @@ -511,30 +494,24 @@ int wakeup_txfh(L1_rxtx_proc_t *proc,PHY_VARS_eNB *eNB) { } int wakeup_tx(PHY_VARS_eNB *eNB) { - L1_proc_t *proc=&eNB->proc; - L1_rxtx_proc_t *L1_proc_tx = &proc->L1_proc_tx; L1_rxtx_proc_t *L1_proc = &proc->L1_proc; - - struct timespec wait; wait.tv_sec=0; wait.tv_nsec=5000000L; - - + if (pthread_mutex_timedlock(&L1_proc_tx->mutex,&wait) != 0) { LOG_E(PHY, "[SCHED][eNB] ERROR locking mutex for eNB L1_thread_tx\n"); exit_fun("ERROR pthread_lock"); return(-1); } - while(L1_proc_tx->instance_cnt == 0){ + + while(L1_proc_tx->instance_cnt == 0) { pthread_cond_wait(&L1_proc_tx->cond,&L1_proc_tx->mutex); } L1_proc_tx->instance_cnt = 0; - - L1_proc_tx->subframe_rx = L1_proc->subframe_rx; L1_proc_tx->frame_rx = L1_proc->frame_rx; L1_proc_tx->subframe_tx = L1_proc->subframe_tx; @@ -547,18 +524,15 @@ int wakeup_tx(PHY_VARS_eNB *eNB) { exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - + pthread_mutex_unlock( &L1_proc_tx->mutex); return(0); } int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { - L1_proc_t *proc=&eNB->proc; RU_proc_t *ru_proc=&ru->proc; - L1_rxtx_proc_t *L1_proc=&proc->L1_proc; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; int i; struct timespec wait; @@ -586,7 +560,6 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; - if (L1_proc->instance_cnt == 0) { LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",L1_proc->frame_rx,L1_proc->subframe_rx); return(-1); @@ -601,9 +574,8 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { } ++L1_proc->instance_cnt; - - // We have just received and processed the common part of a subframe, say n. - // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired + // We have just received and processed the common part of a subframe, say n. + // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired // transmitted timestamp of the next TX slot (first). // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, // we want to generate subframe (n+sf_ahead), so TS_tx = TX_rx+sf_ahead*samples_per_tti, @@ -626,7 +598,6 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { } void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { - L1_proc_t *proc = &eNB->proc; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; int i; @@ -689,7 +660,6 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { - L1_proc_t *proc = &eNB->proc; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; int i; @@ -761,7 +731,6 @@ static void *eNB_thread_prach( void *param ) { static int eNB_thread_prach_status; PHY_VARS_eNB *eNB= (PHY_VARS_eNB *)param; L1_proc_t *proc = &eNB->proc; - // set default return value eNB_thread_prach_status = 0; thread_top_init("eNB_thread_prach",1,500000,1000000,20000000); @@ -798,7 +767,6 @@ static void *eNB_thread_prach_br( void *param ) { static int eNB_thread_prach_status; PHY_VARS_eNB *eNB= (PHY_VARS_eNB *)param; L1_proc_t *proc = &eNB->proc; - // set default return value eNB_thread_prach_status = 0; thread_top_init("eNB_thread_prach_br",1,500000,1000000,20000000); @@ -879,7 +847,6 @@ void init_eNB_proc(int inst) { LOG_I(PHY,"Initializing eNB processes instance:%d CC_id %d \n",inst,CC_id); #endif proc = &eNB->proc; - L1_proc = &proc->L1_proc; L1_proc_tx = &proc->L1_proc_tx; L1_proc->instance_cnt = -1; @@ -889,14 +856,12 @@ void init_eNB_proc(int inst) { proc->instance_cnt_prach = -1; proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_synch = -1; - proc->CC_id = CC_id; - + proc->CC_id = CC_id; proc->first_rx =1; proc->first_tx =1; proc->RU_mask_tx = (1<<eNB->num_RU)-1; proc->RU_mask =0; proc->RU_mask_prach =0; - pthread_mutex_init( &eNB->UL_INFO_mutex, NULL); pthread_mutex_init( &L1_proc->mutex, NULL); pthread_mutex_init( &L1_proc_tx->mutex, NULL); @@ -906,7 +871,6 @@ void init_eNB_proc(int inst) { pthread_mutex_init( &L1_proc_tx->mutex_RUs, NULL); pthread_cond_init( &L1_proc->cond_RUs, NULL); pthread_cond_init( &L1_proc_tx->cond_RUs, NULL); - pthread_mutex_init( &proc->mutex_prach, NULL); pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_RU,NULL); @@ -959,7 +923,6 @@ void init_eNB_proc(int inst) { #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_create( &proc->pthread_prach_br, attr_prach_br, eNB_thread_prach_br, eNB ); #endif - AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void *)eNB); @@ -1000,7 +963,6 @@ void kill_eNB_proc(int inst) { for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { eNB=RC.eNB[inst][CC_id]; - proc = &eNB->proc; L1_proc = &proc->L1_proc; L1_proc_tx = &proc->L1_proc_tx; @@ -1017,7 +979,6 @@ void kill_eNB_proc(int inst) { L1_proc->instance_cnt = 0; pthread_cond_signal(&L1_proc->cond); pthread_mutex_unlock(&L1_proc->mutex); - pthread_mutex_lock(&L1_proc_tx->mutex); L1_proc_tx->instance_cnt = 0; pthread_cond_signal(&L1_proc_tx->cond); @@ -1047,10 +1008,11 @@ void kill_eNB_proc(int inst) { if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) { LOG_I(PHY, "Joining L1_proc mutex/cond\n"); - pthread_join( L1_proc->pthread, (void**)&status ); + pthread_join( L1_proc->pthread, (void **)&status ); LOG_I(PHY, "Joining L1_proc_tx mutex/cond\n"); - pthread_join( L1_proc_tx->pthread, (void**)&status ); + pthread_join( L1_proc_tx->pthread, (void **)&status ); } + LOG_I(PHY, "Destroying L1_proc mutex/cond\n"); pthread_mutex_destroy( &L1_proc->mutex ); pthread_cond_destroy( &L1_proc->cond ); @@ -1061,7 +1023,6 @@ void kill_eNB_proc(int inst) { pthread_cond_destroy( &L1_proc_tx->cond ); pthread_mutex_destroy( &L1_proc_tx->mutex_RUs ); pthread_cond_destroy( &L1_proc_tx->cond_RUs ); - pthread_attr_destroy(&proc->attr_prach); pthread_attr_destroy(&proc->attr_asynch_rxtx); pthread_attr_destroy(&L1_proc->attr); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 5ac8a77f872f0c84737bb3639b5b5af2f20ccf18..89ca097bb5d67684225a77b197905f43d020b0a5 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -18,7 +18,6 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - /*! \file lte-enb.c * \brief Top-level threads for eNodeB * \author R. Knopp, F. Kaltenberger, Navid Nikaein @@ -82,7 +81,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "enb_config.h" -#include "targets/RT/USER/lte-softmodem.h" +#include "targets/RT/USER/lte-softmodem.h" //#include "PHY/TOOLS/time_meas.h" /* these variables have to be defined before including ENB_APP/enb_paramdef.h */ @@ -93,17 +92,13 @@ static int DEFENBS[] = {0}; #include "common/config/config_userapi.h" #ifndef OPENAIR2 -#include "UTIL/OTG/otg_extern.h" + #include "UTIL/OTG/otg_extern.h" #endif -#if defined(ENABLE_ITTI) -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -#ifdef PDCP_USE_NETLINK -# include "SIMULATION/ETH_TRANSPORT/proto.h" -#endif -# endif -#endif +#include "s1ap_eNB.h" +#include "SIMULATION/ETH_TRANSPORT/proto.h" + + #include "T.h" @@ -118,18 +113,18 @@ extern uint8_t nfapi_mode; extern PARALLEL_CONF_t get_thread_parallel_conf(void); extern WORKER_CONF_t get_thread_worker_conf(void); -extern void phy_init_RU(RU_t*); -extern void phy_free_RU(RU_t*); +extern void phy_init_RU(RU_t *); +extern void phy_free_RU(RU_t *); void stop_RU(int nb_ru); void do_ru_sync(RU_t *ru); void configure_ru(int idx, - void *arg); + void *arg); void configure_rru(int idx, - void *arg); + void *arg); int attach_rru(RU_t *ru); @@ -138,7 +133,7 @@ int connect_rau(RU_t *ru); extern uint16_t sf_ahead; #if defined(PRE_SCD_THREAD) -void init_ru_vnf(void); + void init_ru_vnf(void); #endif @@ -148,74 +143,65 @@ void init_ru_vnf(void); extern void wait_eNBs(void); int attach_rru(RU_t *ru) { - ssize_t msg_len,len; RRU_CONFIG_msg_t rru_config_msg; int received_capabilities=0; - wait_eNBs(); + // Wait for capabilities while (received_capabilities==0) { - - memset((void*)&rru_config_msg,0,sizeof(rru_config_msg)); - rru_config_msg.type = RAU_tick; + memset((void *)&rru_config_msg,0,sizeof(rru_config_msg)); + rru_config_msg.type = RAU_tick; rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE; LOG_I(PHY,"Sending RAU tick to RRU %d\n",ru->idx); AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1), - "RU %d cannot access remote radio\n",ru->idx); - + "RU %d cannot access remote radio\n",ru->idx); msg_len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t); - // wait for answer with timeout + // wait for answer with timeout if ((len = ru->ifdevice.trx_ctlrecv_func(&ru->ifdevice, - &rru_config_msg, - msg_len))<0) { - LOG_I(PHY,"Waiting for RRU %d\n",ru->idx); - } - else if (rru_config_msg.type == RRU_capabilities) { + &rru_config_msg, + msg_len))<0) { + LOG_I(PHY,"Waiting for RRU %d\n",ru->idx); + } else if (rru_config_msg.type == RRU_capabilities) { AssertFatal(rru_config_msg.len==msg_len,"Received capabilities with incorrect length (%d!=%d)\n",(int)rru_config_msg.len,(int)msg_len); LOG_I(PHY,"Received capabilities from RRU %d (len %d/%d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n",ru->idx, - (int)rru_config_msg.len,(int)msg_len, - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->num_bands, - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_pdschReferenceSignalPower[0], - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_rxgain[0], - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_tx[0], - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_rx[0]); + (int)rru_config_msg.len,(int)msg_len, + ((RRU_capabilities_t *)&rru_config_msg.msg[0])->num_bands, + ((RRU_capabilities_t *)&rru_config_msg.msg[0])->max_pdschReferenceSignalPower[0], + ((RRU_capabilities_t *)&rru_config_msg.msg[0])->max_rxgain[0], + ((RRU_capabilities_t *)&rru_config_msg.msg[0])->nb_tx[0], + ((RRU_capabilities_t *)&rru_config_msg.msg[0])->nb_rx[0]); received_capabilities=1; - } - else { - LOG_E(PHY,"Received incorrect message %d from RRU %d\n",rru_config_msg.type,ru->idx); + } else { + LOG_E(PHY,"Received incorrect message %d from RRU %d\n",rru_config_msg.type,ru->idx); } } + configure_ru(ru->idx, - (RRU_capabilities_t *)&rru_config_msg.msg[0]); - + (RRU_capabilities_t *)&rru_config_msg.msg[0]); rru_config_msg.type = RRU_config; rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_config_t); LOG_I(PHY,"Sending Configuration to RRU %d (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n",ru->idx, - ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands, - ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); - - + ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands, + ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1), - "RU %d failed send configuration to remote radio\n",ru->idx); - + "RU %d failed send configuration to remote radio\n",ru->idx); return 0; } int connect_rau(RU_t *ru) { - RRU_CONFIG_msg_t rru_config_msg; - ssize_t msg_len; + ssize_t msg_len; int tick_received = 0; int configuration_received = 0; RRU_capabilities_t *cap; @@ -224,85 +210,86 @@ int connect_rau(RU_t *ru) { // wait for RAU_tick while (tick_received == 0) { - msg_len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE; if ((len = ru->ifdevice.trx_ctlrecv_func(&ru->ifdevice, - &rru_config_msg, - msg_len))<0) { - LOG_I(PHY,"Waiting for RAU\n"); - } - else { + &rru_config_msg, + msg_len))<0) { + LOG_I(PHY,"Waiting for RAU\n"); + } else { if (rru_config_msg.type == RAU_tick) { - LOG_I(PHY,"Tick received from RAU\n"); - tick_received = 1; - } - else LOG_E(PHY,"Received erroneous message (%d)from RAU, expected RAU_tick\n",rru_config_msg.type); + LOG_I(PHY,"Tick received from RAU\n"); + tick_received = 1; + } else LOG_E(PHY,"Received erroneous message (%d)from RAU, expected RAU_tick\n",rru_config_msg.type); } } // send capabilities - - rru_config_msg.type = RRU_capabilities; + rru_config_msg.type = RRU_capabilities; rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t); - cap = (RRU_capabilities_t*)&rru_config_msg.msg[0]; + cap = (RRU_capabilities_t *)&rru_config_msg.msg[0]; LOG_I(PHY,"Sending Capabilities (len %d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n", - (int)rru_config_msg.len,ru->num_bands,ru->max_pdschReferenceSignalPower,ru->max_rxgain,ru->nb_tx,ru->nb_rx); + (int)rru_config_msg.len,ru->num_bands,ru->max_pdschReferenceSignalPower,ru->max_rxgain,ru->nb_tx,ru->nb_rx); + switch (ru->function) { - case NGFI_RRU_IF4p5: - cap->FH_fmt = OAI_IF4p5_only; - break; - case NGFI_RRU_IF5: - cap->FH_fmt = OAI_IF5_only; - break; - case MBP_RRU_IF5: - cap->FH_fmt = MBP_IF5; - break; - default: - AssertFatal(1==0,"RU_function is unknown %d\n",RC.ru[0]->function); - break; + case NGFI_RRU_IF4p5: + cap->FH_fmt = OAI_IF4p5_only; + break; + + case NGFI_RRU_IF5: + cap->FH_fmt = OAI_IF5_only; + break; + + case MBP_RRU_IF5: + cap->FH_fmt = MBP_IF5; + break; + + default: + AssertFatal(1==0,"RU_function is unknown %d\n",RC.ru[0]->function); + break; } + cap->num_bands = ru->num_bands; - for (i=0;i<ru->num_bands;i++) { - LOG_I(PHY,"Band %d: nb_rx %d nb_tx %d pdschReferenceSignalPower %d rxgain %d\n", - ru->band[i],ru->nb_rx,ru->nb_tx,ru->max_pdschReferenceSignalPower,ru->max_rxgain); + + for (i=0; i<ru->num_bands; i++) { + LOG_I(PHY,"Band %d: nb_rx %d nb_tx %d pdschReferenceSignalPower %d rxgain %d\n", + ru->band[i],ru->nb_rx,ru->nb_tx,ru->max_pdschReferenceSignalPower,ru->max_rxgain); cap->band_list[i] = ru->band[i]; cap->nb_rx[i] = ru->nb_rx; cap->nb_tx[i] = ru->nb_tx; cap->max_pdschReferenceSignalPower[i] = ru->max_pdschReferenceSignalPower; cap->max_rxgain[i] = ru->max_rxgain; } - AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1), - "RU %d failed send capabilities to RAU\n",ru->idx); + AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1), + "RU %d failed send capabilities to RAU\n",ru->idx); // wait for configuration rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_config_t); - while (configuration_received == 0) { + while (configuration_received == 0) { if ((len = ru->ifdevice.trx_ctlrecv_func(&ru->ifdevice, - &rru_config_msg, - rru_config_msg.len))<0) { - LOG_I(PHY,"Waiting for configuration from RAU\n"); - } - else { + &rru_config_msg, + rru_config_msg.len))<0) { + LOG_I(PHY,"Waiting for configuration from RAU\n"); + } else { LOG_I(PHY,"Configuration received from RAU (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n", - ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands, - ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); - + ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands, + ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); configure_rru(ru->idx, - (void*)&rru_config_msg.msg[0]); + (void *)&rru_config_msg.msg[0]); configuration_received = 1; } } + return 0; } /*************************************************************/ @@ -311,43 +298,44 @@ int connect_rau(RU_t *ru) { // southbound IF5 fronthaul for 16-bit OAI format static inline void fh_if5_south_out(RU_t *ru) { if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); + send_IF5(ru, ru->proc.timestamp_tx, ru->proc.subframe_tx, &ru->seqno, IF5_RRH_GW_DL); } // southbound IF5 fronthaul for Mobipass packet format static inline void fh_if5_mobipass_south_out(RU_t *ru) { if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); - send_IF5(ru, ru->proc.timestamp_tx, ru->proc.subframe_tx, &ru->seqno, IF5_MOBIPASS); + + send_IF5(ru, ru->proc.timestamp_tx, ru->proc.subframe_tx, &ru->seqno, IF5_MOBIPASS); } // southbound IF4p5 fronthaul static inline void fh_if4p5_south_out(RU_t *ru) { if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); + LOG_D(PHY,"Sending IF4p5 for frame %d subframe %d\n",ru->proc.frame_tx,ru->proc.subframe_tx); - if (subframe_select(&ru->frame_parms,ru->proc.subframe_tx)!=SF_UL) + + if (subframe_select(&ru->frame_parms,ru->proc.subframe_tx)!=SF_UL) send_IF4p5(ru,ru->proc.frame_tx, ru->proc.subframe_tx, IF4p5_PDLFFT); } /*************************************************************/ /* Input Fronthaul from south RCC/RAU */ -// Synchronous if5 from south +// Synchronous if5 from south void fh_if5_south_in(RU_t *ru,int *frame, int *subframe) { - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; RU_proc_t *proc = &ru->proc; - - recv_IF5(ru, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); - + recv_IF5(ru, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; - + if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ + if (proc->subframe_rx != *subframe) { LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe); exit_fun("Exiting"); } - + if (proc->frame_rx != *frame) { LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame); exit_fun("Exiting"); @@ -355,45 +343,44 @@ void fh_if5_south_in(RU_t *ru,int *frame, int *subframe) { } else { proc->first_rx = 0; *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - } - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + *subframe = proc->subframe_rx; + } + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); } -// Synchronous if4p5 from south +// Synchronous if4p5 from south void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; RU_proc_t *proc = &ru->proc; int f,sf; - - uint16_t packet_type; uint32_t symbol_number=0; uint32_t symbol_mask_full; - if ((fp->frame_type == TDD) && (subframe_select(fp,*subframe)==SF_S)) - symbol_mask_full = (1<<fp->ul_symbols_in_S_subframe)-1; - else - symbol_mask_full = (1<<fp->symbols_per_tti)-1; + if ((fp->frame_type == TDD) && (subframe_select(fp,*subframe)==SF_S)) + symbol_mask_full = (1<<fp->ul_symbols_in_S_subframe)-1; + else + symbol_mask_full = (1<<fp->symbols_per_tti)-1; AssertFatal(proc->symbol_mask[*subframe]==0,"rx_fh_if4p5: proc->symbol_mask[%d] = %x\n",*subframe,proc->symbol_mask[*subframe]); + do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! recv_IF4p5(ru, &f, &sf, &packet_type, &symbol_number); if (packet_type == IF4p5_PULFFT) proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<<symbol_number); - else if (packet_type == IF4p5_PULTICK) { - if ((proc->first_rx==0) && (f!=*frame)) LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d\n",f,*frame); - if ((proc->first_rx==0) && (sf!=*subframe)) LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx); - break; - + else if (packet_type == IF4p5_PULTICK) { + if ((proc->first_rx==0) && (f!=*frame)) LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d\n",f,*frame); + + if ((proc->first_rx==0) && (sf!=*subframe)) LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx); + + break; } else if (packet_type == IF4p5_PRACH) { // nothing in RU for RAU } + LOG_D(PHY,"rx_fh_if4p5: subframe %d symbol mask %x\n",*subframe,proc->symbol_mask[*subframe]); - } while(proc->symbol_mask[*subframe] != symbol_mask_full); + } while(proc->symbol_mask[*subframe] != symbol_mask_full); //caculate timestamp_rx, timestamp_tx based on frame and subframe proc->subframe_rx = sf; @@ -402,12 +389,13 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) { // proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); proc->subframe_tx = (sf+sf_ahead)%10; proc->frame_tx = (sf>(9-sf_ahead)) ? (f+1)&1023 : f; - + if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ + if (proc->subframe_rx != *subframe) { LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe); exit_fun("Exiting"); } + if (proc->frame_rx != *frame) { LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame); exit_fun("Exiting"); @@ -415,7 +403,7 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) { } else { proc->first_rx = 0; *frame = proc->frame_rx; - *subframe = proc->subframe_rx; + *subframe = proc->subframe_rx; } if (ru == RC.ru[0]) { @@ -425,7 +413,7 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx ); } - proc->symbol_mask[sf] = 0; + proc->symbol_mask[sf] = 0; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); LOG_D(PHY,"RU %d: fh_if4p5_south_in sleeping ...\n",ru->idx); usleep(100); @@ -441,99 +429,95 @@ void fh_slave_south_in(RU_t *ru,int *frame,int *subframe) { return; release_thread(&proc->mutex_FH,&proc->instance_cnt_FH,"rx_fh_slave_south_in"); - - } // asynchronous inbound if5 fronthaul from south (Mobipass) void fh_if5_south_asynch_in_mobipass(RU_t *ru,int *frame,int *subframe) { - RU_proc_t *proc = &ru->proc; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; - - recv_IF5(ru, &proc->timestamp_rx, *subframe, IF5_MOBIPASS); + recv_IF5(ru, &proc->timestamp_rx, *subframe, IF5_MOBIPASS); pthread_mutex_lock(&proc->mutex_asynch_rxtx); int offset_mobipass = 40120; pthread_mutex_lock(&proc->mutex_asynch_rxtx); proc->subframe_rx = ((proc->timestamp_rx-offset_mobipass)/fp->samples_per_tti)%10; proc->frame_rx = ((proc->timestamp_rx-offset_mobipass)/(fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx/fp->samples_per_tti)%10; proc->frame_rx = (proc->timestamp_rx/(10*fp->samples_per_tti))&1023; if (proc->first_rx == 1) { proc->first_rx =2; *subframe = proc->subframe_rx; - *frame = proc->frame_rx; + *frame = proc->frame_rx; LOG_E(PHY,"[Mobipass]timestamp_rx:%llu, frame_rx %d, subframe: %d\n",(unsigned long long int)proc->timestamp_rx,proc->frame_rx,proc->subframe_rx); - } - else { + } else { if (proc->subframe_rx != *subframe) { - proc->first_rx++; - LOG_E(PHY,"[Mobipass]timestamp:%llu, subframe_rx %d is not what we expect %d, first_rx:%d\n",(unsigned long long int)proc->timestamp_rx, proc->subframe_rx,*subframe, proc->first_rx); + proc->first_rx++; + LOG_E(PHY,"[Mobipass]timestamp:%llu, subframe_rx %d is not what we expect %d, first_rx:%d\n",(unsigned long long int)proc->timestamp_rx, proc->subframe_rx,*subframe, proc->first_rx); //exit_fun("Exiting"); } + if (proc->frame_rx != *frame) { - proc->first_rx++; - LOG_E(PHY,"[Mobipass]timestamp:%llu, frame_rx %d is not what we expect %d, first_rx:%d\n",(unsigned long long int)proc->timestamp_rx,proc->frame_rx,*frame, proc->first_rx); - // exit_fun("Exiting"); + proc->first_rx++; + LOG_E(PHY,"[Mobipass]timestamp:%llu, frame_rx %d is not what we expect %d, first_rx:%d\n",(unsigned long long int)proc->timestamp_rx,proc->frame_rx,*frame, proc->first_rx); + // exit_fun("Exiting"); } + // temporary solution - *subframe = proc->subframe_rx; - *frame = proc->frame_rx; + *subframe = proc->subframe_rx; + *frame = proc->frame_rx; } pthread_mutex_unlock(&proc->mutex_asynch_rxtx); - - -} // eNodeB_3GPP_BBU +} // eNodeB_3GPP_BBU // asynchronous inbound if4p5 fronthaul from south void fh_if4p5_south_asynch_in(RU_t *ru,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; RU_proc_t *proc = &ru->proc; - uint16_t packet_type; uint32_t symbol_number,symbol_mask,prach_rx; uint32_t got_prach_info=0; - symbol_number = 0; symbol_mask = (1<<fp->symbols_per_tti)-1; prach_rx = 0; do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! recv_IF4p5(ru, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number); + // grab first prach information for this new subframe if (got_prach_info==0) { prach_rx = is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx); got_prach_info = 1; } + if (proc->first_rx != 0) { *frame = proc->frame_rx; *subframe = proc->subframe_rx; proc->first_rx = 0; - } - else { + } else { if (proc->frame_rx != *frame) { - LOG_E(PHY,"frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame); - exit_fun("Exiting"); + LOG_E(PHY,"frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame); + exit_fun("Exiting"); } + if (proc->subframe_rx != *subframe) { - LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); - exit_fun("Exiting"); + LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); + exit_fun("Exiting"); } } + if (packet_type == IF4p5_PULFFT) symbol_mask &= (~(1<<symbol_number)); else if (packet_type == IF4p5_PRACH) prach_rx &= (~0x1); + #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) else if (packet_type == IF4p5_PRACH_BR_CE0) prach_rx &= (~0x2); else if (packet_type == IF4p5_PRACH_BR_CE1) prach_rx &= (~0x4); else if (packet_type == IF4p5_PRACH_BR_CE2) prach_rx &= (~0x8); else if (packet_type == IF4p5_PRACH_BR_CE3) prach_rx &= (~0x10); + #endif - } while( (symbol_mask > 0) || (prach_rx >0)); // haven't received all PUSCH symbols and PRACH information -} + } while( (symbol_mask > 0) || (prach_rx >0)); // haven't received all PUSCH symbols and PRACH information +} @@ -541,25 +525,22 @@ void fh_if4p5_south_asynch_in(RU_t *ru,int *frame,int *subframe) { /*************************************************************/ /* Input Fronthaul from North RRU */ - -// RRU IF4p5 TX fronthaul receiver. Assumes an if_device on input and if or rf device on output + +// RRU IF4p5 TX fronthaul receiver. Assumes an if_device on input and if or rf device on output // receives one subframe's worth of IF4p5 OFDM symbols and OFDM modulates void fh_if4p5_north_in(RU_t *ru,int *frame,int *subframe) { - uint32_t symbol_number=0; uint32_t symbol_mask, symbol_mask_full; uint16_t packet_type; - - - /// **** incoming IF4p5 from remote RCC/RAU **** /// + /// **** incoming IF4p5 from remote RCC/RAU **** /// symbol_number = 0; symbol_mask = 0; symbol_mask_full = (1<<ru->frame_parms.symbols_per_tti)-1; - - do { + + do { recv_IF4p5(ru, frame, subframe, &packet_type, &symbol_number); symbol_mask = symbol_mask | (1<<symbol_number); - } while (symbol_mask != symbol_mask_full); + } while (symbol_mask != symbol_mask_full); // dump VCD output for first RU in list if (ru == RC.ru[0]) { @@ -569,15 +550,12 @@ void fh_if4p5_north_in(RU_t *ru,int *frame,int *subframe) { } void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; RU_proc_t *proc = &ru->proc; int subframe_tx,frame_tx; openair0_timestamp timestamp_tx; - - recv_IF5(ru, ×tamp_tx, *subframe, IF5_RRH_GW_DL); - // printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx); - + recv_IF5(ru, ×tamp_tx, *subframe, IF5_RRH_GW_DL); + // printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx); subframe_tx = (timestamp_tx/fp->samples_per_tti)%10; frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023; @@ -585,50 +563,49 @@ void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { *subframe = subframe_tx; *frame = frame_tx; proc->first_tx = 0; - } - else { + } else { AssertFatal(subframe_tx == *subframe, "subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); - AssertFatal(frame_tx == *frame, + AssertFatal(frame_tx == *frame, "frame_tx %d is not what we expect %d\n",frame_tx,*frame); } } void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; RU_proc_t *proc = &ru->proc; - uint16_t packet_type; uint32_t symbol_number,symbol_mask,symbol_mask_full; int subframe_tx,frame_tx; - LOG_D(PHY, "%s(ru:%p frame, subframe)\n", __FUNCTION__, ru); symbol_number = 0; symbol_mask = 0; symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1; - do { + + do { recv_IF4p5(ru, &frame_tx, &subframe_tx, &packet_type, &symbol_number); + if ((subframe_select(fp,subframe_tx) == SF_DL) && (symbol_number == 0)) start_meas(&ru->rx_fhaul); + LOG_D(PHY,"subframe %d (%d): frame %d, subframe %d, symbol %d\n", - *subframe,subframe_select(fp,*subframe),frame_tx,subframe_tx,symbol_number); + *subframe,subframe_select(fp,*subframe),frame_tx,subframe_tx,symbol_number); + if (proc->first_tx != 0) { *frame = frame_tx; *subframe = subframe_tx; proc->first_tx = 0; symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1; - } - else { + } else { AssertFatal(frame_tx == *frame, - "frame_tx %d is not what we expect %d\n",frame_tx,*frame); + "frame_tx %d is not what we expect %d\n",frame_tx,*frame); AssertFatal(subframe_tx == *subframe, - "subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); + "subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); } + if (packet_type == IF4p5_PDLFFT) { symbol_mask = symbol_mask | (1<<symbol_number); - } - else AssertFatal(1==0,"Illegal IF4p5 packet type (should only be IF4p5_PDLFFT%d\n",packet_type); - } while (symbol_mask != symbol_mask_full); + } else AssertFatal(1==0,"Illegal IF4p5 packet type (should only be IF4p5_PDLFFT%d\n",packet_type); + } while (symbol_mask != symbol_mask_full); if (subframe_select(fp,subframe_tx) == SF_DL) stop_meas(&ru->rx_fhaul); @@ -638,36 +615,34 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { if ((frame_tx == 0)&&(subframe_tx == 0)) proc->frame_tx_unwrap += 1024; proc->timestamp_tx = ((((uint64_t)frame_tx + (uint64_t)proc->frame_tx_unwrap) * 10) + (uint64_t)subframe_tx) * (uint64_t)fp->samples_per_tti; - LOG_D(PHY,"RU %d/%d TST %llu, frame %d, subframe %d\n",ru->idx,0,(long long unsigned int)proc->timestamp_tx,frame_tx,subframe_tx); - // dump VCD output for first RU in list + + // dump VCD output for first RU in list if (ru == RC.ru[0]) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, subframe_tx ); } if (ru->feptx_ofdm) ru->feptx_ofdm(ru); + if (ru->fh_south_out) ru->fh_south_out(ru); -} +} void fh_if5_north_out(RU_t *ru) { - RU_proc_t *proc=&ru->proc; uint8_t seqno=0; - - /// **** send_IF5 of rxdata to BBU **** /// - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 1 ); + /// **** send_IF5 of rxdata to BBU **** /// + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 1 ); send_IF5(ru, proc->timestamp_rx, proc->subframe_rx, &seqno, IF5_RRH_GW_UL); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 0 ); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5, 0 ); } // RRU IF4p5 northbound interface (RX) void fh_if4p5_north_out(RU_t *ru) { - RU_proc_t *proc=&ru->proc; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; const int subframe = proc->subframe_rx; + if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_RU, proc->subframe_rx ); if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) { @@ -679,23 +654,22 @@ void fh_if4p5_north_out(RU_t *ru) { start_meas(&ru->tx_fhaul); send_IF4p5(ru, proc->frame_rx, proc->subframe_rx, IF4p5_PULFFT); stop_meas(&ru->tx_fhaul); - } /* add fail safe for late command */ typedef enum { - STATE_BURST_NORMAL = 0, - STATE_BURST_TERMINATE = 1, - STATE_BURST_STOP_1 = 2, - STATE_BURST_STOP_2 = 3, - STATE_BURST_RESTART = 4, + STATE_BURST_NORMAL = 0, + STATE_BURST_TERMINATE = 1, + STATE_BURST_STOP_1 = 2, + STATE_BURST_STOP_2 = 3, + STATE_BURST_RESTART = 4, } late_control_e; volatile late_control_e late_control=STATE_BURST_NORMAL; /* add fail safe for late command end */ -static void* emulatedRF_thread(void* param) { +static void *emulatedRF_thread(void *param) { RU_proc_t *proc = (RU_proc_t *) param; int microsec = 500; // length of time to sleep, in miliseconds struct timespec req = {0}; @@ -705,65 +679,63 @@ static void* emulatedRF_thread(void* param) { cpu_set_t cpuset; CPU_SET(1,&cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - int policy; struct sched_param sparam; memset(&sparam, 0, sizeof(sparam)); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); - policy = SCHED_FIFO ; + policy = SCHED_FIFO ; pthread_setschedparam(pthread_self(), policy, &sparam); - wait_sync("emulatedRF_thread"); - while(!oai_exit){ + + while(!oai_exit) { nanosleep(&req, (struct timespec *)NULL); - if(proc->emulate_rf_busy ) - { + + if(proc->emulate_rf_busy ) { LOG_E(PHY,"rf being delayed in emulated RF\n"); } + proc->emulate_rf_busy = 1; pthread_mutex_lock(&proc->mutex_emulateRF); ++proc->instance_cnt_emulateRF; pthread_mutex_unlock(&proc->mutex_emulateRF); pthread_cond_signal(&proc->cond_emulateRF); } + return 0; } void rx_rf(RU_t *ru,int *frame,int *subframe) { - RU_proc_t *proc = &ru->proc; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; void *rxp[ru->nb_rx]; unsigned int rxs; int i; openair0_timestamp ts=0,old_ts=0; - + for (i=0; i<ru->nb_rx; i++) - rxp[i] = (void*)&ru->common.rxdata[i][*subframe*fp->samples_per_tti]; + rxp[i] = (void *)&ru->common.rxdata[i][*subframe*fp->samples_per_tti]; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); - old_ts = proc->timestamp_rx; - if(get_softmodem_params()->emulate_rf){ + + if(get_softmodem_params()->emulate_rf) { wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); rxs = fp->samples_per_tti; - } - else{ + } else { rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, - &ts, - rxp, - fp->samples_per_tti, - ru->nb_rx); + &ts, + rxp, + fp->samples_per_tti, + ru->nb_rx); } - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - proc->timestamp_rx = ts-ru->ts_offset; -// AssertFatal(rxs == fp->samples_per_tti, -// "rx_rf: Asked for %d samples, got %d from SDR\n",fp->samples_per_tti,rxs); - if(rxs != fp->samples_per_tti){ + // AssertFatal(rxs == fp->samples_per_tti, + // "rx_rf: Asked for %d samples, got %d from SDR\n",fp->samples_per_tti,rxs); + if(rxs != fp->samples_per_tti) { LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from SDR\n",fp->samples_per_tti,rxs); late_control=STATE_BURST_TERMINATE; } @@ -771,51 +743,47 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { if (proc->first_rx == 1) { ru->ts_offset = proc->timestamp_rx; proc->timestamp_rx = 0; - } - else { + } else { if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { //LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset); ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); proc->timestamp_rx = ts-ru->ts_offset; } - } + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; // synchronize first reception to frame 0 subframe 0 - #ifdef PHY_TX_THREAD proc->timestamp_phy_tx = proc->timestamp_rx+((sf_ahead-1)*fp->samples_per_tti); - proc->subframe_phy_tx = (proc->subframe_rx+(sf_ahead-1))%10; + proc->subframe_phy_tx = (proc->subframe_rx+(sf_ahead-1))%10; proc->frame_phy_tx = (proc->subframe_rx>(9-(sf_ahead-1))) ? (proc->frame_rx+1)&1023 : proc->frame_rx; #else proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti); proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10; proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx; #endif - //proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti); //proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10; //proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx; - LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, subframe %d\n", - ru->idx, - 0, - (unsigned long long int)proc->timestamp_rx, - (int)ru->ts_offset,proc->frame_rx,proc->subframe_rx); + ru->idx, + 0, + (unsigned long long int)proc->timestamp_rx, + (int)ru->ts_offset,proc->frame_rx,proc->subframe_rx); - // dump VCD output for first RU in list + // dump VCD output for first RU in list if (ru == RC.ru[0]) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, proc->frame_rx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_RU, proc->subframe_rx ); } - + if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ + if (proc->subframe_rx != *subframe) { LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",(long long unsigned int)proc->timestamp_rx,proc->subframe_rx,*subframe); exit_fun("Exiting"); } - + if (proc->frame_rx != *frame) { LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",(long long unsigned int)proc->timestamp_rx,proc->frame_rx,*frame); exit_fun("Exiting"); @@ -823,36 +791,31 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { } else { proc->first_rx = 0; *frame = proc->frame_rx; - *subframe = proc->subframe_rx; + *subframe = proc->subframe_rx; } - + //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",ru->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); - - if (rxs != fp->samples_per_tti) - { + + if (rxs != fp->samples_per_tti) { #if defined(USRP_REC_PLAY) exit_fun("Exiting IQ record/playback"); -#else +#else //exit_fun( "problem receiving samples" ); LOG_E(PHY, "problem receiving samples"); -#endif +#endif } } void tx_rf(RU_t *ru) { - RU_proc_t *proc = &ru->proc; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; - void *txp[ru->nb_tx]; + void *txp[ru->nb_tx]; unsigned int txs; int i; - T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(proc->frame_tx), T_INT(proc->subframe_tx), T_INT(0), T_BUFFER(&ru->common.txdata[0][proc->subframe_tx * fp->samples_per_tti], fp->samples_per_tti * 4)); - lte_subframe_t SF_type = subframe_select(fp,proc->subframe_tx%10); lte_subframe_t prevSF_type = subframe_select(fp,(proc->subframe_tx+9)%10); lte_subframe_t nextSF_type = subframe_select(fp,(proc->subframe_tx+1)%10); @@ -860,93 +823,91 @@ void tx_rf(RU_t *ru) { if ((SF_type == SF_DL) || (SF_type == SF_S)) { - int siglen=fp->samples_per_tti,flags=1; - + if (SF_type == SF_S) { siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0); flags=3; // end of burst } + if ((fp->frame_type == TDD) && - (SF_type == SF_DL)&& - (prevSF_type == SF_UL) && - (nextSF_type == SF_DL)) { + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_DL)) { flags = 2; // start of burst sf_extension = ru->N_TA_offset; } - + if ((fp->frame_type == TDD) && - (SF_type == SF_DL)&& - (prevSF_type == SF_UL) && - (nextSF_type == SF_UL)) { + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_UL)) { flags = 4; // start of burst and end of burst (only one DL SF between two UL) sf_extension = ru->N_TA_offset; - } + } + #if defined(__x86_64) || defined(__i386__) #ifdef __AVX2__ - sf_extension = (sf_extension)&0xfffffff8; + sf_extension = (sf_extension)&0xfffffff8; #else - sf_extension = (sf_extension)&0xfffffffc; + sf_extension = (sf_extension)&0xfffffffc; #endif #elif defined(__arm__) - sf_extension = (sf_extension)&0xfffffffc; + sf_extension = (sf_extension)&0xfffffffc; #endif - + for (i=0; i<ru->nb_tx; i++) - txp[i] = (void*)&ru->common.txdata[i][(proc->subframe_tx*fp->samples_per_tti)-sf_extension]; + txp[i] = (void *)&ru->common.txdata[i][(proc->subframe_tx*fp->samples_per_tti)-sf_extension]; /* add fail safe for late command */ - if(late_control!=STATE_BURST_NORMAL){//stop burst + if(late_control!=STATE_BURST_NORMAL) { //stop burst switch (late_control) { - case STATE_BURST_TERMINATE: - flags=10; // end of burst and no time spec - late_control=STATE_BURST_STOP_1; - break; - - case STATE_BURST_STOP_1: - flags=0; // no send - late_control=STATE_BURST_STOP_2; - return;//no send - break; - - case STATE_BURST_STOP_2: - flags=0; // no send - late_control=STATE_BURST_RESTART; - return;//no send - break; - - case STATE_BURST_RESTART: - flags=2; // start burst - late_control=STATE_BURST_NORMAL; - break; - default: - LOG_D(PHY,"[TXPATH] RU %d late_control %d not implemented\n",ru->idx, late_control); - break; + case STATE_BURST_TERMINATE: + flags=10; // end of burst and no time spec + late_control=STATE_BURST_STOP_1; + break; + + case STATE_BURST_STOP_1: + flags=0; // no send + late_control=STATE_BURST_STOP_2; + return;//no send + break; + + case STATE_BURST_STOP_2: + flags=0; // no send + late_control=STATE_BURST_RESTART; + return;//no send + break; + + case STATE_BURST_RESTART: + flags=2; // start burst + late_control=STATE_BURST_NORMAL; + break; + + default: + LOG_D(PHY,"[TXPATH] RU %d late_control %d not implemented\n",ru->idx, late_control); + break; } } - /* add fail safe for late command end */ + /* add fail safe for late command end */ VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); // prepare tx buffer pointers - txs = ru->rfdevice.trx_write_func(&ru->rfdevice, - proc->timestamp_tx+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, - txp, - siglen+sf_extension, - ru->nb_tx, - flags); - + proc->timestamp_tx+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, + txp, + siglen+sf_extension, + ru->nb_tx, + flags); LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n",ru->idx, - (long long unsigned int)proc->timestamp_tx,proc->frame_tx,proc->frame_tx_unwrap,proc->subframe_tx); + (long long unsigned int)proc->timestamp_tx,proc->frame_tx,proc->frame_tx_unwrap,proc->subframe_tx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - - -// AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); - if( (txs != siglen+sf_extension) && (late_control==STATE_BURST_NORMAL) ){ /* add fail safe for late command */ + + // AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); + if( (txs != siglen+sf_extension) && (late_control==STATE_BURST_NORMAL) ) { /* add fail safe for late command */ late_control=STATE_BURST_TERMINATE; LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control); } @@ -960,51 +921,39 @@ void tx_rf(RU_t *ru) { * \param param is a \ref L1_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* ru_thread_asynch_rxtx( void* param ) { - +static void *ru_thread_asynch_rxtx( void *param ) { static int ru_thread_asynch_rxtx_status; - - RU_t *ru = (RU_t*)param; + RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; - - - - int subframe=0, frame=0; - + int subframe=0, frame=0; thread_top_init("ru_thread_asynch_rxtx",1,870000,1000000,1000000); - // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe - wait_sync("ru_thread_asynch_rxtx"); - // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe printf( "waiting for devices (ru_thread_asynch_rx)\n"); - wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch"); - printf( "devices ok (ru_thread_asynch_rx)\n"); + while (!oai_exit) { + if (oai_exit) break; - while (!oai_exit) { - - if (oai_exit) break; - - if (subframe==9) { + if (subframe==9) { subframe=0; frame++; frame&=1023; } else { subframe++; - } + } + LOG_D(PHY,"ru_thread_asynch_rxtx: Waiting on incoming fronthaul\n"); - // asynchronous receive from south (Mobipass) + + // asynchronous receive from south (Mobipass) if (ru->fh_south_asynch_in) ru->fh_south_asynch_in(ru,&frame,&subframe); // asynchronous receive from north (RRU IF4/IF5) else if (ru->fh_north_asynch_in) { - if (subframe_select(&ru->frame_parms,subframe)!=SF_UL) - ru->fh_north_asynch_in(ru,&frame,&subframe); - } - else AssertFatal(1==0,"Unknown function in ru_thread_asynch_rxtx\n"); + if (subframe_select(&ru->frame_parms,subframe)!=SF_UL) + ru->fh_north_asynch_in(ru,&frame,&subframe); + } else AssertFatal(1==0,"Unknown function in ru_thread_asynch_rxtx\n"); } ru_thread_asynch_rxtx_status=0; @@ -1015,15 +964,14 @@ static void* ru_thread_asynch_rxtx( void* param ) { void wakeup_slaves(RU_proc_t *proc) { - int i; struct timespec wait; - wait.tv_sec=0; wait.tv_nsec=5000000L; - - for (i=0;i<proc->num_slaves;i++) { + + for (i=0; i<proc->num_slaves; i++) { RU_proc_t *slave_proc = proc->slave_proc[i]; + // wake up slave FH thread // lock the FH mutex and make sure the thread is ready if (pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait) != 0) { @@ -1031,27 +979,26 @@ void wakeup_slaves(RU_proc_t *proc) { exit_fun( "error locking mutex_rxtx" ); break; } - + int cnt_slave = ++slave_proc->instance_cnt_FH; slave_proc->frame_rx = proc->frame_rx; slave_proc->subframe_rx = proc->subframe_rx; slave_proc->timestamp_rx = proc->timestamp_rx; - slave_proc->timestamp_tx = proc->timestamp_tx; - + slave_proc->timestamp_tx = proc->timestamp_tx; pthread_mutex_unlock( &slave_proc->mutex_FH ); - + if (cnt_slave == 0) { // the thread was presumably waiting where it should and can now be woken up if (pthread_cond_signal(&slave_proc->cond_FH) != 0) { - LOG_E( PHY, "ERROR pthread_cond_signal for RU %d, slave RU %d\n",proc->ru->idx,slave_proc->ru->idx); - exit_fun( "ERROR pthread_cond_signal" ); - break; + LOG_E( PHY, "ERROR pthread_cond_signal for RU %d, slave RU %d\n",proc->ru->idx,slave_proc->ru->idx); + exit_fun( "ERROR pthread_cond_signal" ); + break; } } else { LOG_W( PHY,"[RU] Frame %d, slave %d thread busy!! (cnt_FH %i)\n",slave_proc->frame_rx,slave_proc->ru->idx, cnt_slave); exit_fun( "FH thread busy" ); break; - } + } } } @@ -1060,16 +1007,12 @@ void wakeup_slaves(RU_proc_t *proc) { * \param param is a \ref RU_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* ru_thread_prach( void* param ) { - +static void *ru_thread_prach( void *param ) { static int ru_thread_prach_status; - - RU_t *ru = (RU_t*)param; - RU_proc_t *proc = (RU_proc_t*)&ru->proc; - + RU_t *ru = (RU_t *)param; + RU_proc_t *proc = (RU_proc_t *)&ru->proc; // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach",1,500000,1000000,20000000); //wait_sync("ru_thread_prach"); @@ -1077,84 +1020,82 @@ static void* ru_thread_prach( void* param ) { usleep(1e6); LOG_I(PHY,"%s() RACH waiting for RU to be configured\n", __FUNCTION__); } + LOG_I(PHY,"%s() RU configured - RACH processing thread running\n", __FUNCTION__); while (!oai_exit) { - if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"ru_prach_thread") < 0) break; + if (oai_exit) break; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 1 ); - if (ru->eNB_list[0]){ + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 1 ); + + if (ru->eNB_list[0]) { prach_procedures( ru->eNB_list[0] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,0 #endif - ); - } - else { - rx_prach(NULL, - ru, - NULL, - NULL, - NULL, - proc->frame_prach, - 0 + ); + } else { + rx_prach(NULL, + ru, + NULL, + NULL, + NULL, + proc->frame_prach, + 0 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0 + ,0 #endif - ); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 0 ); + ); + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 0 ); + if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"ru_prach_thread") < 0) break; } LOG_I(PHY, "Exiting RU thread PRACH\n"); - ru_thread_prach_status = 0; return &ru_thread_prach_status; } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) -static void* ru_thread_prach_br( void* param ) { - +static void *ru_thread_prach_br( void *param ) { static int ru_thread_prach_status; - - RU_t *ru = (RU_t*)param; - RU_proc_t *proc = (RU_proc_t*)&ru->proc; - + RU_t *ru = (RU_t *)param; + RU_proc_t *proc = (RU_proc_t *)&ru->proc; // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach_br",1,500000,1000000,20000000); //wait_sync("ru_thread_prach_br"); while (!oai_exit) { - if (wait_on_condition(&proc->mutex_prach_br,&proc->cond_prach_br,&proc->instance_cnt_prach_br,"ru_prach_thread_br") < 0) break; + if (oai_exit) break; + rx_prach(NULL, - ru, - NULL, + ru, + NULL, NULL, NULL, proc->frame_prach_br, 0, - 1); + 1); + if (release_thread(&proc->mutex_prach_br,&proc->instance_cnt_prach_br,"ru_prach_thread_br") < 0) break; } LOG_I(PHY, "Exiting RU thread PRACH BR\n"); - ru_thread_prach_status = 0; return &ru_thread_prach_status; } #endif -int wakeup_synch(RU_t *ru){ - +int wakeup_synch(RU_t *ru) { struct timespec wait; - wait.tv_sec=0; wait.tv_nsec=5000000L; @@ -1165,23 +1106,21 @@ int wakeup_synch(RU_t *ru){ exit_fun( "error locking mutex_synch" ); return(-1); } - + ++ru->proc.instance_cnt_synch; - + // the thread can now be woken up if (pthread_cond_signal(&ru->proc.cond_synch) != 0) { LOG_E( PHY, "[RU] ERROR pthread_cond_signal for RU synch thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - - pthread_mutex_unlock( &ru->proc.mutex_synch ); + pthread_mutex_unlock( &ru->proc.mutex_synch ); return(0); } void do_ru_synch(RU_t *ru) { - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; RU_proc_t *proc = &ru->proc; int i; @@ -1191,102 +1130,99 @@ void do_ru_synch(RU_t *ru) { int ic; // initialize the synchronization buffer to the common_vars.rxdata - for (int i=0;i<ru->nb_rx;i++) + for (int i=0; i<ru->nb_rx; i++) rxp[i] = &ru->common.rxdata[i][0]; double temp_freq1 = ru->rfdevice.openair0_cfg->rx_freq[0]; double temp_freq2 = ru->rfdevice.openair0_cfg->tx_freq[0]; - for (i=0;i<4;i++) { + + for (i=0; i<4; i++) { ru->rfdevice.openair0_cfg->rx_freq[i] = ru->rfdevice.openair0_cfg->tx_freq[i]; ru->rfdevice.openair0_cfg->tx_freq[i] = temp_freq1; } + ru->rfdevice.trx_set_freq_func(&ru->rfdevice,ru->rfdevice.openair0_cfg,0); - + while ((ru->in_synch ==0)&&(!oai_exit)) { // read in frame rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, - &(proc->timestamp_rx), - rxp, - fp->samples_per_tti*10, - ru->nb_rx); + &(proc->timestamp_rx), + rxp, + fp->samples_per_tti*10, + ru->nb_rx); + if (rxs != fp->samples_per_tti*10) LOG_E(PHY,"requested %d samples, got %d\n",fp->samples_per_tti*10,rxs); - + // wakeup synchronization processing thread wakeup_synch(ru); ic=0; - + while ((ic>=0)&&(!oai_exit)) { - // continuously read in frames, 1ms at a time, + // continuously read in frames, 1ms at a time, // until we are done with the synchronization procedure - for (i=0; i<ru->nb_rx; i++) - rxp2[i] = (void*)&dummy_rx[i][0]; - for (i=0;i<10;i++) - rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, - &(proc->timestamp_rx), - rxp2, - fp->samples_per_tti, - ru->nb_rx); + rxp2[i] = (void *)&dummy_rx[i][0]; + + for (i=0; i<10; i++) + rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, + &(proc->timestamp_rx), + rxp2, + fp->samples_per_tti, + ru->nb_rx); + pthread_mutex_lock(&ru->proc.mutex_synch); ic = ru->proc.instance_cnt_synch; pthread_mutex_unlock(&ru->proc.mutex_synch); } // ic>=0 } // in_synch==0 - // read in rx_offset samples + + // read in rx_offset samples LOG_I(PHY,"Resynchronizing by %d samples\n",ru->rx_offset); rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, - &(proc->timestamp_rx), - rxp, - ru->rx_offset, - ru->nb_rx); - for (i=0;i<4;i++) { + &(proc->timestamp_rx), + rxp, + ru->rx_offset, + ru->nb_rx); + + for (i=0; i<4; i++) { ru->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; ru->rfdevice.openair0_cfg->tx_freq[i] = temp_freq2; } ru->rfdevice.trx_set_freq_func(&ru->rfdevice,ru->rfdevice.openair0_cfg,0); - } void wakeup_L1s(RU_t *ru) { - int i; PHY_VARS_eNB **eNB_list = ru->eNB_list; - LOG_D(PHY,"wakeup_L1s (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top); - if (ru->num_eNB==1 && ru->eNB_top!=0 && get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD) { // call eNB function directly - char string[20]; sprintf(string,"Incoming RU %d",ru->idx); LOG_D(PHY,"RU %d Call eNB_top\n",ru->idx); ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string,ru); ru->proc.emulate_rf_busy = 0; - } - else { - + } else { LOG_D(PHY,"ru->num_eNB:%d\n", ru->num_eNB); - for (i=0;i<ru->num_eNB;i++) - { + for (i=0; i<ru->num_eNB; i++) { LOG_D(PHY,"ru->wakeup_rxtx:%p\n", ru->wakeup_rxtx); - if (ru->wakeup_rxtx!=0 && ru->wakeup_rxtx(eNB_list[i],ru) < 0) - { + + if (ru->wakeup_rxtx!=0 && ru->wakeup_rxtx(eNB_list[i],ru) < 0) { LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); } + ru->proc.emulate_rf_busy = 0; } } } static inline int wakeup_prach_ru(RU_t *ru) { - struct timespec wait; - wait.tv_sec=0; wait.tv_nsec=5000000L; @@ -1295,6 +1231,7 @@ static inline int wakeup_prach_ru(RU_t *ru) { exit_fun( "error locking mutex_rxtx" ); return(-1); } + if (ru->proc.instance_cnt_prach==-1) { ++ru->proc.instance_cnt_prach; ru->proc.frame_prach = ru->proc.frame_rx; @@ -1305,21 +1242,19 @@ static inline int wakeup_prach_ru(RU_t *ru) { ru->eNB_list[0]->proc.frame_prach = ru->proc.frame_rx; ru->eNB_list[0]->proc.subframe_prach = ru->proc.subframe_rx; } + LOG_D(PHY,"RU %d: waking up PRACH thread\n",ru->idx); // the thread can now be woken up AssertFatal(pthread_cond_signal(&ru->proc.cond_prach) == 0, "ERROR pthread_cond_signal for RU prach thread\n"); - } - else LOG_W(PHY,"RU prach thread busy, skipping\n"); - pthread_mutex_unlock( &ru->proc.mutex_prach ); + } else LOG_W(PHY,"RU prach thread busy, skipping\n"); + pthread_mutex_unlock( &ru->proc.mutex_prach ); return(0); } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) static inline int wakeup_prach_ru_br(RU_t *ru) { - struct timespec wait; - wait.tv_sec=0; wait.tv_nsec=5000000L; @@ -1328,62 +1263,59 @@ static inline int wakeup_prach_ru_br(RU_t *ru) { exit_fun( "error locking mutex_rxtx" ); return(-1); } + if (ru->proc.instance_cnt_prach_br==-1) { ++ru->proc.instance_cnt_prach_br; ru->proc.frame_prach_br = ru->proc.frame_rx; ru->proc.subframe_prach_br = ru->proc.subframe_rx; - LOG_D(PHY,"RU %d: waking up PRACH thread\n",ru->idx); // the thread can now be woken up AssertFatal(pthread_cond_signal(&ru->proc.cond_prach_br) == 0, "ERROR pthread_cond_signal for RU prach thread BR\n"); - } - else LOG_W(PHY,"RU prach thread busy, skipping\n"); - pthread_mutex_unlock( &ru->proc.mutex_prach_br ); + } else LOG_W(PHY,"RU prach thread busy, skipping\n"); + pthread_mutex_unlock( &ru->proc.mutex_prach_br ); return(0); } #endif // this is for RU with local RF unit void fill_rf_config(RU_t *ru, char *rf_config_file) { - int i; - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; openair0_config_t *cfg = &ru->openair0_cfg; //printf("////////////////numerology in config = %d\n",numerology); int numerology = get_softmodem_params()->numerology; + if(fp->N_RB_DL == 100) { - if(numerology == 0){ + if(numerology == 0) { if (fp->threequarter_fs) { cfg->sample_rate=23.04e6; - cfg->samples_per_frame = 230400; + cfg->samples_per_frame = 230400; cfg->tx_bw = 10e6; cfg->rx_bw = 10e6; - } - else { + } else { cfg->sample_rate=30.72e6; - cfg->samples_per_frame = 307200; + cfg->samples_per_frame = 307200; cfg->tx_bw = 10e6; cfg->rx_bw = 10e6; } - }else if(numerology == 1){ - cfg->sample_rate=61.44e6; - cfg->samples_per_frame = 307200; + } else if(numerology == 1) { + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 307200; cfg->tx_bw = 20e6; cfg->rx_bw = 20e6; - }else if(numerology == 2){ - cfg->sample_rate=122.88e6; - cfg->samples_per_frame = 307200; + } else if(numerology == 2) { + cfg->sample_rate=122.88e6; + cfg->samples_per_frame = 307200; cfg->tx_bw = 40e6; cfg->rx_bw = 40e6; - }else{ - printf("Wrong input for numerology %d\n setting to 20MHz normal CP configuration",numerology); - cfg->sample_rate=30.72e6; - cfg->samples_per_frame = 307200; + } else { + printf("Wrong input for numerology %d\n setting to 20MHz normal CP configuration",numerology); + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; cfg->tx_bw = 10e6; cfg->rx_bw = 10e6; - } + } } else if(fp->N_RB_DL == 50) { cfg->sample_rate=15.36e6; cfg->samples_per_frame = 153600; @@ -1399,8 +1331,7 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->samples_per_frame = 19200; cfg->tx_bw = 1.5e6; cfg->rx_bw = 1.5e6; - } - else AssertFatal(1==0,"Unknown N_RB_DL %d\n",fp->N_RB_DL); + } else AssertFatal(1==0,"Unknown N_RB_DL %d\n",fp->N_RB_DL); if (fp->frame_type==TDD) cfg->duplex_mode = duplex_mode_TDD; @@ -1414,20 +1345,16 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->clock_source=get_softmodem_params()->clock_source; for (i=0; i<ru->nb_tx; i++) { - cfg->tx_freq[i] = (double)fp->dl_CarrierFreq; cfg->rx_freq[i] = (double)fp->ul_CarrierFreq; - cfg->tx_gain[i] = (double)ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx; - - cfg->configFilename = rf_config_file; printf("channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", - i, cfg->tx_gain[i], - cfg->rx_gain[i], - cfg->tx_freq[i], - cfg->rx_freq[i]); + i, cfg->tx_gain[i], + cfg->rx_gain[i], + cfg->tx_freq[i], + cfg->rx_freq[i]); } } @@ -1436,14 +1363,11 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { rf_map specifies for each antenna port, on which rf chain the mapping should start. Multiple antennas are mapped to successive RF chains on the same card. */ int setup_RU_buffers(RU_t *ru) { - - int i,j; + int i,j; int card,ant; - //uint16_t N_TA_offset = 0; - LTE_DL_FRAME_PARMS *frame_parms; - + if (ru) { frame_parms = &ru->frame_parms; printf("setup_RU_buffers: frame_parms = %p\n",frame_parms); @@ -1451,224 +1375,221 @@ int setup_RU_buffers(RU_t *ru) { printf("RU not initialized (NULL pointer)\n"); return(-1); } - - + if (frame_parms->frame_type == TDD) { if (frame_parms->N_RB_DL == 100) ru->N_TA_offset = 624; else if (frame_parms->N_RB_DL == 50) ru->N_TA_offset = 624/2; else if (frame_parms->N_RB_DL == 25) ru->N_TA_offset = 624/4; + #if BASIC_SIMULATOR /* this is required for the basic simulator in TDD mode * TODO: find a proper cleaner solution */ ru->N_TA_offset = 0; #endif - } + } + if (ru->openair0_cfg.mmapped_dma == 1) { // replace RX signal buffers with mmaped HW versions - for (i=0; i<ru->nb_rx; i++) { card = i/4; ant = i%4; printf("Mapping RU id %d, rx_ant %d, on card %d, chain %d\n",ru->idx,i,ru->rf_map.card+card, ru->rf_map.chain+ant); free(ru->common.rxdata[i]); ru->common.rxdata[i] = ru->openair0_cfg.rxbase[ru->rf_map.chain+ant]; - printf("rxdata[%d] @ %p\n",i,ru->common.rxdata[i]); + for (j=0; j<16; j++) { - printf("rxbuffer %d: %x\n",j,ru->common.rxdata[i][j]); - ru->common.rxdata[i][j] = 16-j; + printf("rxbuffer %d: %x\n",j,ru->common.rxdata[i][j]); + ru->common.rxdata[i][j] = 16-j; } } - + for (i=0; i<ru->nb_tx; i++) { card = i/4; ant = i%4; printf("Mapping RU id %d, tx_ant %d, on card %d, chain %d\n",ru->idx,i,ru->rf_map.card+card, ru->rf_map.chain+ant); free(ru->common.txdata[i]); ru->common.txdata[i] = ru->openair0_cfg.txbase[ru->rf_map.chain+ant]; - printf("txdata[%d] @ %p\n",i,ru->common.txdata[i]); - + for (j=0; j<16; j++) { - printf("txbuffer %d: %x\n",j,ru->common.txdata[i][j]); - ru->common.txdata[i][j] = 16-j; + printf("txbuffer %d: %x\n",j,ru->common.txdata[i][j]); + ru->common.txdata[i][j] = 16-j; } } - } - else { // not memory-mapped DMA + } else { // not memory-mapped DMA //nothing to do, everything already allocated in lte_init } + return(0); } -static void* ru_stats_thread(void* param) { - - RU_t *ru = (RU_t*)param; +static void *ru_stats_thread(void *param) { + RU_t *ru = (RU_t *)param; wait_sync("ru_stats_thread"); while (!oai_exit) { - sleep(1); - if (opp_enabled) { - if (ru->feprx) print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL); - if (ru->feptx_ofdm) print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL); - if (ru->fh_north_asynch_in) print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); - if (ru->fh_north_out) { - print_meas(&ru->tx_fhaul,"tx_fhaul",NULL,NULL); - print_meas(&ru->compression,"compression",NULL,NULL); - print_meas(&ru->transport,"transport",NULL,NULL); - } - } + sleep(1); + + if (opp_enabled) { + if (ru->feprx) print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL); + + if (ru->feptx_ofdm) print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL); + + if (ru->fh_north_asynch_in) print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); + + if (ru->fh_north_out) { + print_meas(&ru->tx_fhaul,"tx_fhaul",NULL,NULL); + print_meas(&ru->compression,"compression",NULL,NULL); + print_meas(&ru->transport,"transport",NULL,NULL); + } + } } + return(NULL); } #ifdef PHY_TX_THREAD -int first_phy_tx = 1; -volatile int16_t phy_tx_txdataF_end; -volatile int16_t phy_tx_end; + int first_phy_tx = 1; + volatile int16_t phy_tx_txdataF_end; + volatile int16_t phy_tx_end; #endif -static void* ru_thread_tx( void* param ) { - RU_t *ru = (RU_t*)param; +static void *ru_thread_tx( void *param ) { + RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; PHY_VARS_eNB *eNB; L1_proc_t *eNB_proc; L1_rxtx_proc_t *L1_proc; - cpu_set_t cpuset; CPU_ZERO(&cpuset); - - thread_top_init("ru_thread_tx",1,400000,500000,500000); - //CPU_SET(5, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); //wait_sync("ru_thread_tx"); - wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); - - printf( "ru_thread_tx ready\n"); - while (!oai_exit) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD_TX,sched_getcpu()); - if (oai_exit) break; + while (!oai_exit) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD_TX,sched_getcpu()); + if (oai_exit) break; LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); // wait until eNBs are finished subframe RX n and TX n+4 wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); + if (oai_exit) break; - + // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); - + // do OFDM if needed if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - if(!(get_softmodem_params()->emulate_rf)){ + + if(!(get_softmodem_params()->emulate_rf)) { // do outgoing fronthaul (south) if needed if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - + if (ru->fh_north_out) ru->fh_north_out(ru); - } + } + release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); - for(int i = 0; i<ru->num_eNB; i++) - { + + for(int i = 0; i<ru->num_eNB; i++) { eNB = ru->eNB_list[i]; eNB_proc = &eNB->proc; L1_proc = (get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)? &eNB_proc->L1_proc_tx : &eNB_proc->L1_proc; pthread_mutex_lock(&eNB_proc->mutex_RU_tx); - for (int j=0;j<eNB->num_RU;j++) { + + for (int j=0; j<eNB->num_RU; j++) { if (ru == eNB->RU_list[j]) { if ((eNB_proc->RU_mask_tx&(1<<j)) > 0) LOG_E(PHY,"eNB %d frame %d, subframe %d : previous information from RU tx %d (num_RU %d,mask %x) has not been served yet!\n", - eNB->Mod_id,eNB_proc->frame_rx,eNB_proc->subframe_rx,ru->idx,eNB->num_RU,eNB_proc->RU_mask_tx); + eNB->Mod_id,eNB_proc->frame_rx,eNB_proc->subframe_rx,ru->idx,eNB->num_RU,eNB_proc->RU_mask_tx); + eNB_proc->RU_mask_tx |= (1<<j); } } + if (eNB_proc->RU_mask_tx != (1<<eNB->num_RU)-1) { // not all RUs have provided their information so return pthread_mutex_unlock(&eNB_proc->mutex_RU_tx); - } - else { // all RUs TX are finished so send the ready signal to eNB processing + } else { // all RUs TX are finished so send the ready signal to eNB processing eNB_proc->RU_mask_tx = 0; pthread_mutex_unlock(&eNB_proc->mutex_RU_tx); - pthread_mutex_lock( &L1_proc->mutex_RUs); L1_proc->instance_cnt_RUs = 0; + // the thread can now be woken up if (pthread_cond_signal(&L1_proc->cond_RUs) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); } + pthread_mutex_unlock( &L1_proc->mutex_RUs ); } } } + release_thread(&proc->mutex_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); return 0; } -static void* ru_thread( void* param ) { - +static void *ru_thread( void *param ) { static int ru_thread_status; - - RU_t *ru = (RU_t*)param; + RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; int ret; int subframe =9; - int frame =1023; + int frame =1023; cpu_set_t cpuset; CPU_ZERO(&cpuset); - - // set default return value ru_thread_status = 0; #if defined(PRE_SCD_THREAD) dlsch_ue_select_tbl_in_use = 1; #endif - - // set default return value thread_top_init("ru_thread",1,400000,500000,500000); - //CPU_SET(1, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); pthread_setname_np( pthread_self(),"ru thread"); LOG_I(PHY,"thread ru created id=%ld\n", syscall(__NR_gettid)); - LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); - if(get_softmodem_params()->emulate_rf){ + if(get_softmodem_params()->emulate_rf) { fill_rf_config(ru,ru->rf_config_file); init_frame_parms(&ru->frame_parms,1); phy_init_RU(ru); + if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); } - } - else{ + } else { // Start IF device if any if (ru->start_if) { LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n"); + if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); else ret = attach_rru(ru); + AssertFatal(ret==0,"Cannot connect to radio\n"); } - if (ru->if_south == LOCAL_RF) { // configure RF parameters only - fill_rf_config(ru,ru->rf_config_file); - init_frame_parms(&ru->frame_parms,1); - phy_init_RU(ru); - - - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + + if (ru->if_south == LOCAL_RF) { // configure RF parameters only + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); } + if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); } } @@ -1677,174 +1598,173 @@ static void* ru_thread( void* param ) { RC.ru_mask &= ~(1<<ru->idx); pthread_cond_signal(&RC.ru_cond); pthread_mutex_unlock(&RC.ru_mutex); - - pthread_mutex_lock(&proc->mutex_FH1); proc->instance_cnt_FH1 = 0; pthread_mutex_unlock(&proc->mutex_FH1); pthread_cond_signal(&proc->cond_FH1); - wait_sync("ru_thread"); - if(!(get_softmodem_params()->emulate_rf)){ + if(!(get_softmodem_params()->emulate_rf)) { // Start RF device if any if (ru->start_rf) { if (ru->start_rf(ru) != 0) LOG_E(HW,"Could not start the RF device\n"); else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); - } - else LOG_I(PHY,"RU %d no rf device\n",ru->idx); - + } else LOG_I(PHY,"RU %d no rf device\n",ru->idx); + // if an asnych_rxtx thread exists // wakeup the thread because the devices are ready at this point - + if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { pthread_mutex_lock(&proc->mutex_asynch_rxtx); proc->instance_cnt_asynch_rxtx=0; pthread_mutex_unlock(&proc->mutex_asynch_rxtx); pthread_cond_signal(&proc->cond_asynch_rxtx); - } - else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); - + } else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); + // if this is a slave RRU, try to synchronize on the DL frequency if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); } - - - // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (!oai_exit) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD,sched_getcpu()); // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. // They are set on the first rx/tx in the underly FH routines. - if (subframe==9) { + if (subframe==9) { subframe=0; frame++; frame&=1023; } else { subframe++; - } + } // synchronization on input FH interface, acquire signals/data and block if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&subframe); else AssertFatal(1==0, "No fronthaul interface at south port"); #ifdef PHY_TX_THREAD - if(first_phy_tx == 0) - { - phy_tx_end = 0; - phy_tx_txdataF_end = 0; - if(pthread_mutex_lock(&ru->proc.mutex_phy_tx) != 0){ - LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for phy tx thread (IC %d)\n", ru->proc.instance_cnt_phy_tx); - exit_fun( "error locking mutex_rxtx" ); - } - if (ru->proc.instance_cnt_phy_tx==-1) { - ++ru->proc.instance_cnt_phy_tx; - - // the thread can now be woken up - AssertFatal(pthread_cond_signal(&ru->proc.cond_phy_tx) == 0, "ERROR pthread_cond_signal for phy_tx thread\n"); - }else{ - LOG_E(PHY,"phy tx thread busy, skipping\n"); - ++ru->proc.instance_cnt_phy_tx; - } - pthread_mutex_unlock( &ru->proc.mutex_phy_tx ); + + if(first_phy_tx == 0) { + phy_tx_end = 0; + phy_tx_txdataF_end = 0; + + if(pthread_mutex_lock(&ru->proc.mutex_phy_tx) != 0) { + LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for phy tx thread (IC %d)\n", ru->proc.instance_cnt_phy_tx); + exit_fun( "error locking mutex_rxtx" ); + } + + if (ru->proc.instance_cnt_phy_tx==-1) { + ++ru->proc.instance_cnt_phy_tx; + // the thread can now be woken up + AssertFatal(pthread_cond_signal(&ru->proc.cond_phy_tx) == 0, "ERROR pthread_cond_signal for phy_tx thread\n"); + } else { + LOG_E(PHY,"phy tx thread busy, skipping\n"); + ++ru->proc.instance_cnt_phy_tx; + } + + pthread_mutex_unlock( &ru->proc.mutex_phy_tx ); } else { - phy_tx_end = 1; - phy_tx_txdataF_end = 1; + phy_tx_end = 1; + phy_tx_txdataF_end = 1; } + first_phy_tx = 0; #endif - - - LOG_D(PHY,"RU thread (do_prach %d, is_prach_subframe %d), received frame %d, subframe %d\n", + LOG_D(PHY,"RU thread (do_prach %d, is_prach_subframe %d), received frame %d, subframe %d\n", ru->do_prach, is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx), proc->frame_rx,proc->subframe_rx); + if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { wakeup_prach_ru(ru); } + #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) else if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>1)) { wakeup_prach_ru_br(ru); } + #endif // adjust for timing offset between RU if (ru->idx!=0) proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; - // do RX front-end processing (frequency-shift, dft) if needed if (ru->feprx) ru->feprx(ru); // At this point, all information for subframe has been received on FH interface // If this proc is to provide synchronization, do so wakeup_slaves(proc); - #if defined(PRE_SCD_THREAD) new_dlsch_ue_select_tbl_in_use = dlsch_ue_select_tbl_in_use; dlsch_ue_select_tbl_in_use = !dlsch_ue_select_tbl_in_use; memcpy(&pre_scd_eNB_UE_stats,&RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.eNB_UE_stats, sizeof(eNB_UE_STATS)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); memcpy(&pre_scd_activeUE, &RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.active, sizeof(boolean_t)*NUMBER_OF_UE_MAX); + if (pthread_mutex_lock(&ru->proc.mutex_pre_scd)!= 0) { - LOG_E( PHY, "[eNB] error locking proc mutex for eNB pre scd\n"); - exit_fun("error locking mutex_time"); + LOG_E( PHY, "[eNB] error locking proc mutex for eNB pre scd\n"); + exit_fun("error locking mutex_time"); } ru->proc.instance_pre_scd++; if (ru->proc.instance_pre_scd == 0) { - if (pthread_cond_signal(&ru->proc.cond_pre_scd) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB pre scd\n" ); - exit_fun( "ERROR pthread_cond_signal cond_pre_scd" ); - } - }else{ - LOG_E( PHY, "[eNB] frame %d subframe %d rxtx busy instance_pre_scd %d\n", - frame,subframe,ru->proc.instance_pre_scd ); + if (pthread_cond_signal(&ru->proc.cond_pre_scd) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB pre scd\n" ); + exit_fun( "ERROR pthread_cond_signal cond_pre_scd" ); + } + } else { + LOG_E( PHY, "[eNB] frame %d subframe %d rxtx busy instance_pre_scd %d\n", + frame,subframe,ru->proc.instance_pre_scd ); } if (pthread_mutex_unlock(&ru->proc.mutex_pre_scd)!= 0) { - LOG_E( PHY, "[eNB] error unlocking mutex_pre_scd mutex for eNB pre scd\n"); - exit_fun("error unlocking mutex_pre_scd"); + LOG_E( PHY, "[eNB] error unlocking mutex_pre_scd mutex for eNB pre scd\n"); + exit_fun("error unlocking mutex_pre_scd"); } + #endif // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_L1s(ru); - + #ifndef PHY_TX_THREAD - if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD || ru->num_eNB==0){ + + if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD || ru->num_eNB==0) { // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); - + // do OFDM if needed if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - if(!(get_softmodem_params()->emulate_rf)){ + + if(!(get_softmodem_params()->emulate_rf)) { // do outgoing fronthaul (south) if needed if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - + if (ru->fh_north_out) ru->fh_north_out(ru); } + proc->emulate_rf_busy = 0; } + #else struct timespec time_req, time_rem; time_req.tv_sec = 0; time_req.tv_nsec = 10000; - while((!oai_exit)&&(phy_tx_end == 0)){ - nanosleep(&time_req,&time_rem); - continue; + while((!oai_exit)&&(phy_tx_end == 0)) { + nanosleep(&time_req,&time_rem); + continue; } + #endif } - printf( "Exiting ru_thread \n"); - if (!(get_softmodem_params()->emulate_rf)){ + if (!(get_softmodem_params()->emulate_rf)) { if (ru->stop_rf != NULL) { if (ru->stop_rf(ru) != 0) LOG_E(HW,"Could not stop the RF device\n"); @@ -1854,75 +1774,65 @@ static void* ru_thread( void* param ) { ru_thread_status = 0; return &ru_thread_status; - } // This thread run the initial synchronization like a UE void *ru_thread_synch(void *arg) { - - RU_t *ru = (RU_t*)arg; + RU_t *ru = (RU_t *)arg; LTE_DL_FRAME_PARMS *fp=&ru->frame_parms; int32_t sync_pos,sync_pos2; uint32_t peak_val; uint32_t sync_corr[307200] __attribute__((aligned(32))); static int ru_thread_synch_status; - - thread_top_init("ru_thread_synch",0,5000000,10000000,10000000); - wait_sync("ru_thread_synch"); - // initialize variables for PSS detection lte_sync_time_init(&ru->frame_parms); while (!oai_exit) { - // wait to be woken up if (wait_on_condition(&ru->proc.mutex_synch,&ru->proc.cond_synch,&ru->proc.instance_cnt_synch,"ru_thread_synch")<0) break; // if we're not in synch, then run initial synch - if (ru->in_synch == 0) { + if (ru->in_synch == 0) { // run intial synch like UE LOG_I(PHY,"Running initial synchronization\n"); - sync_pos = lte_sync_time_eNB(ru->common.rxdata, - fp, - fp->samples_per_tti*5, - &peak_val, - sync_corr); + fp, + fp->samples_per_tti*5, + &peak_val, + sync_corr); LOG_I(PHY,"RU synch: %d, val %d\n",sync_pos,peak_val); if (sync_pos >= 0) { - if (sync_pos >= fp->nb_prefix_samples) - sync_pos2 = sync_pos - fp->nb_prefix_samples; - else - sync_pos2 = sync_pos + (fp->samples_per_tti*10) - fp->nb_prefix_samples; - - if (fp->frame_type == FDD) { - - // PSS is hypothesized in last symbol of first slot in Frame - int sync_pos_slot = (fp->samples_per_tti>>1) - fp->ofdm_symbol_size - fp->nb_prefix_samples; - - if (sync_pos2 >= sync_pos_slot) - ru->rx_offset = sync_pos2 - sync_pos_slot; - else - ru->rx_offset = (fp->samples_per_tti*10) + sync_pos2 - sync_pos_slot; - } - else { - - } - - LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,ru->rx_offset); - - if (LOG_DEBUGFLAG(RU)) { - if ((peak_val > 300000) && (sync_pos > 0)) { - LOG_M("ru_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2); - LOG_M("ru_rx.m","rxs",&(ru->eNB_list[0]->common_vars.rxdata[0][0]),fp->samples_per_tti*10,1,1); - exit(-1); - } + if (sync_pos >= fp->nb_prefix_samples) + sync_pos2 = sync_pos - fp->nb_prefix_samples; + else + sync_pos2 = sync_pos + (fp->samples_per_tti*10) - fp->nb_prefix_samples; + + if (fp->frame_type == FDD) { + // PSS is hypothesized in last symbol of first slot in Frame + int sync_pos_slot = (fp->samples_per_tti>>1) - fp->ofdm_symbol_size - fp->nb_prefix_samples; + + if (sync_pos2 >= sync_pos_slot) + ru->rx_offset = sync_pos2 - sync_pos_slot; + else + ru->rx_offset = (fp->samples_per_tti*10) + sync_pos2 - sync_pos_slot; + } else { + } + + LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,ru->rx_offset); + + if (LOG_DEBUGFLAG(RU)) { + if ((peak_val > 300000) && (sync_pos > 0)) { + LOG_M("ru_sync.m","sync",(void *)&sync_corr[0],fp->samples_per_tti*5,1,2); + LOG_M("ru_rx.m","rxs",&(ru->eNB_list[0]->common_vars.rxdata[0][0]),fp->samples_per_tti*10,1,1); + exit(-1); + } } - ru->in_synch=1; + + ru->in_synch=1; } } @@ -1931,64 +1841,67 @@ void *ru_thread_synch(void *arg) { ru_thread_synch_status = 0; return &ru_thread_synch_status; - } #if defined(PRE_SCD_THREAD) -void* pre_scd_thread( void* param ){ - static int eNB_pre_scd_status; - protocol_ctxt_t ctxt; - int frame; - int subframe; - int min_rb_unit[MAX_NUM_CCs]; - int CC_id; - int Mod_id; - RU_t *ru = (RU_t*)param; - - // L2-emulator can work only one eNB - if( nfapi_mode == 2) - Mod_id = 0; - else - Mod_id = ru->eNB_list[0]->Mod_id; - - frame = 0; - subframe = 4; - thread_top_init("pre_scd_thread",0,870000,1000000,1000000); - - while (!oai_exit) { - if(oai_exit){ - break; - } - pthread_mutex_lock(&ru->proc.mutex_pre_scd ); - if (ru->proc.instance_pre_scd < 0) { - pthread_cond_wait(&ru->proc.cond_pre_scd, &ru->proc.mutex_pre_scd); - } - pthread_mutex_unlock(&ru->proc.mutex_pre_scd); - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, Mod_id, ENB_FLAG_YES, - NOT_A_RNTI, frame, subframe,Mod_id); - pdcp_run(&ctxt); +void *pre_scd_thread( void *param ) { + static int eNB_pre_scd_status; + protocol_ctxt_t ctxt; + int frame; + int subframe; + int min_rb_unit[MAX_NUM_CCs]; + int CC_id; + int Mod_id; + RU_t *ru = (RU_t *)param; + + // L2-emulator can work only one eNB + if( nfapi_mode == 2) + Mod_id = 0; + else + Mod_id = ru->eNB_list[0]->Mod_id; + + frame = 0; + subframe = 4; + thread_top_init("pre_scd_thread",0,870000,1000000,1000000); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + while (!oai_exit) { + if(oai_exit) { + break; + } - rrc_rx_tx(&ctxt, CC_id); - min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - } + pthread_mutex_lock(&ru->proc.mutex_pre_scd ); + + if (ru->proc.instance_pre_scd < 0) { + pthread_cond_wait(&ru->proc.cond_pre_scd, &ru->proc.mutex_pre_scd); + } - pre_scd_nb_rbs_required(Mod_id, frame, subframe,min_rb_unit,pre_nb_rbs_required[new_dlsch_ue_select_tbl_in_use]); + pthread_mutex_unlock(&ru->proc.mutex_pre_scd); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, Mod_id, ENB_FLAG_YES, + NOT_A_RNTI, frame, subframe,Mod_id); + pdcp_run(&ctxt); - if (subframe==9) { - subframe=0; - frame++; - frame&=1023; - } else { - subframe++; - } - pthread_mutex_lock(&ru->proc.mutex_pre_scd ); - ru->proc.instance_pre_scd--; - pthread_mutex_unlock(&ru->proc.mutex_pre_scd); + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + rrc_rx_tx(&ctxt, CC_id); + min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); + } + + pre_scd_nb_rbs_required(Mod_id, frame, subframe,min_rb_unit,pre_nb_rbs_required[new_dlsch_ue_select_tbl_in_use]); + + if (subframe==9) { + subframe=0; + frame++; + frame&=1023; + } else { + subframe++; } - eNB_pre_scd_status = 0; - return &eNB_pre_scd_status; + + pthread_mutex_lock(&ru->proc.mutex_pre_scd ); + ru->proc.instance_pre_scd--; + pthread_mutex_unlock(&ru->proc.mutex_pre_scd); + } + + eNB_pre_scd_status = 0; + return &eNB_pre_scd_status; } #endif @@ -1998,111 +1911,106 @@ void* pre_scd_thread( void* param ){ * \param param is a \ref L1_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* eNB_thread_phy_tx( void* param ) { +static void *eNB_thread_phy_tx( void *param ) { static int eNB_thread_phy_tx_status; - - - RU_t *ru = (RU_t*)param; + RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; PHY_VARS_eNB **eNB_list = ru->eNB_list; - L1_rxtx_proc_t L1_proc; - // set default return value eNB_thread_phy_tx_status = 0; - thread_top_init("eNB_thread_phy_tx",1,500000L,1000000L,20000000L); - while (!oai_exit) { - if (oai_exit) break; - if (wait_on_condition(&proc->mutex_phy_tx,&proc->cond_phy_tx,&proc->instance_cnt_phy_tx,"eNB_phy_tx_thread") < 0) break; LOG_D(PHY,"Running eNB phy tx procedures\n"); - if(ru->num_eNB == 1){ - L1_proc.subframe_tx = proc->subframe_phy_tx; - L1_proc.frame_tx = proc->frame_phy_tx; - phy_procedures_eNB_TX(eNB_list[0], &L1_proc, 1); - phy_tx_txdataF_end = 1; - if(pthread_mutex_lock(&ru->proc.mutex_rf_tx) != 0){ - LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for rf tx thread (IC %d)\n", ru->proc.instance_cnt_rf_tx); - exit_fun( "error locking mutex_rf_tx" ); - } - if (ru->proc.instance_cnt_rf_tx==-1) { - ++ru->proc.instance_cnt_rf_tx; - ru->proc.frame_tx = proc->frame_phy_tx; - ru->proc.subframe_tx = proc->subframe_phy_tx; - ru->proc.timestamp_tx = proc->timestamp_phy_tx; - - // the thread can now be woken up - AssertFatal(pthread_cond_signal(&ru->proc.cond_rf_tx) == 0, "ERROR pthread_cond_signal for rf_tx thread\n"); - }else{ - LOG_E(PHY,"rf tx thread busy, skipping\n"); - late_control=STATE_BURST_TERMINATE; - } - pthread_mutex_unlock( &ru->proc.mutex_rf_tx ); + + if(ru->num_eNB == 1) { + L1_proc.subframe_tx = proc->subframe_phy_tx; + L1_proc.frame_tx = proc->frame_phy_tx; + phy_procedures_eNB_TX(eNB_list[0], &L1_proc, 1); + phy_tx_txdataF_end = 1; + + if(pthread_mutex_lock(&ru->proc.mutex_rf_tx) != 0) { + LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for rf tx thread (IC %d)\n", ru->proc.instance_cnt_rf_tx); + exit_fun( "error locking mutex_rf_tx" ); + } + + if (ru->proc.instance_cnt_rf_tx==-1) { + ++ru->proc.instance_cnt_rf_tx; + ru->proc.frame_tx = proc->frame_phy_tx; + ru->proc.subframe_tx = proc->subframe_phy_tx; + ru->proc.timestamp_tx = proc->timestamp_phy_tx; + // the thread can now be woken up + AssertFatal(pthread_cond_signal(&ru->proc.cond_rf_tx) == 0, "ERROR pthread_cond_signal for rf_tx thread\n"); + } else { + LOG_E(PHY,"rf tx thread busy, skipping\n"); + late_control=STATE_BURST_TERMINATE; + } + + pthread_mutex_unlock( &ru->proc.mutex_rf_tx ); } + if (release_thread(&proc->mutex_phy_tx,&proc->instance_cnt_phy_tx,"eNB_thread_phy_tx") < 0) break; + phy_tx_end = 1; } LOG_I(PHY, "Exiting eNB thread PHY TX\n"); - eNB_thread_phy_tx_status = 0; return &eNB_thread_phy_tx_status; } -static void* rf_tx( void* param ) { +static void *rf_tx( void *param ) { static int rf_tx_status; - - RU_t *ru = (RU_t*)param; + RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; - // set default return value rf_tx_status = 0; - thread_top_init("rf_tx",1,500000L,1000000L,20000000L); - - while (!oai_exit) { + while (!oai_exit) { if (oai_exit) break; - if (wait_on_condition(&proc->mutex_rf_tx,&proc->cond_rf_tx,&proc->instance_cnt_rf_tx,"rf_tx_thread") < 0) break; LOG_D(PHY,"Running eNB rf tx procedures\n"); - if(ru->num_eNB == 1){ - // do TX front-end processing if needed (precoding and/or IDFTs) - if (ru->feptx_prec) ru->feptx_prec(ru); - // do OFDM if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - if(!emulate_rf){ - // do outgoing fronthaul (south) if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - - if (ru->fh_north_out) ru->fh_north_out(ru); - } + + if(ru->num_eNB == 1) { + // do TX front-end processing if needed (precoding and/or IDFTs) + if (ru->feptx_prec) ru->feptx_prec(ru); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + + if(!emulate_rf) { + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + + if (ru->fh_north_out) ru->fh_north_out(ru); + } } + if (release_thread(&proc->mutex_rf_tx,&proc->instance_cnt_rf_tx,"rf_tx") < 0) break; - if(proc->instance_cnt_rf_tx >= 0){ + + if(proc->instance_cnt_rf_tx >= 0) { late_control=STATE_BURST_TERMINATE; LOG_E(PHY,"detect rf tx busy change mode TX failsafe\n"); } } LOG_I(PHY, "Exiting rf TX\n"); - rf_tx_status = 0; return &rf_tx_status; } #endif - + int start_if(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB) { return(ru->ifdevice.trx_start_func(&ru->ifdevice)); } @@ -2111,8 +2019,7 @@ int start_rf(RU_t *ru) { return(ru->rfdevice.trx_start_func(&ru->rfdevice)); } -int stop_rf(RU_t *ru) -{ +int stop_rf(RU_t *ru) { ru->rfdevice.trx_end_func(&ru->rfdevice); return 0; } @@ -2128,7 +2035,6 @@ extern void kill_fep_thread(RU_t *ru); extern void kill_feptx_thread(RU_t *ru); void init_RU_proc(RU_t *ru) { - int i=0; RU_proc_t *proc; pthread_attr_t *attr_FH=NULL,*attr_FH1=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL,*attr_emulateRF=NULL; @@ -2137,13 +2043,11 @@ void init_RU_proc(RU_t *ru) { pthread_attr_t *attr_prach_br=NULL; #endif char name[100]; - #ifndef OCP_FRAMEWORK LOG_I(PHY,"Initializing RU proc %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); #endif proc = &ru->proc; - memset((void*)proc,0,sizeof(RU_proc_t)); - + memset((void *)proc,0,sizeof(RU_proc_t)); proc->ru = ru; proc->instance_cnt_prach = -1; proc->instance_cnt_synch = -1; @@ -2158,8 +2062,8 @@ void init_RU_proc(RU_t *ru) { proc->num_slaves = 0; proc->frame_tx_unwrap = 0; - for (i=0;i<10;i++) proc->symbol_mask[i]=0; - + for (i=0; i<10; i++) proc->symbol_mask[i]=0; + pthread_mutex_init( &proc->mutex_prach, NULL); pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_synch,NULL); @@ -2167,7 +2071,6 @@ void init_RU_proc(RU_t *ru) { pthread_mutex_init( &proc->mutex_FH1,NULL); pthread_mutex_init( &proc->mutex_emulateRF,NULL); pthread_mutex_init( &proc->mutex_eNBs, NULL); - pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); pthread_cond_init( &proc->cond_FH1, NULL); @@ -2175,7 +2078,6 @@ void init_RU_proc(RU_t *ru) { pthread_cond_init( &proc->cond_asynch_rxtx, NULL); pthread_cond_init( &proc->cond_synch,NULL); pthread_cond_init( &proc->cond_eNBs, NULL); - pthread_attr_init( &proc->attr_FH); pthread_attr_init( &proc->attr_FH1); pthread_attr_init( &proc->attr_emulateRF); @@ -2183,14 +2085,12 @@ void init_RU_proc(RU_t *ru) { pthread_attr_init( &proc->attr_synch); pthread_attr_init( &proc->attr_asynch_rxtx); pthread_attr_init( &proc->attr_fep); - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) proc->instance_cnt_prach_br = -1; pthread_mutex_init( &proc->mutex_prach_br, NULL); pthread_cond_init( &proc->cond_prach_br, NULL); pthread_attr_init( &proc->attr_prach_br); -#endif - +#endif #ifdef PHY_TX_THREAD proc->instance_cnt_phy_tx = -1; pthread_mutex_init( &proc->mutex_phy_tx, NULL); @@ -2199,7 +2099,6 @@ void init_RU_proc(RU_t *ru) { pthread_mutex_init( &proc->mutex_rf_tx, NULL); pthread_cond_init( &proc->cond_rf_tx, NULL); #endif - #ifndef DEADLINE_SCHEDULER attr_FH = &proc->attr_FH; attr_FH1 = &proc->attr_FH1; @@ -2211,65 +2110,57 @@ void init_RU_proc(RU_t *ru) { attr_prach_br = &proc->attr_prach_br; #endif #endif - - pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru ); - + pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void *)ru ); #if defined(PRE_SCD_THREAD) - proc->instance_pre_scd = -1; - pthread_mutex_init( &proc->mutex_pre_scd, NULL); - pthread_cond_init( &proc->cond_pre_scd, NULL); - pthread_create(&proc->pthread_pre_scd, NULL, pre_scd_thread, (void*)ru); - pthread_setname_np(proc->pthread_pre_scd, "pre_scd_thread"); + proc->instance_pre_scd = -1; + pthread_mutex_init( &proc->mutex_pre_scd, NULL); + pthread_cond_init( &proc->cond_pre_scd, NULL); + pthread_create(&proc->pthread_pre_scd, NULL, pre_scd_thread, (void *)ru); + pthread_setname_np(proc->pthread_pre_scd, "pre_scd_thread"); #endif - #ifdef PHY_TX_THREAD - pthread_create( &proc->pthread_phy_tx, NULL, eNB_thread_phy_tx, (void*)ru ); - pthread_setname_np( proc->pthread_phy_tx, "phy_tx_thread" ); - pthread_create( &proc->pthread_rf_tx, NULL, rf_tx, (void*)ru ); + pthread_create( &proc->pthread_phy_tx, NULL, eNB_thread_phy_tx, (void *)ru ); + pthread_setname_np( proc->pthread_phy_tx, "phy_tx_thread" ); + pthread_create( &proc->pthread_rf_tx, NULL, rf_tx, (void *)ru ); #endif if(get_softmodem_params()->emulate_rf) - pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); + pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void *)proc ); if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) - pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); + pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void *)ru ); if (ru->function == NGFI_RRU_IF4p5) { - pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - pthread_create( &proc->pthread_prach_br, attr_prach_br, ru_thread_prach_br, (void*)ru ); + pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void *)ru ); +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + pthread_create( &proc->pthread_prach_br, attr_prach_br, ru_thread_prach_br, (void *)ru ); #endif - if (ru->is_slave == 1) pthread_create( &proc->pthread_synch, attr_synch, ru_thread_synch, (void*)ru); - - + + if (ru->is_slave == 1) pthread_create( &proc->pthread_synch, attr_synch, ru_thread_synch, (void *)ru); + if ((ru->if_timing == synch_to_other) || - (ru->function == NGFI_RRU_IF5) || - (ru->function == NGFI_RRU_IF4p5)) - { - pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, ru_thread_asynch_rxtx, (void*)ru ); - } - + (ru->function == NGFI_RRU_IF5) || + (ru->function == NGFI_RRU_IF4p5)) { + pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, ru_thread_asynch_rxtx, (void *)ru ); + } + snprintf( name, sizeof(name), "ru_thread_FH %d", ru->idx ); pthread_setname_np( proc->pthread_FH, name ); - - } - else if (ru->function == eNodeB_3GPP && ru->if_south == LOCAL_RF) { // DJP - need something else to distinguish between monolithic and PNF + } else if (ru->function == eNodeB_3GPP && ru->if_south == LOCAL_RF) { // DJP - need something else to distinguish between monolithic and PNF LOG_I(PHY,"%s() DJP - added creation of pthread_prach\n", __FUNCTION__); - pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); + pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void *)ru ); } - if (get_thread_worker_conf() == WORKER_ENABLE) { - init_fep_thread(ru,NULL); + if (get_thread_worker_conf() == WORKER_ENABLE) { + init_fep_thread(ru,NULL); init_feptx_thread(ru,NULL); - } - if (opp_enabled == 1) pthread_create(&ru->ru_stats_thread,NULL,ru_stats_thread,(void*)ru); - + } + + if (opp_enabled == 1) pthread_create(&ru->ru_stats_thread,NULL,ru_stats_thread,(void *)ru); } -void kill_RU_proc(RU_t *ru) -{ +void kill_RU_proc(RU_t *ru) { RU_proc_t *proc = &ru->proc; - #if defined(PRE_SCD_THREAD) pthread_mutex_lock(&proc->mutex_pre_scd); ru->proc.instance_pre_scd = 0; @@ -2297,57 +2188,52 @@ void kill_RU_proc(RU_t *ru) #endif if (get_thread_worker_conf() == WORKER_ENABLE) { - LOG_D(PHY, "killing FEP thread\n"); - kill_fep_thread(ru); - LOG_D(PHY, "killing FEP TX thread\n"); - kill_feptx_thread(ru); + LOG_D(PHY, "killing FEP thread\n"); + kill_fep_thread(ru); + LOG_D(PHY, "killing FEP TX thread\n"); + kill_feptx_thread(ru); } pthread_mutex_lock(&proc->mutex_FH); proc->instance_cnt_FH = 0; pthread_cond_signal(&proc->cond_FH); pthread_mutex_unlock(&proc->mutex_FH); - pthread_mutex_lock(&proc->mutex_FH1); proc->instance_cnt_FH1 = 0; pthread_cond_signal(&proc->cond_FH1); pthread_mutex_unlock(&proc->mutex_FH1); - pthread_mutex_lock(&proc->mutex_prach); proc->instance_cnt_prach = 0; pthread_cond_signal(&proc->cond_prach); pthread_mutex_unlock(&proc->mutex_prach); - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_mutex_lock(&proc->mutex_prach_br); proc->instance_cnt_prach_br = 0; pthread_cond_signal(&proc->cond_prach_br); pthread_mutex_unlock(&proc->mutex_prach_br); #endif - pthread_mutex_lock(&proc->mutex_synch); proc->instance_cnt_synch = 0; pthread_cond_signal(&proc->cond_synch); pthread_mutex_unlock(&proc->mutex_synch); - pthread_mutex_lock(&proc->mutex_eNBs); proc->instance_cnt_eNBs = 1; // cond_eNBs is used by both ru_thread and ru_thread_tx, so we need to send // a broadcast to wake up both threads pthread_cond_broadcast(&proc->cond_eNBs); pthread_mutex_unlock(&proc->mutex_eNBs); - pthread_mutex_lock(&proc->mutex_asynch_rxtx); proc->instance_cnt_asynch_rxtx = 0; pthread_cond_signal(&proc->cond_asynch_rxtx); pthread_mutex_unlock(&proc->mutex_asynch_rxtx); - LOG_D(PHY, "Joining pthread_FH\n"); pthread_join(proc->pthread_FH, NULL); + if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) { LOG_D(PHY, "Joining pthread_FHTX\n"); pthread_join(proc->pthread_FH1, NULL); } + if (ru->function == NGFI_RRU_IF4p5) { LOG_D(PHY, "Joining pthread_prach\n"); pthread_join(proc->pthread_prach, NULL); @@ -2355,6 +2241,7 @@ void kill_RU_proc(RU_t *ru) LOG_D(PHY, "Joining pthread_prach_br\n"); pthread_join(proc->pthread_prach_br, NULL); #endif + if (ru->is_slave) { LOG_D(PHY, "Joining pthread_\n"); pthread_join(proc->pthread_synch, NULL); @@ -2367,6 +2254,7 @@ void kill_RU_proc(RU_t *ru) pthread_join(proc->pthread_asynch_rxtx, NULL); } } + if (opp_enabled) { LOG_D(PHY, "Joining ru_stats_thread\n"); pthread_join(ru->ru_stats_thread, NULL); @@ -2378,21 +2266,18 @@ void kill_RU_proc(RU_t *ru) pthread_mutex_destroy(&proc->mutex_FH); pthread_mutex_destroy(&proc->mutex_FH1); pthread_mutex_destroy(&proc->mutex_eNBs); - pthread_cond_destroy(&proc->cond_prach); pthread_cond_destroy(&proc->cond_FH); pthread_cond_destroy(&proc->cond_FH1); pthread_cond_destroy(&proc->cond_asynch_rxtx); pthread_cond_destroy(&proc->cond_synch); pthread_cond_destroy(&proc->cond_eNBs); - pthread_attr_destroy(&proc->attr_FH); pthread_attr_destroy(&proc->attr_FH1); pthread_attr_destroy(&proc->attr_prach); pthread_attr_destroy(&proc->attr_synch); pthread_attr_destroy(&proc->attr_asynch_rxtx); pthread_attr_destroy(&proc->attr_fep); - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_mutex_destroy(&proc->mutex_prach_br); pthread_cond_destroy(&proc->cond_prach_br); @@ -2401,15 +2286,14 @@ void kill_RU_proc(RU_t *ru) } int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) { - FH_fmt_options_t fmt = cap->FH_fmt; - int i; int found_band=0; - LOG_I(PHY,"RRU %d, num_bands %d, looking for band %d\n",ru->idx,cap->num_bands,ru->frame_parms.eutra_band); - for (i=0;i<cap->num_bands;i++) { + + for (i=0; i<cap->num_bands; i++) { LOG_I(PHY,"band %d on RRU %d\n",cap->band_list[i],ru->idx); + if (ru->frame_parms.eutra_band == cap->band_list[i]) { found_band=1; break; @@ -2422,22 +2306,29 @@ int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) { } switch (ru->if_south) { - case LOCAL_RF: - AssertFatal(1==0, "This RU should not have a local RF, exiting\n"); - return(0); - break; - case REMOTE_IF5: - if (fmt == OAI_IF5_only || fmt == OAI_IF5_and_IF4p5) return(0); - break; - case REMOTE_IF4p5: - if (fmt == OAI_IF4p5_only || fmt == OAI_IF5_and_IF4p5) return(0); - break; - case REMOTE_MBP_IF5: - if (fmt == MBP_IF5) return(0); - break; - default: - LOG_I(PHY,"No compatible Fronthaul interface found for RRU %d\n", ru->idx); - return(-1); + case LOCAL_RF: + AssertFatal(1==0, "This RU should not have a local RF, exiting\n"); + return(0); + break; + + case REMOTE_IF5: + if (fmt == OAI_IF5_only || fmt == OAI_IF5_and_IF4p5) return(0); + + break; + + case REMOTE_IF4p5: + if (fmt == OAI_IF4p5_only || fmt == OAI_IF5_and_IF4p5) return(0); + + break; + + case REMOTE_MBP_IF5: + if (fmt == MBP_IF5) return(0); + + break; + + default: + LOG_I(PHY,"No compatible Fronthaul interface found for RRU %d\n", ru->idx); + return(-1); } return(-1); @@ -2450,32 +2341,29 @@ char rru_formats[3][20] = {"OAI_IF5","MBP_IF5","OAI_IF4p5"}; char ru_if_formats[4][20] = {"LOCAL_RF","REMOTE_OAI_IF5","REMOTE_MBP_IF5","REMOTE_OAI_IF4p5"}; void configure_ru(int idx, - void *arg) { - + void *arg) { RU_t *ru = RC.ru[idx]; RRU_config_t *config = (RRU_config_t *)arg; - RRU_capabilities_t *capabilities = (RRU_capabilities_t*)arg; + RRU_capabilities_t *capabilities = (RRU_capabilities_t *)arg; int ret; - LOG_I(PHY, "Received capabilities from RRU %d\n",idx); - if (capabilities->FH_fmt < MAX_FH_FMTs) LOG_I(PHY, "RU FH options %s\n",rru_format_options[capabilities->FH_fmt]); + ret=check_capabilities(ru,capabilities); AssertFatal((ret == 0), - "Cannot configure RRU %d, check_capabilities returned %d\n", idx,ret); + "Cannot configure RRU %d, check_capabilities returned %d\n", idx,ret); // take antenna capabilities of RRU ru->nb_tx = capabilities->nb_tx[0]; ru->nb_rx = capabilities->nb_rx[0]; - // Pass configuration to RRU LOG_I(PHY, "Using %s fronthaul (%d), band %d \n",ru_if_formats[ru->if_south],ru->if_south,ru->frame_parms.eutra_band); - // wait for configuration + // wait for configuration config->FH_fmt = ru->if_south; config->num_bands = 1; config->band_list[0] = ru->frame_parms.eutra_band; - config->tx_freq[0] = ru->frame_parms.dl_CarrierFreq; - config->rx_freq[0] = ru->frame_parms.ul_CarrierFreq; + config->tx_freq[0] = ru->frame_parms.dl_CarrierFreq; + config->rx_freq[0] = ru->frame_parms.ul_CarrierFreq; config->tdd_config[0] = ru->frame_parms.tdd_config; config->tdd_config_S[0] = ru->frame_parms.tdd_config_S; config->att_tx[0] = ru->att_tx; @@ -2483,19 +2371,21 @@ void configure_ru(int idx, config->N_RB_DL[0] = ru->frame_parms.N_RB_DL; config->N_RB_UL[0] = ru->frame_parms.N_RB_UL; config->threequarter_fs[0] = ru->frame_parms.threequarter_fs; + if (ru->if_south==REMOTE_IF4p5) { config->prach_FreqOffset[0] = ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; config->prach_ConfigIndex[0] = ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; LOG_I(PHY,"REMOTE_IF4p5: prach_FrequOffset %d, prach_ConfigIndex %d\n", - config->prach_FreqOffset[0],config->prach_ConfigIndex[0]); - + config->prach_FreqOffset[0],config->prach_ConfigIndex[0]); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int i; - for (i=0;i<4;i++) { + + for (i=0; i<4; i++) { config->emtc_prach_CElevel_enable[0][i] = ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i]; config->emtc_prach_FreqOffset[0][i] = ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[i]; config->emtc_prach_ConfigIndex[0][i] = ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i]; } + #endif } @@ -2504,325 +2394,312 @@ void configure_ru(int idx, } void configure_rru(int idx, - void *arg) { - + void *arg) { RRU_config_t *config = (RRU_config_t *)arg; RU_t *ru = RC.ru[idx]; - ru->frame_parms.eutra_band = config->band_list[0]; ru->frame_parms.dl_CarrierFreq = config->tx_freq[0]; ru->frame_parms.ul_CarrierFreq = config->rx_freq[0]; + if (ru->frame_parms.dl_CarrierFreq == ru->frame_parms.ul_CarrierFreq) { LOG_I(PHY,"Setting RRU to TDD frame type\n"); ru->frame_parms.frame_type = TDD; ru->frame_parms.tdd_config = config->tdd_config[0]; - ru->frame_parms.tdd_config_S = config->tdd_config_S[0]; - } - else ru->frame_parms.frame_type = FDD; + ru->frame_parms.tdd_config_S = config->tdd_config_S[0]; + } else ru->frame_parms.frame_type = FDD; + ru->att_tx = config->att_tx[0]; ru->att_rx = config->att_rx[0]; ru->frame_parms.N_RB_DL = config->N_RB_DL[0]; ru->frame_parms.N_RB_UL = config->N_RB_UL[0]; ru->frame_parms.threequarter_fs = config->threequarter_fs[0]; ru->frame_parms.pdsch_config_common.referenceSignalPower = ru->max_pdschReferenceSignalPower-config->att_tx[0]; + if (ru->function==NGFI_RRU_IF4p5) { ru->frame_parms.att_rx = ru->att_rx; ru->frame_parms.att_tx = ru->att_tx; - LOG_I(PHY,"Setting ru->function to NGFI_RRU_IF4p5, prach_FrequOffset %d, prach_ConfigIndex %d, att (%d,%d)\n", - config->prach_FreqOffset[0],config->prach_ConfigIndex[0],ru->att_tx,ru->att_rx); - ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = config->prach_FreqOffset[0]; - ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = config->prach_ConfigIndex[0]; + config->prach_FreqOffset[0],config->prach_ConfigIndex[0],ru->att_tx,ru->att_rx); + ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = config->prach_FreqOffset[0]; + ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = config->prach_ConfigIndex[0]; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - for (int i=0;i<4;i++) { + + for (int i=0; i<4; i++) { ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] = config->emtc_prach_CElevel_enable[0][i]; ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[i] = config->emtc_prach_FreqOffset[0][i]; ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i] = config->emtc_prach_ConfigIndex[0][i]; } + #endif } - - init_frame_parms(&ru->frame_parms,1); + init_frame_parms(&ru->frame_parms,1); fill_rf_config(ru,ru->rf_config_file); - - phy_init_RU(ru); - } void init_precoding_weights(PHY_VARS_eNB *eNB) { - int layer,ru_id,aa,re,ue,tb; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; RU_t *ru; LTE_eNB_DLSCH_t *dlsch; // init precoding weigths - for (ue=0;ue<NUMBER_OF_UE_MAX;ue++) { - for (tb=0;tb<2;tb++) { + for (ue=0; ue<NUMBER_OF_UE_MAX; ue++) { + for (tb=0; tb<2; tb++) { dlsch = eNB->dlsch[ue][tb]; + for (layer=0; layer<4; layer++) { - int nb_tx=0; - for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { - ru = RC.ru[ru_id]; - nb_tx+=ru->nb_tx; - } - dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(nb_tx*sizeof(int32_t*)); - - for (aa=0; aa<nb_tx; aa++) { - dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(fp->ofdm_symbol_size*sizeof(int32_t)); - for (re=0;re<fp->ofdm_symbol_size; re++) { - dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff; - } - } + int nb_tx=0; + + for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { + ru = RC.ru[ru_id]; + nb_tx+=ru->nb_tx; + } + + dlsch->ue_spec_bf_weights[layer] = (int32_t **)malloc16(nb_tx*sizeof(int32_t *)); + + for (aa=0; aa<nb_tx; aa++) { + dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(fp->ofdm_symbol_size*sizeof(int32_t)); + + for (re=0; re<fp->ofdm_symbol_size; re++) { + dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff; + } + } } } } } -void set_function_spec_param(RU_t *ru) -{ +void set_function_spec_param(RU_t *ru) { int ret; switch (ru->if_south) { - case LOCAL_RF: // this is an RU with integrated RF (RRU, eNB) - if (ru->function == NGFI_RRU_IF5) { // IF5 RRU - ru->do_prach = 0; // no prach processing in RU - ru->fh_north_in = NULL; // no shynchronous incoming fronthaul from north - ru->fh_north_out = fh_if5_north_out; // need only to do send_IF5 reception - ru->fh_south_out = tx_rf; // send output to RF - ru->fh_north_asynch_in = fh_if5_north_asynch_in; // TX packets come asynchronously - ru->feprx = NULL; // nothing (this is a time-domain signal) - ru->feptx_ofdm = NULL; // nothing (this is a time-domain signal) - ru->feptx_prec = NULL; // nothing (this is a time-domain signal) - ru->start_if = start_if; // need to start the if interface for if5 - ru->ifdevice.host_type = RRU_HOST; - ru->rfdevice.host_type = RRU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - reset_meas(&ru->rx_fhaul); - reset_meas(&ru->tx_fhaul); - reset_meas(&ru->compression); - reset_meas(&ru->transport); + case LOCAL_RF: // this is an RU with integrated RF (RRU, eNB) + if (ru->function == NGFI_RRU_IF5) { // IF5 RRU + ru->do_prach = 0; // no prach processing in RU + ru->fh_north_in = NULL; // no shynchronous incoming fronthaul from north + ru->fh_north_out = fh_if5_north_out; // need only to do send_IF5 reception + ru->fh_south_out = tx_rf; // send output to RF + ru->fh_north_asynch_in = fh_if5_north_asynch_in; // TX packets come asynchronously + ru->feprx = NULL; // nothing (this is a time-domain signal) + ru->feptx_ofdm = NULL; // nothing (this is a time-domain signal) + ru->feptx_prec = NULL; // nothing (this is a time-domain signal) + ru->start_if = start_if; // need to start the if interface for if5 + ru->ifdevice.host_type = RRU_HOST; + ru->rfdevice.host_type = RRU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + reset_meas(&ru->rx_fhaul); + reset_meas(&ru->tx_fhaul); + reset_meas(&ru->compression); + reset_meas(&ru->transport); + ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); + printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + } else if (ru->function == NGFI_RRU_IF4p5) { + ru->do_prach = 1; // do part of prach processing in RU + ru->fh_north_in = NULL; // no synchronous incoming fronthaul from north + ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception + ru->fh_south_out = tx_rf; // send output to RF + ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously + ru->feprx = (get_thread_worker_conf() == WORKER_DISABLE) ? fep_full :ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_DISABLE) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) + ru->feptx_prec = NULL; + ru->start_if = start_if; // need to start the if interface for if4p5 + ru->ifdevice.host_type = RRU_HOST; + ru->rfdevice.host_type = RRU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + reset_meas(&ru->rx_fhaul); + reset_meas(&ru->tx_fhaul); + reset_meas(&ru->compression); + reset_meas(&ru->transport); + ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); + printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + + malloc_IF4p5_buffer(ru); + } else if (ru->function == eNodeB_3GPP) { + ru->do_prach = 0; // no prach processing in RU + ru->feprx = (get_thread_worker_conf() == WORKER_DISABLE) ? fep_full : ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_DISABLE) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding + ru->feptx_prec = feptx_prec; // this is fep with idft and precoding + ru->fh_north_in = NULL; // no incoming fronthaul from north + ru->fh_north_out = NULL; // no outgoing fronthaul to north + ru->start_if = NULL; // no if interface + ru->rfdevice.host_type = RAU_HOST; + } + + ru->fh_south_in = rx_rf; // local synchronous RF RX + ru->fh_south_out = tx_rf; // local synchronous RF TX + ru->start_rf = start_rf; // need to start the local RF interface + ru->stop_rf = stop_rf; + printf("configuring ru_id %d (start_rf %p)\n", ru->idx, start_rf); + /* + if (ru->function == eNodeB_3GPP) { // configure RF parameters only for 3GPP eNodeB, we need to get them from RAU otherwise + fill_rf_config(ru,rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + } + + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + }*/ + break; + + case REMOTE_IF5: // the remote unit is IF5 RRU + ru->do_prach = 0; + ru->feprx = (get_thread_worker_conf() == WORKER_DISABLE) ? fep_full : fep_full; // this is frequency-shift + DFTs + ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_DISABLE) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs + + if (ru->if_timing == synch_to_other) { + ru->fh_south_in = fh_slave_south_in; // synchronize to master + ru->fh_south_out = fh_if5_mobipass_south_out; // use send_IF5 for mobipass + ru->fh_south_asynch_in = fh_if5_south_asynch_in_mobipass; // UL is asynchronous + } else { + ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception + ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission + ru->fh_south_asynch_in = NULL; // no asynchronous UL + } + ru->start_rf = NULL; // no local RF + ru->stop_rf = NULL; + ru->start_if = start_if; // need to start if interface for IF5 + ru->ifdevice.host_type = RAU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + ru->ifdevice.configure_rru = configure_ru; ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + if (ret<0) { printf("Exiting, cannot initialize transport protocol\n"); exit(-1); } - } - else if (ru->function == NGFI_RRU_IF4p5) { - ru->do_prach = 1; // do part of prach processing in RU - ru->fh_north_in = NULL; // no synchronous incoming fronthaul from north - ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception - ru->fh_south_out = tx_rf; // send output to RF - ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously - ru->feprx = (get_thread_worker_conf() == WORKER_DISABLE) ? fep_full :ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_DISABLE) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) - ru->feptx_prec = NULL; - ru->start_if = start_if; // need to start the if interface for if4p5 - ru->ifdevice.host_type = RRU_HOST; - ru->rfdevice.host_type = RRU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - reset_meas(&ru->rx_fhaul); - reset_meas(&ru->tx_fhaul); - reset_meas(&ru->compression); - reset_meas(&ru->transport); - ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); + break; + + case REMOTE_IF4p5: + ru->do_prach = 0; + ru->feprx = NULL; // DFTs + ru->feptx_prec = feptx_prec; // Precoding operation + ru->feptx_ofdm = NULL; // no OFDM mod + ru->fh_south_in = fh_if4p5_south_in; // synchronous IF4p5 reception + ru->fh_south_out = fh_if4p5_south_out; // synchronous IF4p5 transmission + ru->fh_south_asynch_in = (ru->if_timing == synch_to_other) ? fh_if4p5_south_in : NULL; // asynchronous UL if synch_to_other + ru->fh_north_out = NULL; + ru->fh_north_asynch_in = NULL; + ru->start_rf = NULL; // no local RF + ru->stop_rf = NULL; + ru->start_if = start_if; // need to start if interface for IF4p5 + ru->ifdevice.host_type = RAU_HOST; + ru->ifdevice.eth_params = &ru->eth_params; + ru->ifdevice.configure_rru = configure_ru; + ret = openair0_transport_load(&ru->ifdevice, &ru->openair0_cfg, &ru->eth_params); printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); + if (ret<0) { printf("Exiting, cannot initialize transport protocol\n"); exit(-1); } - malloc_IF4p5_buffer(ru); - } - else if (ru->function == eNodeB_3GPP) { - ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_thread_worker_conf() == WORKER_DISABLE) ? fep_full : ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_DISABLE) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding - ru->feptx_prec = feptx_prec; // this is fep with idft and precoding - ru->fh_north_in = NULL; // no incoming fronthaul from north - ru->fh_north_out = NULL; // no outgoing fronthaul to north - ru->start_if = NULL; // no if interface - ru->rfdevice.host_type = RAU_HOST; - } - ru->fh_south_in = rx_rf; // local synchronous RF RX - ru->fh_south_out = tx_rf; // local synchronous RF TX - ru->start_rf = start_rf; // need to start the local RF interface - ru->stop_rf = stop_rf; - printf("configuring ru_id %d (start_rf %p)\n", ru->idx, start_rf); -/* - if (ru->function == eNodeB_3GPP) { // configure RF parameters only for 3GPP eNodeB, we need to get them from RAU otherwise - fill_rf_config(ru,rf_config_file); - init_frame_parms(&ru->frame_parms,1); - phy_init_RU(ru); - } - - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); - }*/ - break; - - case REMOTE_IF5: // the remote unit is IF5 RRU - ru->do_prach = 0; - ru->feprx = (get_thread_worker_conf() == WORKER_DISABLE) ? fep_full : fep_full; // this is frequency-shift + DFTs - ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_DISABLE) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs - if (ru->if_timing == synch_to_other) { - ru->fh_south_in = fh_slave_south_in; // synchronize to master - ru->fh_south_out = fh_if5_mobipass_south_out; // use send_IF5 for mobipass - ru->fh_south_asynch_in = fh_if5_south_asynch_in_mobipass; // UL is asynchronous - } - else { - ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception - ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission - ru->fh_south_asynch_in = NULL; // no asynchronous UL - } - ru->start_rf = NULL; // no local RF - ru->stop_rf = NULL; - ru->start_if = start_if; // need to start if interface for IF5 - ru->ifdevice.host_type = RAU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - ru->ifdevice.configure_rru = configure_ru; - - ret = openair0_transport_load(&ru->ifdevice,&ru->openair0_cfg,&ru->eth_params); - printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - break; - - case REMOTE_IF4p5: - ru->do_prach = 0; - ru->feprx = NULL; // DFTs - ru->feptx_prec = feptx_prec; // Precoding operation - ru->feptx_ofdm = NULL; // no OFDM mod - ru->fh_south_in = fh_if4p5_south_in; // synchronous IF4p5 reception - ru->fh_south_out = fh_if4p5_south_out; // synchronous IF4p5 transmission - ru->fh_south_asynch_in = (ru->if_timing == synch_to_other) ? fh_if4p5_south_in : NULL; // asynchronous UL if synch_to_other - ru->fh_north_out = NULL; - ru->fh_north_asynch_in = NULL; - ru->start_rf = NULL; // no local RF - ru->stop_rf = NULL; - ru->start_if = start_if; // need to start if interface for IF4p5 - ru->ifdevice.host_type = RAU_HOST; - ru->ifdevice.eth_params = &ru->eth_params; - ru->ifdevice.configure_rru = configure_ru; - - ret = openair0_transport_load(&ru->ifdevice, &ru->openair0_cfg, &ru->eth_params); - printf("openair0_transport_init returns %d for ru_id %d\n", ret, ru->idx); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - malloc_IF4p5_buffer(ru); - - break; + malloc_IF4p5_buffer(ru); + break; - default: - LOG_E(PHY,"RU with invalid or unknown southbound interface type %d\n",ru->if_south); - break; + default: + LOG_E(PHY,"RU with invalid or unknown southbound interface type %d\n",ru->if_south); + break; } // switch on interface type } //extern void RCconfig_RU(void); void init_RU(char *rf_config_file) { - int ru_id; RU_t *ru; PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; int i; int CC_id; - // create status mask RC.ru_mask = 0; pthread_mutex_init(&RC.ru_mutex,NULL); pthread_cond_init(&RC.ru_cond,NULL); - // read in configuration file) printf("configuring RU from file\n"); RCconfig_RU(); LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",RC.nb_L1_inst,RC.nb_RU,get_nprocs()); if (RC.nb_CC != 0) - for (i=0;i<RC.nb_L1_inst;i++) - for (CC_id=0;CC_id<RC.nb_CC[i];CC_id++) RC.eNB[i][CC_id]->num_RU=0; + for (i=0; i<RC.nb_L1_inst; i++) + for (CC_id=0; CC_id<RC.nb_CC[i]; CC_id++) RC.eNB[i][CC_id]->num_RU=0; LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); - for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { + + for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { LOG_D(PHY,"Process RC.ru[%d]\n",ru_id); ru = RC.ru[ru_id]; ru->rf_config_file = rf_config_file; - ru->idx = ru_id; + ru->idx = ru_id; ru->ts_offset = 0; // use eNB_list[0] as a reference for RU frame parameters // NOTE: multiple CC_id are not handled here yet! - if (ru->num_eNB > 0) { LOG_D(PHY, "%s() RC.ru[%d].num_eNB:%d ru->eNB_list[0]:%p RC.eNB[0][0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], RC.eNB[0][0], ru->rf_config_file); - if (ru->eNB_list[0] == 0) - { + if (ru->eNB_list[0] == 0) { LOG_E(PHY,"%s() DJP - ru->eNB_list ru->num_eNB are not initialized - so do it manually\n", __FUNCTION__); ru->eNB_list[0] = RC.eNB[0][0]; ru->num_eNB=1; - // - // DJP - feptx_prec() / feptx_ofdm() parses the eNB_list (based on num_eNB) and copies the txdata_F to txdata in RU - // - - } - else - { + // + // DJP - feptx_prec() / feptx_ofdm() parses the eNB_list (based on num_eNB) and copies the txdata_F to txdata in RU + // + } else { LOG_E(PHY,"DJP - delete code above this %s:%d\n", __FILE__, __LINE__); } } + eNB0 = ru->eNB_list[0]; LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south); LOG_D(PHY, "eNB0:%p\n", eNB0); - if (eNB0) - { + + if (eNB0) { if ((ru->function != NGFI_RRU_IF5) && (ru->function != NGFI_RRU_IF4p5)) AssertFatal(eNB0!=NULL,"eNB0 is null!\n"); if (eNB0) { LOG_I(PHY,"Copying frame parms from eNB %d to ru %d\n",eNB0->Mod_id,ru->idx); - memcpy((void*)&ru->frame_parms,(void*)&eNB0->frame_parms,sizeof(LTE_DL_FRAME_PARMS)); - + memcpy((void *)&ru->frame_parms,(void *)&eNB0->frame_parms,sizeof(LTE_DL_FRAME_PARMS)); // attach all RU to all eNBs in its list/ LOG_D(PHY,"ru->num_eNB:%d eNB0->num_RU:%d\n", ru->num_eNB, eNB0->num_RU); - for (i=0;i<ru->num_eNB;i++) { + + for (i=0; i<ru->num_eNB; i++) { eNB0 = ru->eNB_list[i]; eNB0->RU_list[eNB0->num_RU++] = ru; } } } - LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); + LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); set_function_spec_param(ru); LOG_I(PHY,"Starting ru_thread %d\n",ru_id); - init_RU_proc(ru); - - - } // for ru_id // sleep(1); LOG_D(HW,"[lte-softmodem.c] RU threads created\n"); - - } -void stop_RU(int nb_ru) -{ +void stop_RU(int nb_ru) { for (int inst = 0; inst < nb_ru; inst++) { LOG_I(PHY, "Stopping RU %d processing threads\n", inst); kill_RU_proc(RC.ru[inst]); @@ -2833,107 +2710,89 @@ void stop_RU(int nb_ru) //This funtion is for initializing ru pointer for L2 FAPI simulator. #if defined(PRE_SCD_THREAD) void init_ru_vnf(void) { - int ru_id; RU_t *ru; RU_proc_t *proc; -// PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; + // PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; int i; int CC_id; - - dlsch_ue_select_tbl_in_use = 1; - - // create status mask RC.ru_mask = 0; pthread_mutex_init(&RC.ru_mutex,NULL); pthread_cond_init(&RC.ru_cond,NULL); - // read in configuration file) printf("configuring RU from file\n"); RCconfig_RU(); LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",RC.nb_L1_inst,RC.nb_RU,get_nprocs()); if (RC.nb_CC != 0) - for (i=0;i<RC.nb_L1_inst;i++) - for (CC_id=0;CC_id<RC.nb_CC[i];CC_id++) RC.eNB[i][CC_id]->num_RU=0; + for (i=0; i<RC.nb_L1_inst; i++) + for (CC_id=0; CC_id<RC.nb_CC[i]; CC_id++) RC.eNB[i][CC_id]->num_RU=0; LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); - for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { + + for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { LOG_D(PHY,"Process RC.ru[%d]\n",ru_id); ru = RC.ru[ru_id]; -// ru->rf_config_file = rf_config_file; - ru->idx = ru_id; + // ru->rf_config_file = rf_config_file; + ru->idx = ru_id; ru->ts_offset = 0; // use eNB_list[0] as a reference for RU frame parameters // NOTE: multiple CC_id are not handled here yet! if (ru->num_eNB > 0) { -// LOG_D(PHY, "%s() RC.ru[%d].num_eNB:%d ru->eNB_list[0]:%p RC.eNB[0][0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], RC.eNB[0][0], ru->rf_config_file); - - if (ru->eNB_list[0] == 0) - { + // LOG_D(PHY, "%s() RC.ru[%d].num_eNB:%d ru->eNB_list[0]:%p RC.eNB[0][0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], RC.eNB[0][0], ru->rf_config_file); + if (ru->eNB_list[0] == 0) { LOG_E(PHY,"%s() DJP - ru->eNB_list ru->num_eNB are not initialized - so do it manually\n", __FUNCTION__); ru->eNB_list[0] = RC.eNB[0][0]; ru->num_eNB=1; - // - // DJP - feptx_prec() / feptx_ofdm() parses the eNB_list (based on num_eNB) and copies the txdata_F to txdata in RU - // - } - else - { + // + // DJP - feptx_prec() / feptx_ofdm() parses the eNB_list (based on num_eNB) and copies the txdata_F to txdata in RU + // + } else { LOG_E(PHY,"DJP - delete code above this %s:%d\n", __FILE__, __LINE__); } } -// frame_parms is not used in L2 FAPI simulator -/* - eNB0 = ru->eNB_list[0]; - LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south); - LOG_D(PHY, "eNB0:%p\n", eNB0); - if (eNB0) - { - if ((ru->function != NGFI_RRU_IF5) && (ru->function != NGFI_RRU_IF4p5)) - AssertFatal(eNB0!=NULL,"eNB0 is null!\n"); - - if (eNB0) { - LOG_I(PHY,"Copying frame parms from eNB %d to ru %d\n",eNB0->Mod_id,ru->idx); - memcpy((void*)&ru->frame_parms,(void*)&eNB0->frame_parms,sizeof(LTE_DL_FRAME_PARMS)); - - // attach all RU to all eNBs in its list/ - LOG_D(PHY,"ru->num_eNB:%d eNB0->num_RU:%d\n", ru->num_eNB, eNB0->num_RU); - for (i=0;i<ru->num_eNB;i++) { - eNB0 = ru->eNB_list[i]; - eNB0->RU_list[eNB0->num_RU++] = ru; + // frame_parms is not used in L2 FAPI simulator + /* + eNB0 = ru->eNB_list[0]; + LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south); + LOG_D(PHY, "eNB0:%p\n", eNB0); + if (eNB0) + { + if ((ru->function != NGFI_RRU_IF5) && (ru->function != NGFI_RRU_IF4p5)) + AssertFatal(eNB0!=NULL,"eNB0 is null!\n"); + + if (eNB0) { + LOG_I(PHY,"Copying frame parms from eNB %d to ru %d\n",eNB0->Mod_id,ru->idx); + memcpy((void*)&ru->frame_parms,(void*)&eNB0->frame_parms,sizeof(LTE_DL_FRAME_PARMS)); + + // attach all RU to all eNBs in its list/ + LOG_D(PHY,"ru->num_eNB:%d eNB0->num_RU:%d\n", ru->num_eNB, eNB0->num_RU); + for (i=0;i<ru->num_eNB;i++) { + eNB0 = ru->eNB_list[i]; + eNB0->RU_list[eNB0->num_RU++] = ru; + } + } } - } - } -*/ + */ LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); - -// set_function_spec_param(ru); + // set_function_spec_param(ru); LOG_I(PHY,"Starting ru_thread %d\n",ru_id); - -// init_RU_proc(ru); - + // init_RU_proc(ru); proc = &ru->proc; - memset((void*)proc,0,sizeof(RU_proc_t)); - + memset((void *)proc,0,sizeof(RU_proc_t)); proc->instance_pre_scd = -1; pthread_mutex_init( &proc->mutex_pre_scd, NULL); pthread_cond_init( &proc->cond_pre_scd, NULL); - pthread_create(&proc->pthread_pre_scd, NULL, pre_scd_thread, (void*)ru); + pthread_create(&proc->pthread_pre_scd, NULL, pre_scd_thread, (void *)ru); pthread_setname_np(proc->pthread_pre_scd, "pre_scd_thread"); - } // for ru_id - - // sleep(1); LOG_D(HW,"[lte-softmodem.c] RU threads created\n"); - - } #endif @@ -2941,42 +2800,30 @@ void init_ru_vnf(void) { /* --------------------------------------------------------*/ /* from here function to use configuration module */ void RCconfig_RU(void) { - int j = 0; int i = 0; - - paramdef_t RUParams[] = RUPARAMS_DESC; paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; + config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL); - - config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL); - - if ( RUParamList.numelt > 0) { - - RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*)); - - - - + RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *)); RC.ru_mask=(1<<RC.nb_RU) - 1; printf("Set RU mask to %lx\n",RC.ru_mask); for (j = 0; j < RC.nb_RU; j++) { - - RC.ru[j] = (RU_t*)malloc(sizeof(RU_t)); - memset((void*)RC.ru[j],0,sizeof(RU_t)); + RC.ru[j] = (RU_t *)malloc(sizeof(RU_t)); + memset((void *)RC.ru[j],0,sizeof(RU_t)); RC.ru[j]->idx = j; - printf("Creating RC.ru[%d]:%p\n", j, RC.ru[j]); - RC.ru[j]->if_timing = synch_to_ext_device; + if (RC.nb_L1_inst >0) RC.ru[j]->num_eNB = RUParamList.paramarray[j][RU_ENB_LIST_IDX].numelt; else - RC.ru[j]->num_eNB = 0; - for (i=0;i<RC.ru[j]->num_eNB;i++) RC.ru[j]->eNB_list[i] = RC.eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; + RC.ru[j]->num_eNB = 0; + + for (i=0; i<RC.ru[j]->num_eNB; i++) RC.ru[j]->eNB_list[i] = RC.eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) { RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr)); @@ -2998,91 +2845,90 @@ void RCconfig_RU(void) { } if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { - if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = eNodeB_3GPP; - printf("Setting function for RU %d to eNodeB_3GPP\n",j); - } - else { - RC.ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); - RC.ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); + if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { + RC.ru[j]->if_south = LOCAL_RF; + RC.ru[j]->function = eNodeB_3GPP; + printf("Setting function for RU %d to eNodeB_3GPP\n",j); + } else { + RC.ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); + RC.ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); RC.ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); RC.ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); RC.ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); - if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; - printf("Setting function for RU %d to NGFI_RRU_IF5 (udp)\n",j); - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE; - printf("Setting function for RU %d to NGFI_RRU_IF5 (raw)\n",j); - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; - printf("Setting function for RU %d to NGFI_RRU_IF4p5 (udp)\n",j); - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; - printf("Setting function for RU %d to NGFI_RRU_IF4p5 (raw)\n",j); - } - } - RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; - RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); - RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; - for (i=0;i<RC.ru[j]->num_bands;i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; + if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { + RC.ru[j]->if_south = LOCAL_RF; + RC.ru[j]->function = NGFI_RRU_IF5; + RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF5 (udp)\n",j); + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { + RC.ru[j]->if_south = LOCAL_RF; + RC.ru[j]->function = NGFI_RRU_IF5; + RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF5 (raw)\n",j); + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { + RC.ru[j]->if_south = LOCAL_RF; + RC.ru[j]->function = NGFI_RRU_IF4p5; + RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF4p5 (udp)\n",j); + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { + RC.ru[j]->if_south = LOCAL_RF; + RC.ru[j]->function = NGFI_RRU_IF4p5; + RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF4p5 (raw)\n",j); + } + } + + RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; + RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); + RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; + + for (i=0; i<RC.ru[j]->num_bands; i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; } //strcmp(local_rf, "yes") == 0 else { - printf("RU %d: Transport %s\n",j,*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr)); - - RC.ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); - RC.ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); - RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); - RC.ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); - RC.ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); - if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { - RC.ru[j]->if_south = REMOTE_IF5; - RC.ru[j]->function = NGFI_RAU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { - RC.ru[j]->if_south = REMOTE_IF5; - RC.ru[j]->function = NGFI_RAU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE; - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { - RC.ru[j]->if_south = REMOTE_IF4p5; - RC.ru[j]->function = NGFI_RAU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { - RC.ru[j]->if_south = REMOTE_IF4p5; - RC.ru[j]->function = NGFI_RAU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; - } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if5_mobipass") == 0) { - RC.ru[j]->if_south = REMOTE_IF5; - RC.ru[j]->function = NGFI_RAU_IF5; - RC.ru[j]->if_timing = synch_to_other; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF5_MOBIPASS; - } + printf("RU %d: Transport %s\n",j,*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr)); + RC.ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); + RC.ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); + RC.ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); + RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); + RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + RC.ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); + RC.ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); + + if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { + RC.ru[j]->if_south = REMOTE_IF5; + RC.ru[j]->function = NGFI_RAU_IF5; + RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { + RC.ru[j]->if_south = REMOTE_IF5; + RC.ru[j]->function = NGFI_RAU_IF5; + RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { + RC.ru[j]->if_south = REMOTE_IF4p5; + RC.ru[j]->function = NGFI_RAU_IF4p5; + RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { + RC.ru[j]->if_south = REMOTE_IF4p5; + RC.ru[j]->function = NGFI_RAU_IF4p5; + RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if5_mobipass") == 0) { + RC.ru[j]->if_south = REMOTE_IF5; + RC.ru[j]->function = NGFI_RAU_IF5; + RC.ru[j]->if_timing = synch_to_other; + RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF5_MOBIPASS; + } } /* strcmp(local_rf, "yes") != 0 */ RC.ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); RC.ru[j]->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); - RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); }// j=0..num_rus } else { - RC.nb_RU = 0; + RC.nb_RU = 0; } // setting != NULL return; - } diff --git a/targets/RT/USER/lte-softmodem-common.c b/targets/RT/USER/lte-softmodem-common.c index 814800ccfcb6bb1572197d856fba2cd79cc841d6..0a637975368e4be03f98f53eb844e17cff13a411 100644 --- a/targets/RT/USER/lte-softmodem-common.c +++ b/targets/RT/USER/lte-softmodem-common.c @@ -94,3 +94,13 @@ void get_common_options(void) { if(worker_config != NULL) set_worker_conf(worker_config); } + +unsigned int is_nos1exec(char *exepath) { + if ( strcmp( basename(exepath), "lte-softmodem-nos1") == 0) + return 1; + + if ( strcmp( basename(exepath), "lte-uesoftmodem-nos1") == 0) + return 1; + + return 0; +} diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index b349b06a06b3cfae572bd77bfaa53344f3d6ed45..9c736f8172285af4e0a0d46783d3c24cf160d2b3 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -82,9 +82,9 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "UTIL/OTG/otg_vars.h" #endif -#if defined(ENABLE_ITTI) - #include "create_tasks.h" -#endif + +#include "create_tasks.h" + #include "PHY/INIT/phy_init.h" @@ -107,9 +107,6 @@ unsigned short config_frames[4] = {2,9,11,13}; static pthread_t forms_thread; //xforms #endif //XFORMS -#ifndef ENABLE_USE_MME - #define EPC_MODE_ENABLED 0 -#endif pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; @@ -482,7 +479,7 @@ void wait_eNBs(void) { printf("eNB L1 are configured\n"); } -#if defined(ENABLE_ITTI) + /* * helper function to terminate a certain ITTI task */ @@ -578,7 +575,7 @@ int restart_L1L2(module_id_t enb_id) { pthread_mutex_unlock(&sync_mutex); return 0; } -#endif + static void wait_nfapi_init(char *thread_name) { printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); @@ -612,6 +609,11 @@ int main( int argc, char **argv ) { printf("Reading in command-line options\n"); get_options (); + if (is_nos1exec(argv[0]) ) + set_softmodem_optmask(SOFTMODEM_NOS1_BIT); + + EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; + if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { fprintf(stderr,"Getting configuration failed\n"); exit(-1); @@ -629,8 +631,7 @@ int main( int argc, char **argv ) { } cpuf=get_cpu_freq_GHz(); -#if defined(ENABLE_ITTI) - printf("ITTI init, useMME: %i\n" ,EPC_MODE_ENABLED); + printf("ITTI init, useMME: %i\n",EPC_MODE_ENABLED); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); // initialize mscgen log after ITTI @@ -639,15 +640,7 @@ int main( int argc, char **argv ) { } MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); -#endif init_opt(); -#ifdef PDCP_USE_NETLINK - printf("PDCP netlink\n"); - netlink_init(); -#if defined(PDCP_USE_NETLINK_QUEUES) - pdcp_netlink_init(); -#endif -#endif // to make a graceful exit when ctrl-c is pressed signal(SIGSEGV, signal_handler); signal(SIGINT, signal_handler); @@ -660,49 +653,8 @@ int main( int argc, char **argv ) { LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); printf("Runtime table\n"); fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); -#ifndef DEADLINE_SCHEDULER - printf("NO deadline scheduler\n"); - /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ - cpu_set_t cpuset; - int s; - char cpu_affinity[1024]; - CPU_ZERO(&cpuset); -#ifdef CPU_AFFINITY - - if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); - s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - - if (s != 0) { - perror( "pthread_setaffinity_np"); - exit_fun("Error setting processor affinity"); - } - - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); - } - -#endif - /* Check the actual affinity mask assigned to the thread */ - s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - - if (s != 0) { - perror( "pthread_getaffinity_np"); - exit_fun("Error getting processor affinity "); - } - - memset(cpu_affinity, 0 , sizeof(cpu_affinity)); - - for (int j = 0; j < CPU_SETSIZE; j++) { - if (CPU_ISSET(j, &cpuset)) { - char temp[1024]; - sprintf(temp, " CPU_%d ", j); - strcat(cpu_affinity, temp); - } - } - - LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); -#endif -#if defined(ENABLE_ITTI) + pdcp_module_init( ( IS_SOFTMODEM_NOS1 && !(IS_SOFTMODEM_NOKRNMOD))? (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT); +# if (RC.nb_inst > 0) { // don't create if node doesn't connect to RRC/S1/GTP @@ -717,7 +669,6 @@ int main( int argc, char **argv ) { RCconfig_L1(); } -#endif /* Start the agent. If it is turned off in the configuration, it won't start */ RCconfig_flexran(); @@ -770,7 +721,7 @@ int main( int argc, char **argv ) { rt_sleep_ns(10*100000000ULL); if (nfapi_mode) { - printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); + LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); } @@ -795,18 +746,16 @@ int main( int argc, char **argv ) { break; } - printf("NFAPI MODE:%s\n", nfapi_mode_str); - + LOG_I(ENB_APP,"NFAPI MODE:%s\n", nfapi_mode_str); -if (nfapi_mode==2) {// VNF + if (nfapi_mode==2) {// VNF #if defined(PRE_SCD_THREAD) init_ru_vnf(); // ru pointer is necessary for pre_scd. #endif wait_nfapi_init("main?"); } - - printf("START MAIN THREADS\n"); + LOG_I(ENB_APP,"START MAIN THREADS\n"); // start the main threads number_of_cards = 1; printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); @@ -820,7 +769,6 @@ if (nfapi_mode==2) {// VNF printf("wait_eNBs()\n"); wait_eNBs(); - printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. @@ -829,7 +777,8 @@ if (nfapi_mode==2) {// VNF if (RC.nb_RU >0 && nfapi_mode != 2) { printf("Initializing RU threads\n"); init_RU(get_softmodem_params()->rf_config_file); - for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { + + 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+(get_softmodem_params()->chain_offset); } @@ -845,43 +794,32 @@ if (nfapi_mode==2) {// VNF fflush(stdout); fflush(stderr); wait_RUs(); - printf("ALL RUs READY!\n"); - printf("RC.nb_RU:%d\n", RC.nb_RU); + LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU); // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init eNBs\n"); if (nfapi_mode != 1 && nfapi_mode != 2) { - printf("Not NFAPI mode - call init_eNB_afterRU()\n"); + LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n"); init_eNB_afterRU(); } else { - printf("NFAPI mode - DO NOT call init_eNB_afterRU()\n"); + LOG_I(ENB_APP,"NFAPI mode - DO NOT call init_eNB_afterRU()\n"); } - printf("ALL RUs ready - ALL eNBs ready\n"); + LOG_UI(ENB_APP,"ALL RUs ready - ALL eNBs ready\n"); // connect the TX/RX buffers sleep(1); /* wait for thread activation */ - printf("Sending sync to all threads\n"); + LOG_I(ENB_APP,"Sending sync to all threads\n"); pthread_mutex_lock(&sync_mutex); sync_var=0; pthread_cond_broadcast(&sync_cond); pthread_mutex_unlock(&sync_mutex); config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS); // wait for end of program - printf("TYPE <CTRL-C> TO TERMINATE\n"); + LOG_UI(ENB_APP,"TYPE <CTRL-C> TO TERMINATE\n"); //getchar(); -#if defined(ENABLE_ITTI) - printf("Entering ITTI signals handler\n"); itti_wait_tasks_end(); - printf("Returned from ITTI signal handler\n"); oai_exit=1; - printf("oai_exit=%d\n",oai_exit); -#else - - while (oai_exit==0) - rt_sleep_ns(100000000ULL); - - printf("Terminating application - oai_exit=%d\n",oai_exit); -#endif + LOG_I(ENB_APP,"oai_exit=%d\n",oai_exit); // stop threads #ifdef XFORMS printf("waiting for XFORMS thread\n"); @@ -902,7 +840,7 @@ if (nfapi_mode==2) {// VNF } #endif - printf("stopping MODEM threads\n"); + LOG_I(ENB_APP,"stopping MODEM threads\n"); stop_eNB(NB_eNB_INST); stop_RU(RC.nb_RU); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 85ee4765f09b283577845ec4e9a7e6a0355d263c..39f997a71f5a53ceab82a2ee1478a2a6d6d560ff 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -33,15 +33,8 @@ #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "flexran_agent.h" - -#if defined(ENABLE_ITTI) - #if defined(ENABLE_USE_MME) - #include "s1ap_eNB.h" - #ifdef PDCP_USE_NETLINK - #include "SIMULATION/ETH_TRANSPORT/proto.h" - #endif - #endif -#endif +#include "s1ap_eNB.h" +#include "SIMULATION/ETH_TRANSPORT/proto.h" /* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ #define CONFIG_HLP_RFCFGF "Configuration file for front-end (e.g. LMS7002M)\n" @@ -245,6 +238,8 @@ #define SOFTMODEM_NOS1_BIT (1<<0) #define SOFTMODEM_NOKRNMOD_BIT (1<<1) #define SOFTMODEM_NONBIOT_BIT (1<<2) +#define SOFTMODEM_BASICSIM_BIT (1<<10) + typedef struct { uint64_t optmask; THREAD_STRUCT thread_struct; @@ -265,11 +260,12 @@ typedef struct { #define IS_SOFTMODEM_NOS1 ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT) #define IS_SOFTMODEM_NOKRNMOD ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT) #define IS_SOFTMODEM_NONBIOT ( get_softmodem_optmask() & SOFTMODEM_NONBIOT_BIT) +#define IS_SOFTMODEM_BASICSIM ( get_softmodem_optmask() & SOFTMODEM_BASICSIM_BIT) extern uint64_t get_softmodem_optmask(void); extern uint64_t set_softmodem_optmask(uint64_t bitmask); extern void get_common_options(void); extern softmodem_params_t *get_softmodem_params(void); - +extern unsigned int is_nos1exec(char *exepath) ; uint64_t get_pdcp_optmask(void); extern pthread_cond_t sync_cond; extern pthread_mutex_t sync_mutex; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 13cc859414314ccc8d2162c2962c35111571bd3a..b19d440b0d09a10c12150e95557b89a0f76aecb4 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -110,10 +110,8 @@ pthread_mutex_t nfapi_sync_mutex; int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex uint8_t nfapi_mode = 0; -#ifdef PDCP_USE_NETLINK #ifdef UESIM_EXPANSION -uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; -#endif + uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; #endif uint16_t sf_ahead=2; int tddflag; @@ -443,12 +441,16 @@ static void get_options(void) { if (dumpframe > 0) mode = rx_dump_frame; +# if BASIC_SIMULATOR + set_softmodem_optmask(SOFTMODEM_BASICSIM_BIT); //this BASIC_SIMULATOR should be a config option +# endif + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; } UE_scan=0; - + if (tddflag > 0) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { frame_parms[CC_id]->frame_type = TDD; @@ -681,10 +683,8 @@ int main( int argc, char **argv ) { #endif int CC_id; uint8_t abstraction_flag=0; -#ifdef PDCP_USE_NETLINK #ifdef UESIM_EXPANSION memset(inst_pdcp_list, 0, sizeof(inst_pdcp_list)); -#endif #endif // Default value for the number of UEs. It will hold, // if not changed from the command line option --num-ues @@ -694,9 +694,7 @@ int main( int argc, char **argv ) { int ret; #endif configmodule_interface_t *config_mod; - start_background_system(); - config_mod = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); if (config_mod == NULL) { @@ -712,6 +710,11 @@ int main( int argc, char **argv ) { for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23; get_options (); + + if (is_nos1exec(argv[0]) ) + set_softmodem_optmask(SOFTMODEM_NOS1_BIT); + + EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; printf("Running with %d UE instances\n",NB_UE_INST); if (NB_UE_INST > 1 && simL1flag != 1 && nfapi_mode != 3) { @@ -722,15 +725,17 @@ int main( int argc, char **argv ) { printf("NFAPI_MODE value: %d \n", nfapi_mode); // Checking option of nums_ue_thread. - if(NB_THREAD_INST < 1){ + if(NB_THREAD_INST < 1) { printf("Running with 0 UE rxtx thread, exiting.\n"); abort(); } + // Checking option's relation between nums_ue_thread and num-ues - if(NB_UE_INST <NB_THREAD_INST ){ + if(NB_UE_INST <NB_THREAD_INST ) { printf("Number of UEs < number of UE rxtx threads, exiting.\n"); abort(); } + // Not sure if the following is needed here /*if (CONFIG_ISFLAGSET(CONFIG_ABORT)) { if (UE_flag == 0) { @@ -742,8 +747,6 @@ int main( int argc, char **argv ) { nfapi_mode = 4; } }*/ - - #if T_TRACER T_Config_Init(); #endif @@ -764,13 +767,13 @@ int main( int argc, char **argv ) { MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); #endif init_opt(); -#ifdef PDCP_USE_NETLINK - printf("PDCP netlink\n"); - netlink_init(); -#if defined(PDCP_USE_NETLINK_QUEUES) - pdcp_netlink_init(); -#endif -#endif + uint32_t pdcp_initmask = ((!IS_SOFTMODEM_NOS1) || IS_SOFTMODEM_NOKRNMOD)? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); + + if ( IS_SOFTMODEM_BASICSIM || (nfapi_mode == 3) ) { + pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; + } + + pdcp_module_init( pdcp_initmask ); //TTN for D2D #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) printf ("RRC control socket\n"); @@ -818,38 +821,6 @@ int main( int argc, char **argv ) { RCConfig_sim(); } -// source code written in below moved to later to avoid keeping waiting for nfapi_sync_cond in wait_nfapi_init. -/* - // start the main UE threads - int eMBMS_active = 0; - - if (nfapi_mode==3) { // UE-STUB-PNF - config_sync_var=0; - wait_nfapi_init("main?"); - //Panos: Temporarily we will be using single set of threads for multiple UEs. - //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); - init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); - } else { - init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], - frame_parms[0]); - } - - if (get_softmodem_params()->phy_test==0) { - printf("Filling UE band info\n"); - fill_ue_band_info(); - dl_phy_sync_success (0, 0, 0, 1); - } - - if (nfapi_mode!=3) { - number_of_cards = 1; - - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id]->rf_map.card=0; - PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); - } - } -*/ - cpuf=get_cpu_freq_GHz(); #ifndef DEADLINE_SCHEDULER printf("NO deadline scheduler\n"); @@ -881,7 +852,7 @@ int main( int argc, char **argv ) { exit_fun("Error getting processor affinity "); } - memset(cpu_affinity, 0 , sizeof(cpu_affinity)); + memset(cpu_affinity, 0, sizeof(cpu_affinity)); for (int j = 0; j < CPU_SETSIZE; j++) { if (CPU_ISSET(j, &cpuset)) { @@ -894,6 +865,7 @@ int main( int argc, char **argv ) { LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); #endif #if defined(ENABLE_ITTI) + if (create_tasks_ue(NB_UE_INST) < 0) { printf("cannot create ITTI tasks\n"); exit(-1); // need a softer mode @@ -939,33 +911,32 @@ int main( int argc, char **argv ) { printf("NFAPI MODE:%s\n", nfapi_mode_str); - if (nfapi_mode==3) // UE-STUB-PNF - { - config_sync_var=0; - wait_nfapi_init("main?"); - //Panos: Temporarily we will be using single set of threads for multiple UEs. - //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); - init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); - } - else { - init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], - frame_parms[0]); + if (nfapi_mode==3) { // UE-STUB-PNF + config_sync_var=0; + wait_nfapi_init("main?"); + //Panos: Temporarily we will be using single set of threads for multiple UEs. + //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); + init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); + } else { + init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], + frame_parms[0]); } - if (get_softmodem_params()->phy_test==0) { printf("Filling UE band info\n"); fill_ue_band_info(); dl_phy_sync_success (0, 0, 0, 1); } - if (nfapi_mode!=3){ - number_of_cards = 1; - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id]->rf_map.card=0; - PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); - } + if (nfapi_mode!=3) { + number_of_cards = 1; + + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[0][CC_id]->rf_map.card=0; + PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); + } } + // connect the TX/RX buffers /*