diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 1574f5366a5f4222ea68d299d601824edf0a09df..e81db5366e1e5d5dd8471e03ab5c4c2ffa83ca10 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -27,8 +27,8 @@ cmake_minimum_required (VERSION 2.8) # Base directories, compatible with legacy OAI building ################################################ set (OPENAIR_DIR $ENV{OPENAIR_DIR}) -set (NFAPI_DIR $ENV{NFAPI_DIR}) -set (NFAPI_USER_DIR ${OPENAIR_DIR}/nfapi) +set (NFAPI_DIR ${OPENAIR_DIR}/nfapi/open-nFAPI) +set (NFAPI_USER_DIR ${OPENAIR_DIR}/nfapi/oai_integration) set (OPENAIR1_DIR ${OPENAIR_DIR}/openair1) set (OPENAIR2_DIR ${OPENAIR_DIR}/openair2) set (OPENAIR3_DIR ${OPENAIR_DIR}/openair3) @@ -241,6 +241,7 @@ add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace") add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace") add_boolean_option(DISABLE_LOG_X False "Deactivate all LOG_* macros") +add_boolean_option(USRP_REC_PLAY False "Enable USRP record playback mode") add_boolean_option(DEBUG_CONSOLE False "makes debugging easier, disables stdout/stderr buffering") @@ -261,9 +262,6 @@ if (${ENABLE_ITTI}) set(GTPU_need_ITTI ${OPENAIR3_DIR}/GTPV1-U/gtpv1u_eNB.c) endif (${ENABLE_ITTI}) -add_boolean_option(RTAI False "Use RTAI") - - ############################# # ASN.1 grammar C code generation & dependancies ################################ @@ -484,7 +482,6 @@ include_directories ("${X2AP_DIR}") ################################### add_list1_option(NB_ANTENNAS_RX "2" "Number of antennas in reception" "1" "2" "4") add_list1_option(NB_ANTENNAS_TX "4" "Number of antennas in transmission" "1" "2" "4") -add_list1_option(NB_ANTENNAS_TXRX "2" "Number of antennas in ????" "1" "2" "4") add_list2_option(RF_BOARD "EXMIMO" "RF head type" "None" "EXMIMO" "OAI_USRP" "OAI_BLADERF" "CPRIGW" "OAI_LMSSDR") @@ -586,15 +583,13 @@ Message("CPU_Affinity flag is ${CPU_AFFINITY}") 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(USER_MODE True "????") add_boolean_option(RRC_DEFAULT_RAB_IS_AM False "set the RLC mode to AM for the default bearer") add_boolean_option(OAI_NW_DRIVER_TYPE_ETHERNET False "????") -add_boolean_option(DISABLE_USE_NAS False "???") add_boolean_option(DEADLINE_SCHEDULER True "Use the Linux scheduler SCHED_DEADLINE: kernel >= 3.14") add_boolean_option(CPU_AFFINITY False "Enable CPU Affinity of threads (only valid without deadline scheduler). It is enabled only with >2 CPUs") add_boolean_option(NAS_ADDRESS_FIX False "specific to oaisim: for nasmesh driver") -add_boolean_option(NAS_NETLINK False "???? Must be True to compile nasmesh driver without rtai") +add_boolean_option(NAS_NETLINK False "useless ??? Must be True to compile nasmesh driver without rtai ????") add_boolean_option(OAISIM False "specific to oaisim") add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????") @@ -611,22 +606,12 @@ add_boolean_option(FLEXRAN_AGENT_SB_IF False "enable FlexRAN ########################## add_boolean_option(ENB_MODE True "Swap the include directories between openair2 and openair3" ) -########################## -# Emulation options -########################## -add_boolean_option(ENABLE_PGM_TRANSPORT False "specific to oaisim, emulation through ethernet, reliable multicast") -add_boolean_option(ADDR_CONF False "specific to oaisim, IP autoconf of user-plane IP interface") -add_boolean_option(OPENAIR_EMU False "specific to oaisim") -add_boolean_option(OAI_EMU False "specific to oaisim") -add_boolean_option(PHY_ABSTRACTION False "specific to oaisim") - ########################## # SCHEDULING/REAL-TIME/PERF options ########################## add_boolean_option(ENABLE_USE_CPU_EXECUTION_TIME True "Add data in vcd traces: disable it if perf issues") add_boolean_option(ENABLE_VCD True "always true now, time measurements of proc calls and var displays") add_boolean_option(ENABLE_VCD_FIFO True "time measurements of proc calls and var displays sent to FIFO (one more thread)") -add_boolean_option(HARD_RT False "???") add_boolean_option(LINUX False "used in weird memcpy() in pdcp.c ???") add_boolean_option(LINUX_LIST False "used only in lists.c: either use OAI implementation of lists or Linux one (should be True, but it is False") add_boolean_option(LOG_NO_THREAD True "Disable thread for log, seems always set to true") @@ -636,24 +621,15 @@ add_boolean_option(OPENAIR_LTE True "Seems legacy: keep it to true") # PHY options ########################## add_boolean_option(DRIVER2013 True "only relevant for EXMIMO") -add_boolean_option(ENABLE_FXP True "????") add_boolean_option(ENABLE_NEW_MULTICAST False "specific to oaisim") add_boolean_option(EXMIMO_IOT True "????") add_boolean_option(LARGE_SCALE False "specific to oaisim: defines max eNB=2 and max UE=120") add_boolean_option(LOCALIZATION False "???") add_integer_option(MAX_NUM_CCs 1 "????") add_boolean_option(MU_RECEIVER False "????") -add_boolean_option(NEW_FFT True "????") -add_boolean_option(OPENAIR1 True "????") -add_boolean_option(PBS_SIM False "????") -add_boolean_option(PC_DSP True "????") -add_boolean_option(PC_TARGET True "????") -add_boolean_option(PERFECT_CE False "????") add_boolean_option(PHYSIM True "for L1 simulators (dlsim, ulsim, ...)") add_boolean_option(PHY_CONTEXT True "not clear: must remain False for dlsim") add_boolean_option(PHY_EMUL False "not clear: must remain False for dlsim") -add_boolean_option(PUCCH True "????") -add_boolean_option(RANDOM_BF False "????") add_boolean_option(SMBV False "Rohde&Schwarz SMBV100A vector signal generator") add_boolean_option(DEBUG_PHY False "Enable PHY layer debugging options") add_boolean_option(DEBUG_PHY_PROC False "Enable debugging of PHY layer procedures") @@ -726,23 +702,7 @@ add_boolean_option(RRC_DEFAULT_RAB_IS_AM False "Otherwise it is UM, confi ########################## # none -########################## -# PROJECTS (IST, FRENCH COLL., etc) -# SPECIFIC OPTIONS -########################## -add_boolean_option(SPECTRA False "???") -add_boolean_option(MIH_C_MEDIEVAL_EXTENSIONS False "EXTENSIONS TO MIH 802.21 IN CONTEXT OF IST PROJECT CALLED MEDIEVAL") - - - -add_boolean_option(EMOS False "????") -if(${EMOS}) - add_definitions("-D_FILE_OFFSET_BITS=64") - set(EMOS_LIB gps) -endif(${EMOS}) - - - # add the binary tree to the search path for include files +# add the binary tree to the search path for include files ####################################################### # We will find ConfigOAI.h after generation in target directory include_directories("${OPENAIR_BIN_DIR}") @@ -775,7 +735,6 @@ include_directories("${NFAPI_DIR}/nfapi/inc") include_directories("${NFAPI_DIR}/sim_common/inc") include_directories("${NFAPI_DIR}/pnf_sim/inc") include_directories("${OPENAIR1_DIR}") -include_directories("${OPENAIR2_DIR}/NAS") include_directories("${OPENAIR2_DIR}") include_directories("${OPENAIR2_DIR}/LAYER2/RLC") include_directories("${OPENAIR2_DIR}/LAYER2/RLC/AM_v9.3.0") @@ -1007,6 +966,7 @@ set(SCHED_SRC ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_eNb.c ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_ue.c ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c + ${OPENAIR1_DIR}/SCHED/prach_procedures.c ${OPENAIR1_DIR}/SCHED/ru_procedures.c # ${OPENAIR1_DIR}/SCHED/phy_mac_stub.c ${OPENAIR1_DIR}/SCHED/pucch_pc.c @@ -1015,6 +975,17 @@ set(SCHED_SRC ) add_library(SCHED_LIB ${SCHED_SRC}) +set(SCHED_SRC_UE + ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_ue.c + ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c + ${OPENAIR1_DIR}/SCHED/ru_procedures.c + ${OPENAIR1_DIR}/SCHED/prach_procedures.c + ${OPENAIR1_DIR}/SCHED/pucch_pc.c + ${OPENAIR1_DIR}/SCHED/pusch_pc.c + ${OPENAIR1_DIR}/SCHED/srs_pc.c +) +add_library(SCHED_UE_LIB ${SCHED_SRC_UE}) + # nFAPI ################################# set(NFAPI_COMMON_SRC @@ -1060,9 +1031,9 @@ include_directories(${NFAPI_DIR}/vnf/inc) # nFAPI user defined code ############################# set(NFAPI_USER_SRC -${NFAPI_USER_DIR}/nfapi.c -${NFAPI_USER_DIR}/nfapi_pnf.c -${NFAPI_USER_DIR}/nfapi_vnf.c + ${NFAPI_USER_DIR}/nfapi.c + ${NFAPI_USER_DIR}/nfapi_pnf.c + ${NFAPI_USER_DIR}/nfapi_vnf.c ) add_library(NFAPI_USER_LIB ${NFAPI_USER_SRC}) include_directories(${NFAPI_USER_DIR}) @@ -1148,6 +1119,103 @@ set(PHY_SRC ${OPENAIR1_DIR}/PHY/CODING/viterbi.c ${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c ${OPENAIR1_DIR}/PHY/INIT/lte_init.c + ${OPENAIR1_DIR}/PHY/INIT/lte_init_ru.c + ${OPENAIR1_DIR}/PHY/INIT/lte_init_ue.c + ${OPENAIR1_DIR}/PHY/INIT/init_top.c + ${OPENAIR1_DIR}/PHY/INIT/lte_parms.c + ${OPENAIR1_DIR}/PHY/INIT/lte_param_init.c + ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c + ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c + ${OPENAIR1_DIR}/PHY/TOOLS/lte_dfts.c + ${OPENAIR1_DIR}/PHY/TOOLS/log2_approx.c + ${OPENAIR1_DIR}/PHY/TOOLS/cmult_sv.c + ${OPENAIR1_DIR}/PHY/TOOLS/cmult_vv.c + ${OPENAIR1_DIR}/PHY/TOOLS/cdot_prod.c + ${OPENAIR1_DIR}/PHY/TOOLS/signal_energy.c + ${OPENAIR1_DIR}/PHY/TOOLS/dB_routines.c + ${OPENAIR1_DIR}/PHY/TOOLS/sqrt.c + ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c + ${OPENAIR1_DIR}/PHY/TOOLS/lut.c + ) + +set(PHY_SRC_UE + # depend on code generation from asn1c + ${RRC_FULL_DIR}/asn1_constants.h + # actual source + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pss.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots_mbsfn.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_coding.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_demodulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/power_control.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_decoding.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/uci_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pbch.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/edci.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pcfich.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pch.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/group_hopping.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/srs_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/drs_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_demodulation.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_coding.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_decoding.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/rar_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/print_stats.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/initial_sync.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_tools.c + ${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c + ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c + ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_mbsfn.c + ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_ul.c + ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz.c + ${OPENAIR1_DIR}/PHY/MODULATION/beamforming.c + ${OPENAIR1_DIR}/PHY/MODULATION/compute_bf_weights.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/freq_equalization.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_time.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_timefreq.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_est_freq_offset.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ue_measurements.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_eNB_measurements.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/adjust_gain.c + ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_cell_spec.c + ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_uespec.c + ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold.c + ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold_mbsfn.c + ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_mbsfn.c + ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_ul_ref.c + ${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c + ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c + ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c + ${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c + ${OPENAIR1_DIR}/PHY/CODING/crc_byte.c + ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c + ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c + ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c + ${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching.c + ${OPENAIR1_DIR}/PHY/CODING/viterbi.c + ${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c + ${OPENAIR1_DIR}/PHY/INIT/lte_init_ru.c + ${OPENAIR1_DIR}/PHY/INIT/lte_init_ue.c + ${OPENAIR1_DIR}/PHY/INIT/init_top.c ${OPENAIR1_DIR}/PHY/INIT/lte_parms.c ${OPENAIR1_DIR}/PHY/INIT/lte_param_init.c ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c @@ -1163,15 +1231,18 @@ set(PHY_SRC ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c ${OPENAIR1_DIR}/PHY/TOOLS/lut.c ) + if (${SMBV}) set(PHY_SRC "${PHY_SRC} ${OPENAIR1_DIR}/PHY/TOOLS/smbv.c") endif (${SMBV}) if (${COMPILATION_AVX2} STREQUAL "True") set(PHY_SRC ${PHY_SRC} ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c) + set(PHY_SRC_UE ${PHY_SRC_UE} ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c) endif () add_library(PHY ${PHY_SRC}) +add_library(PHY_UE ${PHY_SRC_UE}) #Layer 2 library ##################### @@ -1225,15 +1296,62 @@ set(L2_SRC ${RRC_DIR}/rrc_eNB_UE_context.c ${RRC_DIR}/rrc_common.c ${RRC_DIR}/L2_interface.c + ${RRC_DIR}/L2_interface_common.c + ${RRC_DIR}/L2_interface_ue.c + ) + +set(L2_SRC_UE + ${OPENAIR2_DIR}/LAYER2/openair2_proc.c + ${PDCP_DIR}/pdcp.c + ${PDCP_DIR}/pdcp_fifo.c + ${PDCP_DIR}/pdcp_sequence_manager.c + ${PDCP_DIR}/pdcp_primitives.c + ${PDCP_DIR}/pdcp_util.c + ${PDCP_DIR}/pdcp_security.c + ${PDCP_DIR}/pdcp_netlink.c + ${RLC_AM_DIR}/rlc_am.c + ${RLC_AM_DIR}/rlc_am_init.c + ${RLC_AM_DIR}/rlc_am_timer_poll_retransmit.c + ${RLC_AM_DIR}/rlc_am_timer_reordering.c + ${RLC_AM_DIR}/rlc_am_timer_status_prohibit.c + ${RLC_AM_DIR}/rlc_am_segment.c + ${RLC_AM_DIR}/rlc_am_segments_holes.c + ${RLC_AM_DIR}/rlc_am_in_sdu.c + ${RLC_AM_DIR}/rlc_am_receiver.c + ${RLC_AM_DIR}/rlc_am_retransmit.c + ${RLC_AM_DIR}/rlc_am_windows.c + ${RLC_AM_DIR}/rlc_am_rx_list.c + ${RLC_AM_DIR}/rlc_am_reassembly.c + ${RLC_AM_DIR}/rlc_am_status_report.c + ${RLC_TM_DIR}/rlc_tm.c + ${RLC_TM_DIR}/rlc_tm_init.c + ${RLC_UM_DIR}/rlc_um.c + ${RLC_UM_DIR}/rlc_um_fsm.c + ${RLC_UM_DIR}/rlc_um_control_primitives.c + ${RLC_UM_DIR}/rlc_um_segment.c + ${RLC_UM_DIR}/rlc_um_reassembly.c + ${RLC_UM_DIR}/rlc_um_receiver.c + ${RLC_UM_DIR}/rlc_um_dar.c + ${RLC_DIR}/rlc_mac.c + ${RLC_DIR}/rlc.c + ${RLC_DIR}/rlc_rrc.c + ${RLC_DIR}/rlc_mpls.c + ${RRC_DIR}/rrc_UE.c + ${RRC_DIR}/rrc_common.c + ${RRC_DIR}/L2_interface_common.c + ${RRC_DIR}/L2_interface_ue.c ) + set (MAC_SRC ${PHY_INTERFACE_DIR}/phy_stub_UE.c ${PHY_INTERFACE_DIR}/IF_Module.c ${MAC_DIR}/main.c + ${MAC_DIR}/main_ue.c ${MAC_DIR}/ue_procedures.c ${MAC_DIR}/ra_procedures.c ${MAC_DIR}/l1_helpers.c ${MAC_DIR}/rar_tools.c + ${MAC_DIR}/rar_tools_ue.c ${MAC_DIR}/eNB_scheduler.c ${MAC_DIR}/eNB_scheduler_dlsch.c ${MAC_DIR}/eNB_scheduler_ulsch.c @@ -1243,8 +1361,19 @@ set (MAC_SRC ${MAC_DIR}/eNB_scheduler_RA.c ${MAC_DIR}/pre_processor.c ${MAC_DIR}/config.c + ${MAC_DIR}/config_ue.c ) +set (MAC_SRC_UE + ${MAC_DIR}/main_ue.c + ${MAC_DIR}/ue_procedures.c + ${MAC_DIR}/ra_procedures.c + ${MAC_DIR}/l1_helpers.c + ${MAC_DIR}/rar_tools_ue.c + ${MAC_DIR}/config_ue.c + ) + + if (FLEXRAN_AGENT_SB_IF) set (MAC_SRC ${MAC_SRC} @@ -1266,6 +1395,11 @@ add_library(L2 ${ENB_APP_SRC}) # ${OPENAIR2_DIR}/RRC/L2_INTERFACE/openair_rrc_L2_interface.c) +add_library(L2_UE + ${L2_SRC_UE} + ${MAC_SRC_UE} +) + include_directories(${NFAPI_USER_DIR}) if (FLEXRAN_AGENT_SB_IF) @@ -1305,26 +1439,6 @@ if (${ENABLE_RAL}) set(RAL_LIB RAL) endif() -if(${MIH_C_MEDIEVAL_EXTENSIONS}) - set(MIH_SRC - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_header_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_msg_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_primitive_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_F1_basic_data_types_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_F2_general_data_types_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_F3_data_types_for_address_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_F4_data_types_for_links_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_F9_data_types_for_qos_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_F13_data_types_for_information_elements_codec.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_L2_type_values_for_tlv_encoding.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_Medieval_extensions.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_bit_buffer.c - ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C.c - ) - add_library(MIH ${MIH_SRC}) - set(MIH_LIB MIH) -endif() - # CN libs ########################## @@ -1674,7 +1788,6 @@ ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c #${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/emu_transport.c -${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/pgm_link.c ) add_library(OPENAIR0_LIB @@ -1866,13 +1979,13 @@ add_executable(lte-softmodem ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c + ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${GTPU_need_ITTI} - ${RTAI_SOURCE} ${XFORMS_SOURCE} ${XFORMS_SOURCE_SOFTMODEM} ${T_SOURCE} @@ -1882,7 +1995,7 @@ add_executable(lte-softmodem target_link_libraries (lte-softmodem -Wl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_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) @@ -1908,12 +2021,14 @@ add_executable(lte-softmodem-nos1 ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.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 ${OPENAIR_DIR}/common/utils/system.c - ${RTAI_SOURCE} ${XFORMS_SOURCE} ${XFORMS_SOURCE_SOFTMODEM} ${T_SOURCE} @@ -1949,6 +2064,7 @@ add_executable(lte-softmodem-stub-nos1 ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c + ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c @@ -1957,7 +2073,7 @@ add_executable(lte-softmodem-stub-nos1 ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c #${GTPU_need_ITTI} - ${RTAI_SOURCE} + #${RTAI_SOURCE} ${XFORMS_SOURCE} ${XFORMS_SOURCE_SOFTMODEM} ${T_SOURCE} @@ -1996,6 +2112,7 @@ add_executable(lte-softmodem-stub ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c + ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c @@ -2004,7 +2121,7 @@ add_executable(lte-softmodem-stub ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${GTPU_need_ITTI} - ${RTAI_SOURCE} + #${RTAI_SOURCE} ${XFORMS_SOURCE} ${XFORMS_SOURCE_SOFTMODEM} ${T_SOURCE} @@ -2026,27 +2143,6 @@ target_link_libraries (lte-softmodem-stub ${T_LIB}) -# rrh -################################ -#Note: only one RF type (USRP) is currently supported for RRH -add_executable(rrh_gw - ${OPENAIR_TARGETS}/RT/USER/rrh_gw.c - ${OPENAIR_TARGETS}/RT/USER/eNB_transport_IQ.c - ${OPENAIR_TARGETS}/RT/USER/UE_transport_IQ.c - ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c - ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c - ${T_SOURCE} - ) -target_include_directories(rrh_gw PRIVATE ${OPENAIR_DIR}/common/utils/itti) -target_link_libraries(rrh_gw - -Wl,--start-group - UTIL LFDS -ldl - -Wl,--end-group ) -target_link_libraries (rrh_gw rt pthread m ) -target_link_libraries (rrh_gw ${LIB_LMS_LIBRARIES}) -target_link_libraries (rrh_gw ${T_LIB}) - - # USIM process ################# #add_executable(usim @@ -2099,7 +2195,7 @@ add_executable(oaisim ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${GTPU_need_ITTI} - ${OPENAIR_TARGETS}/COMMON/create_tasks.c + ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${XFORMS_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} @@ -2131,10 +2227,10 @@ add_executable(oaisim target_include_directories(oaisim PUBLIC ${OPENAIR_TARGETS}/SIMU/USER) target_link_libraries (oaisim -Wl,-ldl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} + RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_UE LFDS L2 ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB - -Wl,--end-group ) + -Wl,--end-group z dl) target_link_libraries (oaisim ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES}) target_link_libraries (oaisim pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp z @@ -2152,7 +2248,7 @@ add_executable(oaisim_nos1 ${x2ap_h} ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR_TARGETS}/RT/USER/lte-ue.c - ${OPENAIR_TARGETS}/RT/USER/lte-enb.c + ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c @@ -2165,7 +2261,7 @@ add_executable(oaisim_nos1 ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c - ${OPENAIR_TARGETS}/COMMON/create_tasks.c + ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_DIR}/common/utils/system.c ${XFORMS_SOURCE} ${T_SOURCE} @@ -2175,8 +2271,8 @@ add_executable(oaisim_nos1 target_include_directories(oaisim_nos1 PUBLIC ${OPENAIR_TARGETS}/SIMU/USER) target_link_libraries (oaisim_nos1 -Wl,--start-group - RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 - -Wl,--end-group ) + RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_UE_LIB PHY_UE LFDS ${MSC_LIB} ${ITTI_LIB} SIMU L2_UE ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 + -Wl,--end-group z dl ) target_link_libraries (oaisim_nos1 ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES}) target_link_libraries (oaisim_nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} @@ -2283,7 +2379,8 @@ endforeach(myExe) if (${T_TRACER}) foreach(i #all "add_executable" definitions (except tests, rb_tool, updatefw) - lte-softmodem lte-softmodem-stub lte-softmodem-nos1 rrh_gw oaisim oaisim_nos1 + lte-softmodem lte-softmodem-stub lte-softmodem-nos1 oaisim oaisim_nos1 + dlsim_tm4 dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim #all "add_library" definitions @@ -2291,7 +2388,7 @@ if (${T_TRACER}) oai_exmimodevif oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif oai_eth_transpro FLPT_MSG ASYNC_IF FLEXRAN_AGENT HASHTABLE MSC UTIL OMG_SUMO SECU_OSA - SECU_CN SCHED_LIB PHY L2 default_sched remote_sched RAL MIH CN_UTILS + SECU_CN SCHED_LIB PHY L2 default_sched remote_sched RAL CN_UTILS GTPV1U SCTP_CLIENT UDP LIB_NAS_UE LFDS LFDS7 SIMU OPENAIR0_LIB) if (TARGET ${i}) add_dependencies(${i} generate_T) @@ -2353,7 +2450,6 @@ get_directory_property(DirDefs COMPILE_DEFINITIONS ) foreach( d ${DirDefs} ) set(module_cc_opt_tmp "${module_cc_opt_tmp} -D${d}") endforeach() -string(REPLACE "-DUSER_MODE" "" module_cc_opt ${module_cc_opt_tmp}) get_directory_property( DirDefs INCLUDE_DIRECTORIES ) foreach( d ${DirDefs} ) set(module_cc_opt "${module_cc_opt} -I${d}") @@ -2385,15 +2481,7 @@ endfunction(make_driver name dir src) # nashmesh module ################ list(APPEND nasmesh_src device.c common.c ioctl.c classifier.c tool.c mesh.c) -# Actually nasty stuff to be FIXED: the hereafter flag is for RTAI compilation in the driver, -# but has different meaning in the other parts of the code -# We should change the constant name to xxx_RTAI or likely -if(NOT ${module_cc_opt} MATCHES "DRTAI") - set(module_cc_opt "${module_cc_opt} -DNAS_NETLINK") -else() - string(REPLACE "-DNAS_NETLINK" "" tmp "${module_cc_opt}") - set(module_cc_opt ${tmp}) -endif() +set(module_cc_opt "${module_cc_opt} -DNAS_NETLINK -DPDCP_USE_NETLINK") # legacy Makefile was using NAS_NETLINK flag, but other drivers the hereafter flag # so, this cmake use OAI_NW_DRIVER_USE_NETLINK everywhere if (OAI_NW_DRIVER_USE_NETLINK) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 45ff89e2adf0a9742f9e9dfa2d58a383c6e2ce94..8fe9886f117747fcd3718ada2db9e2ccca3fae67 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -66,6 +66,7 @@ UE_AUTOTEST_TRACE="False" UE_DEBUG_TRACE="False" UE_TIMING_TRACE="False" DISABLE_LOG_X="False" +USRP_REC_PLAY="False" BUILD_ECLIPSE=0 trap handle_ctrl_c INT @@ -99,8 +100,6 @@ Options Specify conf_nvram_path (default \"$conf_nvram_path\") --UE-gen-nvram [output path] Specify gen_nvram_path (default \"$gen_nvram_path\") ---RRH - Makes the RRH -a | --agent Enables agent for software-defined control of the eNB -r | --3gpp-release @@ -158,6 +157,8 @@ Options Disable all LOG_* macros --build-eclipse Build eclipse project files. Paths are auto corrected by fixprj.sh +--usrp-recplay + Build for I/Q record-playback modes Usage (first build): oaisim (eNB + UE): ./build_oai -I --oaisim -x --install-system-files Eurecom EXMIMO + COTS UE : ./build_oai -I --eNB -x --install-system-files @@ -216,10 +217,6 @@ function main() { --UE-gen-nvram) gen_nvram_path=$(readlink -f $2) shift 2;; - --RRH) - RRH=1 - echo_info "Will compile RRH" - shift;; -r | --3gpp-release) REL=$2 echo_info "Setting release to: $REL" @@ -350,6 +347,10 @@ function main() { BUILD_TELNETSRV=1 echo_info "Build embedded telnet server" shift ;; + --usrp-recplay) + USRP_REC_PLAY="True" + echo_info "Enabling USRP record playback mode" + shift 1;; -h | --help) print_help exit 1;; @@ -364,7 +365,7 @@ function main() { echo_info "CMAKE_CMD=$CMAKE_CMD" ######################################################### - # check validity of HW and TP parameters for RRH and eNB + # check validity of HW and TP parameters for eNB ######################################################### # to be discussed @@ -380,15 +381,6 @@ function main() { fi fi - if [ "$RRH" = "1" ] ; then - if [ "$TP" = "None" ] ; then - echo_fatal "A transport protocol (e.g. -t ETHERNET) must be defined!" - fi - if [ "$HW" = "None" ] ; then - echo_info "No radio head has been selected (HW set to $HW)" - fi - fi - echo_info "RF HW set to $HW" #Now we set flags to enable deadline scheduler settings #By default: USRP: disable, @@ -542,6 +534,7 @@ function main() { echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)" >> $cmake_file echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file echo "set (DISABLE_LOG_X $DISABLE_LOG_X)" >> $cmake_file + echo "set (USRP_REC_PLAY $USRP_REC_PLAY)" >> $cmake_file if [ "$UE" = 1 -a "$NOS1" = "0" ] ; then echo_info "Compiling UE S1 build : enabling Linux and NETLINK" echo "set (LINUX True )" >> $cmake_file @@ -787,36 +780,6 @@ function main() { # oaisim_mme $dbin/oaisim_mme.$REL fi - # RRH compilation - ##################### - if [ "$RRH" = "1" ] ; then - - rrh_exec=rrh_gw - rrh_build_dir=rrh_gw - - echo_info "Compiling $rrh_exec ..." - - [ "$CLEAN" = "1" ] && rm -rf $DIR/rrh_gw/build - mkdir -p $DIR/$rrh_build_dir/build - cmake_file=$DIR/$rrh_build_dir/CMakeLists.txt - echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file - echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file - echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file - echo "set ( ENABLE_ITTI False )" >> $cmake_file - echo "set ( RF_BOARD \"${HW}\")" >> $cmake_file - echo "set ( TRANSP_PRO \"${TP}\")" >> $cmake_file - echo 'set ( PACKAGE_NAME "\"rrh_gw\"")' >> $cmake_file - echo "set ( DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )" >>$cmake_file - echo "set ( CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )" >>$cmake_file - echo "set ( T_TRACER $T_TRACER )" >> $cmake_file - echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file - cd $DIR/$rrh_build_dir/build - eval $CMAKE_CMD - compilations \ - rrh_gw rrh_gw \ - rrh_gw $dbin/rrh_gw - - fi # Telnet server compilation ##################### if [ "$BUILD_TELNETSRV" = "1" ] ; then @@ -835,13 +798,9 @@ function main() { fi # build RF device and transport protocol libraries ##################################### - if [ "$eNB" = "1" -o "$UE" = "1" -o "$RRH" = "1" ] ; then + if [ "$eNB" = "1" -o "$UE" = "1" ] ; then - if [ "$eNB" = "1" -o "$UE" = "1" ] ; then - build_dir=$lte_build_dir - else - build_dir=$rrh_build_dir - fi + build_dir=$lte_build_dir # build RF device libraries if [ "$HW" != "None" ] ; then diff --git a/cmake_targets/epc_test/CMakeLists.template b/cmake_targets/epc_test/CMakeLists.template index 76defbc7d7f1318602aa6c9ecbc85be4169a94ff..e046bb75391a178a605ed390cbb13a91b05bcbd7 100644 --- a/cmake_targets/epc_test/CMakeLists.template +++ b/cmake_targets/epc_test/CMakeLists.template @@ -2,17 +2,13 @@ cmake_minimum_required(VERSION 2.8) set ( CMAKE_BUILD_TYPE "RelWithDebInfo" ) set ( ASN_DEBUG False) -set ( ADDR_CONF False ) set ( DEBUG_OMG False ) set ( DISABLE_XER_PRINT False ) set ( DRIVER2013 True ) -set ( EMOS False ) set ( EMIT_ASN_DEBUG False ) -set ( ENABLE_FXP True ) set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING True ) set ( ENABLE_NEW_MULTICAST True ) -set ( ENABLE_PGM_TRANSPORT True ) set ( ENABLE_SECURITY True ) set ( ENABLE_STANDALONE_EPC False) set ( ENABLE_USE_CPU_EXECUTION_TIME True ) @@ -21,7 +17,6 @@ set ( ENABLE_USE_RAW_SOCKET_FOR_SGI True) set ( ENABLE_VCD_FIFO False ) set ( ENB_MODE True ) set ( EXMIMO_IOT True ) -set ( HARD_RT False ) set ( JUMBO_FRAME True ) set ( LARGE_SCALE False ) set ( LINK_ENB_PDCP_TO_GTPV1U True) @@ -33,7 +28,6 @@ set ( DEADLINE_SCHEDULER False ) set ( MAC_CONTEXT 1 ) set ( MAX_NUM_CCs 1 ) set ( MESSAGE_CHART_GENERATOR False) -set ( MIH_C_MEDIEVAL_EXTENSIONS False ) set ( MSG_PRINT False ) set ( MU_RECEIVER False ) set ( NAS_ADDRESS_FIX False ) @@ -42,38 +36,25 @@ set ( NAS_MME False ) set ( NAS_UE True ) set ( NB_ANTENNAS_RX "2" ) set ( NB_ANTENNAS_TX "2" ) -set ( NB_ANTENNAS_TXRX "2" ) -set ( NEW_FFT True ) set ( NO_RRM True ) -set ( OAI_EMU False ) set ( OAISIM False ) set ( OAI_NW_DRIVER_TYPE_ETHERNET False ) set ( OAI_NW_DRIVER_USE_NETLINK True ) -set ( OPENAIR1 True ) set ( OPENAIR2 True ) set ( OPENAIR_LTE True ) set ( PACKAGE_NAME "epc_test" ) -set ( PBS_SIM False ) set ( PDCP_USE_NETLINK True ) -set ( PC_DSP True ) -set ( PC_TARGET True ) set ( PDCP_MSG_PRINT False ) -set ( PERFECT_CE False ) -set ( PHY_ABSTRACTION True ) set ( PHY_CONTEXT False ) set ( PHY_EMUL False ) set ( PHYSIM True ) -set ( PUCCH True ) -set ( RANDOM_BF False ) set ( RF_BOARD "False" ) set ( RLC_STOP_ON_LOST_PDU False ) set ( RRC_ASN1_VERSION "Rel10" ) set ( RRC_DEFAULT_RAB_IS_AM True) set ( RRC_MSG_PRINT False ) -set ( RTAI False ) set ( SECU False ) set ( SMBV False ) set ( TEST_OMG False ) set ( USE_MME "R10" ) -set ( USER_MODE True ) set ( XER_PRINT True ) diff --git a/cmake_targets/lte-simulators/CMakeLists.txt b/cmake_targets/lte-simulators/CMakeLists.txt index ab718a8503d3a1339d0ba3996eae2e082458319d..ca754449d7f9c6bbea10e1dcf726160df18a9f97 100644 --- a/cmake_targets/lte-simulators/CMakeLists.txt +++ b/cmake_targets/lte-simulators/CMakeLists.txt @@ -6,9 +6,6 @@ set(XFORMS True) set(ENABLE_ITTI False) set(DEBUG_PHY False) set(MU_RECIEVER False) -set(RANDOM_BF False) -set(PBS_SIM False) -set(PERFECT_CE True) set(NAS_UE False) set(MESSAGE_CHART_GENERATOR False) diff --git a/cmake_targets/oaisim_build_oai/CMakeLists.template b/cmake_targets/oaisim_build_oai/CMakeLists.template index 0a05d68d10d5d6ce758e8aa17588c444632bf700..22faac75b5855fd33b2fb6630c5dde36e8fe83a4 100644 --- a/cmake_targets/oaisim_build_oai/CMakeLists.template +++ b/cmake_targets/oaisim_build_oai/CMakeLists.template @@ -1,16 +1,12 @@ cmake_minimum_required(VERSION 2.8) set ( CMAKE_BUILD_TYPE "RelWithDebInfo" ) -set ( ADDR_CONF False ) set ( DEBUG_OMG False ) set ( DISABLE_XER_PRINT False ) set ( DRIVER2013 True ) -set ( EMOS False ) -set ( ENABLE_FXP True ) set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING True ) set ( ENABLE_NEW_MULTICAST True ) -set ( ENABLE_PGM_TRANSPORT True ) set ( ENABLE_RAL False ) set ( ENABLE_SECURITY True ) set ( ENABLE_STANDALONE_EPC False) @@ -20,7 +16,6 @@ set ( ENABLE_USE_RAW_SOCKET_FOR_SGI True) set ( ENABLE_VCD_FIFO False ) set ( ENB_MODE True ) set ( EXMIMO_IOT True ) -set ( HARD_RT False ) set ( JUMBO_FRAME True ) set ( LARGE_SCALE False ) set ( LINK_ENB_PDCP_TO_GTPV1U True) @@ -32,7 +27,6 @@ set ( DEADLINE_SCHEDULER False ) set ( MAC_CONTEXT 1 ) set ( MAX_NUM_CCs 1 ) set ( MESSAGE_CHART_GENERATOR False) -set ( MIH_C_MEDIEVAL_EXTENSIONS False ) set ( MSG_PRINT False ) set ( MU_RECEIVER False ) set ( NAS_ADDRESS_FIX False ) @@ -41,40 +35,26 @@ set ( NAS_MME False ) set ( NAS_UE True ) set ( NB_ANTENNAS_RX "2" ) set ( NB_ANTENNAS_TX "2" ) -set ( NB_ANTENNAS_TXRX "2" ) -set ( NEW_FFT True ) set ( NO_RRM True ) -set ( OAI_EMU True ) set ( OAISIM True ) set ( OAI_NW_DRIVER_TYPE_ETHERNET False ) set ( OAI_NW_DRIVER_USE_NETLINK True ) -set ( OPENAIR1 True ) set ( OPENAIR2 True ) set ( OPENAIR_LTE True ) set ( PACKAGE_NAME "oaisim" ) -set ( PBS_SIM False ) set ( PDCP_USE_NETLINK True ) -set ( PC_DSP True ) -set ( PC_TARGET True ) set ( PDCP_MSG_PRINT False ) -set ( PERFECT_CE False ) -set ( PHY_ABSTRACTION True ) set ( PHY_CONTEXT False ) set ( PHY_EMUL False ) set ( PHYSIM True ) -set ( PUCCH True ) -set ( RANDOM_BF False ) set ( RF_BOARD "False" ) set ( RLC_STOP_ON_LOST_PDU False ) set ( RRC_ASN1_VERSION "Rel10" ) set ( RRC_DEFAULT_RAB_IS_AM True) set ( RRC_MSG_PRINT False ) -set ( RTAI False ) set ( SECU False ) set ( SMBV False ) -set ( SPECTRA False ) set ( TEST_OMG False ) set ( USE_3GPP_ADDR_AS_LINK_ADDR False ) set ( USE_MME "R10" ) -set ( USER_MODE True ) set ( XER_PRINT False ) diff --git a/cmake_targets/oaisim_mme_build_oai/CMakeLists.template b/cmake_targets/oaisim_mme_build_oai/CMakeLists.template index 69fa209b16d266e5a5d846facba62904bd11143b..b18b23ee9abf72e93a74a9d70a9edede932a0b8c 100644 --- a/cmake_targets/oaisim_mme_build_oai/CMakeLists.template +++ b/cmake_targets/oaisim_mme_build_oai/CMakeLists.template @@ -1,16 +1,12 @@ cmake_minimum_required(VERSION 2.8) set ( CMAKE_BUILD_TYPE "RelWithDebInfo" ) -set ( ADDR_CONF False ) set ( DEBUG_OMG False ) set ( DISABLE_XER_PRINT False ) set ( DRIVER2013 False ) -set ( EMOS False ) -set ( ENABLE_FXP False ) set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING False ) set ( ENABLE_NEW_MULTICAST False ) -set ( ENABLE_PGM_TRANSPORT False ) set ( ENABLE_RAL False ) set ( ENABLE_SECURITY False ) set ( ENABLE_STANDALONE_EPC False ) @@ -21,7 +17,6 @@ set ( ENABLE_VCD_FIFO False ) set ( ENB_MODE False ) set ( EPC_BUILD True ) set ( EXMIMO_IOT False ) -set ( HARD_RT False ) set ( JUMBO_FRAME False ) set ( LARGE_SCALE False ) set ( LINK_ENB_PDCP_TO_GTPV1U True) @@ -32,7 +27,6 @@ set ( LOG_NO_THREAD False ) set ( DEADLINE_SCHEDULER False ) set ( MAC_CONTEXT 1 ) set ( MAX_NUM_CCs 1 ) -set ( MIH_C_MEDIEVAL_EXTENSIONS False ) set ( MSG_PRINT False ) set ( MU_RECEIVER False ) set ( NAS_ADDRESS_FIX False ) @@ -42,42 +36,27 @@ set ( NAS_NETLINK False ) set ( NAS_UE False ) set ( NB_ANTENNAS_RX "2" ) set ( NB_ANTENNAS_TX "2" ) -set ( NB_ANTENNAS_TXRX "2" ) -set ( NEW_FFT False ) set ( NO_RRM False ) -set ( OAI_EMU False ) set ( OAISIM False ) set ( OAI_NW_DRIVER_TYPE_ETHERNET False ) set ( OAI_NW_DRIVER_USE_NETLINK False ) -set ( OPENAIR1 False ) set ( OPENAIR2 False ) -set ( OPENAIR_EMU False ) set ( OPENAIR_LTE False ) set ( PACKAGE_NAME "EPC" ) -set ( PBS_SIM False ) -set ( PC_DSP False ) -set ( PC_TARGET False ) set ( PDCP_MSG_PRINT False ) -set ( PERFECT_CE False ) -set ( PHY_ABSTRACTION False ) set ( PHY_CONTEXT False ) set ( PHY_EMUL False ) set ( PHYSIM False ) -set ( PUCCH False ) -set ( RANDOM_BF False ) set ( RF_BOARD "False" ) set ( RRC_ASN1_VERSION "Rel10" ) set ( RLC_STOP_ON_LOST_PDU False ) set ( RRC_MSG_PRINT False ) -set ( RTAI False ) set ( SECU False ) set ( SMBV False ) -set ( SPECTRA False ) set ( TEST_OMG False ) set ( UPDATE_RELEASE_9 True) set ( UPDATE_RELEASE_10 True) set ( USE_3GPP_ADDR_AS_LINK_ADDR False ) set ( USE_MME "R10" ) -set ( USER_MODE True ) set ( XER_PRINT False ) set ( XFORMS False ) diff --git a/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template b/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template index 8e1670ea43e9208190d895d1948467e580c602bc..bc416cff55fef58c4a19492585c07addd4f60115 100644 --- a/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template +++ b/cmake_targets/oaisim_noS1_build_oai/CMakeLists.template @@ -1,15 +1,11 @@ cmake_minimum_required(VERSION 2.8) -set ( ADDR_CONF False ) set ( DEBUG_OMG False ) set ( DISABLE_XER_PRINT False ) set ( DRIVER2013 True ) -set ( EMOS False ) -set ( ENABLE_FXP True ) set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING False ) set ( ENABLE_NEW_MULTICAST True ) -set ( ENABLE_PGM_TRANSPORT True ) set ( ENABLE_RAL False ) set ( ENABLE_SECURITY False ) set ( ENABLE_STANDALONE_EPC False) @@ -19,7 +15,6 @@ set ( ENABLE_USE_RAW_SOCKET_FOR_SGI False) set ( ENABLE_VCD_FIFO False ) set ( ENB_MODE True ) set ( EXMIMO_IOT True ) -set ( HARD_RT False ) set ( JUMBO_FRAME True ) set ( LARGE_SCALE False ) set ( LINK_ENB_PDCP_TO_GTPV1U False) @@ -33,51 +28,35 @@ set ( MAX_NUM_CCs 1 ) set ( MESSAGE_CHART_GENERATOR False ) set ( MESSAGE_CHART_GENERATOR_RLC_MAC False ) set ( MESSAGE_CHART_GENERATOR_PHY False ) -set ( MIH_C_MEDIEVAL_EXTENSIONS False ) set ( MSG_PRINT False ) set ( MU_RECEIVER False ) -set ( NAS_ADDRESS_FIX True ) +set ( NAS_ADDRESS_FIX False ) set ( NAS_BUILT_IN_UE False) set ( NAS_MME False ) set ( NAS_UE False ) set ( NB_ANTENNAS_RX "2" ) set ( NB_ANTENNAS_TX "2" ) -set ( NB_ANTENNAS_TXRX "2" ) -set ( NEW_FFT True ) set ( NO_RRM True ) -set ( OAI_EMU True ) set ( OAISIM True ) set ( OAI_NW_DRIVER_TYPE_ETHERNET False ) set ( OAI_NW_DRIVER_USE_NETLINK True ) -set ( OPENAIR1 True ) set ( OPENAIR2 True ) -set ( OPENAIR_EMU False ) set ( OPENAIR_LTE True ) set ( PACKAGE_NAME "oaisim" ) -set ( PBS_SIM False ) set ( PDCP_USE_NETLINK True ) -set ( PC_DSP True ) -set ( PC_TARGET True ) set ( PDCP_MSG_PRINT False ) -set ( PERFECT_CE False ) -set ( PHY_ABSTRACTION True ) set ( PHY_CONTEXT False ) set ( PHY_EMUL False ) set ( PHYSIM True ) -set ( PUCCH True ) -set ( RANDOM_BF False ) set ( RF_BOARD "False" ) set ( RRC_ASN1_VERSION "Rel10" ) set ( RLC_STOP_ON_LOST_PDU False ) set ( RRC_MSG_PRINT False ) -set ( RTAI False ) set ( SECU False ) set ( SMBV False ) -set ( SPECTRA False ) set ( TEST_OMG False ) set ( USE_3GPP_ADDR_AS_LINK_ADDR False ) set ( USE_MME "R10" ) -set ( USER_MODE True ) set ( XER_PRINT False ) set ( DEBUG_PHY False ) set ( DEBUG_PHY_PROC False) diff --git a/cmake_targets/s1c_mme_test/CMakeLists.template b/cmake_targets/s1c_mme_test/CMakeLists.template index 994edf835232401dbc9f41e70ae8b8e9e47e4740..9f1ff3e36015965cf5403c37472f259f32d29a25 100644 --- a/cmake_targets/s1c_mme_test/CMakeLists.template +++ b/cmake_targets/s1c_mme_test/CMakeLists.template @@ -1,17 +1,13 @@ cmake_minimum_required(VERSION 2.8) set ( CMAKE_BUILD_TYPE "RelWithDebInfo" ) -set ( ADDR_CONF False ) set ( DEBUG_OMG False ) set ( DISABLE_XER_PRINT False ) set ( DRIVER2013 True ) -set ( EMOS False ) -set ( ENABLE_FXP True ) set ( ENABLE_ITTI True ) set ( ENABLE_NAS_UE_LOGGING True ) set ( ENABLE_NEW_MULTICAST True ) set ( ENABLE_PDCP_NETLINK_FIFO False ) -set ( ENABLE_PGM_TRANSPORT True ) set ( ENABLE_RAL False ) set ( ENABLE_SECURITY True ) set ( ENABLE_STANDALONE_EPC False) @@ -21,7 +17,6 @@ set ( ENABLE_USE_RAW_SOCKET_FOR_SGI True) set ( ENABLE_VCD_FIFO False ) set ( ENB_MODE True ) set ( EXMIMO_IOT True ) -set ( HARD_RT False ) set ( JUMBO_FRAME True ) set ( LARGE_SCALE False ) set ( LINK_ENB_PDCP_TO_GTPV1U True) @@ -33,7 +28,6 @@ set ( DEADLINE_SCHEDULER False ) set ( MAC_CONTEXT 1 ) set ( MAX_NUM_CCs 1 ) set ( MESSAGE_CHART_GENERATOR False) -set ( MIH_C_MEDIEVAL_EXTENSIONS False ) set ( MSG_PRINT False ) set ( MU_RECEIVER False ) set ( NAS_ADDRESS_FIX False ) @@ -42,44 +36,30 @@ set ( NAS_MME False ) set ( NAS_UE True ) set ( NB_ANTENNAS_RX "2" ) set ( NB_ANTENNAS_TX "2" ) -set ( NB_ANTENNAS_TXRX "2" ) -set ( NEW_FFT True ) set ( NO_RRM True ) -set ( OAI_EMU True ) set ( OAISIM True ) set ( OAI_NW_DRIVER_TYPE_ETHERNET False ) set ( OAI_NW_DRIVER_USE_NETLINK True ) -set ( OPENAIR1 True ) set ( OPENAIR2 True ) set ( OPENAIR_LTE True ) set ( PACKAGE_NAME "oaisim" ) -set ( PBS_SIM False ) set ( PDCP_USE_NETLINK True ) -set ( PC_DSP True ) -set ( PC_TARGET True ) set ( PDCP_MSG_PRINT False ) -set ( PERFECT_CE False ) -set ( PHY_ABSTRACTION True ) set ( PHY_CONTEXT False ) set ( PHY_EMUL False ) set ( PHYSIM True ) -set ( PUCCH True ) -set ( RANDOM_BF False ) set ( RF_BOARD "False" ) set ( RLC_STOP_ON_LOST_PDU False ) set ( RRC_ASN1_VERSION "Rel10" ) set ( RRC_DEFAULT_RAB_IS_AM True) set ( RRC_MSG_PRINT False ) -set ( RTAI False ) set ( SECU False ) set ( SMBV False ) -set ( SPECTRA False ) set ( TEST_OMG False ) set ( TEST_S1C_MME True ) set ( USE_3GPP_ADDR_AS_LINK_ADDR False ) set ( USE_MME "R10" ) -set ( USER_MODE True ) set ( XER_PRINT False ) set ( XFORMS False ) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index e98a2b9fbf96ea73f1b57c130c3f4d3ed3b10510..1ea97c030f2b07169c0009920e55be800c7da3c1 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -95,6 +95,8 @@ get_distribution_release() { check_supported_distribution() { local distribution=$(get_distribution_release) case "$distribution" in + "ubuntu17.10") return 0 ;; + "ubuntu17.04") return 0 ;; "ubuntu16.04") return 0 ;; "ubuntu14.04") return 0 ;; "fedora24") return 0 ;; @@ -480,16 +482,26 @@ check_install_oai_software() { fi $SUDO $INSTALLER update -y if [[ "$OS_DISTRO" == "ubuntu" ]]; then + local LAPACK_LIBNAME="liblapack.so" + local LAPACK_TARGET="/usr/lib/atlas-base/atlas/liblapack.so" $SUDO apt install -y software-properties-common case "$(get_distribution_release)" in "ubuntu14.04") - specific_packages="libtasn1-3-dev" + specific_packages="libtasn1-3-dev gccxml libgnutls-dev libatlas-dev" # For iperf3 $SUDO add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports universe" $SUDO apt-get update ;; "ubuntu16.04") - specific_packages="libtasn1-6-dev" + specific_packages="libtasn1-6-dev gccxml libgnutls-dev libatlas-dev" + ;; + "ubuntu17.04") + specific_packages="libtasn1-6-dev castxml libgnutls28-dev libatlas-dev" + ;; + "ubuntu17.10") + specific_packages="libtasn1-6-dev castxml libgnutls28-dev" + LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" + LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" ;; esac $SUDO apt-get install -y \ @@ -505,7 +517,6 @@ check_install_oai_software() { texlive-latex-base \ ethtool \ flex \ - gccxml \ gdb \ git \ graphviz \ @@ -516,7 +527,6 @@ check_install_oai_software() { iptables \ iptables-dev \ libatlas-base-dev \ - libatlas-dev \ libblas-dev \ libconfig8-dev \ libffi-dev \ @@ -554,11 +564,9 @@ check_install_oai_software() { wget \ libxpm-dev - $SUDO update-alternatives --set liblapack.so /usr/lib/atlas-base/atlas/liblapack.so - - $SUDO apt-get install -y nettle-dev nettle-bin + $SUDO update-alternatives --set "$LAPACK_LIBNAME" "$LAPACK_TARGET" - $SUDO apt-get install -y libgnutls-dev + $SUDO apt-get install -y nettle-dev nettle-bin elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then if rpm -q epel-release > /dev/null; then diff --git a/cmake_targets/tools/init_nas_nos1 b/cmake_targets/tools/init_nas_nos1 index 9bcaa0afb5bd8d0961315443620aa7d643374df8..f7347e55083c19c85e7a51f5b159a389808d2afa 100755 --- a/cmake_targets/tools/init_nas_nos1 +++ b/cmake_targets/tools/init_nas_nos1 @@ -44,11 +44,11 @@ load_module $OPENAIR_DIR/targets/bin/nasmesh.ko if [ "$1" = "eNB" ]; then echo "bring up oai0 interface for enb" sudo ifconfig oai0 10.0.1.1 netmask 255.255.255.0 broadcast 10.0.1.255 - $OPENAIR_DIR/targets/bin/rb_tool -a -c0 -i0 -z0 -s 10.0.1.1 -t 10.0.1.9 -r 1 + $OPENAIR_DIR/targets/bin/rb_tool -a -c0 -i0 -z0 -s 10.0.1.1 -t 10.0.1.2 -r 1 else if [ "$1" = "UE" ]; then echo "bring up oai0 interface for UE" sudo ifconfig oai0 10.0.1.9 netmask 255.255.255.0 broadcast 10.0.1.255 - $OPENAIR_DIR/targets/bin/rb_tool -a -c0 -i0 -z0 -s 10.0.1.9 -t 10.0.1.1 -r 1 + $OPENAIR_DIR/targets/bin/rb_tool -a -c0 -i0 -z0 -s 10.0.1.2 -t 10.0.1.1 -r 1 fi fi diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index fd30ff9d00758f270b5f9493d5e7efa367a3e5d5..2816cf15804e5b3db6f7b42e8b4df034b4b75530 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -59,6 +59,15 @@ char defbool[2]="1"; printf("cfgoptions->strptr %p (&emul_iface %p, emul_iface %p)\n",cfgoptions->strptr,&emul_iface,emul_iface); sprintf(*(cfgoptions->strptr), "%s",tmpval); printf("[CONFIG] %s set to %s from command line\n", cfgoptions->optname, tmpval); +/*======= + if (cfgoptions->numelt == 0 ) { + config_check_valptr(cfgoptions, cfgoptions->strptr, strlen(tmpval)+1); + sprintf(*(cfgoptions->strptr), "%s",tmpval); + } else { + sprintf( (char *)(cfgoptions->strptr), "%s",tmpval); + } + printf_cmdl("[CONFIG] %s set to %s from command line\n", cfgoptions->optname, tmpval); +>>>>>>> main/develop*/ optisset=1; break; diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 8351d4d82c143bf05601638fcebe4e80e1f02039..ff66d22a1c847bd783ccd43211709b1e5bf741c1 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -129,20 +129,21 @@ int i; /* default */ if (cfgparam == NULL) { - cfgparam = "libconfig:oaisoftmodem.conf"; + tmpflags = tmpflags | CONFIG_NOOOPT; + cfgparam = DEFAULT_CFGMODE ":" DEFAULT_CFGFILENAME; } /* parse the config parameters to set the config source */ i = sscanf(cfgparam,"%m[^':']:%ms",&cfgmode,&modeparams); if (i< 0) { fprintf(stderr,"[CONFIG] %s, %d, sscanf error parsing config source %s: %s\n", __FILE__, __LINE__,cfgparam, strerror(errno)); - cfgmode=strdup("libconfig"); - modeparams = strdup("oaisoftmodem.conf"); + cfgmode=strdup(DEFAULT_CFGMODE); + modeparams = strdup(DEFAULT_CFGFILENAME); } else if ( i == 1 ) { /* -O argument doesn't contain ":" separator, assume -O <conf file> option, default cfgmode to libconfig with one parameter, the path to the configuration file */ modeparams=cfgmode; - cfgmode=strdup("libconfig"); + cfgmode=strdup(DEFAULT_CFGMODE); } cfgptr = malloc(sizeof(configmodule_interface_t)); diff --git a/common/config/config_load_configmodule.h b/common/config/config_load_configmodule.h index 71c642f68054180bf521dfcd8a7e0f12bc39e57b..76f074cd6c38cf805938f28567237368b2d8e253 100644 --- a/common/config/config_load_configmodule.h +++ b/common/config/config_load_configmodule.h @@ -46,6 +46,7 @@ #define CONFIG_DEBUGCMDLINE 4 // print command line processing messages #define CONFIG_HELP 8 // print help message #define CONFIG_ABORT 16 // config failed,abort execution +#define CONFIG_NOOOPT 32 // no -O option found when parsing command line typedef int(*configmodule_initfunc_t)(char *cfgP[],int numP); diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c index 339889ea2f209ef720fd2034495c45777b056410..acee5646cd7aae319f6fccef056a309e306d8fde 100644 --- a/common/config/config_userapi.c +++ b/common/config/config_userapi.c @@ -50,7 +50,11 @@ configmodule_interface_t *config_get_if(void) char * config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) { - printf_ptrs("-- %s 0x%08lx %i\n",cfgoptions->optname,(uintptr_t)(*ptr),length); + printf_ptrs("[CONFIG] %s ptr: 0x%08lx requested size: %i\n",cfgoptions->optname,(uintptr_t)(ptr),length); + if(cfgoptions->numelt > 0) { /* already allocated */ + return *ptr; + } + if (*ptr == NULL) { *ptr = malloc(length); if ( *ptr != NULL) { @@ -148,3 +152,7 @@ int config_isparamset(paramdef_t *params,int paramidx) return 0; } } + +int config_getparamval_fromparamdefidx(paramdef_t *cfgoptions,int paramidx) { + return -1; +} diff --git a/common/config/config_userapi.h b/common/config/config_userapi.h index 6acaacf7166b3e3dcac77c46bff4bef5b7d4d807..5bbc20a950bfb2150a6bfb0945821a08008dab41 100644 --- a/common/config/config_userapi.h +++ b/common/config/config_userapi.h @@ -38,6 +38,9 @@ extern "C" { #endif +#define DEFAULT_CFGFILENAME "oaisoftmodem.conf" +#define DEFAULT_CFGMODE "libconfig" + #define CONFIG_GETSOURCE ( (config_get_if()==NULL) ? NULL : config_get_if()->cfgmode ) #define CONFIG_GETNUMP ( (config_get_if()==NULL) ? 0 : config_get_if()->num_cfgP ) #define CONFIG_GETP(P) ( (config_get_if()==NULL) ? NULL : config_get_if()->cfgP[P] ) @@ -51,6 +54,7 @@ extern int config_get(paramdef_t *params,int numparams, char *prefix); extern int config_isparamset(paramdef_t *params,int paramidx); extern void config_assign_int(paramdef_t *cfgoptions, char *fullname, int val); extern int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix); +extern int config_getparamval_fromparamdefidx(paramdef_t *cfgoptions,int paramidx); #define config_getlist config_get_if()->getlist #define CONFIG_GETCONFFILE (config_get_if()->cfgP[0]) diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index 35a70dfcc79d49fd560a5f8952f4441812c24bf9..00f5f38b8fba60a042b42ebde78f78e6e87c886e 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -104,17 +104,28 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) cfgpath,str,cfgoptions[i].numelt); str[strlen(str)-1] = 0; } - config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].strptr)), sizeof(char *)); - config_check_valptr(&(cfgoptions[i]), cfgoptions[i].strptr, strlen(str)+1); - sprintf( *(cfgoptions[i].strptr) , "%s", str); - printf_params("[LIBCONFIG] %s: %s\n", cfgpath,*(cfgoptions[i].strptr) ); + if (cfgoptions[i].numelt == 0 ) { + config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].strptr)), sizeof(char *)); + config_check_valptr(&(cfgoptions[i]), cfgoptions[i].strptr, strlen(str)+1); + sprintf( *(cfgoptions[i].strptr) , "%s", str); + printf_params("[LIBCONFIG] %s: %s\n", cfgpath,*(cfgoptions[i].strptr) ); + } else { + sprintf( (char *)(cfgoptions[i].strptr) , "%s", str); + printf_params("[LIBCONFIG] %s: %s\n", cfgpath,(char *)cfgoptions[i].strptr ); + } } else { if( cfgoptions[i].defstrval != NULL) { defval=1; - config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].strptr)), sizeof(char *)); - config_check_valptr(&(cfgoptions[i]), cfgoptions[i].strptr, strlen(cfgoptions[i].defstrval)+1); - sprintf(*(cfgoptions[i].strptr), "%s",cfgoptions[i].defstrval); - printf_params("[LIBCONFIG] %s set to default value %s\n", cfgpath, *(cfgoptions[i].strptr)); + + if (cfgoptions[i].numelt == 0 ) { + config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].strptr)), sizeof(char *)); + config_check_valptr(&(cfgoptions[i]), cfgoptions[i].strptr, strlen(cfgoptions[i].defstrval)+1); + sprintf(*(cfgoptions[i].strptr), "%s",cfgoptions[i].defstrval); + printf_params("[LIBCONFIG] %s set to default value %s\n", cfgpath, *(cfgoptions[i].strptr)); + } else { + sprintf((char *)(cfgoptions[i].strptr), "%s",cfgoptions[i].defstrval); + printf_params("[LIBCONFIG] %s set to default value %s\n", cfgpath, (char *)cfgoptions[i].strptr); + } } else { notfound=1; } @@ -183,7 +194,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) read_intarray(&cfgoptions[i],setting,cfgpath); } else { if( cfgoptions[i].defintarrayval != NULL) { - config_check_valptr(&(cfgoptions[i]),(char **)&(cfgoptions[i].iptr), sizeof(int32_t)); + config_check_valptr(&(cfgoptions[i]),(char **)&(cfgoptions[i].iptr), sizeof(int32_t*)); cfgoptions[i].iptr=cfgoptions[i].defintarrayval; defval=1; for (int j=0; j<cfgoptions[i].numelt ; j++) { diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index 24845b6b9eafb2241ad62e7cc9e9ad643f0ecbbb..6bdda0edacdb8f53ead52a6eea844037de309080 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -29,7 +29,7 @@ typedef struct { #define T_SHM_FILENAME "/T_shm_segment" /* number of VCD functions (to be kept up to date! see in T_messages.txt) */ -#define VCD_NUM_FUNCTIONS 178 +#define VCD_NUM_FUNCTIONS 187 /* number of VCD variables (to be kept up to date! see in T_messages.txt) */ #define VCD_NUM_VARIABLES 128 diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 3e37b5ea150c7913d5c596001c03d364db13f828..8d531f9067708a301b395cb9ca4e2fb5d3bf1ec2 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -185,6 +185,10 @@ ID = ENB_RRC_CONNECTION_REESTABLISHMENT_REQUEST DESC = RRC connection reestablishment request GROUP = ALL:RRC:ENB FORMAT = int,eNB_ID : int,frame : int,subframe : int,rnti +ID = ENB_RRC_CONNECTION_REESTABLISHMENT + DESC = RRC connection reestablishment + GROUP = ALL:RRC:ENB + FORMAT = int,eNB_ID : int,frame : int,subframe : int,rnti ID = ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE DESC = RRC connection reestablishment complete GROUP = ALL:RRC:ENB @@ -2157,3 +2161,39 @@ ID = VCD_FUNCTION_TRX_DECOMPR_IF DESC = VCD function TRX_DECOMPR_IF GROUP = ALL:VCD:ENB:VCD_FUNCTION FORMAT = int,value +ID = VCD_FUNCTION_NFAPI + DESC = VCD function NFAPI + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_GENERATE_PCFICH + DESC = VCD function GENERATE_PCFICH + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_GENERATE_DCI0 + DESC = VCD function GENERATE_DCI0 + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_GENERATE_DLSCH + DESC = VCD function GENERATE_DLSCH + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_GENERATE_PHICH + DESC = VCD function GENERATE_PHICH + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_PDCCH_SCRAMBLING + DESC = VCD function PDCCH_SCRAMBLING + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_PDCCH_MODULATION + DESC = VCD function PDCCH_MODULATION + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_PDCCH_INTERLEAVING + DESC = VCD function PDCCH_INTERLEAVING + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value +ID = VCD_FUNCTION_PDCCH_TX + DESC = VCD function PDCCH_TX + GROUP = ALL:VCD:ENB:VCD_FUNCTION + FORMAT = int,value diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index 6c9a95732bccddc1d96f19f6529e4f2d980554fe..449fa434af09d62c38c3e556bf41cd614514451f 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -31,10 +31,6 @@ #include <sys/epoll.h> #include <sys/eventfd.h> -#ifdef RTAI -# include <rtai_shm.h> -#endif - #if !defined(TRUE) #define TRUE 1 #endif @@ -45,11 +41,6 @@ #include "intertask_interface.h" #include "intertask_interface_dump.h" -#if defined(OAI_EMU) || defined(RTAI) -# include "memory_pools.h" -# include "vcd_signal_dumper.h" -#endif - #if T_TRACER #include "T.h" #endif @@ -64,14 +55,6 @@ #include "signals.h" #include "timer.h" -#ifdef RTAI -# include <rtai.h> -# include <rtai_fifos.h> -# define FIFO_PRINTF_MAX_STRING_SIZE 1000 -# define FIFO_PRINTF_NO 62 -# define FIFO_PRINTF_SIZE 65536 -#endif - /* ITTI DEBUG groups */ #define ITTI_DEBUG_POLL (1<<0) #define ITTI_DEBUG_SEND (1<<1) @@ -83,22 +66,12 @@ const int itti_debug = (ITTI_DEBUG_ISSUES | ITTI_DEBUG_MP_STATISTICS); -/* Don't flush if using RTAI */ -#ifdef RTAI -# define ITTI_DEBUG(m, x, args...) do { if ((m) & itti_debug) rt_log_debug (x, ##args); } while(0); -#else # define ITTI_DEBUG(m, x, args...) do { if ((m) & itti_debug) {fprintf(stdout, "[ITTI][D]"x, ##args); fflush (stdout);} } while(0); -#endif #define ITTI_ERROR(x, args...) do { fprintf(stdout, "[ITTI][E]"x, ##args); fflush (stdout); } while(0); /* Global message size */ #define MESSAGE_SIZE(mESSAGEiD) (sizeof(MessageHeader) + itti_desc.messages_info[mESSAGEiD].size) -#ifdef RTAI -# define ITTI_MEM_PAGE_SIZE (1024) -# define ITTI_MEM_SIZE (16 * 1024 * 1024) -#endif - typedef enum task_state_s { TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX, } task_state_t; @@ -137,13 +110,11 @@ typedef struct thread_desc_s { int epoll_nb_events; - //#ifdef RTAI /* Flag to mark real time thread */ unsigned real_time; - /* Counter to indicate from RTAI threads that messages are pending for the thread */ + /* Counter to indicate that messages are pending for the thread */ unsigned messages_pending; - //#endif } thread_desc_t; typedef struct task_desc_s { @@ -175,17 +146,6 @@ typedef struct itti_desc_s { volatile uint32_t created_tasks; volatile uint32_t ready_tasks; volatile int wait_tasks; -#ifdef RTAI - pthread_t rt_relay_thread; -#endif - -#if defined(OAI_EMU) || defined(RTAI) - memory_pools_handle_t memory_pools_handle; - - uint64_t vcd_poll_msg; - uint64_t vcd_receive_msg; - uint64_t vcd_send_msg; -#endif } itti_desc_t; static itti_desc_t itti_desc; @@ -194,20 +154,8 @@ void *itti_malloc(task_id_t origin_task_id, task_id_t destination_task_id, ssize { void *ptr = NULL; -#if defined(OAI_EMU) || defined(RTAI) - ptr = memory_pools_allocate (itti_desc.memory_pools_handle, size, origin_task_id, destination_task_id); - - if (ptr == NULL) { - char *statistics = memory_pools_statistics (itti_desc.memory_pools_handle); - - ITTI_ERROR (" Memory pools statistics:\n%s", statistics); - free (statistics); - } - -#else ptr = malloc (size); if (ptr) memset(ptr,0,size); -#endif AssertFatal (ptr != NULL, "Memory allocation of %d bytes failed (%d -> %d)!\n", (int) size, origin_task_id, destination_task_id); @@ -219,13 +167,7 @@ int itti_free(task_id_t task_id, void *ptr) int result = EXIT_SUCCESS; AssertFatal (ptr != NULL, "Trying to free a NULL pointer (%d)!\n", task_id); -#if defined(OAI_EMU) || defined(RTAI) - result = memory_pools_free (itti_desc.memory_pools_handle, ptr, task_id); - - AssertError (result == EXIT_SUCCESS, {}, "Failed to free memory at %p (%d)!\n", ptr, task_id); -#else free (ptr); -#endif return (result); } @@ -281,27 +223,6 @@ static task_id_t itti_get_current_task_id(void) return TASK_UNKNOWN; } -#ifdef RTAI -static void rt_log_debug(char *format, ...) -{ - task_id_t task_id; - va_list args; - char log_buffer[FIFO_PRINTF_MAX_STRING_SIZE]; - int len; - - task_id = itti_get_current_task_id (); - len = snprintf(log_buffer, FIFO_PRINTF_MAX_STRING_SIZE-1, "[ITTI][D][%s]", itti_get_task_name(task_id)); - va_start(args, format); - len += vsnprintf(&log_buffer[len], FIFO_PRINTF_MAX_STRING_SIZE-1-len, format, args); - va_end (args); - - if (task_id != TASK_UNKNOWN) - fwrite(log_buffer, len, 1, stdout); - else - rtf_put (FIFO_PRINTF_NO, log_buffer, len); -} -#endif - void itti_update_lte_time(uint32_t frame, uint8_t slot) { itti_desc.lte_time.frame = frame; @@ -358,10 +279,6 @@ MessageDef *itti_alloc_new_message_sized(task_id_t origin_task_id, MessagesIds m AssertFatal (message_id < itti_desc.messages_id_max, "Message id (%d) is out of range (%d)!\n", message_id, itti_desc.messages_id_max); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_ALLOC_MSG, size); -#endif - if (origin_task_id == TASK_UNKNOWN) { /* Try to identify real origin task ID */ origin_task_id = itti_get_current_task_id(); @@ -373,10 +290,6 @@ MessageDef *itti_alloc_new_message_sized(task_id_t origin_task_id, MessagesIds m temp->ittiMsgHeader.originTaskId = origin_task_id; temp->ittiMsgHeader.ittiMsgSize = size; -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_ALLOC_MSG, 0); -#endif - return temp; } @@ -394,11 +307,6 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me message_number_t message_number; uint32_t message_id; -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_SEND_MSG, - __sync_or_and_fetch (&itti_desc.vcd_send_msg, 1L << destination_task_id)); -#endif - AssertFatal (message != NULL, "Message is NULL!\n"); AssertFatal (destination_task_id < itti_desc.task_max, "Destination task id (%d) is out of range (%d)\n", destination_task_id, itti_desc.task_max); @@ -421,11 +329,6 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me sizeof(MessageHeader) + message->ittiMsgHeader.ittiMsgSize); if (destination_task_id != TASK_UNKNOWN) { -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_ENQUEUE_MESSAGE, VCD_FUNCTION_IN); - - memory_pools_set_info (itti_desc.memory_pools_handle, message, 1, destination_task_id); -#endif if (itti_desc.threads[destination_thread_id].task_state == TASK_STATE_ENDED) { ITTI_DEBUG(ITTI_DEBUG_ISSUES, " Message %s, number %lu with priority %d can not be sent from %s to queue (%u:%s), ended destination task!\n", @@ -458,17 +361,6 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me AssertFatal(0, "Error: lfds611_queue_enqueue returns 0, queue is full, exiting\n"); } -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_ENQUEUE_MESSAGE, VCD_FUNCTION_OUT); -#endif - -#ifdef RTAI - - if (itti_desc.threads[TASK_GET_THREAD_ID(origin_task_id)].real_time) { - /* This is a RT task, increase destination task messages pending counter */ - __sync_fetch_and_add (&itti_desc.threads[destination_thread_id].messages_pending, 1); - } else -#endif { /* Only use event fd for tasks, subtasks will pool the queue */ if (TASK_GET_PARENT_TASK_ID(destination_task_id) == TASK_UNKNOWN) { @@ -496,11 +388,6 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); } -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_SEND_MSG, - __sync_and_and_fetch (&itti_desc.vcd_send_msg, ~(1L << destination_task_id))); -#endif - return 0; } @@ -645,17 +532,9 @@ static inline void itti_receive_msg_internal_event_fd(task_id_t task_id, uint8_t void itti_receive_msg(task_id_t task_id, MessageDef **received_msg) { -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG, - __sync_and_and_fetch (&itti_desc.vcd_receive_msg, ~(1L << task_id))); -#endif itti_receive_msg_internal_event_fd(task_id, 0, received_msg); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG, - __sync_or_and_fetch (&itti_desc.vcd_receive_msg, 1L << task_id)); -#endif } void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) @@ -664,11 +543,6 @@ void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) *received_msg = NULL; -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_POLL_MSG, - __sync_or_and_fetch (&itti_desc.vcd_poll_msg, 1L << task_id)); -#endif - { struct message_list_s *message; @@ -685,10 +559,6 @@ void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) ITTI_DEBUG(ITTI_DEBUG_POLL, " No message in queue[(%u:%s)]\n", task_id, itti_get_task_name(task_id)); } -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_POLL_MSG, - __sync_and_and_fetch (&itti_desc.vcd_poll_msg, ~(1L << task_id))); -#endif } int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *args_p) @@ -720,7 +590,6 @@ int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *ar return 0; } -//#ifdef RTAI void itti_set_task_real_time(task_id_t task_id) { thread_id_t thread_id = TASK_GET_THREAD_ID(task_id); @@ -729,7 +598,6 @@ void itti_set_task_real_time(task_id_t task_id) itti_desc.threads[thread_id].real_time = TRUE; } -//#endif void itti_wait_ready(int wait_tasks) { @@ -757,15 +625,6 @@ void itti_mark_task_ready(task_id_t task_id) /* Mark the thread as using LFDS queue */ lfds611_queue_use(itti_desc.tasks[task_id].message_queue); -#ifdef RTAI - /* Assign low priority to created threads */ - { - struct sched_param sched_param; - sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1; - sched_setscheduler(0, SCHED_FIFO, &sched_param); - } -#endif - itti_desc.threads[thread_id].task_state = TASK_STATE_READY; itti_desc.ready_tasks ++; @@ -778,15 +637,6 @@ void itti_mark_task_ready(task_id_t task_id) void itti_exit_task(void) { -#if defined(OAI_EMU) || defined(RTAI) - task_id_t task_id = itti_get_current_task_id(); - - if (task_id > TASK_UNKNOWN) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG, - __sync_and_and_fetch (&itti_desc.vcd_receive_msg, ~(1L << task_id))); - } - -#endif pthread_exit (NULL); } @@ -802,45 +652,6 @@ void itti_terminate_tasks(task_id_t task_id) pthread_exit (NULL); } -#ifdef RTAI -static void *itti_rt_relay_thread(void *arg) -{ - thread_id_t thread_id; - unsigned pending_messages; - - while (itti_desc.running) { - usleep (200); // Poll for messages a little more than 2 time by slot to get a small latency between RT and other tasks - -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_RELAY_THREAD, VCD_FUNCTION_IN); -#endif - - /* Checks for all non real time tasks if they have pending messages */ - for (thread_id = THREAD_FIRST; thread_id < itti_desc.thread_max; thread_id++) { - if ((itti_desc.threads[thread_id].task_state == TASK_STATE_READY) - && (itti_desc.threads[thread_id].real_time == FALSE)) { - pending_messages = __sync_fetch_and_and (&itti_desc.threads[thread_id].messages_pending, 0); - - if (pending_messages > 0) { - ssize_t write_ret; - eventfd_t sem_counter = pending_messages; - - /* Call to write for an event fd must be of 8 bytes */ - write_ret = write (itti_desc.threads[thread_id].task_event_fd, &sem_counter, sizeof(sem_counter)); - DevCheck(write_ret == sizeof(sem_counter), write_ret, sem_counter, thread_id); - } - } - } - -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_RELAY_THREAD, VCD_FUNCTION_OUT); -#endif - } - - return NULL; -} -#endif - int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_id_max, const task_info_t *tasks_info, const message_info_t *messages_info, const char * const messages_definition_xml, const char * const dump_file_name) { @@ -921,45 +732,12 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i ITTI_DEBUG(ITTI_DEBUG_EVEN_FD, " Successfully subscribed fd %d for thread %d\n", itti_desc.threads[thread_id].task_event_fd, thread_id); -#ifdef RTAI - itti_desc.threads[thread_id].real_time = FALSE; - itti_desc.threads[thread_id].messages_pending = 0; -#endif } itti_desc.running = 1; itti_desc.wait_tasks = 0; itti_desc.created_tasks = 0; itti_desc.ready_tasks = 0; -#ifdef RTAI - /* Start RT relay thread */ - DevAssert(pthread_create (&itti_desc.rt_relay_thread, NULL, itti_rt_relay_thread, NULL) >= 0); - - rt_global_heap_open(); -#endif - -#if defined(OAI_EMU) || defined(RTAI) - itti_desc.memory_pools_handle = memory_pools_create (5); - memory_pools_add_pool (itti_desc.memory_pools_handle, 1000 + ITTI_QUEUE_MAX_ELEMENTS, 50); - memory_pools_add_pool (itti_desc.memory_pools_handle, 1000 + (2 * ITTI_QUEUE_MAX_ELEMENTS), 100); - memory_pools_add_pool (itti_desc.memory_pools_handle, 10000, 1000); - memory_pools_add_pool (itti_desc.memory_pools_handle, 400, 20050); - memory_pools_add_pool (itti_desc.memory_pools_handle, 100, 30050); - - { - char *statistics = memory_pools_statistics (itti_desc.memory_pools_handle); - - ITTI_DEBUG(ITTI_DEBUG_MP_STATISTICS, " Memory pools statistics:\n%s", statistics); - free (statistics); - } -#endif - -#if defined(OAI_EMU) || defined(RTAI) - itti_desc.vcd_poll_msg = 0; - itti_desc.vcd_receive_msg = 0; - itti_desc.vcd_send_msg = 0; -#endif - itti_dump_init (messages_definition_xml, dump_file_name); CHECK_INIT_RETURN(timer_init ()); @@ -1022,15 +800,6 @@ void itti_wait_tasks_end(void) itti_desc.running = 0; -#if defined(OAI_EMU) || defined(RTAI) - { - char *statistics = memory_pools_statistics (itti_desc.memory_pools_handle); - - ITTI_DEBUG(ITTI_DEBUG_MP_STATISTICS, " Memory pools statistics:\n%s", statistics); - free (statistics); - } -#endif - if (ready_tasks > 0) { ITTI_DEBUG(ITTI_DEBUG_ISSUES, " Some threads are still running, force exit\n"); exit (0); diff --git a/common/utils/itti/intertask_interface.h b/common/utils/itti/intertask_interface.h index 191d9199c33b58d9bb67a7879e21d30e296f9928..606c851d1de02dd6647f68321499a83da3e6fcc3 100644 --- a/common/utils/itti/intertask_interface.h +++ b/common/utils/itti/intertask_interface.h @@ -27,10 +27,6 @@ #include <sys/epoll.h> -#ifdef RTAI -# include <rtai_sem.h> -#endif - #ifndef INTERTASK_INTERFACE_H_ #define INTERTASK_INTERFACE_H_ @@ -155,12 +151,10 @@ int itti_create_task(task_id_t task_id, void *(*start_routine) (void *), void *args_p); -//#ifdef RTAI /** \brief Mark the task as a real time task * \param task_id task to mark as real time **/ void itti_set_task_real_time(task_id_t task_id); -//#endif /** \brief Indicates to ITTI if newly created tasks should wait for all tasks to be ready * \param wait_tasks non 0 to make new created tasks to wait, 0 to let created tasks to run diff --git a/common/utils/itti/intertask_interface_dump.c b/common/utils/itti/intertask_interface_dump.c index a06b97c63b36eea50583a43ffd20e53a70058f3c..bb7750972664b8ef5ca48e71554277a10fdbf0a9 100644 --- a/common/utils/itti/intertask_interface_dump.c +++ b/common/utils/itti/intertask_interface_dump.c @@ -51,23 +51,14 @@ #include "intertask_interface.h" #include "intertask_interface_dump.h" -#if defined(OAI_EMU) || defined(RTAI) -#include "vcd_signal_dumper.h" -#endif - #if T_TRACER #include "T.h" #endif static const int itti_dump_debug = 0; // 0x8 | 0x4 | 0x2; -#ifdef RTAI -# define ITTI_DUMP_DEBUG(m, x, args...) do { if ((m) & itti_dump_debug) rt_printk("[ITTI_DUMP][D]"x, ##args); } \ - while(0) -#else # define ITTI_DUMP_DEBUG(m, x, args...) do { if ((m) & itti_dump_debug) fprintf(stdout, "[ITTI_DUMP][D]"x, ##args); } \ while(0) -#endif #define ITTI_DUMP_ERROR(x, args...) do { fprintf(stdout, "[ITTI_DUMP][E]"x, ##args); } \ while(0) @@ -99,13 +90,8 @@ typedef struct itti_desc_s { int nb_connected; -#ifndef RTAI /* Event fd used to notify new messages (semaphore) */ int event_fd; -#else - unsigned long messages_in_queue __attribute__((aligned(8))); -#endif - int itti_listen_socket; itti_client_desc_t itti_clients[ITTI_DUMP_MAX_CON]; @@ -194,9 +180,7 @@ static int itti_dump_fwrite_message(itti_dump_queue_item_t *message) fwrite (&new_message_header, sizeof(itti_dump_message_t), 1, dump_file); fwrite (message->data, message->data_size, 1, dump_file); fwrite (&itti_dump_message_type_end, sizeof(itti_message_types_t), 1, dump_file); - // #if !defined(RTAI) fflush (dump_file); - // #endif return (1); } @@ -280,10 +264,6 @@ static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t messa int overwrite_flag; AssertFatal (new != NULL, "Message to queue is NULL!\n"); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE, VCD_FUNCTION_IN); -#endif - new->message_type = message_type; new->message_size = message_size; @@ -303,9 +283,6 @@ static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t messa lfds611_ringbuffer_put_write_element(itti_dump_queue.itti_message_queue, new_queue_element); if (overwrite_flag == 0) { -#ifdef RTAI - __sync_fetch_and_add (&itti_dump_queue.messages_in_queue, 1); -#else { ssize_t write_ret; eventfd_t sem_counter = 1; @@ -314,25 +291,18 @@ static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t messa write_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter)); AssertFatal (write_ret == sizeof(sem_counter), "Write to dump event failed (%d/%d)!\n", (int) write_ret, (int) sizeof(sem_counter)); } -#endif // add one to pending_messages, atomically __sync_fetch_and_add (&pending_messages, 1); } ITTI_DUMP_DEBUG (0x2, " Added element to queue %p %p, pending %u, type %u\n", new_queue_element, new, pending_messages, message_type); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE, VCD_FUNCTION_OUT); -#endif - return 0; } static void itti_dump_socket_exit(void) { -#ifndef RTAI close(itti_dump_queue.event_fd); -#endif close(itti_dump_queue.itti_listen_socket); /* Leave the thread as we detected end signal */ @@ -346,10 +316,6 @@ static int itti_dump_flush_ring_buffer(int flush_all) int j; int consumer; -#ifdef RTAI - unsigned long number_of_messages; -#endif - /* Check if there is a least one consumer */ consumer = 0; @@ -365,18 +331,6 @@ static int itti_dump_flush_ring_buffer(int flush_all) } if (consumer > 0) { -#ifdef RTAI - number_of_messages = itti_dump_queue.messages_in_queue; - - ITTI_DUMP_DEBUG(0x4, "%lu elements in queue\n", number_of_messages); - - if (number_of_messages == 0) { - return (consumer); - } - - __sync_sub_and_fetch(&itti_dump_queue.messages_in_queue, number_of_messages); -#endif - do { /* Acquire the ring element */ lfds611_ringbuffer_get_read_element(itti_dump_queue.itti_message_queue, &element); @@ -419,9 +373,6 @@ static int itti_dump_flush_ring_buffer(int flush_all) lfds611_ringbuffer_put_read_element(itti_dump_queue.itti_message_queue, element); } } while(flush_all -#ifdef RTAI - && --number_of_messages -#endif ); } @@ -478,9 +429,6 @@ static void *itti_dump_socket(void *arg_p) struct sockaddr_in servaddr; /* socket address structure */ struct timeval *timeout_p = NULL; -#ifdef RTAI - struct timeval timeout; -#endif ITTI_DUMP_DEBUG(0x2, " Creating TCP dump socket on port %u\n", ITTI_PORT); @@ -536,15 +484,11 @@ static void *itti_dump_socket(void *arg_p) /* Add the listener */ FD_SET(itti_listen_socket, &read_set); -#ifndef RTAI /* Add the event fd */ FD_SET(itti_dump_queue.event_fd, &read_set); /* Max of both sd */ max_sd = itti_listen_socket > itti_dump_queue.event_fd ? itti_listen_socket : itti_dump_queue.event_fd; -#else - max_sd = itti_listen_socket; -#endif itti_dump_queue.itti_listen_socket = itti_listen_socket; @@ -557,14 +501,7 @@ static void *itti_dump_socket(void *arg_p) int i; memcpy(&working_set, &read_set, sizeof(read_set)); -#ifdef RTAI - timeout.tv_sec = 0; - timeout.tv_usec = 100000; - - timeout_p = &timeout; -#else timeout_p = NULL; -#endif /* No timeout: select blocks till a new event has to be handled * on sd's. @@ -592,8 +529,6 @@ static void *itti_dump_socket(void *arg_p) if (FD_ISSET(i, &working_set)) { desc_ready -= 1; -#ifndef RTAI - if (i == itti_dump_queue.event_fd) { /* Notification of new element to dump from other tasks */ eventfd_t sem_counter; @@ -613,7 +548,6 @@ static void *itti_dump_socket(void *arg_p) if (itti_dump_running) { ITTI_DUMP_DEBUG (0x4, " No messages consumers, waiting ...\n"); usleep(100 * 1000); -#ifndef RTAI { ssize_t write_ret; @@ -622,7 +556,6 @@ static void *itti_dump_socket(void *arg_p) write_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter)); AssertFatal (write_ret == sizeof(sem_counter), "Failed to write to dump event FD (%d/%d)!\n", (int) write_ret, (int) sem_counter); } -#endif } else { itti_dump_socket_exit(); } @@ -630,7 +563,6 @@ static void *itti_dump_socket(void *arg_p) ITTI_DUMP_DEBUG(0x1, " Write element to file\n"); } } else -#endif if (i == itti_listen_socket) { do { client_socket = accept(itti_listen_socket, NULL, NULL); @@ -719,21 +651,9 @@ int itti_dump_queue_message(task_id_t sender_task, AssertFatal (message_name != NULL, "Message name is NULL!\n"); AssertFatal (message_p != NULL, "Message is NULL!\n"); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE_MALLOC, VCD_FUNCTION_IN); -#endif new = itti_malloc(sender_task, TASK_MAX, sizeof(itti_dump_queue_item_t)); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE_MALLOC, VCD_FUNCTION_OUT); -#endif -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE_MALLOC, VCD_FUNCTION_IN); -#endif new->data = itti_malloc(sender_task, TASK_MAX, message_size); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE_MALLOC, VCD_FUNCTION_OUT); -#endif memcpy(new->data, message_p, message_size); new->data_size = message_size; @@ -791,9 +711,6 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons AssertFatal (0, " Failed to create ring buffer!\n"); } -#ifdef RTAI - itti_dump_queue.messages_in_queue = 0; -#else itti_dump_queue.event_fd = eventfd(0, EFD_SEMAPHORE); if (itti_dump_queue.event_fd == -1) { @@ -801,8 +718,6 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons AssertFatal (0, "eventfd failed: %s!\n", strerror(errno)); } -#endif - itti_dump_queue.nb_connected = 0; for(i = 0; i < ITTI_DUMP_MAX_CON; i++) { diff --git a/common/utils/itti/itti_types.h b/common/utils/itti/itti_types.h index 7f01901712346275b778fd75dd59889b0edccad8..d07853133bae343772b1d3b277602923b5fc3761 100644 --- a/common/utils/itti/itti_types.h +++ b/common/utils/itti/itti_types.h @@ -27,11 +27,7 @@ #ifndef _ITTI_TYPES_H_ #define _ITTI_TYPES_H_ -#ifdef USER_MODE #include <stdint.h> -#else -#include <linux/types.h> -#endif #define CHARS_TO_UINT32(c1, c2, c3, c4) (((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1)) diff --git a/common/utils/itti/memory_pools.c b/common/utils/itti/memory_pools.c index 23c53b71ae210400cb10b0d171d90c3bc935f2b2..78b6923dc863f982683d57a126c539651ef3817d 100644 --- a/common/utils/itti/memory_pools.c +++ b/common/utils/itti/memory_pools.c @@ -19,15 +19,8 @@ * contact@openairinterface.org */ -#ifdef RTAI -# include <rtai_shm.h> -#endif - #include "assertions.h" #include "memory_pools.h" -#if defined(OAI_EMU) || defined(RTAI) -# include "vcd_signal_dumper.h" -#endif #if T_TRACER #include <string.h> @@ -37,18 +30,8 @@ /*------------------------------------------------------------------------------*/ const static int mp_debug = 0; -#ifdef RTAI -# define MP_DEBUG(x, args...) do { if (mp_debug) rt_printk("[MP][D]"x, ##args); } \ - while(0) -#else # define MP_DEBUG(x, args...) do { if (mp_debug) fprintf(stdout, "[MP][D]"x, ##args); fflush (stdout); } \ while(0) -#endif - -#if defined(OAI_EMU) || defined(RTAI) -uint64_t vcd_mp_alloc; -uint64_t vcd_mp_free; -#endif /*------------------------------------------------------------------------------*/ #ifndef CHARS_TO_UINT32 @@ -414,11 +397,6 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po pool_id_t pool; items_group_index_t item_index = ITEMS_GROUP_INDEX_INVALID; -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_MP_ALLOC, - __sync_or_and_fetch (&vcd_mp_alloc, 1L << info_0)); -#endif - /* Recover memory_pools */ memory_pools = memory_pools_from_handler (memory_pools_handle); AssertError (memory_pools != NULL, {}, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle); @@ -464,11 +442,6 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po MP_DEBUG(" Alloc [--][------]{------}, %3u %3u, %6u, failed!\n", info_0, info_1, item_size); } -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_MP_ALLOC, - __sync_and_and_fetch (&vcd_mp_alloc, ~(1L << info_0))); -#endif - return memory_pool_item_handle; } @@ -493,11 +466,6 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it info_1 = memory_pool_item->start.info[1]; -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_MP_FREE, - __sync_or_and_fetch (&vcd_mp_free, 1L << info_1)); -#endif - /* Recover pool index */ pool = memory_pool_item->start.pool_id; AssertFatal (pool < memory_pools->pools_defined, "Pool index is invalid (%u/%u)!\n", pool, memory_pools->pools_defined); @@ -531,11 +499,6 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it AssertError (result == EXIT_SUCCESS, {}, "Failed to free memory pool item (pool %u, item %d)!\n", pool, item_index); -#if defined(OAI_EMU) || defined(RTAI) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLE_MP_FREE, - __sync_and_and_fetch (&vcd_mp_free, ~(1L << info_1))); -#endif - return (result); } diff --git a/common/utils/telnetsrv/CMakeLists.txt b/common/utils/telnetsrv/CMakeLists.txt index 51284ad2e835377e9eb6f8d682578594bd2bec16..bc4a550742291e2c9a67cbf4e923ca79d00eb8e0 100644 --- a/common/utils/telnetsrv/CMakeLists.txt +++ b/common/utils/telnetsrv/CMakeLists.txt @@ -24,7 +24,7 @@ set(OPENAIR_NFAPIINC $ENV{NFAPI_DIR} ) set(CMAKE_INSTALL_PREFIX $ENV{OPENAIR_TARGETS}) -add_definitions (-DRel14 -DCMAKER -DENABLE_FXP -DENABLE_ITTI -DENABLE_NAS_UE_LOGGING -DENABLE_SECURITY -DENABLE_USE_CPU_EXECUTION_TIME -DENABLE_USE_MME -DENABLE_VCD -DENB_AGENT -DENB_MODE -DETHERNET=1 -DEXMIMO_IOT -DJUMBO_FRAME -DLINK_ENB_PDCP_TO_GTPV1U -DLOG_NO_THREAD -DMAC_CONTEXT -DMAX_NUM_CCs=1 -DNAS_BUILT_IN_UE -DNAS_UE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DNB_ANTENNAS_TXRX=2 -DNEW_FFT -DNO_RRM -DNone=1 -DOAI_NW_DRIVER_USE_NETLINK -DOPENAIR1 -DOPENAIR2 -DOPENAIR_LTE -DPC_DSP -DPC_TARGET -DPHYSIM -DPHY_CONTEXT -DPUCCH -DRel10=1 -DS1AP_VERSION=R10 -DTRACE_RLC_MUTEX -DUSER_MODE -DX2AP_VERSION=R11 -DXFORMS -mavx2 -msse4.1 -mssse3) +add_definitions (-DRel14 -DCMAKER -DENABLE_ITTI -DENABLE_NAS_UE_LOGGING -DENABLE_SECURITY -DENABLE_USE_CPU_EXECUTION_TIME -DENABLE_USE_MME -DENABLE_VCD -DENB_AGENT -DENB_MODE -DETHERNET=1 -DEXMIMO_IOT -DJUMBO_FRAME -DLINK_ENB_PDCP_TO_GTPV1U -DLOG_NO_THREAD -DMAC_CONTEXT -DMAX_NUM_CCs=1 -DNAS_BUILT_IN_UE -DNAS_UE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DNO_RRM -DNone=1 -DOAI_NW_DRIVER_USE_NETLINK -DOPENAIR2 -DOPENAIR_LTE -DPHYSIM -DPHY_CONTEXT -DRel10=1 -DS1AP_VERSION=R10 -DTRACE_RLC_MUTEX -DX2AP_VERSION=R11 -DXFORMS -mavx2 -msse4.1 -mssse3) add_compile_options( -fPIC -march=native -Ofast) include_directories( ./ ${OPENAIR_COMMON_DIR} ${OPENAIR_DIR} ${OPENAIR1_DIR} ${OPENAIR2_DIR} ${OPENAIR2_COMMON_DIR} ${OPENAIR2_DIR}/UTIL/LOG diff --git a/nfapi/README b/nfapi/README new file mode 100644 index 0000000000000000000000000000000000000000..b2e132153244fbef1c5eab14f653c623817e1fc6 --- /dev/null +++ b/nfapi/README @@ -0,0 +1,15 @@ +This directory contains the NFAPI code. + +It comes in two parts: + +1 - open-nFAPI + + This is a clone of the github repository + (https://github.com/cisco/open-nFAPI, + commit b3bc579b1697eab829d5d8a2de59c93a61b88fa4). + The patch open-nfapi.oai.patch has then been applied. + +2 - oai_integration + + This is code written by David Price from Cisco to integrate + open-nFAPI into OpenAirInterface. diff --git a/nfapi/nfapi.c b/nfapi/nfapi.c deleted file mode 100644 index 1c4e917e65baf0d08bfeba0bdebc3f6de9f4646b..0000000000000000000000000000000000000000 --- a/nfapi/nfapi.c +++ /dev/null @@ -1,176 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> -#include <string.h> -#include <unistd.h> -#include <pthread.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <ifaddrs.h> -#include <netdb.h> -#include <pthread.h> -#include <unistd.h> - -#if 0 -#if 0 -//DJP -#include <mutex> -#include <queue> -#include <list> -#endif - -//DJP struct phy_pdu -typedef struct -{ -#if 0 - phy_pdu() : buffer_len(1500), buffer(0), len(0) - { - buffer = (char*) malloc(buffer_len); - } - - virtual ~phy_pdu() - { - free(buffer); - } -#endif - - unsigned buffer_len; - char* buffer; - unsigned len; -} phy_pdu; - -// DJP class fapi_private -typedef struct -{ - //std::mutex mutex; - //std::queue<phy_pdu*> rx_buffer; - - //std::queue<phy_pdu*> free_store; -#if 0 - public: - - fapi_private() - : byte_count(0), tick(0), first_dl_config(false) - { - } - - phy_pdu* allocate_phy_pdu() - { - phy_pdu* pdu = 0; - mutex.lock(); - if(free_store.empty()) - { - pdu = new phy_pdu(); - } - else - { - pdu = free_store.front(); - free_store.pop(); - } - mutex.unlock(); - return pdu; - } - - void release_phy_pdu(phy_pdu* pdu) - { - mutex.lock(); - free_store.push(pdu); - mutex.unlock(); - } - - bool rx_buffer_empty() - { - bool empty; - mutex.lock(); - empty = rx_buffer.empty(); - mutex.unlock(); - - return empty; - } - - - void push_rx_buffer(phy_pdu* buff) - { - mutex.lock(); - rx_buffer.push(buff); - mutex.unlock(); - } - - phy_pdu* pop_rx_buffer() - { - phy_pdu* buff = 0; - mutex.lock(); - if(!rx_buffer.empty()) - { - buff = rx_buffer.front(); - rx_buffer.pop(); - } - mutex.unlock(); - return buff; - } -#endif - - uint32_t byte_count; - uint32_t tick; - uint8_t first_dl_config; - -} fapi_private ; - -#if defined(__cplusplus) -extern "C" -{ -#endif - typedef struct fapi_internal - { - fapi_t _public; - - fapi_cb_t callbacks; - - uint8_t state; - fapi_config_t config; - - int rx_sock; - int tx_sock; - struct sockaddr_in tx_addr; - - uint32_t tx_byte_count; - uint32_t tick; - - fapi_private* fapi; - - } fapi_internal_t; -#if defined(__cplusplus) -} -#endif -#endif - -void set_thread_priority(int priority) -{ - //printf("%s(priority:%d)\n", __FUNCTION__, priority); - - pthread_attr_t ptAttr; - - struct sched_param schedParam; - schedParam.__sched_priority = priority; //79; - if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) - { - printf("Failed to set scheduler to SCHED_RR\n"); - } - - if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) - { - printf("Failed to set pthread sched policy SCHED_RR\n"); - } - - 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"); - } -} diff --git a/nfapi/nfapi_pnf.h b/nfapi/nfapi_pnf.h deleted file mode 100644 index 12f2f8e9927c21e272412a0edd213c151d770fac..0000000000000000000000000000000000000000 --- a/nfapi/nfapi_pnf.h +++ /dev/null @@ -1,6 +0,0 @@ -#if !defined(NFAPI_PNF_H__) -#define NFAPI_PNF_H__ - -void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port); - -#endif diff --git a/nfapi/nfapi_vnf.h b/nfapi/nfapi_vnf.h deleted file mode 100644 index 5a608d49555c22a5d2fed4436cfa4465545dc09b..0000000000000000000000000000000000000000 --- a/nfapi/nfapi_vnf.h +++ /dev/null @@ -1,6 +0,0 @@ -#if !defined(NFAPI_VNF_H__) -#define NFAPI_VNF_H__ - -void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port); - -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/nascell_ioctl.h b/nfapi/oai_integration/nfapi.c similarity index 59% rename from openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/nascell_ioctl.h rename to nfapi/oai_integration/nfapi.c index 128503094f3deda19e45c54406c50a0ac58e7c5a..5a3bc804c1b7685ad1292413d71d3965a03339a1 100644 --- a/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/nascell_ioctl.h +++ b/nfapi/oai_integration/nfapi.c @@ -19,31 +19,33 @@ * contact@openairinterface.org */ -#ifndef _IOCTL_H -#define _IOCTL_H - -#include <sys/ioctl.h> -#include <string.h> #include <stdio.h> -#include <stdlib.h> -#include <net/if.h> -#include <linux/ipv6.h> -#include <linux/in.h> -#include <linux/in6.h> -//#include <linux/netdevice.h> +#include <pthread.h> + +void set_thread_priority(int priority) +{ + //printf("%s(priority:%d)\n", __FUNCTION__, priority); + + pthread_attr_t ptAttr; -//#include <graal_constant.h> -//#define GRAAL_STATE_IDLE 0 -//#define GRAAL_STATE_CONNECTED 1 -//#define GRAAL_STATE_ESTABLISHMENT_REQUEST 2 -//#define GRAAL_STATE_ESTABLISHMENT_FAILURE 3 -//#define GRAAL_STATE_RELEASE_FAILURE 4 + struct sched_param schedParam; + schedParam.__sched_priority = priority; //79; + if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) + { + printf("Failed to set scheduler to SCHED_RR\n"); + } -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; + if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) + { + printf("Failed to set pthread sched policy SCHED_RR\n"); + } -extern int inet_pton(int af, const char *src, void *dst); -extern char *inet_ntop(int af, const void *src, char *dst, size_t sise); + pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED); -#endif //_IOCTL_H + 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"); + } +} diff --git a/nfapi/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c similarity index 74% rename from nfapi/nfapi_pnf.c rename to nfapi/oai_integration/nfapi_pnf.c index 0b8528cb655045203e18a0bf4e518d76508e9dd6..9f22edb5b9a65ae86662f4ca1aff0d35260028d4 100644 --- a/nfapi/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -1,3 +1,26 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#define _GNU_SOURCE + #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -25,6 +48,7 @@ extern RAN_CONTEXT_t RC; #include "fapi_stub.h" //#include "fapi_l1.h" #include "UTIL/LOG/log.h" +#include "openair2/LAYER2/MAC/proto.h" #define NUM_P5_PHY 2 @@ -42,20 +66,19 @@ char uecap_xer_in; extern void init_eNB_afterRU(void); extern void init_UE_stub(int nb_inst,int,int); -extern void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu); +extern void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, int frame, int subframe, eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu); extern void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nfapi_ul_config_request_pdu_t *ul_config_pdu, uint16_t frame,uint8_t subframe,uint8_t srs_present); -extern void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t codeword_index, uint8_t *sdu); -extern void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); -extern void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); +extern void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t codeword_index, uint8_t *sdu); +extern void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); +extern void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); extern void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t *sdu); extern uint8_t nfapi_mode; -extern int timer_subframe; -extern int timer_frame; - nfapi_tx_request_pdu_t* tx_request_pdu[1023][10][10]; // [frame][subframe][max_num_pdus] +uint8_t tx_pdus[32][8][4096]; + uint16_t phy_antenna_capability_values[] = { 1, 2, 4, 8, 16 }; @@ -64,72 +87,32 @@ nfapi_pnf_param_response_t g_pnf_param_resp; nfapi_pnf_p7_config_t *p7_config_g = NULL; -void* pnf_allocate(size_t size) -{ - //DJP - //return (void*)memory_pool::allocate(size); +void* pnf_allocate(size_t size) { return malloc(size); } -void pnf_deallocate(void* ptr) -{ - //DJP - //memory_pool::deallocate((uint8_t*)ptr); +void pnf_deallocate(void* ptr) { free(ptr); } -//class udp_data -//DJP -typedef struct -{ +typedef struct { //public: uint8_t enabled; uint32_t rx_port; uint32_t tx_port; //std::string tx_addr; char tx_addr[80]; -}udp_data; - -//class phy_info -//DJP -typedef struct -{ -#if 0 - public: - - phy_info() - : first_subframe_ind(0), fapi(0), - dl_ues_per_subframe(0), ul_ues_per_subframe(0), - timing_window(0), timing_info_mode(0), timing_info_period(0) - { - index = 0; - id = 0; - - local_port = 0; - remote_addr = 0; - remote_port = 0; - - duplex_mode = 0; - dl_channel_bw_support = 0; - ul_channel_bw_support = 0; - num_dl_layers_supported = 0; - num_ul_layers_supported = 0; - release_supported = 0; - nmm_modes_supported = 0; - } -#endif +} udp_data; +typedef struct { uint16_t index; uint16_t id; - //std::vector<uint8_t> rfs; - //std::vector<uint8_t> excluded_rfs; uint8_t rfs[2]; uint8_t excluded_rfs[2]; udp_data udp; - //std::string local_addr; char local_addr[80]; int local_port; @@ -154,14 +137,9 @@ typedef struct uint8_t timing_info_mode; uint8_t timing_info_period; - //fapi_t* fapi; +} phy_info; -}phy_info; - -//class rf_info -//DJP -typedef struct -{ +typedef struct { //public: uint16_t index; uint16_t band; @@ -172,43 +150,12 @@ typedef struct uint32_t max_downlink_frequency; uint32_t max_uplink_frequency; uint32_t min_uplink_frequency; -}rf_info; - - -//class pnf_info -//DJP -typedef struct -{ -#if 0 - public: - - pnf_info() - : release(13), wireshark_test_mode(0), - max_total_power(0), oui(0) - - { - release = 0; +} rf_info; - sync_mode = 0; - location_mode = 0; - dl_config_timing = 0; - ul_config_timing = 0; - tx_timing = 0; - hi_dci0_timing = 0; - max_phys = 0; - max_total_bw = 0; - max_total_dl_layers = 0; - max_total_ul_layers = 0; - shared_bands = 0; - shared_pa = 0; - - } -#endif +typedef struct { int release; - //DJPstd::vector<phy_info> phys; - //std::vector<rf_info> rfs; phy_info phys[2]; rf_info rfs[2]; @@ -231,77 +178,52 @@ typedef struct uint8_t wireshark_test_mode; -}pnf_info; +} pnf_info; -// DJP struct pnf_phy_user_data_t -typedef struct -{ +typedef struct { uint16_t phy_id; nfapi_pnf_config_t* config; phy_info* phy; nfapi_pnf_p7_config_t* p7_config; -}pnf_phy_user_data_t; +} pnf_phy_user_data_t; static pnf_info pnf; static pthread_t pnf_start_pthread; - extern void nfapi_log(char *file, char *func, int line, int comp, int level, const char* format, va_list args); -void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) -{ -#if 1 - - va_list args; +void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) { + va_list args; int oai_level; - if (nfapi_level==NFAPI_TRACE_ERROR) - { + if (nfapi_level==NFAPI_TRACE_ERROR) { oai_level = LOG_ERR; - } - else if (nfapi_level==NFAPI_TRACE_WARN) - { + } else if (nfapi_level==NFAPI_TRACE_WARN) { oai_level = LOG_WARNING; - } - else if (nfapi_level==NFAPI_TRACE_NOTE) - { - oai_level = LOG_INFO; - } - else if (nfapi_level==NFAPI_TRACE_INFO) - { - oai_level = LOG_INFO; - } - else - { + } else if (nfapi_level==NFAPI_TRACE_NOTE) { oai_level = LOG_INFO; + } else if (nfapi_level==NFAPI_TRACE_INFO) { + oai_level = LOG_DEBUG; + } else { + oai_level = LOG_ERR; } va_start(args, message); nfapi_log("FILE>", "FUNC", 999, PHY, oai_level, message, args); va_end(args); - #else - va_list args; - va_start(args, message); - vprintf(message, args); - va_end(args); - #endif } -void pnf_set_thread_priority(int priority) -{ - //printf("%s(priority:%d)\n", __FUNCTION__, priority); +void pnf_set_thread_priority(int priority) { pthread_attr_t ptAttr; struct sched_param schedParam; - schedParam.__sched_priority = priority; //79; - if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) - { + schedParam.__sched_priority = priority; + if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) { printf("failed to set SCHED_RR\n"); } - if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) - { + if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) { printf("failed to set pthread SCHED_RR %d\n", errno); } @@ -309,14 +231,12 @@ void pnf_set_thread_priority(int priority) struct sched_param thread_params; thread_params.sched_priority = 20; - if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) - { + 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); @@ -327,10 +247,8 @@ void* pnf_p7_thread_start(void* ptr) 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; @@ -343,7 +261,6 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req 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; - //uint8_t location_coordinates[NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH]; resp.pnf_param_general.dl_config_timing = pnf->dl_config_timing; resp.pnf_param_general.tx_timing = pnf->tx_timing; resp.pnf_param_general.ul_config_timing = pnf->ul_config_timing; @@ -355,15 +272,11 @@ 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; - //uint8_t oui[NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH]; resp.pnf_phy.tl.tag = NFAPI_PNF_PHY_TAG; - //DJP resp.pnf_phy.number_of_phys = pnf->phys.size(); resp.pnf_phy.number_of_phys = 1; - //for(int i = 0; i < pnf->phys.size(); ++i) - for(int i = 0; i < 1; ++i) - { + for(int i = 0; i < 1; ++i) { 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; @@ -372,31 +285,21 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req 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; - //DJP resp.pnf_phy.phy[i].number_of_rfs = pnf->phys[i].rfs.size(); resp.pnf_phy.phy[i].number_of_rfs = 2; - //for(int j = 0; j < pnf->phys[i].rfs.size(); ++j) - for(int j = 0; j < 1; ++j) - { + for(int j = 0; j < 1; ++j) { resp.pnf_phy.phy[i].rf_config[j].rf_config_index = pnf->phys[i].rfs[j]; } - //DJP resp.pnf_phy.phy[i].number_of_rf_exclusions = pnf->phys[i].excluded_rfs.size(); resp.pnf_phy.phy[i].number_of_rf_exclusions = 0; - //DJP for(int j = 0; j < pnf->phys[i].excluded_rfs.size(); ++j) - for(int j = 0; j < 0; ++j) - { + 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]; } } - resp.pnf_rf.tl.tag = NFAPI_PNF_RF_TAG; - //DJPresp.pnf_rf.number_of_rfs = pnf->rfs.size(); resp.pnf_rf.number_of_rfs = 2; - //for(int i = 0; i < pnf->rfs.size(); ++i) - for(int i = 0; i < 2; ++i) - { + for(int i = 0; i < 2; ++i) { 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; @@ -408,13 +311,10 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_rf.rf[i].maximum_uplink_frequency = pnf->rfs[i].max_uplink_frequency; } - if(pnf->release >= 10) - { + if(pnf->release >= 10) { resp.pnf_phy_rel10.tl.tag = NFAPI_PNF_PHY_REL10_TAG; - //DJPresp.pnf_phy_rel10.number_of_phys = pnf->phys.size(); resp.pnf_phy_rel10.number_of_phys = 1; - //for(int i = 0; i < pnf->phys.size(); ++i) for(int i = 0; i < 1; ++i) { resp.pnf_phy_rel10.phy[i].phy_config_index = pnf->phys[i].index; @@ -424,19 +324,14 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_phy_rel10.phy[i].transmission_mode_9_supported = 1; resp.pnf_phy_rel10.phy[i].simultaneous_pucch_pusch = 0; resp.pnf_phy_rel10.phy[i].four_layer_tx_with_tm3_and_tm4 = 1; - } } - if(pnf->release >= 11) - { + if(pnf->release >= 11) { resp.pnf_phy_rel11.tl.tag = NFAPI_PNF_PHY_REL11_TAG; - //DJP resp.pnf_phy_rel11.number_of_phys = pnf->phys.size(); resp.pnf_phy_rel11.number_of_phys = 1; - //DJP for(int i = 0; i < pnf->phys.size(); ++i) - for(int i = 0; i < 1; ++i) - { + 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].edpcch_supported = 0; resp.pnf_phy_rel11.phy[i].multi_ack_csi_reporting = 1; @@ -446,18 +341,14 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req } } - if(pnf->release >= 12) - { + if(pnf->release >= 12) { resp.pnf_phy_rel12.tl.tag = NFAPI_PNF_PHY_REL12_TAG; - //DJP resp.pnf_phy_rel12.number_of_phys = pnf->phys.size(); resp.pnf_phy_rel12.number_of_phys = 1; - //DJP for(int i = 0; i < pnf->phys.size(); ++i) - for(int i = 0; i < 1; ++i) - { + 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].csi_subframe_set = 0; - resp.pnf_phy_rel12.phy[i].enhanced_4tx_codebook = 2; // yes this is invalid + resp.pnf_phy_rel12.phy[i].enhanced_4tx_codebook = 2; resp.pnf_phy_rel12.phy[i].drs_supported = 0; resp.pnf_phy_rel12.phy[i].ul_64qam_supported = 1; resp.pnf_phy_rel12.phy[i].transmission_mode_10_supported = 0; @@ -465,15 +356,11 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req } } - if(pnf->release >= 13) - { + if(pnf->release >= 13) { resp.pnf_phy_rel13.tl.tag = NFAPI_PNF_PHY_REL13_TAG; - //DJP resp.pnf_phy_rel13.number_of_phys = pnf->phys.size(); resp.pnf_phy_rel13.number_of_phys = 1; - //for(int i = 0; i < pnf->phys.size(); ++i) - for(int i = 0; i < 1; ++i) - { + 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].pucch_format4_supported = 0; resp.pnf_phy_rel13.phy[i].pucch_format5_supported = 1; @@ -488,27 +375,18 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req } resp.pnf_phy_rel13_nb_iot.tl.tag = NFAPI_PNF_PHY_REL13_NB_IOT_TAG; - //DJP resp.pnf_phy_rel13_nb_iot.number_of_phys = pnf->phys.size(); resp.pnf_phy_rel13_nb_iot.number_of_phys = 1; - //for(int i = 0; i < pnf->phys.size(); ++i) - for(int i = 0; i < 1; ++i) - { + for(int i = 0; i < 1; ++i) { resp.pnf_phy_rel13_nb_iot.phy[i].phy_config_index = pnf->phys[i].index; - //DJP resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rfs = pnf->phys[i].rfs.size(); resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rfs = 1; - //DJP for(int j = 0; j < pnf->phys[i].rfs.size(); ++j) - for(int j = 0; j < 1; ++j) - { + 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]; } - //DJP resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rf_exclusions = pnf->phys[i].excluded_rfs.size(); resp.pnf_phy_rel13_nb_iot.phy[i].number_of_rf_exclusions = 1; - //DJP for(int j = 0; j < pnf->phys[i].excluded_rfs.size(); ++j) - for(int j = 0; j < 1; ++j) - { + 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]; } @@ -516,47 +394,23 @@ int pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req resp.pnf_phy_rel13_nb_iot.phy[i].number_of_ul_layers_supported = pnf->phys[i].num_ul_layers_supported; resp.pnf_phy_rel13_nb_iot.phy[i].maximum_3gpp_release_supported = pnf->phys[i].release_supported; resp.pnf_phy_rel13_nb_iot.phy[i].nmm_modes_supported = pnf->phys[i].nmm_modes_supported; - } } - 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); -#if 0 - for(int i = 0; i < req->pnf_phy_rf_config.number_phy_rf_config_info; ++i) - { - auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) - { return item.index == req->pnf_phy_rf_config.phy_rf_config[i].phy_config_index; }); - - if(found != pnf->phys.end()) - { - phy_info& phy = (*found); - phy.id = req->pnf_phy_rf_config.phy_rf_config[i].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[i].phy_config_index); - } - else - { - // did not find the phy - printf("[PNF] pnf config request did not find phy_config_index %d\n", req->pnf_phy_rf_config.phy_rf_config[i].phy_config_index); - } - - } -#endif - //DJP 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); - //DJP nfapi_pnf_config_response_t resp; memset(&resp, 0, sizeof(resp)); @@ -568,8 +422,8 @@ int pnf_config_request(nfapi_pnf_config_t* config, nfapi_pnf_config_request_t* r 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; @@ -581,25 +435,16 @@ void nfapi_send_pnf_start_resp(nfapi_pnf_config_t* config, uint16_t phy_id) 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); // start all phys that have been configured - //for(phy_info& phy : pnf->phys) phy_info* phy = pnf->phys; - if(phy->id != 0) - { - //auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) - // { return item.id == req->header.phy_id; }); - // - // if(found != pnf->phys.end()) - // { - // phy_info& phy = (*found); - //} + if(phy->id != 0) { nfapi_pnf_start_response_t resp; memset(&resp, 0, sizeof(resp)); resp.header.message_id = NFAPI_PNF_START_RESPONSE; @@ -610,8 +455,8 @@ int pnf_start_request(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req 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; @@ -624,8 +469,8 @@ int pnf_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_stop_request_t* req) 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); @@ -648,46 +493,25 @@ int param_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi // 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; // 32123; // DJP - hard code alert!!!! FIXME TODO + 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); -#if 0 - //DJP - auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) - { return item.id == req->header.phy_id; }); - - if(found != pnf->phys.end()) -#endif - { - //DJP phy_info& phy_info = (*found); - //phy_info *phy_info = pnf->phys; - - } -#if 0 - else - { - // did not find the phy - } -#endif printf("[PNF] param request .. exit\n"); return 0; } -// From MAC config.c -extern uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn); -extern int32_t get_uldl_offset(int eutra_bandP); +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); uint8_t num_tlv = 0; + //struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; // Panos: 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. @@ -714,66 +538,52 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap //DJP phy_info* phy_info = pnf->phys; - //if(nfapi_mode!=3) { - if(req->nfapi_config.timing_window.tl.tag == NFAPI_NFAPI_TIMING_WINDOW_TAG) - { + if(req->nfapi_config.timing_window.tl.tag == NFAPI_NFAPI_TIMING_WINDOW_TAG) { phy_info->timing_window = req->nfapi_config.timing_window.value; printf("Phy_info:Timing window:%u NFAPI_CONFIG:timing_window:%u\n", phy_info->timing_window, req->nfapi_config.timing_window.value); num_tlv++; } - if(req->nfapi_config.timing_info_mode.tl.tag == NFAPI_NFAPI_TIMING_INFO_MODE_TAG) - { + if(req->nfapi_config.timing_info_mode.tl.tag == NFAPI_NFAPI_TIMING_INFO_MODE_TAG) { printf("timing info mode:%d\n", req->nfapi_config.timing_info_mode.value); phy_info->timing_info_mode = req->nfapi_config.timing_info_mode.value; num_tlv++; - } - else - { + } else { phy_info->timing_info_mode = 0; printf("NO timing info mode provided\n"); } - if(req->nfapi_config.timing_info_period.tl.tag == NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG) - { + if(req->nfapi_config.timing_info_period.tl.tag == NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG) { printf("timing info period provided value:%d\n", req->nfapi_config.timing_info_period.value); phy_info->timing_info_period = req->nfapi_config.timing_info_period.value; num_tlv++; - } - else - { + } else { phy_info->timing_info_period = 0; } - if(req->rf_config.dl_channel_bandwidth.tl.tag == NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG) - { + if(req->rf_config.dl_channel_bandwidth.tl.tag == NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG) { phy_info->dl_channel_bw_support = req->rf_config.dl_channel_bandwidth.value; fp->N_RB_DL = req->rf_config.dl_channel_bandwidth.value; num_tlv++; NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG N_RB_DL:%u\n", __FUNCTION__, fp->N_RB_DL); - } - else - { + } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() Missing NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG\n", __FUNCTION__); } - if(req->rf_config.ul_channel_bandwidth.tl.tag == NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG) - { + if(req->rf_config.ul_channel_bandwidth.tl.tag == NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG) { phy_info->ul_channel_bw_support = req->rf_config.ul_channel_bandwidth.value; fp->N_RB_UL = req->rf_config.ul_channel_bandwidth.value; num_tlv++; } - if(req->nfapi_config.rf_bands.tl.tag == NFAPI_NFAPI_RF_BANDS_TAG) - { + if(req->nfapi_config.rf_bands.tl.tag == NFAPI_NFAPI_RF_BANDS_TAG) { pnf->rfs[0].band = req->nfapi_config.rf_bands.rf_band[0]; fp->eutra_band = req->nfapi_config.rf_bands.rf_band[0]; num_tlv++; } - if(req->nfapi_config.earfcn.tl.tag == NFAPI_NFAPI_EARFCN_TAG) - { - fp->dl_CarrierFreq = from_earfcn(fp->eutra_band, req->nfapi_config.earfcn.value); // DJP - TODO FIXME - hard coded to first rf + if(req->nfapi_config.earfcn.tl.tag == NFAPI_NFAPI_EARFCN_TAG) { + 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++; @@ -781,114 +591,103 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap __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) - { + if (req->subframe_config.duplex_mode.tl.tag == NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG) { fp->frame_type = req->subframe_config.duplex_mode.value==0 ? TDD : FDD; num_tlv++; NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() frame_type:%d\n", __FUNCTION__, fp->frame_type); } - if (req->subframe_config.dl_cyclic_prefix_type.tl.tag == NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG) - { + + if (req->subframe_config.dl_cyclic_prefix_type.tl.tag == NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG) { fp->Ncp = req->subframe_config.dl_cyclic_prefix_type.value; num_tlv++; } - if (req->subframe_config.ul_cyclic_prefix_type.tl.tag == NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG) - { + if (req->subframe_config.ul_cyclic_prefix_type.tl.tag == NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG) { fp->Ncp_UL = req->subframe_config.ul_cyclic_prefix_type.value; num_tlv++; } fp->num_MBSFN_config = 0; // DJP - hard code alert - if (req->sch_config.physical_cell_id.tl.tag == NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG) - { + if (req->sch_config.physical_cell_id.tl.tag == NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG) { fp->Nid_cell = req->sch_config.physical_cell_id.value; fp->nushift = fp->Nid_cell%6; num_tlv++; } - if (req->rf_config.tx_antenna_ports.tl.tag == NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG) - { + if (req->rf_config.tx_antenna_ports.tl.tag == NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG) { fp->nb_antennas_tx = req->rf_config.tx_antenna_ports.value; fp->nb_antenna_ports_eNB = 1; num_tlv++; } - if (req->rf_config.rx_antenna_ports.tl.tag == NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG) - { + if (req->rf_config.rx_antenna_ports.tl.tag == NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG) { fp->nb_antennas_rx = req->rf_config.rx_antenna_ports.value; num_tlv++; } - if (req->phich_config.phich_resource.tl.tag == NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG) - { + if (req->phich_config.phich_resource.tl.tag == NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG) { fp->phich_config_common.phich_resource = req->phich_config.phich_resource.value; num_tlv++; } - if (req->phich_config.phich_duration.tl.tag == NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG) - { + if (req->phich_config.phich_duration.tl.tag == NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG) { fp->phich_config_common.phich_duration = req->phich_config.phich_duration.value; num_tlv++; } - if (req->phich_config.phich_power_offset.tl.tag == NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG) - { + if (req->phich_config.phich_power_offset.tl.tag == NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG) { LOG_E(PHY, "%s() NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG tag:%d not supported\n", __FUNCTION__, req->phich_config.phich_power_offset.tl.tag); //fp->phich_config_common.phich_power_offset = req->phich_config. num_tlv++; } // UL RS Config - if (req->uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG) - { + if (req->uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG) { fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = req->uplink_reference_signal_config.cyclic_shift_1_for_drms.value; num_tlv++; } - if (req->uplink_reference_signal_config.uplink_rs_hopping.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG) - { + if (req->uplink_reference_signal_config.uplink_rs_hopping.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG) { fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = req->uplink_reference_signal_config.uplink_rs_hopping.value; num_tlv++; } - if (req->uplink_reference_signal_config.group_assignment.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG) - { + if (req->uplink_reference_signal_config.group_assignment.tl.tag == NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG) { fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = req->uplink_reference_signal_config.group_assignment.value; num_tlv++; } - if (req->pusch_config.hopping_mode.tl.tag == NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG) { } // DJP - not being handled? + if (req->pusch_config.hopping_mode.tl.tag == NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG) { + } // DJP - not being handled? - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; // DJP - not being handled + if (req->pusch_config.hopping_offset.tl.tag == NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG) { + } // DJP - not being handled? - if (req->prach_config.configuration_index.tl.tag == NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG) - { + if (req->pusch_config.number_of_subbands.tl.tag == NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG) { + } // DJP - not being handled? + + if (req->prach_config.configuration_index.tl.tag == NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG) { fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=req->prach_config.configuration_index.value; num_tlv++; } - if (req->prach_config.root_sequence_index.tl.tag == NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG) - { + if (req->prach_config.root_sequence_index.tl.tag == NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG) { fp->prach_config_common.rootSequenceIndex=req->prach_config.root_sequence_index.value; num_tlv++; } - if (req->prach_config.zero_correlation_zone_configuration.tl.tag == NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG) - { + if (req->prach_config.zero_correlation_zone_configuration.tl.tag == NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG) { fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=req->prach_config.zero_correlation_zone_configuration.value; num_tlv++; } - if (req->prach_config.high_speed_flag.tl.tag == NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG) - { + if (req->prach_config.high_speed_flag.tl.tag == NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG) { fp->prach_config_common.prach_ConfigInfo.highSpeedFlag=req->prach_config.high_speed_flag.value; num_tlv++; } - if (req->prach_config.frequency_offset.tl.tag == NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG) - { + if (req->prach_config.frequency_offset.tl.tag == NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG) { fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset=req->prach_config.frequency_offset.value; num_tlv++; } @@ -929,10 +728,9 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap return 0; } -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) - { +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)); } @@ -940,72 +738,68 @@ nfapi_p7_message_header_t* pnf_phy_allocate_p7_vendor_ext(uint16_t message_id, u 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) -{ - LOG_D(PHY,"[PNF] hi dci0 request sfn_sf:%d 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); +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]; eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0]; - for (int i=0; i<req->hi_dci0_request_body.number_of_dci + req->hi_dci0_request_body.number_of_hi; i++) - { + 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); + 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,proc,hi_dci0_req_pdu); + 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) - { + + } 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, proc, hi_dci0_req_pdu); - } - else - { + 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) -{ - LOG_D(PHY,"[PNF] %s() sfn_sf:%d pdcch:%u dl_cfg[dci:%u pdus:%d pdsch_rnti:%d] pcfich:%u\n", __FUNCTION__,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); +int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) { - if (RC.ru == 0) - { + if (RC.ru == 0) { return -1; } - if (RC.eNB == 0) - { + if (RC.eNB == 0) { return -2; } - if (RC.eNB[0][0] == 0) - { + if (RC.eNB[0][0] == 0) { 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; } @@ -1021,80 +815,74 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request pdcch_vars->num_pdcch_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; pdcch_vars->num_dci = 0; - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d sfn_sf:%d DCI:%d PDU:%d\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_dci, req->dl_config_request_body.number_pdu); + 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() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size); + for (int i=0;i<req->dl_config_request_body.number_pdu;i++) { - if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) - { - handle_nfapi_dci_dl_pdu(eNB,proc,&dl_config_pdu_list[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_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) - { - uint8_t *sdu = malloc(tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_length); - - memcpy(sdu, tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_data, tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_length); + 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], sdu); + 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 - { + + } 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); } - } - else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) - { + } 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]; - if (tx_pdu != NULL) - { - uint8_t *dlsch_sdu = malloc(tx_pdu->segments[0].segment_length); - -// ********************************************************************** -// THIS IS CREATING AN INTENTIONAL LEAK - I think... -// -// nFAPI won't be managing dlsch_sdu -// -// not sure about the stack, but it does seem to allow it to stay up!!! -// -// I THINK I NEED TO FIX THIS - unless it IS getting freed by the stack -// -// ********************************************************************** - 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, - &eNB->proc.proc_rxtx[0], - &dl_config_pdu_list[i], - rel8_pdu->transport_blocks-1, - dlsch_sdu); - } - else - { + if (tx_pdu != NULL) { + int UE_id = find_dlsch(rel8_pdu->rnti,eNB,SEARCH_EXIST_OR_FREE); + AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); + AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); + 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[sf]; + 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.proc_rxtx[0], &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 - { + + } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_config_pdu_list[i].pdu_type); } } @@ -1105,18 +893,16 @@ 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); if (req->tx_request_body.number_of_pdus==0) LOG_D(PHY,"%s() SFN/SF:%d%d PDUs:%d\n", __FUNCTION__, sfn, sf, req->tx_request_body.number_of_pdus); - 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++) - { + 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, @@ -1134,8 +920,8 @@ 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) -{ +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), @@ -1144,23 +930,19 @@ int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request req->ul_config_request_body.srs_present ); - if (RC.ru == 0) - { + if (RC.ru == 0) { return -1; } - if (RC.eNB == 0) - { + if (RC.eNB == 0) { return -2; } - if (RC.eNB[0][0] == 0) - { + if (RC.eNB[0][0] == 0) { 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; } @@ -1172,8 +954,7 @@ int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0]; 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 ( @@ -1184,14 +965,11 @@ int pnf_phy_ul_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request 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 - { + } else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", __FUNCTION__, i, ul_config_pdu_list[i].pdu_type); } } @@ -1199,31 +977,24 @@ 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) -{ - if(msg->message_id == P7_VENDOR_EXT_REQ) - { +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 - { + } 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) - { + if(header->message_id == P7_VENDOR_EXT_IND) { vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)(header); if(!push16(ind->error_code, ppWritePackedMsg, end)) return 0; @@ -1233,10 +1004,8 @@ int pnf_phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t* 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) -{ - if(header->message_id == P7_VENDOR_EXT_REQ) - { +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); if(!(pull16(ppReadPackedMessage, &req->dummy1, end) && @@ -1247,8 +1016,7 @@ int pnf_phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_ 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) @@ -1265,16 +1033,14 @@ 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) @@ -1291,8 +1057,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; @@ -1304,61 +1069,55 @@ 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); -#if 0 - //DJP - auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) - { return item.id == req->header.phy_id; }); + phy_info* phy_info = pnf->phys; - if(found != pnf->phys.end()) -#endif - { - //DJP phy_info& phy_info = (*found); - phy_info* phy_info = pnf->phys; + nfapi_pnf_p7_config_t* p7_config = nfapi_pnf_p7_config_create(); - nfapi_pnf_p7_config_t* p7_config = nfapi_pnf_p7_config_create(); + p7_config->phy_id = phy->phy_id; - 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; - p7_config->remote_p7_port = phy_info->remote_port; - p7_config->remote_p7_addr = phy_info->remote_addr; - p7_config->local_p7_port = 32123; //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); - 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->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->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; - p7_config->trace = &pnf_nfapi_trace; + phy->user_data = p7_config; - 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; + } - 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; - } + if(phy_info->timing_info_mode & 0x2) { + p7_config->timing_info_mode_aperiodic = 1; + } - if(phy_info->timing_info_mode & 0x2) - { - LOG_I(MAC, "Panos-D: Configure timing info aperiodic"); - p7_config->timing_info_mode_aperiodic = 1; - } + 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; if (nfapi_mode==3) { p7_config->dl_config_req = &memcpy_dl_config_req; @@ -1464,13 +1223,12 @@ int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi 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; @@ -1480,8 +1238,8 @@ 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; @@ -1498,11 +1256,12 @@ 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; @@ -1516,17 +1275,14 @@ int cell_search_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, ind.header.phy_id = req->header.phy_id; ind.error_code = NFAPI_P4_MSG_OK; - switch(req->rat_type) - { + switch(req->rat_type) { case NFAPI_RAT_TYPE_LTE: - { - ind.lte_cell_search_indication.tl.tag = NFAPI_LTE_CELL_SEARCH_INDICATION_TAG; - ind.lte_cell_search_indication.number_of_lte_cells_found = 1; - ind.lte_cell_search_indication.lte_found_cells[0].pci = 123; - ind.lte_cell_search_indication.lte_found_cells[0].rsrp = 123; - ind.lte_cell_search_indication.lte_found_cells[0].rsrq = 123; - ind.lte_cell_search_indication.lte_found_cells[0].frequency_offset = 123; - } + ind.lte_cell_search_indication.tl.tag = NFAPI_LTE_CELL_SEARCH_INDICATION_TAG; + ind.lte_cell_search_indication.number_of_lte_cells_found = 1; + ind.lte_cell_search_indication.lte_found_cells[0].pci = 123; + ind.lte_cell_search_indication.lte_found_cells[0].rsrp = 123; + 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: { @@ -1714,10 +1470,9 @@ int vendor_ext(nfapi_pnf_config_t* config, nfapi_p4_p5_message_header_t* msg) return 0; } -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) - { +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)); } @@ -1725,27 +1480,22 @@ nfapi_p4_p5_message_header_t* pnf_sim_allocate_p4_p5_vendor_ext(uint16_t message 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) - { + if(header->message_id == P5_VENDOR_EXT_RSP) { 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) - { + if(header->message_id == P5_VENDOR_EXT_REQ) { vendor_ext_p5_req* req = (vendor_ext_p5_req*)(header); return (!(pull16(ppReadPackedMessage, &req->dummy1, end) && pull16(ppReadPackedMessage, &req->dummy2, end))); @@ -1757,8 +1507,8 @@ int pnf_sim_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, /*------------------------------------------------------------------------------*/ -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; @@ -1772,8 +1522,8 @@ void* pnf_start_thread(void* ptr) 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) -{ +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) { @@ -1835,22 +1585,17 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, 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) -{ +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 - if (p7_config_g != NULL && sync_var==0) - { - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Panos-D: oai_subframe_ind 1, buffer size: %d", p7_config_g->subframe_buffer_size); - //printf("Panos-D: oai_subframe_ind 1, buffer size:%d", p7_config_g->subframe_buffer_size); + if (p7_config_g != NULL && sync_var==0) { - uint16_t sfn_sf_tx = sfn<<4 | sf; - //LOG_I(MAC, " Panos-D: oai_subframe_ind SFN/SF: %d.%d, SFN_Tx: %d \n", sfn, sf, sfn_sf_tx); + uint16_t sfn_sf_tx = sfn<<4 | sf; if ((sfn % 100 == 0) && sf==0) { @@ -1863,70 +1608,64 @@ void oai_subframe_ind(uint16_t sfn, uint16_t sf) int subframe_ret = nfapi_pnf_p7_subframe_ind(p7_config_g, p7_config_g->phy_id, sfn_sf_tx); - if (subframe_ret) - { + if (subframe_ret) { NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] %s(frame:%u subframe:%u) SFN/SF(TX):%u - PROBLEM with pnf_p7_subframe_ind()\n", __FUNCTION__, sfn, sf, sfn_sf_tx, NFAPI_SFNSF2DEC(sfn_sf_tx)); - } - else - { + } else { //NFAPI_TRACE(NFAPI_TRACE_INFO, "***NFAPI subframe handler finished *** \n"); } - } - else - { + } else { } } -int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) -{ +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_E(PHY, "%s() sfn_sf:%d preambles:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(rach_ind->sfn_sf), rach_ind->rach_indication_body.number_of_preambles); + 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) -{ +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); - LOG_E(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); - - LOG_E(PHY, "%s() Panos-D: Number of ACK/NACKs: %d", __FUNCTION__, harq_ind->harq_indication_body.harq_pdu_list[0].harq_indication_fdd_rel13.number_of_ack_nack); int retval = nfapi_pnf_p7_harq_ind(p7_config_g, harq_ind); - if (retval != 0) LOG_E(PHY, "%s() sfn_sf:%d number_of_harqs:%d nfapi_pnf_p7_harq_ind()=%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(harq_ind->sfn_sf), harq_ind->harq_indication_body.number_of_harqs, retval); + if (retval != 0) + LOG_E(PHY, "%s() sfn_sf:%d number_of_harqs:%d nfapi_pnf_p7_harq_ind()=%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(harq_ind->sfn_sf), harq_ind->harq_indication_body.number_of_harqs, retval); + return retval; } -int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_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_E(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); + //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) -{ +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_E(PHY, "%s() sfn_sf:%d number_of_cqis:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis); + //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) -{ +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; - LOG_I(MAC, "Panos-D: oai_nfapi_rx_ind 1 TIMER SFN/SF:%d.%d \n", timer_frame, timer_subframe); 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); @@ -1936,13 +1675,13 @@ int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind) return retval; } -int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind) -{ +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_E(PHY,"%s() SFN/SF:%d srs:%d retval:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs, retval); + //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); diff --git a/openair1/SIMULATION/ETH_TRANSPORT/pgm_link.h b/nfapi/oai_integration/nfapi_pnf.h similarity index 71% rename from openair1/SIMULATION/ETH_TRANSPORT/pgm_link.h rename to nfapi/oai_integration/nfapi_pnf.h index 03fa6d4b482aa1b84ed4e6d35814c6d1fedd739e..592d4877af1ac87a95c67f9d4d2365b0c586e36d 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/pgm_link.h +++ b/nfapi/oai_integration/nfapi_pnf.h @@ -19,20 +19,9 @@ * contact@openairinterface.org */ -#ifndef PGM_LINK_H_ -#define PGM_LINK_H_ +#if !defined(NFAPI_PNF_H__) +#define NFAPI_PNF_H__ -/* Define prototypes only if enabled */ -#if defined(ENABLE_PGM_TRANSPORT) -void bypass_tx_nack(unsigned int frame, unsigned int next_slot); - -int pgm_oai_init(char *if_name); - -int pgm_recv_msg(int group, uint8_t *buffer, uint32_t length, - unsigned int frame, unsigned int next_slot); - -int pgm_link_send_msg(int group, uint8_t *data, uint32_t len); +void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port); #endif - -#endif /* PGM_LINK_H_ */ diff --git a/nfapi/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c similarity index 57% rename from nfapi/nfapi_vnf.c rename to nfapi/oai_integration/nfapi_vnf.c index 316a9d713fbb7110ed250ac90e832dffc0e97ab2..07c3f1aa91fda58261b36dd8c90df3cbaf12d781 100644 --- a/nfapi/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -1,3 +1,25 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#define _GNU_SOURCE #include <stdio.h> #include <string.h> @@ -18,166 +40,92 @@ #include "common/ran_context.h" -//#include "openair1/PHY/vars.h" extern RAN_CONTEXT_t RC; -typedef struct -{ - //public: - uint8_t enabled; - uint32_t rx_port; - uint32_t tx_port; - //std::string tx_addr; - char tx_addr[80]; +typedef struct { + uint8_t enabled; + uint32_t rx_port; + uint32_t tx_port; + char tx_addr[80]; } udp_data; -//class phy_info -//DJP -typedef struct -{ -#if 0 - public: - - phy_info() - : first_subframe_ind(0), fapi(0), - dl_ues_per_subframe(0), ul_ues_per_subframe(0), - timing_window(0), timing_info_mode(0), timing_info_period(0) - { - index = 0; - id = 0; - - local_port = 0; - remote_addr = 0; - remote_port = 0; - - duplex_mode = 0; - dl_channel_bw_support = 0; - ul_channel_bw_support = 0; - num_dl_layers_supported = 0; - num_ul_layers_supported = 0; - release_supported = 0; - nmm_modes_supported = 0; - } -#endif - - uint16_t index; - uint16_t id; - //std::vector<uint8_t> rfs; - //std::vector<uint8_t> excluded_rfs; - uint8_t rfs[2]; - uint8_t excluded_rfs[2]; +typedef struct { + uint16_t index; + uint16_t id; + uint8_t rfs[2]; + uint8_t excluded_rfs[2]; - udp_data udp; + udp_data udp; - //std::string local_addr; - 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; - - // DJP - //fapi_t* fapi; + // timing information recevied from the vnf + uint8_t timing_window; + uint8_t timing_info_mode; + uint8_t timing_info_period; } phy_info; -//class rf_info -//DJP -typedef struct -{ - //public: - uint16_t index; - uint16_t band; - int16_t max_transmit_power; - int16_t min_transmit_power; - uint8_t num_antennas_supported; - uint32_t min_downlink_frequency; - uint32_t max_downlink_frequency; - uint32_t max_uplink_frequency; - uint32_t min_uplink_frequency; +typedef struct { + uint16_t index; + uint16_t band; + int16_t max_transmit_power; + int16_t min_transmit_power; + uint8_t num_antennas_supported; + uint32_t min_downlink_frequency; + uint32_t max_downlink_frequency; + uint32_t max_uplink_frequency; + uint32_t min_uplink_frequency; } rf_info; +typedef struct { -//class pnf_info -//DJP -typedef struct -{ -#if 0 - public: - - pnf_info() - : release(13), wireshark_test_mode(0), - max_total_power(0), oui(0) - - { - release = 0; - - sync_mode = 0; - location_mode = 0; - dl_config_timing = 0; - ul_config_timing = 0; - tx_timing = 0; - hi_dci0_timing = 0; - - max_phys = 0; - max_total_bw = 0; - max_total_dl_layers = 0; - max_total_ul_layers = 0; - shared_bands = 0; - shared_pa = 0; - - } -#endif + int release; + phy_info phys[2]; + rf_info rfs[2]; - int release; - //DJPstd::vector<phy_info> phys; - //std::vector<rf_info> rfs; - 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; + 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 mac mac_t; -typedef struct mac -{ +typedef struct mac { + void* user_data; void (*dl_config_req)(mac_t* mac, nfapi_dl_config_request_t* req); @@ -186,91 +134,40 @@ typedef struct mac void (*tx_req)(mac_t* mac, nfapi_tx_request_t* req); } mac_t; -//class vnf_p7_info -typedef struct -{ - //public: - -#if 0 - vnf_p7_info() - : thread_started(false), - config(nfapi_vnf_p7_config_create(), - [] (nfapi_vnf_p7_config_t* f) { nfapi_vnf_p7_config_destory(f); }), - mac(0) - { - local_port = 0; - - timing_window = 0; - periodic_timing_enabled = 0; - aperiodic_timing_enabled = 0; - periodic_timing_period = 0; - - //config = nfapi_vnf_p7_config_create(); - } - - vnf_p7_info(const vnf_p7_info& other) = default; - - vnf_p7_info(vnf_p7_info&& other) = default; - - vnf_p7_info& operator=(const vnf_p7_info&) = default; - - vnf_p7_info& operator=(vnf_p7_info&&) = default; - - - - virtual ~vnf_p7_info() - { - //NFAPI_TRACE(NFAPI_TRACE_INFO, "*** vnf_p7_info delete ***\n"); - - //nfapi_vnf_p7_config_destory(config); - - // should we delete the mac? - } -#endif - +typedef struct { - int local_port; - //DJP std::string local_addr; - char local_addr[80]; + int local_port; + char local_addr[80]; - unsigned timing_window; - unsigned periodic_timing_enabled; - unsigned aperiodic_timing_enabled; - unsigned periodic_timing_period; + unsigned timing_window; + unsigned periodic_timing_enabled; + unsigned aperiodic_timing_enabled; + unsigned periodic_timing_period; - // This is not really the right place if we have multiple PHY, - // should be part of the phy struct - udp_data udp; + // This is not really the right place if we have multiple PHY, + // should be part of the phy struct + udp_data udp; - uint8_t thread_started; + uint8_t thread_started; - nfapi_vnf_p7_config_t* config; - //std::shared_ptr<nfapi_vnf_p7_config_t> config; + nfapi_vnf_p7_config_t* config; - mac_t* mac; + mac_t* mac; } vnf_p7_info; -//class vnf_info -typedef struct -{ - //public: - - uint8_t wireshark_test_mode; +typedef struct { - //std::map<uint16_t, pnf_info> pnfs; - pnf_info pnfs[2]; + uint8_t wireshark_test_mode; + pnf_info pnfs[2]; + vnf_p7_info p7_vnfs[2]; - //std::vector<vnf_p7_info> p7_vnfs; - vnf_p7_info p7_vnfs[2]; } vnf_info; -int vnf_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) -{ +int vnf_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "vnf_pack_vendor_extension_tlv\n"); nfapi_tl_t* tlv = (nfapi_tl_t*)ve; - switch(tlv->tag) - { + switch(tlv->tag) { case VENDOR_EXT_TLV_2_TAG: { //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n"); @@ -283,8 +180,8 @@ int vnf_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t } return -1; } -int vnf_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* codec) -{ + +int vnf_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* codec) { return -1; } @@ -293,8 +190,8 @@ extern int single_thread_flag; extern void init_eNB_afterRU(void); extern uint16_t sf_ahead; -void oai_create_enb(void) -{ +void oai_create_enb(void) { + int bodge_counter=0; PHY_VARS_eNB *eNB = RC.eNB[0][0]; @@ -316,8 +213,8 @@ void oai_create_enb(void) // This will cause phy_config_request to be installed. That will result in RRC configuring the PHY // that will result in eNB->configured being set to TRUE. // See we need to wait for that to happen otherwise the NFAPI message exchanges won't contain the right parameter values - if (RC.eNB[0][0]->if_inst==0 || RC.eNB[0][0]->if_inst->PHY_config_req==0 || RC.eNB[0][0]->if_inst->schedule_response==0) - { + if (RC.eNB[0][0]->if_inst==0 || RC.eNB[0][0]->if_inst->PHY_config_req==0 || RC.eNB[0][0]->if_inst->schedule_response==0) { + printf("RC.eNB[0][0]->if_inst->PHY_config_req is not installed - install it\n"); install_schedule_handlers(RC.eNB[0][0]->if_inst); } @@ -326,22 +223,19 @@ void oai_create_enb(void) printf("%s() Waiting for eNB to become configured (by RRC/PHY) - need to wait otherwise NFAPI messages won't contain correct values\n", __FUNCTION__); usleep(50000); } while(eNB->configured != 1); + printf("%s() eNB is now configured\n", __FUNCTION__); } -void oai_enb_init(void) -{ +void oai_enb_init(void) { + printf("%s() About to call init_eNB_afterRU()\n", __FUNCTION__); init_eNB_afterRU(); } -int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) -{ - printf("[VNF] pnf connection indication idx:%d\n", p5_idx); +int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) { - //pnf_info pnf; - //vnf_info* vnf = (vnf_info*)(config->user_data); - //vnf->pnfs.insert(std::pair<uint16_t, pnf_info>(p5_idx, pnf)); + printf("[VNF] pnf connection indication idx:%d\n", p5_idx); oai_create_enb(); @@ -352,124 +246,85 @@ int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) return 0; } -int pnf_disconnection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) -{ +int pnf_disconnection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) { printf("[VNF] pnf disconnection indication idx:%d\n", p5_idx); vnf_info* vnf = (vnf_info*)(config->user_data); -#if 0 - auto find_result = vnf->pnfs.find(p5_idx); - if(find_result != vnf->pnfs.end()) - { - pnf_info& pnf = find_result->second; - - for(phy_info& phy : pnf.phys) - { - vnf_p7_info& p7_vnf = vnf->p7_vnfs[0]; - nfapi_vnf_p7_del_pnf((p7_vnf.config.get()), phy.id); - } - } -#else pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; vnf_p7_info* p7_vnf = vnf->p7_vnfs; - // DJP nfapi_vnf_p7_del_pnf((p7_vnf->config.get()), phy->id); nfapi_vnf_p7_del_pnf((p7_vnf->config), phy->id); -#endif return 0; } -int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp) -{ +int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp) { + printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code); vnf_info* vnf = (vnf_info*)(config->user_data); -#if 0 - auto find_result = vnf->pnfs.find(p5_idx); - if(find_result != vnf->pnfs.end()) + pnf_info *pnf = vnf->pnfs; + + for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) { - pnf_info& pnf = find_result->second; -#else - { - pnf_info *pnf = vnf->pnfs; -#endif + phy_info phy; + phy.index = resp->pnf_phy.phy[i].phy_config_index; - for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) - { - phy_info phy; - phy.index = resp->pnf_phy.phy[i].phy_config_index; + printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); - printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); + nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id)); - nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id)); + for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) + { + printf("[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); + phy.rfs[0] = resp->pnf_phy.phy[i].rf_config[j].rf_config_index; + } - for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) - { - printf("[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); - phy.rfs[0] = resp->pnf_phy.phy[i].rf_config[j].rf_config_index; - } + pnf->phys[0] = phy; + } - pnf->phys[0] = phy; - } + for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) { + rf_info rf; + rf.index = resp->pnf_rf.rf[i].rf_config_index; - for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) - { - rf_info rf; - rf.index = resp->pnf_rf.rf[i].rf_config_index; + printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); - printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); + pnf->rfs[0] = rf; + } - pnf->rfs[0] = rf; - } + nfapi_pnf_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; - nfapi_pnf_config_request_t req; - memset(&req, 0, sizeof(req)); - req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; + req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; + req.pnf_phy_rf_config.number_phy_rf_config_info = 2; // DJP pnf.phys.size(); + printf("DJP:Hard coded num phy rf to 2\n"); - req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; - req.pnf_phy_rf_config.number_phy_rf_config_info = 2; // DJP pnf.phys.size(); - printf("DJP:Hard coded num phy rf to 2\n"); + for(unsigned i = 0; i < 2; ++i) { + req.pnf_phy_rf_config.phy_rf_config[i].phy_id = pnf->phys[i].id; + req.pnf_phy_rf_config.phy_rf_config[i].phy_config_index = pnf->phys[i].index; + req.pnf_phy_rf_config.phy_rf_config[i].rf_config_index = pnf->phys[i].rfs[0]; + } - // DJP for(unsigned i = 0; i < pnf.phys.size(); ++i) - for(unsigned i = 0; i < 2; ++i) - { - req.pnf_phy_rf_config.phy_rf_config[i].phy_id = pnf->phys[i].id; - req.pnf_phy_rf_config.phy_rf_config[i].phy_config_index = pnf->phys[i].index; - req.pnf_phy_rf_config.phy_rf_config[i].rf_config_index = pnf->phys[i].rfs[0]; - } + nfapi_vnf_pnf_config_req(config, p5_idx, &req); - nfapi_vnf_pnf_config_req(config, p5_idx, &req); - } return 0; } -int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp) -{ +int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp) { + printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length); - if(1) - { - //vnf_info* vnf = (vnf_info*)(config->user_data); -#if 0 - auto find_result = vnf->pnfs.find(p5_idx); - if(find_result != vnf->pnfs.end()) - { - //pnf_info& pnf = find_result->second; - } -#else + if(1) { nfapi_pnf_start_request_t req; memset(&req, 0, sizeof(req)); req.header.phy_id = resp->header.phy_id; req.header.message_id = NFAPI_PNF_START_REQUEST; nfapi_vnf_pnf_start_req(config, p5_idx, &req); -#endif - } - else - { + } else { // Rather than send the pnf_start_request we will demonstrate // sending a vendor extention message. The start request will be // send when the vendor extension response is received @@ -485,8 +340,8 @@ int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_ return 0; } -int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) -{ +int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) { + eNB_proc_t *proc=&eNB->proc; eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[sf&1]; @@ -537,7 +392,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) ++proc_rxtx->instance_cnt_rxtx; - //LOG_E( PHY,"[VNF-subframe_ind] sfn/sf:%d:%d proc[frame_rx:%d subframe_rx:%d] proc_rxtx->instance_cnt_rxtx:%d \n", sfn, sf, proc->frame_rx, proc->subframe_rx, proc_rxtx->instance_cnt_rxtx); + //LOG_D( PHY,"[VNF-subframe_ind] sfn/sf:%d:%d proc[frame_rx:%d subframe_rx:%d] proc_rxtx->instance_cnt_rxtx:%d \n", sfn, sf, proc->frame_rx, proc->subframe_rx, proc_rxtx->instance_cnt_rxtx); // 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 @@ -551,7 +406,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > (9-sf_ahead)) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + sf_ahead)%10; - LOG_D(PHY, "sfn/sf:%d%d proc[rx:%d%d] proc_rxtx[instance_cnt_rxtx:%d rx:%d%d] About to wake rxtx thread\n\n", sfn, sf, proc->frame_rx, proc->subframe_rx, proc_rxtx->instance_cnt_rxtx, proc_rxtx->frame_rx, proc_rxtx->subframe_rx); + //LOG_D(PHY, "sfn/sf:%d%d proc[rx:%d%d] proc_rxtx[instance_cnt_rxtx:%d rx:%d%d] About to wake rxtx thread\n\n", sfn, sf, proc->frame_rx, proc->subframe_rx, proc_rxtx->instance_cnt_rxtx, proc_rxtx->frame_rx, proc_rxtx->subframe_rx); // the thread can now be woken up if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { @@ -571,65 +426,48 @@ extern pthread_cond_t nfapi_sync_cond; extern pthread_mutex_t nfapi_sync_mutex; extern int nfapi_sync_var; -int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) -{ - //vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); +int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) { printf("[VNF] SYNC %s\n", sync==1 ? "ACHIEVED" : "LOST"); - if (1) - { - if (sync==1 && nfapi_sync_var!=0) - { + if (sync==1 && nfapi_sync_var!=0) { - printf("[VNF] Signal to OAI main code that it can go\n"); - pthread_mutex_lock(&nfapi_sync_mutex); - nfapi_sync_var=0; - pthread_cond_broadcast(&nfapi_sync_cond); - pthread_mutex_unlock(&nfapi_sync_mutex); - } + printf("[VNF] Signal to OAI main code that it can go\n"); + pthread_mutex_lock(&nfapi_sync_mutex); + nfapi_sync_var=0; + pthread_cond_broadcast(&nfapi_sync_cond); + pthread_mutex_unlock(&nfapi_sync_mutex); } return(0); } -int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf) -{ +int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf) { + static uint8_t first_time = 1; - if (first_time) - { + if (first_time) { printf("[VNF] subframe indication %d\n", NFAPI_SFNSF2DEC(sfn_sf)); first_time = 0; } - // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); - //mac_subframe_ind(p7_vnf->mac, phy_id, sfn_sf); - -#if 1 - //if (RC.eNB) printf("RC.eNB[0][0]->configured:%d\n", RC.eNB[0][0]->configured); - - if (RC.eNB && RC.eNB[0][0]->configured) - { + if (RC.eNB && RC.eNB[0][0]->configured) { uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf); uint16_t sf = NFAPI_SFNSF2SF(sfn_sf); - //LOG_E(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf); + //LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf); wake_eNB_rxtx(RC.eNB[0][0], sfn, sf); - } - else - { + } else { printf("[VNF] %s() RC.eNB:%p\n", __FUNCTION__, RC.eNB); if (RC.eNB) printf("RC.eNB[0][0]->configured:%d\n", RC.eNB[0][0]->configured); } -#endif return 0; } -int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind) -{ - LOG_E(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles); +int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind) { + + LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles); struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; @@ -638,12 +476,11 @@ int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indicatio pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.rach_ind = *ind; - eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = eNB->preamble_list; + eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = eNB->preamble_list; + + for (int i=0;i<ind->rach_indication_body.number_of_preambles;i++) { + if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) { - for (int i=0;i<ind->rach_indication_body.number_of_preambles;i++) - { - if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) - { printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n", i, ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti, @@ -652,8 +489,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indicatio ); } - if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) - { + if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) { printf("RACH PREAMBLE REL13 present\n"); } @@ -661,14 +497,13 @@ int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indicatio } pthread_mutex_unlock(&eNB->UL_INFO_mutex); - // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_rach_ind(p7_vnf->mac, ind); return 1; } -int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind) -{ +int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind) { + struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs); @@ -678,8 +513,7 @@ int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indicatio eNB->UL_INFO.harq_ind = *ind; eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list; - for (int i=0; i<ind->harq_indication_body.number_of_harqs; i++) - { + for (int i=0; i<ind->harq_indication_body.number_of_harqs; i++) { memcpy(&eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[i], &ind->harq_indication_body.harq_pdu_list[i], sizeof(eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[i])); } @@ -687,11 +521,12 @@ int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indicatio // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_harq_ind(p7_vnf->mac, ind); + return 1; } -int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind) -{ +int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind) { + struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; pthread_mutex_lock(&eNB->UL_INFO_mutex); @@ -705,10 +540,9 @@ int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_ dest_ind->crc_indication_body.crc_pdu_list = dest_pdu_list; if (ind->crc_indication_body.number_of_crcs==0) - LOG_E(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs); + LOG_D(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs); - for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) - { + for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) { memcpy(&dest_ind->crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0])); LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n", @@ -717,23 +551,22 @@ int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_ i, ind->crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti, eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti); - } pthread_mutex_unlock(&eNB->UL_INFO_mutex); // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); - //mac_crc_ind(p7_vnf->mac, ind); + //mac_crc_ind(p7_vnf->mac, ind); + return 1; } -int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind) -{ +int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind) { + struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - if (ind->rx_indication_body.number_of_pdus==0) - { - LOG_E(MAC, "%s() NFAPI SFN/SF:%d number_of_pdus:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus); + if (ind->rx_indication_body.number_of_pdus==0) { + LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_pdus:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus); } pthread_mutex_lock(&eNB->UL_INFO_mutex); @@ -744,8 +577,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* *dest_ind = *ind; dest_ind->rx_indication_body.rx_pdu_list = dest_pdu_list; - for(int i=0; i<ind->rx_indication_body.number_of_pdus; i++) - { + for(int i=0; i<ind->rx_indication_body.number_of_pdus; i++) { nfapi_rx_indication_pdu_t *dest_pdu = &dest_ind->rx_indication_body.rx_pdu_list[i]; nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i]; @@ -756,7 +588,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length); - LOG_E(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", + LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i, dest_pdu->rx_ue_information.handle, @@ -775,14 +607,13 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* //mac_rx_ind(p7_vnf->mac, ind); return 1; } -int phy_srs_indication(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind) -{ - // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); - //mac_srs_ind(p7_vnf->mac, ind); - return 1; +int phy_srs_indication(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind) { + // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + //mac_srs_ind(p7_vnf->mac, ind); + return 1; } -int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind) -{ + +int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind) { struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; @@ -798,8 +629,7 @@ int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* LOG_D(MAC,"%s() eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs); - for (int i=0;i<eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs;i++) - { + for (int i=0;i<eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs;i++) { nfapi_sr_indication_pdu_t *dest_pdu = &dest_ind->sr_indication_body.sr_pdu_list[i]; nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i]; @@ -812,16 +642,17 @@ int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_sr_ind(p7_vnf->mac, ind); + return 1; } -int phy_cqi_indication(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind) -{ +int phy_cqi_indication(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind) { + // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); //mac_cqi_ind(p7_vnf->mac, ind); struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - LOG_E(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis); + LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis); pthread_mutex_lock(&eNB->UL_INFO_mutex); @@ -832,43 +663,39 @@ int phy_cqi_indication(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_ return 1; } -int phy_lbt_dl_indication(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind) -{ - // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); - //mac_lbt_dl_ind(p7_vnf->mac, ind); - return 1; +int phy_lbt_dl_indication(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind) { + // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + //mac_lbt_dl_ind(p7_vnf->mac, ind); + return 1; } -int phy_nb_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind) -{ - // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); - //mac_nb_harq_ind(p7_vnf->mac, ind); - return 1; + +int phy_nb_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind) { + // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + //mac_nb_harq_ind(p7_vnf->mac, ind); + return 1; } -int phy_nrach_indication(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind) -{ - // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); - //mac_nrach_ind(p7_vnf->mac, ind); - return 1; + +int phy_nrach_indication(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind) { + // vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + //mac_nrach_ind(p7_vnf->mac, ind); + return 1; } -void* vnf_allocate(size_t size) -{ - //return (void*)memory_pool::allocate(size); - return (void*)malloc(size); +void* vnf_allocate(size_t size) { + //return (void*)memory_pool::allocate(size); + return (void*)malloc(size); } -void vnf_deallocate(void* ptr) -{ - //memory_pool::deallocate((uint8_t*)ptr); - free(ptr); +void vnf_deallocate(void* ptr) { + //memory_pool::deallocate((uint8_t*)ptr); + free(ptr); } extern void nfapi_log(char *file, char *func, int line, int comp, int level, const char* format, va_list args); -void vnf_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) -{ -#if 1 - va_list args; +void vnf_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) { + + va_list args; int oai_level; if (nfapi_level==NFAPI_TRACE_ERROR) @@ -895,119 +722,109 @@ void vnf_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) va_start(args, message); nfapi_log("FILE>", "FUNC", 999, PHY, oai_level, message, args); va_end(args); -#else - va_list args; - va_start(args, message); - vprintf(message, args); - va_end(args); -#endif } -int phy_vendor_ext(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg) -{ - if(msg->message_id == P7_VENDOR_EXT_IND) - { - //vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg; - //printf("[VNF] vendor_ext (error_code:%d)\n", ind->error_code); - } - else - { - printf("[VNF] unknown %02x\n", msg->message_id); - } - return 0; +int phy_vendor_ext(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg) { + + if(msg->message_id == P7_VENDOR_EXT_IND) + { + //vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg; + //printf("[VNF] vendor_ext (error_code:%d)\n", ind->error_code); + } + else + { + printf("[VNF] unknown %02x\n", msg->message_id); + } + return 0; } -nfapi_p7_message_header_t* phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t* msg_size) -{ - if(message_id == P7_VENDOR_EXT_IND) - { - *msg_size = sizeof(vendor_ext_p7_ind); - return (nfapi_p7_message_header_t*)malloc(sizeof(vendor_ext_p7_ind)); - } - return 0; +nfapi_p7_message_header_t* phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t* msg_size) { + if(message_id == P7_VENDOR_EXT_IND) + { + *msg_size = sizeof(vendor_ext_p7_ind); + return (nfapi_p7_message_header_t*)malloc(sizeof(vendor_ext_p7_ind)); + } + return 0; } -void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header) -{ - free(header); +void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header) { + free(header); } -/// maybe these should be in the mac file... -int phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p7_codec_config_t* codec) -{ - (void)tl; - (void)ppReadPackedMessage; - (void)ve; - return -1; +int phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p7_codec_config_t* codec) { + + (void)tl; + (void)ppReadPackedMessage; + (void)ve; + return -1; } -int phy_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* codec) -{ - //NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n"); - - nfapi_tl_t* tlv = (nfapi_tl_t*)ve; - switch(tlv->tag) - { - case VENDOR_EXT_TLV_1_TAG: - { - //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n"); - vendor_ext_tlv_1* ve = (vendor_ext_tlv_1*)tlv; - if(!push32(ve->dummy, ppWritePackedMsg, end)) - return 0; - return 1; - } - break; - default: - return -1; - break; - } +int phy_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* codec) { + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n"); + + nfapi_tl_t* tlv = (nfapi_tl_t*)ve; + switch(tlv->tag) { + case VENDOR_EXT_TLV_1_TAG: + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n"); + vendor_ext_tlv_1* ve = (vendor_ext_tlv_1*)tlv; + if(!push32(ve->dummy, ppWritePackedMsg, end)) + return 0; + return 1; + } + break; + default: + return -1; + break; + } } -int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t* config) -{ - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); - if(header->message_id == P7_VENDOR_EXT_IND) - { - vendor_ext_p7_ind* req = (vendor_ext_p7_ind*)(header); - if(!pull16(ppReadPackedMessage, &req->error_code, end)) - return 0; - } - return 1; +int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t* config) { + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); + if(header->message_id == P7_VENDOR_EXT_IND) { + vendor_ext_p7_ind* req = (vendor_ext_p7_ind*)(header); + if(!pull16(ppReadPackedMessage, &req->error_code, end)) + return 0; + } + + return 1; } -int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) -{ - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); - 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); - if(!(push16(req->dummy1, ppWritePackedMsg, end) && - push16(req->dummy2, ppWritePackedMsg, end))) - return 0; - } - return 1; +int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); + 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); + if(!(push16(req->dummy1, ppWritePackedMsg, end) && + push16(req->dummy2, ppWritePackedMsg, end))) + return 0; + } + return 1; } -int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppWritePackedMsg, 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); - //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2); - return (!(push16(req->dummy1, ppWritePackedMsg, end) && - push16(req->dummy2, ppWritePackedMsg, end))); - } - return 0; +int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppWritePackedMsg, 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); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2); + return (!(push16(req->dummy1, ppWritePackedMsg, end) && + push16(req->dummy2, ppWritePackedMsg, end))); + } + return 0; } static pthread_t vnf_start_pthread; static pthread_t vnf_p7_start_pthread; -void* vnf_p7_start_thread(void *ptr) -{ + +void* vnf_p7_start_thread(void *ptr) { + printf("%s()\n", __FUNCTION__); + pthread_setname_np(pthread_self(), "VNF_P7"); + nfapi_vnf_p7_config_t* config = (nfapi_vnf_p7_config_t*)ptr; nfapi_vnf_p7_start(config); @@ -1017,61 +834,62 @@ void* vnf_p7_start_thread(void *ptr) void set_thread_priority(int priority); -void* vnf_p7_thread_start(void* ptr) -{ - set_thread_priority(79); - - vnf_p7_info* p7_vnf = (vnf_p7_info*)ptr; - - p7_vnf->config->port = p7_vnf->local_port; - p7_vnf->config->sync_indication = &phy_sync_indication; - p7_vnf->config->subframe_indication = &phy_subframe_indication; - p7_vnf->config->harq_indication = &phy_harq_indication; - p7_vnf->config->crc_indication = &phy_crc_indication; - p7_vnf->config->rx_indication = &phy_rx_indication; - p7_vnf->config->rach_indication = &phy_rach_indication; - p7_vnf->config->srs_indication = &phy_srs_indication; - p7_vnf->config->sr_indication = &phy_sr_indication; - p7_vnf->config->cqi_indication = &phy_cqi_indication; - p7_vnf->config->lbt_dl_indication = &phy_lbt_dl_indication; - p7_vnf->config->nb_harq_indication = &phy_nb_harq_indication; - p7_vnf->config->nrach_indication = &phy_nrach_indication; - p7_vnf->config->malloc = &vnf_allocate; - p7_vnf->config->free = &vnf_deallocate; - - p7_vnf->config->trace = &vnf_trace; - - p7_vnf->config->vendor_ext = &phy_vendor_ext; - p7_vnf->config->user_data = p7_vnf; - - p7_vnf->mac->user_data = p7_vnf; - - p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension; - p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension; - p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv; - p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv; - p7_vnf->config->codec_config.allocate = &vnf_allocate; - p7_vnf->config->codec_config.deallocate = &vnf_deallocate; - - p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext; - p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext; - - { - NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__); - pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config); - } - return 0; +void* vnf_p7_thread_start(void* ptr) { + + set_thread_priority(79); + + vnf_p7_info* p7_vnf = (vnf_p7_info*)ptr; + + p7_vnf->config->port = p7_vnf->local_port; + p7_vnf->config->sync_indication = &phy_sync_indication; + p7_vnf->config->subframe_indication = &phy_subframe_indication; + p7_vnf->config->harq_indication = &phy_harq_indication; + p7_vnf->config->crc_indication = &phy_crc_indication; + p7_vnf->config->rx_indication = &phy_rx_indication; + p7_vnf->config->rach_indication = &phy_rach_indication; + p7_vnf->config->srs_indication = &phy_srs_indication; + p7_vnf->config->sr_indication = &phy_sr_indication; + p7_vnf->config->cqi_indication = &phy_cqi_indication; + p7_vnf->config->lbt_dl_indication = &phy_lbt_dl_indication; + p7_vnf->config->nb_harq_indication = &phy_nb_harq_indication; + p7_vnf->config->nrach_indication = &phy_nrach_indication; + p7_vnf->config->malloc = &vnf_allocate; + p7_vnf->config->free = &vnf_deallocate; + + p7_vnf->config->trace = &vnf_trace; + + p7_vnf->config->vendor_ext = &phy_vendor_ext; + p7_vnf->config->user_data = p7_vnf; + + p7_vnf->mac->user_data = p7_vnf; + + p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension; + p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension; + p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv; + p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv; + p7_vnf->config->codec_config.allocate = &vnf_allocate; + p7_vnf->config->codec_config.deallocate = &vnf_deallocate; + + p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext; + p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__); + pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config); + + return 0; } -int pnf_start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp) -{ +int pnf_start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp) { + vnf_info* vnf = (vnf_info*)(config->user_data); vnf_p7_info *p7_vnf = vnf->p7_vnfs; + pnf_info *pnf = vnf->pnfs; + nfapi_param_request_t req; printf("[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started); - if(p7_vnf->thread_started == 0) - { + if(p7_vnf->thread_started == 0) { + pthread_t vnf_p7_thread; pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, p7_vnf); p7_vnf->thread_started = 1; @@ -1082,143 +900,92 @@ int pnf_start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_re } // start all the phys in the pnf. + printf("[VNF] Sending NFAPI_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id); -#if 0 - auto find_result = vnf->pnfs.find(p5_idx); - if(find_result != vnf->pnfs.end()) - { - pnf_info& pnf = find_result->second; - - for(unsigned i = 0; i < pnf.phys.size(); ++i) - { - pnf_info& pnf = find_result->second; - } - } -#else - { - pnf_info *pnf = vnf->pnfs; - nfapi_param_request_t req; - - printf("[VNF] Sending NFAPI_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id); - - memset(&req, 0, sizeof(req)); - req.header.message_id = NFAPI_PARAM_REQUEST; - req.header.phy_id = pnf->phys[0].id; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PARAM_REQUEST; + req.header.phy_id = pnf->phys[0].id; - nfapi_vnf_param_req(config, p5_idx, &req); - } -#endif + nfapi_vnf_param_req(config, p5_idx, &req); return 0; } extern uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw); -int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* resp) -{ +int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* resp) { + printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); vnf_info* vnf = (vnf_info*)(config->user_data); + vnf_p7_info *p7_vnf = vnf->p7_vnfs; -#if 0 - auto find_result = vnf->pnfs.find(p5_idx); - if(find_result != vnf->pnfs.end()) - { - pnf_info& pnf = find_result->second; - - auto found = std::find_if(pnf.phys.begin(), pnf.phys.end(), [&](phy_info& item) - { return item.id == resp->header.phy_id; }); - - if(found != pnf.phys.end()) - { - phy_info& phy = (*found); -#else pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; - { - { -#endif + struct sockaddr_in pnf_p7_sockaddr; + nfapi_config_request_t *req = &RC.mac[0]->config[0]; - phy->remote_port = resp->nfapi_config.p7_pnf_port.value; + phy->remote_port = resp->nfapi_config.p7_pnf_port.value; - struct sockaddr_in pnf_p7_sockaddr; - memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4); + memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4); - phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr); + phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr); - // for now just 1 - vnf_p7_info *p7_vnf = vnf->p7_vnfs; + // for now just 1 - printf("[VNF] %d.%d pnf p7 %s:%d timing %d %d %d %d\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period); + printf("[VNF] %d.%d pnf p7 %s:%d timing %d %d %d %d\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period); - nfapi_config_request_t *req = &RC.mac[0]->config[0]; + req->header.message_id = NFAPI_CONFIG_REQUEST; + req->header.phy_id = phy->id; - //memset(&req, 0, sizeof(req)); - req->header.message_id = NFAPI_CONFIG_REQUEST; - req->header.phy_id = phy->id; + printf("[VNF] Send NFAPI_CONFIG_REQUEST\n"); - printf("[VNF] Send NFAPI_CONFIG_REQUEST\n"); + req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG; + req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port; + req->num_tlv++; - req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG; - req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port; - req->num_tlv++; + printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port); -printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port); + req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; + struct sockaddr_in vnf_p7_sockaddr; + vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr); + memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4); + req->num_tlv++; + printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr); - req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; - struct sockaddr_in vnf_p7_sockaddr; - vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr); - memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4); - req->num_tlv++; -printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr); + req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG; + req->nfapi_config.timing_window.value = p7_vnf->timing_window; + printf("[VNF] Timing window:%d\n", p7_vnf->timing_window); + req->num_tlv++; - req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG; - req->nfapi_config.timing_window.value = p7_vnf->timing_window; -printf("[VNF] Timing window:%d\n", p7_vnf->timing_window); - req->num_tlv++; + if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) { - if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) - { - req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG; - req->nfapi_config.timing_info_mode.value = (p7_vnf->aperiodic_timing_enabled << 1) | (p7_vnf->periodic_timing_enabled); - req->num_tlv++; - - if(p7_vnf->periodic_timing_enabled) - { - req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG; - req->nfapi_config.timing_info_period.value = p7_vnf->periodic_timing_period; - req->num_tlv++; - } - } + req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG; + req->nfapi_config.timing_info_mode.value = (p7_vnf->aperiodic_timing_enabled << 1) | (p7_vnf->periodic_timing_enabled); + req->num_tlv++; - vendor_ext_tlv_2 ve2; - memset(&ve2, 0, sizeof(ve2)); - ve2.tl.tag = VENDOR_EXT_TLV_2_TAG; - ve2.dummy = 2016; - req->vendor_extension = &ve2.tl; + if(p7_vnf->periodic_timing_enabled) { - nfapi_vnf_config_req(config, p5_idx, req); - printf("[VNF] Sent NFAPI_CONFIG_REQ num_tlv:%u\n",req->num_tlv); - } -#if 0 - else - { - printf("[VNF] param response failed to find pnf %d phy %d\n", p5_idx, resp->header.phy_id); + req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG; + req->nfapi_config.timing_info_period.value = p7_vnf->periodic_timing_period; + req->num_tlv++; } -#endif - } -#if 0 - else - { - printf("[VNF] param response failed to find pnf %d\n", p5_idx); } -#endif + + vendor_ext_tlv_2 ve2; + memset(&ve2, 0, sizeof(ve2)); + ve2.tl.tag = VENDOR_EXT_TLV_2_TAG; + ve2.dummy = 2016; + req->vendor_extension = &ve2.tl; + + nfapi_vnf_config_req(config, p5_idx, req); + printf("[VNF] Sent NFAPI_CONFIG_REQ num_tlv:%u\n",req->num_tlv); return 0; } -int config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp) -{ +int config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp) { + nfapi_start_request_t req; printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); @@ -1236,64 +1003,25 @@ int config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response return 0; } -int start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp) -{ +int start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp) { + printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); vnf_info* vnf = (vnf_info*)(config->user_data); -#if 0 - auto find_result = vnf->pnfs.find(p5_idx); - if(find_result != vnf->pnfs.end()) - { - pnf_info& pnf = find_result->second; - - - auto found = std::find_if(pnf.phys.begin(), pnf.phys.end(), [&](phy_info& item) - { return item.id == resp->header.phy_id; }); - - if(found != pnf.phys.end()) - { - phy_info& phy = (*found); - - vnf_p7_info& p7_vnf = vnf->p7_vnfs[0]; - - nfapi_vnf_p7_add_pnf((p7_vnf.config.get()), phy.remote_addr.c_str(), phy.remote_port, phy.id); - - } - } -#else pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; vnf_p7_info *p7_vnf = vnf->p7_vnfs; nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id); - -#if 0 - { - extern pthread_cond_t nfapi_sync_cond; - extern pthread_mutex_t nfapi_sync_mutex; - extern int nfapi_sync_var; - - printf("[VNF] Signal to OAI main code that it can go\n"); - pthread_mutex_lock(&nfapi_sync_mutex); - nfapi_sync_var=0; - pthread_cond_broadcast(&nfapi_sync_cond); - pthread_mutex_unlock(&nfapi_sync_mutex); - } -#endif - -#endif - return 0; } -int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg) -{ +int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg) { + printf("[VNF] %s\n", __FUNCTION__); - switch(msg->message_id) - { + switch(msg->message_id) { case P5_VENDOR_EXT_RSP: { vendor_ext_p5_rsp* rsp = (vendor_ext_p5_rsp*)msg; @@ -1312,8 +1040,8 @@ int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_he return 0; } -int vnf_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 vnf_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_RSP) { @@ -1323,27 +1051,27 @@ int vnf_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint return 0; } -nfapi_p4_p5_message_header_t* vnf_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t* msg_size) -{ - if(message_id == P5_VENDOR_EXT_RSP) - { +nfapi_p4_p5_message_header_t* vnf_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t* msg_size) { + + if(message_id == P5_VENDOR_EXT_RSP) { *msg_size = sizeof(vendor_ext_p5_rsp); return (nfapi_p4_p5_message_header_t*)malloc(sizeof(vendor_ext_p5_rsp)); } return 0; } -void vnf_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t* header) -{ +void vnf_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t* header) { free(header); } nfapi_vnf_config_t *config = 0; -void vnf_start_thread(void* ptr) -{ +void vnf_start_thread(void* ptr) { + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] VNF NFAPI thread - nfapi_vnf_start()%s\n", __FUNCTION__); + pthread_setname_np(pthread_self(), "VNF"); + config = (nfapi_vnf_config_t*)ptr; nfapi_vnf_start(config); @@ -1362,8 +1090,7 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) vnf.p7_vnfs[0].timing_window = 32; vnf.p7_vnfs[0].periodic_timing_enabled = 1; - // Panos: - vnf.p7_vnfs[0].aperiodic_timing_enabled = 1; + vnf.p7_vnfs[0].aperiodic_timing_enabled = 0; vnf.p7_vnfs[0].periodic_timing_period = 10; vnf.p7_vnfs[0].config = nfapi_vnf_p7_config_create(); @@ -1409,11 +1136,9 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) config->codec_config.allocate = &vnf_allocate; config->codec_config.deallocate = &vnf_deallocate; - { - NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__); - pthread_create(&vnf_start_pthread, NULL, (void*)&vnf_start_thread, config); - NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Created VNF NFAPI start thread %s\n", __FUNCTION__); - } + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__); + pthread_create(&vnf_start_pthread, NULL, (void*)&vnf_start_thread, config); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Created VNF NFAPI start thread %s\n", __FUNCTION__); } int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) @@ -1421,11 +1146,6 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! - //dl_config_req->header.message_id = NFAPI_DL_CONFIG_BCH_PDU_TYPE; - - //LOG_D(PHY, "[VNF] %s() header message_id:%02x\n", __FUNCTION__, dl_config_req->header.message_id); - - //LOG_D(PHY, "[VNF] %s() DL_CONFIG sfn_sf:%d pdcch:%d dci:%d pdu:%d pdsch_rnti:%d pcfich:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(dl_config_req->sfn_sf), dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols, dl_config_req->dl_config_request_body.number_dci, dl_config_req->dl_config_request_body.number_pdu, dl_config_req->dl_config_request_body.number_pdsch_rnti, dl_config_req->dl_config_request_body.transmission_power_pcfich); int retval = nfapi_vnf_p7_dl_config_req(p7_config, dl_config_req); @@ -1434,8 +1154,7 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) dl_config_req->dl_config_request_body.number_pdu = 0; dl_config_req->dl_config_request_body.number_pdsch_rnti = 0; - if (retval!=0) - { + if (retval!=0) { LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval); } return retval; @@ -1452,19 +1171,15 @@ int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) int retval = nfapi_vnf_p7_tx_req(p7_config, tx_req); - if (retval!=0) - { + if (retval!=0) { LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval); - } - else - { + } else { tx_req->tx_request_body.number_of_pdus = 0; } return retval; } -int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) -{ +int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; hi_dci0_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! @@ -1473,21 +1188,17 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) int retval = nfapi_vnf_p7_hi_dci0_req(p7_config, hi_dci0_req); - - if (retval!=0) - { + if (retval!=0) { LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval); - } - else - { + } else { hi_dci0_req->hi_dci0_request_body.number_of_hi = 0; hi_dci0_req->hi_dci0_request_body.number_of_dci = 0; } return retval; } -int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) -{ +int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { + nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; ul_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! @@ -1498,12 +1209,9 @@ int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) int retval = nfapi_vnf_p7_ul_config_req(p7_config, ul_config_req); - if (retval!=0) - { + if (retval!=0) { LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval); - } - else - { + } else { // Reset number of PDUs so that it is not resent ul_config_req->ul_config_request_body.number_of_pdus = 0; ul_config_req->ul_config_request_body.rach_prach_frequency_resources = 0; diff --git a/openair2/RRC/LITE/MESSAGES/rtai_mem.h b/nfapi/oai_integration/nfapi_vnf.h similarity index 70% rename from openair2/RRC/LITE/MESSAGES/rtai_mem.h rename to nfapi/oai_integration/nfapi_vnf.h index 9efc24851f0d57b92c7a43c78330e13e6586962b..4ea26eda12d1a8d3feb1d9013830eff9c72b7b44 100644 --- a/openair2/RRC/LITE/MESSAGES/rtai_mem.h +++ b/nfapi/oai_integration/nfapi_vnf.h @@ -19,26 +19,9 @@ * contact@openairinterface.org */ -/*! \file rtai_mem.h -* \brief a wrapper for Unified RTAI real-time memory management. -* \author Florian Kaltenberger -* \date 2011-04-06 -* \version 0.1 -* \company Eurecom -* \email: florian.kaltenberger@eurecom.fr -* \note -* \bug -* \warning -*/ +#if !defined(NFAPI_VNF_H__) +#define NFAPI_VNF_H__ -/* -void* rt_alloc_wrapper(int size); - -int rt_free_wrapper(void* ptr); - -void* rt_realloc_wrapper(void* oldptr, int size); -*/ - -void* rt_realloc(void* oldptr, int size); +void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port); -void* rt_calloc(int nmemb, int size); +#endif diff --git a/nfapi/oai_integration/vendor_ext.h b/nfapi/oai_integration/vendor_ext.h new file mode 100644 index 0000000000000000000000000000000000000000..0622432260060dc7ef3f4fc4d76f889a7e3860d8 --- /dev/null +++ b/nfapi/oai_integration/vendor_ext.h @@ -0,0 +1,67 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _VENDOR_EXT_H_ +#define _VENDOR_EXT_H_ + +#include "nfapi_interface.h" + +typedef enum { + P5_VENDOR_EXT_REQ = NFAPI_VENDOR_EXT_MSG_MIN, + P5_VENDOR_EXT_RSP, + + P7_VENDOR_EXT_REQ, + P7_VENDOR_EXT_IND + +} vendor_ext_message_id_e; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint16_t dummy1; + uint16_t dummy2; +} vendor_ext_p5_req; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint16_t error_code; +} vendor_ext_p5_rsp; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t dummy1; + uint16_t dummy2; +} vendor_ext_p7_req; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t error_code; +} vendor_ext_p7_ind; + +typedef struct { + nfapi_tl_t tl; + uint32_t dummy; +} vendor_ext_tlv_1; + +#define VENDOR_EXT_TLV_1_TAG 0xF001 + +typedef struct { + nfapi_tl_t tl; + uint32_t dummy; +} vendor_ext_tlv_2; + +#define VENDOR_EXT_TLV_2_TAG 0xF002 + +#endif // _VENDOR_EXT_ diff --git a/nfapi/open-nFAPI/.travis.yml b/nfapi/open-nFAPI/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..ce2faea92371b6bb7c7748819cfbe69a926692b2 --- /dev/null +++ b/nfapi/open-nFAPI/.travis.yml @@ -0,0 +1,36 @@ + +env: + global: + # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created + # via the "travis encrypt" command using the project repo's public key + - secure: "oNj8JhGBN/zjzrAU7y2Nn/wxSxA/MDp2Y8fVLLp6fhx+y2mWdlMZhgCjeKSpdbGtroUnxErX1P8t+8EPz2+mMoq+G809Q9t7eJjd1+6nkVhEEfDXN83BmJkvIylC0/IKJiT2wCa8LzbdhpQUFyZ1Gk1WKZozAW5HotfFjm6/NFi/GX4uA7S0tU5E4yC3r4yqH9cLZ+arWMOEY/X0lrx0n6tLjDe921kFwkZQGFzAzrbXN2fZXKQ3xFcpREWEgEWsY7H2n4T7oJI3nEPY4P/4kvCjeQMjnlATEwtcciBiUbHRew4WWSTndF54crRlqFlzFcEf/Ouz27U/d2xYHJWcWNi88l+/qsb+V0uobwhiGUJGbVhf9IkgEO3tr/zbwkPDFrXpa/1xuSoc6jDm8i61gKQkcBhQsRFXlciPvwLhiL07gzeAfZD1Yke3tE+0geHPbEA0czzwtHe35jorAKYWsFXOXmcoK9t9SpnvBRFz6JuEsHPooafze43sTJg3qkgBszkU+U38CneeAVwo/uTA3Zw1ZrtOQv56v0UvAHze/VAF5z3rFJPl1oJl60OI8V5UBg4yIa2bySKhO//zwd4MGmsBpcWwDuu2BHUVasfk0vaetVxVVtdXG/2BuBP+IXinpJtI48NSFs6PT82dHz4cDF/iLDs0hPC6sbV258PY8F0=" + +language: cpp + +dist: trusty +sudo: required + +compiler: + - g++ + +before_install: + - sudo apt-get install doxygen + - sudo apt-get install libcunit1-dev + - sudo apt-get install libz-dev + - sudo apt-get install libsctp-dev + - sudo apt-get install libboost-all-dev + - autoreconf -i + +addons: + coverity_scan: + project: + name: cisco-open-nFAPI + version: 1.0 + description: Build submitted via Travis CI + notification_email: xxx@cisco.com + build_command_prepend: ./configure + build_command: make + branch_pattern: coverity_scan + +script: + - ./configure && make && make check diff --git a/nfapi/open-nFAPI/CHANGELOG.md b/nfapi/open-nFAPI/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/nfapi/open-nFAPI/LICENSE.md b/nfapi/open-nFAPI/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..5e0fd33cbbdc8038b61e29ce0437688cc3bc1d00 --- /dev/null +++ b/nfapi/open-nFAPI/LICENSE.md @@ -0,0 +1,201 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "{}" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + +Copyright {yyyy} {name of copyright owner} + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/nfapi/open-nFAPI/Makefile.am b/nfapi/open-nFAPI/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..900cf2bbcf5ad4740f544fe9af7132e4a37eba68 --- /dev/null +++ b/nfapi/open-nFAPI/Makefile.am @@ -0,0 +1,15 @@ +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS =common/ \ + sim_common/ \ + nfapi/ \ + pnf/ \ + vnf/ \ + nfapi/tests \ + pnf/tests \ + vnf/tests \ + pnf_sim/ \ + vnf_sim/ \ + integration_tests/ \ + docs/ \ + $(NULL) diff --git a/nfapi/open-nFAPI/README.md b/nfapi/open-nFAPI/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f3132c78d6f088e3df6ef32f97262250f7989393 --- /dev/null +++ b/nfapi/open-nFAPI/README.md @@ -0,0 +1,138 @@ +[](https://travis-ci.org/cisco/open-nFAPI) +[](https://scan.coverity.com/projects/cisco-open-nfapi) + +# open-nFAPI + +Open-nFAPI is implementation of the Small Cell Forum's network functional API or nFAPI for short. +nFAPI defines a network protocol that is used to connect a Physical Network Function (PNF) +running LTE Layer 1 to a Virtual Network Function (VNF) running LTE layer 2 and above. The specification +can be found at http://scf.io/documents/082. + +The aim of open-nFAPI is to provide an open interface between LTE layer 1 and layer 2 to allow for +interoperability between the PNF and VNF & also to facilitate the sharing of PNF's between +different VNF's + +Open-nFAPI implements the P4, P5 and P7 interfaces as defined by the nFAPI specification. +* The P5 interface allows the VNF to query and configure the 'resources' of the PNF; i.e slice it into + 1 or more PHY instances. +* The P7 interface is used to send the subframe information between the PNF and VNF for a PHY instance +* The P4 interface allows the VNF to request the PNF PHY instance to perform measurements of the surrounding network + +The remaining interfaces are currently outside of the scope of this project. + +Supports release 082.09.05 of the nFAPI specification + +**The Small Cell Forum cordially requests that any derivative work that looks to +extend the nFAPI libraries use the specified vendor extension techniques, +so ensuring the widest interoperability of the baseline nFAPI specification +in those derivative works.** + +## Awards + +The Open-nFAPI project has won the Small Cell Forum Judges Choice award 2017. (http://www.smallcellforum.org/awards-2/winners-2017/) + +## Licensing + +The open-nFAPI libraries are release by CISCO under an Apache 2 license. See `LICENSE.md` file for details + +## Downloading + +The open-nFAPI project can be pulled from git hub + +``` +git clone https://github.com/cisco/open-nFAPI.git nfapi +``` + +The following dependencies are required. These are based on a fresh ubuntu installation. + +``` +sudo apt-get install autoconf +sudo apt-get install gcc +sudo apt-get install g++ +sudo apt-get install libtool +sudo apt-get install make +sudo apt-get install doxygen +sudo apt-get install libcunit1-dev +sudo apt-get install libz-dev +sudo apt-get install libsctp-dev +sudo apt-get install libboost-all-dev +``` + + + +## Building + +To build the open-nFAPI project + +``` +autoreconf -i +./configure +make +``` + +To run the unit and integration tests + +``` +make check +``` + +You may notice in the console output of the final integration tests the following + +``` +*** Missing subframe 123 125 +``` + +Out of the box the machine on which you are running has not be configured for real time operation as a result +the vnf may not be scheduled at the correct times and hence it may risk 'missing' subframe opportunities. This +warning indicates this has happened. + +## Running the simulator + +The vnf and pnf simulator can be run using the following commands. The pnf and vnf simulator support sourcing and sinking +data over udp. Review the xml configuration files for the details of the port and address to configure. Console logging will show +which address:port is being used + +Note : Pinning the simulators to unused cores will produce more consistent behaviour. + +Note : You may have to run the processes with sudo to be able to set the real time scheduling and priority + +### vnf simulator + +To run the vnf simulator you need to specify the port the vnf will listen for p5 connection request upon and also the xml configuration file + +``` +vnfsim <port> <xml config file> +``` + +### pnf simulator + +To run the vnf simulator you need to specify the addrss & port the pnf will connect to the vnf on and also the xml configuration file + +``` +pnfsim <address> <port> <xml config file> +``` + + +## Directory structure + +``` +docs doxgen documentation +common common code used by the nfapi libraries +nfapi the nfapi library including message definitions & encode/decode functions +pnf the pnf library for p4, p5, & p7 interfaces +vnf the vnf library for p4, p5, & p7 interfaces +sim_common common simulation for used by the vnf and pnf sim +vnf_sim a vnf simulator including a stub mac implementation +pnf_sim a pnf simualtor including a fapi interface defintion and stub implementation +xml xml configuration files for the vnf and pnf simulator +wireshark code for a wireshark dissector for the nFAPI protocol +``` + +## Coverity + +Coverity runs on the coverity-scan branch. Changes must be merged to the coverity-scan branch to be checked. + + +## eNB Integration - Open Air Interface + +The open-nFAPI implementation has been integrated with the Open Air Interface solution here (https://gitlab.eurecom.fr/oai/openairinterface5g) and is (at the time of writing) here (https://gitlab.eurecom.fr/daveprice/openairinterface5g/tree/nfapi-ru-rau-split). The open-nFAPI implementation is integrated with the source eNB implementation with any changes required applied as a patch on top of the baseline open-nFAPI library. Any extensions required must be implemented through the vendor extensions as specified by the Small Cell Forum documentation. Any integration wrapping of functionality must be done within the target environment as shown in the Open Air Interface implementation nfapi directory which is defined by the $NFAPI_DIR location at the top level. diff --git a/nfapi/open-nFAPI/common/Makefile.am b/nfapi/open-nFAPI/common/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..3e3326ea2c9dea397e3b2bb47ea6f7e736a870ba --- /dev/null +++ b/nfapi/open-nFAPI/common/Makefile.am @@ -0,0 +1,31 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +AM_CPPFLAGS = -I$(top_srcdir)/common/public_inc -g -Wall -Werror + +noinst_LIBRARIES =libnfapi_common.a + +libnfapi_common_a_SOURCES = src/debug.c + +libnfapi_common_a_CFLAGS =$(AM_CFLAGS) + +lib_LTLIBRARIES =libnfapi_common.la + +libnfapi_common_la_SOURCES = src/debug.c + + + + diff --git a/nfapi/open-nFAPI/common/public_inc/debug.h b/nfapi/open-nFAPI/common/public_inc/debug.h new file mode 100644 index 0000000000000000000000000000000000000000..14f97a17f6f8fbe23bd2e3e414b51baaa90f4714 --- /dev/null +++ b/nfapi/open-nFAPI/common/public_inc/debug.h @@ -0,0 +1,51 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _DEBUG_H_ +#define _DEBUG_H_ + +/*! The trace levels used by the nfapi libraries */ +typedef enum nfapi_trace_level +{ + NFAPI_TRACE_ERROR = 1, + NFAPI_TRACE_WARN, + NFAPI_TRACE_NOTE, + NFAPI_TRACE_INFO, + + NFAPI_TRACE_LEVEL_MAX +} nfapi_trace_level_t; + +/*! The trace function pointer */ +typedef void (*nfapi_trace_fn_t)(nfapi_trace_level_t level, const char* format, ...); + +/*! Global trace function */ +extern nfapi_trace_fn_t nfapi_trace_g; + +/*! Global trace level */ +extern nfapi_trace_level_t nfapi_trace_level_g; + +/*! NFAPI trace macro */ +//#define NFAPI_TRACE(level, format, ...) { if(nfapi_trace_g && ((nfapi_trace_level_t)level <= nfapi_trace_level_g)) (*nfapi_trace_g)(level, format, ##__VA_ARGS__); } +#define NFAPI_TRACE(level, format, ...) { if (nfapi_trace_g) (*nfapi_trace_g)(level, format, ##__VA_ARGS__); } + +/*! Function to change the trace level + * \param new_level The modified trace level + */ + +void nfapi_set_trace_level(nfapi_trace_level_t new_level); + +#endif /* _DEBUG_H_ */ diff --git a/nfapi/open-nFAPI/common/src/debug.c b/nfapi/open-nFAPI/common/src/debug.c new file mode 100644 index 0000000000000000000000000000000000000000..a45d41d7d7218f806869f6fda7dd9c628b893d9a --- /dev/null +++ b/nfapi/open-nFAPI/common/src/debug.c @@ -0,0 +1,76 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <stdio.h> +#include <stdarg.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/types.h> +#include <pthread.h> +#include <syslog.h> + +#include <debug.h> + +#define MAX_MSG_LENGTH 2096 +#define TRACE_HEADER_LENGTH 44 + +void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...); + +// initialize the trace function to 0 +void (*nfapi_trace_g)(nfapi_trace_level_t level, const char* format, ...) = &nfapi_trace_dbg; + +nfapi_trace_level_t nfapi_trace_level_g = NFAPI_TRACE_INFO; +//nfapi_trace_level_t nfapi_trace_level_g = NFAPI_TRACE_WARN; + +void nfapi_set_trace_level(nfapi_trace_level_t new_level) +{ + nfapi_trace_level_g = new_level; +} + +void nfapi_trace_dbg(nfapi_trace_level_t level, const char *format, ...) +{ + char trace_buff[MAX_MSG_LENGTH + TRACE_HEADER_LENGTH]; + uint32_t num_chars; + va_list p_args; + struct timeval tv; + pthread_t tid = pthread_self(); + + (void)gettimeofday(&tv, NULL); + + num_chars = (uint32_t)snprintf(trace_buff, TRACE_HEADER_LENGTH, "%04u.%06u: 0x%02x: %10u: ", ((uint32_t)tv.tv_sec) & 0x1FFF, (uint32_t)tv.tv_usec, (uint32_t)level, (uint32_t)tid); + + if (num_chars > TRACE_HEADER_LENGTH) + { + printf("trace_dbg: Error, num_chars is too large: %d", num_chars); + return; + } + + va_start(p_args, format); + if ((num_chars = (uint32_t)vsnprintf(&trace_buff[num_chars], MAX_MSG_LENGTH, format, p_args))) + { + if (level <= NFAPI_TRACE_WARN) + { + printf("%s", trace_buff); + } + printf("%s", trace_buff); + } + va_end(p_args); +} diff --git a/nfapi/open-nFAPI/configure.ac b/nfapi/open-nFAPI/configure.ac new file mode 100644 index 0000000000000000000000000000000000000000..fd3b387ee50d185af57efe1e27cb8f6777ebb28a --- /dev/null +++ b/nfapi/open-nFAPI/configure.ac @@ -0,0 +1,45 @@ +AC_INIT([open-nFAPI], [1.0]) + +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign serial-tests]) +AM_PROG_AR + +LT_INIT([shared static]) + +# Dependencies +AC_PROG_CC +AC_PROG_CXX +AC_PROG_AWK +AC_CONFIG_HEADERS([config.h]) + +AC_PROG_LIBTOOL + +AC_CHECK_FILE([/usr/include/CUnit/CUnit.h], + [CFLAGS_CUNIT=-I/usr/include/CUnit AC_SUBST(CFLAGS_CUNIT)], + [AC_MSG_NOTICE([Have cunit *************])]) + +# Need doxygen +AC_CHECK_PROGS([DOXYGEN], [doxygen]) +if test -z "$DOXYGEN"; + then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support]) +fi +AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([docs/Doxyfile])]) + +AC_REQUIRE_AUX_FILE([tap-driver.sh]) + +AC_CONFIG_FILES([Makefile + sim_common/Makefile + common/Makefile + nfapi/Makefile + pnf/Makefile + vnf/Makefile + nfapi/tests/Makefile + pnf/tests/Makefile + vnf/tests/Makefile + pnf_sim/Makefile + vnf_sim/Makefile + integration_tests/Makefile + docs/Makefile +]) +AC_OUTPUT diff --git a/nfapi/open-nFAPI/docs/Doxyfile b/nfapi/open-nFAPI/docs/Doxyfile new file mode 100644 index 0000000000000000000000000000000000000000..9491727d2b53802448d2bad3abd61e6009ee2210 --- /dev/null +++ b/nfapi/open-nFAPI/docs/Doxyfile @@ -0,0 +1,1720 @@ +# Doxyfile 1.7.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = open-nFAPI + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 1.0 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../nfapi/public_inc ../pnf/public_inc ../vnf/public_inc ../docs/doxygen.h + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is adviced to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# If the HTML_TIMESTAMP tag is set to YES then the generated HTML documentation will contain the timesstamp. + +HTML_TIMESTAMP = NO + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> +# Qt Help Project / Custom Filters</a>. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> +# Qt Help Project / Filter Attributes</a>. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called Helvetica to the output +# directory and reference it in all dot files that doxygen generates. +# When you want a differently looking font you can specify the font name +# using DOT_FONTNAME. You need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/nfapi/open-nFAPI/docs/Doxyfile.in b/nfapi/open-nFAPI/docs/Doxyfile.in new file mode 100644 index 0000000000000000000000000000000000000000..74d405ad000e5b796d92948249e95018a1b4bb33 --- /dev/null +++ b/nfapi/open-nFAPI/docs/Doxyfile.in @@ -0,0 +1,1720 @@ +# Doxyfile 1.7.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = @PACKAGE_NAME@ + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @PACKAGE_VERSION@ + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = @top_srcdir@/nfapi/public_inc @top_srcdir@/pnf/public_inc @top_srcdir@/vnf/public_inc @top_srcdir@/docs/doxygen.h + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is adviced to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# If the HTML_TIMESTAMP tag is set to YES then the generated HTML documentation will contain the timesstamp. + +HTML_TIMESTAMP = NO + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> +# Qt Help Project / Custom Filters</a>. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> +# Qt Help Project / Filter Attributes</a>. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called Helvetica to the output +# directory and reference it in all dot files that doxygen generates. +# When you want a differently looking font you can specify the font name +# using DOT_FONTNAME. You need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/nfapi/open-nFAPI/docs/Makefile.am b/nfapi/open-nFAPI/docs/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..9530fa844d9d99e1a8df86f3c90dddcb46008826 --- /dev/null +++ b/nfapi/open-nFAPI/docs/Makefile.am @@ -0,0 +1,35 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if HAVE_DOXYGEN +directory = $(top_srcdir)/docs/man/man3/ + +dist_man_MANS = $(directory)/man_page_1.3 $(directory)/man_page_2.3 +$(directory)/man_page_1.3: doxyfile.stamp +$(directory)/man_page_2.3: doxyfile.stamp + +doxyfile.stamp: + $(DOXYGEN) Doxyfile + echo Timestamp > doxyfile.stamp + +CLEANFILES = doxyfile.stamp + +all-local: doxyfile.stamp +clean-local: + rm -rf $(top_srcdir)/docs/man + rm -rf $(top_srcdir)/docs/html + rm -rf $(top_srcdir)/docs/latex +endif diff --git a/nfapi/open-nFAPI/docs/doxygen.h b/nfapi/open-nFAPI/docs/doxygen.h new file mode 100644 index 0000000000000000000000000000000000000000..ae815e68d6feb2389a7978e182998a5300e0a1b8 --- /dev/null +++ b/nfapi/open-nFAPI/docs/doxygen.h @@ -0,0 +1,327 @@ +/*! \mainpage Open Network Function Application Platform Interface (Open-nFAPI) + * + * \section intro_sec Introduction + * + * Open-nFAPI is implementation of the Small Cell Forum's network femto API or nFAPI for short. + * nFAPI defines a network protocol that is used to connect a Physical Network Function (PNF) + * running LTE Layer 1 to a Virtual Network Function (VNF) running LTE Layer 2 and above. The specification + * can be found at http://scf.io/documents/082. + * + * The aim of Open-nFAPI is to provide an open interface between LTE Layer 1 and Layer 2 to allow for + * interoperability between the PNF and VNF & also to facilitate the sharing of PNF's between + * different VNF's + * + * Open-nFAPI implements the P4, P5 and P7 interfaces as defined by the nFAPI specification. + * - The P5 interface allows the VNF to query and configure the 'resources' of the PNF; slicing it into + * 1 or more phy instances. + * - The P7 interface is used to send the subframe information between the PNF and VNF for 1 or more phy instances + * - The P4 interface allows the VNF to request the PNF phy instances to perform measurements of the surrounding network + * + * The remaining interfaces are currently outside of the scope of this project. + * + * The best place to start is by reviewing the detailed nFAPI call flow which can be \ref nfapi_call_flow "here" + * + * \section contrib Contibuting + * + * The Small Cell Forum cordially requests that any derivative work that looks to extend + * the nFAPI libraries use the specified vendor extension techniques, so ensuring + *the widest interoperability of the baseline nFAPI specification in those derivative works. + * + * \section install_sec Installation + * + * \subsection step1 Step 1: Opening the box + * + * etc... + * + * \section dir_struct Directory Structure + * \code + + * nfapi + * |- common Common functions for the nfapi project + * | |- src + * | |- public-inc + * |- nfapi The NFAPI lib + * | |- inc + * | |- src + * | |- public-inc Public interface for the nfapi library + * | |- tests Unit test for the nfapi lib + * |- pnf The PNF lib + * | |- inc + * | |- src + * | |- public-inc Public interface for the pnf library + * | |- tests Unit test for the pnf lib + * |- vnf The VNF lib + * | |- inc + * | |- src + * | |- public-inc Public interface for the vnf library + * | |- tests Unit test for the vnf lib + * |- sim_common Common functions for the nfapi simulators + * | |- inc + * | |- src + * |- pnf_sim The PNF simulator + * | |- inc + * | |- src + * |- vnf_sim The VNF simulator + * | |- inc + * | |- src + * |- integration_tests Integration tests that run both VNF & PNF simulators + * | |- inc + * | |- src + * |- docs Documentation + * |- xml Xml configuration for the simulator + + * \endcode + * \section building Building + * To build the nfapi project and run the unit test you will need to + * \code + * autoreconf -i + * ./configure + * make + * make check + * \endcode + * The following dependencies will be required + * - Boost. Need to build the simulators + * - STCP. Need to run the simulators + * - + * \section simulators Running the simulators + * Once you have build the nfapi project you can run the PNF/VNF simulators on either the same + * of seperate linux machines. + * + * To run the VNF from the vnf_sim directory. + * \code + * ./vnfsim 4242 ../xml/vnf_A.xml + * [MAC] Rx Data from 8891 + * [MAC] Tx Data to 10.231.16.80.8892 + * Calling nfapi_vnf_start + * 2035.854438: 0x04: 773068608: nfapi_vnf_start() + * 2035.854450: 0x04: 773068608: Starting P5 VNF connection on port 4242 + * 2035.854472: 0x04: 773068608: P5 socket created... 3 + * 2035.854478: 0x03: 773068608: VNF Setting the SCTP_INITMSG + * 2035.854481: 0x04: 773068608: IPV4 binding to port 4242 + * 2035.854485: 0x04: 773068608: bind succeeded..3. + * 2035.854497: 0x04: 773068608: listen succeeded... + * \endcode + * + * + * To run the PNF from the pnf_sim directory + * \code + * ./pnfsim 127.0.01 4242 ../xml/pnf_phy_1_A.xml + * nfapi_pnf_start + * Starting P5 PNF connection to VNF at 127.0.0.1:4242 + * Host address info 0 Family:IPV4 Address:127.0.0.1 + * PNF Setting the SCTP_INITMSG + * P5 socket created... + * Socket CONNECTED + * PNF_PARAM.request received + * [PNF_SIM] pnf param request + * PNF_CONFIG.request received + * [PNF_SIM] pnf config request + * .... and so on + * \endcode + * + * You can Ctrl-C to exit the simulators. + * + + */ + +/*! \page nfapi_call_flow NFAPI Call Flow + * + * \section seq_diag Sequence diagram + * + * The follow sequence digram show how the nFAPI api will be used to bring up + * the PNF and then the PNF PHY and initiate subframe message exchange + * The names of the CLIENT callbacks are placeholders for the functions that + * the CLIENT will provide. + * + * \msc + * + * width="1750"; + * FAPI, PNF_P7_CLIENT, PNF_P7_LIB, PNF_P5_CLIENT, PNF_P5_LIB, VNF_P5_LIB, VNF_P5_CLIENT, VNF_P7_LIB, VNF_P7_CLIENT, MAC; + * VNF_P5_CLIENT=>VNF_P5_LIB [label="nfapi_vnf_config_create", URL="\ref nfapi_vnf_config_create"]; + * VNF_P5_CLIENT=>VNF_P5_LIB [label="nfapi_vnf_start", URL="\ref nfapi_vnf_start"]; + * VNF_P5_LIB note VNF_P5_LIB [label="Listening for PNF connection"]; + * PNF_P5_CLIENT note PNF_P5_CLIENT [label="P9 has provided the address of the VNF"]; + * PNF_P5_CLIENT=>PNF_P5_LIB [label="nfapi_pnf_config_create", URL="\ref nfapi_pnf_config_create"]; + * PNF_P5_CLIENT=>PNF_P5_LIB [label="nfapi_pnf_start", URL="\ref nfapi_pnf_start"]; + * PNF_P5_LIB note PNF_P5_LIB [label="PNF STATE : PNF IDLE"]; + * PNF_P5_LIB->VNF_P5_LIB [label="<connect>"]; + * VNF_P5_LIB=>VNF_P5_CLIENT [label="pnf_connection_indication", URL="\ref nfapi_vnf_config::pnf_connection_indication"]; + * + * VNF_P5_LIB<=VNF_P5_CLIENT [label="nfapi_vnf_pnf_param_req", URL="\ref nfapi_vnf_pnf_param_req"]; + * VNF_P5_LIB->PNF_P5_LIB [label="PNF_PARAM.request"]; + * PNF_P5_LIB=>PNF_P5_CLIENT [label="pnf_param_request", URL="\ref nfapi_pnf_config::pnf_param_req"]; + * PNF_P5_LIB<=PNF_P5_CLIENT [label="nfapi_pnf_pnf_param_response", URL="\ref nfapi_pnf_pnf_param_resp"]; + * VNF_P5_LIB<-PNF_P5_LIB [label="PNF_PARAM.response"]; + * VNF_P5_LIB=>VNF_P5_CLIENT [label="pnf_param_response", URL="\ref nfapi_vnf_config::pnf_param_resp"]; + * + * VNF_P5_LIB<=VNF_P5_CLIENT [label="nfapi_vnf_pnf_config_req", URL="\ref nfapi_vnf_pnf_config_req"]; + * VNF_P5_LIB->PNF_P5_LIB [label="PNF_CONFIG.request"]; + * PNF_P5_LIB=>PNF_P5_CLIENT [label="pnf_config_request", URL="\ref nfapi_pnf_config::pnf_config_req"]; + * PNF_P5_LIB<=PNF_P5_CLIENT [label="nfapi_pnf_pnf_config_response", URL="\ref nfapi_pnf_pnf_config_resp"]; + * PNF_P5_LIB note PNF_P5_LIB [label="PNF STATE : PNF CONFIGURED"]; + * VNF_P5_LIB<-PNF_P5_LIB [label="PNF_CONFIG.response"]; + * VNF_P5_LIB=>VNF_P5_CLIENT [label="pnf_config_response", URL="\ref nfapi_vnf_config::pnf_config_resp"]; + * + * VNF_P5_LIB<=VNF_P5_CLIENT [label="nfapi_vnf_pnf_start_req", URL="\ref nfapi_vnf_pnf_start_req"]; + * VNF_P5_LIB->PNF_P5_LIB [label="PNF_START.request"]; + * PNF_P5_LIB=>PNF_P5_CLIENT [label="pnf_start_request", URL="\ref nfapi_pnf_config::pnf_start_req"]; + * PNF_P5_CLIENT=>FAPI [label="<create>"]; + * FAPI note FAPI [label="FAPI STATE : IDLE"]; + * PNF_P5_LIB<=PNF_P5_CLIENT [label="nfapi_pnf_pnf_start_response", URL="\ref nfapi_pnf_pnf_start_resp"]; + * PNF_P5_LIB note PNF_P5_LIB [label="PNF STATE : PNF RUNNING"]; + * VNF_P5_LIB<-PNF_P5_LIB [label="PNF_START.response"]; + * VNF_P5_LIB=>VNF_P5_CLIENT [label="pnf_start_response", URL="\ref nfapi_vnf_config::pnf_param_resp"]; + * + * --- [ label="If vnf p7 instance not already running"]; + * VNF_P5_CLIENT=>VNF_P5_LIB [label="nfapi_vnf_allocate_phy", URL="\ref nfapi_vnf_allocate_phy"]; + * VNF_P5_CLIENT=>VNF_P7_CLIENT [label="<create>"]; + * VNF_P7_CLIENT=>VNF_P7_LIB [label="nfapi_vnf_p7_config_create", URL="\ref nfapi_vnf_p7_config_create"]; + * VNF_P7_CLIENT=>VNF_P7_LIB [label="nfapi_vnf_p7_start", URL="\ref nfapi_vnf_p7_start"]; + * ---; + * + * VNF_P5_LIB<=VNF_P5_CLIENT [label="nfapi_vnf_param_request", URL="\ref nfapi_vnf_param_req"]; + * VNF_P5_LIB->PNF_P5_LIB [label="PARAM.request"]; + * PNF_P5_LIB=>PNF_P5_CLIENT [label="param_request", URL="\ref nfapi_pnf_config::param_req"]; + * PNF_P5_CLIENT=>FAPI [label="fapi_param_request"]; + * PNF_P5_CLIENT<=FAPI [label="fapi_param_response"]; + * PNF_P5_CLIENT=>PNF_P7_CLIENT [label="<create>"]; + * PNF_P7_CLIENT=>PNF_P7_LIB [label="nfapi_pnf_p7_create", URL="\ref nfapi_pnf_p7_config_create"]; + * PNF_P7_CLIENT=>PNF_P7_LIB [label="nfapi_pnf_p7_start", URL="\ref nfapi_pnf_p7_start"]; + * PNF_P5_LIB<=PNF_P5_CLIENT [label="nfapi_pnf_param_response", URL="\ref nfapi_pnf_param_resp"]; + * VNF_P5_LIB<-PNF_P5_LIB [label="PARAM.response"]; + * VNF_P5_LIB=>VNF_P5_CLIENT [label="param_response", URL="\ref nfapi_vnf_config::param_resp"]; + * + * VNF_P5_LIB<=VNF_P5_CLIENT [label="nfapi_vnf_config_request", URL="\ref nfapi_vnf_config_req"]; + * VNF_P5_LIB->PNF_P5_LIB [label="CONFIG.request"]; + * PNF_P5_LIB=>PNF_P5_CLIENT [label="config_request", URL="\ref nfapi_pnf_config::config_req"]; + * PNF_P5_CLIENT=>FAPI [label="fapi_config_request"]; + * FAPI note FAPI [label="FAPI STATE : CONFIGURED"]; + * PNF_P5_CLIENT<=FAPI [label="fapi_config_response"]; + * PNF_P5_LIB<=PNF_P5_CLIENT [label="nfapi_pnf_config_response", URL="\ref nfapi_pnf_param_resp"]; + * VNF_P5_LIB<-PNF_P5_LIB [label="CONFIG.response"]; + * VNF_P5_LIB=>VNF_P5_CLIENT [label="config_response", URL="\ref nfapi_vnf_config::config_resp"]; + * + * VNF_P5_LIB<=VNF_P5_CLIENT [label="nfapi_vnf_start_request", URL="\ref nfapi_vnf_start_req"]; + * VNF_P5_LIB->PNF_P5_LIB [label="START.request"]; + * PNF_P5_LIB=>PNF_P5_CLIENT [label="start_request", URL="\ref nfapi_pnf_config::start_req"]; + * PNF_P5_CLIENT=>FAPI [label="fapi_start_request"]; + * FAPI note FAPI [label="FAPI STATE : RUNNING"]; + * FAPI note FAPI [label="FAPI will start sending subframe indications"]; + * + * --- [ label="For each 'phy' subframe"]; + * FAPI=>PNF_P7_CLIENT [label="fapi_subframe_indication"]; + * PNF_P7_CLIENT=>PNF_P7_LIB [label="nfapi_pnf_p7_subframe_ind", URL="\ref nfapi_pnf_p7_subframe_ind"]; + * ---; + * PNF_P7_CLIENT=>PNF_P5_CLIENT [label="<start_response>"]; + * + * PNF_P5_LIB<=PNF_P5_CLIENT [label="nfapi_pnf_start_response", URL="\ref nfapi_pnf_start_resp"]; + * VNF_P5_LIB<-PNF_P5_LIB [label="START.response"]; + * VNF_P5_LIB=>VNF_P5_CLIENT [label="start_response", URL="\ref nfapi_vnf_config::start_resp"]; + * VNF_P5_CLIENT=>VNF_P7_CLIENT [label="<p7_add_pnf>"]; + * VNF_P7_CLIENT=>VNF_P7_LIB [label="nfapi_vnf_p7_add_pnf", URL="\ref nfapi_vnf_p7_add_pnf"]; + * + * VNF_P7_LIB->PNF_P7_LIB [label="DL_NODE_SYNC"]; + * VNF_P7_LIB<-PNF_P7_LIB [label="UL_NODE_SYNC"]; + * VNF_P7_LIB<-PNF_P7_LIB [label="TIMING_INFO"]; + * VNF_P7_LIB note VNF_P7_LIB [label="When sync is achieved"]; + * + * VNF_P7_LIB=>VNF_P7_CLIENT [label="sync_indication", URL="\ref nfapi_vnf_p7_config::sync_indication"]; + * + * --- [ label="For each 'vnf phy' subframe"]; + * VNF_P7_LIB=>VNF_P7_CLIENT [label="subframe_indication(tti=x)", URL="\ref nfapi_vnf_p7_config::subframe_indication"]; + * VNF_P7_CLIENT=>MAC [label="subframe_indication"]; + * VNF_P7_CLIENT<=MAC [label="dl_config_req"]; + * VNF_P7_CLIENT=>VNF_P7_LIB [label="nfapi_vnf_p7_dl_config_req", URL="\ref nfapi_vnf_p7_dl_config_req"]; + * VNF_P7_LIB->PNF_P7_LIB [label="DL_CONFIG.request"]; + * PNF_P7_LIB note PNF_P7_LIB [label="Store in subframe buffer for tti x"]; + * VNF_P7_CLIENT<=MAC [label="ul_config_req"]; + * VNF_P7_CLIENT=>VNF_P7_LIB [label="nfapi_vnf_p7_ul_config_req", URL="\ref nfapi_vnf_p7_ul_config_req"]; + * VNF_P7_LIB->PNF_P7_LIB [label="UL_CONFIG.request"]; + * PNF_P7_LIB note PNF_P7_LIB [label="Store in subframe buffer for tti x"]; + * VNF_P7_CLIENT<=MAC [label="hi_dci0_req"]; + * VNF_P7_CLIENT=>VNF_P7_LIB [label="nfapi_vnf_p7_hi_dci0_req", URL="\ref nfapi_vnf_p7_hi_dci0_req"]; + * VNF_P7_LIB->PNF_P7_LIB [label="HI_DCI0.request"]; + * PNF_P7_LIB note PNF_P7_LIB [label="Store in subframe buffer for tti x"]; + * VNF_P7_CLIENT<=MAC [label="tx_req"]; + * VNF_P7_CLIENT=>VNF_P7_LIB [label="nfapi_vnf_p7_tx_req", URL="\ref nfapi_vnf_p7_tx_req"]; + * VNF_P7_LIB->PNF_P7_LIB [label="TX.request"]; + * PNF_P7_LIB note PNF_P7_LIB [label="Store in subframe buffer for tti x"]; + * ---; + * + * + * --- [ label="For each 'phy' subframe"]; + * + * FAPI=>PNF_P7_CLIENT [label="harq_indication"]; + * PNF_P7_CLIENT=>PNF_P7_LIB [label="nfapi_pnf_p7_harq_ind", URL="\ref nfapi_pnf_p7_harq_ind"]; + * PNF_P7_LIB->VNF_P7_LIB [label="HARQ.ind"]; + * VNF_P7_LIB=>VNF_P7_CLIENT [label="harq_ind", URL="\ref nfapi_vnf_p7_config::harq_indication"]; + * VNF_P7_CLIENT=>MAC [label="harq_ind"]; + * + * FAPI=>PNF_P7_CLIENT [label="subframe_indication(tti=x)"]; + * PNF_P7_CLIENT=>PNF_P7_LIB [label="nfapi_pnf_p7_subframe_ind", URL="\ref nfapi_pnf_p7_subframe_ind"]; + * PNF_P7_LIB note PNF_P7_LIB [label="Send data from subframe buffer for tti x"]; + * PNF_P7_LIB=>PNF_P7_CLIENT [label="dl_config_req", URL="\ref nfapi_pnf_p7_config::dl_config_req"]; + * PNF_P7_CLIENT=>FAPI [label="dl_config_req"]; + * PNF_P7_LIB=>PNF_P7_CLIENT [label="ul_config_req", URL="\ref nfapi_pnf_p7_config::ul_config_req"]; + * PNF_P7_CLIENT=>FAPI [label="ul_config_req"]; + * PNF_P7_LIB=>PNF_P7_CLIENT [label="hi_dci0_req", URL="\ref nfapi_pnf_p7_config::hi_dci0_req"]; + * PNF_P7_CLIENT=>FAPI [label="hi_dci0_req"]; + * PNF_P7_LIB=>PNF_P7_CLIENT [label="tx_req", URL="\ref nfapi_pnf_p7_config::tx_req"]; + * PNF_P7_CLIENT=>FAPI [label="tx_req"]; + * ---; + * + * \endmsc + * + * \section seq_diag_bca BCA + * + * -# The VNF_P5_CLIENT is created. If it left to the VRAN partner to define how that is done. The client is responsiable to creation of the thread with the correct priorities within the wider system. + * -# The VNF_P5_CLIENT creates and initializes the VNF_P5_LIB (nfapi_vnf_config_create & nfapi_vnf_start) providing the address that it should listen on for incoming SCTP connections. It is expected that this would be provided by some VNF management system. The VNF_P5_CLIENT also provides information on the callbacks that the VNF_P5_LIB will use to inform the VNF_P5_CLIENT of the received messages + * \code + * nfapi_vnf_config_t* vnf_config = nfapi_vnf_config_create(); + * vnf_config->pnf_connection_indication = &pnf_connection_indication; + * vnf_config->pnf_param_resp = &pnf_param_resp; + * nfapi_vnf_start(vnf_config); + * \endcode + * -# It is FFS how the address information of the VNF P5 is passed to the PNF over P9, but assuming that has been done + * -# The PNF_P5_CLIENT is created and then creates the PNF_P5_LIB (nfapi_pnf_init & nfapi_pnf_start) passing the address of the VNF to connect to. The PNF_P5_CLIENT also provides information on the callbacks that the PNF_P5_LIB will use to inform the PNF_P5_CLIENT of the received messages + * \code + * nfapi_pnf_config_t* pnf_config = nfapi_pnf_config_create(); + * pnf_config->pnf_param_req = &pnf_param_req; + * nfapi_pnf_start(pnf_config); + * \endcode + * -# The PNF_P5_LIB attempts to establish connection to the VNF_P5 endpoint + * -# The VNF_P5_LIB receives the STCP connection request and indicates this to the VNF_P5_CLIENT (pnf_connection_indication). The VNF_P5_CLIENT can decide to accept or reject the connection. + * \code + * int pnf_connection_indication(nfapi_vnf_config_t* config, int p5_idx) { + * // send the PNF_PARAM.request + * nfapi_pnf_param_request_t req; + * memset(&req, 0, sizeof(req)); + * req.header.message_id = NFAPI_PNF_PARAM_REQUEST; + * nfapi_vnf_pnf_param_req(config, p5_idx, req); + * return 0; + * } + * \endcode + + * -# The VNF and PNF then proceed to exchange the NFAPI PNF messages (PNF_PARAM, PNF_CONFIG and PNF_START). At each stage the LIB’s invoke callbacks on the CLIENT’s for them to handle message the return the appropriate response. + * -# Finally the VNF will send the PNF_START.req which will invoke the PNF_P5_CLIENT nfapi_pnf_start_request callback. This is the point at which it is expect that the PNF_CLIENT will create the FAPI module. The PNF_P5_CLIENT will need to perform the translation between NFAPI structures and vendor specific FAPI structures for messages sent between the PNF_P5_LIB and the FAPI interface. + * -# The PNF_START.response will sent back to the VNF and at this point the VNF_P5_CLIENT will need to decide which VNF_P7 instance will handle the P7 connection. i.e. it needs to determine the IP address and port number of the P7 VNF instance. + * -# A new VNF_P7_CLIENT & VNF_P7_LIB should be configured and started if necessary. + * -# The VNF_P5 will then send the PARAM.request to the PNF_P5 which will forward it onto the FAPI interface. This PARAM.request includes the VNF_P7 address. The PNF_P7_CLIENT must decide on the PNF P7 address. This information is used to create and initialize the PNF_P7_LIB. The PNF_P7 address is then returned by the PNF_P5 to the VNF_P5 in the PARAM.response. + * -# The VNF_P5 will then exchange with the PNF_P5 the CONFIG.request/response which will be used to configure the PNF FAPI instance. + * -# The VNF_P5 will then decide to start the PNF_P7 by sending the START.request. + * -# The PNF_P5_CLIENT need to send the start request to the FAPI instance. The response which is the start of subframe indications from the FAPI. In receipt of the first subframe indication the PNF_P5_CLIENT will send the START.response to the VNF_P5 via the PNF_P5_LIB + * -# The FAPI subframe indications should be forwarded to the PNF_P7_LIB by the PNF_P7_CLIENT. Until the VNF_P7 instance has sent the subframe configuration messages (dl_config, ul_config, etc) the PNF_P7_LIB will send ‘dummy’ subframe configuration messages. The contents of which are configurable by the PNF_P7_CLIENT. + * -# When the VNF_P5_CLIENT receives the START.response it will need to ‘communicate’ with the VNF_P7_CLIENT to inform it that the PNF_P7 instance has started. The VNF_P7_CLIENT will call the nfapi_vnf_P7_add_pnf function passing the address details of the PNF_P7 instance. + * -# The VNF_P7_LIB will then start the sync procedure to establish sub frame synchronization between the PNF_P7 and VNF_P7 instances. This involves sending the DL_NODE_SYNC and UL_NODE_SYNC to determine network latency and PNF processing latency to be able to request MAC generate sub frames in advance on when they are required by the FAPI interface. + * -# When sync is achieved the VNF_P7_LIB will send the nfapi_sync_indication to the VNF_P7_CLIENT. + * -# The VNF_P7_LIB will then start issuing sub frame indications to the VNF_P7_CLIENT. The logical intent is that they indications are sent every millisecond. However due to the scheduling jitter that may be seen by the VNF these subframe indications may be less than or more than 1ms apart. How this is handled is one of the critical functions of the VNF_P7_LIB and may require specialization or requirements on the VNF environment i.e. CPU pinning. + * -# The VNF_P7_LIB will send the subframe_indication to the VNF_P7_CLIENT for ‘x’ subframe’s inadvance of the current TTI at the PNF. The delta ‘x’ will be determined by the sync procedure and how far in advance the FAPI needs to receive messages before RF transmission. + * -# The VNF_P7_CLIENT is then responsible for communicating to the MAC layer to prepare the dl_config_request, ul_config_request, hi_dci0_request, tx_req in a timely manner and sending them to the VNF_P7_LIB + * -# The VNF_P7_LIB will send them to the VNF_P7_LIB. + * -# The PNF_P7_LIB will store these messages in a subframe buffer or playout buffer in advance of when they are required by FAPI. + * -# The PNF_P7_LIB will monitor to see if these messages arrive too late and if they do trigger a TIMING_INFO response to the VNF_P7_LIB to reassess if the sync is still valid. + * -# As some time in the future the FAPI will send a subframe indication for the TTI that the VNF_P7_LIB had previously requested. + * -# The PNF_P7_LIB will then use the messages in the subframe buffer and send them too the FAPI interface for transmission. The PNF_P7_CLIENT will need to perform the translation between NFAPI structure and vendor specific FAPI structures + * -# This subframe exchange will continue and allow high layer MAC and RRC function to bringup the cell and connect UE’s + + */ diff --git a/nfapi/open-nFAPI/integration_tests/Makefile.am b/nfapi/open-nFAPI/integration_tests/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..2413590182596bea836252483d9ed1ccc4eb22af --- /dev/null +++ b/nfapi/open-nFAPI/integration_tests/Makefile.am @@ -0,0 +1,29 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#vnf unit test +AM_CPPFLAGS = -I../nfapi/inc -I../nfapi/public_inc -I../common/public_inc -I../vnf/public_inc $(CFLAGS_CUNIT) -Wall -Werror + +export LD_LIBRARY_PATH=/opt/gcc-4.7.3/lib +check_PROGRAMS= nfapi_integration_tests +nfapi_integration_tests_SOURCES = main.cpp ../common/src/debug.c +nfapi_integration_tests_LDADD= -L$(libdir) -lpthread -lrt -lcunit + + + +LOG_DRIVER = $(top_srcdir)/tap-driver.sh +TESTS=nfapi_integration_tests +EXTRA_DIST=$(TESTS) diff --git a/nfapi/open-nFAPI/integration_tests/main.cpp b/nfapi/open-nFAPI/integration_tests/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..83c48afec3d086374bd8221ba6918f1c1c27845f --- /dev/null +++ b/nfapi/open-nFAPI/integration_tests/main.cpp @@ -0,0 +1,269 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "CUnit.h" +#include "Basic.h" +#include "Automated.h" + +#include <unistd.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/wait.h> + +int start_vnf_proc(int port) +{ + char port_str[10]; + sprintf(port_str, "%d", port); + + const char *argv[] = {"vnfsim", port_str, "../xml/vnf_A.xml", NULL}; + int pid = fork(); + + if(pid == 0) + { + int result = execv("../vnf_sim/vnfsim", (char* const*)argv); //, env_args); + if(result == -1) + { + printf("Failed to exec vnf process %d\n", errno); + } + exit(0); + } + else + { + return pid; + } +} + +int start_pnf_proc(const char* addr, int port, const char* file) +{ + char port_str[10]; + sprintf(port_str, "%d", port); + + char filename[256]; + sprintf(filename, "../xml/%s", file); + + const char * argv[] = {"pnfsim", addr, port_str, filename, NULL}; + int pid = fork(); + + if(pid == 0) + { + int result = execv("../pnf_sim/pnfsim", (char* const*)argv); //, env_args); + if(result == -1) + { + printf("Failed to exec pnf process %d\n", errno); + } + exit(0); + } + else + { + return pid; + } +} + +int kill_proc(int pid) +{ + kill(pid, SIGKILL); + + int status; + int waitpid_result = waitpid(pid, &status, 0); + + return waitpid_result; +} + + +void test_1() +{ + + int pnf_port = 5655; + const char* pnf_addr = "localhost"; + + printf("**** starting vnf *****\n"); + int vnf_pid = start_vnf_proc(pnf_port); + + printf("**** starting pnf *****\n"); + int pnf1_pid = start_pnf_proc(pnf_addr, pnf_port, "pnf_phy_1_A.xml"); + + + sleep(10); + + printf ("*** Terminating ****\n"); + kill_proc(vnf_pid); + kill_proc(pnf1_pid); +} +void test_1a() +{ + + int pnf_port = 5655; + const char* pnf_addr = "localhost"; + + printf("**** starting vnf *****\n"); + int vnf_pid = start_vnf_proc(pnf_port); + + printf("**** starting pnf *****\n"); + int pnf1_pid = start_pnf_proc(pnf_addr, pnf_port, "pnf_phy_2_A.xml"); + + + sleep(10); + + printf ("*** Terminating ****\n"); + kill_proc(vnf_pid); + kill_proc(pnf1_pid); +} + + +void test_2() +{ + int pnf_port = 5655; + const char* pnf_addr = "127.0.0.1"; + + int vnf_pid = start_vnf_proc(pnf_port); + sleep(2); + + int pnf1_pid = start_pnf_proc(pnf_addr, pnf_port, "pnf_phy_1_A.xml"); + int pnf2_pid = start_pnf_proc(pnf_addr, pnf_port, "pnf_phy_1_A.xml"); + + sleep(2); + + kill_proc(pnf2_pid); + kill_proc(pnf1_pid); + kill_proc(vnf_pid); +} + +void test_32() +{ + int pnf_count = 32; + int pnf_pid[pnf_count]; + + int pnf_port = 5655; + const char* pnf_addr = "127.0.0.1"; + + int vnf_pid = start_vnf_proc(pnf_port); + sleep(2); + + for(int i = 0; i < pnf_count; ++i) + { + pnf_pid[i] = start_pnf_proc(pnf_addr, pnf_port, "pnf_phy_1_A.xml"); + } + + sleep(5); + + printf ("*** Terminating pnfs\n"); + + for(int i = 0; i < pnf_count; ++i) + { + kill_proc(pnf_pid[i]); + } + printf ("*** Terminating vnf\n"); + kill_proc(vnf_pid); +} + + +int init_suite() +{ + return 0; +} + +int clean_suite() +{ + return 0; +} + +int main ( void ) +{ + CU_pSuite pSuite = NULL; + + /* initialize the CUnit test registry */ + if ( CUE_SUCCESS != CU_initialize_registry() ) + return CU_get_error(); + + /* add a suite to the registry */ + pSuite = CU_add_suite( "integration_test_suite", init_suite, clean_suite ); + if ( NULL == pSuite ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + //(NULL == CU_add_test(pSuite, "vnf_test_start_connect_2", vnf_test_start_connect_2)) + /* add the tests to the suite */ + if ( (NULL == CU_add_test(pSuite, "test_1a", test_1a)) +// (NULL == CU_add_test(pSuite, "test_2", test_2)) || +// (NULL == CU_add_test(pSuite, "test_32", test_32)) + ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + // Run all tests using the basic interface + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_set_output_filename("vnf_unit_test_results.xml"); + CU_basic_run_tests(); + + CU_pSuite s = CU_get_registry()->pSuite; + int count = 0; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + count++; + t = t->pNext; + } + s = s->pNext; + } + + printf("%d..%d\n", 1, count); + + + + s = CU_get_registry()->pSuite; + count = 1; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + int pass = 1; + CU_FailureRecord* failures = CU_get_failure_list(); + while(failures) + { + if(strcmp(failures->pSuite->pName, s->pName) == 0 && + strcmp(failures->pTest->pName, t->pName) == 0) + { + pass = 0; + failures = 0; + } + else + { + failures = failures->pNext; + } + } + + if(pass) + printf("ok %d - %s:%s\n", count, s->pName, t->pName); + else + printf("not ok %d - %s:%s\n", count, s->pName, t->pName); + + count++; + t = t->pNext; + } + s = s->pNext; + } + + CU_cleanup_registry(); + return CU_get_error(); + +} diff --git a/nfapi/open-nFAPI/nfapi/Makefile.am b/nfapi/open-nFAPI/nfapi/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..853ee9ff80a35529fac8a3e4937c6707512f32c5 --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +AUTOMAKE_OPTIONS=subdir-objects +AM_CPPFLAGS = -I$(top_srcdir)/nfapi/inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/pnf/public_inc $(BOOST_CPPFLAGS) -Wall -Werror -g + +noinst_LIBRARIES = libnfapi.a + +libnfapi_a_SOURCES = src/nfapi.c src/nfapi_p5.c src/nfapi_p7.c src/nfapi_p4.c +libnfapi_a_CFLAGS =$(AM_CFLAGS) + +lib_LTLIBRARIES = libnfapi.la +libnfapi_la_SOURCES = src/nfapi.c src/nfapi_p5.c src/nfapi_p7.c src/nfapi_p4.c + + +LDADD= ../pnf/src/libnfapi_pnf.a ../vnf/src/libnfapi_vnf.a ../common/bin/libnfapi_common.a + diff --git a/nfapi/open-nFAPI/nfapi/inc/nfapi.h b/nfapi/open-nFAPI/nfapi/inc/nfapi.h new file mode 100644 index 0000000000000000000000000000000000000000..65ad4dd1609653c85b67dd777f2491859de4ab63 --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/inc/nfapi.h @@ -0,0 +1,91 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _NFAPI_H_ +#define _NFAPI_H_ + +#if defined(__cplusplus) +extern "C" { +#endif + +// todo : move to public_inc so can be used by vendor extensions + +#define MAX_BAD_TAG 3 + +uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end); +uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end); +uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end); +uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end); +uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end); +uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end); + +uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end); +uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end); +uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end); +uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end); +uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end); +uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end); + + +uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end); +uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end); +uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end); + +uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); +uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); +uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end); + +typedef uint8_t (*pack_array_elem_fn)(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end); +uint8_t packarray(void* array, uint16_t elem_size, uint16_t max_count, uint16_t count, uint8_t **ppWritePackedMsg, uint8_t *end, pack_array_elem_fn fn); + +typedef uint8_t (*unpack_array_elem_fn)(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end); +uint8_t unpackarray(uint8_t **ppReadPackedMsg, void* array, uint16_t elem_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn); + +uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end); +uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end); + +typedef uint8_t (*pack_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end); +uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn); + +uint32_t pack_vendor_extension_tlv(nfapi_tl_t* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config); +int unpack_vendor_extension(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve_tlv); + +typedef uint8_t (*unpack_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end); +typedef struct +{ + uint16_t tag; + void* tlv; + unpack_tlv_fn unpack_func; +} unpack_tlv_t; + +int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t* packedMsgEnd, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve); + +uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config); +typedef uint8_t (*unpack_p7_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t*); +typedef struct +{ + uint16_t tag; + void* tlv; + unpack_p7_tlv_fn unpack_func; +} unpack_p7_tlv_t; +int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t* packedMsgEnd, nfapi_p7_codec_config_t* config, nfapi_tl_t** ve); + +#if defined(__cplusplus) +} +#endif + +#endif /* _NFAPI_H_ */ diff --git a/nfapi/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h similarity index 99% rename from nfapi/nfapi_interface.h rename to nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index 45af99a50f3384725c167e93c064d7dc952fc2be..f665d11c8916f2ce82cea65080f3fad005284e4c 100644 --- a/nfapi/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -34,7 +34,7 @@ #define NFAPI_MAX_NUM_ANTENNAS 8 #define NFAPI_MAX_NUM_SUBBANDS 13 #define NFAPI_MAX_BF_VECTORS 8 -#define NFAPI_MAX_CC 2 +#define NFAPI_MAX_CC 1 #define NFAPI_MAX_NUM_PHYSICAL_ANTENNAS 8 #define NFAPI_MAX_RSSI 8 #define NFAPI_MAX_PSC_LIST 32 @@ -1689,7 +1689,7 @@ typedef struct { uint16_t number_pdu; uint8_t number_pdsch_rnti; uint16_t transmission_power_pcfich; - nfapi_dl_config_request_pdu_t* dl_config_pdu_list; + nfapi_dl_config_request_pdu_t* dl_config_pdu_list; } nfapi_dl_config_request_body_t; #define NFAPI_DL_CONFIG_REQUEST_BODY_TAG 0x2000 @@ -1962,7 +1962,7 @@ typedef struct { } nfapi_ul_config_harq_information_rel8_fdd_t; #define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG 0x2019 -typedef struct { +typedef struct { nfapi_tl_t tl; uint8_t harq_size; uint8_t ack_nack_mode; diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi.c b/nfapi/open-nFAPI/nfapi/src/nfapi.c new file mode 100644 index 0000000000000000000000000000000000000000..3f017bc9a4a53b1fc40d939c308b78642cce2cca --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/src/nfapi.c @@ -0,0 +1,860 @@ +/* + * Copyright (c) 2001-2016, Cisco Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * Neither the name of the Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <signal.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <sched.h> +#include <time.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <pthread.h> + +#include <nfapi_interface.h> +#include <nfapi.h> +#include <debug.h> + + +// Fundamental routines + +uint8_t push8(uint8_t in, uint8_t **out, uint8_t *end) +{ + uint8_t *pOut = *out; + + if((end - pOut) >= 1) + { + pOut[0] = in; + + (*out)+=1; + + return 1; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } + +} + +uint8_t pushs8(int8_t in, uint8_t **out, uint8_t *end) +{ + uint8_t *pOut = *out; + + if((end - pOut) >= 1) + { + pOut[0] = in; + + (*out)+=1; + + return 1; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t push16(uint16_t in, uint8_t **out, uint8_t *end) +{ + uint8_t *pOut = *out; + + if((end - pOut) >= 2) + { + pOut[0] = (in & 0xFF00) >> 8; + pOut[1] = (in & 0xFF); + + (*out)+=2; + + return 2; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pushs16(int16_t in, uint8_t **out, uint8_t *end) +{ + uint8_t *pOut = *out; + + if((end - pOut) >= 2) + { + pOut[0] = (in & 0xFF00) >> 8; + pOut[1] = (in & 0xFF); + + (*out)+=2; + + return 2; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t push32(uint32_t in, uint8_t **out, uint8_t *end) +{ + uint8_t *pOut = *out; + if((end - pOut) >= 4) + { + pOut[0] = (in & 0xFF000000) >> 24; + pOut[1] = (in & 0xFF0000) >> 16; + pOut[2] = (in & 0xFF00) >> 8; + pOut[3] = (in & 0xFF); + + (*out)+=4; + + return 4; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pushs32(int32_t in, uint8_t **out, uint8_t *end) +{ + uint8_t *pOut = *out; + + if((end - pOut) >= 4) + { + pOut[0] = (in & 0xFF000000) >> 24; + pOut[1] = (in & 0xFF0000) >> 16; + pOut[2] = (in & 0xFF00) >> 8; + pOut[3] = (in & 0xFF); + + (*out)+=4; + + return 4; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pull8(uint8_t **in, uint8_t *out, uint8_t *end) +{ + uint8_t *pIn = *in; + + if((end - pIn) >= 1 ) + { + *out = *pIn; + + (*in)+=1; + + return 1; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pulls8(uint8_t **in, int8_t *out, uint8_t *end) +{ + uint8_t *pIn = *in; + + if((end - pIn) >= 1 ) + { + *out = *pIn; + + (*in)+=1; + + return 1; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pull16(uint8_t **in, uint16_t *out, uint8_t *end) +{ + uint8_t *pIn = *in; + + if((end - pIn) >=2 ) + { + *out = ((pIn[0]) << 8) | pIn[1]; + (*in)+=2; + + return 2; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end) +{ + uint8_t *pIn = *in; + + if((end - pIn) >=2 ) + { + *out = ((pIn[0]) << 8) | pIn[1]; + + (*in)+=2; + + return 2; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end) +{ + uint8_t *pIn = *in; + + if((end - pIn) >=4 ) + { + *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; + + (*in)+=4; + + return 4; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end) +{ + uint8_t *pIn = *in; + + if((end - pIn) >=4 ) + { + *out = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; + + (*in)+=4; + + return 4; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +/* +inline void pusharray16(uint8_t **, uint16_t, uint32_t len) +{ +} +*/ + +uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) +{ + if(len == 0) + return 1; + + if(len > max_len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*in)) >= sizeof(uint16_t) * len) + { + uint32_t idx; + for(idx = 0; idx < len; ++idx) + { + if(!pull16(in, &out[idx], end)) + return 0; + } + + return sizeof(uint16_t) * len; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end) +{ + if(len == 0) + return 1; + + if(len > max_len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*in)) >= sizeof(uint16_t) * len) + { + uint32_t idx; + for(idx = 0; idx < len; ++idx) + { + if(!pulls16(in, &out[idx], end)) + return 0; + } + + return sizeof(uint16_t) * len; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pusharray16(uint16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) +{ + if(len == 0) + return 1; + + if(len > max_len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint16_t) * len) + { + uint32_t idx; + for(idx = 0; idx < len; ++idx) + { + if(!push16(in[idx], out, end)) + return 0; + } + return sizeof(uint16_t) * len; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} +uint32_t pusharrays16(int16_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) +{ + if(len == 0) + return 1; + + if(len > max_len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint16_t) * len) + { + uint32_t idx; + for(idx = 0; idx < len; ++idx) + { + pushs16(in[idx], out, end); + } + return sizeof(uint16_t) * len; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end) +{ + if(len == 0) + return 1; + + if(len > max_len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - out) >= sizeof(uint8_t) * len) + { + memcpy(out, (*in), len); + (*in)+=len; + + return sizeof(uint8_t) * len; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint32_t pusharray8(uint8_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end) +{ + if(len == 0) + return 1; + + if(len > max_len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, len, max_len); + return 0; + } + + if((end - (*out)) >= sizeof(uint8_t) * len) + { + memcpy((*out), in, len); + (*out)+=len; + + return sizeof(uint8_t) * len; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s no space in buffer\n", __FUNCTION__); + return 0; + } +} + +uint8_t packarray(void* array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t **ppwritepackedmsg, uint8_t *end, pack_array_elem_fn fn) +{ + if(count > max_count) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); + return 0; + } + + uint16_t i = 0; + for(i = 0; i < count; ++i) + { + if((fn)(array, ppwritepackedmsg, end) == 0) + return 0; + + array += array_element_size; + } + + return 1; +} + +uint8_t unpackarray(uint8_t **ppReadPackedMsg, void* array, uint16_t array_element_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn) +{ + if(count > max_count) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s exceed array size (%d > %d)\n", __FUNCTION__, count, max_count); + return 0; + } + + uint16_t i = 0; + for(i = 0; i < count; ++i) + { + if((fn)(array, ppReadPackedMsg, end) == 0) + return 0; + + array += array_element_size; + } + + return 1; +} + + +uint32_t pack_vendor_extension_tlv(nfapi_tl_t* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + if(ve != 0 && config != 0) + { + if(config->pack_vendor_extension_tlv) + { + + uint8_t* pStartOfTlv = *ppWritePackedMsg; + if(pack_tl(ve, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t* pStartOfValue = *ppWritePackedMsg; + if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) + return 0; + + ve->length = (*ppWritePackedMsg) - pStartOfValue; + + pack_tl(ve, &pStartOfTlv, end); + + return 1; + + } + } + return 1; +} + +uint32_t unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve_tlv) +{ + if(ve_tlv != 0 && config != 0) + { + if(config->unpack_vendor_extension_tlv) + { + return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void**)ve_tlv, config); + } + } + return 1; +} + +uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end ,nfapi_p7_codec_config_t* config) +{ + if(ve != 0 && config != 0) + { + if(config->pack_vendor_extension_tlv) + { + uint8_t* pStartOfTlv = *ppWritePackedMsg; + if(pack_tl(ve, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t* pStartOfValue = *ppWritePackedMsg; + if((config->pack_vendor_extension_tlv)(ve, ppWritePackedMsg, end, config) == 0) + return 0; + + ve->length = (*ppWritePackedMsg) - pStartOfValue; + + pack_tl(ve, &pStartOfTlv, end); + + return 1; + + } + } + return 1; +} + +int unpack_p7_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config, nfapi_tl_t** ve_tlv) +{ + if(ve_tlv != 0 && config != 0) + { + if(config->unpack_vendor_extension_tlv) + { + return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void**)ve_tlv, config); + } + } + return 1; +} + + +uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return (push16(tl->tag, ppWritePackedMsg, end) && + push16(tl->length, ppWritePackedMsg, end)); +} + +uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end) +{ + return (pull16(ppReadPackedMsg, &tl->tag, end) && + pull16(ppReadPackedMsg, &tl->length, end)); +} + +int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve) +{ + nfapi_tl_t generic_tl; + uint8_t numBadTags = 0; + uint16_t idx = 0; + + while ((uint8_t*)(*ppReadPackedMsg) < end) + { + // unpack the tl and process the values accordingly + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + uint8_t tagMatch = 0; + + uint8_t* pStartOfValue = *ppReadPackedMsg; + + for(idx = 0; idx < size; ++idx) + { + if(unpack_fns[idx].tag == generic_tl.tag) + { + tagMatch = 1; + nfapi_tl_t* tl = (nfapi_tl_t*)(unpack_fns[idx].tlv); + tl->tag = generic_tl.tag; + tl->length = generic_tl.length; + + int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end); + + if(result == 0) + { + return 0; + } + + // check if the length was right; + if(tl->length != (*ppReadPackedMsg - pStartOfValue)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %d\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); + } + } + } + + if(tagMatch == 0) + { + + if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && + generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) + { + int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); + if(result == 0) + { + // got tot the end. + return 0; + } + else if(result < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return 0; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) + { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } + else + { + // go to the end + return 0; + } + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return 0; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) + { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } + else + { + // go to the end + return 0; + } + } + + } + } + + return 1; +} +int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t* end, nfapi_p7_codec_config_t* config, nfapi_tl_t** ve) +{ + nfapi_tl_t generic_tl; + uint8_t numBadTags = 0; + uint16_t idx = 0; + + while ((uint8_t*)(*ppReadPackedMsg) < end) + { + // unpack the tl and process the values accordingly + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + uint8_t tagMatch = 0; + + uint8_t* pStartOfValue = *ppReadPackedMsg; + + for(idx = 0; idx < size; ++idx) + { + if(unpack_fns[idx].tag == generic_tl.tag) + { + tagMatch = 1; + nfapi_tl_t* tl = (nfapi_tl_t*)(unpack_fns[idx].tlv); + tl->tag = generic_tl.tag; + tl->length = generic_tl.length; + + int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end , config); + + if(result == 0) + { + return 0; + } + + // check if the length was right; + if(tl->length != (*ppReadPackedMsg - pStartOfValue)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %d\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue)); + } + } + } + + if(tagMatch == 0) + { + + if(generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && + generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) + { + int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve); + if(result == 0) + { + // got to end + return 0; + } + else if(result < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return -1; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) + { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } + else + { + // got ot the dn + return 0; + } + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag); + + if (++numBadTags > MAX_BAD_TAG) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n"); + return -1; + } + + if((end - *ppReadPackedMsg) >= generic_tl.length) + { + // Advance past the unknown TLV + (*ppReadPackedMsg) += generic_tl.length; + } + else + { + // got ot the dn + return 0; + } + + } + + } + } + + return 1; +} + +// This intermediate function deals with calculating the length of the value +// and writing into the tlv header. +uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn) +{ + nfapi_tl_t* tl = (nfapi_tl_t*)tlv; + + // If the tag is defined + if(tl->tag == tag) + { + uint8_t* pStartOfTlv = *ppWritePackedMsg; + + // write a dumy tlv header + if(pack_tl(tl, ppWritePackedMsg, end) == 0) + return 0; + + // Record the start of the value + uint8_t* pStartOfValue = *ppWritePackedMsg; + + // pack the tlv value + if(fn(tlv, ppWritePackedMsg, end) == 0) + return 0; + + // calculate the length of the value and rewrite the tl header + tl->length = (*ppWritePackedMsg) - pStartOfValue; + + // rewrite the header with the correct length + pack_tl(tl, &pStartOfTlv, end); + } + else + { + if(tl->tag != 0) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag); + } + else + { + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag); + } + } + + return 1; +} + +const char* nfapi_error_code_to_str(nfapi_error_code_e value) +{ + switch(value) + { + case NFAPI_MSG_OK: + return "NFAPI_MSG_OK"; + case NFAPI_MSG_INVALID_STATE: + return "NFAPI_MSG_INVALID_STATE"; + case NFAPI_MSG_INVALID_CONFIG: + return "NFAPI_MSG_INVALID_CONFIG"; + case NFAPI_SFN_OUT_OF_SYNC: + return "NFAPI_SFN_OUT_OF_SYNC"; + case NFAPI_MSG_SUBFRAME_ERR: + return "NFAPI_MSG_SUBFRAME_ERR"; + case NFAPI_MSG_BCH_MISSING: + return "NFAPI_MSG_BCH_MISSING"; + case NFAPI_MSG_INVALID_SFN: + return "NFAPI_MSG_INVALID_SFN"; + case NFAPI_MSG_HI_ERR: + return "NFAPI_MSG_HI_ERR"; + case NFAPI_MSG_TX_ERR: + return "NFAPI_MSG_TX_ERR"; + default: + return "UNKNOWN"; + } +} diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p4.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p4.c new file mode 100644 index 0000000000000000000000000000000000000000..b429e0a6ce586b1efd943e7f337464e7852e26a2 --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p4.c @@ -0,0 +1,2085 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <arpa/inet.h> // need for uintptr_t? + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdint.h> + +#include <nfapi_interface.h> +#include <nfapi.h> +#include <debug.h> + +static uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd) +{ + if (msgEnd < msgHead) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %d, %d\n", msgHead, msgEnd); + return 0; + } + + return (msgEnd - msgHead); +} + +static uint8_t pack_opaque_data_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_opaqaue_data_t* value = (nfapi_opaqaue_data_t*)tlv; + return pusharray8(value->value, NFAPI_MAX_OPAQUE_DATA, value->length, ppWritePackedMsg, end); +} + +static uint8_t unpack_opaque_data_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_opaqaue_data_t* value = (nfapi_opaqaue_data_t*)tlv; + value->length = value->tl.length; + if(value->length <= NFAPI_MAX_OPAQUE_DATA) + { + if(!pullarray8(ppReadPackedMsg, value->value, NFAPI_MAX_OPAQUE_DATA, value->length, end)) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Opaque date to long %d \n", value->length); + return 0; + } + + return 1; + +} + +static uint8_t pack_lte_rssi_request_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_rssi_request_t* value = (nfapi_lte_rssi_request_t*)tlv; + + return (push8(value->frequency_band_indicator, ppWritePackedMsg, end) && + push16(value->measurement_period, ppWritePackedMsg, end) && + push8(value->bandwidth, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_earfcns, ppWritePackedMsg, end) && + pusharray16(value->earfcn, NFAPI_MAX_CARRIER_LIST, value->number_of_earfcns, ppWritePackedMsg, end)); +} + +static uint8_t pack_utran_rssi_request_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_utran_rssi_request_t* value = (nfapi_utran_rssi_request_t*)tlv; + + return (push8(value->frequency_band_indicator, ppWritePackedMsg, end) && + push16(value->measurement_period, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_uarfcns, ppWritePackedMsg, end) && + pusharray16(value->uarfcn, NFAPI_MAX_CARRIER_LIST, value->number_of_uarfcns, ppWritePackedMsg, end)); +} + +static uint8_t pack_geran_rssi_request_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_geran_rssi_request_t* value = (nfapi_geran_rssi_request_t*)tlv; + uint16_t idx = 0; + + if(!(push8(value->frequency_band_indicator, ppWritePackedMsg, end) && + push16(value->measurement_period, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_arfcns, ppWritePackedMsg, end))) + return 0; + + for(;idx < value->number_of_arfcns; ++idx) + { + if(!(push16(value->arfcn[idx].arfcn, ppWritePackedMsg, end) && + push8(value->arfcn[idx].direction, ppWritePackedMsg, end))) + return 0; + } + + return 1; +} + +static uint8_t pack_nb_iot_rssi_request_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_rssi_request_t* value = (nfapi_nb_iot_rssi_request_t*)tlv; + uint16_t idx = 0; + + if(!(push8(value->frequency_band_indicator, ppWritePackedMsg, end) && + push16(value->measurement_period, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_earfcns, ppWritePackedMsg, end))) + return 0; + + for(;idx < value->number_of_earfcns; ++idx) + { + if(!(push16(value->earfcn[idx].earfcn, ppWritePackedMsg, end) && + push8(value->earfcn[idx].number_of_ro_dl, ppWritePackedMsg, end))) + return 0; + + uint8_t ro_dl_idx = 0; + for(ro_dl_idx = 0; ro_dl_idx < value->earfcn[idx].number_of_ro_dl; ++ro_dl_idx) + { + if(!push8(value->earfcn[idx].ro_dl[ro_dl_idx], ppWritePackedMsg, end)) + return 0; + } + } + + return 1; +} + + + +static uint8_t pack_rssi_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_rssi_request_t *pNfapiMsg = (nfapi_rssi_request_t*)msg; + + if(push8(pNfapiMsg->rat_type, ppWritePackedMsg, end) == 0) + return 0; + + switch(pNfapiMsg->rat_type) + { + case NFAPI_RAT_TYPE_LTE: + if(pack_tlv(NFAPI_LTE_RSSI_REQUEST_TAG, &pNfapiMsg->lte_rssi_request, ppWritePackedMsg, end, &pack_lte_rssi_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_UTRAN: + if(pack_tlv(NFAPI_UTRAN_RSSI_REQUEST_TAG, &pNfapiMsg->utran_rssi_request, ppWritePackedMsg, end, &pack_utran_rssi_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_GERAN: + if(pack_tlv(NFAPI_GERAN_RSSI_REQUEST_TAG, &pNfapiMsg->geran_rssi_request, ppWritePackedMsg, end, &pack_geran_rssi_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_NB_IOT: + if(pack_tlv(NFAPI_NB_IOT_RSSI_REQUEST_TAG, &pNfapiMsg->nb_iot_rssi_request, ppWritePackedMsg, end, &pack_nb_iot_rssi_request_value) == 0) + return 0; + break; + } + + return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); +} + +static uint8_t pack_rssi_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_rssi_response_t *pNfapiMsg = (nfapi_rssi_response_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_rssi_indication_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rssi_indication_body_t* value = (nfapi_rssi_indication_body_t*)tlv; + + return (push16(value->number_of_rssi, ppWritePackedMsg, end) && + pusharrays16(value->rssi, NFAPI_MAX_RSSI, value->number_of_rssi, ppWritePackedMsg, end)); +} + +static uint8_t pack_rssi_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_rssi_indication_t *pNfapiMsg = (nfapi_rssi_indication_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_tlv(NFAPI_RSSI_INDICATION_TAG, &pNfapiMsg->rssi_indication_body, ppWritePackedMsg, end, &pack_rssi_indication_body_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + + +static uint8_t pack_lte_cell_search_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_cell_search_request_t* value = (nfapi_lte_cell_search_request_t*)msg; + + return (push16(value->earfcn, ppWritePackedMsg, end) && + push8(value->measurement_bandwidth, ppWritePackedMsg, end) && + push8(value->exhaustive_search, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_pci, ppWritePackedMsg, end) && + pusharray16(value->pci, NFAPI_MAX_PCI_LIST, value->number_of_pci, ppWritePackedMsg, end)); +} + +static uint8_t pack_utran_cell_search_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_utran_cell_search_request_t* value = (nfapi_utran_cell_search_request_t*)msg; + + return (push16(value->uarfcn, ppWritePackedMsg, end) && + push8(value->exhaustive_search, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_psc, ppWritePackedMsg, end) && + pusharray16(value->psc, NFAPI_MAX_PSC_LIST, value->number_of_psc, ppWritePackedMsg, end)); +} + +static uint8_t pack_geran_cell_search_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_geran_cell_search_request_t* value = (nfapi_geran_cell_search_request_t*)msg; + + return (push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_arfcn, ppWritePackedMsg, end) && + pusharray16(value->arfcn, NFAPI_MAX_ARFCN_LIST, value->number_of_arfcn, ppWritePackedMsg, end)); +} + +static uint8_t pack_nb_iot_cell_search_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_cell_search_request_t* value = (nfapi_nb_iot_cell_search_request_t*)msg; + + return (push16(value->earfcn, ppWritePackedMsg, end) && + push8(value->ro_dl, ppWritePackedMsg, end) && + push8(value->exhaustive_search, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end) && + push8(value->number_of_pci, ppWritePackedMsg, end) && + pusharray16(value->pci, NFAPI_MAX_PCI_LIST, value->number_of_pci, ppWritePackedMsg, end)); +} + + +static uint8_t pack_cell_search_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_cell_search_request_t *pNfapiMsg = (nfapi_cell_search_request_t*)msg; + + if(push8(pNfapiMsg->rat_type, ppWritePackedMsg, end) == 0) + return 0; + + switch(pNfapiMsg->rat_type) + { + case NFAPI_RAT_TYPE_LTE: + { + if(pack_tlv(NFAPI_LTE_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->lte_cell_search_request, ppWritePackedMsg, end, &pack_lte_cell_search_request_value) == 0) + return 0; + } + break; + case NFAPI_RAT_TYPE_UTRAN: + { + if(pack_tlv(NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->utran_cell_search_request, ppWritePackedMsg, end, &pack_utran_cell_search_request_value) == 0) + return 0; + } + break; + case NFAPI_RAT_TYPE_GERAN: + { + if(pack_tlv(NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->geran_cell_search_request, ppWritePackedMsg, end, &pack_geran_cell_search_request_value) == 0) + return 0; + } + break; + case NFAPI_RAT_TYPE_NB_IOT: + { + if(pack_tlv(NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->nb_iot_cell_search_request, ppWritePackedMsg, end, &pack_nb_iot_cell_search_request_value) == 0) + return 0; + } + break; + }; + + return (pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_cell_search_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_cell_search_response_t *pNfapiMsg = (nfapi_cell_search_response_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_lte_cell_search_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_cell_search_indication_t* value = (nfapi_lte_cell_search_indication_t*)msg; + uint16_t idx = 0; + + if(push16(value->number_of_lte_cells_found, ppWritePackedMsg, end) == 0) + return 0; + + for(idx = 0; idx < value->number_of_lte_cells_found; ++idx) + { + if(!(push16(value->lte_found_cells[idx].pci, ppWritePackedMsg, end) && + push8(value->lte_found_cells[idx].rsrp, ppWritePackedMsg, end) && + push8(value->lte_found_cells[idx].rsrq, ppWritePackedMsg, end) && + pushs16(value->lte_found_cells[idx].frequency_offset, ppWritePackedMsg, end))) + return 0; + } + return 1; +} + +static uint8_t pack_utran_cell_search_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_utran_cell_search_indication_t* value = (nfapi_utran_cell_search_indication_t*)msg; + uint16_t idx = 0; + + if(push16(value->number_of_utran_cells_found, ppWritePackedMsg, end) == 0) + return 0; + + for(idx = 0; idx < value->number_of_utran_cells_found; ++idx) + { + if(!(push16(value->utran_found_cells[idx].psc, ppWritePackedMsg, end) && + push8(value->utran_found_cells[idx].rscp, ppWritePackedMsg, end) && + push8(value->utran_found_cells[idx].ecno, ppWritePackedMsg, end) && + pushs16(value->utran_found_cells[idx].frequency_offset, ppWritePackedMsg, end))) + return 0; + } + + return 1; +} + +static uint8_t pack_geran_cell_search_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_geran_cell_search_indication_t* value = (nfapi_geran_cell_search_indication_t*)msg; + uint16_t idx = 0; + + if(push16(value->number_of_gsm_cells_found, ppWritePackedMsg, end) == 0) + return 0; + + for(idx = 0; idx < value->number_of_gsm_cells_found; ++idx) + { + if(!(push16(value->gsm_found_cells[idx].arfcn, ppWritePackedMsg, end) && + push8(value->gsm_found_cells[idx].bsic, ppWritePackedMsg, end) && + push8(value->gsm_found_cells[idx].rxlev, ppWritePackedMsg, end) && + push8(value->gsm_found_cells[idx].rxqual, ppWritePackedMsg, end) && + pushs16(value->gsm_found_cells[idx].frequency_offset, ppWritePackedMsg, end) && + push32(value->gsm_found_cells[idx].sfn_offset, ppWritePackedMsg, end))) + return 0; + } + + return 1; +} + +static uint8_t pack_nb_iot_cell_search_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_cell_search_indication_t* value = (nfapi_nb_iot_cell_search_indication_t*)msg; + uint16_t idx = 0; + + if(push16(value->number_of_nb_iot_cells_found, ppWritePackedMsg, end) == 0) + return 0; + + for(idx = 0; idx < value->number_of_nb_iot_cells_found; ++idx) + { + if(!(push16(value->nb_iot_found_cells[idx].pci, ppWritePackedMsg, end) && + push8(value->nb_iot_found_cells[idx].rsrp, ppWritePackedMsg, end) && + push8(value->nb_iot_found_cells[idx].rsrq, ppWritePackedMsg, end) && + pushs16(value->nb_iot_found_cells[idx].frequency_offset, ppWritePackedMsg, end))) + return 0; + } + + return 1; +} +static uint8_t pack_cell_search_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_cell_search_indication_t *pNfapiMsg = (nfapi_cell_search_indication_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_tlv(NFAPI_LTE_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->lte_cell_search_indication, ppWritePackedMsg, end, &pack_lte_cell_search_indication_value) && + pack_tlv(NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->utran_cell_search_indication, ppWritePackedMsg, end, &pack_utran_cell_search_indication_value) && + pack_tlv(NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->geran_cell_search_indication, ppWritePackedMsg, end, &pack_geran_cell_search_indication_value) && + pack_tlv(NFAPI_PNF_CELL_SEARCH_STATE_TAG, &pNfapiMsg->pnf_cell_search_state, ppWritePackedMsg, end, &pack_opaque_data_value) && + pack_tlv(NFAPI_NB_IOT_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->nb_iot_cell_search_indication, ppWritePackedMsg, end, &pack_nb_iot_cell_search_indication_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); + +} + +static uint8_t pack_lte_broadcast_detect_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_broadcast_detect_request_t* value = (nfapi_lte_broadcast_detect_request_t*)msg; + + return (push16(value->earfcn, ppWritePackedMsg, end) && + push16(value->pci, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} + +static uint8_t pack_utran_broadcast_detect_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_utran_broadcast_detect_request_t* value = (nfapi_utran_broadcast_detect_request_t*)msg; + + return (push16(value->uarfcn, ppWritePackedMsg, end) && + push16(value->psc, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} + +static uint8_t pack_nb_iot_broadcast_detect_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_broadcast_detect_request_t* value = (nfapi_nb_iot_broadcast_detect_request_t*)msg; + + return (push16(value->earfcn, ppWritePackedMsg, end) && + push8(value->ro_dl, ppWritePackedMsg, end) && + push16(value->pci, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} + +static uint8_t pack_broadcast_detect_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t * end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_broadcast_detect_request_t *pNfapiMsg = (nfapi_broadcast_detect_request_t*)msg; + + if(push8(pNfapiMsg->rat_type, ppWritePackedMsg, end) == 0) + return 0; + + switch(pNfapiMsg->rat_type) + { + case NFAPI_RAT_TYPE_LTE: + if(pack_tlv(NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG, &pNfapiMsg->lte_broadcast_detect_request, ppWritePackedMsg, end ,&pack_lte_broadcast_detect_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_UTRAN: + if(pack_tlv(NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG, &pNfapiMsg->utran_broadcast_detect_request, ppWritePackedMsg, end, &pack_utran_broadcast_detect_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_NB_IOT: + if(pack_tlv(NFAPI_NB_IOT_BROADCAST_DETECT_REQUEST_TAG, &pNfapiMsg->nb_iot_broadcast_detect_request, ppWritePackedMsg, end, &pack_nb_iot_broadcast_detect_request_value) == 0) + return 0; + break; + + } + + return (pack_tlv(NFAPI_PNF_CELL_SEARCH_STATE_TAG, &pNfapiMsg->pnf_cell_search_state, ppWritePackedMsg, end, &pack_opaque_data_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_broadcast_detect_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_broadcast_detect_response_t *pNfapiMsg = (nfapi_broadcast_detect_response_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_lte_broadcast_detect_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_broadcast_detect_indication_t* value = (nfapi_lte_broadcast_detect_indication_t*)msg; + + return (push8(value->number_of_tx_antenna, ppWritePackedMsg, end) && + push16(value->mib_length, ppWritePackedMsg, end) && + pusharray8(value->mib, NFAPI_MAX_MIB_LENGTH, value->mib_length, ppWritePackedMsg, end) && + push32(value->sfn_offset, ppWritePackedMsg, end)); +} + +static uint8_t pack_utran_broadcast_detect_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_utran_broadcast_detect_indication_t* value = (nfapi_utran_broadcast_detect_indication_t*)msg; + + return (push16(value->mib_length, ppWritePackedMsg, end) && + pusharray8(value->mib, NFAPI_MAX_MIB_LENGTH, value->mib_length, ppWritePackedMsg, end) && + push32(value->sfn_offset, ppWritePackedMsg, end)); +} + +static uint8_t pack_nb_iot_broadcast_detect_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_broadcast_detect_indication_t* value = (nfapi_nb_iot_broadcast_detect_indication_t*)msg; + + return (push8(value->number_of_tx_antenna, ppWritePackedMsg, end) && + push16(value->mib_length, ppWritePackedMsg, end) && + pusharray8(value->mib, NFAPI_MAX_MIB_LENGTH, value->mib_length, ppWritePackedMsg, end) && + push32(value->sfn_offset, ppWritePackedMsg, end)); +} + +static uint8_t pack_broadcast_detect_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_broadcast_detect_indication_t *pNfapiMsg = (nfapi_broadcast_detect_indication_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_tlv(NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG, &pNfapiMsg->lte_broadcast_detect_indication, ppWritePackedMsg, end, &pack_lte_broadcast_detect_indication_value) && + pack_tlv(NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG, &pNfapiMsg->utran_broadcast_detect_indication, ppWritePackedMsg, end, &pack_utran_broadcast_detect_indication_value) && + pack_tlv(NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &pNfapiMsg->pnf_cell_broadcast_state, ppWritePackedMsg, end, &pack_opaque_data_value) && + pack_tlv(NFAPI_NB_IOT_BROADCAST_DETECT_INDICATION_TAG, &pNfapiMsg->nb_iot_broadcast_detect_indication, ppWritePackedMsg, end, &pack_nb_iot_broadcast_detect_indication_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_lte_system_information_schedule_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_system_information_schedule_request_t* value = (nfapi_lte_system_information_schedule_request_t*)msg; + + return (push16(value->earfcn, ppWritePackedMsg, end) && + push16(value->pci, ppWritePackedMsg, end) && + push16(value->downlink_channel_bandwidth, ppWritePackedMsg, end) && + push8(value->phich_configuration, ppWritePackedMsg, end) && + push8(value->number_of_tx_antenna, ppWritePackedMsg, end) && + push8(value->retry_count, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} + +static uint8_t pack_nb_iot_system_information_schedule_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_system_information_schedule_request_t* value = (nfapi_nb_iot_system_information_schedule_request_t*)msg; + + return (push16(value->earfcn, ppWritePackedMsg, end) && + push8(value->ro_dl, ppWritePackedMsg, end) && + push16(value->pci, ppWritePackedMsg, end) && + push8(value->scheduling_info_sib1_nb, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} + + +static uint8_t pack_system_information_schedule_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_schedule_request_t *pNfapiMsg = (nfapi_system_information_schedule_request_t*)msg; + + if(push8(pNfapiMsg->rat_type, ppWritePackedMsg, end) == 0) + return 0; + + switch(pNfapiMsg->rat_type) + { + case NFAPI_RAT_TYPE_LTE: + if(pack_tlv(NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG, &pNfapiMsg->lte_system_information_schedule_request, ppWritePackedMsg, end, &pack_lte_system_information_schedule_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_NB_IOT: + if(pack_tlv(NFAPI_NB_IOT_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG, &pNfapiMsg->nb_iot_system_information_schedule_request, ppWritePackedMsg, end, &pack_nb_iot_system_information_schedule_request_value) == 0) + return 0; + break; + } + + return (pack_tlv(NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &pNfapiMsg->pnf_cell_broadcast_state, ppWritePackedMsg, end, &pack_opaque_data_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); + +} + +static uint8_t pack_system_information_schedule_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_schedule_response_t *pNfapiMsg = (nfapi_system_information_schedule_response_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_lte_system_information_indication_value(void* msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_system_information_indication_t* value = (nfapi_lte_system_information_indication_t*)msg; + + return (push8(value->sib_type, ppWritePackedMsg, end) && + push16(value->sib_length, ppWritePackedMsg, end) && + pusharray8(value->sib, NFAPI_MAX_SIB_LENGTH, value->sib_length, ppWritePackedMsg, end)); +} + +static uint8_t pack_nb_iot_system_information_indication_value(void* msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_system_information_indication_t* value = (nfapi_nb_iot_system_information_indication_t*)msg; + + return (push8(value->sib_type, ppWritePackedMsg, end) && + push16(value->sib_length, ppWritePackedMsg, end) && + pusharray8(value->sib, NFAPI_MAX_SIB_LENGTH, value->sib_length, ppWritePackedMsg, end)); +} + +static uint8_t pack_system_information_schedule_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_schedule_indication_t *pNfapiMsg = (nfapi_system_information_schedule_indication_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_tlv(NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->lte_system_information_indication, ppWritePackedMsg, end, &pack_lte_system_information_indication_value) && + pack_tlv(NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->nb_iot_system_information_indication, ppWritePackedMsg, end, &pack_nb_iot_system_information_indication_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_lte_system_information_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lte_system_information_request_t* value = (nfapi_lte_system_information_request_t*)msg; + uint16_t idx = 0; + + if(!(push16(value->earfcn, ppWritePackedMsg, end) && + push16(value->pci, ppWritePackedMsg, end) && + push16(value->downlink_channel_bandwidth, ppWritePackedMsg, end) && + push8(value->phich_configuration, ppWritePackedMsg, end) && + push8(value->number_of_tx_antenna, ppWritePackedMsg, end) && + push8(value->number_of_si_periodicity, ppWritePackedMsg, end))) + return 0; + + for(idx = 0; idx < value->number_of_si_periodicity; ++idx) + { + if(!(push8(value->si_periodicity[idx].si_periodicity, ppWritePackedMsg, end) && + push8(value->si_periodicity[idx].si_index, ppWritePackedMsg, end))) + return 0; + } + + return (push8(value->si_window_length, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} +static uint8_t pack_utran_system_information_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_utran_system_information_request_t* value = (nfapi_utran_system_information_request_t*)msg; + + return (push16(value->uarfcn, ppWritePackedMsg, end) && + push16(value->psc, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} +static uint8_t pack_geran_system_information_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_geran_system_information_request_t* value = (nfapi_geran_system_information_request_t*)msg; + + return (push16(value->arfcn, ppWritePackedMsg, end) && + push8(value->bsic, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} +static uint8_t pack_nb_iot_system_information_request_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_iot_system_information_request_t* value = (nfapi_nb_iot_system_information_request_t*)msg; + uint16_t idx = 0; + + if(!(push16(value->earfcn, ppWritePackedMsg, end) && + push8(value->ro_dl, ppWritePackedMsg, end) && + push16(value->pci, ppWritePackedMsg, end) && + push8(value->number_of_si_periodicity, ppWritePackedMsg, end))) + return 0; + + for(idx = 0; idx < value->number_of_si_periodicity; ++idx) + { + if(!(push8(value->si_periodicity[idx].si_periodicity, ppWritePackedMsg, end) && + push8(value->si_periodicity[idx].si_repetition_pattern, ppWritePackedMsg, end) && + push8(value->si_periodicity[idx].si_tb_size, ppWritePackedMsg, end) && + push8(value->si_periodicity[idx].number_of_si_index, ppWritePackedMsg, end))) + return 0; + + uint8_t si_idx; + for(si_idx = 0; si_idx < value->si_periodicity[idx].number_of_si_index; ++si_idx) + { + if(!(push8(value->si_periodicity[idx].si_index[si_idx], ppWritePackedMsg, end))) + return 0; + } + } + + return (push8(value->si_window_length, ppWritePackedMsg, end) && + push32(value->timeout, ppWritePackedMsg, end)); +} + + +static uint8_t pack_system_information_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_request_t *pNfapiMsg = (nfapi_system_information_request_t*)msg; + + if(push8(pNfapiMsg->rat_type, ppWritePackedMsg, end) == 0) + return 0; + + switch(pNfapiMsg->rat_type) + { + case NFAPI_RAT_TYPE_LTE: + if(pack_tlv(NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->lte_system_information_request, ppWritePackedMsg, end, &pack_lte_system_information_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_UTRAN: + if(pack_tlv(NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->utran_system_information_request, ppWritePackedMsg, end, &pack_utran_system_information_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_GERAN: + if(pack_tlv(NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->geran_system_information_request, ppWritePackedMsg, end, &pack_geran_system_information_request_value) == 0) + return 0; + break; + case NFAPI_RAT_TYPE_NB_IOT: + if(pack_tlv(NFAPI_NB_IOT_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->nb_iot_system_information_request, ppWritePackedMsg, end, &pack_nb_iot_system_information_request_value) == 0) + return 0; + break; + } + + return (pack_tlv(NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &pNfapiMsg->pnf_cell_broadcast_state, ppWritePackedMsg, end, &pack_opaque_data_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_system_information_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_response_t *pNfapiMsg = (nfapi_system_information_response_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_utran_system_information_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_utran_system_information_indication_t* value = (nfapi_utran_system_information_indication_t*)msg; + + return (push16(value->sib_length, ppWritePackedMsg, end) && + pusharray8(value->sib, NFAPI_MAX_SIB_LENGTH, value->sib_length, ppWritePackedMsg, end)); +} + +static uint8_t pack_geran_system_information_indication_value(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_geran_system_information_indication_t* value = (nfapi_geran_system_information_indication_t*)msg; + + return (push16(value->si_length, ppWritePackedMsg, end) && + pusharray8(value->si, NFAPI_MAX_SIB_LENGTH, value->si_length, ppWritePackedMsg, end)); +} + +static uint8_t pack_system_information_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_indication_t *pNfapiMsg = (nfapi_system_information_indication_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_tlv(NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->lte_system_information_indication, ppWritePackedMsg, end, &pack_lte_system_information_indication_value) && + pack_tlv(NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->utran_system_information_indication, ppWritePackedMsg, end, &pack_utran_system_information_indication_value) && + pack_tlv(NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->geran_system_information_indication, ppWritePackedMsg, end, &pack_geran_system_information_indication_value) && + pack_tlv(NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->nb_iot_system_information_indication, ppWritePackedMsg, end, &pack_nb_iot_system_information_indication_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_nmm_stop_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_nmm_stop_request_t *pNfapiMsg = (nfapi_nmm_stop_request_t*)msg; + + return (pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_nmm_stop_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_nmm_stop_response_t *pNfapiMsg = (nfapi_nmm_stop_response_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t unpack_lte_rssi_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + //int result = 0; + nfapi_lte_rssi_request_t* value = (nfapi_lte_rssi_request_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->frequency_band_indicator, end) && + pull16(ppReadPackedMsg, &value->measurement_period, end) && + pull8(ppReadPackedMsg, &value->bandwidth, end) && + pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_earfcns, end))) + return 0; + + if(value->number_of_earfcns <= NFAPI_MAX_CARRIER_LIST) + { + if(pullarray16(ppReadPackedMsg, value->earfcn, NFAPI_MAX_CARRIER_LIST, value->number_of_earfcns, end) == 0) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More EARFCN's than we can decode %d \n", value->number_of_earfcns); + return 0; + } + + return 1; + +} + +static uint8_t unpack_utran_rssi_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_utran_rssi_request_t* value = (nfapi_utran_rssi_request_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->frequency_band_indicator, end) && + pull16(ppReadPackedMsg, &value->measurement_period, end) && + pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_uarfcns, end))) + return 0; + + if(value->number_of_uarfcns <= NFAPI_MAX_CARRIER_LIST) + { + if(pullarray16(ppReadPackedMsg, value->uarfcn, NFAPI_MAX_CARRIER_LIST, value->number_of_uarfcns, end) == 0) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More UARFCN's than we can decode %d \n", value->number_of_uarfcns); + return 0; + } + + return 1; +} + +static uint8_t unpack_geran_rssi_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_geran_rssi_request_t* value = (nfapi_geran_rssi_request_t*)tlv; + uint16_t idx = 0; + + if(!(pull8(ppReadPackedMsg, &value->frequency_band_indicator, end) && + pull16(ppReadPackedMsg, &value->measurement_period, end) && + pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_arfcns, end))) + return 0; + + if(value->number_of_arfcns <= NFAPI_MAX_CARRIER_LIST) + { + for(idx = 0; idx < value->number_of_arfcns; ++idx) + { + if(!(pull16(ppReadPackedMsg, &value->arfcn[idx].arfcn, end) && + pull8(ppReadPackedMsg, &value->arfcn[idx].direction, end))) + return 0; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More ARFCN's than we can decode %d \n", value->number_of_arfcns); + return 0; + } + + return 1; +} + +static uint8_t unpack_nb_iot_rssi_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_rssi_request_t* value = (nfapi_nb_iot_rssi_request_t*)tlv; + uint16_t idx = 0; + + if(!(pull8(ppReadPackedMsg, &value->frequency_band_indicator, end) && + pull16(ppReadPackedMsg, &value->measurement_period, end) && + pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_earfcns, end))) + return 0; + + if(value->number_of_earfcns <= NFAPI_MAX_CARRIER_LIST) + { + for(idx = 0; idx < value->number_of_earfcns; ++idx) + { + if(!(pull16(ppReadPackedMsg, &value->earfcn[idx].earfcn, end) && + pull8(ppReadPackedMsg, &value->earfcn[idx].number_of_ro_dl, end))) + return 0; + + if(value->earfcn[idx].number_of_ro_dl <= NFAPI_MAX_RO_DL) + { + uint8_t ro_dl_idx = 0; + for(ro_dl_idx = 0; ro_dl_idx < value->earfcn[idx].number_of_ro_dl; ++ro_dl_idx) + { + if(!pull8(ppReadPackedMsg, &value->earfcn[idx].ro_dl[ro_dl_idx], end)) + return 0; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More ROdl's than we can decode %d \n", value->earfcn[idx].number_of_ro_dl); + return 0; + } + + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More EARFCN's than we can decode %d \n", value->number_of_earfcns); + return 0; + } + + return 1; +} + +static uint8_t unpack_rssi_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_rssi_request_t *pNfapiMsg = (nfapi_rssi_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_RSSI_REQUEST_TAG, &pNfapiMsg->lte_rssi_request, &unpack_lte_rssi_request_value}, + { NFAPI_UTRAN_RSSI_REQUEST_TAG, &pNfapiMsg->utran_rssi_request, &unpack_utran_rssi_request_value}, + { NFAPI_GERAN_RSSI_REQUEST_TAG, &pNfapiMsg->geran_rssi_request, &unpack_geran_rssi_request_value}, + { NFAPI_NB_IOT_RSSI_REQUEST_TAG, &pNfapiMsg->nb_iot_rssi_request, &unpack_nb_iot_rssi_request_value}, + }; + + int result = 0; + + result = (pull8(ppReadPackedMsg, &pNfapiMsg->rat_type, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); + + + // Verify that the rat type and the tlv match + if(result == 1 && + !((pNfapiMsg->rat_type == NFAPI_RAT_TYPE_LTE && pNfapiMsg->lte_rssi_request.tl.tag == NFAPI_LTE_RSSI_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_UTRAN && pNfapiMsg->utran_rssi_request.tl.tag == NFAPI_UTRAN_RSSI_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_GERAN && pNfapiMsg->geran_rssi_request.tl.tag == NFAPI_GERAN_RSSI_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_NB_IOT && pNfapiMsg->nb_iot_rssi_request.tl.tag == NFAPI_NB_IOT_RSSI_REQUEST_TAG))) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Mismatch RAT Type: %d and TAG value: 0x%04x \n", pNfapiMsg->rat_type, pNfapiMsg->lte_rssi_request.tl.tag); + result = 0; + } + + return result; +} + +static uint8_t unpack_rssi_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_rssi_response_t *pNfapiMsg = (nfapi_rssi_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); +} + +static uint8_t unpack_rssi_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_rssi_indication_body_t* value = (nfapi_rssi_indication_body_t*)tlv; + + if(pull16(ppReadPackedMsg, &value->number_of_rssi, end) == 0) + return 0; + + if(value->number_of_rssi <= NFAPI_MAX_RSSI) + { + if(pullarrays16(ppReadPackedMsg, value->rssi, NFAPI_MAX_RSSI, value->number_of_rssi, end) == 0) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More RSSI's than we can decode %d \n", value->number_of_rssi); + return 0; + } + + return 1; +} + +static uint8_t unpack_rssi_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_rssi_indication_t *pNfapiMsg = (nfapi_rssi_indication_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_RSSI_INDICATION_TAG, &pNfapiMsg->rssi_indication_body, &unpack_rssi_indication_value}, + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_lte_cell_search_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lte_cell_search_request_t* value = (nfapi_lte_cell_search_request_t*)tlv; + + if(!(pull16(ppReadPackedMsg, &value->earfcn, end) && + pull8(ppReadPackedMsg, &value->measurement_bandwidth, end) && + pull8(ppReadPackedMsg, &value->exhaustive_search, end) && + pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_pci, end))) + return 0; + + if(value->number_of_pci <= NFAPI_MAX_PCI_LIST) + { + if(pullarray16(ppReadPackedMsg, value->pci, NFAPI_MAX_PCI_LIST, value->number_of_pci, end) == 0) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More PCI's than we can decode %d \n", value->number_of_pci); + return 0; + } + return 1; +} + +static uint8_t unpack_utran_cell_search_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_utran_cell_search_request_t* value = (nfapi_utran_cell_search_request_t*)tlv; + + if(!(pull16(ppReadPackedMsg, &value->uarfcn, end) && + pull8(ppReadPackedMsg, &value->exhaustive_search, end) && + pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_psc, end))) + return 0; + + if(value->number_of_psc <= NFAPI_MAX_PSC_LIST) + { + if(pullarray16(ppReadPackedMsg, value->psc, NFAPI_MAX_PSC_LIST, value->number_of_psc, end) == 0) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More PSC's than we can decode %d \n", value->number_of_psc); + return 0; + } + return 1; +} + +static uint8_t unpack_geran_cell_search_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_geran_cell_search_request_t* value = (nfapi_geran_cell_search_request_t*)tlv; + + if(!(pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_arfcn, end))) + return 0; + + if(value->number_of_arfcn <= NFAPI_MAX_ARFCN_LIST) + { + if(pullarray16(ppReadPackedMsg, value->arfcn, NFAPI_MAX_ARFCN_LIST, value->number_of_arfcn, end) == 0) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More ARFCN's than we can decode %d \n", value->number_of_arfcn); + return 0; + } + return 1; +} + +static uint8_t unpack_nb_iot_cell_search_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_cell_search_request_t* value = (nfapi_nb_iot_cell_search_request_t*)tlv; + + if(!(pull16(ppReadPackedMsg, &value->earfcn, end) && + pull8(ppReadPackedMsg, &value->ro_dl, end) && + pull8(ppReadPackedMsg, &value->exhaustive_search, end) && + pull32(ppReadPackedMsg, &value->timeout, end) && + pull8(ppReadPackedMsg, &value->number_of_pci, end))) + return 0; + + if(value->number_of_pci <= NFAPI_MAX_PCI_LIST) + { + if(pullarray16(ppReadPackedMsg, value->pci, NFAPI_MAX_PCI_LIST, value->number_of_pci, end) == 0) + return 0; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More PCI's than we can decode %d \n", value->number_of_pci); + return 0; + } + return 1; +} + +static uint8_t unpack_cell_search_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_cell_search_request_t *pNfapiMsg = (nfapi_cell_search_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->lte_cell_search_request, &unpack_lte_cell_search_request_value}, + { NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->utran_cell_search_request, &unpack_utran_cell_search_request_value}, + { NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->geran_cell_search_request, &unpack_geran_cell_search_request_value}, + { NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG, &pNfapiMsg->nb_iot_cell_search_request, &unpack_nb_iot_cell_search_request_value}, + }; + + int result = (pull8(ppReadPackedMsg, &pNfapiMsg->rat_type, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + + // Verify that the rat type and the tlv match + if(result == 1 && + !((pNfapiMsg->rat_type == NFAPI_RAT_TYPE_LTE && pNfapiMsg->lte_cell_search_request.tl.tag == NFAPI_LTE_CELL_SEARCH_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_UTRAN && pNfapiMsg->utran_cell_search_request.tl.tag == NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_GERAN && pNfapiMsg->geran_cell_search_request.tl.tag == NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_NB_IOT && pNfapiMsg->nb_iot_cell_search_request.tl.tag == NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG))) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Mismatch RAT Type: %d and TAG value: 0x%04x \n", pNfapiMsg->rat_type, pNfapiMsg->lte_cell_search_request.tl.tag); + result = 0; + } + + return result; +} + +static uint8_t unpack_cell_search_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_cell_search_response_t *pNfapiMsg = (nfapi_cell_search_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_lte_cell_search_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lte_cell_search_indication_t* value = (nfapi_lte_cell_search_indication_t*)tlv; + + uint16_t idx = 0; + if(pull16(ppReadPackedMsg, &value->number_of_lte_cells_found, end) == 0) + return 0; + + if(value->number_of_lte_cells_found <= NFAPI_MAX_LTE_CELLS_FOUND) + { + for(idx = 0; idx < value->number_of_lte_cells_found; ++idx) + { + if(!(pull16(ppReadPackedMsg, &value->lte_found_cells[idx].pci, end) && + pull8(ppReadPackedMsg, &value->lte_found_cells[idx].rsrp, end) && + pull8(ppReadPackedMsg, &value->lte_found_cells[idx].rsrq, end) && + pulls16(ppReadPackedMsg, &value->lte_found_cells[idx].frequency_offset, end))) + return 0; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More found LTE cells than we can decode %d \n", value->number_of_lte_cells_found); + return 0; + } + return 1; +} + +static uint8_t unpack_utran_cell_search_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_utran_cell_search_indication_t* value = (nfapi_utran_cell_search_indication_t*)tlv; + + uint16_t idx = 0; + if(pull16(ppReadPackedMsg, &value->number_of_utran_cells_found, end) == 0) + return 0; + + if(value->number_of_utran_cells_found <= NFAPI_MAX_UTRAN_CELLS_FOUND) + { + for(idx = 0; idx < value->number_of_utran_cells_found; ++idx) + { + if(!(pull16(ppReadPackedMsg, &value->utran_found_cells[idx].psc, end) && + pull8(ppReadPackedMsg, &value->utran_found_cells[idx].rscp, end) && + pull8(ppReadPackedMsg, &value->utran_found_cells[idx].ecno, end) && + pulls16(ppReadPackedMsg, &value->utran_found_cells[idx].frequency_offset, end))) + return 0; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More found UTRAN cells than we can decode %d \n", value->number_of_utran_cells_found); + return 0; + } + return 1; +} + +static uint8_t unpack_geran_cell_search_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_geran_cell_search_indication_t* value = (nfapi_geran_cell_search_indication_t*)tlv; + + uint16_t idx = 0; + if(pull16(ppReadPackedMsg, &value->number_of_gsm_cells_found, end) == 0) + return 0; + + if(value->number_of_gsm_cells_found <= NFAPI_MAX_GSM_CELLS_FOUND) + { + for(idx = 0; idx < value->number_of_gsm_cells_found; ++idx) + { + if(!(pull16(ppReadPackedMsg, &value->gsm_found_cells[idx].arfcn, end) && + pull8(ppReadPackedMsg, &value->gsm_found_cells[idx].bsic, end) && + pull8(ppReadPackedMsg, &value->gsm_found_cells[idx].rxlev, end) && + pull8(ppReadPackedMsg, &value->gsm_found_cells[idx].rxqual, end) && + pulls16(ppReadPackedMsg, &value->gsm_found_cells[idx].frequency_offset, end) && + pull32(ppReadPackedMsg, &value->gsm_found_cells[idx].sfn_offset, end))) + return 0; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More found GSM cells than we can decode %d \n", value->number_of_gsm_cells_found); + return 0; + } + return 1; +} + +static uint8_t unpack_nb_iot_cell_search_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_cell_search_indication_t* value = (nfapi_nb_iot_cell_search_indication_t*)tlv; + + uint16_t idx = 0; + if(pull16(ppReadPackedMsg, &value->number_of_nb_iot_cells_found, end) == 0) + return 0; + + if(value->number_of_nb_iot_cells_found <= NFAPI_MAX_NB_IOT_CELLS_FOUND) + { + for(idx = 0; idx < value->number_of_nb_iot_cells_found; ++idx) + { + if(!(pull16(ppReadPackedMsg, &value->nb_iot_found_cells[idx].pci, end) && + pull8(ppReadPackedMsg, &value->nb_iot_found_cells[idx].rsrp, end) && + pull8(ppReadPackedMsg, &value->nb_iot_found_cells[idx].rsrq, end) && + pulls16(ppReadPackedMsg, &value->nb_iot_found_cells[idx].frequency_offset, end))) + return 0; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More found NB_IOT cells than we can decode %d \n", value->number_of_nb_iot_cells_found); + return 0; + } + return 1; +} + +static uint8_t unpack_cell_search_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_cell_search_indication_t *pNfapiMsg = (nfapi_cell_search_indication_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->lte_cell_search_indication, &unpack_lte_cell_search_indication_value}, + { NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->utran_cell_search_indication, &unpack_utran_cell_search_indication_value}, + { NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->geran_cell_search_indication, &unpack_geran_cell_search_indication_value}, + { NFAPI_PNF_CELL_SEARCH_STATE_TAG, &pNfapiMsg->pnf_cell_search_state, &unpack_opaque_data_value}, + { NFAPI_NB_IOT_CELL_SEARCH_INDICATION_TAG, &pNfapiMsg->nb_iot_cell_search_indication, &unpack_nb_iot_cell_search_indication_value}, + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + +} + +static uint8_t unpack_lte_broadcast_detect_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lte_broadcast_detect_request_t* value = (nfapi_lte_broadcast_detect_request_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->earfcn, end) && + pull16(ppReadPackedMsg, &value->pci, end) && + pull32(ppReadPackedMsg, &value->timeout, end)); +} + +static uint8_t unpack_utran_broadcast_detect_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_utran_broadcast_detect_request_t* value = (nfapi_utran_broadcast_detect_request_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->uarfcn, end) && + pull16(ppReadPackedMsg, &value->psc, end) && + pull32(ppReadPackedMsg, &value->timeout, end)); +} + +static uint8_t unpack_nb_iot_broadcast_detect_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_broadcast_detect_request_t* value = (nfapi_nb_iot_broadcast_detect_request_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->earfcn, end) && + pull8(ppReadPackedMsg, &value->ro_dl, end) && + pull16(ppReadPackedMsg, &value->pci, end) && + pull32(ppReadPackedMsg, &value->timeout, end)); +} + +static uint8_t unpack_broadcast_detect_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_broadcast_detect_request_t *pNfapiMsg = (nfapi_broadcast_detect_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG, &pNfapiMsg->lte_broadcast_detect_request, &unpack_lte_broadcast_detect_request_value}, + { NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG, &pNfapiMsg->utran_broadcast_detect_request, &unpack_utran_broadcast_detect_request_value}, + { NFAPI_PNF_CELL_SEARCH_STATE_TAG, &pNfapiMsg->pnf_cell_search_state, &unpack_opaque_data_value}, + { NFAPI_NB_IOT_BROADCAST_DETECT_REQUEST_TAG, &pNfapiMsg->nb_iot_broadcast_detect_request, &unpack_nb_iot_broadcast_detect_request_value} + }; + + return (pull8(ppReadPackedMsg, &pNfapiMsg->rat_type, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_broadcast_detect_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_broadcast_detect_response_t *pNfapiMsg = (nfapi_broadcast_detect_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_lte_broadcast_detect_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lte_broadcast_detect_indication_t* value = (nfapi_lte_broadcast_detect_indication_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->number_of_tx_antenna, end) && + pull16(ppReadPackedMsg, &value->mib_length, end))) + return 0; + + if(value->mib_length > NFAPI_MAX_MIB_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "MIB too long %d \n", value->mib_length); + return 0; + } + + return (pullarray8(ppReadPackedMsg, value->mib, NFAPI_MAX_MIB_LENGTH, value->mib_length, end) && + pull32(ppReadPackedMsg, &value->sfn_offset, end)); +} + +static uint8_t unpack_utran_broadcast_detect_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_utran_broadcast_detect_indication_t* value = (nfapi_utran_broadcast_detect_indication_t*)tlv; + + if(pull16(ppReadPackedMsg, &value->mib_length, end) == 0) + return 0; + + if(value->mib_length > NFAPI_MAX_MIB_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "MIB too long %d \n", value->mib_length); + return 0; + } + + return (pullarray8(ppReadPackedMsg, value->mib, NFAPI_MAX_MIB_LENGTH, value->mib_length, end) && + pull32(ppReadPackedMsg, &value->sfn_offset, end)); +} + +static uint8_t unpack_nb_iot_broadcast_detect_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_broadcast_detect_indication_t* value = (nfapi_nb_iot_broadcast_detect_indication_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->number_of_tx_antenna, end) && + pull16(ppReadPackedMsg, &value->mib_length, end))) + return 0; + + if(value->mib_length > NFAPI_MAX_MIB_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "MIB too long %d \n", value->mib_length); + return 0; + } + + return (pullarray8(ppReadPackedMsg, value->mib, NFAPI_MAX_MIB_LENGTH, value->mib_length, end) && + pull32(ppReadPackedMsg, &value->sfn_offset, end)); +} + +static uint8_t unpack_broadcast_detect_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_broadcast_detect_indication_t *pNfapiMsg = (nfapi_broadcast_detect_indication_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG, &pNfapiMsg->lte_broadcast_detect_indication, &unpack_lte_broadcast_detect_indication_value}, + { NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG, &pNfapiMsg->utran_broadcast_detect_indication, &unpack_utran_broadcast_detect_indication_value}, + { NFAPI_NB_IOT_BROADCAST_DETECT_INDICATION_TAG, &pNfapiMsg->nb_iot_broadcast_detect_indication, &unpack_nb_iot_broadcast_detect_indication_value}, + { NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &pNfapiMsg->pnf_cell_broadcast_state, &unpack_opaque_data_value} + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_lte_system_information_schedule_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lte_system_information_schedule_request_t* value = (nfapi_lte_system_information_schedule_request_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->earfcn, end) && + pull16(ppReadPackedMsg, &value->pci, end) && + pull16(ppReadPackedMsg, &value->downlink_channel_bandwidth, end) && + pull8(ppReadPackedMsg, &value->phich_configuration, end) && + pull8(ppReadPackedMsg, &value->number_of_tx_antenna, end) && + pull8(ppReadPackedMsg, &value->retry_count, end) && + pull32(ppReadPackedMsg, &value->timeout, end)); +} + +static uint8_t unpack_nb_iot_system_information_schedule_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_system_information_schedule_request_t* value = (nfapi_nb_iot_system_information_schedule_request_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->earfcn, end) && + pull8(ppReadPackedMsg, &value->ro_dl, end) && + pull16(ppReadPackedMsg, &value->pci, end) && + pull8(ppReadPackedMsg, &value->scheduling_info_sib1_nb, end) && + pull32(ppReadPackedMsg, &value->timeout, end)); +} + +static uint8_t unpack_system_information_schedule_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_schedule_request_t *pNfapiMsg = (nfapi_system_information_schedule_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG, &pNfapiMsg->lte_system_information_schedule_request, &unpack_lte_system_information_schedule_request_value}, + { NFAPI_NB_IOT_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG, &pNfapiMsg->nb_iot_system_information_schedule_request, &unpack_nb_iot_system_information_schedule_request_value}, + { NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &pNfapiMsg->pnf_cell_broadcast_state, &unpack_opaque_data_value} + }; + + return (pull8(ppReadPackedMsg, &pNfapiMsg->rat_type, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_system_information_schedule_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_schedule_response_t *pNfapiMsg = (nfapi_system_information_schedule_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_lte_system_information_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lte_system_information_indication_t* value = (nfapi_lte_system_information_indication_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->sib_type, end) && + pull16(ppReadPackedMsg, &value->sib_length, end))) + return 0; + + if(value->sib_length > NFAPI_MAX_SIB_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "SIB too long %d \n", value->sib_length); + return 0; + } + + if(pullarray8(ppReadPackedMsg, value->sib, NFAPI_MAX_SIB_LENGTH, value->sib_length, end) == 0) + return 0; + + return 1; +} + +static uint8_t unpack_nb_iot_system_information_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_system_information_indication_t* value = (nfapi_nb_iot_system_information_indication_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->sib_type, end) && + pull16(ppReadPackedMsg, &value->sib_length, end))) + return 0; + + if(value->sib_length > NFAPI_MAX_SIB_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "SIB too long %d \n", value->sib_length); + return 0; + } + + if(pullarray8(ppReadPackedMsg, value->sib, NFAPI_MAX_SIB_LENGTH, value->sib_length, end) == 0) + return 0; + + return 1; +} + +static uint8_t unpack_system_information_schedule_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_schedule_indication_t *pNfapiMsg = (nfapi_system_information_schedule_indication_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->lte_system_information_indication, &unpack_lte_system_information_indication_value}, + { NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->nb_iot_system_information_indication, &unpack_nb_iot_system_information_indication_value}, + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_lte_system_information_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lte_system_information_request_t* value = (nfapi_lte_system_information_request_t*)tlv; + uint16_t idx = 0; + + if(!(pull16(ppReadPackedMsg, &value->earfcn, end) && + pull16(ppReadPackedMsg, &value->pci, end) && + pull16(ppReadPackedMsg, &value->downlink_channel_bandwidth, end) && + pull8(ppReadPackedMsg, &value->phich_configuration, end) && + pull8(ppReadPackedMsg, &value->number_of_tx_antenna, end) && + pull8(ppReadPackedMsg, &value->number_of_si_periodicity, end))) + return 0; + + if(value->number_of_si_periodicity > NFAPI_MAX_SI_PERIODICITY) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More found SI periodicity than we can decode %d \n", value->number_of_si_periodicity); + return 0; + } + + for(idx = 0; idx < value->number_of_si_periodicity; ++idx) + { + if(!(pull8(ppReadPackedMsg, &value->si_periodicity[idx].si_periodicity, end) && + pull8(ppReadPackedMsg, &value->si_periodicity[idx].si_index, end))) + return 0; + } + + if(!(pull8(ppReadPackedMsg, &value->si_window_length, end) && + pull32(ppReadPackedMsg, &value->timeout, end))) + return 0; + + return 1; +} + +static uint8_t unpack_utran_system_information_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_utran_system_information_request_t* value = (nfapi_utran_system_information_request_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->uarfcn, end) && + pull16(ppReadPackedMsg, &value->psc, end) && + pull32(ppReadPackedMsg, &value->timeout, end)); +} + +static uint8_t unpack_geran_system_information_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_geran_system_information_request_t* value = (nfapi_geran_system_information_request_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->arfcn, end) && + pull8(ppReadPackedMsg, &value->bsic, end) && + pull32(ppReadPackedMsg, &value->timeout, end)); +} + +static uint8_t unpack_nb_iot_system_information_request_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_iot_system_information_request_t* value = (nfapi_nb_iot_system_information_request_t*)tlv; + uint16_t idx = 0; + + if(!(pull16(ppReadPackedMsg, &value->earfcn, end) && + pull8(ppReadPackedMsg, &value->ro_dl, end) && + pull16(ppReadPackedMsg, &value->pci, end) && + pull8(ppReadPackedMsg, &value->number_of_si_periodicity, end))) + return 0; + + if(value->number_of_si_periodicity > NFAPI_MAX_SI_PERIODICITY) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "More found SI periodicity than we can decode %d \n", value->number_of_si_periodicity); + return 0; + } + + for(idx = 0; idx < value->number_of_si_periodicity; ++idx) + { + if(!(pull8(ppReadPackedMsg, &value->si_periodicity[idx].si_periodicity, end) && + pull8(ppReadPackedMsg, &value->si_periodicity[idx].si_repetition_pattern, end) && + pull8(ppReadPackedMsg, &value->si_periodicity[idx].si_tb_size, end) && + pull8(ppReadPackedMsg, &value->si_periodicity[idx].number_of_si_index, end))) + return 0; + + uint8_t si_idx; + for(si_idx = 0; si_idx < value->si_periodicity[idx].number_of_si_index; ++si_idx) + { + if(!(pull8(ppReadPackedMsg, &value->si_periodicity[idx].si_index[si_idx], end))) + return 0; + + } + } + + if(!(pull8(ppReadPackedMsg, &value->si_window_length, end) && + pull32(ppReadPackedMsg, &value->timeout, end))) + return 0; + + return 1; +} + +static uint8_t unpack_system_information_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_request_t *pNfapiMsg = (nfapi_system_information_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->lte_system_information_request, &unpack_lte_system_information_request_value}, + { NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->utran_system_information_request, &unpack_utran_system_information_request_value}, + { NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->geran_system_information_request, &unpack_geran_system_information_request_value}, + { NFAPI_NB_IOT_SYSTEM_INFORMATION_REQUEST_TAG, &pNfapiMsg->nb_iot_system_information_request, &unpack_nb_iot_system_information_request_value}, + { NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &pNfapiMsg->pnf_cell_broadcast_state, &unpack_opaque_data_value} + }; + + + int result = (pull8(ppReadPackedMsg, &pNfapiMsg->rat_type, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + + // Verify that the rat type and the tlv match + if(result == 1 && + !((pNfapiMsg->rat_type == NFAPI_RAT_TYPE_LTE && pNfapiMsg->lte_system_information_request.tl.tag == NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_UTRAN && pNfapiMsg->utran_system_information_request.tl.tag == NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG) || + (pNfapiMsg->rat_type == NFAPI_RAT_TYPE_GERAN && pNfapiMsg->geran_system_information_request.tl.tag == NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG))) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Mismatch RAT Type: %d and TAG value: 0x%04x \n", pNfapiMsg->rat_type, pNfapiMsg->lte_system_information_request.tl.tag); + result = 0; + } + + return result; +} + +static uint8_t unpack_system_information_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_response_t *pNfapiMsg = (nfapi_system_information_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_utran_system_information_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_utran_system_information_indication_t* value = (nfapi_utran_system_information_indication_t*)tlv; + + if(pull16(ppReadPackedMsg, &value->sib_length, end) == 0) + return 0; + + if(value->sib_length > NFAPI_MAX_SIB_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "SIB too long %d \n", value->sib_length); + return 0; + } + + if(pullarray8(ppReadPackedMsg, value->sib, NFAPI_MAX_SIB_LENGTH, value->sib_length, end) == 0) + return 0; + + return 1; +} + +static uint8_t unpack_geran_system_information_indication_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_geran_system_information_indication_t* value = (nfapi_geran_system_information_indication_t*)tlv; + + if(pull16(ppReadPackedMsg, &value->si_length, end) == 0) + return 0; + + if(value->si_length > NFAPI_MAX_SI_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "SIB too long %d \n", value->si_length); + return 0; + } + + if(pullarray8(ppReadPackedMsg, value->si, NFAPI_MAX_SI_LENGTH, value->si_length, end) == 0) + return 0; + + return 1; +} + +static uint8_t unpack_system_information_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_system_information_indication_t *pNfapiMsg = (nfapi_system_information_indication_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->lte_system_information_indication, &unpack_lte_system_information_indication_value}, + { NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->utran_system_information_indication, &unpack_utran_system_information_indication_value}, + { NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->geran_system_information_indication, &unpack_geran_system_information_indication_value}, + { NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG, &pNfapiMsg->nb_iot_system_information_indication, &unpack_nb_iot_system_information_indication_value}, + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + +} + +static uint8_t unpack_nmm_stop_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_nmm_stop_request_t *pNfapiMsg = (nfapi_nmm_stop_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension); +} + +static uint8_t unpack_nmm_stop_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_nmm_stop_response_t *pNfapiMsg = (nfapi_nmm_stop_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + + +static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen) +{ + int retLen = 0; + + switch (msgId) + { + case NFAPI_RSSI_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_rssi_request_t)) + retLen = sizeof(nfapi_rssi_request_t); + break; + + case NFAPI_RSSI_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_rssi_response_t)) + retLen = sizeof(nfapi_rssi_response_t); + break; + + case NFAPI_RSSI_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_rssi_indication_t)) + retLen = sizeof(nfapi_rssi_indication_t); + break; + + case NFAPI_CELL_SEARCH_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_cell_search_request_t)) + retLen = sizeof(nfapi_cell_search_request_t); + break; + + case NFAPI_CELL_SEARCH_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_cell_search_response_t)) + retLen = sizeof(nfapi_cell_search_response_t); + break; + + case NFAPI_CELL_SEARCH_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_cell_search_indication_t)) + retLen = sizeof(nfapi_cell_search_indication_t); + break; + + case NFAPI_BROADCAST_DETECT_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_broadcast_detect_request_t)) + retLen = sizeof(nfapi_broadcast_detect_request_t); + break; + + case NFAPI_BROADCAST_DETECT_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_broadcast_detect_response_t)) + retLen = sizeof(nfapi_broadcast_detect_response_t); + break; + + case NFAPI_BROADCAST_DETECT_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_broadcast_detect_indication_t)) + retLen = sizeof(nfapi_broadcast_detect_indication_t); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_system_information_schedule_request_t)) + retLen = sizeof(nfapi_system_information_schedule_request_t); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_system_information_schedule_response_t)) + retLen = sizeof(nfapi_system_information_schedule_response_t); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_system_information_schedule_indication_t)) + retLen = sizeof(nfapi_system_information_schedule_indication_t); + break; + + case NFAPI_SYSTEM_INFORMATION_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_system_information_request_t)) + retLen = sizeof(nfapi_system_information_request_t); + break; + + case NFAPI_SYSTEM_INFORMATION_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_system_information_response_t)) + retLen = sizeof(nfapi_system_information_response_t); + break; + + case NFAPI_SYSTEM_INFORMATION_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_system_information_indication_t)) + retLen = sizeof(nfapi_system_information_indication_t); + break; + + case NFAPI_NMM_STOP_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_nmm_stop_request_t)) + retLen = sizeof(nfapi_nmm_stop_request_t); + break; + + case NFAPI_NMM_STOP_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_nmm_stop_response_t)) + retLen = sizeof(nfapi_nmm_stop_response_t); + break; + + default: + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown message ID %d\n", msgId); + break; + } + + return retLen; +} + +int nfapi_p4_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_p4_p5_message_header_t *pMessageHeader = pMessageBuf; + uint8_t *end = pPackedBuf + packedBufLen; + uint8_t *pWritePackedMessage = pPackedBuf; + uint8_t *pPackedLengthField = &pWritePackedMessage[4]; + uint32_t packedMsgLen; + uint16_t packedMsgLen16; + + if (pMessageBuf == NULL || pPackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P4 Pack supplied pointers are null\n"); + return -1; + } + + // process the header + if(!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) && + push16(pMessageHeader->message_id, &pWritePackedMessage, end) && + push16(0/*pMessageHeader->message_length*/, &pWritePackedMessage, end) && + push16(pMessageHeader->spare, &pWritePackedMessage, end))) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to pack p4 message header\n"); + return -1; + } + + // look for the specific message + uint8_t result = 0; + switch (pMessageHeader->message_id) + { + case NFAPI_RSSI_REQUEST: + result = pack_rssi_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_RSSI_RESPONSE: + result = pack_rssi_response(pMessageHeader, &pWritePackedMessage, end,config); + break; + + case NFAPI_RSSI_INDICATION: + result = pack_rssi_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_CELL_SEARCH_REQUEST: + result = pack_cell_search_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_CELL_SEARCH_RESPONSE: + result = pack_cell_search_response(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_CELL_SEARCH_INDICATION: + result = pack_cell_search_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_BROADCAST_DETECT_REQUEST: + result = pack_broadcast_detect_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_BROADCAST_DETECT_RESPONSE: + result = pack_broadcast_detect_response(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_BROADCAST_DETECT_INDICATION: + result = pack_broadcast_detect_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST: + result = pack_system_information_schedule_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE: + result = pack_system_information_schedule_response(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION: + result = pack_system_information_schedule_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_SYSTEM_INFORMATION_REQUEST: + result = pack_system_information_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_SYSTEM_INFORMATION_RESPONSE: + result = pack_system_information_response(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_SYSTEM_INFORMATION_INDICATION: + result = pack_system_information_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_NMM_STOP_REQUEST: + result = pack_nmm_stop_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_NMM_STOP_RESPONSE: + result = pack_nmm_stop_response(pMessageHeader, &pWritePackedMessage, end, config); + break; + + default: + { + if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MIN) + { + if(config && config->pack_p4_p5_vendor_extension) + { + result =(config->pack_p4_p5_vendor_extension)(pMessageHeader, &pWritePackedMessage, end, config); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve encoder provided\n", __FUNCTION__, pMessageHeader->message_id); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id); + } + } + break; + } + + // return the packed length + if(result == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Result is 0\n"); + return -1; + } + + + // check for a valid message length + packedMsgLen = get_packed_msg_len((uintptr_t)pPackedBuf, (uintptr_t)pWritePackedMessage); + if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen); + return -1; + } + else + { + packedMsgLen16 = (uint16_t)packedMsgLen; + } + + // Update the message length in the header + if(push16(packedMsgLen16, &pPackedLengthField, end) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to pack p4 message header lengt\n"); + return -1; + } + + return (packedMsgLen); + +} + +// Main unpack functions - public + +int nfapi_p4_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf; + uint8_t *pReadPackedMessage = pMessageBuf; + uint8_t *end = pMessageBuf + messageBufLen; + + if (pMessageBuf == NULL || pUnpackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P4 header unpack supplied pointers are null\n"); + return -1; + } + + if (messageBufLen < NFAPI_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p4_p5_message_header_t)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 header unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen); + return -1; + } + + // process the headei + if (pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) && + pull16(&pReadPackedMessage, &pMessageHeader->spare, end)) + return -1; + + return 0; +} + +int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config) +{ + int result = 0; + nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf; + uint8_t *pReadPackedMessage = pMessageBuf; + uint8_t *end = pMessageBuf + messageBufLen; + + if (pMessageBuf == NULL || pUnpackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P4 unpack supplied pointers are null\n"); + return -1; + } + + if (messageBufLen < NFAPI_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p4_p5_message_header_t)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P4 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen); + return -1; + } + + // clean the supplied buffer for - tag value blanking + (void)memset(pUnpackedBuf, 0, unpackedBufLen); + + // process the header + if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) && + pull16(&pReadPackedMessage, &pMessageHeader->spare, end))) + return -1; + + // look for the specific message + switch (pMessageHeader->message_id) + { + case NFAPI_RSSI_REQUEST: + if (check_unpack_length(NFAPI_RSSI_REQUEST, unpackedBufLen)) + result = unpack_rssi_request(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_RSSI_RESPONSE: + if (check_unpack_length(NFAPI_RSSI_RESPONSE, unpackedBufLen)) + result = unpack_rssi_response(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_RSSI_INDICATION: + if (check_unpack_length(NFAPI_RSSI_INDICATION, unpackedBufLen)) + result = unpack_rssi_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_CELL_SEARCH_REQUEST: + if (check_unpack_length(NFAPI_CELL_SEARCH_REQUEST, unpackedBufLen)) + result = unpack_cell_search_request(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_CELL_SEARCH_RESPONSE: + if (check_unpack_length(NFAPI_CELL_SEARCH_RESPONSE, unpackedBufLen)) + result = unpack_cell_search_response(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_CELL_SEARCH_INDICATION: + if (check_unpack_length(NFAPI_CELL_SEARCH_INDICATION, unpackedBufLen)) + result = unpack_cell_search_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_BROADCAST_DETECT_REQUEST: + if (check_unpack_length(NFAPI_BROADCAST_DETECT_REQUEST, unpackedBufLen)) + result = unpack_broadcast_detect_request(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_BROADCAST_DETECT_RESPONSE: + if (check_unpack_length(NFAPI_BROADCAST_DETECT_RESPONSE, unpackedBufLen)) + result = unpack_broadcast_detect_response(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_BROADCAST_DETECT_INDICATION: + if (check_unpack_length(NFAPI_BROADCAST_DETECT_INDICATION, unpackedBufLen)) + result = unpack_broadcast_detect_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST: + if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST, unpackedBufLen)) + result = unpack_system_information_schedule_request(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE: + if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE, unpackedBufLen)) + result = unpack_system_information_schedule_response(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION: + if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION, unpackedBufLen)) + result = unpack_system_information_schedule_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_SYSTEM_INFORMATION_REQUEST: + if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_REQUEST, unpackedBufLen)) + result = unpack_system_information_request(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_SYSTEM_INFORMATION_RESPONSE: + if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_RESPONSE, unpackedBufLen)) + result = unpack_system_information_response(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_SYSTEM_INFORMATION_INDICATION: + if (check_unpack_length(NFAPI_SYSTEM_INFORMATION_INDICATION, unpackedBufLen)) + result = unpack_system_information_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_NMM_STOP_REQUEST: + if (check_unpack_length(NFAPI_NMM_STOP_REQUEST, unpackedBufLen)) + result = unpack_nmm_stop_request(&pReadPackedMessage, end, pMessageHeader, config); + else + result = -1; + break; + + case NFAPI_NMM_STOP_RESPONSE: + if (check_unpack_length(NFAPI_NMM_STOP_RESPONSE, unpackedBufLen)) + result = unpack_nmm_stop_response(&pReadPackedMessage, end , pMessageHeader, config); + else + result = -1; + break; + + default: + if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + if(config && config->unpack_p4_p5_vendor_extension) + { + result = (config->unpack_p4_p5_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve decoder provided\n", __FUNCTION__, pMessageHeader->message_id); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown P4 message ID %d\n", __FUNCTION__, pMessageHeader->message_id); + } + break; + } + + if(result == 0) + return -1; + + return result; +} diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c new file mode 100644 index 0000000000000000000000000000000000000000..c78b8291358c2a611763649d024bb86acf2b9fba --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c @@ -0,0 +1,1800 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <signal.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <sched.h> +#include <time.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <pthread.h> +#include <stdint.h> + +#include <nfapi_interface.h> +#include <nfapi.h> +#include <debug.h> + + +// Pack routines + +static uint8_t pack_pnf_param_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_param_request_t* request = (nfapi_pnf_param_request_t*)msg; + return pack_vendor_extension_tlv(request->vendor_extension, ppWritePackedMsg, end, config); +} + +static uint8_t pack_pnf_param_general_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_param_general_t* value = (nfapi_pnf_param_general_t*)tlv; + + return ( push8(value->nfapi_sync_mode, ppWritePackedMsg, end) && + push8(value->location_mode, ppWritePackedMsg, end) && + push16(value->location_coordinates_length, ppWritePackedMsg, end) && + pusharray8(value->location_coordinates, NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH, value->location_coordinates_length, ppWritePackedMsg, end) && + push32(value->dl_config_timing, ppWritePackedMsg, end) && + push32(value->tx_timing, ppWritePackedMsg, end) && + push32(value->ul_config_timing, ppWritePackedMsg, end) && + push32(value->hi_dci0_timing, ppWritePackedMsg, end) && + push16(value->maximum_number_phys, ppWritePackedMsg, end) && + push16(value->maximum_total_bandwidth, ppWritePackedMsg, end) && + push8(value->maximum_total_number_dl_layers, ppWritePackedMsg, end) && + push8(value->maximum_total_number_ul_layers, ppWritePackedMsg, end) && + push8(value->shared_bands, ppWritePackedMsg, end) && + push8(value->shared_pa, ppWritePackedMsg, end) && + pushs16(value->maximum_total_power, ppWritePackedMsg, end) && + pusharray8(value->oui, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, ppWritePackedMsg, end)); +} + +static uint8_t pack_rf_config_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rf_config_info_t* rf = (nfapi_rf_config_info_t*)elem; + + return (push16(rf->rf_config_index, ppWritePackedMsg, end)); +} + + +static uint8_t pack_pnf_phy_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t* end) +{ + nfapi_pnf_phy_info_t* phy = (nfapi_pnf_phy_info_t*)elem; + + return ( push16(phy->phy_config_index, ppWritePackedMsg, end) && + push16(phy->number_of_rfs, ppWritePackedMsg, end) && + packarray(phy->rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rfs, ppWritePackedMsg, end, &pack_rf_config_info) && + push16(phy->number_of_rf_exclusions, ppWritePackedMsg, end) && + packarray(phy->excluded_rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rf_exclusions, ppWritePackedMsg, end, &pack_rf_config_info) && + push16(phy->downlink_channel_bandwidth_supported, ppWritePackedMsg, end) && + push16(phy->uplink_channel_bandwidth_supported, ppWritePackedMsg, end) && + push8(phy->number_of_dl_layers_supported, ppWritePackedMsg, end) && + push8(phy->number_of_ul_layers_supported, ppWritePackedMsg, end) && + push16(phy->maximum_3gpp_release_supported, ppWritePackedMsg, end) && + push8(phy->nmm_modes_supported, ppWritePackedMsg, end)); + + +} + +static uint8_t pack_pnf_phy_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_t* value = (nfapi_pnf_phy_t*)tlv; + + return ( push16(value->number_of_phys, ppWritePackedMsg, end) && + packarray(value->phy, sizeof(nfapi_pnf_phy_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, ppWritePackedMsg, end, &pack_pnf_phy_info)); +} + +static uint8_t pack_pnf_rf_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_rf_t* value = (nfapi_pnf_rf_t*)tlv; + uint16_t rf_index = 0; + + if(push16(value->number_of_rfs, ppWritePackedMsg, end) == 0) + return 0; + + for(; rf_index < value->number_of_rfs; ++rf_index) + { + if( !(push16(value->rf[rf_index].rf_config_index, ppWritePackedMsg, end) && + push16(value->rf[rf_index].band, ppWritePackedMsg, end) && + pushs16(value->rf[rf_index].maximum_transmit_power, ppWritePackedMsg, end) && + pushs16(value->rf[rf_index].minimum_transmit_power, ppWritePackedMsg, end) && + push8(value->rf[rf_index].number_of_antennas_suppported, ppWritePackedMsg, end) && + push32(value->rf[rf_index].minimum_downlink_frequency, ppWritePackedMsg, end) && + push32(value->rf[rf_index].maximum_downlink_frequency, ppWritePackedMsg, end) && + push32(value->rf[rf_index].minimum_uplink_frequency, ppWritePackedMsg, end) && + push32(value->rf[rf_index].maximum_uplink_frequency, ppWritePackedMsg, end))) + return 0; + } + + return 1; +} +static uint8_t pack_pnf_phy_rel10_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel10_info_t* phy = (nfapi_pnf_phy_rel10_info_t*)elem; + + return(push16(phy->phy_config_index, ppWritePackedMsg, end) && + push16(phy->transmission_mode_7_supported, ppWritePackedMsg, end) && + push16(phy->transmission_mode_8_supported, ppWritePackedMsg, end) && + push16(phy->two_antenna_ports_for_pucch, ppWritePackedMsg, end) && + push16(phy->transmission_mode_9_supported, ppWritePackedMsg, end) && + push16(phy->simultaneous_pucch_pusch, ppWritePackedMsg, end) && + push16(phy->four_layer_tx_with_tm3_and_tm4, ppWritePackedMsg, end)); +} + +static uint8_t pack_pnf_phy_rel10_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel10_t* value = (nfapi_pnf_phy_rel10_t*)tlv; + + return (push16(value->number_of_phys, ppWritePackedMsg, end) && + packarray(value->phy, sizeof(nfapi_pnf_phy_rel10_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, ppWritePackedMsg, end, &pack_pnf_phy_rel10_info)); + +} + +static uint8_t pack_pnf_phy_rel11_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel11_info_t* phy = (nfapi_pnf_phy_rel11_info_t*)elem; + + return (push16(phy->phy_config_index, ppWritePackedMsg, end) && + push16(phy->edpcch_supported, ppWritePackedMsg, end) && + push16(phy->multi_ack_csi_reporting, ppWritePackedMsg, end) && + push16(phy->pucch_tx_diversity, ppWritePackedMsg, end) && + push16(phy->ul_comp_supported, ppWritePackedMsg, end) && + push16(phy->transmission_mode_5_supported, ppWritePackedMsg, end )); +} +static uint8_t pack_pnf_phy_rel11_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel11_t* value = (nfapi_pnf_phy_rel11_t*)tlv; + + return (push16(value->number_of_phys, ppWritePackedMsg, end) && + packarray(value->phy, sizeof(nfapi_pnf_phy_rel11_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, ppWritePackedMsg, end, &pack_pnf_phy_rel11_info)); +} +static uint8_t pack_pnf_phy_rel12_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel12_info_t* phy = (nfapi_pnf_phy_rel12_info_t*)elem; + + return( push16(phy->phy_config_index, ppWritePackedMsg, end) && + push16(phy->csi_subframe_set, ppWritePackedMsg, end) && + push16(phy->enhanced_4tx_codebook, ppWritePackedMsg, end) && + push16(phy->drs_supported, ppWritePackedMsg, end) && + push16(phy->ul_64qam_supported, ppWritePackedMsg, end) && + push16(phy->transmission_mode_10_supported, ppWritePackedMsg, end) && + push16(phy->alternative_bts_indices, ppWritePackedMsg, end)); +} +static uint8_t pack_pnf_phy_rel12_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel12_t* value = (nfapi_pnf_phy_rel12_t*)tlv; + + return (push16(value->number_of_phys, ppWritePackedMsg, end) && + packarray(value->phy, sizeof(nfapi_pnf_phy_rel12_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, ppWritePackedMsg, end, &pack_pnf_phy_rel12_info)); + +} + +static uint8_t pack_pnf_phy_rel13_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_info_t* phy = (nfapi_pnf_phy_rel13_info_t*)elem; + + return( push16(phy->phy_config_index, ppWritePackedMsg, end) && + push16(phy->pucch_format4_supported, ppWritePackedMsg, end) && + push16(phy->pucch_format5_supported, ppWritePackedMsg, end) && + push16(phy->more_than_5_ca_support, ppWritePackedMsg, end) && + push16(phy->laa_supported, ppWritePackedMsg, end) && + push16(phy->laa_ending_in_dwpts_supported, ppWritePackedMsg, end) && + push16(phy->laa_starting_in_second_slot_supported, ppWritePackedMsg, end) && + push16(phy->beamforming_supported, ppWritePackedMsg, end) && + push16(phy->csi_rs_enhancement_supported, ppWritePackedMsg, end) && + push16(phy->drms_enhancement_supported, ppWritePackedMsg, end) && + push16(phy->srs_enhancement_supported, ppWritePackedMsg, end) ); +} + +static uint8_t pack_pnf_phy_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_t* value = (nfapi_pnf_phy_rel13_t*)tlv; + + return (push16(value->number_of_phys, ppWritePackedMsg, end) && + packarray(value->phy, sizeof(nfapi_pnf_phy_rel13_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, ppWritePackedMsg, end, &pack_pnf_phy_rel13_info)); +} + +static uint8_t pack_pnf_phy_rel13_nb_iot_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_nb_iot_info_t* phy = (nfapi_pnf_phy_rel13_nb_iot_info_t*)elem; + + return( push16(phy->phy_config_index, ppWritePackedMsg, end) && + push16(phy->number_of_rfs, ppWritePackedMsg, end) && + packarray(phy->rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rfs, ppWritePackedMsg, end, &pack_rf_config_info) && + push16(phy->number_of_rf_exclusions, ppWritePackedMsg, end) && + packarray(phy->excluded_rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rf_exclusions, ppWritePackedMsg, end, &pack_rf_config_info) && + push8(phy->number_of_dl_layers_supported, ppWritePackedMsg, end) && + push8(phy->number_of_ul_layers_supported, ppWritePackedMsg, end) && + push16(phy->maximum_3gpp_release_supported, ppWritePackedMsg, end) && + push8(phy->nmm_modes_supported, ppWritePackedMsg, end)); +} + +static uint8_t pack_pnf_phy_rel13_nb_iot_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_nb_iot_t* value = (nfapi_pnf_phy_rel13_nb_iot_t*)tlv; + + return (push16(value->number_of_phys, ppWritePackedMsg, end) && + packarray(value->phy, sizeof(nfapi_pnf_phy_rel13_nb_iot_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, ppWritePackedMsg, end, &pack_pnf_phy_rel13_nb_iot_info)); +} + + +static uint8_t pack_pnf_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_param_response_t *pNfapiMsg = (nfapi_pnf_param_response_t*)msg; + + return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_tlv(NFAPI_PNF_PARAM_GENERAL_TAG, &pNfapiMsg->pnf_param_general, ppWritePackedMsg, end, &pack_pnf_param_general_value) && + pack_tlv(NFAPI_PNF_PHY_TAG, &pNfapiMsg->pnf_phy, ppWritePackedMsg, end, &pack_pnf_phy_value) && + pack_tlv(NFAPI_PNF_RF_TAG, &pNfapiMsg->pnf_rf, ppWritePackedMsg, end, &pack_pnf_rf_value) && + pack_tlv(NFAPI_PNF_PHY_REL10_TAG, &pNfapiMsg->pnf_phy_rel10, ppWritePackedMsg, end, &pack_pnf_phy_rel10_value) && + pack_tlv(NFAPI_PNF_PHY_REL11_TAG, &pNfapiMsg->pnf_phy_rel11, ppWritePackedMsg, end, &pack_pnf_phy_rel11_value) && + pack_tlv(NFAPI_PNF_PHY_REL12_TAG, &pNfapiMsg->pnf_phy_rel12, ppWritePackedMsg, end, &pack_pnf_phy_rel12_value) && + pack_tlv(NFAPI_PNF_PHY_REL13_TAG, &pNfapiMsg->pnf_phy_rel13, ppWritePackedMsg, end, &pack_pnf_phy_rel13_value) && + pack_tlv(NFAPI_PNF_PHY_REL13_NB_IOT_TAG, &pNfapiMsg->pnf_phy_rel13_nb_iot, ppWritePackedMsg, end, &pack_pnf_phy_rel13_nb_iot_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_phy_rf_config_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_phy_rf_config_info_t* rf = (nfapi_phy_rf_config_info_t*)elem; + + return (push16(rf->phy_id, ppWritePackedMsg, end) && + push16(rf->phy_config_index, ppWritePackedMsg, end) && + push16(rf->rf_config_index, ppWritePackedMsg, end)); +} + + +static uint8_t pack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rf_config_t *value = (nfapi_pnf_phy_rf_config_t*)tlv; + + return(push16(value->number_phy_rf_config_info, ppWritePackedMsg, end) && + packarray(value->phy_rf_config, sizeof(nfapi_phy_rf_config_info_t), NFAPI_MAX_PHY_RF_INSTANCES, value->number_phy_rf_config_info, ppWritePackedMsg, end, &pack_phy_rf_config_info)); + +} + +static uint8_t pack_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_config_request_t *pNfapiMsg = (nfapi_pnf_config_request_t*)msg; + return ( pack_tlv(NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, ppWritePackedMsg, end, &pack_pnf_phy_rf_config_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end , config)); +} + + +static uint8_t pack_pnf_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_config_response_t *pNfapiMsg = (nfapi_pnf_config_response_t*)msg; + + return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_pnf_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_start_request_t *pNfapiMsg = (nfapi_pnf_start_request_t*)msg; + return ( pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_pnf_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_start_response_t *pNfapiMsg = (nfapi_pnf_start_response_t*)msg; + + return( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_pnf_stop_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_stop_request_t *pNfapiMsg = (nfapi_pnf_stop_request_t*)msg; + return ( pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); +} + +static uint8_t pack_pnf_stop_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_stop_response_t *pNfapiMsg = (nfapi_pnf_stop_response_t*)msg; + + return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_param_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t* end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_param_request_t *pNfapiMsg = (nfapi_param_request_t*)msg; + return (pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_uint16_tlv_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_uint16_tlv_t* value = (nfapi_uint16_tlv_t*)tlv; + return push16(value->value, ppWritePackedMsg, end); +} + +static uint8_t unpack_uint16_tlv_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_uint16_tlv_t* value = (nfapi_uint16_tlv_t*)tlv; + return pull16(ppReadPackedMsg, &value->value, end); +} +static uint8_t pack_int16_tlv_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_int16_tlv_t* value = (nfapi_int16_tlv_t*)tlv; + return pushs16(value->value, ppWritePackedMsg, end); +} + +static uint8_t unpack_int16_tlv_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_int16_tlv_t* value = (nfapi_int16_tlv_t*)tlv; + return pulls16(ppReadPackedMsg, &value->value, end); +} + +static uint8_t pack_uint8_tlv_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_uint8_tlv_t* value = (nfapi_uint8_tlv_t*)tlv; + return push8(value->value, ppWritePackedMsg, end); +} +static uint8_t unpack_uint8_tlv_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_uint8_tlv_t* value = (nfapi_uint8_tlv_t*)tlv; + return pull8(ppReadPackedMsg, &value->value, end); +} + +static uint8_t pack_ipv4_address_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ipv4_address_t* value = (nfapi_ipv4_address_t*)tlv; + return pusharray8(value->address, NFAPI_IPV4_ADDRESS_LENGTH, NFAPI_IPV4_ADDRESS_LENGTH, ppWritePackedMsg, end); +} +static uint8_t unpack_ipv4_address_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ipv4_address_t* value = (nfapi_ipv4_address_t*)tlv; + return pullarray8(ppReadPackedMsg, value->address, NFAPI_IPV4_ADDRESS_LENGTH, NFAPI_IPV4_ADDRESS_LENGTH, end); +} +static uint8_t pack_ipv6_address_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ipv6_address_t* value = (nfapi_ipv6_address_t*)tlv; + return pusharray8(value->address, NFAPI_IPV6_ADDRESS_LENGTH, NFAPI_IPV6_ADDRESS_LENGTH, ppWritePackedMsg, end); +} +static uint8_t unpack_ipv6_address_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ipv4_address_t* value = (nfapi_ipv4_address_t*)tlv; + return pullarray8(ppReadPackedMsg, value->address, NFAPI_IPV6_ADDRESS_LENGTH, NFAPI_IPV6_ADDRESS_LENGTH, end); +} + +static uint8_t pack_rf_bands_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rf_bands_t* value = (nfapi_rf_bands_t*)tlv; + + return ( push16(value->number_rf_bands, ppWritePackedMsg, end) && + pusharray16(value->rf_band, NFAPI_MAX_NUM_RF_BANDS, value->number_rf_bands, ppWritePackedMsg, end)); +} +static uint8_t unpack_rf_bands_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t* end) +{ + nfapi_rf_bands_t* value = (nfapi_rf_bands_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_rf_bands, end) && + pullarray16(ppReadPackedMsg, value->rf_band, NFAPI_MAX_NUM_RF_BANDS, value->number_rf_bands, end)); +} + +static uint8_t pack_nmm_frequency_bands_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nmm_frequency_bands_t* value = (nfapi_nmm_frequency_bands_t*)tlv; + + return( push16(value->number_of_rf_bands, ppWritePackedMsg, end) && + pusharray16(value->bands, NFAPI_MAX_NMM_FREQUENCY_BANDS, value->number_of_rf_bands, ppWritePackedMsg, end)); +} +static uint8_t unpack_nmm_frequency_bands_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nmm_frequency_bands_t* value = (nfapi_nmm_frequency_bands_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_of_rf_bands, end) && + pullarray16(ppReadPackedMsg, value->bands, NFAPI_MAX_NMM_FREQUENCY_BANDS, value->number_of_rf_bands, end)); +} + +static uint8_t pack_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_param_response_t *pNfapiMsg = (nfapi_param_response_t*)msg; + + return( push8(pNfapiMsg->error_code, ppWritePackedMsg, end) && + push8(pNfapiMsg->num_tlv, ppWritePackedMsg, end) && + pack_tlv(NFAPI_L1_STATUS_PHY_STATE_TAG, &pNfapiMsg->l1_status.phy_state, ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + // Do we check the phy state and then just fill those sepecified, however + // we do not know the duplex mode, so just attempt to pack all and assumme + // that the callee has set the right tlvs + + pack_tlv(NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG, &(pNfapiMsg->phy_capabilities.dl_bandwidth_support), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG, &(pNfapiMsg->phy_capabilities.ul_bandwidth_support), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG, &(pNfapiMsg->phy_capabilities.dl_modulation_support), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG, &(pNfapiMsg->phy_capabilities.ul_modulation_support), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG, &(pNfapiMsg->phy_capabilities.phy_antenna_capability), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG, &(pNfapiMsg->phy_capabilities.release_capability), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG, &(pNfapiMsg->phy_capabilities.mbsfn_capability), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + // laa capability + + pack_tlv(NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG, &(pNfapiMsg->subframe_config.duplex_mode), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG, &(pNfapiMsg->subframe_config.pcfich_power_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value)&& + pack_tlv(NFAPI_SUBFRAME_CONFIG_PB_TAG, &(pNfapiMsg->subframe_config.pb), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG, &(pNfapiMsg->subframe_config.dl_cyclic_prefix_type), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG, &(pNfapiMsg->subframe_config.ul_cyclic_prefix_type), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG, &(pNfapiMsg->rf_config.dl_channel_bandwidth), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG, &(pNfapiMsg->rf_config.ul_channel_bandwidth), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG, &(pNfapiMsg->rf_config.reference_signal_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG, &(pNfapiMsg->rf_config.tx_antenna_ports), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG, &(pNfapiMsg->rf_config.rx_antenna_ports), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG, &(pNfapiMsg->phich_config.phich_resource), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG, &(pNfapiMsg->phich_config.phich_duration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG, &(pNfapiMsg->phich_config.phich_power_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &(pNfapiMsg->sch_config.primary_synchronization_signal_epre_eprers), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &(pNfapiMsg->sch_config.secondary_synchronization_signal_epre_eprers), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG, &(pNfapiMsg->sch_config.physical_cell_id), ppWritePackedMsg, end ,&pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG, &(pNfapiMsg->prach_config.configuration_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG, &(pNfapiMsg->prach_config.root_sequence_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, &(pNfapiMsg->prach_config.zero_correlation_zone_configuration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG, &(pNfapiMsg->prach_config.high_speed_flag), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG, &(pNfapiMsg->prach_config.frequency_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG, &(pNfapiMsg->pusch_config.hopping_mode), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG, &(pNfapiMsg->pusch_config.hopping_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG, &(pNfapiMsg->pusch_config.number_of_subbands), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG, &(pNfapiMsg->pucch_config.delta_pucch_shift), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG, &(pNfapiMsg->pucch_config.n_cqi_rb), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUCCH_CONFIG_N_AN_CS_TAG, &(pNfapiMsg->pucch_config.n_an_cs), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG, &(pNfapiMsg->pucch_config.n1_pucch_an), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG, &(pNfapiMsg->srs_config.bandwidth_configuration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG, &(pNfapiMsg->srs_config.max_up_pts), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG, &(pNfapiMsg->srs_config.srs_subframe_configuration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG, &(pNfapiMsg->srs_config.srs_acknack_srs_simultaneous_transmission), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG, &(pNfapiMsg->uplink_reference_signal_config.uplink_rs_hopping), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG, &(pNfapiMsg->uplink_reference_signal_config.group_assignment), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG, &(pNfapiMsg->uplink_reference_signal_config.cyclic_shift_1_for_drms), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG, &(pNfapiMsg->tdd_frame_structure_config.subframe_assignment), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG, &(pNfapiMsg->tdd_frame_structure_config.special_subframe_patterns), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG, &(pNfapiMsg->l23_config.data_report_mode), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_L23_CONFIG_SFNSF_TAG, &(pNfapiMsg->l23_config.sfnsf), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && + pack_tlv(NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && + + pack_tlv(NFAPI_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && + pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && + + pack_tlv(NFAPI_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.dl_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + + pack_tlv(NFAPI_NFAPI_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value) && + + pack_tlv(NFAPI_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + + pack_tlv(NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &(pNfapiMsg->nfapi_config.max_transmit_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NFAPI_EARFCN_TAG, &(pNfapiMsg->nfapi_config.earfcn), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + + pack_tlv(NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_gsm_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && + pack_tlv(NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_umts_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && + pack_tlv(NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_lte_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && + pack_tlv(NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, &(pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); + +} + +static uint8_t pack_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_config_request_t *pNfapiMsg = (nfapi_config_request_t*)msg; + + return ( push8(pNfapiMsg->num_tlv, ppWritePackedMsg, end) && + + // Do we check the phy state and then just fill those sepecified, however + // we do not know the duplex mode, so just attempt to pack all and assumme + // that the callee has set the right tlvs + + pack_tlv(NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG, &(pNfapiMsg->subframe_config.duplex_mode), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG, &(pNfapiMsg->subframe_config.pcfich_power_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SUBFRAME_CONFIG_PB_TAG, &(pNfapiMsg->subframe_config.pb), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG, &(pNfapiMsg->subframe_config.dl_cyclic_prefix_type), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG, &(pNfapiMsg->subframe_config.ul_cyclic_prefix_type), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG, &(pNfapiMsg->rf_config.dl_channel_bandwidth), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG, &(pNfapiMsg->rf_config.ul_channel_bandwidth), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG, &(pNfapiMsg->rf_config.reference_signal_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG, &(pNfapiMsg->rf_config.tx_antenna_ports), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG, &(pNfapiMsg->rf_config.rx_antenna_ports), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG, &(pNfapiMsg->phich_config.phich_resource), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG, &(pNfapiMsg->phich_config.phich_duration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG, &(pNfapiMsg->phich_config.phich_power_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &(pNfapiMsg->sch_config.primary_synchronization_signal_epre_eprers), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &(pNfapiMsg->sch_config.secondary_synchronization_signal_epre_eprers), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG, &(pNfapiMsg->sch_config.physical_cell_id), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG, &(pNfapiMsg->prach_config.configuration_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG, &(pNfapiMsg->prach_config.root_sequence_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, &(pNfapiMsg->prach_config.zero_correlation_zone_configuration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG, &(pNfapiMsg->prach_config.high_speed_flag), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG, &(pNfapiMsg->prach_config.frequency_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG, &(pNfapiMsg->pusch_config.hopping_mode), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG, &(pNfapiMsg->pusch_config.hopping_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG, &(pNfapiMsg->pusch_config.number_of_subbands), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG, &(pNfapiMsg->pucch_config.delta_pucch_shift), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG, &(pNfapiMsg->pucch_config.n_cqi_rb), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUCCH_CONFIG_N_AN_CS_TAG, &(pNfapiMsg->pucch_config.n_an_cs), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG, &(pNfapiMsg->pucch_config.n1_pucch_an), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG, &(pNfapiMsg->srs_config.bandwidth_configuration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG, &(pNfapiMsg->srs_config.max_up_pts), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG, &(pNfapiMsg->srs_config.srs_subframe_configuration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG, &(pNfapiMsg->srs_config.srs_acknack_srs_simultaneous_transmission), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG, &(pNfapiMsg->uplink_reference_signal_config.uplink_rs_hopping), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG, &(pNfapiMsg->uplink_reference_signal_config.group_assignment), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG, &(pNfapiMsg->uplink_reference_signal_config.cyclic_shift_1_for_drms), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG, &(pNfapiMsg->laa_config.ed_threshold_lbt_pdsch), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG, &(pNfapiMsg->laa_config.ed_threshold_lbt_drs), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG, &(pNfapiMsg->laa_config.pd_threshold), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG, &(pNfapiMsg->laa_config.multi_carrier_type), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG, &(pNfapiMsg->laa_config.multi_carrier_tx), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG, &(pNfapiMsg->laa_config.multi_carrier_freeze), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG, &(pNfapiMsg->laa_config.tx_antenna_ports_drs), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG, &(pNfapiMsg->laa_config.tx_power_drs), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG, &(pNfapiMsg->emtc_config.pbch_repetitions_enable_r13), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG, &(pNfapiMsg->emtc_config.prach_catm_root_sequence_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, &(pNfapiMsg->emtc_config.prach_catm_zero_correlation_zone_configuration), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG, &(pNfapiMsg->emtc_config.prach_catm_high_speed_flag), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_0_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_0_configuration_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_0_frequency_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_0_starting_subframe_periodicity), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_0_hopping_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_0_hopping_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_1_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_1_configuration_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_1_frequency_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_1_starting_subframe_periodicity), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_1_hopping_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_1_hopping_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_2_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_2_configuration_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_2_frequency_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_2_starting_subframe_periodicity), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_2_hopping_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_2_hopping_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_3_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_3_configuration_index), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_3_frequency_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_3_starting_subframe_periodicity), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_3_hopping_enable), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG, &(pNfapiMsg->emtc_config.prach_ce_level_3_hopping_offset), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG, &(pNfapiMsg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG, &(pNfapiMsg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG, &(pNfapiMsg->tdd_frame_structure_config.subframe_assignment), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG, &(pNfapiMsg->tdd_frame_structure_config.special_subframe_patterns), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + pack_tlv(NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG, &(pNfapiMsg->l23_config.data_report_mode), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_L23_CONFIG_SFNSF_TAG, &(pNfapiMsg->l23_config.sfnsf), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + + pack_tlv(NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && + pack_tlv(NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && + pack_tlv(NFAPI_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && + pack_tlv(NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && + pack_tlv(NFAPI_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.dl_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + + pack_tlv(NFAPI_PHY_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value) && + + pack_tlv(NFAPI_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + + pack_tlv(NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &(pNfapiMsg->nfapi_config.max_transmit_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_NFAPI_EARFCN_TAG, &(pNfapiMsg->nfapi_config.earfcn), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + + + pack_tlv(NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_gsm_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && + pack_tlv(NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_umts_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && + pack_tlv(NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG, &(pNfapiMsg->nfapi_config.nmm_lte_frequency_bands), ppWritePackedMsg, end, &pack_nmm_frequency_bands_value) && + pack_tlv(NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, &(pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); +} + +static uint8_t pack_config_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_config_response_t *pNfapiMsg = (nfapi_config_response_t*)msg; + + return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); +} + +static uint8_t pack_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_start_request_t *pNfapiMsg = (nfapi_start_request_t*)msg; + return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); +} + +static uint8_t pack_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_start_response_t *pNfapiMsg = (nfapi_start_response_t*)msg; + + return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end ) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); +} + +static uint8_t pack_stop_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_stop_request_t *pNfapiMsg = (nfapi_stop_request_t*)msg; + return pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); +} + +static uint8_t pack_stop_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_stop_response_t *pNfapiMsg = (nfapi_stop_response_t*)msg; + + return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); +} + +static uint8_t pack_measurement_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_measurement_request_t *pNfapiMsg = (nfapi_measurement_request_t*)msg; + + return( pack_tlv(NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG, &(pNfapiMsg->dl_rs_tx_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG, &(pNfapiMsg->received_interference_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_tlv(NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG, &(pNfapiMsg->thermal_noise_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_recevied_interference_power_measurement_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_received_interference_power_measurement_t* value = (nfapi_received_interference_power_measurement_t*)tlv; + + return ( push16(value->number_of_resource_blocks, ppWritePackedMsg, end) && + pusharrays16(value->received_interference_power, NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS, value->number_of_resource_blocks, ppWritePackedMsg, end)); +} + +static uint8_t pack_measurement_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_measurement_response_t *pNfapiMsg = (nfapi_measurement_response_t*)msg; + + return( push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && + pack_tlv(NFAPI_MEASUREMENT_RESPONSE_DL_RS_POWER_MEASUREMENT_TAG, &(pNfapiMsg->dl_rs_tx_power_measurement), ppWritePackedMsg, end, &pack_int16_tlv_value) && + pack_tlv(NFAPI_MEASUREMENT_RESPONSE_RECEIVED_INTERFERENCE_POWER_MEASUREMENT_TAG, &(pNfapiMsg->received_interference_power_measurement), ppWritePackedMsg, end, &pack_recevied_interference_power_measurement_value) && + pack_tlv(NFAPI_MEASUREMENT_RESPONSE_THERMAL_NOISE_MEASUREMENT_TAG, &(pNfapiMsg->thermal_noise_power_measurement), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_p5_message_body(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + uint8_t result = 0; + // look for the specific message + switch (header->message_id) + { + case NFAPI_PNF_PARAM_REQUEST: + result = pack_pnf_param_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PNF_PARAM_RESPONSE: + result = pack_pnf_param_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PNF_CONFIG_REQUEST: + result = pack_pnf_config_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PNF_CONFIG_RESPONSE: + result = pack_pnf_config_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PNF_START_REQUEST: + result = pack_pnf_start_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PNF_START_RESPONSE: + result = pack_pnf_start_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PNF_STOP_REQUEST: + result = pack_pnf_stop_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PNF_STOP_RESPONSE: + result = pack_pnf_stop_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PARAM_REQUEST: + result = pack_param_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_PARAM_RESPONSE: + result = pack_param_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_CONFIG_REQUEST: + result = pack_config_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_CONFIG_RESPONSE: + result = pack_config_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_START_REQUEST: + result = pack_start_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_START_RESPONSE: + result = pack_start_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_STOP_REQUEST: + result = pack_stop_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_STOP_RESPONSE: + result = pack_stop_response(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_MEASUREMENT_REQUEST: + result = pack_measurement_request(header, ppWritePackedMsg, end, config); + break; + + case NFAPI_MEASUREMENT_RESPONSE: + result = pack_measurement_response(header, ppWritePackedMsg, end, config); + break; + + default: + { + if(header->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + header->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + if(config && config->pack_p4_p5_vendor_extension) + { + result = (config->pack_p4_p5_vendor_extension)(header, ppWritePackedMsg, end, config); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve ecoder provided\n", __FUNCTION__, header->message_id); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, header->message_id); + } + } + break; + } + + return result; +} + + +// helper function for message length calculation - +// takes the pointers to the start of message to end of message + +static uint32_t get_packed_msg_len(uintptr_t msgHead, uintptr_t msgEnd) +{ + if (msgEnd < msgHead) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "get_packed_msg_len: Error in pointers supplied %d, %d\n", msgHead, msgEnd); + return 0; + } + + return (msgEnd - msgHead); +} + +// Main pack function - public + +int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_p4_p5_message_header_t *pMessageHeader = pMessageBuf; + uint8_t *pWritePackedMessage = pPackedBuf; + uint8_t *pPackMessageEnd = pPackedBuf + packedBufLen; + uint8_t *pPackedLengthField = &pWritePackedMessage[4]; + uint32_t packedMsgLen; + uint16_t packedMsgLen16; + + if (pMessageBuf == NULL || pPackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 Pack supplied pointers are null\n"); + return -1; + } + + // pack the message + if(push16(pMessageHeader->phy_id, &pWritePackedMessage, pPackMessageEnd) && + push16(pMessageHeader->message_id, &pWritePackedMessage, pPackMessageEnd) && + push16(0/*pMessageHeader->message_length*/, &pWritePackedMessage, pPackMessageEnd) && + push16(pMessageHeader->spare, &pWritePackedMessage, pPackMessageEnd) && + pack_p5_message_body(pMessageHeader, &pWritePackedMessage, pPackMessageEnd, config)) + { + // check for a valid message length + packedMsgLen = get_packed_msg_len((uintptr_t)pPackedBuf, (uintptr_t)pWritePackedMessage); + if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen); + return -1; + } + else + { + packedMsgLen16 = (uint16_t)packedMsgLen; + } + + // Update the message length in the header + if(!push16(packedMsgLen16, &pPackedLengthField, pPackMessageEnd)) + return -1; + + // return the packed length + return (packedMsgLen); + } + else + { + // Failed to pack the meassage + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 Failed to pack message\n"); + return -1; + } + +} + + + +// Unpack routines +static uint8_t unpack_pnf_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_param_request_t *pNfapiMsg = (nfapi_pnf_param_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_pnf_param_general_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_param_general_t* value = (nfapi_pnf_param_general_t*)tlv; + + return( pull8(ppReadPackedMsg, &value->nfapi_sync_mode, end) && + pull8(ppReadPackedMsg, &value->location_mode, end) && + pull16(ppReadPackedMsg, &value->location_coordinates_length, end) && + pullarray8(ppReadPackedMsg, value->location_coordinates, NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH, value->location_coordinates_length, end) && + pull32(ppReadPackedMsg, &value->dl_config_timing, end) && + pull32(ppReadPackedMsg, &value->tx_timing, end) && + pull32(ppReadPackedMsg, &value->ul_config_timing, end) && + pull32(ppReadPackedMsg, &value->hi_dci0_timing, end) && + pull16(ppReadPackedMsg, &value->maximum_number_phys, end) && + pull16(ppReadPackedMsg, &value->maximum_total_bandwidth, end) && + pull8(ppReadPackedMsg, &value->maximum_total_number_dl_layers, end) && + pull8(ppReadPackedMsg, &value->maximum_total_number_ul_layers, end) && + pull8(ppReadPackedMsg, &value->shared_bands, end) && + pull8(ppReadPackedMsg, &value->shared_pa, end) && + pulls16(ppReadPackedMsg, &value->maximum_total_power, end) && + pullarray8(ppReadPackedMsg, value->oui, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH, end)); +} + +static uint8_t unpack_rf_config_info(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_rf_config_info_t* info = (nfapi_rf_config_info_t*)elem; + return pull16(ppReadPackedMsg, &info->rf_config_index, end); +} + +static uint8_t unpack_pnf_phy_info(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_info_t* phy = (nfapi_pnf_phy_info_t*)elem; + + return ( pull16(ppReadPackedMsg, &phy->phy_config_index, end) && + pull16(ppReadPackedMsg, &phy->number_of_rfs, end) && + unpackarray(ppReadPackedMsg, phy->rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rfs, end, &unpack_rf_config_info) && + pull16(ppReadPackedMsg, &phy->number_of_rf_exclusions, end) && + unpackarray(ppReadPackedMsg, phy->excluded_rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rf_exclusions, end, &unpack_rf_config_info) && + pull16(ppReadPackedMsg, &phy->downlink_channel_bandwidth_supported, end) && + pull16(ppReadPackedMsg, &phy->uplink_channel_bandwidth_supported, end) && + pull8(ppReadPackedMsg, &phy->number_of_dl_layers_supported, end) && + pull8(ppReadPackedMsg, &phy->number_of_ul_layers_supported, end) && + pull16(ppReadPackedMsg, &phy->maximum_3gpp_release_supported, end) && + pull8(ppReadPackedMsg, &phy->nmm_modes_supported, end)); +} + + +static uint8_t unpack_pnf_phy_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_t* value = (nfapi_pnf_phy_t*)tlv; + return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) && + unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_info)); +} + +static uint8_t unpack_pnf_rf_info(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_rf_info_t* rf = (nfapi_pnf_rf_info_t*)elem; + + return( pull16(ppReadPackedMsg, &rf->rf_config_index, end) && + pull16(ppReadPackedMsg, &rf->band, end) && + pulls16(ppReadPackedMsg, &rf->maximum_transmit_power, end) && + pulls16(ppReadPackedMsg, &rf->minimum_transmit_power, end) && + pull8(ppReadPackedMsg, &rf->number_of_antennas_suppported, end) && + pull32(ppReadPackedMsg, &rf->minimum_downlink_frequency, end) && + pull32(ppReadPackedMsg, &rf->maximum_downlink_frequency, end) && + pull32(ppReadPackedMsg, &rf->minimum_uplink_frequency, end) && + pull32(ppReadPackedMsg, &rf->maximum_uplink_frequency, end)); + +} +static uint8_t unpack_pnf_rf_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_rf_t* value = (nfapi_pnf_rf_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_of_rfs, end) && + unpackarray(ppReadPackedMsg, value->rf, sizeof(nfapi_pnf_rf_info_t), NFAPI_MAX_PNF_RF, value->number_of_rfs, end, &unpack_pnf_rf_info)); +} + +static uint8_t unpack_pnf_phy_rel10_info(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel10_info_t* phy = (nfapi_pnf_phy_rel10_info_t*)elem; + + return( pull16(ppReadPackedMsg, &phy->phy_config_index, end) && + pull16(ppReadPackedMsg, &phy->transmission_mode_7_supported, end) && + pull16(ppReadPackedMsg, &phy->transmission_mode_8_supported, end) && + pull16(ppReadPackedMsg, &phy->two_antenna_ports_for_pucch, end) && + pull16(ppReadPackedMsg, &phy->transmission_mode_9_supported, end) && + pull16(ppReadPackedMsg, &phy->simultaneous_pucch_pusch, end) && + pull16(ppReadPackedMsg, &phy->four_layer_tx_with_tm3_and_tm4, end)); + + +} +static uint8_t unpack_pnf_phy_rel10_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel10_t* value = (nfapi_pnf_phy_rel10_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) && + unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_rel10_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_rel10_info)); + +} + + +static uint8_t unpack_pnf_phy_rel11_info(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel11_info_t* phy = (nfapi_pnf_phy_rel11_info_t*)elem; + + return( pull16(ppReadPackedMsg, &phy->phy_config_index, end) && + pull16(ppReadPackedMsg, &phy->edpcch_supported, end) && + pull16(ppReadPackedMsg, &phy->multi_ack_csi_reporting, end ) && + pull16(ppReadPackedMsg, &phy->pucch_tx_diversity, end) && + pull16(ppReadPackedMsg, &phy->ul_comp_supported, end) && + pull16(ppReadPackedMsg, &phy->transmission_mode_5_supported, end)); +} + +static uint8_t unpack_pnf_phy_rel11_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel11_t* value = (nfapi_pnf_phy_rel11_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) && + unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_rel11_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_rel11_info)); + +} + +static uint8_t unpack_phy_phy_rel12_info(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel12_info_t* phy = (nfapi_pnf_phy_rel12_info_t*)elem; + + return( pull16(ppReadPackedMsg, &phy->phy_config_index, end) && + pull16(ppReadPackedMsg, &phy->csi_subframe_set, end) && + pull16(ppReadPackedMsg, &phy->enhanced_4tx_codebook, end) && + pull16(ppReadPackedMsg, &phy->drs_supported, end) && + pull16(ppReadPackedMsg, &phy->ul_64qam_supported, end) && + pull16(ppReadPackedMsg, &phy->transmission_mode_10_supported, end) && + pull16(ppReadPackedMsg, &phy->alternative_bts_indices, end)); +} + +static uint8_t unpack_pnf_phy_rel12_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel12_t* value = (nfapi_pnf_phy_rel12_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->number_of_phys, end) && + unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_rel12_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_phy_phy_rel12_info)); + +} + +static uint8_t unpack_pnf_phy_rel13_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_info_t* phy = (nfapi_pnf_phy_rel13_info_t*)elem; + + return( pull16(ppReadPackedMsg, &phy->phy_config_index, end) && + pull16(ppReadPackedMsg, &phy->pucch_format4_supported, end) && + pull16(ppReadPackedMsg, &phy->pucch_format5_supported, end) && + pull16(ppReadPackedMsg, &phy->more_than_5_ca_support, end) && + pull16(ppReadPackedMsg, &phy->laa_supported, end) && + pull16(ppReadPackedMsg, &phy->laa_ending_in_dwpts_supported, end) && + pull16(ppReadPackedMsg, &phy->laa_starting_in_second_slot_supported, end) && + pull16(ppReadPackedMsg, &phy->beamforming_supported, end) && + pull16(ppReadPackedMsg, &phy->csi_rs_enhancement_supported, end) && + pull16(ppReadPackedMsg, &phy->drms_enhancement_supported, end) && + pull16(ppReadPackedMsg, &phy->srs_enhancement_supported, end)); +} + +static uint8_t unpack_pnf_phy_rel13_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_t* value = (nfapi_pnf_phy_rel13_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) && + unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_rel13_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_rel13_info)); +} + +static uint8_t unpack_pnf_phy_rel13_nb_info_info(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_nb_iot_info_t* phy = (nfapi_pnf_phy_rel13_nb_iot_info_t*)elem; + + return( pull16(ppReadPackedMsg, &phy->phy_config_index, end) && + pull16(ppReadPackedMsg, &phy->number_of_rfs, end) && + unpackarray(ppReadPackedMsg, phy->rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rfs, end, &unpack_rf_config_info) && + pull16(ppReadPackedMsg, &phy->number_of_rf_exclusions, end) && + unpackarray(ppReadPackedMsg, phy->excluded_rf_config, sizeof(nfapi_rf_config_info_t), NFAPI_MAX_PNF_PHY_RF_CONFIG, phy->number_of_rf_exclusions, end, &unpack_rf_config_info) && + pull8(ppReadPackedMsg, &phy->number_of_dl_layers_supported, end) && + pull8(ppReadPackedMsg, &phy->number_of_ul_layers_supported, end) && + pull16(ppReadPackedMsg, &phy->maximum_3gpp_release_supported, end) && + pull8(ppReadPackedMsg, &phy->nmm_modes_supported, end)); +} + +static uint8_t unpack_pnf_phy_rel13_nb_iot_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rel13_nb_iot_t* value = (nfapi_pnf_phy_rel13_nb_iot_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_of_phys, end) && + unpackarray(ppReadPackedMsg, value->phy, sizeof(nfapi_pnf_phy_rel13_nb_iot_info_t), NFAPI_MAX_PNF_PHY, value->number_of_phys, end, &unpack_pnf_phy_rel13_nb_info_info)); +} + + + +static uint8_t unpack_pnf_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_param_response_t *pNfapiMsg = (nfapi_pnf_param_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_PNF_PARAM_GENERAL_TAG, &pNfapiMsg->pnf_param_general, &unpack_pnf_param_general_value}, + { NFAPI_PNF_PHY_TAG, &pNfapiMsg->pnf_phy, &unpack_pnf_phy_value}, + { NFAPI_PNF_RF_TAG, &pNfapiMsg->pnf_rf, &unpack_pnf_rf_value}, + { NFAPI_PNF_PHY_REL10_TAG, &pNfapiMsg->pnf_phy_rel10, &unpack_pnf_phy_rel10_value}, + { NFAPI_PNF_PHY_REL11_TAG, &pNfapiMsg->pnf_phy_rel11, &unpack_pnf_phy_rel11_value}, + { NFAPI_PNF_PHY_REL12_TAG, &pNfapiMsg->pnf_phy_rel12, &unpack_pnf_phy_rel12_value}, + { NFAPI_PNF_PHY_REL13_TAG, &pNfapiMsg->pnf_phy_rel13, &unpack_pnf_phy_rel13_value}, + { NFAPI_PNF_PHY_REL13_NB_IOT_TAG, &pNfapiMsg->pnf_phy_rel13_nb_iot, &unpack_pnf_phy_rel13_nb_iot_value}, + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_phy_rf_config_info(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_phy_rf_config_info_t* rf = (nfapi_phy_rf_config_info_t*)elem; + + return( pull16(ppReadPackedMsg, &rf->phy_id, end) && + pull16(ppReadPackedMsg, &rf->phy_config_index, end) && + pull16(ppReadPackedMsg, &rf->rf_config_index, end)); + +} + +static uint8_t unpack_pnf_phy_rf_config_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_pnf_phy_rf_config_t* value = (nfapi_pnf_phy_rf_config_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_phy_rf_config_info, end) && + unpackarray(ppReadPackedMsg, value->phy_rf_config, sizeof(nfapi_phy_rf_config_info_t), NFAPI_MAX_PHY_RF_INSTANCES, value->number_phy_rf_config_info, end, &unpack_phy_rf_config_info)); +} + +static uint8_t unpack_pnf_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_config_request_t *pNfapiMsg = (nfapi_pnf_config_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, &unpack_pnf_phy_rf_config_value}, + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension); +} + +static uint8_t unpack_pnf_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_config_response_t *pNfapiMsg = (nfapi_pnf_config_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); + +} + +static uint8_t unpack_pnf_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_start_request_t *pNfapiMsg = (nfapi_pnf_start_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_pnf_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_start_response_t *pNfapiMsg = (nfapi_pnf_start_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end ) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); +} + +static uint8_t unpack_pnf_stop_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_stop_request_t *pNfapiMsg = (nfapi_pnf_stop_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_pnf_stop_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_pnf_stop_response_t *pNfapiMsg = (nfapi_pnf_stop_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); + +} + +static uint8_t unpack_param_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_param_request_t *pNfapiMsg = (nfapi_param_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_param_response_t *pNfapiMsg = (nfapi_param_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_L1_STATUS_PHY_STATE_TAG, &pNfapiMsg->l1_status.phy_state, &unpack_uint16_tlv_value}, + + { NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG, &pNfapiMsg->phy_capabilities.dl_bandwidth_support, &unpack_uint16_tlv_value}, + { NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG, &pNfapiMsg->phy_capabilities.ul_bandwidth_support, &unpack_uint16_tlv_value}, + { NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG, &pNfapiMsg->phy_capabilities.dl_modulation_support, &unpack_uint16_tlv_value}, + { NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG, &pNfapiMsg->phy_capabilities.ul_modulation_support, &unpack_uint16_tlv_value}, + { NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG, &pNfapiMsg->phy_capabilities.phy_antenna_capability, &unpack_uint16_tlv_value}, + { NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG, &pNfapiMsg->phy_capabilities.release_capability, &unpack_uint16_tlv_value}, + { NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG, &pNfapiMsg->phy_capabilities.mbsfn_capability, &unpack_uint16_tlv_value}, + + { NFAPI_LAA_CAPABILITY_LAA_SUPPORT_TAG, &pNfapiMsg->laa_capability.laa_support, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CAPABILITY_PD_SENSING_LBT_SUPPORT_TAG, &pNfapiMsg->laa_capability.pd_sensing_lbt_support, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CAPABILITY_MULTI_CARRIER_LBT_SUPPORT_TAG, &pNfapiMsg->laa_capability.multi_carrier_lbt_support, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CAPABILITY_PARTIAL_SF_SUPPORT_TAG, &pNfapiMsg->laa_capability.partial_sf_support, &unpack_uint16_tlv_value}, + + { NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG, &pNfapiMsg->subframe_config.duplex_mode, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG, &pNfapiMsg->subframe_config.pcfich_power_offset, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_PB_TAG, &pNfapiMsg->subframe_config.pb, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG, &pNfapiMsg->subframe_config.dl_cyclic_prefix_type, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG, &pNfapiMsg->subframe_config.ul_cyclic_prefix_type, &unpack_uint16_tlv_value}, + + { NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG, &pNfapiMsg->rf_config.dl_channel_bandwidth, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG, &pNfapiMsg->rf_config.ul_channel_bandwidth, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG, &pNfapiMsg->rf_config.reference_signal_power, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG, &pNfapiMsg->rf_config.tx_antenna_ports, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG, &pNfapiMsg->rf_config.rx_antenna_ports, &unpack_uint16_tlv_value}, + + { NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG, &pNfapiMsg->phich_config.phich_resource, &unpack_uint16_tlv_value}, + { NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG, &pNfapiMsg->phich_config.phich_duration, &unpack_uint16_tlv_value}, + { NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG, &pNfapiMsg->phich_config.phich_power_offset, &unpack_uint16_tlv_value}, + + { NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &pNfapiMsg->sch_config.primary_synchronization_signal_epre_eprers, &unpack_uint16_tlv_value}, + { NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &pNfapiMsg->sch_config.secondary_synchronization_signal_epre_eprers, &unpack_uint16_tlv_value}, + { NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG, &pNfapiMsg->sch_config.physical_cell_id, &unpack_uint16_tlv_value}, + + { NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG, &pNfapiMsg->prach_config.configuration_index, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG, &pNfapiMsg->prach_config.root_sequence_index, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, &pNfapiMsg->prach_config.zero_correlation_zone_configuration, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG, &pNfapiMsg->prach_config.high_speed_flag, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG, &pNfapiMsg->prach_config.frequency_offset, &unpack_uint16_tlv_value}, + + { NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG, &pNfapiMsg->pusch_config.hopping_mode, &unpack_uint16_tlv_value}, + { NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG, &pNfapiMsg->pusch_config.hopping_offset, &unpack_uint16_tlv_value}, + { NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG, &pNfapiMsg->pusch_config.number_of_subbands, &unpack_uint16_tlv_value}, + + { NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG, &pNfapiMsg->pucch_config.delta_pucch_shift, &unpack_uint16_tlv_value}, + { NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG, &pNfapiMsg->pucch_config.n_cqi_rb, &unpack_uint16_tlv_value}, + { NFAPI_PUCCH_CONFIG_N_AN_CS_TAG, &pNfapiMsg->pucch_config.n_an_cs, &unpack_uint16_tlv_value}, + { NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG, &pNfapiMsg->pucch_config.n1_pucch_an, &unpack_uint16_tlv_value}, + + { NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG, &pNfapiMsg->srs_config.bandwidth_configuration, &unpack_uint16_tlv_value}, + { NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG, &pNfapiMsg->srs_config.max_up_pts, &unpack_uint16_tlv_value}, + { NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG, &pNfapiMsg->srs_config.srs_subframe_configuration, &unpack_uint16_tlv_value}, + { NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG, &pNfapiMsg->srs_config.srs_acknack_srs_simultaneous_transmission, &unpack_uint16_tlv_value}, + + { NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG, &pNfapiMsg->uplink_reference_signal_config.uplink_rs_hopping, &unpack_uint16_tlv_value}, + { NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG, &pNfapiMsg->uplink_reference_signal_config.group_assignment, &unpack_uint16_tlv_value}, + { NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG, &pNfapiMsg->uplink_reference_signal_config.cyclic_shift_1_for_drms, &unpack_uint16_tlv_value}, + + { NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG, &pNfapiMsg->tdd_frame_structure_config.subframe_assignment, &unpack_uint16_tlv_value}, + { NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG, &pNfapiMsg->tdd_frame_structure_config.special_subframe_patterns, &unpack_uint16_tlv_value}, + + { NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG, &pNfapiMsg->l23_config.data_report_mode, &unpack_uint16_tlv_value}, + { NFAPI_L23_CONFIG_SFNSF_TAG, &pNfapiMsg->l23_config.sfnsf, &unpack_uint16_tlv_value}, + + { NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv4, &unpack_ipv4_address_value}, + { NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv6, &unpack_ipv6_address_value}, + { NFAPI_NFAPI_P7_VNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_vnf_port, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv4, &unpack_ipv4_address_value}, + { NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv6, &unpack_ipv6_address_value}, + { NFAPI_NFAPI_P7_PNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_pnf_port, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.dl_ue_per_sf, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.ul_ue_per_sf, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_RF_BANDS_TAG, &pNfapiMsg->nfapi_config.rf_bands, &unpack_rf_bands_value}, + { NFAPI_NFAPI_TIMING_WINDOW_TAG, &pNfapiMsg->nfapi_config.timing_window, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_TIMING_INFO_MODE_TAG, &pNfapiMsg->nfapi_config.timing_info_mode, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG, &pNfapiMsg->nfapi_config.timing_info_period, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &pNfapiMsg->nfapi_config.max_transmit_power, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_EARFCN_TAG, &pNfapiMsg->nfapi_config.earfcn, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG, &pNfapiMsg->nfapi_config.nmm_gsm_frequency_bands, &unpack_nmm_frequency_bands_value}, + { NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG, &pNfapiMsg->nfapi_config.nmm_umts_frequency_bands, &unpack_nmm_frequency_bands_value}, + { NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG, &pNfapiMsg->nfapi_config.nmm_lte_frequency_bands, &unpack_nmm_frequency_bands_value}, + { NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, &pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported, &unpack_uint8_tlv_value}, + + }; + + return ( pull8(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + +} + +static uint8_t unpack_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_config_request_t *pNfapiMsg = (nfapi_config_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG, &pNfapiMsg->subframe_config.duplex_mode, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG, &pNfapiMsg->subframe_config.pcfich_power_offset, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_PB_TAG, &pNfapiMsg->subframe_config.pb, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG, &pNfapiMsg->subframe_config.dl_cyclic_prefix_type, &unpack_uint16_tlv_value}, + { NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG, &pNfapiMsg->subframe_config.ul_cyclic_prefix_type, &unpack_uint16_tlv_value}, + + { NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG, &pNfapiMsg->rf_config.dl_channel_bandwidth, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG, &pNfapiMsg->rf_config.ul_channel_bandwidth, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG, &pNfapiMsg->rf_config.reference_signal_power, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG, &pNfapiMsg->rf_config.tx_antenna_ports, &unpack_uint16_tlv_value}, + { NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG, &pNfapiMsg->rf_config.rx_antenna_ports, &unpack_uint16_tlv_value}, + + { NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG, &pNfapiMsg->phich_config.phich_resource, &unpack_uint16_tlv_value}, + { NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG, &pNfapiMsg->phich_config.phich_duration, &unpack_uint16_tlv_value}, + { NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG, &pNfapiMsg->phich_config.phich_power_offset, &unpack_uint16_tlv_value}, + + { NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &pNfapiMsg->sch_config.primary_synchronization_signal_epre_eprers, &unpack_uint16_tlv_value}, + { NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, &pNfapiMsg->sch_config.secondary_synchronization_signal_epre_eprers, &unpack_uint16_tlv_value}, + { NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG, &pNfapiMsg->sch_config.physical_cell_id, &unpack_uint16_tlv_value}, + + { NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG, &pNfapiMsg->prach_config.configuration_index, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG, &pNfapiMsg->prach_config.root_sequence_index, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, &pNfapiMsg->prach_config.zero_correlation_zone_configuration, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG, &pNfapiMsg->prach_config.high_speed_flag, &unpack_uint16_tlv_value}, + { NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG, &pNfapiMsg->prach_config.frequency_offset, &unpack_uint16_tlv_value}, + + { NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG, &pNfapiMsg->pusch_config.hopping_mode, &unpack_uint16_tlv_value}, + { NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG, &pNfapiMsg->pusch_config.hopping_offset, &unpack_uint16_tlv_value}, + { NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG, &pNfapiMsg->pusch_config.number_of_subbands, &unpack_uint16_tlv_value}, + + { NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG, &pNfapiMsg->pucch_config.delta_pucch_shift, &unpack_uint16_tlv_value}, + { NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG, &pNfapiMsg->pucch_config.n_cqi_rb, &unpack_uint16_tlv_value}, + { NFAPI_PUCCH_CONFIG_N_AN_CS_TAG, &pNfapiMsg->pucch_config.n_an_cs, &unpack_uint16_tlv_value}, + { NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG, &pNfapiMsg->pucch_config.n1_pucch_an, &unpack_uint16_tlv_value}, + + { NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG, &pNfapiMsg->srs_config.bandwidth_configuration, &unpack_uint16_tlv_value}, + { NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG, &pNfapiMsg->srs_config.max_up_pts, &unpack_uint16_tlv_value}, + { NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG, &pNfapiMsg->srs_config.srs_subframe_configuration, &unpack_uint16_tlv_value}, + { NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG, &pNfapiMsg->srs_config.srs_acknack_srs_simultaneous_transmission, &unpack_uint16_tlv_value}, + + { NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG, &pNfapiMsg->uplink_reference_signal_config.uplink_rs_hopping, &unpack_uint16_tlv_value}, + { NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG, &pNfapiMsg->uplink_reference_signal_config.group_assignment, &unpack_uint16_tlv_value}, + { NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG, &pNfapiMsg->uplink_reference_signal_config.cyclic_shift_1_for_drms, &unpack_uint16_tlv_value}, + + + { NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG, &pNfapiMsg->laa_config.ed_threshold_lbt_pdsch, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG, &pNfapiMsg->laa_config.ed_threshold_lbt_drs, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG, &pNfapiMsg->laa_config.pd_threshold, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG, &pNfapiMsg->laa_config.multi_carrier_type, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG, &pNfapiMsg->laa_config.multi_carrier_tx, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG, &pNfapiMsg->laa_config.multi_carrier_freeze, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG, &pNfapiMsg->laa_config.tx_antenna_ports_drs, &unpack_uint16_tlv_value}, + { NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG, &pNfapiMsg->laa_config.tx_power_drs, &unpack_uint16_tlv_value}, + + { NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG, &pNfapiMsg->emtc_config.pbch_repetitions_enable_r13, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG, &pNfapiMsg->emtc_config.prach_catm_root_sequence_index, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, &pNfapiMsg->emtc_config.prach_catm_zero_correlation_zone_configuration, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG, &pNfapiMsg->emtc_config.prach_catm_high_speed_flag, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_0_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG, &pNfapiMsg->emtc_config.prach_ce_level_0_configuration_index, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_0_frequency_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &pNfapiMsg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG, &pNfapiMsg->emtc_config.prach_ce_level_0_starting_subframe_periodicity, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_0_hopping_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_0_hopping_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_1_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG, &pNfapiMsg->emtc_config.prach_ce_level_1_configuration_index, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_1_frequency_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &pNfapiMsg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG, &pNfapiMsg->emtc_config.prach_ce_level_1_starting_subframe_periodicity, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_1_hopping_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_1_hopping_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_2_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG, &pNfapiMsg->emtc_config.prach_ce_level_2_configuration_index, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_2_frequency_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &pNfapiMsg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG, &pNfapiMsg->emtc_config.prach_ce_level_2_starting_subframe_periodicity, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_2_hopping_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_2_hopping_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_3_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG, &pNfapiMsg->emtc_config.prach_ce_level_3_configuration_index, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_3_frequency_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, &pNfapiMsg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG, &pNfapiMsg->emtc_config.prach_ce_level_3_starting_subframe_periodicity, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG, &pNfapiMsg->emtc_config.prach_ce_level_3_hopping_enable, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG, &pNfapiMsg->emtc_config.prach_ce_level_3_hopping_offset, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG, &pNfapiMsg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea, &unpack_uint16_tlv_value}, + { NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG, &pNfapiMsg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb, &unpack_uint16_tlv_value}, + + { NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG, &pNfapiMsg->tdd_frame_structure_config.subframe_assignment, &unpack_uint16_tlv_value}, + { NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG, &pNfapiMsg->tdd_frame_structure_config.special_subframe_patterns, &unpack_uint16_tlv_value}, + + { NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG, &pNfapiMsg->l23_config.data_report_mode, &unpack_uint16_tlv_value}, + { NFAPI_L23_CONFIG_SFNSF_TAG, &pNfapiMsg->l23_config.sfnsf, &unpack_uint16_tlv_value}, + + { NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv4, &unpack_ipv4_address_value}, + { NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_vnf_address_ipv6, &unpack_ipv6_address_value}, + { NFAPI_NFAPI_P7_VNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_vnf_port, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv4, &unpack_ipv4_address_value}, + { NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv6, &unpack_ipv6_address_value}, + { NFAPI_NFAPI_P7_PNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_pnf_port, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.dl_ue_per_sf, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.ul_ue_per_sf, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_RF_BANDS_TAG, &pNfapiMsg->nfapi_config.rf_bands, &unpack_rf_bands_value}, + { NFAPI_NFAPI_TIMING_WINDOW_TAG, &pNfapiMsg->nfapi_config.timing_window, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_TIMING_INFO_MODE_TAG, &pNfapiMsg->nfapi_config.timing_info_mode, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG, &pNfapiMsg->nfapi_config.timing_info_period, &unpack_uint8_tlv_value}, + { NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &pNfapiMsg->nfapi_config.max_transmit_power, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_EARFCN_TAG, &pNfapiMsg->nfapi_config.earfcn, &unpack_uint16_tlv_value}, + { NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG, &pNfapiMsg->nfapi_config.nmm_gsm_frequency_bands, &unpack_nmm_frequency_bands_value}, + { NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG, &pNfapiMsg->nfapi_config.nmm_umts_frequency_bands, &unpack_nmm_frequency_bands_value}, + { NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG, &pNfapiMsg->nfapi_config.nmm_lte_frequency_bands, &unpack_nmm_frequency_bands_value}, + { NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, &pNfapiMsg->nfapi_config.nmm_uplink_rssi_supported, &unpack_uint8_tlv_value}, + + }; + + return ( pull8(ppReadPackedMsg, &pNfapiMsg->num_tlv, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + +} + +static uint8_t unpack_config_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_config_response_t *pNfapiMsg = (nfapi_config_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); +} + +static uint8_t unpack_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_start_request_t *pNfapiMsg = (nfapi_start_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_start_response_t *pNfapiMsg = (nfapi_start_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); + +} + +static uint8_t unpack_stop_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_stop_request_t *pNfapiMsg = (nfapi_stop_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_stop_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_stop_response_t *pNfapiMsg = (nfapi_stop_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension))); + +} +static uint8_t unpack_measurement_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_measurement_request_t *pNfapiMsg = (nfapi_measurement_request_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG, &pNfapiMsg->dl_rs_tx_power, &unpack_uint16_tlv_value}, + { NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG, &pNfapiMsg->received_interference_power, &unpack_uint16_tlv_value}, + { NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG, &pNfapiMsg->thermal_noise_power, &unpack_uint16_tlv_value}, + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &(pNfapiMsg->vendor_extension)); + +} + +static uint8_t unpack_received_interference_power_measurement_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_received_interference_power_measurement_t* value = (nfapi_received_interference_power_measurement_t*)tlv; + + return ( pull16(ppReadPackedMsg, &value->number_of_resource_blocks, end) && + pullarrays16(ppReadPackedMsg, value->received_interference_power, NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS, value->number_of_resource_blocks, end)); +} + + +static uint8_t unpack_measurement_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_measurement_response_t *pNfapiMsg = (nfapi_measurement_response_t*)msg; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_MEASUREMENT_RESPONSE_DL_RS_POWER_MEASUREMENT_TAG, &pNfapiMsg->dl_rs_tx_power_measurement, &unpack_int16_tlv_value}, + { NFAPI_MEASUREMENT_RESPONSE_RECEIVED_INTERFERENCE_POWER_MEASUREMENT_TAG, &pNfapiMsg->received_interference_power_measurement, &unpack_received_interference_power_measurement_value}, + { NFAPI_MEASUREMENT_RESPONSE_THERMAL_NOISE_MEASUREMENT_TAG, &pNfapiMsg->thermal_noise_power_measurement, &unpack_int16_tlv_value}, + }; + + return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + +} + +// unpack length check + +static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen) +{ + int retLen = 0; + + switch (msgId) + { + case NFAPI_PNF_PARAM_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_pnf_param_request_t)) + retLen = sizeof(nfapi_pnf_param_request_t); + break; + + case NFAPI_PNF_PARAM_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_pnf_param_response_t)) + retLen = sizeof(nfapi_pnf_param_response_t); + break; + + case NFAPI_PNF_CONFIG_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_pnf_config_request_t)) + retLen = sizeof(nfapi_pnf_config_request_t); + break; + + case NFAPI_PNF_CONFIG_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_pnf_config_response_t)) + retLen = sizeof(nfapi_pnf_config_response_t); + break; + + case NFAPI_PNF_START_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_pnf_start_request_t)) + retLen = sizeof(nfapi_pnf_start_request_t); + break; + + case NFAPI_PNF_START_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_pnf_start_response_t)) + retLen = sizeof(nfapi_pnf_start_response_t); + break; + + case NFAPI_PNF_STOP_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_pnf_stop_request_t)) + retLen = sizeof(nfapi_pnf_stop_request_t); + break; + + case NFAPI_PNF_STOP_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_pnf_stop_response_t)) + retLen = sizeof(nfapi_pnf_stop_response_t); + break; + + case NFAPI_PARAM_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_param_request_t)) + retLen = sizeof(nfapi_param_request_t); + break; + + case NFAPI_PARAM_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_param_response_t)) + retLen = sizeof(nfapi_param_response_t); + break; + + case NFAPI_CONFIG_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_config_request_t)) + retLen = sizeof(nfapi_config_request_t); + break; + + case NFAPI_CONFIG_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_config_response_t)) + retLen = sizeof(nfapi_config_response_t); + break; + + case NFAPI_START_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_start_request_t)) + retLen = sizeof(nfapi_start_request_t); + break; + + case NFAPI_START_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_start_response_t)) + retLen = sizeof(nfapi_start_response_t); + break; + + case NFAPI_STOP_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_stop_request_t)) + retLen = sizeof(nfapi_stop_request_t); + break; + + case NFAPI_STOP_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_stop_response_t)) + retLen = sizeof(nfapi_stop_response_t); + break; + + case NFAPI_MEASUREMENT_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_measurement_request_t)) + retLen = sizeof(nfapi_measurement_request_t); + break; + + case NFAPI_MEASUREMENT_RESPONSE: + if (unpackedBufLen >= sizeof(nfapi_measurement_response_t)) + retLen = sizeof(nfapi_measurement_response_t); + break; + + default: + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s Unknown message ID %d\n", __FUNCTION__, msgId); + break; + } + + return retLen; +} + + +// Main unpack functions - public + +int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf; + uint8_t *pReadPackedMessage = pMessageBuf; + uint8_t *end = pMessageBuf + messageBufLen; + + if (pMessageBuf == NULL || pUnpackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 header unpack supplied pointers are null\n"); + return -1; + } + + if (messageBufLen < NFAPI_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p4_p5_message_header_t)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 header unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen); + return -1; + } + + // process the header + return ( pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) && + pull16(&pReadPackedMessage, &pMessageHeader->spare, end) ); + +} + +int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config) +{ + nfapi_p4_p5_message_header_t *pMessageHeader = pUnpackedBuf; + uint8_t *pReadPackedMessage = pMessageBuf; + uint8_t *end = pMessageBuf + messageBufLen; + + if (pMessageBuf == NULL || pUnpackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 unpack supplied pointers are null\n"); + return -1; + } + + if (messageBufLen < NFAPI_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p4_p5_message_header_t)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P5 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen); + return -1; + } + + // clean the supplied buffer for - tag value blanking + (void)memset(pUnpackedBuf, 0, unpackedBufLen); + + // process the header + if( !(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end ) && + pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) && + pull16(&pReadPackedMessage, &pMessageHeader->spare, end))) + { + // failed to read the header + return -1; + } + + int result = -1; + + + if(check_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0) + { + // the unpack buffer is not big enough for the struct + return -1; + } + + // look for the specific message + switch (pMessageHeader->message_id) + { + case NFAPI_PNF_PARAM_REQUEST: + result = unpack_pnf_param_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PNF_PARAM_RESPONSE: + result = unpack_pnf_param_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PNF_CONFIG_REQUEST: + result = unpack_pnf_config_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PNF_CONFIG_RESPONSE: + result = unpack_pnf_config_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PNF_START_REQUEST: + result = unpack_pnf_start_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PNF_START_RESPONSE: + result = unpack_pnf_start_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PNF_STOP_REQUEST: + result = unpack_pnf_stop_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PNF_STOP_RESPONSE: + result = unpack_pnf_stop_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PARAM_REQUEST: + result = unpack_param_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_PARAM_RESPONSE: + result = unpack_param_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_CONFIG_REQUEST: + result = unpack_config_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_CONFIG_RESPONSE: + result = unpack_config_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_START_REQUEST: + result = unpack_start_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_START_RESPONSE: + result = unpack_start_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_STOP_REQUEST: + result = unpack_stop_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_STOP_RESPONSE: + result = unpack_stop_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_MEASUREMENT_REQUEST: + result = unpack_measurement_request(&pReadPackedMessage, end, pMessageHeader, config); + break; + + case NFAPI_MEASUREMENT_RESPONSE: + result = unpack_measurement_response(&pReadPackedMessage, end, pMessageHeader, config); + break; + + default: + if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + if(config && config->unpack_p4_p5_vendor_extension) + { + result = (config->unpack_p4_p5_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve decoder provided\n", __FUNCTION__, pMessageHeader->message_id); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown P5 message ID %d\n", __FUNCTION__, pMessageHeader->message_id); + } + break; + } + + return result; +} + diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c new file mode 100644 index 0000000000000000000000000000000000000000..3754fe379fef576b75d2ea026f1a4c35007bd807 --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -0,0 +1,6185 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <assert.h> +#include <signal.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <zlib.h> +#include <sched.h> +#include <time.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <pthread.h> +#include <stdint.h> + +#include <nfapi_interface.h> +#include <nfapi.h> +#include <debug.h> + +extern int nfapi_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t **ppReadPackedMsg, void* user_data); +extern int nfapi_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t **ppWritePackedMsg, void* user_data); + +uint32_t nfapi_calculate_checksum(uint8_t* buffer, uint16_t len) +{ + uint32_t chksum = 0; + // calcaulte upto the checksum + chksum = crc32(chksum, buffer, 8); + + // skip the checksum + uint8_t zeros[4] = {0, 0, 0, 0}; + chksum = crc32(chksum, zeros, 4); + + // continu with the rest of the mesage + chksum = crc32(chksum, &buffer[NFAPI_P7_HEADER_LENGTH], len - NFAPI_P7_HEADER_LENGTH); + + // return the inverse + return ~(chksum); +} + +int nfapi_p7_update_checksum(uint8_t* buffer, uint32_t len) +{ + uint32_t checksum = nfapi_calculate_checksum(buffer, len); + + uint8_t* p_write = &buffer[8]; + return (push32(checksum, &p_write, buffer + len) > 0 ? 0 : -1); +} + +int nfapi_p7_update_transmit_timestamp(uint8_t* buffer, uint32_t timestamp) +{ + uint8_t* p_write = &buffer[12]; + return (push32(timestamp, &p_write, buffer + 16) > 0 ? 0 : -1); +} + +uint32_t nfapi_p7_calculate_checksum(uint8_t* buffer, uint32_t len) +{ + return nfapi_calculate_checksum(buffer, len); +} + +void* nfapi_p7_allocate(size_t size, nfapi_p7_codec_config_t* config) +{ + if(size == 0) + return 0; + + if(config && config->allocate) + { + return (config->allocate)(size); + } + else + { + return calloc(1, size); + } +} + +void nfapi_p7_deallocate(void* ptr, nfapi_p7_codec_config_t* config) +{ + if(ptr == NULL) + return; + + if(config && config->deallocate) + { + return (config->deallocate)(ptr); + } + else + { + return free(ptr); + } +} +// Pack routines + + +static uint8_t pack_dl_config_dci_dl_pdu_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel8_t* value = (nfapi_dl_config_dci_dl_pdu_rel8_t*)tlv; + + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() dci_format:%u\n", __FUNCTION__, value->dci_format); + + return ( push8(value->dci_format, ppWritePackedMsg, end) && + push8(value->cce_idx, ppWritePackedMsg, end) && + push8(value->aggregation_level, ppWritePackedMsg, end) && + push16(value->rnti, ppWritePackedMsg, end) && + push8(value->resource_allocation_type, ppWritePackedMsg, end) && + push8(value->virtual_resource_block_assignment_flag, ppWritePackedMsg, end) && + push32(value->resource_block_coding, ppWritePackedMsg, end) && + push8(value->mcs_1, ppWritePackedMsg, end) && + push8(value->redundancy_version_1, ppWritePackedMsg, end) && + push8(value->new_data_indicator_1, ppWritePackedMsg, end) && + push8(value->transport_block_to_codeword_swap_flag, ppWritePackedMsg, end) && + push8(value->mcs_2, ppWritePackedMsg, end) && + push8(value->redundancy_version_2, ppWritePackedMsg, end) && + push8(value->new_data_indicator_2, ppWritePackedMsg, end) && + push8(value->harq_process, ppWritePackedMsg, end) && + push8(value->tpmi, ppWritePackedMsg, end) && + push8(value->pmi, ppWritePackedMsg, end) && + push8(value->precoding_information, ppWritePackedMsg, end) && + push8(value->tpc, ppWritePackedMsg, end) && + push8(value->downlink_assignment_index, ppWritePackedMsg, end) && + push8(value->ngap, ppWritePackedMsg, end) && + push8(value->transport_block_size_index, ppWritePackedMsg, end) && + push8(value->downlink_power_offset, ppWritePackedMsg, end) && + push8(value->allocate_prach_flag, ppWritePackedMsg, end) && + push8(value->preamble_index, ppWritePackedMsg, end) && + push8(value->prach_mask_index, ppWritePackedMsg, end) && + push8(value->rnti_type, ppWritePackedMsg, end) && + push16(value->transmission_power, ppWritePackedMsg, end)); +} + +static uint8_t pack_dl_config_dci_dl_pdu_rel9_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel9_t* value = (nfapi_dl_config_dci_dl_pdu_rel9_t*)tlv; + + return( push8(value->mcch_flag, ppWritePackedMsg, end) && + push8(value->mcch_change_notification, ppWritePackedMsg, end) && + push8(value->scrambling_identity, ppWritePackedMsg, end)); +} + +static uint8_t pack_dl_config_dci_dl_pdu_rel10_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel10_t* value = (nfapi_dl_config_dci_dl_pdu_rel10_t*)tlv; + + return ( push8(value->cross_carrier_scheduling_flag, ppWritePackedMsg, end) && + push8(value->carrier_indicator, ppWritePackedMsg, end) && + push8(value->srs_flag, ppWritePackedMsg, end) && + push8(value->srs_request, ppWritePackedMsg, end) && + push8(value->antenna_ports_scrambling_and_layers, ppWritePackedMsg, end) && + push8(value->total_dci_length_including_padding, ppWritePackedMsg, end) && + push8(value->n_dl_rb, ppWritePackedMsg, end)); +} + +static uint8_t pack_dl_config_dci_dl_pdu_rel11_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel11_t* value = (nfapi_dl_config_dci_dl_pdu_rel11_t*)tlv; + + return ( push8(value->harq_ack_resource_offset, ppWritePackedMsg, end) && + push8(value->pdsch_re_mapping_quasi_co_location_indicator, ppWritePackedMsg, end)); +} + +static uint8_t pack_dl_config_dci_dl_pdu_rel12_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel12_t* value = (nfapi_dl_config_dci_dl_pdu_rel12_t*)tlv; + + return ( push8(value->primary_cell_type, ppWritePackedMsg, end) && + push8(value->ul_dl_configuration_flag, ppWritePackedMsg, end) && + push8(value->number_ul_dl_configurations, ppWritePackedMsg, end) && + pusharray8(value->ul_dl_configuration_indication, NFAPI_MAX_UL_DL_CONFIGURATIONS, value->number_ul_dl_configurations, ppWritePackedMsg, end)); +} + +static uint8_t pack_tpm_value(nfapi_dl_config_dci_dl_tpm_t* value, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + if (!( push8(value->num_prb_per_subband, ppWritePackedMsg, end) && + push8(value->number_of_subbands, ppWritePackedMsg, end) && + push8(value->num_antennas, ppWritePackedMsg, end))) + return 0; + + uint8_t idx = 0; + for(idx = 0; idx < value->number_of_subbands; ++idx) + { + nfapi_dl_config_dci_dl_tpm_subband_info_t* subband_info = &(value->subband_info[idx]); + + if(!(push8(subband_info->subband_index, ppWritePackedMsg, end) && + push8(subband_info->scheduled_ues, ppWritePackedMsg, end))) + return 0; + + + uint8_t antenna_idx = 0; + uint8_t scheduled_ue_idx = 0; + + for(antenna_idx = 0; antenna_idx < value->num_antennas; ++antenna_idx) + { + for(scheduled_ue_idx = 0; scheduled_ue_idx < subband_info->scheduled_ues; ++scheduled_ue_idx) + { + if(!push16(subband_info->precoding_value[antenna_idx][scheduled_ue_idx], ppWritePackedMsg, end)) + return 0; + } + } + + } + + + return 1; + +} + +static uint8_t pack_dl_config_dci_dl_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel13_t* value = (nfapi_dl_config_dci_dl_pdu_rel13_t*)tlv; + + return( push8(value->laa_end_partial_sf_flag, ppWritePackedMsg, end) && + push8(value->laa_end_partial_sf_configuration, ppWritePackedMsg, end) && + push8(value->initial_lbt_sf, ppWritePackedMsg, end) && + push8(value->codebook_size_determination, ppWritePackedMsg, end) && + push8(value->drms_table_flag, ppWritePackedMsg, end) && + push8(value->tpm_struct_flag, ppWritePackedMsg, end) && + (value->tpm_struct_flag == 1 ? pack_tpm_value(&(value->tpm), ppWritePackedMsg, end) : 1)); +} + +static uint8_t pack_dl_config_bch_pdu_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_bch_pdu_rel8_t* value = (nfapi_dl_config_bch_pdu_rel8_t*)tlv; + + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s()\n", __FUNCTION__); + + return( push16(value->length, ppWritePackedMsg, end) && + push16(value->pdu_index, ppWritePackedMsg, end) && + push16(value->transmission_power, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_mch_pdu_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_mch_pdu_rel8_t* value = (nfapi_dl_config_mch_pdu_rel8_t*)tlv; + + return ( push16(value->length, ppWritePackedMsg, end) && + push16(value->pdu_index, ppWritePackedMsg, end) && + push16(value->rnti, ppWritePackedMsg, end) && + push8(value->resource_allocation_type, ppWritePackedMsg, end) && + push32(value->resource_block_coding, ppWritePackedMsg, end) && + push8(value->modulation, ppWritePackedMsg, end) && + push16(value->transmission_power, ppWritePackedMsg, end) && + push16(value->mbsfn_area_id, ppWritePackedMsg, end)); +} + +static uint8_t pack_bf_vector_info(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_bf_vector_t* bf = (nfapi_bf_vector_t*)elem; + + return ( push8(bf->subband_index, ppWritePackedMsg, end) && + push8(bf->num_antennas, ppWritePackedMsg, end) && + pusharray16(bf->bf_value, NFAPI_MAX_NUM_ANTENNAS, bf->num_antennas, ppWritePackedMsg, end)); + + +} +static uint8_t pack_dl_config_dlsch_pdu_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel8_t* value = (nfapi_dl_config_dlsch_pdu_rel8_t*)tlv; + + return ( push16(value->length, ppWritePackedMsg, end) && + push16(value->pdu_index, ppWritePackedMsg, end) && + push16(value->rnti, ppWritePackedMsg, end) && + push8(value->resource_allocation_type, ppWritePackedMsg, end) && + push8(value->virtual_resource_block_assignment_flag, ppWritePackedMsg, end) && + push32(value->resource_block_coding, ppWritePackedMsg, end) && + push8(value->modulation, ppWritePackedMsg, end) && + push8(value->redundancy_version, ppWritePackedMsg, end) && + push8(value->transport_blocks, ppWritePackedMsg, end) && + push8(value->transport_block_to_codeword_swap_flag, ppWritePackedMsg, end) && + push8(value->transmission_scheme, ppWritePackedMsg, end) && + push8(value->number_of_layers, ppWritePackedMsg, end) && + push8(value->number_of_subbands, ppWritePackedMsg, end) && + pusharray8(value->codebook_index, NFAPI_MAX_NUM_SUBBANDS, value->number_of_subbands, ppWritePackedMsg, end) && + push8(value->ue_category_capacity, ppWritePackedMsg, end) && + push8(value->pa, ppWritePackedMsg, end) && + push8(value->delta_power_offset_index, ppWritePackedMsg, end) && + push8(value->ngap, ppWritePackedMsg, end) && + push8(value->nprb, ppWritePackedMsg, end) && + push8(value->transmission_mode, ppWritePackedMsg, end) && + push8(value->num_bf_prb_per_subband, ppWritePackedMsg, end) && + push8(value->num_bf_vector, ppWritePackedMsg, end) && + packarray(value->bf_vector, sizeof(nfapi_bf_vector_t), NFAPI_MAX_BF_VECTORS, value->num_bf_vector, ppWritePackedMsg, end, &pack_bf_vector_info)); + +} +static uint8_t pack_dl_config_dlsch_pdu_rel9_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel9_t* value = (nfapi_dl_config_dlsch_pdu_rel9_t*)tlv; + return ( push8(value->nscid, ppWritePackedMsg, end) ); +} +static uint8_t pack_dl_config_dlsch_pdu_rel10_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel10_t* value = (nfapi_dl_config_dlsch_pdu_rel10_t*)tlv; + + return ( push8(value->csi_rs_flag, ppWritePackedMsg, end) && + push8(value->csi_rs_resource_config_r10, ppWritePackedMsg, end) && + push16(value->csi_rs_zero_tx_power_resource_config_bitmap_r10, ppWritePackedMsg, end) && + push8(value->csi_rs_number_nzp_configuration, ppWritePackedMsg, end) && + pusharray8(value->csi_rs_resource_config, NFAPI_MAX_CSI_RS_RESOURCE_CONFIG, value->csi_rs_number_nzp_configuration, ppWritePackedMsg, end) && + push8(value->pdsch_start, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_dlsch_pdu_rel11_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel11_t* value = (nfapi_dl_config_dlsch_pdu_rel11_t*)tlv; + + return( push8(value->drms_config_flag, ppWritePackedMsg, end) && + push16(value->drms_scrambling, ppWritePackedMsg, end) && + push8(value->csi_config_flag, ppWritePackedMsg, end) && + push16(value->csi_scrambling, ppWritePackedMsg, end) && + push8(value->pdsch_re_mapping_flag, ppWritePackedMsg, end) && + push8(value->pdsch_re_mapping_atenna_ports, ppWritePackedMsg, end) && + push8(value->pdsch_re_mapping_freq_shift, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_dlsch_pdu_rel12_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel12_t* value = (nfapi_dl_config_dlsch_pdu_rel12_t*)tlv; + + return( push8(value->altcqi_table_r12, ppWritePackedMsg, end) && + push8(value->maxlayers, ppWritePackedMsg, end) && + push8(value->n_dl_harq, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_dlsch_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel13_t* value = (nfapi_dl_config_dlsch_pdu_rel13_t*)tlv; + + return( push8(value->dwpts_symbols, ppWritePackedMsg, end) && + push8(value->initial_lbt_sf, ppWritePackedMsg, end) && + push8(value->ue_type, ppWritePackedMsg, end) && + push8(value->pdsch_payload_type, ppWritePackedMsg, end) && + push16(value->initial_transmission_sf_io, ppWritePackedMsg, end) && + push8(value->drms_table_flag, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_pch_pdu_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_pch_pdu_rel8_t* value = (nfapi_dl_config_pch_pdu_rel8_t*)tlv; + + return( push16(value->length, ppWritePackedMsg, end) && + push16(value->pdu_index, ppWritePackedMsg, end) && + push16(value->p_rnti, ppWritePackedMsg, end) && + push8(value->resource_allocation_type, ppWritePackedMsg, end) && + push8(value->virtual_resource_block_assignment_flag, ppWritePackedMsg, end) && + push32(value->resource_block_coding, ppWritePackedMsg, end) && + push8(value->mcs, ppWritePackedMsg, end) && + push8(value->redundancy_version, ppWritePackedMsg, end) && + push8(value->number_of_transport_blocks, ppWritePackedMsg, end) && + push8(value->transport_block_to_codeword_swap_flag, ppWritePackedMsg, end) && + push8(value->transmission_scheme, ppWritePackedMsg, end) && + push8(value->number_of_layers, ppWritePackedMsg, end) && + push8(value->codebook_index, ppWritePackedMsg, end) && + push8(value->ue_category_capacity, ppWritePackedMsg, end) && + push8(value->pa, ppWritePackedMsg, end) && + push16(value->transmission_power, ppWritePackedMsg, end) && + push8(value->nprb, ppWritePackedMsg, end) && + push8(value->ngap, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_pch_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_pch_pdu_rel13_t* value = (nfapi_dl_config_pch_pdu_rel13_t*)tlv; + + return ( push8(value->ue_mode, ppWritePackedMsg, end) && + push16(value->initial_transmission_sf_io, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_prs_pdu_rel9_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_prs_pdu_rel9_t* value = (nfapi_dl_config_prs_pdu_rel9_t*)tlv; + + return( push16(value->transmission_power, ppWritePackedMsg, end) && + push8(value->prs_bandwidth, ppWritePackedMsg, end) && + push8(value->prs_cyclic_prefix_type, ppWritePackedMsg, end) && + push8(value->prs_muting, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_csi_rs_pdu_rel10_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_csi_rs_pdu_rel10_t* value = (nfapi_dl_config_csi_rs_pdu_rel10_t*)tlv; + + return( push8(value->csi_rs_antenna_port_count_r10, ppWritePackedMsg, end) && + push8(value->csi_rs_resource_config_r10, ppWritePackedMsg, end) && + push16(value->transmission_power, ppWritePackedMsg, end) && + push16(value->csi_rs_zero_tx_power_resource_config_bitmap_r10, ppWritePackedMsg, end) && + push8(value->csi_rs_number_of_nzp_configuration, ppWritePackedMsg, end) && + pusharray8(value->csi_rs_resource_config, NFAPI_MAX_CSI_RS_RESOURCE_CONFIG, value->csi_rs_number_of_nzp_configuration, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_csi_rs_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_csi_rs_pdu_rel13_t* value = (nfapi_dl_config_csi_rs_pdu_rel13_t*)tlv; + + if(!(push8(value->csi_rs_class, ppWritePackedMsg, end) && + push8(value->cdm_type, ppWritePackedMsg, end) && + push8(value->num_bf_vector, ppWritePackedMsg, end))) + { + return 0; + } + + uint16_t i; + for(i = 0; i < value->num_bf_vector; ++i) + { + if(!(push8(value->bf_vector[i].csi_rs_resource_index, ppWritePackedMsg, end) && + pusharray16(value->bf_vector[i].bf_value, NFAPI_MAX_ANTENNA_PORT_COUNT, NFAPI_MAX_ANTENNA_PORT_COUNT, ppWritePackedMsg, end))) + return 0; + } + + return 1; +} +static uint8_t pack_bf_vector(nfapi_bf_vector_t* vector, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( push8(vector->subband_index, ppWritePackedMsg, end) && + push8(vector->num_antennas, ppWritePackedMsg, end) && + pusharray16(vector->bf_value, NFAPI_MAX_NUM_ANTENNAS, vector->num_antennas, ppWritePackedMsg, end)); +} + +static uint8_t pack_dl_config_epdcch_parameters_rel11_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_epdcch_parameters_rel11_t* value = (nfapi_dl_config_epdcch_parameters_rel11_t*)tlv; + + return ( push8(value->epdcch_resource_assignment_flag, ppWritePackedMsg, end) && + push16(value->epdcch_id, ppWritePackedMsg, end) && + push8(value->epdcch_start_symbol, ppWritePackedMsg, end) && + push8(value->epdcch_num_prb, ppWritePackedMsg, end) && + pusharray8(value->epdcch_prb_index, NFAPI_MAX_EPDCCH_PRB, value->epdcch_num_prb, ppWritePackedMsg, end) && + pack_bf_vector(&value->bf_vector, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_epdcch_parameters_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_epdcch_parameters_rel13_t* value = (nfapi_dl_config_epdcch_parameters_rel13_t*)tlv; + + return (push8(value->dwpts_symbols, ppWritePackedMsg, end) && + push8(value->initial_lbt_sf, ppWritePackedMsg, end)); +} +static uint8_t pack_dl_config_mpdcch_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_mpdcch_pdu_rel13_t* value = (nfapi_dl_config_mpdcch_pdu_rel13_t*)tlv; + + return ( push8(value->mpdcch_narrow_band, ppWritePackedMsg, end) && + push8(value->number_of_prb_pairs, ppWritePackedMsg, end) && + push8(value->resource_block_assignment, ppWritePackedMsg, end) && + push8(value->mpdcch_tansmission_type, ppWritePackedMsg, end) && + push8(value->start_symbol, ppWritePackedMsg, end) && + push8(value->ecce_index, ppWritePackedMsg, end) && + push8(value->aggregation_level, ppWritePackedMsg, end) && + push8(value->rnti_type, ppWritePackedMsg, end) && + push16(value->rnti, ppWritePackedMsg, end) && + push8(value->ce_mode, ppWritePackedMsg, end) && + push16(value->drms_scrambling_init, ppWritePackedMsg, end) && + push16(value->initial_transmission_sf_io, ppWritePackedMsg, end) && + push16(value->transmission_power, ppWritePackedMsg, end) && + push8(value->dci_format, ppWritePackedMsg, end) && + push16(value->resource_block_coding, ppWritePackedMsg, end) && + push8(value->mcs, ppWritePackedMsg, end) && + push8(value->pdsch_reptition_levels, ppWritePackedMsg, end) && + push8(value->redundancy_version, ppWritePackedMsg, end) && + push8(value->new_data_indicator, ppWritePackedMsg, end) && + push8(value->harq_process, ppWritePackedMsg, end) && + push8(value->tpmi_length, ppWritePackedMsg, end) && + push8(value->tpmi, ppWritePackedMsg, end) && + push8(value->pmi_flag, ppWritePackedMsg, end) && + push8(value->pmi, ppWritePackedMsg, end) && + push8(value->harq_resource_offset, ppWritePackedMsg, end) && + push8(value->dci_subframe_repetition_number, ppWritePackedMsg, end) && + push8(value->tpc, ppWritePackedMsg, end) && + push8(value->downlink_assignment_index_length, ppWritePackedMsg, end) && + push8(value->downlink_assignment_index, ppWritePackedMsg, end) && + push8(value->allocate_prach_flag, ppWritePackedMsg, end) && + push8(value->preamble_index, ppWritePackedMsg, end) && + push8(value->prach_mask_index, ppWritePackedMsg, end) && + push8(value->starting_ce_level, ppWritePackedMsg, end) && + push8(value->srs_request, ppWritePackedMsg, end) && + push8(value->antenna_ports_and_scrambling_identity_flag, ppWritePackedMsg, end) && + push8(value->antenna_ports_and_scrambling_identity, ppWritePackedMsg, end) && + push8(value->frequency_hopping_enabled_flag, ppWritePackedMsg, end) && + push8(value->paging_direct_indication_differentiation_flag, ppWritePackedMsg, end) && + push8(value->direct_indication, ppWritePackedMsg, end) && + push8(value->total_dci_length_including_padding, ppWritePackedMsg, end) && + push8(value->number_of_tx_antenna_ports, ppWritePackedMsg, end) && + pusharray16(value->precoding_value, NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS, value->number_of_tx_antenna_ports, ppWritePackedMsg, end)); +} + + +static uint8_t pack_dl_config_nbch_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_nbch_pdu_rel13_t* value = (nfapi_dl_config_nbch_pdu_rel13_t*)tlv; + + return (push16(value->length, ppWritePackedMsg, end) && + push16(value->pdu_index, ppWritePackedMsg, end) && + push16(value->transmission_power, ppWritePackedMsg, end) && + push16(value->hyper_sfn_2_lsbs, ppWritePackedMsg, end)); +} + + +static uint8_t pack_dl_config_npdcch_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_npdcch_pdu_rel13_t* value = (nfapi_dl_config_npdcch_pdu_rel13_t*)tlv; + + return (push16(value->length, ppWritePackedMsg, end) && + push16(value->pdu_index, ppWritePackedMsg, end) && + push8(value->ncce_index, ppWritePackedMsg, end) && + push8(value->aggregation_level, ppWritePackedMsg, end) && + push8(value->start_symbol, ppWritePackedMsg, end) && + push8(value->rnti_type, ppWritePackedMsg, end) && + push16(value->rnti, ppWritePackedMsg, end) && + push8(value->scrambling_reinitialization_batch_index, ppWritePackedMsg, end) && + push8(value->nrs_antenna_ports_assumed_by_the_ue, ppWritePackedMsg, end) && + push8(value->dci_format, ppWritePackedMsg, end) && + push8(value->scheduling_delay, ppWritePackedMsg, end) && + push8(value->resource_assignment, ppWritePackedMsg, end) && + push8(value->repetition_number, ppWritePackedMsg, end) && + push8(value->mcs, ppWritePackedMsg, end) && + push8(value->new_data_indicator, ppWritePackedMsg, end) && + push8(value->harq_ack_resource, ppWritePackedMsg, end) && + push8(value->npdcch_order_indication, ppWritePackedMsg, end) && + push8(value->starting_number_of_nprach_repetitions, ppWritePackedMsg, end) && + push8(value->subcarrier_indication_of_nprach, ppWritePackedMsg, end) && + push8(value->paging_direct_indication_differentation_flag, ppWritePackedMsg, end) && + push8(value->direct_indication, ppWritePackedMsg, end) && + push8(value->dci_subframe_repetition_number, ppWritePackedMsg, end) && + push8(value->total_dci_length_including_padding, ppWritePackedMsg, end)); +} + +static uint8_t pack_dl_config_ndlsch_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_ndlsch_pdu_rel13_t* value = (nfapi_dl_config_ndlsch_pdu_rel13_t*)tlv; + + return (push16(value->length, ppWritePackedMsg, end) && + push16(value->pdu_index, ppWritePackedMsg, end) && + push8(value->start_symbol, ppWritePackedMsg, end) && + push8(value->rnti_type, ppWritePackedMsg, end) && + push16(value->rnti, ppWritePackedMsg, end) && + push16(value->resource_assignment, ppWritePackedMsg, end) && + push16(value->repetition_number, ppWritePackedMsg, end) && + push8(value->modulation, ppWritePackedMsg, end) && + push8(value->number_of_subframes_for_resource_assignment, ppWritePackedMsg, end) && + push8(value->scrambling_sequence_initialization_cinit, ppWritePackedMsg, end) && + push16(value->sf_idx, ppWritePackedMsg, end) && + push8(value->nrs_antenna_ports_assumed_by_the_ue, ppWritePackedMsg, end)); +} + +static uint8_t pack_dl_config_request_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_dl_config_request_body_t* value = (nfapi_dl_config_request_body_t*)tlv; + + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() dci:%u pdu:%u pdsch:%u rnti:%u pcfich:%u\n", __FUNCTION__, value->number_dci, value->number_pdu, value->number_pdsch_rnti, value->transmission_power_pcfich); + + if(!(push8(value->number_pdcch_ofdm_symbols, ppWritePackedMsg, end) && + push8(value->number_dci, ppWritePackedMsg, end) && + push16(value->number_pdu, ppWritePackedMsg, end) && + push8(value->number_pdsch_rnti, ppWritePackedMsg, end) && + push16(value->transmission_power_pcfich, ppWritePackedMsg, end))) + { + return 0; + } + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_pdu; + for(; i < total_number_of_pdus; ++i) + { + nfapi_dl_config_request_pdu_t* pdu = &(value->dl_config_pdu_list[i]); + + if(push8(pdu->pdu_type, ppWritePackedMsg, end) == 0) + return 0; + + // Put a 0 size in and then determine the size after the pdu + // has been writen and write the calculated size + uint8_t* pWritePackedMsgPduSize = *ppWritePackedMsg; + pdu->pdu_size = 0; + if(push8(pdu->pdu_size, ppWritePackedMsg, end) == 0) + return 0; + + switch(pdu->pdu_type) + { + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: + { + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE\n", __FUNCTION__); + + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel8, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel8_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel9, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel9_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel10, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel10_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel11, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel11_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel12, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel12_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel13_value))) + { + return 0; + } + } + break; + case NFAPI_DL_CONFIG_BCH_PDU_TYPE: + { + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() NFAPI_DL_CONFIG_BCH_PDU_TYPE\n", __FUNCTION__); + + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG, &pdu->bch_pdu.bch_pdu_rel8, ppWritePackedMsg, end, &pack_dl_config_bch_pdu_rel8_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_MCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG, &pdu->mch_pdu.mch_pdu_rel8, ppWritePackedMsg, end, &pack_dl_config_mch_pdu_rel8_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel8, ppWritePackedMsg, end, &pack_dl_config_dlsch_pdu_rel8_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel9, ppWritePackedMsg, end, &pack_dl_config_dlsch_pdu_rel9_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel10, ppWritePackedMsg, end, &pack_dl_config_dlsch_pdu_rel10_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel11, ppWritePackedMsg, end, &pack_dl_config_dlsch_pdu_rel11_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel12, ppWritePackedMsg, end, &pack_dl_config_dlsch_pdu_rel12_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_dlsch_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_PCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG, &pdu->pch_pdu.pch_pdu_rel8, ppWritePackedMsg, end, &pack_dl_config_pch_pdu_rel8_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG, &pdu->pch_pdu.pch_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_pch_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_PRS_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG, &pdu->prs_pdu.prs_pdu_rel9, ppWritePackedMsg, end, &pack_dl_config_prs_pdu_rel9_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG, &pdu->csi_rs_pdu.csi_rs_pdu_rel10, ppWritePackedMsg, end, &pack_dl_config_csi_rs_pdu_rel10_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG, &pdu->csi_rs_pdu.csi_rs_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_csi_rs_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel8, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel8_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel9, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel9_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel10, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel10_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel11, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel11_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel12, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel12_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_dci_dl_pdu_rel13_value) && + pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG, &pdu->epdcch_pdu.epdcch_params_rel11, ppWritePackedMsg, end, &pack_dl_config_epdcch_parameters_rel11_value) & + pack_tlv(NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG, &pdu->epdcch_pdu.epdcch_params_rel13, ppWritePackedMsg, end, &pack_dl_config_epdcch_parameters_rel13_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG, &pdu->mpdcch_pdu.mpdcch_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_mpdcch_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG, &pdu->nbch_pdu.nbch_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_nbch_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG, &pdu->npdcch_pdu.npdcch_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_npdcch_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG, &pdu->ndlsch_pdu.ndlsch_pdu_rel13, ppWritePackedMsg, end, &pack_dl_config_ndlsch_pdu_rel13_value))) + return 0; + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid pdu type %d \n", pdu->pdu_type ); + } + break; + }; + + // add 1 for the pdu_type. The delta will include the pdu_size + pdu->pdu_size = 1 + (*ppWritePackedMsg - pWritePackedMsgPduSize); + push8(pdu->pdu_size, &pWritePackedMsgPduSize, end); + } + + return 1; +} + +static uint8_t pack_dl_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_dl_config_request_t *pNfapiMsg = (nfapi_dl_config_request_t*)msg; + + //return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + //pack_tlv(NFAPI_DL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->dl_config_request_body, ppWritePackedMsg, end, &pack_dl_config_request_body_value) && + //pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); + { + uint8_t x = push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end); + uint8_t y = pack_tlv(NFAPI_DL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->dl_config_request_body, ppWritePackedMsg, end, &pack_dl_config_request_body_value); + uint8_t z = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); + + if (!x || !y || !z) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() NFAPI_DL_CONFIG_REQUEST x:%u y:%u z:%u \n", __FUNCTION__,x,y,z); + } + + return x && y && z; + } +} + +static uint8_t pack_ul_config_request_ulsch_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t * end) +{ + nfapi_ul_config_ulsch_pdu_rel8_t* ulsch_pdu_rel8 = (nfapi_ul_config_ulsch_pdu_rel8_t*)tlv; + + return( push32(ulsch_pdu_rel8->handle, ppWritePackedMsg, end) && + push16(ulsch_pdu_rel8->size, ppWritePackedMsg, end) && + push16(ulsch_pdu_rel8->rnti, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->resource_block_start, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->number_of_resource_blocks, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->modulation_type, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->cyclic_shift_2_for_drms, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->frequency_hopping_enabled_flag, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->frequency_hopping_bits, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->new_data_indication, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->redundancy_version, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->harq_process_number, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->ul_tx_mode, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->current_tx_nb, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel8->n_srs, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_ulsch_rel10_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_pdu_rel10_t* ulsch_pdu_rel10 = (nfapi_ul_config_ulsch_pdu_rel10_t*)tlv; + + return (push8(ulsch_pdu_rel10->resource_allocation_type, ppWritePackedMsg, end) && + push32(ulsch_pdu_rel10->resource_block_coding, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel10->transport_blocks, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel10->transmission_scheme, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel10->number_of_layers, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel10->codebook_index, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel10->disable_sequence_hopping_flag, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_ulsch_rel11_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_pdu_rel11_t* ulsch_pdu_rel11 = (nfapi_ul_config_ulsch_pdu_rel11_t*)tlv; + + return (push8(ulsch_pdu_rel11->virtual_cell_id_enabled_flag, ppWritePackedMsg, end) && + push16(ulsch_pdu_rel11->npusch_identity, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel11->dmrs_config_flag, ppWritePackedMsg, end) && + push16(ulsch_pdu_rel11->ndmrs_csh_identity, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_ulsch_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_pdu_rel13_t* ulsch_pdu_rel13 = (nfapi_ul_config_ulsch_pdu_rel13_t*)tlv; + + return (push8(ulsch_pdu_rel13->ue_type, ppWritePackedMsg, end) && + push16(ulsch_pdu_rel13->total_number_of_repetitions, ppWritePackedMsg, end) && + push16(ulsch_pdu_rel13->repetition_number, ppWritePackedMsg, end) && + push16(ulsch_pdu_rel13->initial_transmission_sf_io, ppWritePackedMsg, end) && + push8(ulsch_pdu_rel13->empty_symbols_due_to_re_tunning, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_ulsch_pdu(nfapi_ul_config_ulsch_pdu* ulsch_pdu, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( pack_tlv(NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG, &ulsch_pdu->ulsch_pdu_rel8, ppWritePackedMsg, end, &pack_ul_config_request_ulsch_rel8_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG, &ulsch_pdu->ulsch_pdu_rel10, ppWritePackedMsg, end, &pack_ul_config_request_ulsch_rel10_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG, &ulsch_pdu->ulsch_pdu_rel11, ppWritePackedMsg, end, &pack_ul_config_request_ulsch_rel11_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG, &ulsch_pdu->ulsch_pdu_rel13, ppWritePackedMsg, end, &pack_ul_config_request_ulsch_rel13_value)); +} + +static uint8_t pack_ul_config_request_cqi_ri_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_ri_information_rel8_t* cqi_ri_info_rel8 = (nfapi_ul_config_cqi_ri_information_rel8_t*)tlv; + + return ( push8(cqi_ri_info_rel8->dl_cqi_pmi_size_rank_1, ppWritePackedMsg, end) && + push8(cqi_ri_info_rel8->dl_cqi_pmi_size_rank_greater_1, ppWritePackedMsg, end) && + push8(cqi_ri_info_rel8->ri_size, ppWritePackedMsg, end) && + push8(cqi_ri_info_rel8->delta_offset_cqi, ppWritePackedMsg, end) && + push8(cqi_ri_info_rel8->delta_offset_ri, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_cqi_ri_rel9_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_ri_information_rel9_t* cqi_ri_info_rel9 = (nfapi_ul_config_cqi_ri_information_rel9_t*)tlv; + + if(!(push8(cqi_ri_info_rel9->report_type, ppWritePackedMsg, end) && + push8(cqi_ri_info_rel9->delta_offset_cqi, ppWritePackedMsg, end) && + push8(cqi_ri_info_rel9->delta_offset_ri, ppWritePackedMsg, end))) + { + return 0; + } + + switch(cqi_ri_info_rel9->report_type) + { + case NFAPI_CSI_REPORT_TYPE_PERIODIC: + { + if(!(push8(cqi_ri_info_rel9->periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size, ppWritePackedMsg, end) && + push8(cqi_ri_info_rel9->periodic_cqi_pmi_ri_report.control_type, ppWritePackedMsg, end))) + { + return 0; + } + } + break; + case NFAPI_CSI_REPORT_TYPE_APERIODIC: + { + if(push8(cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.number_of_cc, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t i; + for(i = 0; i < cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.number_of_cc; ++i) + { + if(push8(cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.cc[i].ri_size, ppWritePackedMsg, end) == 0) + return 0; + + uint8_t j; + for(j = 0; j < 8; ++j) + { + if(push8(cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.cc[i].dl_cqi_pmi_size[j], ppWritePackedMsg, end) == 0) + return 0; + } + } + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid report type %d \n", cqi_ri_info_rel9->report_type ); + } + break; + }; + + return 1; +} + +static uint8_t pack_ul_config_request_cqi_ri_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_ri_information_rel13_t* cqi_ri_info_rel13 = (nfapi_ul_config_cqi_ri_information_rel13_t*)tlv; + + switch(cqi_ri_info_rel13->report_type) + { + case NFAPI_CSI_REPORT_TYPE_PERIODIC: + { + if(push16(cqi_ri_info_rel13->periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size_2, ppWritePackedMsg, end) == 0) + return 0; + } + break; + case NFAPI_CSI_REPORT_TYPE_APERIODIC: + { + // No parameters + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid report type %d \n", cqi_ri_info_rel13->report_type ); + } + break; + }; + + return 1; +} + +static uint8_t pack_ul_config_request_cqi_ri_information(nfapi_ul_config_cqi_ri_information* cqi_ri_info, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return (pack_tlv(NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG, &cqi_ri_info->cqi_ri_information_rel8, ppWritePackedMsg, end, &pack_ul_config_request_cqi_ri_rel8_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG, &cqi_ri_info->cqi_ri_information_rel9, ppWritePackedMsg, end, &pack_ul_config_request_cqi_ri_rel9_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG, &cqi_ri_info->cqi_ri_information_rel13, ppWritePackedMsg, end, &pack_ul_config_request_cqi_ri_rel13_value)); + +} + +static uint8_t pack_ul_config_request_init_tx_params_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_initial_transmission_parameters_rel8_t* init_tx_params_rel8 = (nfapi_ul_config_initial_transmission_parameters_rel8_t*)tlv; + + return (push8(init_tx_params_rel8->n_srs_initial, ppWritePackedMsg, end) && + push8(init_tx_params_rel8->initial_number_of_resource_blocks, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_initial_transmission_parameters(nfapi_ul_config_initial_transmission_parameters* init_tx_params, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return pack_tlv(NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG, &init_tx_params->initial_transmission_parameters_rel8, ppWritePackedMsg, end, &pack_ul_config_request_init_tx_params_rel8_value); +} + +static uint8_t pack_ul_config_request_ulsch_harq_info_rel10_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_harq_information_rel10_t* harq_info_rel10 = (nfapi_ul_config_ulsch_harq_information_rel10_t*)tlv; + + return (push8(harq_info_rel10->harq_size, ppWritePackedMsg, end) && + push8(harq_info_rel10->delta_offset_harq, ppWritePackedMsg, end) && + push8(harq_info_rel10->ack_nack_mode, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_ulsch_harq_info_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_harq_information_rel13_t* harq_info_rel13 = (nfapi_ul_config_ulsch_harq_information_rel13_t*)tlv; + + return (push16(harq_info_rel13->harq_size_2, ppWritePackedMsg, end) && + push8(harq_info_rel13->delta_offset_harq_2, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_ulsch_harq_information(nfapi_ul_config_ulsch_harq_information* harq_info, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( pack_tlv(NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG, &harq_info->harq_information_rel10, ppWritePackedMsg, end, &pack_ul_config_request_ulsch_harq_info_rel10_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG, &harq_info->harq_information_rel13, ppWritePackedMsg, end, &pack_ul_config_request_ulsch_harq_info_rel13_value)); +} + +static uint8_t pack_ul_config_request_ue_info_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ue_information_rel8_t* ue_info_rel8 = (nfapi_ul_config_ue_information_rel8_t*)tlv; + + return ( push32(ue_info_rel8->handle, ppWritePackedMsg, end) && + push16(ue_info_rel8->rnti, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_ue_info_rel11_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ue_information_rel11_t* ue_info_rel11 = (nfapi_ul_config_ue_information_rel11_t*)tlv; + + return ( push8(ue_info_rel11->virtual_cell_id_enabled_flag, ppWritePackedMsg, end) && + push16(ue_info_rel11->npusch_identity, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_ue_info_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_ue_information_rel13_t* ue_info_rel13 = (nfapi_ul_config_ue_information_rel13_t*)tlv; + + return ( push8(ue_info_rel13->ue_type, ppWritePackedMsg, end) && + push8(ue_info_rel13->empty_symbols, ppWritePackedMsg, end) && + push16(ue_info_rel13->total_number_of_repetitions, ppWritePackedMsg, end) && + push16(ue_info_rel13->repetition_number, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_ue_information(nfapi_ul_config_ue_information* ue_info, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( pack_tlv(NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG, &ue_info->ue_information_rel8, ppWritePackedMsg, end, &pack_ul_config_request_ue_info_rel8_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG, &ue_info->ue_information_rel11, ppWritePackedMsg, end, &pack_ul_config_request_ue_info_rel11_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG, &ue_info->ue_information_rel13, ppWritePackedMsg, end, &pack_ul_config_request_ue_info_rel13_value)); +} + +static uint8_t pack_ul_config_request_harq_info_rel10_tdd_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel10_tdd_t* harq_info_rel10_tdd = (nfapi_ul_config_harq_information_rel10_tdd_t*)tlv; + + return ( push8(harq_info_rel10_tdd->harq_size, ppWritePackedMsg, end) && + push8(harq_info_rel10_tdd->ack_nack_mode, ppWritePackedMsg, end) && + push8(harq_info_rel10_tdd->number_of_pucch_resources, ppWritePackedMsg, end) && + push16(harq_info_rel10_tdd->n_pucch_1_0, ppWritePackedMsg, end) && + push16(harq_info_rel10_tdd->n_pucch_1_1, ppWritePackedMsg, end) && + push16(harq_info_rel10_tdd->n_pucch_1_2, ppWritePackedMsg, end) && + push16(harq_info_rel10_tdd->n_pucch_1_3, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_harq_info_rel8_fdd_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel8_fdd_t* harq_info_rel8_fdd = (nfapi_ul_config_harq_information_rel8_fdd_t*)tlv; + + return ( push16(harq_info_rel8_fdd->n_pucch_1_0, ppWritePackedMsg, end) && + push8(harq_info_rel8_fdd->harq_size, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_harq_info_rel9_fdd_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel9_fdd_t* harq_info_rel9_fdd = (nfapi_ul_config_harq_information_rel9_fdd_t*)tlv; + + return ( push8(harq_info_rel9_fdd->harq_size, ppWritePackedMsg, end) && + push8(harq_info_rel9_fdd->ack_nack_mode, ppWritePackedMsg, end) && + push8(harq_info_rel9_fdd->number_of_pucch_resources, ppWritePackedMsg, end) && + push16(harq_info_rel9_fdd->n_pucch_1_0, ppWritePackedMsg, end) && + push16(harq_info_rel9_fdd->n_pucch_1_1, ppWritePackedMsg, end) && + push16(harq_info_rel9_fdd->n_pucch_1_2, ppWritePackedMsg, end) && + push16(harq_info_rel9_fdd->n_pucch_1_3, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_harq_info_rel11_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel11_t* harq_info_rel11 = (nfapi_ul_config_harq_information_rel11_t*)tlv; + + return ( push8(harq_info_rel11->num_ant_ports, ppWritePackedMsg, end) && + push16(harq_info_rel11->n_pucch_2_0, ppWritePackedMsg, end) && + push16(harq_info_rel11->n_pucch_2_1, ppWritePackedMsg, end) && + push16(harq_info_rel11->n_pucch_2_2, ppWritePackedMsg, end) && + push16(harq_info_rel11->n_pucch_2_3, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_harq_info_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel13_t* harq_info_rel13 = (nfapi_ul_config_harq_information_rel13_t*)tlv; + + return ( push16(harq_info_rel13->harq_size_2, ppWritePackedMsg, end) && + push8(harq_info_rel13->starting_prb, ppWritePackedMsg, end) && + push8(harq_info_rel13->n_prb, ppWritePackedMsg, end) && + push8(harq_info_rel13->cdm_index, ppWritePackedMsg, end) && + push8(harq_info_rel13->n_srs, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_harq_information(nfapi_ul_config_harq_information* harq_info, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( pack_tlv(NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG, &harq_info->harq_information_rel10_tdd, ppWritePackedMsg, end, &pack_ul_config_request_harq_info_rel10_tdd_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG, &harq_info->harq_information_rel8_fdd, ppWritePackedMsg, end, &pack_ul_config_request_harq_info_rel8_fdd_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG, &harq_info->harq_information_rel9_fdd, ppWritePackedMsg, end, &pack_ul_config_request_harq_info_rel9_fdd_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG, &harq_info->harq_information_rel11, ppWritePackedMsg, end, &pack_ul_config_request_harq_info_rel11_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG, &harq_info->harq_information_rel13, ppWritePackedMsg, end, &pack_ul_config_request_harq_info_rel13_value)); + +} + +static uint8_t pack_ul_config_request_cqi_info_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_information_rel8_t* cqi_info_rel8 = (nfapi_ul_config_cqi_information_rel8_t*)tlv; + + return ( push16(cqi_info_rel8->pucch_index, ppWritePackedMsg, end) && + push8(cqi_info_rel8->dl_cqi_pmi_size, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_cqi_info_rel10_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_information_rel10_t* cqi_info_rel10 = (nfapi_ul_config_cqi_information_rel10_t*)tlv; + + return ( push8(cqi_info_rel10->number_of_pucch_resource, ppWritePackedMsg, end) && + push16(cqi_info_rel10->pucch_index_p1, ppWritePackedMsg, end)); +} +static uint8_t pack_ul_config_request_cqi_info_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_information_rel13_t* cqi_info_rel13 = (nfapi_ul_config_cqi_information_rel13_t*)tlv; + + return ( push8(cqi_info_rel13->csi_mode, ppWritePackedMsg, end) && + push16(cqi_info_rel13->dl_cqi_pmi_size_2, ppWritePackedMsg, end) && + push8(cqi_info_rel13->starting_prb, ppWritePackedMsg, end) && + push8(cqi_info_rel13->n_prb, ppWritePackedMsg, end) && + push8(cqi_info_rel13->cdm_index, ppWritePackedMsg, end) && + push8(cqi_info_rel13->n_srs, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_cqi_information(nfapi_ul_config_cqi_information* cqi_info, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( pack_tlv(NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG, &cqi_info->cqi_information_rel8, ppWritePackedMsg, end, &pack_ul_config_request_cqi_info_rel8_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG, &cqi_info->cqi_information_rel10, ppWritePackedMsg, end, &pack_ul_config_request_cqi_info_rel10_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG, &cqi_info->cqi_information_rel13, ppWritePackedMsg, end, &pack_ul_config_request_cqi_info_rel13_value)); + +} + +static uint8_t pack_ul_config_request_sr_info_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_sr_information_rel8_t* sr_info_rel8 = (nfapi_ul_config_sr_information_rel8_t*)tlv; + return push16(sr_info_rel8->pucch_index, ppWritePackedMsg, end); +} +static uint8_t pack_ul_config_request_sr_info_rel10_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_sr_information_rel10_t* sr_info_rel10 = (nfapi_ul_config_sr_information_rel10_t*)tlv; + + return ( push8(sr_info_rel10->number_of_pucch_resources, ppWritePackedMsg, end) && + push16(sr_info_rel10->pucch_index_p1, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_sr_information(nfapi_ul_config_sr_information* sr_info, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( pack_tlv(NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG, &sr_info->sr_information_rel8, ppWritePackedMsg, end, &pack_ul_config_request_sr_info_rel8_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG, &sr_info->sr_information_rel10, ppWritePackedMsg, end, &pack_ul_config_request_sr_info_rel10_value)); +} + +static uint8_t pack_ul_config_request_srs_pdu_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_srs_pdu_rel8_t* srs_pdu_rel8 = (nfapi_ul_config_srs_pdu_rel8_t*)tlv; + + return (push32(srs_pdu_rel8->handle, ppWritePackedMsg, end) && + push16(srs_pdu_rel8->size, ppWritePackedMsg, end) && + push16(srs_pdu_rel8->rnti, ppWritePackedMsg, end) && + push8(srs_pdu_rel8->srs_bandwidth, ppWritePackedMsg, end) && + push8(srs_pdu_rel8->frequency_domain_position, ppWritePackedMsg, end) && + push8(srs_pdu_rel8->srs_hopping_bandwidth, ppWritePackedMsg, end) && + push8(srs_pdu_rel8->transmission_comb, ppWritePackedMsg, end) && + push16(srs_pdu_rel8->i_srs, ppWritePackedMsg, end) && + push8(srs_pdu_rel8->sounding_reference_cyclic_shift, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_srs_pdu_rel10_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_srs_pdu_rel10_t* srs_pdu_rel10 = (nfapi_ul_config_srs_pdu_rel10_t*)tlv; + return push8(srs_pdu_rel10->antenna_port, ppWritePackedMsg, end); +} + +static uint8_t pack_ul_config_request_srs_pdu_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_srs_pdu_rel13_t* srs_pdu_rel13 = (nfapi_ul_config_srs_pdu_rel13_t*)tlv; + + return ( push8(srs_pdu_rel13->number_of_combs, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_nb_harq_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_nb_harq_information_rel13_fdd_t* nb_harq_pdu_rel13 = (nfapi_ul_config_nb_harq_information_rel13_fdd_t*)tlv; + + return ( push8(nb_harq_pdu_rel13->harq_ack_resource, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_config_request_nulsch_pdu_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_nulsch_pdu_rel13_t* nulsch_pdu_rel13 = (nfapi_ul_config_nulsch_pdu_rel13_t*)tlv; + + return (push8(nulsch_pdu_rel13->nulsch_format, ppWritePackedMsg, end) && + push32(nulsch_pdu_rel13->handle, ppWritePackedMsg, end) && + push16(nulsch_pdu_rel13->size, ppWritePackedMsg, end) && + push16(nulsch_pdu_rel13->rnti, ppWritePackedMsg, end) && + push8(nulsch_pdu_rel13->subcarrier_indication, ppWritePackedMsg, end) && + push8(nulsch_pdu_rel13->resource_assignment, ppWritePackedMsg, end) && + push8(nulsch_pdu_rel13->mcs, ppWritePackedMsg, end) && + push8(nulsch_pdu_rel13->redudancy_version, ppWritePackedMsg, end) && + push8(nulsch_pdu_rel13->repetition_number, ppWritePackedMsg, end) && + push8(nulsch_pdu_rel13->new_data_indication, ppWritePackedMsg, end) && + push8(nulsch_pdu_rel13->n_srs, ppWritePackedMsg, end) && + push16(nulsch_pdu_rel13->scrambling_sequence_initialization_cinit, ppWritePackedMsg, end) && + push16(nulsch_pdu_rel13->sf_idx, ppWritePackedMsg, end) && + pack_ul_config_request_ue_information(&(nulsch_pdu_rel13->ue_information), ppWritePackedMsg, end) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG, &nulsch_pdu_rel13->nb_harq_information.nb_harq_information_rel13_fdd, ppWritePackedMsg, end, &pack_ul_config_request_nb_harq_rel13_value)); +} +static uint8_t pack_ul_config_request_nrach_pdu_rel13_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_nrach_pdu_rel13_t* nrach_pdu_rel13 = (nfapi_ul_config_nrach_pdu_rel13_t*)tlv; + + return ( push8(nrach_pdu_rel13->nprach_config_0, ppWritePackedMsg, end) && + push8(nrach_pdu_rel13->nprach_config_1, ppWritePackedMsg, end) && + push8(nrach_pdu_rel13->nprach_config_2, ppWritePackedMsg, end)); + +} + +static uint8_t pack_ul_config_request_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_config_request_body_t* value = (nfapi_ul_config_request_body_t*)tlv; + + if(!(push8(value->number_of_pdus, ppWritePackedMsg, end) && + push8(value->rach_prach_frequency_resources, ppWritePackedMsg, end) && + push8(value->srs_present, ppWritePackedMsg, end))) + return 0; + + uint16_t i = 0; + for(i = 0; i < value->number_of_pdus; ++i) + { + nfapi_ul_config_request_pdu_t* pdu = &(value->ul_config_pdu_list[i]); + + if(push8(pdu->pdu_type, ppWritePackedMsg, end) == 0) + return 0; + + // Put a 0 size in and then determine the size after the pdu + // has been writen and write the calculated size + uint8_t* pWritePackedMsgPduSize = *ppWritePackedMsg; + pdu->pdu_size = 0; + if(push8(pdu->pdu_size, ppWritePackedMsg, end) == 0) + return 0; + + switch(pdu->pdu_type) + { + case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: + { + if(!pack_ul_config_request_ulsch_pdu(&(pdu->ulsch_pdu), ppWritePackedMsg, end)) + return 0; + } + break; + case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: + { + if(!(pack_ul_config_request_ulsch_pdu(&(pdu->ulsch_cqi_ri_pdu.ulsch_pdu), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_ri_information(&(pdu->ulsch_cqi_ri_pdu.cqi_ri_information), ppWritePackedMsg, end) && + pack_ul_config_request_initial_transmission_parameters(&(pdu->ulsch_cqi_ri_pdu.initial_transmission_parameters), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: + { + if(!(pack_ul_config_request_ulsch_pdu(&(pdu->ulsch_harq_pdu.ulsch_pdu), ppWritePackedMsg, end) && + pack_ul_config_request_ulsch_harq_information(&(pdu->ulsch_harq_pdu.harq_information), ppWritePackedMsg, end) && + pack_ul_config_request_initial_transmission_parameters(&(pdu->ulsch_harq_pdu.initial_transmission_parameters), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: + { + if(!(pack_ul_config_request_ulsch_pdu(&(pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_ri_information(&(pdu->ulsch_cqi_harq_ri_pdu.cqi_ri_information), ppWritePackedMsg, end) && + pack_ul_config_request_ulsch_harq_information(&(pdu->ulsch_cqi_harq_ri_pdu.harq_information), ppWritePackedMsg, end) && + pack_ul_config_request_initial_transmission_parameters(&(pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->uci_cqi_pdu.ue_information), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_information(&(pdu->uci_cqi_pdu.cqi_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->uci_sr_pdu.ue_information), ppWritePackedMsg, end) && + pack_ul_config_request_sr_information(&(pdu->uci_sr_pdu.sr_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->uci_harq_pdu.ue_information), ppWritePackedMsg, end) && + pack_ul_config_request_harq_information(&(pdu->uci_harq_pdu.harq_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->uci_sr_harq_pdu.ue_information), ppWritePackedMsg, end) && + pack_ul_config_request_sr_information(&(pdu->uci_sr_harq_pdu.sr_information), ppWritePackedMsg, end) && + pack_ul_config_request_harq_information(&(pdu->uci_sr_harq_pdu.harq_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->uci_cqi_harq_pdu.ue_information), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_information(&(pdu->uci_cqi_harq_pdu.cqi_information), ppWritePackedMsg, end) && + pack_ul_config_request_harq_information(&(pdu->uci_cqi_harq_pdu.harq_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->uci_cqi_sr_pdu.ue_information), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_information(&(pdu->uci_cqi_sr_pdu.cqi_information), ppWritePackedMsg, end) && + pack_ul_config_request_sr_information(&(pdu->uci_cqi_sr_pdu.sr_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->uci_cqi_sr_harq_pdu.ue_information), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_information(&(pdu->uci_cqi_sr_harq_pdu.cqi_information), ppWritePackedMsg, end) && + pack_ul_config_request_sr_information(&(pdu->uci_cqi_sr_harq_pdu.sr_information), ppWritePackedMsg, end) && + pack_ul_config_request_harq_information(&(pdu->uci_cqi_sr_harq_pdu.harq_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_SRS_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG, &pdu->srs_pdu.srs_pdu_rel8, ppWritePackedMsg, end, &pack_ul_config_request_srs_pdu_rel8_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG, &pdu->srs_pdu.srs_pdu_rel10, ppWritePackedMsg, end, &pack_ul_config_request_srs_pdu_rel10_value) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG, &pdu->srs_pdu.srs_pdu_rel13, ppWritePackedMsg, end, &pack_ul_config_request_srs_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE: + { + if(!(pack_ul_config_request_ue_information(&(pdu->harq_buffer_pdu.ue_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: + { + if(!(pack_ul_config_request_ulsch_pdu(&(pdu->ulsch_uci_csi_pdu.ulsch_pdu), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_information(&(pdu->ulsch_uci_csi_pdu.csi_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: + { + if(!(pack_ul_config_request_ulsch_pdu(&(pdu->ulsch_uci_harq_pdu.ulsch_pdu), ppWritePackedMsg, end) && + pack_ul_config_request_harq_information(&(pdu->ulsch_uci_harq_pdu.harq_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: + { + if(!(pack_ul_config_request_ulsch_pdu(&(pdu->ulsch_csi_uci_harq_pdu.ulsch_pdu), ppWritePackedMsg, end) && + pack_ul_config_request_cqi_information(&(pdu->ulsch_csi_uci_harq_pdu.csi_information), ppWritePackedMsg, end) && + pack_ul_config_request_harq_information(&(pdu->ulsch_csi_uci_harq_pdu.harq_information), ppWritePackedMsg, end))) + return 0; + } + break; + case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG, &pdu->nulsch_pdu.nulsch_pdu_rel13, ppWritePackedMsg, end, &pack_ul_config_request_nulsch_pdu_rel13_value))) + return 0; + } + break; + case NFAPI_UL_CONFIG_NRACH_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG, &pdu->nrach_pdu.nrach_pdu_rel13, ppWritePackedMsg, end, &pack_ul_config_request_nrach_pdu_rel13_value))) + return 0; + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid pdu type %d \n", pdu->pdu_type ); + } + break; + }; + + // add 1 for the pdu_type. The delta will include the pdu_size + pdu->pdu_size = 1 + (*ppWritePackedMsg - pWritePackedMsgPduSize); + push8(pdu->pdu_size, &pWritePackedMsgPduSize, end); + + } + return 1; +} + +static uint8_t pack_ul_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_ul_config_request_t *pNfapiMsg = (nfapi_ul_config_request_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_UL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->ul_config_request_body, ppWritePackedMsg, end, &pack_ul_config_request_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)) ; +} + +static uint8_t pack_hi_dci0_hi_rel8_pdu_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_hi_pdu_rel8_t* hi_pdu_rel8 = (nfapi_hi_dci0_hi_pdu_rel8_t*)tlv; + + return ( push8(hi_pdu_rel8->resource_block_start, ppWritePackedMsg, end) && + push8(hi_pdu_rel8->cyclic_shift_2_for_drms, ppWritePackedMsg, end) && + push8(hi_pdu_rel8->hi_value, ppWritePackedMsg, end) && + push8(hi_pdu_rel8->i_phich, ppWritePackedMsg, end) && + push16(hi_pdu_rel8->transmission_power, ppWritePackedMsg, end)); +} + +static uint8_t pack_hi_dci0_hi_rel10_pdu_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_hi_pdu_rel10_t* hi_pdu_rel10 = (nfapi_hi_dci0_hi_pdu_rel10_t*)tlv; + + return ( push8(hi_pdu_rel10->flag_tb2, ppWritePackedMsg, end) && + push8(hi_pdu_rel10->hi_value_2, ppWritePackedMsg, end)); +} + +static uint8_t pack_hi_dci0_dci_rel8_pdu_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_dci_pdu_rel8_t* dci_pdu_rel8 = (nfapi_hi_dci0_dci_pdu_rel8_t*)tlv; + + return ( push8(dci_pdu_rel8->dci_format, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->cce_index, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->aggregation_level, ppWritePackedMsg, end) && + push16(dci_pdu_rel8->rnti, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->resource_block_start, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->number_of_resource_block, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->mcs_1, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->cyclic_shift_2_for_drms, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->frequency_hopping_enabled_flag, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->frequency_hopping_bits, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->new_data_indication_1, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->ue_tx_antenna_seleciton, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->tpc, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->cqi_csi_request, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->ul_index, ppWritePackedMsg, end) && + push8(dci_pdu_rel8->dl_assignment_index, ppWritePackedMsg, end) && + push32(dci_pdu_rel8->tpc_bitmap, ppWritePackedMsg, end) && + push16(dci_pdu_rel8->transmission_power, ppWritePackedMsg, end)); +} + +static uint8_t pack_hi_dci0_dci_rel10_pdu_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_dci_pdu_rel10_t* dci_pdu_rel10 = (nfapi_hi_dci0_dci_pdu_rel10_t*)tlv; + + return ( push8(dci_pdu_rel10->cross_carrier_scheduling_flag, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->carrier_indicator, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->size_of_cqi_csi_feild, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->srs_flag, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->srs_request, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->resource_allocation_flag, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->resource_allocation_type, ppWritePackedMsg, end) && + push32(dci_pdu_rel10->resource_block_coding, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->mcs_2, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->new_data_indication_2, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->number_of_antenna_ports, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->tpmi, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->total_dci_length_including_padding, ppWritePackedMsg, end) && + push8(dci_pdu_rel10->n_ul_rb, ppWritePackedMsg, end)); +} + +static uint8_t pack_hi_dci0_dci_rel12_pdu_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_dci_pdu_rel12_t* dci_pdu_rel12 = (nfapi_hi_dci0_dci_pdu_rel12_t*)tlv; + + return ( push8(dci_pdu_rel12->pscch_resource, ppWritePackedMsg, end) && + push8(dci_pdu_rel12->time_resource_pattern, ppWritePackedMsg, end)); +} + +static uint8_t pack_hi_dci0_mpdcch_dci_rel13_pdu_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t* mpdcch_dci_pdu_rel13 = (nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t*)tlv; + + return ( push8(mpdcch_dci_pdu_rel13->mpdcch_narrowband, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->number_of_prb_pairs, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->resource_block_assignment, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->mpdcch_transmission_type, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->start_symbol, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->ecce_index, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->aggreagation_level, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->rnti_type, ppWritePackedMsg, end) && + push16(mpdcch_dci_pdu_rel13->rnti, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->ce_mode, ppWritePackedMsg, end) && + push16(mpdcch_dci_pdu_rel13->drms_scrambling_init, ppWritePackedMsg, end) && + push16(mpdcch_dci_pdu_rel13->initial_transmission_sf_io, ppWritePackedMsg, end) && + push16(mpdcch_dci_pdu_rel13->transmission_power, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->dci_format, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->resource_block_start, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->number_of_resource_blocks, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->mcs, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->pusch_repetition_levels, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->frequency_hopping_flag, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->new_data_indication, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->harq_process, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->redudency_version, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->tpc, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->csi_request, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->ul_inex, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->dai_presence_flag, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->dl_assignment_index, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->srs_request, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->dci_subframe_repetition_number, ppWritePackedMsg, end) && + push32(mpdcch_dci_pdu_rel13->tcp_bitmap, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->total_dci_length_include_padding, ppWritePackedMsg, end) && + push8(mpdcch_dci_pdu_rel13->number_of_tx_antenna_ports, ppWritePackedMsg, end) && + pusharray16(mpdcch_dci_pdu_rel13->precoding_value, NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS, mpdcch_dci_pdu_rel13->number_of_tx_antenna_ports, ppWritePackedMsg, end)); + +} + +static uint8_t pack_hi_dci0_npdcch_dci_rel13_pdu_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_npdcch_dci_pdu_rel13_t* npdcch_dci_pdu_rel13 = (nfapi_hi_dci0_npdcch_dci_pdu_rel13_t*)tlv; + + return ( push8(npdcch_dci_pdu_rel13->ncce_index, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->aggregation_level, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->start_symbol, ppWritePackedMsg, end) && + push16(npdcch_dci_pdu_rel13->rnti, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->scrambling_reinitialization_batch_index, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->nrs_antenna_ports_assumed_by_the_ue, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->subcarrier_indication, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->resource_assignment, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->scheduling_delay, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->mcs, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->redudancy_version, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->repetition_number, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->new_data_indicator, ppWritePackedMsg, end) && + push8(npdcch_dci_pdu_rel13->dci_subframe_repetition_number, ppWritePackedMsg, end)); +} + + +static uint8_t pack_hi_dci0_request_body_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_request_body_t* value = (nfapi_hi_dci0_request_body_t*)tlv; + + if(!(push16(value->sfnsf, ppWritePackedMsg, end) && + push8(value->number_of_dci, ppWritePackedMsg, end) && + push8(value->number_of_hi, ppWritePackedMsg, end))) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_dci + value->number_of_hi; + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_hi_dci0_request_pdu_t* pdu = &(value->hi_dci0_pdu_list[i]); + + if(push8(pdu->pdu_type, ppWritePackedMsg, end) == 0) + return 0; + + // Put a 0 size in and then determine the size after the pdu + // has been writen and write the calculated size + uint8_t* pWritePackedMsgPduSize = *ppWritePackedMsg; + pdu->pdu_size = 0; + if(push8(pdu->pdu_size, ppWritePackedMsg, end) == 0) + return 0; + + switch(pdu->pdu_type) + { + case NFAPI_HI_DCI0_HI_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG, &pdu->hi_pdu.hi_pdu_rel8, ppWritePackedMsg, end, pack_hi_dci0_hi_rel8_pdu_value) && + pack_tlv(NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG, &pdu->hi_pdu.hi_pdu_rel10, ppWritePackedMsg, end, pack_hi_dci0_hi_rel10_pdu_value))) + return 0; + } + break; + case NFAPI_HI_DCI0_DCI_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG, &pdu->dci_pdu.dci_pdu_rel8, ppWritePackedMsg, end, pack_hi_dci0_dci_rel8_pdu_value) && + pack_tlv(NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG, &pdu->dci_pdu.dci_pdu_rel10, ppWritePackedMsg, end, pack_hi_dci0_dci_rel10_pdu_value) && + pack_tlv(NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG, &pdu->dci_pdu.dci_pdu_rel12, ppWritePackedMsg, end, pack_hi_dci0_dci_rel12_pdu_value))) + return 0; + } + break; + case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG, &pdu->epdcch_dci_pdu.epdcch_dci_pdu_rel8, ppWritePackedMsg, end, pack_hi_dci0_dci_rel8_pdu_value) && + pack_tlv(NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG, &pdu->epdcch_dci_pdu.epdcch_dci_pdu_rel10, ppWritePackedMsg, end, pack_hi_dci0_dci_rel10_pdu_value) && + pack_tlv(NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG, &pdu->epdcch_dci_pdu.epdcch_parameters_rel11, ppWritePackedMsg, end, pack_dl_config_epdcch_parameters_rel11_value))) + return 0; + } + break; + case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG, &pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13, ppWritePackedMsg, end, pack_hi_dci0_mpdcch_dci_rel13_pdu_value))) + return 0; + } + break; + case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE: + { + if(!(pack_tlv(NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG, &pdu->npdcch_dci_pdu.npdcch_dci_pdu_rel13, ppWritePackedMsg, end, pack_hi_dci0_npdcch_dci_rel13_pdu_value))) + return 0; + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid pdu type %d \n", pdu->pdu_type ); + } + break; + }; + + // add 1 for the pdu_type. The delta will include the pdu_size + pdu->pdu_size = 1 + (*ppWritePackedMsg - pWritePackedMsgPduSize); + push8(pdu->pdu_size, &pWritePackedMsgPduSize, end); + + } + + return 1; +} + +static uint8_t pack_hi_dci0_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_hi_dci0_request_t *pNfapiMsg = (nfapi_hi_dci0_request_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_HI_DCI0_REQUEST_BODY_TAG, &pNfapiMsg->hi_dci0_request_body, ppWritePackedMsg, end, &pack_hi_dci0_request_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_tx_request_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_tx_request_body_t* value = (nfapi_tx_request_body_t*)tlv; + + if(push16(value->number_of_pdus, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_pdus; + for(; i < total_number_of_pdus; ++i) + { + nfapi_tx_request_pdu_t* pdu = &(value->tx_pdu_list[i]); + + if(!(push16(pdu->pdu_length, ppWritePackedMsg, end) && + push16(pdu->pdu_index, ppWritePackedMsg, end))) + return 0; + + uint8_t j; + for(j = 0; j < pdu->num_segments; ++j) + { + // Use -1 as it is unbounded + // DJP - does not handle -1 + // DJP - if(pusharray8(pdu->segments[j].segment_data, (uint32_t)(-1), pdu->segments[j].segment_length, ppWritePackedMsg, end) == 0) + int push_ret = pusharray8(pdu->segments[j].segment_data, 65535, pdu->segments[j].segment_length, ppWritePackedMsg, end); + + if (0 && pdu->segments[j].segment_length == 3) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() BCH? segment_data:%x %x %x\n", __FUNCTION__, + pdu->segments[j].segment_data[0], + pdu->segments[j].segment_data[1], + pdu->segments[j].segment_data[2] + ); + } + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() segment_data:%p segment_length:%u pusharray8()=%d\n", __FUNCTION__, pdu->segments[j].segment_data, pdu->segments[j].segment_length, push_ret); + + if (push_ret == 0) + { + return 0; + } + } + } + + return 1; +} + +static uint8_t pack_tx_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_tx_request_t *pNfapiMsg = (nfapi_tx_request_t*)msg; + + int x = push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end); + int y = pack_tlv(NFAPI_TX_REQUEST_BODY_TAG, &pNfapiMsg->tx_request_body, ppWritePackedMsg, end, &pack_tx_request_body_value); + int z = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() x:%d y:%d z:%d\n", __FUNCTION__, x, y, z); + + return x && y && z; +} + +static uint8_t pack_rx_ue_information_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rx_ue_information* value = (nfapi_rx_ue_information*)tlv; + + return ( push32(value->handle, ppWritePackedMsg, end) && + push16(value->rnti, ppWritePackedMsg, end) ); +} + +static uint8_t unpack_rx_ue_information_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_rx_ue_information* value = (nfapi_rx_ue_information*)tlv; + + return ( pull32(ppReadPackedMsg, &value->handle, end) && + pull16(ppReadPackedMsg, &value->rnti, end)); +} + +static uint8_t pack_harq_indication_tdd_harq_data_bundling(nfapi_harq_indication_tdd_harq_data_bundling_t* data, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( push8(data->value_0, ppWritePackedMsg, end) && + push8(data->value_1, ppWritePackedMsg, end)); +} + +static uint8_t pack_harq_indication_tdd_harq_data_multiplexing(nfapi_harq_indication_tdd_harq_data_multiplexing_t* data, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( push8(data->value_0, ppWritePackedMsg, end) && + push8(data->value_1, ppWritePackedMsg, end) && + push8(data->value_2, ppWritePackedMsg, end) && + push8(data->value_3, ppWritePackedMsg, end)); +} + +static uint8_t pack_harq_indication_tdd_harq_data_special_bundling(nfapi_harq_indication_tdd_harq_data_special_bundling_t* data, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( push8(data->value_0, ppWritePackedMsg, end) ); +} + +static uint8_t pack_harq_indication_tdd_harq_data(nfapi_harq_indication_tdd_harq_data_t* data, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + return ( push8(data->value_0, ppWritePackedMsg, end) ); +} + +static uint8_t pack_harq_indication_tdd_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_rel8_t* harq_indication_tdd_rel8 = (nfapi_harq_indication_tdd_rel8_t*)tlv; + + if(!(push8(harq_indication_tdd_rel8->mode, ppWritePackedMsg, end) && + push8(harq_indication_tdd_rel8->number_of_ack_nack, ppWritePackedMsg, end))) + return 0; + + uint8_t result = 0; + switch(harq_indication_tdd_rel8->mode) + { + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING: + result = pack_harq_indication_tdd_harq_data_bundling(&harq_indication_tdd_rel8->harq_data.bundling, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING: + result = pack_harq_indication_tdd_harq_data_multiplexing(&harq_indication_tdd_rel8->harq_data.multiplex, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING: + result = pack_harq_indication_tdd_harq_data_special_bundling(&harq_indication_tdd_rel8->harq_data.special_bundling, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION: + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3: + result = 1; + break; + default: + // err.... + break; + } + + return result; + +} + +static uint8_t pack_harq_indication_tdd_rel9_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_rel9_t* harq_indication_tdd_rel9 = (nfapi_harq_indication_tdd_rel9_t*)tlv; + + if(!(push8(harq_indication_tdd_rel9->mode, ppWritePackedMsg, end) && + push8(harq_indication_tdd_rel9->number_of_ack_nack, ppWritePackedMsg, end))) + return 0; + + uint8_t idx; + for(idx = 0; idx < harq_indication_tdd_rel9->number_of_ack_nack; ++idx) + { + uint8_t result = 0; + + switch(harq_indication_tdd_rel9->mode) + { + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING: + result = pack_harq_indication_tdd_harq_data(&(harq_indication_tdd_rel9->harq_data[idx].bundling), ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel9->harq_data[idx].multiplex, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING: + result = pack_harq_indication_tdd_harq_data_special_bundling(&harq_indication_tdd_rel9->harq_data[idx].special_bundling, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel9->harq_data[idx].channel_selection, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel9->harq_data[idx].format_3, ppWritePackedMsg, end); + break; + default: + // err.... + break; + } + + if(result == 0) + return 0; + } + + return 1; +} + +static uint8_t pack_harq_indication_tdd_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_rel13_t* harq_indication_tdd_rel13 = (nfapi_harq_indication_tdd_rel13_t*)tlv; + + if(!(push8(harq_indication_tdd_rel13->mode, ppWritePackedMsg, end) && + push16(harq_indication_tdd_rel13->number_of_ack_nack, ppWritePackedMsg, end))) + return 0; + + uint8_t idx; + for(idx = 0; idx < harq_indication_tdd_rel13->number_of_ack_nack; ++idx) + { + uint8_t result = 0; + switch(harq_indication_tdd_rel13->mode) + { + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel13->harq_data[idx].bundling, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel13->harq_data[idx].multiplex, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING: + result = pack_harq_indication_tdd_harq_data_special_bundling(&harq_indication_tdd_rel13->harq_data[idx].special_bundling, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel13->harq_data[idx].channel_selection, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel13->harq_data[idx].format_3, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_4: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel13->harq_data[idx].format_4, ppWritePackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_5: + result = pack_harq_indication_tdd_harq_data(&harq_indication_tdd_rel13->harq_data[idx].format_5, ppWritePackedMsg, end); + break; + default: + // err.... + break; + } + + if(result == 0) + return 0; + } + + return 1; +} + +static uint8_t pack_harq_indication_fdd_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_harq_indication_fdd_rel8_t* harq_indication_fdd_rel8 = (nfapi_harq_indication_fdd_rel8_t*)tlv; + + return ( push8(harq_indication_fdd_rel8->harq_tb1, ppWritePackedMsg, end) && + push8(harq_indication_fdd_rel8->harq_tb2, ppWritePackedMsg, end)); +} + +static uint8_t pack_harq_indication_fdd_rel9_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_harq_indication_fdd_rel9_t* harq_indication_fdd_rel9 = (nfapi_harq_indication_fdd_rel9_t*)tlv; + + return ( push8(harq_indication_fdd_rel9->mode, ppWritePackedMsg, end) && + push8(harq_indication_fdd_rel9->number_of_ack_nack, ppWritePackedMsg, end) && + pusharray8(harq_indication_fdd_rel9->harq_tb_n, NFAPI_HARQ_ACK_NACK_REL9_MAX, harq_indication_fdd_rel9->number_of_ack_nack, ppWritePackedMsg, end)); +} + +static uint8_t pack_harq_indication_fdd_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_harq_indication_fdd_rel13_t* harq_indication_fdd_rel13 = (nfapi_harq_indication_fdd_rel13_t*)tlv; + + return ( push8(harq_indication_fdd_rel13->mode, ppWritePackedMsg, end) && + push16(harq_indication_fdd_rel13->number_of_ack_nack, ppWritePackedMsg, end) && + pusharray8(harq_indication_fdd_rel13->harq_tb_n, NFAPI_HARQ_ACK_NACK_REL13_MAX, harq_indication_fdd_rel13->number_of_ack_nack, ppWritePackedMsg, end)); +} + +static uint8_t pack_ul_cqi_information_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_ul_cqi_information_t* value = (nfapi_ul_cqi_information_t*)tlv; + + return ( push8(value->ul_cqi, ppWritePackedMsg, end) && + push8(value->channel, ppWritePackedMsg, end)); + +} + +static uint8_t pack_harq_indication_body_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_harq_indication_body_t* value = (nfapi_harq_indication_body_t*)tlv; + + if(push16(value->number_of_harqs, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_harqs; + for(; i < total_number_of_pdus; ++i) + { + nfapi_harq_indication_pdu_t* pdu = &(value->harq_pdu_list[i]); + + uint8_t* instance_length_p = *ppWritePackedMsg; + if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + return 0; + + if(!(pack_tlv(NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, ppWritePackedMsg, end, pack_rx_ue_information_value) && + pack_tlv(NFAPI_HARQ_INDICATION_TDD_REL8_TAG, &pdu->harq_indication_tdd_rel8, ppWritePackedMsg, end, pack_harq_indication_tdd_rel8_value) && + pack_tlv(NFAPI_HARQ_INDICATION_TDD_REL9_TAG, &pdu->harq_indication_tdd_rel9, ppWritePackedMsg, end, pack_harq_indication_tdd_rel9_value) && + pack_tlv(NFAPI_HARQ_INDICATION_TDD_REL13_TAG, &pdu->harq_indication_tdd_rel13, ppWritePackedMsg, end, pack_harq_indication_tdd_rel13_value) && + pack_tlv(NFAPI_HARQ_INDICATION_FDD_REL8_TAG, &pdu->harq_indication_fdd_rel8, ppWritePackedMsg, end, pack_harq_indication_fdd_rel8_value) && + pack_tlv(NFAPI_HARQ_INDICATION_FDD_REL9_TAG, &pdu->harq_indication_fdd_rel9, ppWritePackedMsg, end, pack_harq_indication_fdd_rel9_value) && + pack_tlv(NFAPI_HARQ_INDICATION_FDD_REL13_TAG, &pdu->harq_indication_fdd_rel13, ppWritePackedMsg, end, pack_harq_indication_fdd_rel13_value) && + pack_tlv(NFAPI_UL_CQI_INFORMATION_TAG, &pdu->ul_cqi_information, ppWritePackedMsg, end, pack_ul_cqi_information_value))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + push16(instance_length, &instance_length_p, end); + } + + return 1; +} + +static uint8_t pack_harq_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_harq_indication_t *pNfapiMsg = (nfapi_harq_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_HARQ_INDICATION_BODY_TAG, &pNfapiMsg->harq_indication_body, ppWritePackedMsg, end, pack_harq_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_crc_indication_rel8_body(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_crc_indication_rel8_t* crc_indication_rel8 = (nfapi_crc_indication_rel8_t*)tlv; + + return ( push8(crc_indication_rel8->crc_flag, ppWritePackedMsg, end) ); +} + +static uint8_t pack_crc_indication_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_crc_indication_body_t* value = (nfapi_crc_indication_body_t*)tlv; + + if(push16(value->number_of_crcs, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_crcs; + for(; i < total_number_of_pdus; ++i) + { + nfapi_crc_indication_pdu_t* pdu = &(value->crc_pdu_list[i]); + + uint8_t* instance_length_p = *ppWritePackedMsg; + if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + return 0; + + if(!(pack_tlv(NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, ppWritePackedMsg, end, pack_rx_ue_information_value) && + pack_tlv(NFAPI_CRC_INDICATION_REL8_TAG, &pdu->crc_indication_rel8, ppWritePackedMsg, end, pack_crc_indication_rel8_body))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + push16(instance_length, &instance_length_p, end); + } + return 1; +} + +static uint8_t pack_crc_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_crc_indication_t *pNfapiMsg = (nfapi_crc_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_CRC_INDICATION_BODY_TAG, &pNfapiMsg->crc_indication_body, ppWritePackedMsg, end, &pack_crc_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); + +} +static uint8_t pack_rx_indication_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rx_indication_rel8_t* value = (nfapi_rx_indication_rel8_t*)tlv; + + return ( push16(value->length, ppWritePackedMsg, end) && + push16(value->offset, ppWritePackedMsg, end) && + push8(value->ul_cqi, ppWritePackedMsg, end) && + push16(value->timing_advance, ppWritePackedMsg, end)); +} +static uint8_t pack_rx_indication_rel9_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rx_indication_rel9_t* value = (nfapi_rx_indication_rel9_t*)tlv; + + return ( push16(value->timing_advance_r9, ppWritePackedMsg, end)); +} + +static uint8_t pack_rx_ulsch_indication_body_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rx_indication_body_t* value = (nfapi_rx_indication_body_t*)tlv; + + //printf("RX ULSCH BODY\n"); + + if( push16(value->number_of_pdus, ppWritePackedMsg, end) == 0) + return 0; + + // need to calculate the data offset's. + uint16_t i = 0; + uint16_t offset = 2; // taking into account the number_of_pdus + uint16_t total_number_of_pdus = value->number_of_pdus; + //printf("ULSCH:pdus:%d\n", total_number_of_pdus); + + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_rx_indication_pdu_t* pdu = &(value->rx_pdu_list[i]); + if(pdu->rx_ue_information.tl.tag == NFAPI_RX_UE_INFORMATION_TAG) + { + //printf("NFAPI_RX_UE_INFORMATION_TAG\n"); + offset += 4 + 6; + } + + if(pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) + { + //printf("NFAPI_RX_INDICATION_REL8_TAG\n"); + offset += 4 + 7; + } + + if(pdu->rx_indication_rel9.tl.tag == NFAPI_RX_INDICATION_REL9_TAG) + { + //printf("NFAPI_RX_INDICATION_REL9_TAG\n"); + offset += 4 + 2; + } + } + + // Now update the structure to include the offset + for(i =0; i < total_number_of_pdus; ++i) + { + nfapi_rx_indication_pdu_t* pdu = &(value->rx_pdu_list[i]); + + if(pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) + { + if(pdu->rx_indication_rel8.offset == 1) + { + pdu->rx_indication_rel8.offset = offset; + offset += pdu->rx_indication_rel8.length; + } + } + } + + // Write out the pdu + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_rx_indication_pdu_t* pdu = &(value->rx_pdu_list[i]); + if(!(pack_tlv(NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, ppWritePackedMsg, end, pack_rx_ue_information_value) && + pack_tlv(NFAPI_RX_INDICATION_REL8_TAG, &pdu->rx_indication_rel8, ppWritePackedMsg, end, pack_rx_indication_rel8_value) && + pack_tlv(NFAPI_RX_INDICATION_REL9_TAG, &pdu->rx_indication_rel9, ppWritePackedMsg, end, pack_rx_indication_rel9_value))) + return 0; + } + + // Write out the pdu data + for(i = 0; i < total_number_of_pdus; ++i) + { + uint16_t length = 0; + nfapi_rx_indication_pdu_t* pdu = &(value->rx_pdu_list[i]); + + if(pdu->rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) + { + length = pdu->rx_indication_rel8.length; + } + + if( pusharray8(value->rx_pdu_list[i].data, length, length, ppWritePackedMsg, end) == 0) + return 0; + } + return 1; +} + + +static uint8_t pack_rx_ulsch_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_rx_indication_t *pNfapiMsg = (nfapi_rx_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_RX_INDICATION_BODY_TAG, &pNfapiMsg->rx_indication_body, ppWritePackedMsg, end, pack_rx_ulsch_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_preamble_pdu_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_preamble_pdu_rel8_t* preamble_rel8 = (nfapi_preamble_pdu_rel8_t*)tlv; + + return ( push16(preamble_rel8->rnti, ppWritePackedMsg, end) && + push8(preamble_rel8->preamble, ppWritePackedMsg, end) && + push16(preamble_rel8->timing_advance, ppWritePackedMsg, end)); +} +static uint8_t pack_preamble_pdu_rel9_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_preamble_pdu_rel9_t* preamble_rel9 = (nfapi_preamble_pdu_rel9_t*)tlv; + + return ( push16(preamble_rel9->timing_advance_r9, ppWritePackedMsg, end) ); +} +static uint8_t pack_preamble_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_preamble_pdu_rel13_t* preamble_rel13 = (nfapi_preamble_pdu_rel13_t*)tlv; + + return ( push8(preamble_rel13->rach_resource_type, ppWritePackedMsg, end) ); +} + +static uint8_t pack_rach_indication_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_rach_indication_body_t* value = (nfapi_rach_indication_body_t*)tlv; + + if( push16(value->number_of_preambles, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_preambles; + for(; i < total_number_of_pdus; ++i) + { + nfapi_preamble_pdu_t* pdu = &(value->preamble_list[i]); + + uint8_t* instance_length_p = *ppWritePackedMsg; + if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + return 0; + + if(!(pack_tlv(NFAPI_PREAMBLE_REL8_TAG, &pdu->preamble_rel8, ppWritePackedMsg, end, pack_preamble_pdu_rel8_value) && + pack_tlv(NFAPI_PREAMBLE_REL9_TAG, &pdu->preamble_rel9, ppWritePackedMsg, end, pack_preamble_pdu_rel9_value) && + pack_tlv(NFAPI_PREAMBLE_REL13_TAG, &pdu->preamble_rel13, ppWritePackedMsg, end, pack_preamble_pdu_rel13_value))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + push16(instance_length, &instance_length_p, end); + } + + return 1; +} + +static uint8_t pack_rach_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_rach_indication_t *pNfapiMsg = (nfapi_rach_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_RACH_INDICATION_BODY_TAG, &pNfapiMsg->rach_indication_body, ppWritePackedMsg, end, pack_rach_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_srs_indication_fdd_rel8_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_srs_indication_fdd_rel8_t* srs_pdu_rel8 = (nfapi_srs_indication_fdd_rel8_t*)tlv; + + return ( push16(srs_pdu_rel8->doppler_estimation, ppWritePackedMsg, end) && + push16(srs_pdu_rel8->timing_advance, ppWritePackedMsg, end) && + push8(srs_pdu_rel8->number_of_resource_blocks, ppWritePackedMsg, end) && + push8(srs_pdu_rel8->rb_start, ppWritePackedMsg, end) && + pusharray8(srs_pdu_rel8->snr, NFAPI_NUM_RB_MAX, srs_pdu_rel8->number_of_resource_blocks, ppWritePackedMsg, end)); +} + +static uint8_t pack_srs_indication_fdd_rel9_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_srs_indication_fdd_rel9_t* srs_pdu_rel9 = (nfapi_srs_indication_fdd_rel9_t*)tlv; + + return ( push16(srs_pdu_rel9->timing_advance_r9, ppWritePackedMsg, end) ); +} + +static uint8_t pack_srs_indication_tdd_rel10_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_srs_indication_ttd_rel10_t* srs_pdu_rel10 = (nfapi_srs_indication_ttd_rel10_t*)tlv; + + return ( push8(srs_pdu_rel10->uppts_symbol, ppWritePackedMsg, end) ); + +} + +static uint8_t pack_srs_indication_fdd_rel11_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_srs_indication_fdd_rel11_t* srs_pdu_rel11 = (nfapi_srs_indication_fdd_rel11_t*)tlv; + + return ( push16(srs_pdu_rel11->ul_rtoa, ppWritePackedMsg, end) ) ; +} + +static uint8_t pack_tdd_channel_measurement_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_tdd_channel_measurement_t* value = (nfapi_tdd_channel_measurement_t*)tlv; + + if(!(push8(value->num_prb_per_subband, ppWritePackedMsg, end) && + push8(value->number_of_subbands, ppWritePackedMsg, end) && + push8(value->num_atennas, ppWritePackedMsg, end))) + return 0; + + uint8_t idx = 0; + for(idx = 0; idx < value->number_of_subbands; ++idx) + { + if(!(push8(value->subands[idx].subband_index, ppWritePackedMsg, end) && + pusharray16(value->subands[idx].channel, NFAPI_MAX_NUM_PHYSICAL_ANTENNAS, value->num_atennas, ppWritePackedMsg, end))) + return 0; + } + + return 1; +} + +static uint8_t pack_srs_indication_body_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_srs_indication_body_t *value = (nfapi_srs_indication_body_t*)tlv; + + if( push8(value->number_of_ues, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_ues; + for(; i < total_number_of_pdus; ++i) + { + nfapi_srs_indication_pdu_t* pdu = &(value->srs_pdu_list[i]); + + uint8_t* instance_length_p = *ppWritePackedMsg; + if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + return 0; + + if(!(pack_tlv(NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, ppWritePackedMsg, end, &pack_rx_ue_information_value) && + pack_tlv(NFAPI_SRS_INDICATION_FDD_REL8_TAG, &pdu->srs_indication_fdd_rel8, ppWritePackedMsg, end, &pack_srs_indication_fdd_rel8_value) && + pack_tlv(NFAPI_SRS_INDICATION_FDD_REL9_TAG, &pdu->srs_indication_fdd_rel9, ppWritePackedMsg, end, &pack_srs_indication_fdd_rel9_value) && + pack_tlv(NFAPI_SRS_INDICATION_TDD_REL10_TAG, &pdu->srs_indication_tdd_rel10, ppWritePackedMsg, end, &pack_srs_indication_tdd_rel10_value) && + pack_tlv(NFAPI_SRS_INDICATION_FDD_REL11_TAG, &pdu->srs_indication_fdd_rel11, ppWritePackedMsg, end, &pack_srs_indication_fdd_rel11_value) && + pack_tlv(NFAPI_TDD_CHANNEL_MEASUREMENT_TAG, &pdu->tdd_channel_measurement, ppWritePackedMsg, end, &pack_tdd_channel_measurement_value))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + push16(instance_length, &instance_length_p, end); + } + + return 1; +} + +static uint8_t pack_srs_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_srs_indication_t *pNfapiMsg = (nfapi_srs_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_SRS_INDICATION_BODY_TAG, &pNfapiMsg->srs_indication_body, ppWritePackedMsg, end, &pack_srs_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); + +} + +static uint8_t pack_sr_indication_body_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_sr_indication_body_t* value = (nfapi_sr_indication_body_t*)tlv; + + if(push16(value->number_of_srs, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_srs; + for(; i < total_number_of_pdus; ++i) + { + nfapi_sr_indication_pdu_t* pdu = &(value->sr_pdu_list[i]); + + uint8_t* instance_length_p = *ppWritePackedMsg; + if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + return 0; + + if(!(pack_tlv(NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, ppWritePackedMsg, end, pack_rx_ue_information_value) && + pack_tlv(NFAPI_UL_CQI_INFORMATION_TAG, &pdu->ul_cqi_information, ppWritePackedMsg, end, pack_ul_cqi_information_value))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + push16(instance_length, &instance_length_p, end); + } + return 1; +} + +static uint8_t pack_sr_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_sr_indication_t *pNfapiMsg = (nfapi_sr_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_SR_INDICATION_BODY_TAG, &pNfapiMsg->sr_indication_body, ppWritePackedMsg, end, &pack_sr_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); + +} + +static uint8_t pack_cqi_indication_rel8_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_cqi_indication_rel8_t* cqi_pdu_rel8 = (nfapi_cqi_indication_rel8_t*)tlv; + + return ( push16(cqi_pdu_rel8->length, ppWritePackedMsg, end) && + push16(cqi_pdu_rel8->data_offset, ppWritePackedMsg, end) && + push8(cqi_pdu_rel8->ul_cqi, ppWritePackedMsg, end) && + push8(cqi_pdu_rel8->ri, ppWritePackedMsg, end) && + push16(cqi_pdu_rel8->timing_advance, ppWritePackedMsg, end)); +} + +static uint8_t pack_cqi_indication_rel9_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_cqi_indication_rel9_t* cqi_pdu_rel9 = (nfapi_cqi_indication_rel9_t*)tlv; + + return ( push16(cqi_pdu_rel9->length, ppWritePackedMsg, end) && + push16(cqi_pdu_rel9->data_offset, ppWritePackedMsg, end) && + push8(cqi_pdu_rel9->ul_cqi, ppWritePackedMsg, end) && + push8(cqi_pdu_rel9->number_of_cc_reported, ppWritePackedMsg, end) && + pusharray8(cqi_pdu_rel9->ri, NFAPI_CC_MAX, cqi_pdu_rel9->number_of_cc_reported, ppWritePackedMsg, end) && + push16(cqi_pdu_rel9->timing_advance, ppWritePackedMsg, end) && + push16(cqi_pdu_rel9->timing_advance_r9, ppWritePackedMsg, end)); +} + +static uint8_t pack_cqi_indication_body_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_cqi_indication_body_t* value = (nfapi_cqi_indication_body_t*)tlv; + + if( push16(value->number_of_cqis, ppWritePackedMsg, end) == 0) + return 0; + + // need to calculate the data offset's. This very bittle due the hardcoding + // of the sizes. can not use the sizeof as we have an array for the Rel9 + // info + uint16_t i = 0; + uint16_t offset = 2; // taking into account the number_of_cqis + uint16_t total_number_of_pdus = value->number_of_cqis; + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]); + + offset += 2; // for the instance length + + if(pdu->rx_ue_information.tl.tag == NFAPI_RX_UE_INFORMATION_TAG) + { + offset += 4 + 6; // sizeof(nfapi_rx_ue_information) - sizeof(nfapi_tl_t) + } + + if(pdu->cqi_indication_rel8.tl.tag == NFAPI_CQI_INDICATION_REL8_TAG) + { + offset += 4 + 8; + } + + if(pdu->cqi_indication_rel9.tl.tag == NFAPI_CQI_INDICATION_REL9_TAG) + { + offset += 4 + 10 + pdu->cqi_indication_rel9.number_of_cc_reported; + } + + if(pdu->ul_cqi_information.tl.tag == NFAPI_UL_CQI_INFORMATION_TAG) + { + offset += 4 + 2; + } + } + + // Now update the structure to include the offset + for(i =0; i < total_number_of_pdus; ++i) + { + nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]); + + if(pdu->cqi_indication_rel8.tl.tag == NFAPI_CQI_INDICATION_REL8_TAG) + { + if(pdu->cqi_indication_rel8.data_offset == 1) + { + pdu->cqi_indication_rel8.data_offset = offset; + offset += pdu->cqi_indication_rel8.length; + } + } + + if(pdu->cqi_indication_rel9.tl.tag == NFAPI_CQI_INDICATION_REL9_TAG) + { + if(pdu->cqi_indication_rel9.data_offset == 1) + { + pdu->cqi_indication_rel9.data_offset = offset; + offset += pdu->cqi_indication_rel9.length; + } + } + + } + + // Write out the cqi information + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]); + + uint8_t* instance_length_p = *ppWritePackedMsg; + if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + return 0; + + if(!(pack_tlv(NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, ppWritePackedMsg, end ,pack_rx_ue_information_value) && + pack_tlv(NFAPI_CQI_INDICATION_REL8_TAG, &pdu->cqi_indication_rel8, ppWritePackedMsg, end, pack_cqi_indication_rel8_value) && + pack_tlv(NFAPI_CQI_INDICATION_REL9_TAG, &pdu->cqi_indication_rel9, ppWritePackedMsg, end, pack_cqi_indication_rel9_value) && + pack_tlv(NFAPI_UL_CQI_INFORMATION_TAG, &pdu->ul_cqi_information, ppWritePackedMsg, end, pack_ul_cqi_information_value))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + push16(instance_length, &instance_length_p, end); + + } + + // Write out the cqi raw data + for(i = 0; i < total_number_of_pdus; ++i) + { + uint16_t length = 0; + nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]); + + if(pdu->cqi_indication_rel8.tl.tag == NFAPI_CQI_INDICATION_REL8_TAG) + { + length = pdu->cqi_indication_rel8.length; + } + + if(pdu->cqi_indication_rel9.tl.tag == NFAPI_CQI_INDICATION_REL9_TAG) + { + length = pdu->cqi_indication_rel9.length; + } + + if( pusharray8(value->cqi_raw_pdu_list[i].pdu, NFAPI_CQI_RAW_MAX_LEN, length, ppWritePackedMsg, end) == 0) + return 0; + } + + return 1; +} + +static uint8_t pack_cqi_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_cqi_indication_t *pNfapiMsg = (nfapi_cqi_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_CQI_INDICATION_BODY_TAG, &pNfapiMsg->cqi_indication_body, ppWritePackedMsg, end, pack_cqi_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); + +} + +static uint8_t pack_lbt_pdsch_req_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lbt_pdsch_req_pdu_rel13_t* value = (nfapi_lbt_pdsch_req_pdu_rel13_t*)tlv; + + return ( push32(value->handle, ppWritePackedMsg, end) && + push32(value->mp_cca, ppWritePackedMsg, end) && + push32(value->n_cca, ppWritePackedMsg, end) && + push32(value->offset, ppWritePackedMsg, end) && + push32(value->lte_txop_sf, ppWritePackedMsg, end) && + push16(value->txop_sfn_sf_end, ppWritePackedMsg, end) && + push32(value->lbt_mode, ppWritePackedMsg, end)); +} + +static uint8_t pack_lbt_drs_req_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lbt_drs_req_pdu_rel13_t* value = (nfapi_lbt_drs_req_pdu_rel13_t*)tlv; + + return ( push32(value->handle, ppWritePackedMsg, end) && + push32(value->offset, ppWritePackedMsg, end) && + push16(value->sfn_sf_end, ppWritePackedMsg, end) && + push32(value->lbt_mode, ppWritePackedMsg, end)); +} + +static uint8_t pack_lbt_dl_config_request_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lbt_dl_config_request_body_t* value = (nfapi_lbt_dl_config_request_body_t*)tlv; + + if( push16(value->number_of_pdus, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_pdus; + for(; i < total_number_of_pdus; ++i) + { + nfapi_lbt_dl_config_request_pdu_t* pdu = &(value->lbt_dl_config_req_pdu_list[i]); + + if( push8(pdu->pdu_type, ppWritePackedMsg, end) == 0) + return 0; + + // Put a 0 size in and then determine the size after the pdu + // has been writen and write the calculated size + uint8_t* pWritePackedMsgPduSize = *ppWritePackedMsg; + pdu->pdu_size = 0; + if( push8(pdu->pdu_size, ppWritePackedMsg, end) == 0) + return 0; + + switch(pdu->pdu_type) + { + case NFAPI_LBT_DL_CONFIG_REQUEST_PDSCH_PDU_TYPE: + { + if( pack_tlv(NFAPI_LBT_PDSCH_REQ_PDU_REL13_TAG, &pdu->lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13, ppWritePackedMsg, end, pack_lbt_pdsch_req_pdu_rel13_value) == 0) + return 0; + } + break; + case NFAPI_LBT_DL_CONFIG_REQUEST_DRS_PDU_TYPE: + { + if(pack_tlv(NFAPI_LBT_DRS_REQ_PDU_REL13_TAG, &pdu->lbt_drs_req_pdu.lbt_drs_req_pdu_rel13, ppWritePackedMsg, end, pack_lbt_drs_req_pdu_rel13_value) == 0) + return 0; + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "LBT_DL_CONFIG.request invalid pdu type %d \n", pdu->pdu_type ); + } + break; + }; + + // add 1 for the pdu_type. The delta will include the pdu_size + pdu->pdu_size = 1 + (*ppWritePackedMsg - pWritePackedMsgPduSize); + push8(pdu->pdu_size, &pWritePackedMsgPduSize, end); + } + + return 1; +} + +static uint8_t pack_lbt_pdsch_rsp_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lbt_pdsch_rsp_pdu_rel13_t* value = (nfapi_lbt_pdsch_rsp_pdu_rel13_t*)tlv; + + return ( push32(value->handle, ppWritePackedMsg, end) && + push32(value->result, ppWritePackedMsg, end) && + push32(value->lte_txop_symbols, ppWritePackedMsg, end) && + push32(value->initial_partial_sf, ppWritePackedMsg, end)); +} + +static uint8_t pack_lbt_drs_rsp_pdu_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lbt_drs_rsp_pdu_rel13_t* value = (nfapi_lbt_drs_rsp_pdu_rel13_t*)tlv; + + return ( push32(value->handle, ppWritePackedMsg, end) && + push32(value->result, ppWritePackedMsg, end)); +} + +static uint8_t pack_lbt_dl_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_lbt_dl_config_request_t *pNfapiMsg = (nfapi_lbt_dl_config_request_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_LBT_DL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->lbt_dl_config_request_body, ppWritePackedMsg, end, &pack_lbt_dl_config_request_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_lbt_dl_config_indication_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_lbt_dl_indication_body_t* value = (nfapi_lbt_dl_indication_body_t*)tlv; + + if( push16(value->number_of_pdus, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_pdus = value->number_of_pdus; + for(; i < total_number_of_pdus; ++i) + { + nfapi_lbt_dl_indication_pdu_t* pdu = &(value->lbt_indication_pdu_list[i]); + + if( push8(pdu->pdu_type, ppWritePackedMsg, end) == 0) + return 0; + + // Put a 0 size in and then determine the size after the pdu + // has been writen and write the calculated size + uint8_t* pWritePackedMsgPduSize = *ppWritePackedMsg; + pdu->pdu_size = 0; + + if(push8(pdu->pdu_size, ppWritePackedMsg, end) == 0) + return 0; + + switch(pdu->pdu_type) + { + case NFAPI_LBT_DL_RSP_PDSCH_PDU_TYPE: + { + if( pack_tlv(NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG, &pdu->lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13, ppWritePackedMsg, end, pack_lbt_pdsch_rsp_pdu_rel13_value) == 0) + return 0; + } + break; + case NFAPI_LBT_DL_RSP_DRS_PDU_TYPE: + { + if( pack_tlv(NFAPI_LBT_DRS_RSP_PDU_REL13_TAG, &pdu->lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13, ppWritePackedMsg, end, pack_lbt_drs_rsp_pdu_rel13_value) == 0) + return 0; + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "LBT_DL.indication body invalid pdu type %d \n", pdu->pdu_type ); + } + break; + }; + + // add 1 for the pdu_type. The delta will include the pdu_size + pdu->pdu_size = 1 + (*ppWritePackedMsg - pWritePackedMsgPduSize); + push8(pdu->pdu_size, &pWritePackedMsgPduSize, end); + } + + return 1; +} + +static uint8_t pack_lbt_dl_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_lbt_dl_indication_t *pNfapiMsg = (nfapi_lbt_dl_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_LBT_DL_INDICATION_BODY_TAG, &pNfapiMsg->lbt_dl_indication_body, ppWritePackedMsg, end, &pack_lbt_dl_config_indication_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_nb_harq_indication_fdd_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_harq_indication_fdd_rel13_t* nb_harq_indication_fdd_rel13 = (nfapi_nb_harq_indication_fdd_rel13_t*)tlv; + + return ( push8(nb_harq_indication_fdd_rel13->harq_tb1, ppWritePackedMsg, end) ); +} + +static uint8_t pack_nb_harq_indication_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nb_harq_indication_body_t* value = (nfapi_nb_harq_indication_body_t*)tlv; + + if( push16(value->number_of_harqs, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_harqs = value->number_of_harqs; + for(; i < total_number_of_harqs; ++i) + { + nfapi_nb_harq_indication_pdu_t* pdu = &(value->nb_harq_pdu_list[i]); + + uint8_t* instance_length_p = *ppWritePackedMsg; + if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + return 0; + + if(!(pack_tlv(NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, ppWritePackedMsg, end, pack_rx_ue_information_value) && + pack_tlv(NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG, &pdu->nb_harq_indication_fdd_rel13, ppWritePackedMsg, end, pack_nb_harq_indication_fdd_rel13_value) && + pack_tlv(NFAPI_UL_CQI_INFORMATION_TAG, &pdu->ul_cqi_information, ppWritePackedMsg, end, pack_ul_cqi_information_value))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + push16(instance_length, &instance_length_p, end); + } + + return 1; +} + + +static uint8_t pack_nb_harq_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_nb_harq_indication_t *pNfapiMsg = (nfapi_nb_harq_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_NB_HARQ_INDICATION_BODY_TAG, &pNfapiMsg->nb_harq_indication_body, ppWritePackedMsg, end, &pack_nb_harq_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_nrach_indication_rel13_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nrach_indication_pdu_rel13_t* nrach_indication_fdd_rel13 = (nfapi_nrach_indication_pdu_rel13_t*)tlv; + + return ( push16(nrach_indication_fdd_rel13->rnti, ppWritePackedMsg, end) && + push8(nrach_indication_fdd_rel13->initial_sc, ppWritePackedMsg, end) && + push16(nrach_indication_fdd_rel13->timing_advance, ppWritePackedMsg, end) && + push8(nrach_indication_fdd_rel13->nrach_ce_level, ppWritePackedMsg, end)); +} + + +static uint8_t pack_nrach_indication_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +{ + nfapi_nrach_indication_body_t* value = (nfapi_nrach_indication_body_t*)tlv; + + if( push8(value->number_of_initial_scs_detected, ppWritePackedMsg, end) == 0) + return 0; + + uint16_t i = 0; + uint16_t total_number_of_initial_scs_detected = value->number_of_initial_scs_detected; + for(; i < total_number_of_initial_scs_detected; ++i) + { + nfapi_nrach_indication_pdu_t* pdu = &(value->nrach_pdu_list[i]); + + //uint8_t* instance_length_p = *ppWritePackedMsg; + //if(!push16(pdu->instance_length, ppWritePackedMsg, end)) + // return 0; + + if(!(pack_tlv(NFAPI_NRACH_INDICATION_REL13_TAG, &pdu->nrach_indication_rel13, ppWritePackedMsg, end, pack_nrach_indication_rel13_value))) + return 0; + + // calculate the instance length subtracting the size of the instance + // length feild + //uint16_t instance_length = *ppWritePackedMsg - instance_length_p - 2; + //push16(instance_length, &instance_length_p, end); + } + + return 1; +} + +static uint8_t pack_nrach_indication(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_nrach_indication_t *pNfapiMsg = (nfapi_nrach_indication_t*)msg; + + return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && + pack_tlv(NFAPI_NRACH_INDICATION_BODY_TAG, &pNfapiMsg->nrach_indication_body, ppWritePackedMsg, end, &pack_nrach_indication_body_value) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_dl_node_sync_t *pNfapiMsg = (nfapi_dl_node_sync_t*)msg; + + return ( push32(pNfapiMsg->t1, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->delta_sfn_sf, ppWritePackedMsg, end) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_ul_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_ul_node_sync_t *pNfapiMsg = (nfapi_ul_node_sync_t*)msg; + + return (push32(pNfapiMsg->t1, ppWritePackedMsg, end) && + push32(pNfapiMsg->t2, ppWritePackedMsg, end) && + push32(pNfapiMsg->t3, ppWritePackedMsg, end) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + +static uint8_t pack_timing_info(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_timing_info_t *pNfapiMsg = (nfapi_timing_info_t*)msg; + + return (push32(pNfapiMsg->last_sfn_sf, ppWritePackedMsg, end) && + push32(pNfapiMsg->time_since_last_timing_info, ppWritePackedMsg, end) && + push32(pNfapiMsg->dl_config_jitter, ppWritePackedMsg, end) && + push32(pNfapiMsg->tx_request_jitter, ppWritePackedMsg, end) && + push32(pNfapiMsg->ul_config_jitter, ppWritePackedMsg, end) && + push32(pNfapiMsg->hi_dci0_jitter, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->dl_config_latest_delay, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->tx_request_latest_delay, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->ul_config_latest_delay, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->hi_dci0_latest_delay, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->dl_config_earliest_arrival, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->tx_request_earliest_arrival, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->ul_config_earliest_arrival, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->hi_dci0_earliest_arrival, ppWritePackedMsg, end) && + pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); +} + + +// Main pack function - public + +int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config) +{ + nfapi_p7_message_header_t *pMessageHeader = pMessageBuf; + uint8_t *pWritePackedMessage = pPackedBuf; + uint8_t *pPackedLengthField = &pWritePackedMessage[4]; + uint8_t *end = pPackedBuf + packedBufLen; + + if (pMessageBuf == NULL || pPackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack supplied pointers are null\n"); + return -1; + } + + // process the header + if(!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) && + push16(pMessageHeader->message_id, &pWritePackedMessage, end) && + push16(0/*pMessageHeader->message_length*/, &pWritePackedMessage, end) && + push16(pMessageHeader->m_segment_sequence, &pWritePackedMessage, end) && + push32(0/*pMessageHeader->checksum*/, &pWritePackedMessage, end) && + push32(pMessageHeader->transmit_timestamp, &pWritePackedMessage, end))) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack header failed\n"); + return -1; + } + + if (pMessageHeader->message_id != NFAPI_TIMING_INFO) + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() message_id:0x%04x phy_id:%u m_segment_sequence:%u timestamp:%u\n", __FUNCTION__, pMessageHeader->message_id, pMessageHeader->phy_id, pMessageHeader->m_segment_sequence, pMessageHeader->transmit_timestamp); + } + // look for the specific message + uint8_t result = 0; + switch (pMessageHeader->message_id) + { + case NFAPI_DL_CONFIG_REQUEST: + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() NFAPI_DL_CONFIG_REQUEST\n", __FUNCTION__); + result = pack_dl_config_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_UL_CONFIG_REQUEST: + result = pack_ul_config_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_HI_DCI0_REQUEST: + result = pack_hi_dci0_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_TX_REQUEST: + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() NFAPI_TX_REQUEST\n", __FUNCTION__); + result = pack_tx_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_HARQ_INDICATION: + result = pack_harq_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_CRC_INDICATION: + result = pack_crc_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_RX_ULSCH_INDICATION: + //printf("RX ULSCH\n"); + result = pack_rx_ulsch_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_RACH_INDICATION: + result = pack_rach_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_SRS_INDICATION: + result = pack_srs_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_RX_SR_INDICATION: + result = pack_sr_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_RX_CQI_INDICATION: + result = pack_cqi_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_LBT_DL_CONFIG_REQUEST: + result = pack_lbt_dl_config_request(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_LBT_DL_INDICATION: + result = pack_lbt_dl_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_NB_HARQ_INDICATION: + result = pack_nb_harq_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_NRACH_INDICATION: + result = pack_nrach_indication(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_DL_NODE_SYNC: + result = pack_dl_node_sync(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_UL_NODE_SYNC: + result = pack_ul_node_sync(pMessageHeader, &pWritePackedMessage, end, config); + break; + + case NFAPI_TIMING_INFO: + result = pack_timing_info(pMessageHeader, &pWritePackedMessage, end, config); + break; + + default: + { + if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + if(config && config->pack_p7_vendor_extension) + { + result = (config->pack_p7_vendor_extension)(pMessageHeader, &pWritePackedMessage, end, config); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve ecoder provided\n", __FUNCTION__, pMessageHeader->message_id); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id); + } + } + break; + } + + if(result == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack failed to pack message\n"); + return -1; + } + + // check for a valid message length + uintptr_t msgHead = (uintptr_t)pPackedBuf; + uintptr_t msgEnd = (uintptr_t)pWritePackedMessage; + uint32_t packedMsgLen = msgEnd - msgHead; + uint16_t packedMsgLen16; + if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen); + return -1; + } + else + { + packedMsgLen16 = (uint16_t)packedMsgLen; + } + + // Update the message length in the header + pMessageHeader->message_length = packedMsgLen16; + + if(!push16(packedMsgLen16, &pPackedLengthField, end)) + return -1; + + if(1) + { + //quick test + if(pMessageHeader->message_length != packedMsgLen) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi packedMsgLen(%d) != message_length(%d) id %d\n", packedMsgLen, pMessageHeader->message_length, pMessageHeader->message_id); + } + } + + return (packedMsgLen); +} + + + +// Unpack routines + +static uint8_t unpack_dl_config_dci_dl_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel8_t* dci_dl_pdu_rel8 = (nfapi_dl_config_dci_dl_pdu_rel8_t*)tlv; + + return (pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->dci_format, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->cce_idx, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->aggregation_level, end) && + pull16(ppReadPackedMsg, &dci_dl_pdu_rel8->rnti, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->resource_allocation_type, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->virtual_resource_block_assignment_flag, end) && + pull32(ppReadPackedMsg, &dci_dl_pdu_rel8->resource_block_coding, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->mcs_1, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->redundancy_version_1, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->new_data_indicator_1, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->transport_block_to_codeword_swap_flag, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->mcs_2, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->redundancy_version_2, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->new_data_indicator_2, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->harq_process, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->tpmi, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->pmi, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->precoding_information, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->tpc, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->downlink_assignment_index, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->ngap, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->transport_block_size_index, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->downlink_power_offset, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->allocate_prach_flag, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->preamble_index, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->prach_mask_index, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel8->rnti_type, end) && + pull16(ppReadPackedMsg, &dci_dl_pdu_rel8->transmission_power, end)); + +} + +static uint8_t unpack_dl_config_dci_dl_pdu_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel9_t* dci_dl_pdu_rel9 = (nfapi_dl_config_dci_dl_pdu_rel9_t*)tlv; + + return ( pull8(ppReadPackedMsg, &dci_dl_pdu_rel9->mcch_flag, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel9->mcch_change_notification, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel9->scrambling_identity, end)); +} + +static uint8_t unpack_dl_config_dci_dl_pdu_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel10_t* dci_dl_pdu_rel10 = (nfapi_dl_config_dci_dl_pdu_rel10_t*)tlv; + + return (pull8(ppReadPackedMsg, &dci_dl_pdu_rel10->cross_carrier_scheduling_flag, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel10->carrier_indicator, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel10->srs_flag, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel10->srs_request, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel10->antenna_ports_scrambling_and_layers, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel10->total_dci_length_including_padding, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel10->n_dl_rb, end)); +} + +static uint8_t unpack_dl_config_dci_dl_pdu_rel11_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel11_t* dci_dl_pdu_rel11 = (nfapi_dl_config_dci_dl_pdu_rel11_t*)tlv; + + return (pull8(ppReadPackedMsg, &dci_dl_pdu_rel11->harq_ack_resource_offset, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel11->pdsch_re_mapping_quasi_co_location_indicator, end)); +} + +static uint8_t unpack_dl_config_dci_dl_pdu_rel12_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel12_t* dci_dl_pdu_rel12 = (nfapi_dl_config_dci_dl_pdu_rel12_t*)tlv; + + return (pull8(ppReadPackedMsg, &dci_dl_pdu_rel12->primary_cell_type, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel12->ul_dl_configuration_flag, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel12->number_ul_dl_configurations, end) && + pullarray8(ppReadPackedMsg, dci_dl_pdu_rel12->ul_dl_configuration_indication, NFAPI_MAX_UL_DL_CONFIGURATIONS, dci_dl_pdu_rel12->number_ul_dl_configurations, end)); +} + +static uint8_t unpack_tpm_value(uint8_t **ppReadPackedMsg, nfapi_dl_config_dci_dl_tpm_t *value, uint8_t *end) +{ + if(!(pull8(ppReadPackedMsg, &value->num_prb_per_subband, end) && + pull8(ppReadPackedMsg, &value->number_of_subbands, end) && + pull8(ppReadPackedMsg, &value->num_antennas, end))) + return 0; + + + uint8_t idx = 0; + for(idx = 0; idx < value->number_of_subbands; ++idx) + { + nfapi_dl_config_dci_dl_tpm_subband_info_t* subband_info = &(value->subband_info[idx]); + + if(!(pull8(ppReadPackedMsg, &subband_info->subband_index, end) && + pull8(ppReadPackedMsg, &subband_info->scheduled_ues, end))) + return 0; + + uint8_t antenna_idx = 0; + uint8_t scheduled_ue_idx = 0; + + for(antenna_idx = 0; antenna_idx < value->num_antennas; ++antenna_idx) + { + for(scheduled_ue_idx = 0; scheduled_ue_idx < subband_info->scheduled_ues; ++scheduled_ue_idx) + { + if(!pull16(ppReadPackedMsg, &(subband_info->precoding_value[antenna_idx][scheduled_ue_idx]), end)) + return 0; + } + } + + } + + + return 1; + +} + + +static uint8_t unpack_dl_config_dci_dl_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dci_dl_pdu_rel13_t* dci_dl_pdu_rel13 = (nfapi_dl_config_dci_dl_pdu_rel13_t*)tlv; + + // If the length is greater than 5 then the TPM struct flag and possiably the TPM structure have been + // added + uint8_t tpm_struct_flag_present = dci_dl_pdu_rel13->tl.length > 5; + dci_dl_pdu_rel13->tpm_struct_flag = 0; + + return (pull8(ppReadPackedMsg, &dci_dl_pdu_rel13->laa_end_partial_sf_flag, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel13->laa_end_partial_sf_configuration, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel13->initial_lbt_sf, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel13->codebook_size_determination, end) && + pull8(ppReadPackedMsg, &dci_dl_pdu_rel13->drms_table_flag, end) && + ( (tpm_struct_flag_present == 1) ? pull8(ppReadPackedMsg, &dci_dl_pdu_rel13->tpm_struct_flag, end) : 1) && + ( (tpm_struct_flag_present == 1 && dci_dl_pdu_rel13->tpm_struct_flag == 1) ? unpack_tpm_value(ppReadPackedMsg, &dci_dl_pdu_rel13->tpm, end) : 1)); + +} + +static uint8_t unpack_dl_config_bch_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_bch_pdu_rel8_t* bch_pdu_rel8 = (nfapi_dl_config_bch_pdu_rel8_t*)tlv; + + return ( pull16(ppReadPackedMsg, &bch_pdu_rel8->length, end) && + pull16(ppReadPackedMsg, &bch_pdu_rel8->pdu_index, end) && + pull16(ppReadPackedMsg, &bch_pdu_rel8->transmission_power, end)); +} + +static uint8_t unpack_dl_config_mch_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_mch_pdu_rel8_t* mch_pdu_rel8 = (nfapi_dl_config_mch_pdu_rel8_t*)tlv; + + return (pull16(ppReadPackedMsg, &mch_pdu_rel8->length, end) && + pull16(ppReadPackedMsg, &mch_pdu_rel8->pdu_index, end) && + pull16(ppReadPackedMsg, &mch_pdu_rel8->rnti, end) && + pull8(ppReadPackedMsg, &mch_pdu_rel8->resource_allocation_type, end) && + pull32(ppReadPackedMsg, &mch_pdu_rel8->resource_block_coding, end) && + pull8(ppReadPackedMsg, &mch_pdu_rel8->modulation, end) && + pull16(ppReadPackedMsg, &mch_pdu_rel8->transmission_power, end) && + pull16(ppReadPackedMsg, &mch_pdu_rel8->mbsfn_area_id, end)); +} + +static uint8_t unpack_dl_config_dlsch_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel8_t* dlsch_pdu_rel8 = (nfapi_dl_config_dlsch_pdu_rel8_t*)tlv; + + if (!(pull16(ppReadPackedMsg, &dlsch_pdu_rel8->length, end) && + pull16(ppReadPackedMsg, &dlsch_pdu_rel8->pdu_index, end) && + pull16(ppReadPackedMsg, &dlsch_pdu_rel8->rnti, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->resource_allocation_type, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->virtual_resource_block_assignment_flag, end) && + pull32(ppReadPackedMsg, &dlsch_pdu_rel8->resource_block_coding, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->modulation, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->redundancy_version, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->transport_blocks, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->transport_block_to_codeword_swap_flag, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->transmission_scheme, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->number_of_layers, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->number_of_subbands, end) && + pullarray8(ppReadPackedMsg, dlsch_pdu_rel8->codebook_index, NFAPI_MAX_NUM_SUBBANDS, dlsch_pdu_rel8->number_of_subbands, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->ue_category_capacity, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->pa, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->delta_power_offset_index, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->ngap, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->nprb, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->transmission_mode, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->num_bf_prb_per_subband, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->num_bf_vector, end))) + return 0; + + uint16_t j = 0; + for(j = 0; j < dlsch_pdu_rel8->num_bf_vector; ++j) + { + if(!(pull8(ppReadPackedMsg, &dlsch_pdu_rel8->bf_vector[j].subband_index, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel8->bf_vector[j].num_antennas, end) && + pullarray16(ppReadPackedMsg, dlsch_pdu_rel8->bf_vector[j].bf_value, NFAPI_MAX_NUM_ANTENNAS, dlsch_pdu_rel8->bf_vector[j].num_antennas, end))) + return 0; + } + return 1; +} +static uint8_t unpack_dl_config_dlsch_pdu_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel9_t* dlsch_pdu_rel9 = (nfapi_dl_config_dlsch_pdu_rel9_t*)tlv; + return ( pull8(ppReadPackedMsg, &dlsch_pdu_rel9->nscid, end) ); +} +static uint8_t unpack_dl_config_dlsch_pdu_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel10_t* dlsch_pdu_rel10 = (nfapi_dl_config_dlsch_pdu_rel10_t*)tlv; + + return ( pull8(ppReadPackedMsg, &dlsch_pdu_rel10->csi_rs_flag, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel10->csi_rs_resource_config_r10, end) && + pull16(ppReadPackedMsg, &dlsch_pdu_rel10->csi_rs_zero_tx_power_resource_config_bitmap_r10, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel10->csi_rs_number_nzp_configuration, end) && + pullarray8(ppReadPackedMsg, dlsch_pdu_rel10->csi_rs_resource_config, NFAPI_MAX_CSI_RS_RESOURCE_CONFIG, dlsch_pdu_rel10->csi_rs_number_nzp_configuration, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel10->pdsch_start, end)) ; +} +static uint8_t unpack_dl_config_dlsch_pdu_rel11_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel11_t* dlsch_pdu_rel11 = (nfapi_dl_config_dlsch_pdu_rel11_t*)tlv; + + return ( pull8(ppReadPackedMsg, &dlsch_pdu_rel11->drms_config_flag, end) && + pull16(ppReadPackedMsg, &dlsch_pdu_rel11->drms_scrambling, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel11->csi_config_flag, end) && + pull16(ppReadPackedMsg, &dlsch_pdu_rel11->csi_scrambling, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel11->pdsch_re_mapping_flag, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel11->pdsch_re_mapping_atenna_ports, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel11->pdsch_re_mapping_freq_shift, end)); +} +static uint8_t unpack_dl_config_dlsch_pdu_rel12_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel12_t* dlsch_pdu_rel12 = (nfapi_dl_config_dlsch_pdu_rel12_t*)tlv; + + return ( pull8(ppReadPackedMsg, &dlsch_pdu_rel12->altcqi_table_r12, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel12->maxlayers, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel12->n_dl_harq, end)); +} +static uint8_t unpack_dl_config_dlsch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_dlsch_pdu_rel13_t* dlsch_pdu_rel13 = (nfapi_dl_config_dlsch_pdu_rel13_t*)tlv; + + return ( pull8(ppReadPackedMsg, &dlsch_pdu_rel13->dwpts_symbols, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel13->initial_lbt_sf, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel13->ue_type, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel13->pdsch_payload_type, end) && + pull16(ppReadPackedMsg, &dlsch_pdu_rel13->initial_transmission_sf_io, end) && + pull8(ppReadPackedMsg, &dlsch_pdu_rel13->drms_table_flag, end)); +} + +static uint8_t unpack_dl_config_pch_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_pch_pdu_rel8_t* pch_pdu_rel8 = (nfapi_dl_config_pch_pdu_rel8_t*)tlv; + + return ( pull16(ppReadPackedMsg, &pch_pdu_rel8->length, end) && + pull16(ppReadPackedMsg, &pch_pdu_rel8->pdu_index, end) && + pull16(ppReadPackedMsg, &pch_pdu_rel8->p_rnti, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->resource_allocation_type, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->virtual_resource_block_assignment_flag, end) && + pull32(ppReadPackedMsg, &pch_pdu_rel8->resource_block_coding, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->mcs, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->redundancy_version, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->number_of_transport_blocks, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->transport_block_to_codeword_swap_flag, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->transmission_scheme, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->number_of_layers, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->codebook_index, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->ue_category_capacity, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->pa, end) && + pull16(ppReadPackedMsg, &pch_pdu_rel8->transmission_power, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->nprb, end) && + pull8(ppReadPackedMsg, &pch_pdu_rel8->ngap, end)); +} +static uint8_t unpack_dl_config_pch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_pch_pdu_rel13_t* pch_pdu_rel13 = (nfapi_dl_config_pch_pdu_rel13_t*)tlv; + + return ( pull8(ppReadPackedMsg, &pch_pdu_rel13->ue_mode, end) && + pull16(ppReadPackedMsg, &pch_pdu_rel13->initial_transmission_sf_io, end)); +} + +static uint8_t unpack_dl_config_prs_pdu_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_prs_pdu_rel9_t* prs_pdu_rel9 = (nfapi_dl_config_prs_pdu_rel9_t*)tlv; + + return ( pull16(ppReadPackedMsg, &prs_pdu_rel9->transmission_power, end) && + pull8(ppReadPackedMsg, &prs_pdu_rel9->prs_bandwidth, end) && + pull8(ppReadPackedMsg, &prs_pdu_rel9->prs_cyclic_prefix_type, end) && + pull8(ppReadPackedMsg, &prs_pdu_rel9->prs_muting, end)); +} + +static uint8_t unpack_dl_config_csi_rs_pdu_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_csi_rs_pdu_rel10_t* csi_rs_pdu_rel10 = (nfapi_dl_config_csi_rs_pdu_rel10_t*)tlv; + + return ( pull8(ppReadPackedMsg, &csi_rs_pdu_rel10->csi_rs_antenna_port_count_r10, end) && + pull8(ppReadPackedMsg, &csi_rs_pdu_rel10->csi_rs_resource_config_r10, end) && + pull16(ppReadPackedMsg, &csi_rs_pdu_rel10->transmission_power, end) && + pull16(ppReadPackedMsg, &csi_rs_pdu_rel10->csi_rs_zero_tx_power_resource_config_bitmap_r10, end) && + pull8(ppReadPackedMsg, &csi_rs_pdu_rel10->csi_rs_number_of_nzp_configuration, end) && + pullarray8(ppReadPackedMsg, csi_rs_pdu_rel10->csi_rs_resource_config, NFAPI_MAX_CSI_RS_RESOURCE_CONFIG, csi_rs_pdu_rel10->csi_rs_number_of_nzp_configuration, end)); +} + +static uint8_t unpack_dl_config_csi_rs_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_csi_rs_pdu_rel13_t* csi_rs_pdu_rel13 = (nfapi_dl_config_csi_rs_pdu_rel13_t*)tlv; + + if (!(pull8(ppReadPackedMsg, &csi_rs_pdu_rel13->csi_rs_class, end) && + pull8(ppReadPackedMsg, &csi_rs_pdu_rel13->cdm_type, end) && + pull8(ppReadPackedMsg, &csi_rs_pdu_rel13->num_bf_vector, end))) + return 0; + + + uint16_t idx =0; + for(idx = 0; idx < csi_rs_pdu_rel13->num_bf_vector; ++idx) + { + if(!(pull8(ppReadPackedMsg, &csi_rs_pdu_rel13->bf_vector[idx].csi_rs_resource_index, end))) + return 0; + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : HOW TO DECODE BF VALUE \n"); + //pullarray16(ppReadPackedMsg, &csi_rs_pdu_rel13->bf_vector[idx].bf_vector, ??); + } + return 1; +} + +static uint8_t unpack_dl_config_epdcch_params_rel11_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_epdcch_parameters_rel11_t* epdcch_params_rel11 = (nfapi_dl_config_epdcch_parameters_rel11_t*)tlv; + + return (pull8(ppReadPackedMsg, &epdcch_params_rel11->epdcch_resource_assignment_flag, end) && + pull16(ppReadPackedMsg, &epdcch_params_rel11->epdcch_id, end) && + pull8(ppReadPackedMsg, &epdcch_params_rel11->epdcch_start_symbol, end) && + pull8(ppReadPackedMsg, &epdcch_params_rel11->epdcch_num_prb, end) && + pullarray8(ppReadPackedMsg, epdcch_params_rel11->epdcch_prb_index, NFAPI_MAX_EPDCCH_PRB, epdcch_params_rel11->epdcch_num_prb, end) && + pull8(ppReadPackedMsg, &epdcch_params_rel11->bf_vector.subband_index, end) && + pull8(ppReadPackedMsg, &epdcch_params_rel11->bf_vector.num_antennas, end) && + pullarray16(ppReadPackedMsg, epdcch_params_rel11->bf_vector.bf_value, NFAPI_MAX_NUM_ANTENNAS, epdcch_params_rel11->bf_vector.num_antennas, end)); +} + +static uint8_t unpack_dl_config_epdcch_params_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_epdcch_parameters_rel13_t* epdcch_params_rel13 = (nfapi_dl_config_epdcch_parameters_rel13_t*)tlv; + + return ( pull8(ppReadPackedMsg, &epdcch_params_rel13->dwpts_symbols, end) && + pull8(ppReadPackedMsg, &epdcch_params_rel13->initial_lbt_sf, end)); +} + +static uint8_t unpack_dl_config_mpdcch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_mpdcch_pdu_rel13_t* mpdcch_params_rel13 = (nfapi_dl_config_mpdcch_pdu_rel13_t*)tlv; + + + return ( pull8(ppReadPackedMsg, &mpdcch_params_rel13->mpdcch_narrow_band, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->number_of_prb_pairs, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->resource_block_assignment, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->mpdcch_tansmission_type, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->start_symbol, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->ecce_index, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->aggregation_level, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->rnti_type, end) && + pull16(ppReadPackedMsg, &mpdcch_params_rel13->rnti, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->ce_mode, end) && + pull16(ppReadPackedMsg, &mpdcch_params_rel13->drms_scrambling_init, end) && + pull16(ppReadPackedMsg, &mpdcch_params_rel13->initial_transmission_sf_io, end) && + pull16(ppReadPackedMsg, &mpdcch_params_rel13->transmission_power, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->dci_format, end) && + pull16(ppReadPackedMsg, &mpdcch_params_rel13->resource_block_coding, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->mcs, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->pdsch_reptition_levels, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->redundancy_version, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->new_data_indicator, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->harq_process, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->tpmi_length, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->tpmi, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->pmi_flag, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->pmi, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->harq_resource_offset, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->dci_subframe_repetition_number, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->tpc, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->downlink_assignment_index_length, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->downlink_assignment_index, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->allocate_prach_flag, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->preamble_index, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->prach_mask_index, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->starting_ce_level, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->srs_request, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->antenna_ports_and_scrambling_identity_flag, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->antenna_ports_and_scrambling_identity, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->frequency_hopping_enabled_flag, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->paging_direct_indication_differentiation_flag, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->direct_indication, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->total_dci_length_including_padding, end) && + pull8(ppReadPackedMsg, &mpdcch_params_rel13->number_of_tx_antenna_ports, end) && + pullarray16(ppReadPackedMsg, mpdcch_params_rel13->precoding_value, NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS, mpdcch_params_rel13->number_of_tx_antenna_ports, end)); +} + + +static uint8_t unpack_dl_config_nbch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_nbch_pdu_rel13_t* nbch_params_rel13 = (nfapi_dl_config_nbch_pdu_rel13_t*)tlv; + + return ( pull16(ppReadPackedMsg, &nbch_params_rel13->length, end) && + pull16(ppReadPackedMsg, &nbch_params_rel13->pdu_index, end) && + pull16(ppReadPackedMsg, &nbch_params_rel13->transmission_power, end) && + pull16(ppReadPackedMsg, &nbch_params_rel13->hyper_sfn_2_lsbs, end)); +} + +static uint8_t unpack_dl_config_npdcch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_npdcch_pdu_rel13_t* npdcch_params_rel13 = (nfapi_dl_config_npdcch_pdu_rel13_t*)tlv; + + return ( pull16(ppReadPackedMsg, &npdcch_params_rel13->length, end) && + pull16(ppReadPackedMsg, &npdcch_params_rel13->pdu_index, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->ncce_index, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->aggregation_level, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->start_symbol, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->rnti_type, end) && + pull16(ppReadPackedMsg, &npdcch_params_rel13->rnti, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->scrambling_reinitialization_batch_index, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->nrs_antenna_ports_assumed_by_the_ue, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->dci_format, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->scheduling_delay, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->resource_assignment, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->repetition_number, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->mcs, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->new_data_indicator, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->harq_ack_resource, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->npdcch_order_indication, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->starting_number_of_nprach_repetitions, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->subcarrier_indication_of_nprach, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->paging_direct_indication_differentation_flag, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->direct_indication, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->dci_subframe_repetition_number, end) && + pull8(ppReadPackedMsg, &npdcch_params_rel13->total_dci_length_including_padding, end)); +} + +static uint8_t unpack_dl_config_ndlsch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_dl_config_ndlsch_pdu_rel13_t* ndlsch_params_rel13 = (nfapi_dl_config_ndlsch_pdu_rel13_t*)tlv; + + return ( pull16(ppReadPackedMsg, &ndlsch_params_rel13->length, end) && + pull16(ppReadPackedMsg, &ndlsch_params_rel13->pdu_index, end) && + pull8(ppReadPackedMsg, &ndlsch_params_rel13->start_symbol, end) && + pull8(ppReadPackedMsg, &ndlsch_params_rel13->rnti_type, end) && + pull16(ppReadPackedMsg, &ndlsch_params_rel13->rnti, end) && + pull16(ppReadPackedMsg, &ndlsch_params_rel13->resource_assignment, end) && + pull16(ppReadPackedMsg, &ndlsch_params_rel13->repetition_number, end) && + pull8(ppReadPackedMsg, &ndlsch_params_rel13->modulation, end) && + pull8(ppReadPackedMsg, &ndlsch_params_rel13->number_of_subframes_for_resource_assignment, end) && + pull8(ppReadPackedMsg, &ndlsch_params_rel13->scrambling_sequence_initialization_cinit, end) && + pull16(ppReadPackedMsg, &ndlsch_params_rel13->sf_idx, end) && + pull8(ppReadPackedMsg, &ndlsch_params_rel13->nrs_antenna_ports_assumed_by_the_ue, end)); +} + + +static uint8_t unpack_dl_config_request_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_dl_config_request_body_t* value = (nfapi_dl_config_request_body_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->number_pdcch_ofdm_symbols, end) && + pull8(ppReadPackedMsg, &value->number_dci, end) && + pull16(ppReadPackedMsg, &value->number_pdu, end) && + pull8(ppReadPackedMsg, &value->number_pdsch_rnti, end) && + pull16(ppReadPackedMsg, &value->transmission_power_pcfich, end))) + return 0; + + if(value->number_pdu > NFAPI_DL_CONFIG_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of dl config pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_pdu, NFAPI_DL_CONFIG_MAX_PDU); + return 0; + } + + if(value->number_pdu) + { + value->dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_dl_config_request_pdu_t) * value->number_pdu, config); + if(value->dl_config_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate dl config pdu list (count:%d)\n", __FUNCTION__, value->number_pdu); + return 0; + } + } + else + { + value->dl_config_pdu_list = 0; + } + + uint16_t i; + uint16_t total_number_of_pdus = value->number_pdu; + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_dl_config_request_pdu_t* pdu = &(value->dl_config_pdu_list[i]); + + if(!(pull8(ppReadPackedMsg, &pdu->pdu_type, end) && + pull8(ppReadPackedMsg, &pdu->pdu_size, end))) + return 0; + + uint8_t *packedPduEnd = (*ppReadPackedMsg) + pdu->pdu_size - 2; + + if(packedPduEnd > end) + { + // pdu end of beyond buffer end + return 0; + } + + switch(pdu->pdu_type) + { + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel8, &unpack_dl_config_dci_dl_pdu_rel8_value}, + { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel9, &unpack_dl_config_dci_dl_pdu_rel9_value}, + { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel10, &unpack_dl_config_dci_dl_pdu_rel10_value}, + { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel11, &unpack_dl_config_dci_dl_pdu_rel11_value}, + { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel12, &unpack_dl_config_dci_dl_pdu_rel12_value}, + { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel13, &unpack_dl_config_dci_dl_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_BCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG, &pdu->bch_pdu.bch_pdu_rel8, &unpack_dl_config_bch_pdu_rel8_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_MCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG, &pdu->mch_pdu.mch_pdu_rel8, &unpack_dl_config_mch_pdu_rel8_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel8, &unpack_dl_config_dlsch_pdu_rel8_value}, + { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel9, &unpack_dl_config_dlsch_pdu_rel9_value}, + { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel10, &unpack_dl_config_dlsch_pdu_rel10_value}, + { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel11, &unpack_dl_config_dlsch_pdu_rel11_value}, + { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel12, &unpack_dl_config_dlsch_pdu_rel12_value}, + { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel13, &unpack_dl_config_dlsch_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_PCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG, &pdu->pch_pdu.pch_pdu_rel8, &unpack_dl_config_pch_pdu_rel8_value}, + { NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG, &pdu->pch_pdu.pch_pdu_rel13, &unpack_dl_config_pch_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_PRS_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG, &pdu->prs_pdu.prs_pdu_rel9, &unpack_dl_config_prs_pdu_rel9_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG, &pdu->csi_rs_pdu.csi_rs_pdu_rel10, &unpack_dl_config_csi_rs_pdu_rel10_value}, + { NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG, &pdu->csi_rs_pdu.csi_rs_pdu_rel13, &unpack_dl_config_csi_rs_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel8, &unpack_dl_config_dci_dl_pdu_rel8_value}, + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel9, &unpack_dl_config_dci_dl_pdu_rel9_value}, + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel10, &unpack_dl_config_dci_dl_pdu_rel10_value}, + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel11, &unpack_dl_config_dci_dl_pdu_rel11_value}, + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel12, &unpack_dl_config_dci_dl_pdu_rel12_value}, + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel13, &unpack_dl_config_dci_dl_pdu_rel13_value}, + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG, &pdu->epdcch_pdu.epdcch_params_rel11, &unpack_dl_config_epdcch_params_rel11_value}, + { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG, &pdu->epdcch_pdu.epdcch_params_rel13, &unpack_dl_config_epdcch_params_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG, &pdu->mpdcch_pdu.mpdcch_pdu_rel13, &unpack_dl_config_mpdcch_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG, &pdu->nbch_pdu.nbch_pdu_rel13, &unpack_dl_config_nbch_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG, &pdu->npdcch_pdu.npdcch_pdu_rel13, &unpack_dl_config_npdcch_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + + } + break; + case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG, &pdu->ndlsch_pdu.ndlsch_pdu_rel13, &unpack_dl_config_ndlsch_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + + } + break; + default: + // Need to log an error + break; + } + } + + return 1; +} + +static uint8_t unpack_dl_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_dl_config_request_t *pNfapiMsg = (nfapi_dl_config_request_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_DL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->dl_config_request_body, &unpack_dl_config_request_body_value}, + }; + + return ( pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_ul_config_ulsch_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_pdu_rel8_t* ulsch_pdu_rel8 = (nfapi_ul_config_ulsch_pdu_rel8_t*)tlv; + + return (pull32(ppReadPackedMsg, &ulsch_pdu_rel8->handle, end) && + pull16(ppReadPackedMsg, &ulsch_pdu_rel8->size, end) && + pull16(ppReadPackedMsg, &ulsch_pdu_rel8->rnti, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->resource_block_start, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->number_of_resource_blocks, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->modulation_type, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->cyclic_shift_2_for_drms, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->frequency_hopping_enabled_flag, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->frequency_hopping_bits, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->new_data_indication, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->redundancy_version, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->harq_process_number, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->ul_tx_mode, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->current_tx_nb, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel8->n_srs, end )); +} +static uint8_t unpack_ul_config_ulsch_pdu_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_pdu_rel10_t* ulsch_pdu_rel10 = (nfapi_ul_config_ulsch_pdu_rel10_t*)tlv; + + return (pull8(ppReadPackedMsg, &ulsch_pdu_rel10->resource_allocation_type, end) && + pull32(ppReadPackedMsg, &ulsch_pdu_rel10->resource_block_coding, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel10->transport_blocks, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel10->transmission_scheme, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel10->number_of_layers, end) & + pull8(ppReadPackedMsg, &ulsch_pdu_rel10->codebook_index, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel10->disable_sequence_hopping_flag, end)); +} +static uint8_t unpack_ul_config_ulsch_pdu_rel11_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_pdu_rel11_t* ulsch_pdu_rel11 = (nfapi_ul_config_ulsch_pdu_rel11_t*)tlv; + + return ( pull8(ppReadPackedMsg, &ulsch_pdu_rel11->virtual_cell_id_enabled_flag, end) && + pull16(ppReadPackedMsg, &ulsch_pdu_rel11->npusch_identity, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel11->dmrs_config_flag, end) && + pull16(ppReadPackedMsg, &ulsch_pdu_rel11->ndmrs_csh_identity, end)); +} +static uint8_t unpack_ul_config_ulsch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_pdu_rel13_t* ulsch_pdu_rel13 = (nfapi_ul_config_ulsch_pdu_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &ulsch_pdu_rel13->ue_type, end) && + pull16(ppReadPackedMsg, &ulsch_pdu_rel13->total_number_of_repetitions, end) && + pull16(ppReadPackedMsg, &ulsch_pdu_rel13->repetition_number, end) && + pull16(ppReadPackedMsg, &ulsch_pdu_rel13->initial_transmission_sf_io, end) && + pull8(ppReadPackedMsg, &ulsch_pdu_rel13->empty_symbols_due_to_re_tunning, end)); +} +static uint8_t unpack_ul_config_cqi_ri_info_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_ri_information_rel8_t* cqi_ri_info_rel8 = (nfapi_ul_config_cqi_ri_information_rel8_t*)tlv; + + return (pull8(ppReadPackedMsg, &cqi_ri_info_rel8->dl_cqi_pmi_size_rank_1, end) && + pull8(ppReadPackedMsg, &cqi_ri_info_rel8->dl_cqi_pmi_size_rank_greater_1, end) && + pull8(ppReadPackedMsg, &cqi_ri_info_rel8->ri_size, end) && + pull8(ppReadPackedMsg, &cqi_ri_info_rel8->delta_offset_cqi, end) && + pull8(ppReadPackedMsg, &cqi_ri_info_rel8->delta_offset_ri, end)); +} + +static uint8_t unpack_ul_config_cqi_ri_info_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_ri_information_rel9_t* cqi_ri_info_rel9 = (nfapi_ul_config_cqi_ri_information_rel9_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &cqi_ri_info_rel9->report_type, end) && + pull8(ppReadPackedMsg, &cqi_ri_info_rel9->delta_offset_cqi, end) && + pull8(ppReadPackedMsg, &cqi_ri_info_rel9->delta_offset_ri, end))) + return 0; + + switch(cqi_ri_info_rel9->report_type) + { + case NFAPI_CSI_REPORT_TYPE_PERIODIC: + { + if(!(pull8(ppReadPackedMsg, &cqi_ri_info_rel9->periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size, end) && + pull8(ppReadPackedMsg, &cqi_ri_info_rel9->periodic_cqi_pmi_ri_report.control_type, end))) + return 0; + } + break; + case NFAPI_CSI_REPORT_TYPE_APERIODIC: + { + if(pull8(ppReadPackedMsg, &cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.number_of_cc, end) ==0) + return 0; + + uint8_t i; + for(i = 0; i < cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.number_of_cc; ++i) + { + if(pull8(ppReadPackedMsg, &cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.cc[i].ri_size, end) == 0) + return 0; + + uint8_t j; + for(j = 0; j < 8; ++j) + { + if(pull8(ppReadPackedMsg, &cqi_ri_info_rel9->aperiodic_cqi_pmi_ri_report.cc[i].dl_cqi_pmi_size[j], end) == 0) + return 0; + } + } + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid report type %d \n", cqi_ri_info_rel9->report_type ); + return 0; + } + break; + }; + return 1; +} + +// NOTE : This function is a little unconventional as we uese the side to +// determine the report type +static uint8_t unpack_ul_config_cqi_ri_info_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_ri_information_rel13_t* cqi_ri_info_rel13 = (nfapi_ul_config_cqi_ri_information_rel13_t*)tlv; + if(cqi_ri_info_rel13->tl.length == 0) + { + cqi_ri_info_rel13->report_type = NFAPI_CSI_REPORT_TYPE_APERIODIC; + } + else + { + cqi_ri_info_rel13->report_type = NFAPI_CSI_REPORT_TYPE_PERIODIC; + if(pull16(ppReadPackedMsg, &cqi_ri_info_rel13->periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size_2, end) == 0) + return 0; + } + return 1; +} +static uint8_t unpack_ul_config_cqi_init_tx_params_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_initial_transmission_parameters_rel8_t* init_tx_params_rel8 = (nfapi_ul_config_initial_transmission_parameters_rel8_t*)tlv; + + return (pull8(ppReadPackedMsg, &init_tx_params_rel8->n_srs_initial, end) && + pull8(ppReadPackedMsg, &init_tx_params_rel8->initial_number_of_resource_blocks, end)); +} +static uint8_t unpack_ul_config_ulsch_harq_info_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_harq_information_rel10_t* harq_info_rel10 = (nfapi_ul_config_ulsch_harq_information_rel10_t*)tlv; + + return (pull8(ppReadPackedMsg, &harq_info_rel10->harq_size, end) && + pull8(ppReadPackedMsg, &harq_info_rel10->delta_offset_harq, end) && + pull8(ppReadPackedMsg, &harq_info_rel10->ack_nack_mode, end)); +} + +static uint8_t unpack_ul_config_ulsch_harq_info_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ulsch_harq_information_rel13_t* harq_info_rel13 = (nfapi_ul_config_ulsch_harq_information_rel13_t*)tlv; + + return (pull16(ppReadPackedMsg, &harq_info_rel13->harq_size_2, end) && + pull8(ppReadPackedMsg, &harq_info_rel13->delta_offset_harq_2, end)); +} + +static uint8_t unpack_ul_config_ue_info_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ue_information_rel8_t* ue_info_rel8 = (nfapi_ul_config_ue_information_rel8_t*)tlv; + + return (pull32(ppReadPackedMsg, &ue_info_rel8->handle, end) && + pull16(ppReadPackedMsg, &ue_info_rel8->rnti, end)); +} +static uint8_t unpack_ul_config_ue_info_rel11_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ue_information_rel11_t* ue_info_rel11 = (nfapi_ul_config_ue_information_rel11_t*)tlv; + + return (pull8(ppReadPackedMsg, &ue_info_rel11->virtual_cell_id_enabled_flag, end) && + pull16(ppReadPackedMsg, &ue_info_rel11->npusch_identity, end)); +} +static uint8_t unpack_ul_config_ue_info_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_ue_information_rel13_t* ue_info_rel13 = (nfapi_ul_config_ue_information_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &ue_info_rel13->ue_type, end) && + pull8(ppReadPackedMsg, &ue_info_rel13->empty_symbols, end) && + pull16(ppReadPackedMsg, &ue_info_rel13->total_number_of_repetitions, end) && + pull16(ppReadPackedMsg, &ue_info_rel13->repetition_number, end)); +} + +static uint8_t unpack_ul_config_cqi_info_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_information_rel8_t* cqi_info_rel8 = (nfapi_ul_config_cqi_information_rel8_t*)tlv; + + return ( pull16(ppReadPackedMsg, &cqi_info_rel8->pucch_index, end) && + pull8(ppReadPackedMsg, &cqi_info_rel8->dl_cqi_pmi_size, end)); +} +static uint8_t unpack_ul_config_cqi_info_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_information_rel10_t* cqi_info_rel10 = (nfapi_ul_config_cqi_information_rel10_t*)tlv; + + return (pull8(ppReadPackedMsg, &cqi_info_rel10->number_of_pucch_resource, end) && + pull16(ppReadPackedMsg, &cqi_info_rel10->pucch_index_p1, end)); +} +static uint8_t unpack_ul_config_cqi_info_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_cqi_information_rel13_t* cqi_info_rel13 = (nfapi_ul_config_cqi_information_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &cqi_info_rel13->csi_mode, end) && + pull16(ppReadPackedMsg, &cqi_info_rel13->dl_cqi_pmi_size_2, end) && + pull8(ppReadPackedMsg, &cqi_info_rel13->starting_prb, end) && + pull8(ppReadPackedMsg, &cqi_info_rel13->n_prb, end) && + pull8(ppReadPackedMsg, &cqi_info_rel13->cdm_index, end) && + pull8(ppReadPackedMsg, &cqi_info_rel13->n_srs, end)); +} + +static uint8_t unpack_ul_config_sr_info_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_sr_information_rel8_t* sr_info_rel8 = (nfapi_ul_config_sr_information_rel8_t*)tlv; + + return ( pull16(ppReadPackedMsg, &sr_info_rel8->pucch_index, end)); +} + +static uint8_t unpack_ul_config_sr_info_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_sr_information_rel10_t* sr_info_rel10 = (nfapi_ul_config_sr_information_rel10_t*)tlv; + + return (pull8(ppReadPackedMsg, &sr_info_rel10->number_of_pucch_resources, end) && + pull16(ppReadPackedMsg, &sr_info_rel10->pucch_index_p1, end)); +} + +static uint8_t unpack_ul_config_harq_info_rel10_tdd_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel10_tdd_t* harq_info_tdd_rel10 = (nfapi_ul_config_harq_information_rel10_tdd_t*)tlv; + + return (pull8(ppReadPackedMsg, &harq_info_tdd_rel10->harq_size, end) && + pull8(ppReadPackedMsg, &harq_info_tdd_rel10->ack_nack_mode, end) && + pull8(ppReadPackedMsg, &harq_info_tdd_rel10->number_of_pucch_resources, end) && + pull16(ppReadPackedMsg, &harq_info_tdd_rel10->n_pucch_1_0, end) && + pull16(ppReadPackedMsg, &harq_info_tdd_rel10->n_pucch_1_1, end) && + pull16(ppReadPackedMsg, &harq_info_tdd_rel10->n_pucch_1_2, end) && + pull16(ppReadPackedMsg, &harq_info_tdd_rel10->n_pucch_1_3, end)); +} + +static uint8_t unpack_ul_config_harq_info_rel8_fdd_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel8_fdd_t* harq_info_fdd_rel8 = (nfapi_ul_config_harq_information_rel8_fdd_t*)tlv; + + return (pull16(ppReadPackedMsg, &harq_info_fdd_rel8->n_pucch_1_0, end) && + pull8(ppReadPackedMsg, &harq_info_fdd_rel8->harq_size, end)); +} + +static uint8_t unpack_ul_config_harq_info_rel9_fdd_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel9_fdd_t* harq_info_fdd_rel9 = (nfapi_ul_config_harq_information_rel9_fdd_t*)tlv; + + return (pull8(ppReadPackedMsg, &harq_info_fdd_rel9->harq_size, end) && + pull8(ppReadPackedMsg, &harq_info_fdd_rel9->ack_nack_mode, end) && + pull8(ppReadPackedMsg, &harq_info_fdd_rel9->number_of_pucch_resources, end) && + pull16(ppReadPackedMsg, &harq_info_fdd_rel9->n_pucch_1_0, end) && + pull16(ppReadPackedMsg, &harq_info_fdd_rel9->n_pucch_1_1, end) && + pull16(ppReadPackedMsg, &harq_info_fdd_rel9->n_pucch_1_2, end) && + pull16(ppReadPackedMsg, &harq_info_fdd_rel9->n_pucch_1_3, end)); +} + +static uint8_t unpack_ul_config_harq_info_rel11_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel11_t* harq_info_rel11 = (nfapi_ul_config_harq_information_rel11_t*)tlv; + + return (pull8(ppReadPackedMsg, &harq_info_rel11->num_ant_ports, end) && + pull16(ppReadPackedMsg, &harq_info_rel11->n_pucch_2_0, end) && + pull16(ppReadPackedMsg, &harq_info_rel11->n_pucch_2_1, end) && + pull16(ppReadPackedMsg, &harq_info_rel11->n_pucch_2_2, end) && + pull16(ppReadPackedMsg, &harq_info_rel11->n_pucch_2_3, end)); +} + +static uint8_t unpack_ul_config_harq_info_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_harq_information_rel13_t* harq_info_rel13 = (nfapi_ul_config_harq_information_rel13_t*)tlv; + + return (pull16(ppReadPackedMsg, &harq_info_rel13->harq_size_2, end) && + pull8(ppReadPackedMsg, &harq_info_rel13->starting_prb, end) && + pull8(ppReadPackedMsg, &harq_info_rel13->n_prb, end) && + pull8(ppReadPackedMsg, &harq_info_rel13->cdm_index, end) && + pull8(ppReadPackedMsg, &harq_info_rel13->n_srs, end)); +} + + +static uint8_t unpack_ul_config_srs_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_srs_pdu_rel8_t* srs_pdu_rel8 = (nfapi_ul_config_srs_pdu_rel8_t*)tlv; + + return (pull32(ppReadPackedMsg, &srs_pdu_rel8->handle, end) && + pull16(ppReadPackedMsg, &srs_pdu_rel8->size, end) && + pull16(ppReadPackedMsg, &srs_pdu_rel8->rnti, end) && + pull8(ppReadPackedMsg, &srs_pdu_rel8->srs_bandwidth, end) && + pull8(ppReadPackedMsg, &srs_pdu_rel8->frequency_domain_position, end) && + pull8(ppReadPackedMsg, &srs_pdu_rel8->srs_hopping_bandwidth, end) && + pull8(ppReadPackedMsg, &srs_pdu_rel8->transmission_comb, end) && + pull16(ppReadPackedMsg, &srs_pdu_rel8->i_srs, end) && + pull8(ppReadPackedMsg, &srs_pdu_rel8->sounding_reference_cyclic_shift, end)); +} + +static uint8_t unpack_ul_config_srs_pdu_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_srs_pdu_rel10_t* srs_pdu_rel10 = (nfapi_ul_config_srs_pdu_rel10_t*)tlv; + return pull8(ppReadPackedMsg, &srs_pdu_rel10->antenna_port, end); +} + +static uint8_t unpack_ul_config_srs_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_srs_pdu_rel13_t* srs_pdu_rel13 = (nfapi_ul_config_srs_pdu_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &srs_pdu_rel13->number_of_combs, end)); +} + +static uint8_t unpack_ul_nb_harq_info_rel13_fdd_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_nb_harq_information_rel13_fdd_t* nb_harq_info_fdd_rel13 = (nfapi_ul_config_nb_harq_information_rel13_fdd_t*)tlv; + + return (pull8(ppReadPackedMsg, &nb_harq_info_fdd_rel13->harq_ack_resource, end)); +} + +static uint8_t unpack_ul_config_nulsch_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_nulsch_pdu_rel13_t* nulsch_pdu_rel13 = (nfapi_ul_config_nulsch_pdu_rel13_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &nulsch_pdu_rel13->nulsch_format, end) && + pull32(ppReadPackedMsg, &nulsch_pdu_rel13->handle, end) && + pull16(ppReadPackedMsg, &nulsch_pdu_rel13->size, end) && + pull16(ppReadPackedMsg, &nulsch_pdu_rel13->rnti, end) && + pull8(ppReadPackedMsg, &nulsch_pdu_rel13->subcarrier_indication, end) && + pull8(ppReadPackedMsg, &nulsch_pdu_rel13->resource_assignment, end) && + pull8(ppReadPackedMsg, &nulsch_pdu_rel13->mcs, end) && + pull8(ppReadPackedMsg, &nulsch_pdu_rel13->redudancy_version, end) && + pull8(ppReadPackedMsg, &nulsch_pdu_rel13->repetition_number, end) && + pull8(ppReadPackedMsg, &nulsch_pdu_rel13->new_data_indication, end) && + pull8(ppReadPackedMsg, &nulsch_pdu_rel13->n_srs, end) && + pull16(ppReadPackedMsg, &nulsch_pdu_rel13->scrambling_sequence_initialization_cinit, end) && + pull16(ppReadPackedMsg, &nulsch_pdu_rel13->sf_idx, end))) + return 0; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG, &nulsch_pdu_rel13->ue_information.ue_information_rel8, &unpack_ul_config_ue_info_rel8_value}, + { NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG, &nulsch_pdu_rel13->ue_information.ue_information_rel11, &unpack_ul_config_ue_info_rel11_value}, + { NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG, &nulsch_pdu_rel13->ue_information.ue_information_rel13, &unpack_ul_config_ue_info_rel13_value}, + { NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG, &nulsch_pdu_rel13->nb_harq_information.nb_harq_information_rel13_fdd, &unpack_ul_nb_harq_info_rel13_fdd_value}, + }; + + return unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, 0, 0); +} + +static uint8_t unpack_ul_config_nrach_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_config_nrach_pdu_rel13_t* nrach_pdu_rel13 = (nfapi_ul_config_nrach_pdu_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &nrach_pdu_rel13->nprach_config_0, end) && + pull8(ppReadPackedMsg, &nrach_pdu_rel13->nprach_config_1, end) && + pull8(ppReadPackedMsg, &nrach_pdu_rel13->nprach_config_2, end)); +} + + +static uint8_t unpack_ul_config_request_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + #define UL_CONFIG_ULSCH_PDU_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG, &_pdu.ulsch_pdu_rel8, &unpack_ul_config_ulsch_pdu_rel8_value}, \ + { NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG, &_pdu.ulsch_pdu_rel10, &unpack_ul_config_ulsch_pdu_rel10_value}, \ + { NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG, &_pdu.ulsch_pdu_rel11, &unpack_ul_config_ulsch_pdu_rel11_value}, \ + { NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG, &_pdu.ulsch_pdu_rel13, &unpack_ul_config_ulsch_pdu_rel13_value}, + + #define UL_CONFIG_CQI_RI_INFO_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG, &_pdu.cqi_ri_information_rel8, &unpack_ul_config_cqi_ri_info_rel8_value}, \ + { NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG, &_pdu.cqi_ri_information_rel9, &unpack_ul_config_cqi_ri_info_rel9_value}, \ + { NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG, &_pdu.cqi_ri_information_rel13, &unpack_ul_config_cqi_ri_info_rel13_value}, + + #define UL_CONFIG_ULSCH_HARQ_INFO_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG, &_pdu.harq_information_rel10, &unpack_ul_config_ulsch_harq_info_rel10_value},\ + { NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG, &_pdu.harq_information_rel13, &unpack_ul_config_ulsch_harq_info_rel13_value}, + + #define UL_CONFIG_INIT_TX_PARAMS_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG, &_pdu.initial_transmission_parameters_rel8, &unpack_ul_config_cqi_init_tx_params_rel8_value}, + + #define UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG, &_pdu.ue_information_rel8, &unpack_ul_config_ue_info_rel8_value}, \ + { NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG, &_pdu.ue_information_rel11, &unpack_ul_config_ue_info_rel11_value}, \ + { NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG, &_pdu.ue_information_rel13, &unpack_ul_config_ue_info_rel13_value}, + + #define UL_CONFIG_UCI_CQI_INFO_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG, &_pdu.cqi_information_rel8, &unpack_ul_config_cqi_info_rel8_value}, \ + { NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG, &_pdu.cqi_information_rel10, &unpack_ul_config_cqi_info_rel10_value}, \ + { NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG, &_pdu.cqi_information_rel13, &unpack_ul_config_cqi_info_rel13_value}, + + #define UL_CONFIG_UCI_SR_INFO_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG, &_pdu.sr_information_rel8, &unpack_ul_config_sr_info_rel8_value}, \ + { NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG, &_pdu.sr_information_rel10, &unpack_ul_config_sr_info_rel10_value}, + + #define UL_CONFIG_UCI_HARQ_INFO_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG, &_pdu.harq_information_rel10_tdd, &unpack_ul_config_harq_info_rel10_tdd_value}, \ + { NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG, &_pdu.harq_information_rel8_fdd, &unpack_ul_config_harq_info_rel8_fdd_value}, \ + { NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG, &_pdu.harq_information_rel9_fdd, &unpack_ul_config_harq_info_rel9_fdd_value}, \ + { NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG, &_pdu.harq_information_rel11, &unpack_ul_config_harq_info_rel11_value}, \ + { NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG, &_pdu.harq_information_rel13, &unpack_ul_config_harq_info_rel13_value}, + + #define UL_CONFIG_SRS_PDU_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG, &_pdu.srs_pdu_rel8, &unpack_ul_config_srs_pdu_rel8_value}, \ + { NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG, &_pdu.srs_pdu_rel10, &unpack_ul_config_srs_pdu_rel10_value}, \ + { NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG, &_pdu.srs_pdu_rel13, &unpack_ul_config_srs_pdu_rel13_value}, + + #define UL_CONFIG_NULSCH_PDU_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG, &_pdu.nulsch_pdu_rel13, &unpack_ul_config_nulsch_pdu_rel13_value}, + + #define UL_CONFIG_NRACH_PDU_UNPACK_FNS(_pdu) \ + { NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG, &_pdu.nrach_pdu_rel13, &unpack_ul_config_nrach_pdu_rel13_value}, + + + nfapi_ul_config_request_body_t* value = (nfapi_ul_config_request_body_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->number_of_pdus, end) && + pull8(ppReadPackedMsg, &value->rach_prach_frequency_resources, end) && + pull8(ppReadPackedMsg, &value->srs_present, end))) + return 0; + + if(value->number_of_pdus > NFAPI_UL_CONFIG_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of ul config pdus exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_pdus, NFAPI_UL_CONFIG_MAX_PDU); + return 0; + } + + if(value->number_of_pdus > 0) + { + value->ul_config_pdu_list = (nfapi_ul_config_request_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_ul_config_request_pdu_t) * value->number_of_pdus, config); + + if(value->ul_config_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate ul config pdu list (count:%d)\n", __FUNCTION__, value->number_of_pdus); + return 0; + } + } + else + { + value->ul_config_pdu_list = 0; + } + + + uint16_t i; + uint16_t total_number_of_pdus = value->number_of_pdus; + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_ul_config_request_pdu_t* pdu = &(value->ul_config_pdu_list[i]); + + if(!(pull8(ppReadPackedMsg, &pdu->pdu_type, end) && + pull8(ppReadPackedMsg, &pdu->pdu_size, end))) + return 0; + + uint8_t *packedPduEnd = (*ppReadPackedMsg) + pdu->pdu_size - 2; + + if(packedPduEnd > end) + { + // pdu end is past buffer end + return 0; + } + + switch(pdu->pdu_type) + { + case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_ULSCH_PDU_UNPACK_FNS(pdu->ulsch_pdu) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + + case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_ULSCH_PDU_UNPACK_FNS(pdu->ulsch_cqi_ri_pdu.ulsch_pdu) + UL_CONFIG_CQI_RI_INFO_UNPACK_FNS(pdu->ulsch_cqi_ri_pdu.cqi_ri_information) + UL_CONFIG_INIT_TX_PARAMS_UNPACK_FNS(pdu->ulsch_cqi_ri_pdu.initial_transmission_parameters) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_ULSCH_PDU_UNPACK_FNS(pdu->ulsch_harq_pdu.ulsch_pdu) + UL_CONFIG_ULSCH_HARQ_INFO_UNPACK_FNS(pdu->ulsch_harq_pdu.harq_information) + UL_CONFIG_INIT_TX_PARAMS_UNPACK_FNS(pdu->ulsch_harq_pdu.initial_transmission_parameters) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_ULSCH_PDU_UNPACK_FNS(pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu) + UL_CONFIG_CQI_RI_INFO_UNPACK_FNS(pdu->ulsch_cqi_harq_ri_pdu.cqi_ri_information) + UL_CONFIG_ULSCH_HARQ_INFO_UNPACK_FNS(pdu->ulsch_cqi_harq_ri_pdu.harq_information) + UL_CONFIG_INIT_TX_PARAMS_UNPACK_FNS(pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->uci_cqi_pdu.ue_information) + UL_CONFIG_UCI_CQI_INFO_UNPACK_FNS(pdu->uci_cqi_pdu.cqi_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->uci_sr_pdu.ue_information) + UL_CONFIG_UCI_SR_INFO_UNPACK_FNS(pdu->uci_sr_pdu.sr_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->uci_harq_pdu.ue_information) + UL_CONFIG_UCI_HARQ_INFO_UNPACK_FNS(pdu->uci_harq_pdu.harq_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->uci_sr_harq_pdu.ue_information) + UL_CONFIG_UCI_SR_INFO_UNPACK_FNS(pdu->uci_sr_harq_pdu.sr_information) + UL_CONFIG_UCI_HARQ_INFO_UNPACK_FNS(pdu->uci_sr_harq_pdu.harq_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->uci_cqi_harq_pdu.ue_information) + UL_CONFIG_UCI_CQI_INFO_UNPACK_FNS(pdu->uci_cqi_harq_pdu.cqi_information) + UL_CONFIG_UCI_HARQ_INFO_UNPACK_FNS(pdu->uci_cqi_harq_pdu.harq_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->uci_cqi_sr_pdu.ue_information) + UL_CONFIG_UCI_CQI_INFO_UNPACK_FNS(pdu->uci_cqi_sr_pdu.cqi_information) + UL_CONFIG_UCI_SR_INFO_UNPACK_FNS(pdu->uci_cqi_sr_pdu.sr_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->uci_cqi_sr_harq_pdu.ue_information) + UL_CONFIG_UCI_CQI_INFO_UNPACK_FNS(pdu->uci_cqi_sr_harq_pdu.cqi_information) + UL_CONFIG_UCI_SR_INFO_UNPACK_FNS(pdu->uci_cqi_sr_harq_pdu.sr_information) + UL_CONFIG_UCI_HARQ_INFO_UNPACK_FNS(pdu->uci_cqi_sr_harq_pdu.harq_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_SRS_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_SRS_PDU_UNPACK_FNS(pdu->srs_pdu) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_UCI_UE_INFO_UNPACK_FNS(pdu->harq_buffer_pdu.ue_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_ULSCH_PDU_UNPACK_FNS(pdu->ulsch_uci_csi_pdu.ulsch_pdu) + UL_CONFIG_UCI_CQI_INFO_UNPACK_FNS(pdu->ulsch_uci_csi_pdu.csi_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_ULSCH_PDU_UNPACK_FNS(pdu->ulsch_uci_harq_pdu.ulsch_pdu) + UL_CONFIG_UCI_HARQ_INFO_UNPACK_FNS(pdu->ulsch_uci_harq_pdu.harq_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_ULSCH_PDU_UNPACK_FNS(pdu->ulsch_csi_uci_harq_pdu.ulsch_pdu) + UL_CONFIG_UCI_CQI_INFO_UNPACK_FNS(pdu->ulsch_csi_uci_harq_pdu.csi_information) + UL_CONFIG_UCI_HARQ_INFO_UNPACK_FNS(pdu->ulsch_csi_uci_harq_pdu.harq_information) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_NULSCH_PDU_UNPACK_FNS(pdu->nulsch_pdu) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_UL_CONFIG_NRACH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + UL_CONFIG_NRACH_PDU_UNPACK_FNS(pdu->nrach_pdu) + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + } + } + return 1; +} + + +static uint8_t unpack_ul_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_ul_config_request_t *pNfapiMsg = (nfapi_ul_config_request_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_UL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->ul_config_request_body, &unpack_ul_config_request_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_hi_dci0_hi_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_hi_pdu_rel8_t* hi_pdu_rel8 = (nfapi_hi_dci0_hi_pdu_rel8_t*)tlv; + + return( pull8(ppReadPackedMsg, &hi_pdu_rel8->resource_block_start, end) && + pull8(ppReadPackedMsg, &hi_pdu_rel8->cyclic_shift_2_for_drms, end) && + pull8(ppReadPackedMsg, &hi_pdu_rel8->hi_value, end) && + pull8(ppReadPackedMsg, &hi_pdu_rel8->i_phich, end) && + pull16(ppReadPackedMsg, &hi_pdu_rel8->transmission_power, end)); +} + +static uint8_t unpack_hi_dci0_hi_pdu_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_hi_pdu_rel10_t* hi_pdu_rel10 = (nfapi_hi_dci0_hi_pdu_rel10_t*)tlv; + + return (pull8(ppReadPackedMsg, &hi_pdu_rel10->flag_tb2, end) && + pull8(ppReadPackedMsg, &hi_pdu_rel10->hi_value_2, end)); +} + +static uint8_t unpack_hi_dci0_dci_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_dci_pdu_rel8_t* dci_pdu_rel8 = (nfapi_hi_dci0_dci_pdu_rel8_t*)tlv; + + return (pull8(ppReadPackedMsg, &dci_pdu_rel8->dci_format, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->cce_index, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->aggregation_level, end) && + pull16(ppReadPackedMsg, &dci_pdu_rel8->rnti, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->resource_block_start, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->number_of_resource_block, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->mcs_1, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->cyclic_shift_2_for_drms, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->frequency_hopping_enabled_flag, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->frequency_hopping_bits, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->new_data_indication_1, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->ue_tx_antenna_seleciton, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->tpc, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->cqi_csi_request, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->ul_index, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel8->dl_assignment_index, end) && + pull32(ppReadPackedMsg, &dci_pdu_rel8->tpc_bitmap, end) && + pull16(ppReadPackedMsg, &dci_pdu_rel8->transmission_power, end)); +} + +static uint8_t unpack_hi_dci0_dci_pdu_rel10_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_dci_pdu_rel10_t* dci_pdu_rel10 = (nfapi_hi_dci0_dci_pdu_rel10_t*)tlv; + + return (pull8(ppReadPackedMsg, &dci_pdu_rel10->cross_carrier_scheduling_flag, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->carrier_indicator, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->size_of_cqi_csi_feild, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->srs_flag, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->srs_request, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->resource_allocation_flag, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->resource_allocation_type, end) && + pull32(ppReadPackedMsg, &dci_pdu_rel10->resource_block_coding, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->mcs_2, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->new_data_indication_2, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->number_of_antenna_ports, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->tpmi, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->total_dci_length_including_padding, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel10->n_ul_rb, end)); +} + +static uint8_t unpack_hi_dci0_dci_pdu_rel12_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_dci_pdu_rel12_t* dci_pdu_rel12 = (nfapi_hi_dci0_dci_pdu_rel12_t*)tlv; + + return ( pull8(ppReadPackedMsg, &dci_pdu_rel12->pscch_resource, end) && + pull8(ppReadPackedMsg, &dci_pdu_rel12->time_resource_pattern, end)); +} + +static uint8_t unpack_hi_dci0_mpdcch_dci_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t* value = (nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &value->mpdcch_narrowband, end) && + pull8(ppReadPackedMsg, &value->number_of_prb_pairs, end) && + pull8(ppReadPackedMsg, &value->resource_block_assignment, end) && + pull8(ppReadPackedMsg, &value->mpdcch_transmission_type, end) && + pull8(ppReadPackedMsg, &value->start_symbol, end) && + pull8(ppReadPackedMsg, &value->ecce_index, end) && + pull8(ppReadPackedMsg, &value->aggreagation_level, end) && + pull8(ppReadPackedMsg, &value->rnti_type, end) && + pull16(ppReadPackedMsg, &value->rnti, end) && + pull8(ppReadPackedMsg, &value->ce_mode, end) && + pull16(ppReadPackedMsg, &value->drms_scrambling_init, end) && + pull16(ppReadPackedMsg, &value->initial_transmission_sf_io, end) && + pull16(ppReadPackedMsg, &value->transmission_power, end) && + pull8(ppReadPackedMsg, &value->dci_format, end) && + pull8(ppReadPackedMsg, &value->resource_block_start, end) && + pull8(ppReadPackedMsg, &value->number_of_resource_blocks, end) && + pull8(ppReadPackedMsg, &value->mcs, end) && + pull8(ppReadPackedMsg, &value->pusch_repetition_levels, end) && + pull8(ppReadPackedMsg, &value->frequency_hopping_flag, end) && + pull8(ppReadPackedMsg, &value->new_data_indication, end) && + pull8(ppReadPackedMsg, &value->harq_process, end) && + pull8(ppReadPackedMsg, &value->redudency_version, end) && + pull8(ppReadPackedMsg, &value->tpc, end) && + pull8(ppReadPackedMsg, &value->csi_request, end) && + pull8(ppReadPackedMsg, &value->ul_inex, end) && + pull8(ppReadPackedMsg, &value->dai_presence_flag, end) && + pull8(ppReadPackedMsg, &value->dl_assignment_index, end) && + pull8(ppReadPackedMsg, &value->srs_request, end) && + pull8(ppReadPackedMsg, &value->dci_subframe_repetition_number, end) && + pull32(ppReadPackedMsg, &value->tcp_bitmap, end) && + pull8(ppReadPackedMsg, &value->total_dci_length_include_padding, end) && + pull8(ppReadPackedMsg, &value->number_of_tx_antenna_ports, end) && + pullarray16(ppReadPackedMsg, value->precoding_value, NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS, value->number_of_tx_antenna_ports, end)); +} + +static uint8_t unpack_hi_dci0_npdcch_dci_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_hi_dci0_npdcch_dci_pdu_rel13_t* value = (nfapi_hi_dci0_npdcch_dci_pdu_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &value->ncce_index, end) && + pull8(ppReadPackedMsg, &value->aggregation_level, end) && + pull8(ppReadPackedMsg, &value->start_symbol, end) && + pull16(ppReadPackedMsg, &value->rnti, end) && + pull8(ppReadPackedMsg, &value->scrambling_reinitialization_batch_index, end) && + pull8(ppReadPackedMsg, &value->nrs_antenna_ports_assumed_by_the_ue, end) && + pull8(ppReadPackedMsg, &value->subcarrier_indication, end) && + pull8(ppReadPackedMsg, &value->resource_assignment, end) && + pull8(ppReadPackedMsg, &value->scheduling_delay, end) && + pull8(ppReadPackedMsg, &value->mcs, end) && + pull8(ppReadPackedMsg, &value->redudancy_version, end) && + pull8(ppReadPackedMsg, &value->repetition_number, end) && + pull8(ppReadPackedMsg, &value->new_data_indicator, end) && + pull8(ppReadPackedMsg, &value->dci_subframe_repetition_number, end)); +} + +static uint8_t unpack_hi_dci0_request_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_hi_dci0_request_body_t* value = (nfapi_hi_dci0_request_body_t*)tlv; + + if(!(pull16(ppReadPackedMsg, &value->sfnsf, end) && + pull8(ppReadPackedMsg, &value->number_of_dci, end) && + pull8(ppReadPackedMsg, &value->number_of_hi, end))) + return 0; + + uint8_t totalNumPdus = value->number_of_hi + value->number_of_dci; + + if(totalNumPdus > NFAPI_HI_DCI0_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of dci0 pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, totalNumPdus, NFAPI_HI_DCI0_MAX_PDU); + return 0; + } + + if(totalNumPdus > 0) + { + value->hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_hi_dci0_request_pdu_t) * totalNumPdus, config); + if(value->hi_dci0_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate hi dci0 pdu list (count:%d)\n", __FUNCTION__, totalNumPdus); + return 0; + } + } + else + { + value->hi_dci0_pdu_list = 0; + } + + uint8_t i; + for(i = 0; i < totalNumPdus; ++i) + { + nfapi_hi_dci0_request_pdu_t* pdu = &(value->hi_dci0_pdu_list[i]); + + if(!(pull8(ppReadPackedMsg, &pdu->pdu_type, end) && + pull8(ppReadPackedMsg, &pdu->pdu_size, end))) + return 0; + + uint8_t *packedPduEnd = (*ppReadPackedMsg) + pdu->pdu_size - 2; + + if(packedPduEnd > end) + { + // pdu end if past buffer end + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s pdu size to big %d %d\n", __FUNCTION__, packedPduEnd, end); + return 0; + } + + switch(pdu->pdu_type) + { + case NFAPI_HI_DCI0_HI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG, &pdu->hi_pdu.hi_pdu_rel8, &unpack_hi_dci0_hi_pdu_rel8_value}, + { NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG, &pdu->hi_pdu.hi_pdu_rel10, &unpack_hi_dci0_hi_pdu_rel10_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_HI_DCI0_DCI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG, &pdu->dci_pdu.dci_pdu_rel8, &unpack_hi_dci0_dci_pdu_rel8_value}, + { NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG, &pdu->dci_pdu.dci_pdu_rel10, &unpack_hi_dci0_dci_pdu_rel10_value}, + { NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG, &pdu->dci_pdu.dci_pdu_rel12, &unpack_hi_dci0_dci_pdu_rel12_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG, &pdu->epdcch_dci_pdu.epdcch_dci_pdu_rel8, &unpack_hi_dci0_dci_pdu_rel8_value}, + { NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG, &pdu->epdcch_dci_pdu.epdcch_dci_pdu_rel10, &unpack_hi_dci0_dci_pdu_rel10_value}, + { NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG, &pdu->epdcch_dci_pdu.epdcch_parameters_rel11, &unpack_dl_config_epdcch_params_rel11_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG, &pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13, &unpack_hi_dci0_mpdcch_dci_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG, &pdu->npdcch_dci_pdu.npdcch_dci_pdu_rel13, &unpack_hi_dci0_npdcch_dci_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid pdu type %d \n", pdu->pdu_type ); + } + break; + }; + } + + return 1; +} + +static uint8_t unpack_hi_dci0_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_hi_dci0_request_t *pNfapiMsg = (nfapi_hi_dci0_request_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_HI_DCI0_REQUEST_BODY_TAG, &pNfapiMsg->hi_dci0_request_body, &unpack_hi_dci0_request_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + +} + +static uint8_t unpack_tx_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + uint8_t proceed = 1; + nfapi_tx_request_t *pNfapiMsg = (nfapi_tx_request_t*)msg; + + if(pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) == 0) + return 0; + + while (((uint8_t*)(*ppReadPackedMsg) < end) && proceed) + { + nfapi_tl_t generic_tl; + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + switch(generic_tl.tag) + { + case NFAPI_TX_REQUEST_BODY_TAG: + { + pNfapiMsg->tx_request_body.tl = generic_tl; + + if( pull16(ppReadPackedMsg, &pNfapiMsg->tx_request_body.number_of_pdus, end) == 0) + return 0; + + if(pNfapiMsg->tx_request_body.number_of_pdus > NFAPI_TX_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of tx pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, pNfapiMsg->tx_request_body.number_of_pdus, NFAPI_TX_MAX_PDU); + return 0; + } + + if(pNfapiMsg->tx_request_body.number_of_pdus > 0) + { + pNfapiMsg->tx_request_body.tx_pdu_list = (nfapi_tx_request_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_tx_request_pdu_t) * pNfapiMsg->tx_request_body.number_of_pdus, config); + if(pNfapiMsg->tx_request_body.tx_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate tx pdu list (count:%d)\n", __FUNCTION__, pNfapiMsg->tx_request_body.number_of_pdus); + return 0; + } + } + else + { + pNfapiMsg->tx_request_body.tx_pdu_list = 0; + } + + + uint16_t i; + uint16_t totalNumPdus = pNfapiMsg->tx_request_body.number_of_pdus; + for(i = 0; i < totalNumPdus; ++i) + { + nfapi_tx_request_pdu_t* pdu = &(pNfapiMsg->tx_request_body.tx_pdu_list[i]); + + uint16_t length = 0; + uint16_t index = 0; + + if(!(pull16(ppReadPackedMsg, &length, end) && + pull16(ppReadPackedMsg, &index, end))) + return 0; + + pdu->pdu_length = length; + pdu->pdu_index = index; + + + // TODO : May need to rethink this bit + pdu->num_segments = 1; + pdu->segments[0].segment_length = pdu->pdu_length; + pdu->segments[0].segment_data = nfapi_p7_allocate(pdu->pdu_length, config); + + if(pdu->segments[0].segment_data) + { + if(!pullarray8(ppReadPackedMsg, pdu->segments[0].segment_data, pdu->segments[0].segment_length, pdu->segments[0].segment_length, end)) + return 0; + if (0 && pdu->segments[0].segment_length == 3) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() BCH? segment_data:%x %x %x\n", __FUNCTION__, + pdu->segments[0].segment_data[0], + pdu->segments[0].segment_data[1], + pdu->segments[0].segment_data[2] + ); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "unpack_tx_request: Failed to allocate pdu (len:%d) %d/%d %d\n", pdu->pdu_length, totalNumPdus, i, pdu->pdu_index); + } + } + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "unpack_tx_request FIXME : Invalid pdu type %d \n", generic_tl.tag ); + } + break; + }; + } + + return 1; +} + +static uint8_t unpack_harq_indication_tdd_harq_data_bundling(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_harq_data_bundling_t* value = (nfapi_harq_indication_tdd_harq_data_bundling_t*)tlv; + + return (pull8(ppReadPackedMsg, &value->value_0, end) && + pull8(ppReadPackedMsg, &value->value_1, end)); +} + +static uint8_t unpack_harq_indication_tdd_harq_data_multiplexing(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_harq_data_multiplexing_t* value = (nfapi_harq_indication_tdd_harq_data_multiplexing_t*)tlv; + + return (pull8(ppReadPackedMsg, &value->value_0, end) && + pull8(ppReadPackedMsg, &value->value_1, end) && + pull8(ppReadPackedMsg, &value->value_2, end) && + pull8(ppReadPackedMsg, &value->value_3, end)); +} +static uint8_t unpack_harq_indication_tdd_harq_data_special_bundling(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_harq_data_special_bundling_t* value = (nfapi_harq_indication_tdd_harq_data_special_bundling_t*)tlv; + return ( pull8(ppReadPackedMsg, &value->value_0, end)); +} +static uint8_t unpack_harq_indication_tdd_harq_data(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_harq_data_t* value = (nfapi_harq_indication_tdd_harq_data_t*)tlv; + return (pull8(ppReadPackedMsg, &value->value_0, end)); +} + +static uint8_t unpack_harq_indication_tdd_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_rel8_t* value = (nfapi_harq_indication_tdd_rel8_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->mode, end) && + pull8(ppReadPackedMsg, &value->number_of_ack_nack, end))) + return 0; + + uint8_t result = 0; + switch(value->mode) + { + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING: + result = unpack_harq_indication_tdd_harq_data_bundling(&value->harq_data.bundling, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING: + result = unpack_harq_indication_tdd_harq_data_multiplexing(&value->harq_data.multiplex, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING: + result = unpack_harq_indication_tdd_harq_data_special_bundling(&value->harq_data.special_bundling, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3: + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION: + result = 1; + break; + default: + // TODO add error message + return 0; + break; + } + return result; +} + +static uint8_t unpack_harq_indication_tdd_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_rel9_t* value = (nfapi_harq_indication_tdd_rel9_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->mode, end) && + pull8(ppReadPackedMsg, &value->number_of_ack_nack, end))) + return 0; + + if(value->number_of_ack_nack > NFAPI_MAX_NUMBER_ACK_NACK_TDD) + { + // TODO : add error message + return 0; + } + + uint16_t idx = 0; + for(idx = 0; idx < value->number_of_ack_nack; ++idx) + { + uint8_t result = 0; + switch(value->mode) + { + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].bundling, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].multiplex, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING: + result = unpack_harq_indication_tdd_harq_data_special_bundling(&value->harq_data[idx].special_bundling, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].channel_selection, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].format_3, ppReadPackedMsg, end); + break; + default: + // TODO add error message + return 0; + break; + } + + if(result == 0) + return 0; + } + return 1; +} + +static uint8_t unpack_harq_indication_tdd_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_tdd_rel13_t* value = (nfapi_harq_indication_tdd_rel13_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->mode, end) && + pull16(ppReadPackedMsg, &value->number_of_ack_nack, end))) + return 0; + + if(value->number_of_ack_nack > NFAPI_MAX_NUMBER_ACK_NACK_TDD) + { + // TODO : add error message + return 0; + } + + uint16_t idx = 0; + for(idx = 0; idx < value->number_of_ack_nack; ++idx) + { + uint8_t result = 0; + switch(value->mode) + { + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].bundling, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].multiplex, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING: + result = unpack_harq_indication_tdd_harq_data_special_bundling(&value->harq_data[idx].special_bundling, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].channel_selection, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].format_3, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_4: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].format_4, ppReadPackedMsg, end); + break; + case NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_5: + result = unpack_harq_indication_tdd_harq_data(&value->harq_data[idx].format_5, ppReadPackedMsg, end); + break; + default: + // TODO add error message + return 0; + break; + } + + if(result == 0) + return 0; + } + return 1; +} + +static uint8_t unpack_harq_indication_fdd_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_fdd_rel8_t* value = (nfapi_harq_indication_fdd_rel8_t*)tlv; + return (pull8(ppReadPackedMsg, &value->harq_tb1, end) && + pull8(ppReadPackedMsg, &value->harq_tb2, end)); +} + +static uint8_t unpack_harq_indication_fdd_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_fdd_rel9_t* value = (nfapi_harq_indication_fdd_rel9_t*)tlv; + + return (pull8(ppReadPackedMsg, &value->mode, end) && + pull8(ppReadPackedMsg, &value->number_of_ack_nack, end) && + pullarray8(ppReadPackedMsg, value->harq_tb_n, NFAPI_HARQ_ACK_NACK_REL9_MAX, value->number_of_ack_nack, end)); +} + +static uint8_t unpack_harq_indication_fdd_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_harq_indication_fdd_rel13_t* value = (nfapi_harq_indication_fdd_rel13_t*)tlv; + + return (pull8(ppReadPackedMsg, &value->mode, end) && + pull16(ppReadPackedMsg, &value->number_of_ack_nack, end) && + pullarray8(ppReadPackedMsg, value->harq_tb_n, NFAPI_HARQ_ACK_NACK_REL13_MAX, value->number_of_ack_nack, end)); +} + +static uint8_t unpack_ul_cqi_information_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_ul_cqi_information_t* value = (nfapi_ul_cqi_information_t*)tlv; + + return (pull8(ppReadPackedMsg, &value->ul_cqi, end) && + pull8(ppReadPackedMsg, &value->channel, end)); +} + + + +static uint8_t unpack_harq_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_harq_indication_body_t* value = (nfapi_harq_indication_body_t*)tlv; + uint8_t* harqBodyEnd = *ppReadPackedMsg + value->tl.length; + + if(harqBodyEnd > end) + return 0; + + if(pull16(ppReadPackedMsg, &value->number_of_harqs, end) == 0) + return 0; + + if(value->number_of_harqs > NFAPI_HARQ_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of harq ind pdus exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_harqs, NFAPI_HARQ_IND_MAX_PDU); + return 0; + } + + value->harq_pdu_list = (nfapi_harq_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_harq_indication_pdu_t) * value->number_of_harqs, config); + if(value->harq_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate harq ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_harqs); + return 0; + } + + uint8_t i = 0; + for(i = 0; i < value->number_of_harqs; ++i) + { + nfapi_harq_indication_pdu_t* pdu = &(value->harq_pdu_list[i]); + if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0) + return 0; + + uint8_t* harqPduInstanceEnd = *ppReadPackedMsg + pdu->instance_length; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, unpack_rx_ue_information_value }, + { NFAPI_HARQ_INDICATION_TDD_REL8_TAG, &pdu->harq_indication_tdd_rel8, &unpack_harq_indication_tdd_rel8_value}, + { NFAPI_HARQ_INDICATION_TDD_REL9_TAG, &pdu->harq_indication_tdd_rel9, &unpack_harq_indication_tdd_rel9_value}, + { NFAPI_HARQ_INDICATION_TDD_REL13_TAG, &pdu->harq_indication_tdd_rel13, &unpack_harq_indication_tdd_rel13_value}, + { NFAPI_HARQ_INDICATION_FDD_REL8_TAG, &pdu->harq_indication_fdd_rel8, &unpack_harq_indication_fdd_rel8_value}, + { NFAPI_HARQ_INDICATION_FDD_REL9_TAG, &pdu->harq_indication_fdd_rel9, &unpack_harq_indication_fdd_rel9_value}, + { NFAPI_HARQ_INDICATION_FDD_REL13_TAG, &pdu->harq_indication_fdd_rel13, &unpack_harq_indication_fdd_rel13_value}, + { NFAPI_UL_CQI_INFORMATION_TAG, &pdu->ul_cqi_information, &unpack_ul_cqi_information_value} + }; + + if(unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, harqPduInstanceEnd, 0, 0) == 0) + return 0; + + } + + return 1; +} + +static uint8_t unpack_harq_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_harq_indication_t *pNfapiMsg = (nfapi_harq_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_HARQ_INDICATION_BODY_TAG, &pNfapiMsg->harq_indication_body, &unpack_harq_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_crc_indication_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_crc_indication_rel8_t* crc_pdu_rel8 = (nfapi_crc_indication_rel8_t*)tlv; + return ( pull8(ppReadPackedMsg, &crc_pdu_rel8->crc_flag, end) ); +} + +static uint8_t unpack_crc_indication_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_crc_indication_body_t* value = (nfapi_crc_indication_body_t*)tlv; + uint8_t* crcBodyEnd = *ppReadPackedMsg + value->tl.length; + + if(crcBodyEnd > end) + return 0; + + if(pull16(ppReadPackedMsg, &value->number_of_crcs, end) == 0) + return 0; + + if(value->number_of_crcs > NFAPI_CRC_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of crc ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_crcs, NFAPI_CRC_IND_MAX_PDU); + return 0; + } + + if(value->number_of_crcs > 0) + { + value->crc_pdu_list = (nfapi_crc_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_crc_indication_pdu_t) * value->number_of_crcs, config); + if(value->crc_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate crc ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_crcs); + return 0; + } + } + else + { + value->crc_pdu_list = 0; + } + + + uint8_t i = 0; + for(i = 0; i < value->number_of_crcs; ++i) + { + nfapi_crc_indication_pdu_t* pdu = &(value->crc_pdu_list[i]); + + if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0) + return 0; + + uint8_t* crcPduInstanceEnd = *ppReadPackedMsg + pdu->instance_length; + + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, unpack_rx_ue_information_value }, + { NFAPI_CRC_INDICATION_REL8_TAG, &pdu->crc_indication_rel8, unpack_crc_indication_rel8_value }, + }; + + if(unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, crcPduInstanceEnd, 0, 0) == 0) + return 0; + } + + return 1; +} + +static uint8_t unpack_crc_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_crc_indication_t *pNfapiMsg = (nfapi_crc_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_CRC_INDICATION_BODY_TAG, &pNfapiMsg->crc_indication_body, &unpack_crc_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_rx_indication_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_rx_indication_rel8_t* value = (nfapi_rx_indication_rel8_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->length, end) && + pull16(ppReadPackedMsg, &value->offset, end) && + pull8(ppReadPackedMsg, &value->ul_cqi, end) && + pull16(ppReadPackedMsg, &value->timing_advance, end)); +} +static uint8_t unpack_rx_indication_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_rx_indication_rel9_t* value = (nfapi_rx_indication_rel9_t*)tlv; + return (pull16(ppReadPackedMsg, &value->timing_advance_r9, end)); +} + +static uint8_t unpack_rx_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_rx_indication_body_t* value = (nfapi_rx_indication_body_t*)tlv; + + // the rxBodyEnd points to the end of the cqi PDU's + uint8_t* rxBodyEnd = *ppReadPackedMsg + value->tl.length; + uint8_t* rxPduEnd = rxBodyEnd; + + uint8_t* numberOfPdusAddress = *ppReadPackedMsg; + + if(rxBodyEnd > end) + { + // pdu end is past buffer end + return 0; + } + + if(pull16(ppReadPackedMsg, &value->number_of_pdus, end) == 0) + return 0; + + if(value->number_of_pdus > NFAPI_RX_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of rx ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_pdus, NFAPI_RX_IND_MAX_PDU); + return 0; + } + + if(value->number_of_pdus > 0) + { + value->rx_pdu_list = (nfapi_rx_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_rx_indication_pdu_t) * value->number_of_pdus, config); + if(value->rx_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate rx ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_pdus); + return 0; + } + } + else + { + value->rx_pdu_list = 0; + } + + uint8_t i = 0; + nfapi_rx_indication_pdu_t* pdu = 0; + while((uint8_t*)(*ppReadPackedMsg) < rxBodyEnd && (uint8_t*)(*ppReadPackedMsg) < rxPduEnd) + { + nfapi_tl_t generic_tl; + if( unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + switch(generic_tl.tag) + { + case NFAPI_RX_UE_INFORMATION_TAG: + { + pdu = &(value->rx_pdu_list[i++]); + pdu->rx_ue_information.tl = generic_tl; + if(unpack_rx_ue_information_value(&pdu->rx_ue_information, ppReadPackedMsg, end) == 0) + return 0; + } + break; + case NFAPI_RX_INDICATION_REL8_TAG: + { + if(pdu != 0) + { + pdu->rx_indication_rel8.tl = generic_tl; + if(unpack_rx_indication_rel8_value(&pdu->rx_indication_rel8, ppReadPackedMsg, end) == 0) + return 0; + + if(pdu->rx_indication_rel8.offset > 0) + { + // Need to check that the data is within the tlv + if(numberOfPdusAddress + pdu->rx_indication_rel8.offset + pdu->rx_indication_rel8.length <= rxBodyEnd) + { + // If this the first pdu set the rxPduEnd + if(numberOfPdusAddress + pdu->rx_indication_rel8.offset < rxPduEnd) + { + rxPduEnd = numberOfPdusAddress + pdu->rx_indication_rel8.offset; + + if(rxPduEnd > end) + { + // pdu end is past buffer end + return 0; + } + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME: the rx data is outside of the tlv\n"); + } + } + } + } + break; + case NFAPI_RX_INDICATION_REL9_TAG: + { + if(pdu != 0) + { + pdu->rx_indication_rel9.tl = generic_tl; + if(unpack_rx_indication_rel9_value(&pdu->rx_indication_rel9, ppReadPackedMsg, end) == 0) + return 0; + } + } + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "RX_ULSCH.indication Invalid pdu type %d \n", generic_tl.tag ); + } + break; + } + } + + uint8_t idx = 0; + for(idx = 0; idx < value->number_of_pdus; ++idx) + { + if(value->rx_pdu_list[idx].rx_indication_rel8.tl.tag == NFAPI_RX_INDICATION_REL8_TAG) + { + uint32_t length = value->rx_pdu_list[idx].rx_indication_rel8.length; + value->rx_pdu_list[idx].data = nfapi_p7_allocate(length, config); + if(pullarray8(ppReadPackedMsg, value->rx_pdu_list[idx].data, length, length, end) == 0) + { + return 0; + } + } + } + + return 1; +} + +static uint8_t unpack_rx_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_rx_indication_t *pNfapiMsg = (nfapi_rx_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_RX_INDICATION_BODY_TAG, &pNfapiMsg->rx_indication_body, &unpack_rx_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_preamble_pdu_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_preamble_pdu_rel8_t* preamble_pdu_rel8 = (nfapi_preamble_pdu_rel8_t*)tlv; + + return (pull16(ppReadPackedMsg, &preamble_pdu_rel8->rnti, end) && + pull8(ppReadPackedMsg, &preamble_pdu_rel8->preamble, end) && + pull16(ppReadPackedMsg, &preamble_pdu_rel8->timing_advance, end)); +} + +static uint8_t unpack_preamble_pdu_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_preamble_pdu_rel9_t* preamble_pdu_rel9 = (nfapi_preamble_pdu_rel9_t*)tlv; + return pull16(ppReadPackedMsg, &preamble_pdu_rel9->timing_advance_r9, end); +} + +static uint8_t unpack_preamble_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_preamble_pdu_rel13_t* preamble_pdu_rel13 = (nfapi_preamble_pdu_rel13_t*)tlv; + return pull8(ppReadPackedMsg, &preamble_pdu_rel13->rach_resource_type, end); +} + +static uint8_t unpack_rach_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_rach_indication_body_t* value = (nfapi_rach_indication_body_t*)tlv; + uint8_t* rachBodyEnd = *ppReadPackedMsg + value->tl.length; + + if(rachBodyEnd > end) + return 0; + + if(pull16(ppReadPackedMsg, &value->number_of_preambles, end) == 0) + return 0; + + if(value->number_of_preambles > NFAPI_PREAMBLE_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of preamble du's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_preambles, NFAPI_PREAMBLE_MAX_PDU); + return 0; + } + + if(value->number_of_preambles > 0) + { + value->preamble_list = (nfapi_preamble_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_preamble_pdu_t) * value->number_of_preambles, config); + if(value->preamble_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate preamble pdu list (count:%d)\n", __FUNCTION__, value->number_of_preambles); + return 0; + } + } + else + { + value->preamble_list = 0; + } + + + uint8_t i = 0; + for(i = 0; i < value->number_of_preambles; ++i) + { + nfapi_preamble_pdu_t* pdu = &(value->preamble_list[i]); + + if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0) + return 0; + + uint8_t* preamblePduInstanceEnd = *ppReadPackedMsg + pdu->instance_length; + + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_PREAMBLE_REL8_TAG, &pdu->preamble_rel8, unpack_preamble_pdu_rel8_value }, + { NFAPI_PREAMBLE_REL9_TAG, &pdu->preamble_rel9, unpack_preamble_pdu_rel9_value }, + { NFAPI_PREAMBLE_REL13_TAG, &pdu->preamble_rel13, unpack_preamble_pdu_rel13_value }, + }; + + if(unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, preamblePduInstanceEnd, 0, 0) == 0) + return 0; + } + return 1; +} + +static uint8_t unpack_rach_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_rach_indication_t *pNfapiMsg = (nfapi_rach_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_RACH_INDICATION_BODY_TAG, &pNfapiMsg->rach_indication_body, &unpack_rach_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_srs_indication_fdd_rel8_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_srs_indication_fdd_rel8_t* srs_pdu_fdd_rel8 = (nfapi_srs_indication_fdd_rel8_t*)tlv; + + if(!(pull16(ppReadPackedMsg, &srs_pdu_fdd_rel8->doppler_estimation, end) && + pull16(ppReadPackedMsg, &srs_pdu_fdd_rel8->timing_advance, end) && + pull8(ppReadPackedMsg, &srs_pdu_fdd_rel8->number_of_resource_blocks, end) && + pull8(ppReadPackedMsg, &srs_pdu_fdd_rel8->rb_start, end) && + pullarray8(ppReadPackedMsg, srs_pdu_fdd_rel8->snr, NFAPI_NUM_RB_MAX, srs_pdu_fdd_rel8->number_of_resource_blocks, end))) + return 0; + return 1; +} + +static uint8_t unpack_srs_indication_fdd_rel9_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_srs_indication_fdd_rel9_t* srs_pdu_fdd_rel9 = (nfapi_srs_indication_fdd_rel9_t*)tlv; + return (pull16(ppReadPackedMsg, &srs_pdu_fdd_rel9->timing_advance_r9, end)); +} + +static uint8_t unpack_srs_indication_tdd_rel10_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_srs_indication_ttd_rel10_t* srs_pdu_tdd_rel10 = (nfapi_srs_indication_ttd_rel10_t*)tlv; + return (pull8(ppReadPackedMsg, &srs_pdu_tdd_rel10->uppts_symbol, end)); +} + +static uint8_t unpack_srs_indication_fdd_rel11_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_srs_indication_fdd_rel11_t* srs_pdu_fdd_rel11 = (nfapi_srs_indication_fdd_rel11_t*)tlv; + return ( pull16(ppReadPackedMsg, &srs_pdu_fdd_rel11->ul_rtoa, end)); +} + +static uint8_t unpack_tdd_channel_measurement_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_tdd_channel_measurement_t* value = (nfapi_tdd_channel_measurement_t*)tlv; + + if(!(pull8(ppReadPackedMsg, &value->num_prb_per_subband, end) && + pull8(ppReadPackedMsg, &value->number_of_subbands, end) && + pull8(ppReadPackedMsg, &value->num_atennas, end))) + return 0; + + if(value->number_of_subbands > NFAPI_MAX_NUM_SUBBANDS) + { + // todo : add error + return 0; + } + + if(value->num_atennas > NFAPI_MAX_NUM_PHYSICAL_ANTENNAS) + { + // todo : add error + return 0; + } + + uint8_t idx = 0; + for(idx = 0; idx < value->number_of_subbands; ++idx) + { + if(!(pull8(ppReadPackedMsg, &value->subands[idx].subband_index, end) && + pullarray16(ppReadPackedMsg, value->subands[idx].channel, NFAPI_MAX_NUM_PHYSICAL_ANTENNAS, value->num_atennas, end))) + return 0; + } + + return 1; +} + + +static uint8_t unpack_srs_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_srs_indication_body_t* value = (nfapi_srs_indication_body_t*)tlv; + uint8_t* srsBodyEnd = *ppReadPackedMsg + value->tl.length; + + if(srsBodyEnd > end) + return 0; + + if(pull8(ppReadPackedMsg, &value->number_of_ues, end) == 0) + return 0; + + if(value->number_of_ues > NFAPI_SRS_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of srs ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_ues, NFAPI_SRS_IND_MAX_PDU); + return 0; + } + + if(value->number_of_ues > 0) + { + value->srs_pdu_list = (nfapi_srs_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_srs_indication_pdu_t) * value->number_of_ues, config); + if(value->srs_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate srs ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_ues); + return 0; + } + } + else + { + value->srs_pdu_list = 0; + } + + + + uint8_t i = 0; + for(i = 0; i < value->number_of_ues; ++i) + { + nfapi_srs_indication_pdu_t* pdu = &(value->srs_pdu_list[i]); + + + if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0) + return 0; + + uint8_t* srsPduInstanceEnd = *ppReadPackedMsg + pdu->instance_length; + + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, unpack_rx_ue_information_value }, + { NFAPI_SRS_INDICATION_FDD_REL8_TAG, &pdu->srs_indication_fdd_rel8, unpack_srs_indication_fdd_rel8_value}, + { NFAPI_SRS_INDICATION_FDD_REL9_TAG, &pdu->srs_indication_fdd_rel9, unpack_srs_indication_fdd_rel9_value}, + { NFAPI_SRS_INDICATION_TDD_REL10_TAG, &pdu->srs_indication_tdd_rel10, unpack_srs_indication_tdd_rel10_value}, + { NFAPI_SRS_INDICATION_FDD_REL11_TAG, &pdu->srs_indication_fdd_rel11, unpack_srs_indication_fdd_rel11_value}, + { NFAPI_TDD_CHANNEL_MEASUREMENT_TAG, &pdu->tdd_channel_measurement, unpack_tdd_channel_measurement_value}, + }; + + if(unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, srsPduInstanceEnd, 0, 0) == 0) + return 0; + } + return 1; +} + +static uint8_t unpack_srs_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_srs_indication_t *pNfapiMsg = (nfapi_srs_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_SRS_INDICATION_BODY_TAG, &pNfapiMsg->srs_indication_body, &unpack_srs_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + + +static uint8_t unpack_sr_indication_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_sr_indication_body_t* value = (nfapi_sr_indication_body_t*)tlv; + uint8_t* srBodyEnd = *ppReadPackedMsg + value->tl.length; + + if(srBodyEnd > end) + return 0; + + if(pull16(ppReadPackedMsg, &value->number_of_srs, end) == 0) + return 0; + + if(value->number_of_srs > NFAPI_SR_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of sr ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_srs, NFAPI_SR_IND_MAX_PDU); + return 0; + } + + if(value->number_of_srs > 0) + { + value->sr_pdu_list = (nfapi_sr_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_sr_indication_pdu_t) * value->number_of_srs, config); + if(value->sr_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate sr ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_srs); + return 0; + } + } + else + { + value->sr_pdu_list = 0; + } + + uint8_t i = 0; + for(i = 0; i < value->number_of_srs; ++i) + { + nfapi_sr_indication_pdu_t* pdu = &(value->sr_pdu_list[i]); + + if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0) + return 0; + + uint8_t* srPduInstanceEnd = *ppReadPackedMsg + pdu->instance_length; + + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, unpack_rx_ue_information_value }, + { NFAPI_UL_CQI_INFORMATION_TAG, &pdu->ul_cqi_information, unpack_ul_cqi_information_value }, + }; + + if(unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, srPduInstanceEnd, 0, 0) == 0) + return 0; + } + + return 1; + +} + +static int unpack_sr_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_sr_indication_t *pNfapiMsg = (nfapi_sr_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_SR_INDICATION_BODY_TAG, &pNfapiMsg->sr_indication_body, &unpack_sr_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} +static uint8_t unpack_cqi_indication_rel8_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_cqi_indication_rel8_t* cqi_pdu_rel8 = (nfapi_cqi_indication_rel8_t*)tlv; + + return (pull16(ppReadPackedMsg, &cqi_pdu_rel8->length, end) && + pull16(ppReadPackedMsg, &cqi_pdu_rel8->data_offset, end) && + pull8(ppReadPackedMsg, &cqi_pdu_rel8->ul_cqi, end) && + pull8(ppReadPackedMsg, &cqi_pdu_rel8->ri, end) && + pull16(ppReadPackedMsg, &cqi_pdu_rel8->timing_advance, end)); + +} + +static uint8_t unpack_cqi_indication_rel9_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_cqi_indication_rel9_t* cqi_pdu_rel9 = (nfapi_cqi_indication_rel9_t*)tlv; + + if(!(pull16(ppReadPackedMsg, &cqi_pdu_rel9->length, end) && + pull16(ppReadPackedMsg, &cqi_pdu_rel9->data_offset, end) && + pull8(ppReadPackedMsg, &cqi_pdu_rel9->ul_cqi, end) && + pull8(ppReadPackedMsg, &cqi_pdu_rel9->number_of_cc_reported, end))) + return 0; + + if(cqi_pdu_rel9->number_of_cc_reported > NFAPI_CC_MAX) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : out of bound array\n"); + return 0; + } + + if(!(pullarray8(ppReadPackedMsg, cqi_pdu_rel9->ri, NFAPI_CC_MAX, cqi_pdu_rel9->number_of_cc_reported, end) && + pull16(ppReadPackedMsg, &cqi_pdu_rel9->timing_advance, end) && + pull16(ppReadPackedMsg, &cqi_pdu_rel9->timing_advance_r9, end))) + return 0; + + return 1; +} + +static uint8_t unpack_cqi_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_cqi_indication_body_t* value = (nfapi_cqi_indication_body_t*)tlv; + + // the cqiBodyEnd points to the end of the cqi PDU's + uint8_t* cqiBodyEnd = *ppReadPackedMsg + value->tl.length; + + //uint8_t* cqiPduEnd = cqiBodyEnd; + //uint8_t* numberOfPdusAddress = *ppReadPackedMsg; + + if(cqiBodyEnd > end) + return 0; + + if(pull16(ppReadPackedMsg, &value->number_of_cqis, end) == 0) + return 0; + + if(value->number_of_cqis > NFAPI_CQI_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of cqi ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_cqis, NFAPI_CQI_IND_MAX_PDU); + return -1; + } + + if(value->number_of_cqis > 0) + { + value->cqi_pdu_list = (nfapi_cqi_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_cqi_indication_pdu_t) * value->number_of_cqis, config); + if(value->cqi_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate cqi ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_cqis); + return 0; + } + } + else + { + value->cqi_pdu_list = 0; + } + + if(value->number_of_cqis > 0) + { + value->cqi_raw_pdu_list = (nfapi_cqi_indication_raw_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_cqi_indication_raw_pdu_t) * value->number_of_cqis, config); + if(value->cqi_raw_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate raw cqi ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_cqis); + return 0; + } + } + else + { + value->cqi_raw_pdu_list = 0; + } + + uint8_t i = 0; + for(i = 0; i < value->number_of_cqis; ++i) + { + nfapi_cqi_indication_pdu_t* pdu = &(value->cqi_pdu_list[i]); + memset(pdu, 0, sizeof(nfapi_cqi_indication_pdu_t)); + + if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0) + return 0; + + uint8_t* cqiPduInstanceEnd = *ppReadPackedMsg + pdu->instance_length; + + + while((uint8_t*)(*ppReadPackedMsg) < cqiPduInstanceEnd) + { + nfapi_tl_t generic_tl; + if(unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0) + return 0; + + switch(generic_tl.tag) + { + case NFAPI_RX_UE_INFORMATION_TAG: + pdu->rx_ue_information.tl = generic_tl; + if(unpack_rx_ue_information_value(&pdu->rx_ue_information, ppReadPackedMsg, end) == 0) + return 0; + break; + case NFAPI_CQI_INDICATION_REL8_TAG: + pdu->cqi_indication_rel8.tl = generic_tl; + if(unpack_cqi_indication_rel8_value(&pdu->cqi_indication_rel8, ppReadPackedMsg, end) == 0) + return 0; + + break; + case NFAPI_CQI_INDICATION_REL9_TAG: + pdu->cqi_indication_rel9.tl = generic_tl; + if(unpack_cqi_indication_rel9_value(&pdu->cqi_indication_rel9, ppReadPackedMsg, end) == 0) + return 0; + + break; + case NFAPI_UL_CQI_INFORMATION_TAG: + pdu->ul_cqi_information.tl = generic_tl; + if(unpack_ul_cqi_information_value(&pdu->ul_cqi_information, ppReadPackedMsg, end) == 0) + return 0; + break; + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "RX_CQI.indication Invalid pdu type %d \n", generic_tl.tag ); + } + break; + + }; + } + } + + uint8_t idx = 0; + for(idx = 0; idx < value->number_of_cqis; ++idx) + { + if(value->cqi_pdu_list[idx].cqi_indication_rel8.tl.tag == NFAPI_CQI_INDICATION_REL8_TAG) + { + if(pullarray8(ppReadPackedMsg, &(value->cqi_raw_pdu_list[idx].pdu[0]), NFAPI_CQI_RAW_MAX_LEN, value->cqi_pdu_list[idx].cqi_indication_rel8.length, end) == 0) + return 0; + } + else if(value->cqi_pdu_list[idx].cqi_indication_rel9.tl.tag == NFAPI_CQI_INDICATION_REL9_TAG) + { + if(pullarray8(ppReadPackedMsg, &(value->cqi_raw_pdu_list[idx].pdu[0]), NFAPI_CQI_RAW_MAX_LEN, value->cqi_pdu_list[idx].cqi_indication_rel9.length, end) == 0) + return 0; + } + } + + + return 1; + +} + +static uint8_t unpack_cqi_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_cqi_indication_t *pNfapiMsg = (nfapi_cqi_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_CQI_INDICATION_BODY_TAG, &pNfapiMsg->cqi_indication_body, &unpack_cqi_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} +static uint8_t unpack_lbt_pdsch_req_pdu_rel13_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lbt_pdsch_req_pdu_rel13_t* value = (nfapi_lbt_pdsch_req_pdu_rel13_t*)tlv; + + return (pull32(ppReadPackedMsg, &value->handle, end) && + pull32(ppReadPackedMsg, &value->mp_cca, end) && + pull32(ppReadPackedMsg, &value->n_cca, end) && + pull32(ppReadPackedMsg, &value->offset, end) && + pull32(ppReadPackedMsg, &value->lte_txop_sf, end) && + pull16(ppReadPackedMsg, &value->txop_sfn_sf_end, end) && + pull32(ppReadPackedMsg, &value->lbt_mode, end)); +} + +static uint8_t unpack_lbt_drs_req_pdu_rel13_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lbt_drs_req_pdu_rel13_t* value = (nfapi_lbt_drs_req_pdu_rel13_t*)tlv; + + return (pull32(ppReadPackedMsg, &value->handle, end) && + pull32(ppReadPackedMsg, &value->offset, end) && + pull16(ppReadPackedMsg, &value->sfn_sf_end, end) && + pull32(ppReadPackedMsg, &value->lbt_mode, end)); +} + + +static uint8_t unpack_lbt_config_request_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_lbt_dl_config_request_body_t* value = (nfapi_lbt_dl_config_request_body_t*)tlv; + + if(pull16(ppReadPackedMsg, &value->number_of_pdus, end) == 0) + return 0; + + if(value->number_of_pdus > NFAPI_LBT_DL_CONFIG_REQ_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of lbt dl config pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_pdus, NFAPI_LBT_DL_CONFIG_REQ_MAX_PDU); + return 0; + } + + if(value->number_of_pdus) + { + value->lbt_dl_config_req_pdu_list = (nfapi_lbt_dl_config_request_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_lbt_dl_config_request_pdu_t) * value->number_of_pdus, config); + if(value->lbt_dl_config_req_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate lbt dl config pdu list (count:%d)\n", __FUNCTION__, value->number_of_pdus); + return 0; + } + } + else + { + value->lbt_dl_config_req_pdu_list = 0; + } + + + uint16_t i; + uint16_t total_number_of_pdus = value->number_of_pdus; + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_lbt_dl_config_request_pdu_t* pdu = &(value->lbt_dl_config_req_pdu_list[i]); + + if(!(pull8(ppReadPackedMsg, &pdu->pdu_type, end) && + pull8(ppReadPackedMsg, &pdu->pdu_size, end))) + return 0; + + uint8_t *packedPduEnd = (*ppReadPackedMsg) + pdu->pdu_size - 2; + + if(packedPduEnd > end) + return 0; + + switch(pdu->pdu_type) + { + case NFAPI_LBT_DL_CONFIG_REQUEST_PDSCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LBT_PDSCH_REQ_PDU_REL13_TAG, &pdu->lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13, &unpack_lbt_pdsch_req_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_LBT_DL_CONFIG_REQUEST_DRS_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LBT_DRS_REQ_PDU_REL13_TAG, &pdu->lbt_drs_req_pdu.lbt_drs_req_pdu_rel13, &unpack_lbt_drs_req_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + default: + NFAPI_TRACE(NFAPI_TRACE_ERROR, "LBT_DL_CONFIG.request body invalid pdu type %d\n", pdu->pdu_type); + return 0; + } + } + + return 1; +} +static uint8_t unpack_lbt_dl_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_lbt_dl_config_request_t *pNfapiMsg = (nfapi_lbt_dl_config_request_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_LBT_DL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->lbt_dl_config_request_body, &unpack_lbt_config_request_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_lbt_pdsch_rsp_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lbt_pdsch_rsp_pdu_rel13_t* value = (nfapi_lbt_pdsch_rsp_pdu_rel13_t*)tlv; + + return (pull32(ppReadPackedMsg, &value->handle, end) && + pull32(ppReadPackedMsg, &value->result, end) && + pull32(ppReadPackedMsg, &value->lte_txop_symbols, end) && + pull32(ppReadPackedMsg, &value->initial_partial_sf, end)); + +} +static uint8_t unpack_lbt_drs_rsp_pdu_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_lbt_drs_rsp_pdu_rel13_t* value = (nfapi_lbt_drs_rsp_pdu_rel13_t*)tlv; + + return (pull32(ppReadPackedMsg, &value->handle, end) && + pull32(ppReadPackedMsg, &value->result, end)); +} + +static uint8_t unpack_lbt_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_lbt_dl_indication_body_t* value = (nfapi_lbt_dl_indication_body_t*)tlv; + + if(pull16(ppReadPackedMsg, &value->number_of_pdus, end) == 0) + return 0; + + if(value->number_of_pdus > NFAPI_LBT_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of lbt dl ind pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_pdus, NFAPI_LBT_IND_MAX_PDU); + return 0; + } + + if(value->number_of_pdus > 0) + { + value->lbt_indication_pdu_list = (nfapi_lbt_dl_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_lbt_dl_indication_pdu_t) * value->number_of_pdus, config); + if(value->lbt_indication_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate lbt dl ind config pdu list (count:%d)\n", __FUNCTION__, value->number_of_pdus); + return 0; + } + } + else + { + value->lbt_indication_pdu_list = 0; + } + + uint16_t i; + uint16_t total_number_of_pdus = value->number_of_pdus; + for(i = 0; i < total_number_of_pdus; ++i) + { + nfapi_lbt_dl_indication_pdu_t* pdu = &(value->lbt_indication_pdu_list[i]); + + if(!(pull8(ppReadPackedMsg, &pdu->pdu_type, end) && + pull8(ppReadPackedMsg, &pdu->pdu_size, end))) + return 0; + + uint8_t *packedPduEnd = (*ppReadPackedMsg) + pdu->pdu_size - 2; + + if(packedPduEnd > end) + return 0; + + switch(pdu->pdu_type) + { + case NFAPI_LBT_DL_RSP_PDSCH_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG, &pdu->lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13, &unpack_lbt_pdsch_rsp_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + case NFAPI_LBT_DL_RSP_DRS_PDU_TYPE: + { + unpack_tlv_t unpack_fns[] = + { + { NFAPI_LBT_DRS_RSP_PDU_REL13_TAG, &pdu->lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13, &unpack_lbt_drs_rsp_pdu_rel13_value}, + }; + + unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); + } + break; + default: + NFAPI_TRACE(NFAPI_TRACE_ERROR, "LBT_DL.indication body invalid pdu type %d\n", pdu->pdu_type); + return 0; + } + } + + return 1; +} +static uint8_t unpack_lbt_dl_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_lbt_dl_indication_t *pNfapiMsg = (nfapi_lbt_dl_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_LBT_DL_INDICATION_BODY_TAG, &pNfapiMsg->lbt_dl_indication_body, &unpack_lbt_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_nb_harq_indication_fdd_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nb_harq_indication_fdd_rel13_t* value = (nfapi_nb_harq_indication_fdd_rel13_t*)tlv; + return (pull8(ppReadPackedMsg, &value->harq_tb1, end)); +} + + +static uint8_t unpack_nb_harq_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_nb_harq_indication_body_t* value = (nfapi_nb_harq_indication_body_t*)tlv; + uint8_t* nbharqBodyEnd = *ppReadPackedMsg + value->tl.length; + + if(nbharqBodyEnd > end) + return 0; + + if(pull16(ppReadPackedMsg, &value->number_of_harqs, end) == 0) + return 0; + + if(value->number_of_harqs > NFAPI_HARQ_IND_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of harq ind pdus exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_harqs, NFAPI_HARQ_IND_MAX_PDU); + return 0; + } + + value->nb_harq_pdu_list = (nfapi_nb_harq_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_nb_harq_indication_pdu_t) * value->number_of_harqs, config); + if(value->nb_harq_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate harq ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_harqs); + return 0; + } + + uint8_t i = 0; + for(i = 0; i < value->number_of_harqs; ++i) + { + nfapi_nb_harq_indication_pdu_t* pdu = &(value->nb_harq_pdu_list[i]); + if(pull16(ppReadPackedMsg, &pdu->instance_length, end) == 0) + return 0; + + uint8_t* harqPduInstanceEnd = *ppReadPackedMsg + pdu->instance_length; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_RX_UE_INFORMATION_TAG, &pdu->rx_ue_information, unpack_rx_ue_information_value }, + { NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG, &pdu->nb_harq_indication_fdd_rel13, &unpack_nb_harq_indication_fdd_rel13_value}, + { NFAPI_UL_CQI_INFORMATION_TAG, &pdu->ul_cqi_information, &unpack_ul_cqi_information_value} + }; + + if(unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, harqPduInstanceEnd, 0, 0) == 0) + return 0; + + } + + return 1; +} + +static uint8_t unpack_nb_harq_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_nb_harq_indication_t *pNfapiMsg = (nfapi_nb_harq_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_NB_HARQ_INDICATION_BODY_TAG, &pNfapiMsg->nb_harq_indication_body, &unpack_nb_harq_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_nrach_indication_rel13_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end) +{ + nfapi_nrach_indication_pdu_rel13_t* value = (nfapi_nrach_indication_pdu_rel13_t*)tlv; + + return (pull16(ppReadPackedMsg, &value->rnti, end) && + pull8(ppReadPackedMsg, &value->initial_sc, end) && + pull16(ppReadPackedMsg, &value->timing_advance, end) && + pull8(ppReadPackedMsg, &value->nrach_ce_level, end)); +} + + +static uint8_t unpack_nrach_indication_body_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + nfapi_nrach_indication_body_t* value = (nfapi_nrach_indication_body_t*)tlv; + uint8_t* nrachBodyEnd = *ppReadPackedMsg + value->tl.length; + + if(nrachBodyEnd > end) + return 0; + + if(pull8(ppReadPackedMsg, &value->number_of_initial_scs_detected, end) == 0) + return 0; + + if(value->number_of_initial_scs_detected > NFAPI_PREAMBLE_MAX_PDU) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of detected scs ind pdus exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->number_of_initial_scs_detected, NFAPI_PREAMBLE_MAX_PDU); + return 0; + } + + value->nrach_pdu_list = (nfapi_nrach_indication_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_nrach_indication_pdu_t) * value->number_of_initial_scs_detected, config); + if(value->nrach_pdu_list == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate nrach ind pdu list (count:%d)\n", __FUNCTION__, value->number_of_initial_scs_detected); + return 0; + } + + uint8_t i = 0; + for(i = 0; i < value->number_of_initial_scs_detected; ++i) + { + nfapi_nrach_indication_pdu_t* pdu = &(value->nrach_pdu_list[i]); + + uint8_t* nrachPduInstanceEnd = *ppReadPackedMsg + 4 + 6; + + unpack_tlv_t unpack_fns[] = + { + { NFAPI_NRACH_INDICATION_REL13_TAG, &pdu->nrach_indication_rel13, &unpack_nrach_indication_rel13_value}, + }; + + if(unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, nrachPduInstanceEnd, 0, 0) == 0) + return 0; + + } + + return 1; +} + +static uint8_t unpack_nrach_indication(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_nrach_indication_t *pNfapiMsg = (nfapi_nrach_indication_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + { NFAPI_NRACH_INDICATION_BODY_TAG, &pNfapiMsg->nrach_indication_body, &unpack_nrach_indication_body_value}, + }; + + return (pull16(ppReadPackedMsg, &pNfapiMsg->sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_dl_node_sync_t *pNfapiMsg = (nfapi_dl_node_sync_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->delta_sfn_sf, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_ul_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_ul_node_sync_t *pNfapiMsg = (nfapi_ul_node_sync_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) && + pull32(ppReadPackedMsg, &pNfapiMsg->t2, end) && + pull32(ppReadPackedMsg, &pNfapiMsg->t3, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + +static uint8_t unpack_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) +{ + nfapi_timing_info_t *pNfapiMsg = (nfapi_timing_info_t*)msg; + + unpack_p7_tlv_t unpack_fns[] = + { + }; + + return (pull32(ppReadPackedMsg, &pNfapiMsg->last_sfn_sf, end) && + pull32(ppReadPackedMsg, &pNfapiMsg->time_since_last_timing_info, end) && + pull32(ppReadPackedMsg, &pNfapiMsg->dl_config_jitter, end) && + pull32(ppReadPackedMsg, &pNfapiMsg->tx_request_jitter, end) && + pull32(ppReadPackedMsg, &pNfapiMsg->ul_config_jitter, end) && + pull32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_jitter, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->dl_config_latest_delay, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->tx_request_latest_delay, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->ul_config_latest_delay, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_latest_delay, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->dl_config_earliest_arrival, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->tx_request_earliest_arrival, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->ul_config_earliest_arrival, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->hi_dci0_earliest_arrival, end) && + unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); +} + + +// unpack length check + +static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen) +{ + int retLen = 0; + + switch (msgId) + { + case NFAPI_DL_CONFIG_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_dl_config_request_t)) + retLen = sizeof(nfapi_dl_config_request_t); + break; + + case NFAPI_UL_CONFIG_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_ul_config_request_t)) + retLen = sizeof(nfapi_ul_config_request_t); + break; + + case NFAPI_SUBFRAME_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_subframe_indication_t)) + retLen = sizeof(nfapi_subframe_indication_t); + break; + + case NFAPI_HI_DCI0_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_hi_dci0_request_t)) + retLen = sizeof(nfapi_hi_dci0_request_t); + break; + + case NFAPI_TX_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_tx_request_t)) + retLen = sizeof(nfapi_tx_request_t); + break; + + case NFAPI_HARQ_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_harq_indication_t)) + retLen = sizeof(nfapi_harq_indication_t); + break; + + case NFAPI_CRC_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_crc_indication_t)) + retLen = sizeof(nfapi_crc_indication_t); + break; + + case NFAPI_RX_ULSCH_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_rx_indication_t)) + retLen = sizeof(nfapi_rx_indication_t); + break; + + case NFAPI_RACH_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_rach_indication_t)) + retLen = sizeof(nfapi_rach_indication_t); + break; + + case NFAPI_SRS_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_srs_indication_t)) + retLen = sizeof(nfapi_srs_indication_t); + break; + + case NFAPI_RX_SR_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_sr_indication_t)) + retLen = sizeof(nfapi_sr_indication_t); + break; + + case NFAPI_RX_CQI_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_cqi_indication_t)) + retLen = sizeof(nfapi_cqi_indication_t); + break; + + case NFAPI_LBT_DL_CONFIG_REQUEST: + if (unpackedBufLen >= sizeof(nfapi_lbt_dl_config_request_t)) + retLen = sizeof(nfapi_lbt_dl_config_request_t); + break; + + case NFAPI_LBT_DL_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_lbt_dl_indication_t)) + retLen = sizeof(nfapi_lbt_dl_indication_t); + break; + + case NFAPI_NB_HARQ_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_nb_harq_indication_t)) + retLen = sizeof(nfapi_nb_harq_indication_t); + break; + + case NFAPI_NRACH_INDICATION: + if (unpackedBufLen >= sizeof(nfapi_nrach_indication_t)) + retLen = sizeof(nfapi_nrach_indication_t); + break; + + case NFAPI_DL_NODE_SYNC: + if (unpackedBufLen >= sizeof(nfapi_dl_node_sync_t)) + retLen = sizeof(nfapi_dl_node_sync_t); + break; + + case NFAPI_UL_NODE_SYNC: + if (unpackedBufLen >= sizeof(nfapi_ul_node_sync_t)) + retLen = sizeof(nfapi_ul_node_sync_t); + break; + + case NFAPI_TIMING_INFO: + if (unpackedBufLen >= sizeof(nfapi_timing_info_t)) + retLen = sizeof(nfapi_timing_info_t); + break; + + default: + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown message ID %d\n", msgId); + break; + } + + return retLen; +} + + +// Main unpack functions - public + +int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config) +{ + nfapi_p7_message_header_t *pMessageHeader = pUnpackedBuf; + uint8_t *pReadPackedMessage = pMessageBuf; + uint8_t *end = pMessageBuf + messageBufLen; + + if (pMessageBuf == NULL || pUnpackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 header unpack supplied pointers are null\n"); + return -1; + } + + if (messageBufLen < NFAPI_P7_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p7_message_header_t)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 header unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen); + return -1; + } + + // process the header + if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) && + pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end) && + pull32(&pReadPackedMessage, &pMessageHeader->checksum, end) && + pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end))) + return -1; + + return 0; +} + +int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config) +{ + int result = 0; + nfapi_p7_message_header_t *pMessageHeader = (nfapi_p7_message_header_t*)pUnpackedBuf; + uint8_t *pReadPackedMessage = pMessageBuf; + uint8_t *end = pMessageBuf + messageBufLen; + + if (pMessageBuf == NULL || pUnpackedBuf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied pointers are null\n"); + return -1; + } + + if (messageBufLen < NFAPI_P7_HEADER_LENGTH || unpackedBufLen < sizeof(nfapi_p7_message_header_t)) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen); + return -1; + } + + // clean the supplied buffer for - tag value blanking + (void)memset(pUnpackedBuf, 0, unpackedBufLen); + + // process the header + if(!(pull16(&pReadPackedMessage, &pMessageHeader->phy_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_id, end) && + pull16(&pReadPackedMessage, &pMessageHeader->message_length, end) && + pull16(&pReadPackedMessage, &pMessageHeader->m_segment_sequence, end) && + pull32(&pReadPackedMessage, &pMessageHeader->checksum, end) && + pull32(&pReadPackedMessage, &pMessageHeader->transmit_timestamp, end))) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack header failed\n"); + return -1; + } + + if((uint8_t*)(pMessageBuf + pMessageHeader->message_length) > end) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack message length is greater than the message buffer \n"); + return -1; + } + + /* + if(check_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack unpack buffer is not large enough \n"); + return -1; + } + */ + + // look for the specific message + switch (pMessageHeader->message_id) + { + case NFAPI_DL_CONFIG_REQUEST: + if (check_unpack_length(NFAPI_DL_CONFIG_REQUEST, unpackedBufLen)) + result = unpack_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_UL_CONFIG_REQUEST: + if (check_unpack_length(NFAPI_UL_CONFIG_REQUEST, unpackedBufLen)) + result = unpack_ul_config_request(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_HI_DCI0_REQUEST: + if (check_unpack_length(NFAPI_HI_DCI0_REQUEST, unpackedBufLen)) + result = unpack_hi_dci0_request(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_TX_REQUEST: + if (check_unpack_length(NFAPI_TX_REQUEST, unpackedBufLen)) + result = unpack_tx_request(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_HARQ_INDICATION: + if (check_unpack_length(NFAPI_HARQ_INDICATION, unpackedBufLen)) + result = unpack_harq_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_CRC_INDICATION: + if (check_unpack_length(NFAPI_CRC_INDICATION, unpackedBufLen)) + result = unpack_crc_indication(&pReadPackedMessage,end , pMessageHeader, config); + else + return -1; + break; + + case NFAPI_RX_ULSCH_INDICATION: + if (check_unpack_length(NFAPI_RX_ULSCH_INDICATION, unpackedBufLen)) + result = unpack_rx_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_RACH_INDICATION: + if (check_unpack_length(NFAPI_RACH_INDICATION, unpackedBufLen)) + result = unpack_rach_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_SRS_INDICATION: + if (check_unpack_length(NFAPI_SRS_INDICATION, unpackedBufLen)) + result = unpack_srs_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_RX_SR_INDICATION: + if (check_unpack_length(NFAPI_RX_SR_INDICATION, unpackedBufLen)) + result = unpack_sr_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_RX_CQI_INDICATION: + if (check_unpack_length(NFAPI_RX_CQI_INDICATION, unpackedBufLen)) + result = unpack_cqi_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_LBT_DL_CONFIG_REQUEST: + if (check_unpack_length(NFAPI_LBT_DL_CONFIG_REQUEST, unpackedBufLen)) + result = unpack_lbt_dl_config_request(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_LBT_DL_INDICATION: + if (check_unpack_length(NFAPI_LBT_DL_INDICATION, unpackedBufLen)) + result = unpack_lbt_dl_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_NB_HARQ_INDICATION: + if (check_unpack_length(NFAPI_NB_HARQ_INDICATION, unpackedBufLen)) + result = unpack_nb_harq_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_NRACH_INDICATION: + if (check_unpack_length(NFAPI_NRACH_INDICATION, unpackedBufLen)) + result = unpack_nrach_indication(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_DL_NODE_SYNC: + if (check_unpack_length(NFAPI_DL_NODE_SYNC, unpackedBufLen)) + result = unpack_dl_node_sync(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + case NFAPI_UL_NODE_SYNC: + if (check_unpack_length(NFAPI_UL_NODE_SYNC, unpackedBufLen)) + result = unpack_ul_node_sync(&pReadPackedMessage, end , pMessageHeader, config); + else + return -1; + break; + + case NFAPI_TIMING_INFO: + if (check_unpack_length(NFAPI_TIMING_INFO, unpackedBufLen)) + result = unpack_timing_info(&pReadPackedMessage, end, pMessageHeader, config); + else + return -1; + break; + + default: + + if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + if(config && config->unpack_p7_vendor_extension) + { + result = (config->unpack_p7_vendor_extension)(pMessageHeader, &pReadPackedMessage, end, config); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve decoder provided\n", __FUNCTION__, pMessageHeader->message_id); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id); + } + break; + } + + if(result == 0) + return -1; + else + return 0; +} + diff --git a/nfapi/open-nFAPI/nfapi/tests/Makefile.am b/nfapi/open-nFAPI/nfapi/tests/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..46785869b02d4e026b22b49416d782dc5bd4f2a6 --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/tests/Makefile.am @@ -0,0 +1,36 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#nfapi unit test +AUTOMAKE_OPTIONS=subdir-objects + +AM_CPPFLAGS = -I$(top_srcdir)/nfapi/inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)pnf/public_inc $(CFLAGS_CUNIT) -Wall -Werror +AM_CFLAGS = -I$(top_srcdir)/nfapi/inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/pnf/public_inc $(CFLAGS_CUNIT) -Wall -Werror + +check_PROGRAMS= test_nfapi +test_nfapi_SOURCES = nfapi_cunit_main.c ../src/nfapi.c ../src/nfapi_p7.c ../../common/src/debug.c ../src/nfapi_p5.c ../src/nfapi_p4.c +test_nfapi_LDADD=$(top_builddir)/pnf/libnfapi_pnf.a -L$(libdir) -lpthread -lrt -lsctp -lz -lcunit + + +#jTEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh --ingore-exit +#TEST_ENVIRONMENT = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh + +#AM_TESTS_ENVIRONMENT = env AM_TAP_AWK='$(AWK)' $(SHELL); +LOG_DRIVER = $(top_srcdir)/tap-driver.sh +#AM_LOG_FLAGS = -- test_nfapi + +TESTS=$(check_PROGRAMS) +EXTRA_DIST = $(TESTS) diff --git a/nfapi/open-nFAPI/nfapi/tests/nfapi_cunit_main.c b/nfapi/open-nFAPI/nfapi/tests/nfapi_cunit_main.c new file mode 100644 index 0000000000000000000000000000000000000000..daaf65a3ffebb3a0f889cacc02727cff1e2bd659 --- /dev/null +++ b/nfapi/open-nFAPI/nfapi/tests/nfapi_cunit_main.c @@ -0,0 +1,5511 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "CUnit.h" +#include "Basic.h" +#include "Automated.h" +//#include "CUnit/Console.h" + +#include "nfapi_interface.h" +#include "nfapi.h" +#include <stdio.h> // for printf +#include <stdlib.h> +#include "debug.h" +#include "nfapi_interface.h" +/* Test Suite setup and cleanup functions: */ + +int init_suite(void) { return 0; } +int clean_suite(void) { return 0; } + +#define MAX_PACKED_MESSAGE_SIZE 8192 + +#define IN_OUT_ASSERT(_V) { CU_ASSERT_EQUAL(in._V, out._V); } + +typedef struct +{ + nfapi_tl_t tl; + uint16_t value1; + uint32_t value2; +} my_vendor_extention; + +extern void* nfapi_allocate_pdu(size_t size) +{ + return malloc(size); +} + +extern int nfapi_test_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* config) +{ + printf("nfapi_unpack_vendor_extension_tlv\n"); + + if(tl->tag == NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE) + { + my_vendor_extention* mve = (my_vendor_extention*)malloc(sizeof(my_vendor_extention)); + mve->tl.tag = NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE; + + if(!(pull16(ppReadPackedMsg, &mve->value1, end) && + pull32(ppReadPackedMsg, &mve->value2, end))) + { + free(mve); + return 0; + } + + (*ve) = mve; + + } + + return 1; +} + +int nfapi_pack_vendor_extension_tlv_called = 0; +extern int nfapi_test_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) +{ + printf("nfapi_pack_vendor_extension_tlv\n"); + nfapi_pack_vendor_extension_tlv_called++; + + my_vendor_extention* mve = (my_vendor_extention*)ve; + + return (push16(mve->value1, ppWritePackedMsg, end) && + push32(mve->value2, ppWritePackedMsg, end)); + +} + +uint8_t gTestNfapiMessageTx[MAX_PACKED_MESSAGE_SIZE]; + + +uint8_t rand8(uint8_t min, uint8_t max) +{ + return ((rand() % (max + 1 - min)) + min); +} + +/************* Test case functions ****************/ + +void test_case_sample(void) +{ + /*Sample assert function, use as per your test case scenario.*/ + CU_ASSERT(CU_TRUE); + CU_ASSERT_NOT_EQUAL(2, -1); + CU_ASSERT_STRING_EQUAL("string #1", "string #1"); + CU_ASSERT_STRING_NOT_EQUAL("string #1", "string #2"); + + CU_ASSERT(CU_FALSE); + CU_ASSERT_EQUAL(2, 3); + CU_ASSERT_STRING_NOT_EQUAL("string #1", "string #1"); + CU_ASSERT_STRING_EQUAL("string #1", "string #2"); +} + + +int nfapi_test_verify_configreq_params(nfapi_pnf_config_request_t pnfConfigRequest_in, nfapi_pnf_config_request_t pnfConfigRequest_out) +{ + int i=0; + if(memcmp(&pnfConfigRequest_in, &pnfConfigRequest_out, sizeof(nfapi_pnf_config_request_t)) == 0) + { + /*packed and unpacked phy config request are matched.*/ + + printf("Success: packed and unpacked phy config request are matched\n"); + return 1; + } + else + { + if (pnfConfigRequest_in.header.message_id != pnfConfigRequest_out.header.message_id) + { + printf("Mismatch: packed message id %d, unpacked message id %d\n", + pnfConfigRequest_in.header.message_id, pnfConfigRequest_out.header.message_id); + } + if (pnfConfigRequest_in.header.message_length != pnfConfigRequest_out.header.message_length) + { + printf("Mismatch: packed message_length %d, unpacked message_length %d\n", + pnfConfigRequest_in.header.message_length, pnfConfigRequest_out.header.message_length); + } + if (pnfConfigRequest_in.header.phy_id != pnfConfigRequest_out.header.phy_id) + { + printf("Mismatch: packed phy_id %d, unpacked phy_id %d\n", + pnfConfigRequest_in.header.phy_id, pnfConfigRequest_out.header.phy_id); + } + if (pnfConfigRequest_in.pnf_phy_rf_config.number_phy_rf_config_info != pnfConfigRequest_out.pnf_phy_rf_config.number_phy_rf_config_info) + { + printf("Mismatch: packed number_phy_rf_config_info %d, unpacked number_phy_rf_config_info %d\n", + pnfConfigRequest_in.pnf_phy_rf_config.number_phy_rf_config_info, pnfConfigRequest_out.pnf_phy_rf_config.number_phy_rf_config_info); + } + + for (i=0; i < NFAPI_MAX_PHY_RF_INSTANCES; i++) + { + if (pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[i].phy_id != pnfConfigRequest_out.pnf_phy_rf_config.phy_rf_config[i].phy_id) + { + printf("Mismatch: rf idx %d, packed phy id %d, unpacked phy id %d\n", + i, pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[i].phy_id, pnfConfigRequest_out.pnf_phy_rf_config.phy_rf_config[i].phy_id); + } + if (pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[i].phy_config_index!= pnfConfigRequest_out.pnf_phy_rf_config.phy_rf_config[i].phy_config_index) + { + printf("Mismatch: rf idx %d, packed phy_config_index %d, unpacked phy_config_index %d\n", + i, pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[i].phy_config_index, pnfConfigRequest_out.pnf_phy_rf_config.phy_rf_config[i].phy_config_index); + } + if (pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[i].rf_config_index != pnfConfigRequest_out.pnf_phy_rf_config.phy_rf_config[i].rf_config_index) + { + printf("Mismatch: rf idx %d, packed rf_config_index %d, unpacked rf_config_index %d\n", + i, pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[i].rf_config_index, pnfConfigRequest_out.pnf_phy_rf_config.phy_rf_config[i].rf_config_index); + } + } + return 0; + } + +} + + +void nfapi_test_pnf_config_req(void) +{ + + nfapi_pnf_config_request_t pnfConfigRequest_out; + nfapi_pnf_config_request_t pnfConfigRequest_in; + int packedMessageLength =0; + + printf(" nfapi_test_pnf_config_req run \n"); + + /* Build phy config req */ + pnfConfigRequest_in.header.phy_id = NFAPI_PHY_ID_NA; + pnfConfigRequest_in.header.message_id = NFAPI_PNF_CONFIG_REQUEST; + pnfConfigRequest_in.header.message_length = 22; + pnfConfigRequest_in.header.spare = 0; + + pnfConfigRequest_in.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; + pnfConfigRequest_in.pnf_phy_rf_config.tl.length = 0; + pnfConfigRequest_in.pnf_phy_rf_config.number_phy_rf_config_info = 2; + pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[0].phy_id = 4; + pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[0].phy_config_index = 1; + pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[0].rf_config_index = 1; + pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[1].phy_id = 5; + pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[1].phy_config_index = 2; + pnfConfigRequest_in.pnf_phy_rf_config.phy_rf_config[1].rf_config_index = 2; + + /*Pack pnf config req*/ + packedMessageLength = nfapi_p5_message_pack(&pnfConfigRequest_in, sizeof(nfapi_pnf_config_request_t), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + /*Unpack pnf config request*/ + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &pnfConfigRequest_out, sizeof(nfapi_pnf_config_request_t), 0); + + /*Verify unpacked message*/ + CU_ASSERT_EQUAL(nfapi_test_verify_configreq_params(pnfConfigRequest_in, pnfConfigRequest_out), 1); + +} + +void nfapi_test_2(void) { + /*Sample test function*/ + CU_ASSERT_EQUAL( 0, 0); +} + +void nfapi_test_rssi_request_lte() +{ + uint16_t idx; + nfapi_rssi_request_t in; + nfapi_rssi_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RSSI_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_LTE; + + in.lte_rssi_request.tl.tag = NFAPI_LTE_RSSI_REQUEST_TAG; + in.lte_rssi_request.frequency_band_indicator = 0; + in.lte_rssi_request.bandwidth = 0; + in.lte_rssi_request.timeout = 0; + in.lte_rssi_request.number_of_earfcns = 4; + in.lte_rssi_request.earfcn[0] = 42; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int upack_result = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_NOT_EQUAL(packedMessageLength, -1); + CU_ASSERT_NOT_EQUAL(packedMessageLength, 0); + CU_ASSERT_NOT_EQUAL(upack_result, 0); + CU_ASSERT_NOT_EQUAL(upack_result, -1); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.lte_rssi_request.frequency_band_indicator, out.lte_rssi_request.frequency_band_indicator); + CU_ASSERT_EQUAL(in.lte_rssi_request.bandwidth, out.lte_rssi_request.bandwidth); + CU_ASSERT_EQUAL(in.lte_rssi_request.timeout, out.lte_rssi_request.timeout); + CU_ASSERT_EQUAL(in.lte_rssi_request.number_of_earfcns, out.lte_rssi_request.number_of_earfcns); + + for(idx = 0; idx < out.lte_rssi_request.number_of_earfcns; ++idx) + { + CU_ASSERT_EQUAL(in.lte_rssi_request.earfcn[idx], out.lte_rssi_request.earfcn[idx]); + } +} + +void nfapi_test_rssi_request_lte2() +{ + uint16_t idx; + nfapi_rssi_request_t in; + nfapi_rssi_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RSSI_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_LTE; + + in.lte_rssi_request.tl.tag = NFAPI_LTE_RSSI_REQUEST_TAG; + in.lte_rssi_request.frequency_band_indicator = 0; + in.lte_rssi_request.bandwidth = 0; + in.lte_rssi_request.timeout = 0; + in.lte_rssi_request.number_of_earfcns = 4; + in.lte_rssi_request.earfcn[0] = 42; + + // try and pak with a buffer that is too small + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, NFAPI_HEADER_LENGTH + 4, 0); + CU_ASSERT_EQUAL(packedMessageLength, -1); + + // pack correctly + packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + // unpack with a small bufer + int upack_result = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength - 1, &out, sizeof(out), 0); + + upack_result = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_NOT_EQUAL(packedMessageLength, -1); + CU_ASSERT_NOT_EQUAL(packedMessageLength, 0); + CU_ASSERT_NOT_EQUAL(upack_result, 0); + CU_ASSERT_NOT_EQUAL(upack_result, -1); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.lte_rssi_request.frequency_band_indicator, out.lte_rssi_request.frequency_band_indicator); + CU_ASSERT_EQUAL(in.lte_rssi_request.bandwidth, out.lte_rssi_request.bandwidth); + CU_ASSERT_EQUAL(in.lte_rssi_request.timeout, out.lte_rssi_request.timeout); + CU_ASSERT_EQUAL(in.lte_rssi_request.number_of_earfcns, out.lte_rssi_request.number_of_earfcns); + + for(idx = 0; idx < out.lte_rssi_request.number_of_earfcns; ++idx) + { + CU_ASSERT_EQUAL(in.lte_rssi_request.earfcn[idx], out.lte_rssi_request.earfcn[idx]); + } +} + + + +// Test decoding of message which has a large number if earfcn which could +// cause a buffer over run if not handled +void nfapi_test_rssi_request_lte_overrun() +{ + nfapi_rssi_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t* end = p + 1024; + push16(0, &p, end); + push16(NFAPI_RSSI_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(NFAPI_RAT_TYPE_LTE, &p, end); + push16(NFAPI_LTE_RSSI_REQUEST_TAG, &p, end); + push16(11, &p, end); + + push8(0, &p, end); + push16(0, &p, end); + push8(0, &p, end); + push32(0, &p, end); + push8(123, &p, end); // to many EARFCN's + push16(16, &p, end); + + int result = nfapi_p4_message_unpack(buffer, sizeof(buffer), &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} + +void nfapi_test_rssi_request_lte_rat_type_mismatch() +{ + nfapi_rssi_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_RSSI_REQUEST, &p, end); + push16(16, &p, end); + push16(0, &p, end); + + push8(NFAPI_RAT_TYPE_GERAN, &p, end); + + push16(NFAPI_LTE_RSSI_REQUEST_TAG, &p, end); + push16(11, &p, end); + + push8(0, &p, end); + push16(0, &p, end); + push8(0, &p, end); + push32(0, &p, end); + push8(1, &p, end); + push16(16, &p, end); + + int result = nfapi_p4_message_unpack(buffer, sizeof(buffer), &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} + +void nfapi_test_rssi_request_utran() +{ + uint16_t idx; + nfapi_rssi_request_t in; + nfapi_rssi_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RSSI_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_UTRAN; + + + in.utran_rssi_request.tl.tag = NFAPI_UTRAN_RSSI_REQUEST_TAG; + in.utran_rssi_request.frequency_band_indicator = 0; + in.utran_rssi_request.measurement_period = 0; + in.utran_rssi_request.timeout = 0; + in.utran_rssi_request.number_of_uarfcns = 3; + in.utran_rssi_request.uarfcn[0] = 42; + in.utran_rssi_request.uarfcn[1] = 42; + in.utran_rssi_request.uarfcn[2] = 42; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.utran_rssi_request.frequency_band_indicator, out.utran_rssi_request.frequency_band_indicator); + CU_ASSERT_EQUAL(in.utran_rssi_request.measurement_period, out.utran_rssi_request.measurement_period); + CU_ASSERT_EQUAL(in.utran_rssi_request.timeout, out.utran_rssi_request.timeout); + CU_ASSERT_EQUAL(in.utran_rssi_request.number_of_uarfcns, out.utran_rssi_request.number_of_uarfcns); + + for(idx = 0; idx < out.utran_rssi_request.number_of_uarfcns; ++idx) + { + CU_ASSERT_EQUAL(in.utran_rssi_request.uarfcn[idx], out.utran_rssi_request.uarfcn[idx]); + } + +} + +void nfapi_test_rssi_request_geran() +{ + uint16_t idx; + nfapi_rssi_request_t in; + nfapi_rssi_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RSSI_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_GERAN; + + in.geran_rssi_request.tl.tag = NFAPI_GERAN_RSSI_REQUEST_TAG; + in.geran_rssi_request.frequency_band_indicator = 0; + in.geran_rssi_request.measurement_period = 0; + in.geran_rssi_request.timeout = 0; + in.geran_rssi_request.number_of_arfcns = 3; + in.geran_rssi_request.arfcn[0].arfcn = 42; + in.geran_rssi_request.arfcn[0].direction = 0; + in.geran_rssi_request.arfcn[1].arfcn = 42; + in.geran_rssi_request.arfcn[1].direction = 1; + in.geran_rssi_request.arfcn[2].arfcn = 42; + in.geran_rssi_request.arfcn[2].direction = 1; + + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.geran_rssi_request.frequency_band_indicator, out.geran_rssi_request.frequency_band_indicator); + CU_ASSERT_EQUAL(in.geran_rssi_request.measurement_period, out.geran_rssi_request.measurement_period); + CU_ASSERT_EQUAL(in.geran_rssi_request.timeout, out.geran_rssi_request.timeout); + CU_ASSERT_EQUAL(in.geran_rssi_request.number_of_arfcns, out.geran_rssi_request.number_of_arfcns); + + for(idx = 0; idx < out.geran_rssi_request.number_of_arfcns; ++idx) + { + CU_ASSERT_EQUAL(in.geran_rssi_request.arfcn[idx].arfcn, out.geran_rssi_request.arfcn[idx].arfcn); + CU_ASSERT_EQUAL(in.geran_rssi_request.arfcn[idx].direction, out.geran_rssi_request.arfcn[idx].direction); + } +} + +void nfapi_test_rssi_request_nb_iot() +{ + uint16_t idx, idx2; + nfapi_rssi_request_t in; + nfapi_rssi_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RSSI_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_NB_IOT; + + in.nb_iot_rssi_request.tl.tag = NFAPI_NB_IOT_RSSI_REQUEST_TAG; + in.nb_iot_rssi_request.frequency_band_indicator = 34; + in.nb_iot_rssi_request.measurement_period = 900; + in.nb_iot_rssi_request.timeout = 4321; + in.nb_iot_rssi_request.number_of_earfcns = 3; + in.nb_iot_rssi_request.earfcn[0].earfcn = 42; + in.nb_iot_rssi_request.earfcn[0].number_of_ro_dl = 1; + in.nb_iot_rssi_request.earfcn[0].ro_dl[0] = 2; + in.nb_iot_rssi_request.earfcn[1].earfcn = 43; + in.nb_iot_rssi_request.earfcn[1].number_of_ro_dl = 0; + in.nb_iot_rssi_request.earfcn[2].earfcn = 44; + in.nb_iot_rssi_request.earfcn[2].number_of_ro_dl = 2; + in.nb_iot_rssi_request.earfcn[2].ro_dl[0] = 0; + in.nb_iot_rssi_request.earfcn[2].ro_dl[1] = 4; + + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + IN_OUT_ASSERT(header.message_id); + IN_OUT_ASSERT(rat_type); + IN_OUT_ASSERT(nb_iot_rssi_request.frequency_band_indicator); + IN_OUT_ASSERT(nb_iot_rssi_request.measurement_period); + IN_OUT_ASSERT(nb_iot_rssi_request.timeout); + IN_OUT_ASSERT(nb_iot_rssi_request.number_of_earfcns); + + for(idx = 0; idx < out.nb_iot_rssi_request.number_of_earfcns; ++idx) + { + IN_OUT_ASSERT(nb_iot_rssi_request.earfcn[idx].earfcn); + IN_OUT_ASSERT(nb_iot_rssi_request.earfcn[idx].number_of_ro_dl); + + for(idx2 = 0; idx2 < out.nb_iot_rssi_request.earfcn[idx].number_of_ro_dl; ++idx2) + IN_OUT_ASSERT(nb_iot_rssi_request.earfcn[idx].ro_dl[idx2]); + } +} + + +void nfapi_test_rssi_response() +{ + nfapi_rssi_response_t in; + nfapi_rssi_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RSSI_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + +} + +void nfapi_test_rssi_indication() +{ + uint16_t idx = 0; + nfapi_rssi_indication_t in; + nfapi_rssi_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RSSI_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_OK; + in.rssi_indication_body.tl.tag = NFAPI_RSSI_INDICATION_TAG; + in.rssi_indication_body.tl.length = 0; + in.rssi_indication_body.number_of_rssi = 4; + in.rssi_indication_body.rssi[0] = 2; + in.rssi_indication_body.rssi[1] = 0; + in.rssi_indication_body.rssi[2] = -23; + in.rssi_indication_body.rssi[3] = -18000; + + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.rssi_indication_body.tl.tag, out.rssi_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.rssi_indication_body.number_of_rssi, out.rssi_indication_body.number_of_rssi); + + for(idx = 0; idx < out.rssi_indication_body.number_of_rssi; ++idx) + { + CU_ASSERT_EQUAL(in.rssi_indication_body.rssi[idx], out.rssi_indication_body.rssi[idx]); + } + +} +void nfapi_test_rssi_indication_overrun() +{ + nfapi_rssi_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_RSSI_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error code + + push16(NFAPI_RSSI_INDICATION_TAG, &p, end); + push16(11, &p, end); + + push16(NFAPI_MAX_RSSI + 23, &p, end); // to many EARFCN's + push16(16, &p, end); + + int result = nfapi_p4_message_unpack(buffer, sizeof(buffer), &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} + +void nfapi_test_cell_search_request_lte() +{ + uint16_t idx; + nfapi_cell_search_request_t in; + nfapi_cell_search_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_LTE; + + in.lte_cell_search_request.tl.tag = NFAPI_LTE_CELL_SEARCH_REQUEST_TAG; + in.lte_cell_search_request.earfcn = 213; + in.lte_cell_search_request.measurement_bandwidth = 1; + in.lte_cell_search_request.exhaustive_search = 0; + in.lte_cell_search_request.timeout = 123; + in.lte_cell_search_request.number_of_pci = 3; + in.lte_cell_search_request.pci[0] = 3; + in.lte_cell_search_request.pci[1] = 6; + in.lte_cell_search_request.pci[2] = 9; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.lte_cell_search_request.earfcn, out.lte_cell_search_request.earfcn); + CU_ASSERT_EQUAL(in.lte_cell_search_request.measurement_bandwidth, out.lte_cell_search_request.measurement_bandwidth); + CU_ASSERT_EQUAL(in.lte_cell_search_request.exhaustive_search, out.lte_cell_search_request.exhaustive_search); + CU_ASSERT_EQUAL(in.lte_cell_search_request.timeout, out.lte_cell_search_request.timeout); + CU_ASSERT_EQUAL(in.lte_cell_search_request.number_of_pci, out.lte_cell_search_request.number_of_pci); + + for(idx = 0; idx < out.lte_cell_search_request.number_of_pci; ++idx) + { + CU_ASSERT_EQUAL(in.lte_cell_search_request.pci[idx], out.lte_cell_search_request.pci[idx]); + } +} + +void nfapi_test_cell_search_request_utran() +{ + uint16_t idx; + nfapi_cell_search_request_t in; + nfapi_cell_search_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_UTRAN; + + in.utran_cell_search_request.tl.tag = NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG; + in.utran_cell_search_request.uarfcn = 213; + in.utran_cell_search_request.exhaustive_search = 0; + in.utran_cell_search_request.timeout = 123; + in.utran_cell_search_request.number_of_psc = 3; + in.utran_cell_search_request.psc[0] = 3; + in.utran_cell_search_request.psc[1] = 6; + in.utran_cell_search_request.psc[2] = 9; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int unpackResult = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_NOT_EQUAL(unpackResult, -1); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.utran_cell_search_request.uarfcn, out.utran_cell_search_request.uarfcn); + CU_ASSERT_EQUAL(in.utran_cell_search_request.exhaustive_search, out.utran_cell_search_request.exhaustive_search); + CU_ASSERT_EQUAL(in.utran_cell_search_request.timeout, out.utran_cell_search_request.timeout); + CU_ASSERT_EQUAL(in.utran_cell_search_request.number_of_psc, out.utran_cell_search_request.number_of_psc); + + for(idx = 0; idx < out.utran_cell_search_request.number_of_psc; ++idx) + { + CU_ASSERT_EQUAL(in.utran_cell_search_request.psc[idx], out.utran_cell_search_request.psc[idx]); + } +} + +void nfapi_test_cell_search_request_geran() +{ + uint16_t idx; + nfapi_cell_search_request_t in; + nfapi_cell_search_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_GERAN; + + in.geran_cell_search_request.tl.tag = NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG; + in.geran_cell_search_request.timeout = 123; + in.geran_cell_search_request.number_of_arfcn = 3; + in.geran_cell_search_request.arfcn[0] = 3; + in.geran_cell_search_request.arfcn[1] = 6; + in.geran_cell_search_request.arfcn[2] = 9; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int unpackResult = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_NOT_EQUAL(unpackResult, -1); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.geran_cell_search_request.timeout, out.geran_cell_search_request.timeout); + CU_ASSERT_EQUAL(in.geran_cell_search_request.number_of_arfcn, out.geran_cell_search_request.number_of_arfcn); + + for(idx = 0; idx < out.geran_cell_search_request.number_of_arfcn; ++idx) + { + CU_ASSERT_EQUAL(in.geran_cell_search_request.arfcn[idx], out.geran_cell_search_request.arfcn[idx]); + } +} + +void nfapi_test_cell_search_request_nb_iot() +{ + uint16_t idx; + nfapi_cell_search_request_t in; + nfapi_cell_search_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_NB_IOT; + + in.nb_iot_cell_search_request.tl.tag = NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG; + in.nb_iot_cell_search_request.earfcn = 54; + in.nb_iot_cell_search_request.ro_dl = 3; + in.nb_iot_cell_search_request.exhaustive_search = 1; + in.nb_iot_cell_search_request.timeout = 123; + in.nb_iot_cell_search_request.number_of_pci = 3; + in.nb_iot_cell_search_request.pci[0] = 3; + in.nb_iot_cell_search_request.pci[1] = 6; + in.nb_iot_cell_search_request.pci[2] = 9; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int unpackResult = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_NOT_EQUAL(unpackResult, -1); + + IN_OUT_ASSERT(header.message_id); + IN_OUT_ASSERT(rat_type); + IN_OUT_ASSERT(nb_iot_cell_search_request.earfcn); + IN_OUT_ASSERT(nb_iot_cell_search_request.ro_dl); + IN_OUT_ASSERT(nb_iot_cell_search_request.exhaustive_search); + IN_OUT_ASSERT(nb_iot_cell_search_request.timeout); + IN_OUT_ASSERT(nb_iot_cell_search_request.number_of_pci); + + for(idx = 0; idx < out.nb_iot_cell_search_request.number_of_pci; ++idx) + { + IN_OUT_ASSERT(nb_iot_cell_search_request.pci[idx]); + } +} + +void nfapi_test_cell_search_response() +{ + nfapi_cell_search_response_t in; + nfapi_cell_search_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} + +void nfapi_test_cell_search_indication_lte() +{ + uint16_t idx = 0; + nfapi_cell_search_indication_t in; + nfapi_cell_search_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_OK; + in.lte_cell_search_indication.tl.tag = NFAPI_LTE_CELL_SEARCH_INDICATION_TAG; + in.lte_cell_search_indication.number_of_lte_cells_found = 2; + in.lte_cell_search_indication.lte_found_cells[0].pci = 0; + in.lte_cell_search_indication.lte_found_cells[0].rsrp = 42; + in.lte_cell_search_indication.lte_found_cells[0].rsrq= 11; + in.lte_cell_search_indication.lte_found_cells[0].frequency_offset = -100; + + in.lte_cell_search_indication.lte_found_cells[1].pci = 123; + in.lte_cell_search_indication.lte_found_cells[1].rsrp = 2; + in.lte_cell_search_indication.lte_found_cells[1].rsrq= 17; + in.lte_cell_search_indication.lte_found_cells[1].frequency_offset = 123; + + in.utran_cell_search_indication.tl.tag = 0; + in.geran_cell_search_indication.tl.tag = 0; + in.nb_iot_cell_search_indication.tl.tag = 0; + in.pnf_cell_search_state.tl.tag = 0; + + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_cell_search_indication.tl.tag, out.lte_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.lte_cell_search_indication.number_of_lte_cells_found, out.lte_cell_search_indication.number_of_lte_cells_found); + + for(idx = 0; idx < out.lte_cell_search_indication.number_of_lte_cells_found; ++idx) + { + CU_ASSERT_EQUAL(in.lte_cell_search_indication.lte_found_cells[idx].pci, out.lte_cell_search_indication.lte_found_cells[idx].pci); + CU_ASSERT_EQUAL(in.lte_cell_search_indication.lte_found_cells[idx].rsrp, out.lte_cell_search_indication.lte_found_cells[idx].rsrp); + CU_ASSERT_EQUAL(in.lte_cell_search_indication.lte_found_cells[idx].rsrq, out.lte_cell_search_indication.lte_found_cells[idx].rsrq); + CU_ASSERT_EQUAL(in.lte_cell_search_indication.lte_found_cells[idx].frequency_offset, out.lte_cell_search_indication.lte_found_cells[idx].frequency_offset); + } + + + CU_ASSERT_EQUAL(in.utran_cell_search_indication.tl.tag, out.utran_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.tl.tag, out.geran_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_search_state.tl.tag, out.pnf_cell_search_state.tl.tag); +} +void nfapi_test_cell_search_indication_utran() +{ + uint16_t idx = 0; + nfapi_cell_search_indication_t in; + nfapi_cell_search_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_OK; + in.utran_cell_search_indication.tl.tag = NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG; + in.utran_cell_search_indication.number_of_utran_cells_found = 1; + in.utran_cell_search_indication.utran_found_cells[0].psc = 123; + in.utran_cell_search_indication.utran_found_cells[0].rscp = 2; + in.utran_cell_search_indication.utran_found_cells[0].ecno = 89; + in.utran_cell_search_indication.utran_found_cells[0].frequency_offset = -1000; + + in.lte_cell_search_indication.tl.tag = 0; + in.geran_cell_search_indication.tl.tag = 0; + in.nb_iot_cell_search_indication.tl.tag = 0; + in.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; + in.pnf_cell_search_state.length = 12; + in.pnf_cell_search_state.value[0] = 34; + in.pnf_cell_search_state.value[1] = 35; + in.pnf_cell_search_state.value[2] = 36; + in.pnf_cell_search_state.value[3] = 37; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.utran_cell_search_indication.tl.tag, out.utran_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_cell_search_indication.number_of_utran_cells_found, out.utran_cell_search_indication.number_of_utran_cells_found); + + for(idx = 0; idx < out.utran_cell_search_indication.number_of_utran_cells_found; ++idx) + { + CU_ASSERT_EQUAL(in.utran_cell_search_indication.utran_found_cells[idx].psc, out.utran_cell_search_indication.utran_found_cells[idx].psc); + CU_ASSERT_EQUAL(in.utran_cell_search_indication.utran_found_cells[idx].rscp, out.utran_cell_search_indication.utran_found_cells[idx].rscp); + CU_ASSERT_EQUAL(in.utran_cell_search_indication.utran_found_cells[idx].ecno, out.utran_cell_search_indication.utran_found_cells[idx].ecno); + CU_ASSERT_EQUAL(in.utran_cell_search_indication.utran_found_cells[idx].frequency_offset, out.utran_cell_search_indication.utran_found_cells[idx].frequency_offset); + } + + CU_ASSERT_EQUAL(in.lte_cell_search_indication.tl.tag, out.lte_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.tl.tag, out.geran_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_search_state.tl.tag, out.pnf_cell_search_state.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_search_state.length, out.pnf_cell_search_state.length); + + for(idx = 0; idx < out.pnf_cell_search_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_search_state.value[idx], out.pnf_cell_search_state.value[idx]); + } +} +void nfapi_test_cell_search_indication_geran() +{ + uint16_t idx = 0; + nfapi_cell_search_indication_t in; + nfapi_cell_search_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_OK; + in.geran_cell_search_indication.tl.tag = NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG; + in.geran_cell_search_indication.number_of_gsm_cells_found = 1; + in.geran_cell_search_indication.gsm_found_cells[0].arfcn = 123; + in.geran_cell_search_indication.gsm_found_cells[0].bsic = 2; + in.geran_cell_search_indication.gsm_found_cells[0].rxlev = 89; + in.geran_cell_search_indication.gsm_found_cells[0].rxqual = 12; + in.geran_cell_search_indication.gsm_found_cells[0].frequency_offset = 2389; + in.geran_cell_search_indication.gsm_found_cells[0].sfn_offset = 23; + + in.lte_cell_search_indication.tl.tag = 0; + in.utran_cell_search_indication.tl.tag = 0; + in.nb_iot_cell_search_indication.tl.tag = 0; + in.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; + in.pnf_cell_search_state.length = 63; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.tl.tag, out.geran_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.number_of_gsm_cells_found, out.geran_cell_search_indication.number_of_gsm_cells_found); + + for(idx = 0; idx < out.geran_cell_search_indication.number_of_gsm_cells_found; ++idx) + { + CU_ASSERT_EQUAL(in.geran_cell_search_indication.gsm_found_cells[idx].arfcn, out.geran_cell_search_indication.gsm_found_cells[idx].arfcn); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.gsm_found_cells[idx].bsic, out.geran_cell_search_indication.gsm_found_cells[idx].bsic); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.gsm_found_cells[idx].rxlev, out.geran_cell_search_indication.gsm_found_cells[idx].rxlev); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.gsm_found_cells[idx].rxqual, out.geran_cell_search_indication.gsm_found_cells[idx].rxqual); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.gsm_found_cells[idx].frequency_offset, out.geran_cell_search_indication.gsm_found_cells[idx].frequency_offset); + CU_ASSERT_EQUAL(in.geran_cell_search_indication.gsm_found_cells[idx].sfn_offset, out.geran_cell_search_indication.gsm_found_cells[idx].sfn_offset); + } + + CU_ASSERT_EQUAL(in.lte_cell_search_indication.tl.tag, out.lte_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_cell_search_indication.tl.tag, out.utran_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_cell_search_indication.tl.tag, out.nb_iot_cell_search_indication.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_search_state.tl.tag, out.pnf_cell_search_state.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_search_state.length, out.pnf_cell_search_state.length); + + for(idx = 0; idx < out.pnf_cell_search_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_search_state.value[idx], out.pnf_cell_search_state.value[idx]); + } +} + +void nfapi_test_cell_search_indication_nb_iot() +{ + uint16_t idx = 0; + nfapi_cell_search_indication_t in; + nfapi_cell_search_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CELL_SEARCH_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_OK; + in.nb_iot_cell_search_indication.tl.tag = NFAPI_NB_IOT_CELL_SEARCH_INDICATION_TAG; + in.nb_iot_cell_search_indication.number_of_nb_iot_cells_found = 1; + in.nb_iot_cell_search_indication.nb_iot_found_cells[0].pci = 123; + in.nb_iot_cell_search_indication.nb_iot_found_cells[0].rsrp = 2; + in.nb_iot_cell_search_indication.nb_iot_found_cells[0].rsrq = 89; + in.nb_iot_cell_search_indication.nb_iot_found_cells[0].frequency_offset = 2389; + + in.lte_cell_search_indication.tl.tag = 0; + in.utran_cell_search_indication.tl.tag = 0; + in.geran_cell_search_indication.tl.tag = 0; + + in.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; + in.pnf_cell_search_state.length = 63; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + IN_OUT_ASSERT(header.message_id); + IN_OUT_ASSERT(error_code); + IN_OUT_ASSERT(nb_iot_cell_search_indication.tl.tag); + IN_OUT_ASSERT(nb_iot_cell_search_indication.number_of_nb_iot_cells_found); + + for(idx = 0; idx < out.nb_iot_cell_search_indication.number_of_nb_iot_cells_found; ++idx) + { + IN_OUT_ASSERT(nb_iot_cell_search_indication.nb_iot_found_cells[idx].pci); + IN_OUT_ASSERT(nb_iot_cell_search_indication.nb_iot_found_cells[idx].rsrp); + IN_OUT_ASSERT(nb_iot_cell_search_indication.nb_iot_found_cells[idx].rsrq); + IN_OUT_ASSERT(nb_iot_cell_search_indication.nb_iot_found_cells[idx].frequency_offset); + } + + IN_OUT_ASSERT(lte_cell_search_indication.tl.tag); + IN_OUT_ASSERT(utran_cell_search_indication.tl.tag); + IN_OUT_ASSERT(geran_cell_search_indication.tl.tag); + IN_OUT_ASSERT(pnf_cell_search_state.tl.tag); + IN_OUT_ASSERT(pnf_cell_search_state.length); + + for(idx = 0; idx < out.pnf_cell_search_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_search_state.value[idx], out.pnf_cell_search_state.value[idx]); + } +} + +void nfapi_test_cell_search_request_lte_overrun() +{ + nfapi_cell_search_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_CELL_SEARCH_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(0, &p, end); // rat_type + + push16(NFAPI_LTE_CELL_SEARCH_REQUEST_TAG, &p, end); + push16(8, &p, end); + + push16(11, &p, end); + push8(11, &p, end); + push8(11, &p, end); + push32(11, &p, end); + push8(NFAPI_MAX_PCI_LIST + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); + +} +void nfapi_test_cell_search_request_utran_overrun() +{ + nfapi_cell_search_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_CELL_SEARCH_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(NFAPI_RAT_TYPE_UTRAN, &p, end); // rat_type + + push16(NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG, &p, end); + push16(8, &p, end); + + push16(11, &p, end); + push8(11, &p, end); + push32(11, &p, end); + push8(NFAPI_MAX_PSC_LIST + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_cell_search_request_geran_overrun() +{ + nfapi_cell_search_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_CELL_SEARCH_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(NFAPI_RAT_TYPE_GERAN, &p, end); // rat_type + + push16(NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG, &p, end); + push16(8, &p, end); + + push32(11, &p, end); + push8(NFAPI_MAX_ARFCN_LIST + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_cell_search_indication_lte_overrun() +{ + nfapi_cell_search_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_CELL_SEARCH_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error_code + + push16(NFAPI_LTE_CELL_SEARCH_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push16(NFAPI_MAX_LTE_CELLS_FOUND + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_cell_search_indication_utran_overrun() +{ + nfapi_cell_search_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_CELL_SEARCH_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error_code + + push16(NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push16(NFAPI_MAX_UTRAN_CELLS_FOUND + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_cell_search_indication_geran_overrun() +{ + nfapi_cell_search_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_CELL_SEARCH_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error_code + + push16(NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push16(NFAPI_MAX_GSM_CELLS_FOUND + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_cell_search_indication_state_overrun() +{ + nfapi_cell_search_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_CELL_SEARCH_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error_code + + push16(NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG, &p, end); + push16(13, &p, end); + + push16(1, &p, end); + if(1) + { + push16(42, &p, end); + push8(42, &p, end); + push8(42, &p, end); + push8(42, &p, end); + pushs16(42, &p, end); + push32(42, &p, end); + } + + push16(NFAPI_PNF_CELL_SEARCH_STATE_TAG, &p, end); + push16(NFAPI_MAX_OPAQUE_DATA + 12, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_broadcast_detect_request_lte() +{ + nfapi_broadcast_detect_request_t in; + nfapi_broadcast_detect_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_LTE; + + in.lte_broadcast_detect_request.tl.tag = NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG; + in.lte_broadcast_detect_request.earfcn = 123; + in.lte_broadcast_detect_request.pci = 12; + in.lte_broadcast_detect_request.timeout = 1246; + + in.pnf_cell_search_state.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int unpackResult = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_NOT_EQUAL(unpackResult, -1); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_request.earfcn, out.lte_broadcast_detect_request.earfcn); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_request.pci, out.lte_broadcast_detect_request.pci); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_request.timeout, out.lte_broadcast_detect_request.timeout); + +} +void nfapi_test_broadcast_detect_request_utran() +{ + uint16_t idx; + nfapi_broadcast_detect_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_broadcast_detect_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_UTRAN; + + in.utran_broadcast_detect_request.tl.tag = NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG; + in.utran_broadcast_detect_request.uarfcn = 123; + in.utran_broadcast_detect_request.psc = 12; + in.utran_broadcast_detect_request.timeout = 1246; + + in.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; + in.pnf_cell_search_state.length = 60; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + CU_ASSERT_NOT_EQUAL(packedMessageLength, 0); + CU_ASSERT_NOT_EQUAL(packedMessageLength, -1); + + int unpackResult = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_NOT_EQUAL(unpackResult, 0); + CU_ASSERT_NOT_EQUAL(unpackResult, -1); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.utran_broadcast_detect_request.uarfcn, out.utran_broadcast_detect_request.uarfcn); + CU_ASSERT_EQUAL(in.utran_broadcast_detect_request.psc, out.utran_broadcast_detect_request.psc); + CU_ASSERT_EQUAL(in.utran_broadcast_detect_request.timeout, out.utran_broadcast_detect_request.timeout); + + CU_ASSERT_EQUAL(in.pnf_cell_search_state.length, out.pnf_cell_search_state.length); + + for(idx = 0; idx < out.pnf_cell_search_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_search_state.value[idx], out.pnf_cell_search_state.value[idx]); + } + +} + +void nfapi_test_broadcast_detect_request_nb_iot() +{ + uint16_t idx; + nfapi_broadcast_detect_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_broadcast_detect_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_NB_IOT; + + in.nb_iot_broadcast_detect_request.tl.tag = NFAPI_NB_IOT_BROADCAST_DETECT_REQUEST_TAG; + in.nb_iot_broadcast_detect_request.earfcn = 123; + in.nb_iot_broadcast_detect_request.ro_dl = 12; + in.nb_iot_broadcast_detect_request.pci = 12; + in.nb_iot_broadcast_detect_request.timeout = 1246; + + in.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; + in.pnf_cell_search_state.length = 60; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + CU_ASSERT_NOT_EQUAL(packedMessageLength, 0); + CU_ASSERT_NOT_EQUAL(packedMessageLength, -1); + + int unpackResult = nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_NOT_EQUAL(unpackResult, 0); + CU_ASSERT_NOT_EQUAL(unpackResult, -1); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_request.earfcn, out.nb_iot_broadcast_detect_request.earfcn); + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_request.ro_dl, out.nb_iot_broadcast_detect_request.ro_dl); + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_request.pci, out.nb_iot_broadcast_detect_request.pci); + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_request.timeout, out.nb_iot_broadcast_detect_request.timeout); + + CU_ASSERT_EQUAL(in.pnf_cell_search_state.length, out.pnf_cell_search_state.length); + + for(idx = 0; idx < out.pnf_cell_search_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_search_state.value[idx], out.pnf_cell_search_state.value[idx]); + } + +} + + +void nfapi_test_broadcast_detect_request_state_overrun() +{ + nfapi_broadcast_detect_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_BROADCAST_DETECT_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(NFAPI_RAT_TYPE_UTRAN, &p, end); // error_code + + push16(NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG, &p, end); + push16(8, &p, end); + + push16(42, &p, end); + push16(42, &p, end); + push32(42, &p, end); + + push16(NFAPI_PNF_CELL_SEARCH_STATE_TAG, &p, end); + push16(NFAPI_MAX_OPAQUE_DATA + 12, &p, end); + + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} + +void nfapi_test_broadcast_detect_response() +{ + nfapi_broadcast_detect_response_t in; + nfapi_broadcast_detect_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_BROADCAST_DETECT_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + +} +void nfapi_test_broadcast_detect_indication_lte() +{ + uint16_t idx; + nfapi_broadcast_detect_indication_t in; + nfapi_broadcast_detect_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_BROADCAST_DETECT_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + in.lte_broadcast_detect_indication.tl.tag = NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG; + in.lte_broadcast_detect_indication.number_of_tx_antenna = 1; + in.lte_broadcast_detect_indication.mib_length = 8; + in.lte_broadcast_detect_indication.sfn_offset = 4; + in.utran_broadcast_detect_indication.tl.tag = 0; + in.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG; + in.pnf_cell_broadcast_state.length = 23; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_indication.tl.tag, out.lte_broadcast_detect_indication.tl.tag); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_indication.number_of_tx_antenna, out.lte_broadcast_detect_indication.number_of_tx_antenna); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_indication.mib_length, out.lte_broadcast_detect_indication.mib_length); + for(idx = 0; idx < out.lte_broadcast_detect_indication.mib_length; ++idx) + { + CU_ASSERT_EQUAL(in.lte_broadcast_detect_indication.mib[idx], out.lte_broadcast_detect_indication.mib[idx]); + } + CU_ASSERT_EQUAL(in.lte_broadcast_detect_indication.sfn_offset, out.lte_broadcast_detect_indication.sfn_offset); + + + CU_ASSERT_EQUAL(in.utran_broadcast_detect_indication.tl.tag, out.utran_broadcast_detect_indication.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); + for(idx = 0; idx < out.pnf_cell_broadcast_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.value[idx], out.pnf_cell_broadcast_state.value[idx]); + } +} +void nfapi_test_broadcast_detect_indication_lte_overrun() +{ + nfapi_broadcast_detect_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_BROADCAST_DETECT_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error_code + + push16(NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push8(1, &p, end); + push16(NFAPI_MAX_MIB_LENGTH + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out) ,0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_broadcast_detect_indication_utran() +{ + uint16_t idx; + nfapi_broadcast_detect_indication_t in; + nfapi_broadcast_detect_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_BROADCAST_DETECT_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + in.lte_broadcast_detect_indication.tl.tag = 0; + in.utran_broadcast_detect_indication.tl.tag = NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG; + in.utran_broadcast_detect_indication.mib_length = 16; + in.utran_broadcast_detect_indication.sfn_offset = 4; + in.pnf_cell_broadcast_state.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_indication.tl.tag, out.lte_broadcast_detect_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_broadcast_detect_indication.tl.tag, out.utran_broadcast_detect_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_broadcast_detect_indication.mib_length, out.utran_broadcast_detect_indication.mib_length); + for(idx = 0; idx < out.utran_broadcast_detect_indication.mib_length; ++idx) + { + CU_ASSERT_EQUAL(in.utran_broadcast_detect_indication.mib[idx], out.utran_broadcast_detect_indication.mib[idx]); + } + CU_ASSERT_EQUAL(in.utran_broadcast_detect_indication.sfn_offset, out.utran_broadcast_detect_indication.sfn_offset); + + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); +} +void nfapi_test_broadcast_detect_indication_nb_iot() +{ + uint16_t idx; + nfapi_broadcast_detect_indication_t in; + nfapi_broadcast_detect_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_BROADCAST_DETECT_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + in.lte_broadcast_detect_indication.tl.tag = 0; + in.utran_broadcast_detect_indication.tl.tag = 0; + in.nb_iot_broadcast_detect_indication.tl.tag = NFAPI_NB_IOT_BROADCAST_DETECT_INDICATION_TAG; + in.nb_iot_broadcast_detect_indication.number_of_tx_antenna = 2; + in.nb_iot_broadcast_detect_indication.mib_length = 16; + in.nb_iot_broadcast_detect_indication.sfn_offset = 4; + in.pnf_cell_broadcast_state.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_broadcast_detect_indication.tl.tag, out.lte_broadcast_detect_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_broadcast_detect_indication.tl.tag, out.utran_broadcast_detect_indication.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_indication.tl.tag, out.nb_iot_broadcast_detect_indication.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_indication.number_of_tx_antenna, out.nb_iot_broadcast_detect_indication.number_of_tx_antenna); + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_indication.mib_length, out.nb_iot_broadcast_detect_indication.mib_length); + for(idx = 0; idx < out.nb_iot_broadcast_detect_indication.mib_length; ++idx) + { + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_indication.mib[idx], out.nb_iot_broadcast_detect_indication.mib[idx]); + } + CU_ASSERT_EQUAL(in.nb_iot_broadcast_detect_indication.sfn_offset, out.nb_iot_broadcast_detect_indication.sfn_offset); + + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); +} +void nfapi_test_broadcast_detect_indication_utran_overrun() +{ + nfapi_broadcast_detect_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_BROADCAST_DETECT_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error_code + + push16(NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push16(NFAPI_MAX_MIB_LENGTH + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_broadcast_detect_indication_state_overrun() +{ +} +void nfapi_test_system_information_schedule_request_lte() +{ + uint16_t idx; + nfapi_system_information_schedule_request_t in; + nfapi_system_information_schedule_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_LTE; + + in.nb_iot_system_information_schedule_request.tl.tag = 0; + + in.lte_system_information_schedule_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG; + in.lte_system_information_schedule_request.earfcn = 16; + in.lte_system_information_schedule_request.pci = 4; + in.lte_system_information_schedule_request.downlink_channel_bandwidth = 20; + in.lte_system_information_schedule_request.phich_configuration = 1; + in.lte_system_information_schedule_request.number_of_tx_antenna = 2; + in.lte_system_information_schedule_request.retry_count = 4; + in.lte_system_information_schedule_request.timeout = 0; + in.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG; + in.pnf_cell_broadcast_state.length = 7; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.tl.tag, out.lte_system_information_schedule_request.tl.tag); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.earfcn, out.lte_system_information_schedule_request.earfcn); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.pci, out.lte_system_information_schedule_request.pci); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.downlink_channel_bandwidth, out.lte_system_information_schedule_request.downlink_channel_bandwidth); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.downlink_channel_bandwidth, out.lte_system_information_schedule_request.downlink_channel_bandwidth); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.number_of_tx_antenna, out.lte_system_information_schedule_request.number_of_tx_antenna); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.retry_count, out.lte_system_information_schedule_request.retry_count); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.timeout, out.lte_system_information_schedule_request.timeout); + + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.length, out.pnf_cell_broadcast_state.length); + for(idx = 0; idx < out.pnf_cell_broadcast_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.value[idx], out.pnf_cell_broadcast_state.value[idx]); + } +} + +void nfapi_test_system_information_schedule_request_nb_iot() +{ + uint16_t idx; + nfapi_system_information_schedule_request_t in; + nfapi_system_information_schedule_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_NB_IOT; + + in.lte_system_information_schedule_request.tl.tag = 0; + in.nb_iot_system_information_schedule_request.tl.tag = NFAPI_NB_IOT_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG; + in.nb_iot_system_information_schedule_request.earfcn = 16; + in.nb_iot_system_information_schedule_request.ro_dl = 4; + in.nb_iot_system_information_schedule_request.pci = 4; + in.nb_iot_system_information_schedule_request.scheduling_info_sib1_nb = 4; + in.nb_iot_system_information_schedule_request.timeout = 0; + in.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG; + in.pnf_cell_broadcast_state.length = 7; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.lte_system_information_schedule_request.tl.tag, out.lte_system_information_schedule_request.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_system_information_schedule_request.tl.tag, out.nb_iot_system_information_schedule_request.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_system_information_schedule_request.earfcn, out.nb_iot_system_information_schedule_request.earfcn); + CU_ASSERT_EQUAL(in.nb_iot_system_information_schedule_request.ro_dl, out.nb_iot_system_information_schedule_request.ro_dl); + CU_ASSERT_EQUAL(in.nb_iot_system_information_schedule_request.pci, out.nb_iot_system_information_schedule_request.pci); + CU_ASSERT_EQUAL(in.nb_iot_system_information_schedule_request.scheduling_info_sib1_nb, out.nb_iot_system_information_schedule_request.scheduling_info_sib1_nb); + CU_ASSERT_EQUAL(in.nb_iot_system_information_schedule_request.timeout, out.nb_iot_system_information_schedule_request.timeout); + + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.length, out.pnf_cell_broadcast_state.length); + for(idx = 0; idx < out.pnf_cell_broadcast_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.value[idx], out.pnf_cell_broadcast_state.value[idx]); + } +} + +void nfapi_test_system_information_schedule_request_state_overrun() +{ + nfapi_system_information_schedule_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(0, &p, end); // rat type + + push16(NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG, &p, end); + push16(13, &p, end); + + push16(1, &p, end); + push16(1, &p, end); + push16(1, &p, end); + push8(142, &p, end); + push8(142, &p, end); + push8(142, &p, end); + push32(42, &p, end); + + push16(NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &p, end); + push16(NFAPI_MAX_OPAQUE_DATA + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); + +} +void nfapi_test_system_information_schedule_response() +{ + nfapi_system_information_schedule_response_t in; + nfapi_system_information_schedule_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_system_information_schedule_indication_lte() +{ + uint16_t idx; + nfapi_system_information_schedule_indication_t in; + nfapi_system_information_schedule_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = 0; + + in.nb_iot_system_information_indication.tl.tag = 0; + in.lte_system_information_indication.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG; + in.lte_system_information_indication.sib_type = 16; + in.lte_system_information_indication.sib_length = 4; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_system_information_indication.tl.tag, out.lte_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.lte_system_information_indication.sib_type, out.lte_system_information_indication.sib_type); + CU_ASSERT_EQUAL(in.lte_system_information_indication.sib_length, out.lte_system_information_indication.sib_length); + + for(idx = 0; idx < out.lte_system_information_indication.sib_length; ++idx) + { + CU_ASSERT_EQUAL(in.lte_system_information_indication.sib[idx], out.lte_system_information_indication.sib[idx]); + } +} +void nfapi_test_system_information_schedule_indication_nb_iot() +{ + uint16_t idx; + nfapi_system_information_schedule_indication_t in; + nfapi_system_information_schedule_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = 0; + + in.lte_system_information_indication.tl.tag = 0; + in.nb_iot_system_information_indication.tl.tag = NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG; + in.nb_iot_system_information_indication.sib_type = 16; + in.nb_iot_system_information_indication.sib_length = 4; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_system_information_indication.tl.tag, out.lte_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.tl.tag, out.nb_iot_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.sib_type, out.nb_iot_system_information_indication.sib_type); + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.sib_length, out.nb_iot_system_information_indication.sib_length); + + for(idx = 0; idx < out.nb_iot_system_information_indication.sib_length; ++idx) + { + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.sib[idx], out.nb_iot_system_information_indication.sib[idx]); + } +} +void nfapi_test_system_information_request_lte() +{ + uint16_t idx; + nfapi_system_information_request_t in; + nfapi_system_information_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_LTE; + + in.lte_system_information_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG; + in.lte_system_information_request.earfcn = 16; + in.lte_system_information_request.pci = 4; + in.lte_system_information_request.downlink_channel_bandwidth = 20; + in.lte_system_information_request.phich_configuration = 1; + in.lte_system_information_request.number_of_tx_antenna = 2; + in.lte_system_information_request.number_of_si_periodicity = 1; + in.lte_system_information_request.si_periodicity[0].si_periodicity = 3; + in.lte_system_information_request.si_periodicity[0].si_index = 0; + in.lte_system_information_request.si_window_length = 0; + in.lte_system_information_request.timeout = 2000; + + in.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG; + in.pnf_cell_broadcast_state.length = 7; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.lte_system_information_request.tl.tag, out.lte_system_information_request.tl.tag); + CU_ASSERT_EQUAL(in.lte_system_information_request.earfcn, out.lte_system_information_request.earfcn); + CU_ASSERT_EQUAL(in.lte_system_information_request.pci, out.lte_system_information_request.pci); + CU_ASSERT_EQUAL(in.lte_system_information_request.downlink_channel_bandwidth, out.lte_system_information_request.downlink_channel_bandwidth); + CU_ASSERT_EQUAL(in.lte_system_information_request.downlink_channel_bandwidth, out.lte_system_information_request.downlink_channel_bandwidth); + CU_ASSERT_EQUAL(in.lte_system_information_request.number_of_tx_antenna, out.lte_system_information_request.number_of_tx_antenna); + CU_ASSERT_EQUAL(in.lte_system_information_request.number_of_si_periodicity, out.lte_system_information_request.number_of_si_periodicity); + for(idx = 0; idx < in.lte_system_information_request.number_of_si_periodicity; ++idx) + { + CU_ASSERT_EQUAL(in.lte_system_information_request.si_periodicity[idx].si_periodicity, out.lte_system_information_request.si_periodicity[idx].si_periodicity); + CU_ASSERT_EQUAL(in.lte_system_information_request.si_periodicity[idx].si_index, out.lte_system_information_request.si_periodicity[idx].si_index); + } + + CU_ASSERT_EQUAL(in.lte_system_information_request.si_window_length, out.lte_system_information_request.si_window_length); + CU_ASSERT_EQUAL(in.lte_system_information_request.timeout, out.lte_system_information_request.timeout); + + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.length, out.pnf_cell_broadcast_state.length); + for(idx = 0; idx < out.pnf_cell_broadcast_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.value[idx], out.pnf_cell_broadcast_state.value[idx]); + } +} +void nfapi_test_system_information_request_lte_overrun() +{ + nfapi_system_information_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_SYSTEM_INFORMATION_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(NFAPI_RAT_TYPE_LTE, &p, end); + + push16(NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG, &p, end); + push16(8, &p, end); + + push16(8, &p, end); + push16(8, &p, end); + push16(8, &p, end); + push8(8, &p, end); + push8(8, &p, end); + push8(NFAPI_MAX_SI_PERIODICITY + 1, &p, end); + + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_system_information_request_utran() +{ + nfapi_system_information_request_t in; + nfapi_system_information_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_UTRAN; + + in.utran_system_information_request.tl.tag = NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG; + in.utran_system_information_request.uarfcn = 16; + in.utran_system_information_request.psc = 4; + in.utran_system_information_request.timeout = 2000; + + in.pnf_cell_broadcast_state.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.utran_system_information_request.tl.tag, out.utran_system_information_request.tl.tag); + CU_ASSERT_EQUAL(in.utran_system_information_request.uarfcn, out.utran_system_information_request.uarfcn); + CU_ASSERT_EQUAL(in.utran_system_information_request.psc, out.utran_system_information_request.psc); + CU_ASSERT_EQUAL(in.utran_system_information_request.timeout, out.utran_system_information_request.timeout); + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); +} +void nfapi_test_system_information_request_geran() +{ + nfapi_system_information_request_t in; + nfapi_system_information_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_GERAN; + + in.geran_system_information_request.tl.tag = NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG; + in.geran_system_information_request.arfcn = 16; + in.geran_system_information_request.bsic = 4; + in.geran_system_information_request.timeout = 2000; + + in.pnf_cell_broadcast_state.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rat_type, out.rat_type); + CU_ASSERT_EQUAL(in.geran_system_information_request.tl.tag, out.geran_system_information_request.tl.tag); + CU_ASSERT_EQUAL(in.geran_system_information_request.arfcn, out.geran_system_information_request.arfcn); + CU_ASSERT_EQUAL(in.geran_system_information_request.bsic, out.geran_system_information_request.bsic); + CU_ASSERT_EQUAL(in.geran_system_information_request.timeout, out.geran_system_information_request.timeout); + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); +} +void nfapi_test_system_information_request_state_overrun() +{ + nfapi_system_information_request_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_SYSTEM_INFORMATION_REQUEST, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push8(NFAPI_RAT_TYPE_LTE, &p, end); + + push16(NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG, &p, end); + push16(16, &p, end); + + push16(8, &p, end); + push16(8, &p, end); + push16(8, &p, end); + push8(8, &p, end); + push8(8, &p, end); + push8(1, &p, end); + { + push8(1, &p, end); + push8(1, &p, end); + } + push8(1, &p, end); + push32(1, &p, end); + + push16(NFAPI_PNF_CELL_BROADCAST_STATE_TAG, &p, end); + push16(NFAPI_MAX_OPAQUE_DATA + 1, &p, end); + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} + +void nfapi_test_system_information_request_nb_iot() +{ + uint16_t idx, idx2; + nfapi_system_information_request_t in; + nfapi_system_information_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.rat_type = NFAPI_RAT_TYPE_NB_IOT; + + in.nb_iot_system_information_request.tl.tag = NFAPI_NB_IOT_SYSTEM_INFORMATION_REQUEST_TAG; + in.nb_iot_system_information_request.earfcn = 16; + in.nb_iot_system_information_request.ro_dl = 1; + in.nb_iot_system_information_request.pci = 4; + in.nb_iot_system_information_request.number_of_si_periodicity = 1; + in.nb_iot_system_information_request.si_periodicity[0].si_periodicity = 3; + in.nb_iot_system_information_request.si_periodicity[0].si_repetition_pattern = 0; + in.nb_iot_system_information_request.si_periodicity[0].si_tb_size = 0; + in.nb_iot_system_information_request.si_periodicity[0].number_of_si_index = 2; + in.nb_iot_system_information_request.si_periodicity[0].si_index[0] = 2; + in.nb_iot_system_information_request.si_periodicity[0].si_index[1] = 20; + in.nb_iot_system_information_request.si_window_length = 0; + in.nb_iot_system_information_request.timeout = 2000; + + in.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG; + in.pnf_cell_broadcast_state.length = 7; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + IN_OUT_ASSERT(header.message_id); + IN_OUT_ASSERT(rat_type); + IN_OUT_ASSERT(nb_iot_system_information_request.tl.tag); + IN_OUT_ASSERT(nb_iot_system_information_request.earfcn); + IN_OUT_ASSERT(nb_iot_system_information_request.ro_dl); + IN_OUT_ASSERT(nb_iot_system_information_request.pci); + IN_OUT_ASSERT(nb_iot_system_information_request.number_of_si_periodicity); + + for(idx = 0; idx < in.nb_iot_system_information_request.number_of_si_periodicity; ++idx) + { + IN_OUT_ASSERT(nb_iot_system_information_request.si_periodicity[idx].si_periodicity); + IN_OUT_ASSERT(nb_iot_system_information_request.si_periodicity[idx].si_repetition_pattern); + IN_OUT_ASSERT(nb_iot_system_information_request.si_periodicity[idx].si_tb_size); + IN_OUT_ASSERT(nb_iot_system_information_request.si_periodicity[idx].number_of_si_index); + + for(idx2 = 0; idx2 < in.nb_iot_system_information_request.si_periodicity[idx].number_of_si_index; ++idx2) + IN_OUT_ASSERT(nb_iot_system_information_request.si_periodicity[idx].si_index[idx2]); + } + + IN_OUT_ASSERT(nb_iot_system_information_request.si_window_length); + IN_OUT_ASSERT(nb_iot_system_information_request.timeout); + + + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.tl.tag, out.pnf_cell_broadcast_state.tl.tag); + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.length, out.pnf_cell_broadcast_state.length); + for(idx = 0; idx < out.pnf_cell_broadcast_state.length; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_cell_broadcast_state.value[idx], out.pnf_cell_broadcast_state.value[idx]); + } +} + + +void nfapi_test_system_information_response() +{ + nfapi_system_information_response_t in; + nfapi_system_information_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_system_information_indication_lte() +{ + uint16_t idx; + nfapi_system_information_indication_t in; + nfapi_system_information_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + in.lte_system_information_indication.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG; + in.lte_system_information_indication.sib_type = 2; + in.lte_system_information_indication.sib_length = 15; + + in.utran_system_information_indication.tl.tag = 0; + in.geran_system_information_indication.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_system_information_indication.tl.tag, out.lte_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.lte_system_information_indication.sib_type, out.lte_system_information_indication.sib_type); + CU_ASSERT_EQUAL(in.lte_system_information_indication.sib_length, out.lte_system_information_indication.sib_length); + + for(idx = 0; idx < out.lte_system_information_indication.sib_length; ++idx) + { + CU_ASSERT_EQUAL(in.lte_system_information_indication.sib[idx], out.lte_system_information_indication.sib[idx]); + } + + CU_ASSERT_EQUAL(in.utran_system_information_indication.tl.tag, out.utran_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.geran_system_information_indication.tl.tag, out.geran_system_information_indication.tl.tag); + +} +void nfapi_test_system_information_indication_lte_overrun() +{ + nfapi_system_information_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_SYSTEM_INFORMATION_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error code + + push16(NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push8(1, &p, end); + push16(NFAPI_MAX_SIB_LENGTH + 1, &p, end); + + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_system_information_indication_utran() +{ + uint16_t idx; + nfapi_system_information_indication_t in; + nfapi_system_information_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + in.lte_system_information_indication.tl.tag = 0; + + in.utran_system_information_indication.tl.tag = NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG; + in.utran_system_information_indication.sib_length = 25; + + in.geran_system_information_indication.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_system_information_indication.tl.tag, out.lte_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_system_information_indication.tl.tag, out.utran_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_system_information_indication.sib_length, out.utran_system_information_indication.sib_length); + + for(idx = 0; idx < out.utran_system_information_indication.sib_length; ++idx) + { + CU_ASSERT_EQUAL(in.utran_system_information_indication.sib[idx], out.utran_system_information_indication.sib[idx]); + } + + CU_ASSERT_EQUAL(in.geran_system_information_indication.tl.tag, out.geran_system_information_indication.tl.tag); + +} +void nfapi_test_system_information_indication_utran_overrun() +{ + nfapi_system_information_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_SYSTEM_INFORMATION_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error code + + push16(NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push16(NFAPI_MAX_SIB_LENGTH + 1, &p, end); + + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} +void nfapi_test_system_information_indication_geran() +{ + uint16_t idx; + nfapi_system_information_indication_t in; + nfapi_system_information_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + in.lte_system_information_indication.tl.tag = 0; + in.utran_system_information_indication.tl.tag = 0; + + in.geran_system_information_indication.tl.tag = NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG; + in.geran_system_information_indication.si_length = 25; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.lte_system_information_indication.tl.tag, out.lte_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_system_information_indication.tl.tag, out.utran_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.geran_system_information_indication.tl.tag, out.geran_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.geran_system_information_indication.si_length, out.geran_system_information_indication.si_length); + + for(idx = 0; idx < out.geran_system_information_indication.si_length; ++idx) + { + CU_ASSERT_EQUAL(in.geran_system_information_indication.si[idx], out.geran_system_information_indication.si[idx]); + } + +} +void nfapi_test_system_information_indication_geran_overrun() +{ + nfapi_system_information_indication_t out; + + uint8_t buffer[1024]; + uint8_t* p = &buffer[0]; + uint8_t *end = p + 1024; + push16(0, &p, end); + push16(NFAPI_SYSTEM_INFORMATION_INDICATION, &p, end); + push16(64, &p, end); + push16(0, &p, end); + + push32(0, &p, end); // error code + + push16(NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG, &p, end); + push16(8, &p, end); + + push16(NFAPI_MAX_SI_LENGTH + 1, &p, end); + + + int result = nfapi_p4_message_unpack(buffer, 34, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(result, -1); +} + +void nfapi_test_system_information_indication_nb_iot() +{ + uint16_t idx; + nfapi_system_information_indication_t in; + nfapi_system_information_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SYSTEM_INFORMATION_INDICATION; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + in.nb_iot_system_information_indication.tl.tag = NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG; + in.nb_iot_system_information_indication.sib_type = 2; + in.nb_iot_system_information_indication.sib_length = 15; + + in.lte_system_information_indication.tl.tag = 0; + in.utran_system_information_indication.tl.tag = 0; + in.geran_system_information_indication.tl.tag = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.tl.tag, out.nb_iot_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.sib_type, out.nb_iot_system_information_indication.sib_type); + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.sib_length, out.nb_iot_system_information_indication.sib_length); + + for(idx = 0; idx < out.nb_iot_system_information_indication.sib_length; ++idx) + { + CU_ASSERT_EQUAL(in.nb_iot_system_information_indication.sib[idx], out.nb_iot_system_information_indication.sib[idx]); + } + + CU_ASSERT_EQUAL(in.lte_system_information_indication.tl.tag, out.lte_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.utran_system_information_indication.tl.tag, out.utran_system_information_indication.tl.tag); + CU_ASSERT_EQUAL(in.geran_system_information_indication.tl.tag, out.geran_system_information_indication.tl.tag); + +} + +void nfapi_test_nmm_stop_request() +{ + nfapi_nmm_stop_request_t in; + nfapi_nmm_stop_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_NMM_STOP_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); +} +void nfapi_test_nmm_stop_response() +{ + nfapi_nmm_stop_response_t in; + nfapi_nmm_stop_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_NMM_STOP_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_P4_MSG_RAT_NOT_SUPPORTED; + + int packedMessageLength = nfapi_p4_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p4_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} + + +void nfapi_test_pnf_param_request() +{ + nfapi_pnf_param_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_param_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_PARAM_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); +} +void nfapi_test_pnf_param_request_ve() +{ + nfapi_pnf_param_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_param_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_PARAM_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + my_vendor_extention ve; + ve.tl.tag = NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE; + ve.value1 = 56; + ve.value2 = 1234; + in.vendor_extension = (void*)&ve; + + nfapi_p4_p5_codec_config_t codec; + memset(&codec, 0, sizeof(codec)); + codec.unpack_vendor_extension_tlv = &nfapi_test_unpack_vendor_extension_tlv; + codec.pack_vendor_extension_tlv = &nfapi_test_pack_vendor_extension_tlv; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, &codec); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), &codec); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + + CU_ASSERT_NOT_EQUAL(in.vendor_extension, 0); + CU_ASSERT_EQUAL(((my_vendor_extention*)(out.vendor_extension))->tl.tag, ve.tl.tag); + CU_ASSERT_EQUAL(((my_vendor_extention*)(out.vendor_extension))->value1, ve.value1); + CU_ASSERT_EQUAL(((my_vendor_extention*)(out.vendor_extension))->value2, ve.value2); + + free(out.vendor_extension); +} +void nfapi_test_pnf_param_response() +{ + uint16_t idx = 0; + uint16_t idx2 = 0; + nfapi_pnf_param_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_param_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_PARAM_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = 0; + in.pnf_param_general.tl.tag = NFAPI_PNF_PARAM_GENERAL_TAG; + in.pnf_param_general.nfapi_sync_mode = 2; + in.pnf_param_general.location_mode = 1; + in.pnf_param_general.location_coordinates_length = 1; + in.pnf_param_general.location_coordinates[0] = 123; + in.pnf_param_general.dl_config_timing = 12; + in.pnf_param_general.tx_timing = 12; + in.pnf_param_general.ul_config_timing = 12; + in.pnf_param_general.hi_dci0_timing = 12; + in.pnf_param_general.maximum_number_phys = 2; + in.pnf_param_general.maximum_total_bandwidth = 100; + in.pnf_param_general.maximum_total_number_dl_layers = 2; + in.pnf_param_general.maximum_total_number_ul_layers = 2; + in.pnf_param_general.shared_bands = 0; + in.pnf_param_general.shared_pa = 0; + in.pnf_param_general.maximum_total_power = -190; + in.pnf_param_general.oui[0] = 88; + + in.pnf_phy.tl.tag = NFAPI_PNF_PHY_TAG; + in.pnf_phy.number_of_phys = 2; + in.pnf_phy.phy[0].phy_config_index = 0; + in.pnf_phy.phy[0].number_of_rfs = 2; + in.pnf_phy.phy[0].rf_config[0].rf_config_index = 0; + in.pnf_phy.phy[0].number_of_rf_exclusions = 1; + in.pnf_phy.phy[0].rf_config[0].rf_config_index = 1; + in.pnf_phy.phy[0].downlink_channel_bandwidth_supported = 20; + in.pnf_phy.phy[0].uplink_channel_bandwidth_supported = 20; + in.pnf_phy.phy[0].number_of_dl_layers_supported = 2; + in.pnf_phy.phy[0].number_of_ul_layers_supported = 1; + in.pnf_phy.phy[0].maximum_3gpp_release_supported = 3; + in.pnf_phy.phy[0].nmm_modes_supported = 2; + + in.pnf_rf.tl.tag = NFAPI_PNF_RF_TAG; + in.pnf_rf.number_of_rfs = 2; + in.pnf_rf.rf[0].rf_config_index = 0; + in.pnf_rf.rf[0].band = 1; + in.pnf_rf.rf[0].maximum_transmit_power = -100; + in.pnf_rf.rf[0].minimum_transmit_power = -90; + in.pnf_rf.rf[0].number_of_antennas_suppported = 4; + in.pnf_rf.rf[0].minimum_downlink_frequency = 100; + in.pnf_rf.rf[0].maximum_downlink_frequency = 2132; + in.pnf_rf.rf[0].minimum_uplink_frequency = 1231; + in.pnf_rf.rf[0].maximum_uplink_frequency = 123; + + + in.pnf_phy_rel10.tl.tag = NFAPI_PNF_PHY_REL10_TAG; + in.pnf_phy_rel10.number_of_phys = 2; + in.pnf_phy_rel10.phy[0].phy_config_index = 0; + in.pnf_phy_rel10.phy[0].transmission_mode_7_supported = 1; + in.pnf_phy_rel10.phy[0].transmission_mode_8_supported = 2; + in.pnf_phy_rel10.phy[0].two_antenna_ports_for_pucch = 3; + in.pnf_phy_rel10.phy[0].transmission_mode_9_supported = 4; + in.pnf_phy_rel10.phy[0].simultaneous_pucch_pusch = 5; + in.pnf_phy_rel10.phy[0].four_layer_tx_with_tm3_and_tm4 = 6; + + in.pnf_phy_rel11.tl.tag = NFAPI_PNF_PHY_REL11_TAG; + in.pnf_phy_rel11.number_of_phys = 2; + in.pnf_phy_rel11.phy[0].phy_config_index = 0; + in.pnf_phy_rel11.phy[0].edpcch_supported = 1; + in.pnf_phy_rel11.phy[0].multi_ack_csi_reporting = 2; + in.pnf_phy_rel11.phy[0].pucch_tx_diversity = 3; + in.pnf_phy_rel11.phy[0].ul_comp_supported = 4; + in.pnf_phy_rel11.phy[0].transmission_mode_5_supported = 5; + + in.pnf_phy_rel12.tl.tag = NFAPI_PNF_PHY_REL12_TAG; + in.pnf_phy_rel12.number_of_phys = 2; + in.pnf_phy_rel12.phy[0].phy_config_index = 0; + in.pnf_phy_rel12.phy[0].csi_subframe_set = 1; + in.pnf_phy_rel12.phy[0].enhanced_4tx_codebook = 2; + in.pnf_phy_rel12.phy[0].drs_supported = 3; + in.pnf_phy_rel12.phy[0].ul_64qam_supported = 4; + in.pnf_phy_rel12.phy[0].transmission_mode_10_supported = 5; + in.pnf_phy_rel12.phy[0].alternative_bts_indices = 6; + + in.pnf_phy_rel13.tl.tag = NFAPI_PNF_PHY_REL13_TAG; + in.pnf_phy_rel13.number_of_phys = 2; + in.pnf_phy_rel13.phy[0].phy_config_index = 0; + in.pnf_phy_rel13.phy[0].pucch_format4_supported = 1; + in.pnf_phy_rel13.phy[0].pucch_format5_supported = 2; + in.pnf_phy_rel13.phy[0].more_than_5_ca_support = 3; + in.pnf_phy_rel13.phy[0].laa_supported = 4; + in.pnf_phy_rel13.phy[0].laa_ending_in_dwpts_supported = 5; + in.pnf_phy_rel13.phy[0].laa_starting_in_second_slot_supported = 6; + in.pnf_phy_rel13.phy[0].beamforming_supported = 7; + in.pnf_phy_rel13.phy[0].csi_rs_enhancement_supported = 8; + in.pnf_phy_rel13.phy[0].drms_enhancement_supported = 9; + in.pnf_phy_rel13.phy[0].srs_enhancement_supported = 10; + + in.pnf_phy_rel13_nb_iot.tl.tag = NFAPI_PNF_PHY_REL13_NB_IOT_TAG; + in.pnf_phy_rel13_nb_iot.number_of_phys = 2; + in.pnf_phy_rel13_nb_iot.phy[0].phy_config_index = 0; + in.pnf_phy_rel13_nb_iot.phy[0].number_of_rfs = 2; + in.pnf_phy_rel13_nb_iot.phy[0].rf_config[0].rf_config_index = 0; + in.pnf_phy_rel13_nb_iot.phy[0].number_of_rf_exclusions = 1; + in.pnf_phy_rel13_nb_iot.phy[0].rf_config[0].rf_config_index = 1; + in.pnf_phy_rel13_nb_iot.phy[0].number_of_dl_layers_supported = 2; + in.pnf_phy_rel13_nb_iot.phy[0].number_of_ul_layers_supported = 1; + in.pnf_phy_rel13_nb_iot.phy[0].maximum_3gpp_release_supported = 3; + in.pnf_phy_rel13_nb_iot.phy[0].nmm_modes_supported = 2; + + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int unpack_result = nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(unpack_result, 1); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.pnf_param_general.tl.tag, out.pnf_param_general.tl.tag); + CU_ASSERT_EQUAL(in.pnf_param_general.nfapi_sync_mode, out.pnf_param_general.nfapi_sync_mode); + CU_ASSERT_EQUAL(in.pnf_param_general.location_mode, out.pnf_param_general.location_mode); + + for(idx = 0; idx < NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH; ++idx) + CU_ASSERT_EQUAL(in.pnf_param_general.location_coordinates[idx], out.pnf_param_general.location_coordinates[idx]); + + CU_ASSERT_EQUAL(in.pnf_param_general.dl_config_timing, out.pnf_param_general.dl_config_timing); + CU_ASSERT_EQUAL(in.pnf_param_general.tx_timing, out.pnf_param_general.tx_timing); + CU_ASSERT_EQUAL(in.pnf_param_general.ul_config_timing, out.pnf_param_general.ul_config_timing); + CU_ASSERT_EQUAL(in.pnf_param_general.hi_dci0_timing, out.pnf_param_general.hi_dci0_timing); + CU_ASSERT_EQUAL(in.pnf_param_general.maximum_number_phys, out.pnf_param_general.maximum_number_phys); + CU_ASSERT_EQUAL(in.pnf_param_general.maximum_total_bandwidth, out.pnf_param_general.maximum_total_bandwidth); + CU_ASSERT_EQUAL(in.pnf_param_general.maximum_total_number_dl_layers, out.pnf_param_general.maximum_total_number_dl_layers); + CU_ASSERT_EQUAL(in.pnf_param_general.maximum_total_number_ul_layers, out.pnf_param_general.maximum_total_number_ul_layers); + CU_ASSERT_EQUAL(in.pnf_param_general.shared_bands, out.pnf_param_general.shared_bands); + CU_ASSERT_EQUAL(in.pnf_param_general.shared_pa, out.pnf_param_general.shared_pa); + CU_ASSERT_EQUAL(in.pnf_param_general.maximum_total_power, out.pnf_param_general.maximum_total_power); + for(idx = 0; idx < NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH; ++idx) + CU_ASSERT_EQUAL(in.pnf_param_general.oui[idx], out.pnf_param_general.oui[idx]); + + CU_ASSERT_EQUAL(in.pnf_phy.tl.tag, out.pnf_phy.tl.tag); + CU_ASSERT_EQUAL(in.pnf_phy.number_of_phys, out.pnf_phy.number_of_phys); + + for(idx = 0; idx < out.pnf_phy.number_of_phys; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].phy_config_index, out.pnf_phy.phy[idx].phy_config_index); + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].number_of_rfs, out.pnf_phy.phy[idx].number_of_rfs); + + + for(idx2 = 0; idx2 < out.pnf_phy.phy[idx].number_of_rfs; ++idx2) + { + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].rf_config[idx2].rf_config_index, out.pnf_phy.phy[idx].rf_config[idx2].rf_config_index); + } + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].number_of_rf_exclusions, out.pnf_phy.phy[idx].number_of_rf_exclusions); + + for(idx2 = 0; idx2 < out.pnf_phy.phy[idx].number_of_rf_exclusions; ++idx2) + { + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].excluded_rf_config[idx2].rf_config_index, out.pnf_phy.phy[idx].excluded_rf_config[idx2].rf_config_index); + } + + + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].downlink_channel_bandwidth_supported, out.pnf_phy.phy[idx].downlink_channel_bandwidth_supported); + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].uplink_channel_bandwidth_supported, out.pnf_phy.phy[idx].uplink_channel_bandwidth_supported); + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].number_of_dl_layers_supported, out.pnf_phy.phy[idx].number_of_dl_layers_supported); + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].number_of_ul_layers_supported, out.pnf_phy.phy[idx].number_of_ul_layers_supported); + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].maximum_3gpp_release_supported, out.pnf_phy.phy[idx].maximum_3gpp_release_supported); + CU_ASSERT_EQUAL(in.pnf_phy.phy[idx].nmm_modes_supported, out.pnf_phy.phy[idx].nmm_modes_supported); + } + + CU_ASSERT_EQUAL(in.pnf_rf.tl.tag, out.pnf_rf.tl.tag); + CU_ASSERT_EQUAL(in.pnf_rf.number_of_rfs, out.pnf_rf.number_of_rfs); + for(idx = 0; idx < out.pnf_rf.number_of_rfs; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].rf_config_index, out.pnf_rf.rf[idx].rf_config_index); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].band, out.pnf_rf.rf[idx].band); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].maximum_transmit_power, out.pnf_rf.rf[idx].maximum_transmit_power); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].minimum_transmit_power, out.pnf_rf.rf[idx].minimum_transmit_power); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].number_of_antennas_suppported, out.pnf_rf.rf[idx].number_of_antennas_suppported); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].minimum_downlink_frequency, out.pnf_rf.rf[idx].minimum_downlink_frequency); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].maximum_downlink_frequency, out.pnf_rf.rf[idx].maximum_downlink_frequency); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].minimum_uplink_frequency, out.pnf_rf.rf[idx].minimum_uplink_frequency); + CU_ASSERT_EQUAL(in.pnf_rf.rf[idx].maximum_uplink_frequency, out.pnf_rf.rf[idx].maximum_uplink_frequency); + } + + + CU_ASSERT_EQUAL(in.pnf_phy_rel10.tl.tag, out.pnf_phy_rel10.tl.tag); + CU_ASSERT_EQUAL(in.pnf_phy_rel10.number_of_phys, out.pnf_phy_rel10.number_of_phys); + for(idx = 0; idx < out.pnf_phy_rel10.number_of_phys; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_phy_rel10.phy[idx].phy_config_index, out.pnf_phy_rel10.phy[idx].phy_config_index); + CU_ASSERT_EQUAL(in.pnf_phy_rel10.phy[idx].transmission_mode_7_supported, out.pnf_phy_rel10.phy[idx].transmission_mode_7_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel10.phy[idx].transmission_mode_8_supported, out.pnf_phy_rel10.phy[idx].transmission_mode_8_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel10.phy[idx].two_antenna_ports_for_pucch, out.pnf_phy_rel10.phy[idx].two_antenna_ports_for_pucch); + CU_ASSERT_EQUAL(in.pnf_phy_rel10.phy[idx].transmission_mode_9_supported, out.pnf_phy_rel10.phy[idx].transmission_mode_9_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel10.phy[idx].simultaneous_pucch_pusch, out.pnf_phy_rel10.phy[idx].simultaneous_pucch_pusch); + CU_ASSERT_EQUAL(in.pnf_phy_rel10.phy[idx].four_layer_tx_with_tm3_and_tm4, out.pnf_phy_rel10.phy[idx].four_layer_tx_with_tm3_and_tm4); + } + + CU_ASSERT_EQUAL(in.pnf_phy_rel11.tl.tag, out.pnf_phy_rel11.tl.tag); + CU_ASSERT_EQUAL(in.pnf_phy_rel11.number_of_phys, out.pnf_phy_rel11.number_of_phys); + for(idx = 0; idx < out.pnf_phy_rel11.number_of_phys; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_phy_rel11.phy[idx].phy_config_index, out.pnf_phy_rel11.phy[idx].phy_config_index); + CU_ASSERT_EQUAL(in.pnf_phy_rel11.phy[idx].edpcch_supported, out.pnf_phy_rel11.phy[idx].edpcch_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel11.phy[idx].multi_ack_csi_reporting, out.pnf_phy_rel11.phy[idx].multi_ack_csi_reporting); + CU_ASSERT_EQUAL(in.pnf_phy_rel11.phy[idx].pucch_tx_diversity, out.pnf_phy_rel11.phy[idx].pucch_tx_diversity); + CU_ASSERT_EQUAL(in.pnf_phy_rel11.phy[idx].ul_comp_supported, out.pnf_phy_rel11.phy[idx].ul_comp_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel11.phy[idx].transmission_mode_5_supported, out.pnf_phy_rel11.phy[idx].transmission_mode_5_supported); + } + + CU_ASSERT_EQUAL(in.pnf_phy_rel12.tl.tag, out.pnf_phy_rel12.tl.tag); + CU_ASSERT_EQUAL(in.pnf_phy_rel12.number_of_phys, out.pnf_phy_rel12.number_of_phys); + for(idx = 0; idx < out.pnf_phy_rel12.number_of_phys; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_phy_rel12.phy[idx].phy_config_index, out.pnf_phy_rel12.phy[idx].phy_config_index); + CU_ASSERT_EQUAL(in.pnf_phy_rel12.phy[idx].csi_subframe_set, out.pnf_phy_rel12.phy[idx].csi_subframe_set); + CU_ASSERT_EQUAL(in.pnf_phy_rel12.phy[idx].enhanced_4tx_codebook, out.pnf_phy_rel12.phy[idx].enhanced_4tx_codebook); + CU_ASSERT_EQUAL(in.pnf_phy_rel12.phy[idx].drs_supported, out.pnf_phy_rel12.phy[idx].drs_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel12.phy[idx].ul_64qam_supported, out.pnf_phy_rel12.phy[idx].ul_64qam_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel12.phy[idx].transmission_mode_10_supported, out.pnf_phy_rel12.phy[idx].transmission_mode_10_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel12.phy[idx].alternative_bts_indices, out.pnf_phy_rel12.phy[idx].alternative_bts_indices); + } + + CU_ASSERT_EQUAL(in.pnf_phy_rel13.tl.tag, out.pnf_phy_rel13.tl.tag); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.number_of_phys, out.pnf_phy_rel13.number_of_phys); + for(idx = 0; idx < out.pnf_phy_rel13.number_of_phys; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].phy_config_index, out.pnf_phy_rel13.phy[idx].phy_config_index); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].pucch_format4_supported, out.pnf_phy_rel13.phy[idx].pucch_format4_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].pucch_format5_supported, out.pnf_phy_rel13.phy[idx].pucch_format5_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].more_than_5_ca_support, out.pnf_phy_rel13.phy[idx].more_than_5_ca_support); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].laa_supported, out.pnf_phy_rel13.phy[idx].laa_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].laa_ending_in_dwpts_supported, out.pnf_phy_rel13.phy[idx].laa_ending_in_dwpts_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].laa_starting_in_second_slot_supported, out.pnf_phy_rel13.phy[idx].laa_starting_in_second_slot_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].beamforming_supported, out.pnf_phy_rel13.phy[idx].beamforming_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].csi_rs_enhancement_supported, out.pnf_phy_rel13.phy[idx].csi_rs_enhancement_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].drms_enhancement_supported, out.pnf_phy_rel13.phy[idx].drms_enhancement_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13.phy[idx].srs_enhancement_supported, out.pnf_phy_rel13.phy[idx].srs_enhancement_supported); + } + + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.tl.tag, out.pnf_phy_rel13_nb_iot.tl.tag); + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.number_of_phys, out.pnf_phy_rel13_nb_iot.number_of_phys); + + for(idx = 0; idx < out.pnf_phy_rel13_nb_iot.number_of_phys; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].phy_config_index, out.pnf_phy_rel13_nb_iot.phy[idx].phy_config_index); + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].number_of_rfs, out.pnf_phy_rel13_nb_iot.phy[idx].number_of_rfs); + + + for(idx2 = 0; idx2 < out.pnf_phy_rel13_nb_iot.phy[idx].number_of_rfs; ++idx2) + { + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].rf_config[idx2].rf_config_index, out.pnf_phy_rel13_nb_iot.phy[idx].rf_config[idx2].rf_config_index); + } + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].number_of_rf_exclusions, out.pnf_phy_rel13_nb_iot.phy[idx].number_of_rf_exclusions); + + for(idx2 = 0; idx2 < out.pnf_phy_rel13_nb_iot.phy[idx].number_of_rf_exclusions; ++idx2) + { + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].excluded_rf_config[idx2].rf_config_index, out.pnf_phy_rel13_nb_iot.phy[idx].excluded_rf_config[idx2].rf_config_index); + } + + + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].number_of_dl_layers_supported, out.pnf_phy_rel13_nb_iot.phy[idx].number_of_dl_layers_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].number_of_ul_layers_supported, out.pnf_phy_rel13_nb_iot.phy[idx].number_of_ul_layers_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].maximum_3gpp_release_supported, out.pnf_phy_rel13_nb_iot.phy[idx].maximum_3gpp_release_supported); + CU_ASSERT_EQUAL(in.pnf_phy_rel13_nb_iot.phy[idx].nmm_modes_supported, out.pnf_phy_rel13_nb_iot.phy[idx].nmm_modes_supported); + } + + +} + +void nfapi_test_pnf_config_request() +{ + uint16_t idx; + nfapi_pnf_config_request_t in; + nfapi_pnf_config_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_CONFIG_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + in.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; + in.pnf_phy_rf_config.number_phy_rf_config_info = 2; + in.pnf_phy_rf_config.phy_rf_config[0].phy_id = 0; + in.pnf_phy_rf_config.phy_rf_config[0].phy_config_index = 0; + in.pnf_phy_rf_config.phy_rf_config[0].rf_config_index = 0; + + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int unpack_result = nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(unpack_result, 1); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + //CU_ASSERT_EQUAL(in.error_code, out.error_code); + + CU_ASSERT_EQUAL(in.pnf_phy_rf_config.tl.tag, out.pnf_phy_rf_config.tl.tag); + CU_ASSERT_EQUAL(in.pnf_phy_rf_config.number_phy_rf_config_info, out.pnf_phy_rf_config.number_phy_rf_config_info); + + for(idx = 0; idx < out.pnf_phy_rf_config.number_phy_rf_config_info; ++idx) + { + CU_ASSERT_EQUAL(in.pnf_phy_rf_config.phy_rf_config[idx].phy_id, out.pnf_phy_rf_config.phy_rf_config[idx].phy_id); + CU_ASSERT_EQUAL(in.pnf_phy_rf_config.phy_rf_config[idx].phy_config_index, out.pnf_phy_rf_config.phy_rf_config[idx].phy_config_index); + CU_ASSERT_EQUAL(in.pnf_phy_rf_config.phy_rf_config[idx].rf_config_index, out.pnf_phy_rf_config.phy_rf_config[idx].rf_config_index); + } +} + + + +void nfapi_test_pnf_config_response() +{ + nfapi_pnf_config_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_config_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_CONFIG_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_pnf_config_response1() +{ + uint8_t buffer[NFAPI_HEADER_LENGTH + 1]; + + nfapi_pnf_config_response_t in; + memset(&in, 0, sizeof(in)); + //nfapi_pnf_config_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_CONFIG_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), buffer, sizeof(buffer), 0); + CU_ASSERT_EQUAL(packedMessageLength, -1); + + //nfapi_p5_message_unpack(buffer, sizeof(buffer), &out, sizeof(out), 0); + //CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + //CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_pnf_start_request() +{ + nfapi_pnf_start_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_start_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_START_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); +} + +void nfapi_test_pnf_start_response() +{ + nfapi_pnf_start_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_start_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_START_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_pnf_stop_request() +{ + nfapi_pnf_stop_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_stop_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_STOP_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); +} +void nfapi_test_pnf_stop_response() +{ + nfapi_pnf_stop_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_pnf_stop_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PNF_STOP_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} + +void nfapi_test_param_request() +{ + nfapi_param_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_param_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PARAM_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); +} +void nfapi_test_param_response() +{ + #define SET_TLV(_TLV, _TAG, _VALUE) { _TLV.tl.tag = _TAG; _TLV.value = _VALUE; num_tlv++; } + #define ASSERT_TLV(IN_TLV, OUT_TLV) { CU_ASSERT_EQUAL(IN_TLV.tl.tag, OUT_TLV.tl.tag); CU_ASSERT_EQUAL(IN_TLV.value, OUT_TLV.value);} + + nfapi_param_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_param_response_t out; + memset(&out, 0, sizeof(out)); + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_PARAM_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + uint16_t idx = 0; + uint16_t num_tlv = 0; // Bit of a hack, it is incremented in the SET_UINT16_TLV macro + + SET_TLV(in.l1_status.phy_state, NFAPI_L1_STATUS_PHY_STATE_TAG, 1); + SET_TLV(in.phy_capabilities.dl_bandwidth_support, NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG, 63); + SET_TLV(in.phy_capabilities.ul_bandwidth_support, NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG, 63); + SET_TLV(in.phy_capabilities.dl_modulation_support, NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG, 3); + SET_TLV(in.phy_capabilities.ul_modulation_support, NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG, 3); + SET_TLV(in.phy_capabilities.phy_antenna_capability, NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG, 8); + SET_TLV(in.phy_capabilities.release_capability, NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG, 63); + SET_TLV(in.phy_capabilities.mbsfn_capability, NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG, 0); + + SET_TLV(in.laa_capability.laa_support, NFAPI_LAA_CAPABILITY_LAA_SUPPORT_TAG, 1); + SET_TLV(in.laa_capability.pd_sensing_lbt_support, NFAPI_LAA_CAPABILITY_PD_SENSING_LBT_SUPPORT_TAG, 0); + SET_TLV(in.laa_capability.multi_carrier_lbt_support, NFAPI_LAA_CAPABILITY_MULTI_CARRIER_LBT_SUPPORT_TAG, 3); + SET_TLV(in.laa_capability.partial_sf_support, NFAPI_LAA_CAPABILITY_PARTIAL_SF_SUPPORT_TAG, 2); + + SET_TLV(in.subframe_config.duplex_mode, NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG, 1); + SET_TLV(in.subframe_config.pcfich_power_offset, NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG, 1000); + SET_TLV(in.subframe_config.pb, NFAPI_SUBFRAME_CONFIG_PB_TAG, 1); + SET_TLV(in.subframe_config.dl_cyclic_prefix_type, NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG, 0); + SET_TLV(in.subframe_config.ul_cyclic_prefix_type, NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG, 0); + + SET_TLV(in.rf_config.dl_channel_bandwidth, NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG, 50); + SET_TLV(in.rf_config.ul_channel_bandwidth, NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG, 50); + SET_TLV(in.rf_config.reference_signal_power, NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG, 120); + SET_TLV(in.rf_config.tx_antenna_ports, NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG, 2); + SET_TLV(in.rf_config.rx_antenna_ports, NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG, 2); + + SET_TLV(in.phich_config.phich_resource, NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG, 3); + SET_TLV(in.phich_config.phich_duration, NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG, 0); + SET_TLV(in.phich_config.phich_power_offset, NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG, 500); + + SET_TLV(in.sch_config.primary_synchronization_signal_epre_eprers, NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, 1000); + SET_TLV(in.sch_config.secondary_synchronization_signal_epre_eprers, NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, 2000); + SET_TLV(in.sch_config.physical_cell_id, NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG, 12344); + + + SET_TLV(in.prach_config.configuration_index, NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG, 63); + SET_TLV(in.prach_config.root_sequence_index, NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG, 800); + SET_TLV(in.prach_config.zero_correlation_zone_configuration, NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, 14); + SET_TLV(in.prach_config.high_speed_flag, NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG, 0); + SET_TLV(in.prach_config.frequency_offset, NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG, 23); + + SET_TLV(in.pusch_config.hopping_mode, NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG, 0); + SET_TLV(in.pusch_config.hopping_offset, NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG, 55); + SET_TLV(in.pusch_config.number_of_subbands, NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG, 1); + + SET_TLV(in.pucch_config.delta_pucch_shift, NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG, 2); + SET_TLV(in.pucch_config.n_cqi_rb, NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG, 88); + SET_TLV(in.pucch_config.n_an_cs, NFAPI_PUCCH_CONFIG_N_AN_CS_TAG, 3); + SET_TLV(in.pucch_config.n1_pucch_an, NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG, 2015); + + SET_TLV(in.srs_config.bandwidth_configuration, NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG, 3); + SET_TLV(in.srs_config.max_up_pts, NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG, 0); + SET_TLV(in.srs_config.srs_subframe_configuration, NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG, 11); + SET_TLV(in.srs_config.srs_acknack_srs_simultaneous_transmission, NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG, 1); + + SET_TLV(in.uplink_reference_signal_config.uplink_rs_hopping, NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG, 2); + SET_TLV(in.uplink_reference_signal_config.group_assignment, NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG, 22); + SET_TLV(in.uplink_reference_signal_config.cyclic_shift_1_for_drms, NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG, 2); + + SET_TLV(in.tdd_frame_structure_config.subframe_assignment, NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG, 5); + SET_TLV(in.tdd_frame_structure_config.special_subframe_patterns, NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG, 3); + + SET_TLV(in.l23_config.data_report_mode, NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG, 1); + SET_TLV(in.l23_config.sfnsf, NFAPI_L23_CONFIG_SFNSF_TAG, 12354); + + in.nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; + num_tlv++; + + in.nfapi_config.p7_vnf_address_ipv6.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG; + num_tlv++; + + SET_TLV(in.nfapi_config.p7_vnf_port, NFAPI_NFAPI_P7_VNF_PORT_TAG, 1111); + + in.nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG; + num_tlv++; + + in.nfapi_config.p7_pnf_address_ipv6.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG; + num_tlv++; + + SET_TLV(in.nfapi_config.p7_pnf_port, NFAPI_NFAPI_P7_PNF_PORT_TAG, 9999); + SET_TLV(in.nfapi_config.dl_ue_per_sf, NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, 4); + SET_TLV(in.nfapi_config.ul_ue_per_sf, NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, 4); + + in.nfapi_config.rf_bands.tl.tag = NFAPI_PHY_RF_BANDS_TAG; + in.nfapi_config.rf_bands.number_rf_bands = 2; + in.nfapi_config.rf_bands.rf_band[0] = 783; + num_tlv++; + + SET_TLV(in.nfapi_config.timing_window, NFAPI_NFAPI_TIMING_WINDOW_TAG, 29); + SET_TLV(in.nfapi_config.timing_info_mode, NFAPI_NFAPI_TIMING_INFO_MODE_TAG, 2); + SET_TLV(in.nfapi_config.timing_info_period, NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG, 23); + SET_TLV(in.nfapi_config.max_transmit_power, NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, 123); + SET_TLV(in.nfapi_config.earfcn, NFAPI_NFAPI_EARFCN_TAG, 1800); + + in.nfapi_config.nmm_gsm_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG; + in.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands = 2; + num_tlv++; + + in.nfapi_config.nmm_umts_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG; + in.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands = 3; + num_tlv++; + + in.nfapi_config.nmm_lte_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG; + in.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands = 1; + num_tlv++; + + SET_TLV(in.nfapi_config.nmm_uplink_rssi_supported, NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, 1); + + + in.num_tlv = num_tlv; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + CU_ASSERT_EQUAL(in.num_tlv, out.num_tlv); + + ASSERT_TLV(in.l1_status.phy_state, out.l1_status.phy_state); + ASSERT_TLV(in.phy_capabilities.dl_bandwidth_support, out.phy_capabilities.dl_bandwidth_support); + ASSERT_TLV(in.phy_capabilities.ul_bandwidth_support, out.phy_capabilities.ul_bandwidth_support); + ASSERT_TLV(in.phy_capabilities.dl_modulation_support, out.phy_capabilities.dl_modulation_support); + ASSERT_TLV(in.phy_capabilities.ul_modulation_support, out.phy_capabilities.ul_modulation_support); + ASSERT_TLV(in.phy_capabilities.phy_antenna_capability, out.phy_capabilities.phy_antenna_capability); + ASSERT_TLV(in.phy_capabilities.release_capability, out.phy_capabilities.release_capability); + ASSERT_TLV(in.phy_capabilities.mbsfn_capability, out.phy_capabilities.mbsfn_capability); + + ASSERT_TLV(in.laa_capability.laa_support, in.laa_capability.laa_support); + ASSERT_TLV(in.laa_capability.pd_sensing_lbt_support, in.laa_capability.pd_sensing_lbt_support); + ASSERT_TLV(in.laa_capability.multi_carrier_lbt_support, in.laa_capability.multi_carrier_lbt_support); + ASSERT_TLV(in.laa_capability.partial_sf_support, in.laa_capability.partial_sf_support); + + ASSERT_TLV(in.subframe_config.duplex_mode, out.subframe_config.duplex_mode); + ASSERT_TLV(in.subframe_config.pcfich_power_offset, out.subframe_config.pcfich_power_offset); + ASSERT_TLV(in.subframe_config.pb, out.subframe_config.pb); + ASSERT_TLV(in.subframe_config.dl_cyclic_prefix_type, out.subframe_config.dl_cyclic_prefix_type); + ASSERT_TLV(in.subframe_config.ul_cyclic_prefix_type, out.subframe_config.ul_cyclic_prefix_type); + + ASSERT_TLV(in.rf_config.dl_channel_bandwidth, out.rf_config.dl_channel_bandwidth); + ASSERT_TLV(in.rf_config.ul_channel_bandwidth, out.rf_config.ul_channel_bandwidth); + ASSERT_TLV(in.rf_config.reference_signal_power, out.rf_config.reference_signal_power); + ASSERT_TLV(in.rf_config.tx_antenna_ports, out.rf_config.tx_antenna_ports); + ASSERT_TLV(in.rf_config.rx_antenna_ports, out.rf_config.rx_antenna_ports); + + ASSERT_TLV(in.phich_config.phich_resource, out.phich_config.phich_resource); + ASSERT_TLV(in.phich_config.phich_duration, out.phich_config.phich_duration); + ASSERT_TLV(in.phich_config.phich_power_offset, out.phich_config.phich_power_offset); + + ASSERT_TLV(in.sch_config.primary_synchronization_signal_epre_eprers, out.sch_config.primary_synchronization_signal_epre_eprers); + ASSERT_TLV(in.sch_config.secondary_synchronization_signal_epre_eprers, out.sch_config.secondary_synchronization_signal_epre_eprers); + ASSERT_TLV(in.sch_config.physical_cell_id, out.sch_config.physical_cell_id); + + + ASSERT_TLV(in.prach_config.configuration_index, out.prach_config.configuration_index); + ASSERT_TLV(in.prach_config.root_sequence_index, out.prach_config.root_sequence_index); + ASSERT_TLV(in.prach_config.zero_correlation_zone_configuration, out.prach_config.zero_correlation_zone_configuration); + ASSERT_TLV(in.prach_config.high_speed_flag, out.prach_config.high_speed_flag); + ASSERT_TLV(in.prach_config.frequency_offset, out.prach_config.frequency_offset); + + ASSERT_TLV(in.pusch_config.hopping_mode, in.pusch_config.hopping_mode); + ASSERT_TLV(in.pusch_config.hopping_offset, in.pusch_config.hopping_offset); + ASSERT_TLV(in.pusch_config.number_of_subbands, in.pusch_config.number_of_subbands); + + ASSERT_TLV(in.pucch_config.delta_pucch_shift, out.pucch_config.delta_pucch_shift); + ASSERT_TLV(in.pucch_config.n_cqi_rb, out.pucch_config.n_cqi_rb); + ASSERT_TLV(in.pucch_config.n_an_cs, out.pucch_config.n_an_cs); + ASSERT_TLV(in.pucch_config.n1_pucch_an, out.pucch_config.n1_pucch_an); + + ASSERT_TLV(in.srs_config.bandwidth_configuration, out.srs_config.bandwidth_configuration); + ASSERT_TLV(in.srs_config.max_up_pts, out.srs_config.max_up_pts); + ASSERT_TLV(in.srs_config.srs_subframe_configuration, out.srs_config.srs_subframe_configuration); + ASSERT_TLV(in.srs_config.srs_acknack_srs_simultaneous_transmission, out.srs_config.srs_acknack_srs_simultaneous_transmission); + + ASSERT_TLV(in.uplink_reference_signal_config.uplink_rs_hopping, out.uplink_reference_signal_config.uplink_rs_hopping); + ASSERT_TLV(in.uplink_reference_signal_config.group_assignment, out.uplink_reference_signal_config.group_assignment); + ASSERT_TLV(in.uplink_reference_signal_config.cyclic_shift_1_for_drms, out.uplink_reference_signal_config.cyclic_shift_1_for_drms); + + ASSERT_TLV(in.tdd_frame_structure_config.subframe_assignment, out.tdd_frame_structure_config.subframe_assignment); + ASSERT_TLV(in.tdd_frame_structure_config.special_subframe_patterns, out.tdd_frame_structure_config.special_subframe_patterns); + + ASSERT_TLV(in.l23_config.data_report_mode, out.l23_config.data_report_mode); + ASSERT_TLV(in.l23_config.sfnsf, out.l23_config.sfnsf); + + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv4.tl.tag, out.nfapi_config.p7_vnf_address_ipv4.tl.tag); + for(idx = 0; idx < NFAPI_IPV4_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv4.address[idx], out.nfapi_config.p7_vnf_address_ipv4.address[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv6.tl.tag, out.nfapi_config.p7_vnf_address_ipv6.tl.tag); + for(idx = 0; idx < NFAPI_IPV6_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv6.address[idx], out.nfapi_config.p7_vnf_address_ipv6.address[idx]); + } + + ASSERT_TLV(in.nfapi_config.p7_vnf_port, out.nfapi_config.p7_vnf_port); + + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv4.tl.tag, out.nfapi_config.p7_pnf_address_ipv4.tl.tag); + for(idx = 0; idx < NFAPI_IPV4_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv4.address[idx], out.nfapi_config.p7_pnf_address_ipv4.address[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv6.tl.tag, out.nfapi_config.p7_pnf_address_ipv6.tl.tag); + for(idx = 0; idx < NFAPI_IPV6_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv6.address[idx], out.nfapi_config.p7_pnf_address_ipv6.address[idx]); + } + + ASSERT_TLV(in.nfapi_config.p7_pnf_port, out.nfapi_config.p7_pnf_port); + ASSERT_TLV(in.nfapi_config.dl_ue_per_sf, out.nfapi_config.dl_ue_per_sf); + ASSERT_TLV(in.nfapi_config.ul_ue_per_sf, out.nfapi_config.ul_ue_per_sf); + + CU_ASSERT_EQUAL(in.nfapi_config.rf_bands.tl.tag, out.nfapi_config.rf_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.rf_bands.number_rf_bands, out.nfapi_config.rf_bands.number_rf_bands); + for(idx = 0; idx < out.nfapi_config.rf_bands.number_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.rf_bands.rf_band[idx], out.nfapi_config.rf_bands.rf_band[idx]); + } + + ASSERT_TLV(in.nfapi_config.timing_window, out.nfapi_config.timing_window); + ASSERT_TLV(in.nfapi_config.timing_info_mode, out.nfapi_config.timing_info_mode); + ASSERT_TLV(in.nfapi_config.timing_info_period, out.nfapi_config.timing_info_period); + ASSERT_TLV(in.nfapi_config.max_transmit_power, out.nfapi_config.max_transmit_power); + ASSERT_TLV(in.nfapi_config.earfcn, out.nfapi_config.earfcn); + + CU_ASSERT_EQUAL(in.nfapi_config.nmm_gsm_frequency_bands.tl.tag, out.nfapi_config.nmm_gsm_frequency_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands, out.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands); + for(idx = 0; idx < out.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.nmm_gsm_frequency_bands.bands[idx], out.nfapi_config.nmm_gsm_frequency_bands.bands[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.nmm_umts_frequency_bands.tl.tag, out.nfapi_config.nmm_umts_frequency_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands, out.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands); + for(idx = 0; idx < out.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.nmm_umts_frequency_bands.bands[idx], out.nfapi_config.nmm_umts_frequency_bands.bands[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.nmm_lte_frequency_bands.tl.tag, out.nfapi_config.nmm_lte_frequency_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands, out.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands); + for(idx = 0; idx < out.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.nmm_lte_frequency_bands.bands[idx], out.nfapi_config.nmm_lte_frequency_bands.bands[idx]); + } + + ASSERT_TLV(in.nfapi_config.nmm_uplink_rssi_supported, out.nfapi_config.nmm_uplink_rssi_supported); +} +void nfapi_test_config_request() +{ + #define SET_TLV(_TLV, _TAG, _VALUE) { _TLV.tl.tag = _TAG; _TLV.value = _VALUE; num_tlv++; } + #define ASSERT_TLV(IN_TLV, OUT_TLV) { CU_ASSERT_EQUAL(IN_TLV.tl.tag, OUT_TLV.tl.tag); CU_ASSERT_EQUAL(IN_TLV.value, OUT_TLV.value);} + + nfapi_config_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_config_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CONFIG_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + + uint16_t idx = 0; + uint16_t num_tlv = 0; // Bit of a hack, it is incremented in the SET_UINT16_TLV macro + + SET_TLV(in.subframe_config.duplex_mode, NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG, 1); + SET_TLV(in.subframe_config.pcfich_power_offset, NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG, 1000); + SET_TLV(in.subframe_config.pb, NFAPI_SUBFRAME_CONFIG_PB_TAG, 1); + SET_TLV(in.subframe_config.dl_cyclic_prefix_type, NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG, 0); + SET_TLV(in.subframe_config.ul_cyclic_prefix_type, NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG, 0); + + SET_TLV(in.rf_config.dl_channel_bandwidth, NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG, 50); + SET_TLV(in.rf_config.ul_channel_bandwidth, NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG, 50); + SET_TLV(in.rf_config.reference_signal_power, NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG, 120); + SET_TLV(in.rf_config.tx_antenna_ports, NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG, 2); + SET_TLV(in.rf_config.rx_antenna_ports, NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG, 2); + + SET_TLV(in.phich_config.phich_resource, NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG, 3); + SET_TLV(in.phich_config.phich_duration, NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG, 0); + SET_TLV(in.phich_config.phich_power_offset, NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG, 500); + + SET_TLV(in.sch_config.primary_synchronization_signal_epre_eprers, NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, 1000); + SET_TLV(in.sch_config.secondary_synchronization_signal_epre_eprers, NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG, 2000); + SET_TLV(in.sch_config.physical_cell_id, NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG, 12344); + + + SET_TLV(in.prach_config.configuration_index, NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG, 63); + SET_TLV(in.prach_config.root_sequence_index, NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG, 800); + SET_TLV(in.prach_config.zero_correlation_zone_configuration, NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, 14); + SET_TLV(in.prach_config.high_speed_flag, NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG, 0); + SET_TLV(in.prach_config.frequency_offset, NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG, 23); + + SET_TLV(in.pusch_config.hopping_mode, NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG, 0); + SET_TLV(in.pusch_config.hopping_offset, NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG, 55); + SET_TLV(in.pusch_config.number_of_subbands, NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG, 1); + + SET_TLV(in.pucch_config.delta_pucch_shift, NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG, 2); + SET_TLV(in.pucch_config.n_cqi_rb, NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG, 88); + SET_TLV(in.pucch_config.n_an_cs, NFAPI_PUCCH_CONFIG_N_AN_CS_TAG, 3); + SET_TLV(in.pucch_config.n1_pucch_an, NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG, 2015); + + SET_TLV(in.srs_config.bandwidth_configuration, NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG, 3); + SET_TLV(in.srs_config.max_up_pts, NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG, 0); + SET_TLV(in.srs_config.srs_subframe_configuration, NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG, 11); + SET_TLV(in.srs_config.srs_acknack_srs_simultaneous_transmission, NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG, 1); + + SET_TLV(in.uplink_reference_signal_config.uplink_rs_hopping, NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG, 2); + SET_TLV(in.uplink_reference_signal_config.group_assignment, NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG, 22); + SET_TLV(in.uplink_reference_signal_config.cyclic_shift_1_for_drms, NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG, 2); + + + // laa config + SET_TLV(in.laa_config.ed_threshold_lbt_pdsch, NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG, 45); + SET_TLV(in.laa_config.ed_threshold_lbt_drs, NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG, 69); + SET_TLV(in.laa_config.pd_threshold, NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG, 65535); + SET_TLV(in.laa_config.multi_carrier_type, NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG, 3); + SET_TLV(in.laa_config.multi_carrier_tx, NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG, 1); + SET_TLV(in.laa_config.multi_carrier_freeze, NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG, 0); + SET_TLV(in.laa_config.tx_antenna_ports_drs, NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG, 4); + SET_TLV(in.laa_config.tx_power_drs, NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG, 10000); + // + // emtc config + SET_TLV(in.emtc_config.pbch_repetitions_enable_r13, NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG, 1); + SET_TLV(in.emtc_config.prach_catm_root_sequence_index, NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG, 837); + SET_TLV(in.emtc_config.prach_catm_zero_correlation_zone_configuration, NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG, 15); + SET_TLV(in.emtc_config.prach_catm_high_speed_flag, NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG, 15); + SET_TLV(in.emtc_config.prach_ce_level_0_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG, 1); + SET_TLV(in.emtc_config.prach_ce_level_0_configuration_index, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG, 60); + SET_TLV(in.emtc_config.prach_ce_level_0_frequency_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG, 90); + SET_TLV(in.emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, 128); + SET_TLV(in.emtc_config.prach_ce_level_0_starting_subframe_periodicity, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG, 256); + SET_TLV(in.emtc_config.prach_ce_level_0_hopping_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG, 1); + SET_TLV(in.emtc_config.prach_ce_level_0_hopping_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG, 0); + SET_TLV(in.emtc_config.prach_ce_level_1_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG, 1); + SET_TLV(in.emtc_config.prach_ce_level_1_configuration_index, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG, 45); + SET_TLV(in.emtc_config.prach_ce_level_1_frequency_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG, 88); + SET_TLV(in.emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, 64); + SET_TLV(in.emtc_config.prach_ce_level_1_starting_subframe_periodicity, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG, 0xFFFF); + SET_TLV(in.emtc_config.prach_ce_level_1_hopping_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG, 1); + SET_TLV(in.emtc_config.prach_ce_level_1_hopping_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG, 22); + SET_TLV(in.emtc_config.prach_ce_level_2_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG, 1); + SET_TLV(in.emtc_config.prach_ce_level_2_configuration_index, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG, 63); + SET_TLV(in.emtc_config.prach_ce_level_2_frequency_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG, 22); + SET_TLV(in.emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, 8); + SET_TLV(in.emtc_config.prach_ce_level_2_starting_subframe_periodicity, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG, 64) + SET_TLV(in.emtc_config.prach_ce_level_2_hopping_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG, 1); + SET_TLV(in.emtc_config.prach_ce_level_2_hopping_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG, 45); + SET_TLV(in.emtc_config.prach_ce_level_3_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG, 0); + SET_TLV(in.emtc_config.prach_ce_level_3_configuration_index, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG, 45); + SET_TLV(in.emtc_config.prach_ce_level_3_frequency_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG, 22); + SET_TLV(in.emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG, 4); + SET_TLV(in.emtc_config.prach_ce_level_3_starting_subframe_periodicity, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG, 4); + SET_TLV(in.emtc_config.prach_ce_level_3_hopping_enable, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG, 0); + SET_TLV(in.emtc_config.prach_ce_level_3_hopping_offset, NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG, 0); + SET_TLV(in.emtc_config.pucch_interval_ulhoppingconfigcommonmodea, NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG, 8); + SET_TLV(in.emtc_config.pucch_interval_ulhoppingconfigcommonmodeb, NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG, 8); + + + SET_TLV(in.tdd_frame_structure_config.subframe_assignment, NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG, 5); + SET_TLV(in.tdd_frame_structure_config.special_subframe_patterns, NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG, 3); + + SET_TLV(in.l23_config.data_report_mode, NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG, 1); + SET_TLV(in.l23_config.sfnsf, NFAPI_L23_CONFIG_SFNSF_TAG, 12354); + + in.nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; + num_tlv++; + + in.nfapi_config.p7_vnf_address_ipv6.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG; + num_tlv++; + + SET_TLV(in.nfapi_config.p7_vnf_port, NFAPI_NFAPI_P7_VNF_PORT_TAG, 1111); + + in.nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG; + num_tlv++; + + in.nfapi_config.p7_pnf_address_ipv6.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG; + for(idx = 0; idx < NFAPI_IPV6_ADDRESS_LENGTH; ++idx) + { + in.nfapi_config.p7_pnf_address_ipv6.address[idx] = idx; + } + num_tlv++; + + SET_TLV(in.nfapi_config.p7_pnf_port, NFAPI_NFAPI_P7_PNF_PORT_TAG, 9999); + SET_TLV(in.nfapi_config.dl_ue_per_sf, NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, 4); + SET_TLV(in.nfapi_config.ul_ue_per_sf, NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, 4); + + in.nfapi_config.rf_bands.tl.tag = NFAPI_PHY_RF_BANDS_TAG; + in.nfapi_config.rf_bands.number_rf_bands = 2; + in.nfapi_config.rf_bands.rf_band[0] = 783; + num_tlv++; + + SET_TLV(in.nfapi_config.timing_window, NFAPI_NFAPI_TIMING_WINDOW_TAG, 29); + SET_TLV(in.nfapi_config.timing_info_mode, NFAPI_NFAPI_TIMING_INFO_MODE_TAG, 2); + SET_TLV(in.nfapi_config.timing_info_period, NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG, 23); + SET_TLV(in.nfapi_config.max_transmit_power, NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, 123); + SET_TLV(in.nfapi_config.earfcn, NFAPI_NFAPI_EARFCN_TAG, 1800); + + in.nfapi_config.nmm_gsm_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG; + in.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands = 2; + num_tlv++; + + in.nfapi_config.nmm_umts_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG; + in.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands = 3; + num_tlv++; + + in.nfapi_config.nmm_lte_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG; + in.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands = 1; + num_tlv++; + + SET_TLV(in.nfapi_config.nmm_uplink_rssi_supported, NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG, 1); + + + in.num_tlv = num_tlv; + + in.vendor_extension = 0; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.num_tlv, out.num_tlv); + + ASSERT_TLV(in.subframe_config.duplex_mode, out.subframe_config.duplex_mode); + ASSERT_TLV(in.subframe_config.pcfich_power_offset, out.subframe_config.pcfich_power_offset); + ASSERT_TLV(in.subframe_config.pb, out.subframe_config.pb); + ASSERT_TLV(in.subframe_config.dl_cyclic_prefix_type, out.subframe_config.dl_cyclic_prefix_type); + ASSERT_TLV(in.subframe_config.ul_cyclic_prefix_type, out.subframe_config.ul_cyclic_prefix_type); + + ASSERT_TLV(in.rf_config.dl_channel_bandwidth, out.rf_config.dl_channel_bandwidth); + ASSERT_TLV(in.rf_config.ul_channel_bandwidth, out.rf_config.ul_channel_bandwidth); + ASSERT_TLV(in.rf_config.reference_signal_power, out.rf_config.reference_signal_power); + ASSERT_TLV(in.rf_config.tx_antenna_ports, out.rf_config.tx_antenna_ports); + ASSERT_TLV(in.rf_config.rx_antenna_ports, out.rf_config.rx_antenna_ports); + + ASSERT_TLV(in.phich_config.phich_resource, out.phich_config.phich_resource); + ASSERT_TLV(in.phich_config.phich_duration, out.phich_config.phich_duration); + ASSERT_TLV(in.phich_config.phich_power_offset, out.phich_config.phich_power_offset); + + ASSERT_TLV(in.sch_config.primary_synchronization_signal_epre_eprers, out.sch_config.primary_synchronization_signal_epre_eprers); + ASSERT_TLV(in.sch_config.secondary_synchronization_signal_epre_eprers, out.sch_config.secondary_synchronization_signal_epre_eprers); + ASSERT_TLV(in.sch_config.physical_cell_id, out.sch_config.physical_cell_id); + + + ASSERT_TLV(in.prach_config.configuration_index, out.prach_config.configuration_index); + ASSERT_TLV(in.prach_config.root_sequence_index, out.prach_config.root_sequence_index); + ASSERT_TLV(in.prach_config.zero_correlation_zone_configuration, out.prach_config.zero_correlation_zone_configuration); + ASSERT_TLV(in.prach_config.high_speed_flag, out.prach_config.high_speed_flag); + ASSERT_TLV(in.prach_config.frequency_offset, out.prach_config.frequency_offset); + + ASSERT_TLV(in.pusch_config.hopping_mode, in.pusch_config.hopping_mode); + ASSERT_TLV(in.pusch_config.hopping_offset, in.pusch_config.hopping_offset); + ASSERT_TLV(in.pusch_config.number_of_subbands, in.pusch_config.number_of_subbands); + + ASSERT_TLV(in.pucch_config.delta_pucch_shift, out.pucch_config.delta_pucch_shift); + ASSERT_TLV(in.pucch_config.n_cqi_rb, out.pucch_config.n_cqi_rb); + ASSERT_TLV(in.pucch_config.n_an_cs, out.pucch_config.n_an_cs); + ASSERT_TLV(in.pucch_config.n1_pucch_an, out.pucch_config.n1_pucch_an); + + ASSERT_TLV(in.srs_config.bandwidth_configuration, out.srs_config.bandwidth_configuration); + ASSERT_TLV(in.srs_config.max_up_pts, out.srs_config.max_up_pts); + ASSERT_TLV(in.srs_config.srs_subframe_configuration, out.srs_config.srs_subframe_configuration); + ASSERT_TLV(in.srs_config.srs_acknack_srs_simultaneous_transmission, out.srs_config.srs_acknack_srs_simultaneous_transmission); + + ASSERT_TLV(in.uplink_reference_signal_config.uplink_rs_hopping, out.uplink_reference_signal_config.uplink_rs_hopping); + ASSERT_TLV(in.uplink_reference_signal_config.group_assignment, out.uplink_reference_signal_config.group_assignment); + ASSERT_TLV(in.uplink_reference_signal_config.cyclic_shift_1_for_drms, out.uplink_reference_signal_config.cyclic_shift_1_for_drms); + + ASSERT_TLV(in.tdd_frame_structure_config.subframe_assignment, out.tdd_frame_structure_config.subframe_assignment); + ASSERT_TLV(in.tdd_frame_structure_config.special_subframe_patterns, out.tdd_frame_structure_config.special_subframe_patterns); + + // laa config + ASSERT_TLV(in.laa_config.ed_threshold_lbt_pdsch, out.laa_config.ed_threshold_lbt_pdsch); + ASSERT_TLV(in.laa_config.ed_threshold_lbt_drs, out.laa_config.ed_threshold_lbt_drs); + ASSERT_TLV(in.laa_config.pd_threshold, out.laa_config.pd_threshold); + ASSERT_TLV(in.laa_config.multi_carrier_type, out.laa_config.multi_carrier_type); + ASSERT_TLV(in.laa_config.multi_carrier_tx, out.laa_config.multi_carrier_tx); + ASSERT_TLV(in.laa_config.multi_carrier_freeze, out.laa_config.multi_carrier_freeze); + ASSERT_TLV(in.laa_config.tx_antenna_ports_drs, out.laa_config.tx_antenna_ports_drs); + ASSERT_TLV(in.laa_config.tx_power_drs, out.laa_config.tx_power_drs); + // emtc config + ASSERT_TLV(in.emtc_config.pbch_repetitions_enable_r13, out.emtc_config.pbch_repetitions_enable_r13); + ASSERT_TLV(in.emtc_config.prach_catm_root_sequence_index, out.emtc_config.prach_catm_root_sequence_index); + ASSERT_TLV(in.emtc_config.prach_catm_zero_correlation_zone_configuration, out.emtc_config.prach_catm_zero_correlation_zone_configuration); + ASSERT_TLV(in.emtc_config.prach_catm_high_speed_flag, out.emtc_config.prach_catm_high_speed_flag); + ASSERT_TLV(in.emtc_config.prach_ce_level_0_enable, out.emtc_config.prach_ce_level_0_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_0_configuration_index, out.emtc_config.prach_ce_level_0_configuration_index); + ASSERT_TLV(in.emtc_config.prach_ce_level_0_frequency_offset, out.emtc_config.prach_ce_level_0_frequency_offset); + ASSERT_TLV(in.emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt, out.emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt); + ASSERT_TLV(in.emtc_config.prach_ce_level_0_starting_subframe_periodicity, out.emtc_config.prach_ce_level_0_starting_subframe_periodicity); + ASSERT_TLV(in.emtc_config.prach_ce_level_0_hopping_enable, out.emtc_config.prach_ce_level_0_hopping_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_0_hopping_offset, out.emtc_config.prach_ce_level_0_hopping_offset); + ASSERT_TLV(in.emtc_config.prach_ce_level_1_enable, out.emtc_config.prach_ce_level_1_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_1_configuration_index, out.emtc_config.prach_ce_level_1_configuration_index); + ASSERT_TLV(in.emtc_config.prach_ce_level_1_frequency_offset, out.emtc_config.prach_ce_level_1_frequency_offset); + ASSERT_TLV(in.emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt, out.emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt); + ASSERT_TLV(in.emtc_config.prach_ce_level_1_starting_subframe_periodicity, out.emtc_config.prach_ce_level_1_starting_subframe_periodicity); + ASSERT_TLV(in.emtc_config.prach_ce_level_1_hopping_enable, out.emtc_config.prach_ce_level_1_hopping_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_1_hopping_offset, out.emtc_config.prach_ce_level_1_hopping_offset); + ASSERT_TLV(in.emtc_config.prach_ce_level_2_enable, out.emtc_config.prach_ce_level_2_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_2_configuration_index, out.emtc_config.prach_ce_level_2_configuration_index); + ASSERT_TLV(in.emtc_config.prach_ce_level_2_frequency_offset, out.emtc_config.prach_ce_level_2_frequency_offset); + ASSERT_TLV(in.emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt, out.emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt); + ASSERT_TLV(in.emtc_config.prach_ce_level_2_starting_subframe_periodicity, out.emtc_config.prach_ce_level_2_starting_subframe_periodicity); + ASSERT_TLV(in.emtc_config.prach_ce_level_2_hopping_enable, out.emtc_config.prach_ce_level_2_hopping_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_2_hopping_offset, out.emtc_config.prach_ce_level_2_hopping_offset); + ASSERT_TLV(in.emtc_config.prach_ce_level_3_enable, out.emtc_config.prach_ce_level_3_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_3_configuration_index, out.emtc_config.prach_ce_level_3_configuration_index); + ASSERT_TLV(in.emtc_config.prach_ce_level_3_frequency_offset, out.emtc_config.prach_ce_level_3_frequency_offset); + ASSERT_TLV(in.emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt, out.emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt); + ASSERT_TLV(in.emtc_config.prach_ce_level_3_starting_subframe_periodicity, out.emtc_config.prach_ce_level_3_starting_subframe_periodicity); + ASSERT_TLV(in.emtc_config.prach_ce_level_3_hopping_enable, out.emtc_config.prach_ce_level_3_hopping_enable); + ASSERT_TLV(in.emtc_config.prach_ce_level_3_hopping_offset, out.emtc_config.prach_ce_level_3_hopping_offset); + ASSERT_TLV(in.emtc_config.pucch_interval_ulhoppingconfigcommonmodea, out.emtc_config.pucch_interval_ulhoppingconfigcommonmodea); + ASSERT_TLV(in.emtc_config.pucch_interval_ulhoppingconfigcommonmodeb, out.emtc_config.pucch_interval_ulhoppingconfigcommonmodeb); + + ASSERT_TLV(in.l23_config.data_report_mode, out.l23_config.data_report_mode); + ASSERT_TLV(in.l23_config.sfnsf, out.l23_config.sfnsf); + + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv4.tl.tag, out.nfapi_config.p7_vnf_address_ipv4.tl.tag); + for(idx = 0; idx < NFAPI_IPV4_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv4.address[idx], out.nfapi_config.p7_vnf_address_ipv4.address[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv6.tl.tag, out.nfapi_config.p7_vnf_address_ipv6.tl.tag); + for(idx = 0; idx < NFAPI_IPV6_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_vnf_address_ipv6.address[idx], out.nfapi_config.p7_vnf_address_ipv6.address[idx]); + } + + ASSERT_TLV(in.nfapi_config.p7_vnf_port, out.nfapi_config.p7_vnf_port); + + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv4.tl.tag, out.nfapi_config.p7_pnf_address_ipv4.tl.tag); + for(idx = 0; idx < NFAPI_IPV4_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv4.address[idx], out.nfapi_config.p7_pnf_address_ipv4.address[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv6.tl.tag, out.nfapi_config.p7_pnf_address_ipv6.tl.tag); + for(idx = 0; idx < NFAPI_IPV6_ADDRESS_LENGTH; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.p7_pnf_address_ipv6.address[idx], out.nfapi_config.p7_pnf_address_ipv6.address[idx]); + } + + ASSERT_TLV(in.nfapi_config.p7_pnf_port, out.nfapi_config.p7_pnf_port); + ASSERT_TLV(in.nfapi_config.dl_ue_per_sf, out.nfapi_config.dl_ue_per_sf); + ASSERT_TLV(in.nfapi_config.ul_ue_per_sf, out.nfapi_config.ul_ue_per_sf); + + CU_ASSERT_EQUAL(in.nfapi_config.rf_bands.tl.tag, out.nfapi_config.rf_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.rf_bands.number_rf_bands, out.nfapi_config.rf_bands.number_rf_bands); + for(idx = 0; idx < out.nfapi_config.rf_bands.number_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.rf_bands.rf_band[idx], out.nfapi_config.rf_bands.rf_band[idx]); + } + + ASSERT_TLV(in.nfapi_config.timing_window, out.nfapi_config.timing_window); + ASSERT_TLV(in.nfapi_config.timing_info_mode, out.nfapi_config.timing_info_mode); + ASSERT_TLV(in.nfapi_config.timing_info_period, out.nfapi_config.timing_info_period); + ASSERT_TLV(in.nfapi_config.max_transmit_power, out.nfapi_config.max_transmit_power); + ASSERT_TLV(in.nfapi_config.earfcn, out.nfapi_config.earfcn); + + CU_ASSERT_EQUAL(in.nfapi_config.nmm_gsm_frequency_bands.tl.tag, out.nfapi_config.nmm_gsm_frequency_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands, out.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands); + for(idx = 0; idx < out.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.nmm_gsm_frequency_bands.bands[idx], out.nfapi_config.nmm_gsm_frequency_bands.bands[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.nmm_umts_frequency_bands.tl.tag, out.nfapi_config.nmm_umts_frequency_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands, out.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands); + for(idx = 0; idx < out.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.nmm_umts_frequency_bands.bands[idx], out.nfapi_config.nmm_umts_frequency_bands.bands[idx]); + } + + CU_ASSERT_EQUAL(in.nfapi_config.nmm_lte_frequency_bands.tl.tag, out.nfapi_config.nmm_lte_frequency_bands.tl.tag); + CU_ASSERT_EQUAL(in.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands, out.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands); + for(idx = 0; idx < out.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands; ++idx) + { + CU_ASSERT_EQUAL(in.nfapi_config.nmm_lte_frequency_bands.bands[idx], out.nfapi_config.nmm_lte_frequency_bands.bands[idx]); + } + + ASSERT_TLV(in.nfapi_config.nmm_uplink_rssi_supported, out.nfapi_config.nmm_uplink_rssi_supported); +} +void nfapi_test_config_response() +{ + nfapi_config_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_config_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CONFIG_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_start_request() +{ + nfapi_start_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_start_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_START_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); +} +void nfapi_test_start_response() +{ + nfapi_start_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_start_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_START_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_stop_request() +{ + nfapi_stop_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_stop_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_STOP_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + +} +void nfapi_test_stop_response() +{ + nfapi_stop_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_stop_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_STOP_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); +} +void nfapi_test_measurement_request() +{ +// #define SET_TLV(_TLV, _TAG, _VALUE) { _TLV.tl.tag = _TAG; _TLV.value = _VALUE; } +// #define ASSERT_TLV(IN_TLV, OUT_TLV) { CU_ASSERT_EQUAL(IN_TLV.tl.tag, OUT_TLV.tl.tag); CU_ASSERT_EQUAL(IN_TLV.value, OUT_TLV.value);} + uint16_t num_tlv = 0; + nfapi_measurement_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_measurement_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_MEASUREMENT_REQUEST; + in.header.message_length = 0; + in.header.spare = 0; + + SET_TLV(in.dl_rs_tx_power, NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG, 1); + SET_TLV(in.received_interference_power, NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG, 123); + SET_TLV(in.thermal_noise_power, NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG, 255); + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + + + ASSERT_TLV(in.dl_rs_tx_power, out.dl_rs_tx_power); + ASSERT_TLV(in.received_interference_power, out.received_interference_power); + ASSERT_TLV(in.thermal_noise_power, out.thermal_noise_power); +} +void nfapi_test_measurement_response() +{ + uint16_t num_tlv = 0; + nfapi_measurement_response_t in; + memset(&in, 0, sizeof(in)); + nfapi_measurement_response_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_MEASUREMENT_RESPONSE; + in.header.message_length = 0; + in.header.spare = 0; + + in.error_code = NFAPI_MSG_OK; + + SET_TLV(in.dl_rs_tx_power_measurement, NFAPI_MEASUREMENT_RESPONSE_DL_RS_POWER_MEASUREMENT_TAG, -400); + + in.received_interference_power_measurement.tl.tag = NFAPI_MEASUREMENT_RESPONSE_RECEIVED_INTERFERENCE_POWER_MEASUREMENT_TAG; + in.received_interference_power_measurement.number_of_resource_blocks = 100; + in.received_interference_power_measurement.received_interference_power[0] = -8767; + + SET_TLV(in.thermal_noise_power_measurement, NFAPI_MEASUREMENT_RESPONSE_THERMAL_NOISE_MEASUREMENT_TAG, -8900); + + int packedMessageLength = nfapi_p5_message_pack(&in, sizeof(in), gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p5_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.error_code, out.error_code); + + ASSERT_TLV(in.dl_rs_tx_power_measurement, out.dl_rs_tx_power_measurement); + CU_ASSERT_EQUAL(in.received_interference_power_measurement.tl.tag, out.received_interference_power_measurement.tl.tag); + CU_ASSERT_EQUAL(in.received_interference_power_measurement.number_of_resource_blocks, out.received_interference_power_measurement.number_of_resource_blocks); + // check array + ASSERT_TLV(in.thermal_noise_power_measurement, out.thermal_noise_power_measurement); +} + +void nfapi_test_dl_config_request() +{ + + + uint16_t idx = 0; + nfapi_dl_config_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_dl_config_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_DL_CONFIG_REQUEST; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 0x3FFF; + + in.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + in.dl_config_request_body.number_pdcch_ofdm_symbols = 4; + in.dl_config_request_body.number_dci = 255; + in.dl_config_request_body.number_pdu = 0; + in.dl_config_request_body.number_pdsch_rnti = 0; + in.dl_config_request_body.transmission_power_pcfich = 10000; + + in.dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)(malloc(sizeof(nfapi_dl_config_request_pdu_t) * 12)); + + in.dl_config_request_body.dl_config_pdu_list[0].pdu_type = 0; + in.dl_config_request_body.dl_config_pdu_list[0].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.primary_cell_type = rand8(0, 2); + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_flag = rand8(0, 1); + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.number_ul_dl_configurations = rand8(0, 5); + for(idx = 0; idx <in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.number_ul_dl_configurations; ++idx) + { + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[idx] = rand8(1, 5); + } + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag = 1; //rand8(0, 1); + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_prb_per_subband = 3; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands = 2; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas = 2; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[0].subband_index = 1; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[0].scheduled_ues = 2; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[0].precoding_value[0][0] = 0x321; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[0].precoding_value[0][1] = 0x321; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[0].precoding_value[1][0] = 0x321; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[0].precoding_value[1][1] = 0x321; + + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[1].subband_index = 2; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[1].scheduled_ues = 1; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[1].precoding_value[0][0] = 0x32A; + in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[1].precoding_value[1][0] = 0x32A; + + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[1].pdu_type = 1; + in.dl_config_request_body.dl_config_pdu_list[1].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[1].bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[2].pdu_type = 2; + in.dl_config_request_body.dl_config_pdu_list[2].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[2].mch_pdu.mch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[3].pdu_type = 3; + in.dl_config_request_body.dl_config_pdu_list[3].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + in.dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG; + in.dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; + in.dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG; + in.dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG; + in.dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[4].pdu_type = 4; + in.dl_config_request_body.dl_config_pdu_list[4].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[4].pch_pdu.pch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG; + in.dl_config_request_body.dl_config_pdu_list[4].pch_pdu.pch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[5].pdu_type = 5; + in.dl_config_request_body.dl_config_pdu_list[5].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[5].prs_pdu.prs_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[6].pdu_type = 6; + in.dl_config_request_body.dl_config_pdu_list[6].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[6].csi_rs_pdu.csi_rs_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG; + in.dl_config_request_body.dl_config_pdu_list[6].csi_rs_pdu.csi_rs_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[7].pdu_type = 7; + in.dl_config_request_body.dl_config_pdu_list[7].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_params_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG; + in.dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_params_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[8].pdu_type = 8; + in.dl_config_request_body.dl_config_pdu_list[8].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[8].mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[9].pdu_type = 9; + in.dl_config_request_body.dl_config_pdu_list[9].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[9].nbch_pdu.nbch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[10].pdu_type = 10; + in.dl_config_request_body.dl_config_pdu_list[10].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + in.dl_config_request_body.dl_config_pdu_list[11].pdu_type = 11; + in.dl_config_request_body.dl_config_pdu_list[11].pdu_size = 123; + in.dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG; + in.dl_config_request_body.number_pdu++; + + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + CU_ASSERT_NOT_EQUAL(packedMessageLength, 0); + CU_ASSERT_NOT_EQUAL(packedMessageLength, -1); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + CU_ASSERT_EQUAL(in.dl_config_request_body.tl.tag, out.dl_config_request_body.tl.tag); + CU_ASSERT_EQUAL(in.dl_config_request_body.number_pdcch_ofdm_symbols, out.dl_config_request_body.number_pdcch_ofdm_symbols); + CU_ASSERT_EQUAL(in.dl_config_request_body.number_dci, out.dl_config_request_body.number_dci); + CU_ASSERT_EQUAL(in.dl_config_request_body.number_pdu, out.dl_config_request_body.number_pdu); + CU_ASSERT_EQUAL(in.dl_config_request_body.number_pdsch_rnti, out.dl_config_request_body.number_pdsch_rnti); + CU_ASSERT_EQUAL(in.dl_config_request_body.transmission_power_pcfich, out.dl_config_request_body.transmission_power_pcfich); + + + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].pdu_type, out.dl_config_request_body.dl_config_pdu_list[0].pdu_type); + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].pdu_size, out.dl_config_request_body.dl_config_pdu_list[0].pdu_size); + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.tl.tag, out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.dci_format); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.rnti); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.mcs_1); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_to_codeword_swap_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.mcs_2); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_2); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.harq_process); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.tpmi); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.pmi); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.precoding_information); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.tpc); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.ngap); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_size_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.downlink_power_offset); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.allocate_prach_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.preamble_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.prach_mask_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel8.transmission_power); + + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel9.tl.tag, out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel9.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel9.mcch_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel9.mcch_change_notification); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel9.scrambling_identity); + + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.tl.tag, out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.cross_carrier_scheduling_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.carrier_indicator); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.srs_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.srs_request); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.antenna_ports_scrambling_and_layers); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.total_dci_length_including_padding); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel10.n_dl_rb); + + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel11.tl.tag, out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel11.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel11.harq_ack_resource_offset); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel11.pdsch_re_mapping_quasi_co_location_indicator); + + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.tl.tag, out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.primary_cell_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.number_ul_dl_configurations); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[NFAPI_MAX_UL_DL_CONFIGURATIONS -1]); + + CU_ASSERT_EQUAL(in.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tl.tag, out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_configuration); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.initial_lbt_sf); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.codebook_size_determination); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.drms_table_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag); + if(out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag) + { + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_prb_per_subband); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas); + + uint8_t sb_idx; + for(sb_idx = 0; sb_idx < out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands; ++sb_idx) + { + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[sb_idx].subband_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[sb_idx].scheduled_ues); + + uint8_t a_idx; + uint8_t su_idx; + + for(a_idx = 0; a_idx < out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas ; ++a_idx) + { + for(su_idx = 0; su_idx < out.dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[sb_idx].scheduled_ues; ++su_idx) + { + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[0].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[sb_idx].precoding_value[a_idx][su_idx]); + } + } + } + } + + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[1].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[1].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[1].bch_pdu.bch_pdu_rel8.tl.tag); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[2].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[2].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[2].mch_pdu.mch_pdu_rel8.tl.tag); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel8.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel9.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel10.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel11.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel12.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[3].dlsch_pdu.dlsch_pdu_rel13.tl.tag); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[4].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[4].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[4].pch_pdu.pch_pdu_rel8.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[4].pch_pdu.pch_pdu_rel13.tl.tag); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[5].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[5].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[5].prs_pdu.prs_pdu_rel9.tl.tag); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[6].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[6].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[6].csi_rs_pdu.csi_rs_pdu_rel10.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[6].csi_rs_pdu.csi_rs_pdu_rel13.tl.tag); + + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel8.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel9.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel10.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel11.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel12.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_pdu_rel13.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_params_rel11.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[7].epdcch_pdu.epdcch_params_rel13.tl.tag); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[8].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[8].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[8].mpdcch_pdu.mpdcch_pdu_rel13.tl.tag); + + //in.dl_config_request_body.dl_config_pdu_list[8].mpdcch_pdu; + // + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[9].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[9].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[9].nbch_pdu.nbch_pdu_rel13.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[9].nbch_pdu.nbch_pdu_rel13.length); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[9].nbch_pdu.nbch_pdu_rel13.pdu_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[9].nbch_pdu.nbch_pdu_rel13.transmission_power); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[9].nbch_pdu.nbch_pdu_rel13.hyper_sfn_2_lsbs); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.length); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.pdu_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.ncce_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.aggregation_level); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.start_symbol); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.rnti_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.rnti); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.scrambling_reinitialization_batch_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.dci_format); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.scheduling_delay); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.resource_assignment); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.repetition_number); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.mcs); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.new_data_indicator); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.npdcch_order_indication); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.starting_number_of_nprach_repetitions); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.subcarrier_indication_of_nprach); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.paging_direct_indication_differentation_flag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.direct_indication); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[10].npdcch_pdu.npdcch_pdu_rel13.total_dci_length_including_padding); + + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].pdu_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].pdu_size); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.tl.tag); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.length); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.pdu_index); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.start_symbol); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.rnti_type); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.rnti); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.repetition_number); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.modulation); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.scrambling_sequence_initialization_cinit); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.sf_idx); + IN_OUT_ASSERT(dl_config_request_body.dl_config_pdu_list[11].ndlsch_pdu.ndlsch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue); + + + free(in.dl_config_request_body.dl_config_pdu_list); + free(out.dl_config_request_body.dl_config_pdu_list); +} +void nfapi_test_ul_config_request() +{ + nfapi_ul_config_request_t in; + //memset(&in, 0, sizeof(in)); + nfapi_ul_config_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_UL_CONFIG_REQUEST; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 0x3FFF; + + in.ul_config_request_body.tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + in.ul_config_request_body.number_of_pdus = 0; + in.ul_config_request_body.rach_prach_frequency_resources = 34; + in.ul_config_request_body.srs_present = 1; + + nfapi_ul_config_request_pdu_t ul_config_pdu_list[24]; + memset(&ul_config_pdu_list[0], 0, sizeof(ul_config_pdu_list)); + in.ul_config_request_body.ul_config_pdu_list = &ul_config_pdu_list[0]; + + in.ul_config_request_body.ul_config_pdu_list[0].pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[0].ulsch_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[1].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[1].ulsch_cqi_ri_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[2].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[2].ulsch_harq_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[3].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[3].ulsch_cqi_harq_ri_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[4].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[4].uci_cqi_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[5].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[5].uci_sr_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[6].pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[6].uci_harq_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[7].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[7].uci_sr_harq_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[8].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[8].uci_cqi_harq_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[9].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[9].uci_cqi_sr_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[10].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[10].uci_cqi_sr_harq_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[11].pdu_type = NFAPI_UL_CONFIG_SRS_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[11].srs_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[12].pdu_type = NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[12].harq_buffer_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[13].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[13].ulsch_uci_csi_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[14].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[14].ulsch_uci_harq_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[15].pdu_type = NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE; + //in.ul_config_request_body.ul_config_pdu_list[15].ulsch_csi_uci_harq_pdu; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[16].pdu_type = NFAPI_UL_CONFIG_NULSCH_PDU_TYPE; + in.ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG; + in.ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + in.ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG; + in.ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG; + in.ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG; + in.ul_config_request_body.number_of_pdus++; + + in.ul_config_request_body.ul_config_pdu_list[17].pdu_type = NFAPI_UL_CONFIG_NRACH_PDU_TYPE; + in.ul_config_request_body.ul_config_pdu_list[17].nrach_pdu.nrach_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG; + in.ul_config_request_body.number_of_pdus++; + + + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + IN_OUT_ASSERT(header.message_id); + IN_OUT_ASSERT(sfn_sf); + IN_OUT_ASSERT(ul_config_request_body.rach_prach_frequency_resources); + IN_OUT_ASSERT(ul_config_request_body.srs_present); + IN_OUT_ASSERT(ul_config_request_body.number_of_pdus); + + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[0].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[1].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[2].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[3].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[4].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[5].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[6].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[7].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[8].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[9].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[10].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[11].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[12].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[13].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[14].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[15].pdu_type); + + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].pdu_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.tl.tag); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.nulsch_format); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.handle); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.size); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.rnti); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.subcarrier_indication); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.resource_assignment); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.mcs); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.redudancy_version); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.repetition_number); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.new_data_indication); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.n_srs); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.scrambling_sequence_initialization_cinit); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.sf_idx); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.tl.tag); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.handle); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.rnti); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.tl.tag); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.virtual_cell_id_enabled_flag); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.npusch_identity); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.tl.tag); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.ue_type); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.empty_symbols); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.total_number_of_repetitions); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.repetition_number); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.tl.tag); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.harq_ack_resource); + + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[17].nrach_pdu.nrach_pdu_rel13.tl.tag); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[17].nrach_pdu.nrach_pdu_rel13.nprach_config_0); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[17].nrach_pdu.nrach_pdu_rel13.nprach_config_1); + IN_OUT_ASSERT(ul_config_request_body.ul_config_pdu_list[17].nrach_pdu.nrach_pdu_rel13.nprach_config_2); + + + free(out.ul_config_request_body.ul_config_pdu_list); + +} +void nfapi_test_hi_dci0_request() +{ + nfapi_hi_dci0_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_hi_dci0_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_HI_DCI0_REQUEST; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 9999; + in.hi_dci0_request_body.tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + in.hi_dci0_request_body.sfnsf = 123; + in.hi_dci0_request_body.number_of_dci = 0; + in.hi_dci0_request_body.number_of_hi = 0; + + in.hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*)malloc(sizeof(nfapi_hi_dci0_request_pdu_t) * 8); + + in.hi_dci0_request_body.hi_dci0_pdu_list[0].pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.resource_block_start = 2; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 23; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.hi_value = 0; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.i_phich = 2; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.transmission_power = 12312;; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel10.flag_tb2 = 1; + in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel10.hi_value_2 = 2; + + in.hi_dci0_request_body.number_of_hi++; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; + /* + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.dci_format; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.cce_index; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.aggregation_level; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.rnti; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.resource_block_start; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.number_of_resource_block; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.mcs_1; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.frequency_hopping_bits; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.new_data_indication_1; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.ue_tx_antenna_seleciton; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.tpc; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.cqi_csi_request; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.ul_index; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.dl_assignment_index; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.tpc_bitmap; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.transmission_power; + */ + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG; + /* + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.cross_carrier_scheduling_flag; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.carrier_indicator; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.size_of_cqi_csi_feild; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.srs_flag; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.srs_request; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.resource_allocation_flag; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.resource_allocation_type; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.resource_block_coding; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.mcs_2; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.new_data_indication_2; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.number_of_antenna_ports; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.tpmi; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.total_dci_length_including_padding; + */ + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel12.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG; + /* + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel12.pscch_resource; + in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel12.time_resource_pattern; + */ + + in.hi_dci0_request_body.number_of_dci++; + + in.hi_dci0_request_body.hi_dci0_pdu_list[2].pdu_type = NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE; + in.hi_dci0_request_body.hi_dci0_pdu_list[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG; + in.hi_dci0_request_body.hi_dci0_pdu_list[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG; + in.hi_dci0_request_body.hi_dci0_pdu_list[2].epdcch_dci_pdu.epdcch_parameters_rel11.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG; + /* + in.hi_dci0_request_body.hi_dci0_pdu_list[2].edpcch_dci_pdu.edpcch_dci_pdu_rel8; + uint8_t dci_format; + uint8_t cce_index; + uint8_t aggregation_level; + uint16_t rnti; + uint8_t resource_block_start; + uint8_t number_of_resource_block; + uint8_t mcs_1; + uint8_t cyclic_shift_2_for_drms; + uint8_t frequency_hopping_enabled_flag; + uint8_t frequency_hopping_bits; + uint8_t new_data_indication_1; + uint8_t ue_tx_antenna_seleciton; + uint8_t tpc; + uint8_t cqi_csi_request; + uint8_t ul_index; + uint8_t dl_assignment_index; + uint32_t tpc_bitmap; + uint16_t transmission_power; + in.hi_dci0_request_body.hi_dci0_pdu_list[2].edpcch_dci_pdu.edpcch_dci_pdu_rel10.cross_carrier_scheduling_flag; + uint8_t carrier_indicator; + uint8_t size_of_cqi_csi_feild; + uint8_t srs_flag; + uint8_t srs_request; + uint8_t resource_allocation_flag; + uint8_t resource_allocation_type; + uint32_t resource_block_coding; + uint8_t mcs_2; + uint8_t new_data_indication_2; + uint8_t number_of_antenna_ports; + uint8_t tpmi; + uint8_t total_dci_length_including_padding; + in.hi_dci0_request_body.hi_dci0_pdu_list[2].edpcch_dci_pdu.edpcch_parameters_rel11.edpcch_resource_assigenment_flag; + uint16_t edpcch_id; + uint8_t epdcch_start_symbol; + uint8_t epdcch_num_prb; + uint8_t epdcch_prb_index[NFAPI_MAX_EPDCCH_PRB]; + nfapi_bf_vector_t bf_vector; + */ + in.hi_dci0_request_body.number_of_dci++; + + in.hi_dci0_request_body.hi_dci0_pdu_list[3].pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE; + in.hi_dci0_request_body.hi_dci0_pdu_list[3].mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG; + /* + in.hi_dci0_request_body.hi_dci0_pdu_list[3].mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband; + uint8_t number_of_prb_pairs; + uint8_t resource_block_assignment; + uint8_t mpdcch_transmission_type; + uint8_t start_symbol; + uint8_t ecce_index; + uint8_t aggreagation_level; + uint8_t rnti_type; + uint16_t rnti; + uint8_t ce_mode; + uint16_t drms_scrambling_init; + uint16_t initial_transmission_sf_io; + uint16_t transmission_power; + uint8_t dci_format; + uint8_t resource_block_start; + uint8_t number_of_resource_blocks; + uint8_t mcs; + uint8_t pusch_repetition_levels; + uint8_t frequency_hopping_flag; + uint8_t new_data_indication; + uint8_t harq_process; + uint8_t redudency_version; + uint8_t tpc; + uint8_t csi_request; + uint8_t ul_inex; + uint8_t dai_presence_flag; + uint8_t dl_assignment_index; + uint8_t srs_request; + uint8_t dci_subframe_repetition_number; + uint32_t tcp_bitmap; + uint8_t total_dci_length_include_padding; + uint8_t number_of_tx_antenna_ports; + uint16_t precoding_value[NFAPI_MAX_ANTENNA_PORT_COUNT]; + */ + in.hi_dci0_request_body.number_of_dci++; + + in.hi_dci0_request_body.hi_dci0_pdu_list[4].pdu_type = NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE; + in.hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG; + in.hi_dci0_request_body.number_of_dci++; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.tl.tag, out.hi_dci0_request_body.tl.tag); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.sfnsf, out.hi_dci0_request_body.sfnsf); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.number_of_dci, out.hi_dci0_request_body.number_of_dci); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.number_of_hi, out.hi_dci0_request_body.number_of_hi); + + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[0].pdu_type, out.hi_dci0_request_body.hi_dci0_pdu_list[0].pdu_type); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.tl.tag, out.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel8.tl.tag); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel10.tl.tag, out.hi_dci0_request_body.hi_dci0_pdu_list[0].hi_pdu.hi_pdu_rel10.tl.tag); + + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[1].pdu_type, out.hi_dci0_request_body.hi_dci0_pdu_list[1].pdu_type); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.tl.tag, out.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel8.tl.tag); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.tl.tag, out.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel10.tl.tag); + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel12.tl.tag, out.hi_dci0_request_body.hi_dci0_pdu_list[1].dci_pdu.dci_pdu_rel12.tl.tag); + + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[2].pdu_type, out.hi_dci0_request_body.hi_dci0_pdu_list[2].pdu_type); + + CU_ASSERT_EQUAL(in.hi_dci0_request_body.hi_dci0_pdu_list[3].pdu_type, out.hi_dci0_request_body.hi_dci0_pdu_list[3].pdu_type); + + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].pdu_type); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.tl.tag); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.ncce_index); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.aggregation_level); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.start_symbol); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.rnti); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scrambling_reinitialization_batch_index); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.subcarrier_indication); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.resource_assignment); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scheduling_delay); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.mcs); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.redudancy_version); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.repetition_number); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.new_data_indicator); + IN_OUT_ASSERT(hi_dci0_request_body.hi_dci0_pdu_list[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.dci_subframe_repetition_number); + + free(in.hi_dci0_request_body.hi_dci0_pdu_list); + free(out.hi_dci0_request_body.hi_dci0_pdu_list); +} +void nfapi_test_tx_request() +{ + nfapi_tx_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_tx_request_t out; + + nfapi_p7_codec_config_t config; + config.allocate = &nfapi_allocate_pdu; + //config.deallocate = &nfapi_deallocate_pdu; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_TX_REQUEST; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + uint8_t pdu1_seg1[16]; + uint8_t pdu1_seg2[16]; + uint8_t pdu2[8]; + + in.sfn_sf = 10230; + in.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + in.tx_request_body.number_of_pdus = 2; + + in.tx_request_body.tx_pdu_list = (nfapi_tx_request_pdu_t*)(malloc(sizeof(nfapi_tx_request_pdu_t) * in.tx_request_body.number_of_pdus)); + + in.tx_request_body.tx_pdu_list[0].pdu_length = sizeof(pdu1_seg1) + sizeof(pdu1_seg2); + in.tx_request_body.tx_pdu_list[0].pdu_index = 0; + in.tx_request_body.tx_pdu_list[0].num_segments = 2; + in.tx_request_body.tx_pdu_list[0].segments[0].segment_length = sizeof(pdu1_seg1); + in.tx_request_body.tx_pdu_list[0].segments[0].segment_data = pdu1_seg1; + in.tx_request_body.tx_pdu_list[0].segments[1].segment_length = sizeof(pdu1_seg2); + in.tx_request_body.tx_pdu_list[0].segments[1].segment_data = pdu1_seg2; + + in.tx_request_body.tx_pdu_list[1].pdu_length = sizeof(pdu2); + in.tx_request_body.tx_pdu_list[1].pdu_index = 0; + in.tx_request_body.tx_pdu_list[1].num_segments = 1; + in.tx_request_body.tx_pdu_list[1].segments[0].segment_length = sizeof(pdu2); + in.tx_request_body.tx_pdu_list[1].segments[0].segment_data = pdu2; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, &config); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), &config); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + CU_ASSERT_EQUAL(in.tx_request_body.tl.tag, out.tx_request_body.tl.tag); + CU_ASSERT_EQUAL(in.tx_request_body.number_of_pdus, out.tx_request_body.number_of_pdus); + CU_ASSERT_EQUAL(in.tx_request_body.tx_pdu_list[0].pdu_length, out.tx_request_body.tx_pdu_list[0].pdu_length); + CU_ASSERT_EQUAL(1, out.tx_request_body.tx_pdu_list[0].num_segments); + + CU_ASSERT_EQUAL(in.tx_request_body.tx_pdu_list[1].pdu_length, out.tx_request_body.tx_pdu_list[1].pdu_length); + CU_ASSERT_EQUAL(1, out.tx_request_body.tx_pdu_list[1].num_segments); + + CU_ASSERT_EQUAL(0, memcmp(pdu2, out.tx_request_body.tx_pdu_list[1].segments[0].segment_data, sizeof(pdu2))); + + free(out.tx_request_body.tx_pdu_list[0].segments[0].segment_data); + free(out.tx_request_body.tx_pdu_list[1].segments[0].segment_data); + + free(in.tx_request_body.tx_pdu_list); + free(out.tx_request_body.tx_pdu_list); +} +void nfapi_test_harq_indication() +{ + nfapi_harq_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_harq_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_HARQ_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 10230; + in.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + in.harq_indication_body.number_of_harqs = 6; + + in.harq_indication_body.harq_pdu_list = (nfapi_harq_indication_pdu_t*)(calloc(1, sizeof(nfapi_harq_indication_pdu_t) * in.harq_indication_body.number_of_harqs)); + + in.harq_indication_body.harq_pdu_list[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.harq_indication_body.harq_pdu_list[0].harq_indication_tdd_rel8.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL8_TAG; + in.harq_indication_body.harq_pdu_list[0].harq_indication_tdd_rel8.mode = 0; + in.harq_indication_body.harq_pdu_list[0].harq_indication_tdd_rel8.number_of_ack_nack = 2; + in.harq_indication_body.harq_pdu_list[0].harq_indication_tdd_rel8.harq_data.bundling.value_0 = 6; + in.harq_indication_body.harq_pdu_list[0].harq_indication_tdd_rel8.harq_data.bundling.value_1 = 6; + + in.harq_indication_body.harq_pdu_list[1].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.harq_indication_body.harq_pdu_list[1].harq_indication_tdd_rel9.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL9_TAG; + in.harq_indication_body.harq_pdu_list[1].harq_indication_tdd_rel9.mode = 0; + in.harq_indication_body.harq_pdu_list[1].harq_indication_tdd_rel9.number_of_ack_nack = 2; + in.harq_indication_body.harq_pdu_list[1].harq_indication_tdd_rel9.harq_data[0].bundling.value_0 = 2; + + in.harq_indication_body.harq_pdu_list[2].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.harq_indication_body.harq_pdu_list[2].harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + in.harq_indication_body.harq_pdu_list[2].harq_indication_tdd_rel13.mode = 2; + in.harq_indication_body.harq_pdu_list[2].harq_indication_tdd_rel13.number_of_ack_nack = 2; + in.harq_indication_body.harq_pdu_list[2].harq_indication_tdd_rel13.harq_data[0].special_bundling.value_0 = 2; + + in.harq_indication_body.harq_pdu_list[3].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.harq_indication_body.harq_pdu_list[3].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + in.harq_indication_body.harq_pdu_list[3].ul_cqi_information.ul_cqi = 9; + in.harq_indication_body.harq_pdu_list[3].ul_cqi_information.channel = 3; + in.harq_indication_body.harq_pdu_list[3].harq_indication_fdd_rel8.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL8_TAG; + in.harq_indication_body.harq_pdu_list[3].harq_indication_fdd_rel8.harq_tb1 = 1; + in.harq_indication_body.harq_pdu_list[3].harq_indication_fdd_rel8.harq_tb2 = 2; + + + in.harq_indication_body.harq_pdu_list[4].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.harq_indication_body.harq_pdu_list[4].harq_indication_fdd_rel9.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL9_TAG; + in.harq_indication_body.harq_pdu_list[4].harq_indication_fdd_rel9.mode = 0; + in.harq_indication_body.harq_pdu_list[4].harq_indication_fdd_rel9.number_of_ack_nack = 3; + in.harq_indication_body.harq_pdu_list[4].harq_indication_fdd_rel9.harq_tb_n[0] = 45; + + in.harq_indication_body.harq_pdu_list[5].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.harq_indication_body.harq_pdu_list[5].harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; + in.harq_indication_body.harq_pdu_list[5].harq_indication_fdd_rel13.mode = 1; + in.harq_indication_body.harq_pdu_list[5].harq_indication_fdd_rel13.number_of_ack_nack = 22; + in.harq_indication_body.harq_pdu_list[5].harq_indication_fdd_rel13.harq_tb_n[0] = 123; + + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + + CU_ASSERT_EQUAL(in.harq_indication_body.tl.tag,out.harq_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.number_of_harqs,out.harq_indication_body.number_of_harqs); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[0].rx_ue_information.tl.tag,out.harq_indication_body.harq_pdu_list[0].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[0].harq_indication_tdd_rel8.tl.tag,out.harq_indication_body.harq_pdu_list[0].harq_indication_tdd_rel8.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[1].rx_ue_information.tl.tag,out.harq_indication_body.harq_pdu_list[1].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[1].harq_indication_tdd_rel9.tl.tag,out.harq_indication_body.harq_pdu_list[1].harq_indication_tdd_rel9.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[2].rx_ue_information.tl.tag,out.harq_indication_body.harq_pdu_list[2].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[2].harq_indication_tdd_rel13.tl.tag,out.harq_indication_body.harq_pdu_list[2].harq_indication_tdd_rel13.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[3].rx_ue_information.tl.tag,out.harq_indication_body.harq_pdu_list[3].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[3].ul_cqi_information.tl.tag,out.harq_indication_body.harq_pdu_list[3].ul_cqi_information.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[3].harq_indication_fdd_rel8.tl.tag,out.harq_indication_body.harq_pdu_list[3].harq_indication_fdd_rel8.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[4].rx_ue_information.tl.tag,out.harq_indication_body.harq_pdu_list[4].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[4].harq_indication_fdd_rel9.tl.tag,out.harq_indication_body.harq_pdu_list[4].harq_indication_fdd_rel9.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[5].rx_ue_information.tl.tag,out.harq_indication_body.harq_pdu_list[5].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.harq_indication_body.harq_pdu_list[5].harq_indication_fdd_rel13.tl.tag,out.harq_indication_body.harq_pdu_list[5].harq_indication_fdd_rel13.tl.tag); + + free(in.harq_indication_body.harq_pdu_list); + free(out.harq_indication_body.harq_pdu_list); +} +void nfapi_test_crc_indication() +{ + nfapi_crc_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_crc_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_CRC_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 10230; + in.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG; + in.crc_indication_body.number_of_crcs = 2; + in.crc_indication_body.crc_pdu_list = (nfapi_crc_indication_pdu_t*)malloc(sizeof(nfapi_crc_indication_pdu_t) * in.crc_indication_body.number_of_crcs); + in.crc_indication_body.crc_pdu_list[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.crc_indication_body.crc_pdu_list[0].rx_ue_information.handle = 0x4567; + in.crc_indication_body.crc_pdu_list[0].rx_ue_information.rnti = 42; + in.crc_indication_body.crc_pdu_list[0].crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; + in.crc_indication_body.crc_pdu_list[0].crc_indication_rel8.crc_flag = 0; + + + in.crc_indication_body.crc_pdu_list[1].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.crc_indication_body.crc_pdu_list[1].rx_ue_information.handle = 0x4568; + in.crc_indication_body.crc_pdu_list[1].rx_ue_information.rnti = 43; + in.crc_indication_body.crc_pdu_list[1].crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; + in.crc_indication_body.crc_pdu_list[1].crc_indication_rel8.crc_flag = 1; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.crc_indication_body.tl.tag, out.crc_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.crc_indication_body.number_of_crcs, out.crc_indication_body.number_of_crcs); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[0].rx_ue_information.tl.tag, out.crc_indication_body.crc_pdu_list[0].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[0].rx_ue_information.handle, out.crc_indication_body.crc_pdu_list[0].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[0].rx_ue_information.rnti, out.crc_indication_body.crc_pdu_list[0].rx_ue_information.rnti); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[0].crc_indication_rel8.tl.tag, out.crc_indication_body.crc_pdu_list[0].crc_indication_rel8.tl.tag); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[0].crc_indication_rel8.crc_flag, out.crc_indication_body.crc_pdu_list[0].crc_indication_rel8.crc_flag); + + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[1].rx_ue_information.tl.tag, out.crc_indication_body.crc_pdu_list[1].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[1].rx_ue_information.handle, out.crc_indication_body.crc_pdu_list[1].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[1].rx_ue_information.rnti, out.crc_indication_body.crc_pdu_list[1].rx_ue_information.rnti); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[1].crc_indication_rel8.tl.tag, out.crc_indication_body.crc_pdu_list[1].crc_indication_rel8.tl.tag); + CU_ASSERT_EQUAL(in.crc_indication_body.crc_pdu_list[1].crc_indication_rel8.crc_flag, out.crc_indication_body.crc_pdu_list[1].crc_indication_rel8.crc_flag); + + free(in.crc_indication_body.crc_pdu_list); + free(out.crc_indication_body.crc_pdu_list); +} +void nfapi_test_rx_ulsch_indication() +{ + nfapi_rx_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_rx_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RX_ULSCH_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + uint8_t pdu1[32]; + uint8_t pdu2[8]; + + in.sfn_sf = 12354; + in.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + in.rx_indication_body.number_of_pdus = 3; + + in.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t*)(calloc(1, sizeof(nfapi_rx_indication_pdu_t) * in.rx_indication_body.number_of_pdus)); + + in.rx_indication_body.rx_pdu_list[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.rx_indication_body.rx_pdu_list[0].rx_ue_information.handle = 0xFEDC; + in.rx_indication_body.rx_pdu_list[0].rx_ue_information.rnti = 42; + in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.length = sizeof(pdu1); + in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.offset = 1; + in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.ul_cqi = 1; + in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.timing_advance = 23; + in.rx_indication_body.rx_pdu_list[0].rx_indication_rel9.tl.tag = NFAPI_RX_INDICATION_REL9_TAG; + in.rx_indication_body.rx_pdu_list[0].rx_indication_rel9.timing_advance_r9 = 1; + in.rx_indication_body.rx_pdu_list[0].data = pdu1; + + in.rx_indication_body.rx_pdu_list[1].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.rx_indication_body.rx_pdu_list[1].rx_ue_information.handle = 0xFEDC; + in.rx_indication_body.rx_pdu_list[1].rx_ue_information.rnti = 43; + in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.length = 0; + in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.offset = 1; + in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.ul_cqi = 1; + in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.timing_advance = 23; + in.rx_indication_body.rx_pdu_list[1].data = 0; + + in.rx_indication_body.rx_pdu_list[2].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.rx_indication_body.rx_pdu_list[2].rx_ue_information.handle = 0xFEDC; + in.rx_indication_body.rx_pdu_list[2].rx_ue_information.rnti = 43; + in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.length = sizeof(pdu2); + in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.offset = 1; + in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.ul_cqi = 1; + in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.timing_advance = 23; + in.rx_indication_body.rx_pdu_list[2].rx_indication_rel9.tl.tag = NFAPI_RX_INDICATION_REL9_TAG; + in.rx_indication_body.rx_pdu_list[2].rx_indication_rel9.timing_advance_r9 = 34; + in.rx_indication_body.rx_pdu_list[2].data = pdu2; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + CU_ASSERT_EQUAL(in.rx_indication_body.tl.tag, out.rx_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.number_of_pdus, out.rx_indication_body.number_of_pdus); + + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_ue_information.tl.tag, out.rx_indication_body.rx_pdu_list[0].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_ue_information.handle, out.rx_indication_body.rx_pdu_list[0].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_ue_information.rnti, out.rx_indication_body.rx_pdu_list[0].rx_ue_information.rnti); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.tl.tag, out.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.length, out.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.length); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.offset, out.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.offset); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.ul_cqi, out.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.ul_cqi); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.timing_advance, out.rx_indication_body.rx_pdu_list[0].rx_indication_rel8.timing_advance); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_indication_rel9.tl.tag, out.rx_indication_body.rx_pdu_list[0].rx_indication_rel9.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[0].rx_indication_rel9.timing_advance_r9, out.rx_indication_body.rx_pdu_list[0].rx_indication_rel9.timing_advance_r9); + CU_ASSERT_EQUAL(0, memcmp(in.rx_indication_body.rx_pdu_list[0].data, out.rx_indication_body.rx_pdu_list[0].data, sizeof(pdu1))); + + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_ue_information.tl.tag, out.rx_indication_body.rx_pdu_list[1].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_ue_information.handle, out.rx_indication_body.rx_pdu_list[1].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_ue_information.rnti, out.rx_indication_body.rx_pdu_list[1].rx_ue_information.rnti); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.tl.tag, out.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.length, out.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.length); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.offset, out.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.offset); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.ul_cqi, out.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.ul_cqi); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.timing_advance, out.rx_indication_body.rx_pdu_list[1].rx_indication_rel8.timing_advance); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[1].data, 0); + + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_ue_information.tl.tag, out.rx_indication_body.rx_pdu_list[2].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_ue_information.handle, out.rx_indication_body.rx_pdu_list[2].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_ue_information.rnti, out.rx_indication_body.rx_pdu_list[2].rx_ue_information.rnti); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.tl.tag, out.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.length, out.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.length); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.offset, out.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.offset); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.ul_cqi, in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.ul_cqi); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.timing_advance, out.rx_indication_body.rx_pdu_list[2].rx_indication_rel8.timing_advance); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_indication_rel9.tl.tag, out.rx_indication_body.rx_pdu_list[2].rx_indication_rel9.tl.tag); + CU_ASSERT_EQUAL(in.rx_indication_body.rx_pdu_list[2].rx_indication_rel9.timing_advance_r9, out.rx_indication_body.rx_pdu_list[2].rx_indication_rel9.timing_advance_r9); + CU_ASSERT_EQUAL(0, memcmp(in.rx_indication_body.rx_pdu_list[2].data, out.rx_indication_body.rx_pdu_list[2].data, sizeof(pdu2))); + + free(in.rx_indication_body.rx_pdu_list); + free(out.rx_indication_body.rx_pdu_list); + +} +void nfapi_test_rach_indication() +{ + nfapi_rach_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_rach_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RACH_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 10230; + in.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + in.rach_indication_body.number_of_preambles = 2; + in.rach_indication_body.preamble_list = (nfapi_preamble_pdu_t*)(malloc(sizeof(nfapi_preamble_pdu_t)*in.rach_indication_body.number_of_preambles)); + in.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + in.rach_indication_body.preamble_list[0].preamble_rel9.tl.tag = NFAPI_PREAMBLE_REL9_TAG; + in.rach_indication_body.preamble_list[0].preamble_rel13.tl.tag = NFAPI_PREAMBLE_REL13_TAG; + + in.rach_indication_body.preamble_list[1].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + in.rach_indication_body.preamble_list[1].preamble_rel9.tl.tag = NFAPI_PREAMBLE_REL9_TAG; + in.rach_indication_body.preamble_list[1].preamble_rel13.tl.tag = NFAPI_PREAMBLE_REL13_TAG; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.rach_indication_body.tl.tag, out.rach_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.rach_indication_body.number_of_preambles, out.rach_indication_body.number_of_preambles); + CU_ASSERT_EQUAL(in.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag, out.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag); + CU_ASSERT_EQUAL(in.rach_indication_body.preamble_list[0].preamble_rel9.tl.tag, out.rach_indication_body.preamble_list[0].preamble_rel9.tl.tag); + CU_ASSERT_EQUAL(in.rach_indication_body.preamble_list[0].preamble_rel13.tl.tag, out.rach_indication_body.preamble_list[0].preamble_rel13.tl.tag); + CU_ASSERT_EQUAL(in.rach_indication_body.preamble_list[1].preamble_rel8.tl.tag, out.rach_indication_body.preamble_list[1].preamble_rel8.tl.tag); + CU_ASSERT_EQUAL(in.rach_indication_body.preamble_list[1].preamble_rel9.tl.tag, out.rach_indication_body.preamble_list[1].preamble_rel9.tl.tag); + CU_ASSERT_EQUAL(in.rach_indication_body.preamble_list[1].preamble_rel13.tl.tag, out.rach_indication_body.preamble_list[1].preamble_rel13.tl.tag); + + free(in.rach_indication_body.preamble_list); + free(out.rach_indication_body.preamble_list); +} +void nfapi_test_srs_indication() +{ + nfapi_srs_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_srs_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_SRS_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 10230; + in.srs_indication_body.tl.tag = NFAPI_SRS_INDICATION_BODY_TAG; + in.srs_indication_body.number_of_ues = 2; + in.srs_indication_body.srs_pdu_list = (nfapi_srs_indication_pdu_t*)(malloc(sizeof(nfapi_srs_indication_pdu_t) * in.srs_indication_body.number_of_ues)); + in.srs_indication_body.srs_pdu_list[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.srs_indication_body.srs_pdu_list[0].rx_ue_information.handle = 0x4567; + in.srs_indication_body.srs_pdu_list[0].rx_ue_information.rnti = 42; + + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.tl.tag = NFAPI_SRS_INDICATION_FDD_REL8_TAG; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.doppler_estimation = 244; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.timing_advance = 45; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.number_of_resource_blocks = 100; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.rb_start = 0; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.snr[0] = 255; + //... + + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel9.tl.tag = NFAPI_SRS_INDICATION_FDD_REL9_TAG; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel9.timing_advance_r9 = 7690; + in.srs_indication_body.srs_pdu_list[0].srs_indication_tdd_rel10.tl.tag = NFAPI_SRS_INDICATION_TDD_REL10_TAG; + in.srs_indication_body.srs_pdu_list[0].srs_indication_tdd_rel10.uppts_symbol = 1; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel11.tl.tag = NFAPI_SRS_INDICATION_FDD_REL11_TAG; + in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel11.ul_rtoa = 4800; + + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.tl.tag = NFAPI_TDD_CHANNEL_MEASUREMENT_TAG; + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.num_prb_per_subband = 4; + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.number_of_subbands = 2; + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.num_atennas = 2; + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[0].subband_index = 4; + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[0].channel[0] = 0xEEEE; + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[1].subband_index = 6; + in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[1].channel[0] = 0xAAAA; + + in.srs_indication_body.srs_pdu_list[1].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.srs_indication_body.srs_pdu_list[1].rx_ue_information.handle = 0x4567; + in.srs_indication_body.srs_pdu_list[1].rx_ue_information.rnti = 42; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + + CU_ASSERT_EQUAL(in.srs_indication_body.tl.tag, out.srs_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].rx_ue_information.tl.tag, out.srs_indication_body.srs_pdu_list[0].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].rx_ue_information.handle, out.srs_indication_body.srs_pdu_list[0].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].rx_ue_information.rnti, out.srs_indication_body.srs_pdu_list[0].rx_ue_information.rnti); + + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.tl.tag, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.doppler_estimation, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.doppler_estimation); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.timing_advance, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.timing_advance); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.number_of_resource_blocks, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.number_of_resource_blocks); + CU_ASSERT_EQUAL(memcmp(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.snr, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.snr, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.number_of_resource_blocks), 0); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.rb_start, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel8.rb_start); + + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel9.tl.tag, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel9.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel9.timing_advance_r9, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel9.timing_advance_r9); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_tdd_rel10.tl.tag, out.srs_indication_body.srs_pdu_list[0].srs_indication_tdd_rel10.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_tdd_rel10.uppts_symbol, out.srs_indication_body.srs_pdu_list[0].srs_indication_tdd_rel10.uppts_symbol); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel11.tl.tag, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel11.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel11.ul_rtoa, out.srs_indication_body.srs_pdu_list[0].srs_indication_fdd_rel11.ul_rtoa); + + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.tl.tag, out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.num_prb_per_subband, out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.num_prb_per_subband); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.number_of_subbands, out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.number_of_subbands); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.num_atennas, out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.num_atennas); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[0].subband_index, out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[0].subband_index) + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[0].channel[0], out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[0].channel[0]); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[1].subband_index, out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[1].subband_index); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[1].channel[0], out.srs_indication_body.srs_pdu_list[0].tdd_channel_measurement.subands[1].channel[0]); + + + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[1].rx_ue_information.tl.tag, out.srs_indication_body.srs_pdu_list[1].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[1].rx_ue_information.handle, out.srs_indication_body.srs_pdu_list[1].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.srs_indication_body.srs_pdu_list[1].rx_ue_information.rnti, out.srs_indication_body.srs_pdu_list[1].rx_ue_information.rnti); + + free(in.srs_indication_body.srs_pdu_list); + free(out.srs_indication_body.srs_pdu_list); +} +void nfapi_test_rx_sr_indication() +{ + nfapi_sr_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_sr_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RX_SR_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 10230; + in.sr_indication_body.tl.tag = NFAPI_SR_INDICATION_BODY_TAG; + in.sr_indication_body.number_of_srs = 2; + in.sr_indication_body.sr_pdu_list = (nfapi_sr_indication_pdu_t*)(malloc(sizeof(nfapi_sr_indication_pdu_t) * in.sr_indication_body.number_of_srs)); + in.sr_indication_body.sr_pdu_list[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.sr_indication_body.sr_pdu_list[0].rx_ue_information.handle = 0x4567; + in.sr_indication_body.sr_pdu_list[0].rx_ue_information.rnti = 42; + + in.sr_indication_body.sr_pdu_list[0].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + in.sr_indication_body.sr_pdu_list[0].ul_cqi_information.ul_cqi = 34; + in.sr_indication_body.sr_pdu_list[0].ul_cqi_information.channel = 38; + + in.sr_indication_body.sr_pdu_list[1].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.sr_indication_body.sr_pdu_list[1].rx_ue_information.handle = 0x9876; + in.sr_indication_body.sr_pdu_list[1].rx_ue_information.rnti = 24; + + in.sr_indication_body.sr_pdu_list[1].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + in.sr_indication_body.sr_pdu_list[1].ul_cqi_information.ul_cqi = 24; + in.sr_indication_body.sr_pdu_list[1].ul_cqi_information.channel = 28; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + + CU_ASSERT_EQUAL(in.sr_indication_body.tl.tag, out.sr_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[0].rx_ue_information.tl.tag, out.sr_indication_body.sr_pdu_list[0].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[0].rx_ue_information.handle, out.sr_indication_body.sr_pdu_list[0].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[0].rx_ue_information.rnti, out.sr_indication_body.sr_pdu_list[0].rx_ue_information.rnti); + + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[0].ul_cqi_information.tl.tag, out.sr_indication_body.sr_pdu_list[0].ul_cqi_information.tl.tag); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[0].ul_cqi_information.ul_cqi, out.sr_indication_body.sr_pdu_list[0].ul_cqi_information.ul_cqi); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[0].ul_cqi_information.channel, out.sr_indication_body.sr_pdu_list[0].ul_cqi_information.channel); + + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[1].rx_ue_information.tl.tag, out.sr_indication_body.sr_pdu_list[1].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[1].rx_ue_information.handle, out.sr_indication_body.sr_pdu_list[1].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[1].rx_ue_information.rnti, out.sr_indication_body.sr_pdu_list[1].rx_ue_information.rnti); + + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[1].ul_cqi_information.tl.tag, out.sr_indication_body.sr_pdu_list[1].ul_cqi_information.tl.tag); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[1].ul_cqi_information.ul_cqi, out.sr_indication_body.sr_pdu_list[1].ul_cqi_information.ul_cqi); + CU_ASSERT_EQUAL(in.sr_indication_body.sr_pdu_list[1].ul_cqi_information.channel, out.sr_indication_body.sr_pdu_list[1].ul_cqi_information.channel); + + free(in.sr_indication_body.sr_pdu_list); + free(out.sr_indication_body.sr_pdu_list); + +} +void nfapi_test_rx_cqi_indication() +{ + uint8_t cqi_1[] = { 0, 2, 4, 8, 10}; + uint8_t cqi_2[] = { 100, 101, 102, 103, 104, 105, 106}; + + nfapi_cqi_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_cqi_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_RX_CQI_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 10240; + in.cqi_indication_body.tl.tag = NFAPI_CQI_INDICATION_BODY_TAG; + in.cqi_indication_body.number_of_cqis = 3; + + in.cqi_indication_body.cqi_pdu_list = (nfapi_cqi_indication_pdu_t*)(calloc(1, sizeof(nfapi_cqi_indication_pdu_t)*in.cqi_indication_body.number_of_cqis)); + in.cqi_indication_body.cqi_raw_pdu_list = (nfapi_cqi_indication_raw_pdu_t*)(calloc(1, sizeof(nfapi_cqi_indication_raw_pdu_t)*in.cqi_indication_body.number_of_cqis)); + + in.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.handle = 0x4567; + in.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.rnti = 42; + in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.tl.tag = NFAPI_CQI_INDICATION_REL8_TAG; + in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.length = sizeof(cqi_1); + in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.data_offset = 1; + in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.ul_cqi = 4; + in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.ri = 4; + in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.timing_advance = 63; + in.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + in.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.ul_cqi = 34; + in.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.channel = 38; + + in.cqi_indication_body.cqi_pdu_list[1].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.cqi_indication_body.cqi_pdu_list[1].rx_ue_information.handle = 0x4567; + in.cqi_indication_body.cqi_pdu_list[1].rx_ue_information.rnti = 42; + in.cqi_indication_body.cqi_pdu_list[1].cqi_indication_rel8.tl.tag = NFAPI_CQI_INDICATION_REL8_TAG; + in.cqi_indication_body.cqi_pdu_list[1].cqi_indication_rel8.length = 0; + in.cqi_indication_body.cqi_pdu_list[1].cqi_indication_rel8.data_offset = 0; + in.cqi_indication_body.cqi_pdu_list[1].cqi_indication_rel8.ul_cqi = 0; + in.cqi_indication_body.cqi_pdu_list[1].cqi_indication_rel8.ri = 0; + in.cqi_indication_body.cqi_pdu_list[1].cqi_indication_rel8.timing_advance = 0; + + + in.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.handle = 0x4567; + in.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.rnti = 42; + + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.tl.tag = NFAPI_CQI_INDICATION_REL9_TAG; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.length = sizeof(cqi_2); + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.data_offset = 1; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ul_cqi = 4; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.number_of_cc_reported = 4; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[0] = 6; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[1] = 7; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[2] = 8; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[3] = 1; + in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.timing_advance = 63; + in.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + in.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.ul_cqi = 44; + in.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.channel = 48; + + + memcpy(in.cqi_indication_body.cqi_raw_pdu_list[0].pdu, cqi_1, sizeof(cqi_1)); + memcpy(in.cqi_indication_body.cqi_raw_pdu_list[1].pdu, cqi_2, sizeof(cqi_2)); + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + CU_ASSERT_EQUAL(in.cqi_indication_body.tl.tag, out.cqi_indication_body.tl.tag); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.tl.tag, out.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.handle, out.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.rnti, out.cqi_indication_body.cqi_pdu_list[0].rx_ue_information.rnti); + + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.tl.tag, out.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.tl.tag); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.length, out.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.length); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.data_offset, out.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.data_offset); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.ul_cqi, out.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.ul_cqi); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.ri, out.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.ri); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.timing_advance, out.cqi_indication_body.cqi_pdu_list[0].cqi_indication_rel8.timing_advance); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.tl.tag, out.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.tl.tag); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.ul_cqi, out.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.ul_cqi); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.channel, out.cqi_indication_body.cqi_pdu_list[0].ul_cqi_information.channel); + + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.tl.tag, out.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.tl.tag); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.handle, out.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.handle); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.rnti, out.cqi_indication_body.cqi_pdu_list[2].rx_ue_information.rnti); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.tl.tag, out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.tl.tag); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.length, out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.length); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.data_offset, out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.data_offset); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ul_cqi, out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ul_cqi); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.number_of_cc_reported, out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.number_of_cc_reported); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[0], out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[0]); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[1], out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[1]); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[2], out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[2]); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[3], out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.ri[3]); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.timing_advance, out.cqi_indication_body.cqi_pdu_list[2].cqi_indication_rel9.timing_advance); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.tl.tag, out.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.tl.tag); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.ul_cqi, out.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.ul_cqi); + CU_ASSERT_EQUAL(in.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.channel, out.cqi_indication_body.cqi_pdu_list[2].ul_cqi_information.channel); + + + CU_ASSERT_EQUAL(memcmp(in.cqi_indication_body.cqi_raw_pdu_list[0].pdu, out.cqi_indication_body.cqi_raw_pdu_list[0].pdu, sizeof(cqi_1)), 0); + CU_ASSERT_EQUAL(memcmp(in.cqi_indication_body.cqi_raw_pdu_list[2].pdu, out.cqi_indication_body.cqi_raw_pdu_list[2].pdu, sizeof(cqi_2)), 0); + + free(in.cqi_indication_body.cqi_pdu_list); + free(in.cqi_indication_body.cqi_raw_pdu_list); + free(out.cqi_indication_body.cqi_pdu_list); + free(out.cqi_indication_body.cqi_raw_pdu_list); +} + +void nfapi_test_lbt_dl_config_request() +{ + nfapi_lbt_dl_config_request_t in; + memset(&in, 0, sizeof(in)); + nfapi_lbt_dl_config_request_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_LBT_DL_CONFIG_REQUEST; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + //in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 1234; + in.lbt_dl_config_request_body.tl.tag = NFAPI_LBT_DL_CONFIG_REQUEST_BODY_TAG; + in.lbt_dl_config_request_body.number_of_pdus = 2; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list = (nfapi_lbt_dl_config_request_pdu_t*)(malloc(sizeof(nfapi_lbt_dl_config_request_pdu_t) * in.lbt_dl_config_request_body.number_of_pdus)); + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].pdu_type = NFAPI_LBT_DL_CONFIG_REQUEST_PDSCH_PDU_TYPE; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].pdu_size = 32; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.tl.tag = NFAPI_LBT_PDSCH_REQ_PDU_REL13_TAG; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.handle = 0x1234; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.mp_cca = 22; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.n_cca = 23; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.offset = 24; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.lte_txop_sf = 25; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.txop_sfn_sf_end = 26; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.lbt_mode = 27; + + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].pdu_type = NFAPI_LBT_DL_CONFIG_REQUEST_DRS_PDU_TYPE; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].pdu_size = 32; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.tl.tag = NFAPI_LBT_DRS_REQ_PDU_REL13_TAG; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.handle = 0x4567; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.offset = 1; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.sfn_sf_end = 2; + in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.lbt_mode = 3; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.phy_id, out.header.phy_id); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.header.message_length, out.header.message_length); + CU_ASSERT_EQUAL(in.header.m_segment_sequence, out.header.m_segment_sequence); + CU_ASSERT_EQUAL(in.header.checksum, out.header.checksum); + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.number_of_pdus, out.lbt_dl_config_request_body.number_of_pdus); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].pdu_type, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].pdu_type); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].pdu_size, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].pdu_size); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.tl.tag, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.tl.tag); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.handle, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.handle); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.mp_cca, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.mp_cca); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.n_cca, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.n_cca); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.offset, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.offset); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.lte_txop_sf, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.lte_txop_sf); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.txop_sfn_sf_end, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.txop_sfn_sf_end); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.lbt_mode, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[0].lbt_pdsch_req_pdu.lbt_pdsch_req_pdu_rel13.lbt_mode); + + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].pdu_type, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].pdu_type); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].pdu_size, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].pdu_size); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.tl.tag, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.tl.tag); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.handle, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.handle); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.offset, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.offset); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.sfn_sf_end, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.sfn_sf_end); + CU_ASSERT_EQUAL(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.lbt_mode, out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list[1].lbt_drs_req_pdu.lbt_drs_req_pdu_rel13.lbt_mode); + + free(in.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list); + free(out.lbt_dl_config_request_body.lbt_dl_config_req_pdu_list); +} + +void nfapi_test_lbt_dl_indication() +{ + nfapi_lbt_dl_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_lbt_dl_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_LBT_DL_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + //in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 1234; + in.lbt_dl_indication_body.tl.tag = NFAPI_LBT_DL_INDICATION_BODY_TAG; + in.lbt_dl_indication_body.number_of_pdus = 2; + in.lbt_dl_indication_body.lbt_indication_pdu_list = (nfapi_lbt_dl_indication_pdu_t*)(malloc(sizeof(nfapi_lbt_dl_indication_pdu_t) * in.lbt_dl_indication_body.number_of_pdus)); + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_type = NFAPI_LBT_DL_RSP_PDSCH_PDU_TYPE; + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_size = 32; + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.tl.tag = NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG; + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.handle = 0x1234; + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.result = 22; + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.lte_txop_symbols = 23; + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.initial_partial_sf = 24; + + in.lbt_dl_indication_body.lbt_indication_pdu_list[1].pdu_type = NFAPI_LBT_DL_RSP_DRS_PDU_TYPE; + in.lbt_dl_indication_body.lbt_indication_pdu_list[1].pdu_size = 32; + in.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.tl.tag = NFAPI_LBT_DRS_RSP_PDU_REL13_TAG; + in.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.handle = 0x4567; + in.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.result = 1; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.phy_id, out.header.phy_id); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.header.message_length, out.header.message_length); + CU_ASSERT_EQUAL(in.header.m_segment_sequence, out.header.m_segment_sequence); + CU_ASSERT_EQUAL(in.header.checksum, out.header.checksum); + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.number_of_pdus, out.lbt_dl_indication_body.number_of_pdus); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_type, out.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_type); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_size, out.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_size); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.tl.tag, out.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.tl.tag); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.handle, out.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.handle); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.result, out.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.result); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.lte_txop_symbols, out.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.lte_txop_symbols); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.initial_partial_sf, out.lbt_dl_indication_body.lbt_indication_pdu_list[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.initial_partial_sf); + + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[1].pdu_type, out.lbt_dl_indication_body.lbt_indication_pdu_list[1].pdu_type); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[1].pdu_size, out.lbt_dl_indication_body.lbt_indication_pdu_list[1].pdu_size); + + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.tl.tag, out.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.tl.tag); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.handle, out.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.handle); + CU_ASSERT_EQUAL(in.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.result, out.lbt_dl_indication_body.lbt_indication_pdu_list[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.result); + + free(in.lbt_dl_indication_body.lbt_indication_pdu_list); + free(out.lbt_dl_indication_body.lbt_indication_pdu_list); + +} +void nfapi_test_lbt_dl_indication_invalid_pdu_type() +{ + nfapi_lbt_dl_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_lbt_dl_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_LBT_DL_INDICATION; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + //in.header.checksum = 0xEEEEEEEE; + + in.sfn_sf = 1234; + in.lbt_dl_indication_body.tl.tag = NFAPI_LBT_DL_INDICATION_BODY_TAG; + in.lbt_dl_indication_body.number_of_pdus = 1; + in.lbt_dl_indication_body.lbt_indication_pdu_list = (nfapi_lbt_dl_indication_pdu_t*)(malloc(sizeof(nfapi_lbt_dl_indication_pdu_t) * in.lbt_dl_indication_body.number_of_pdus)); + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_type = 44; // Invalid pdu type + in.lbt_dl_indication_body.lbt_indication_pdu_list[0].pdu_size = 32; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + int unpack_result = nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(unpack_result, -1); + CU_ASSERT_EQUAL(in.header.phy_id, out.header.phy_id); + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.header.message_length, out.header.message_length); + CU_ASSERT_EQUAL(in.header.m_segment_sequence, out.header.m_segment_sequence); + CU_ASSERT_EQUAL(in.header.checksum, out.header.checksum); + CU_ASSERT_EQUAL(in.sfn_sf, out.sfn_sf); + free(in.lbt_dl_indication_body.lbt_indication_pdu_list); + free(out.lbt_dl_indication_body.lbt_indication_pdu_list); +} + +void nfapi_test_nb_harq_indication() +{ + nfapi_nb_harq_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_nb_harq_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_NB_HARQ_INDICATION; + in.header.message_length = 0; + + in.sfn_sf = 1234; + in.nb_harq_indication_body.tl.tag = NFAPI_NB_HARQ_INDICATION_BODY_TAG; + in.nb_harq_indication_body.number_of_harqs = 1; + + nfapi_nb_harq_indication_pdu_t nb_harq_pdu[1]; + in.nb_harq_indication_body.nb_harq_pdu_list = &nb_harq_pdu[0]; + in.nb_harq_indication_body.nb_harq_pdu_list[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + in.nb_harq_indication_body.nb_harq_pdu_list[0].nb_harq_indication_fdd_rel13.tl.tag = NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG; + in.nb_harq_indication_body.nb_harq_pdu_list[0].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + IN_OUT_ASSERT(sfn_sf); + IN_OUT_ASSERT(nb_harq_indication_body.tl.tag); + IN_OUT_ASSERT(nb_harq_indication_body.number_of_harqs); + + IN_OUT_ASSERT(nb_harq_indication_body.nb_harq_pdu_list[0].rx_ue_information.tl.tag); + IN_OUT_ASSERT(nb_harq_indication_body.nb_harq_pdu_list[0].nb_harq_indication_fdd_rel13.tl.tag); + IN_OUT_ASSERT(nb_harq_indication_body.nb_harq_pdu_list[0].ul_cqi_information.tl.tag); + +} + +void nfapi_test_nrach_indication() +{ + nfapi_nrach_indication_t in; + memset(&in, 0, sizeof(in)); + nfapi_nrach_indication_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_NRACH_INDICATION; + in.header.message_length = 0; + + in.sfn_sf = 1234; + + in.nrach_indication_body.tl.tag = NFAPI_NRACH_INDICATION_BODY_TAG; + in.nrach_indication_body.number_of_initial_scs_detected = 1; + + nfapi_nrach_indication_pdu_t nrach_pdu[1]; + in.nrach_indication_body.nrach_pdu_list = &nrach_pdu[0]; + + in.nrach_indication_body.nrach_pdu_list[0].nrach_indication_rel13.tl.tag = NFAPI_NRACH_INDICATION_REL13_TAG; + + + + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + IN_OUT_ASSERT(sfn_sf); + IN_OUT_ASSERT(nrach_indication_body.tl.tag); + IN_OUT_ASSERT(nrach_indication_body.number_of_initial_scs_detected); + IN_OUT_ASSERT(nrach_indication_body.nrach_pdu_list[0].nrach_indication_rel13.tl.tag); + IN_OUT_ASSERT(nrach_indication_body.nrach_pdu_list[0].nrach_indication_rel13.rnti); + IN_OUT_ASSERT(nrach_indication_body.nrach_pdu_list[0].nrach_indication_rel13.initial_sc); + IN_OUT_ASSERT(nrach_indication_body.nrach_pdu_list[0].nrach_indication_rel13.timing_advance); + IN_OUT_ASSERT(nrach_indication_body.nrach_pdu_list[0].nrach_indication_rel13.nrach_ce_level); + +} + +void nfapi_test_dl_node_sync() +{ + nfapi_dl_node_sync_t in; + nfapi_dl_node_sync_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_DL_NODE_SYNC; + in.header.message_length = 0; + + in.t1 = 10239999; + in.delta_sfn_sf = -987; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.t1, out.t1); + CU_ASSERT_EQUAL(in.delta_sfn_sf, out.delta_sfn_sf); +} +void nfapi_test_ul_node_sync() +{ + nfapi_ul_node_sync_t in; + nfapi_ul_node_sync_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_UL_NODE_SYNC; + in.header.message_length = 0; + + in.t1 = 10239999; + in.t2 = 10239999; + in.t2 = 10239999; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.t1, out.t1); + CU_ASSERT_EQUAL(in.t2, out.t2); + CU_ASSERT_EQUAL(in.t3, out.t3); +} +void nfapi_test_timing_info() +{ + nfapi_timing_info_t in; + nfapi_timing_info_t out; + + in.header.phy_id = NFAPI_PHY_ID_NA; + in.header.message_id = NFAPI_TIMING_INFO; + in.header.message_length = 0; + in.header.m_segment_sequence = 0xDDDD; + in.header.checksum = 0xEEEEEEEE; + + in.last_sfn_sf = 0xDEAD; //10239999; + in.time_since_last_timing_info = 4294967295u; + in.dl_config_jitter = 4294967295u; + in.tx_request_jitter = 4294967295u; + in.ul_config_jitter = 4294967295u; + in.hi_dci0_jitter = 4294967295u; + in.dl_config_latest_delay = 0; //-2147483648L; + in.tx_request_latest_delay = 2147483647u; + in.ul_config_latest_delay = 0; //-2147483648L ; + in.hi_dci0_latest_delay = 0; //2147483647u; + in.dl_config_earliest_arrival = 0; //-2147483648L; + in.tx_request_earliest_arrival = 0; //2147483647u; + in.ul_config_earliest_arrival = 0; //2147483648L; + in.hi_dci0_earliest_arrival = -0; //2147483647u; + + int packedMessageLength = nfapi_p7_message_pack(&in, gTestNfapiMessageTx, MAX_PACKED_MESSAGE_SIZE, 0); + + nfapi_p7_message_unpack(gTestNfapiMessageTx, packedMessageLength, &out, sizeof(out), 0); + + CU_ASSERT_EQUAL(in.header.message_id, out.header.message_id); + CU_ASSERT_EQUAL(in.last_sfn_sf, out.last_sfn_sf); + CU_ASSERT_EQUAL(in.time_since_last_timing_info, out.time_since_last_timing_info); + CU_ASSERT_EQUAL(in.dl_config_jitter, out.dl_config_jitter); + CU_ASSERT_EQUAL(in.tx_request_jitter, out.tx_request_jitter); + CU_ASSERT_EQUAL(in.ul_config_jitter, out.ul_config_jitter); + CU_ASSERT_EQUAL(in.hi_dci0_jitter, out.hi_dci0_jitter); + CU_ASSERT_EQUAL(in.dl_config_latest_delay, out.dl_config_latest_delay); + CU_ASSERT_EQUAL(in.tx_request_latest_delay, out.tx_request_latest_delay); + CU_ASSERT_EQUAL(in.ul_config_latest_delay, out.ul_config_latest_delay); + CU_ASSERT_EQUAL(in.hi_dci0_latest_delay, out.hi_dci0_latest_delay); + CU_ASSERT_EQUAL(in.dl_config_earliest_arrival, out.dl_config_earliest_arrival); + CU_ASSERT_EQUAL(in.tx_request_earliest_arrival, out.tx_request_earliest_arrival); + CU_ASSERT_EQUAL(in.ul_config_earliest_arrival, out.ul_config_earliest_arrival); + CU_ASSERT_EQUAL(in.hi_dci0_earliest_arrival, out.hi_dci0_earliest_arrival); +} + +void nfapi_struct_sizes() +{ + + + printf("P5\n"); + printf("nfapi_pnf_param_request %zu\n", sizeof(nfapi_pnf_param_request_t)); + printf("nfapi_pnf_param_response %zu\n", sizeof(nfapi_pnf_param_response_t)); + printf("nfapi_pnf_config_request %zu\n", sizeof(nfapi_pnf_config_request_t)); + printf("nfapi_pnf_config_response %zu\n", sizeof(nfapi_pnf_config_response_t)); + printf("nfapi_pnf_start_request %zu\n", sizeof(nfapi_pnf_start_request_t)); + printf("nfapi_pnf_start_response %zu\n", sizeof(nfapi_pnf_start_response_t)); + printf("nfapi_pnf_stop_request %zu\n", sizeof(nfapi_pnf_stop_request_t)); + printf("nfapi_pnf_stop_request %zu\n", sizeof(nfapi_pnf_stop_response_t)); + printf("nfapi_param_request %zu\n", sizeof(nfapi_param_request_t)); + printf("nfapi_param_response %zu\n", sizeof(nfapi_param_response_t)); + printf("nfapi_config_request %zu\n", sizeof(nfapi_config_request_t)); + printf("nfapi_config_response %zu\n", sizeof(nfapi_config_response_t)); + printf("nfapi_start_request %zu\n", sizeof(nfapi_start_request_t)); + printf("nfapi_start_response %zu\n", sizeof(nfapi_start_response_t)); + printf("nfapi_stop_request %zu\n", sizeof(nfapi_stop_request_t)); + printf("nfapi_stop_response %zu\n", sizeof(nfapi_stop_response_t)); + printf("nfapi_measurement_request %zu\n", sizeof(nfapi_measurement_request_t)); + printf("nfapi_measurement_response %zu\n", sizeof(nfapi_measurement_response_t)); + + printf("P7\n"); + printf("nfapi_timing_info_t %zu\n", sizeof(nfapi_timing_info_t)); + printf("nfapi_dl_config_request_t %zu\n", sizeof(nfapi_dl_config_request_t)); + printf("nfapi_ul_config_request_t %zu\n", sizeof(nfapi_ul_config_request_t)); + printf("nfapi_hi_dci0_request_t %zu\n", sizeof(nfapi_hi_dci0_request_t)); + printf("nfapi_tx_request_t %zu\n", sizeof(nfapi_tx_request_t)); + printf("nfapi_crc_indication_t %zu\n", sizeof(nfapi_crc_indication_t)); + printf("nfapi_sr_indication_t %zu\n", sizeof(nfapi_sr_indication_t)); + printf("nfapi_srs_indication_t %zu\n", sizeof(nfapi_srs_indication_t)); + printf("nfapi_harq_indication_t %zu\n", sizeof(nfapi_harq_indication_t)); + printf("nfapi_rx_indication_t %zu\n", sizeof(nfapi_rx_indication_t)); + printf("nfapi_rach_indication_t %zu\n", sizeof(nfapi_rach_indication_t)); + printf("nfapi_cqi_indication_t %zu\n", sizeof(nfapi_cqi_indication_t)); + printf("nfapi_nb_harq_indication_t %zu\n", sizeof(nfapi_nb_harq_indication_t)); + printf("nfapi_nrach_indication_t %zu\n", sizeof(nfapi_nrach_indication_t)); + printf("nfapi_lbt_dl_config_request_t %zu\n", sizeof(nfapi_lbt_dl_config_request_t)); + printf("nfapi_lbt_dl_indication_t %zu\n", sizeof(nfapi_lbt_dl_indication_t)); + + printf("P4\n"); + printf("nfapi_lte_rssi_request_t %zu\n", sizeof(nfapi_lte_rssi_request_t)); + printf("nfapi_utran_rssi_request_t %zu\n", sizeof(nfapi_utran_rssi_request_t)); + printf("nfapi_geran_rssi_request_t %zu\n", sizeof(nfapi_geran_rssi_request_t)); + printf("nfapi_lte_cell_search_request_t %zu\n", sizeof(nfapi_lte_cell_search_request_t)); + printf("nfapi_utran_cell_search_request_t %zu\n", sizeof(nfapi_utran_cell_search_request_t)); + printf("nfapi_geran_cell_search_request_t %zu\n", sizeof(nfapi_geran_cell_search_request_t)); + printf("nfapi_lte_cell_search_indication_t %zu\n", sizeof(nfapi_lte_cell_search_indication_t)); + printf("nfapi_utran_cell_search_indication_t %zu\n", sizeof(nfapi_utran_cell_search_indication_t)); + printf("nfapi_geran_cell_search_indication_t %zu\n", sizeof(nfapi_geran_cell_search_indication_t)); + printf("nfapi_lte_broadcast_detect_request_t %zu\n", sizeof(nfapi_lte_broadcast_detect_request_t)); + printf("nfapi_utran_broadcast_detect_request_t %zu\n", sizeof(nfapi_utran_broadcast_detect_request_t)); + printf("nfapi_lte_broadcast_detect_indication_t %zu\n", sizeof(nfapi_lte_broadcast_detect_indication_t)); + printf("nfapi_utran_broadcast_detect_indication_t %zu\n", sizeof(nfapi_utran_broadcast_detect_indication_t)); + printf("nfapi_lte_system_information_schedule_request_t %zu\n", sizeof(nfapi_lte_system_information_schedule_request_t)); + printf("nfapi_lte_system_information_request_t %zu\n", sizeof(nfapi_lte_system_information_request_t)); + printf("nfapi_utran_system_information_request_t %zu\n", sizeof(nfapi_utran_system_information_request_t)); + printf("nfapi_geran_system_information_request_t %zu\n", sizeof(nfapi_geran_system_information_request_t)); + printf("nfapi_lte_system_information_indication_t %zu\n", sizeof(nfapi_lte_system_information_indication_t)); + printf("nfapi_utran_system_information_indication_t %zu\n", sizeof(nfapi_utran_system_information_indication_t)); + printf("nfapi_geran_system_information_indication_t %zu\n", sizeof(nfapi_geran_system_information_indication_t)); +} + +/************* Test Runner Code goes here **************/ + + +int main ( int argc, char** argv) +{ + +/* + printf("1..3\n"); + printf("ok 1 - run good\n"); + printf("ok 2 - mojojojo\n"); + printf("not ok 3 - not implemented\n"); + return 0; + */ + + + int i; + printf("%d \n", argc); + for(i = 0; i < argc; ++i) + { + if(argv[i] != 0) + printf("%s \n", argv[i]); + } + + CU_pSuite pSuite = NULL; + + /* initialize the CUnit test registry */ + if ( CUE_SUCCESS != CU_initialize_registry() ) + return CU_get_error(); + + /* add a suite to the registry */ + pSuite = CU_add_suite( "nfapi_test_suite", init_suite, clean_suite ); + if ( NULL == pSuite ) { + CU_cleanup_registry(); + return CU_get_error(); + } + + /* add the tests to the suite */ + //if ( (NULL == CU_add_test(pSuite, "nfapi_test_pnf_config_req", nfapi_test_pnf_config_req)) || + // (NULL == CU_add_test(pSuite, "nfapi_test_2", nfapi_test_2)) + // ) + // { + // CU_cleanup_registry(); + // return CU_get_error(); + //} + + + CU_pSuite pSuiteP4 = CU_add_suite( "nfapi_p4_pack_unpack_test_suite", init_suite, clean_suite ); + if(pSuiteP4) + { + if((NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_request_lte", nfapi_test_rssi_request_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_request_lte2", nfapi_test_rssi_request_lte2)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_request_lte_overrun", nfapi_test_rssi_request_lte_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_request_lte_rat_type_mismatch", nfapi_test_rssi_request_lte_rat_type_mismatch)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_request_utran", nfapi_test_rssi_request_utran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_request_geran", nfapi_test_rssi_request_geran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_request_nb_iot", nfapi_test_rssi_request_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_response", nfapi_test_rssi_response)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_indication", nfapi_test_rssi_indication)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_rssi_indication_overrun", nfapi_test_rssi_indication_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_request_lte", nfapi_test_cell_search_request_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_request_lte_overrun", nfapi_test_cell_search_request_lte_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_request_utran", nfapi_test_cell_search_request_utran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_request_utran_overrun", nfapi_test_cell_search_request_utran_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_request_geran", nfapi_test_cell_search_request_geran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_request_geran_overrun", nfapi_test_cell_search_request_geran_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_request_nb_iot", nfapi_test_cell_search_request_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_response", nfapi_test_cell_search_response)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_lte", nfapi_test_cell_search_indication_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_lte_overrun", nfapi_test_cell_search_indication_lte_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_utran", nfapi_test_cell_search_indication_utran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_utran_overrun", nfapi_test_cell_search_indication_utran_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_geran", nfapi_test_cell_search_indication_geran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_geran_overrun", nfapi_test_cell_search_indication_geran_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_state_overrun", nfapi_test_cell_search_indication_state_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_cell_search_indication_nb_iot", nfapi_test_cell_search_indication_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_request_lte", nfapi_test_broadcast_detect_request_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_request_utran", nfapi_test_broadcast_detect_request_utran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_request_nb_iot", nfapi_test_broadcast_detect_request_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_request_state_overrun", nfapi_test_broadcast_detect_request_state_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_response", nfapi_test_broadcast_detect_response)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_indication_lte", nfapi_test_broadcast_detect_indication_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_indication_lte_overrun", nfapi_test_broadcast_detect_indication_lte_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_indication_utran", nfapi_test_broadcast_detect_indication_utran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_indication_utran_overrun", nfapi_test_broadcast_detect_indication_utran_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_indication_state_overrun", nfapi_test_broadcast_detect_indication_state_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_broadcast_detect_indication_nb_iot", nfapi_test_broadcast_detect_indication_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_schedule_request_lte", nfapi_test_system_information_schedule_request_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_schedule_request_state_overrun", nfapi_test_system_information_schedule_request_state_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_schedule_request_nb_iot", nfapi_test_system_information_schedule_request_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_schedule_response", nfapi_test_system_information_schedule_response)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_schedule_indication_lte", nfapi_test_system_information_schedule_indication_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_schedule_indication_nb_iot", nfapi_test_system_information_schedule_indication_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_request_lte", nfapi_test_system_information_request_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_request_lte_overrun", nfapi_test_system_information_request_lte_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_request_utran", nfapi_test_system_information_request_utran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_request_geran", nfapi_test_system_information_request_geran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_request_state_overrun", nfapi_test_system_information_request_state_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_request_nb_iot", nfapi_test_system_information_request_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_response", nfapi_test_system_information_response)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_indication_lte", nfapi_test_system_information_indication_lte)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_indication_lte_overrun", nfapi_test_system_information_indication_lte_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_indication_utran", nfapi_test_system_information_indication_utran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_indication_utran_overrun", nfapi_test_system_information_indication_utran_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_indication_geran", nfapi_test_system_information_indication_geran)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_indication_geran_overrun", nfapi_test_system_information_indication_geran_overrun)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_system_information_indication_nb_iot", nfapi_test_system_information_indication_nb_iot)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_nmm_stop_request", nfapi_test_nmm_stop_request)) || + (NULL == CU_add_test(pSuiteP4, "nfapi_test_nmm_stop_response", nfapi_test_nmm_stop_response)) + ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + } + else + { + CU_cleanup_registry(); + return CU_get_error(); + } + + CU_pSuite pSuiteP5 = CU_add_suite( "nfapi_p5_pack_unpack_test_suite", init_suite, clean_suite ); + if(pSuiteP5) + { + if((NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_param_request", nfapi_test_pnf_param_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_param_request_ve", nfapi_test_pnf_param_request_ve)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_param_response", nfapi_test_pnf_param_response)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_config_request", nfapi_test_pnf_config_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_config_response", nfapi_test_pnf_config_response)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_config_response1", nfapi_test_pnf_config_response1)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_start_request", nfapi_test_pnf_start_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_start_response", nfapi_test_pnf_start_response)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_stop_request", nfapi_test_pnf_stop_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_pnf_stop_request", nfapi_test_pnf_stop_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_param_request", nfapi_test_param_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_param_response", nfapi_test_param_response)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_config_request", nfapi_test_config_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_config_response", nfapi_test_config_response)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_start_request", nfapi_test_start_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_start_response", nfapi_test_start_response)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_stop_request", nfapi_test_stop_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_stop_response", nfapi_test_stop_response)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_measurement_request", nfapi_test_measurement_request)) || + (NULL == CU_add_test(pSuiteP5, "nfapi_test_measurement_response", nfapi_test_measurement_response)) + ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + } + else + { + CU_cleanup_registry(); + return CU_get_error(); + } + + CU_pSuite pSuiteP7 = CU_add_suite( "nfapi_p7_pack_unpack_test_suite", init_suite, clean_suite ); + if(pSuiteP7) + { + if((NULL == CU_add_test(pSuiteP7, "nfapi_test_dl_config_request", nfapi_test_dl_config_request)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_ul_config_request", nfapi_test_ul_config_request)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_hi_dci0_request", nfapi_test_hi_dci0_request)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_tx_request", nfapi_test_tx_request)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_harq_indication", nfapi_test_harq_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_crc_indication", nfapi_test_crc_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_rx_ulsch_indication", nfapi_test_rx_ulsch_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_rach_indication", nfapi_test_rach_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_srs_indication", nfapi_test_srs_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_rx_sr_indication", nfapi_test_rx_sr_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_rx_cqi_indication", nfapi_test_rx_cqi_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_lbt_dl_config_request", nfapi_test_lbt_dl_config_request)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_lbt_dl_indication", nfapi_test_lbt_dl_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_lbt_dl_indication_invalid_pdu_type", nfapi_test_lbt_dl_indication_invalid_pdu_type)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_nb_harq_indication", nfapi_test_nb_harq_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_nrach_indication", nfapi_test_nrach_indication)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_dl_node_sync", nfapi_test_dl_node_sync)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_ul_node_sync", nfapi_test_ul_node_sync)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_test_timing_info", nfapi_test_timing_info)) || + (NULL == CU_add_test(pSuiteP7, "nfapi_struct_sizes", nfapi_struct_sizes)) + ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + } + else + { + CU_cleanup_registry(); + return CU_get_error(); + } + + + // Run all tests using the basic interface + CU_basic_set_mode(CU_BRM_VERBOSE); + //printf(" CU_basic_set_mode set \n"); + CU_set_output_filename("nfapi_unit_test_results.xml"); + + CU_basic_run_tests(); + //CU_automated_run_tests(); + + //CU_set_test_complete_handler(automated_test_complete_message_handler); + //CU_run_all_tests(); + + + CU_pSuite s = CU_get_registry()->pSuite; + int count = 0; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + count++; + t = t->pNext; + } + s = s->pNext; + } + + printf("%d..%d\n", 1, count); + + + + s = CU_get_registry()->pSuite; + count = 1; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + int pass = 1; + CU_FailureRecord* failures = CU_get_failure_list(); + while(failures) + { + if(strcmp(failures->pSuite->pName, s->pName) == 0 && + strcmp(failures->pTest->pName, t->pName) == 0) + { + pass = 0; + failures = 0; + } + else + { + failures = failures->pNext; + } + } + + if(pass) + printf("ok %d - %s:%s\n", count, s->pName, t->pName); + else + printf("not ok %d - %s:%s\n", count, s->pName, t->pName); + + count++; + t = t->pNext; + } + s = s->pNext; + } + + /* + s = CU_get_registry()->pSuite; + while(s) + { + printf("Suite %s\n", s->pName); + CU_pTest t = s->pTest; + while(t) + { + printf(" Test %s\n", t->pName); + i//CU_ErrorCode e = CU_basic_run_test(s, t); + + t = t->pNext; + } + s = s->pNext; + } + */ + + + + //printf("CU_basic_run_tests completed \n"); + //CU_basic_show_failures(CU_get_failure_list()); + //printf("CU_basic_show_failures completed\n\n"); + /* + // Run all tests using the automated interface + CU_automated_run_tests(); + CU_list_tests_to_file(); + + // Run all tests using the console interface + CU_console_run_tests(); + */ + /* Clean up registry and return */ + + + CU_cleanup_registry(); + return CU_get_error(); + +} diff --git a/nfapi/open-nFAPI/pnf/Makefile.am b/nfapi/open-nFAPI/pnf/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..663d96b6dddeba94a730abf6a82f7c9fe6ddd6a5 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/Makefile.am @@ -0,0 +1,32 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +AUTOMAKE_OPTIONS=subdir-objects + +AM_CPPFLAGS = -I$(top_srcdir)/pnf/inc -I$(top_srcdir)/pnf/public_inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/common/public_inc -g -Wall -Werror + + +noinst_LIBRARIES = libnfapi_pnf.a + +libnfapi_pnf_a_SOURCES = src/pnf.c\ + src/pnf_interface.c\ + src/pnf_p7.c\ + src/pnf_p7_interface.c + +LDADD = -lsctp + + + diff --git a/nfapi/open-nFAPI/pnf/inc/pnf.h b/nfapi/open-nFAPI/pnf/inc/pnf.h new file mode 100644 index 0000000000000000000000000000000000000000..ab38c66e090f1f2ed6d010988465155e25fa8ca8 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/inc/pnf.h @@ -0,0 +1,49 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _PNF_H_ +#define _PNF_H_ + +#include "nfapi_pnf_interface.h" + +#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192 + +typedef struct { + + nfapi_pnf_config_t _public; + + int p5_sock; + uint8_t tx_message_buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + + uint8_t sctp; + + uint8_t terminate; + +} pnf_t; + + +int pnf_connect(pnf_t *pnf); +int pnf_message_pump(pnf_t *pnf); + +int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len); +int pnf_pack_and_send_p4_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len); +int pnf_send_message(pnf_t* pnf, uint8_t* msg, uint32_t msg_len, uint16_t stream_id); + +nfapi_pnf_phy_config_t* nfapi_pnf_phy_config_find(nfapi_pnf_config_t* config, uint16_t phy_id); + +#endif // _PNF_H_ + diff --git a/nfapi/open-nFAPI/pnf/inc/pnf_p7.h b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h new file mode 100644 index 0000000000000000000000000000000000000000..3f08d85e6b678aff5c15c733b3361c65ab81961c --- /dev/null +++ b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h @@ -0,0 +1,126 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef _PNF_P7_H_ +#define _PNF_P7_H_ + +#define TIMEHR_SEC(_time_hr) ((uint32_t)(_time_hr) >> 20) +#define TIMEHR_USEC(_time_hr) ((uint32_t)(_time_hr) & 0xFFFFF) +#define TIME2TIMEHR(_time) (((uint32_t)(_time.tv_sec) & 0xFFF) << 20 | ((uint32_t)(_time.tv_usec) & 0xFFFFF)) + +#include "nfapi_pnf_interface.h" + +#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192 + +typedef struct { + uint16_t dl_conf_ontime; + uint16_t dl_conf_late; + uint16_t ul_conf_ontime; + uint16_t ul_conf_late; + uint16_t hi_dci0_ontime; + uint16_t hi_dci0_late; + uint16_t tx_ontime; + uint16_t tx_late; +} pnf_p7_stats_t; + +typedef struct { + uint8_t* buffer; + uint16_t length; +} pnf_p7_rx_message_segment_t; + +typedef struct pnf_p7_rx_message pnf_p7_rx_message_t; + +typedef struct pnf_p7_rx_message { + uint8_t sequence_number; + uint8_t num_segments_received; + uint8_t num_segments_expected; + + // the spec allows of upto 128 segments, this does seem excessive + pnf_p7_rx_message_segment_t segments[128]; + + uint32_t rx_hr_time; + + pnf_p7_rx_message_t* next; +} pnf_p7_rx_message_t; + +typedef struct { + + pnf_p7_rx_message_t* msg_queue; + +} pnf_p7_rx_reassembly_queue_t; + + +typedef struct { + + nfapi_pnf_p7_config_t _public; + + //private data + int p7_sock; + + uint8_t terminate; + + uint8_t tx_message_buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + uint8_t* rx_message_buffer; + uint16_t rx_message_buffer_size; + + pthread_mutex_t mutex; // should we allow the client to specifiy + pthread_mutex_t pack_mutex; // should we allow the client to specifiy + + nfapi_pnf_p7_subframe_buffer_t subframe_buffer[30/*NFAPI_MAX_TIMING_WINDOW_SIZE*/]; + + uint32_t sequence_number; + uint16_t max_num_segments; + + pnf_p7_rx_reassembly_queue_t reassembly_queue; + + uint8_t* reassemby_buffer; + uint32_t reassemby_buffer_size; + + uint16_t sfn_sf; + uint32_t sf_start_time_hr; + int32_t sfn_sf_shift; + + uint8_t timing_info_period_counter; + uint8_t timing_info_aperiodic_send; // 0:false 1:true + + uint32_t timing_info_ms_counter; // number of ms since last timing info + + uint32_t dl_config_jitter; + uint32_t ul_config_jitter; + uint32_t hi_dci0_jitter; + uint32_t tx_jitter; + + uint32_t tick; + pnf_p7_stats_t stats; + +} pnf_p7_t; + +int pnf_p7_message_pump(pnf_p7_t* pnf_p7); + +int pnf_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* msg, uint32_t msg_len); +int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t msg_len); + + +int pnf_p7_subframe_ind(pnf_p7_t* config, uint16_t phy_id, uint16_t sfn_sf); + +pnf_p7_rx_message_t* pnf_p7_rx_reassembly_queue_add_segment(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, uint32_t rx_hr_time, uint16_t sequence_number, uint16_t segment_number, uint8_t m, uint8_t* data, uint16_t data_len); +void pnf_p7_rx_reassembly_queue_remove_msg(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, pnf_p7_rx_message_t* msg); +void pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, uint32_t rx_hr_time, uint32_t delta); + +#endif /* _PNF_P7_H_ */ + diff --git a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..b25caf28760ff6e06ef4607b2d49f7e1a46e1de5 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h @@ -0,0 +1,803 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _NFAPI_PNF_INTERFACE_H_ +#define _NFAPI_PNF_INTERFACE_H_ + +#if defined(__cplusplus) +extern "C" { +#endif + +#include "nfapi_interface.h" +#include "debug.h" + +#include <sys/types.h> + +/*! This enum is used to describe the states of the pnf + */ +typedef enum +{ + NFAPI_PNF_IDLE = 0, + NFAPI_PNF_CONFIGURED, + NFAPI_PNF_RUNNING +} nfapi_pnf_state_e; + +/*! This enum is used to describe the states of a phy instance of a pnf + */ +typedef enum +{ + NFAPI_PNF_PHY_IDLE = 0, + NFAPI_PNF_PHY_CONFIGURED = 1, + NFAPI_PNF_PHY_RUNNING = 2 +} nfapi_pnf_phy_state_e; + +typedef struct nfapi_pnf_phy_config nfapi_pnf_phy_config_t; + +/*! Configuration information for a pnf phy instance + */ +typedef struct nfapi_pnf_phy_config +{ + /*! The PHY id*/ + uint16_t phy_id; + + /*! The state of the PNF PHY instance*/ + nfapi_pnf_phy_state_e state; + + /*! Optional user defined data that will be passed back in the callbacks*/ + void* user_data; + + /*! Pointer for use in a linked list */ + struct nfapi_pnf_phy_config* next; +} nfapi_pnf_phy_config_t; + +typedef struct nfapi_pnf_config nfapi_pnf_config_t; + +/*! Configuration information for the pnf created by calling nfapi_pnf_create + */ +typedef struct nfapi_pnf_config +{ + /*! A user define callback to override the default memory allocation + * \param size The size of the data buffer to allocate + * \return A pointer to a data buffer + */ + void* (*malloc)(size_t size); + + /*! A user define callback to override the default memory deallocation + * \param ptr Pointer to a data buffer to be deallocated + */ + void (*free)(void* ptr); + + /*! A user define callback to handle trace from the pnf + * \param level The trace level + * \param message The trace string + * + * This is a vardic function. + */ + void (*trace)(nfapi_trace_level_t level, const char* message, ...); + + /*! The ip address of the VNF + * + */ + char* vnf_ip_addr; + + /*! The ip port of the VNF + */ + int vnf_p5_port; + + /*! The state of the PNF */ + nfapi_pnf_state_e state; + + /*! List of PHY instances configured for this PNF */ + nfapi_pnf_phy_config_t* phys; + + /*! Configuation option of the p4 p5 encode decode functions */ + nfapi_p4_p5_codec_config_t codec_config; + + /*! Optional user defined data that will be passed back in the callbacks*/ + void* user_data; + + + /*! A callback for the PNF_PARAM.request + * \param config A pointer to the pnf configuration + * \param req A data structure for the decoded PNF_PARAM.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the PNF_PARAM.response after receiving the + * PNF_PARAM.request. This can be done in the call back. + */ + int (*pnf_param_req)(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req); + + /*! A callback for the PNF_CONFIG.request + * \param config A pointer to the pnf configuration + * \param req A data structure for the decoded PNF_CONFIG.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the PNF_CONFIG.response after receiving the + * PNF_CONFIG.request. This can be done in the call back. + */ + int (*pnf_config_req)(nfapi_pnf_config_t* config, nfapi_pnf_config_request_t* req); + + /*! A callback for the PNF_START.request + * \param config A pointer to the pnf configuration + * \param req A data structure for the decoded PNF_CONFIG.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the PNF_START.response after receiving the + * PNF_START.request. This can be done in the call back. + */ + int (*pnf_start_req)(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req); + + /*! A callback for the PNF_STOP.request + * \param config A pointer to the pnf configuration + * \param req A data structure for the decoded PNF_STOP.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the PNF_STOP.response after receiving the + * PNF_STOP.request. This can be done in the call back. + */ + int (*pnf_stop_req)(nfapi_pnf_config_t* config, nfapi_pnf_stop_request_t* req); + + /*! A callback for the PARAM.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded PARAM.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the PARAM.response after receiving the + * PARAM.request. This can be done in the call back. + */ + int (*param_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_param_request_t* req); + + /*! A callback for the CONFIG.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded CONFIG.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the CONFIG.response after receiving the + * CONFIG.request. This can be done in the call back. + */ + int (*config_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_config_request_t* req); + + /*! A callback for the START.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded START.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the START.response after the client has received the + * first subframe indication from FAPI. + */ + int (*start_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_start_request_t* req); + + /*! A callback for the STOP.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded STOP.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the STOP.response after receiving the + * STOP.request. This can be done in the call back. + */ + int (*stop_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_stop_request_t* req); + + /*! A callback for the MEASUREMENT.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded MEASUREMENT.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the MEASUREMENT.response after receiving the + * MEASUREMENT.request. This can be done in the call back. + */ + int (*measurement_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_measurement_request_t* req); + + /*! A callback for the RSSI.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded RSSI.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the RSSI.response after receiving the + * RSSI.request. This can be done in the call back. + */ + int (*rssi_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_rssi_request_t* req); + + /*! A callback for the CELL_SEARCH.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded CELL_SEARCH.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the CELL_SEARCH.response after receiving the + * CELL_SEARCH.request. This can be done in the call back. + */ + int (*cell_search_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_cell_search_request_t* req); + + /*! A callback for the BROADCAST_DETECT.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded BROADCAST_DETECT.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the BROADCAST_DETECT.response after receiving the + * BROADCAST_DETECT.request. This can be done in the call back. + */ + int (*broadcast_detect_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_broadcast_detect_request_t* req); + + /*! A callback for the SYSTEM_INFORMATION_SCHEDULE.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded SYSTEM_INFORMATION_SCHEDULE.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the SYSTEM_INFORMATION_SCHEDULE.response after receiving the + * SYSTEM_INFORMATION_SCHEDULE.request. This can be done in the call back. + */ + int (*system_information_schedule_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_system_information_schedule_request_t* req); + + /*! A callback for the SYSTEM_INFORMATION.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded SYSTEM_INFORMATION.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the SYSTEM_INFORMATION.response after receiving the + * SYSTEM_INFORMATION.request. This can be done in the call back. + */ + int (*system_information_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_system_information_request_t* req); + + /*! A callback for the NMM_STOP.request + * \param config A pointer to the pnf configuration + * \param phy A pointer to the pnf phy configuration + * \param req A data structure for the decoded NMM_STOP.request. This will have + * been allocated on the stack + * \return not currently used + * + * The client is expected to send the NMM_STOP.response after receiving the + * NMM_STOP.request. This can be done in the call back. + */ + int (*nmm_stop_req)(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_nmm_stop_request_t* req); + + /*! A callback for any vendor extension messages recevied + * \param config A pointer to the pnf configuration + * \param msg A pointer to the decode P4/P5 message + * \return not current used + */ + int (*vendor_ext)(nfapi_pnf_config_t* config, nfapi_p4_p5_message_header_t* msg); + + /*! A callback to allocate vendor extension message + * \param message_id The message id from the decode P4/P5 message header + * \param msg_size A pointer a the size of the allocated message structure. The callee should set this + * \return A pointer to a allocated P4/P5 message structure + */ + nfapi_p4_p5_message_header_t* (*allocate_p4_p5_vendor_ext)(uint16_t message_id, uint16_t* msg_size); + + /*! A callback to deallocate vendor extension message + * \param header A pointer to an P4/P5 message structure + */ + void (*deallocate_p4_p5_vendor_ext)(nfapi_p4_p5_message_header_t* header); + + + +} nfapi_pnf_config_t; + +/*! Create a pnf configuration + * \return A pointer to a pnf configuration struture + * + * This function will create and initialize a pnf instance. It is expected that + * the client will set the callback and parameters need before calling nfapi_pnf_start + * + * 0 will be returned if it fails. + * + * \code + * nfapi_pnf_config_t* config = nfapi_pnf_config_create(void); + * \endcode + */ +nfapi_pnf_config_t* nfapi_pnf_config_create(void); + +/*! Delete a pnf configuration + * \param config A pointer to a pnf configuraiton + * \return 0 is success, -1 for failure + */ +int nfapi_pnf_config_destroy(nfapi_pnf_config_t* config); + +/*! Start the PNF library. + * \param config A pointer to the pnf configuration + * \return 0 is success, -1 for failure + * + * This function will not return until nfapi_pnf_stop is called + * + * \code + * // Create the pnf config + * nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + * + * // Assumed that the vnf_address and vnf_port are provided over the P9 interface + * config->vnf_ip_addr = vnf_address; + * config->vnf_p5_port = vnf_port; + * + * // Set the required callbacks + * config->pnf_param_req = &pnf_param_request; + * ... + * + * // Call start for the PNF to initiate a connection to the VNF + * nfai_pnf_start(config); + * + * \endcode + */ +int nfapi_pnf_start(nfapi_pnf_config_t* config); + +/*! Stop the PNF library. + * \param config A pointer to the pnf configuration + * \return 0 is success, -1 for failure + * + * This function will cause the nfapi_pnf_start function to return + */ +int nfapi_pnf_stop(nfapi_pnf_config_t* config); + +/*! Send the PNF_PARAM.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_pnf_param_response_t* resp); + +/*! Send the PNF_CONFIG.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_pnf_config_response_t* resp); + +/*! Send the PNF_START.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_pnf_start_response_t* resp); + +/*! Send the PNF_STOP.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_pnf_stop_response_t* resp); + +/*! Send the PARAM.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_param_response_t* resp); + +/*! Send the CONFIG.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_config_response_t* resp); + +/*! Send the START.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_start_response_t* resp); + +/*! Send the STOP.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_stop_response_t* resp); + +/*! Send the MEASUREMENT.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_measurement_resp(nfapi_pnf_config_t* config, nfapi_measurement_response_t* resp); + +/*! Send the RSSI.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_rssi_resp(nfapi_pnf_config_t* config, nfapi_rssi_response_t* resp); + +/*! Send the RSSI.indication + * \param config A pointer to a pnf configuraiton + * \param ind A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_rssi_ind(nfapi_pnf_config_t* config, nfapi_rssi_indication_t* ind); + +/*! Send the CELL_SEARCH.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_cell_search_resp(nfapi_pnf_config_t* config, nfapi_cell_search_response_t* resp); + +/*! Send the CELL_SEARCH.indication + * \param config A pointer to a pnf configuraiton + * \param ind A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_cell_search_ind(nfapi_pnf_config_t* config, nfapi_cell_search_indication_t* ind); + +/*! Send the BROADCAST_DETECT.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_broadcast_detect_resp(nfapi_pnf_config_t* config, nfapi_broadcast_detect_response_t* resp); + +/*! Send the BROADCAST_DETECT.indication + * \param config A pointer to a pnf configuraiton + * \param ind A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_broadcast_detect_ind(nfapi_pnf_config_t* config, nfapi_broadcast_detect_indication_t* ind); + +/*! Send the SYSTEM_INFORMATION_SCHEDULE.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_system_information_schedule_resp(nfapi_pnf_config_t* config, nfapi_system_information_schedule_response_t* resp); + +/*! Send the SYSTEM_INFORMATION_SCHEDULE.indication + * \param config A pointer to a pnf configuraiton + * \param ind A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_system_information_schedule_ind(nfapi_pnf_config_t* config, nfapi_system_information_schedule_indication_t* ind); + +/*! Send the SYSTEM_INFORMATION.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_system_information_resp(nfapi_pnf_config_t* config, nfapi_system_information_response_t* resp); + +/*! Send the SYSTEM_INFORMATION.indication + * \param config A pointer to a pnf configuraiton + * \param ind A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_system_information_ind(nfapi_pnf_config_t* config, nfapi_system_information_indication_t* ind); + +/*! Send the NMM_STOP.response + * \param config A pointer to a pnf configuraiton + * \param resp A pointer to the message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_nmm_stop_resp(nfapi_pnf_config_t* config, nfapi_nmm_stop_response_t* resp); + +/*! Send a vendor extension message + * \param config A pointer to a pnf configuraiton + * \param msg A pointer to the vendor extention message structure + * \param msg_len The size of the vendor extention message structure + * \return 0 for success, -1 for failure + * + */ +int nfapi_pnf_vendor_extension(nfapi_pnf_config_t* config, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len); + +//-------------------------- + +/*! A subframe buffer structure which can be used by the client to + * to configure the dummy information + */ +typedef struct +{ + uint16_t sfn_sf; + + nfapi_dl_config_request_t* dl_config_req; + nfapi_ul_config_request_t* ul_config_req; + nfapi_hi_dci0_request_t* hi_dci0_req; + nfapi_tx_request_t* tx_req; + nfapi_lbt_dl_config_request_t* lbt_dl_config_req; + +} nfapi_pnf_p7_subframe_buffer_t; + +typedef struct nfapi_pnf_p7_config nfapi_pnf_p7_config_t; + +/*! The nfapi PNF PHY P7 configuration information created using the nfapi_pnf_p7_create function + */ +typedef struct nfapi_pnf_p7_config +{ + /*! A user define callback to override the default memory allocation + * \param size The size of the buffer to allocate + * \return An allocated buffer. 0 in the case of failure + * + * If not set malloc will be used + */ + void* (*malloc)(size_t size); + + /*! A user define callback to override the default memory deallocation + * \param ptr Pointer to a buffer to dellocate + * + * If not set free will be used + */ + void (*free)(void* ptr); + + /*! A user define callback to handle trace from the pnf + * \param level The trace level + * \param message The message string + */ + void (*trace)(nfapi_trace_level_t level, const char* message, ...); + + /*! The PHY id*/ + uint16_t phy_id; + + // remote + /*! The VNF P7 UDP port */ + int remote_p7_port; + /*! The VNF P7 UDP address */ + char* remote_p7_addr; + + // local + /*! The PNF P7 UDP port */ + int local_p7_port; + /*! The PNF P7 UDP address */ + char* local_p7_addr; + + /*! Flag to indicate of the pnf should use the P7 checksum */ + uint8_t checksum_enabled; + + /*! The maxium size of a P7 segement. If a message is large that this it + * will be segemented */ + uint16_t segment_size; + + /*! The dummy subframe buffer structure that should be used in case there + * are no 'valid' subframe messages */ + nfapi_pnf_p7_subframe_buffer_t dummy_subframe; + + /*! Configuration options for the p7 pack unpack functions*/ + nfapi_p7_codec_config_t codec_config; + + /*! Optional userdata that will be passed back in the callbacks*/ + void* user_data; + + // tdb : if these should be public + uint16_t subframe_buffer_size; + uint8_t timing_info_mode_periodic; // 0:false 1:true + uint8_t timing_info_mode_aperiodic; // 0:false 1:true + uint8_t timing_info_period; // 1..225 in subframes + + /*! A callback for the DL_CONFIG.request + * \param config A poiner to the PNF P7 config + * \param req A pointer to the dl config request message structure + * \return not currently used + */ + int (*dl_config_req)(nfapi_pnf_p7_config_t* config, nfapi_dl_config_request_t* req); + + /*! A callback for the UL_CONFIG.request + * \param config A poiner to the PNF P7 config + * \param req A pointer to the ul config request message structure + * \return not currently used + */ + int (*ul_config_req)(nfapi_pnf_p7_config_t* config, nfapi_ul_config_request_t* req); + + /*! A callback for the HI_DCI0.request + * \param config A poiner to the PNF P7 config + * \param req A pointer to the hi dci0 request message structure + * \return not currently used + */ + int (*hi_dci0_req)(nfapi_pnf_p7_config_t* config, nfapi_hi_dci0_request_t* req); + + /*! A callback for the TX_REQ.request + * \param config A poiner to the PNF P7 config + * \param req A pointer to the tx request message structure + * \return not currently used + * + * The TX request contains pointers to the downlink PDUs to be sent. In the case that the FAPI interface + * will 'keep' the pointers until they are transmitted the callee should set the pointers in the req to 0 + * and then use the p7 codec config free function to release the pdu's when appropriate. + */ + int (*tx_req)(nfapi_pnf_p7_config_t* config, nfapi_tx_request_t* req); + + /*! A callback for the LBT_DL_CONFIG.request + * \param config A poiner to the PNF P7 config + * \param req A pointer to the lbt dl request message structure + * \return not currently used + */ + int (*lbt_dl_config_req)(nfapi_pnf_p7_config_t* config, nfapi_lbt_dl_config_request_t* req); + + /*! A callback for vendor extension messages + * \param config A poiner to the PNF P7 config + * \param msg A pointer to a decode vendor extention message + * \return not currently used + */ + int (*vendor_ext)(nfapi_pnf_p7_config_t* config, nfapi_p7_message_header_t* msg); + + /*! A callback to allocate vendor extension message + * \param message_id The vendor extention message id from the decode message header + * \param msg_size A pointer to size of the allocate vendor extention message. Set by the callee + * \return A pointer to an allocated vendor extention message structure. 0 if failed + * + * + */ + nfapi_p7_message_header_t* (*allocate_p7_vendor_ext)(uint16_t message_id, uint16_t* msg_size); + + /*! A callback to deallocate vendor extension message + * \param header A pointer to a p7 vendor extention message + */ + void (*deallocate_p7_vendor_ext)(nfapi_p7_message_header_t* header); + + + +} nfapi_pnf_p7_config_t; + +/*! Create and initialise a nfapi_pnf_p7_config structure + * \return A pointer to a PNF P7 config structure + */ +nfapi_pnf_p7_config_t* nfapi_pnf_p7_config_create(void); + +/*! Delete an nfapi_pnf_p7_config structure + * \param config + */ +int nfapi_pnf_p7_config_destroy(nfapi_pnf_p7_config_t* config); + + +/*! Start the PNF P7 library. + * \param config A pointer to a PNF P7 config + * \return 0 means success, -1 means failure + * + * This function will not return until nfapi_pnf_p7_stop is called. + */ +int nfapi_pnf_p7_start(nfapi_pnf_p7_config_t* config); + +/*! Stop the PNF P7 library. + * \param config A pointer to a PNF P7 config + * \return 0 means success, -1 means failure + * + * This function will cause the nfapi_pnf_p7_start to return + */ +int nfapi_pnf_p7_stop(nfapi_pnf_p7_config_t* config); + +/*! Subframe indication + * \param config A pointer to a PNF P7 config + * \param phy_id The phy_id for the phy instance + * \param sfn_sf The SFN and SF in the format of FAPI + * \return 0 means success, -1 means failure + * + * The client should call the subframe indication every 1ms. The PNF will + * respond by invoking the pnf p7 subframe callbacks with the messages from the subframe buffer + * + * If messages are not in the subframe buffer, they dummy subframe messages will be sent + */ +int nfapi_pnf_p7_subframe_ind(nfapi_pnf_p7_config_t* config, uint16_t phy_id, uint16_t sfn_sf); + +/*! Send the HARQ.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the harq indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_harq_ind(nfapi_pnf_p7_config_t* config, nfapi_harq_indication_t* ind); + +/*! Send the CRC.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the crc indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_crc_indication_t* ind); + +/*! Send the RX.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the rx indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_rx_ind(nfapi_pnf_p7_config_t* config, nfapi_rx_indication_t* ind); + +/*! Send the RACH.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the rach indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_rach_indication_t* ind); + +/*! Send the SRS.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the srs indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_srs_indication_t* ind); + +/*! Send the SR.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the sr indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_sr_ind(nfapi_pnf_p7_config_t* config, nfapi_sr_indication_t* ind); + +/*! Send the CQI.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the cqi indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_cqi_ind(nfapi_pnf_p7_config_t* config, nfapi_cqi_indication_t* ind); + +/*! Send the LBT_DL.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the lbt dl indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_lbt_dl_ind(nfapi_pnf_p7_config_t* config, nfapi_lbt_dl_indication_t* ind); + +/*! Send the NB_HARQ.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the lbt dl indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_nb_harq_ind(nfapi_pnf_p7_config_t* config, nfapi_nb_harq_indication_t* ind); + +/*! Send the NRACH.indication + * \param config A pointer to a PNF P7 config + * \param ind A pointer to the lbt dl indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_nrach_ind(nfapi_pnf_p7_config_t* config, nfapi_nrach_indication_t* ind); + + +/*! Send a vendor exntesion message + * \param config A pointer to a PNF P7 config + * \param msg A pointer to the lbt dl indication message structure + * \return 0 means success, -1 means failure + */ +int nfapi_pnf_p7_vendor_extension(nfapi_pnf_p7_config_t* config, nfapi_p7_message_header_t* msg); + +#if defined(__cplusplus) +} +#endif + +#endif // _NFAPI_PNF_INTERFACE_H_ diff --git a/nfapi/open-nFAPI/pnf/src/pnf.c b/nfapi/open-nFAPI/pnf/src/pnf.c new file mode 100644 index 0000000000000000000000000000000000000000..d0a7fa6fd12140dd38ab66c1f866ec8d9abe3d09 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/src/pnf.c @@ -0,0 +1,1598 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <netinet/sctp.h> +#include <netdb.h> +#include <arpa/inet.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> + +#include "pnf.h" + +#define MAX_SCTP_STREAMS 16 + +void nfapi_pnf_phy_config_delete_all(nfapi_pnf_config_t* config) +{ + nfapi_pnf_phy_config_t* curr = config->phys; + while(curr != 0) + { + nfapi_pnf_phy_config_t* to_delete = curr; + curr = curr->next; + free(to_delete); + } + + config->phys = 0; +} + +void nfapi_pnf_phy_config_add(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy) +{ + phy->next = config->phys; + config->phys = phy; +} + +nfapi_pnf_phy_config_t* nfapi_pnf_phy_config_find(nfapi_pnf_config_t* config, uint16_t phy_id) +{ + nfapi_pnf_phy_config_t* curr = config->phys; + while(curr != 0) + { + if(curr->phy_id == phy_id) + return curr; + + curr = curr->next; + } + return 0; +} + +void pnf_handle_pnf_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_pnf_param_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_PARAM.request received\n"); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(nfapi_pnf_param_request_t), &pnf->_public.codec_config) >= 0) + { + if(pnf->_public.state == NFAPI_PNF_IDLE) + { + if(pnf->_public.pnf_param_req) + { + (pnf->_public.pnf_param_req)(&pnf->_public, &req); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in IDLE state\n", __FUNCTION__); + + nfapi_pnf_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_pnf_param_resp(&pnf->_public, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + +void pnf_handle_pnf_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + + + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_pnf_config_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_CONFIG.request received\n"); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) + { + // ensure correct state + if(pnf->_public.state != NFAPI_PNF_RUNNING) + { + // delete the phy records + nfapi_pnf_phy_config_delete_all(&pnf->_public); + + // create the phy records + if (req.pnf_phy_rf_config.tl.tag == NFAPI_PNF_PHY_RF_TAG) + { + int i = 0; + for(i = 0; i < req.pnf_phy_rf_config.number_phy_rf_config_info; ++i) + { + nfapi_pnf_phy_config_t* phy = (nfapi_pnf_phy_config_t*)malloc(sizeof(nfapi_pnf_phy_config_t)); + memset(phy, 0, sizeof(nfapi_pnf_phy_config_t)); + + phy->state = NFAPI_PNF_PHY_IDLE; + phy->phy_id = req.pnf_phy_rf_config.phy_rf_config[i].phy_id; + + nfapi_pnf_phy_config_add(&(pnf->_public), phy); + } + } + + if(pnf->_public.pnf_config_req) + { + (pnf->_public.pnf_config_req)(&(pnf->_public), &req); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: PNF not in correct state: %d\n", __FUNCTION__, pnf->_public.state); + + nfapi_pnf_config_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_pnf_config_resp(&(pnf->_public), &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + +void pnf_handle_pnf_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_pnf_start_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_START.request Received\n"); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) + { + if(pnf->_public.state == NFAPI_PNF_CONFIGURED) + { + if(pnf->_public.pnf_start_req) + { + (pnf->_public.pnf_start_req)(&(pnf->_public), &req); + } + } + else + { + nfapi_pnf_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_START_RESPONSE; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_pnf_start_resp(&(pnf->_public), &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + +void pnf_handle_pnf_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_pnf_stop_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF_STOP.request Received\n"); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &pnf->_public.codec_config) >= 0) + { + if(pnf->_public.state == NFAPI_PNF_RUNNING) + { + if(pnf->_public.pnf_stop_req) + { + (pnf->_public.pnf_stop_req)(&(pnf->_public), &req); + } + } + else + { + nfapi_pnf_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_STOP_RESPONSE; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_pnf_stop_resp(&(pnf->_public), &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + +void pnf_handle_param_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_param_request_t req; + + nfapi_pnf_config_t* config = &(pnf->_public); + + NFAPI_TRACE(NFAPI_TRACE_INFO, "PARAM.request received\n"); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state == NFAPI_PNF_PHY_IDLE) + { + if(config->param_req) + { + (config->param_req)(config, phy, &req); + } + } + else + { + nfapi_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PARAM_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_param_resp(config, &resp); + } + } + else + { + nfapi_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PARAM_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_CONFIG; + nfapi_pnf_param_resp(config, &resp); + } + + } + else + { + nfapi_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PARAM_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_param_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + + } +} + +void pnf_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_config_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "CONFIG.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state != NFAPI_PNF_PHY_RUNNING) + { + if(config->config_req) + { + (config->config_req)(config, phy, &req); + } + } + else + { + nfapi_config_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_CONFIG_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_config_resp(config, &resp); + } + } + else + { + nfapi_config_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_CONFIG_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_CONFIG; + nfapi_pnf_config_resp(config, &resp); + } + } + else + { + nfapi_config_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_CONFIG_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_config_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + +void pnf_handle_start_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_start_request_t req; + + nfapi_pnf_config_t* config = &(pnf->_public); + + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() START.request received state:%d\n", __FUNCTION__, config->state); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state != NFAPI_PNF_PHY_RUNNING) + { + if(config->start_req) + { + (config->start_req)(config, phy, &req); + } + } + else + { + nfapi_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_START_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_start_resp(config, &resp); + } + } + else + { + nfapi_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_START_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_CONFIG; + nfapi_pnf_start_resp(config, &resp); + } + } + else + { + nfapi_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_START_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_start_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + + } +} + +void pnf_handle_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_stop_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "STOP.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state != NFAPI_PNF_PHY_RUNNING) + { + if(config->stop_req) + { + (config->stop_req)(config, phy, &req); + } + } + else + { + nfapi_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_STOP_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_stop_resp(config, &resp); + } + } + else + { + nfapi_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_STOP_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_CONFIG; + nfapi_pnf_stop_resp(config, &resp); + } + } + else + { + nfapi_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_STOP_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_stop_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + + } +} + +void pnf_handle_measurement_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + // ensure it's valid + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_measurement_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "MEASUREMENT.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state != NFAPI_PNF_PHY_RUNNING) + { + if(config->measurement_req) + { + (config->measurement_req)(config, phy, &req); + } + } + else + { + nfapi_measurement_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_MEASUREMENT_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_measurement_resp(config, &resp); + } + } + else + { + nfapi_measurement_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_MEASUREMENT_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_CONFIG; + nfapi_pnf_measurement_resp(config, &resp); + } + } + else + { + nfapi_measurement_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_MEASUREMENT_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_measurement_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + +void pnf_handle_rssi_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + + + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_rssi_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "RSSI.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state == NFAPI_PNF_PHY_RUNNING) + { + if(config->rssi_req) + { + (config->rssi_req)(config, phy, &req); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_rssi_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_CONFIG; + nfapi_pnf_rssi_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_rssi_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + + } +} + +void pnf_handle_cell_search_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_cell_search_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "CELL_SEARCH.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state == NFAPI_PNF_PHY_RUNNING) + { + if(config->cell_search_req) + { + (config->cell_search_req)(config, phy, &req); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_cell_search_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_CONFIG; + nfapi_pnf_cell_search_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_cell_search_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } + +} + +void pnf_handle_broadcast_detect_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_broadcast_detect_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "BROADCAST_DETECT.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state == NFAPI_PNF_PHY_RUNNING) + { + if(config->broadcast_detect_req) + { + (config->broadcast_detect_req)(config, phy, &req); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_broadcast_detect_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_CONFIG; + nfapi_pnf_broadcast_detect_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_broadcast_detect_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + + } +} + +void pnf_handle_system_information_schedule_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_system_information_schedule_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "SYSTEM_INFORMATION_SCHEDULE.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state == NFAPI_PNF_PHY_RUNNING) + { + if(config->system_information_schedule_req) + { + (config->system_information_schedule_req)(config, phy, &req); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_system_information_schedule_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_CONFIG; + nfapi_pnf_system_information_schedule_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_system_information_schedule_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + +void pnf_handle_system_information_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_system_information_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "SYSTEM_INFORMATION.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state == NFAPI_PNF_PHY_RUNNING) + { + if(config->system_information_req) + { + (config->system_information_req)(config, phy, &req); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_system_information_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_CONFIG; + nfapi_pnf_system_information_resp(config, &resp); + } + } + else + { + 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_MSG_INVALID_STATE; + nfapi_pnf_system_information_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } + +} + +void pnf_handle_nmm_stop_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_nmm_stop_request_t req; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "NMM_STOP.request received\n"); + + nfapi_pnf_config_t* config = &(pnf->_public); + + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &req, sizeof(req), &config->codec_config) >= 0) + { + if(config->state == NFAPI_PNF_RUNNING) + { + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); + if(phy) + { + if(phy->state != NFAPI_PNF_PHY_RUNNING) + { + if(config->nmm_stop_req) + { + (config->nmm_stop_req)(config, phy, &req); + } + } + else + { + nfapi_nmm_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_NMM_STOP_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_nmm_stop_resp(config, &resp); + } + } + else + { + nfapi_nmm_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_NMM_STOP_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_CONFIG; + nfapi_pnf_nmm_stop_resp(config, &resp); + } + } + else + { + nfapi_nmm_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_NMM_STOP_RESPONSE; + resp.header.phy_id = req.header.phy_id; + resp.error_code = NFAPI_MSG_INVALID_STATE; + nfapi_pnf_nmm_stop_resp(config, &resp); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(req.vendor_extension) + pnf->_public.codec_config.deallocate(req.vendor_extension); + } +} + + +void pnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_t* pnf, uint16_t message_id) +{ + if (pRecvMsg == NULL || pnf == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_pnf_config_t* config = &(pnf->_public); + + if(config->allocate_p4_p5_vendor_ext) + { + uint16_t msg_size; + nfapi_p4_p5_message_header_t* msg = config->allocate_p4_p5_vendor_ext(message_id, &msg_size); + + if(msg == 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n"); + return; + } + + + int unpack_result = nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &config->codec_config); + + if(unpack_result == 0) + { + if(config->vendor_ext) + config->vendor_ext(config, msg); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + if(config->deallocate_p4_p5_vendor_ext) + config->deallocate_p4_p5_vendor_ext(msg); + + } + } +} + + + +void pnf_handle_p5_message(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) +{ + nfapi_p4_p5_message_header_t messageHeader; + + // validate the input params + if(pRecvMsg == NULL || recvMsgLen < NFAPI_HEADER_LENGTH) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return; + } + + // unpack the message header + if (nfapi_p5_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p4_p5_message_header_t), &pnf->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n"); + return; + } + + switch (messageHeader.message_id) + { + case NFAPI_PNF_PARAM_REQUEST: + pnf_handle_pnf_param_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_PNF_CONFIG_REQUEST: + pnf_handle_pnf_config_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_PNF_START_REQUEST: + pnf_handle_pnf_start_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_PNF_STOP_REQUEST: + pnf_handle_pnf_stop_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_PARAM_REQUEST: + pnf_handle_param_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_CONFIG_REQUEST: + pnf_handle_config_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_START_REQUEST: + pnf_handle_start_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_STOP_REQUEST: + pnf_handle_stop_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_MEASUREMENT_REQUEST: + pnf_handle_measurement_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_RSSI_REQUEST: + pnf_handle_rssi_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_CELL_SEARCH_REQUEST: + pnf_handle_cell_search_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_BROADCAST_DETECT_REQUEST: + pnf_handle_broadcast_detect_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST: + pnf_handle_system_information_schedule_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_SYSTEM_INFORMATION_REQUEST: + pnf_handle_system_information_request(pnf, pRecvMsg, recvMsgLen); + break; + + case NFAPI_NMM_STOP_REQUEST: + pnf_handle_nmm_stop_request(pnf, pRecvMsg, recvMsgLen); + break; + + default: + { + if(messageHeader.message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + messageHeader.message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + pnf_handle_vendor_extension(pRecvMsg, recvMsgLen, pnf, messageHeader.message_id); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P5 Unknown message ID %d\n", __FUNCTION__, messageHeader.message_id); + } + } + break; + } +} + +int pnf_pack_and_send_p5_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len) +{ + int packed_len = nfapi_p5_message_pack(msg, msg_len, + pnf->tx_message_buffer, + sizeof(pnf->tx_message_buffer), + &pnf->_public.codec_config); + + if (packed_len < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p5_message_pack failed (%d)\n", packed_len); + return -1; + } + + return pnf_send_message(pnf, pnf->tx_message_buffer, packed_len, 0/*msg->stream_id*/); +} + +int pnf_pack_and_send_p4_message(pnf_t* pnf, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len) +{ + int packed_len = nfapi_p4_message_pack(msg, msg_len, + pnf->tx_message_buffer, + sizeof(pnf->tx_message_buffer), + &pnf->_public.codec_config); + + if (packed_len < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p4_message_pack failed (%d)\n", packed_len); + return -1; + } + + return pnf_send_message(pnf, pnf->tx_message_buffer, packed_len, 0/*msg->stream_id*/); +} + + + +int pnf_connect(pnf_t* pnf) +{ + struct sockaddr_in servaddr; + uint8_t socketConnected = 0; + + if(pnf->_public.vnf_ip_addr == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnfIpAddress is null\n"); + return -1; + } + + + (void)memset(&servaddr, 0, sizeof(struct sockaddr_in)); + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Starting P5 PNF connection to VNF at %s:%u\n", pnf->_public.vnf_ip_addr, pnf->_public.vnf_p5_port); + + // todo split the vnf address list. currently only supporting 1 + + struct addrinfo hints, *servinfo; + memset(&hints, 0, sizeof(hints)); + + hints.ai_socktype = SOCK_STREAM; // For SCTP we are only interested in SOCK_STREAM + // todo : allow the client to restrict IPV4 or IPV6 + // todo : randomize which address to connect to? + + char port_str[8]; + snprintf(port_str, sizeof(port_str), "%d", pnf->_public.vnf_p5_port); + if(getaddrinfo(pnf->_public.vnf_ip_addr, port_str, &hints, &servinfo) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to get host (%s) addr info h_errno:%d \n", pnf->_public.vnf_ip_addr, h_errno); + return -1; + } + + struct addrinfo *p = servinfo; + int i = 0; + int connected = 0; + + while(p != NULL && connected == 0) + { + char* family = "Unknown"; + char* address = "Unknown"; + char _addr[128]; + + if(p->ai_family == AF_INET6) + { + family = "IPV6"; + struct sockaddr_in6* addr = (struct sockaddr_in6*)p->ai_addr; + inet_ntop(AF_INET6, &addr->sin6_addr, _addr, sizeof(_addr)); + address = &_addr[0]; + } + else if(p->ai_family == AF_INET) + { + family = "IPV4"; + struct sockaddr_in* addr = (struct sockaddr_in*)p->ai_addr; + address = inet_ntoa(addr->sin_addr); + } + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "Host address info %d Family:%s Address:%s\n", i++, family, address); + + if (pnf->sctp) + { + // open the SCTP socket + if ((pnf->p5_sock = socket(p->ai_family, SOCK_STREAM, IPPROTO_SCTP)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P5 socket errno: %d\n", errno); + freeaddrinfo(servinfo); + return -1; + } + int noDelay; + struct sctp_initmsg initMsg; + + (void)memset(&initMsg, 0, sizeof(struct sctp_initmsg)); + + // configure the socket options + NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF Setting the SCTP_INITMSG\n"); + initMsg.sinit_num_ostreams = 5; //MAX_SCTP_STREAMS; // number of output streams can be greater + initMsg.sinit_max_instreams = 5; //MAX_SCTP_STREAMS; // number of output streams can be greater + if (setsockopt(pnf->p5_sock, IPPROTO_SCTP, SCTP_INITMSG, &initMsg, sizeof(initMsg)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt errno: %d\n", errno); + freeaddrinfo(servinfo); + return -1; + } + noDelay = 1; + if (setsockopt(pnf->p5_sock, IPPROTO_SCTP, SCTP_NODELAY, &noDelay, sizeof(noDelay)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt errno: %d\n", errno); + freeaddrinfo(servinfo); + return -1; + + } + + struct sctp_event_subscribe events; + memset( (void *)&events, 0, sizeof(events) ); + events.sctp_data_io_event = 1; + + if(setsockopt(pnf->p5_sock, SOL_SCTP, SCTP_EVENTS, (const void *)&events, sizeof(events)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt errno: %d\n", errno); + freeaddrinfo(servinfo); + return -1; + } + } + else + { + // Create an IP socket point + if ((pnf->p5_sock = socket(p->ai_family, SOCK_STREAM, IPPROTO_IP)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P5 socket errno: %d\n", errno); + freeaddrinfo(servinfo); + return -1; + } + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "P5 socket created...\n"); + + if (connect(pnf->p5_sock, p->ai_addr, p->ai_addrlen ) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After connect (address:%s port:%d) errno: %d\n", + pnf->_public.vnf_ip_addr, pnf->_public.vnf_p5_port, errno); + + if(errno == EINVAL) + { + freeaddrinfo(servinfo); + return -1; + } + else + { + if(pnf->terminate != 0) + { + freeaddrinfo(servinfo); + return 0; + } + else + { + close(pnf->p5_sock); + sleep(1); + } + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "connect succeeded...\n"); + + connected = 1; + } + + p = p->ai_next; + } + + freeaddrinfo(servinfo); + + // If we have failed to connect return 0 and it is retry + if(connected == 0) + return 0; + + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "After connect loop\n"); + if (pnf->sctp) + { + socklen_t optLen; + struct sctp_status status; + + (void)memset(&status, 0, sizeof(struct sctp_status)); + + // check the connection status + optLen = (socklen_t) sizeof(struct sctp_status); + if (getsockopt(pnf->p5_sock, IPPROTO_SCTP, SCTP_STATUS, &status, &optLen) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After getsockopt errno: %d\n", errno); + return -1; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Association ID = %d\n", status.sstat_assoc_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "Receiver window size = %d\n", status.sstat_rwnd); + NFAPI_TRACE(NFAPI_TRACE_INFO, "In Streams = %d\n", status.sstat_instrms); + NFAPI_TRACE(NFAPI_TRACE_INFO, "Out Streams = %d\n", status.sstat_outstrms); + + socketConnected = 1; + } + } + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "Socket %s\n", socketConnected ? "CONNECTED" : "NOT_CONNECTED"); + return socketConnected; +} + +int pnf_send_message(pnf_t* pnf, uint8_t *msg, uint32_t len, uint16_t stream) +{ + if (pnf->sctp) + { + if (sctp_sendmsg(pnf->p5_sock, msg, len, NULL, 0, 42/*config->sctp_stream_number*/, 0, stream/*P5_STREAM_ID*/, 0, 0) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "sctp_sendmsg failed errno: %d\n", errno); + return -1; + } + } + else + { + if (write(pnf->p5_sock, msg, len) != len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "read failed errno: %d\n", errno); + return -1; + } + } + return 0; +} + + +int pnf_read_dispatch_message(pnf_t* pnf) +{ + int socket_connected = 1; + + // 1. Peek the message header + // 2. If the message is larger than the stack buffer then create a dynamic buffer + // 3. Read the buffer + // 4. Handle the p5 message + + uint32_t header_buffer_size = NFAPI_HEADER_LENGTH; + uint8_t header_buffer[header_buffer_size]; + + uint32_t stack_buffer_size = 32; //should it be the size of then sctp_notificatoin structure + uint8_t stack_buffer[stack_buffer_size]; + + uint8_t* dynamic_buffer = 0; + + uint8_t* read_buffer = &stack_buffer[0]; + uint32_t message_size = 0; + + struct sockaddr_in addr; + socklen_t addr_len = sizeof(addr); + + struct sctp_sndrcvinfo sndrcvinfo; + (void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo)); + + { + int flags = MSG_PEEK; + message_size = sctp_recvmsg(pnf->p5_sock, header_buffer, header_buffer_size, /*(struct sockaddr*)&addr, &addr_len*/ 0, 0, &sndrcvinfo, &flags); + + if(message_size == -1) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to peek sctp message size errno:%d\n", errno); + return 0; + } + + nfapi_p4_p5_message_header_t header; + int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0); + if(unpack_result < 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to unpack p5 message header\n"); + return 0; + } + message_size = header.message_length; + + // now have the size of the mesage + } + + if(message_size > stack_buffer_size) + { + dynamic_buffer = (uint8_t*)malloc(message_size); + + if(dynamic_buffer == NULL) + { + // todo : add error mesage + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size); + return -1; + } + + read_buffer = dynamic_buffer; + } + + { + int flags = 0; + (void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo)); + + int recvmsg_result = sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags); + if(recvmsg_result == -1) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno); + } + else + { + if (flags & MSG_NOTIFICATION) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); + + // todo - handle the events + } + else + { + /* + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n", + pnf->p5_sock, + inet_ntoa(addr.sin_addr), + ntohs(addr.sin_port), + sndrcvinfo.sinfo_assoc_id, + sndrcvinfo.sinfo_stream, + ntohl(sndrcvinfo.sinfo_ppid), + message_size, + flags); + */ + + // handle now if complete message in one or more segments + if ((flags & 0x80) == 0x80) + { + pnf_handle_p5_message(pnf, read_buffer, message_size); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags); + + // assume socket disconnected + NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n"); + socket_connected = 0; + } + + + } + } + } + + if(dynamic_buffer) + { + free(dynamic_buffer); + } + + return socket_connected; + + +} + + +int pnf_message_pump(pnf_t* pnf) +{ + uint8_t socketConnected = 1; + + while(socketConnected && pnf->terminate == 0) + { + fd_set rfds; + int selectRetval = 0; + + // select on a timeout and then get the message + FD_ZERO(&rfds); + FD_SET(pnf->p5_sock, &rfds); + + struct timeval timeout; + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + selectRetval = select(pnf->p5_sock+1, &rfds, NULL, NULL, &timeout); + + if(selectRetval == 0) + { + // timeout + continue; + } + else if (selectRetval == -1 && (errno == EINTR)) + { + // interrupted by signal + NFAPI_TRACE(NFAPI_TRACE_WARN, "P5 Signal Interrupt %d\n", errno); + continue; + } + else if (selectRetval == -1) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "P5 select() failed\n"); + sleep(1); + continue; + } + + if(FD_ISSET(pnf->p5_sock, &rfds)) + { + socketConnected = pnf_read_dispatch_message(pnf); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Why are we here\n"); + } + } + + // Drop back to idle if we have lost connection + pnf->_public.state = NFAPI_PNF_PHY_IDLE; + + + // close the connection and socket + if (close(pnf->p5_sock) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "close(sctpSock) failed errno: %d\n", errno); + } + + return 0; + +} + diff --git a/nfapi/open-nFAPI/pnf/src/pnf_interface.c b/nfapi/open-nFAPI/pnf/src/pnf_interface.c new file mode 100644 index 0000000000000000000000000000000000000000..7310fc0c66c57209bcedac7cc326ab4b19d4229a --- /dev/null +++ b/nfapi/open-nFAPI/pnf/src/pnf_interface.c @@ -0,0 +1,432 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "pnf.h" +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +nfapi_pnf_config_t* nfapi_pnf_config_create() +{ + pnf_t* _this = (pnf_t*)malloc(sizeof(pnf_t)); + + if(_this == 0) + return 0; + + memset(_this, 0, sizeof(pnf_t)); + + _this->sctp = 1; // enable sctp + + _this->_public.vnf_p5_port = NFAPI_P5_SCTP_PORT; + + _this->_public.malloc = &malloc; + _this->_public.free = &free; + + _this->_public.codec_config.allocate = &malloc; + _this->_public.codec_config.deallocate = &free; + + return &(_this->_public); +} + +void nfapi_pnf_config_destory(nfapi_pnf_config_t* config) +{ + free(config); +} + +int nfapi_pnf_start(nfapi_pnf_config_t* config) +{ + // Verify that config is not null + if(config == 0) + return -1; + + // Make sure to set the defined trace function before using NFAPI_TRACE + if(config->trace) + nfapi_trace_g = config->trace; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); + + pnf_t* _this = (pnf_t*)(config); + + while (_this->terminate == 0) + { + int connect_result = pnf_connect(_this); + + if(connect_result > 0) + { + pnf_message_pump(_this); + } + else if(connect_result < 0) + { + return connect_result; + } + + sleep(1); + } + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() terminate=1 - EXITTING............\n", __FUNCTION__); + + return 0; +} + +int nfapi_pnf_stop(nfapi_pnf_config_t* config) +{ + // Verify that config is not null + if(config == 0) + return -1; + + + pnf_t* _this = (pnf_t*)(config); + _this->terminate = 1; + + // todo wait for the pnf to stop before returning + + return 0; +} + +int nfapi_pnf_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_pnf_param_response_t* resp) +{ + // ensure it's valid + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_pnf_param_response_t)); +} + +int nfapi_pnf_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_pnf_config_response_t* resp) +{ + // ensure it's valid + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + if(resp->error_code == NFAPI_MSG_OK) + { + config->state = NFAPI_PNF_CONFIGURED; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_pnf_config_response_t)); +} + +int nfapi_pnf_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_pnf_start_response_t* resp) +{ + // ensure it's valid + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + if(resp->error_code == NFAPI_MSG_OK) + { + config->state = NFAPI_PNF_RUNNING; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_pnf_start_response_t)); +} + +int nfapi_pnf_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_pnf_stop_response_t* resp) +{ + // ensure it's valid + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + if(resp->error_code == NFAPI_MSG_OK) + { + config->state = NFAPI_PNF_CONFIGURED; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_pnf_stop_response_t)); +} + +int nfapi_pnf_param_resp(nfapi_pnf_config_t* config, nfapi_param_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_param_response_t)); +} + +int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_config_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, resp->header.phy_id); + + if(phy) + { + if(resp->error_code == NFAPI_MSG_OK) + { + phy->state = NFAPI_PNF_PHY_CONFIGURED; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: unknow phy id %d\n", __FUNCTION__, resp->header.phy_id); + return -1; + } + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_config_response_t)); +} + +int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_start_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, resp->header.phy_id); + if(phy) + { + if(resp->error_code == NFAPI_MSG_OK) + { + phy->state = NFAPI_PNF_PHY_RUNNING; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: unknown phy id %d\n", __FUNCTION__, resp->header.phy_id); + return -1; + } + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_start_response_t)); +} + +int nfapi_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_stop_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, resp->header.phy_id); + if(phy) + { + if(resp->error_code == NFAPI_MSG_OK) + { + phy->state = NFAPI_PNF_PHY_CONFIGURED; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: unknow phy id %d\n", __FUNCTION__, resp->header.phy_id); + return -1; + } + + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_stop_response_t)); +} + +int nfapi_pnf_measurement_resp(nfapi_pnf_config_t* config, nfapi_measurement_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_measurement_response_t)); +} + + +int nfapi_pnf_rssi_resp(nfapi_pnf_config_t* config, nfapi_rssi_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(resp->header), sizeof(nfapi_rssi_response_t)); +} + +int nfapi_pnf_rssi_ind(nfapi_pnf_config_t* config, nfapi_rssi_indication_t* ind) +{ + if (config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(ind->header), sizeof(nfapi_rssi_indication_t)); +} +int nfapi_pnf_cell_search_resp(nfapi_pnf_config_t* config, nfapi_cell_search_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Send CELL_SEARCH.response\n"); + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(resp->header), sizeof(nfapi_cell_search_response_t)); +} +int nfapi_pnf_cell_search_ind(nfapi_pnf_config_t* config, nfapi_cell_search_indication_t* ind) +{ + if (config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(ind->header), sizeof(nfapi_cell_search_indication_t)); +} +int nfapi_pnf_broadcast_detect_resp(nfapi_pnf_config_t* config, nfapi_broadcast_detect_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(resp->header), sizeof(nfapi_broadcast_detect_response_t)); +} +int nfapi_pnf_broadcast_detect_ind(nfapi_pnf_config_t* config, nfapi_broadcast_detect_indication_t* ind) +{ + if (config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(ind->header), sizeof(nfapi_broadcast_detect_indication_t)); +} +int nfapi_pnf_system_information_schedule_resp(nfapi_pnf_config_t* config, nfapi_system_information_schedule_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1;; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(resp->header), sizeof(nfapi_system_information_schedule_response_t)); +} + +int nfapi_pnf_system_information_schedule_ind(nfapi_pnf_config_t* config, nfapi_system_information_schedule_indication_t* ind) +{ + if (config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(ind->header), sizeof(nfapi_system_information_schedule_indication_t)); +} +int nfapi_pnf_system_information_resp(nfapi_pnf_config_t* config, nfapi_system_information_response_t* resp) +{ + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(resp->header), sizeof(nfapi_system_information_response_t)); +} + +int nfapi_pnf_system_information_ind(nfapi_pnf_config_t* config, nfapi_system_information_indication_t* ind) +{ + if (config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(ind->header), sizeof(nfapi_system_information_indication_t)); +} +int nfapi_pnf_nmm_stop_resp(nfapi_pnf_config_t* config, nfapi_nmm_stop_response_t* resp) +{ + // ensure it's valid + if (config == NULL || resp == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p4_message(_this, &(resp->header), sizeof(nfapi_nmm_stop_request_t)); +} + +int nfapi_pnf_vendor_extension(nfapi_pnf_config_t* config, nfapi_p4_p5_message_header_t* msg, uint32_t msg_len) +{ + // ensure it's valid + if (config == NULL || msg == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return -1; + } + + pnf_t* _this = (pnf_t*)(config); + + return pnf_pack_and_send_p5_message(_this, msg, msg_len); +} + diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7.c b/nfapi/open-nFAPI/pnf/src/pnf_p7.c new file mode 100644 index 0000000000000000000000000000000000000000..02b828d382bf1a9dfc39cea7fe48544e56ed2000 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7.c @@ -0,0 +1,1769 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <sys/select.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <pthread.h> +#include <stdio.h> + +#include "pnf_p7.h" + +#define FAPI2_IP_DSCP 0 + +extern uint16_t sf_ahead; +//uint16_t sf_ahead=4; + +void add_sf(uint16_t *frameP, uint16_t *subframeP, int offset) +{ + *frameP = *frameP + ((*subframeP + offset) / 10); + + *subframeP = ((*subframeP + offset) % 10); +} + +void subtract_sf(uint16_t *frameP, uint16_t *subframeP, int offset) +{ + if (*subframeP < offset) + { + *frameP = (*frameP+1024-1)%1024; + } + *subframeP = (*subframeP+10-offset)%10; +} + +uint16_t sfnsf_add_sf(uint16_t sfnsf, int offset) +{ + uint16_t new_sfnsf; + uint16_t sfn = NFAPI_SFNSF2SFN(sfnsf); + uint16_t sf = NFAPI_SFNSF2SF(sfnsf); + + //printf("%s() sfn:%u sf:%u\n", __FUNCTION__, sfn, sf); + add_sf(&sfn, &sf, offset); + + new_sfnsf = sfn<<4|sf; + + //printf("%s() sfn:%u sf:%u offset:%d sfnsf:%d(DEC:%d) new:%d(DEC:%d)\n", __FUNCTION__, sfn, sf, offset, sfnsf, NFAPI_SFNSF2DEC(sfnsf), new_sfnsf, NFAPI_SFNSF2DEC(new_sfnsf)); + + return new_sfnsf; +} + +uint16_t sfnsf_subtract_sf(uint16_t sfnsf, int offset) +{ + uint16_t new_sfnsf; + uint16_t sfn = NFAPI_SFNSF2SFN(sfnsf); + uint16_t sf = NFAPI_SFNSF2SF(sfnsf); + + //printf("%s() sfn:%u sf:%u\n", __FUNCTION__, sfn, sf); + subtract_sf(&sfn, &sf, offset); + + new_sfnsf = sfn<<4|sf; + + //printf("%s() offset:%d sfnsf:%d(DEC:%d) new:%d(DEC:%d)\n", __FUNCTION__, offset, sfnsf, NFAPI_SFNSF2DEC(sfnsf), new_sfnsf, NFAPI_SFNSF2DEC(new_sfnsf)); + + return new_sfnsf; +} + +uint32_t pnf_get_current_time_hr(void) +{ + struct timeval now; + (void)gettimeofday(&now, NULL); + uint32_t time_hr = TIME2TIMEHR(now); + return time_hr; +} + +void* pnf_p7_malloc(pnf_p7_t* pnf_p7, size_t size) +{ + if(pnf_p7->_public.malloc) + { + return (pnf_p7->_public.malloc)(size); + } + else + { + return calloc(1, size); + } +} +void pnf_p7_free(pnf_p7_t* pnf_p7, void* ptr) +{ + if(pnf_p7->_public.free) + { + return (pnf_p7->_public.free)(ptr); + } + else + { + return free(ptr); + } +} + +// todo : for now these just malloc/free need to move to a memory cache +nfapi_dl_config_request_t* allocate_nfapi_dl_config_request(pnf_p7_t* pnf_p7) +{ + void *ptr= pnf_p7_malloc(pnf_p7, sizeof(nfapi_dl_config_request_t)); + //printf("%s() ptr:%p\n", __FUNCTION__, ptr); + return ptr; +} + +void deallocate_nfapi_dl_config_request(nfapi_dl_config_request_t* req, pnf_p7_t* pnf_p7) +{ + //printf("%s() SFN/SF:%d %s req:%p pdu_list:%p\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pnf_p7->_public.codec_config.deallocate ? "DEALLOCATE" : "FREE", req, req->dl_config_request_body.dl_config_pdu_list); + if(pnf_p7->_public.codec_config.deallocate) + { + (pnf_p7->_public.codec_config.deallocate)(req->dl_config_request_body.dl_config_pdu_list); + } + else + { + free(req->dl_config_request_body.dl_config_pdu_list); + } + req->dl_config_request_body.dl_config_pdu_list=0; + + pnf_p7_free(pnf_p7, req); +} + +nfapi_ul_config_request_t* allocate_nfapi_ul_config_request(pnf_p7_t* pnf_p7) +{ + void *ptr= pnf_p7_malloc(pnf_p7, sizeof(nfapi_ul_config_request_t)); + //printf("%s() ptr:%p\n", __FUNCTION__, ptr); + return ptr; +} + +void deallocate_nfapi_ul_config_request(nfapi_ul_config_request_t* req, pnf_p7_t* pnf_p7) +{ + //printf("%s() SFN/SF:%d %s req:%p pdu_list:%p\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pnf_p7->_public.codec_config.deallocate ? "DEALLOCATE" : "FREE", req, req->ul_config_request_body.ul_config_pdu_list); + if(pnf_p7->_public.codec_config.deallocate) + { + (pnf_p7->_public.codec_config.deallocate)(req->ul_config_request_body.ul_config_pdu_list); + } + else + { + free(req->ul_config_request_body.ul_config_pdu_list); + } + req->ul_config_request_body.ul_config_pdu_list=0; + + pnf_p7_free(pnf_p7, req); +} + +nfapi_hi_dci0_request_t* allocate_nfapi_hi_dci0_request(pnf_p7_t* pnf_p7) +{ + return pnf_p7_malloc(pnf_p7, sizeof(nfapi_hi_dci0_request_t)); +} + +void deallocate_nfapi_hi_dci0_request(nfapi_hi_dci0_request_t* req, pnf_p7_t* pnf_p7) +{ + //printf("%s() SFN/SF:%d %s req:%p pdu_list:%p\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pnf_p7->_public.codec_config.deallocate ? "DEALLOCATE" : "FREE", req, req->hi_dci0_request_body.hi_dci0_pdu_list); + if(pnf_p7->_public.codec_config.deallocate) + { + (pnf_p7->_public.codec_config.deallocate)(req->hi_dci0_request_body.hi_dci0_pdu_list); + } + else + { + free(req->hi_dci0_request_body.hi_dci0_pdu_list); + } + req->hi_dci0_request_body.hi_dci0_pdu_list=0; + + pnf_p7_free(pnf_p7, req); +} + +nfapi_tx_request_t* allocate_nfapi_tx_request(pnf_p7_t* pnf_p7) +{ + return pnf_p7_malloc(pnf_p7, sizeof(nfapi_tx_request_t)); +} + +void deallocate_nfapi_tx_request(nfapi_tx_request_t* req, pnf_p7_t* pnf_p7) +{ + int i = 0; + + //printf("%s() SFN/SF:%d %s req:%p pdu[0]:data:%p\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pnf_p7->_public.codec_config.deallocate ? "DEALLOCATE" : "FREE", req, req->tx_request_body.tx_pdu_list[i].segments[0].segment_data); + + for(i = 0; i < req->tx_request_body.number_of_pdus; ++i) + { + void* data = req->tx_request_body.tx_pdu_list[i].segments[0].segment_data; + + if(pnf_p7->_public.codec_config.deallocate) + { + (pnf_p7->_public.codec_config.deallocate)(data); + } + else + { + free(data); + } + data=0; + } + + + if(pnf_p7->_public.codec_config.deallocate) + { + (pnf_p7->_public.codec_config.deallocate)(req->tx_request_body.tx_pdu_list); + } + else + { + free(req->tx_request_body.tx_pdu_list); + } + req->tx_request_body.tx_pdu_list=0; + + pnf_p7_free(pnf_p7, req); +} + +nfapi_lbt_dl_config_request_t* allocate_nfapi_lbt_dl_config_request(pnf_p7_t* pnf_p7) +{ + return pnf_p7_malloc(pnf_p7, sizeof(nfapi_lbt_dl_config_request_t)); +} + +void deallocate_nfapi_lbt_dl_config_request(nfapi_lbt_dl_config_request_t* req, pnf_p7_t* pnf_p7) +{ + if(pnf_p7->_public.codec_config.deallocate) + { + (pnf_p7->_public.codec_config.deallocate)(req->lbt_dl_config_request_body.lbt_dl_config_req_pdu_list); + } + else + { + free(req->lbt_dl_config_request_body.lbt_dl_config_req_pdu_list); + } + req->lbt_dl_config_request_body.lbt_dl_config_req_pdu_list=0; + + pnf_p7_free(pnf_p7, req); +} + +pnf_p7_rx_message_t* pnf_p7_rx_reassembly_queue_add_segment(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, uint32_t rx_hr_time, uint16_t sequence_number, uint16_t segment_number, uint8_t m, uint8_t* data, uint16_t data_len) +{ + pnf_p7_rx_message_t* msg = 0; + // attempt to find a entry for this segment + pnf_p7_rx_message_t* iterator = queue->msg_queue; + while(iterator != 0) + { + if(iterator->sequence_number == sequence_number) + { + msg = iterator; + break; + } + + iterator = iterator->next; + } + + // if found then copy data to message + if(msg != 0) + { + + msg->segments[segment_number].buffer = (uint8_t*)pnf_p7_malloc(pnf_p7, data_len); + memcpy(msg->segments[segment_number].buffer, data, data_len); + msg->segments[segment_number].length = data_len; + + msg->num_segments_received++; + + // set the segement number if we have the last segment + if(m == 0) + msg->num_segments_expected = segment_number + 1; + } + // else add new rx message entry + else + { + // create a new message + msg = (pnf_p7_rx_message_t*)(pnf_p7_malloc(pnf_p7, sizeof(pnf_p7_rx_message_t))); + memset(msg, 0, sizeof(pnf_p7_rx_message_t)); + + msg->sequence_number = sequence_number; + msg->num_segments_expected = m ? 255 : segment_number + 1; + msg->num_segments_received = 1; + msg->rx_hr_time = rx_hr_time; + + msg->segments[segment_number].buffer = (uint8_t*)pnf_p7_malloc(pnf_p7, data_len); + memcpy(msg->segments[segment_number].buffer, data, data_len); + msg->segments[segment_number].length = data_len; + + // place the message at the head of the queue + msg->next = queue->msg_queue; + queue->msg_queue = msg; + } + + return msg; +} + +void pnf_p7_rx_reassembly_queue_remove_msg(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, pnf_p7_rx_message_t* msg) +{ + // remove message if it has the same sequence number + pnf_p7_rx_message_t* iterator = queue->msg_queue; + pnf_p7_rx_message_t* previous = 0; + + while(iterator != 0) + { + if(iterator->sequence_number == msg->sequence_number) + { + if(previous == 0) + { + queue->msg_queue = iterator->next; + } + else + { + previous->next = iterator->next; + } + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Deleting reassembly message\n"); + // delete the message + uint16_t i; + for(i = 0; i < 128; ++i) + { + if(iterator->segments[i].buffer) + pnf_p7_free(pnf_p7, iterator->segments[i].buffer); + } + pnf_p7_free(pnf_p7, iterator); + + break; + } + + previous = iterator; + iterator = iterator->next; + } +} + +void pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7_t* pnf_p7, pnf_p7_rx_reassembly_queue_t* queue, uint32_t rx_hr_time, uint32_t delta) +{ + // remove all messages that are too old + pnf_p7_rx_message_t* iterator = queue->msg_queue; + pnf_p7_rx_message_t* previous = 0; + + while(iterator != 0) + { + if(rx_hr_time - iterator->rx_hr_time > delta) + { + if(previous == 0) + { + queue->msg_queue = iterator->next; + } + else + { + previous->next = iterator->next; + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Deleting stale reassembly message (%u %u %d)\n", iterator->rx_hr_time, rx_hr_time, delta); + + pnf_p7_rx_message_t* to_delete = iterator; + iterator = iterator->next; + + // delete the message + uint16_t i; + for(i = 0; i < 128; ++i) + { + if(to_delete->segments[i].buffer) + pnf_p7_free(pnf_p7, to_delete->segments[i].buffer); + } + pnf_p7_free(pnf_p7, to_delete); + + } + else + { + previous = iterator; + iterator = iterator->next; + } + } +} + + +static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr) +{ + if(now_hr < sf_start_hr) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "now is earlier than start of subframe now_hr:%u sf_start_hr:%u\n", now_hr, sf_start_hr); + return 0; + } + else + { + uint32_t now_us = TIMEHR_USEC(now_hr); + uint32_t sf_start_us = TIMEHR_USEC(sf_start_hr); + + // if the us have wrapped adjust for it + if(now_hr < sf_start_us) + { + now_us += 1000000; + } + + return now_us - sf_start_us; + } +} + +int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t len) +{ + // todo : consider how to do this only once + struct sockaddr_in remote_addr; + memset((char*)&remote_addr, 0, sizeof(struct sockaddr_in)); + remote_addr.sin_family = AF_INET; + remote_addr.sin_port = htons(pnf_p7->_public.remote_p7_port); + //remote_addr.sin_addr.s_addr = inet_addr(pnf_p7->_public.remote_p7_addr); + if(inet_aton(pnf_p7->_public.remote_p7_addr, &remote_addr.sin_addr) == -1) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "inet_aton failed %d\n", errno); + return -1; + } + + socklen_t remote_addr_len = sizeof(struct sockaddr_in); + + int sendto_result; + if ((sendto_result = sendto((int)pnf_p7->p7_sock, (const char*)msg, len, 0, (const struct sockaddr*)&remote_addr, remote_addr_len)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s %s:%d sendto(%d, %p, %d) %d failed errno: %d\n", __FUNCTION__, pnf_p7->_public.remote_p7_addr, pnf_p7->_public.remote_p7_port, (int)pnf_p7->p7_sock, (const char*)msg, len, remote_addr_len, errno); + return -1; + } + + if(sendto_result != len) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s sendto failed to send the entire message %d %d\n", __FUNCTION__, sendto_result, len); + } + return 0; +} + +int pnf_p7_pack_and_send_p7_message(pnf_p7_t* pnf_p7, nfapi_p7_message_header_t* header, uint32_t msg_len) +{ + header->m_segment_sequence = NFAPI_P7_SET_MSS(0, 0, pnf_p7->sequence_number); + + // Need to guard against different threads calling the encode function at the same time + if(pthread_mutex_lock(&(pnf_p7->pack_mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return -1; + } + + int len = nfapi_p7_message_pack(header, pnf_p7->tx_message_buffer, sizeof(pnf_p7->tx_message_buffer), &pnf_p7->_public.codec_config); + + if (len < 0) + { + if(pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return -1; + } + + NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p7_message_pack failed with return %d\n", len ); + return -1; + } + + if(len > pnf_p7->_public.segment_size) + { + int msg_body_len = len - NFAPI_P7_HEADER_LENGTH ; + int seg_body_len = pnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH ; + int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0); + + int segment = 0; + int offset = NFAPI_P7_HEADER_LENGTH; + uint8_t buffer[pnf_p7->_public.segment_size]; + for(segment = 0; segment < segment_count; ++segment) + { + uint8_t last = 0; + uint16_t size = pnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH; + if(segment + 1 == segment_count) + { + last = 1; + size = (msg_body_len) - (seg_body_len * segment); + } + + uint16_t segment_size = size + NFAPI_P7_HEADER_LENGTH; + + // Update the header with the m and segement + memcpy(&buffer[0], pnf_p7->tx_message_buffer, NFAPI_P7_HEADER_LENGTH); + + // set the segment length + buffer[4] = (segment_size & 0xFF00) >> 8; + buffer[5] = (segment_size & 0xFF); + + // set the m & segment number + buffer[6] = ((!last) << 7) + segment; + + memcpy(&buffer[NFAPI_P7_HEADER_LENGTH], pnf_p7->tx_message_buffer + offset, size); + offset += size; + + if(pnf_p7->_public.checksum_enabled) + { + nfapi_p7_update_checksum(buffer, segment_size); + } + + + pnf_p7_send_message(pnf_p7, &buffer[0], segment_size); + } + } + else + { + if(pnf_p7->_public.checksum_enabled) + { + nfapi_p7_update_checksum(pnf_p7->tx_message_buffer, len); + } + + // simple case that the message fits in a single segment + pnf_p7_send_message(pnf_p7, pnf_p7->tx_message_buffer, len); + } + + pnf_p7->sequence_number++; + + if(pthread_mutex_unlock(&(pnf_p7->pack_mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return -1; + } + + return 0; +} + +void pnf_pack_and_send_timing_info(pnf_p7_t* pnf_p7) +{ + nfapi_timing_info_t timing_info; + memset(&timing_info, 0, sizeof(timing_info)); + timing_info.header.message_id = NFAPI_TIMING_INFO; + timing_info.header.phy_id = pnf_p7->_public.phy_id; + + timing_info.last_sfn_sf = pnf_p7->sfn_sf; + timing_info.time_since_last_timing_info = pnf_p7->timing_info_ms_counter; + + timing_info.dl_config_jitter = pnf_p7->dl_config_jitter; + timing_info.tx_request_jitter = pnf_p7->tx_jitter; + timing_info.ul_config_jitter = pnf_p7->ul_config_jitter; + timing_info.hi_dci0_jitter = pnf_p7->hi_dci0_jitter; + + timing_info.dl_config_latest_delay = 0; + timing_info.tx_request_latest_delay = 0; + timing_info.ul_config_latest_delay = 0; + timing_info.hi_dci0_latest_delay = 0; + + timing_info.dl_config_earliest_arrival = 0; + timing_info.tx_request_earliest_arrival = 0; + timing_info.ul_config_earliest_arrival = 0; + timing_info.hi_dci0_earliest_arrival = 0; + + + pnf_p7_pack_and_send_p7_message(pnf_p7, &(timing_info.header), sizeof(timing_info)); + + pnf_p7->timing_info_ms_counter = 0; +} + +void send_dummy_subframe(pnf_p7_t* pnf_p7, uint16_t sfn_sf) +{ + struct timespec t; + clock_gettime( CLOCK_MONOTONIC, &t); + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(sfn_sf:%d) t:%ld.%09ld\n", __FUNCTION__, NFAPI_SFNSF2DEC(sfn_sf), t.tv_sec, t.tv_nsec); + + if(pnf_p7->_public.tx_req && pnf_p7->_public.dummy_subframe.tx_req) + { + pnf_p7->_public.dummy_subframe.tx_req->sfn_sf = sfn_sf; + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy tx_req - enter\n"); + (pnf_p7->_public.tx_req)(&pnf_p7->_public, pnf_p7->_public.dummy_subframe.tx_req); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy tx_req - exit\n"); + } + if(pnf_p7->_public.dl_config_req && pnf_p7->_public.dummy_subframe.dl_config_req) + { + pnf_p7->_public.dummy_subframe.dl_config_req->sfn_sf = sfn_sf; + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy dl_config_req - enter\n"); + (pnf_p7->_public.dl_config_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.dl_config_req); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy dl_config_req - exit\n"); + } + if(pnf_p7->_public.ul_config_req && pnf_p7->_public.dummy_subframe.ul_config_req) + { + pnf_p7->_public.dummy_subframe.ul_config_req->sfn_sf = sfn_sf; + NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy ul_config_req - enter\n"); + (pnf_p7->_public.ul_config_req)(&pnf_p7->_public, pnf_p7->_public.dummy_subframe.ul_config_req); + } + if(pnf_p7->_public.hi_dci0_req && pnf_p7->_public.dummy_subframe.hi_dci0_req) + { + pnf_p7->_public.dummy_subframe.hi_dci0_req->sfn_sf = sfn_sf; + NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy hi_dci0 - enter\n"); + (pnf_p7->_public.hi_dci0_req)(&pnf_p7->_public, pnf_p7->_public.dummy_subframe.hi_dci0_req); + } + if(pnf_p7->_public.lbt_dl_config_req && pnf_p7->_public.dummy_subframe.lbt_dl_config_req) + { + pnf_p7->_public.dummy_subframe.lbt_dl_config_req->sfn_sf = sfn_sf; + NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy lbt - enter\n"); + (pnf_p7->_public.lbt_dl_config_req)(&pnf_p7->_public, pnf_p7->_public.dummy_subframe.lbt_dl_config_req); + } +} + +int pnf_p7_subframe_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn_sf) +{ + // We could either send an event to the p7 thread have have it run the + // subframe or we could handle it here and lock access to the subframe + // buffers. If we do it on the p7 thread then we run the risk of blocking + // on the udp send. + // + // todo : start a timer to give us more of the 1 ms tick before send back + // the frame + + // todo : consider a more efficent lock mechasium + if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return -1; + } + +#if 1 + // save the curren time and sfn_sf + pnf_p7->sf_start_time_hr = pnf_get_current_time_hr(); + pnf_p7->sfn_sf = sfn_sf; + + uint32_t sfn_sf_tx = sfnsf_add_sf(sfn_sf, sf_ahead); + uint32_t tx_sfn_sf_dec = NFAPI_SFNSF2DEC(sfn_sf_tx); + + // If the subframe_buffer has been configured + if(pnf_p7->_public.subframe_buffer_size != 0) + { + + // apply the shift to the incoming sfn_sf + if(pnf_p7->sfn_sf_shift != 0) + { + int32_t sfn_sf_dec = NFAPI_SFNSF2DEC(sfn_sf); + + int32_t shifted_sfn_sf = sfn_sf_dec += pnf_p7->sfn_sf_shift; + + // adjust for wrap-around + if(shifted_sfn_sf < 0) + shifted_sfn_sf += NFAPI_MAX_SFNSFDEC; + else if(shifted_sfn_sf > NFAPI_MAX_SFNSFDEC) + shifted_sfn_sf -= NFAPI_MAX_SFNSFDEC; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Applying shift %d to sfn/sf (%d -> %d)\n", pnf_p7->sfn_sf_shift, NFAPI_SFNSF2DEC(sfn_sf), shifted_sfn_sf); + sfn_sf = shifted_sfn_sf; + + // + // DJP - why does the shift not apply to pnf_p7->sfn_sf??? + // + + pnf_p7->sfn_sf_shift = 0; + } + + uint32_t sfn_sf_dec = NFAPI_SFNSF2DEC(sfn_sf); + uint8_t buffer_index = sfn_sf_dec % pnf_p7->_public.subframe_buffer_size; + + nfapi_pnf_p7_subframe_buffer_t* subframe_buffer = &(pnf_p7->subframe_buffer[buffer_index]); + + uint8_t tx_buffer_index = tx_sfn_sf_dec % pnf_p7->_public.subframe_buffer_size; + nfapi_pnf_p7_subframe_buffer_t* tx_subframe_buffer = &(pnf_p7->subframe_buffer[tx_buffer_index]); + + //printf("sfn_sf_dec:%d tx_sfn_sf_dec:%d\n", sfn_sf_dec, tx_sfn_sf_dec); + + if (0) NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() shift:%d subframe_buffer->sfn_sf:%d tx_subframe_buffer->sfn_sf:%d sfn_sf:%d subframe_buffer[buffer_index:%u dl_config_req:%p tx_req:%p] " + "TX:sfn_sf:%d:tx_buffer_index:%d[dl_config_req:%p tx_req:%p]\n", + __FUNCTION__, + pnf_p7->sfn_sf_shift, + NFAPI_SFNSF2DEC(subframe_buffer->sfn_sf), + NFAPI_SFNSF2DEC(tx_subframe_buffer->sfn_sf), + sfn_sf_dec, buffer_index, subframe_buffer->dl_config_req, subframe_buffer->tx_req, + tx_sfn_sf_dec, tx_buffer_index, tx_subframe_buffer->dl_config_req, tx_subframe_buffer->tx_req); + + // if the subframe buffer sfn sf is set then we have atlease 1 message + // from the vnf. + // todo : how to handle the messages we don't have, send dummies for + // now + + //printf("tx_subframe_buffer->sfn_sf:%d sfn_sf_tx:%d\n", tx_subframe_buffer->sfn_sf, sfn_sf_tx); + //printf("subframe_buffer->sfn_sf:%d sfn_sf:%d\n", subframe_buffer->sfn_sf, sfn_sf); + if(tx_subframe_buffer->sfn_sf == sfn_sf_tx) + { + if(tx_subframe_buffer->tx_req != 0) + { + if(pnf_p7->_public.tx_req) + (pnf_p7->_public.tx_req)(&(pnf_p7->_public), tx_subframe_buffer->tx_req); + + //deallocate_nfapi_tx_request(subframe_buffer->tx_req, pnf_p7); + } + else + { + // send dummy + if(pnf_p7->_public.tx_req && pnf_p7->_public.dummy_subframe.tx_req) + { + pnf_p7->_public.dummy_subframe.tx_req->sfn_sf = sfn_sf_tx; + (pnf_p7->_public.tx_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.tx_req); + } + } + + if(tx_subframe_buffer->dl_config_req != 0) + { + if(pnf_p7->_public.dl_config_req) + (pnf_p7->_public.dl_config_req)(&(pnf_p7->_public), tx_subframe_buffer->dl_config_req); + + //deallocate_nfapi_dl_config_request(subframe_buffer->dl_config_req, pnf_p7); + } + else + { + // send dummy + if(pnf_p7->_public.dl_config_req && pnf_p7->_public.dummy_subframe.dl_config_req) + { + pnf_p7->_public.dummy_subframe.dl_config_req->sfn_sf = sfn_sf_tx; + (pnf_p7->_public.dl_config_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.dl_config_req); + } + } + + if(tx_subframe_buffer->hi_dci0_req != 0) + { + if(pnf_p7->_public.hi_dci0_req) + (pnf_p7->_public.hi_dci0_req)(&(pnf_p7->_public), tx_subframe_buffer->hi_dci0_req); + + //deallocate_nfapi_hi_dci0_request(subframe_buffer->hi_dci0_req, pnf_p7); + } + else + { + //send dummy + if(pnf_p7->_public.hi_dci0_req && pnf_p7->_public.dummy_subframe.hi_dci0_req) + { + pnf_p7->_public.dummy_subframe.hi_dci0_req->sfn_sf = sfn_sf_tx; + (pnf_p7->_public.hi_dci0_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.hi_dci0_req); + } + } + + if(tx_subframe_buffer->dl_config_req != 0) + { + deallocate_nfapi_dl_config_request(tx_subframe_buffer->dl_config_req, pnf_p7); + tx_subframe_buffer->dl_config_req = 0; + } + if(tx_subframe_buffer->tx_req != 0) + { + deallocate_nfapi_tx_request(tx_subframe_buffer->tx_req, pnf_p7); + tx_subframe_buffer->tx_req = 0; + } + if(tx_subframe_buffer->hi_dci0_req != 0) + { + deallocate_nfapi_hi_dci0_request(tx_subframe_buffer->hi_dci0_req, pnf_p7); + tx_subframe_buffer->hi_dci0_req = 0; + } + } + else + { + // If we ever need to "send" a dummy ul_config this won't work!!! + send_dummy_subframe(pnf_p7, sfn_sf_tx); + } + + if(subframe_buffer->sfn_sf == sfn_sf) + { + + if(subframe_buffer->ul_config_req != 0) + { + if(pnf_p7->_public.ul_config_req) + (pnf_p7->_public.ul_config_req)(&(pnf_p7->_public), subframe_buffer->ul_config_req); + + //deallocate_nfapi_ul_config_request(subframe_buffer->ul_config_req, pnf_p7); + } + else + { + // send dummy + if(pnf_p7->_public.ul_config_req && pnf_p7->_public.dummy_subframe.ul_config_req) + { + pnf_p7->_public.dummy_subframe.ul_config_req->sfn_sf = sfn_sf; + (pnf_p7->_public.ul_config_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.ul_config_req); + } + } + + if(subframe_buffer->lbt_dl_config_req != 0) + { + if(pnf_p7->_public.lbt_dl_config_req) + (pnf_p7->_public.lbt_dl_config_req)(&(pnf_p7->_public), subframe_buffer->lbt_dl_config_req); + + //deallocate_nfapi_lbt_dl_config_request(subframe_buffer->lbt_dl_config_req, pnf_p7); + } + else + { + // send dummy + if(pnf_p7->_public.lbt_dl_config_req && pnf_p7->_public.dummy_subframe.lbt_dl_config_req) + { + pnf_p7->_public.dummy_subframe.lbt_dl_config_req->sfn_sf = sfn_sf; + (pnf_p7->_public.lbt_dl_config_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_subframe.lbt_dl_config_req); + } + + } + + //if(subframe_buffer->dl_config_req != 0) + //deallocate_nfapi_dl_config_request(subframe_buffer->dl_config_req, pnf_p7); + //if(subframe_buffer->tx_req != 0) + //deallocate_nfapi_tx_request(subframe_buffer->tx_req, pnf_p7); + if(subframe_buffer->ul_config_req != 0) + { + deallocate_nfapi_ul_config_request(subframe_buffer->ul_config_req, pnf_p7); + subframe_buffer->ul_config_req = 0; + + } + //if(subframe_buffer->hi_dci0_req != 0) + //deallocate_nfapi_hi_dci0_request(subframe_buffer->hi_dci0_req, pnf_p7); + if(subframe_buffer->lbt_dl_config_req != 0) + { + deallocate_nfapi_lbt_dl_config_request(subframe_buffer->lbt_dl_config_req, pnf_p7); + subframe_buffer->lbt_dl_config_req = 0; + } + } // sfn_sf match + + if (subframe_buffer->dl_config_req == 0 && subframe_buffer->tx_req == 0 && subframe_buffer->ul_config_req == 0 && subframe_buffer->lbt_dl_config_req == 0) + { + memset(&(pnf_p7->subframe_buffer[buffer_index]), 0, sizeof(nfapi_pnf_p7_subframe_buffer_t)); + pnf_p7->subframe_buffer[buffer_index].sfn_sf = -1; + } + + //printf("pnf_p7->_public.timing_info_mode_periodic:%d pnf_p7->timing_info_period_counter:%d pnf_p7->_public.timing_info_period:%d\n", pnf_p7->_public.timing_info_mode_periodic, pnf_p7->timing_info_period_counter, pnf_p7->_public.timing_info_period); + //printf("pnf_p7->_public.timing_info_mode_aperiodic:%d pnf_p7->timing_info_aperiodic_send:%d\n", pnf_p7->_public.timing_info_mode_aperiodic, pnf_p7->timing_info_aperiodic_send); + //printf("pnf_p7->timing_info_ms_counter:%d\n", pnf_p7->timing_info_ms_counter); + + // send the periodic timing info if configured + if(pnf_p7->_public.timing_info_mode_periodic && (pnf_p7->timing_info_period_counter++) == pnf_p7->_public.timing_info_period) + { + pnf_pack_and_send_timing_info(pnf_p7); + + pnf_p7->timing_info_period_counter = 0; + } + else if(pnf_p7->_public.timing_info_mode_aperiodic && pnf_p7->timing_info_aperiodic_send) + { + pnf_pack_and_send_timing_info(pnf_p7); + + pnf_p7->timing_info_aperiodic_send = 0; + } + else + { + pnf_p7->timing_info_ms_counter++; + } + } + else + { + //send_dummy_subframe(pnf_p7, sfn_sf_tx); + } + + + //printf("pnf_p7->tick:%d\n", pnf_p7->tick); + if(pnf_p7->tick == 1000) + { + + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF P7:%d] (ONTIME/LATE) DL:(%d/%d) UL:(%d/%d) HI:(%d/%d) TX:(%d/%d)\n", pnf_p7->_public.phy_id, + pnf_p7->stats.dl_conf_ontime, pnf_p7->stats.dl_conf_late, + pnf_p7->stats.ul_conf_ontime, pnf_p7->stats.ul_conf_late, + pnf_p7->stats.hi_dci0_ontime, pnf_p7->stats.hi_dci0_late, + pnf_p7->stats.tx_ontime, pnf_p7->stats.tx_late); + pnf_p7->tick = 0; + memset(&pnf_p7->stats, 0, sizeof(pnf_p7->stats)); + } + pnf_p7->tick++; +#endif + + if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return -1; + } + + return 0; +} + + + +// return 1 if in window +// return 0 if out of window +uint8_t is_p7_request_in_window(uint16_t sfnsf, const char* name, pnf_p7_t* phy) +{ + uint32_t recv_sfn_sf_dec = NFAPI_SFNSF2DEC(sfnsf); + uint32_t current_sfn_sf_dec = NFAPI_SFNSF2DEC(phy->sfn_sf); + + uint8_t in_window = 0; + uint8_t timing_window = phy->_public.subframe_buffer_size; + + if(recv_sfn_sf_dec <= current_sfn_sf_dec) + { + // Need to check for wrap in window + if(((current_sfn_sf_dec + timing_window) % NFAPI_MAX_SFNSFDEC) < current_sfn_sf_dec) + { + if(recv_sfn_sf_dec > ((current_sfn_sf_dec + timing_window) % NFAPI_MAX_SFNSFDEC)) + { + // out of window + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is late %d (with wrap)\n", current_sfn_sf_dec, name, recv_sfn_sf_dec); + } + else + { + // ok + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is in window %d (with wrap)\n", current_sfn_sf_dec, name, recv_sfn_sf_dec); + in_window = 1; + } + } + else + { + // too late + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is in late %d (delta:%d)\n", current_sfn_sf_dec, name, recv_sfn_sf_dec, (current_sfn_sf_dec - recv_sfn_sf_dec)); + } + + } + else + { + // Need to check it is in window + if((recv_sfn_sf_dec - current_sfn_sf_dec) <= timing_window) + { + // in window + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is in window %d\n", current_sfn_sf_dec, name, recv_sfn_sf_dec); + in_window = 1; + } + else + { + // too far in the future + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] %s is out of window %d (delta:%d) [max:%d]\n", current_sfn_sf_dec, name, recv_sfn_sf_dec, (recv_sfn_sf_dec - current_sfn_sf_dec), timing_window); + } + + } + + return in_window; +} + + +// P7 messages +// +void pnf_handle_dl_config_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "DL_CONFIG.req Received\n"); + + nfapi_dl_config_request_t* req = allocate_nfapi_dl_config_request(pnf_p7); + + if(req == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_dl_config_request structure\n"); + return; + } + + int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_dl_config_request_t), &(pnf_p7->_public.codec_config)); + + if(unpack_result == 0) + { + if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return; + } + + if ( + 0 && + (NFAPI_SFNSF2DEC(req->sfn_sf) % 100 ==0 || + NFAPI_SFNSF2DEC(req->sfn_sf) % 105 ==0 + ) + ) + NFAPI_TRACE(NFAPI_TRACE_INFO, "DL_CONFIG.req sfn_sf:%d pdcch:%u dci:%u pdu:%u pdsch_rnti:%u pcfich:%u\n", + 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 + ); + + if(is_p7_request_in_window(req->sfn_sf, "dl_config_request", pnf_p7)) + { + uint32_t sfn_sf_dec = NFAPI_SFNSF2DEC(req->sfn_sf); + uint8_t buffer_index = sfn_sf_dec % pnf_p7->_public.subframe_buffer_size; + + struct timespec t; + clock_gettime(CLOCK_MONOTONIC, &t); + + NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE DL_CONFIG_REQ sfn_sf:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_sf_dec, buffer_index); + + // if there is already an dl_config_req make sure we free it. + if(pnf_p7->subframe_buffer[buffer_index].dl_config_req != 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "%s() is_p7_request_in_window()=TRUE buffer_index occupied - free it first sfn_sf:%d buffer_index:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), buffer_index); + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] Freeing dl_config_req at index %d (%d/%d)", + // pMyPhyInfo->sfnSf, bufferIdx, + // SFNSF2SFN(dreq->sfn_sf), SFNSF2SF(dreq->sfn_sf)); + deallocate_nfapi_dl_config_request(pnf_p7->subframe_buffer[buffer_index].dl_config_req, pnf_p7); + } + + // saving dl_config_request in subframe buffer + pnf_p7->subframe_buffer[buffer_index].sfn_sf = req->sfn_sf; + pnf_p7->subframe_buffer[buffer_index].dl_config_req = req; + + pnf_p7->stats.dl_conf_ontime++; + + } + else + { + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "NOT storing dl_config_req SFN/SF %d\n", req->sfn_sf); + deallocate_nfapi_dl_config_request(req, pnf_p7); + + if(pnf_p7->_public.timing_info_mode_aperiodic) + { + pnf_p7->timing_info_aperiodic_send = 1; + } + + pnf_p7->stats.dl_conf_late++; + } + + if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack dl_config_req"); + deallocate_nfapi_dl_config_request(req, pnf_p7); + } +} + +void pnf_handle_ul_config_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "UL_CONFIG.req Received\n"); + + nfapi_ul_config_request_t* req = allocate_nfapi_ul_config_request(pnf_p7); + + if(req == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_ul_config_request structure\n"); + return; + } + + int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_ul_config_request_t), &(pnf_p7->_public.codec_config)); + + if(unpack_result == 0) + { + if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return; + } + + if(is_p7_request_in_window(req->sfn_sf, "ul_config_request", pnf_p7)) + { + uint32_t sfn_sf_dec = NFAPI_SFNSF2DEC(req->sfn_sf); + uint8_t buffer_index = sfn_sf_dec % pnf_p7->_public.subframe_buffer_size; + + struct timespec t; + clock_gettime(CLOCK_MONOTONIC, &t); + + NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE UL_CONFIG_REQ sfn_sf:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_sf_dec, buffer_index); + + if(pnf_p7->subframe_buffer[buffer_index].ul_config_req != 0) + { + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] Freeing ul_config_req at index %d (%d/%d)", + // pMyPhyInfo->sfnSf, bufferIdx, + // SFNSF2SFN(dreq->sfn_sf), SFNSF2SF(dreq->sfn_sf)); + + deallocate_nfapi_ul_config_request(pnf_p7->subframe_buffer[buffer_index].ul_config_req, pnf_p7); + } + + pnf_p7->subframe_buffer[buffer_index].sfn_sf = req->sfn_sf; + pnf_p7->subframe_buffer[buffer_index].ul_config_req = req; + + pnf_p7->stats.ul_conf_ontime++; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] NOT storing ul_config_req OUTSIDE OF TRANSMIT BUFFER WINDOW SFN/SF %d\n", NFAPI_SFNSF2DEC(pnf_p7->sfn_sf), NFAPI_SFNSF2DEC(req->sfn_sf)); + deallocate_nfapi_ul_config_request(req, pnf_p7); + + if(pnf_p7->_public.timing_info_mode_aperiodic) + { + pnf_p7->timing_info_aperiodic_send = 1; + } + + pnf_p7->stats.ul_conf_late++; + } + + if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack ul_config_req\n"); + deallocate_nfapi_ul_config_request(req, pnf_p7); + } +} + +void pnf_handle_hi_dci0_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "HI_DCI0.req Received\n"); + + nfapi_hi_dci0_request_t* req = allocate_nfapi_hi_dci0_request(pnf_p7); + + if(req == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_hi_dci0_request structure\n"); + return; + } + + int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_hi_dci0_request_t), &pnf_p7->_public.codec_config); + + if(unpack_result == 0) + { + if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return; + } + + if(is_p7_request_in_window(req->sfn_sf, "hi_dci0_request", pnf_p7)) + { + uint32_t sfn_sf_dec = NFAPI_SFNSF2DEC(req->sfn_sf); + uint8_t buffer_index = sfn_sf_dec % pnf_p7->_public.subframe_buffer_size; + + if(pnf_p7->subframe_buffer[buffer_index].hi_dci0_req!= 0) + { + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] Freeing hi_dci0_req at index %d (%d/%d)", + // pMyPhyInfo->sfnSf, bufferIdx, + // SFNSF2SFN(dreq->sfn_sf), SFNSF2SF(dreq->sfn_sf)); + + deallocate_nfapi_hi_dci0_request(pnf_p7->subframe_buffer[buffer_index].hi_dci0_req, pnf_p7); + } + + pnf_p7->subframe_buffer[buffer_index].sfn_sf = req->sfn_sf; + pnf_p7->subframe_buffer[buffer_index].hi_dci0_req = req; + + pnf_p7->stats.hi_dci0_ontime++; + + } + else + { + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] NOT storing hi_dci0_req SFN/SF %d/%d\n", pMyPhyInfo->sfnSf, SFNSF2SFN(req->sfn_sf), SFNSF2SF(req->sfn_sf)); + deallocate_nfapi_hi_dci0_request(req, pnf_p7); + + if(pnf_p7->_public.timing_info_mode_aperiodic) + { + pnf_p7->timing_info_aperiodic_send = 1; + } + + pnf_p7->stats.hi_dci0_late++; + } + + if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return; + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack hi_dci0_req\n"); + deallocate_nfapi_hi_dci0_request(req, pnf_p7); + } +} + +void pnf_handle_tx_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "TX.req Received\n"); + + nfapi_tx_request_t* req = allocate_nfapi_tx_request(pnf_p7); + + if(req == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_tx_request structure\n"); + return; + } + + int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_tx_request_t), &pnf_p7->_public.codec_config); + if(unpack_result == 0) + { + if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return; + } + + if(is_p7_request_in_window(req->sfn_sf, "tx_request", pnf_p7)) + { + uint32_t sfn_sf_dec = NFAPI_SFNSF2DEC(req->sfn_sf); + uint8_t buffer_index = sfn_sf_dec % pnf_p7->_public.subframe_buffer_size; + + struct timespec t; + clock_gettime(CLOCK_MONOTONIC, &t); + + NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE TX_REQ sfn_sf:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_sf_dec, buffer_index); + + if (0 && NFAPI_SFNSF2DEC(req->sfn_sf)%100==0) NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX_REQ.req sfn_sf:%d pdus:%d - TX_REQ is within window\n", + __FUNCTION__, + NFAPI_SFNSF2DEC(req->sfn_sf), + req->tx_request_body.number_of_pdus); + + if(pnf_p7->subframe_buffer[buffer_index].tx_req != 0) + { + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] Freeing tx_req at index %d (%d/%d)", + // pMyPhyInfo->sfnSf, bufferIdx, + // SFNSF2SFN(dreq->sfn_sf), SFNSF2SF(dreq->sfn_sf)); + + deallocate_nfapi_tx_request(pnf_p7->subframe_buffer[buffer_index].tx_req, pnf_p7); + } + + pnf_p7->subframe_buffer[buffer_index].sfn_sf = req->sfn_sf; + pnf_p7->subframe_buffer[buffer_index].tx_req = req; + + pnf_p7->stats.tx_ontime++; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() TX_REQUEST Request is outside of window REQ:SFN_SF:%d CURR:SFN_SF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), NFAPI_SFNSF2DEC(pnf_p7->sfn_sf)); + + deallocate_nfapi_tx_request(req, pnf_p7); + + if(pnf_p7->_public.timing_info_mode_aperiodic) + { + pnf_p7->timing_info_aperiodic_send = 1; + } + + pnf_p7->stats.tx_late++; + } + + if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return; + } + } + else + { + deallocate_nfapi_tx_request(req, pnf_p7); + } +} + +void pnf_handle_lbt_dl_config_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) +{ + nfapi_lbt_dl_config_request_t* req = allocate_nfapi_lbt_dl_config_request(pnf_p7); + + if(req == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_lbt_dl_config_request structure\n"); + return; + } + + int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_lbt_dl_config_request_t), &pnf_p7->_public.codec_config); + + if(unpack_result == 0) + { + if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return; + } + + if(is_p7_request_in_window(req->sfn_sf, "lbt_dl_request", pnf_p7)) + { + uint32_t sfn_sf_dec = NFAPI_SFNSF2DEC(req->sfn_sf); + uint8_t buffer_index = sfn_sf_dec % pnf_p7->_public.subframe_buffer_size; + + if(pnf_p7->subframe_buffer[buffer_index].lbt_dl_config_req != 0) + { + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] Freeing tx_req at index %d (%d/%d)", + // pMyPhyInfo->sfnSf, bufferIdx, + // SFNSF2SFN(dreq->sfn_sf), SFNSF2SF(dreq->sfn_sf)); + + deallocate_nfapi_lbt_dl_config_request(pnf_p7->subframe_buffer[buffer_index].lbt_dl_config_req, pnf_p7); + } + + pnf_p7->subframe_buffer[buffer_index].sfn_sf = req->sfn_sf; + pnf_p7->subframe_buffer[buffer_index].lbt_dl_config_req = req; + } + else + { + deallocate_nfapi_lbt_dl_config_request(req, pnf_p7); + + if(pnf_p7->_public.timing_info_mode_aperiodic) + { + pnf_p7->timing_info_aperiodic_send = 1; + } + } + + if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return; + } + } + else + { + deallocate_nfapi_lbt_dl_config_request(req, pnf_p7); + } + +} + +void pnf_handle_p7_vendor_extension(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint16_t message_id) +{ + if(pnf_p7->_public.allocate_p7_vendor_ext) + { + uint16_t msg_size; + nfapi_p7_message_header_t* msg = pnf_p7->_public.allocate_p7_vendor_ext(message_id, &msg_size); + + if(msg == 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n"); + return; + } + + int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &pnf_p7->_public.codec_config); + + if(unpack_result == 0) + { + if(pnf_p7->_public.vendor_ext) + pnf_p7->_public.vendor_ext(&(pnf_p7->_public), msg); + } + + if(pnf_p7->_public.deallocate_p7_vendor_ext) + pnf_p7->_public.deallocate_p7_vendor_ext(msg); + + } + +} + + +uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr) +{ + uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); + uint32_t t2 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + + if (0) + { + static uint32_t prev_t2 = 0; + + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(now_time_hr:%u sfn_sf:%d sf_start_time_Hr:%u) sf_time_us:%u t2:%u prev_t2:%u diff:%u\n", + __FUNCTION__, + now_time_hr, NFAPI_SFNSF2DEC(sfn_sf), sf_start_time_hr, + sf_time_us, + t2, + prev_t2, + t2-prev_t2); + + prev_t2 = t2; + } + + return t2; +} + +uint32_t calculate_t3(uint16_t sfn_sf, uint32_t sf_start_time_hr) +{ + uint32_t now_time_hr = pnf_get_current_time_hr(); + + uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); + + uint32_t t3 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + + return t3; +} + +void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time) +{ + nfapi_dl_node_sync_t dl_node_sync; + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "DL_NODE_SYNC Received\n"); + + if (pRecvMsg == NULL || pnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + return; + } + + // unpack the message + if (nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &dl_node_sync, sizeof(dl_node_sync), &pnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + return; + } + + if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n"); + return; + } + + + if (dl_node_sync.delta_sfn_sf != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Will shift SF timing by %d on next subframe\n", dl_node_sync.delta_sfn_sf); + + pnf_p7->sfn_sf_shift = dl_node_sync.delta_sfn_sf; + } + + nfapi_ul_node_sync_t ul_node_sync; + memset(&ul_node_sync, 0, sizeof(ul_node_sync)); + ul_node_sync.header.message_id = NFAPI_UL_NODE_SYNC; + ul_node_sync.header.phy_id = dl_node_sync.header.phy_id; + ul_node_sync.t1 = dl_node_sync.t1; + ul_node_sync.t2 = calculate_t2(rx_hr_time, pnf_p7->sfn_sf, pnf_p7->sf_start_time_hr); + ul_node_sync.t3 = calculate_t3(pnf_p7->sfn_sf, pnf_p7->sf_start_time_hr); + + if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n"); + return; + } + + pnf_p7_pack_and_send_p7_message(pnf_p7, &(ul_node_sync.header), sizeof(ul_node_sync)); +} + +void pnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time) +{ + nfapi_p7_message_header_t header; + + // validate the input params + if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return; + } + + // unpack the message header + if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &pnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n"); + return; + } + + // ensure the message is sensible + if (recvMsgLen < 8 || pRecvMsg == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen); + return; + } + + switch (header.message_id) + { + case NFAPI_DL_NODE_SYNC: + pnf_handle_dl_node_sync(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time); + break; + + case NFAPI_DL_CONFIG_REQUEST: + pnf_handle_dl_config_request(pRecvMsg, recvMsgLen, pnf_p7); + break; + + case NFAPI_UL_CONFIG_REQUEST: + pnf_handle_ul_config_request(pRecvMsg, recvMsgLen, pnf_p7); + break; + + case NFAPI_HI_DCI0_REQUEST: + pnf_handle_hi_dci0_request(pRecvMsg, recvMsgLen, pnf_p7); + break; + + case NFAPI_TX_REQUEST: + pnf_handle_tx_request(pRecvMsg, recvMsgLen, pnf_p7); + break; + + case NFAPI_LBT_DL_CONFIG_REQUEST: + pnf_handle_lbt_dl_config_request(pRecvMsg, recvMsgLen, pnf_p7); + break; + + default: + { + if(header.message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + header.message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + pnf_handle_p7_vendor_extension(pRecvMsg, recvMsgLen, pnf_p7, header.message_id); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P7 Unknown message ID %d\n", __FUNCTION__, header.message_id); + } + } + break; + } +} + +void pnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time) +{ + nfapi_p7_message_header_t messageHeader; + + // validate the input params + if(pRecvMsg == NULL || recvMsgLen < 4 || pnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "pnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, pnf_p7); + return; + } + + // unpack the message header + if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p7_message_header_t), &pnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n"); + return; + } + + uint8_t m = NFAPI_P7_GET_MORE(messageHeader.m_segment_sequence); + uint8_t sequence_num = NFAPI_P7_GET_SEQUENCE(messageHeader.m_segment_sequence); + uint8_t segment_num = NFAPI_P7_GET_SEGMENT(messageHeader.m_segment_sequence); + + if(pnf_p7->_public.checksum_enabled) + { + uint32_t checksum = nfapi_p7_calculate_checksum(pRecvMsg, recvMsgLen); + if(checksum != messageHeader.checksum) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Checksum verification failed %d %d\n", checksum, messageHeader.checksum); + return; + } + } + + if(m == 0 && segment_num == 0) + { + // we have a complete message + // ensure the message is sensible + if (recvMsgLen < 8 || pRecvMsg == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen); + return; + } + + pnf_dispatch_p7_message(pRecvMsg, recvMsgLen, pnf_p7, rx_hr_time); + } + else + { + pnf_p7_rx_message_t* rx_msg = pnf_p7_rx_reassembly_queue_add_segment(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, sequence_num, segment_num, m, pRecvMsg, recvMsgLen); + + if(rx_msg->num_segments_received == rx_msg->num_segments_expected) + { + // send the buffer on + uint16_t i = 0; + uint16_t length = 0; + for(i = 0; i < rx_msg->num_segments_expected; ++i) + { + length += rx_msg->segments[i].length - (i > 0 ? NFAPI_P7_HEADER_LENGTH : 0); + } + + if(pnf_p7->reassemby_buffer_size < length) + { + pnf_p7_free(pnf_p7, pnf_p7->reassemby_buffer); + pnf_p7->reassemby_buffer = 0; + } + + if(pnf_p7->reassemby_buffer == 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "Resizing PNF_P7 Reassembly buffer %d->%d\n", pnf_p7->reassemby_buffer_size, length); + pnf_p7->reassemby_buffer = (uint8_t*)pnf_p7_malloc(pnf_p7, length); + + if(pnf_p7->reassemby_buffer == 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "Failed to allocate PNF_P7 reassemby buffer len:%d\n", length); + return; + } + + pnf_p7->reassemby_buffer_size = length; + } + + uint16_t offset = 0; + for(i = 0; i < rx_msg->num_segments_expected; ++i) + { + if(i == 0) + { + memcpy(pnf_p7->reassemby_buffer, rx_msg->segments[i].buffer, rx_msg->segments[i].length); + offset += rx_msg->segments[i].length; + } + else + { + memcpy(pnf_p7->reassemby_buffer + offset, rx_msg->segments[i].buffer + NFAPI_P7_HEADER_LENGTH, rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH); + offset += rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH; + } + } + + + pnf_dispatch_p7_message(pnf_p7->reassemby_buffer, length, pnf_p7, rx_msg->rx_hr_time); + + + // delete the structure + pnf_p7_rx_reassembly_queue_remove_msg(pnf_p7, &(pnf_p7->reassembly_queue), rx_msg); + } + } + + pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7, &(pnf_p7->reassembly_queue), rx_hr_time, 1000); + +} +void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time) +{ + int recvfrom_result = 0; + struct sockaddr_in remote_addr; + socklen_t remote_addr_size = sizeof(remote_addr); + + do + { + // peek the header + uint8_t header_buffer[NFAPI_P7_HEADER_LENGTH]; + recvfrom_result = recvfrom(pnf_p7->p7_sock, header_buffer, NFAPI_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size); + + if(recvfrom_result > 0) + { + // get the segment size + nfapi_p7_message_header_t header; + nfapi_p7_message_header_unpack(header_buffer, NFAPI_P7_HEADER_LENGTH, &header, 34, 0); + + // resize the buffer if we have a large segment + if(header.message_length > pnf_p7->rx_message_buffer_size) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length); + pnf_p7->rx_message_buffer = realloc(pnf_p7->rx_message_buffer, header.message_length); + pnf_p7->rx_message_buffer_size = header.message_length; + } + + // read the segment + recvfrom_result = recvfrom(pnf_p7->p7_sock, pnf_p7->rx_message_buffer, header.message_length, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size); + + now_hr_time = pnf_get_current_time_hr(); //DJP - moved to here - get closer timestamp??? + + if(recvfrom_result > 0) + { + pnf_handle_p7_message(pnf_p7->rx_message_buffer, recvfrom_result, pnf_p7, now_hr_time); + } + } + else if(recvfrom_result == 0) + { + // recv zero length message + recvfrom_result = recvfrom(pnf_p7->p7_sock, header_buffer, 0, MSG_DONTWAIT, (struct sockaddr*)&remote_addr, &remote_addr_size); + } + + if(recvfrom_result == -1) + { + if(errno == EAGAIN || errno == EWOULDBLOCK) + { + // return to the select + //NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom would block :%d\n", __FUNCTION__, errno); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom failed errno:%d\n", __FUNCTION__, errno); + } + } + + // need to update the time as we would only use the value from the + // select +#if 0 +// DJP - why do this here and not on return from recv??? + now_hr_time = pnf_get_current_time_hr(); +#endif + } + while(recvfrom_result > 0); +} + +int pnf_p7_message_pump(pnf_p7_t* pnf_p7) +{ + + // initialize the mutex lock + if(pthread_mutex_init(&(pnf_p7->mutex), NULL) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 mutex init: %d\n", errno); + return -1; + } + + if(pthread_mutex_init(&(pnf_p7->pack_mutex), NULL) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 mutex init: %d\n", errno); + return -1; + } + + // create the pnf p7 socket + if ((pnf_p7->p7_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 socket errno: %d\n", errno); + return -1; + } + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 socket created (%d)...\n", pnf_p7->p7_sock); + + // configure the UDP socket options + int reuseaddr_enable = 1; + if (setsockopt(pnf_p7->p7_sock, SOL_SOCKET, SO_REUSEADDR, &reuseaddr_enable, sizeof(int)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF P7 setsockopt (SOL_SOCKET, SO_REUSEADDR) failed errno: %d\n", errno); + return -1; + } + +/* + int reuseport_enable = 1; + if (setsockopt(pnf_p7->p7_sock, SOL_SOCKET, SO_REUSEPORT, &reuseport_enable, sizeof(int)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF P7 setsockopt (SOL_SOCKET, SO_REUSEPORT) failed errno: %d\n", errno); + return -1; + } +*/ + + int iptos_value = FAPI2_IP_DSCP << 2; + if (setsockopt(pnf_p7->p7_sock, IPPROTO_IP, IP_TOS, &iptos_value, sizeof(iptos_value)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF P7 setsockopt (IPPROTO_IP, IP_TOS) failed errno: %d\n", errno); + return -1; + } + + struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(pnf_p7->_public.local_p7_port); + + if(pnf_p7->_public.local_p7_addr == 0) + { + addr.sin_addr.s_addr = INADDR_ANY; + } + else + { + //addr.sin_addr.s_addr = inet_addr(pnf_p7->_public.local_p7_addr); + if(inet_aton(pnf_p7->_public.local_p7_addr, &addr.sin_addr) == -1) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "inet_aton failed\n"); + } + } + + + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 binding %d too %s:%d\n", pnf_p7->p7_sock, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); + if (bind(pnf_p7->p7_sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF_P7 bind error fd:%d errno: %d\n", pnf_p7->p7_sock, errno); + return -1; + } + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 bind succeeded...\n"); + + while(pnf_p7->terminate == 0) + { + fd_set rfds; + int selectRetval = 0; + + // select on a timeout and then get the message + FD_ZERO(&rfds); + FD_SET(pnf_p7->p7_sock, &rfds); + + struct timeval timeout; + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + selectRetval = select(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout); + + uint32_t now_hr_time = pnf_get_current_time_hr(); + + if(selectRetval == 0) + { + // timeout + continue; + } + else if (selectRetval == -1 && (errno == EINTR)) + { + // interrupted by signal + NFAPI_TRACE(NFAPI_TRACE_WARN, "PNF P7 Signal Interrupt %d\n", errno); + continue; + } + else if (selectRetval == -1) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "PNF P7 select() failed\n"); + sleep(1); + continue; + } + + if(FD_ISSET(pnf_p7->p7_sock, &rfds)) + { + pnf_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time); + } + } + NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF_P7 Terminating..\n"); + + // close the connection and socket + if (close(pnf_p7->p7_sock) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "close failed errno: %d\n", errno); + } + + if(pthread_mutex_destroy(&(pnf_p7->pack_mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "mutex destroy failed errno: %d\n", errno); + } + + if(pthread_mutex_destroy(&(pnf_p7->mutex)) != 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "mutex destroy failed errno: %d\n", errno); + } + + return 0; +} diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c new file mode 100644 index 0000000000000000000000000000000000000000..74de5e5d785e5d251dfcc65133fd2154219b7641 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c @@ -0,0 +1,225 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "pnf_p7.h" +#include <stdlib.h> +#include <string.h> + +nfapi_pnf_p7_config_t* nfapi_pnf_p7_config_create() +{ + pnf_p7_t* _this = (pnf_p7_t*)calloc(1, sizeof(pnf_p7_t)); + + if(_this == 0) + return 0; + + + // set the default parameters + _this->_public.segment_size = 1400; + _this->max_num_segments = 8; + + _this->_public.subframe_buffer_size = 8; + _this->_public.timing_info_mode_periodic = 1; + _this->_public.timing_info_period = 32; + _this->_public.timing_info_mode_aperiodic = 1; + + _this->_public.checksum_enabled = 1; + + _this->_public.malloc = &malloc; + _this->_public.free = &free; + + _this->_public.codec_config.allocate = &malloc; + _this->_public.codec_config.deallocate = &free; + + return &(_this->_public); +} + +void nfapi_pnf_p7_config_destory(nfapi_pnf_p7_config_t* config) +{ + if(config == 0) + return ; + + free(config); +} + + + +int nfapi_pnf_p7_start(nfapi_pnf_p7_config_t* config) +{ + // Verify that config is not null + if(config == 0) + return -1; + + // Make sure to set the defined trace function before using NFAPI_TRACE + if(config->trace) + nfapi_trace_g = config->trace; + + pnf_p7_t* _this = (pnf_p7_t*)(config); + + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); + + pnf_p7_message_pump(_this); + + return 0; +} + +int nfapi_pnf_p7_stop(nfapi_pnf_p7_config_t* config) +{ + // Verify that config is not null + if(config == 0) + return -1; + + pnf_p7_t* _this = (pnf_p7_t*)(config); + _this->terminate = 1; + + return 0; +} + + +int nfapi_pnf_p7_subframe_ind(nfapi_pnf_p7_config_t* config, uint16_t phy_id, uint16_t sfn_sf) +{ + // Verify that config is not null + if(config == 0) + return -1; + + pnf_p7_t* _this = (pnf_p7_t*)(config); + + return pnf_p7_subframe_ind(_this, phy_id, sfn_sf); +} + +int nfapi_pnf_p7_harq_ind(nfapi_pnf_p7_config_t* config, nfapi_harq_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_harq_indication_t)); +} +int nfapi_pnf_p7_crc_ind(nfapi_pnf_p7_config_t* config, nfapi_crc_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_crc_indication_t)); +} +int nfapi_pnf_p7_rx_ind(nfapi_pnf_p7_config_t* config, nfapi_rx_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_rx_indication_t)); +} +int nfapi_pnf_p7_rach_ind(nfapi_pnf_p7_config_t* config, nfapi_rach_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_rach_indication_t)); +} +int nfapi_pnf_p7_srs_ind(nfapi_pnf_p7_config_t* config, nfapi_srs_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_srs_indication_t)); +} +int nfapi_pnf_p7_sr_ind(nfapi_pnf_p7_config_t* config, nfapi_sr_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_sr_indication_t)); +} +int nfapi_pnf_p7_cqi_ind(nfapi_pnf_p7_config_t* config, nfapi_cqi_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_cqi_indication_t)); +} +int nfapi_pnf_p7_lbt_dl_ind(nfapi_pnf_p7_config_t* config, nfapi_lbt_dl_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_lbt_dl_indication_t)); +} +int nfapi_pnf_p7_nb_harq_ind(nfapi_pnf_p7_config_t* config, nfapi_nb_harq_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nb_harq_indication_t)); +} +int nfapi_pnf_p7_nrach_ind(nfapi_pnf_p7_config_t* config, nfapi_nrach_indication_t* ind) +{ + if(config == NULL || ind == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, (nfapi_p7_message_header_t*)ind, sizeof(nfapi_nrach_indication_t)); +} +int nfapi_pnf_p7_vendor_extension(nfapi_pnf_p7_config_t* config, nfapi_p7_message_header_t* msg) +{ + if(config == NULL || msg == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return -1; + } + + pnf_p7_t* _this = (pnf_p7_t*)(config); + return pnf_p7_pack_and_send_p7_message(_this, msg, 0); +} + diff --git a/nfapi/open-nFAPI/pnf/tests/Makefile.am b/nfapi/open-nFAPI/pnf/tests/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..4dcdea0511f8997ad211b3d97ffb45af0904a4f7 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/tests/Makefile.am @@ -0,0 +1,28 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#nfapi unit test +AUTOMAKE_OPTIONS=subdir-objects +AM_CPPFLAGS = -I$(top_srcdir)/nfapi/inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/pnf/public_inc $(CFLAGS_CUNIT) -Wall -Werror + +check_PROGRAMS= test_pnf + +test_pnf_SOURCES = pnf_cunit_main.c ../../common/src/debug.c +test_pnf_LDADD=$(top_builddir)/pnf/libnfapi_pnf.a $(top_builddir)/nfapi/libnfapi.a -L$(libdir) -lpthread -lrt -lsctp -lz -lcunit + +LOG_DRIVER = $(top_srcdir)/tap-driver.sh +TESTS=$(check_PROGRAMS) +EXTRA_DIST = $(TESTS) diff --git a/nfapi/open-nFAPI/pnf/tests/pnf_cunit_main.c b/nfapi/open-nFAPI/pnf/tests/pnf_cunit_main.c new file mode 100644 index 0000000000000000000000000000000000000000..d2ab031ad4708000942e490df8a0cd0b64276bb8 --- /dev/null +++ b/nfapi/open-nFAPI/pnf/tests/pnf_cunit_main.c @@ -0,0 +1,2365 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "CUnit.h" + +#include "Basic.h" +#include "Automated.h" +//#include "CUnit/Console.h" + +#include "nfapi_interface.h" +#include "nfapi_pnf_interface.h" +#include "nfapi.h" +#include <stdio.h> // for printf +#include <stdlib.h> +#include <pthread.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <netinet/sctp.h> +#include <arpa/inet.h> +#include <netdb.h> +#include <unistd.h> +#include "debug.h" + +/* Test Suite setup and cleanup functions: */ + +int init_suite(void) { return 0; } +int clean_suite(void) { return 0; } + +#define MAX_PACKED_MESSAGE_SIZE 8192 + +typedef struct phy_info +{ + uint8_t enabled; + uint16_t phy_id; + uint16_t sfn_sf; + + pthread_t thread; + + int pnf_p7_port; + char* pnf_p7_addr; + + int vnf_p7_port; + char* vnf_p7_addr; + + nfapi_pnf_p7_config_t* config; + +} phy_info_t; + +typedef struct pnf_info +{ + uint8_t num_phys; + phy_info_t phys[8]; + +} pnf_info_t; + +phy_info_t* find_phy_info(pnf_info_t* pnf, uint16_t phy_id) +{ + int i = 0; + for(i = 0; i < 8; ++i) + { + if(pnf->phys[i].enabled == 1 && pnf->phys[i].phy_id == phy_id) + { + return &(pnf->phys[i]); + } + } + return 0; +} + + + +/************* Test case functions ****************/ + +void pnf_test_start_no_config(void) +{ + int result = nfapi_pnf_start(0); + CU_ASSERT_EQUAL(result, -1); +} + +void test_trace(nfapi_trace_level_t level, const char* message, ...) +{ + printf("%s", message); +} + + +void* pnf_test_start_thread(void* ptr) +{ + int result = nfapi_pnf_start((nfapi_pnf_config_t*)ptr); + return (void*)(intptr_t)result; +} + +void* pnf_test_start_p7_thread(void* ptr) +{ + int result = nfapi_pnf_p7_start((nfapi_pnf_p7_config_t*)ptr); + return (void*)(intptr_t)result; +} + +void pnf_test_start_no_connection(void) +{ + char* vnf_addr = "127.127.0.1"; + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + sleep(1); + + nfapi_pnf_stop(config); + + int* result; + pthread_join(thread, (void**)&result); + CU_ASSERT_EQUAL(result, 0); +} + +void pnf_test_start_no_ip(void) +{ + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + sleep(2); + + nfapi_pnf_stop(config); + + intptr_t result; + pthread_join(thread, (void**)&result); + CU_ASSERT_EQUAL((int)result, -1); +} + +void pnf_test_start_invalid_ip(void) +{ + char* vnf_addr = "not.an.ip.address"; + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + sleep(2); + + nfapi_pnf_stop(config); + + intptr_t result; + pthread_join(thread, (void**)&result); + CU_ASSERT_EQUAL((int)result, -1); +} + +int create_p5_listen_socket(char* ip, int port) +{ + int p5ListenSock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); + + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(port); + addr.sin_addr.s_addr = INADDR_ANY; + + // bind to the configured address and port + bind(p5ListenSock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); + + return p5ListenSock; +} +int create_p5_ipv6_listen_socket(char* ip, int port) +{ + struct addrinfo hints, *servinfo; + memset(&hints, 0, sizeof(hints)); + hints.ai_socktype = SOCK_STREAM; // For SCTP we are only interested in SOCK_STREAM + hints.ai_family= AF_INET6; + + char port_str[8]; + snprintf(port_str, sizeof(port_str), "%d", port); + getaddrinfo(ip, port_str, &hints, &servinfo); + + + int p5ListenSock = socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP); + //printf("Socket result %d\n", p5ListenSock); + + // bind to the configured address and port + /*int bind_result = */ + bind(p5ListenSock, servinfo->ai_addr, servinfo->ai_addrlen); + //printf("Bind result %d (errno:%d)\n", bind_result, errno); + + freeaddrinfo(servinfo); + + return p5ListenSock; +} + +/* +int wait_for_pnf_connection(int p5ListenSock) +{ + listen(p5ListenSock, 2); + socklen_t addrSize; + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + + return p5Sock; +} +*/ + +int test_param_request_called = 0; +int test_pnf_param_request(nfapi_pnf_config_t* config, nfapi_pnf_param_request_t* req) +{ + printf("test_pnf_param_request called.... ;-)\n"); + + nfapi_pnf_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE; + + resp.pnf_param_general.tl.tag = NFAPI_PNF_PARAM_GENERAL_TAG; + resp.pnf_param_general.nfapi_sync_mode = 2; + resp.pnf_param_general.location_mode = 1; + resp.pnf_param_general.location_coordinates[0] = 123; + resp.pnf_param_general.dl_config_timing = 12; + resp.pnf_param_general.tx_timing = 12; + resp.pnf_param_general.ul_config_timing = 12; + resp.pnf_param_general.hi_dci0_timing = 12; + resp.pnf_param_general.maximum_number_phys = 2; + resp.pnf_param_general.maximum_total_bandwidth = 100; + resp.pnf_param_general.maximum_total_number_dl_layers = 2; + resp.pnf_param_general.maximum_total_number_ul_layers = 2; + resp.pnf_param_general.shared_bands = 0; + resp.pnf_param_general.shared_pa = 0; + resp.pnf_param_general.maximum_total_power = -190; + resp.pnf_param_general.oui[0] = 88; +/* + in.pnf_phy.tl.tag = NFAPI_PNF_PHY_TAG; + in.pnf_phy.number_of_phys = 2; + in.pnf_phy.phy[0].phy_config_index = 0; + in.pnf_phy.phy[0].number_of_rfs = 2; + in.pnf_phy.phy[0].rf_config[0].rf_config_index = 0; + in.pnf_phy.phy[0].number_of_rf_exclusions = 1; + in.pnf_phy.phy[0].rf_config[0].rf_config_index = 1; + in.pnf_phy.phy[0].downlink_channel_bandwidth_supported = 20; + in.pnf_phy.phy[0].uplink_channel_bandwidth_supported = 20; + in.pnf_phy.phy[0].number_of_dl_layers_supported = 2; + in.pnf_phy.phy[0].number_of_ul_layers_supported = 1; + in.pnf_phy.phy[0].maximum_3gpp_release_supported = 3; + in.pnf_phy.phy[0].nmm_modes_supported = 2; + + in.pnf_rf.tl.tag = NFAPI_PNF_RF_TAG; + in.pnf_rf.number_of_rfs = 2; + in.pnf_rf.rf[0].rf_config_index = 0; + in.pnf_rf.rf[0].band = 1; + in.pnf_rf.rf[0].maximum_transmit_power = -100; + in.pnf_rf.rf[0].minimum_transmit_power = -90; + in.pnf_rf.rf[0].number_of_antennas_suppported = 4; + in.pnf_rf.rf[0].minimum_downlink_frequency = 100; + in.pnf_rf.rf[0].maximum_downlink_frequency = 2132; + in.pnf_rf.rf[0].minimum_uplink_frequency = 1231; + in.pnf_rf.rf[0].maximum_uplink_frequency = 123; + + + in.pnf_phy_rel10.tl.tag = NFAPI_PNF_PHY_REL10_TAG; + in.pnf_phy_rel10.number_of_phys = 2; + in.pnf_phy_rel10.phy[0].phy_config_index = 0; + in.pnf_phy_rel10.phy[0].transmission_mode_7_supported = 1; + in.pnf_phy_rel10.phy[0].transmission_mode_8_supported = 2; + in.pnf_phy_rel10.phy[0].two_antenna_ports_for_pucch = 3; + in.pnf_phy_rel10.phy[0].transmission_mode_9_supported = 4; + in.pnf_phy_rel10.phy[0].simultaneous_pucch_pusch = 5; + in.pnf_phy_rel10.phy[0].four_layer_tx_with_tm3_and_tm4 = 6; + + in.pnf_phy_rel11.tl.tag = NFAPI_PNF_PHY_REL11_TAG; + in.pnf_phy_rel11.number_of_phys = 2; + in.pnf_phy_rel11.phy[0].phy_config_index = 0; + in.pnf_phy_rel11.phy[0].edpcch_supported = 1; + in.pnf_phy_rel11.phy[0].multi_ack_csi_reporting = 2; + in.pnf_phy_rel11.phy[0].pucch_tx_diversity = 3; + in.pnf_phy_rel11.phy[0].ul_comp_supported = 4; + in.pnf_phy_rel11.phy[0].transmission_mode_5_supported = 5; + + in.pnf_phy_rel12.tl.tag = NFAPI_PNF_PHY_REL12_TAG; + in.pnf_phy_rel12.number_of_phys = 2; + in.pnf_phy_rel12.phy[0].phy_config_index = 0; + in.pnf_phy_rel12.phy[0].csi_subframe_set = 1; + in.pnf_phy_rel12.phy[0].enhanced_4tx_codebook = 2; + in.pnf_phy_rel12.phy[0].drs_supported = 3; + in.pnf_phy_rel12.phy[0].ul_64qam_supported = 4; + in.pnf_phy_rel12.phy[0].transmission_mode_10_supported = 5; + in.pnf_phy_rel12.phy[0].alternative_bts_indices = 6; + + in.pnf_phy_rel13.tl.tag = NFAPI_PNF_PHY_REL13_TAG; + in.pnf_phy_rel13.number_of_phys = 2; + in.pnf_phy_rel13.phy[0].phy_config_index = 0; + in.pnf_phy_rel13.phy[0].pucch_format4_supported = 1; + in.pnf_phy_rel13.phy[0].pucch_format5_supported = 2; + in.pnf_phy_rel13.phy[0].more_than_5_ca_support = 3; + in.pnf_phy_rel13.phy[0].laa_supported = 4; + in.pnf_phy_rel13.phy[0].laa_ending_in_dwpts_supported = 5; + in.pnf_phy_rel13.phy[0].laa_starting_in_second_slot_supported = 6; + in.pnf_phy_rel13.phy[0].beamforming_supported = 7; + in.pnf_phy_rel13.phy[0].csi_rs_enhancement_supported = 8; + in.pnf_phy_rel13.phy[0].drms_enhancement_supported = 9; + in.pnf_phy_rel13.phy[0].srs_enhancement_supported = 10; +*/ + test_param_request_called++; + + nfapi_pnf_pnf_param_resp(config, &resp); + return 0; +} + +int test_config_request_called = 0; +int test_pnf_config_request(nfapi_pnf_config_t* config, nfapi_pnf_config_request_t* req) +{ + printf("test_pnf_config_request called.... ;-)\n"); + + CU_ASSERT_EQUAL(req->pnf_phy_rf_config.tl.tag, NFAPI_PNF_PHY_RF_TAG); + + if(config->user_data != 0) + { + pnf_info_t* pnf = (pnf_info_t*)(config->user_data); + int i = 0; + for(i = 0; i < req->pnf_phy_rf_config.number_phy_rf_config_info; ++i) + { + pnf->phys[i].enabled = 1; + pnf->phys[i].phy_id = req->pnf_phy_rf_config.phy_rf_config[i].phy_id; + printf("test_pnf_config_request creating phy %d\n", pnf->phys[i].phy_id); + + } + } + + 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); + + test_config_request_called++; + return 0; +} +int test_pnf_start_request(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req) +{ + printf("test_pnf_start_request called.... ;-)\n"); + + nfapi_pnf_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_START_RESPONSE; + resp.error_code = NFAPI_MSG_OK; + nfapi_pnf_pnf_start_resp(config, &resp); + return 0; +} +int test_pnf_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_stop_request_t* req) +{ + printf("test_pnf_stop_request called.... ;-)\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); + return 0; +} +int test_param_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_param_request_t* req) +{ + printf("test_param_request called.... ;-)\n"); + + nfapi_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PARAM_RESPONSE; + resp.header.phy_id = req->header.phy_id; + resp.error_code = NFAPI_MSG_OK; + + if(config->user_data != 0) + { + phy_info_t* phy_info = find_phy_info((pnf_info_t*)(config->user_data), req->header.phy_id); + + resp.nfapi_config.p7_pnf_port.tl.tag = NFAPI_NFAPI_P7_PNF_PORT_TAG; + resp.nfapi_config.p7_pnf_port.value = phy_info->pnf_p7_port; + resp.num_tlv++; + + resp.nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_PNF_PORT_TAG; + struct sockaddr_in pnf_p7_sockaddr; + pnf_p7_sockaddr.sin_addr.s_addr = inet_addr(phy_info->pnf_p7_addr); + memcpy(&(resp.nfapi_config.p7_pnf_address_ipv4.address[0]), &pnf_p7_sockaddr.sin_addr.s_addr, 4); + resp.num_tlv++; + } + + + + + nfapi_pnf_param_resp(config, &resp); + return 0; +} +int test_config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_config_request_t* req) +{ + printf("test_config_request called.... ;-)\n"); + + if(config->user_data != 0) + { + phy_info_t* phy_info = find_phy_info((pnf_info_t*)(config->user_data), req->header.phy_id); + + if(req->nfapi_config.p7_vnf_port.tl.tag == NFAPI_NFAPI_P7_VNF_PORT_TAG) + { + phy_info->vnf_p7_port = req->nfapi_config.p7_vnf_port.value; + printf("vnf_p7_port %d\n", phy_info->vnf_p7_port); + } + + if(req->nfapi_config.p7_vnf_address_ipv4.tl.tag == NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG) + { + struct sockaddr_in addr; + memcpy(&addr.sin_addr.s_addr, req->nfapi_config.p7_vnf_address_ipv4.address, 4); + char* ip = inet_ntoa(addr.sin_addr); + phy_info->vnf_p7_addr = ip; + printf("vnf_p7_addr %s\n", phy_info->vnf_p7_addr); + } + + + } + + nfapi_config_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_CONFIG_RESPONSE; + resp.header.phy_id = req->header.phy_id; + resp.error_code = NFAPI_MSG_OK; + nfapi_pnf_config_resp(config, &resp); + return 0; +} +int test_dl_config_req(nfapi_pnf_p7_config_t* config, nfapi_dl_config_request_t* req) +{ + printf("test_dl_config_req called.... ;-)\n"); + return 0; +} + +int test_ul_config_req(nfapi_pnf_p7_config_t* config, nfapi_ul_config_request_t* req) +{ + printf("test_ul_config_req called.... ;-)\n"); + return 0; +} +int test_hi_dci0_req(nfapi_pnf_p7_config_t* config, nfapi_hi_dci0_request_t* req) +{ + printf("test_hi_dci0_req called.... ;-)\n"); + return 0; +} +int test_tx_req(nfapi_pnf_p7_config_t* config, nfapi_tx_request_t* req) +{ + printf("test_tx_req called.... ;-)\n"); + return 0; +} +int test_lbt_dl_config_req(nfapi_pnf_p7_config_t* config, nfapi_lbt_dl_config_request_t* req) +{ + printf("test_lbt_dl_req called.... ;-)\n"); + return 0; +} +int test_start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_start_request_t* req) +{ + printf("test_start_request called.... ;-)\n"); + + + if(config->user_data != 0) + { + phy_info_t* phy_info = find_phy_info((pnf_info_t*)(config->user_data), req->header.phy_id); + + phy_info->config = nfapi_pnf_p7_config_create(); + phy_info->config->local_p7_port = phy_info->pnf_p7_port; + + phy_info->config->remote_p7_port = phy_info->vnf_p7_port; + phy_info->config->remote_p7_addr = phy_info->vnf_p7_addr; + + phy_info->config->dl_config_req = &test_dl_config_req; + phy_info->config->ul_config_req = &test_ul_config_req; + phy_info->config->hi_dci0_req = &test_hi_dci0_req; + phy_info->config->tx_req = &test_tx_req; + phy_info->config->lbt_dl_config_req = &test_lbt_dl_config_req; + + //phy_info->config->subframe_buffer_size = 8; + //phy_info->config->timing_info_mode_periodic = 1; + //phy_info->config->timing_info_period = 32; + //phy_info->config->timing_info_mode_aperiodic = 1; + + phy_info->config->segment_size = 1400; + phy_info->config->checksum_enabled = 0; + + + pthread_create(&phy_info->thread, NULL, &pnf_test_start_p7_thread, phy_info->config); + } + + nfapi_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_START_RESPONSE; + resp.header.phy_id = req->header.phy_id; + resp.error_code = NFAPI_MSG_OK; + nfapi_pnf_start_resp(config, &resp); + return 0; +} +int test_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_stop_request_t* req) +{ + printf("test_stop_request called.... ;-)\n"); + + nfapi_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_STOP_RESPONSE; + resp.header.phy_id = req->header.phy_id; + resp.error_code = NFAPI_MSG_OK; + nfapi_pnf_stop_resp(config, &resp); + return 0; +} + +int send_p5_message(int p5Sock, nfapi_p4_p5_message_header_t* msg, unsigned msg_size, struct sockaddr* addr, socklen_t addr_size) +{ + char buffer[256]; + int encoded_size = nfapi_p5_message_pack(msg, msg_size, buffer, sizeof(buffer), 0); + int result = sendto(p5Sock, buffer, encoded_size, 0, addr, addr_size); + return result; +} + +int send_p7_message(int p7Sock, nfapi_p7_message_header_t* msg, unsigned msg_size, struct sockaddr_in* addr, socklen_t addr_size) +{ + char buffer[256]; + int encoded_size = nfapi_p7_message_pack(msg, buffer, sizeof(buffer), 0); + int result = sendto(p7Sock, buffer, encoded_size, 0, (struct sockaddr*)addr, addr_size); + + printf("send_p7_message result %d\n", result); + return result; +} +int send_p7_segmented_message(int p7Sock, nfapi_p7_message_header_t* msg, unsigned msg_size, struct sockaddr_in* addr, socklen_t addr_size) +{ + char buffer[1024 * 10]; + int encoded_size = nfapi_p7_message_pack(msg, buffer, sizeof(buffer), 0); + + uint16_t segment_size = 256; + + if(encoded_size < segment_size) + { + int result = sendto(p7Sock, buffer, encoded_size, 0, (struct sockaddr*)addr, addr_size); + return result; + } + else + { + // printf("Segmenting p7 message %d\n", encoded_size); + + uint8_t segment_count = 0; + uint8_t buffer2[segment_size]; + uint32_t offset = 0; + uint16_t msg_size; + //uint8_t m = 1; + + do{ + + if(segment_count == 0) + { + msg_size = segment_size; + memcpy(&buffer2[0], &buffer[0], msg_size); + // M = 1 + buffer2[6] = (1 << 7) | (segment_count & 0x7F); + + offset = msg_size; + } + else + { + memcpy(&buffer2[0], &buffer[0], NFAPI_P7_HEADER_LENGTH); + + if(encoded_size - offset > segment_size) + { + // M = 1 + buffer2[6] = (1 << 7) | (segment_count & 0x7F); + msg_size = segment_size; + } + else + { + // M = 0 + buffer2[6] = (0 << 7) | (segment_count & 0x7F); + msg_size = encoded_size - offset + NFAPI_P7_HEADER_LENGTH; + } + + + memcpy(&buffer2[NFAPI_P7_HEADER_LENGTH], &buffer[offset], msg_size - NFAPI_P7_HEADER_LENGTH); + + offset += msg_size - NFAPI_P7_HEADER_LENGTH; + } + + uint8_t* p = &buffer2[4]; + push16(msg_size, &p, &buffer2[segment_size]); + + //printf("Segmenting p7 message %d %di %d\n", segment_count, msg_size, offset); + /*int result = */sendto(p7Sock, buffer2, msg_size, 0, (struct sockaddr*)addr, addr_size); + + segment_count++; + + }while(offset < encoded_size); + + } + + return 0; +} +int send_p7_segmented_message_outoforder(int p7Sock, nfapi_p7_message_header_t* msg, unsigned msg_size, struct sockaddr_in* addr, socklen_t addr_size) +{ + char buffer[1024 * 10]; + int encoded_size = nfapi_p7_message_pack(msg, buffer, sizeof(buffer), 0); + + uint16_t segment_size = 256; + + if(encoded_size < segment_size) + { + int result = sendto(p7Sock, buffer, encoded_size, 0, (struct sockaddr*)addr, addr_size); + return result; + } + else + { + // printf("Segmenting p7 message %d\n", encoded_size); + + uint8_t segment_count = 0; + uint8_t buffer2[128][segment_size]; + uint32_t offset = 0; + uint16_t msg_size[128]; + uint8_t i = 0; + + do{ + + if(segment_count == 0) + { + msg_size[i] = segment_size; + memcpy(&buffer2[i][0], &buffer[0], msg_size[i]); + // M = 1 + buffer2[i][6] = (1 << 7) | (segment_count & 0x7F); + + offset = msg_size[i]; + } + else + { + memcpy(&buffer2[i][0], &buffer[0], NFAPI_P7_HEADER_LENGTH); + + if(encoded_size - offset > segment_size) + { + // M = 1 + buffer2[i][6] = (1 << 7) | (segment_count & 0x7F); + msg_size[i] = segment_size; + } + else + { + // M = 0 + buffer2[i][6] = (0 << 7) | (segment_count & 0x7F); + msg_size[i] = encoded_size - offset + NFAPI_P7_HEADER_LENGTH; + } + + + memcpy(&buffer2[i][NFAPI_P7_HEADER_LENGTH], &buffer[offset], msg_size[i] - NFAPI_P7_HEADER_LENGTH); + + offset += msg_size[i] - NFAPI_P7_HEADER_LENGTH; + } + + uint8_t* p = &buffer2[i][4]; + push16(msg_size[i], &p, &buffer2[i][segment_size]); + + + segment_count++; + i++; + + }while(offset < encoded_size); + + // send all odd then send event + uint8_t e = 0; + uint8_t o = 1; + while(o <= i) + { + sendto(p7Sock, &buffer2[o][0], msg_size[o], 0, (struct sockaddr*)addr, addr_size); + o += 2; + } + while(e <= i) + { + sendto(p7Sock, &buffer2[e][0], msg_size[e], 0, (struct sockaddr*)addr, addr_size); + e += 2; + } + + } + + return 0; +} + +int get_p7_segmented_message(int p7Sock, nfapi_p7_message_header_t* msg, unsigned _msg_size, struct sockaddr_in* addr, socklen_t addr_size, uint8_t (buffer2)[][256], uint16_t msg_size[256], uint8_t i) +{ + char buffer[1024 * 10]; + int encoded_size = nfapi_p7_message_pack(msg, buffer, sizeof(buffer), 0); + + uint16_t segment_size = 256; + + printf("get_p7_segmented_message size %d\n", encoded_size); + + if(encoded_size < segment_size) + { + msg_size[i] = encoded_size; + memcpy(&buffer2[i][0], &buffer[0], msg_size[i]); + i++; + } + else + { + uint8_t segment_count = 0; + uint32_t offset = 0; + + do{ + + if(segment_count == 0) + { + msg_size[i] = segment_size; + memcpy(&buffer2[i][0], &buffer[0], msg_size[i]); + // M = 1 + (buffer2[i][6]) = (1 << 7) | (segment_count & 0x7F); + + offset = msg_size[i]; + } + else + { + memcpy(&buffer2[i][0], &buffer[0], NFAPI_P7_HEADER_LENGTH); + + if(encoded_size - offset > segment_size) + { + // M = 1 + (buffer2[i][6]) = (1 << 7) | (segment_count & 0x7F); + msg_size[i] = segment_size; + } + else + { + // M = 0 + (buffer2[i][6]) = (0 << 7) | (segment_count & 0x7F); + msg_size[i] = encoded_size - offset + NFAPI_P7_HEADER_LENGTH; + } + + + memcpy(&buffer2[i][NFAPI_P7_HEADER_LENGTH], &buffer[offset], msg_size[i] - NFAPI_P7_HEADER_LENGTH); + + offset += msg_size[i] - NFAPI_P7_HEADER_LENGTH; + } + + uint8_t* p = &buffer2[i][4]; + push16(msg_size[i], &p, &buffer2[i][segment_size]); + + + segment_count++; + i++; + + }while(offset < encoded_size); + + } + + return i; +} + + +int recv_p5_message(int p5Sock, nfapi_p4_p5_message_header_t* msg, unsigned msg_size) +{ + //struct sockaddr_in addr2; + //socklen_t addr2len; + char buffer2[1024]; + int result2 = recv(p5Sock, buffer2, sizeof(buffer2), 0); //, (struct sockaddr*)&addr2, &addr2len); + + if(result2 == -1) + { + printf("%s recvfrom failed errno:%d\n", __FUNCTION__, errno); + } + else + { + /*int unpack_result =*/ nfapi_p5_message_unpack(buffer2, result2, msg, msg_size, 0); //, sizeof(resp)); + } + return 0; +} + +int recv_p7_message(int p7Sock, nfapi_p7_message_header_t* msg, unsigned msg_size) +{ + char buffer2[2560]; + int result2 = recvfrom(p7Sock, buffer2, sizeof(buffer2), 0, 0, 0); + + if(result2 == -1) + { + printf("%s recvfrom failed errno:%d\n", __FUNCTION__, errno); + } + else + { + /*int unpack_result =*/ nfapi_p7_message_unpack(buffer2, result2, msg, msg_size, 0); //, sizeof(resp)); + } + return 0; +} + +int send_pnf_param_request(int p5Sock, struct sockaddr* addr, socklen_t addr_size) +{ + printf("%s\n", __FUNCTION__); + nfapi_pnf_param_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_PARAM_REQUEST; + req.header.message_length = 0; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); + return 0; +} + +int receive_pnf_param_response(int p5Sock, uint8_t error_code) +{ + nfapi_pnf_param_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + printf("0x%x\n", resp.header.message_id); + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_PNF_PARAM_RESPONSE); + if(resp.header.message_id == NFAPI_PNF_PARAM_RESPONSE) + { + printf("decoded nfapi_pnf_param_response\n"); + CU_ASSERT_EQUAL(resp.error_code, error_code); + if(error_code == NFAPI_MSG_OK) + { + CU_ASSERT_EQUAL(resp.pnf_param_general.tl.tag, NFAPI_PNF_PARAM_GENERAL_TAG); + CU_ASSERT_EQUAL(resp.pnf_param_general.nfapi_sync_mode, 2); + CU_ASSERT_EQUAL(resp.pnf_param_general.location_mode, 1); + } + } + return 0; +} + +int send_pnf_config_request(int p5Sock, struct sockaddr* addr, socklen_t addr_size) +{ + nfapi_pnf_config_request_t req; + req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; + req.header.message_length = 0; + + req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; + req.pnf_phy_rf_config.number_phy_rf_config_info = 1; + req.pnf_phy_rf_config.phy_rf_config[0].phy_id = 0; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); + return 0; +} + +int receive_pnf_config_response(int p5Sock) +{ + nfapi_pnf_config_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_PNF_CONFIG_RESPONSE); + if(resp.header.message_id == NFAPI_PNF_CONFIG_RESPONSE) + { + printf("decoded nfapi_pnf_config_response\n"); + } + return 0; +} + +void send_pnf_start_request(int p5Sock, struct sockaddr* addr, socklen_t addr_size) +{ + nfapi_pnf_start_request_t req; + req.header.message_id = NFAPI_PNF_START_REQUEST; + req.header.message_length = 0; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); +} + +void receive_pnf_start_response(int p5Sock) +{ + nfapi_pnf_start_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_PNF_START_RESPONSE); + if(resp.header.message_id == NFAPI_PNF_START_RESPONSE) + { + printf("decoded nfapi_pnf_start_response\n"); + } +} + +void send_pnf_stop_request(int p5Sock, struct sockaddr* addr, socklen_t addr_size) +{ + nfapi_pnf_stop_request_t req; + req.header.message_id = NFAPI_PNF_STOP_REQUEST; + req.header.message_length = 0; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); +} + +void receive_pnf_stop_response(int p5Sock) +{ + nfapi_pnf_stop_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_PNF_STOP_RESPONSE); + if(resp.header.message_id == NFAPI_PNF_STOP_RESPONSE) + { + printf("decoded nfapi_pnf_stop_response\n"); + } +} + +void send_param_request(int p5Sock, int phy_id, struct sockaddr* addr, socklen_t addr_size) +{ + nfapi_param_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PARAM_REQUEST; + req.header.phy_id = phy_id; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); +} +void receive_param_response(int p5Sock) +{ + nfapi_pnf_stop_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_PARAM_RESPONSE); + if(resp.header.message_id == NFAPI_PARAM_RESPONSE) + { + printf("decoded nfapi_param_response\n"); + } +} +void send_config_request(int p5Sock, int phy_id, struct sockaddr* addr, socklen_t addr_size, pnf_info_t* pnf_info) +{ + nfapi_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_CONFIG_REQUEST; + req.header.phy_id = phy_id; + + phy_info_t* phy_info = find_phy_info(pnf_info, phy_id); + + req.nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG; + req.nfapi_config.p7_vnf_port.value = phy_info->vnf_p7_port; + req.num_tlv++; + + //req.nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; + //req.num_tlv++; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); +} +void receive_config_response(int p5Sock) +{ + nfapi_pnf_stop_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_CONFIG_RESPONSE); + if(resp.header.message_id == NFAPI_CONFIG_RESPONSE) + { + printf("decoded nfapi_config_response\n"); + } +} +void send_start_request(int p5Sock, int phy_id, struct sockaddr* addr, socklen_t addr_size) +{ + nfapi_start_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_START_REQUEST; + req.header.phy_id = phy_id; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); +} +void receive_start_response(int p5Sock) +{ + nfapi_pnf_start_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_START_RESPONSE); + if(resp.header.message_id == NFAPI_START_RESPONSE) + { + printf("decoded nfapi_start_response\n"); + } +} +void send_stop_request(int p5Sock, int phy_id, struct sockaddr* addr, socklen_t addr_size) +{ + nfapi_start_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_STOP_REQUEST; + req.header.phy_id = phy_id; + + send_p5_message(p5Sock, &(req.header), sizeof(req), addr, addr_size); +} + +void receive_stop_response(int p5Sock) +{ + nfapi_pnf_stop_response_t resp; + recv_p5_message(p5Sock, &(resp.header), sizeof(resp)); + + CU_ASSERT_EQUAL(resp.header.message_id, NFAPI_STOP_RESPONSE); + if(resp.header.message_id == NFAPI_STOP_RESPONSE) + { + printf("decoded nfapi_stop_response\n"); + } +} + +void send_dl_node_sync(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_dl_node_sync_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_DL_NODE_SYNC; + req.header.phy_id = phy_id; + req.t1 = 1977; + req.delta_sfn_sf = 5000; + + send_p7_message(p7Sock, &(req.header), sizeof(req), addr, addr_size); +} +void receive_ul_node_sync(int p7Sock) +{ + nfapi_ul_node_sync_t sync; + recv_p7_message(p7Sock, &(sync.header), sizeof(sync)); + + CU_ASSERT_EQUAL(sync.header.message_id, NFAPI_UL_NODE_SYNC); + if(sync.header.message_id == NFAPI_UL_NODE_SYNC) + { + printf("decoded nfapi_ul_node_sync t1:%d t2:%d t3:%d\n", + sync.t1, sync.t2, sync.t3); + } +} + +void receive_timing_info(int p7Sock) +{ + nfapi_timing_info_t timing_info; + recv_p7_message(p7Sock, &(timing_info.header), sizeof(timing_info)); + + CU_ASSERT_EQUAL(timing_info.header.message_id, NFAPI_TIMING_INFO); + if(timing_info.header.message_id == NFAPI_TIMING_INFO) + { + printf("decoded nfapi_timing_info\n"); + } + else + { + printf("decoded ?? 0x%x\n", timing_info.header.message_id); + } +} +void send_dl_config_req(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size, uint16_t sfn_sf) +{ + nfapi_dl_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_DL_CONFIG_REQUEST; + req.header.phy_id = phy_id; + req.sfn_sf = sfn_sf; + + send_p7_message(p7Sock, &(req.header), sizeof(req), addr, addr_size); +} +void send_ul_config_req(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size, uint16_t sfn_sf) +{ + nfapi_ul_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_UL_CONFIG_REQUEST; + req.header.phy_id = phy_id; + req.sfn_sf = sfn_sf; + + send_p7_message(p7Sock, &(req.header), sizeof(req), addr, addr_size); +} +void send_hi_dci0_req(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size, uint16_t sfn_sf) +{ + nfapi_hi_dci0_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_HI_DCI0_REQUEST; + req.header.phy_id = phy_id; + req.sfn_sf = sfn_sf; + + send_p7_message(p7Sock, &(req.header), sizeof(req), addr, addr_size); +} +void send_tx_req(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size, uint16_t sfn_sf) +{ + nfapi_tx_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_TX_REQUEST; + req.header.phy_id = phy_id; + req.sfn_sf = sfn_sf; + send_p7_message(p7Sock, &(req.header), sizeof(req), addr, addr_size); +} + +void send_tx_req_1(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size, uint16_t sfn_sf) +{ + nfapi_tx_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_TX_REQUEST; + req.header.phy_id = phy_id; + req.sfn_sf = sfn_sf; + req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + req.tx_request_body.number_of_pdus = 8; + req.tx_request_body.tx_pdu_list = (nfapi_tx_request_pdu_t*)(malloc(sizeof(nfapi_tx_request_t) * 8)); + uint8_t i = 0; + uint8_t test_pdu[1200]; + + for(i = 0; i < 8; i++) + { + req.tx_request_body.tx_pdu_list[i].pdu_length = sizeof(test_pdu); + req.tx_request_body.tx_pdu_list[i].pdu_index = i; + req.tx_request_body.tx_pdu_list[i].num_segments =1; + req.tx_request_body.tx_pdu_list[i].segments[0].segment_length = sizeof(test_pdu); + req.tx_request_body.tx_pdu_list[i].segments[0].segment_data = (void*)&test_pdu; + } + + send_p7_segmented_message(p7Sock, &(req.header), sizeof(req), addr, addr_size); + + free(req.tx_request_body.tx_pdu_list); + +} + +void send_tx_req_2(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size, uint16_t sfn_sf) +{ + nfapi_tx_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_TX_REQUEST; + req.header.phy_id = phy_id; + req.sfn_sf = sfn_sf; + req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + req.tx_request_body.number_of_pdus = 8; + req.tx_request_body.tx_pdu_list = (nfapi_tx_request_pdu_t*)(malloc(sizeof(nfapi_tx_request_t) * 8)); + uint8_t i = 0; + uint8_t test_pdu[1200]; + + for(i = 0; i < 8; i++) + { + req.tx_request_body.tx_pdu_list[i].pdu_length = sizeof(test_pdu); + req.tx_request_body.tx_pdu_list[i].pdu_index = i; + req.tx_request_body.tx_pdu_list[i].num_segments =1; + req.tx_request_body.tx_pdu_list[i].segments[0].segment_length = sizeof(test_pdu); + req.tx_request_body.tx_pdu_list[i].segments[0].segment_data = (void*)&test_pdu; + } + + send_p7_segmented_message_outoforder(p7Sock, &(req.header), sizeof(req), addr, addr_size); + + free(req.tx_request_body.tx_pdu_list); + +} +void send_dl_subframe_msgs_interleaved(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size, uint16_t sfn_sf) +{ + + uint8_t buffer[256][256]; + uint16_t msg_size[256]; + uint16_t count = 0; + + { + nfapi_dl_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_DL_CONFIG_REQUEST; + req.header.phy_id = phy_id; + req.header.m_segment_sequence = 34; + req.sfn_sf = sfn_sf; + req.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + req.dl_config_request_body.number_pdu = 8; + req.dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)malloc(sizeof(nfapi_dl_config_request_pdu_t) * 8); + + uint8_t i = 0; + for(i = 0; i < 8; i++) + { + nfapi_dl_config_request_pdu_t* pdu = &(req.dl_config_request_body.dl_config_pdu_list[i]); + pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + } + + + count = get_p7_segmented_message(p7Sock, &(req.header), sizeof(req), addr, addr_size, buffer, msg_size, count); + } + + { + nfapi_ul_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_UL_CONFIG_REQUEST; + req.header.phy_id = phy_id; + req.header.m_segment_sequence = 35; + req.sfn_sf = sfn_sf; + + count = get_p7_segmented_message(p7Sock, &(req.header), sizeof(req), addr, addr_size, buffer, msg_size, count); + } + + { + nfapi_hi_dci0_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_HI_DCI0_REQUEST; + req.header.phy_id = phy_id; + req.header.m_segment_sequence = 36; + req.sfn_sf = sfn_sf; + count = get_p7_segmented_message(p7Sock, &(req.header), sizeof(req), addr, addr_size, buffer, msg_size, count); + } + + { + nfapi_tx_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_TX_REQUEST; + req.header.phy_id = phy_id; + req.header.m_segment_sequence = 37; + req.sfn_sf = sfn_sf; + req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + req.tx_request_body.number_of_pdus = 8; + req.tx_request_body.tx_pdu_list = (nfapi_tx_request_pdu_t*)(malloc(sizeof(nfapi_tx_request_t) * 8)); + uint8_t i = 0; + uint8_t test_pdu[1200]; + + for(i = 0; i < 8; i++) + { + req.tx_request_body.tx_pdu_list[i].pdu_length = sizeof(test_pdu); + req.tx_request_body.tx_pdu_list[i].pdu_index = i; + req.tx_request_body.tx_pdu_list[i].num_segments =1; + req.tx_request_body.tx_pdu_list[i].segments[0].segment_length = sizeof(test_pdu); + req.tx_request_body.tx_pdu_list[i].segments[0].segment_data = (void*)&test_pdu; + } + + count = get_p7_segmented_message(p7Sock, &(req.header), sizeof(req), addr, addr_size, buffer, msg_size, count); + } + + // send all odd then send event + uint8_t e = 0; + uint8_t o = 1; + while(o <= count) + { + if(msg_size[o] == 0) + printf("**** Sending a zero length msg %d\n", o); + sendto(p7Sock, &buffer[o][0], msg_size[o], 0, (struct sockaddr*)addr, addr_size); + o += 2; + } + while(e <= count) + { + if(msg_size[e] == 0) + printf("**** Sending a zero length msg %d\n", e); + + sendto(p7Sock, &buffer[e][0], msg_size[e], 0, (struct sockaddr*)addr, addr_size); + e += 2; + } + //free(req.tx_request_body.tx_pdu_list); +} + +void send_subframe_indication(phy_info_t* phy_info) +{ + nfapi_pnf_p7_subframe_ind(phy_info->config, phy_info->phy_id, phy_info->sfn_sf); +} + +void send_harq_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_harq_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_HARQ_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_harq_ind((phy_info->config), &ind); +} +void recieve_harq_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_harq_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_HARQ_INDICATION); + if(ind.header.message_id == NFAPI_HARQ_INDICATION) + { + printf("decoded nfapi_harq_indication\n"); + } + else + { + printf("decoded ?? 0x%x\n", ind.header.message_id); + } +} + +void send_crc_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_crc_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_CRC_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_crc_ind((phy_info->config), &ind); + +} +void recieve_crc_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_crc_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_CRC_INDICATION); + if(ind.header.message_id == NFAPI_CRC_INDICATION) + { + printf("decoded nfapi_crc_indication\n"); + } +} + +void send_rx_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_rx_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_RX_ULSCH_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_rx_ind((phy_info->config), &ind); +} +void recieve_rx_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_rx_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_RX_ULSCH_INDICATION); + if(ind.header.message_id == NFAPI_RX_ULSCH_INDICATION) + { + printf("decoded nfapi_rx_indication\n"); + } +} + +void send_rach_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_rach_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_RACH_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_rach_ind((phy_info->config), &ind); +} +void recieve_rach_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_rach_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_RACH_INDICATION); + if(ind.header.message_id == NFAPI_RACH_INDICATION) + { + printf("decoded nfapi_rach_indication\n"); + } +} + +void send_srs_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_srs_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_SRS_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_srs_ind((phy_info->config), &ind); +} +void recieve_srs_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_srs_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_SRS_INDICATION); + if(ind.header.message_id == NFAPI_SRS_INDICATION) + { + printf("decoded nfapi_srs_indication\n"); + } +} + +void send_sr_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_sr_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_RX_SR_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_sr_ind((phy_info->config), &ind); +} +void recieve_sr_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_sr_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_RX_SR_INDICATION); + if(ind.header.message_id == NFAPI_RX_SR_INDICATION) + { + printf("decoded nfapi_sr_indication\n"); + } +} + +void send_cqi_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_cqi_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_RX_CQI_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_cqi_ind((phy_info->config), &ind); +} +void recieve_cqi_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_cqi_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_RX_CQI_INDICATION); + if(ind.header.message_id == NFAPI_RX_CQI_INDICATION) + { + printf("decoded nfapi_cqi_indication\n"); + } +} + +void send_lbt_dl_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_lbt_dl_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_LBT_DL_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_lbt_dl_ind((phy_info->config), &ind); +} +void recieve_lbt_dl_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_lbt_dl_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_LBT_DL_INDICATION); + if(ind.header.message_id == NFAPI_LBT_DL_INDICATION) + { + printf("decoded nfapi_lbt_dl_indication\n"); + } +} + +void send_nb_harq_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_nb_harq_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_NB_HARQ_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_nb_harq_ind((phy_info->config), &ind); +} +void recieve_nb_harq_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_nb_harq_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_NB_HARQ_INDICATION); + if(ind.header.message_id == NFAPI_NB_HARQ_INDICATION) + { + printf("decoded nfapi_nb_harq_indication\n"); + } +} + +void send_nrach_ind(phy_info_t* phy_info, uint16_t sfn_sf) +{ + nfapi_nrach_indication_t ind; + memset(&ind, 0, sizeof(ind)); + ind.header.message_id = NFAPI_NRACH_INDICATION; + ind.header.phy_id = phy_info->phy_id; + ind.sfn_sf = sfn_sf; + + nfapi_pnf_p7_nrach_ind((phy_info->config), &ind); +} +void recieve_nrach_ind(int p7Sock, int phy_id, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_nrach_indication_t ind; + recv_p7_message(p7Sock, &(ind.header), sizeof(ind)); + + CU_ASSERT_EQUAL(ind.header.message_id, NFAPI_NRACH_INDICATION); + if(ind.header.message_id == NFAPI_NRACH_INDICATION) + { + printf("decoded nfapi_nrach_indication\n"); + } +} + +void pnf_test_start_connect(void) +{ + pnf_info_t pnf_info; + pnf_info.num_phys = 1; + pnf_info.phys[0].pnf_p7_port = 9345; + pnf_info.phys[0].pnf_p7_addr = "127.0.0.1"; + pnf_info.phys[0].vnf_p7_port = 8875; + pnf_info.phys[0].vnf_p7_addr = "127.0.0.1"; + + char* vnf_addr = "127.0.0.1"; + int vnf_port = 6699; + + int p5ListenSock = create_p5_listen_socket(vnf_addr, vnf_port); + printf("p5ListenSock %d %d\n", p5ListenSock, errno); + listen(p5ListenSock, 2); + + test_param_request_called = 0; + test_config_request_called = 0; + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + config->vnf_p5_port = vnf_port; + config->pnf_param_req = &test_pnf_param_request; + config->pnf_config_req = &test_pnf_config_request; + config->pnf_start_req = &test_pnf_start_request; + config->pnf_stop_req = &test_pnf_stop_request; + config->param_req = &test_param_request; + config->config_req = &test_config_request; + config->start_req = &test_start_request; + config->stop_req = &test_stop_request; + + config->user_data = &pnf_info; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + struct sockaddr_in addr; + socklen_t addrSize = sizeof(addr);; + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + printf("p5 connection accepted %d %d\n", p5Sock, errno); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_OK); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + send_pnf_start_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_start_response(p5Sock); + + send_param_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_param_response(p5Sock); + + + send_config_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize, &pnf_info); + receive_config_response(p5Sock); + + send_start_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_start_response(p5Sock); + + sleep(2); + + int p7Sock = socket(AF_INET, SOCK_DGRAM, 0); + + { + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(pnf_info.phys[0].vnf_p7_port); + addr.sin_addr.s_addr = INADDR_ANY; + + bind(p7Sock, (struct sockaddr*)&addr, sizeof(addr)); + } + + printf("Sending p7 messages too %s:%d\n", pnf_info.phys[0].pnf_p7_addr, pnf_info.phys[0].pnf_p7_port); + + struct sockaddr_in p7_addr; + p7_addr.sin_family = AF_INET; + p7_addr.sin_port = htons(pnf_info.phys[0].pnf_p7_port); + p7_addr.sin_addr.s_addr = inet_addr(pnf_info.phys[0].pnf_p7_addr); + socklen_t p7_addrSize = sizeof(p7_addr); + + send_dl_node_sync(p7Sock, 0, &p7_addr, p7_addrSize); + receive_ul_node_sync(p7Sock); + + +#define SFNSF(_sfn, _sf) ((_sfn << 4) + _sf) + + uint16_t sfn_sf = SFNSF(500, 3); // sfn:500 sf:3 + pnf_info.phys[0].sfn_sf = sfn_sf; + send_subframe_indication(&(pnf_info.phys[0])); + + // should generate dummy messages + + usleep(500); + + sfn_sf = SFNSF(500, 4); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + + send_dl_config_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_ul_config_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_hi_dci0_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_tx_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + + + usleep(500); + + send_subframe_indication(&(pnf_info.phys[0])); + // should send the cached messages + + send_harq_ind(&pnf_info.phys[0], sfn_sf); + recieve_harq_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_crc_ind(&pnf_info.phys[0], sfn_sf); + recieve_crc_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rx_ind(&pnf_info.phys[0], sfn_sf); + recieve_rx_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rach_ind(&pnf_info.phys[0], sfn_sf); + recieve_rach_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_srs_ind(&pnf_info.phys[0], sfn_sf); + recieve_srs_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_sr_ind(&pnf_info.phys[0], sfn_sf); + recieve_sr_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_cqi_ind(&pnf_info.phys[0], sfn_sf); + recieve_cqi_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_lbt_dl_ind(&pnf_info.phys[0], sfn_sf); + recieve_lbt_dl_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_nb_harq_ind(&pnf_info.phys[0], sfn_sf); + recieve_nb_harq_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_nrach_ind(&pnf_info.phys[0], sfn_sf); + recieve_nrach_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + + // send out of window dl_config, should expect the timing info + send_dl_config_req(p7Sock, 0, &p7_addr, p7_addrSize, SFNSF(600, 0)); + + sfn_sf = SFNSF(500, 5); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + usleep(500); + + send_subframe_indication(&(pnf_info.phys[0])); + receive_timing_info(p7Sock); + + send_stop_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_stop_response(p5Sock); + + + + send_pnf_stop_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_stop_response(p5Sock); + + nfapi_pnf_stop(config); + + int* result; + pthread_join(thread, (void**)&result); + //CU_ASSERT_NOT_EQUAL(*result, -1); + CU_ASSERT_EQUAL(test_param_request_called, 1); + CU_ASSERT_EQUAL(test_config_request_called, 1); + + close(p5Sock); + close(p5ListenSock); + +} +void pnf_test_start_connect_ipv6(void) +{ + pnf_info_t pnf_info; + pnf_info.num_phys = 1; + pnf_info.phys[0].pnf_p7_port = 9345; + pnf_info.phys[0].pnf_p7_addr = "::1"; + pnf_info.phys[0].vnf_p7_port = 8875; + pnf_info.phys[0].vnf_p7_addr = "::1"; + + char* vnf_addr = "::1"; + int vnf_port = 6698; + + int p5ListenSock = create_p5_ipv6_listen_socket(vnf_addr, vnf_port); + printf("p5ListenSock ipv6 %d %d\n", p5ListenSock, errno); + int listen_result = listen(p5ListenSock, 2); + printf("Listen result %d\n", listen_result); + + test_param_request_called = 0; + test_config_request_called = 0; + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + config->vnf_p5_port = vnf_port; + config->pnf_param_req = &test_pnf_param_request; + config->pnf_config_req = &test_pnf_config_request; + config->pnf_start_req = &test_pnf_start_request; + config->pnf_stop_req = &test_pnf_stop_request; + config->param_req = &test_param_request; + config->config_req = &test_config_request; + config->start_req = &test_start_request; + config->stop_req = &test_stop_request; + + config->user_data = &pnf_info; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + struct sockaddr_in6 addr; + socklen_t addrSize = sizeof(addr);; + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + printf("p5 connection accepted %d %d\n", p5Sock, errno); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_OK); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + send_pnf_start_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_start_response(p5Sock); + + send_param_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_param_response(p5Sock); +} + +void pnf_test_state_pnf_config_invalid_state() +{ + char* vnf_addr = "127.0.0.1"; + int vnf_port = 4546; + + int p5ListenSock = create_p5_listen_socket(vnf_addr, vnf_port); + + test_param_request_called = 0; + test_config_request_called = 0; + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + config->vnf_p5_port = vnf_port; + config->pnf_param_req = &test_pnf_param_request; + config->pnf_config_req = &test_pnf_config_request; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + listen(p5ListenSock, 2); + struct sockaddr_in addr; + socklen_t addrSize = sizeof(addr); + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + printf("%s p5Sock %d errno %d\n", __FUNCTION__, p5Sock, errno); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_OK); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_INVALID_STATE); + + nfapi_pnf_stop(config); + + int* result; + pthread_join(thread, (void**)&result); + CU_ASSERT_EQUAL(result, 0); + CU_ASSERT_EQUAL(test_param_request_called, 1); + CU_ASSERT_EQUAL(test_config_request_called, 1); + + close(p5Sock); + close(p5ListenSock); + +} + +void pnf_test_state_pnf_param_invalid_state() +{ + pnf_info_t pnf_info; + + char* vnf_addr = "127.0.0.1"; + int vnf_port = 4547; + + int p5ListenSock = create_p5_listen_socket(vnf_addr, vnf_port); + + test_param_request_called = 0; + test_config_request_called = 0; + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + config->vnf_p5_port = vnf_port; + config->pnf_param_req = &test_pnf_param_request; + config->pnf_config_req = &test_pnf_config_request; + + config->user_data = &pnf_info; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + listen(p5ListenSock, 2); + struct sockaddr_in addr; + socklen_t addrSize = sizeof(addr); + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_OK); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + nfapi_pnf_stop(config); + + int* result; + pthread_join(thread, (void**)&result); + CU_ASSERT_EQUAL(result, 0); + CU_ASSERT_EQUAL(test_param_request_called, 1); + CU_ASSERT_EQUAL(test_config_request_called, 2); + + close(p5Sock); + close(p5ListenSock); + +} +void pnf_test_p7_segmentation_test_1(void) +{ + pnf_info_t pnf_info; + pnf_info.num_phys = 1; + pnf_info.phys[0].pnf_p7_port = 9348; + pnf_info.phys[0].pnf_p7_addr = "127.0.0.1"; + pnf_info.phys[0].vnf_p7_port = 8878; + pnf_info.phys[0].vnf_p7_addr = "127.0.0.1"; + + char* vnf_addr = "127.0.0.1"; + int vnf_port = 6699; + + int p5ListenSock = create_p5_listen_socket(vnf_addr, vnf_port); + printf("p5ListenSock %d %d\n", p5ListenSock, errno); + listen(p5ListenSock, 2); + + test_param_request_called = 0; + test_config_request_called = 0; + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + config->vnf_p5_port = vnf_port; + config->pnf_param_req = &test_pnf_param_request; + config->pnf_config_req = &test_pnf_config_request; + config->pnf_start_req = &test_pnf_start_request; + config->pnf_stop_req = &test_pnf_stop_request; + config->param_req = &test_param_request; + config->config_req = &test_config_request; + config->start_req = &test_start_request; + config->stop_req = &test_stop_request; + + config->user_data = &pnf_info; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + struct sockaddr_in addr; + socklen_t addrSize = sizeof(addr);; + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + printf("p5 connection accepted %d %d\n", p5Sock, errno); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_OK); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + send_pnf_start_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_start_response(p5Sock); + + send_param_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_param_response(p5Sock); + + + send_config_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize, &pnf_info); + receive_config_response(p5Sock); + + send_start_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_start_response(p5Sock); + + sleep(2); + + int p7Sock = socket(AF_INET, SOCK_DGRAM, 0); + + { + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(pnf_info.phys[0].vnf_p7_port); + addr.sin_addr.s_addr = INADDR_ANY; + + bind(p7Sock, (struct sockaddr*)&addr, sizeof(addr)); + } + + printf("Sending p7 messages too %s:%d\n", pnf_info.phys[0].pnf_p7_addr, pnf_info.phys[0].pnf_p7_port); + + struct sockaddr_in p7_addr; + p7_addr.sin_family = AF_INET; + p7_addr.sin_port = htons(pnf_info.phys[0].pnf_p7_port); + p7_addr.sin_addr.s_addr = inet_addr(pnf_info.phys[0].pnf_p7_addr); + socklen_t p7_addrSize = sizeof(p7_addr); + + send_dl_node_sync(p7Sock, 0, &p7_addr, p7_addrSize); + receive_ul_node_sync(p7Sock); + + +#define SFNSF(_sfn, _sf) ((_sfn << 4) + _sf) + + uint16_t sfn_sf = SFNSF(500, 3); // sfn:500 sf:3 + pnf_info.phys[0].sfn_sf = sfn_sf; + send_subframe_indication(&(pnf_info.phys[0])); + + // should generate dummy messages + + usleep(500); + + sfn_sf = SFNSF(500, 4); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + + send_dl_config_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_ul_config_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_hi_dci0_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_tx_req_1(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + + + usleep(500); + + send_subframe_indication(&(pnf_info.phys[0])); + // should send the cached messages + + send_harq_ind(&pnf_info.phys[0], sfn_sf); + recieve_harq_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_crc_ind(&pnf_info.phys[0], sfn_sf); + recieve_crc_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rx_ind(&pnf_info.phys[0], sfn_sf); + recieve_rx_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rach_ind(&pnf_info.phys[0], sfn_sf); + recieve_rach_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_srs_ind(&pnf_info.phys[0], sfn_sf); + recieve_srs_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_sr_ind(&pnf_info.phys[0], sfn_sf); + recieve_sr_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_cqi_ind(&pnf_info.phys[0], sfn_sf); + recieve_cqi_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_lbt_dl_ind(&pnf_info.phys[0], sfn_sf); + recieve_lbt_dl_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_nb_harq_ind(&pnf_info.phys[0], sfn_sf); + recieve_nb_harq_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_nrach_ind(&pnf_info.phys[0], sfn_sf); + recieve_nrach_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + + // send out of window dl_config, should expect the timing info + send_dl_config_req(p7Sock, 0, &p7_addr, p7_addrSize, SFNSF(600, 0)); + + sfn_sf = SFNSF(500, 5); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + usleep(500); + + send_subframe_indication(&(pnf_info.phys[0])); + receive_timing_info(p7Sock); + + nfapi_pnf_p7_stop(pnf_info.phys[0].config); + int* result; + pthread_join(pnf_info.phys[0].thread, (void**)&result); + close(p7Sock); + + send_stop_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_stop_response(p5Sock); + + send_pnf_stop_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_stop_response(p5Sock); + + nfapi_pnf_stop(config); + + pthread_join(thread, (void**)&result); + //CU_ASSERT_NOT_EQUAL(*result, -1); + CU_ASSERT_EQUAL(test_param_request_called, 1); + CU_ASSERT_EQUAL(test_config_request_called, 1); + + close(p5Sock); + close(p5ListenSock); + +} +void pnf_test_p7_segmentation_test_2(void) +{ + pnf_info_t pnf_info; + pnf_info.num_phys = 1; + pnf_info.phys[0].pnf_p7_port = 9348; + pnf_info.phys[0].pnf_p7_addr = "127.0.0.1"; + pnf_info.phys[0].vnf_p7_port = 8878; + pnf_info.phys[0].vnf_p7_addr = "127.0.0.1"; + + char* vnf_addr = "127.0.0.1"; + int vnf_port = 6699; + + int p5ListenSock = create_p5_listen_socket(vnf_addr, vnf_port); + printf("p5ListenSock %d %d\n", p5ListenSock, errno); + listen(p5ListenSock, 2); + + test_param_request_called = 0; + test_config_request_called = 0; + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + config->vnf_p5_port = vnf_port; + config->pnf_param_req = &test_pnf_param_request; + config->pnf_config_req = &test_pnf_config_request; + config->pnf_start_req = &test_pnf_start_request; + config->pnf_stop_req = &test_pnf_stop_request; + config->param_req = &test_param_request; + config->config_req = &test_config_request; + config->start_req = &test_start_request; + config->stop_req = &test_stop_request; + + config->user_data = &pnf_info; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + struct sockaddr_in addr; + socklen_t addrSize = sizeof(addr);; + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + printf("p5 connection accepted %d %d\n", p5Sock, errno); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_OK); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + send_pnf_start_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_start_response(p5Sock); + + send_param_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_param_response(p5Sock); + + + send_config_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize, &pnf_info); + receive_config_response(p5Sock); + + send_start_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_start_response(p5Sock); + + sleep(2); + + int p7Sock = socket(AF_INET, SOCK_DGRAM, 0); + + { + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(pnf_info.phys[0].vnf_p7_port); + addr.sin_addr.s_addr = INADDR_ANY; + + bind(p7Sock, (struct sockaddr*)&addr, sizeof(addr)); + } + + printf("Sending p7 messages too %s:%d\n", pnf_info.phys[0].pnf_p7_addr, pnf_info.phys[0].pnf_p7_port); + + struct sockaddr_in p7_addr; + p7_addr.sin_family = AF_INET; + p7_addr.sin_port = htons(pnf_info.phys[0].pnf_p7_port); + p7_addr.sin_addr.s_addr = inet_addr(pnf_info.phys[0].pnf_p7_addr); + socklen_t p7_addrSize = sizeof(p7_addr); + + send_dl_node_sync(p7Sock, 0, &p7_addr, p7_addrSize); + receive_ul_node_sync(p7Sock); + + +#define SFNSF(_sfn, _sf) ((_sfn << 4) + _sf) + + uint16_t sfn_sf = SFNSF(500, 3); // sfn:500 sf:3 + pnf_info.phys[0].sfn_sf = sfn_sf; + send_subframe_indication(&(pnf_info.phys[0])); + + // should generate dummy messages + + usleep(500); + + sfn_sf = SFNSF(500, 4); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + + send_dl_config_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_ul_config_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_hi_dci0_req(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + send_tx_req_2(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + + + usleep(500); + + send_subframe_indication(&(pnf_info.phys[0])); + // should send the cached messages + + send_harq_ind(&pnf_info.phys[0], sfn_sf); + recieve_harq_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_crc_ind(&pnf_info.phys[0], sfn_sf); + recieve_crc_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rx_ind(&pnf_info.phys[0], sfn_sf); + recieve_rx_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rach_ind(&pnf_info.phys[0], sfn_sf); + recieve_rach_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_srs_ind(&pnf_info.phys[0], sfn_sf); + recieve_srs_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_sr_ind(&pnf_info.phys[0], sfn_sf); + recieve_sr_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_cqi_ind(&pnf_info.phys[0], sfn_sf); + recieve_cqi_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_lbt_dl_ind(&pnf_info.phys[0], sfn_sf); + recieve_lbt_dl_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + // send out of window dl_config, should expect the timing info + send_dl_config_req(p7Sock, 0, &p7_addr, p7_addrSize, SFNSF(600, 0)); + + sfn_sf = SFNSF(500, 5); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + usleep(500); + + send_subframe_indication(&(pnf_info.phys[0])); + receive_timing_info(p7Sock); + + send_stop_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_stop_response(p5Sock); + + nfapi_pnf_p7_stop(pnf_info.phys[0].config); + int* result; + pthread_join(pnf_info.phys[0].thread, (void**)&result); + close(p7Sock); + + + send_pnf_stop_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_stop_response(p5Sock); + + nfapi_pnf_stop(config); + + pthread_join(thread, (void**)&result); + //CU_ASSERT_NOT_EQUAL(*result, -1); + CU_ASSERT_EQUAL(test_param_request_called, 1); + CU_ASSERT_EQUAL(test_config_request_called, 1); + + close(p5Sock); + close(p5ListenSock); + +} +void pnf_test_p7_segmentation_test_3(void) +{ + pnf_info_t pnf_info; + pnf_info.num_phys = 1; + pnf_info.phys[0].pnf_p7_port = 9348; + pnf_info.phys[0].pnf_p7_addr = "127.0.0.1"; + pnf_info.phys[0].vnf_p7_port = 8878; + pnf_info.phys[0].vnf_p7_addr = "127.0.0.1"; + + char* vnf_addr = "127.0.0.1"; + int vnf_port = 6699; + + int p5ListenSock = create_p5_listen_socket(vnf_addr, vnf_port); + printf("p5ListenSock %d %d\n", p5ListenSock, errno); + listen(p5ListenSock, 2); + + test_param_request_called = 0; + test_config_request_called = 0; + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + config->vnf_ip_addr = vnf_addr; + config->vnf_p5_port = vnf_port; + config->pnf_param_req = &test_pnf_param_request; + config->pnf_config_req = &test_pnf_config_request; + config->pnf_start_req = &test_pnf_start_request; + config->pnf_stop_req = &test_pnf_stop_request; + config->param_req = &test_param_request; + config->config_req = &test_config_request; + config->start_req = &test_start_request; + config->stop_req = &test_stop_request; + + config->user_data = &pnf_info; + + pthread_t thread; + pthread_create(&thread, NULL, &pnf_test_start_thread, config); + + struct sockaddr_in addr; + socklen_t addrSize = sizeof(addr);; + int p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + printf("p5 connection accepted %d %d\n", p5Sock, errno); + + send_pnf_param_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_param_response(p5Sock, NFAPI_MSG_OK); + + send_pnf_config_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_config_response(p5Sock); + + send_pnf_start_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_start_response(p5Sock); + + send_param_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_param_response(p5Sock); + + + send_config_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize, &pnf_info); + receive_config_response(p5Sock); + + send_start_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_start_response(p5Sock); + + sleep(2); + + int p7Sock = socket(AF_INET, SOCK_DGRAM, 0); + + { + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(pnf_info.phys[0].vnf_p7_port); + addr.sin_addr.s_addr = INADDR_ANY; + + bind(p7Sock, (struct sockaddr*)&addr, sizeof(addr)); + } + + printf("Sending p7 messages too %s:%d\n", pnf_info.phys[0].pnf_p7_addr, pnf_info.phys[0].pnf_p7_port); + + struct sockaddr_in p7_addr; + p7_addr.sin_family = AF_INET; + p7_addr.sin_port = htons(pnf_info.phys[0].pnf_p7_port); + p7_addr.sin_addr.s_addr = inet_addr(pnf_info.phys[0].pnf_p7_addr); + socklen_t p7_addrSize = sizeof(p7_addr); + + send_dl_node_sync(p7Sock, 0, &p7_addr, p7_addrSize); + receive_ul_node_sync(p7Sock); + + +#define SFNSF(_sfn, _sf) ((_sfn << 4) + _sf) + + uint16_t sfn_sf = SFNSF(500, 3); // sfn:500 sf:3 + pnf_info.phys[0].sfn_sf = sfn_sf; + send_subframe_indication(&(pnf_info.phys[0])); + + // should generate dummy messages + + usleep(500); + + sfn_sf = SFNSF(500, 4); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + + + send_dl_subframe_msgs_interleaved(p7Sock, 0, &p7_addr, p7_addrSize, sfn_sf); + + + usleep(500); + + send_subframe_indication(&(pnf_info.phys[0])); + // should send the cached messages + + send_harq_ind(&pnf_info.phys[0], sfn_sf); + recieve_harq_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_crc_ind(&pnf_info.phys[0], sfn_sf); + recieve_crc_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rx_ind(&pnf_info.phys[0], sfn_sf); + recieve_rx_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_rach_ind(&pnf_info.phys[0], sfn_sf); + recieve_rach_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_srs_ind(&pnf_info.phys[0], sfn_sf); + recieve_srs_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_sr_ind(&pnf_info.phys[0], sfn_sf); + recieve_sr_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_cqi_ind(&pnf_info.phys[0], sfn_sf); + recieve_cqi_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + send_lbt_dl_ind(&pnf_info.phys[0], sfn_sf); + recieve_lbt_dl_ind(p7Sock, 0, &p7_addr, p7_addrSize); + + // send out of window dl_config, should expect the timing info + printf("Sending late dl config req\n"); + send_dl_config_req(p7Sock, 0, &p7_addr, p7_addrSize, SFNSF(600, 0)); + + sfn_sf = SFNSF(500, 5); // sfn:500 sf:4 + pnf_info.phys[0].sfn_sf = sfn_sf; + sleep(2); + + printf("Sending subframe indication\n"); + send_subframe_indication(&(pnf_info.phys[0])); + printf("Waitning for timing info\n"); + receive_timing_info(p7Sock); + + printf("Sending stop request\n"); + send_stop_request(p5Sock, 0, (struct sockaddr*)&addr, addrSize); + receive_stop_response(p5Sock); + + printf("Waiting for P7 thread to stop\n"); + nfapi_pnf_p7_stop(pnf_info.phys[0].config); + int* result; + pthread_join(pnf_info.phys[0].thread, (void**)&result); + close(p7Sock); + + + send_pnf_stop_request(p5Sock, (struct sockaddr*)&addr, addrSize); + receive_pnf_stop_response(p5Sock); + + nfapi_pnf_stop(config); + + pthread_join(thread, (void**)&result); + //CU_ASSERT_NOT_EQUAL(*result, -1); + CU_ASSERT_EQUAL(test_param_request_called, 1); + CU_ASSERT_EQUAL(test_config_request_called, 1); + + close(p5Sock); + close(p5ListenSock); + +} + +/************* Test Runner Code goes here **************/ + +int main ( void ) +{ + CU_pSuite pSuite = NULL; + + /* initialize the CUnit test registry */ + if ( CUE_SUCCESS != CU_initialize_registry() ) + return CU_get_error(); + + /* add a suite to the registry */ + pSuite = CU_add_suite( "pnf_test_suite", init_suite, clean_suite ); + if ( NULL == pSuite ) { + CU_cleanup_registry(); + return CU_get_error(); + } + + /* add the tests to the suite */ + if ( (NULL == CU_add_test(pSuite, "pnf_test_start_no_config", pnf_test_start_no_config)) || + (NULL == CU_add_test(pSuite, "pnf_test_start_no_ip", pnf_test_start_no_ip)) || + (NULL == CU_add_test(pSuite, "pnf_test_start_invalid_ip", pnf_test_start_invalid_ip)) || + (NULL == CU_add_test(pSuite, "pnf_test_start_no_connection", pnf_test_start_no_connection)) || + (NULL == CU_add_test(pSuite, "pnf_test_start_connect", pnf_test_start_connect)) || + (NULL == CU_add_test(pSuite, "pnf_test_start_pnf_config_invalid_state", pnf_test_state_pnf_config_invalid_state)) || + (NULL == CU_add_test(pSuite, "pnf_test_start_pnf_param_invalid_state", pnf_test_state_pnf_param_invalid_state)) || + (NULL == CU_add_test(pSuite, "pnf_test_p7_segmentation_test_1", pnf_test_p7_segmentation_test_1)) || + (NULL == CU_add_test(pSuite, "pnf_test_p7_segmentation_test_2", pnf_test_p7_segmentation_test_2)) || + (NULL == CU_add_test(pSuite, "pnf_test_p7_segmentation_test_3", pnf_test_p7_segmentation_test_3)) + ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + //(NULL == CU_add_test(pSuite, "pnf_test_start_connect_ipv6", pnf_test_start_connect_ipv6)) || + + // Run all tests using the basic interface + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_set_output_filename("pnf_unit_test_results.xml"); + CU_basic_run_tests(); + + CU_pSuite s = CU_get_registry()->pSuite; + int count = 0; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + count++; + t = t->pNext; + } + s = s->pNext; + } + + printf("%d..%d\n", 1, count); + + + + s = CU_get_registry()->pSuite; + count = 1; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + int pass = 1; + CU_FailureRecord* failures = CU_get_failure_list(); + while(failures) + { + if(strcmp(failures->pSuite->pName, s->pName) == 0 && + strcmp(failures->pTest->pName, t->pName) == 0) + { + pass = 0; + failures = 0; + } + else + { + failures = failures->pNext; + } + } + + if(pass) + printf("ok %d - %s:%s\n", count, s->pName, t->pName); + else + printf("not ok %d - %s:%s\n", count, s->pName, t->pName); + + count++; + t = t->pNext; + } + s = s->pNext; + } + + // Clean up registry and return + CU_cleanup_registry(); + return CU_get_error(); + +} diff --git a/nfapi/open-nFAPI/pnf_sim/Makefile.am b/nfapi/open-nFAPI/pnf_sim/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..c8d9d8ddd462bb29eb1666c994fe68febbe566b2 --- /dev/null +++ b/nfapi/open-nFAPI/pnf_sim/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +AUTOMAKE_OPTIONS=subdir-objects +AM_CPPFLAGS = -I$(top_srcdir)/pnf_sim/inc -I$(top_srcdir)/sim_common/inc -I$(top_srcdir)/pnf/public_inc -I$(top_srcdir)/common/inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/nfapi/inc $(XML_CFLAGS) -g +AM_CXXFLAGS = -I$(top_srcdir)/pnf_sim/inc -I$(top_srcdir)/sim_common/inc -I$(top_srcdir)/pnf/public_inc -I$(top_srcdir)/common/inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/nfapi/inc $(XML_CFLAGS) -std=c++11 $(BOOST_CPPFLAGS) -g +bin_PROGRAMS = pnfsim +pnfsim_SOURCES = src/main.cpp src/fapi_stub.cpp +LDADD= $(top_builddir)/pnf/libnfapi_pnf.a $(top_builddir)/common/libnfapi_common.a $(top_builddir)/nfapi/libnfapi.a $(top_builddir)/sim_common/libnfapi_sim_common.a -L$(libdir) -lpthread -lrt -lsctp -lz diff --git a/nfapi/open-nFAPI/pnf_sim/inc/fapi_interface.h b/nfapi/open-nFAPI/pnf_sim/inc/fapi_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..b1d44eab8b0c714e5b764c8edff7819ae6dbc928 --- /dev/null +++ b/nfapi/open-nFAPI/pnf_sim/inc/fapi_interface.h @@ -0,0 +1,1800 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _FAPI_INTERFACE_H_ +#define _FAPI_INTERFACE_H_ + +#if defined(__cplusplus) +extern "C" { +#endif + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; + +#define FAPI_PARAM_REQUEST 0x00 +#define FAPI_PARAM_RESPONSE 0x01 +#define FAPI_CONFIG_REQUEST 0x02 +#define FAPI_CONFIG_RESPONSE 0x03 +#define FAPI_START_REQUEST 0x04 +#define FAPI_STOP_REQUEST 0x05 +#define FAPI_STOP_INDICATION 0x06 +#define FAPI_UE_CONFIG_REQUEST 0x07 +#define FAPI_UE_CONFIG_RESPONSE 0x08 +#define FAPI_ERROR_INDICATION 0x09 +#define FAPI_UE_RELEASE_REQUEST 0x0A +#define FAPI_UE_RELEASE_RESPONSE 0x0B +#define FAPI_DL_CONFIG_REQUEST 0x80 +#define FAPI_UL_CONFIG_REQUEST 0x81 +#define FAPI_SUBFRAME_INDICATION 0x82 +#define FAPI_HI_DCI0_REQUEST 0x83 +#define FAPI_TX_REQUEST 0x84 +#define FAPI_HARQ_INDICATION 0x85 +#define FAPI_CRC_INDICATION 0x86 +#define FAPI_RX_ULSCH_INDICATION 0x87 +#define FAPI_RACH_INDICATION 0x88 +#define FAPI_SRS_INDICATION 0x89 +#define FAPI_RX_SR_INDICATION 0x8A +#define FAPI_RX_CQI_INDICATION 0x8B +#define FAPI_LBT_DL_CONFIG_REQUEST 0x8C +#define FAPI_LBT_DL_INDICATION 0x8D +#define FAPI_NB_HARQ_INDICATION 0x8E +#define FAPI_NRACH_INDICATION 0x8F + + + + +#define FAPI_SUBFRAME_DUPLEX_MODE_TAG 0x01 +#define FAPI_SUBFRAME_PCFICH_POWER_OFFSET_TAG 0x02 +#define FAPI_SUBFRAME_PB_TAG 0x03 +#define FAPI_SUBFRAME_DL_CYCLIC_PREFIX_TYPE_TAG 0x04 +#define FAPI_SUBFRAME_UL_CYCLIC_PREFIX_TYPE_TAG 0x05 +#define FAPI_RF_DL_CHANNEL_BANDWIDTH_TAG 0x0A +#define FAPI_RF_UL_CHANNEL_BANDWIDTH_TAG 0x0B +#define FAPI_RF_REFERENCE_SIGNAL_POWER_TAG 0x0C +#define FAPI_RF_TX_ANTENNA_PORTS_TAG 0x0D +#define FAPI_RF_RX_ANTENNA_PORTS_TAG 0x0E +#define FAPI_PHICH_RESOURCE_TAG 0x14 +#define FAPI_PHICH_DURATION_TAG 0x15 +#define FAPI_PHICH_POWER_OFFSET_TAG 0x16 +#define FAPI_SCH_PRIMARY_SYNC_SIGNAL_TAG 0x1E +#define FAPI_SCH_SECONDARY_SYNC_SIGNAL_TAG 0x1F +#define FAPI_SCH_PHYSICAL_CELL_ID_TAG 0x20 +#define FAPI_PRACH_CONFIGURATION_INDEX_TAG 0x28 +#define FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG 0x29 +#define FAPI_PRACH_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x2A +#define FAPI_PRACH_HIGH_SPEED_FLAG_TAG 0x2B +#define FAPI_PRACH_FREQUENCY_OFFSET_TAG 0x2C +#define FAPI_PUSCH_HOPPING_MODE_TAG 0x32 +#define FAPI_PUSCH_HOPPING_OFFSET_TAG 0x33 +#define FAPI_PUSCH_NUMBER_OF_SUBBANDS_TAG 0x34 +#define FAPI_PUCCH_DELTA_PUCCH_SHIFT_TAG 0x3C +#define FAPI_PUCCH_N_CQI_RB_TAG 0x3D +#define FAPI_PUCCH_N_AN_CS_TAG 0x3E +#define FAPI_PUCCH_N1_PUCCH_AN_TAG 0x3F +#define FAPI_SRS_BANDWIDTH_CONFIGURATION_TAG 0x46 +#define FAPI_SRS_MAX_UP_PTS_TAG 0x47 +#define FAPI_SRS_SUBFRAME_CONFIGURATION_TAG 0x48 +#define FAPI_SRS_ACK_NACK_SRS_SIMULTANEOUS_TX_TAG 0x49 +#define FAPI_UL_REF_SIG_UPLINK_RS_HOPPING_TAG 0x50 +#define FAPI_UL_REF_SIG_GROUP_ASSIGNMENT_TAG 0x51 +#define FAPI_UL_REF_SIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG 0x52 +#define FAPI_TDD_SUBFRAME_ASSIGNMENT_TAG 0x5A +#define FAPI_TDD_SPECIAL_SUBFRAME_PATTERNS_TAG 0x5B + +#define FAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG 0x64 +#define FAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG 0x65 +#define FAPI_LAA_CONFIG_PD_THRESHOLD_TAG 0x66 +#define FAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG 0x67 +#define FAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG 0x68 +#define FAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG 0x69 +#define FAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG 0x6A +#define FAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG 0x6B + +#define FAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLED_R13_TAG 0x78 +#define FAPI_EMTC_CONFIG_PRACH_CAT_M_ROOT_SEQUENCY_INDEX_TAG 0x79 +#define FAPI_EMTC_CONFIG_PRACH_CAT_M_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x7A +#define FAPI_EMTC_CONFIG_PRACH_CAT_M_HIGH_SPEED_FLAG_TAG 0x7B +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG 0x7C +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG 0x7D +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG 0x7E +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x7F +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG 0x80 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG 0x81 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG 0x82 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG 0x83 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG 0x84 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG 0x85 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x86 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG 0x87 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG 0x88 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG 0x89 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG 0x8A +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG 0x8B +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG 0x8C +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x8D +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG 0x8E +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG 0x8F +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG 0x90 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG 0x91 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG 0x92 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG 0x93 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x94 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG 0x95 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG 0x96 +#define FAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG 0x97 +#define FAPI_EMTC_CONFIG_PRACH_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG 0x98 +#define FAPI_EMTC_CONFIG_PRACH_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG 0x99 + +#define FAPI_NB_IOT_OPERATING_MODE_TAG 0xA5 +#define FAPI_NB_IOT_ANCHOR_TAG 0xA6 +#define FAPI_NB_IOT_PRB_INDEX_TAG 0xA7 +#define FAPI_NB_IOT_CONTROL_REGION_SIZE_TAG 0xA8 +#define FAPI_NB_IOT_ASSUMED_CRS_APS_TAG 0xA9 +#define FAPI_NB_IOT_NPRACH_CONFIG_0_ENABLE_TAG 0xAA +#define FAPI_NB_IOT_NPRACH_CONFIG_0_SF_PERIODCITY_TAG 0xAB +#define FAPI_NB_IOT_NPRACH_CONFIG_0_START_TIME_TAG 0xAC +#define FAPI_NB_IOT_NPRACH_CONFIG_0_SUBCARRIER_OFFSET_TAG 0xAD +#define FAPI_NB_IOT_NPRACH_CONFIG_0_NUMBER_OF_SUBCARRIERS_TAG 0xAE +#define FAPI_NB_IOT_NPRACH_CONFIG_0_CP_LENGTH_TAG 0xAD +#define FAPI_NB_IOT_NPRACH_CONFIG_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0xB0 +#define FAPI_NB_IOT_NPRACH_CONFIG_1_ENABLE_TAG 0xB1 +#define FAPI_NB_IOT_NPRACH_CONFIG_1_SF_PERIODCITY_TAG 0xB2 +#define FAPI_NB_IOT_NPRACH_CONFIG_1_START_TIME_TAG 0xB3 +#define FAPI_NB_IOT_NPRACH_CONFIG_1_SUBCARRIER_OFFSET_TAG 0xB4 +#define FAPI_NB_IOT_NPRACH_CONFIG_1_NUMBER_OF_SUBCARRIERS_TAG 0xB5 +#define FAPI_NB_IOT_NPRACH_CONFIG_1_CP_LENGTH_TAG 0xB6 +#define FAPI_NB_IOT_NPRACH_CONFIG_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0xB7 +#define FAPI_NB_IOT_NPRACH_CONFIG_2_ENABLE_TAG 0xB8 +#define FAPI_NB_IOT_NPRACH_CONFIG_2_SF_PERIODCITY_TAG 0xB9 +#define FAPI_NB_IOT_NPRACH_CONFIG_2_START_TIME_TAG 0xBA +#define FAPI_NB_IOT_NPRACH_CONFIG_2_SUBCARRIER_OFFSET_TAG 0xBB +#define FAPI_NB_IOT_NPRACH_CONFIG_2_NUMBER_OF_SUBCARRIERS_TAG 0xBC +#define FAPI_NB_IOT_NPRACH_CONFIG_2_CP_LENGTH_TAG 0xBD +#define FAPI_NB_IOT_NPRACH_CONFIG_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0xBE + +#define FAPI_NB_IOT_THREE_TONE_BASE_SEQUENCE_TAG 0xBF +#define FAPI_NB_IOT_SIX_TONE_BASE_SEQUENCE_TAG 0xC0 +#define FAPI_NB_IOT_TWELVE_TONE_BASE_SEQUENCE_TAG 0xC1 +#define FAPI_NB_IOT_THREE_TONE_CYCLIC_SHIFT_TAG 0xC2 +#define FAPI_NB_IOT_SIX_TONE_CYCLIC_SHIFT_TAG 0xC3 +#define FAPI_NB_IOT_DL_GAP_CONFIG_ENABLE_TAG 0xC4 +#define FAPI_NB_IOT_DL_GAP_THRESHOLD_TAG 0xC5 +#define FAPI_NB_IOT_DL_GAP_PERIODICITY_TAG 0xC6 +#define FAPI_NB_IOT_DL_GAP_DURATION_COEFFICIENT_TAG 0xC7 + +//... +#define FAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG 0xC8 +#define FAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG 0xC9 +#define FAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG 0xCA +#define FAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG 0xCB +#define FAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG 0xCC +#define FAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG 0xCD +#define FAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG 0xCE +#define FAPI_PHY_CAPABILITIES_LAA_SUPPORT_TAG 0xD1 +#define FAPI_PHY_CAPABILITIES_LAA_PD_SENSING_LBT_SUPPORT_TAG 0xD2 +#define FAPI_PHY_CAPABILITIES_LAA_MULTI_CARRIER_LBT_SUPPORT_TAG 0xD3 +#define FAPI_PHY_CAPABILITIES_LAA_PARTIAL_SF_SUPPORT_TAG 0xD4 +#define FAPI_PHY_CAPABILITIES_NB_IOT_SUPPORT_TAG 0xD5 +#define FAPI_PHY_CAPABILITIES_NB_IOT_OPERATING_MODE_CAPABILITY_TAG 0xD6 + +#define FAPI_PHY_CAPABILITIES_DATA_REPORT_MODE_TAG 0xF0 +#define FAPI_PHY_SFN_SF_TAG 0xF1 +#define FAPI_PHY_STATE_TAG 0xFA + +#define FAPI_MSG_OK 0x0 +#define FAPI_MSG_INVALID_STATE 0x1 +#define FAPI_MSG_INVALID_CONFIG 0x2 +#define FAPI_MSG_SFN_OUT_OF_SYNC 0x3 +#define FAPI_MSG_SUBFRAME_ERR 0x4 +#define FAPI_MSG_BCH_MISSING 0x5 +#define FAPI_MSG_INVALID_SFN 0x6 +#define FAPI_MSG_HI_ERR 0x7 +#define FAPI_MSG_TX_ERR 0x8 + +#define FAPI_MSG_LBT_NO_PDU_IN_DL_REQ 0x9 +#define FAPI_MSG_LBT_NO_VALID_CONFIG_REQ_RECIEVED 0xA +#define FAPI_MSG_FAPI_E_LBT_SF_SFN_PASSED_END_SF_SFN 0xB +#define FAPI_MSG_FAPI_E_LBT_OVERLAP 0xC +#define FAPI_MSG_BCH_PRESENT 0xD +#define FAPI_MSG_NBIOT_UNEXPECTED_REQ 0xE + + +// TODO : Work out what the correct maximums should be + +// Number of UL/DL configurations, I, as defined by 36.212 section 5.3.3.1.4 +// todo : work out what the max is +#define FAPI_MAX_UL_DL_CONFIGURATIONS 4 +#define FAPI_MAX_NUM_PHYSICAL_ANTENNAS 4 +#define FAPI_MAX_NUM_SCHEDULED_UES 8 +#define FAPI_MAX_NUM_SUBBANDS 8 +#define FAPI_MAX_ANTENNA_PORT_COUNT 2 + + +typedef struct { + uint8_t message_id; + uint16_t length; +} fapi_header_t; + +typedef struct { + uint8_t tag; + uint8_t length; + uint16_t value; +} fapi_tlv_t; + +typedef struct { + fapi_header_t header; +} fapi_param_req_t; + +typedef struct { + fapi_header_t header; + uint8_t error_code; + uint8_t number_of_tlvs; + fapi_tlv_t tlvs[255]; +} fapi_param_resp_t; + +typedef struct { + fapi_header_t header; + uint8_t number_of_tlvs; + fapi_tlv_t tlvs[255]; +} fapi_config_req_t; + +typedef struct { + fapi_header_t header; + uint8_t error_code; + uint8_t number_of_invalid_tlvs; + uint8_t number_of_missing_tlvs; + fapi_tlv_t tlvs[255]; +} fapi_config_resp_t; + +typedef struct { + fapi_header_t header; +} fapi_start_req_t; + +typedef struct { + fapi_header_t header; +} fapi_stop_req_t; + +typedef struct { + fapi_header_t header; +} fapi_stop_ind_t; + +typedef struct { + uint16_t received_sfn_sf; + uint16_t expected_sfn_sf; +} fapi_sfn_out_of_sync_error_ind_t; + +typedef struct { + uint16_t received_sfn_sf; + uint16_t expected_sfn_sf; +} fapi_invalid_sfn_error_ind_t; + +typedef struct { + uint8_t sub_error_code; + uint8_t direction; + uint16_t rnti; + uint8_t pdu_type; +} fapi_pdu_error_ind_t; + +typedef struct { + uint8_t sub_error_code; + uint8_t phich_lowest_ul_rb_index; +} fapi_hi_error_ind_t; + +typedef struct { + uint8_t sub_error_code; + uint8_t pdu_index; +} fapi_tx_error_ind_t; + +typedef struct { + fapi_header_t header; + uint8_t message_id; + uint8_t error_code; + union + { + fapi_sfn_out_of_sync_error_ind_t out_of_sync_err; + fapi_invalid_sfn_error_ind_t invalid_sfn_err; + fapi_pdu_error_ind_t pdu_err; + fapi_hi_error_ind_t hi_err; + fapi_tx_error_ind_t tx_err; + }; +} fapi_error_ind_t; + +typedef struct { + uint32_t handle; + uint16_t rnti; +} fapi_rx_ue_information_t; + +typedef struct { + uint8_t ul_cqi; + uint8_t channel; +} fapi_ul_cqi_information_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; +} fapi_subframe_ind_t; + +typedef struct { + uint8_t value_0; + uint8_t value_1; +} fapi_harq_ind_rel8_tdd_harq_data_bundling_t; + +typedef struct { + uint8_t value_0; + uint8_t value_1; + uint8_t value_2; + uint8_t value_3; +} fapi_harq_ind_rel8_tdd_harq_data_multiplexing_t; + +typedef struct { + uint8_t value_0; +} fapi_harq_ind_rel8_tdd_harq_data_special_bundling_t; + +typedef struct { + uint8_t mode; + uint8_t number_of_ack_nack; + union{ + fapi_harq_ind_rel8_tdd_harq_data_bundling_t bundling; + fapi_harq_ind_rel8_tdd_harq_data_multiplexing_t multiplex; + fapi_harq_ind_rel8_tdd_harq_data_special_bundling_t special_bundling; + } harq_data; +} fapi_harq_ind_rel8_tdd_pdu_t; + +typedef struct { + uint8_t value_0; +} fapi_harq_ind_rel8_tdd_harq_data_t; + + +typedef struct { + uint8_t mode; + uint8_t number_of_ack_nack; + union{ + fapi_harq_ind_rel8_tdd_harq_data_t bundling; + fapi_harq_ind_rel8_tdd_harq_data_t multiplex; + fapi_harq_ind_rel8_tdd_harq_data_special_bundling_t special_bundling; + fapi_harq_ind_rel8_tdd_harq_data_t channel_selection; + fapi_harq_ind_rel8_tdd_harq_data_t format_3; + } harq_data[21]; +} fapi_harq_ind_rel9_tdd_pdu_t; + +typedef struct { + uint8_t mode; + uint16_t number_of_ack_nack; + union{ + fapi_harq_ind_rel8_tdd_harq_data_t bundling; + fapi_harq_ind_rel8_tdd_harq_data_t multiplex; + fapi_harq_ind_rel8_tdd_harq_data_special_bundling_t special_bundling; + fapi_harq_ind_rel8_tdd_harq_data_t channel_selection; + fapi_harq_ind_rel8_tdd_harq_data_t format_3; + fapi_harq_ind_rel8_tdd_harq_data_t format_4; + fapi_harq_ind_rel8_tdd_harq_data_t format_5; + } harq_data[22]; +} fapi_harq_ind_rel13_tdd_pdu_t; + +typedef struct { + uint8_t harq_tb_1; + uint8_t harq_tb_2; +} fapi_harq_ind_rel8_fdd_pdu_t; + +typedef struct { + uint8_t mode; + uint8_t number_of_ack_nack; + uint8_t harq_tb_n[10]; +} fapi_harq_ind_rel9_fdd_pdu_t; + +typedef struct { + uint8_t mode; + uint16_t number_of_ack_nack; + uint8_t harq_tb_n[22]; +} fapi_harq_ind_rel13_fdd_pdu_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + union { + fapi_harq_ind_rel8_tdd_pdu_t rel8_tdd_pdu; + fapi_harq_ind_rel9_tdd_pdu_t rel9_tdd_pdu; + fapi_harq_ind_rel13_tdd_pdu_t rel13_tdd_pdu; + fapi_harq_ind_rel8_fdd_pdu_t rel8_fdd_pdu; + fapi_harq_ind_rel9_fdd_pdu_t rel9_fdd_pdu; + fapi_harq_ind_rel13_fdd_pdu_t rel13_fdd_pdu; + }; + fapi_ul_cqi_information_t ul_cqi_info; +} fapi_harq_ind_pdu_t; + +typedef struct { + uint16_t number_of_harqs; + fapi_harq_ind_pdu_t pdus[32]; +} fapi_harq_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_harq_ind_body_t body; +} fapi_harq_ind_t; + +typedef struct { + uint8_t crc_flag; +} fapi_crc_ind_rel8_pdu_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + fapi_crc_ind_rel8_pdu_t rel8_pdu; +} fapi_crc_ind_pdu_t; + +typedef struct { + uint16_t number_of_crcs; + fapi_crc_ind_pdu_t pdus[32]; +} fapi_crc_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_crc_ind_body_t body; +} fapi_crc_ind_t; + +typedef struct { + uint16_t length; + uint16_t data_offset; + uint8_t ul_cqi; + uint16_t timing_advance; +} fapi_rx_ulsch_ind_rel8_pdu_t; + +typedef struct { + uint16_t timing_advance_r9; +} fapi_rx_ulsch_ind_rel9_pdu_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + fapi_rx_ulsch_ind_rel8_pdu_t rel8_pdu; + fapi_rx_ulsch_ind_rel9_pdu_t rel9_pdu; +} fapi_rx_ulsch_ind_pdu_t; + +typedef struct { + uint16_t number_of_pdus; + fapi_rx_ulsch_ind_pdu_t pdus[32]; + void* data[32]; +} fapi_rx_ulsch_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_rx_ulsch_ind_body_t body; +} fapi_rx_ulsch_ind_t; + +typedef struct { + uint16_t length; + uint16_t data_offset; + uint8_t ul_cqi; + uint8_t ri; + uint16_t timing_advance; +} fapi_rx_cqi_ind_rel8_pdu_t; + +typedef struct { + uint16_t length; + uint16_t data_offset; + uint8_t ul_cqi; + uint8_t number_of_cc_reported; + uint8_t ri[5]; + uint16_t timing_advance; + uint16_t timing_advance_r9; +} fapi_rx_cqi_ind_rel9_pdu_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + fapi_rx_cqi_ind_rel8_pdu_t rel8_pdu; + fapi_rx_cqi_ind_rel9_pdu_t rel9_pdu; + fapi_ul_cqi_information_t ul_cqi_info; +} fapi_rx_cqi_ind_pdu_t; + +typedef struct { + uint16_t number_of_pdus; + fapi_rx_cqi_ind_pdu_t pdus[32]; + uint8_t* data[32]; +} fapi_rx_cqi_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_rx_cqi_ind_body_t body; +} fapi_rx_cqi_ind_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + fapi_ul_cqi_information_t ul_cqi_info; +} fapi_rx_sr_ind_pdu_t; + +typedef struct { + uint16_t number_of_srs; + fapi_rx_sr_ind_pdu_t pdus[32]; +} fapi_rx_sr_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_rx_sr_ind_body_t body; +} fapi_rx_sr_ind_t; + +typedef struct { + uint16_t rnti; + uint8_t preamble; + uint16_t timing_advance; +} fapi_rach_ind_pdu_rel8_t; + +typedef struct { + uint16_t timing_advance_r9; +} fapi_rach_ind_pdu_rel9_t; + +typedef struct { + uint8_t rach_resource_type; +} fapi_rach_ind_pdu_rel13_t; + +typedef struct { + fapi_rach_ind_pdu_rel8_t rel8_pdu; + fapi_rach_ind_pdu_rel9_t rel9_pdu; + fapi_rach_ind_pdu_rel13_t rel13_pdu; +} fapi_rach_ind_pdu_t; + +typedef struct { + uint8_t number_of_preambles; + fapi_rach_ind_pdu_t pdus[32]; +} fapi_rach_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_rach_ind_body_t body; +} fapi_rach_ind_t; + + +typedef struct { + uint16_t doppler_estimation; + uint16_t timing_advance; + uint8_t number_of_resource_blocks; + uint8_t rb_start; + uint8_t snr[100]; +} fapi_srs_ind_rel8_pdu_t; + +typedef struct { + uint16_t timing_advance_r9; +} fapi_srs_ind_rel9_pdu_t; + +typedef struct { + uint8_t uppts_symbol; +} fapi_srs_ind_rel10_tdd_pdu_t; + +typedef struct { + uint16_t ul_rtoa; +} fapi_srs_ind_rel11_pdu_t; + +typedef struct { + uint8_t num_prb_per_subband; + uint8_t number_of_subbands; + uint8_t num_atennas; + struct { + uint8_t subband_index; + uint16_t channel[FAPI_MAX_NUM_PHYSICAL_ANTENNAS]; + } subands[FAPI_MAX_NUM_SUBBANDS]; +} fapi_ttd_channel_measurement_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + fapi_srs_ind_rel8_pdu_t rel8_pdu; + fapi_srs_ind_rel9_pdu_t rel9_pdu; + fapi_srs_ind_rel10_tdd_pdu_t rel10_tdd_pdu; + fapi_srs_ind_rel11_pdu_t rel11_pdu; + fapi_ttd_channel_measurement_t tdd_channel_measurement; +} fapi_srs_ind_pdu_t; + +typedef struct { + uint8_t number_of_ues; + fapi_srs_ind_pdu_t pdus[32]; +} fapi_srs_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_srs_ind_body_t body; +} fapi_srs_ind_t; + + +typedef struct { + uint32_t handle; + uint32_t result; + uint32_t lte_txop_symbols; + uint32_t initial_partial_sf; +} fapi_lbt_dl_pdsch_rsp_rel13_pdu_t; + +typedef struct { + fapi_lbt_dl_pdsch_rsp_rel13_pdu_t rel13_pdu; +} fapi_lbt_dl_pdsch_rsp_pdu_t; + +typedef struct { + uint32_t handle; + uint32_t result; +} fapi_lbt_dl_drs_rsp_rel13_pdu_t; + +typedef struct { + fapi_lbt_dl_drs_rsp_rel13_pdu_t rel13_pdu; +} fapi_lbt_dl_drs_rsp_pdu_t; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union { + fapi_lbt_dl_pdsch_rsp_pdu_t lbt_pdsch_rsp_pdu; + fapi_lbt_dl_drs_rsp_pdu_t lbt_drs_rsp_pdu; + }; +} fapi_lbt_dl_ind_pdu_t; + +typedef struct { + uint16_t number_of_pdus; + fapi_lbt_dl_ind_pdu_t pdus[32]; +} fapi_lbt_dl_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_lbt_dl_ind_body_t body; +} fapi_lbt_dl_ind_t; + +typedef struct { + uint8_t harq_tb1; +} fapi_nb_harq_ind_rel13_pdu_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + union { + fapi_nb_harq_ind_rel13_pdu_t rel13_pdu; + }; + fapi_ul_cqi_information_t ul_cqi_info; +} fapi_nb_harq_ind_pdu_t; + +typedef struct { + uint16_t number_of_harqs; + fapi_nb_harq_ind_pdu_t pdus[32]; +} fapi_nb_harq_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_nb_harq_ind_body_t body; +} fapi_nb_harq_ind_t; + +typedef struct { + uint16_t rnti; + uint8_t initial_sc; + uint16_t timing_advance; + uint8_t nrach_cs_level; +} fapi_nrach_ind_rel13_pdu_t; + +typedef struct { + fapi_rx_ue_information_t rx_ue_info; + union { + fapi_nrach_ind_rel13_pdu_t rel13_pdu; + }; + fapi_ul_cqi_information_t ul_cqi_info; +} fapi_nrach_ind_pdu_t; + +typedef struct { + uint16_t number_of_initial_scs_detected; + fapi_nrach_ind_pdu_t pdus[32]; +} fapi_nrach_ind_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_nrach_ind_body_t body; +} fapi_nrach_ind_t; + +//------------------------------------------------------------------------------ + +typedef struct { + uint8_t dci_format; + uint8_t cce_index; + uint8_t aggregation_level; + uint16_t rnti; + uint8_t resource_allocation_type; + uint8_t virtual_resource_block_assignment_flag; + uint32_t resource_block_coding; + uint8_t mcs_1; + uint8_t redundancy_version_1; + uint8_t new_data_indicator_1; + uint8_t transport_block_to_codeword_swap_flag; + uint8_t mcs_2; + uint8_t redundancy_version_2; + uint8_t new_data_indictor_2; + uint8_t harq_process; + uint8_t tpmi; + uint8_t pmi; + uint8_t precoding_information; + uint8_t tpc; + uint8_t downlink_assignment_index; + uint8_t n_gap; + uint8_t transport_block_size_index; + uint8_t downlink_power_offset; + uint8_t allocate_prach_flag; + uint8_t preamble_index; + uint8_t prach_mask_index; + uint8_t rnti_type; + uint16_t transmission_power; +} fapi_dl_config_dci_rel8_pdu_t; + +typedef struct { + uint8_t mcch_flag; + uint8_t mcch_change_notification; + uint8_t scrambling_identity; +} fapi_dl_config_dci_rel9_pdu_t; + +typedef struct { + uint8_t cross_carrier_scheduling_flag; + uint8_t carrier_indicator; + uint8_t srs_flag; + uint8_t srs_request; + uint8_t antenna_ports_scrambling_and_layers; + uint8_t total_dci_length_including_padding; + uint8_t n_dl_rb; +} fapi_dl_config_dci_rel10_pdu_t; + +typedef struct { + uint8_t harq_ack_resource_offset; + uint8_t pdsch_re_mapping_quasi_co_location_indicator; +} fapi_dl_config_dci_rel11_pdu_t; + +typedef struct { + uint8_t primary_cell_type; + uint8_t ul_dl_configuration_flag; + uint8_t number_ul_dl_configurations; + uint8_t ul_dl_configuration_indication[FAPI_MAX_UL_DL_CONFIGURATIONS]; +} fapi_dl_config_dci_rel12_pdu_t; + + +typedef struct { + uint8_t subband_index; + uint8_t scheduled_ues; + uint16_t precoding_value[FAPI_MAX_NUM_PHYSICAL_ANTENNAS][FAPI_MAX_NUM_SCHEDULED_UES]; +} fapi_dl_config_dci_dl_tpm_subband_info_t; + +typedef struct { + uint8_t num_prb_per_subband; + uint8_t number_of_subbands; + uint8_t num_antennas; + fapi_dl_config_dci_dl_tpm_subband_info_t subband_info[FAPI_MAX_NUM_SUBBANDS]; +} fapi_dl_config_dci_dl_tpm_t; + +typedef struct { + uint8_t laa_end_partial_sf_flag; + uint8_t laa_end_partial_sf_configuration; + uint8_t initial_lbt_sf; + uint8_t codebook_size_determination; + uint8_t drms_table_flag; + uint8_t tpm_struct_flag; + fapi_dl_config_dci_dl_tpm_t tpm; +} fapi_dl_config_dci_rel13_pdu_t; + +typedef struct { + fapi_dl_config_dci_rel8_pdu_t rel8_pdu; + fapi_dl_config_dci_rel9_pdu_t rel9_pdu; + fapi_dl_config_dci_rel10_pdu_t rel10_pdu; + fapi_dl_config_dci_rel11_pdu_t rel11_pdu; + fapi_dl_config_dci_rel12_pdu_t rel12_pdu; + fapi_dl_config_dci_rel13_pdu_t rel13_pdu; +} fapi_dl_config_dci_pdu_t; + +typedef struct { + uint16_t length; + uint16_t pdu_index; + uint16_t transmission_power; +} fapi_dl_config_bch_rel8_pdu_t; + +typedef struct { + fapi_dl_config_bch_rel8_pdu_t rel8_pdu; +} fapi_dl_config_bch_pdu_t; + +typedef struct { + uint16_t length; + uint16_t pdu_index; + uint16_t rnti; + uint8_t resource_allocation_type; + uint32_t resource_block_coding; + uint8_t modulation; + uint16_t transmission_power; + uint16_t mbsfn_area_id; +} fapi_dl_config_mch_rel8_pdu_t; + +typedef struct { + fapi_dl_config_mch_rel8_pdu_t rel8_pdu; +} fapi_dl_config_mch_pdu_t; + +typedef struct { + uint8_t subband_index; + uint8_t num_atennas; + uint16_t bf_value[8]; +} fapi_dl_config_bf_vector_t; + +typedef struct { + uint16_t length; + uint16_t pdu_index; + uint16_t rnti; + uint8_t resource_allocation_type; + uint8_t virtual_resource_block_assignment_flag; + uint32_t resource_block_coding; + uint8_t modulation; + uint8_t redundacy_version; + uint8_t transport_blocks; + uint8_t transport_block_codeword_swap_flag; + uint8_t transmission_scheme; + uint8_t number_of_layers; + uint8_t nunber_of_subands; + uint8_t codebook_index[13]; + uint8_t ue_category_capacity; + uint8_t p_a; + uint8_t delta_power_offset_index; + uint8_t n_gap; + uint8_t n_prb; + uint8_t transmission_mode; + uint8_t num_bf_prb_per_subband; + uint8_t num_bf_vecitor; + fapi_dl_config_bf_vector_t bf_vector[8]; +} fapi_dl_config_dlsch_rel8_pdu_t; + +typedef struct { + uint8_t nscid; +} fapi_dl_config_dlsch_rel9_pdu_t; + +typedef struct { + uint8_t csi_rs_flag; + uint8_t csi_rs_resource_config_r10; + uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10; + uint8_t csi_rs_number_nzp_configuration; + uint8_t csi_rs_resource_config[4]; + uint8_t pdsch_start; +} fapi_dl_config_dlsch_rel10_pdu_t; + +typedef struct { + uint8_t drms_config_flag; + uint16_t drms_scrambling; + uint8_t csi_config_flag; + uint16_t csi_scrambling; + uint8_t pdsch_re_mapping_flag; + uint8_t pdsch_re_mapping_atenna_ports; + uint8_t pdsch_re_mapping_freq_shift; +} fapi_dl_config_dlsch_rel11_pdu_t; + +typedef struct { + uint8_t altcqi_table_r12; + uint8_t maxlayers; + uint8_t n_dl_harq; +} fapi_dl_config_dlsch_rel12_pdu_t; + +typedef struct { + uint8_t dwpts_symbols; + uint8_t initial_lbt_sf; + uint8_t ue_type; + uint8_t pdsch_payload_type; + uint16_t initial_transmission_sf_io; + uint8_t drms_table_flag; +} fapi_dl_config_dlsch_rel13_pdu_t; + +typedef struct { + fapi_dl_config_dlsch_rel8_pdu_t rel8_pdu; + fapi_dl_config_dlsch_rel9_pdu_t rel9_pdu; + fapi_dl_config_dlsch_rel10_pdu_t rel10_pdu; + fapi_dl_config_dlsch_rel11_pdu_t rel11_pdu; + fapi_dl_config_dlsch_rel12_pdu_t rel12_pdu; + fapi_dl_config_dlsch_rel13_pdu_t rel13_pdu; +} fapi_dl_config_dlsch_pdu_t; + +typedef struct { + uint16_t length; + uint16_t pdu_index; + uint16_t p_rnti; + uint8_t resource_allocation_type; + uint8_t virtual_resource_block_assignment_flag; + uint32_t resource_block_coding; + uint8_t mcs; + uint8_t redudancy_version; + uint8_t number_of_transport_blocks; + uint8_t transport_block_to_codeword_swap_flag; + uint8_t transmission_scheme; + uint8_t number_of_layers; + uint8_t codebook_index; + uint8_t ue_category_capacity; + uint8_t p_a; + uint16_t transmission_power; + uint8_t n_prb; + uint8_t n_gap; +} fapi_dl_config_pch_rel8_pdu_t; + +typedef struct { + uint8_t ue_mode; + uint16_t initial_transmission_sf_io; +} fapi_dl_config_pch_rel13_pdu_t; + +typedef struct { + fapi_dl_config_pch_rel8_pdu_t rel8_pdu; + fapi_dl_config_pch_rel13_pdu_t rel13_pdu; +} fapi_dl_config_pch_pdu_t; + +typedef struct { + uint16_t transmission_power; + uint8_t prs_bandwidth; + uint8_t prs_cyclic_prefix_type; + uint8_t prs_muting; +} fapi_dl_config_prs_rel9_pdu_t; + +typedef struct { + fapi_dl_config_prs_rel9_pdu_t rel9_pdu; +} fapi_dl_config_prs_pdu_t; + +typedef struct { + uint8_t csi_rs_antenna_port_count_r10; + uint8_t csi_rs_resource_config_r10; + uint16_t transmission_power; + uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10; + uint8_t csi_rs_number_of_nzp_configuration; + uint8_t csi_rs_resource_config[8]; +} fapi_dl_config_csi_rs_rel10_pdu_t; + +typedef struct { + uint8_t csi_rs_class; + uint8_t cdm_type; + uint8_t num_bf_vector; + struct { + uint8_t csi_rs_resource_index; + uint16_t bf_value[FAPI_MAX_ANTENNA_PORT_COUNT]; + } bf_vector[8]; +}fapi_dl_config_csi_rs_rel13_pdu_t; + +typedef struct { + fapi_dl_config_csi_rs_rel10_pdu_t rel10_pdu; + fapi_dl_config_csi_rs_rel13_pdu_t rel13_pdu; +} fapi_dl_config_csi_rs_pdu_t; + +typedef struct { + uint8_t edpcch_resource_assigenment_flag; + uint16_t edpcch_id; + uint8_t epdcch_start_symbol; + uint8_t epdcch_num_prb; + uint8_t epdcch_prb_index[8]; + fapi_dl_config_bf_vector_t bf_vector; +} fapi_dl_config_edpcch_rel11_params_t; + +typedef struct { + uint8_t dwpts_symbols; + uint8_t initial_lbt_sf; +} fapi_dl_config_edpcch_rel13_params_t; + +typedef struct { + fapi_dl_config_dci_rel8_pdu_t rel8_pdu; + fapi_dl_config_dci_rel9_pdu_t rel9_pdu; + fapi_dl_config_dci_rel10_pdu_t rel10_pdu; + fapi_dl_config_dci_rel11_pdu_t rel11_pdu; + fapi_dl_config_dci_rel12_pdu_t rel12_pdu; + fapi_dl_config_dci_rel13_pdu_t rel13_pdu; + fapi_dl_config_edpcch_rel11_params_t rel8_params; + fapi_dl_config_edpcch_rel13_params_t rel13_params; +} fapi_dl_config_edpcch_pdu_t; + +typedef struct { + uint8_t mpdcch_narrow_band; + uint8_t number_of_prb_pairs; + uint8_t resource_block_assignment; + uint8_t mpdcch_tansmission_type; + uint8_t start_symbol; + uint8_t ecce_index; + uint8_t aggregation_level; + uint8_t rnti_type; + uint16_t rnti; + uint8_t ce_mode; + uint16_t drms_scrambling_init; + uint16_t initial_transmission_sf_io; + uint16_t transmission_power; + uint8_t dci_format; + uint16_t resource_block_coding; + uint8_t mcs; + uint8_t pdsch_reptition_levels; + uint8_t redundancy_version; + uint8_t new_data_indicator; + uint8_t harq_process; + uint8_t tpmi_length; + uint8_t tpmi; + uint8_t pmi_flag; + uint8_t pmi; + uint8_t harq_resource_offset; + uint8_t dci_subframe_repetition_number; + uint8_t tpc; + uint8_t downlink_assignment_index_length; + uint8_t downlink_assignment_index; + uint8_t allocate_prach_flag; + uint8_t preamble_index; + uint8_t prach_mask_index; + uint8_t starting_ce_level; + uint8_t srs_request; + uint8_t antenna_ports_and_scrambling_identity_flag; + uint8_t antenna_ports_and_scrambling_identity; + uint8_t frequency_hopping_enabled_flag; + uint8_t paging_direct_indication_differentiation_flag; + uint8_t direct_indication; + uint8_t total_dci_length_including_padding; + uint8_t number_of_tx_antenna_ports; + uint16_t precoding_value[8]; +} fapi_dl_config_mdpcch_rel13_pdu_t; + +typedef struct { + fapi_dl_config_mdpcch_rel13_pdu_t rel13_pdu; +} fapi_dl_config_mdpcch_pdu_t; + +typedef struct { + uint16_t length; + uint16_t pdu_index; + uint16_t transmission_power; + uint16_t hyper_sfn_2_lsbs; +} fapi_dl_config_nbch_rel13_pdu_t; + +typedef struct { + fapi_dl_config_nbch_rel13_pdu_t rel13_pdu; +} fapi_dl_config_nbch_pdu_t; + +typedef struct { + uint16_t length; + uint16_t pdu_index; + uint8_t ncce_index; + uint8_t aggregation_level; + uint8_t start_symbol; + uint8_t rnti_type; + uint16_t rnti; + uint8_t scrambling_reinitialization_batch_index; + uint8_t nrs_antenna_ports_assumed_by_the_ue; + uint8_t dci_format; + uint8_t scheduling_delay; + uint8_t resource_assignment; + uint8_t repetition_number; + uint8_t mcs; + uint8_t new_data_indicator; + uint8_t harq_ack_resource; + uint8_t npdcch_order_indication; + uint8_t starting_number_of_nprach_repetitions; + uint8_t subcarrier_indication_of_nprach; + uint8_t paging_direct_indication_differentation_flag; + uint8_t direct_indication; + uint8_t dci_subframe_repetition_number; + uint8_t total_dci_length_including_padding; +} fapi_dl_config_npdcch_rel13_pdu_t; + +typedef struct { + fapi_dl_config_npdcch_rel13_pdu_t rel13_pdu; +} fapi_dl_config_npdcch_pdu_t; + +typedef struct { + uint16_t length; + uint16_t pdu_index; + uint8_t start_symbol; + uint8_t rnti_type; + uint16_t rnti; + uint16_t resource_assignment; + uint16_t repetition_number; + uint8_t modulation; + uint8_t number_of_subframes_for_resource_assignment; + uint8_t scrambling_sequence_initialization_cinit; + uint16_t sf_idx; + uint8_t nrs_antenna_ports_assumed_by_the_ue; +} fapi_dl_config_ndlsch_rel13_pdu_t; + +typedef struct { + fapi_dl_config_ndlsch_rel13_pdu_t rel13_pdu; +} fapi_dl_config_ndlsch_pdu_t; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union + { + fapi_dl_config_dci_pdu_t dci_dl_pdu; + fapi_dl_config_bch_pdu_t bch_pdu; + fapi_dl_config_mch_pdu_t mch_pdu; + fapi_dl_config_dlsch_pdu_t dlsch_pdu; + fapi_dl_config_pch_pdu_t pch_pdu; + fapi_dl_config_prs_pdu_t prs_pdu; + fapi_dl_config_csi_rs_pdu_t csirs_pdu; + fapi_dl_config_edpcch_pdu_t edpcch_pdu; + fapi_dl_config_mdpcch_pdu_t mdpcch_pdu; + fapi_dl_config_nbch_pdu_t nbch_pdu; + fapi_dl_config_npdcch_pdu_t npdcch_pdu; + fapi_dl_config_ndlsch_pdu_t ndlsch_pdu; + }; +} fapi_dl_config_req_pdu_t; + +typedef struct { + uint8_t number_of_pdcch_ofdm_symbols; + uint8_t number_of_dcis; + uint16_t number_of_pdus; + uint8_t number_of_pdsch_rntis; + uint16_t transmission_power_for_pcfich; + fapi_dl_config_req_pdu_t pdus[32]; +} fapi_dl_config_req_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + uint16_t length; + fapi_dl_config_req_body_t body; +} fapi_dl_config_req_t; + +typedef struct { + uint32_t handle; + uint16_t size; + uint16_t rnti; + uint8_t resource_block_start; + uint8_t number_of_resource_blocks; + uint8_t modulation_type; + uint8_t cyclic_shift_2_for_drms; + uint8_t frequency_hopping_enabled_flag; + uint8_t frequency_hopping_bits; + uint8_t new_data_indication; + uint8_t redundancy_version; + uint8_t harq_process_number; + uint8_t ul_tx_mode; + uint8_t current_tx_nb; + uint8_t n_srs; +} fapi_ul_config_req_ulsch_rel8_pdu_t; + +typedef struct { + uint8_t resource_allocation_type; + uint32_t resource_block_coding; + uint8_t transport_blocks; + uint8_t transmission_scheme; + uint8_t number_of_layers; + uint8_t codebook_index; + uint8_t disable_sequence_hopping_flag; +} fapi_ul_config_req_ulsch_rel10_pdu_t; + +typedef struct { + uint8_t virtual_cell_id_enabled_flag; + uint16_t npusch_identity; + uint8_t dmrs_config_flag; + uint16_t ndmrs_csh_identity; +} fapi_ul_config_req_ulsch_rel11_pdu_t; + +typedef struct { + uint8_t ue_type; + uint16_t total_number_of_repetitions; + uint16_t repetition_number; + uint16_t initial_transmission_sf_io; + uint8_t empty_symbols_due_to_re_tunning; +} fapi_ul_config_req_ulsch_rel13_pdu_t; + +typedef struct { + fapi_ul_config_req_ulsch_rel8_pdu_t rel8_pdu; + fapi_ul_config_req_ulsch_rel10_pdu_t rel10_pdu; + fapi_ul_config_req_ulsch_rel11_pdu_t rel11_pdu; + fapi_ul_config_req_ulsch_rel13_pdu_t rel13_pdu; +} fapi_ul_config_req_ulsch_pdu_t; + +typedef struct { + uint8_t dl_cqi_pmi_size_rank_1; + uint8_t dl_cqi_pmi_size_rank_greater_1; + uint8_t ri_size; + uint8_t delta_offset_cqi; + uint8_t delta_offset_ri; +} fapi_ul_config_cqi_ri_rel8_information_t; + +typedef struct { + uint8_t dl_cqi_pmi_ri_size; + uint8_t control_type; +} fapi_ul_config_periodic_cqi_pmi_ri_report_t; + +typedef struct { + uint8_t number_of_cc; + struct { + uint8_t ri_size; + uint8_t dl_cqi_pmi_size; + } cc[5]; +} fapi_ul_config_aperiodic_cqi_pmi_ri_report_t; + +typedef struct { + uint8_t report_type; + uint8_t delta_offset_cqi; + uint8_t delta_offset_ri; + union { + fapi_ul_config_periodic_cqi_pmi_ri_report_t periodic_cqi_pmi_ri_report; + fapi_ul_config_aperiodic_cqi_pmi_ri_report_t aperiodic_cqi_pmi_ri_report; + }; +} fapi_ul_config_cqi_ri_rel9_information_t; + +typedef struct { + uint16_t dl_cqi_pmi_ri_size_2; +} fapi_ul_config_periodic_cqi_pmi_ri_report_re13_t; + +typedef struct { +} fapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t; + + +typedef struct { + union { + fapi_ul_config_periodic_cqi_pmi_ri_report_re13_t periodic_cqi_pmi_ri_report; + fapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t aperiodic_cqi_pmi_ri_report; + }; +} fapi_ul_config_cqi_ri_rel13_information_t; + +typedef struct { + fapi_ul_config_cqi_ri_rel8_information_t rel8_info; + fapi_ul_config_cqi_ri_rel9_information_t rel9_cqi_ri_info; + fapi_ul_config_cqi_ri_rel13_information_t rel13_cqi_ri_info; +} fapi_ul_config_cqi_ri_information_t; + +typedef struct { + uint8_t n_srs_initial; + uint8_t initial_number_of_resource_blocks; +} fapi_ul_config_init_tx_rel8_params_t; + +typedef struct { + fapi_ul_config_init_tx_rel8_params_t rel8_params; +} fapi_ul_config_init_tx_params_t; + +typedef struct { + uint8_t harq_size; + uint8_t delta_offset_harq; + uint8_t ack_nack_mode; +} fapi_ul_config_harq_rel10_information_t; + +typedef struct { + uint16_t harq_size_2; + uint8_t delta_offset_harq_2; +} fapi_ul_config_harq_rel13_information_t; + +typedef struct { + fapi_ul_config_harq_rel10_information_t rel10_info; + fapi_ul_config_harq_rel13_information_t rel13_info; +} fapi_ul_config_harq_information_t; + +typedef struct { + uint32_t handle; + uint16_t rnti; +} fapi_ul_config_req_ue_rel8_info_t; + +typedef struct { + uint8_t virtual_cell_id_enabled_flag; + uint16_t npusch_identity; +} fapi_ul_config_req_ue_rel11_info_t; + +typedef struct { + uint8_t ue_type; + uint8_t empty_symbols; + uint16_t total_number_of_repetitions; + uint16_t repetition_number; +} fapi_ul_config_req_ue_rel13_info_t; + +typedef struct { + fapi_ul_config_req_ue_rel8_info_t rel8_info; + fapi_ul_config_req_ue_rel11_info_t rel11_info; + fapi_ul_config_req_ue_rel13_info_t rel13_info; +} fapi_ul_config_req_ue_info_t; + +typedef struct { + uint16_t pucch_index; + uint8_t dl_cqi_pmi_size; +} fapi_ul_config_req_cqi_rel8_info_t; + +typedef struct { + uint8_t number_of_pucch_resource; + uint16_t pucch_index_p1; +} fapi_ul_config_req_cqi_rel10_info_t; + +typedef struct { + uint8_t csi_mode; + uint16_t dl_cqi_pmi_size_2; + uint8_t starting_prb; + uint8_t n_prb; + uint8_t cdm_index; + uint8_t n_srs; +} fapi_ul_config_req_cqi_rel13_info_t; + +typedef struct { + fapi_ul_config_req_cqi_rel8_info_t rel8_info; + fapi_ul_config_req_cqi_rel10_info_t rel10_info; + fapi_ul_config_req_cqi_rel13_info_t rel13_info; +} fapi_ul_config_req_cqi_info_t; + +typedef struct { + uint16_t pucch_index; +} fapi_ul_config_req_sr_rel8_info_t; + +typedef struct { + uint8_t number_of_pucch_resources; + uint16_t pucch_index_p1; +} fapi_ul_config_req_sr_rel10_info_t; + +typedef struct { + fapi_ul_config_req_sr_rel8_info_t rel8_info; + fapi_ul_config_req_sr_rel10_info_t rel10_info; +} fapi_ul_config_req_sr_info_t; + +typedef struct { + uint8_t harq_size; + uint8_t ack_nack_mode; + uint8_t number_of_pucch_resources; + uint16_t n_pucch_1_0; + uint16_t n_pucch_1_1; + uint16_t n_pucch_1_2; + uint16_t n_pucch_1_3; +} fapi_ul_config_req_harq_rel10_tdd_info_t; + +typedef struct { + uint16_t n_pucch_1_0; + uint8_t harq_size; +} fapi_ul_config_req_harq_rel8_fdd_info_t; + +typedef struct { + uint8_t harq_size; + uint8_t ack_nack_mode; + uint8_t number_of_pucch_resources; + uint16_t n_pucch_1_0; + uint16_t n_pucch_1_1; + uint16_t n_pucch_1_2; + uint16_t n_pucch_1_3; +} fapi_ul_config_req_harq_rel9_fdd_info_t; + +typedef struct { + uint8_t num_ant_ports; + uint16_t n_pucch_2_0; + uint16_t n_pucch_2_1; + uint16_t n_pucch_2_2; + uint16_t n_pucch_2_3; +} fapi_ul_config_req_harq_rel11_fdd_tdd_info_t; + +typedef struct { + uint16_t harq_size_2; + uint8_t starting_prb; + uint8_t n_prb; + uint8_t cdm_index; + uint8_t n_srs; +} fapi_ul_config_req_harq_rel13_fdd_tdd_info_t; + +typedef struct { + fapi_ul_config_req_harq_rel10_tdd_info_t rel10_tdd_info; + fapi_ul_config_req_harq_rel8_fdd_info_t rel8_fdd_info; + fapi_ul_config_req_harq_rel9_fdd_info_t rel9_fdd_info; + fapi_ul_config_req_harq_rel11_fdd_tdd_info_t rel11_fdd_tdd_info; + fapi_ul_config_req_harq_rel13_fdd_tdd_info_t rel13_fdd_tdd_info; +} fapi_ul_config_req_harq_info_t; + +typedef struct { + fapi_ul_config_req_ulsch_pdu_t ulsch_pdu; + fapi_ul_config_cqi_ri_information_t cqi_ri_info; + fapi_ul_config_init_tx_params_t init_tx_params; +} fapi_ul_config_req_ulsch_cqi_ri_pdu_t; + +typedef struct { + fapi_ul_config_req_ulsch_pdu_t ulsch_pdu; + fapi_ul_config_harq_information_t harq_info; + fapi_ul_config_init_tx_params_t init_tx_params; +} fapi_ul_config_req_ulsch_harq_pdu_t; + +typedef struct { + fapi_ul_config_req_ulsch_pdu_t ulsch_pdu; + fapi_ul_config_cqi_ri_information_t cqi_ri_info; + fapi_ul_config_harq_information_t harq_info; + fapi_ul_config_init_tx_params_t init_tx_params; +} fapi_ul_config_req_ulsch_cqi_harq_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; + fapi_ul_config_req_cqi_info_t cqi_info; +} fapi_ul_config_req_uci_cqi_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; + fapi_ul_config_req_sr_info_t sr_info; +} fapi_ul_config_req_uci_sr_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; + fapi_ul_config_req_harq_info_t harq_info; +} fapi_ul_config_req_uci_harq_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; + fapi_ul_config_req_sr_info_t sr_info; + fapi_ul_config_req_harq_info_t harq_info; +} fapi_ul_config_req_uci_sr_harq_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; + fapi_ul_config_req_cqi_info_t cqi_info; + fapi_ul_config_req_harq_info_t harq_info; +} fapi_ul_config_req_uci_cqi_harq_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; + fapi_ul_config_req_cqi_info_t cqi_info; + fapi_ul_config_req_sr_info_t sr_info; +} fapi_ul_config_req_uci_cqi_sr_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; + fapi_ul_config_req_cqi_info_t cqi_info; + fapi_ul_config_req_sr_info_t sr_info; + fapi_ul_config_req_harq_info_t harq_info; +} fapi_ul_config_req_uci_cqi_sr_harq_pdu_t; + +typedef struct { + uint32_t handle; + uint16_t size; + uint16_t rnti; + uint8_t srs_bandwidth; + uint8_t frqeuency_domain_position; + uint8_t srs_hopping_bandwidth; + uint8_t transmission_comb; + uint16_t srs_config_index; + uint8_t sounding_reference_cyclic_shift; +} fapi_ul_config_req_srs_rel8_pdu_t; + +typedef struct { + uint8_t antenna_port; +} fapi_ul_config_req_srs_rel10_pdu_t; + +typedef struct { + uint8_t number_of_combs; +} fapi_ul_config_req_srs_rel13_pdu_t; + +typedef struct { + fapi_ul_config_req_srs_rel8_pdu_t rel8_pdu; + fapi_ul_config_req_srs_rel10_pdu_t rel10_pdu; + fapi_ul_config_req_srs_rel13_pdu_t rel13_pdu; +} fapi_ul_config_req_srs_pdu_t; + +typedef struct { + fapi_ul_config_req_ue_info_t ue_info; +} fapi_ul_config_req_harq_buffer_pdu_t; + +typedef struct { + fapi_ul_config_req_ulsch_pdu_t ulsch_pdu; + fapi_ul_config_req_cqi_info_t csi_information; +} fapi_ul_config_req_ulsch_uci_csi_pdu_t; + +typedef struct { + fapi_ul_config_req_ulsch_pdu_t ulsch_pdu; + fapi_ul_config_req_harq_info_t harq_information; +} fapi_ul_config_req_ulsch_uci_harq_pdu_t; + +typedef struct { + fapi_ul_config_req_ulsch_pdu_t ulsch_pdu; + fapi_ul_config_req_cqi_info_t csi_information; + fapi_ul_config_req_harq_info_t harq_information; +} fapi_ul_config_req_ulsch_csi_uci_harq_pdu_t; + +typedef struct { + uint8_t harq_ack_resource; +} fapi_ul_config_req_nb_harq_rel13_info_t; + +typedef struct { + fapi_ul_config_req_nb_harq_rel13_info_t nb_harq_pdu_rel13; +} fapi_ul_config_req_nb_harq_info_t; + +typedef struct { + uint8_t nulsch_format; + uint32_t handle; + uint16_t size; + uint16_t rnti; + uint8_t subcarrier_indication; + uint8_t resource_assignment; + uint8_t mcs; + uint8_t redudancy_version; + uint8_t repetition_number; + uint8_t new_data_indication; + uint8_t n_srs; + uint16_t scrambling_sequence_initialization_cinit; + uint16_t sf_idx; + fapi_ul_config_req_ue_info_t ue_information; + fapi_ul_config_req_nb_harq_info_t nb_harq_information; +} fapi_ul_config_req_nulsch_rel13_pdu_t; + +typedef struct { + fapi_ul_config_req_nulsch_rel13_pdu_t nulsch_pdu_rel13; +} fapi_ul_config_req_nulsch_pdu_t; + +typedef struct { + uint8_t nprach_config_0; + uint8_t nprach_config_1; + uint8_t nprach_config_2; +} fapi_ul_config_req_nrach_rel13_pdu_t; + +typedef struct { + fapi_ul_config_req_nrach_rel13_pdu_t nrach_pdu_rel13; +} fapi_ul_config_req_nrach_pdu_t; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union + { + fapi_ul_config_req_ulsch_pdu_t ulsch_pdu; + fapi_ul_config_req_ulsch_cqi_ri_pdu_t ulsch_cqi_ri_pdu; + fapi_ul_config_req_ulsch_harq_pdu_t ulsch_harq_pdu; + fapi_ul_config_req_ulsch_cqi_harq_pdu_t ulsch_cqi_harq_pdu; + fapi_ul_config_req_uci_cqi_pdu_t uci_cqi_pdu; + fapi_ul_config_req_uci_sr_pdu_t uci_sr_pdu; + fapi_ul_config_req_uci_harq_pdu_t uci_harq_pdu; + fapi_ul_config_req_uci_sr_harq_pdu_t uci_sr_harq_pdu; + fapi_ul_config_req_uci_cqi_harq_pdu_t uci_cqi_harq_pdu; + fapi_ul_config_req_uci_cqi_sr_pdu_t uci_cqi_sr_pdu; + fapi_ul_config_req_uci_cqi_sr_harq_pdu_t uci_cqi_sr_harq_pdu; + fapi_ul_config_req_srs_pdu_t srs_pdu; + fapi_ul_config_req_harq_buffer_pdu_t harq_buffer_pdu; + fapi_ul_config_req_ulsch_uci_csi_pdu_t ulsch_uci_csi_pdu; + fapi_ul_config_req_ulsch_uci_harq_pdu_t ulsch_uci_harq_pdu; + fapi_ul_config_req_ulsch_csi_uci_harq_pdu_t ulsch_csi_uci_harq_pdu; + fapi_ul_config_req_nulsch_pdu_t nulsch_pdu; + fapi_ul_config_req_nrach_pdu_t nrach_pdu; + }; +} fapi_ul_config_req_pdu_t; + +typedef struct { + uint8_t number_of_pdus; + uint8_t rach_prach_frequency_resources; + uint8_t srs_present; + fapi_ul_config_req_pdu_t* pdus; +} fapi_ul_config_req_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + uint16_t length; + fapi_ul_config_req_body_t body; +} fapi_ul_config_req_t; + +typedef struct { + uint8_t dci_format; + uint8_t cce_index; + uint8_t aggregation_level; + uint8_t rnti; + uint8_t resource_block_start; + uint8_t number_of_resource_blocks; + uint8_t mcs_1; + uint8_t cyclic_shift_2_for_drms; + uint8_t frequency_hopping_enabled_flag; + uint8_t frequency_hopping_flags; + uint8_t new_data_indication_1; + uint8_t ue_tx_antenna_selection; + uint8_t tpc; + uint8_t cqi_csi_request; + uint8_t ul_index; + uint8_t dl_assignment_index; + uint32_t tpc_bitmap; + uint16_t transmission_power; +} fapi_hi_dci0_req_dci0_rel8_pdu_t; + +typedef struct { + uint8_t cross_carrier_scheduling_flag; + uint8_t carrier_indicator; + uint8_t size_of_cqi_csi_feild; + uint8_t srs_flag; + uint8_t srs_request; + uint8_t resource_allocation_flag; + uint8_t resource_allocation_type; + uint32_t resource_block_coding; + uint8_t mcs_2; + uint8_t new_data_indication_2; + uint8_t number_of_antenna_ports; + uint8_t tpmi; + uint8_t total_dci_length_including_padding; + uint8_t n_ul_rb; +} fapi_hi_dci0_req_dci0_rel10_pdu_t; + +typedef struct { + uint8_t pscch_resource; + uint8_t time_resource_pattern; +} fapi_hi_dci0_req_dci0_rel12_pdu_t; + +typedef struct { + fapi_hi_dci0_req_dci0_rel8_pdu_t rel8_pdu; + fapi_hi_dci0_req_dci0_rel10_pdu_t rel10_pdu; + fapi_hi_dci0_req_dci0_rel12_pdu_t rel12_pdu; +} fapi_hi_dci0_req_dci0_pdu_t; + +typedef struct { + uint8_t resource_block_start; + uint8_t cyclic_shift_2_for_drms; + uint8_t hi_value; + uint8_t i_phich; + uint16_t transmission_power; +} fapi_hi_dci0_req_hi_rel8_pdu_t; + +typedef struct { + uint8_t flag_tb2; + uint8_t hi_value_2; +} fapi_hi_dci0_req_hi_rel10_pdu_t; + +typedef struct { + fapi_hi_dci0_req_hi_rel8_pdu_t rel8_pdu; + fapi_hi_dci0_req_hi_rel10_pdu_t rel10_pdu; +} fapi_hi_dci0_req_hi_pdu_t; + +typedef struct { + fapi_dl_config_dci_rel8_pdu_t edpcch_dci_pdu_rel8; + fapi_dl_config_dci_rel10_pdu_t edpcch_dci_pdu_rel10; + fapi_dl_config_edpcch_rel11_params_t edpcch_parameters_rel11; +} fapi_hi_dci0_req_epdcch_dci_ul_pdu_t; + +typedef struct { + uint8_t mpdcch_narrowband; + uint8_t number_of_prb_pairs; + uint8_t resource_block_assignment; + uint8_t mpdcch_transmission_type; + uint8_t start_symbol; + uint8_t ecce_index; + uint8_t aggreagation_level; + uint8_t rnti_type; + uint16_t rnti; + uint8_t ce_mode; + uint16_t drms_scrambling_init; + uint16_t initial_transmission_sf_io; + uint16_t transmission_power; + uint8_t dci_format; + uint8_t resource_block_start; + uint8_t number_of_resource_blocks; + uint8_t mcs; + uint8_t pusch_repetition_levels; + uint8_t frequency_hopping_flag; + uint8_t new_data_indication; + uint8_t harq_process; + uint8_t redudency_version; + uint8_t tpc; + uint8_t csi_request; + uint8_t ul_inex; + uint8_t dai_presence_flag; + uint8_t dl_assignment_index; + uint8_t srs_request; + uint8_t dci_subframe_repetition_number; + uint32_t tcp_bitmap; + uint8_t total_dci_length_include_padding; + uint8_t number_of_tx_antenna_ports; + uint16_t precoding_value[FAPI_MAX_ANTENNA_PORT_COUNT]; +} fapi_hi_dci0_req_mpdcch_dci_ul_rel13_pdu_t; + +typedef struct { + fapi_hi_dci0_req_mpdcch_dci_ul_rel13_pdu_t mpdcch_dci_pdu_rel13; +} fapi_hi_dci0_req_mpdcch_dci_ul_pdu_t; + +typedef struct { + uint8_t ncce_index; + uint8_t aggregation_level; + uint8_t start_symbol; + uint16_t rnti; + uint8_t scrambling_reinitialization_batch_index; + uint8_t nrs_antenna_ports_assumed_by_the_ue; + uint8_t subcarrier_indication; + uint8_t resource_assignment; + uint8_t scheduling_delay; + uint8_t mcs; + uint8_t redudancy_version; + uint8_t repetition_number; + uint8_t new_data_indicator; + uint8_t dci_subframe_repetition_number; +} fapi_hi_dci0_req_npdcch_dci_ul_rel13_pdu_t; + +typedef struct { + fapi_hi_dci0_req_npdcch_dci_ul_rel13_pdu_t npdcch_dci_pdu_rel13; +} fapi_hi_dci0_req_npdcch_dci_ul_pdu_t; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union + { + fapi_hi_dci0_req_hi_pdu_t hi_pdu; + fapi_hi_dci0_req_dci0_pdu_t dci0_pdu; + fapi_hi_dci0_req_epdcch_dci_ul_pdu_t edpcch_dci_ul_pdu; + fapi_hi_dci0_req_mpdcch_dci_ul_pdu_t mdpcch_dci_ul_pdu; + fapi_hi_dci0_req_npdcch_dci_ul_pdu_t ndpcch_dci_ul_pdu; + }; +} fapi_hi_dci0_req_pdu_t; + +typedef struct { + uint16_t sfn_sf; + uint8_t number_of_dci; + uint8_t number_of_hi; + fapi_hi_dci0_req_pdu_t* pdus; +} fapi_hi_dci0_req_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_hi_dci0_req_body_t body; +} fapi_hi_dci0_req_t; + +typedef struct { + uint16_t tag; + uint16_t length; + uint32_t* value; +} fapi_tx_req_pdu_tlv_t; + +typedef struct { + uint16_t pdu_length; + uint16_t pdu_index; + uint32_t num_tlv; + fapi_tx_req_pdu_tlv_t tlvs[32]; +} fapi_tx_req_pdu_t; + +typedef struct { + uint16_t number_of_pdus; + fapi_tx_req_pdu_t* pdus; +} fapi_tx_req_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + fapi_tx_req_body_t body; +} fapi_tx_req_t; + +typedef struct { + uint32_t handle; + uint32_t mp_cca; + uint32_t n_cca; + uint32_t offset; + uint32_t lte_txop_sf; + uint16_t txop_sfn_sf_end; + uint32_t lbt_mode; +} fapi_lbt_pdsch_req_rel13_pdu_t; + +typedef struct { + fapi_lbt_pdsch_req_rel13_pdu_t rel13_pdu; +} fapi_lbt_pdsch_req_pdu_t; + +typedef struct { + uint32_t handle; + uint32_t offset; + uint16_t sfn_sf_end; + uint32_t lbt_mode; +} fapi_lbt_drs_req_rel13_pdu_t; + +typedef struct { + fapi_lbt_drs_req_rel13_pdu_t rel13_pdu; +} fapi_lbt_drs_req_pdu_t; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union { + fapi_lbt_pdsch_req_pdu_t lbt_pdsch_req_pdu; + fapi_lbt_drs_req_pdu_t lbt_drs_req_pdu; + }; +} fapi_lbt_dl_config_req_pdu_t; + +typedef struct { + uint16_t number_of_pdus; + fapi_lbt_dl_config_req_pdu_t pdus[32]; +} fapi_lbt_dl_config_req_body_t; + +typedef struct { + fapi_header_t header; + uint16_t sfn_sf; + uint16_t length; + fapi_lbt_dl_config_req_body_t body; +} fapi_lbt_dl_config_req_t; + +//------------------------------------------------------------------------------ + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/nfapi/open-nFAPI/pnf_sim/inc/fapi_stub.h b/nfapi/open-nFAPI/pnf_sim/inc/fapi_stub.h new file mode 100644 index 0000000000000000000000000000000000000000..10df46e7ab34ddb297e8200c25cc159eb1a7be19 --- /dev/null +++ b/nfapi/open-nFAPI/pnf_sim/inc/fapi_stub.h @@ -0,0 +1,76 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _FAPI_STUB_H_ +#define _FAPI_STUB_H_ + +#include "fapi_interface.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +typedef struct fapi fapi_t; + +typedef struct fapi { + void* user_data; +} fapi_t; + +typedef struct { + int (*fapi_param_response)(fapi_t* fapi, fapi_param_resp_t* resp); + int (*fapi_config_response)(fapi_t* fapi, fapi_config_resp_t* resp); + + int (*fapi_subframe_ind)(fapi_t* fapi, fapi_subframe_ind_t* ind); + + int (*fapi_harq_ind)(fapi_t* fapi, fapi_harq_ind_t* ind); + int (*fapi_crc_ind)(fapi_t* fapi, fapi_crc_ind_t* ind); + int (*fapi_rx_ulsch_ind)(fapi_t* fapi, fapi_rx_ulsch_ind_t* ind); + int (*fapi_rx_cqi_ind)(fapi_t* fapi, fapi_rx_cqi_ind_t* ind); + int (*fapi_rx_sr_ind)(fapi_t* fapi, fapi_rx_sr_ind_t* ind); + int (*fapi_rach_ind)(fapi_t* fapi, fapi_rach_ind_t* ind); + int (*fapi_srs_ind)(fapi_t* fapi, fapi_srs_ind_t* ind); + + int (*fapi_lbt_dl_ind)(fapi_t* fapi, fapi_lbt_dl_ind_t* ind); + int (*fapi_nb_harq_ind)(fapi_t* fapi, fapi_nb_harq_ind_t* ind); + int (*fapi_nrach_ind)(fapi_t* fapi, fapi_nrach_ind_t* ind); + +} fapi_cb_t; + +typedef struct { + + uint16_t duplex_mode; + uint16_t dl_channel_bw_support; + uint16_t ul_channel_bw_support; +} fapi_config_t; + +fapi_t* fapi_create(fapi_cb_t* callbacks, fapi_config_t* config); + +void fapi_start_data(fapi_t* fapi, unsigned rx_port, const char* tx_address, unsigned tx_port); + +int fapi_param_request(fapi_t* fapi, fapi_param_req_t* req); +int fapi_config_request(fapi_t* fapi, fapi_config_req_t* req); +int fapi_start_request(fapi_t* fapi, fapi_start_req_t* req); + +int fapi_dl_config_request(fapi_t* fapi, fapi_dl_config_req_t* req); +int fapi_ul_config_request(fapi_t* fapi, fapi_ul_config_req_t* req); +int fapi_hi_dci0_request(fapi_t* fapi, fapi_hi_dci0_req_t* req); +int fapi_tx_request(fapi_t* fapi, fapi_tx_req_t* req); + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp new file mode 100644 index 0000000000000000000000000000000000000000..df0ca12305f6ca954c9f02f1874e31c46637022e --- /dev/null +++ b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp @@ -0,0 +1,642 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "fapi_stub.h" +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> +#include <string.h> +#include <unistd.h> +#include <pthread.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <ifaddrs.h> +#include <netdb.h> +#include <pthread.h> +#include <unistd.h> + +#include <mutex> +#include <queue> +#include <list> + +struct phy_pdu +{ + phy_pdu() : buffer_len(1500), buffer(0), len(0) + { + buffer = (char*) malloc(buffer_len); + } + + virtual ~phy_pdu() + { + free(buffer); + } + + + unsigned buffer_len; + char* buffer; + unsigned len; +}; + +class fapi_private +{ + std::mutex mutex; + std::queue<phy_pdu*> rx_buffer; + + std::queue<phy_pdu*> free_store; + public: + + fapi_private() + : byte_count(0), tick(0), first_dl_config(false) + { + } + + phy_pdu* allocate_phy_pdu() + { + phy_pdu* pdu = 0; + mutex.lock(); + if(free_store.empty()) + { + pdu = new phy_pdu(); + } + else + { + pdu = free_store.front(); + free_store.pop(); + } + mutex.unlock(); + return pdu; + } + + void release_phy_pdu(phy_pdu* pdu) + { + mutex.lock(); + free_store.push(pdu); + mutex.unlock(); + } + + bool rx_buffer_empty() + { + bool empty; + mutex.lock(); + empty = rx_buffer.empty(); + mutex.unlock(); + + return empty; + } + + + void push_rx_buffer(phy_pdu* buff) + { + mutex.lock(); + rx_buffer.push(buff); + mutex.unlock(); + } + + phy_pdu* pop_rx_buffer() + { + phy_pdu* buff = 0; + mutex.lock(); + if(!rx_buffer.empty()) + { + buff = rx_buffer.front(); + rx_buffer.pop(); + } + mutex.unlock(); + return buff; + } + + uint32_t byte_count; + uint32_t tick; + bool first_dl_config; + +}; + +extern "C" +{ + typedef struct fapi_internal + { + fapi_t _public; + + fapi_cb_t callbacks; + + uint8_t state; + fapi_config_t config; + + int rx_sock; + int tx_sock; + struct sockaddr_in tx_addr; + + uint32_t tx_byte_count; + uint32_t tick; + + fapi_private* fapi; + + } fapi_internal_t; +} + +extern void set_thread_priority(int); +/* +{ + pthread_attr_t ptAttr; + + struct sched_param schedParam; + schedParam.__sched_priority = 79; + sched_setscheduler(0, SCHED_RR, &schedParam); + + pthread_attr_setschedpolicy(&ptAttr, SCHED_RR); + + pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED); + + struct sched_param thread_params; + thread_params.sched_priority = 20; + pthread_attr_setschedparam(&ptAttr, &thread_params); +} +*/ + +void send_uplink_indications(fapi_internal_t* instance, uint16_t sfn_sf) +{ + fapi_harq_ind_t harq_ind; + (instance->callbacks.fapi_harq_ind)(&(instance->_public), &harq_ind); + + fapi_crc_ind_t crc_ind; + crc_ind.header.message_id = FAPI_CRC_INDICATION; + crc_ind.header.length = 0; //??; + crc_ind.sfn_sf = sfn_sf; + crc_ind.body.number_of_crcs = 1; + crc_ind.body.pdus[0].rx_ue_info.handle = 0; //?? + crc_ind.body.pdus[0].rx_ue_info.rnti = 0; //?? + crc_ind.body.pdus[0].rel8_pdu.crc_flag = 1; + + (instance->callbacks.fapi_crc_ind)(&(instance->_public), &crc_ind); + + if(!instance->fapi->rx_buffer_empty()) + { + fapi_rx_ulsch_ind_t rx_ind; + memset(&rx_ind, 0, sizeof(rx_ind)); + rx_ind.header.message_id = FAPI_RX_ULSCH_INDICATION; + rx_ind.sfn_sf = sfn_sf; + + + phy_pdu* buff = 0; + int i = 0; + std::list<phy_pdu*> free_list; + do + { + buff = instance->fapi->pop_rx_buffer(); + if(buff != 0) + { + if(buff->len == 0) + { + printf("[FAPI] Buffer length = 0\n"); + } + + rx_ind.body.pdus[i].rx_ue_info.handle = 0xDEADBEEF; + rx_ind.body.pdus[i].rx_ue_info.rnti = 0x4242; + + rx_ind.body.pdus[i].rel8_pdu.length = buff->len; + //rx_ind.pdus[i].rel8_pdu.data_offset; + //rx_ind.pdus[i].rel8_pdu.ul_cqi; + //rx_ind.pdus[i].rel8_pdu.timing_advance; + + rx_ind.body.data[i] = buff->buffer; + + rx_ind.body.number_of_pdus++; + i++; + + instance->fapi->byte_count += buff->len; + + free_list.push_back(buff); + } + }while(buff != 0 && i < 8); + + (instance->callbacks.fapi_rx_ulsch_ind)(&(instance->_public), &rx_ind); + + for(phy_pdu* pdu : free_list) + { + instance->fapi->release_phy_pdu(pdu); + //free(tx_req.tx_request_body.tx_pdu_list[j].segments[0].segment_data); + } + } + else + { + fapi_rx_ulsch_ind_t rx_ind; + memset(&rx_ind, 0, sizeof(rx_ind)); + rx_ind.header.message_id = FAPI_RX_ULSCH_INDICATION; + rx_ind.sfn_sf = sfn_sf; + (instance->callbacks.fapi_rx_ulsch_ind)(&(instance->_public), &rx_ind); + } + + + fapi_rx_cqi_ind_t cqi_ind; + cqi_ind.sfn_sf = sfn_sf; + (instance->callbacks.fapi_rx_cqi_ind)(&(instance->_public), &cqi_ind); + + fapi_rx_sr_ind_t sr_ind; + sr_ind.sfn_sf = sfn_sf; + (instance->callbacks.fapi_rx_sr_ind)(&(instance->_public), &sr_ind); + + fapi_rach_ind_t rach_ind; + rach_ind.sfn_sf = sfn_sf; + (instance->callbacks.fapi_rach_ind)(&(instance->_public), &rach_ind); + + fapi_srs_ind_t srs_ind; + srs_ind.sfn_sf = sfn_sf; + (instance->callbacks.fapi_srs_ind)(&(instance->_public), &srs_ind); + /* + nfapi_lbt_dl_indication_t lbt_ind; + memset(&lbt_ind, 0, sizeof(lbt_ind)); + lbt_ind.header.message_id = NFAPI_LBT_DL_INDICATION; + lbt_ind.header.phy_id = config->phy_id; + lbt_ind.sfn_sf = sfn_sf; + nfapi_pnf_p7_lbt_dl_ind(config, &lbt_ind); + + vendor_ext_p7_ind ve_p7_ind; + memset(&ve_p7_ind, 0, sizeof(ve_p7_ind)); + ve_p7_ind.header.message_id = P7_VENDOR_EXT_IND; + ve_p7_ind.header.phy_id = config->phy_id; + ve_p7_ind.error_code = NFAPI_MSG_OK; + nfapi_pnf_p7_vendor_extension(config, &(ve_p7_ind.header)); + */ + + fapi_nb_harq_ind_t nb_harq_ind; + nb_harq_ind.sfn_sf = sfn_sf; + (instance->callbacks.fapi_nb_harq_ind)(&(instance->_public), &nb_harq_ind); + + fapi_nrach_ind_t nrach_ind; + nrach_ind.sfn_sf = sfn_sf; + (instance->callbacks.fapi_nrach_ind)(&(instance->_public), &nrach_ind); + +} + +void* fapi_thread_start(void* ptr) +{ + set_thread_priority(81); + + fapi_internal_t* instance = (fapi_internal_t*)ptr; + uint16_t sfn_sf_dec = 0; + uint32_t last_tv_usec = 0; + uint32_t last_tv_sec = 0; + + uint32_t millisec; + uint32_t last_millisec = -1; + uint16_t catchup = 0; + + while(1) + { + // get the time + struct timeval sf_start; + (void)gettimeofday(&sf_start, NULL); + + uint16_t sfn_sf = ((((sfn_sf_dec) / 10) << 4) | (((sfn_sf_dec) - (((sfn_sf_dec) / 10) * 10)) & 0xF)); + // increment the sfn/sf - for the next subframe + sfn_sf_dec++; + if(sfn_sf_dec > 10239) + sfn_sf_dec = 0; + + + fapi_subframe_ind_t ind; + ind.sfn_sf = sfn_sf; + + if(instance->fapi->first_dl_config) + send_uplink_indications(instance, sfn_sf); + + if(instance->tick == 1000) + { + if(instance->tx_byte_count > 0) + { + printf("[FAPI] Tx rate %d bytes/sec\n", instance->tx_byte_count); + instance->tx_byte_count = 0; + } + + instance->tick = 0; + } + + instance->tick++; + + (instance->callbacks.fapi_subframe_ind)(&(instance->_public), &ind); + + { + phy_pdu* pdu = instance->fapi->allocate_phy_pdu(); + int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, MSG_DONTWAIT, 0, 0); + if(len > 0) + { + pdu->len = len; + instance->fapi->push_rx_buffer(pdu); + } + else + { + instance->fapi->release_phy_pdu(pdu); + } + } + + + if(catchup) + { + catchup--; + } + else + { + struct timespec now_ts; + struct timespec sleep_ts; + struct timespec sleep_rem_ts; + + // get the current time + clock_gettime(CLOCK_MONOTONIC, &now_ts); + + + // determine how long to sleep before the start of the next 1ms + sleep_ts.tv_sec = 0; + sleep_ts.tv_nsec = 1e6 - (now_ts.tv_nsec % 1000000); + + int nanosleep_result = nanosleep(&sleep_ts, &sleep_rem_ts); + + if(nanosleep_result != 0) + printf("*** nanosleep failed or was interrupted\n"); + + + clock_gettime(CLOCK_MONOTONIC, &now_ts); + millisec = now_ts.tv_nsec / 1e6; + + if(last_millisec != -1 && ((last_millisec + 1 ) % 1000) != millisec) + { + printf("*** missing millisec %d %d\n", last_millisec, millisec); + catchup = millisec - last_millisec - 1; + } + + last_millisec = millisec; + } + } +} + +extern "C" +{ + fapi_t* fapi_create(fapi_cb_t* callbacks, fapi_config_t* config) + { + fapi_internal_t* instance = (fapi_internal*)calloc(1, sizeof(fapi_internal_t)); + instance->callbacks = *callbacks; + instance->config = *config; + instance->state = 0; + + instance->fapi = new fapi_private(); + + return (fapi_t*)instance; + } + + void fapi_destroy(fapi_t* fapi) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + + delete instance->fapi; + free(instance); + } + + void* fapi_rx_thread_start(void* ptr) + { + set_thread_priority(60); + + fapi_internal_t* instance = (fapi_internal_t*)ptr; + + while(1) + { + phy_pdu* pdu = instance->fapi->allocate_phy_pdu(); + int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, 0, 0, 0); + if(len > 0) + { + pdu->len = len; + instance->fapi->push_rx_buffer(pdu); + } + else + { + instance->fapi->release_phy_pdu(pdu); + } + + } + } + + void fapi_start_data(fapi_t* fapi, unsigned rx_port, const char* tx_address, unsigned tx_port) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + + printf("[FAPI] Rx Data from %d\n", rx_port); + printf("[FAPI] Tx Data to %s:%d\n", tx_address, tx_port); + + instance->rx_sock = socket(AF_INET, SOCK_DGRAM, 0); + + if(instance->rx_sock < 0) + { + printf("[FAPI] Failed to create socket\n"); + return; + } + + struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(rx_port); + addr.sin_addr.s_addr = INADDR_ANY; + + int bind_result = bind(instance->rx_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); + + if(bind_result == -1) + { + printf("[FAPI] Failed to bind to port %d\n", rx_port); + close(instance->rx_sock); + return ; + } + + instance->tx_sock = socket(AF_INET, SOCK_DGRAM, 0); + instance->tx_addr.sin_family = AF_INET; + instance->tx_addr.sin_port = htons(tx_port); + instance->tx_addr.sin_addr.s_addr = inet_addr(tx_address); + + } + + + void fill_tlv(fapi_tlv_t tlvs[], uint8_t count, uint8_t tag, uint8_t len, uint16_t value) + { + tlvs[count].tag = tag; + tlvs[count].value = value; + tlvs[count].length = len; + + } + + int fapi_param_request(fapi_t* fapi, fapi_param_req_t* req) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + + fapi_param_resp_t resp; + resp.header.message_id = FAPI_PARAM_RESPONSE; + + resp.error_code = FAPI_MSG_OK; + + resp.number_of_tlvs = 0; + fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_STATE_TAG, 2, instance->state); + + + if(instance->state == 0) + { + if(instance->config.duplex_mode == 0) + { + // -- TDD + // Downlink Bandwidth Support + // Uplink Bandwidth Support + // Downlink Modulation Support + // Uplink Modulation Support + // PHY Antenna Capability + // Release Capability + // MBSFN Capability + } + else if(instance->config.duplex_mode == 1) + { + // -- FDD + // Downlink Bandwidth Support + fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG, 2, instance->config.dl_channel_bw_support); + // Uplink Bandwidth Support + fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG, 2, instance->config.ul_channel_bw_support); + // Downlink Modulation Support + // Uplink Modulation Support + // PHY Antenna Capability + // Release Capability + // MBSFN Capability + // LAA Capability + } + } + else + { + if(instance->config.duplex_mode == 0) + { + // -- TDD + // Downlink Bandwidth Support + // Uplink Bandwidth Support + // Downlink Modulation Support + // Uplink Modulation Support + // PHY Antenna Capability + // Release Capability + // MBSFN Capability + // Duplexing Mode + // PCFICH Power Offset + // P-B + // DL Cyclic Prefix Type + // UL Cyclic Prefix Type + // RF Config + // PHICH Config + // SCH Config + // PRACH Config + // PUSCH Config + // PUCCH Config + // SRS Config + // Uplink Reference Signal Config + // TDD Frame Structure Config + // Data Report Mode + } + else if(instance->config.duplex_mode == 1) + { + // FDD + // Downlink Bandwidth Support + // Uplink Bandwidth Support + // Downlink Modulation Support + // Uplink Modulation Support + // PHY Antenna Capability + // Release Capability + // MBSFN Capability + // LAA Capability + // Duplexing Mode + // PCFICH Power Offset + // P-B + // DL Cyclic Prefix Type + // UL Cyclic Prefix Type + // RF Config + // PHICH Config + // SCH Config + // PRACH Config + // PUSCH Config + // PUCCH Config + // SRS Config + // Uplink Reference Signal Config + // Data Report Mode + } + } + + + //todo fill + (instance->callbacks.fapi_param_response)(fapi, &resp); + + return 0; + } + + int fapi_config_request(fapi_t* fapi, fapi_config_req_t* req) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + + fapi_config_resp_t resp; + resp.header.message_id = FAPI_CONFIG_RESPONSE; + resp.error_code = FAPI_MSG_OK; + + (instance->callbacks.fapi_config_response)(fapi, &resp); + return 0; + } + + int fapi_start_request(fapi_t* fapi, fapi_start_req_t* req) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + + pthread_t fapi_thread; + pthread_create(&fapi_thread, NULL, &fapi_thread_start, instance); + + return 0; + } + + int fapi_dl_config_request(fapi_t* fapi, fapi_dl_config_req_t* req) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + instance->fapi->first_dl_config = true; + return 0; + } + int fapi_ul_config_request(fapi_t* fapi, fapi_ul_config_req_t* req) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + return 0; + } + int fapi_hi_dci0_request(fapi_t* fapi, fapi_hi_dci0_req_t* req) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + return 0; + } + int fapi_tx_request(fapi_t* fapi, fapi_tx_req_t* req) + { + fapi_internal_t* instance = (fapi_internal_t*)fapi; + + for(int i = 0; i < req->body.number_of_pdus; ++i) + { + uint16_t len = req->body.pdus[i].pdu_length; + uint32_t* data = req->body.pdus[i].tlvs[0].value; + //printf("[FAPI] sfnsf:%d len:%d\n", req->sfn_sf,len); + // + instance->tx_byte_count += len; + + int sendto_result = sendto(instance->tx_sock, data, len, 0, (struct sockaddr*)&(instance->tx_addr), sizeof(instance->tx_addr)); + + if(sendto_result == -1) + { + // error + } + } + + return 0; + } +} + diff --git a/nfapi/open-nFAPI/pnf_sim/src/main.cpp b/nfapi/open-nFAPI/pnf_sim/src/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e2622cf3c3636f1021633e1570c8949d31088f8c --- /dev/null +++ b/nfapi/open-nFAPI/pnf_sim/src/main.cpp @@ -0,0 +1,2285 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <unistd.h> +#include "debug.h" +#include "nfapi_pnf_interface.h" +#include "nfapi.h" +#include <sys/socket.h> +#include <sys/time.h> +#include <netinet/in.h> +#include <assert.h> +#include <arpa/inet.h> + +#include <boost/foreach.hpp> +#include <boost/property_tree/xml_parser.hpp> +#include <boost/property_tree/ptree.hpp> +#include <boost/exception/diagnostic_information.hpp> +#include <boost/exception_ptr.hpp> + + +#include <vendor_ext.h> + +#include "fapi_stub.h" +#include "pool.h" + + +#include <mutex> +#include <list> +#include <queue> +#include <map> +#include <vector> +#include <algorithm> +#include <stdlib.h> + +#define NUM_P5_PHY 2 + +uint16_t phy_antenna_capability_values[] = { 1, 2, 4, 8, 16 }; + +static uint32_t rand_range(uint32_t min, uint32_t max) +{ + return ((rand() % (max + 1 - min)) + min); +} + + + +extern "C" nfapi_pnf_param_response_t g_pnf_param_resp; + +extern "C" { + + +void* pnf_allocate(size_t size) +{ + return (void*)memory_pool::allocate(size); +} + +void pnf_deallocate(void* ptr) +{ + memory_pool::deallocate((uint8_t*)ptr); +} + + +int read_xml(const char *xml_file); + +}; + +class udp_data +{ + public: + bool enabled; + uint32_t rx_port; + uint32_t tx_port; + std::string tx_addr; +}; + +class phy_info +{ + public: + + phy_info() + : first_subframe_ind(0), fapi(0), + dl_ues_per_subframe(0), ul_ues_per_subframe(0), + timing_window(0), timing_info_mode(0), timing_info_period(0) + { + index = 0; + id = 0; + + local_port = 0; + remote_addr = 0; + remote_port = 0; + + duplex_mode = 0; + dl_channel_bw_support = 0; + ul_channel_bw_support = 0; + num_dl_layers_supported = 0; + num_ul_layers_supported = 0; + release_supported = 0; + nmm_modes_supported = 0; + } + + uint16_t index; + uint16_t id; + std::vector<uint8_t> rfs; + std::vector<uint8_t> excluded_rfs; + + udp_data udp; + + std::string local_addr; + int local_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 dl_ues_per_subframe; + uint8_t ul_ues_per_subframe; + + 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; + + fapi_t* fapi; + +}; + +class rf_info +{ + public: + uint16_t index; + uint16_t band; + int16_t max_transmit_power; + int16_t min_transmit_power; + uint8_t num_antennas_supported; + uint32_t min_downlink_frequency; + uint32_t max_downlink_frequency; + uint32_t max_uplink_frequency; + uint32_t min_uplink_frequency; +}; + + +class pnf_info +{ + public: + + pnf_info() + : release(13), wireshark_test_mode(0), + max_total_power(0), oui(0) + + { + release = 0; + + sync_mode = 0; + location_mode = 0; + dl_config_timing = 0; + ul_config_timing = 0; + tx_timing = 0; + hi_dci0_timing = 0; + + max_phys = 0; + max_total_bw = 0; + max_total_dl_layers = 0; + max_total_ul_layers = 0; + shared_bands = 0; + shared_pa = 0; + + } + + int release; + std::vector<phy_info> phys; + std::vector<rf_info> rfs; + + 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; + +}; + +struct pnf_phy_user_data_t +{ + uint16_t phy_id; + nfapi_pnf_config_t* config; + phy_info* phy; + nfapi_pnf_p7_config_t* p7_config; +}; + +int read_pnf_xml(pnf_info& pnf, const char* xml_file) +{ + try + { + std::ifstream input(xml_file); + + using boost::property_tree::ptree; + ptree pt; + + read_xml(input, pt); + + pnf.wireshark_test_mode = pt.get<unsigned>("pnf.wireshark_test_mode", 0); + + + pnf.sync_mode = pt.get<unsigned>("pnf.sync_mode"); + pnf.location_mode= pt.get<unsigned>("pnf.location_mode"); + //pnf.sync_mode = pt.get<unsigned>("pnf.location_coordinates"); + + pnf.dl_config_timing= pt.get<unsigned>("pnf.dl_config_timing"); + pnf.ul_config_timing = pt.get<unsigned>("pnf.ul_config_timing"); + pnf.tx_timing = pt.get<unsigned>("pnf.tx_timing"); + pnf.hi_dci0_timing = pt.get<unsigned>("pnf.hi_dci0_timing"); + + pnf.max_phys = pt.get<unsigned>("pnf.max_phys"); + pnf.max_total_bw = pt.get<unsigned>("pnf.max_total_bandwidth"); + pnf.max_total_dl_layers = pt.get<unsigned>("pnf.max_total_num_dl_layers"); + pnf.max_total_ul_layers = pt.get<unsigned>("pnf.max_total_num_ul_layers"); + + pnf.shared_bands = pt.get<unsigned>("pnf.shared_bands"); + pnf.shared_pa = pt.get<unsigned>("pnf.shared_pas"); + + pnf.max_total_power = pt.get<signed>("pnf.maximum_total_power"); + + //"oui"); + + for(const auto& v : pt.get_child("pnf.phys")) + { + if(v.first == "phy") + { + phy_info phy; + + + + phy.index = v.second.get<unsigned>("index"); + phy.local_port = v.second.get<unsigned>("port"); + phy.local_addr = v.second.get<std::string>("address"); + phy.duplex_mode = v.second.get<unsigned>("duplex_mode"); + + phy.dl_channel_bw_support = v.second.get<unsigned>("downlink_channel_bandwidth_support"); + phy.ul_channel_bw_support = v.second.get<unsigned>("uplink_channel_bandwidth_support"); + phy.num_dl_layers_supported = v.second.get<unsigned>("number_of_dl_layers"); + phy.num_ul_layers_supported = v.second.get<unsigned>("number_of_ul_layers"); + phy.release_supported = v.second.get<unsigned>("3gpp_release_supported"); + phy.nmm_modes_supported = v.second.get<unsigned>("nmm_modes_supported"); + + for(const auto& v2 : v.second.get_child("rfs")) + { + if(v2.first == "index") + phy.rfs.push_back(v2.second.get_value<unsigned>()); + } + for(const auto& v2 : v.second.get_child("excluded_rfs")) + { + if(v2.first == "index") + phy.excluded_rfs.push_back(v2.second.get_value<unsigned>()); + } + + boost::optional<const boost::property_tree::ptree&> d = v.second.get_child_optional("data.udp"); + if(d.is_initialized()) + { + phy.udp.enabled = true; + phy.udp.rx_port = d.get().get<unsigned>("rx_port"); + phy.udp.tx_port = d.get().get<unsigned>("tx_port"); + phy.udp.tx_addr = d.get().get<std::string>("tx_addr"); + } + else + { + phy.udp.enabled = false; + } + + phy.dl_ues_per_subframe = v.second.get<unsigned>("dl_ues_per_subframe"); + phy.ul_ues_per_subframe = v.second.get<unsigned>("ul_ues_per_subframe"); + + pnf.phys.push_back(phy); + } + } + for(const auto& v : pt.get_child("pnf.rfs")) + { + if(v.first == "rf") + { + rf_info rf; + + rf.index = v.second.get<unsigned>("index"); + rf.band = v.second.get<unsigned>("band"); + rf.max_transmit_power = v.second.get<signed>("max_transmit_power"); + rf.min_transmit_power = v.second.get<signed>("min_transmit_power"); + rf.num_antennas_supported = v.second.get<unsigned>("num_antennas_supported"); + rf.min_downlink_frequency = v.second.get<unsigned>("min_downlink_frequency"); + rf.max_downlink_frequency = v.second.get<unsigned>("max_downlink_frequency"); + rf.min_uplink_frequency = v.second.get<unsigned>("max_uplink_frequency"); + rf.max_uplink_frequency = v.second.get<unsigned>("min_uplink_frequency"); + + pnf.rfs.push_back(rf); + } + } + } + catch(std::exception& e) + { + printf("%s", e.what()); + return -1; + } + catch(boost::exception& e) + { + printf("%s", boost::diagnostic_information(e).c_str()); + return -1; + } + + return 0; +} + + + +void pnf_sim_trace(nfapi_trace_level_t level, const char* message, ...) +{ + va_list args; + va_start(args, message); + vprintf(message, args); + va_end(args); +} + +void set_thread_priority(int priority) +{ + //printf("%s(priority:%d)\n", __FUNCTION__, priority); + + pthread_attr_t ptAttr; + + struct sched_param schedParam; + schedParam.__sched_priority = priority; //79; + if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) + { + printf("failed to set SCHED_RR\n"); + } + + if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) + { + printf("failed to set pthread SCHED_RR %d\n", errno); + } + + 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) +{ + set_thread_priority(79); + + 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) +{ + printf("[PNF_SIM] 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); + + 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; + //uint8_t location_coordinates[NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH]; + resp.pnf_param_general.dl_config_timing = pnf->dl_config_timing; + resp.pnf_param_general.tx_timing = pnf->tx_timing; + resp.pnf_param_general.ul_config_timing = pnf->ul_config_timing; + resp.pnf_param_general.hi_dci0_timing = pnf->hi_dci0_timing; + resp.pnf_param_general.maximum_number_phys = pnf->max_phys; + resp.pnf_param_general.maximum_total_bandwidth = pnf->max_total_bw; + resp.pnf_param_general.maximum_total_number_dl_layers = pnf->max_total_dl_layers; + resp.pnf_param_general.maximum_total_number_ul_layers = pnf->max_total_ul_layers; + 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; + //uint8_t oui[NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH]; + + resp.pnf_phy.tl.tag = NFAPI_PNF_PHY_TAG; + resp.pnf_phy.number_of_phys = pnf->phys.size(); + + for(int i = 0; i < pnf->phys.size(); ++i) + { + 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 = pnf->phys[i].rfs.size(); + for(int j = 0; j < pnf->phys[i].rfs.size(); ++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 = pnf->phys[i].excluded_rfs.size(); + for(int j = 0; j < pnf->phys[i].excluded_rfs.size(); ++j) + { + resp.pnf_phy.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j]; + } + } + + + resp.pnf_rf.tl.tag = NFAPI_PNF_RF_TAG; + resp.pnf_rf.number_of_rfs = pnf->rfs.size(); + + for(int i = 0; i < pnf->rfs.size(); ++i) + { + 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].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; + resp.pnf_rf.rf[i].maximum_downlink_frequency = pnf->rfs[i].max_downlink_frequency; + resp.pnf_rf.rf[i].minimum_uplink_frequency = pnf->rfs[i].min_uplink_frequency; + resp.pnf_rf.rf[i].maximum_uplink_frequency = pnf->rfs[i].max_uplink_frequency; + } + + if(pnf->release >= 10) + { + resp.pnf_phy_rel10.tl.tag = NFAPI_PNF_PHY_REL10_TAG; + resp.pnf_phy_rel10.number_of_phys = pnf->phys.size(); + + for(int i = 0; i < pnf->phys.size(); ++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; + resp.pnf_phy_rel10.phy[i].transmission_mode_9_supported = 1; + resp.pnf_phy_rel10.phy[i].simultaneous_pucch_pusch = 0; + resp.pnf_phy_rel10.phy[i].four_layer_tx_with_tm3_and_tm4 = 1; + + } + } + + if(pnf->release >= 11) + { + resp.pnf_phy_rel11.tl.tag = NFAPI_PNF_PHY_REL11_TAG; + resp.pnf_phy_rel11.number_of_phys = pnf->phys.size(); + + for(int i = 0; i < pnf->phys.size(); ++i) + { + 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; + resp.pnf_phy_rel11.phy[i].ul_comp_supported = 1; + resp.pnf_phy_rel11.phy[i].transmission_mode_5_supported = 0; + } + } + + if(pnf->release >= 12) + { + resp.pnf_phy_rel12.tl.tag = NFAPI_PNF_PHY_REL12_TAG; + resp.pnf_phy_rel12.number_of_phys = pnf->phys.size(); + + for(int i = 0; i < pnf->phys.size(); ++i) + { + 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; // yes this is invalid + resp.pnf_phy_rel12.phy[i].drs_supported = 0; + resp.pnf_phy_rel12.phy[i].ul_64qam_supported = 1; + resp.pnf_phy_rel12.phy[i].transmission_mode_10_supported = 0; + resp.pnf_phy_rel12.phy[i].alternative_bts_indices = 1; + } + } + + if(pnf->release >= 13) + { + resp.pnf_phy_rel13.tl.tag = NFAPI_PNF_PHY_REL13_TAG; + resp.pnf_phy_rel13.number_of_phys = pnf->phys.size(); + + for(int i = 0; i < pnf->phys.size(); ++i) + { + 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; + resp.pnf_phy_rel13.phy[i].laa_supported = 1; + resp.pnf_phy_rel13.phy[i].laa_ending_in_dwpts_supported = 0; + resp.pnf_phy_rel13.phy[i].laa_starting_in_second_slot_supported = 1; + resp.pnf_phy_rel13.phy[i].beamforming_supported = 0; + resp.pnf_phy_rel13.phy[i].csi_rs_enhancement_supported = 1; + resp.pnf_phy_rel13.phy[i].drms_enhancement_supported = 0; + resp.pnf_phy_rel13.phy[i].srs_enhancement_supported = 1; + } + + resp.pnf_phy_rel13_nb_iot.tl.tag = NFAPI_PNF_PHY_REL13_NB_IOT_TAG; + resp.pnf_phy_rel13_nb_iot.number_of_phys = pnf->phys.size(); + + for(int i = 0; i < pnf->phys.size(); ++i) + { + 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 = pnf->phys[i].rfs.size(); + for(int j = 0; j < pnf->phys[i].rfs.size(); ++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 = pnf->phys[i].excluded_rfs.size(); + for(int j = 0; j < pnf->phys[i].excluded_rfs.size(); ++j) + { + resp.pnf_phy_rel13_nb_iot.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j]; + } + + resp.pnf_phy_rel13_nb_iot.phy[i].number_of_dl_layers_supported = pnf->phys[i].num_dl_layers_supported; + resp.pnf_phy_rel13_nb_iot.phy[i].number_of_ul_layers_supported = pnf->phys[i].num_ul_layers_supported; + resp.pnf_phy_rel13_nb_iot.phy[i].maximum_3gpp_release_supported = pnf->phys[i].release_supported; + resp.pnf_phy_rel13_nb_iot.phy[i].nmm_modes_supported = pnf->phys[i].nmm_modes_supported; + + } + } + + + nfapi_pnf_pnf_param_resp(config, &resp); + + return 0; +} + +int pnf_config_request(nfapi_pnf_config_t* config, nfapi_pnf_config_request_t* req) +{ + printf("[PNF_SIM] pnf config request\n"); + + pnf_info* pnf = (pnf_info*)(config->user_data); + + for(int i = 0; i < req->pnf_phy_rf_config.number_phy_rf_config_info; ++i) + { + auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) + { return item.index == req->pnf_phy_rf_config.phy_rf_config[i].phy_config_index; }); + + if(found != pnf->phys.end()) + { + phy_info& phy = (*found); + phy.id = req->pnf_phy_rf_config.phy_rf_config[i].phy_id; + printf("[PNF_SIM] pnf config request assigned phy_id %d to phy_config_index %d\n", phy.id, req->pnf_phy_rf_config.phy_rf_config[i].phy_config_index); + } + else + { + // did not find the phy + printf("[PNF_SIM] pnf config request did not find phy_config_index %d\n", req->pnf_phy_rf_config.phy_rf_config[i].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); + + return 0; +} + +int fapi_param_response(fapi_t* fapi, fapi_param_resp_t* resp) +{ + printf("[PNF_SIM] fapi param response\n"); + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_param_response_t nfapi_resp; + + memset(&nfapi_resp, 0, sizeof(nfapi_resp)); + nfapi_resp.header.message_id = NFAPI_PARAM_RESPONSE; + nfapi_resp.header.phy_id = data->phy_id; + nfapi_resp.error_code = resp->error_code; + + for(int i = 0; i < resp->number_of_tlvs; ++i) + { + switch(resp->tlvs[i].tag) + { + case FAPI_PHY_STATE_TAG: + nfapi_resp.l1_status.phy_state.tl.tag = NFAPI_L1_STATUS_PHY_STATE_TAG; + nfapi_resp.l1_status.phy_state.value = resp->tlvs[i].value; + nfapi_resp.num_tlv++; + break; + + case FAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG: + nfapi_resp.phy_capabilities.dl_bandwidth_support.tl.tag = NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG; + nfapi_resp.phy_capabilities.dl_bandwidth_support.value = resp->tlvs[i].value; + nfapi_resp.num_tlv++; + break; + + case FAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG: + nfapi_resp.phy_capabilities.ul_bandwidth_support.tl.tag = NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG; + nfapi_resp.phy_capabilities.ul_bandwidth_support.value = resp->tlvs[i].value; + nfapi_resp.num_tlv++; + break; + } + } + + if(1) + { + // just code to populate all the tlv for testing with wireshark + // todo : these should be move up so that they are populated by fapi + + nfapi_resp.phy_capabilities.dl_modulation_support.tl.tag = NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG; + nfapi_resp.phy_capabilities.dl_modulation_support.value = rand_range(0, 0x0F); + nfapi_resp.num_tlv++; + nfapi_resp.phy_capabilities.ul_modulation_support.tl.tag = NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG; + nfapi_resp.phy_capabilities.ul_modulation_support.value = rand_range(0, 0x07); + nfapi_resp.num_tlv++; + nfapi_resp.phy_capabilities.phy_antenna_capability.tl.tag = NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG; + nfapi_resp.phy_capabilities.phy_antenna_capability.value = phy_antenna_capability_values[rand_range(0, 4)]; + nfapi_resp.num_tlv++; + nfapi_resp.phy_capabilities.release_capability.tl.tag = NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG; + nfapi_resp.phy_capabilities.release_capability.value = rand_range(0, 0x3F); + nfapi_resp.num_tlv++; + nfapi_resp.phy_capabilities.mbsfn_capability.tl.tag = NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG; + nfapi_resp.phy_capabilities.mbsfn_capability.value = rand_range(0, 1); + nfapi_resp.num_tlv++; + + + nfapi_resp.laa_capability.laa_support.tl.tag = NFAPI_LAA_CAPABILITY_LAA_SUPPORT_TAG; + nfapi_resp.laa_capability.laa_support.value = rand_range(0, 1); + nfapi_resp.num_tlv++; + nfapi_resp.laa_capability.pd_sensing_lbt_support.tl.tag = NFAPI_LAA_CAPABILITY_PD_SENSING_LBT_SUPPORT_TAG; + nfapi_resp.laa_capability.pd_sensing_lbt_support.value = rand_range(0, 1); + nfapi_resp.num_tlv++; + nfapi_resp.laa_capability.multi_carrier_lbt_support.tl.tag = NFAPI_LAA_CAPABILITY_MULTI_CARRIER_LBT_SUPPORT_TAG; + nfapi_resp.laa_capability.multi_carrier_lbt_support.value = rand_range(0, 0x0F); + nfapi_resp.num_tlv++; + nfapi_resp.laa_capability.partial_sf_support.tl.tag = NFAPI_LAA_CAPABILITY_PARTIAL_SF_SUPPORT_TAG; + nfapi_resp.laa_capability.partial_sf_support.value = rand_range(0, 1); + nfapi_resp.num_tlv++; + + nfapi_resp.nb_iot_capability.nb_iot_support.tl.tag = NFAPI_LAA_CAPABILITY_NB_IOT_SUPPORT_TAG; + nfapi_resp.nb_iot_capability.nb_iot_support.value = rand_range(0, 2); + nfapi_resp.num_tlv++; + nfapi_resp.nb_iot_capability.nb_iot_operating_mode_capability.tl.tag = NFAPI_LAA_CAPABILITY_NB_IOT_OPERATING_MODE_CAPABILITY_TAG; + nfapi_resp.nb_iot_capability.nb_iot_operating_mode_capability.value = rand_range(0, 1); + nfapi_resp.num_tlv++; + + nfapi_resp.subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.subframe_config.pcfich_power_offset.tl.tag = NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.subframe_config.pb.tl.tag = NFAPI_SUBFRAME_CONFIG_PB_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.subframe_config.dl_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.subframe_config.ul_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.rf_config.dl_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.rf_config.ul_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.rf_config.reference_signal_power.tl.tag = NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.rf_config.tx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.rf_config.rx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.phich_config.phich_resource.tl.tag = NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.phich_config.phich_duration.tl.tag = NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.phich_config.phich_power_offset.tl.tag = NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.sch_config.primary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.sch_config.secondary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.sch_config.physical_cell_id.tl.tag = NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.prach_config.configuration_index.tl.tag = NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.prach_config.root_sequence_index.tl.tag = NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.prach_config.zero_correlation_zone_configuration.tl.tag = NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.prach_config.high_speed_flag.tl.tag = NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.prach_config.frequency_offset.tl.tag = NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.pusch_config.hopping_mode.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.pusch_config.hopping_offset.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.pusch_config.number_of_subbands.tl.tag = NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.pucch_config.delta_pucch_shift.tl.tag = NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.pucch_config.n_cqi_rb.tl.tag = NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.pucch_config.n_an_cs.tl.tag = NFAPI_PUCCH_CONFIG_N_AN_CS_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.pucch_config.n1_pucch_an.tl.tag = NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.srs_config.bandwidth_configuration.tl.tag = NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.srs_config.max_up_pts.tl.tag = NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.srs_config.srs_subframe_configuration.tl.tag = NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.srs_config.srs_acknack_srs_simultaneous_transmission.tl.tag = NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.uplink_reference_signal_config.uplink_rs_hopping.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.uplink_reference_signal_config.group_assignment.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.tdd_frame_structure_config.subframe_assignment.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.tdd_frame_structure_config.special_subframe_patterns.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG; + nfapi_resp.num_tlv++; + + nfapi_resp.l23_config.data_report_mode.tl.tag = NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG; + nfapi_resp.num_tlv++; + nfapi_resp.l23_config.sfnsf.tl.tag = NFAPI_L23_CONFIG_SFNSF_TAG; + nfapi_resp.num_tlv++; + } + + + { + //if(phy->state == NFAPI_PNF_PHY_IDLE) + //if(nfapi_resp.l1_status.phy_state.value == NFAPI_PNF_PHY_IDLE) + { + // -- NFAPI + // Downlink UEs per Subframe + nfapi_resp.nfapi_config.dl_ue_per_sf.tl.tag = NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG; + nfapi_resp.nfapi_config.dl_ue_per_sf.value = data->phy->dl_ues_per_subframe; + nfapi_resp.num_tlv++; + // Uplink UEs per Subframe + nfapi_resp.nfapi_config.ul_ue_per_sf.tl.tag = NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG; + nfapi_resp.nfapi_config.ul_ue_per_sf.value = data->phy->ul_ues_per_subframe; + nfapi_resp.num_tlv++; + // nFAPI RF Bands + nfapi_resp.nfapi_config.rf_bands.tl.tag = NFAPI_PHY_RF_BANDS_TAG; + nfapi_resp.nfapi_config.rf_bands.number_rf_bands = 2; + nfapi_resp.nfapi_config.rf_bands.rf_band[0] = 23; + nfapi_resp.nfapi_config.rf_bands.rf_band[1] = 7; + + // P7 PNF Address IPv4 + nfapi_resp.nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG; + struct sockaddr_in pnf_p7_sockaddr; + pnf_p7_sockaddr.sin_addr.s_addr = inet_addr(data->phy->local_addr.c_str()); + memcpy(&(nfapi_resp.nfapi_config.p7_pnf_address_ipv4.address[0]), &pnf_p7_sockaddr.sin_addr.s_addr, 4); + nfapi_resp.num_tlv++; + // P7 PNF Address IPv6 + // 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 = data->phy->local_port; + nfapi_resp.num_tlv++; + // NMM GSM Frequency Bands + nfapi_resp.nfapi_config.nmm_gsm_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG; + nfapi_resp.nfapi_config.nmm_gsm_frequency_bands.number_of_rf_bands = 1; + nfapi_resp.nfapi_config.nmm_gsm_frequency_bands.bands[0] = 23; + nfapi_resp.num_tlv++; + // NMM UMTS Frequency Bands + nfapi_resp.nfapi_config.nmm_umts_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG; + nfapi_resp.nfapi_config.nmm_umts_frequency_bands.number_of_rf_bands = 1; + nfapi_resp.nfapi_config.nmm_umts_frequency_bands.bands[0] = 23; + nfapi_resp.num_tlv++; + // NMM LTE Frequency Bands + nfapi_resp.nfapi_config.nmm_lte_frequency_bands.tl.tag = NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG; + nfapi_resp.nfapi_config.nmm_lte_frequency_bands.number_of_rf_bands = 1; + nfapi_resp.nfapi_config.nmm_lte_frequency_bands.bands[0] = 23; + nfapi_resp.num_tlv++; + // NMM Uplink RSSI supported + nfapi_resp.nfapi_config.nmm_uplink_rssi_supported.tl.tag = NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG; + nfapi_resp.nfapi_config.nmm_uplink_rssi_supported.value = 1; + nfapi_resp.num_tlv++; + + } + } + + + + nfapi_pnf_param_resp(data->config, &nfapi_resp); + + return 0; +} + +int fapi_config_response(fapi_t* fapi, fapi_config_resp_t* resp) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_config_response_t nfapi_resp; + memset(&nfapi_resp, 0, sizeof(nfapi_resp)); + nfapi_resp.header.message_id = NFAPI_CONFIG_RESPONSE; + nfapi_resp.header.phy_id = data->phy_id; + nfapi_resp.error_code = resp->error_code; + nfapi_pnf_config_resp(data->config, &nfapi_resp); + + return 0; +} + +int fapi_subframe_ind(fapi_t* fapi, fapi_subframe_ind_t* resp) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + if(data->phy->first_subframe_ind == 0) + { + printf("Sending nfapi_pnf_start_resp phy_id:%d\n", data->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 = data->phy_id; + start_resp.error_code = NFAPI_MSG_OK; + nfapi_pnf_start_resp(data->config, &start_resp); + + data->phy->first_subframe_ind = 1; + + if(data->phy->udp.enabled) + { + fapi_start_data(fapi, + data->phy->udp.rx_port, + data->phy->udp.tx_addr.c_str(), + data->phy->udp.tx_port); + } + + } + + + nfapi_pnf_p7_subframe_ind(data->p7_config, data->phy_id, resp->sfn_sf); + + return 0; + +} + +int fapi_harq_ind(fapi_t* fapi, fapi_harq_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_harq_indication_t harq_ind; + memset(&harq_ind, 0, sizeof(harq_ind)); + harq_ind.header.message_id = NFAPI_HARQ_INDICATION; + harq_ind.header.phy_id = data->p7_config->phy_id; + harq_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + harq_ind.harq_indication_body.number_of_harqs = 1; + + nfapi_harq_indication_pdu_t pdus[harq_ind.harq_indication_body.number_of_harqs]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdus[0].rx_ue_information.handle = rand_range(0, 9999); + pdus[0].rx_ue_information.rnti = rand_range(1, 65535); + + + + pdus[0].harq_indication_tdd_rel8.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL8_TAG; + pdus[0].harq_indication_tdd_rel8.mode = rand_range(0, 4); + pdus[0].harq_indication_tdd_rel8.number_of_ack_nack = rand_range(1, 4); + + switch(pdus[0].harq_indication_tdd_rel8.mode) + { + case 0: + { + pdus[0].harq_indication_tdd_rel8.harq_data.bundling.value_0 = rand_range(1, 7); + pdus[0].harq_indication_tdd_rel8.harq_data.bundling.value_1 = rand_range(1, 7); + } + break; + case 1: + { + pdus[0].harq_indication_tdd_rel8.harq_data.multiplex.value_0 = rand_range(1, 7); + pdus[0].harq_indication_tdd_rel8.harq_data.multiplex.value_1 = rand_range(1, 7); + pdus[0].harq_indication_tdd_rel8.harq_data.multiplex.value_2 = rand_range(1, 7); + pdus[0].harq_indication_tdd_rel8.harq_data.multiplex.value_3 = rand_range(1, 7); + } + break; + case 2: + { + pdus[0].harq_indication_tdd_rel8.harq_data.special_bundling.value_0 = rand_range(1, 7); + } + break; + }; + + + pdus[0].harq_indication_tdd_rel9.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL9_TAG; + pdus[0].harq_indication_tdd_rel9.mode = rand_range(0, 4); + pdus[0].harq_indication_tdd_rel9.number_of_ack_nack = 1; + + switch(pdus[0].harq_indication_tdd_rel9.mode) + { + case 0: + { + pdus[0].harq_indication_tdd_rel9.harq_data[0].bundling.value_0 = rand_range(1, 7); + } + break; + case 1: + { + pdus[0].harq_indication_tdd_rel9.harq_data[0].multiplex.value_0 = rand_range(1, 7); + } + break; + case 2: + { + pdus[0].harq_indication_tdd_rel9.harq_data[0].special_bundling.value_0 = rand_range(1, 7); + } + break; + case 3: + { + pdus[0].harq_indication_tdd_rel9.harq_data[0].channel_selection.value_0 = rand_range(1, 7); + } + break; + case 4: + { + pdus[0].harq_indication_tdd_rel9.harq_data[0].format_3.value_0 = rand_range(1, 7); + } + break; + }; + + + + pdus[0].harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdus[0].harq_indication_tdd_rel13.mode = rand_range(0, 6); + pdus[0].harq_indication_tdd_rel13.number_of_ack_nack = 1; + + switch(pdus[0].harq_indication_tdd_rel13.mode) + { + case 0: + { + pdus[0].harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = rand_range(1, 7); + } + break; + case 1: + { + pdus[0].harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = rand_range(1, 7); + } + break; + case 2: + { + pdus[0].harq_indication_tdd_rel13.harq_data[0].special_bundling.value_0 = rand_range(1, 7); + } + break; + case 3: + { + pdus[0].harq_indication_tdd_rel13.harq_data[0].channel_selection.value_0 = rand_range(1, 7); + } + break; + case 4: + { + pdus[0].harq_indication_tdd_rel13.harq_data[0].format_3.value_0 = rand_range(1, 7); + } + break; + case 5: + { + pdus[0].harq_indication_tdd_rel13.harq_data[0].format_4.value_0 = rand_range(1, 7); + } + break; + case 6: + { + pdus[0].harq_indication_tdd_rel13.harq_data[0].format_5.value_0 = rand_range(1, 7); + } + break; + }; + + pdus[0].harq_indication_fdd_rel8.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL8_TAG; + pdus[0].harq_indication_fdd_rel8.harq_tb1 = rand_range(1, 7); + pdus[0].harq_indication_fdd_rel8.harq_tb2 = rand_range(1, 7); + + pdus[0].harq_indication_fdd_rel9.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL9_TAG; + pdus[0].harq_indication_fdd_rel9.mode = rand_range(0, 2); + pdus[0].harq_indication_fdd_rel9.number_of_ack_nack = 2; + pdus[0].harq_indication_fdd_rel9.harq_tb_n[0] = rand_range(1, 7); + pdus[0].harq_indication_fdd_rel9.harq_tb_n[1] = rand_range(1, 7); + + pdus[0].harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; + pdus[0].harq_indication_fdd_rel13.mode = rand_range(0, 2); + pdus[0].harq_indication_fdd_rel13.number_of_ack_nack = 2; + pdus[0].harq_indication_fdd_rel13.harq_tb_n[0] = rand_range(1, 7); + pdus[0].harq_indication_fdd_rel13.harq_tb_n[1] = rand_range(1, 7); + + pdus[0].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + pdus[0].ul_cqi_information.ul_cqi = rand_range(0,255); + pdus[0].ul_cqi_information.channel = rand_range(0, 1); + + harq_ind.harq_indication_body.harq_pdu_list = pdus; + + nfapi_pnf_p7_harq_ind(data->p7_config, &harq_ind); + } + else + { + + harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + harq_ind.harq_indication_body.number_of_harqs = 8; + + nfapi_harq_indication_pdu_t pdus[8]; + memset(&pdus, 0, sizeof(pdus)); + + for(int i = 0; i < 8; ++i) + { + pdus[i].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdus[i].rx_ue_information.handle = 0xFF; + pdus[i].rx_ue_information.rnti = i; + + pdus[i].harq_indication_fdd_rel8.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL8_TAG; + pdus[i].harq_indication_fdd_rel8.harq_tb1 = 1; + pdus[i].harq_indication_fdd_rel8.harq_tb2 = 2; + } + + harq_ind.harq_indication_body.harq_pdu_list = pdus; + + nfapi_pnf_p7_harq_ind(data->p7_config, &harq_ind); + } + + return 0; +} + +int fapi_crc_ind(fapi_t* fapi, fapi_crc_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_crc_indication_t crc_ind; + memset(&crc_ind, 0, sizeof(crc_ind)); + crc_ind.header.message_id = NFAPI_CRC_INDICATION; + crc_ind.header.phy_id = data->p7_config->phy_id; + crc_ind.sfn_sf = ind->sfn_sf; + + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG; + crc_ind.crc_indication_body.number_of_crcs = 1; + + nfapi_crc_indication_pdu_t pdus[crc_ind.crc_indication_body.number_of_crcs]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdus[0].rx_ue_information.handle = rand_range(0, 9999); + pdus[0].rx_ue_information.rnti = rand_range(1, 65535); + + pdus[0].crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; + pdus[0].crc_indication_rel8.crc_flag = rand_range(0, 1); + + crc_ind.crc_indication_body.crc_pdu_list = pdus; + nfapi_pnf_p7_crc_ind(data->p7_config, &crc_ind); + } + else + { + crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG; + crc_ind.crc_indication_body.number_of_crcs = ind->body.number_of_crcs; + + crc_ind.crc_indication_body.crc_pdu_list = (nfapi_crc_indication_pdu_t*)malloc(sizeof(nfapi_crc_indication_pdu_t) * ind->body.number_of_crcs); + + for(int i = 0; i < ind->body.number_of_crcs; ++i) + { + crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.handle = ind->body.pdus[i].rx_ue_info.handle; + crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti = ind->body.pdus[i].rx_ue_info.rnti; + crc_ind.crc_indication_body.crc_pdu_list[i].crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; + crc_ind.crc_indication_body.crc_pdu_list[i].crc_indication_rel8.crc_flag = ind->body.pdus[i].rel8_pdu.crc_flag; + } + + nfapi_pnf_p7_crc_ind(data->p7_config, &crc_ind); + + free(crc_ind.crc_indication_body.crc_pdu_list); + } + + return 0; +} +int fapi_rx_ulsch_ind(fapi_t* fapi, fapi_rx_ulsch_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_rx_indication_t rx_ind; + memset(&rx_ind, 0, sizeof(rx_ind)); + rx_ind.header.message_id = NFAPI_RX_ULSCH_INDICATION; + rx_ind.header.phy_id = data->p7_config->phy_id; + rx_ind.sfn_sf = ind->sfn_sf; + + if(1)//((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + rx_ind.rx_indication_body.number_of_pdus = 1; + + uint8_t rx_data[1024]; + + nfapi_rx_indication_pdu_t pdus[rx_ind.rx_indication_body.number_of_pdus]; + memset(&pdus, 0, sizeof(pdus)); + + strcpy((char*)rx_data, (char*)"123456789"); + + for(int i = 0; i < rx_ind.rx_indication_body.number_of_pdus;++i) + { + + pdus[i].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdus[i].rx_ue_information.handle = rand_range(0, 9999); + pdus[i].rx_ue_information.rnti = rand_range(1, 65535); + + pdus[i].rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + pdus[i].rx_indication_rel8.length = 10;//rand_range(0, 1024); + pdus[i].rx_indication_rel8.offset = 0;//djp - 1; + pdus[i].rx_indication_rel8.ul_cqi = rand_range(0, 255); + pdus[i].rx_indication_rel8.timing_advance = rand_range(0, 63); + + //pdus[i].rx_indication_rel9.tl.tag = NFAPI_RX_INDICATION_REL9_TAG; + //pdus[i].rx_indication_rel9.timing_advance_r9 = rand_range(0, 7690); + + pdus[i].data = &rx_data[0]; + } + + rx_ind.rx_indication_body.rx_pdu_list = pdus; + + nfapi_pnf_p7_rx_ind(data->p7_config, &rx_ind); + } + else + { + + rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + rx_ind.rx_indication_body.number_of_pdus = ind->body.number_of_pdus; + + rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t*)malloc(sizeof(nfapi_rx_indication_pdu_t) * ind->body.number_of_pdus); + + for(int i = 0; i < ind->body.number_of_pdus; ++i) + { + rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.handle = ind->body.pdus[i].rx_ue_info.handle; + rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length = ind->body.pdus[i].rel8_pdu.length; + rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.offset = 1; + rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel9.tl.tag = 0; + rx_ind.rx_indication_body.rx_pdu_list[i].data = (uint8_t*)ind->body.data[i]; + + } + + nfapi_pnf_p7_rx_ind(data->p7_config, &rx_ind); + + free(rx_ind.rx_indication_body.rx_pdu_list); + } + + return 0; + +} +int fapi_rx_cqi_ind(fapi_t* fapi, fapi_rx_cqi_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_cqi_indication_t cqi_ind; + memset(&cqi_ind, 0, sizeof(cqi_ind)); + cqi_ind.header.message_id = NFAPI_RX_CQI_INDICATION; + cqi_ind.header.phy_id = data->p7_config->phy_id; + cqi_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + cqi_ind.cqi_indication_body.tl.tag = NFAPI_CQI_INDICATION_BODY_TAG; + cqi_ind.cqi_indication_body.number_of_cqis = 3; + + nfapi_cqi_indication_pdu_t cqi_pdu_list[cqi_ind.cqi_indication_body.number_of_cqis]; + memset(&cqi_pdu_list, 0, sizeof(cqi_pdu_list)); + nfapi_cqi_indication_raw_pdu_t cqi_raw_pdu_list[cqi_ind.cqi_indication_body.number_of_cqis]; + //memset(&cqi_raw_pdu_list, 0, sizeof(cqi_raw_pdu_list)); + + + for(int i = 0; i < cqi_ind.cqi_indication_body.number_of_cqis; ++i) + { + cqi_pdu_list[i].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + cqi_pdu_list[i].rx_ue_information.handle = rand_range(0, 9999); + cqi_pdu_list[i].rx_ue_information.rnti = rand_range(1, 65535); + + uint8_t rel8_or_9 = rand_range(0, 1); + + if(rel8_or_9) + { + cqi_pdu_list[i].cqi_indication_rel8.tl.tag = NFAPI_CQI_INDICATION_REL8_TAG; + cqi_pdu_list[i].cqi_indication_rel8.length = 8; //rand_range(1, 12); + cqi_pdu_list[i].cqi_indication_rel8.data_offset = 1; //rand_range(0, 1); + cqi_pdu_list[i].cqi_indication_rel8.ul_cqi = 0; + cqi_pdu_list[i].cqi_indication_rel8.ri = rand_range(0, 4); + cqi_pdu_list[i].cqi_indication_rel8.timing_advance = rand_range(0, 63); + } + else + { + cqi_pdu_list[i].cqi_indication_rel9.tl.tag = NFAPI_CQI_INDICATION_REL9_TAG; + cqi_pdu_list[i].cqi_indication_rel9.length = 8; //rand_range(1, 12); + cqi_pdu_list[i].cqi_indication_rel9.data_offset = 1; //rand_range(0, 1); + cqi_pdu_list[i].cqi_indication_rel9.ul_cqi = 0; //rand_range(0, 1); + cqi_pdu_list[i].cqi_indication_rel9.number_of_cc_reported = 1; + cqi_pdu_list[i].cqi_indication_rel9.ri[0] = rand_range(0, 8); + cqi_pdu_list[i].cqi_indication_rel9.timing_advance = rand_range(0, 63); + cqi_pdu_list[i].cqi_indication_rel9.timing_advance_r9 = rand_range(0, 7690); + } + + cqi_pdu_list[i].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + cqi_pdu_list[i].ul_cqi_information.ul_cqi = rand_range(0,255); + cqi_pdu_list[i].ul_cqi_information.channel = rand_range(0, 1); + } + + cqi_ind.cqi_indication_body.cqi_pdu_list = cqi_pdu_list; + cqi_ind.cqi_indication_body.cqi_raw_pdu_list = cqi_raw_pdu_list; + + nfapi_pnf_p7_cqi_ind(data->p7_config, &cqi_ind); + } + else + { + nfapi_pnf_p7_cqi_ind(data->p7_config, &cqi_ind); + } + + return 0; +} +int fapi_rx_sr_ind(fapi_t* fapi, fapi_rx_sr_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_sr_indication_t sr_ind; + memset(&sr_ind, 0, sizeof(sr_ind)); + sr_ind.header.message_id = NFAPI_RX_SR_INDICATION; + sr_ind.header.phy_id = data->p7_config->phy_id; + sr_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + sr_ind.sr_indication_body.tl.tag = NFAPI_SR_INDICATION_BODY_TAG; + sr_ind.sr_indication_body.number_of_srs = 1; + + nfapi_sr_indication_pdu_t pdus[sr_ind.sr_indication_body.number_of_srs]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdus[0].rx_ue_information.handle = rand_range(0, 9999); + pdus[0].rx_ue_information.rnti = rand_range(1, 65535); + + pdus[0].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + pdus[0].ul_cqi_information.ul_cqi = rand_range(0,255); + pdus[0].ul_cqi_information.channel = rand_range(0, 1); + + sr_ind.sr_indication_body.sr_pdu_list = pdus; + + nfapi_pnf_p7_sr_ind(data->p7_config, &sr_ind); + } + else + { + nfapi_pnf_p7_sr_ind(data->p7_config, &sr_ind); + } + + return 0; +} + +int fapi_rach_ind(fapi_t* fapi, fapi_rach_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_rach_indication_t rach_ind; + memset(&rach_ind, 0, sizeof(rach_ind)); + rach_ind.header.message_id = NFAPI_RACH_INDICATION; + rach_ind.header.phy_id = data->p7_config->phy_id; + rach_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + rach_ind.rach_indication_body.number_of_preambles = 1; + + nfapi_preamble_pdu_t pdus[rach_ind.rach_indication_body.number_of_preambles]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + pdus[0].preamble_rel8.rnti = rand_range(1, 65535); + pdus[0].preamble_rel8.preamble = rand_range(0, 63); + pdus[0].preamble_rel8.timing_advance = rand_range(0, 1282); + pdus[0].preamble_rel9.tl.tag = NFAPI_PREAMBLE_REL9_TAG; + pdus[0].preamble_rel9.timing_advance_r9 = rand_range(0, 7690); + pdus[0].preamble_rel13.tl.tag = NFAPI_PREAMBLE_REL13_TAG; + pdus[0].preamble_rel13.rach_resource_type = rand_range(0, 4); + + rach_ind.rach_indication_body.preamble_list = pdus; + nfapi_pnf_p7_rach_ind(data->p7_config, &rach_ind); + } + else + { + nfapi_pnf_p7_rach_ind(data->p7_config, &rach_ind); + } + + return 0; +} + +int fapi_srs_ind(fapi_t* fapi, fapi_srs_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_srs_indication_t srs_ind; + memset(&srs_ind, 0, sizeof(srs_ind)); + srs_ind.header.message_id = NFAPI_SRS_INDICATION; + srs_ind.header.phy_id = data->p7_config->phy_id; + srs_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + srs_ind.srs_indication_body.tl.tag = NFAPI_SRS_INDICATION_BODY_TAG; + srs_ind.srs_indication_body.number_of_ues = 1; + + nfapi_srs_indication_pdu_t pdus[srs_ind.srs_indication_body.number_of_ues]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdus[0].rx_ue_information.handle = rand_range(0, 9999); + pdus[0].rx_ue_information.rnti = rand_range(1, 65535); + + pdus[0].srs_indication_fdd_rel8.tl.tag = NFAPI_SRS_INDICATION_FDD_REL8_TAG; + pdus[0].srs_indication_fdd_rel8.doppler_estimation = rand_range(0, 255); + pdus[0].srs_indication_fdd_rel8.timing_advance = rand_range(0, 63); + pdus[0].srs_indication_fdd_rel8.number_of_resource_blocks = 2; //rand_range(0, 255); + pdus[0].srs_indication_fdd_rel8.rb_start = rand_range(0, 245); + pdus[0].srs_indication_fdd_rel8.snr[0] = rand_range(0, 255); + pdus[0].srs_indication_fdd_rel8.snr[1] = rand_range(0, 255); + + pdus[0].srs_indication_fdd_rel9.tl.tag = NFAPI_SRS_INDICATION_FDD_REL9_TAG; + pdus[0].srs_indication_fdd_rel9.timing_advance_r9 = rand_range(0, 7690); + + pdus[0].srs_indication_tdd_rel10.tl.tag = NFAPI_SRS_INDICATION_TDD_REL10_TAG; + pdus[0].srs_indication_tdd_rel10.uppts_symbol = rand_range(0, 1); + + pdus[0].srs_indication_fdd_rel11.tl.tag = NFAPI_SRS_INDICATION_FDD_REL11_TAG; + pdus[0].srs_indication_fdd_rel11.ul_rtoa; + + pdus[0].tdd_channel_measurement.tl.tag = NFAPI_TDD_CHANNEL_MEASUREMENT_TAG; + pdus[0].tdd_channel_measurement.num_prb_per_subband = rand_range(0, 255); + pdus[0].tdd_channel_measurement.number_of_subbands = 1; + pdus[0].tdd_channel_measurement.num_atennas = 2; + pdus[0].tdd_channel_measurement.subands[0].subband_index = rand_range(0, 255); + pdus[0].tdd_channel_measurement.subands[0].channel[0] = rand_range(0, 9999); + pdus[0].tdd_channel_measurement.subands[0].channel[1] = rand_range(0, 9999); + + srs_ind.srs_indication_body.srs_pdu_list = pdus; + nfapi_pnf_p7_srs_ind(data->p7_config, &srs_ind); + } + else + { + nfapi_pnf_p7_srs_ind(data->p7_config, &srs_ind); + } + + return 0; +} + +int fapi_lbt_dl_ind(fapi_t* fapi, fapi_lbt_dl_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_lbt_dl_indication_t lbt_dl_ind; + memset(&lbt_dl_ind, 0, sizeof(lbt_dl_ind)); + lbt_dl_ind.header.message_id = NFAPI_LBT_DL_INDICATION; + lbt_dl_ind.header.phy_id = data->p7_config->phy_id; + lbt_dl_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + lbt_dl_ind.lbt_dl_indication_body.tl.tag = NFAPI_LBT_DL_INDICATION_BODY_TAG; + lbt_dl_ind.lbt_dl_indication_body.number_of_pdus = 2; + + nfapi_lbt_dl_indication_pdu_t pdus[lbt_dl_ind.lbt_dl_indication_body.number_of_pdus]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].pdu_type = 0; // LBT_PDSCH_RSP PDU + pdus[0].pdu_size = 0; + pdus[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.tl.tag = NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG; + pdus[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.handle = 0xABCD; + pdus[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.result = rand_range(0, 1); + pdus[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.lte_txop_symbols = rand_range(0, 0xFFFF); + pdus[0].lbt_pdsch_rsp_pdu.lbt_pdsch_rsp_pdu_rel13.initial_partial_sf = rand_range(0, 1); + + pdus[1].pdu_type = 1; // LBT_DRS_RSP PDU + pdus[1].pdu_size = 0; + pdus[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.tl.tag = NFAPI_LBT_DRS_RSP_PDU_REL13_TAG; + pdus[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.handle = 0xABCD; + pdus[1].lbt_drs_rsp_pdu.lbt_drs_rsp_pdu_rel13.result = rand_range(0, 1); + + lbt_dl_ind.lbt_dl_indication_body.lbt_indication_pdu_list = pdus; + nfapi_pnf_p7_lbt_dl_ind(data->p7_config, &lbt_dl_ind); + } + else + { + nfapi_pnf_p7_lbt_dl_ind(data->p7_config, &lbt_dl_ind); + } + + return 0; +} + +int fapi_nb_harq_ind(fapi_t* fapi, fapi_nb_harq_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_nb_harq_indication_t nb_harq_ind; + memset(&nb_harq_ind, 0, sizeof(nb_harq_ind)); + nb_harq_ind.header.message_id = NFAPI_NB_HARQ_INDICATION; + nb_harq_ind.header.phy_id = data->p7_config->phy_id; + nb_harq_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + + nb_harq_ind.nb_harq_indication_body.tl.tag = NFAPI_NB_HARQ_INDICATION_BODY_TAG; + nb_harq_ind.nb_harq_indication_body.number_of_harqs = 1; + + nfapi_nb_harq_indication_pdu_t pdus[nb_harq_ind.nb_harq_indication_body.number_of_harqs]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdus[0].rx_ue_information.handle = rand_range(0, 0xFFFF); + pdus[0].rx_ue_information.rnti = rand_range(0, 65535); + + pdus[0].nb_harq_indication_fdd_rel13.tl.tag = NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG; + pdus[0].nb_harq_indication_fdd_rel13.harq_tb1 = rand_range(1, 7); + + pdus[0].ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + pdus[0].ul_cqi_information.ul_cqi = rand_range(0, 255); + pdus[0].ul_cqi_information.channel = rand_range(0, 1); + + nb_harq_ind.nb_harq_indication_body.nb_harq_pdu_list = pdus; + nfapi_pnf_p7_nb_harq_ind(data->p7_config, &nb_harq_ind); + } + else + { + nfapi_pnf_p7_nb_harq_ind(data->p7_config, &nb_harq_ind); + } + + return 0; +} + +int fapi_nrach_ind(fapi_t* fapi, fapi_nrach_ind_t* ind) +{ + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)(fapi->user_data); + + nfapi_nrach_indication_t nrach_ind; + memset(&nrach_ind, 0, sizeof(nrach_ind)); + nrach_ind.header.message_id = NFAPI_NRACH_INDICATION; + nrach_ind.header.phy_id = data->p7_config->phy_id; + nrach_ind.sfn_sf = ind->sfn_sf; + + if(((pnf_info*)(data->config->user_data))->wireshark_test_mode) + { + nrach_ind.nrach_indication_body.tl.tag = NFAPI_NRACH_INDICATION_BODY_TAG; + nrach_ind.nrach_indication_body.number_of_initial_scs_detected = 1; + + nfapi_nrach_indication_pdu_t pdus[nrach_ind.nrach_indication_body.number_of_initial_scs_detected]; + memset(&pdus, 0, sizeof(pdus)); + + pdus[0].nrach_indication_rel13.tl.tag = NFAPI_NRACH_INDICATION_REL13_TAG; + pdus[0].nrach_indication_rel13.rnti = rand_range(1, 65535); + pdus[0].nrach_indication_rel13.initial_sc = rand_range(0, 47); + pdus[0].nrach_indication_rel13.timing_advance = rand_range(0, 3840); + pdus[0].nrach_indication_rel13.nrach_ce_level = rand_range(0, 2); + + nrach_ind.nrach_indication_body.nrach_pdu_list = pdus; + + nfapi_pnf_p7_nrach_ind(data->p7_config, &nrach_ind); + } + else + { + nfapi_pnf_p7_nrach_ind(data->p7_config, &nrach_ind); + } + + return 0; +} + +int pnf_start_request(nfapi_pnf_config_t* config, nfapi_pnf_start_request_t* req) +{ + + pnf_info* pnf = (pnf_info*)(config->user_data); + + // start all phys that have been configured + for(phy_info& phy : pnf->phys) + { + if(phy.id != 0) + { + //auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) + // { return item.id == req->header.phy_id; }); +// +// if(found != pnf->phys.end()) +// { +// phy_info& phy = (*found); + + fapi_cb_t cb; + cb.fapi_param_response = &fapi_param_response; + cb.fapi_config_response = &fapi_config_response; + cb.fapi_subframe_ind = &fapi_subframe_ind; + cb.fapi_harq_ind = fapi_harq_ind; + cb.fapi_crc_ind = fapi_crc_ind; + cb.fapi_rx_ulsch_ind = fapi_rx_ulsch_ind; + cb.fapi_rx_cqi_ind = fapi_rx_cqi_ind; + cb.fapi_rx_sr_ind = fapi_rx_sr_ind; + cb.fapi_rach_ind = fapi_rach_ind; + cb.fapi_srs_ind = fapi_srs_ind; + + cb.fapi_lbt_dl_ind = fapi_lbt_dl_ind; + cb.fapi_nb_harq_ind = fapi_nb_harq_ind; + cb.fapi_nrach_ind = fapi_nrach_ind; + + + + fapi_config_t c; + c.duplex_mode = phy.duplex_mode; + c.dl_channel_bw_support = phy.dl_channel_bw_support; + c.ul_channel_bw_support = phy.ul_channel_bw_support; + + phy.fapi = fapi_create(&cb, &c); + printf("[PNF_SIM] staring fapi %p phy_id:%d\n", phy.fapi, phy.id); + + pnf_phy_user_data_t* data = (pnf_phy_user_data_t*)malloc(sizeof(pnf_phy_user_data_t)); + data->phy_id = phy.id; + data->config = config; + data->phy = &phy; + + phy.fapi->user_data = data; + } + + } + + nfapi_pnf_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_START_RESPONSE; + resp.error_code = NFAPI_MSG_OK; + nfapi_pnf_pnf_start_resp(config, &resp); + + return 0; +} + +int pnf_stop_request(nfapi_pnf_config_t* config, nfapi_pnf_stop_request_t* req) +{ + printf("[PNF_SIM] pnf stop request\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); + + return 0; +} + +int param_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_param_request_t* req) +{ + printf("[PNF_SIM] param request phy_id:%d\n", req->header.phy_id); + + pnf_info* pnf = (pnf_info*)(config->user_data); + + auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) + { return item.id == req->header.phy_id; }); + + if(found != pnf->phys.end()) + { + phy_info& phy_info = (*found); + + fapi_param_req_t fapi_req; + fapi_req.header.message_id = req->header.message_id; + fapi_req.header.length = 0; + + // convert nfapi to fapi + + fapi_param_request(phy_info.fapi, &fapi_req); + + } + else + { + // did not find the phy + } + + + printf("[PNF_SIM] 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) +{ + printf("[PNF_SIM] config request phy_id:%d\n", req->header.phy_id); + + pnf_info* pnf = (pnf_info*)(config->user_data); + + auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) + { return item.id == req->header.phy_id; }); + + if(found != pnf->phys.end()) + { + phy_info& phy_info = (*found); + + + if(req->nfapi_config.timing_window.tl.tag == NFAPI_NFAPI_TIMING_WINDOW_TAG) + { + phy_info.timing_window = req->nfapi_config.timing_window.value; + } + + if(req->nfapi_config.timing_info_mode.tl.tag == NFAPI_NFAPI_TIMING_INFO_MODE_TAG) + { + printf("timing info mode provided\n"); + phy_info.timing_info_mode = req->nfapi_config.timing_info_mode.value; + } + else + { + phy_info.timing_info_mode = 0; + printf("NO timing info mode provided\n"); + } + + if(req->nfapi_config.timing_info_period.tl.tag == NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG) + { + printf("timing info period provided\n"); + phy_info.timing_info_period = req->nfapi_config.timing_info_period.value; + } + else + { + phy_info.timing_info_period = 0; + } + + 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_SIM] %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); + + fapi_config_req_t fapi_req; + fapi_config_request(phy_info.fapi, &fapi_req); + } + + return 0; +} + +nfapi_p7_message_header_t* 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 0; +} + +void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header) +{ + free(header); +} + +int phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) +{ + //printf("[PNF_SIM] dl config request\n"); + + if(req->vendor_extension) + free(req->vendor_extension); + + phy_info* phy = (phy_info*)(pnf_p7->user_data); + + fapi_dl_config_req_t fapi_req; + // convert + fapi_dl_config_request(phy->fapi, &fapi_req); + + return 0; +} +int phy_ul_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) +{ + //printf("[PNF_SIM] ul config request\n"); + phy_info* phy = (phy_info*)(pnf_p7->user_data); + + fapi_ul_config_req_t fapi_req; + // convert + fapi_ul_config_request(phy->fapi, &fapi_req); + + return 0; +} +int phy_hi_dci0_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) +{ + //printf("[PNF_SIM] hi dci0 request\n"); + phy_info* phy = (phy_info*)(pnf_p7->user_data); + + fapi_hi_dci0_req_t fapi_req; + // convert + fapi_hi_dci0_request(phy->fapi, &fapi_req); + return 0; +} +int phy_tx_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) +{ + //printf("[PNF_SIM] tx request\n"); + phy_info* phy = (phy_info*)(pnf_p7->user_data); + + fapi_tx_req_t fapi_req; + fapi_req.header.message_id = FAPI_TX_REQUEST; + fapi_req.sfn_sf = req->sfn_sf; + fapi_req.body.number_of_pdus = req->tx_request_body.number_of_pdus; + + fapi_tx_req_pdu_t pdus[8]; + fapi_req.body.pdus = &pdus[0]; + + for(int i = 0; i < fapi_req.body.number_of_pdus; ++i) + { + fapi_req.body.pdus[i].pdu_length = req->tx_request_body.tx_pdu_list[i].pdu_length; + fapi_req.body.pdus[i].pdu_index = req->tx_request_body.tx_pdu_list[i].pdu_index; + fapi_req.body.pdus[i].num_tlv = 1; + fapi_req.body.pdus[i].tlvs[0].value = (uint32_t*)req->tx_request_body.tx_pdu_list[i].segments[0].segment_data; + + //if the pnf wants to retain the pointer then req->tx_request_body.tx_pdu_list[i].segments[0].segment_data should be set to 0 + + + } + + fapi_tx_request(phy->fapi, &fapi_req); +/* + if(fapi_req.body.number_of_pdus > 0) + { + for(int i = 0; i < fapi_req.body.number_of_pdus; ++i) + { + //printf("freeing tx pdu %p\n", fapi_req.body.pdus[i].tlvs[0].value); + if(0) + { + free(fapi_req.body.pdus[i].tlvs[0].value); + } + else + { + pnf_deallocate(fapi_req.body.pdus[i].tlvs[0].value); + } + } + } +*/ + + return 0; +} +int phy_lbt_dl_config_req(nfapi_pnf_p7_config_t*, nfapi_lbt_dl_config_request_t* req) +{ + //printf("[PNF_SIM] lbt dl config request\n"); + return 0; +} + +int 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_SIM] vendor request (1:%d 2:%d)\n", req->dummy1, req->dummy2); + } + else + { + printf("[PNF_SIM] unknown vendor ext\n"); + } + return 0; +} + + + +int 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); + if(!push16(ind->error_code, ppWritePackedMsg, end)) + return 0; + + return 1; + } + return -1; +} + +int 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); + if(!(pull16(ppReadPackedMessage, &req->dummy1, end) && + pull16(ppReadPackedMessage, &req->dummy2, end))) + return 0; + return 1; + } + return -1; +} + +int 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, "phy_unpack_vendor_extension_tlv\n"); + + 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; + + return 1; + break; + } + + return -1; +} + +int 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) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "pnf_sim_unpack_vendor_extension_tlv\n"); + + 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; + + return 1; + break; + } + + return -1; +} + +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; + return -1; +} +int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi_start_request_t* req) +{ + printf("[PNF_SIM] start request phy_id:%d\n", req->header.phy_id); + + pnf_info* pnf = (pnf_info*)(config->user_data); + + auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) + { return item.id == req->header.phy_id; }); + + if(found != pnf->phys.end()) + { + phy_info& phy_info = (*found); + + + 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 = phy_info.local_port; + p7_config->local_p7_addr = (char*)phy_info.local_addr.c_str(); + 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_sim_trace; + + phy->user_data = p7_config; + + p7_config->subframe_buffer_size = 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; + } + + if(phy_info.timing_info_mode & 0x2) + { + p7_config->timing_info_mode_aperiodic = 1; + } + + p7_config->dl_config_req = &phy_dl_config_req; + p7_config->ul_config_req = &phy_ul_config_req; + p7_config->hi_dci0_req = &phy_hi_dci0_req; + p7_config->tx_req = &phy_tx_req; + p7_config->lbt_dl_config_req = &phy_lbt_dl_config_req; + + p7_config->vendor_ext = &phy_vendor_ext; + + p7_config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext; + p7_config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext; + + p7_config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension; + p7_config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension; + p7_config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv; + p7_config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extention_tlv; + + 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; + + fapi_start_req_t fapi_req; + fapi_start_request(phy_info.fapi, &fapi_req); + + } + + return 0; +} + +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; + resp.header.phy_id = req->header.phy_id; + resp.error_code = NFAPI_MSG_OK; + nfapi_pnf_measurement_resp(config, &resp); + return 0; +} +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; + ind.header.phy_id = req->header.phy_id; + ind.error_code = NFAPI_P4_MSG_OK; + ind.rssi_indication_body.tl.tag = NFAPI_RSSI_INDICATION_TAG; + 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) +{ + 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; + 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_cell_search_indication.tl.tag = NFAPI_LTE_CELL_SEARCH_INDICATION_TAG; + ind.lte_cell_search_indication.number_of_lte_cells_found = 1; + ind.lte_cell_search_indication.lte_found_cells[0].pci = 123; + ind.lte_cell_search_indication.lte_found_cells[0].rsrp = 123; + 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; + } + + 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); + return 0; +} +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; + + } + 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); + 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) +{ + 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); + return 0; +} +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... + + } + 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); + + return 0; +} +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; + resp.header.phy_id = req->header.phy_id; + resp.error_code = NFAPI_P4_MSG_OK; + nfapi_pnf_nmm_stop_resp(config, &resp); + return 0; +} + +int vendor_ext(nfapi_pnf_config_t* config, nfapi_p4_p5_message_header_t* msg) +{ + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF_SIM] 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_SIM] 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) +{ + 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 0; +} + +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) +{ + //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); + 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) +{ + //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); + return (!(pull16(ppReadPackedMessage, &req->dummy1, end) && + pull16(ppReadPackedMessage, &req->dummy2, end))); + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s (%d %d)\n", __FUNCTION__, req->dummy1, req->dummy2); + } + return 0; +} +int main(int argc, char *argv[]) +{ + if (argc < 3) + { + printf("Use parameters: <IP Address of VNF P5> <P5 Port> <Config File>\n"); + return 0; + } + + set_thread_priority(50); + + pnf_info pnf; + if(read_pnf_xml(pnf, argv[3]) < 0) + { + printf("Failed to read xml file>\n"); + return 0; + } + + + nfapi_pnf_config_t* config = nfapi_pnf_config_create(); + + config->vnf_ip_addr = argv[1]; + config->vnf_p5_port = atoi(argv[2]); + + config->pnf_param_req = &pnf_param_request; + config->pnf_config_req = &pnf_config_request; + config->pnf_start_req = &pnf_start_request; + config->pnf_stop_req = &pnf_stop_request; + 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; + config->broadcast_detect_req = &broadcast_detect_request; + 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_sim_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; + + return nfapi_pnf_start(config); + +} diff --git a/nfapi/open-nFAPI/sim_common/Makefile.am b/nfapi/open-nFAPI/sim_common/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..771b768a163feeb41bfc54cc8ca07f587fd1d948 --- /dev/null +++ b/nfapi/open-nFAPI/sim_common/Makefile.am @@ -0,0 +1,31 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +AUTOMAKE_OPTIONS=subdir-objects + +AM_CFLAGS = -I$(top_srcdir)/sim_common/public_inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/nfapi/public_inc -g -Wall -Werror + +AM_CXXFLAGS = -I$(top_srcdir)/sim_common/public_inc -I$(top_srcdir)/common/public_inc -std=c++11 -I$(top_srcdir)/nfapi/public_inc $(BOOST_CPPFLAGS) -g -Wall -Werror +noinst_LIBRARIES =libnfapi_sim_common.a +#libnfapi_sim_common_a_SOURCES = src/xml_property_tree.cpp src/pool.cpp +libnfapi_sim_common_a_SOURCES = src/pool.cpp + +libnfapi_sim_common_a_CFLAGS =$(AM_CFLAGS) +libnfapi_sim_common_a_CXXFLAGS =$(AM_CXXFLAGS) + +lib_LTLIBRARIES =libnfapi_sim_common.la +#libnfapi_sim_common_la_SOURCES = src/xml_property_tree.cpp +libnfapi_sim_common_la_SOURCES = src/pool.cpp diff --git a/nfapi/open-nFAPI/sim_common/inc/pool.h b/nfapi/open-nFAPI/sim_common/inc/pool.h new file mode 100644 index 0000000000000000000000000000000000000000..8591d939f969b422cf9c76743f5cb8fe79bc96e1 --- /dev/null +++ b/nfapi/open-nFAPI/sim_common/inc/pool.h @@ -0,0 +1,186 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _POOL_H_ +#define _POOL_H_ + +#include <mutex> +#include <map> +#include <queue> +#include <cassert> + + +class pool_config +{ + public: + + size_t size; + uint16_t initial_count; +}; + +class memory_pool +{ + std::mutex mutex; + std::map<size_t, std::queue<uint8_t*>> free_store; + std::map<size_t, uint16_t> allocated_store; + + void init(std::vector<pool_config> config) + { + printf("memory_pool::init\n"); + + for(pool_config c : config) + { + // todo : use the initial count to allocate initial pool memory + free_store.insert(std::pair<size_t, + std::queue<uint8_t*>> + (c.size, std::queue<uint8_t*>())); + allocated_store.insert(std::pair<size_t, uint16_t>(c.size, 0)); + } + } + + memory_pool() + { + std::vector<pool_config> config + { + {8, 0}, {32, 0}, {64, 0}, {128, 0}, {256, 0}, + {1024, 0}, {4096, 0}, {8912, 0} + + }; + + init(config); + } + + + uint16_t determine_pool_size(size_t size) + { + for(auto pool : free_store) + { + if(pool.first >= size) + return pool.first; + } + + return 0; + } + + uint8_t* alloc(size_t size) + { + if(size == 0) + return 0; + + uint8_t* ptr = 0; + size_t psize = determine_pool_size(size + 4); + + if(psize == 0) + { + ptr = (uint8_t*)malloc(size + 4); + memset(ptr, 0, size + 4); + } + else + { + mutex.lock(); + + auto it = free_store.find(psize); + + if(it == free_store.end()) + { + // Unknown pool size + ptr = (uint8_t*)malloc(psize + 4); + memcpy(ptr, &psize, 4); + } + else + { + if(it->second.size() > 0) + { + // Take from the pool + ptr = (uint8_t*)(it->second.front()); + it->second.pop(); + } + else + { + // No memory left in pool + ptr = (uint8_t*)malloc(psize + 4); + memcpy(ptr, &psize, 4); + } + } + + mutex.unlock(); + } + + return (ptr + 4); + } + + void dealloc(uint8_t* ptr) + { + if(ptr == 0) + return; + + uint8_t* _ptr = (uint8_t*)ptr; + + size_t psize; + memcpy(&psize, _ptr - 4, 4); + + if(psize == 0) + { + free(_ptr - 4); + } + else + { + mutex.lock(); + + auto it = free_store.find(psize); + if(it == free_store.end()) + { + free(_ptr - 4); + } + else + { + assert((_ptr - 4) != 0); + it->second.push(_ptr - 4); + } + + mutex.unlock(); + } + + } + + public: + + memory_pool(memory_pool const&) = delete; + void operator=(memory_pool const&) = delete; + + /*! Get the memory_pool instance */ + static memory_pool& instance() + { + static memory_pool instance; + return instance; + } + + /*! Allocate a buffer from the memory_pool is at least size */ + static uint8_t* allocate(size_t size) + { + return instance().alloc(size); + } + + /*! Return the buffer to the memory_pool */ + static void deallocate(uint8_t* ptr) + { + return instance().dealloc(ptr); + } + + +}; + +#endif // _POOL_H_ diff --git a/nfapi/vendor_ext.h b/nfapi/open-nFAPI/sim_common/inc/vendor_ext.h similarity index 100% rename from nfapi/vendor_ext.h rename to nfapi/open-nFAPI/sim_common/inc/vendor_ext.h diff --git a/nfapi/open-nFAPI/sim_common/src/pool.cpp b/nfapi/open-nFAPI/sim_common/src/pool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..47d9cfa992ebd7fdd05ffa6d9963009226fed354 --- /dev/null +++ b/nfapi/open-nFAPI/sim_common/src/pool.cpp @@ -0,0 +1,15 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/nfapi/open-nFAPI/vnf/Makefile.am b/nfapi/open-nFAPI/vnf/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..ae8d2bb3d67ed480faf29d94762438c250728d9b --- /dev/null +++ b/nfapi/open-nFAPI/vnf/Makefile.am @@ -0,0 +1,43 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +AUTOMAKE_OPTIONS=subdir-objects + +AM_CPPFLAGS = -I$(top_srcdir)/vnf/inc\ + -I$(top_srcdir)/vnf/public_inc\ + -I$(top_srcdir)/nfapi/public_inc\ + -I$(top_srcdir)/common/public_inc\ + -Wall -Werror -g + + +noinst_LIBRARIES = libnfapi_vnf.a + +libnfapi_vnf_a_SOURCES = src/vnf.c\ + src/vnf_p7.c\ + src/vnf_interface.c\ + src/vnf_p7_interface.c + +LDADD = -lsctp ../common/bin/libnfapi_common.a + +libnfapi_vnf_a_CFLAGS =$(AM_CFLAGS) + +lib_LTLIBRARIES = libnfapi_vnf.la + +libnfapi_vnf_la_SOURCES = src/vnf.c\ + src/vnf_p7.c\ + src/vnf_interface.c\ + src/vnf_p7_interface.c diff --git a/nfapi/open-nFAPI/vnf/inc/vnf.h b/nfapi/open-nFAPI/vnf/inc/vnf.h new file mode 100644 index 0000000000000000000000000000000000000000..4fd8d2b91d6e1ec63b08e8ffb3a4ba0786c30b53 --- /dev/null +++ b/nfapi/open-nFAPI/vnf/inc/vnf.h @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _VNF_H_ +#define _VNF_H_ + +#include "nfapi_vnf_interface.h" + +typedef struct +{ + + nfapi_vnf_config_t _public; + + uint8_t terminate; + uint8_t sctp; + + uint8_t tx_message_buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + uint16_t next_phy_id; + +} vnf_t; + + +int vnf_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len); +int vnf_pack_and_send_p4_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len); + +int vnf_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf); + +void nfapi_vnf_phy_info_list_add(nfapi_vnf_config_t* config, nfapi_vnf_phy_info_t* info); +nfapi_vnf_phy_info_t* nfapi_vnf_phy_info_list_find(nfapi_vnf_config_t* config, uint16_t phy_id); +void nfapi_vnf_pnf_list_add(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* node); +nfapi_vnf_pnf_info_t* nfapi_vnf_pnf_list_find(nfapi_vnf_config_t* config, int p5_idx); +#endif // _VNF_H_ diff --git a/nfapi/open-nFAPI/vnf/inc/vnf_p7.h b/nfapi/open-nFAPI/vnf/inc/vnf_p7.h new file mode 100644 index 0000000000000000000000000000000000000000..fc2ab4e6b5382bd282d08d1a20290b98b0e65f88 --- /dev/null +++ b/nfapi/open-nFAPI/vnf/inc/vnf_p7.h @@ -0,0 +1,136 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _VNF_P7_H_ +#define _VNF_P7_H_ + +#include "nfapi_vnf_interface.h" + +#define TIMEHR_SEC(_time_hr) ((uint32_t)(_time_hr) >> 20) +#define TIMEHR_USEC(_time_hr) ((uint32_t)(_time_hr) & 0xFFFFF) +#define TIME2TIMEHR(_time) (((uint32_t)(_time.tv_sec) & 0xFFF) << 20 | ((uint32_t)(_time.tv_usec) & 0xFFFFF)) + + + +typedef struct { + uint8_t* buffer; + uint16_t length; +} vnf_p7_rx_message_segment_t; + +typedef struct vnf_p7_rx_message vnf_p7_rx_message_t; + +typedef struct vnf_p7_rx_message { + uint8_t sequence_number; + uint8_t num_segments_received; + uint8_t num_segments_expected; + + // the spec allows of upto 128 segments, this does seem excessive + vnf_p7_rx_message_segment_t segments[128]; + + uint32_t rx_hr_time; + + vnf_p7_rx_message_t* next; +} vnf_p7_rx_message_t; + +typedef struct { + + vnf_p7_rx_message_t* msg_queue; + +} vnf_p7_rx_reassembly_queue_t; + +typedef struct nfapi_vnf_p7_connection_info { + + /*! The PHY id */ + int phy_id; + + + // this does not belong here... + uint8_t stream_id; + + /*! Flag indicating the sync state of the P7 conenction */ + uint8_t in_sync; + + int dl_out_sync_offset; + int dl_out_sync_period; // ms (as a pow2) + + int dl_in_sync_offset; + int dl_in_sync_period; // ms (as a pow2) + + uint8_t filtered_adjust; + uint16_t min_sync_cycle_count; + uint32_t latency[8]; + uint32_t average_latency; + int32_t sf_offset_filtered; + int32_t sf_offset_trend; + int32_t sf_offset; + uint16_t zero_count; + int32_t adjustment; + int32_t insync_minor_adjustment; + int32_t insync_minor_adjustment_duration; + + uint32_t previous_t1; + uint32_t previous_t2; + int32_t previous_sf_offset_filtered; + + int sfn_sf; + + int socket; + struct sockaddr_in local_addr; + struct sockaddr_in remote_addr; + + vnf_p7_rx_reassembly_queue_t reassembly_queue; + uint8_t* reassembly_buffer; + uint32_t reassembly_buffer_size; + + uint32_t sequence_number; + + struct nfapi_vnf_p7_connection_info* next; + +} nfapi_vnf_p7_connection_info_t; + +typedef struct { + + nfapi_vnf_p7_config_t _public; + + // private data + uint8_t terminate; + nfapi_vnf_p7_connection_info_t* p7_connections; + int socket; + uint32_t sf_start_time_hr; + uint8_t* rx_message_buffer; // would this be better put in the p7 conenction info? + uint16_t rx_message_buffer_size; + +} vnf_p7_t; + +uint32_t vnf_get_current_time_hr(void); + +uint16_t increment_sfn_sf(uint16_t sfn_sf); +int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info); +int send_mac_subframe_indications(vnf_p7_t* config); +int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7 ); + +void vnf_p7_connection_info_list_add(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* node); +nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_find(vnf_p7_t* vnf_p7, uint16_t phy_id); +nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_delete(vnf_p7_t* vnf_p7, uint16_t phy_id); + +int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header); + +void vnf_p7_release_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header); +void vnf_p7_release_pdu(vnf_p7_t* vnf_p7, void* pdu); + + +#endif // _VNF_P7_H_ diff --git a/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h b/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..462901391a8cd63bfc9b25a239f8600870fdad52 --- /dev/null +++ b/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h @@ -0,0 +1,995 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _NFAPI_VNF_INTERFACE_H_ +#define _NFAPI_VNF_INTERFACE_H_ + +#include "nfapi_interface.h" +#include "debug.h" + +#include "netinet/in.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#define NFAPI_MAX_PACKED_MESSAGE_SIZE 8192 + +/*! The nfapi VNF phy configuration information + */ +typedef struct nfapi_vnf_phy_info +{ + /*! The P5 Index */ + int p5_idx; //which p5 connection + /*! The PHY ID */ + int phy_id; //phy_id + + /*! Timing window */ + uint8_t timing_window; + /*! Timing info mode */ + uint8_t timing_info_mode; + /*! Timing info period */ + uint8_t timing_info_period; + + /*! P7 UDP socket information for the pnf */ + struct sockaddr_in p7_pnf_address; + /*! P7 UDP socket information for the vnf */ + struct sockaddr_in p7_vnf_address; + + struct nfapi_vnf_phy_info* next; +} nfapi_vnf_phy_info_t; + +/*! The nfapi VNF pnf configuration information + */ +typedef struct nfapi_vnf_pnf_info +{ + /*! The P5 Index */ + int p5_idx; + /*! The P5 socket */ + int p5_sock; + /*! Flag indicating if the pnf is connected */ + uint8_t connected; + + /*! P5 SCTP socket information for the pnf */ + struct sockaddr_in p5_pnf_sockaddr; + + /*! Flag indicating if this pnf should be deleted */ + uint8_t to_delete; + + struct nfapi_vnf_pnf_info* next; + +} nfapi_vnf_pnf_info_t; + +typedef struct nfapi_vnf_config nfapi_vnf_config_t; + +/*! The nfapi VNF configuration information + */ +typedef struct nfapi_vnf_config +{ + /*! A user define callback to override the default memory allocation */ + void* (*malloc)(size_t size); + /*! A user define callback to override the default memory deallocation */ + void (*free)(void*); + /*! A user define callback to handle trace from the pnf */ + void (*trace)(nfapi_trace_level_t level, const char* message, ...); + + /*! The port the VNF P5 SCTP connection listens on + * + * By default this will be set to 7701. However this can be changed if + * required. + */ + int vnf_p5_port; + + // todo : for enabling ipv4/ipv6 + int vnf_ipv4; + int vnf_ipv6; + + /*! List of connected pnfs */ + nfapi_vnf_pnf_info_t* pnf_list; + + /*! List of configured phys */ + nfapi_vnf_phy_info_t* phy_list; + + /*! Configuration options for the p4 p5 pack unpack functions */ + nfapi_p4_p5_codec_config_t codec_config; + + /*! Optional user defined data that will be avaliable in the callbacks*/ + void* user_data; + + /*! \brief Callback indicating that a pnf has established connection + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 used to indicate this pnf p5 connection + * + * The client is expected to send the PNF_PARAM.request in response to + * the connection indication + * + * \todo Do we need to send the address information of the PNF? + */ + int (*pnf_connection_indication)(nfapi_vnf_config_t* config, int p5_idx); + + /*! \brief Callback indicating that a pnf has lost connection + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 used to indicate this pnf p5 connection + * + * The p5_idx may be used for future new p5 connections + * + * The client is responsiable for communicating to the p7 instance(s) that + * may be associated with this p5 that they should be deleted using the + * nfapi_vnf_p7_del_pnf functon + * + */ + int (*pnf_disconnect_indication)(nfapi_vnf_config_t* config, int p5_idx); + + // p5 interface functions + + /*! \brief A callback to handle the PNF_PARAM.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded PNF_PARAM.response. This will + * have been allocated on the stack. + * \return not currently used. + * + * The PNF_PARAM.resp contains the capability of the PNF identified by the + * p5_idx. + * + * The client is expected to send the PNF_CONFIG.request after receiving the + * PNF_PARAM.resp. This can be done in the call back. + * + * It is expected that the client when building the PNF_CONFIG.request will + * used the nfapi_vnf_allocate_phy() to allocate unique phy id for each FAPI + * instance the client wishes to create. + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*pnf_param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp); + + /*! A callback for the PNF_CONFIG.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded PNF_CONFIG.response. This will + * have been allocated on the stack. + * \return not currently used. + * + * The PNF_CONFIG.resp contains the result of the PNF_CONFIG.request for the + * PNF identified by the p5_idx. + * + * The client is expected to send the PNF_START.request after receiving the + * PNF_PARAM.resp. This can be done in the call back. + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*pnf_config_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp); + + /*! A callback for the PNF_START.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded PNF_START.response. This will + * have been allocated on the stack. + * \return not currently used. + * + * The PNF_START.resp contains the result of the PNF_START.request for the + * PNF identified by the p5_idx. + * + * The client is expected to send the PARAM.request for each FAPI instance + * that has been created in the PNF. + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*pnf_start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp); + + /*! A callback for the PNF_STOP.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded PNF_STOP.response. This will + * have been allocated on the stack. + * \return not currently used. + * + * The PNF_STOP.response contains the result of the PNF_STOP.request for the + * PNF identified by the p5_idx. + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*pnf_stop_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_stop_response_t* resp); + + /*! A callback for the PARAM.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded PARAM.resposne. This will + * have been allocated on the stack. + * \return not currently used. + * + * The PARAM.request contains the capabilities of the FAPI instance identified + * by the phy_id + * + * The client is expected to send the CONFIG.request after receiving the + * PARAM.response. This can be done in the call back. The PARAM.response + * contains the PNF P7 address (ipv4 or ipv6) and port. This information + * is used when calling the nfapi_vnf_p7_add_pnf() + * + * The client is responsible for identifing the VNF P7 ip address + * (ipv4 or ipv6) and port for the VNF P7 entity which will be sent to the + * PNF P7 entity. That endpoint should be valid before send the + * CONFIG.request. + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*param_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* resp); + + /*! A callback for the CONFIG.response + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded CONFIG.response This will + * have been allocated on the stack. + * \return not currently used. + * + * The CONFIG.response contains the result of the CONFIG.request + * + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*config_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp); + + /*! A callback for the START.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded START.response This will + * have been allocated on the stack. + * \return not currently used. + * + * The START.response contains the result of the START.request + * + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp); + + /*! A callback for the STOP.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded STOP.response This will + * have been allocated on the stack. + * \return not currently used. + * + * The STOP.response contains the result of the STOP.request + * + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*stop_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_stop_response_t* resp); + + /*! A callback for the MEASUREMENT.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded MEASUREMENT.response This will + * have been allocated on the stack. + * \return not currently used. + * + * The MEASUREMENT.response contains the result of the MEASUREMENT.request + * + * The resp may contain pointers to dyanmically allocated sub structures + * such as the vendor_extention. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*measurement_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_measurement_response_t* resp); + + // p4 interface functions + /*! A callback for the RSSI.resp + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded RSSI.response This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*rssi_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_rssi_response_t* resp); + + /*! A callback for the RSSI.indication + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded RSSI.indication This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*rssi_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_rssi_indication_t* ind); + + /*! A callback for the CELL_SEARCH.response + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded CELL_SEARCH.response This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*cell_search_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_cell_search_response_t* resp); + + /*! A callback for the CELL_SEARCH.indication + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded CELL_SEARCH.indication This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*cell_search_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_cell_search_indication_t* ind); + + /*! A callback for the BROADCAST_DETECT.response + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded BROADCAST_DETECT.response This will + * have been allocated on the stack. + * \return not currently used. */ + int (*broadcast_detect_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_broadcast_detect_response_t* resp); + + /*! A callback for the BROADCAST_DETECT.indication + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded BROADCAST_DETECT.indication This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*broadcast_detect_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_broadcast_detect_indication_t* ind); + + /*! A callback for the SYSTEM_INFORMATION_SCHEUDLE.response + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded SYSTEM_INFORMATION_SCHEUDLE.response This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*system_information_schedule_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_schedule_response_t* resp); + + /*! A callback for the SYSTEM_INFORMATION_SCHEUDLE.indication + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded SYSTEM_INFORMATION_SCHEUDLE.indication This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*system_information_schedule_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_schedule_indication_t* ind); + + /*! A callback for the SYSTEM_INFORMATION.response + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded SYSTEM_INFORMATION.response This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*system_information_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_response_t* resp); + + /*! A callback for the SYSTEM_INFORMATION.indication + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded SYSTEM_INFORMATION.indication This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*system_information_ind)(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_indication_t* ind); + + /*! A callback for the NMM_STOP.response + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded NMM_STOP.response This will + * have been allocated on the stack. + * \return not currently used. + */ + int (*nmm_stop_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nmm_stop_response_t* resp); + + + /*! A callback for any vendor extension message received + * \param config A pointer to the vnf configuration + * \param p5_idx The p5 index used to indicate a particular pnf p5 connection + * \param resp A data structure for the decoded vendor extention message + * \return not currently used. + */ + int (*vendor_ext)(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg); + + /*! A callback to allocate vendor extension messages + * \param message_id The message is taken from the message header + * \param msg_size The is the vendor extention message that has been allocated. + * The callee must set this value + * \return A pointer to an allocated vendor extention message + */ + nfapi_p4_p5_message_header_t* (*allocate_p4_p5_vendor_ext)(uint16_t message_id, uint16_t* msg_size); + + /*! A callback to deallocate vendor extension messages + * \param header A pointer to an allocated vendor extention message + */ + void (*deallocate_p4_p5_vendor_ext)(nfapi_p4_p5_message_header_t* header); + + + + + + +} nfapi_vnf_config_t; + +/*! Creates and initialise the vnf config structure before use + * \return A pointer to a vnf config structure + */ +nfapi_vnf_config_t* nfapi_vnf_config_create(void); + +/*! Delete an vnf config + */ +void nfapi_vnf_config_destory(nfapi_vnf_config_t* config); + + +/*! Start the VNF library. + * \param config A pointer to a vnf config + * \return 0 means success, -1 failure + * + * The config should be initailize with port the vnf should listen on and + * the callback set to functions that will be called when a nFAPI message is + * recevied before calling nfapi_vnf_start. + * + * This function will not return untill nfapi_vnf_stop is called + */ +int nfapi_vnf_start(nfapi_vnf_config_t* config); + +/*! Stop the VNF library. + * \param config A pointer to a vnf config + * \return 0 means success, -1 failure + * + * This function will cause the nfapi_vnf_start function to return + */ +int nfapi_vnf_stop(nfapi_vnf_config_t* config); + +/*! Allocates a PHY ID for the PNF PHY instance managed by this VNF + * \param config A pointer to a vnf config + * \param p5_idx The P5 index return by the callbacks + * \param phy_id A pointer to a phy_id that will be set by this function + * \return 0 means success, -1 failure + * + * Called before nfapi_vnf_config_req to allocate a vnf phy instance. This + * function will return unqiue phy_id to be used for this identify the phy + * + */ +int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy_id); + +// P5 Request functions +// +/*! Send the PNF_PARAM.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a PNF_PARAM.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_request_t* req); + +/*! Send the PNF_CONFIG.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a PNF_CONFIG.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_pnf_config_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_pnf_config_request_t* req); + +/*! Send the PNF_START.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a PNF_START.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_pnf_start_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_pnf_start_request_t* req); + +/*! Send the PNF_STOP.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a PNF_STOP.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_pnf_stop_req(nfapi_vnf_config_t* config,int p5_idx, nfapi_pnf_stop_request_t* req); + +/*! Send the PARAM.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a PARAM.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_request_t* req); + +/*! Send the CONFIG.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a CONFIG.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_request_t* req); + +/*! Send the START.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a START.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_request_t* req); + +/*! Send the STOP.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a STOP.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_stop_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_stop_request_t* req); + +/*! Send the MEASUREMENT.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a MEASUREMENT.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_measurement_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_measurement_request_t* req); + +// P4 Request functions +/*! Send the RSSI.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a RSSI.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_rssi_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_rssi_request_t* req); + +/*! Send the CELL_SEARCH.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a CELL_SEARCH.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_cell_search_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_cell_search_request_t* req); + +/*! Send the BROADCAST_DETECT.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a BROADCAST_DETECT.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_broadcast_detect_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_broadcast_detect_request_t* req); + +/*! Send the SYSTEM_INFORMATION_SCHEDULE.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a SYSTEM_INFORMATION_SCHEDULE.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_system_information_schedule_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_schedule_request_t* req); + +/*! Send the SYSTEM_INFORMATION.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a SYSTEM_INFORMATION.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_system_information_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_request_t* req); + +/*! Send the NMM_STOP.request + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param req A pointer to a NMM_STOP.request message structure + * \return 0 means success, -1 failure + */ +int nfapi_vnf_nmm_stop_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_nmm_stop_request_t* req); + +/*! Send a vendor extension message + * \param config A pointer to a vnf config + * \param p5_idx The P5 index + * \param msg A poiner to a vendor extention message + * \return 0 means success, -1 failure + */ +int nfapi_vnf_vendor_extension(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg); + +//----------------------------------------------------------------------------- + +/*! The nfapi VNF P7 connection information + */ +typedef struct nfapi_vnf_p7_config nfapi_vnf_p7_config_t; + +/*! The nfapi VNF P7 configuration information + */ +typedef struct nfapi_vnf_p7_config +{ + /*! A user define callback to override the default memory allocation + * \param size Size of the memory block to allocate + * \return a pointer to a memory block + * + * If not set the vnf p7 library will use malloc + */ + void* (*malloc)(size_t size); + + /*! A user define callback to override the default memory deallocation + * \param ptr Pointer to a memory block to deallocate + * + * If not set the vnf p7 library will use free + */ + void (*free)(void*); + + /*! A user define callback to handle trace from the pnf + * \param level The trace level + * \param message The trace string + */ + void (*trace)(nfapi_trace_level_t level, const char* message, ...); + + /*! The port the vnf p7 will receive on */ + int port; + + /*! Flag to indicate of the pnf should use the P7 checksum */ + uint8_t checksum_enabled; + + /*! The maxium size of a P7 segement. If a message is large that this it + * will be segemented */ + uint16_t segment_size; + uint16_t max_num_segments; + + /*! Configuration option for the p7 pack unpack functions*/ + nfapi_p7_codec_config_t codec_config; + + /* ! Call back to indicate the sync state with the PNF PHY + * \param config A pointer to the vnf p7 configuration + * \param sync Indicating if the pnf is in sync or not + * \return not currently used + * + * sync = 0 : in sync + * sync != 0 : out of sync + */ + int (*sync_indication)(struct nfapi_vnf_p7_config* config, uint8_t sync); + + /*! A callback for the subframe indication + * \param config A pointer to the vnf p7 configuration + * \param phy_id The ID for the PNF PHY instance + * \param sfn_sf The SFN SF number formated as per the FAPI specification + * \return not currently used + * + * This callback is an indication for the VNF to generate the downlink subframe messages + * for sfn/sf. This indicatoin is called every millisecond + * + * The VNF P7 Lib will adjust the subframe timing to 'catch-up' or 'slow-down' with the PNF PHY's + * + * \todo Need some way the tell the VNF how long it has + */ + + int (*subframe_indication)(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf); + + /*! A callback for the HARQ.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded HARQ.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*harq_indication)(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind); + + /*! A callback for the CRC.ind + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded CRC.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*crc_indication)(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind); + + /*! A callback for the RX_ULSCH.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded RX_ULSCH.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + * + * Note that the rx_indication may hold one or many uplink pdus in the + * ind.rx_indication_body.rx_pdu_list + */ + int (*rx_indication)(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind); + + /*! A callback for the RACH.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded RACH.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*rach_indication)(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind); + + /*! A callback for the SRS.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded SRS.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*srs_indication)(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind); + + /*! A callback for the RX_SR.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded RX_SR.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*sr_indication)(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind); + + /*! A callback for the RX_CQI.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded RX_CQI.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*cqi_indication)(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind); + + /*! A callback for the LBT_DL.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded LBT_DL.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*lbt_dl_indication)(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind); + + /*! A callback for the NB_HARQ.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded LBT_DL.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*nb_harq_indication)(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind); + + /*! A callback for the NRACH.indication + * \param config A pointer to the vnf p7 configuration + * \param ind A data structure for the decoded LBT_DL.indication This will + * have been allocated on the stack. + * \return not currently used. + * + * The ind may contain pointers to dyanmically allocated sub structures + * such as the pdu. The dyanmically allocated structure will + * be deallocated on return. If the client wishes to 'keep' the structures + * then the substructure pointers should be set to 0 and then the client should + * use the codec_config.deallocate function to release it at a future point + */ + int (*nrach_indication)(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind); + + /*! A callback for any vendor extension messages + * \param config A pointer to the vnf p7 configuration + * \param msg A data structure for the decoded vendor extention message allocated + * using the allocate_p7_vendor_ext callback + * \return not currently used. + */ + int (*vendor_ext)(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg); + + /*! Optional userdata that will be passed back in the callbacks*/ + void* user_data; + + /*! A callback to allocate a memory for a vendor extension message + * \param message_id The message is taken from the p7 message header + * \param msg_size The is the vendor extention message that has been allocated. + * The callee must set this value + * \return A pointer to an allocated vendor extention message + */ + nfapi_p7_message_header_t* (*allocate_p7_vendor_ext)(uint16_t message_id, uint16_t* msg_size); + + /*! A callback to deallocate a vendor extension message + * \param header A pointer to an allocated vendor extention message + */ + void (*deallocate_p7_vendor_ext)(nfapi_p7_message_header_t* header); + + +} nfapi_vnf_p7_config_t; + +/*! Creates and initializes the nfapi_vnf_p7_config structure before use + * \return A pointer to an allocated vnf p7 configuration + */ +nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create(void); + +/*! Cleanup and delete nfapi_vnf_p7_config structure + * \param config A pointer to an vnf p7 configuration structure + * + * The pointer to the config will not long be valid after this call + */ + +void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config); + +/*! Start the VNF P7 library. + * \param config A pointer to an vnf p7 configuration structure + * \return A status value. 0 equal success, -1 indicates failure + * + * This function is blocking and will not return until the nfapi_vnf_p7_stop + * function is called. + */ + +int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config); + +/*! Stop the VNF P7 library. + * \param config A pointer to an vnf p7 configuration structure + * \return A status value. 0 equal success, -1 indicates failure + * + * This function will cause the nfapi_vnf_p7_start function to return + */ +int nfapi_vnf_p7_stop(nfapi_vnf_p7_config_t* config); + +/*! Release a P7 message back to the vnf_p7 library. This should be used if the + * callback return 0 in the case where MAC wants to keep the message for + * futher processing. + * This function will release any pdu's is they are non-null. If the uplink + * PDU need to be kept then they pdu pointer should be set to 0 in the message + * and then the nfapi_vnf_p7_release_pdu message can be used to release the + * pdu later. + */ +int nfapi_vnf_p7_release_msg(nfapi_vnf_p7_config_t* config, nfapi_p7_message_header_t*); + +/*! Release a P7 pdu's back to the vnf_p7 library. + */ +int nfapi_vnf_p7_release_pdu(nfapi_vnf_p7_config_t* config, void*); + +/*! Add a vnf p7 instance to the vnf p7 module + * \param config A pointer to the vnf p7 configuration + * \param pnf_p7_addr The udp address the pnf p7 entity has chosen + * \param pnf_p7_port The udp port the pnf p7 entity has chosen + * \param phy_id The unique phy id for the pnf p7 entity + * \return A status value. 0 equal success, -1 indicates failure + * + * This function should be used to each pnf p7 entity that is to be added to this + * vnf p7 entity. Once added the vnf p7 entity will start establish sync with the + * pnf p7 entity and that has been sucessfull will generate subframe indications for it + */ +int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, int pnf_p7_port, int phy_id); + +/*! Delete a vnf p7 instance to the vnf p7 module + * \param config A pointer to the vnf p7 configuration + * \param phy_id The unique phy id for the pnf p7 entity + * \return A status value. 0 equal success, -1 indicates failure + * + * This function should be used to remove a pnf p7 entity from the vnf p7 entity + */ +int nfapi_vnf_p7_del_pnf(nfapi_vnf_p7_config_t* config, int phy_id); + +/*! Send the DL_CONFIG.request + * \param config A pointer to the vnf p7 configuration + * \param req A data structure for the decoded DL_CONFIG.request. + * \return A status value. 0 equal success, -1 indicates failure + * + * The caller is responsiable for memory management of any pointers set in the req, which + * may be released after this function call has returned or at a later pointer + */ +int nfapi_vnf_p7_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_dl_config_request_t* req); + +/*! Send the UL_CONFIG.request + * \param config A pointer to the vnf p7 configuration + * \param req A data structure for the decoded UL_CONFIG.request. + * \return A status value. 0 equal success, -1 indicates failure + * + * The caller is responsiable for memory management of any pointers set in the req, which + * may be released after this function call has returned or at a later pointer + */ +int nfapi_vnf_p7_ul_config_req(nfapi_vnf_p7_config_t* config, nfapi_ul_config_request_t* req); + +/*! Send the HI_DCI0.request + * \param config A pointer to the vnf p7 configuration + * \param req A data structure for the decoded HI_DCI0.request. + * \return A status value. 0 equal success, -1 indicates failure + * + * The caller is responsiable for memory management of any pointers set in the req, which + * may be released after this function call has returned or at a later pointer + */ +int nfapi_vnf_p7_hi_dci0_req(nfapi_vnf_p7_config_t* config, nfapi_hi_dci0_request_t* req); + +/*! Send the TX.req + * \param config A pointer to the vnf p7 configuration + * \param req A data structure for the decoded HI_DCI0.request. + * \return A status value. 0 equal success, -1 indicates failure + * + * The caller is responsiable for memory management of any pointers set in the req, which + * may be released after this function call has returned or at a later pointer + */ +int nfapi_vnf_p7_tx_req(nfapi_vnf_p7_config_t* config, nfapi_tx_request_t* req); + +/*! Send the LBT_DL_CONFIG.requst + * \param config A pointer to the vnf p7 configuration + * \param req A data structure for the decoded LBT_DL_CONFIG.request. + * \return A status value. 0 equal success, -1 indicates failure + * + * The caller is responsiable for memory management of any pointers set in the req, which + * may be released after this function call has returned or at a later pointer + */ +int nfapi_vnf_p7_lbt_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_lbt_dl_config_request_t* req); + +/*! Send a vendor extension message + * \param config A pointer to the vnf p7 configuration + * \param msg A data structure for the decoded vendor extention message + * \return A status value. 0 equal success, -1 indicates failure + * + * The caller is responsiable for memory management of any pointers set in the req, which + * may be released after this function call has returned or at a later pointer + */ +int nfapi_vnf_p7_vendor_extension(nfapi_vnf_p7_config_t* config, nfapi_p7_message_header_t* msg); + +#if defined(__cplusplus) +} +#endif + +#endif // _NFAPI_PNF_INTERFACE_H_ diff --git a/nfapi/open-nFAPI/vnf/src/vnf.c b/nfapi/open-nFAPI/vnf/src/vnf.c new file mode 100644 index 0000000000000000000000000000000000000000..6800ee21d202cbae1c69ae5335ab7fbae3efd7a0 --- /dev/null +++ b/nfapi/open-nFAPI/vnf/src/vnf.c @@ -0,0 +1,1123 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/sctp.h> +#include <arpa/inet.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#include "vnf.h" + + +void* vnf_malloc(nfapi_vnf_config_t* config, size_t size) +{ + if(config->malloc) + { + return (config->malloc)(size); + } + else + { + return calloc(1, size); + } +} +void vnf_free(nfapi_vnf_config_t* config, void* ptr) +{ + if(config->free) + { + return (config->free)(ptr); + } + else + { + return free(ptr); + } +} + +void nfapi_vnf_phy_info_list_add(nfapi_vnf_config_t* config, nfapi_vnf_phy_info_t* info) +{ + NFAPI_TRACE(NFAPI_TRACE_INFO, "Adding phy p5_idx:%d phy_id:%d\n", info->p5_idx, info->phy_id); + info->next = config->phy_list; + config->phy_list = info; +} + +nfapi_vnf_phy_info_t* nfapi_vnf_phy_info_list_find(nfapi_vnf_config_t* config, uint16_t phy_id) +{ + nfapi_vnf_phy_info_t* curr = config->phy_list; + while(curr != 0) + { + if(curr->phy_id == phy_id) + return curr; + + curr = curr->next; + } + + return 0; +} + + + + +void nfapi_vnf_pnf_list_add(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* node) +{ + node->next = config->pnf_list; + config->pnf_list = node; +} + + +nfapi_vnf_pnf_info_t* nfapi_vnf_pnf_list_find(nfapi_vnf_config_t* config, int p5_idx) +{ + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s : config->pnf_list:%p\n", __FUNCTION__, config->pnf_list); + + nfapi_vnf_pnf_info_t* curr = config->pnf_list; + while(curr != 0) + { + if(curr->p5_idx == p5_idx) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s : curr->p5_idx:%d p5_idx:%d\n", __FUNCTION__, curr->p5_idx, p5_idx); + return curr; + } + + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s : curr->next:%p\n", __FUNCTION__, curr->next); + + curr = curr->next; + } + + return 0; +} + +void vnf_handle_pnf_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s : NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PNF_PARAM.reponse\n"); + + nfapi_pnf_param_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + // Invoke the call back + if(config->pnf_param_resp) + { + (config->pnf_param_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_pnf_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PNF_CONFIG_RESPONSE\n"); + + nfapi_pnf_config_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + // Invoke the call back + if(config->pnf_config_resp) + { + (config->pnf_config_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_pnf_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PNF_START_RESPONSE\n"); + + nfapi_pnf_start_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->pnf_start_resp) + { + (config->pnf_start_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_pnf_stop_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PNF_STOP_RESPONSE\n"); + + nfapi_pnf_stop_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->pnf_stop_resp) + { + (config->pnf_stop_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + + } +} + +void vnf_handle_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received PARAM_RESPONSE\n"); + + nfapi_param_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + + if (msg.error_code == NFAPI_MSG_OK) + { + nfapi_vnf_phy_info_t* phy_info = nfapi_vnf_phy_info_list_find(config, msg.header.phy_id); + + if(msg.nfapi_config.p7_pnf_address_ipv4.tl.tag) + { + struct sockaddr_in sockAddr; + + (void)memcpy(&sockAddr.sin_addr.s_addr, msg.nfapi_config.p7_pnf_address_ipv4.address, NFAPI_IPV4_ADDRESS_LENGTH); + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 IPv4 address: %s\n", inet_ntoa(sockAddr.sin_addr)); + + // store address + phy_info->p7_pnf_address.sin_addr = sockAddr.sin_addr; + } + + if(msg.nfapi_config.p7_pnf_address_ipv6.tl.tag) + { + struct sockaddr_in6 sockAddr6; + char addr6[64]; + (void)memcpy(&sockAddr6.sin6_addr, msg.nfapi_config.p7_pnf_address_ipv6.address, NFAPI_IPV6_ADDRESS_LENGTH); + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 IPv6 address: %s\n", inet_ntop(AF_INET6, &sockAddr6.sin6_addr, addr6, sizeof(addr6))); + } + + if (msg.nfapi_config.p7_pnf_port.tl.tag) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 Port: %d\n", msg.nfapi_config.p7_pnf_port.value); + + // store port + phy_info->p7_pnf_address.sin_port = htons(msg.nfapi_config.p7_pnf_port.value); + } + } + + if(config->param_resp) + { + (config->param_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received CONFIG_RESPONSE\n"); + + nfapi_config_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >=0 ) + { + if(config->config_resp) + { + (config->config_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received START_RESPONSE\n"); + + nfapi_start_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->start_resp) + { + (config->start_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_stop_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received STOP.response\n"); + + nfapi_stop_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->stop_resp) + { + (config->stop_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_measurement_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received MEASUREMENT.response\n"); + + nfapi_measurement_response_t msg; + + // unpack the message + if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->measurement_resp) + { + (config->measurement_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_rssi_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received RSSI.response\n"); + + nfapi_rssi_response_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->rssi_resp) + { + (config->rssi_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_rssi_indication(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received RSSI.indication\n"); + + nfapi_rssi_indication_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->rssi_ind) + { + (config->rssi_ind)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_cell_search_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received CELL_SEARCH.response\n"); + + nfapi_cell_search_response_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->cell_search_resp) + { + (config->cell_search_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_cell_search_indication(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_cell_search_indication: NULL parameters\n"); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received CELL_SEARCH.indication\n"); + + nfapi_cell_search_indication_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->cell_search_ind) + { + (config->cell_search_ind)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_cell_search_response: Unpack message failed, ignoring\n"); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_broadcast_detect_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received BROADCAST_DETECT.response\n"); + + nfapi_broadcast_detect_response_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->broadcast_detect_resp) + { + (config->broadcast_detect_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_broadcast_detect_indication(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received BROADCAST_DETECT.indication\n"); + + nfapi_broadcast_detect_indication_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->broadcast_detect_ind) + { + (config->broadcast_detect_ind)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + return; + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_system_information_schedule_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received SYSTEM_INFORMATION_SCHEDULE.response\n"); + + nfapi_system_information_schedule_response_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->system_information_schedule_resp) + { + (config->system_information_schedule_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_system_information_schedule_indication(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received SYSTEM_INFORMATION_SCHEDULE.indication\n"); + + nfapi_system_information_schedule_indication_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->system_information_schedule_ind) + { + (config->system_information_schedule_ind)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_system_information_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received SYSTEM_INFORMATION.response\n"); + + nfapi_system_information_response_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0) + { + if(config->system_information_resp) + { + (config->system_information_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_system_information_indication(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received SYSTEM_INFORMATION.indication\n"); + + nfapi_system_information_indication_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + return; + } + + if(config->system_information_ind) + { + (config->system_information_ind)(config, p5_idx, &msg); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } +} + +void vnf_handle_nmm_stop_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx) +{ + // ensure it's valid + if (pRecvMsg == NULL || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received NMM_STOP.response\n"); + + nfapi_nmm_stop_response_t msg; + + // unpack the message + if (nfapi_p4_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(nfapi_nmm_stop_response_t), &config->codec_config) >= 0) + { + if(config->nmm_stop_resp) + { + (config->nmm_stop_resp)(config, p5_idx, &msg); + } + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + // make sure to release any dyanmic part of the message + if(msg.vendor_extension) + config->codec_config.deallocate(msg.vendor_extension); + } + +} + +void vnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx, uint16_t message_id) +{ + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); + + if(config->allocate_p4_p5_vendor_ext && config->deallocate_p4_p5_vendor_ext) + { + uint16_t msg_size; + + nfapi_p4_p5_message_header_t* msg = config->allocate_p4_p5_vendor_ext(message_id, &msg_size); + + if(msg) + { + if(nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &config->codec_config) >= 0) + { + if(config->vendor_ext) + config->vendor_ext(config, p5_idx, msg); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Unpack message failed, ignoring\n", __FUNCTION__); + } + + config->deallocate_p4_p5_vendor_ext(msg); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n"); + } + } +} + +void vnf_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfapi_vnf_config_t* config) +{ + nfapi_p4_p5_message_header_t messageHeader; + + // validate the input params + if(pRecvMsg == NULL || recvMsgLen < NFAPI_HEADER_LENGTH || config == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_p4_p5_message: invalid input params\n"); + return; + } + + // unpack the message header + if (nfapi_p5_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p4_p5_message_header_t), &config->codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n"); + return; + } + + switch (messageHeader.message_id) + { + case NFAPI_PNF_PARAM_RESPONSE: + vnf_handle_pnf_param_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_PNF_CONFIG_RESPONSE: + vnf_handle_pnf_config_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_PNF_START_RESPONSE: + vnf_handle_pnf_start_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_PNF_STOP_RESPONSE: + vnf_handle_pnf_stop_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_PARAM_RESPONSE: + vnf_handle_param_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_CONFIG_RESPONSE: + vnf_handle_config_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_START_RESPONSE: + vnf_handle_start_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_STOP_RESPONSE: + vnf_handle_stop_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_MEASUREMENT_RESPONSE: + vnf_handle_measurement_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_RSSI_RESPONSE: + vnf_handle_rssi_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_RSSI_INDICATION: + vnf_handle_rssi_indication(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_CELL_SEARCH_RESPONSE: + vnf_handle_cell_search_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_CELL_SEARCH_INDICATION: + vnf_handle_cell_search_indication(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_BROADCAST_DETECT_RESPONSE: + vnf_handle_broadcast_detect_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_BROADCAST_DETECT_INDICATION: + vnf_handle_broadcast_detect_indication(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE: + vnf_handle_system_information_schedule_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION: + vnf_handle_system_information_schedule_indication(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_SYSTEM_INFORMATION_RESPONSE: + vnf_handle_system_information_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_SYSTEM_INFORMATION_INDICATION: + vnf_handle_system_information_indication(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + case NFAPI_NMM_STOP_RESPONSE: + vnf_handle_nmm_stop_response(pRecvMsg, recvMsgLen, config, p5_idx); + break; + + default: + { + if(messageHeader.message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + messageHeader.message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + vnf_handle_vendor_extension(pRecvMsg, recvMsgLen, config, p5_idx, messageHeader.message_id); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s P5 Unknown message ID %d\n", __FUNCTION__, messageHeader.message_id); + } + } + break; + } +} +int vnf_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf) +{ + if(1) + { + int socket_connected = 1; + + // 1. Peek the message header + // 2. If the message is larger than the stack buffer then create a dynamic buffer + // 3. Read the buffer + // 4. Handle the p5 message + + uint32_t header_buffer_size = NFAPI_HEADER_LENGTH; + uint8_t header_buffer[header_buffer_size]; + + uint32_t stack_buffer_size = 32; //should it be the size of then sctp_notificatoin structure + uint8_t stack_buffer[stack_buffer_size]; + + uint8_t* dynamic_buffer = 0; + + uint8_t* read_buffer = &stack_buffer[0]; + uint32_t message_size = 0; + + struct sockaddr_in addr; + socklen_t addr_len = sizeof(addr); + + struct sctp_sndrcvinfo sndrcvinfo; + (void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo)); + + { + int flags = MSG_PEEK; + message_size = sctp_recvmsg(pnf->p5_sock, header_buffer, header_buffer_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags); + + if(message_size == -1) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to peek sctp message size errno:%d\n", errno); + return 0; + } + + nfapi_p4_p5_message_header_t header; + int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0); + if(unpack_result < 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to decode message header %d\n", unpack_result); + return 0; + } + message_size = header.message_length; + + // now have the size of the mesage + } + + if(message_size > stack_buffer_size) + { + dynamic_buffer = (uint8_t*)malloc(message_size); + + if(dynamic_buffer == NULL) + { + // todo : add error mesage + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size); + return -1; + } + + read_buffer = dynamic_buffer; + } + + { + int flags = 0; + (void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo)); + + int recvmsg_result = sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags); + if(recvmsg_result == -1) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno); + } + else + { + if (flags & MSG_NOTIFICATION) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); + + // todo - handle the events + } + else + { + /* + NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n", + pnf->p5_sock, + inet_ntoa(addr.sin_addr), + ntohs(addr.sin_port), + sndrcvinfo.sinfo_assoc_id, + sndrcvinfo.sinfo_stream, + ntohl(sndrcvinfo.sinfo_ppid), + message_size, + flags); + */ + + // handle now if complete message in one or more segments + if ((flags & 0x80) == 0x80) + { + vnf_handle_p4_p5_message(read_buffer, message_size, pnf->p5_idx, config); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags); + + // assume socket disconnected + NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n"); + socket_connected = 0; + } + + + } + } + } + + if(dynamic_buffer) + { + free(dynamic_buffer); + } + + return socket_connected; + } +} + +static int vnf_send_p5_msg(nfapi_vnf_pnf_info_t* pnf, const void *msg, int len, uint8_t stream) +{ + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s len:%d stream:%d\n", __FUNCTION__, len, stream); + + int result = sctp_sendmsg(pnf->p5_sock, msg, len, (struct sockaddr*)&pnf->p5_pnf_sockaddr, sizeof(pnf->p5_pnf_sockaddr),1, 0, stream, 0, 4); + + if(result != len) + { + if(result < 0) + { + // error + NFAPI_TRACE(NFAPI_TRACE_ERROR, "sctp sendto failed errno: %d\n", errno); + } + else + { + // did not send all the message + } + } + + return 0; +} + + +int vnf_pack_and_send_p5_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len) +{ + nfapi_vnf_pnf_info_t* pnf = nfapi_vnf_pnf_list_find(&(vnf->_public), p5_idx); + + if(pnf) + { + // pack the message for transmission + int packedMessageLength = nfapi_p5_message_pack(msg, msg_len, vnf->tx_message_buffer, sizeof(vnf->tx_message_buffer), &vnf->_public.codec_config); + + if (packedMessageLength < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p5_message_pack failed with return %d\n", packedMessageLength); + return -1; + } + + return vnf_send_p5_msg(pnf, vnf->tx_message_buffer, packedMessageLength, 0/*msg->phy_id*/); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() cannot find pnf info for p5_idx:%d\n", __FUNCTION__, p5_idx); + return -1; + } +} + + +int vnf_pack_and_send_p4_message(vnf_t* vnf, uint16_t p5_idx, nfapi_p4_p5_message_header_t* msg, uint16_t msg_len) +{ + nfapi_vnf_pnf_info_t* pnf = nfapi_vnf_pnf_list_find(&(vnf->_public), p5_idx); + + if(pnf) + { + // pack the message for transmission + int packedMessageLength = nfapi_p4_message_pack(msg, msg_len, vnf->tx_message_buffer, sizeof(vnf->tx_message_buffer), &vnf->_public.codec_config); + + if (packedMessageLength < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi_p4_message_pack failed with return %d\n", packedMessageLength); + return -1; + } + + return vnf_send_p5_msg(pnf, vnf->tx_message_buffer, packedMessageLength, 0/*msg->phy_id*/); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() cannot find pnf info for p5_idx:%d\n", __FUNCTION__, p5_idx); + return -1; + } +} + diff --git a/nfapi/open-nFAPI/vnf/src/vnf_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_interface.c new file mode 100644 index 0000000000000000000000000000000000000000..0aba0a29f5e0c9a6d74ef1e361f7c135a875e31b --- /dev/null +++ b/nfapi/open-nFAPI/vnf/src/vnf_interface.c @@ -0,0 +1,676 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <netinet/sctp.h> +#include <arpa/inet.h> +#include <netdb.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> + +#include <stdio.h> + +#include "vnf.h" + + + +nfapi_vnf_config_t* nfapi_vnf_config_create() +{ + vnf_t* _this = (vnf_t*)calloc(1, sizeof(vnf_t)); + + if(_this == 0) + return 0; + + _this->sctp = 1; + + _this->next_phy_id = 1; + + // Set the default P5 port + _this->_public.vnf_p5_port = NFAPI_P5_SCTP_PORT; + + // set the default memory allocation + _this->_public.malloc = &malloc; + _this->_public.free = &free; + + // set the default memory allocation + _this->_public.codec_config.allocate = &malloc; + _this->_public.codec_config.deallocate = &free; + + + return &(_this->_public); +} + +void nfapi_vnf_config_destory(nfapi_vnf_config_t* config) +{ + free(config); +} + +int nfapi_vnf_start(nfapi_vnf_config_t* config) +{ + // Verify that config is not null + if(config == 0) + return -1; + + // Make sure to set the defined trace function before using NFAPI_TRACE + if(config->trace) + nfapi_trace_g = (nfapi_trace_fn_t)config->trace; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__); + + int p5ListenSock, p5Sock; + + struct sockaddr_in addr; + socklen_t addrSize; + + struct sockaddr_in6 addr6; + + struct sctp_event_subscribe events; + struct sctp_initmsg initMsg; + int noDelay; + + (void)memset(&addr, 0, sizeof(struct sockaddr_in)); + (void)memset(&addr6, 0, sizeof(struct sockaddr_in6)); + (void)memset(&events, 0, sizeof(struct sctp_event_subscribe)); + (void)memset(&initMsg, 0, sizeof(struct sctp_initmsg)); + + vnf_t* vnf = (vnf_t*)(config); + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Starting P5 VNF connection on port %u\n", config->vnf_p5_port); + + /* + char * host = 0; + char * port = "4242"; + struct addrinfo hints; + bzero(&hints, sizeof(struct addrinfo)); + //hints.ai_flags=AI_PASSIVE; + //hints.ai_flags=AI_DEFAULT; + hints.ai_family=AF_UNSPEC; + //hints.ai_family=AF_INET6; + hints.ai_socktype=SOCK_STREAM; + //hints.ai_protocol=IPPROTO_SCTP + + struct addrinfo *aiHead = 0; + + + + int result = getaddrinfo(host, port, &hints, &aiHead); + NFAPI_TRACE(NFAPI_TRACE_INFO, "getaddrinfo return %d %d\n", result, errno); + + while(aiHead->ai_next != NULL) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "addr info %d (IP %d UDP %d SCTP %d)\n %d (%d)\n", + aiHead->ai_protocol, IPPROTO_IP, IPPROTO_UDP, IPPROTO_SCTP, + aiHead->ai_flags, AI_PASSIVE); + + char hostBfr[ NI_MAXHOST ]; + char servBfr[ NI_MAXSERV ]; + + getnameinfo(aiHead->ai_addr, + aiHead->ai_addrlen, + hostBfr, + sizeof( hostBfr ), + servBfr, + sizeof( servBfr ), + NI_NUMERICHOST | NI_NUMERICSERV ); + + switch(aiHead->ai_family) + { + case PF_INET: + { + struct sockaddr_in *pSadrIn = (struct sockaddr_in*) aiHead->ai_addr; + printf( + " ai_addr = sin_family: %d (AF_INET = %d, " + "AF_INET6 = %d)\n" + " sin_addr: %s\n" + " sin_port: %s\n", + pSadrIn->sin_family, + AF_INET, + AF_INET6, + hostBfr, + servBfr ); + } + break; + case PF_INET6: + { + struct sockaddr_in6 *pSadrIn6 = (struct sockaddr_in6*) aiHead->ai_addr; + fprintf( stderr, + " ai_addr = sin6_family: %d (AF_INET = %d, " + "AF_INET6 = %d) \n" + " sin6_addr: %s\n" + " sin6_port: %s\n" + " sin6_flowinfo: %d\n" + " sin6_scope_id: %d\n", + pSadrIn6->sin6_family, + AF_INET, + AF_INET6, + hostBfr, + servBfr, + pSadrIn6->sin6_flowinfo, + pSadrIn6->sin6_scope_id); + } + break; + default: + NFAPI_TRACE(NFAPI_TRACE_INFO, "Not ment to be here\n"); + break; + } + + aiHead = aiHead->ai_next; + } + */ + + { + int protocol; + int domain; + + if (vnf->sctp) + protocol = IPPROTO_SCTP; + else + protocol = IPPROTO_IP; + + if(config->vnf_ipv6) + { + domain = PF_INET6; + } + else + { + domain = AF_INET; + } + + // open the SCTP socket + if ((p5ListenSock = socket(domain, SOCK_STREAM, protocol)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P5 socket errno: %d\n", errno); + return 0; + } + NFAPI_TRACE(NFAPI_TRACE_INFO, "P5 socket created... %d\n", p5ListenSock); + } + + if (vnf->sctp) + { + // configure for MSG_NOTIFICATION + if (setsockopt(p5ListenSock, IPPROTO_SCTP, SCTP_EVENTS, &events, sizeof(struct sctp_event_subscribe)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (SCTP_EVENTS) errno: %d\n", errno); + close(p5ListenSock); + return 0; + } + NFAPI_TRACE(NFAPI_TRACE_NOTE, "VNF Setting the SCTP_INITMSG\n"); + // configure the SCTP socket options + initMsg.sinit_num_ostreams = 5; //MAX_SCTP_STREAMS; // number of output streams can be greater + initMsg.sinit_max_instreams = 5; //MAX_SCTP_STREAMS; // number of output streams can be greater + if (setsockopt(p5ListenSock, IPPROTO_SCTP, SCTP_INITMSG, &initMsg, sizeof(initMsg)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (SCTP_INITMSG) errno: %d\n", errno) + close(p5ListenSock); + return 0; + } + noDelay = 1; + if (setsockopt(p5ListenSock, IPPROTO_SCTP, SCTP_NODELAY, &noDelay, sizeof(noDelay)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (STCP_NODELAY) errno: %d\n", errno); + close(p5ListenSock); + return 0; + } + struct sctp_event_subscribe events; + memset( (void *)&events, 0, sizeof(events) ); + events.sctp_data_io_event = 1; + + if(setsockopt(p5ListenSock, SOL_SCTP, SCTP_EVENTS, (const void *)&events, sizeof(events)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt errno: %d\n", errno); + close(p5ListenSock); + return -1; + } + + } + + + if(config->vnf_ipv6) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "IPV6 binding to port %d %d\n", config->vnf_p5_port, p5ListenSock); + addr6.sin6_family = AF_INET6; + addr6.sin6_port = htons(config->vnf_p5_port); + addr6.sin6_addr = in6addr_any; + + // bind to the configured address and port + if (bind(p5ListenSock, (struct sockaddr *)&addr6, sizeof(struct sockaddr_in6)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After bind errno: %d\n", errno); + close(p5ListenSock); + return 0; + } + } + else if(config->vnf_ipv4) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "IPV4 binding to port %d\n", config->vnf_p5_port); + addr.sin_family = AF_INET; + addr.sin_port = htons(config->vnf_p5_port); + addr.sin_addr.s_addr = INADDR_ANY; + + // bind to the configured address and port + if (bind(p5ListenSock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) + //if (sctp_bindx(p5ListenSock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in), SCTP_BINDX_ADD_ADDR) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After bind errno: %d\n", errno); + close(p5ListenSock); + return 0; + } + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "bind succeeded..%d.\n", p5ListenSock); + + // put the socket into listen mode + if (listen(p5ListenSock, 2) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After listen errno: %d\n", errno); + close(p5ListenSock); + return 0; + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "listen succeeded...\n"); + + struct timeval tv; + fd_set read_fd_set; + + + int p5_idx = 0; + while(vnf->terminate == 0) + { + FD_ZERO(&read_fd_set); + + FD_SET(p5ListenSock, &read_fd_set); + int max_fd = p5ListenSock; + + tv.tv_sec = 5; + tv.tv_usec = 0; + + nfapi_vnf_pnf_info_t* pnf = config->pnf_list; + while(pnf != 0) + { + if(pnf->connected) + { + FD_SET(pnf->p5_sock, &read_fd_set); + if (pnf->p5_sock > max_fd) + { + max_fd = pnf->p5_sock; + } + } + + pnf = pnf->next; + } + + int select_result = select(max_fd + 1, &read_fd_set, 0, 0, &tv); + + if(select_result == -1) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "select result %d errno %d\n", select_result, errno); + close(p5ListenSock); + return 0; + } + else if(select_result) + { + if(FD_ISSET(p5ListenSock, &read_fd_set)) + { + addrSize = sizeof(struct sockaddr_in); + NFAPI_TRACE(NFAPI_TRACE_INFO, "Accepting connection from PNF...\n"); + + p5Sock = accept(p5ListenSock, (struct sockaddr *)&addr, &addrSize); + + if (p5Sock < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to accept PNF connection reason:%d\n", errno); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF connection (fd:%d) accepted from %s:%d \n", p5Sock, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); + nfapi_vnf_pnf_info_t* pnf = (nfapi_vnf_pnf_info_t*)malloc(sizeof(nfapi_vnf_pnf_info_t)); + NFAPI_TRACE(NFAPI_TRACE_INFO, "MALLOC nfapi_vnf_pnf_info_t for pnf_list pnf:%p\n", pnf); + memset(pnf, 0, sizeof(nfapi_vnf_pnf_info_t)); + pnf->p5_sock = p5Sock; + pnf->p5_idx = p5_idx++; + pnf->p5_pnf_sockaddr = addr; + pnf->connected = 1; + + nfapi_vnf_pnf_list_add(config, pnf); + + // Inform mac that a pnf connection has been established + // todo : allow mac to 'accept' the connection. i.e. to + // reject it. + if(config->pnf_connection_indication != 0) + { + (config->pnf_connection_indication)(config, pnf->p5_idx); + } + + + // check the connection status + { + struct sctp_status status; + (void)memset(&status, 0, sizeof(struct sctp_status)); + socklen_t optLen = (socklen_t) sizeof(struct sctp_status); + if (getsockopt(p5Sock, IPPROTO_SCTP, SCTP_STATUS, &status, &optLen) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After getsockopt errno: %d\n", errno); + return -1; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Association ID = %d\n", status.sstat_assoc_id); + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Receiver window size = %d\n", status.sstat_rwnd); + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF In Streams = %d\n", status.sstat_instrms); + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Out Streams = %d\n", status.sstat_outstrms); + + } + } + } + } + else + { + uint8_t delete_pnfs = 0; + + nfapi_vnf_pnf_info_t* pnf = config->pnf_list; + while(pnf != 0) + { + if(FD_ISSET(pnf->p5_sock, &read_fd_set)) + { + if(vnf_read_dispatch_message(config, pnf) == 0) + { + if(config->pnf_disconnect_indication != 0) + { + (config->pnf_disconnect_indication)(config, pnf->p5_idx); + } + + close(pnf->p5_sock); + + pnf->to_delete = 1; + delete_pnfs = 1; + } + } + + pnf = pnf->next; + } + + if(delete_pnfs) + { + nfapi_vnf_pnf_info_t* pnf = config->pnf_list; + nfapi_vnf_pnf_info_t* prev = 0; + while(pnf != 0) + { + nfapi_vnf_pnf_info_t* curr = pnf; + + if(pnf->to_delete == 1) + { + if(prev == 0) + { + config->pnf_list = pnf->next; + } + else + { + prev->next = pnf->next; + } + + pnf = pnf->next; + + free(curr); + } + else + { + prev = pnf; + pnf = pnf->next; + } + + } + + } + } + + continue; + } + else + { + // timeout + + // Should we test for socket closure here every second? + + continue; + } + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Closing p5Sock socket's\n"); + { + nfapi_vnf_pnf_info_t* curr = config->pnf_list; + while(curr != NULL) + { + if(config->pnf_disconnect_indication) + { + (config->pnf_disconnect_indication)(config, curr->p5_idx); + } + + close(curr->p5_sock); + curr = curr->next; + } + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Closing p5Listen socket\n"); + close(p5ListenSock); + + return 0; + +} + +int nfapi_vnf_stop(nfapi_vnf_config_t* config) +{ + // Verify that config is not null + if(config == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + _this->terminate = 1; + return 0; +} + +int nfapi_vnf_pnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_pnf_param_request_t)); +} + +int nfapi_vnf_pnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_pnf_config_request_t)); +} + +int nfapi_vnf_pnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_pnf_start_request_t)); +} + +int nfapi_vnf_pnf_stop_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_stop_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_pnf_stop_request_t)); +} + +int nfapi_vnf_param_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_param_request_t)); +} +int nfapi_vnf_config_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + nfapi_vnf_phy_info_t* phy = nfapi_vnf_phy_info_list_find(config, req->header.phy_id); + + if(phy == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "%s failed to find phy inforation phy_id:%d\n", __FUNCTION__, req->header.phy_id); + return -1; + } + + // set the timing parameters + req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG; + req->nfapi_config.timing_window.value = phy->timing_window; + req->num_tlv++; + + req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG; + req->nfapi_config.timing_info_mode.value = phy->timing_info_mode; + req->num_tlv++; + + req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG; + req->nfapi_config.timing_info_period.value = phy->timing_info_period; + req->num_tlv++; + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_config_request_t)); +} +int nfapi_vnf_start_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_start_request_t)); +} +int nfapi_vnf_stop_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_stop_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_stop_request_t)); +} +int nfapi_vnf_measurement_req(nfapi_vnf_config_t* config, int p5_idx, nfapi_measurement_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, &req->header, sizeof(nfapi_measurement_request_t)); +} +int nfapi_vnf_rssi_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_rssi_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p4_message(_this, p5_idx, &req->header, sizeof(nfapi_rssi_request_t)); +} +int nfapi_vnf_cell_search_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_cell_search_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p4_message(_this, p5_idx, &req->header, sizeof(nfapi_cell_search_request_t)); +} +int nfapi_vnf_broadcast_detect_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_broadcast_detect_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p4_message(_this, p5_idx, &req->header, sizeof(nfapi_broadcast_detect_request_t)); +} +int nfapi_vnf_system_information_schedule_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_schedule_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p4_message(_this, p5_idx, &req->header, sizeof(nfapi_system_information_schedule_request_t)); +} +int nfapi_vnf_system_information_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_system_information_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p4_message(_this, p5_idx, &req->header, sizeof(nfapi_system_information_request_t)); +} +int nfapi_vnf_nmm_stop_request(nfapi_vnf_config_t* config, int p5_idx, nfapi_nmm_stop_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p4_message(_this, p5_idx, &req->header, sizeof(nfapi_nmm_stop_request_t)); +} +int nfapi_vnf_vendor_extension(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg) +{ + if(config == 0 || msg == 0) + return -1; + + vnf_t* _this = (vnf_t*)(config); + + return vnf_pack_and_send_p5_message(_this, p5_idx, msg, sizeof(nfapi_p4_p5_message_header_t)); +} + +int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy_id) +{ + vnf_t* vnf = (vnf_t*)config; + + nfapi_vnf_phy_info_t* info = (nfapi_vnf_phy_info_t*)calloc(1, sizeof(nfapi_vnf_phy_info_t)); + info->p5_idx = p5_idx; + info->phy_id = vnf->next_phy_id++; + + info->timing_window = 30; // This seems to override what gets set by the user - why??? + info->timing_info_mode = 0x03; + info->timing_info_period = 128; + + nfapi_vnf_phy_info_list_add(config, info); + + (*phy_id) = info->phy_id; + + return 0; +} diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c new file mode 100644 index 0000000000000000000000000000000000000000..13041767522935fb74a90cfe9748517d303588dd --- /dev/null +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -0,0 +1,1599 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <time.h> + +#include <sys/time.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> + +#include "vnf_p7.h" + +#define SYNC_CYCLE_COUNT 2 + +void* vnf_p7_malloc(vnf_p7_t* vnf_p7, size_t size) +{ + if(vnf_p7->_public.malloc) + { + return (vnf_p7->_public.malloc)(size); + } + else + { + return calloc(1, size); + } +} +void vnf_p7_free(vnf_p7_t* vnf_p7, void* ptr) +{ + if(ptr == 0) + return; + + if(vnf_p7->_public.free) + { + (vnf_p7->_public.free)(ptr); + } + else + { + free(ptr); + } +} + +void vnf_p7_codec_free(vnf_p7_t* vnf_p7, void* ptr) +{ + if(ptr == 0) + return; + + if(vnf_p7->_public.codec_config.deallocate) + { + (vnf_p7->_public.codec_config.deallocate)(ptr); + } + else + { + free(ptr); + } +} + +void vnf_p7_connection_info_list_add(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* node) +{ + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__); + // todo : add mutex + node->next = vnf_p7->p7_connections; + vnf_p7->p7_connections = node; +} + +nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_find(vnf_p7_t* vnf_p7, uint16_t phy_id) +{ + nfapi_vnf_p7_connection_info_t* curr = vnf_p7->p7_connections; + while(curr != 0) + { + if(curr->phy_id == phy_id) + { + return curr; + } + curr = curr->next; + } + + return 0; +} + +nfapi_vnf_p7_connection_info_t* vnf_p7_connection_info_list_delete(vnf_p7_t* vnf_p7, uint16_t phy_id) +{ + nfapi_vnf_p7_connection_info_t* curr = vnf_p7->p7_connections; + nfapi_vnf_p7_connection_info_t* prev = 0; + + while(curr != 0) + { + if(curr->phy_id == phy_id) + { + if(prev == 0) + { + vnf_p7->p7_connections = curr->next; + } + else + { + prev->next = curr->next; + } + + return curr; + } + else + { + prev = curr; + curr = curr->next; + } + } + + return 0; +} + +vnf_p7_rx_message_t* vnf_p7_rx_reassembly_queue_add_segment(vnf_p7_t* vnf_p7, vnf_p7_rx_reassembly_queue_t* queue, uint16_t sequence_number, uint16_t segment_number, uint8_t m, uint8_t* data, uint16_t data_len) +{ + vnf_p7_rx_message_t* msg = 0; + // attempt to find a entry for this segment + vnf_p7_rx_message_t* iterator = queue->msg_queue; + while(iterator != 0) + { + if(iterator->sequence_number == sequence_number) + { + msg = iterator; + break; + } + + iterator = iterator->next; + } + + // if found then copy data to message + if(msg != 0) + { + + msg->segments[segment_number].buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, data_len); + memcpy(msg->segments[segment_number].buffer, data, data_len); + msg->segments[segment_number].length = data_len; + + msg->num_segments_received++; + + // set the segement number if we have the last segment + if(m == 0) + msg->num_segments_expected = segment_number + 1; + } + // else add new rx message entry + else + { + // create a new message + msg = (vnf_p7_rx_message_t*)(vnf_p7_malloc(vnf_p7, sizeof(vnf_p7_rx_message_t))); + memset(msg, 0, sizeof(vnf_p7_rx_message_t)); + + msg->sequence_number = sequence_number; + msg->num_segments_expected = m ? 255 : segment_number + 1; + msg->num_segments_received = 1; + msg->rx_hr_time = vnf_get_current_time_hr(); + + msg->segments[segment_number].buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, data_len); + memcpy(msg->segments[segment_number].buffer, data, data_len); + msg->segments[segment_number].length = data_len; + + // place the message at the head of the queue + msg->next = queue->msg_queue; + queue->msg_queue = msg; + } + + return msg; +} + +void vnf_p7_rx_reassembly_queue_remove_msg(vnf_p7_t* vnf_p7, vnf_p7_rx_reassembly_queue_t* queue, vnf_p7_rx_message_t* msg) +{ + // remove message if it has the same sequence number + vnf_p7_rx_message_t* iterator = queue->msg_queue; + vnf_p7_rx_message_t* previous = 0; + + while(iterator != 0) + { + if(iterator->sequence_number == msg->sequence_number) + { + if(previous == 0) + { + queue->msg_queue = iterator->next; + } + else + { + previous->next = iterator->next; + } + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Deleting reassembly message\n"); + // delete the message + uint16_t i; + for(i = 0; i < 128; ++i) + { + if(iterator->segments[i].buffer) + vnf_p7_free(vnf_p7, iterator->segments[i].buffer); + } + vnf_p7_free(vnf_p7, iterator); + + break; + } + + previous = iterator; + iterator = iterator->next; + } +} + +void vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7_t* vnf_p7, vnf_p7_rx_reassembly_queue_t* queue, uint32_t delta) +{ + // remove all messages that are too old + vnf_p7_rx_message_t* iterator = queue->msg_queue; + vnf_p7_rx_message_t* previous = 0; + + uint32_t rx_hr_time = vnf_get_current_time_hr(); + + while(iterator != 0) + { + if(rx_hr_time - iterator->rx_hr_time > delta) + { + if(previous == 0) + { + queue->msg_queue = iterator->next; + } + else + { + previous->next = iterator->next; + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Deleting stale reassembly message (%u %u %d)\n", iterator->rx_hr_time, rx_hr_time, delta); + + vnf_p7_rx_message_t* to_delete = iterator; + iterator = iterator->next; + + // delete the message + uint16_t i; + for(i = 0; i < 128; ++i) + { + if(to_delete->segments[i].buffer) + vnf_p7_free(vnf_p7, to_delete->segments[i].buffer); + } + vnf_p7_free(vnf_p7, to_delete); + + } + else + { + previous = iterator; + iterator = iterator->next; + } + } +} + +uint32_t vnf_get_current_time_hr() +{ + struct timeval now; + (void)gettimeofday(&now, NULL); + uint32_t time_hr = TIME2TIMEHR(now); + return time_hr; +} + +uint16_t increment_sfn_sf(uint16_t sfn_sf) +{ + if((sfn_sf & 0xF) == 9) + { + sfn_sf += 0x0010; + sfn_sf &= 0x3FF0; + } + else if((sfn_sf & 0xF) > 9) + { + // error should not happen + } + else + { + sfn_sf++; + } + + return sfn_sf; +} + +struct timespec timespec_delta(struct timespec start, struct timespec end) +{ + struct timespec temp; + if ((end.tv_nsec-start.tv_nsec)<0) + { + temp.tv_sec = end.tv_sec-start.tv_sec-1; + temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; + } + else + { + temp.tv_sec = end.tv_sec-start.tv_sec; + temp.tv_nsec = end.tv_nsec-start.tv_nsec; + } + return temp; +} + +static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr) +{ + if(now_hr < sf_start_hr) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "now is earlier that start of subframe\n"); + return 0; + } + else + { + uint32_t now_us = TIMEHR_USEC(now_hr); + uint32_t sf_start_us = TIMEHR_USEC(sf_start_hr); + + // if the us have wrapped adjust for it + if(now_hr < sf_start_us) + { + now_us += 1000000; + } + + return now_us - sf_start_us; + } +} + +uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr) +{ + uint32_t now_time_hr = vnf_get_current_time_hr(); + + uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); + + uint32_t t1 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + + return t1; +} + + +uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr) +{ + uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); + + uint32_t t4 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + + return t4; + +} + + +uint32_t calculate_transmit_timestamp(uint16_t sfn_sf, uint32_t sf_start_time_hr) +{ + uint32_t now_time_hr = vnf_get_current_time_hr(); + + uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); + + uint32_t tt = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + + return tt; +} + + +uint16_t increment_sfn_sf_by(uint16_t sfn_sf, uint8_t increment) +{ + while(increment > 0) + { + sfn_sf = increment_sfn_sf(sfn_sf); + --increment; + } + + return sfn_sf; +} + + +int send_mac_subframe_indications(vnf_p7_t* vnf_p7) +{ + nfapi_vnf_p7_connection_info_t* curr = vnf_p7->p7_connections; + while(curr != 0) + { + if(curr->in_sync == 1) + { + // ask for subframes in the future + uint16_t sfn_sf_adv = increment_sfn_sf_by(curr->sfn_sf, 2); + + vnf_p7->_public.subframe_indication(&(vnf_p7->_public), curr->phy_id, sfn_sf_adv); + } + + curr = curr->next; + } + + return 0; +} + +int vnf_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info, uint8_t* msg, const uint32_t len) +{ + int sendto_result = sendto(vnf_p7->socket, msg, len, 0, (struct sockaddr*)&(p7_info->remote_addr), sizeof(p7_info->remote_addr)); + + if(sendto_result != len) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sendto_result %d %d\n", __FUNCTION__, sendto_result, errno); + } + + return 0; +} + +int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header) +{ + + nfapi_vnf_p7_connection_info_t* p7_connection = vnf_p7_connection_info_list_find(vnf_p7, header->phy_id); + if(p7_connection) + { + int send_result = 0; + uint8_t buffer[1024 * 32]; + + header->m_segment_sequence = NFAPI_P7_SET_MSS(0, 0, p7_connection->sequence_number); + + int len = nfapi_p7_message_pack(header, buffer, sizeof(buffer), &vnf_p7->_public.codec_config); + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() phy_id:%d nfapi_p7_message_pack()=len=%d vnf_p7->_public.segment_size:%u\n", __FUNCTION__, header->phy_id, len, vnf_p7->_public.segment_size); + + if(len < 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() failed to pack p7 message phy_id:%d\n", __FUNCTION__, header->phy_id); + return -1; + } + + if(len > vnf_p7->_public.segment_size) + { + // todo : consider replacing with the sendmmsg call + // todo : worry about blocking writes? + + // segmenting the transmit + int msg_body_len = len - NFAPI_P7_HEADER_LENGTH ; + int seg_body_len = vnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH ; + int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0); + + int segment = 0; + int offset = NFAPI_P7_HEADER_LENGTH; + uint8_t tx_buffer[vnf_p7->_public.segment_size]; + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() MORE THAN ONE SEGMENT phy_id:%d nfapi_p7_message_pack()=len=%d vnf_p7->_public.segment_size:%u\n", __FUNCTION__, header->phy_id, len, vnf_p7->_public.segment_size); + for(segment = 0; segment < segment_count; ++segment) + { + uint8_t last = 0; + uint16_t size = vnf_p7->_public.segment_size - NFAPI_P7_HEADER_LENGTH; + if(segment + 1 == segment_count) + { + last = 1; + size = (msg_body_len) - (seg_body_len * segment); + } + + uint16_t segment_size = size + NFAPI_P7_HEADER_LENGTH; + + // Update the header with the m and segement + memcpy(&tx_buffer[0], buffer, NFAPI_P7_HEADER_LENGTH); + + // set the segment length + tx_buffer[4] = (segment_size & 0xFF00) >> 8; + tx_buffer[5] = (segment_size & 0xFF); + + // set the m & segment number + tx_buffer[6] = ((!last) << 7) + segment; + + memcpy(&tx_buffer[NFAPI_P7_HEADER_LENGTH], &buffer[0] + offset, size); + offset += size; + + if(vnf_p7->_public.checksum_enabled) + { + nfapi_p7_update_checksum(tx_buffer, segment_size); + } + + nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn_sf, vnf_p7->sf_start_time_hr)); + + send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size); + } + } + else + { + if(vnf_p7->_public.checksum_enabled) + { + nfapi_p7_update_checksum(buffer, len); + } + + nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn_sf, vnf_p7->sf_start_time_hr)); + + // simple case that the message fits in a single segement + send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len); + } + + p7_connection->sequence_number++; + + return send_result; + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() cannot find p7 connection info for phy_id:%d\n", __FUNCTION__, header->phy_id); + return -1; + } +} + +int vnf_build_send_dl_node_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info) +{ + nfapi_dl_node_sync_t dl_node_sync; + memset(&dl_node_sync, 0, sizeof(dl_node_sync)); + + dl_node_sync.header.phy_id = p7_info->phy_id; + dl_node_sync.header.message_id = NFAPI_DL_NODE_SYNC; + dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr); + dl_node_sync.delta_sfn_sf = 0; + + return vnf_p7_pack_and_send_p7_msg(vnf_p7, &dl_node_sync.header); +} + +int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info) +{ + + if(p7_info->in_sync == 1) + { + uint16_t dl_sync_period_mask = p7_info->dl_in_sync_period-1; + uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); + + if ((((sfn_sf_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) + { + vnf_build_send_dl_node_sync(vnf_p7, p7_info); + } + } + else + { + uint16_t dl_sync_period_mask = p7_info->dl_out_sync_period-1; + uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); + + if ((((sfn_sf_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) + { + vnf_build_send_dl_node_sync(vnf_p7, p7_info); + } + } + return 0; +} + + +void vnf_handle_harq_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_harq_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.harq_indication) + { + (vnf_p7->_public.harq_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.harq_indication_body.harq_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } +} + +void vnf_handle_crc_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_crc_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.crc_indication) + { + (vnf_p7->_public.crc_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.crc_indication_body.crc_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } +} + +void vnf_handle_rx_ulsch_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_rx_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.rx_indication) + { + (vnf_p7->_public.rx_indication)(&(vnf_p7->_public), &ind); + } + } + + uint16_t i = 0; + for(i = 0; i < ind.rx_indication_body.number_of_pdus; ++i) + { + vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list[i].data); + } + vnf_p7_codec_free(vnf_p7, ind.rx_indication_body.rx_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } + +} + +void vnf_handle_rach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_rach_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.rach_indication) + { + (vnf_p7->_public.rach_indication)(&vnf_p7->_public, &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.rach_indication_body.preamble_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + + } +} + +void vnf_handle_srs_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_srs_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.srs_indication) + { + (vnf_p7->_public.srs_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.srs_indication_body.srs_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } +} + +void vnf_handle_rx_sr_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_sr_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.sr_indication) + { + (vnf_p7->_public.sr_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.sr_indication_body.sr_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } +} +void vnf_handle_rx_cqi_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_cqi_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.cqi_indication) + { + (vnf_p7->_public.cqi_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.cqi_indication_body.cqi_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.cqi_indication_body.cqi_raw_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + + } + +} + +void vnf_handle_lbt_dl_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_lbt_dl_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.lbt_dl_indication) + { + (vnf_p7->_public.lbt_dl_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.lbt_dl_indication_body.lbt_indication_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } +} + +void vnf_handle_nb_harq_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_nb_harq_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.nb_harq_indication) + { + (vnf_p7->_public.nb_harq_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.nb_harq_indication_body.nb_harq_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } +} + +void vnf_handle_nrach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + // ensure it's valid + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else + { + nfapi_nrach_indication_t ind; + + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__); + } + else + { + if(vnf_p7->_public.nrach_indication) + { + (vnf_p7->_public.nrach_indication)(&(vnf_p7->_public), &ind); + } + } + + vnf_p7_codec_free(vnf_p7, ind.nrach_indication_body.nrach_pdu_list); + vnf_p7_codec_free(vnf_p7, ind.vendor_extension); + } +} + +void vnf_handle_p7_vendor_extension(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7, uint16_t message_id) +{ + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: NULL parameters\n", __FUNCTION__); + } + else if(vnf_p7->_public.allocate_p7_vendor_ext) + { + uint16_t msg_size; + nfapi_p7_message_header_t* msg = vnf_p7->_public.allocate_p7_vendor_ext(message_id, &msg_size); + + if(msg == 0) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to allocate vendor extention structure\n", __FUNCTION__); + return; + } + + int unpack_result = nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &vnf_p7->_public.codec_config); + + if(unpack_result == 0) + { + if(vnf_p7->_public.vendor_ext) + vnf_p7->_public.vendor_ext(&(vnf_p7->_public), msg); + } + + if(vnf_p7->_public.deallocate_p7_vendor_ext) + vnf_p7->_public.deallocate_p7_vendor_ext(msg); + + } +} + + +void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + uint32_t now_time_hr = vnf_get_current_time_hr(); + + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_ul_node_sync: NULL parameters\n"); + return; + } + + nfapi_ul_node_sync_t ind; + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(nfapi_ul_node_sync_t), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack ul_node_sync\n"); + return; + } + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Received UL_NODE_SYNC phy_id:%d t1:%d t2:%d t3:%d\n", ind.header.phy_id, ind.t1, ind.t2, ind.t3); + + nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, ind.header.phy_id); + uint32_t t4 = calculate_t4(now_time_hr, phy->sfn_sf, vnf_p7->sf_start_time_hr); + + uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSFDEC - ind.t1 ; + uint32_t pnf_proc_time = ind.t3 - ind.t2; + + // divide by 2 using shift operator + uint32_t latency = (tx_2_rx - pnf_proc_time) >> 1; + + if(!(phy->filtered_adjust)) + { + phy->latency[phy->min_sync_cycle_count] = latency; + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) PNF to VNF !sync phy_id:%d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d\n", + NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, ind.t1, ind.t2, ind.t3, t4, + tx_2_rx, pnf_proc_time, latency); + } + else + { + phy->latency[phy->min_sync_cycle_count] = latency; + + //if(phy->min_sync_cycle_count != SYNC_CYCLE_COUNT) + { + if (ind.t2 < phy->previous_t2 && ind.t1 > phy->previous_t1) + { + // Only t2 wrap has occurred!!! + phy->sf_offset = (NFAPI_MAX_SFNSFDEC + ind.t2) - ind.t1 - latency; + } + else if (ind.t2 > phy->previous_t2 && ind.t1 < phy->previous_t1) + { + // Only t1 wrap has occurred + phy->sf_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSFDEC) - latency; + } + else + { + // Either no wrap or both have wrapped + phy->sf_offset = ind.t2 - ind.t1 - latency; + } + + if (phy->sf_offset_filtered == 0) + { + phy->sf_offset_filtered = phy->sf_offset; + } + else + { + int32_t oldFilteredValueShifted = phy->sf_offset_filtered << 5; + int32_t newOffsetShifted = phy->sf_offset << 5; + + // 1/8 of new and 7/8 of old + phy->sf_offset_filtered = ((newOffsetShifted >> 3) + ((oldFilteredValueShifted * 7) >> 3)) >> 5; + } + } + + if(1) + { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%1d) %d.%d PNF to VNF phy_id:%2d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d(avg:%4d) offset(us):%8d filtered(us):%8d wrap[t1:%u t2:%u]\n", + NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ts.tv_sec, ts.tv_nsec, ind.header.phy_id, + ind.t1, ind.t2, ind.t3, t4, + tx_2_rx, pnf_proc_time, latency, phy->average_latency, phy->sf_offset, phy->sf_offset_filtered, + (ind.t1<phy->previous_t1), (ind.t2<phy->previous_t2)); + } + + } + + if (phy->filtered_adjust && (phy->sf_offset_filtered > 1e6 || phy->sf_offset_filtered < -1e6)) + { + phy->filtered_adjust = 0; + phy->zero_count=0; + phy->min_sync_cycle_count = 2; + phy->in_sync = 0; + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s - ADJUST TOO BAD - go out of filtered phy->sf_offset_filtered:%d\n", __FUNCTION__, phy->sf_offset_filtered); + } + + if(phy->min_sync_cycle_count) + phy->min_sync_cycle_count--; + + if(phy->min_sync_cycle_count == 0) + { + uint32_t curr_sfn_sf = phy->sfn_sf; + int32_t sfn_sf_dec = NFAPI_SFNSF2DEC(phy->sfn_sf); + + if(!phy->filtered_adjust) + { + int i = 0; + //phy->average_latency = 0; + for(i = 0; i < SYNC_CYCLE_COUNT; ++i) + { + phy->average_latency += phy->latency[i]; + + } + phy->average_latency /= SYNC_CYCLE_COUNT; + + phy->sf_offset = ind.t2 - (ind.t1 - phy->average_latency); + + sfn_sf_dec += (phy->sf_offset / 1000); + } + else + { + sfn_sf_dec += ((phy->sf_offset_filtered + 500) / 1000); //Round up go from microsecond to subframe(1ms) + } + + if(sfn_sf_dec < 0) + { + sfn_sf_dec += NFAPI_MAX_SFNSFDEC; + } + else if( sfn_sf_dec >= NFAPI_MAX_SFNSFDEC) + { + sfn_sf_dec -= NFAPI_MAX_SFNSFDEC; + } + + uint16_t new_sfn_sf = NFAPI_SFNSFDEC2SFNSF(sfn_sf_dec); + + + { + phy->adjustment = NFAPI_SFNSF2DEC(new_sfn_sf) - NFAPI_SFNSF2DEC(curr_sfn_sf); + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_sf_offset_filtered:%d phy->previous_sf_offset_filtered:%d phy->sf_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_sf_offset_filtered, phy->previous_sf_offset_filtered, phy->sf_offset_trend); + + phy->previous_t1 = 0; + phy->previous_t2 = 0; + + if(phy->previous_sf_offset_filtered > 0) + { + if( phy->sf_offset_filtered > phy->previous_sf_offset_filtered) + { + // pnf is getting futher ahead of vnf + //phy->sf_offset_trend = phy->sf_offset_filtered - phy->previous_sf_offset_filtered; + phy->sf_offset_trend = (phy->sf_offset_filtered + phy->previous_sf_offset_filtered)/2; + } + else + { + // pnf is getting back in sync + } + } + else if(phy->previous_sf_offset_filtered < 0) + { + if(phy->sf_offset_filtered < phy->previous_sf_offset_filtered) + { + // vnf is getting future ahead of pnf + //phy->sf_offset_trend = -(phy->sf_offset_filtered - phy->previous_sf_offset_filtered); + phy->sf_offset_trend = (-(phy->sf_offset_filtered + phy->previous_sf_offset_filtered)) /2; + } + else + { + // vnf is getting back in sync + } + } + + + int insync_minor_adjustment_1 = phy->sf_offset_trend / 6; + int insync_minor_adjustment_2 = phy->sf_offset_trend / 2; + + + if(insync_minor_adjustment_1 == 0) + insync_minor_adjustment_1 = 2; + + if(insync_minor_adjustment_2 == 0) + insync_minor_adjustment_2 = 10; + + if(!phy->filtered_adjust) + { + if(phy->adjustment < 10) + { + phy->zero_count++; + + if(phy->zero_count >= 10) + { + phy->filtered_adjust = 1; + phy->zero_count = 0; + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "***** Adjusting VNF SFN/SF switching to filtered mode\n"); + } + } + else + { + phy->zero_count = 0; + } + } + else + { + // Fine level of adjustment + if (phy->adjustment == 0) + { + if (phy->zero_count >= 10) + { + if(phy->in_sync == 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "VNF P7 In Sync with phy (phy_id:%d)\n", phy->phy_id); + + if(vnf_p7->_public.sync_indication) + (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), 1); + } + + phy->in_sync = 1; + } + else + { + phy->zero_count++; + } + + if(phy->in_sync) + { + // in sync + if(phy->sf_offset_filtered > 250) + { + // VNF is slow + phy->insync_minor_adjustment = insync_minor_adjustment_1; //25; + phy->insync_minor_adjustment_duration = ((phy->sf_offset_filtered) / insync_minor_adjustment_1); + } + else if(phy->sf_offset_filtered < -250) + { + // VNF is fast + phy->insync_minor_adjustment = -(insync_minor_adjustment_1); //25; + phy->insync_minor_adjustment_duration = (((phy->sf_offset_filtered) / -(insync_minor_adjustment_1))); + } + else + { + phy->insync_minor_adjustment = 0; + } + + if(phy->insync_minor_adjustment != 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (sf_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adjustment:%d\n", + NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, + phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, + phy->sf_offset_filtered, + insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend, + NFAPI_SFNSF2DEC(new_sfn_sf), + NFAPI_SFNSF2DEC(curr_sfn_sf), + phy->adjustment); + } + } + } + else + { + if (phy->in_sync) + { + if(phy->adjustment == 0) + { + } + else if(phy->adjustment > 0) + { + // VNF is slow + //if(phy->adjustment == 1) + { + // + if(phy->sf_offset_filtered > 250) + { + // VNF is slow + phy->insync_minor_adjustment = insync_minor_adjustment_2; + phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered - 250) / insync_minor_adjustment_2); + } + else if(phy->sf_offset_filtered < -250) + { + // VNF is fast + phy->insync_minor_adjustment = -(insync_minor_adjustment_2); + phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered + 250) / -(insync_minor_adjustment_2)); + } + + } + //else + { + // out of sync? + } + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (adjustment:%d sf_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adj:%d\n", + NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, + phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->sf_offset_filtered, + insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend, + NFAPI_SFNSF2DEC(new_sfn_sf), + NFAPI_SFNSF2DEC(curr_sfn_sf), + phy->adjustment); + + } + else if(phy->adjustment < 0) + { + // VNF is fast + //if(phy->adjustment == -1) + { + // + if(phy->sf_offset_filtered > 250) + { + // VNF is slow + phy->insync_minor_adjustment = insync_minor_adjustment_2; + phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered - 250) / insync_minor_adjustment_2); + } + else if(phy->sf_offset_filtered < -250) + { + // VNF is fast + phy->insync_minor_adjustment = -(insync_minor_adjustment_2); + phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered + 250) / -(insync_minor_adjustment_2)); + } + } + //else + { + // out of sync? + } + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (adjustment:%d sf_offset_filtered:%d) %d %d %d\n", + NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, + phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->sf_offset_filtered, + insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend); + } + + /* + if (phy->adjustment > 10 || phy->adjustment < -10) + { + phy->zero_count++; // Add one to the getting out of sync counter + } + else + { + phy->zero_count = 0; // Small error - zero the out of sync counter + } + + if (phy->zero_count >= 10) // If we have had 10 consecutive large errors - drop out of sync + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "we have fallen out of sync...\n"); + //pP7SockInfo->syncAchieved = 0; + } + */ + } + } + } + + + if(phy->in_sync == 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "***** Adjusting VNF phy_id:%d SFN/SF (%s) from %d to %d (%d) mode:%s zeroCount:%u sync:%s\n", + ind.header.phy_id, (phy->in_sync ? "via sfn" : "now"), + NFAPI_SFNSF2DEC(curr_sfn_sf), NFAPI_SFNSF2DEC(new_sfn_sf), phy->adjustment, + phy->filtered_adjust ? "FILTERED" : "ABSOLUTE", + phy->zero_count, + phy->in_sync ? "IN_SYNC" : "OUT_OF_SYNC"); + + phy->sfn_sf = new_sfn_sf; + } + } + + // reset for next cycle + phy->previous_sf_offset_filtered = phy->sf_offset_filtered; + phy->min_sync_cycle_count = 2; + phy->sf_offset_filtered = 0; + phy->sf_offset = 0; + } + else + { + phy->previous_t1 = ind.t1; + phy->previous_t2 = ind.t2; + } +} + +void vnf_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + if (pRecvMsg == NULL || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_timing_info: NULL parameters\n"); + return; + } + + nfapi_timing_info_t ind; + if(nfapi_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(nfapi_timing_info_t), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack timing_info\n"); + return; + } + + if (vnf_p7 && vnf_p7->p7_connections) + { + int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf); + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PNF:SFN/SF:%d VNF:SFN/SF:%d deltaSFNSF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind.last_sfn_sf), NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), vnf_pnf_sfnsf_delta); + if (vnf_pnf_sfnsf_delta>1 || vnf_pnf_sfnsf_delta < -1) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SF DELTA between PNF and VNF delta:%d VNF:%d PNF:%d\n\n\n\n\n\n\n\n\n", __FUNCTION__, vnf_pnf_sfnsf_delta, NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), NFAPI_SFNSF2DEC(ind.last_sfn_sf)); + } + } +} + +void vnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + nfapi_p7_message_header_t header; + + // validate the input params + if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: invalid input params\n", __FUNCTION__); + return; + } + + // unpack the message header + if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &header, sizeof(header), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n"); + return; + } + + // ensure the message is sensible + if (recvMsgLen < 8 || pRecvMsg == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen); + return; + } + + switch (header.message_id) + { + case NFAPI_UL_NODE_SYNC: + vnf_handle_ul_node_sync(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_TIMING_INFO: + vnf_handle_timing_info(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_HARQ_INDICATION: + vnf_handle_harq_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_CRC_INDICATION: + vnf_handle_crc_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_RX_ULSCH_INDICATION: + vnf_handle_rx_ulsch_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_RACH_INDICATION: + vnf_handle_rach_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_SRS_INDICATION: + vnf_handle_srs_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_RX_SR_INDICATION: + vnf_handle_rx_sr_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_RX_CQI_INDICATION: + vnf_handle_rx_cqi_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_LBT_DL_INDICATION: + vnf_handle_lbt_dl_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_NB_HARQ_INDICATION: + vnf_handle_nb_harq_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + case NFAPI_NRACH_INDICATION: + vnf_handle_nrach_indication(pRecvMsg, recvMsgLen, vnf_p7); + break; + + default: + { + if(header.message_id >= NFAPI_VENDOR_EXT_MSG_MIN && + header.message_id <= NFAPI_VENDOR_EXT_MSG_MAX) + { + vnf_handle_p7_vendor_extension(pRecvMsg, recvMsgLen, vnf_p7, header.message_id); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Unknown message ID %d\n", header.message_id); + } + } + break; + } +} + +void vnf_handle_p7_message(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) +{ + nfapi_p7_message_header_t messageHeader; + + // validate the input params + if(pRecvMsg == NULL || recvMsgLen < 4 || vnf_p7 == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "vnf_handle_p7_message: invalid input params (%d %d %d)\n", pRecvMsg, recvMsgLen, vnf_p7); + return; + } + + // unpack the message header + if (nfapi_p7_message_header_unpack(pRecvMsg, recvMsgLen, &messageHeader, sizeof(nfapi_p7_message_header_t), &vnf_p7->_public.codec_config) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n"); + return; + } + + if(vnf_p7->_public.checksum_enabled) + { + uint32_t checksum = nfapi_p7_calculate_checksum(pRecvMsg, recvMsgLen); + if(checksum != messageHeader.checksum) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Checksum verification failed %d %d msg:%d len:%d\n", checksum, messageHeader.checksum, messageHeader.message_id, recvMsgLen); + return; + } + } + + uint8_t m = NFAPI_P7_GET_MORE(messageHeader.m_segment_sequence); + uint8_t segment_num = NFAPI_P7_GET_SEGMENT(messageHeader.m_segment_sequence); + uint8_t sequence_num = NFAPI_P7_GET_SEQUENCE(messageHeader.m_segment_sequence); + + + if(m == 0 && segment_num == 0) + { + // we have a complete message + // ensure the message is sensible + if (recvMsgLen < 8 || pRecvMsg == NULL) + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "Invalid message size: %d, ignoring\n", recvMsgLen); + return; + } + + //vnf_dispatch_p7_message(&messageHeader, pRecvMsg, recvMsgLen, vnf_p7); + vnf_dispatch_p7_message(pRecvMsg, recvMsgLen, vnf_p7); + } + else + { + nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, messageHeader.phy_id); + + if(phy) + { + vnf_p7_rx_message_t* rx_msg = vnf_p7_rx_reassembly_queue_add_segment(vnf_p7, &(phy->reassembly_queue), sequence_num, segment_num, m, pRecvMsg, recvMsgLen); + + if(rx_msg->num_segments_received == rx_msg->num_segments_expected) + { + // send the buffer on + uint16_t i = 0; + uint16_t length = 0; + for(i = 0; i < rx_msg->num_segments_expected; ++i) + { + length += rx_msg->segments[i].length - (i > 0 ? NFAPI_P7_HEADER_LENGTH : 0); + } + + if(phy->reassembly_buffer_size < length) + { + vnf_p7_free(vnf_p7, phy->reassembly_buffer); + phy->reassembly_buffer = 0; + } + + if(phy->reassembly_buffer == 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "Resizing VNF_P7 Reassembly buffer %d->%d\n", phy->reassembly_buffer_size, length); + phy->reassembly_buffer = (uint8_t*)vnf_p7_malloc(vnf_p7, length); + + if(phy->reassembly_buffer == 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "Failed to allocate VNF_P7 reassemby buffer len:%d\n", length); + return; + } + + phy->reassembly_buffer_size = length; + } + + uint16_t offset = 0; + for(i = 0; i < rx_msg->num_segments_expected; ++i) + { + if(i == 0) + { + memcpy(phy->reassembly_buffer, rx_msg->segments[i].buffer, rx_msg->segments[i].length); + offset += rx_msg->segments[i].length; + } + else + { + memcpy(phy->reassembly_buffer + offset, rx_msg->segments[i].buffer + NFAPI_P7_HEADER_LENGTH, rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH); + offset += rx_msg->segments[i].length - NFAPI_P7_HEADER_LENGTH; + } + } + + + //pnf_dispatch_p7_message(pnf_p7->reassemby_buffer, length, pnf_p7, rx_msg->rx_hr_time); + vnf_dispatch_p7_message(phy->reassembly_buffer, length , vnf_p7); + + + // delete the structure + vnf_p7_rx_reassembly_queue_remove_msg(vnf_p7, &(phy->reassembly_queue), rx_msg); + } + + vnf_p7_rx_reassembly_queue_remove_old_msgs(vnf_p7, &(phy->reassembly_queue), 1000); + } + else + { + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Unknown phy id %d\n", messageHeader.phy_id); + } + } +} + +int vnf_p7_read_dispatch_message(vnf_p7_t* vnf_p7) +{ + int recvfrom_result = 0; + struct sockaddr_in remote_addr; + socklen_t remote_addr_size = sizeof(remote_addr); + + do + { + // peek the header + uint8_t header_buffer[NFAPI_P7_HEADER_LENGTH]; + recvfrom_result = recvfrom(vnf_p7->socket, header_buffer, NFAPI_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size); + + if(recvfrom_result > 0) + { + // get the segment size + nfapi_p7_message_header_t header; + if(nfapi_p7_message_header_unpack(header_buffer, NFAPI_P7_HEADER_LENGTH, &header, sizeof(header), 0) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unpack message header failed, ignoring\n"); + return -1; + } + + // resize the buffer if we have a large segment + if(header.message_length > vnf_p7->rx_message_buffer_size) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "reallocing rx buffer %d\n", header.message_length); + vnf_p7->rx_message_buffer = realloc(vnf_p7->rx_message_buffer, header.message_length); + vnf_p7->rx_message_buffer_size = header.message_length; + } + + // read the segment + recvfrom_result = recvfrom(vnf_p7->socket, vnf_p7->rx_message_buffer, header.message_length, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size); + + // todo : how to handle incomplete readfroms, need some sort of buffer/select + + if(recvfrom_result == 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom returned 0\n"); + } + else if(recvfrom_result != header.message_length) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "did not receive the entire message %d %d\n", recvfrom_result, header.message_length); + + recvfrom_result += recvfrom(vnf_p7->socket, &vnf_p7->rx_message_buffer[recvfrom_result], header.message_length - recvfrom_result, MSG_WAITALL, (struct sockaddr*)&remote_addr, &remote_addr_size); + + } + + + if(recvfrom_result > 0) + { + vnf_handle_p7_message(vnf_p7->rx_message_buffer, recvfrom_result, vnf_p7); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "recvfrom failed %d %d\n", recvfrom_result, errno); + } + } + + if(recvfrom_result == -1) + { + if(errno == EAGAIN || errno == EWOULDBLOCK) + { + // return to the select + //NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom would block :%d\n", __FUNCTION__, errno); + } + else + { + NFAPI_TRACE(NFAPI_TRACE_WARN, "%s recvfrom failed errno:%d\n", __FUNCTION__, errno); + } + } + } + while(recvfrom_result > 0); + + return 0; +} + +void vnf_p7_release_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* header) +{ + switch(header->message_id) + { + case NFAPI_HARQ_INDICATION: + { + vnf_p7_codec_free(vnf_p7, ((nfapi_harq_indication_t*)(header))->harq_indication_body.harq_pdu_list); + } + break; + case NFAPI_CRC_INDICATION: + { + vnf_p7_codec_free(vnf_p7, ((nfapi_crc_indication_t*)(header))->crc_indication_body.crc_pdu_list); + } + break; + case NFAPI_RX_ULSCH_INDICATION: + { + nfapi_rx_indication_t* rx_ind = (nfapi_rx_indication_t*)(header); + uint16_t i = 0; + for(i = 0; i < rx_ind->rx_indication_body.number_of_pdus; ++i) + { + vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list[i].data); + } + + vnf_p7_codec_free(vnf_p7, rx_ind->rx_indication_body.rx_pdu_list); + } + break; + case NFAPI_RACH_INDICATION: + { + vnf_p7_codec_free(vnf_p7, ((nfapi_rach_indication_t*)(header))->rach_indication_body.preamble_list); + } + break; + case NFAPI_SRS_INDICATION: + { + vnf_p7_codec_free(vnf_p7, ((nfapi_srs_indication_t*)(header))->srs_indication_body.srs_pdu_list); + } + break; + case NFAPI_RX_SR_INDICATION: + { + vnf_p7_codec_free(vnf_p7, ((nfapi_sr_indication_t*)(header))->sr_indication_body.sr_pdu_list); + } + break; + case NFAPI_RX_CQI_INDICATION: + { + vnf_p7_codec_free(vnf_p7, ((nfapi_cqi_indication_t*)(header))->cqi_indication_body.cqi_pdu_list); + vnf_p7_codec_free(vnf_p7, ((nfapi_cqi_indication_t*)(header))->cqi_indication_body.cqi_raw_pdu_list); + } + break; + } + + vnf_p7_free(vnf_p7, header); + +} + +void vnf_p7_release_pdu(vnf_p7_t* vnf_p7, void* pdu) +{ + vnf_p7_free(vnf_p7, pdu); +} + diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c new file mode 100644 index 0000000000000000000000000000000000000000..a35d8e3c1d1963a2927c981c58d9ac7cf0f486d8 --- /dev/null +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c @@ -0,0 +1,562 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <time.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> + +#include "vnf_p7.h" + +#define FAPI2_IP_DSCP 0 + +nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create() +{ + vnf_p7_t* _this = (vnf_p7_t*)calloc(1, sizeof(vnf_p7_t)); + + if(_this == 0) + return 0; + + // todo : initialize + _this->_public.segment_size = 1400; + _this->_public.max_num_segments = 8; + _this->_public.checksum_enabled = 1; + + _this->_public.malloc = &malloc; + _this->_public.free = &free; + + _this->_public.codec_config.allocate = &malloc; + _this->_public.codec_config.deallocate = &free; + + + return &(_this->_public); +} + +void nfapi_vnf_p7_config_destory(nfapi_vnf_p7_config_t* config) +{ + free(config); +} + + +struct timespec timespec_add(struct timespec lhs, struct timespec rhs) +{ + struct timespec result; + + result.tv_sec = lhs.tv_sec + rhs.tv_sec; + result.tv_nsec = lhs.tv_nsec + rhs.tv_nsec; + + if(result.tv_nsec > 1e9) + { + result.tv_sec++; + result.tv_nsec-= 1e9; + } + + return result; +} + +struct timespec timespec_sub(struct timespec lhs, struct timespec rhs) +{ + struct timespec result; + if ((lhs.tv_nsec-rhs.tv_nsec)<0) + { + result.tv_sec = lhs.tv_sec-rhs.tv_sec-1; + result.tv_nsec = 1000000000+lhs.tv_nsec-rhs.tv_nsec; + } + else + { + result.tv_sec = lhs.tv_sec-rhs.tv_sec; + result.tv_nsec = lhs.tv_nsec-rhs.tv_nsec; + } + return result; +} + +// monitor the p7 endpoints and the timing loop and +// send indications to mac +int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) +{ + if(config == 0) + return -1; + + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s()\n", __FUNCTION__); + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + + // Create p7 receive udp port + // todo : this needs updating for Ipv6 + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Initialising VNF P7 port:%u\n", config->port); + + // open the UDP socket + if ((vnf_p7->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After P7 socket errno: %d\n", errno); + return -1; + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 socket created...\n"); + + // configure the UDP socket options + int iptos_value = FAPI2_IP_DSCP << 2; + if (setsockopt(vnf_p7->socket, IPPROTO_IP, IP_TOS, &iptos_value, sizeof(iptos_value)) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (IP_TOS) errno: %d\n", errno); + return -1; + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 setsockopt succeeded...\n"); + + // Create the address structure + struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(config->port); + addr.sin_addr.s_addr = INADDR_ANY; + + // bind to the configured port + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 binding too %s:%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); + if (bind(vnf_p7->socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) + //if (sctp_bindx(config->socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in), 0) < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "After bind errno: %d\n", errno); + return -1; + } + + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 bind succeeded...\n"); + + + //struct timespec original_pselect_timeout; + struct timespec pselect_timeout; + pselect_timeout.tv_sec = 0; + pselect_timeout.tv_nsec = 1000000; // ns in a 1 us + + + struct timespec pselect_start; + struct timespec pselect_stop; + + //struct timespec sf_end; + + long last_millisecond = -1; + + + struct timespec sf_duration; + sf_duration.tv_sec = 0; + sf_duration.tv_nsec = 1e6; // We want 1ms pause + + struct timespec sf_start; + clock_gettime(CLOCK_MONOTONIC, &sf_start); + long millisecond = sf_start.tv_nsec / 1e6; + sf_start = timespec_add(sf_start, sf_duration); + NFAPI_TRACE(NFAPI_TRACE_INFO, "next subframe will start at %d.%d\n", sf_start.tv_sec, sf_start.tv_nsec); + + while(vnf_p7->terminate == 0) + { + fd_set rfds; + int maxSock = 0; + FD_ZERO(&rfds); + int selectRetval = 0; + + // Add the p7 socket + FD_SET(vnf_p7->socket, &rfds); + maxSock = vnf_p7->socket; + + clock_gettime(CLOCK_MONOTONIC, &pselect_start); + //long millisecond = pselect_start.tv_nsec / 1e6; + + if((last_millisecond == -1) || (millisecond == last_millisecond) || (millisecond == (last_millisecond + 1) % 1000) ) + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "pselect_start:%d.%d sf_start:%d.%d\n", pselect_start.tv_sec, pselect_start.tv_nsec, sf_start.tv_sec, sf_start.tv_nsec); + + + if((pselect_start.tv_sec > sf_start.tv_sec) || + ((pselect_start.tv_sec == sf_start.tv_sec) && (pselect_start.tv_nsec > sf_start.tv_nsec))) + { + // overran the end of the subframe we do not want to wait + pselect_timeout.tv_sec = 0; + pselect_timeout.tv_nsec = 0; + + //struct timespec overrun = timespec_sub(pselect_start, sf_start); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Subframe overrun detected of %d.%d running to catchup\n", overrun.tv_sec, overrun.tv_nsec); + } + else + { + // still time before the end of the subframe wait + pselect_timeout = timespec_sub(sf_start, pselect_start); + +#if 0 + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sf_start:%d.%ld pselect_start:%d.%ld pseclect_timeout:%d.%ld\n", + __FUNCTION__, + sf_start.tv_sec, sf_start.tv_nsec, + pselect_start.tv_sec, pselect_start.tv_nsec, + pselect_timeout.tv_sec, pselect_timeout.tv_nsec); +#endif + } + +//original_pselect_timeout = pselect_timeout; + + // detemine how long to sleep in ns before the start of the next 1ms + //pselect_timeout.tv_nsec = 1e6 - (pselect_start.tv_nsec % 1000000); + + //uint8_t underrun_possible =0; + + // if we are not sleeping until the next milisecond due to the + // insycn minor adjment flag it so we don't consider it an error + //uint8_t underrun_possible =0; + /* + { + nfapi_vnf_p7_connection_info_t* phy = vnf_p7->p7_connections; + if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0 && pselect_start.tv_nsec != 0) + { + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] Subframe minor adjustment %d (%d->%d)\n", phy->insync_minor_adjustment, + pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000)) + if(phy->insync_minor_adjustment > 0) + { + // todo check we don't go below 0 + if((phy->insync_minor_adjustment * 1000) > pselect_timeout.tv_nsec) + pselect_timeout.tv_nsec = 0; + else + pselect_timeout.tv_nsec = pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000); + + + //underrun_possible = 1; + } + else if(phy->insync_minor_adjustment < 0) + { + // todo check we don't go below 0 + pselect_timeout.tv_nsec = pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000); + } + + //phy->insync_minor_adjustment = 0; + phy->insync_minor_adjustment_duration--; + } + } + */ + + +//long wraps = pselect_timeout.tv_nsec % 1e9; + + + selectRetval = pselect(maxSock+1, &rfds, NULL, NULL, &pselect_timeout, NULL); + + clock_gettime(CLOCK_MONOTONIC, &pselect_stop); + + nfapi_vnf_p7_connection_info_t* phy = vnf_p7->p7_connections; + +if (selectRetval==-1 && errno == 22) +{ + NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", + pselect_timeout.tv_sec, pselect_timeout.tv_nsec, + phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, + sf_duration.tv_sec, sf_duration.tv_nsec); +} +#if 0 + if (selectRetval != 0 || phy->insync_minor_adjustment_duration != 0) + NFAPI_TRACE(NFAPI_TRACE_NOTE, "pselect()=%d maxSock:%d vnf_p7->socket:%d pselect_timeout:%u.%u original_pselect_timeout:%u.%u\n", + selectRetval, maxSock, vnf_p7->socket, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, + original_pselect_timeout.tv_sec, original_pselect_timeout.tv_nsec); +#endif + + if(selectRetval == 0) + { + // calculate the start of the next subframe + sf_start = timespec_add(sf_start, sf_duration); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "next subframe will start at %d.%d\n", sf_start.tv_sec, sf_start.tv_nsec); + + if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0) + { + long insync_minor_adjustment_ns = (phy->insync_minor_adjustment * 1000); + + sf_start.tv_nsec -= insync_minor_adjustment_ns; + +#if 1 + if (sf_start.tv_nsec > 1e9) + { + sf_start.tv_sec++; + sf_start.tv_nsec-=1e9; + } + else if (sf_start.tv_nsec < 0) + { + sf_start.tv_sec--; + sf_start.tv_nsec+=1e9; + } +#else + //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] BEFORE adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d\n", phy->insync_minor_adjustment, sf_start.tv_nsec); + if(phy->insync_minor_adjustment > 0) + { + // decrease the subframe duration a little + if (sf_start.tv_nsec > insync_minor_adjustment_ns) + sf_start.tv_nsec -= insync_minor_adjustment_ns; + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "[VNF] Adjustment would make it negative sf:%d.%ld adjust:%ld\n\n\n", sf_start.tv_sec, sf_start.tv_nsec, insync_minor_adjustment_ns); + sf_start.tv_sec--; + sf_start.tv_nsec += 1e9 - insync_minor_adjustment_ns; + } + } + else if(phy->insync_minor_adjustment < 0) + { + // todo check we don't go below 0 + // increase the subframe duration a little + sf_start.tv_nsec += insync_minor_adjustment_ns; + + if (sf_start.tv_nsec < 0) + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "[VNF] OVERFLOW %d.%ld\n\n\n\n", sf_start.tv_sec, sf_start.tv_nsec); + sf_start.tv_sec++; + sf_start.tv_nsec += 1e9; + } + } +#endif + + //phy->insync_minor_adjustment = 0; + phy->insync_minor_adjustment_duration--; + + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d duration:%u\n", + phy->insync_minor_adjustment, sf_start.tv_nsec, phy->insync_minor_adjustment_duration); + + if (phy->insync_minor_adjustment_duration==0) + { + phy->insync_minor_adjustment = 0; + } + } + /* + long pselect_stop_millisecond = pselect_stop.tv_nsec / 1e6; + if(millisecond == pselect_stop_millisecond) + { + // we have woke up in the same subframe + if(underrun_possible == 0) + NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe pselect underrun %ld (%d.%d)\n", millisecond, pselect_stop.tv_sec, pselect_stop.tv_nsec); + } + else if(((millisecond + 1) % 1000) != pselect_stop_millisecond) + { + // we have overrun the subframe + NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe pselect overrun %ld %ld\n", millisecond, pselect_stop_millisecond); + NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe underrun %ld\n", millisecond); + } + last_millisecond = millisecond; + */ + + millisecond ++; + } + } + else + { + // we have overrun the subframe advance to go and collect $200 + if((millisecond - last_millisecond) > 3) + NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe overrun %ld %ld (%ld)\n", millisecond, last_millisecond, millisecond - last_millisecond + 1); + + last_millisecond = ( last_millisecond + 1 ) % 1000; + selectRetval = 0; + } + + if(selectRetval == 0) + { + vnf_p7->sf_start_time_hr = vnf_get_current_time_hr(); + + // pselect timed out + nfapi_vnf_p7_connection_info_t* curr = vnf_p7->p7_connections; + + while(curr != 0) + { + curr->sfn_sf = increment_sfn_sf(curr->sfn_sf); + + vnf_sync(vnf_p7, curr); + + curr = curr->next; + } + + send_mac_subframe_indications(vnf_p7); + + } + else if(selectRetval > 0) + { + // have a p7 message + if(FD_ISSET(vnf_p7->socket, &rfds)) + { + vnf_p7_read_dispatch_message(vnf_p7); + } + } + else + { + // pselect error + if(selectRetval == -1 && errno == EINTR) + { + // a sigal was received. + } + else + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "P7 select failed result %d errno %d timeout:%d.%d orginal:%d.%d last_ms:%ld ms:%ld\n", selectRetval, errno, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, pselect_timeout.tv_sec, pselect_timeout.tv_nsec, last_millisecond, millisecond); + // should we exit now? + if (selectRetval == -1 && errno == 22) // invalid argument??? not sure about timeout duration + { + usleep(100000); + } + } + } + + } + + + NFAPI_TRACE(NFAPI_TRACE_INFO, "Closing p7 socket\n"); + close(vnf_p7->socket); + + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() returning\n", __FUNCTION__); + + return 0; +} + +int nfapi_vnf_p7_stop(nfapi_vnf_p7_config_t* config) +{ + if(config == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + vnf_p7->terminate =1; + return 0; +} + +int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, int pnf_p7_port, int phy_id) +{ + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(config:%p phy_id:%d pnf_addr:%s pnf_p7_port:%d)\n", __FUNCTION__, config, phy_id, pnf_p7_addr, pnf_p7_port); + + if(config == 0) + { + return -1; + } + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + + nfapi_vnf_p7_connection_info_t* node = (nfapi_vnf_p7_connection_info_t*)malloc(sizeof(nfapi_vnf_p7_connection_info_t)); + + memset(node, 0, sizeof(nfapi_vnf_p7_connection_info_t)); + node->phy_id = phy_id; + node->in_sync = 0; + node->dl_out_sync_offset = 30; + node->dl_out_sync_period = 10; + node->dl_in_sync_offset = 30; + node->dl_in_sync_period = 512; + node->sfn_sf = 0; + + node->min_sync_cycle_count = 8; + + // save the remote endpoint information + node->remote_addr.sin_family = AF_INET; + node->remote_addr.sin_port = htons(pnf_p7_port); + node->remote_addr.sin_addr.s_addr = inet_addr(pnf_p7_addr); + + vnf_p7_connection_info_list_add(vnf_p7, node); + + return 0; +} + +int nfapi_vnf_p7_del_pnf(nfapi_vnf_p7_config_t* config, int phy_id) +{ + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(phy_id:%d)\n", __FUNCTION__, phy_id); + + if(config == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + + nfapi_vnf_p7_connection_info_t* to_delete = vnf_p7_connection_info_list_delete(vnf_p7, phy_id); + + if(to_delete) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(phy_id:%d) deleting connection info\n", __FUNCTION__, phy_id); + free(to_delete); + } + + return 0; +} +int nfapi_vnf_p7_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_dl_config_request_t* req) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(config:%p req:%p)\n", __FUNCTION__, config, req); + + if(config == 0 || req == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header); +} + +int nfapi_vnf_p7_ul_config_req(nfapi_vnf_p7_config_t* config, nfapi_ul_config_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header); +} +int nfapi_vnf_p7_hi_dci0_req(nfapi_vnf_p7_config_t* config, nfapi_hi_dci0_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header); +} +int nfapi_vnf_p7_tx_req(nfapi_vnf_p7_config_t* config, nfapi_tx_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header); +} +int nfapi_vnf_p7_lbt_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_lbt_dl_config_request_t* req) +{ + if(config == 0 || req == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header); +} +int nfapi_vnf_p7_vendor_extension(nfapi_vnf_p7_config_t* config, nfapi_p7_message_header_t* header) +{ + if(config == 0 || header == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + return vnf_p7_pack_and_send_p7_msg(vnf_p7, header); +} + + +int nfapi_vnf_p7_release_msg(nfapi_vnf_p7_config_t* config, nfapi_p7_message_header_t* header) +{ + if(config == 0 || header == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + vnf_p7_release_msg(vnf_p7, header); + + return 0; + +} + +int nfapi_vnf_p7_release_pdu(nfapi_vnf_p7_config_t* config, void* pdu) +{ + if(config == 0 || pdu == 0) + return -1; + + vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; + vnf_p7_release_pdu(vnf_p7, pdu); + + return 0; +} diff --git a/nfapi/open-nFAPI/vnf/tests/Makefile.am b/nfapi/open-nFAPI/vnf/tests/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..0c8163102c61a1c196414d4aade3ea939bbde293 --- /dev/null +++ b/nfapi/open-nFAPI/vnf/tests/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#vnf unit test +#AUTOMAKE_OPTIONS=subdir-objects + +AM_CPPFLAGS = -I$(top_srcdir)/nfapi/inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/vnf/public_inc $(CFLAGS_CUNIT) -Wall -Werror + +check_PROGRAMS= test_vnf + +test_vnf_SOURCES = vnf_cunit_main.c ../..//common/src/debug.c +test_vnf_LDADD=$(top_builddir)/vnf/libnfapi_vnf.a $(top_builddir)/nfapi/libnfapi.a -L$(libdir) -lpthread -lrt -lsctp -lz -lcunit + +LOG_DRIVER = $(top_srcdir)/tap-driver.sh +TESTS=test_vnf +EXTRA_DIST = $(TESTS) + diff --git a/nfapi/open-nFAPI/vnf/tests/vnf_cunit_main.c b/nfapi/open-nFAPI/vnf/tests/vnf_cunit_main.c new file mode 100644 index 0000000000000000000000000000000000000000..4df5da7c261d6398cce7aaaf6c3e4d13b8a14500 --- /dev/null +++ b/nfapi/open-nFAPI/vnf/tests/vnf_cunit_main.c @@ -0,0 +1,1497 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "CUnit.h" +#include "Basic.h" +#include "Automated.h" +//#include "CUnit/Console.h" + +#include "nfapi_interface.h" +#include "nfapi_vnf_interface.h" +#include "nfapi.h" +#include <stdio.h> // for printf +#include <pthread.h> +#include <sys/time.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <netinet/sctp.h> +#include <arpa/inet.h> +#include "debug.h" +#include <unistd.h> +#include <stdlib.h> + +/* Test Suite setup and cleanup functions: */ + +int init_suite(void) { return 0; } +int clean_suite(void) { return 0; } + +#define MAX_PACKED_MESSAGE_SIZE 8192 + +#define SFNSF2SFN(_sfnsf) ((_sfnsf) >> 4) +#define SFNSF2SF(_sfnsf) ((_sfnsf) & 0xF) + +typedef struct +{ + uint8_t enabled; + uint8_t started; + uint16_t phy_id; + + int p7_rx_port; + char* p7_rx_addr; + + struct sockaddr_in p7_rx_sockaddr; + int p7_rx_sock; + + struct sockaddr_in p7_tx_sockaddr; + int p7_tx_sock; +} pnf_test_config_phy_t; + +typedef struct +{ + uint8_t enabled; + + char* vnf_p5_addr; + int vnf_p5_port; + + struct sockaddr_in p5_tx_sockaddr; + int p5_sock; + + int p7_rx_port_base; + + pnf_test_config_phy_t phys[4]; + +} pnf_test_config_t; + +pnf_test_config_t pnf_test_config[5]; + +typedef struct +{ + uint8_t enabled; + uint8_t state; + uint16_t p5_idx; + uint16_t phy_id; + + uint8_t vnf_idx; + //struct sockaddr_in p7_rx_sockaddr; + struct sockaddr_in p7_tx_sockaddr; + +} vnf_test_config_phy_t; + +typedef struct +{ + uint8_t enabled; + pthread_t thread; + + char* vnf_p7_addr; + int vnf_p7_port; + + struct sockaddr_in p7_rx_sockaddr; + + nfapi_vnf_p7_config_t* config; + + uint8_t max_phys; + uint8_t phy_count; + //uint8_t phy_ids[4]; + +} vnf_test_config_vnf_t; + +typedef struct +{ + char* p5_addr; + int p5_port; + + pthread_t thread; + + vnf_test_config_vnf_t vnfs[2]; + + uint8_t phy_count; + vnf_test_config_phy_t phys[5]; + + nfapi_vnf_config_t* p5_vnf_config; + +} vnf_test_config_t; + +vnf_test_config_t vnf_test_config[5]; + +void reset_test_configs() +{ + memset(&pnf_test_config, 0, sizeof(pnf_test_config)); + memset(&vnf_test_config, 0, sizeof(vnf_test_config)); +} + +void pnf_create_p5_sock(pnf_test_config_t* config) +{ + config->p5_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); + + config->p5_tx_sockaddr.sin_family = AF_INET; + config->p5_tx_sockaddr.sin_port = htons(config->vnf_p5_port); + config->p5_tx_sockaddr.sin_addr.s_addr = inet_addr(config->vnf_p5_addr); +} + +void pnf_p5_connect(pnf_test_config_t* config) +{ + int connect_result = connect(config->p5_sock, (struct sockaddr *)&config->p5_tx_sockaddr, sizeof(config->p5_tx_sockaddr) ); + + printf("connect_result %d %d\n", connect_result, errno); +} + +pnf_test_config_phy_t* find_pnf_phy_config(pnf_test_config_t* config, uint16_t phy_id) +{ + int i = 0; + for(i = 0; i < 4; ++i) + { + if(config->phys[i].phy_id == phy_id) + return &(config->phys[i]); + } + + return 0; +} + +vnf_test_config_phy_t* find_vnf_phy_config(vnf_test_config_t* config, uint16_t phy_id) +{ + int i = 0; + for(i = 0; i < 4; ++i) + { + if(config->phys[i].phy_id == phy_id) + return &(config->phys[i]); + } + + return 0; +} + + + + +/************* Test case functions ****************/ + + +void vnf_test_start_no_config(void) +{ + int result = nfapi_vnf_start(0); + CU_ASSERT_EQUAL(result, -1); +} + +void* vnf_test_start_thread(void* ptr) +{ + int result = nfapi_vnf_start((nfapi_vnf_config_t*)ptr); + return (void*)(intptr_t)result; +} + +int pnf_connection_indication_called = 0; +int pnf_connection_indication(nfapi_vnf_config_t* config, int p5_idx) +{ + printf("[VNF] pnf_connection_indication p5_idx:%d\n", p5_idx); + pnf_connection_indication_called++; + + nfapi_pnf_param_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_PARAM_REQUEST; + req.header.message_length = 0; + + nfapi_vnf_pnf_param_req(config, p5_idx, &req); + + return 1; +} + +int pnf_disconnect_indication(nfapi_vnf_config_t* config, int p5_idx) +{ + printf("[VNF] pnf_disconnect_indication p5_idx:%d\n", p5_idx); + pnf_connection_indication_called++; + + vnf_test_config_t* test_config = (vnf_test_config_t*)(config->user_data); + printf("[VNF] pnf_disconnect_indication user_data %p\n", config->user_data); + + int i = 0; + for(i = 0; i < test_config->phy_count; ++i) + { + vnf_test_config_phy_t* phy = &test_config->phys[i]; + vnf_test_config_vnf_t* vnf = &test_config->vnfs[phy->p5_idx]; + + // need to send stop request/response + + nfapi_vnf_p7_del_pnf((vnf->config), phy->phy_id); + vnf->phy_count--; + } + + + for(i = 0; i < 2; ++i) + { + vnf_test_config_vnf_t* vnf = &test_config->vnfs[i]; + printf("[VNF] pnf_disconnect_indication phy_count:%d\n", vnf->phy_count); + if(vnf->enabled == 1) + { + nfapi_vnf_p7_stop(vnf->config); + //vnf->config->terminate = 1; + + int* result; + printf("[VNF] waiting for vnf p7 thread to exit\n"); + pthread_join((vnf->thread), (void**)&result); + CU_ASSERT_EQUAL(result, 0); + + vnf->enabled = 0; + } + } + + return 1; +} + +int send_p5_message(int p5Sock, nfapi_p4_p5_message_header_t* msg, unsigned msg_size, struct sockaddr_in* addr, socklen_t addr_size) +{ + char buffer[256]; + int encoded_size = nfapi_p5_message_pack(msg, msg_size, buffer, sizeof(buffer), 0); + int result = sendto(p5Sock, buffer, encoded_size, 0, (struct sockaddr*)addr, addr_size); + (void)result; + return 0; +} + +int recv_p5_message(int p5Sock, nfapi_p4_p5_message_header_t* msg, unsigned msg_size) +{ + struct sockaddr_in addr2; + socklen_t addr2len; + char buffer2[256]; + int result2 = recvfrom(p5Sock, buffer2, sizeof(buffer2), 0, (struct sockaddr*)&addr2, &addr2len); + + int unpack_result = nfapi_p5_message_unpack(buffer2, result2, msg, msg_size, 0); //, sizeof(resp)); + (void)unpack_result; + return 0; +} + +int send_pnf_param_response(pnf_test_config_t* config) //int p5Sock, struct sockaddr_in* addr, socklen_t addr_size) +{ + nfapi_pnf_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_PARAM_RESPONSE; + + resp.header.message_length = 0; + resp.error_code = NFAPI_MSG_OK; + + //send_p5_message(p5Sock, &resp, sizeof(resp), addr, addr_size); + send_p5_message(config->p5_sock, &resp.header, sizeof(resp), &(config->p5_tx_sockaddr), sizeof(config->p5_tx_sockaddr)); + return 0; +} + +int create_p7_rx_socket(const char* addr, int port) +{ + int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + + struct sockaddr_in sock_addr; + sock_addr.sin_family = AF_INET; + sock_addr.sin_port = htons(port); + + if(addr == 0) + sock_addr.sin_addr.s_addr = INADDR_ANY; + else + sock_addr.sin_addr.s_addr = inet_addr(addr); + + int bind_result = bind(fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr)); + if(bind_result != 0) + { + printf("Failed to bind p7 rx socket %d(%d) to %s:%d\n", bind_result, errno, addr, port); + } + + + return fd; +} + +int create_p7_tx_socket() +{ + int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + return fd; +} + +int send_param_response(pnf_test_config_t* config, uint16_t phy_id) +{ + nfapi_param_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PARAM_RESPONSE; + resp.header.phy_id = phy_id; + + pnf_test_config_phy_t* phy = find_pnf_phy_config(config, phy_id); + + resp.error_code = NFAPI_MSG_OK; + + resp.nfapi_config.p7_pnf_port.tl.tag = NFAPI_NFAPI_P7_PNF_PORT_TAG; + resp.nfapi_config.p7_pnf_port.value = phy->p7_rx_port; + + struct sockaddr_in pnf_p7_sockaddr; + pnf_p7_sockaddr.sin_addr.s_addr = inet_addr(phy->p7_rx_addr); + + resp.nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG; + memcpy(&resp.nfapi_config.p7_pnf_address_ipv4.address[0], &pnf_p7_sockaddr.sin_addr.s_addr, 4); + + send_p5_message(config->p5_sock, &resp.header, sizeof(resp), &(config->p5_tx_sockaddr), sizeof(config->p5_tx_sockaddr)); + return 0; +} + +int receive_pnf_param_request(pnf_test_config_t* config) +{ + nfapi_pnf_param_request_t req; + recv_p5_message(config->p5_sock, &req.header, sizeof(req)); + + CU_ASSERT_EQUAL(req.header.message_id, NFAPI_PNF_PARAM_REQUEST); + if(req.header.message_id == NFAPI_PNF_PARAM_REQUEST) + { + printf("[PNF] nfapi_pnf_param_request\n"); + } + return 0; +} + +int receive_param_request(pnf_test_config_t* config) +{ + nfapi_param_request_t req; + recv_p5_message(config->p5_sock, &req.header, sizeof(req)); + + CU_ASSERT_EQUAL(req.header.message_id, NFAPI_PARAM_REQUEST); + if(req.header.message_id == NFAPI_PARAM_REQUEST) + { + printf("[PNF] nfapi_param_request phy_id:%d\n", req.header.phy_id); + } + else + { + printf("[PNF] ERROR, unexpected message %d phy_id:%d\n", req.header.message_id, req.header.phy_id); + } + return req.header.phy_id; +} + +int send_pnf_config_response(pnf_test_config_t* config) +{ + nfapi_pnf_config_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_CONFIG_RESPONSE; + resp.header.message_length = 0; + resp.error_code = NFAPI_MSG_OK; + + send_p5_message(config->p5_sock, &resp.header, sizeof(resp), &(config->p5_tx_sockaddr), sizeof(config->p5_tx_sockaddr)); + return 0; +} + +int send_config_response(pnf_test_config_t* config, uint16_t phy_id) +{ + nfapi_config_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_CONFIG_RESPONSE; + resp.header.message_length = 0; + resp.header.phy_id = phy_id; + resp.error_code = NFAPI_MSG_OK; + + send_p5_message(config->p5_sock, &resp.header, sizeof(resp), &(config->p5_tx_sockaddr), sizeof(config->p5_tx_sockaddr)); + return 0; +} + + +int receive_pnf_config_request(pnf_test_config_t* config) +{ + nfapi_pnf_config_request_t req; + recv_p5_message(config->p5_sock, &req.header, sizeof(req)); + + CU_ASSERT_EQUAL(req.header.message_id, NFAPI_PNF_CONFIG_REQUEST); + if(req.header.message_id == NFAPI_PNF_CONFIG_REQUEST) + { + printf("decoded nfapi_pnf_config_request\n"); + + int i = 0; + for(i = 0; i < req.pnf_phy_rf_config.number_phy_rf_config_info; ++i) + { + nfapi_phy_rf_config_info_t* info = &(req.pnf_phy_rf_config.phy_rf_config[i]); + printf("adding pnf phy %d id %d\n", i, info->phy_id); + + config->phys[i].enabled = 1; + config->phys[i].phy_id = info->phy_id; + } + } + return 0; +} + +int receive_config_request(pnf_test_config_t* config) +{ + nfapi_config_request_t req; + recv_p5_message(config->p5_sock, &req.header, sizeof(req)); + + CU_ASSERT_EQUAL(req.header.message_id, NFAPI_CONFIG_REQUEST); + if(req.header.message_id == NFAPI_CONFIG_REQUEST) + { + printf("[PNF] nfapi_config_request phy_id:%d\n", req.header.phy_id); + + pnf_test_config_phy_t* phy = find_pnf_phy_config(config, req.header.phy_id); + + // todo verify that this is the same as a vnf config? + phy->p7_tx_sockaddr.sin_family = AF_INET; + phy->p7_tx_sockaddr.sin_port = htons(req.nfapi_config.p7_vnf_port.value); + memcpy(&phy->p7_tx_sockaddr.sin_addr.s_addr, &req.nfapi_config.p7_vnf_address_ipv4.address, 4); + phy->p7_tx_sock = create_p7_tx_socket(); + + + printf("[PNF] vnf p7 address %s:%d\n", inet_ntoa(phy->p7_tx_sockaddr.sin_addr), ntohs(phy->p7_tx_sockaddr.sin_port)); + + return req.header.phy_id; + } + + return NFAPI_PHY_ID_NA; +} + +int send_pnf_start_response(pnf_test_config_t* config) +{ + nfapi_pnf_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_START_RESPONSE; + resp.header.message_length = 0; + resp.error_code = NFAPI_MSG_OK; + + send_p5_message(config->p5_sock, &resp.header, sizeof(resp), &(config->p5_tx_sockaddr), sizeof(config->p5_tx_sockaddr)); + return 0; +} + +int send_start_response(pnf_test_config_t* config, uint16_t phy_id) +{ + nfapi_start_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_START_RESPONSE; + resp.header.message_length = 0; + resp.header.phy_id = phy_id; + resp.error_code = NFAPI_MSG_OK; + + send_p5_message(config->p5_sock, &resp.header, sizeof(resp), &(config->p5_tx_sockaddr), sizeof(config->p5_tx_sockaddr)); + return 0; +} + +int receive_pnf_start_request(pnf_test_config_t* config) +{ + nfapi_pnf_start_request_t req; + recv_p5_message(config->p5_sock, &req.header, sizeof(req)); + + CU_ASSERT_EQUAL(req.header.message_id, NFAPI_PNF_START_REQUEST); + if(req.header.message_id == NFAPI_PNF_START_REQUEST) + { + printf("decoded nfapi_pnf_start_request\n"); + + int phy_idx = 0; + for(phy_idx = 0; phy_idx < 4; ++phy_idx) + { + if(config->phys[phy_idx].enabled) + { + pnf_test_config_phy_t* phy = &(config->phys[phy_idx]); + phy->p7_rx_port = config->p7_rx_port_base + phy_idx; + phy->p7_rx_addr = "127.0.0.1"; + } + } + } + return 0; +} + +int receive_start_request(pnf_test_config_t* config) +{ + nfapi_start_request_t req; + recv_p5_message(config->p5_sock, &req.header, sizeof(req)); + + CU_ASSERT_EQUAL(req.header.message_id, NFAPI_START_REQUEST); + if(req.header.message_id == NFAPI_START_REQUEST) + { + printf("[PNF] nfapi_start_request\n"); + + pnf_test_config_phy_t* phy = find_pnf_phy_config(config, req.header.phy_id); + printf("[PNF] creating p7 rx socket %s:%d\n", phy->p7_rx_addr, phy->p7_rx_port); + phy->p7_rx_sock = create_p7_rx_socket(phy->p7_rx_addr, phy->p7_rx_port); + phy->started = 1; + + } + + return req.header.phy_id; +} + +int send_pnf_stop_response(pnf_test_config_t* config, uint16_t phy_id) +{ + printf("pnf_stop_response\n"); + nfapi_pnf_stop_response_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_PNF_STOP_RESPONSE; + resp.header.message_length = 0; + resp.error_code = NFAPI_MSG_OK; + + send_p5_message(config->p5_sock, &resp.header, sizeof(resp), &(config->p5_tx_sockaddr), sizeof(config->p5_tx_sockaddr)); + return 0; +} + +int receive_pnf_stop_request(pnf_test_config_t* config) +{ + printf("pnf_stop_request\n"); + nfapi_pnf_stop_request_t req; + recv_p5_message(config->p5_sock, &req.header, sizeof(req)); + + CU_ASSERT_EQUAL(req.header.message_id, NFAPI_PNF_STOP_REQUEST); + if(req.header.message_id == NFAPI_PNF_STOP_REQUEST) + { + printf("decoded nfapi_pnf_stop_request\n"); + } + return 0; +} +int pnf_param_response(nfapi_vnf_config_t* config, int p5_idx,nfapi_pnf_param_response_t* response) +{ + printf("[VNF] pnf_param_response p5_idx:%d\n", p5_idx); + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + + uint16_t phy_id; + nfapi_vnf_allocate_phy(config, p5_idx, &phy_id); + + nfapi_pnf_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; + req.header.message_length = 0; + req.header.phy_id = NFAPI_PHY_ID_NA; + + req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; + req.pnf_phy_rf_config.number_phy_rf_config_info = 2; + nfapi_vnf_allocate_phy(config, p5_idx, &req.pnf_phy_rf_config.phy_rf_config[0].phy_id); + nfapi_vnf_allocate_phy(config, p5_idx, &req.pnf_phy_rf_config.phy_rf_config[1].phy_id); + + uint16_t i = vnf_test_config[0].phy_count; + + vnf_test_config[0].phys[i].enabled = 1; + vnf_test_config[0].phys[i].p5_idx = p5_idx; + vnf_test_config[0].phys[i].phy_id = req.pnf_phy_rf_config.phy_rf_config[0].phy_id; + + i++; + + vnf_test_config[0].phys[i].enabled = 1; + vnf_test_config[0].phys[i].p5_idx = p5_idx; + vnf_test_config[0].phys[i].phy_id = req.pnf_phy_rf_config.phy_rf_config[1].phy_id; + + i++; + + vnf_test_config[0].phy_count = i; + + nfapi_vnf_pnf_config_req(config, p5_idx, &req); + + return 0; +} + +int pnf_config_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* response) +{ + printf("pnf_config_response\n"); + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + + nfapi_pnf_start_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_START_REQUEST; + req.header.message_length = 0; + req.header.phy_id = response->header.phy_id; + + nfapi_vnf_pnf_start_req(config, p5_idx, &req); + + return 0; +} + + +void* vnf_test_start_p7_thread(void* ptr) +{ + int result = nfapi_vnf_p7_start((nfapi_vnf_p7_config_t*)ptr); + (void)result; + return 0; +} + +int test_subframe_indication(nfapi_vnf_p7_config_t* config, uint16_t phy_id, uint16_t sfn_sf) +{ + //printf("[VNF:%d] (%d:%d) SUBFRAME_IND\n", phy_id, SFNSF2SFN(sfn_sf), SFNSF2SF(sfn_sf)); + + nfapi_dl_config_request_t dl_config_req; + memset(&dl_config_req, 0, sizeof(dl_config_req)); + dl_config_req.header.message_id = NFAPI_DL_CONFIG_REQUEST; + dl_config_req.header.phy_id = phy_id; + dl_config_req.sfn_sf = sfn_sf; + nfapi_vnf_p7_dl_config_req(config, &dl_config_req); + + nfapi_ul_config_request_t ul_config_req; + memset(&ul_config_req, 0, sizeof(ul_config_req)); + ul_config_req.header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_config_req.header.phy_id = phy_id; + ul_config_req.sfn_sf = sfn_sf; + nfapi_vnf_p7_ul_config_req(config, &ul_config_req); + + nfapi_hi_dci0_request_t hi_dci0_req; + memset(&hi_dci0_req, 0, sizeof(hi_dci0_req)); + hi_dci0_req.header.message_id = NFAPI_HI_DCI0_REQUEST; + hi_dci0_req.header.phy_id = phy_id; + hi_dci0_req.sfn_sf = sfn_sf; + nfapi_vnf_p7_hi_dci0_req(config, &hi_dci0_req); + + + nfapi_tx_request_t tx_req; + memset(&tx_req, 0, sizeof(tx_req)); + tx_req.header.message_id = NFAPI_TX_REQUEST; + tx_req.header.phy_id = phy_id; + tx_req.sfn_sf = sfn_sf; + nfapi_vnf_p7_tx_req(config, &tx_req); + return 0; +} + +int test_harq_indication(nfapi_vnf_p7_config_t* config, nfapi_harq_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) HARQ_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} + +int test_nb_harq_indication(nfapi_vnf_p7_config_t* config, nfapi_nb_harq_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) HARQ_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} + + +int test_crc_indication(nfapi_vnf_p7_config_t* config, nfapi_crc_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) CRC_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} +int test_rx_indication(nfapi_vnf_p7_config_t* config, nfapi_rx_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) RX_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} +int test_rach_indication(nfapi_vnf_p7_config_t* config, nfapi_rach_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) RACH_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} +int test_nrach_indication(nfapi_vnf_p7_config_t* config, nfapi_nrach_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) RACH_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} +int test_srs_indication(nfapi_vnf_p7_config_t* config, nfapi_srs_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) SRS_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} +int test_sr_indication(nfapi_vnf_p7_config_t* config, nfapi_sr_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) SR_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} +int test_cqi_indication(nfapi_vnf_p7_config_t* config, nfapi_cqi_indication_t* ind) +{ + //printf("[VNF:%d] (%d:%d) CQI_IND\n", ind->header.phy_id, SFNSF2SFN(ind->sfn_sf), SFNSF2SF(ind->sfn_sf)); + return 0; +} + +int pnf_start_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* response) +{ + printf("[VNF] pnf_start_response p5_idx:%d\n", p5_idx); + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + + return 0; +} + +int pnf_stop_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_stop_response_t* response) +{ + printf("pnf_stop_response\n"); + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + + nfapi_vnf_p7_stop(vnf_test_config[0].vnfs[0].config); + return 0; +} + +int param_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* response) +{ + printf("[VNF] param_response p5_idx:%d phy_id:%d\n", p5_idx, response->header.phy_id); + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + + struct sockaddr_in addr; + memcpy(&addr.sin_addr.s_addr, &response->nfapi_config.p7_pnf_address_ipv4.address, 4); + printf("[VNF] param_response pnf p7 %s:%d\n", inet_ntoa(addr.sin_addr), response->nfapi_config.p7_pnf_port.value); + + // find the vnf phy configuration + vnf_test_config_phy_t* phy = find_vnf_phy_config(&(vnf_test_config[0]), response->header.phy_id); + + // save the pnf p7 connection information + phy->p7_tx_sockaddr.sin_port = response->nfapi_config.p7_pnf_port.value; + memcpy(&phy->p7_tx_sockaddr.sin_addr.s_addr, &response->nfapi_config.p7_pnf_address_ipv4.address, 4); + + nfapi_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_CONFIG_REQUEST; + req.header.phy_id = response->header.phy_id; + + vnf_test_config_vnf_t* vnf = &(vnf_test_config[0].vnfs[phy->vnf_idx]); + req.nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; + memcpy(&req.nfapi_config.p7_vnf_address_ipv4.address, &vnf->p7_rx_sockaddr.sin_addr.s_addr, 4); + + req.nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG; + req.nfapi_config.p7_vnf_port.value = vnf->p7_rx_sockaddr.sin_port; + + nfapi_vnf_config_req(config, p5_idx, &req); + return 0; +} + +int config_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* response) +{ + printf("[VNF] config_response p5_idx:%d phy_id:%d\n", p5_idx, response->header.phy_id); + return 0; + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + +} + +int send_vnf_start_req(vnf_test_config_t* config, vnf_test_config_phy_t* phy) +{ + nfapi_start_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_START_REQUEST; + req.header.phy_id = phy->phy_id; + + nfapi_vnf_start_req(config->p5_vnf_config, phy->p5_idx, &req); + return 0; +} + +int start_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* response) +{ + printf("[VNF] start_response p5_idx:%d phy_id:%d\n", p5_idx, response->header.phy_id); + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + + sleep(1); + + vnf_test_config_phy_t* phy = find_vnf_phy_config(&(vnf_test_config[0]), response->header.phy_id); + + char* addr = inet_ntoa(phy->p7_tx_sockaddr.sin_addr); + int port = phy->p7_tx_sockaddr.sin_port; + + vnf_test_config_vnf_t* vnf = &(vnf_test_config[0].vnfs[phy->vnf_idx]); + + nfapi_vnf_p7_add_pnf(vnf->config, addr, port, response->header.phy_id); + return 0; +} + +int stop_response(nfapi_vnf_config_t* config, int p5_idx, nfapi_stop_response_t* response) +{ + printf("stop_response p5_idx:%d phy_id:%d\n", p5_idx, response->header.phy_id); + CU_ASSERT_EQUAL(response->error_code, NFAPI_MSG_OK); + return 0; +} + +void start_vnf_p5(vnf_test_config_t* test_config) +{ + test_config->p5_vnf_config = nfapi_vnf_config_create(); + + test_config->p5_vnf_config->vnf_p5_port = test_config->p5_port; + test_config->p5_vnf_config->vnf_ipv4 = 1; + test_config->p5_vnf_config->pnf_connection_indication = &pnf_connection_indication; + test_config->p5_vnf_config->pnf_disconnect_indication = &pnf_disconnect_indication; + test_config->p5_vnf_config->pnf_param_resp = &pnf_param_response; + test_config->p5_vnf_config->pnf_config_resp = &pnf_config_response; + test_config->p5_vnf_config->pnf_start_resp = &pnf_start_response; + test_config->p5_vnf_config->pnf_stop_resp = &pnf_stop_response; + test_config->p5_vnf_config->param_resp = ¶m_response; + test_config->p5_vnf_config->config_resp = &config_response; + test_config->p5_vnf_config->start_resp = &start_response; + test_config->p5_vnf_config->stop_resp = &stop_response; + + test_config->p5_vnf_config->user_data = test_config; + + pthread_create(&test_config->thread, NULL, &vnf_test_start_thread, test_config->p5_vnf_config); + + sleep(1); + +} + +void start_vnf_p7(vnf_test_config_vnf_t* vnf) +{ + + // todo : select which vnf to use for these phy's + vnf->enabled = 1; + + vnf->p7_rx_sockaddr.sin_addr.s_addr = inet_addr(vnf->vnf_p7_addr); + vnf->p7_rx_sockaddr.sin_port = vnf->vnf_p7_port; + + + vnf->config = nfapi_vnf_p7_config_create(); + vnf->config->checksum_enabled = 0; + vnf->config->port = vnf->vnf_p7_port; + vnf->config->subframe_indication = &test_subframe_indication; + vnf->config->harq_indication = &test_harq_indication; + vnf->config->crc_indication = &test_crc_indication; + vnf->config->rx_indication = &test_rx_indication; + vnf->config->rach_indication = &test_rach_indication; + vnf->config->srs_indication = &test_srs_indication; + vnf->config->sr_indication = &test_sr_indication; + vnf->config->cqi_indication = &test_cqi_indication; + + vnf->config->nb_harq_indication = &test_nb_harq_indication; + vnf->config->nrach_indication = &test_nrach_indication; + + + vnf->config->segment_size = 1400; + vnf->config->max_num_segments = 6; + + pthread_create(&(vnf->thread), NULL, &vnf_test_start_p7_thread, vnf->config); + + vnf->enabled = 1; + + //vnf->phy_count++; + + sleep(1); +} + +void send_p7_segmented_msg(int sock, char* msg, int len, int segment_size, struct sockaddr* addr, socklen_t addr_len) +{ + static uint8_t sequence_num = 0; + if(len < segment_size) + { + msg[7] = sequence_num; + sendto(sock, msg, len, 0, addr, addr_len); + } + else + { + int msg_body_len = len - 12 ; + int seg_body_len = segment_size - 12 ; + int segments = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0); + + //printf("sending segmented message len:%d seg_size:%d count:%d\n", len, segment_size, segments); + + int segment = 0; + int offset = 12; + for(segment = 0; segment < segments; ++segment) + { + uint8_t last = 0; + uint16_t size = segment_size - 12; + if(segment + 1 == segments) + { + last = 1; + size = (msg_body_len) - (seg_body_len * segment); + } + + char buffer[segment_size]; + + memcpy(&buffer[0], msg, 12); + buffer[6] = ((!last) << 7) + segment; + buffer[7] = sequence_num; + + // msg length + uint8_t* p = (uint8_t*)&buffer[4]; + push16(size + 12, &p, (uint8_t*)&buffer[size + 12]); + + memcpy(&buffer[12], msg + offset, size); + offset += size; + + sendto(sock, &buffer[0], size + 12, 0, addr, addr_len); + + } + + + } + + sequence_num++; +} + +void start_phy(vnf_test_config_phy_t* phy) +{ + + nfapi_param_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PARAM_REQUEST; + req.header.phy_id = phy->phy_id; + + nfapi_vnf_config_t* p5_vnf_config = (vnf_test_config[0].p5_vnf_config); + + + nfapi_vnf_param_req(p5_vnf_config, phy->p5_idx, &req); + +} + + +void vnf_test_start_connect(void) +{ + reset_test_configs(); + + int segment_size = 256; + + vnf_test_config[0].p5_addr = "127.0.0.1"; + vnf_test_config[0].p5_port = 4242; + + vnf_test_config[0].vnfs[0].enabled = 0; + vnf_test_config[0].vnfs[0].vnf_p7_addr = "127.0.0.1"; + vnf_test_config[0].vnfs[0].vnf_p7_port = 7878; + vnf_test_config[0].vnfs[0].max_phys = 1; + + vnf_test_config[0].vnfs[1].enabled = 0; + vnf_test_config[0].vnfs[1].vnf_p7_addr = "127.0.0.1"; + vnf_test_config[0].vnfs[1].vnf_p7_port = 7879; + vnf_test_config[0].vnfs[1].max_phys = 1; + + + // this is the action that p9 would take to set the vnf p5 address/port + pnf_test_config[0].enabled = 1; + pnf_test_config[0].vnf_p5_port = vnf_test_config[0].p5_port; + pnf_test_config[0].vnf_p5_addr = vnf_test_config[0].p5_addr; + pnf_test_config[0].p7_rx_port_base = 8000; + + pnf_test_config[1].enabled = 1; + pnf_test_config[1].vnf_p5_port = vnf_test_config[0].p5_port; + pnf_test_config[1].vnf_p5_addr = vnf_test_config[0].p5_addr; + pnf_test_config[1].p7_rx_port_base = 8100; + + pnf_connection_indication_called = 0; + + start_vnf_p5(&vnf_test_config[0]); + + + pnf_create_p5_sock(&pnf_test_config[0]); + pnf_p5_connect(&pnf_test_config[0]); + + receive_pnf_param_request(&pnf_test_config[0]); + send_pnf_param_response(&pnf_test_config[0]); + + receive_pnf_config_request(&pnf_test_config[0]); + send_pnf_config_response(&pnf_test_config[0]); + + receive_pnf_start_request(&pnf_test_config[0]); + send_pnf_start_response(&pnf_test_config[0]); + + pnf_create_p5_sock(&pnf_test_config[1]); + + pnf_p5_connect(&pnf_test_config[1]); + + receive_pnf_param_request(&pnf_test_config[1]); + send_pnf_param_response(&pnf_test_config[1]); + + receive_pnf_config_request(&pnf_test_config[1]); + send_pnf_config_response(&pnf_test_config[1]); + + receive_pnf_start_request(&pnf_test_config[1]); + send_pnf_start_response(&pnf_test_config[1]); + + // start the vnf_p7 thread and assign by phys to that instance + + start_vnf_p7(&vnf_test_config[0].vnfs[0]); + //start_vnf_p7(&vnf_test_config[0].vnfs[1]); + + printf("---- configuring phy %d -----\n", vnf_test_config[0].phys[0].phy_id); + vnf_test_config[0].phys[0].vnf_idx = 0; + start_phy(&vnf_test_config[0].phys[0]); + + int phy_id = receive_param_request(&pnf_test_config[0]); + send_param_response(&pnf_test_config[0], phy_id); + + phy_id = receive_config_request(&pnf_test_config[0]); + send_config_response(&pnf_test_config[0], phy_id); + + printf("---- configuring phy %d -----\n", vnf_test_config[0].phys[2].phy_id); + vnf_test_config[0].phys[2].vnf_idx = 0; + start_phy(&vnf_test_config[0].phys[2]); + + phy_id = receive_param_request(&pnf_test_config[1]); + send_param_response(&pnf_test_config[1], phy_id); + + phy_id = receive_config_request(&pnf_test_config[1]); + send_config_response(&pnf_test_config[1], phy_id); + + printf("---- configuring phy %d -----\n", vnf_test_config[0].phys[1].phy_id); + + vnf_test_config[0].phys[1].vnf_idx = 0; + start_phy(&vnf_test_config[0].phys[1]); + + phy_id = receive_param_request(&pnf_test_config[0]); + send_param_response(&pnf_test_config[0], phy_id); + + phy_id = receive_config_request(&pnf_test_config[0]); + send_config_response(&pnf_test_config[0], phy_id); + + //------------- + printf("---- starting phy %d -----\n", vnf_test_config[0].phys[0].phy_id); + + send_vnf_start_req(&vnf_test_config[0], &vnf_test_config[0].phys[0]); + phy_id = receive_start_request(&pnf_test_config[0]); + send_start_response(&pnf_test_config[0], phy_id); +/* + printf("---- starting phy %d -----\n", vnf_test_config[0].phys[2].phy_id); + + send_vnf_start_req(&vnf_test_config[0], &vnf_test_config[0].phys[2]); + phy_id = receive_start_request(&pnf_test_config[1]); + send_start_response(&pnf_test_config[1], phy_id); + + printf("---- starting phy %d -----\n", vnf_test_config[0].phys[1].phy_id); + + send_vnf_start_req(&vnf_test_config[0], &vnf_test_config[0].phys[1]); + phy_id = receive_start_request(&pnf_test_config[0]); + send_start_response(&pnf_test_config[0], phy_id); +*/ + //close(pnf_test_config[0].p5_sock); + + char buffer[2048]; + int buffer_size = sizeof(buffer); + + + fd_set rdfs; + int exit = 0; + while(exit != 1) + { + int pnf_idx, phy_idx; + int max_fd = 0; + FD_ZERO(&rdfs); + + for(pnf_idx = 0; pnf_idx < 4; ++pnf_idx) + { + if(pnf_test_config[pnf_idx].enabled) + { + FD_SET(pnf_test_config[pnf_idx].p5_sock, &rdfs); + if(pnf_test_config[pnf_idx].p5_sock > max_fd) + max_fd = pnf_test_config[pnf_idx].p5_sock; + } + + for(phy_idx = 0; phy_idx < 4; ++phy_idx) + { + pnf_test_config_phy_t* phy_info = &(pnf_test_config[pnf_idx].phys[phy_idx]); + + if(phy_info->started == 1 && phy_info->enabled == 1) + { + //////////////////printf("adding %d/%d %d %d\n", pnf_idx, phy_idx, phy_info->phy_id, phy_info->p7_rx_sock); + FD_SET(phy_info->p7_rx_sock, &rdfs); + if(phy_info->p7_rx_sock > max_fd) + max_fd = phy_info->p7_rx_sock; + } + } + } + + + // changed to select, + int select_result = select(max_fd + 1, &rdfs, NULL, NULL, NULL); + (void)select_result; + + for(pnf_idx = 0; pnf_idx < 4; ++pnf_idx) + { + if(pnf_test_config[pnf_idx].enabled) + { + //pnf_test_config_t* pnf_config = &(pnf_test_config[pnf_idx]); + } + + for(phy_idx = 0; phy_idx < 4; ++phy_idx) + { + pnf_test_config_phy_t* phy_info = &(pnf_test_config[pnf_idx].phys[phy_idx]); + + if(phy_info->enabled) + { + if(FD_ISSET(phy_info->p7_rx_sock, &rdfs)) + { + //struct sockaddr_in recv_addr; + //memset(&recv_addr, 0, sizeof(recv_addr)); + //socklen_t recv_addr_size; + int len = recvfrom(phy_info->p7_rx_sock, &buffer[0], buffer_size, 0, 0, 0);// (struct sockaddr*)&recv_addr, &recv_addr_size); + + if(len == -1) + { + printf("recvfrom %d failed %d\n", phy_info->p7_rx_sock, errno); + continue; + } + + nfapi_p7_message_header_t header; + nfapi_p7_message_header_unpack(buffer, len, &header, sizeof(header), 0); + + switch(header.message_id) + { + case NFAPI_DL_NODE_SYNC: + { + nfapi_dl_node_sync_t msg; + nfapi_p7_message_unpack(buffer, len, &msg, sizeof(msg), 0); + printf("[PNF:%d] NFAPI_DL_NODE_SYNC t1:%d\n", msg.header.phy_id, msg.t1); + + nfapi_ul_node_sync_t resp; + memset(&resp, 0, sizeof(resp)); + resp.header.message_id = NFAPI_UL_NODE_SYNC; + resp.header.phy_id = msg.header.phy_id; + resp.t1 = msg.t1; + usleep(50); + resp.t2 = msg.t1 + 50; // 50 us rx latency + resp.t3 = msg.t1 + 10; // 10 us pnf proc + + usleep(50); + + len = nfapi_p7_message_pack(&resp, buffer, buffer_size, 0); + // send ul node sycn + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + } + break; + case NFAPI_DL_CONFIG_REQUEST: + { + nfapi_dl_config_request_t msg; + nfapi_p7_message_unpack(buffer, len, &msg, sizeof(msg), 0); + //printf("[PNF:%d] (%d/%d) NFAPI_DL_CONFIG_REQUEST\n", header.phy_id, SFNSF2SFN(msg.sfn_sf), SFNSF2SF(msg.sfn_sf)); + + if(SFNSF2SFN(msg.sfn_sf) == 500) + exit = 1; + // simulate the uplink messages + + nfapi_harq_indication_t harq_ind; + memset(&harq_ind, 0, sizeof(harq_ind)); + harq_ind.header.message_id = NFAPI_HARQ_INDICATION; + harq_ind.header.phy_id = msg.header.phy_id; + harq_ind.sfn_sf = msg.sfn_sf; + harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + harq_ind.harq_indication_body.number_of_harqs = 2; + + harq_ind.harq_indication_body.harq_pdu_list = (nfapi_harq_indication_pdu_t*)(malloc(sizeof(nfapi_harq_indication_pdu_t) * harq_ind.harq_indication_body.number_of_harqs)); + + int i = 0; + for(i = 0; i < harq_ind.harq_indication_body.number_of_harqs; ++i) + { + harq_ind.harq_indication_body.harq_pdu_list[i].rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + } + len = nfapi_p7_message_pack(&harq_ind, buffer, buffer_size, 0); + //sendto(phy_info->p7_tx_sock, &buffer[0], len, 0, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + + + //sendto(phy_info->p7_tx_sock, &buffer[0], len, 0, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + free(harq_ind.harq_indication_body.harq_pdu_list); + + nfapi_crc_indication_t crc_ind; + memset(&crc_ind, 0, sizeof(crc_ind)); + crc_ind.header.message_id = NFAPI_CRC_INDICATION; + crc_ind.header.phy_id = msg.header.phy_id; + crc_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&crc_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + nfapi_sr_indication_t sr_ind; + memset(&sr_ind, 0, sizeof(sr_ind)); + sr_ind.header.message_id = NFAPI_RX_SR_INDICATION; + sr_ind.header.phy_id = msg.header.phy_id; + sr_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&sr_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + nfapi_cqi_indication_t cqi_ind; + memset(&cqi_ind, 0, sizeof(cqi_ind)); + cqi_ind.header.message_id = NFAPI_RX_CQI_INDICATION; + cqi_ind.header.phy_id = msg.header.phy_id; + cqi_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&cqi_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + nfapi_rach_indication_t rach_ind; + memset(&rach_ind, 0, sizeof(rach_ind)); + rach_ind.header.message_id = NFAPI_RACH_INDICATION; + rach_ind.header.phy_id = msg.header.phy_id; + rach_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&rach_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + nfapi_srs_indication_t srs_ind; + memset(&srs_ind, 0, sizeof(srs_ind)); + srs_ind.header.message_id = NFAPI_SRS_INDICATION; + srs_ind.header.phy_id = msg.header.phy_id; + srs_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&srs_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + nfapi_rx_indication_t rx_ind; + memset(&rx_ind, 0, sizeof(rx_ind)); + rx_ind.header.message_id = NFAPI_RX_ULSCH_INDICATION; + rx_ind.header.phy_id = msg.header.phy_id; + rx_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&rx_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + if(msg.sfn_sf % 5 == 0) + { + // periodically send the timing info + nfapi_timing_info_t timing_info; + memset(&timing_info, 0, sizeof(timing_info)); + timing_info.header.message_id = NFAPI_TIMING_INFO; + timing_info.header.phy_id = msg.header.phy_id; + len = nfapi_p7_message_pack(&timing_info, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + } + + nfapi_nb_harq_indication_t nb_harq_ind; + memset(&nb_harq_ind, 0, sizeof(nb_harq_ind)); + nb_harq_ind.header.message_id = NFAPI_NB_HARQ_INDICATION; + nb_harq_ind.header.phy_id = msg.header.phy_id; + nb_harq_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&nb_harq_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + nfapi_nrach_indication_t nrach_ind; + memset(&nrach_ind, 0, sizeof(nrach_ind)); + nrach_ind.header.message_id = NFAPI_NRACH_INDICATION; + nrach_ind.header.phy_id = msg.header.phy_id; + nrach_ind.sfn_sf = msg.sfn_sf; + len = nfapi_p7_message_pack(&nrach_ind, buffer, buffer_size, 0); + send_p7_segmented_msg(phy_info->p7_tx_sock, &buffer[0], len, segment_size, (struct sockaddr*)&phy_info->p7_tx_sockaddr, sizeof(phy_info->p7_tx_sockaddr)); + + } + break; + case NFAPI_UL_CONFIG_REQUEST: + { + nfapi_ul_config_request_t msg; + nfapi_p7_message_unpack(buffer, len, &msg, sizeof(msg), 0); + //printf("[PNF:%d] (%d/%d) NFAPI_UL_CONFIG_REQUEST\n", header.phy_id, SFNSF2SFN(msg.sfn_sf), SFNSF2SF(msg.sfn_sf)); + } + break; + case NFAPI_HI_DCI0_REQUEST: + { + nfapi_hi_dci0_request_t msg; + nfapi_p7_message_unpack(buffer, len, &msg, sizeof(msg), 0); + //printf("[PNF:%d] (%d/%d) NFAPI_HI_DCI0_REQUEST\n", header.phy_id, SFNSF2SFN(msg.sfn_sf), SFNSF2SF(msg.sfn_sf)); + } + break; + case NFAPI_TX_REQUEST: + { + nfapi_tx_request_t msg; + nfapi_p7_message_unpack(buffer, len, &msg, sizeof(msg), 0); + //printf("[PNF:%d] (%d/%d) NFAPI_TX_REQUEST\n", header.phy_id, SFNSF2SFN(msg.sfn_sf), SFNSF2SF(msg.sfn_sf)); + } + break; + } + + } + } + } + } + } + + printf("Triggering p5 shutdown\n"); + + // vnf p5 trigger shutdown + nfapi_pnf_stop_request_t stop_req; + memset(&stop_req, 0, sizeof(stop_req)); + stop_req.header.message_id = NFAPI_PNF_STOP_REQUEST; + nfapi_vnf_pnf_stop_req(vnf_test_config[0].p5_vnf_config, 0, &stop_req); + + phy_id = receive_pnf_stop_request(&pnf_test_config[0]); + send_pnf_stop_response(&pnf_test_config[0], phy_id); + + + nfapi_vnf_stop(vnf_test_config[0].p5_vnf_config); + + + + int* result; + pthread_join((vnf_test_config[0].thread), (void**)&result); + CU_ASSERT_EQUAL(result, 0); + //CU_ASSERT_EQUAL(pnf_connection_indication_called, 1); + + + close(pnf_test_config[0].p5_sock); +} + +void vnf_test_start_connect_ipv6(void) +{ + char* vnf_addr = "::1"; + int vnf_port = 4242; + pnf_connection_indication_called = 0; + + nfapi_vnf_config_t* config = nfapi_vnf_config_create(); + config->vnf_p5_port = vnf_port; + config->vnf_ipv4 = 0; + config->vnf_ipv6 = 1; + config->pnf_connection_indication = &pnf_connection_indication; + config->pnf_disconnect_indication = &pnf_disconnect_indication; + config->pnf_param_resp = &pnf_param_response; + config->pnf_config_resp = &pnf_config_response; + config->pnf_start_resp = &pnf_start_response; + + pthread_t thread; + pthread_create(&thread, NULL, &vnf_test_start_thread, config); + + sleep(1); + + + int p5Sock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); + + struct sockaddr_in6 addr; + addr.sin6_family = AF_INET6; + addr.sin6_port = htons(vnf_port); + //addr.sin6_addr = inet_addr(vnf_addr); + inet_pton(AF_INET6, vnf_addr, &addr.sin6_addr); + + + /* + int connect_result = connect(p5Sock, (struct sockaddr *)&addr, sizeof(addr) ); + + printf("connect_result %d %d\n", connect_result, errno); + + receive_pnf_param_request(p5Sock); + send_pnf_param_response(p5Sock, &addr, sizeof(addr)); + + receive_pnf_config_request(p5Sock); + send_pnf_config_response(p5Sock, &addr, sizeof(addr)); + + receive_pnf_start_request(p5Sock); + send_pnf_start_response(p5Sock, &addr, sizeof(addr)); + */ + sleep(4); + nfapi_vnf_stop(config); + + int* result; + pthread_join(thread, (void**)&result); + CU_ASSERT_EQUAL(result, 0); + CU_ASSERT_EQUAL(pnf_connection_indication_called, 1); + + + close(p5Sock); +} +void vnf_test_start_connect_2(void) +{ + char* vnf_addr = "127.0.0.1"; + int vnf_port = 4242; + pnf_connection_indication_called = 0; + + nfapi_vnf_config_t * config = nfapi_vnf_config_create(); + config->vnf_p5_port = vnf_port; + config->pnf_connection_indication = &pnf_connection_indication; + + pthread_t thread; + pthread_create(&thread, NULL, &vnf_test_start_thread, config); + + sleep(1); + + + + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(vnf_port); + addr.sin_addr.s_addr = inet_addr(vnf_addr); + + + int p5Sock1 = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); + + int connect_result_1 = connect(p5Sock1, (struct sockaddr *)&addr, sizeof(addr) ); + + printf("connect_result_1 %d %d\n", connect_result_1, errno); + + int p5Sock2 = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); + + int connect_result_2 = connect(p5Sock2, (struct sockaddr *)&addr, sizeof(addr) ); + + printf("connect_result_2 %d %d\n", connect_result_2, errno); + + sleep(1); + + close(p5Sock1); + + sleep(1); + + close(p5Sock2); + + sleep(1); + + nfapi_vnf_stop(config); + + int* result; + pthread_join(thread, (void**)&result); + CU_ASSERT_EQUAL(result, 0); + CU_ASSERT_EQUAL(pnf_connection_indication_called, 2); + + + close(p5Sock1); + close(p5Sock2); +} + +void vnf_test_p7_segmentation_test1(void) +{ + +} + + +/************* Test Runner Code goes here **************/ + +int main ( void ) +{ + CU_pSuite pSuite = NULL; + + /* initialize the CUnit test registry */ + if ( CUE_SUCCESS != CU_initialize_registry() ) + return CU_get_error(); + + /* add a suite to the registry */ + pSuite = CU_add_suite( "vnf_test_suite", init_suite, clean_suite ); + if ( NULL == pSuite ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + //(NULL == CU_add_test(pSuite, "vnf_test_start_connect_2", vnf_test_start_connect_2)) + /* add the tests to the suite */ + if ( (NULL == CU_add_test(pSuite, "vnf_test_start_no_config", vnf_test_start_no_config)) || + (NULL == CU_add_test(pSuite, "vnf_test_start_connect", vnf_test_start_connect)) || + (NULL == CU_add_test(pSuite, "vnf_test_p7_segmentation_test1", vnf_test_p7_segmentation_test1)) + ) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + // Run all tests using the basic interface + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_set_output_filename("vnf_unit_test_results.xml"); + CU_basic_run_tests(); + + CU_pSuite s = CU_get_registry()->pSuite; + int count = 0; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + count++; + t = t->pNext; + } + s = s->pNext; + } + + printf("%d..%d\n", 1, count); + + + + s = CU_get_registry()->pSuite; + count = 1; + while(s) + { + CU_pTest t = s->pTest; + while(t) + { + int pass = 1; + CU_FailureRecord* failures = CU_get_failure_list(); + while(failures) + { + if(strcmp(failures->pSuite->pName, s->pName) == 0 && + strcmp(failures->pTest->pName, t->pName) == 0) + { + pass = 0; + failures = 0; + } + else + { + failures = failures->pNext; + } + } + + if(pass) + printf("ok %d - %s:%s\n", count, s->pName, t->pName); + else + printf("not ok %d - %s:%s\n", count, s->pName, t->pName); + + count++; + t = t->pNext; + } + s = s->pNext; + } + + CU_cleanup_registry(); + return CU_get_error(); + +} diff --git a/nfapi/open-nFAPI/vnf_sim/Makefile.am b/nfapi/open-nFAPI/vnf_sim/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..c3e42cebf35fcb6d3744c5953a0c3f0daee0acb6 --- /dev/null +++ b/nfapi/open-nFAPI/vnf_sim/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2017 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +AUTOMAKE_OPTIONS=subdir-objects +AM_CPPFLAGS = -I$(top_srcdir)/vnf_sim/inc -I$(top_srcdir)/sim_common/inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/nfapi/inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/vnf/inc -I$(top_srcdir)/vnf/public_inc $(XML_CFLAGS) -Wall -Werror -g +AM_CXXFLAGS = -I$(top_srcidr)/vnf_sim/inc -I$(top_srcdir)/sim_common/inc -I$(top_srcdir)/common/public_inc -I$(top_srcdir)/nfapi/inc -I$(top_srcdir)/nfapi/public_inc -I$(top_srcdir)/vnf/inc -I$(top_srcdir)/vnf/public_inc $(XML_CFLAGS) -std=c++11 $(BOOST_CPPFLAGS) -g +bin_PROGRAMS = vnfsim +vnfsim_SOURCES = src/main.cpp src/mac.cpp +LDADD= $(top_builddir)/vnf/libnfapi_vnf.a $(top_builddir)/common/libnfapi_common.a $(top_builddir)/nfapi/libnfapi.a $(top_builddir)/sim_common/libnfapi_sim_common.a -L$(libdir) -lpthread -lrt -lsctp -lz diff --git a/nfapi/open-nFAPI/vnf_sim/inc/mac.h b/nfapi/open-nFAPI/vnf_sim/inc/mac.h new file mode 100644 index 0000000000000000000000000000000000000000..eac5b3b2ac5a854d9afb72462c3ed2c86a52a1b9 --- /dev/null +++ b/nfapi/open-nFAPI/vnf_sim/inc/mac.h @@ -0,0 +1,60 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MAC_H_ +#define _MAC_H_ + +#include "nfapi_interface.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +typedef struct mac mac_t; + +typedef struct mac +{ + void* user_data; + + void (*dl_config_req)(mac_t* mac, nfapi_dl_config_request_t* req); + void (*ul_config_req)(mac_t* mac, nfapi_ul_config_request_t* req); + void (*hi_dci0_req)(mac_t* mac, nfapi_hi_dci0_request_t* req); + void (*tx_req)(mac_t* mac, nfapi_tx_request_t* req); +} mac_t; + +mac_t* mac_create(uint8_t wireshark_test_mode); +void mac_destroy(mac_t* mac); + +void mac_start_data(mac_t* mac, unsigned rx_port, const char* tx_addres, unsigned tx_port); + +void mac_subframe_ind(mac_t* mac, uint16_t phy_id, uint16_t sfn_sf); +void mac_harq_ind(mac_t* mac, nfapi_harq_indication_t* ind); +void mac_crc_ind(mac_t* mac, nfapi_crc_indication_t* ind); +void mac_rx_ind(mac_t* mac, nfapi_rx_indication_t* ind); +void mac_rach_ind(mac_t* mac, nfapi_rach_indication_t* ind); +void mac_srs_ind(mac_t* mac, nfapi_srs_indication_t* ind); +void mac_sr_ind(mac_t* mac, nfapi_sr_indication_t* ind); +void mac_cqi_ind(mac_t* mac, nfapi_cqi_indication_t* ind); +void mac_lbt_dl_ind(mac_t* mac, nfapi_lbt_dl_indication_t* ind); +void mac_nb_harq_ind(mac_t* mac, nfapi_nb_harq_indication_t* ind); +void mac_nrach_ind(mac_t* mac, nfapi_nrach_indication_t* ind); + + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/nfapi/open-nFAPI/vnf_sim/src/mac.cpp b/nfapi/open-nFAPI/vnf_sim/src/mac.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fa6f487be8e2274d55ac10c69b238070abfea6f6 --- /dev/null +++ b/nfapi/open-nFAPI/vnf_sim/src/mac.cpp @@ -0,0 +1,1327 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mac.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <vendor_ext.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <ifaddrs.h> +#include <netdb.h> +#include <pthread.h> +#include <unistd.h> + +#include <mutex> +#include <queue> +#include <list> + +uint32_t rand_range(uint32_t min, uint32_t max) +{ + return ((rand() % (max + 1 - min)) + min); +} + +struct mac_pdu +{ + mac_pdu() : buffer_len(1500), buffer(0), len(0) + { + buffer = (char*) malloc(buffer_len); + } + + virtual ~mac_pdu() + { + free(buffer); + } + + unsigned buffer_len; + char* buffer; + unsigned len; +}; + +class mac_private +{ + std::mutex mutex; + std::queue<mac_pdu*> rx_buffer; + + std::queue<mac_pdu*> free_store; + public: + + mac_private(bool _wireshark_test_mode) + : byte_count(0), tick(0), wireshark_test_mode(_wireshark_test_mode) + { + + } + + mac_pdu* allocate_mac_pdu() + { + mac_pdu* pdu = 0; + mutex.lock(); + if(free_store.empty()) + { + pdu = new mac_pdu(); + } + else + { + pdu = free_store.front(); + free_store.pop(); + } + mutex.unlock(); + return pdu; + } + + void release_mac_pdu(mac_pdu* pdu) + { + mutex.lock(); + free_store.push(pdu); + mutex.unlock(); + } + + + + void push_rx_buffer(mac_pdu* buff) + { + mutex.lock(); + rx_buffer.push(buff); + mutex.unlock(); + } + + mac_pdu* pop_rx_buffer() + { + mac_pdu* buff = 0; + mutex.lock(); + if(!rx_buffer.empty()) + { + buff = rx_buffer.front(); + rx_buffer.pop(); + } + mutex.unlock(); + return buff; + } + + uint32_t byte_count; + uint32_t tick; + + bool wireshark_test_mode; + +}; + +extern "C" +{ + typedef struct { + mac_t _public; + + int rx_sock; + int tx_sock; + struct sockaddr_in tx_addr; + + uint32_t tx_byte_count; + + mac_private* mac; + + } mac_internal_t; + + mac_t* mac_create(uint8_t wireshark_test_mode) + { + mac_internal_t* instance = (mac_internal_t*)malloc(sizeof(mac_internal_t)); + instance->mac = new mac_private((wireshark_test_mode >= 1)); + return (mac_t*)instance; + } + + void mac_destroy(mac_t* mac) + { + mac_internal_t* instance = (mac_internal_t*)mac; + delete instance->mac; + free(instance); + } + + void* mac_rx_thread_start(void* ptr) + { + mac_internal_t* instance = (mac_internal_t*)ptr; + + while(1) + { + mac_pdu* pdu = instance->mac->allocate_mac_pdu(); + int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, 0, 0, 0); + if(len > 0) + { + pdu->len = len; + instance->mac->push_rx_buffer(pdu); + } + else + { + instance->mac->release_mac_pdu(pdu); + } + } + return 0; + } + + void mac_start_data(mac_t* mac, unsigned rx_port, const char* tx_address, unsigned tx_port) + { + mac_internal_t* instance = (mac_internal_t*)mac; + + printf("[MAC] Rx Data from %d\n", rx_port); + printf("[MAC] Tx Data to %s.%d\n", tx_address, tx_port); + + instance->rx_sock = socket(AF_INET, SOCK_DGRAM, 0); + + if(instance->rx_sock < 0) + { + printf("[MAC] Failed to create socket\n"); + return; + } + + struct sockaddr_in addr; + memset(&addr, 0, sizeof(0)); + addr.sin_family = AF_INET; + addr.sin_port = htons(rx_port); + addr.sin_addr.s_addr = INADDR_ANY; + + if(bind(instance->rx_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) + { + printf("[MAC] Failed to bind to %d\n", rx_port); + close(instance->rx_sock); + return; + } + + pthread_t mac_rx_thread; + pthread_create(&mac_rx_thread, NULL, &mac_rx_thread_start, instance); + + instance->tx_sock = socket(AF_INET, SOCK_DGRAM, 0); + instance->tx_addr.sin_family = AF_INET; + instance->tx_addr.sin_port = htons(tx_port); + instance->tx_addr.sin_addr.s_addr = inet_addr(tx_address); + } + + + + void generate_test_subframe(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf) + { + //mac_internal_t* instance = (mac_internal_t*)mac; + + uint8_t max_num_dl_pdus = 50; + nfapi_dl_config_request_pdu_t dl_config_pdus[max_num_dl_pdus]; + memset(&dl_config_pdus, 0, sizeof(dl_config_pdus)); + + nfapi_dl_config_request_t dl_config_req; + memset(&dl_config_req, 0, sizeof(dl_config_req)); + dl_config_req.header.message_id = NFAPI_DL_CONFIG_REQUEST; + dl_config_req.header.phy_id = phy_id; + dl_config_req.sfn_sf = sfn_sf; + dl_config_req.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + dl_config_req.dl_config_request_body.number_pdu = rand_range(4, max_num_dl_pdus); + + uint16_t i = 0; + for(i = 0; i < dl_config_req.dl_config_request_body.number_pdu; ++i) + { + dl_config_pdus[i].pdu_type = rand_range(0, 11); + + switch(dl_config_pdus[i].pdu_type) + { + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: + { + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.dci_format = rand_range(0, 9); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx = rand_range(0, 255); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = rand_range(0, 32); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti = rand_range(0, (uint16_t)-1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = rand_range(0, 320000); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = rand_range(0, 31); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = rand_range(0, 3); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = rand_range(0, 31); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = rand_range(0, 31); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_2 = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.harq_process = rand_range(0, 31); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tpmi = rand_range(0, 15); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.pmi = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.precoding_information = rand_range(0, 63); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tpc = rand_range(0, 3); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = rand_range(0, 15); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.ngap = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_size_index = rand_range(0, 31); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.downlink_power_offset = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.allocate_prach_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.preamble_index = rand_range(0, 63); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.prach_mask_index = rand_range(0, 15); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = rand_range(0, 3); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = rand_range(0, 10000); + + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.mcch_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.mcch_change_notification = rand_range(0, 255); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.scrambling_identity = rand_range(0, 1); + + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.carrier_indicator = rand_range(0, 7); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.srs_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.srs_request = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.antenna_ports_scrambling_and_layers = rand_range(0, 15); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.n_dl_rb = rand_range(0, 100); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.harq_ack_resource_offset = rand_range(0, 3); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.pdsch_re_mapping_quasi_co_location_indicator = rand_range(0, 3); + + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.primary_cell_type = rand_range(0, 2); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.number_ul_dl_configurations = 2; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[0] = rand_range(1, 5); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[1] = rand_range(1, 5); + + + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_configuration = rand_range(0, 255); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.initial_lbt_sf = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.codebook_size_determination = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.drms_table_flag = rand_range(0, 1); + + // if the tpm extention is present of not. + if(rand_range(0, 1)) + { + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag = rand_range(0, 1); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_prb_per_subband = rand_range(0, 8); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands = rand_range(0, 13); + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas = 1; // rand_range(0, 8); + + for(int j = 0; j < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands; ++j) + { + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].subband_index = j; + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].scheduled_ues = 1; //rand_range(1, 4); + + for(int k = 0; k < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas; ++k) + for(int l = 0; l < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].scheduled_ues; ++l) + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].precoding_value[k][l] = rand_range(0, 65535); + } + } + else + { + dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag = 0; + } + + } + break; + + case NFAPI_DL_CONFIG_BCH_PDU_TYPE: + { + dl_config_pdus[i].bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG; + dl_config_pdus[i].bch_pdu.bch_pdu_rel8.length = rand_range(0, 42); + dl_config_pdus[i].bch_pdu.bch_pdu_rel8.pdu_index = rand_range(0, 65535); + dl_config_pdus[i].bch_pdu.bch_pdu_rel8.transmission_power = rand_range(0, 10000); + } + break; + + case NFAPI_DL_CONFIG_MCH_PDU_TYPE: + { + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG; + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.length = rand_range(0, 42); + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.pdu_index = rand_range(0, 65535); + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.rnti = 0xFFFD; + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.resource_allocation_type = 0; + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.resource_block_coding = 0; + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.modulation = rand_range(0, 8); + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.transmission_power = rand_range(0, 10000); + dl_config_pdus[i].mch_pdu.mch_pdu_rel8.mbsfn_area_id = rand_range(0, 255); + } + break; + + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: + { + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.length = rand_range(0, 42); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.pdu_index = rand_range(0, 65535); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.rnti = rand_range(1, 65535); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = rand_range(0, 5); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = rand_range(0, 32000); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.modulation = rand_range(2, 8); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.redundancy_version = rand_range(0, 3); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transport_blocks = rand_range(1, 2); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = rand_range(0, 13); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.number_of_layers = rand_range(1, 8); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 2; //rand_range(0, 13); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.codebook_index[0] = rand_range(0, 15); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.codebook_index[1] = rand_range(0, 15); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = rand_range(0, 14); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.pa = rand_range(0, 7); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.ngap = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.nprb = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transmission_mode = rand_range(1, 10); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 2; //rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 2; //rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].subband_index = rand_range(0, 4); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].num_antennas = 1; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].bf_value[0] = rand_range(0, 128); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].subband_index = rand_range(0, 4); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].num_antennas = 1; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].bf_value[0] = rand_range(0, 128); + + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel9.nscid = rand_range(0, 1); + + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_flag = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_resource_config_r10 = 0; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_zero_tx_power_resource_config_bitmap_r10 = rand_range(0, 65535); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_number_nzp_configuration = 1; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_resource_config[0] = rand_range(0, 31); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.pdsch_start = rand_range(0, 4); + + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.drms_config_flag = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.drms_scrambling = rand_range(0, 503); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.csi_config_flag = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.csi_scrambling = rand_range(0, 503); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_flag = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_atenna_ports = rand_range(1,4); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_freq_shift = rand_range(0, 5); + + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG; + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.altcqi_table_r12 = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.maxlayers = rand_range(1, 8); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.n_dl_harq = rand_range(0, 255); + + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.dwpts_symbols = rand_range(3, 14); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.initial_lbt_sf = rand_range(0, 1); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.ue_type = rand_range(0, 2); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = rand_range(0, 2); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239); + dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = rand_range(0, 1); + } + break; + + case NFAPI_DL_CONFIG_PCH_PDU_TYPE: + { + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG; + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.length = rand_range(0, 42); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.pdu_index = rand_range(0, 65535); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.p_rnti = 0xFFFE; + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.resource_allocation_type = rand_range(2, 6); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.resource_block_coding = rand_range(0, 34000); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.mcs = 0; + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.redundancy_version = 0; + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.number_of_transport_blocks = 1; + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transmission_scheme = rand_range(1, 6); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.number_of_layers = rand_range(1, 4); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.codebook_index = 0; + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.ue_category_capacity = rand_range(0, 14); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.pa = rand_range(0, 7); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transmission_power = rand_range(0, 10000); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.nprb = rand_range(0, 1); + dl_config_pdus[i].pch_pdu.pch_pdu_rel8.ngap = rand_range(0, 1); + dl_config_pdus[i].pch_pdu.pch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG; + dl_config_pdus[i].pch_pdu.pch_pdu_rel13.ue_mode = rand_range(0, 1); + dl_config_pdus[i].pch_pdu.pch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239); + } + break; + + case NFAPI_DL_CONFIG_PRS_PDU_TYPE: + { + dl_config_pdus[i].prs_pdu.prs_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG; + dl_config_pdus[i].prs_pdu.prs_pdu_rel9.transmission_power = rand_range(0, 10000); + dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_bandwidth = rand_range(6, 100); + dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_cyclic_prefix_type = rand_range(0, 1); + dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_muting = rand_range(0, 1); + } + break; + + case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: + { + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG; + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_antenna_port_count_r10 = rand_range(1, 16); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config_r10 = 0; + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.transmission_power = rand_range(0, 10000); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_zero_tx_power_resource_config_bitmap_r10 = rand_range(0, 8); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_number_of_nzp_configuration = 2; + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config[0] = rand_range(0, 31); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config[1] = rand_range(0, 31); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG; + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.csi_rs_class = rand_range(0, 2); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.cdm_type = rand_range(0, 1); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.num_bf_vector = 0; // set to zero as not clear how to handle bf value array + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.bf_vector[0].csi_rs_resource_index = rand_range(0, 7); + dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.bf_vector[0].bf_value[0] = 42; + } + break; + + case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: + { + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.dci_format = rand_range(0, 9); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.cce_idx = rand_range(0, 255); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.aggregation_level = rand_range(0, 32); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.rnti = rand_range(0, (uint16_t)-1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.resource_allocation_type = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.resource_block_coding = rand_range(0, 320000); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.mcs_1 = rand_range(0, 31); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.redundancy_version_1 = rand_range(0, 3); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.new_data_indicator_1 = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.mcs_2 = rand_range(0, 31); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.redundancy_version_2 = rand_range(0, 31); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.new_data_indicator_2 = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.harq_process = rand_range(0, 31); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tpmi = rand_range(0, 15); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.pmi = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.precoding_information = rand_range(0, 63); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tpc = rand_range(0, 3); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.downlink_assignment_index = rand_range(0, 15); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.ngap = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transport_block_size_index = rand_range(0, 31); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.downlink_power_offset = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.allocate_prach_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.preamble_index = rand_range(0, 63); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.prach_mask_index = rand_range(0, 15); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.rnti_type = rand_range(0, 3); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transmission_power = rand_range(0, 10000); + + + + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.mcch_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.mcch_change_notification = rand_range(0, 255); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.scrambling_identity = rand_range(0, 1); + + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.carrier_indicator = rand_range(0, 7); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.srs_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.srs_request = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.antenna_ports_scrambling_and_layers = rand_range(0, 15); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.n_dl_rb = rand_range(0, 100); + + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.harq_ack_resource_offset = rand_range(0, 3); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.pdsch_re_mapping_quasi_co_location_indicator = rand_range(0, 3); + + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.primary_cell_type = rand_range(0, 2); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.number_ul_dl_configurations = 2; + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_indication[0] = rand_range(1, 5); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_indication[1] = rand_range(1, 5); + + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.laa_end_partial_sf_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.laa_end_partial_sf_configuration = rand_range(0, 255); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.initial_lbt_sf = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.codebook_size_determination = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.drms_table_flag = rand_range(0, 1); + + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_resource_assignment_flag = rand_range(0, 1); + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_id = rand_range(0, 503); + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_start_symbol = rand_range(1, 4); + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb = rand_range(2, 8); + for(int j = 0; j < dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb; ++j) + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_prb_index[j] = rand_range(0, 99); + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.subband_index = rand_range(0, 25); + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.num_antennas= rand_range(1, 4); + for(int j = 0; j < dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb; ++j) + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.bf_value[j] = rand_range(0, 65535); + + + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG; + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.dwpts_symbols = rand_range(3, 14); + dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.initial_lbt_sf = rand_range(0, 1); + } + break; + + case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: + { + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG; + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = rand_range(0, 15); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = rand_range(2, 6); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = rand_range(0, 14); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = rand_range(1, 4); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = rand_range(0, 22); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = rand_range(2, 24); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = rand_range(0, 4); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.rnti = rand_range(1, 65535); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = rand_range(1, 2); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = rand_range(0, 503); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = rand_range(0, 10000); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.dci_format = rand_range(10, 12); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = rand_range(0, 0xFFFF); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mcs = rand_range(0, 15); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = rand_range(1, 8); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rand_range(0, 3); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.harq_process = rand_range(0, 15); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = rand_range(0, 4); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpmi = rand_range(0, 15); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pmi = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = rand_range(0, 3); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rand_range(1, 4); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpc = rand_range(0, 3); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = rand_range(0, 4); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = rand_range(0, 15); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = rand_range(0, 63); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = rand_range(0, 15); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = rand_range(0, 3); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.srs_request = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = rand_range(0, 3); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = rand_range(0, 255); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = rand_range(0, 1); + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = rand_range(0, 8); + for(int j = 0 ; j < dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports; ++j) + dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.precoding_value[j] = rand_range(0, 65535); + } + break; + + case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: + { + dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG; + dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.length = rand_range(0, 5555); + dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.pdu_index = rand_range(0, 65535); + dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.transmission_power = rand_range(0, 10000); + dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.hyper_sfn_2_lsbs = rand_range(0, 3); + } + break; + + case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: + { + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG; + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.length = rand_range(0, 5555); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.pdu_index = rand_range(0, 65535); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.ncce_index = rand_range(0, 1); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.aggregation_level = rand_range(1, 2); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.start_symbol = rand_range(0, 4); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.rnti_type = rand_range(0, 3); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.rnti = rand_range(1, 65535); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.scrambling_reinitialization_batch_index = rand_range(1, 4); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.dci_format = rand_range(0, 1); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.scheduling_delay = rand_range(0, 7); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.resource_assignment = rand_range(0, 7); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.repetition_number = rand_range(0, 15); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.mcs = rand_range(0, 13); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.new_data_indicator = rand_range(0, 1); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource = rand_range(0, 15); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.npdcch_order_indication = rand_range(0, 1); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.starting_number_of_nprach_repetitions = rand_range(0, 3); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.subcarrier_indication_of_nprach = rand_range(0, 63); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.paging_direct_indication_differentation_flag = rand_range(0, 1); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.direct_indication = rand_range(0, 255); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number = rand_range(0, 7); + dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.total_dci_length_including_padding = rand_range(0, 255); + } + break; + + case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: + { + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG; + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.length = rand_range(0, 5555); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.pdu_index = rand_range(0, 65535); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.start_symbol = rand_range(0, 4); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.rnti_type = rand_range(0, 1); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.rnti = rand_range(1, 65535); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment = rand_range(0, 7); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.repetition_number = rand_range(0, 15); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.modulation = 2; + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment = rand_range(1, 10); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.scrambling_sequence_initialization_cinit = rand_range(0, 65535); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.sf_idx = rand_range(1, 10240); + dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2); + } + break; + + }; + } + + + dl_config_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdus; + mac->dl_config_req(mac, &dl_config_req); + + uint8_t num_ul_pdus = 18; + nfapi_ul_config_request_pdu_t ul_config_pdus[num_ul_pdus]; + memset(&ul_config_pdus, 0, sizeof(ul_config_pdus)); + + nfapi_ul_config_request_t ul_config_req; + memset(&ul_config_req, 0, sizeof(ul_config_req)); + ul_config_req.header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_config_req.header.phy_id = phy_id; + ul_config_req.sfn_sf = sfn_sf; + ul_config_req.ul_config_request_body.tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_config_req.ul_config_request_body.number_of_pdus = num_ul_pdus; + ul_config_req.ul_config_request_body.rach_prach_frequency_resources = rand_range(0, 255); + ul_config_req.ul_config_request_body.srs_present = rand_range(0, 1); + + auto ul_config_ulsch_pdu_test_gen = [](nfapi_ul_config_ulsch_pdu& ulsch_pdu) + { + ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; + ulsch_pdu.ulsch_pdu_rel8.handle = rand_range(0, 50000); + ulsch_pdu.ulsch_pdu_rel8.size = rand_range(0, 32000); + ulsch_pdu.ulsch_pdu_rel8.rnti = rand_range(1, 65535); + ulsch_pdu.ulsch_pdu_rel8.resource_block_start = rand_range(0, 99); + ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = rand_range(1, 100); + ulsch_pdu.ulsch_pdu_rel8.modulation_type = rand_range(2, 6); + ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7); + ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = rand_range(0, 3); + ulsch_pdu.ulsch_pdu_rel8.new_data_indication = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rand_range(0, 3); + ulsch_pdu.ulsch_pdu_rel8.harq_process_number = rand_range(0, 15); + ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = rand_range(0, 5); + ulsch_pdu.ulsch_pdu_rel8.n_srs = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG; + ulsch_pdu.ulsch_pdu_rel10.resource_allocation_type = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel10.resource_block_coding = rand_range(0, 35000); + ulsch_pdu.ulsch_pdu_rel10.transport_blocks = rand_range(1, 2); + ulsch_pdu.ulsch_pdu_rel10.transmission_scheme = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel10.number_of_layers = rand_range(1, 4); + ulsch_pdu.ulsch_pdu_rel10.codebook_index = rand_range(0, 23); + ulsch_pdu.ulsch_pdu_rel10.disable_sequence_hopping_flag = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG; + ulsch_pdu.ulsch_pdu_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel11.npusch_identity = rand_range(0, 509); + ulsch_pdu.ulsch_pdu_rel11.dmrs_config_flag = rand_range(0, 1); + ulsch_pdu.ulsch_pdu_rel11.ndmrs_csh_identity = rand_range(0, 509); + ulsch_pdu.ulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG; + ulsch_pdu.ulsch_pdu_rel13.ue_type = rand_range(0, 2); + ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = rand_range(1, 2048); + ulsch_pdu.ulsch_pdu_rel13.repetition_number = rand_range(1, 2048); + ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239); + ulsch_pdu.ulsch_pdu_rel13.empty_symbols_due_to_re_tunning = rand_range(0, 8); + }; + + auto ul_config_cqi_ri_info_test_gen = [](nfapi_ul_config_cqi_ri_information& cqi_ri_information) + { + cqi_ri_information.cqi_ri_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG; + cqi_ri_information.cqi_ri_information_rel8.dl_cqi_pmi_size_rank_1 = rand_range(0, 255); + cqi_ri_information.cqi_ri_information_rel8.dl_cqi_pmi_size_rank_greater_1 = rand_range(0, 255); + cqi_ri_information.cqi_ri_information_rel8.ri_size = rand_range(0, 3); + cqi_ri_information.cqi_ri_information_rel8.delta_offset_cqi = rand_range(0, 15); + cqi_ri_information.cqi_ri_information_rel8.delta_offset_ri = rand_range(0, 15); + + cqi_ri_information.cqi_ri_information_rel9.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG; + cqi_ri_information.cqi_ri_information_rel9.report_type = 1; // rand_range(0, 1); + cqi_ri_information.cqi_ri_information_rel9.delta_offset_cqi = rand_range(0, 15); + cqi_ri_information.cqi_ri_information_rel9.delta_offset_ri = rand_range(0, 15); + + if(cqi_ri_information.cqi_ri_information_rel9.report_type == 0) + { + cqi_ri_information.cqi_ri_information_rel9.periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size = rand_range(0, 255); + cqi_ri_information.cqi_ri_information_rel9.periodic_cqi_pmi_ri_report.control_type = rand_range(0, 1); + } + else + { + cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.number_of_cc = 1; + cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = rand_range(0, 3); + cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[0] = rand_range(0, 255); + } + + cqi_ri_information.cqi_ri_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG; + cqi_ri_information.cqi_ri_information_rel13.report_type = rand_range(0, 1); + + if(cqi_ri_information.cqi_ri_information_rel13.report_type == 0) + { + cqi_ri_information.cqi_ri_information_rel13.periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size_2 = rand_range(255, 10000); + } + }; + + auto ul_config_init_tx_params_test_gen = [](nfapi_ul_config_initial_transmission_parameters& initial_transmission_parameters) + { + initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = rand_range(0, 1); + initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rand_range(1, 100); + }; + + auto ul_config_harqinfo_test_gen = [](nfapi_ul_config_ulsch_harq_information& harq_information) + { + harq_information.harq_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG; + harq_information.harq_information_rel10.harq_size = rand_range(0, 21); + harq_information.harq_information_rel10.delta_offset_harq = rand_range(0, 15); + harq_information.harq_information_rel10.ack_nack_mode = rand_range(0, 5); + harq_information.harq_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG; + harq_information.harq_information_rel13.harq_size_2 = rand_range(0, 21); + harq_information.harq_information_rel13.delta_offset_harq_2 = rand_range(0, 15); + }; + + auto ul_config_sr_info_test_gen = [](nfapi_ul_config_sr_information& sr_info) + { + sr_info.sr_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG; + sr_info.sr_information_rel8.pucch_index = rand_range(0, 2047); + sr_info.sr_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG; + sr_info.sr_information_rel10.number_of_pucch_resources = rand_range(1, 2); + sr_info.sr_information_rel10.pucch_index_p1 = rand_range(0, 2047); + }; + + auto ul_config_ue_info_test_gen = [](nfapi_ul_config_ue_information& ue_information) + { + ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ue_information.ue_information_rel8.handle = rand_range(0, 99999); + ue_information.ue_information_rel8.rnti = rand_range(1, 65535); + ue_information.ue_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG; + ue_information.ue_information_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1); + ue_information.ue_information_rel11.npusch_identity = rand_range(0, 503); + ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG; + ue_information.ue_information_rel13.ue_type = rand_range(0, 2); + ue_information.ue_information_rel13.empty_symbols = rand_range(0, 2); + ue_information.ue_information_rel13.total_number_of_repetitions = rand_range(1, 32); + ue_information.ue_information_rel13.repetition_number = rand_range(1, 32); + }; + + auto ul_config_cqi_info_test_gen = [](nfapi_ul_config_cqi_information& cqi_information) + { + cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG; + cqi_information.cqi_information_rel8.pucch_index = rand_range(0, 1184); + cqi_information.cqi_information_rel8.dl_cqi_pmi_size = rand_range(0, 255); + cqi_information.cqi_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG; + cqi_information.cqi_information_rel10.number_of_pucch_resource = rand_range(1, 2); + cqi_information.cqi_information_rel10.pucch_index_p1 = rand_range(0, 1184); + cqi_information.cqi_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG; + cqi_information.cqi_information_rel13.csi_mode = rand_range(0, 2); + cqi_information.cqi_information_rel13.dl_cqi_pmi_size_2 = rand_range(0, 999); + cqi_information.cqi_information_rel13.starting_prb = rand_range(0, 109); + cqi_information.cqi_information_rel13.n_prb = rand_range(0, 7); + cqi_information.cqi_information_rel13.cdm_index = rand_range(0, 1); + cqi_information.cqi_information_rel13.n_srs = rand_range(0, 1); + }; + + auto ul_config_harq_info_test_gen = [](nfapi_ul_config_harq_information& harq_information) + { + harq_information.harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; + harq_information.harq_information_rel10_tdd.harq_size = rand_range(0, 21); + harq_information.harq_information_rel10_tdd.ack_nack_mode = rand_range(0, 5); + harq_information.harq_information_rel10_tdd.number_of_pucch_resources = rand_range(0, 4); + harq_information.harq_information_rel10_tdd.n_pucch_1_0 = rand_range(0, 2047); + harq_information.harq_information_rel10_tdd.n_pucch_1_1 = rand_range(0, 2047); + harq_information.harq_information_rel10_tdd.n_pucch_1_2 = rand_range(0, 2047); + harq_information.harq_information_rel10_tdd.n_pucch_1_3 = rand_range(0, 2047); + harq_information.harq_information_rel8_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG; + harq_information.harq_information_rel8_fdd.n_pucch_1_0 = rand_range(0, 2047); + harq_information.harq_information_rel8_fdd.harq_size = rand_range(1, 2); + harq_information.harq_information_rel9_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG; + harq_information.harq_information_rel9_fdd.harq_size = rand_range(1, 10); + harq_information.harq_information_rel9_fdd.ack_nack_mode = rand_range(0, 4); + harq_information.harq_information_rel9_fdd.number_of_pucch_resources = rand_range(0, 4); + harq_information.harq_information_rel9_fdd.n_pucch_1_0 = rand_range(0, 2047); + harq_information.harq_information_rel9_fdd.n_pucch_1_1 = rand_range(0, 2047); + harq_information.harq_information_rel9_fdd.n_pucch_1_2 = rand_range(0, 2047); + harq_information.harq_information_rel9_fdd.n_pucch_1_3 = rand_range(0, 2047); + harq_information.harq_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG; + harq_information.harq_information_rel11.num_ant_ports = rand_range(1, 2); + harq_information.harq_information_rel11.n_pucch_2_0 = rand_range(0, 2047); + harq_information.harq_information_rel11.n_pucch_2_1 = rand_range(0, 2047); + harq_information.harq_information_rel11.n_pucch_2_2 = rand_range(0, 2047); + harq_information.harq_information_rel11.n_pucch_2_3 = rand_range(0, 2047); + harq_information.harq_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG; + harq_information.harq_information_rel13.harq_size_2 = rand_range(0, 999); + harq_information.harq_information_rel13.starting_prb = rand_range(0, 109); + harq_information.harq_information_rel13.n_prb = rand_range(0, 7); + harq_information.harq_information_rel13.cdm_index = rand_range(0, 1); + harq_information.harq_information_rel13.n_srs = rand_range(0, 1); + }; + + + ul_config_pdus[0].pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; + ul_config_ulsch_pdu_test_gen(ul_config_pdus[0].ulsch_pdu); + + ul_config_pdus[1].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE; + ul_config_ulsch_pdu_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.ulsch_pdu); + ul_config_cqi_ri_info_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.cqi_ri_information); + ul_config_init_tx_params_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.initial_transmission_parameters); + + ul_config_pdus[2].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ul_config_ulsch_pdu_test_gen(ul_config_pdus[2].ulsch_harq_pdu.ulsch_pdu); + ul_config_harqinfo_test_gen(ul_config_pdus[2].ulsch_harq_pdu.harq_information); + ul_config_init_tx_params_test_gen(ul_config_pdus[2].ulsch_harq_pdu.initial_transmission_parameters); + + ul_config_pdus[3].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ul_config_ulsch_pdu_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.ulsch_pdu); + ul_config_cqi_ri_info_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.cqi_ri_information); + ul_config_harqinfo_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.harq_information); + ul_config_init_tx_params_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters); + + + ul_config_pdus[4].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[4].uci_cqi_pdu.ue_information); + ul_config_cqi_info_test_gen(ul_config_pdus[4].uci_cqi_pdu.cqi_information); + + ul_config_pdus[5].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[5].uci_sr_pdu.ue_information); + ul_config_sr_info_test_gen(ul_config_pdus[5].uci_sr_pdu.sr_information); + + + ul_config_pdus[6].pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[6].uci_harq_pdu.ue_information); + ul_config_harq_info_test_gen(ul_config_pdus[6].uci_harq_pdu.harq_information); + + + ul_config_pdus[7].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.ue_information); + ul_config_sr_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.sr_information); + ul_config_harq_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.harq_information); + + ul_config_pdus[8].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.ue_information); + ul_config_cqi_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.cqi_information); + ul_config_harq_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.harq_information); + + ul_config_pdus[9].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.ue_information); + ul_config_cqi_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.cqi_information); + ul_config_sr_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.sr_information); + + ul_config_pdus[10].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.ue_information); + ul_config_cqi_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.cqi_information); + ul_config_sr_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.sr_information); + ul_config_harq_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.harq_information); + + ul_config_pdus[11].pdu_type = NFAPI_UL_CONFIG_SRS_PDU_TYPE; + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG; + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.handle = rand_range(0, 9999); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.size = rand_range(1, 999); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.rnti = rand_range(1, 65535); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.srs_bandwidth = rand_range(0, 3); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.frequency_domain_position = rand_range(0, 23); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = rand_range(0, 3); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.transmission_comb = rand_range(0, 3); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.i_srs = rand_range(0, 1023); + ul_config_pdus[11].srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift = rand_range(0, 11); + ul_config_pdus[11].srs_pdu.srs_pdu_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG; + ul_config_pdus[11].srs_pdu.srs_pdu_rel10.antenna_port = rand_range(0, 2); + ul_config_pdus[11].srs_pdu.srs_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG; + ul_config_pdus[11].srs_pdu.srs_pdu_rel13.number_of_combs = rand_range(0, 1); + + ul_config_pdus[12].pdu_type = NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE; + ul_config_ue_info_test_gen(ul_config_pdus[12].harq_buffer_pdu.ue_information); + + ul_config_pdus[13].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE; + ul_config_ulsch_pdu_test_gen(ul_config_pdus[13].ulsch_uci_csi_pdu.ulsch_pdu); + ul_config_cqi_info_test_gen(ul_config_pdus[13].ulsch_uci_csi_pdu.csi_information); + + ul_config_pdus[14].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE; + ul_config_ulsch_pdu_test_gen(ul_config_pdus[14].ulsch_uci_harq_pdu.ulsch_pdu); + ul_config_harq_info_test_gen(ul_config_pdus[14].ulsch_uci_harq_pdu.harq_information); + + ul_config_pdus[15].pdu_type = NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE; + ul_config_ulsch_pdu_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.ulsch_pdu); + ul_config_cqi_info_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.csi_information); + ul_config_harq_info_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.harq_information); + + ul_config_pdus[16].pdu_type = NFAPI_UL_CONFIG_NULSCH_PDU_TYPE; + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG; + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nulsch_format = rand_range(0, 1); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.handle = rand_range(0, 0xFFFF); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.size = rand_range(0, 65535); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.rnti = rand_range(1, 65535); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.subcarrier_indication = rand_range(0, 47); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.resource_assignment = rand_range(0, 7); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.mcs = rand_range(0, 12); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.redudancy_version = rand_range(0, 1); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.repetition_number = rand_range(0, 7); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.new_data_indication = rand_range(0, 1); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.n_srs = rand_range(0, 1); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.scrambling_sequence_initialization_cinit = rand_range(0, 65535); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.sf_idx = rand_range(0, 40960); + + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.handle = rand_range(0, 0xFF); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.rnti = rand_range(1, 65535); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG; + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.npusch_identity = rand_range(0, 503); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG; + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.ue_type = rand_range(0, 2); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.empty_symbols = rand_range(0, 0x3); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.total_number_of_repetitions = rand_range(1, 32); + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.repetition_number = rand_range(1, 32); + + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG; + ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.harq_ack_resource = rand_range(0, 15); + + ul_config_pdus[17].pdu_type = NFAPI_UL_CONFIG_NRACH_PDU_TYPE; + ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG; + ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_0 = rand_range(0, 1); + ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_1 = rand_range(0, 1); + ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_2 = rand_range(0, 1); + + ul_config_req.ul_config_request_body.ul_config_pdu_list = ul_config_pdus; + mac->ul_config_req(mac, &ul_config_req); + + + uint8_t num_dci_pdus = 4; + uint8_t num_hi_pdus = 1; + nfapi_hi_dci0_request_pdu_t hi_dci0_pdus[num_dci_pdus + num_hi_pdus]; + memset(&hi_dci0_pdus, 0, sizeof(hi_dci0_pdus)); + + nfapi_hi_dci0_request_t hi_dci0_req; + memset(&hi_dci0_req, 0, sizeof(hi_dci0_req)); + hi_dci0_req.header.message_id = NFAPI_HI_DCI0_REQUEST; + hi_dci0_req.header.phy_id = phy_id; + hi_dci0_req.sfn_sf = sfn_sf; + + hi_dci0_req.hi_dci0_request_body.tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + hi_dci0_req.hi_dci0_request_body.sfnsf = sfn_sf; + hi_dci0_req.hi_dci0_request_body.number_of_dci = num_dci_pdus; + hi_dci0_req.hi_dci0_request_body.number_of_hi = num_hi_pdus; + + hi_dci0_pdus[0].pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.resource_block_start = rand_range(0, 100); + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7); + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.hi_value = rand_range(0, 1); + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.i_phich = rand_range(0, 1); + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.transmission_power = rand_range(0, 10000); + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG; + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.flag_tb2 = rand_range(0, 1); + hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.hi_value_2 = rand_range(0, 1); + + hi_dci0_pdus[1].pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.dci_format = rand_range(0, 4); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cce_index = rand_range(0, 88); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.aggregation_level = rand_range(1, 8); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.rnti = rand_range(1, 65535); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.resource_block_start = rand_range(0, 100); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.number_of_resource_block = rand_range(0, 100); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.mcs_1 = rand_range(0, 31); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.frequency_hopping_bits = rand_range(0, 3); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.new_data_indication_1 = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.ue_tx_antenna_seleciton = rand_range(0, 2); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tpc = rand_range(0, 3); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cqi_csi_request = rand_range(0, 7); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.ul_index = rand_range(0, 3); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.dl_assignment_index = rand_range(1, 4); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tpc_bitmap = rand_range(0, 9999); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.transmission_power = rand_range(0, 10000); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG; + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.carrier_indicator = rand_range(0, 7); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.size_of_cqi_csi_feild = rand_range(0, 2); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.srs_flag = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.srs_request = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_allocation_flag = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_allocation_type = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_block_coding = rand_range(0, 9999); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.mcs_2 = rand_range(0, 31); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.new_data_indication_2 = rand_range(0, 1); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.number_of_antenna_ports = rand_range(0, 2); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.tpmi = rand_range(0, 63); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.n_ul_rb = rand_range(6, 100); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG; + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.pscch_resource = rand_range(0, 16); + hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.time_resource_pattern = rand_range(0, 32); + + + hi_dci0_pdus[2].pdu_type = NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE; + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG; + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.dci_format = rand_range(0, 4); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cce_index = rand_range(0, 88); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.aggregation_level = rand_range(1, 8); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.rnti = rand_range(1, 65535); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.resource_block_start = rand_range(0, 100); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.number_of_resource_block = rand_range(0, 100); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.mcs_1 = rand_range(0, 31); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.frequency_hopping_bits = rand_range(0, 3); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.new_data_indication_1 = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.ue_tx_antenna_seleciton = rand_range(0, 2); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tpc = rand_range(0, 3); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cqi_csi_request = rand_range(0, 7); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.ul_index = rand_range(0, 3); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.dl_assignment_index = rand_range(1, 4); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tpc_bitmap = rand_range(0, 9999); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.transmission_power = rand_range(0, 10000); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG; + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.carrier_indicator = rand_range(0, 7); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.size_of_cqi_csi_feild = rand_range(0, 2); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.srs_flag = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.srs_request = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_allocation_flag = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_allocation_type = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_block_coding = rand_range(0, 9999); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.mcs_2 = rand_range(0, 31); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.new_data_indication_2 = rand_range(0, 1); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.number_of_antenna_ports = rand_range(0, 2); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.tpmi = rand_range(0, 63); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.n_ul_rb = rand_range(6, 100); + hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_parameters_rel11.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG; + + hi_dci0_pdus[3].pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE; + hi_dci0_pdus[3].mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG; + + hi_dci0_pdus[4].pdu_type = NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE; + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG; + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.ncce_index = rand_range(0, 1); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.aggregation_level = rand_range(1, 2); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.start_symbol = rand_range(0, 4); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.rnti = rand_range(1, 65535); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scrambling_reinitialization_batch_index = rand_range(1, 4); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.subcarrier_indication = rand_range(0, 63); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.resource_assignment = rand_range(0, 7); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scheduling_delay = rand_range(0, 3); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.mcs = rand_range(0, 12); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.redudancy_version = rand_range(0, 1); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.repetition_number = rand_range(0, 7); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.new_data_indicator = rand_range(0, 1); + hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.dci_subframe_repetition_number = rand_range(0, 3); + + hi_dci0_req.hi_dci0_request_body.hi_dci0_pdu_list = hi_dci0_pdus; + mac->hi_dci0_req(mac, &hi_dci0_req); + + uint8_t num_tx_pdus = 2; + nfapi_tx_request_pdu_t tx_pdus[num_tx_pdus]; + memset(&tx_pdus, 0, sizeof(tx_pdus)); + + nfapi_tx_request_t tx_req; + memset(&tx_req, 0, sizeof(tx_req)); + tx_req.header.message_id = NFAPI_TX_REQUEST; + tx_req.header.phy_id = phy_id; + tx_req.sfn_sf = sfn_sf; + + tx_req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + tx_req.tx_request_body.number_of_pdus = num_tx_pdus; + + uint32_t data[2]; + data[0] = 0x11223344; + data[1] = 0x55667788; + + tx_pdus[0].pdu_length = 8; + tx_pdus[0].pdu_index = 1; + tx_pdus[0].num_segments = 2; + tx_pdus[0].segments[0].segment_length = 4; + tx_pdus[0].segments[0].segment_data = (uint8_t*)&data[0]; + tx_pdus[0].segments[1].segment_length = 4; + tx_pdus[0].segments[1].segment_data = (uint8_t*)&data[1]; + + tx_pdus[1].pdu_length = 8; + tx_pdus[1].pdu_index = 2; + tx_pdus[1].num_segments = 2; + tx_pdus[1].segments[0].segment_length = 4; + tx_pdus[1].segments[0].segment_data = (uint8_t*)&data[0]; + tx_pdus[1].segments[1].segment_length = 4; + tx_pdus[1].segments[1].segment_data = (uint8_t*)&data[1]; + + + tx_req.tx_request_body.tx_pdu_list = tx_pdus; + mac->tx_req(mac, &tx_req); + } + + void generate_subframe(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf) + { + mac_internal_t* instance = (mac_internal_t*)mac; + + nfapi_dl_config_request_t dl_config_req; + memset(&dl_config_req, 0, sizeof(dl_config_req)); + dl_config_req.header.message_id = NFAPI_DL_CONFIG_REQUEST; + dl_config_req.header.phy_id = phy_id; + dl_config_req.sfn_sf = sfn_sf; + + dl_config_req.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + dl_config_req.dl_config_request_body.number_pdu = 8; + + nfapi_dl_config_request_pdu_t pdus[8]; + memset(&pdus, 0, sizeof(pdus)); + for(int i = 0; i < 8; i++) + { + pdus[i].pdu_type = NFAPI_DL_CONFIG_BCH_PDU_TYPE; + + pdus[i].bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG; + pdus[i].bch_pdu.bch_pdu_rel8.length = 42; + pdus[i].bch_pdu.bch_pdu_rel8.pdu_index = i; + pdus[i].bch_pdu.bch_pdu_rel8.transmission_power = 56; + + } + + dl_config_req.dl_config_request_body.dl_config_pdu_list = pdus; + + /* + vendor_ext_tlv_1 ve; + ve.tl.tag = VENDOR_EXT_TLV_1_TAG; + ve.dummy = 999; + dl_config_req.vendor_extension = &ve.tl; + */ + + mac->dl_config_req(mac, &dl_config_req); + + + nfapi_ul_config_request_t ul_config_req; + memset(&ul_config_req, 0, sizeof(ul_config_req)); + ul_config_req.header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_config_req.header.phy_id = phy_id; + ul_config_req.sfn_sf = sfn_sf; + mac->ul_config_req(mac, &ul_config_req); + + nfapi_hi_dci0_request_t hi_dci0_req; + memset(&hi_dci0_req, 0, sizeof(hi_dci0_req)); + hi_dci0_req.header.message_id = NFAPI_HI_DCI0_REQUEST; + hi_dci0_req.header.phy_id = phy_id; + hi_dci0_req.sfn_sf = sfn_sf; + mac->hi_dci0_req(mac, &hi_dci0_req); + + + + nfapi_tx_request_t tx_req; + memset(&tx_req, 0, sizeof(tx_req)); + tx_req.header.message_id = NFAPI_TX_REQUEST; + tx_req.header.phy_id = phy_id; + tx_req.sfn_sf = sfn_sf; + + nfapi_tx_request_pdu_t tx_pdus[8]; + + tx_req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + tx_req.tx_request_body.number_of_pdus = 0; + tx_req.tx_request_body.tx_pdu_list = &tx_pdus[0]; + + mac_pdu* buff = 0; + int i = 0; + std::list<mac_pdu*> free_list; + do + { + buff = instance->mac->pop_rx_buffer(); + if(buff != 0) + { + if(buff->len == 0) + { + printf("[MAC] Buffer length = 0\n"); + } + + tx_req.tx_request_body.tx_pdu_list[i].pdu_length = buff->len; + tx_req.tx_request_body.tx_pdu_list[i].pdu_index = i; + tx_req.tx_request_body.tx_pdu_list[i].num_segments = 1; + tx_req.tx_request_body.tx_pdu_list[i].segments[0].segment_length = buff->len; + tx_req.tx_request_body.tx_pdu_list[i].segments[0].segment_data = (uint8_t*)buff->buffer; + + tx_req.tx_request_body.number_of_pdus++; + i++; + + instance->mac->byte_count += buff->len; + + free_list.push_back(buff); + } + }while(buff != 0 && i < 8); + + mac->tx_req(mac, &tx_req); + + //for(int j = 0; j < tx_req.tx_request_body.number_of_pdus; ++j) + for(mac_pdu* pdu : free_list) + { + instance->mac->release_mac_pdu(pdu); + //free(tx_req.tx_request_body.tx_pdu_list[j].segments[0].segment_data); + } + } + + void mac_subframe_ind(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf) + { + + + //printf("[MAC] subframe indication phyid:%d sfnsf:%d\n", phy_id, sfn_sf); + mac_internal_t* instance = (mac_internal_t*)mac; + + if(instance->mac->tick == 1000) + { + if(instance->mac->byte_count > 0) + { + printf("[MAC] Rx rate %d bytes/sec\n", instance->mac->byte_count); + instance->mac->byte_count = 0; + } + instance->mac->tick = 0; + } + instance->mac->tick++; + + if(instance->mac->wireshark_test_mode) + { + generate_test_subframe(mac, phy_id, sfn_sf); + } + else + { + generate_subframe(mac, phy_id, sfn_sf); + } + } + + void mac_harq_ind(mac_t* mac, nfapi_harq_indication_t* ind) + { + } + void mac_crc_ind(mac_t* mac, nfapi_crc_indication_t* ind) + { + } + void mac_rx_ind(mac_t* mac, nfapi_rx_indication_t* ind) + { + mac_internal_t* instance = (mac_internal_t*)mac; + + for(int i = 0; i < ind->rx_indication_body.number_of_pdus; ++i) + { + uint16_t len = ind->rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length; + uint8_t* data = ind->rx_indication_body.rx_pdu_list[i].data; + //printf("[MAC] sfnsf:%d len:%d\n", ind->sfn_sf,len); + // + instance->tx_byte_count += len; + + int sendto_result = sendto(instance->tx_sock, data, len, 0, (struct sockaddr*)&(instance->tx_addr), sizeof(instance->tx_addr)); + + if(sendto_result < 0) + { + // error + } + } + + } + void mac_rach_ind(mac_t* mac, nfapi_rach_indication_t* ind) + { + } + void mac_srs_ind(mac_t* mac, nfapi_srs_indication_t* ind) + { + } + void mac_sr_ind(mac_t* mac, nfapi_sr_indication_t* ind) + { + } + void mac_cqi_ind(mac_t* mac, nfapi_cqi_indication_t* ind) + { + } + void mac_lbt_dl_ind(mac_t* mac, nfapi_lbt_dl_indication_t* ind) + { + } + void mac_nb_harq_ind(mac_t* mac, nfapi_nb_harq_indication_t* ind) + { + } + void mac_nrach_ind(mac_t* mac, nfapi_nrach_indication_t* ind) + { + } +} + diff --git a/nfapi/open-nFAPI/vnf_sim/src/main.cpp b/nfapi/open-nFAPI/vnf_sim/src/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5dc7161157defe8b5c6e3b8d5b10c445cf79a25d --- /dev/null +++ b/nfapi/open-nFAPI/vnf_sim/src/main.cpp @@ -0,0 +1,1525 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#include <string.h> +#include "debug.h" +#include <map> +#include <vector> +#include <list> +#include <string> +#include <algorithm> +#include <sys/socket.h> +#include <sys/time.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <ifaddrs.h> +#include <netdb.h> + +#include "pool.h" + +#include <boost/foreach.hpp> +#include <boost/property_tree/xml_parser.hpp> +#include <boost/property_tree/ptree.hpp> +#include <boost/exception/diagnostic_information.hpp> +#include <boost/exception_ptr.hpp> + +extern "C" { +#include <nfapi_vnf_interface.h> +#include <nfapi.h> +#include "mac.h" + +#include <vendor_ext.h> + +//int vnf_main(int iPortP5, int, int); +int start_simulated_mac(int*, int*); +int read_xml(const char *xml_file); + +} + +static uint32_t rand_range(uint32_t min, uint32_t max) +{ + return ((rand() % (max + 1 - min)) + min); +} + + +void* vnf_allocate(size_t size) +{ + return (void*)memory_pool::allocate(size); +} + +void vnf_deallocate(void* ptr) +{ + memory_pool::deallocate((uint8_t*)ptr); +} + + + +class udp_data +{ + public: + bool enabled; + uint32_t rx_port; + uint32_t tx_port; + std::string tx_addr; +}; + + +class phy_info +{ + public: + + uint16_t index; + uint16_t id; + + std::vector<uint16_t> rfs; + std::vector<uint16_t> excluded_rfs; + + int remote_port; + std::string remote_addr; + + uint16_t earfcn; + +}; + +class rf_info +{ + public: + + uint16_t index; + uint16_t band; +}; + +class pnf_info +{ + public: + + std::vector<phy_info> phys; + std::vector<rf_info> rfs; +}; + +class vnf_p7_info +{ + public: + + vnf_p7_info() + : thread_started(false), + config(nfapi_vnf_p7_config_create(), + [] (nfapi_vnf_p7_config_t* f) { nfapi_vnf_p7_config_destory(f); }), + mac(0) + { + local_port = 0; + + timing_window = 0; + periodic_timing_enabled = 0; + aperiodic_timing_enabled = 0; + periodic_timing_period = 0; + + //config = nfapi_vnf_p7_config_create(); + } + + vnf_p7_info(const vnf_p7_info& other) = default; + + vnf_p7_info(vnf_p7_info&& other) = default; + + vnf_p7_info& operator=(const vnf_p7_info&) = default; + + vnf_p7_info& operator=(vnf_p7_info&&) = default; + + + + virtual ~vnf_p7_info() + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "*** vnf_p7_info delete ***\n"); + + //nfapi_vnf_p7_config_destory(config); + + // should we delete the mac? + } + + + int local_port; + std::string local_addr; + + unsigned timing_window; + unsigned periodic_timing_enabled; + unsigned aperiodic_timing_enabled; + unsigned periodic_timing_period; + + // This is not really the right place if we have multiple PHY, + // should be part of the phy struct + udp_data udp; + + bool thread_started; + + //nfapi_vnf_p7_config_t* config; + std::shared_ptr<nfapi_vnf_p7_config_t> config; + + mac_t* mac; + + +}; + +class vnf_info +{ + public: + + uint8_t wireshark_test_mode; + + std::map<uint16_t, pnf_info> pnfs; + + std::vector<vnf_p7_info> p7_vnfs; + +}; + + +/// maybe these should be in the mac file... +int phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p7_codec_config_t* codec) +{ + (void)tl; + (void)ppReadPackedMessage; + (void)ve; + return -1; +} + +int phy_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* codec) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n"); + + nfapi_tl_t* tlv = (nfapi_tl_t*)ve; + switch(tlv->tag) + { + case VENDOR_EXT_TLV_1_TAG: + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n"); + vendor_ext_tlv_1* ve = (vendor_ext_tlv_1*)tlv; + if(!push32(ve->dummy, ppWritePackedMsg, end)) + return 0; + return 1; + } + break; + default: + return -1; + break; + } +} + +int vnf_sim_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "pnf_sim_pack_vendor_extension_tlv\n"); + nfapi_tl_t* tlv = (nfapi_tl_t*)ve; + switch(tlv->tag) + { + case VENDOR_EXT_TLV_2_TAG: + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n"); + vendor_ext_tlv_2* ve = (vendor_ext_tlv_2*)tlv; + if(!push32(ve->dummy, ppWritePackedMsg, end)) + return 0; + return 1; + } + break; + } + return -1; +} + +int vnf_sim_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* codec) +{ + return -1; +} + + + + +int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); + if(header->message_id == P7_VENDOR_EXT_IND) + { + vendor_ext_p7_ind* req = (vendor_ext_p7_ind*)(header); + if(!pull16(ppReadPackedMessage, &req->error_code, end)) + return 0; + } + return 1; +} + +int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +{ + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__); + 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); + if(!(push16(req->dummy1, ppWritePackedMsg, end) && + push16(req->dummy2, ppWritePackedMsg, end))) + return 0; + } + return 1; +} + +int vnf_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_RSP) + { + vendor_ext_p5_rsp* req = (vendor_ext_p5_rsp*)(header); + return(!pull16(ppReadPackedMessage, &req->error_code, end)); + } + return 0; +} + +int vnf_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* 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); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2); + return (!(push16(req->dummy1, ppWritePackedMsg, end) && + push16(req->dummy2, ppWritePackedMsg, end))); + } + return 0; +} + +void vnf_sim_trace(nfapi_trace_level_t level, const char* message, ...) +{ + va_list args; + va_start(args, message); + vprintf(message, args); + va_end(args); +} + +void mac_dl_config_req(mac_t* mac, nfapi_dl_config_request_t* req) +{ + vnf_p7_info* info = (vnf_p7_info*)(mac->user_data); + + nfapi_vnf_p7_dl_config_req(info->config.get(), req); +} + +void mac_ul_config_req(mac_t* mac, nfapi_ul_config_request_t* req) +{ + vnf_p7_info* info = (vnf_p7_info*)(mac->user_data); + + nfapi_vnf_p7_ul_config_req(info->config.get(), req); +} + +void mac_hi_dci0_req(mac_t* mac, nfapi_hi_dci0_request_t* req) +{ + vnf_p7_info* info = (vnf_p7_info*)(mac->user_data); + + nfapi_vnf_p7_hi_dci0_req(info->config.get(), req); +} + +void mac_tx_req(mac_t* mac, nfapi_tx_request_t* req) +{ + vnf_p7_info* info = (vnf_p7_info*)(mac->user_data); + + nfapi_vnf_p7_tx_req(info->config.get(), req); +} + +int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf) +{ + //printf("[VNF_SIM] subframe indication %d\n", sfn_sf); + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_subframe_ind(p7_vnf->mac, phy_id, sfn_sf); + return 0; +} +int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_harq_ind(p7_vnf->mac, ind); + return 1; +} +int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_crc_ind(p7_vnf->mac, ind); + return 1; +} +int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_rx_ind(p7_vnf->mac, ind); + return 1; +} +int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_rach_ind(p7_vnf->mac, ind); + return 1; +} +int phy_srs_indication(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_srs_ind(p7_vnf->mac, ind); + return 1; +} +int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_sr_ind(p7_vnf->mac, ind); + return 1; +} +int phy_cqi_indication(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_cqi_ind(p7_vnf->mac, ind); + return 1; +} +int phy_lbt_dl_indication(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_lbt_dl_ind(p7_vnf->mac, ind); + return 1; +} +int phy_nb_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_nb_harq_ind(p7_vnf->mac, ind); + return 1; +} +int phy_nrach_indication(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind) +{ + vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data); + mac_nrach_ind(p7_vnf->mac, ind); + return 1; +} +int phy_vendor_ext(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg) +{ + if(msg->message_id == P7_VENDOR_EXT_IND) + { + //vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg; + //printf("[VNF_SIM] vendor_ext (error_code:%d)\n", ind->error_code); + } + else + { + printf("[VNF_SIM] unknown %d\n", msg->message_id); + } + return 0; +} +nfapi_p7_message_header_t* phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t* msg_size) +{ + if(message_id == P7_VENDOR_EXT_IND) + { + *msg_size = sizeof(vendor_ext_p7_ind); + return (nfapi_p7_message_header_t*)malloc(sizeof(vendor_ext_p7_ind)); + } + return 0; +} +void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header) +{ + free(header); +} + +//static pthread_t vnf_start_pthread; +static pthread_t vnf_p7_start_pthread; +void* vnf_p7_start_thread(void *ptr) +{ + printf("%s()\n", __FUNCTION__); + + //std::shared_ptr<nfapi_vnf_p7_config> config = std::shared_ptr<nfapi_vnf_p7_config>(ptr); + nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr; + + nfapi_vnf_p7_start(config); + + return 0; +} + +void set_thread_priority(int priority) +{ + //printf("%s(priority:%d)\n", __FUNCTION__, priority); + + pthread_attr_t ptAttr; + + struct sched_param schedParam; + schedParam.__sched_priority = priority; //79; + if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) + { + printf("Failed to set scheduler to SCHED_RR\n"); + } + + if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) + { + printf("Failed to set pthread sched policy SCHED_RR\n"); + } + + 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* vnf_p7_thread_start(void* ptr) +{ + printf("%s()\n", __FUNCTION__); + + set_thread_priority(79); + + vnf_p7_info* p7_vnf = (vnf_p7_info*)ptr; + + p7_vnf->config->port = p7_vnf->local_port; + p7_vnf->config->subframe_indication = &phy_subframe_indication; + p7_vnf->config->harq_indication = &phy_harq_indication; + p7_vnf->config->crc_indication = &phy_crc_indication; + p7_vnf->config->rx_indication = &phy_rx_indication; + p7_vnf->config->rach_indication = &phy_rach_indication; + p7_vnf->config->srs_indication = &phy_srs_indication; + p7_vnf->config->sr_indication = &phy_sr_indication; + p7_vnf->config->cqi_indication = &phy_cqi_indication; + p7_vnf->config->lbt_dl_indication = &phy_lbt_dl_indication; + p7_vnf->config->nb_harq_indication = &phy_nb_harq_indication; + p7_vnf->config->nrach_indication = &phy_nrach_indication; + p7_vnf->config->malloc = &vnf_allocate; + p7_vnf->config->free = &vnf_deallocate; + + p7_vnf->config->trace = &vnf_sim_trace; + + p7_vnf->config->vendor_ext = &phy_vendor_ext; + p7_vnf->config->user_data = p7_vnf; + + p7_vnf->mac->user_data = p7_vnf; + + p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension; + p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension; + p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv; + p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv; + p7_vnf->config->codec_config.allocate = &vnf_allocate; + p7_vnf->config->codec_config.deallocate = &vnf_deallocate; + + p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext; + p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext; + + printf("[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__); + pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config.get()); + + return 0; +} + +int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) +{ + printf("[VNF_SIM] pnf connection indication idx:%d\n", p5_idx); + + pnf_info pnf; + vnf_info* vnf = (vnf_info*)(config->user_data); + vnf->pnfs.insert(std::pair<uint16_t, pnf_info>(p5_idx, pnf)); + + nfapi_pnf_param_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_PARAM_REQUEST; + nfapi_vnf_pnf_param_req(config, p5_idx, &req); + return 0; +} +int pnf_disconnection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) +{ + printf("[VNF_SIM] pnf disconnection indication idx:%d\n", p5_idx); + + + vnf_info* vnf = (vnf_info*)(config->user_data); + auto find_result = vnf->pnfs.find(p5_idx); + + if(find_result != vnf->pnfs.end()) + { + pnf_info& pnf = find_result->second; + + for(phy_info& phy : pnf.phys) + { + vnf_p7_info& p7_vnf = vnf->p7_vnfs[0]; + nfapi_vnf_p7_del_pnf((p7_vnf.config.get()), phy.id); + } + } + + return 0; +} + +int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp) +{ + printf("[VNF_SIM] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code); + + vnf_info* vnf = (vnf_info*)(config->user_data); + + auto find_result = vnf->pnfs.find(p5_idx); + if(find_result != vnf->pnfs.end()) + { + pnf_info& pnf = find_result->second; + + for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) + { + phy_info phy; + phy.index = resp->pnf_phy.phy[i].phy_config_index; + + printf("[VNF_SIM] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); + + nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id)); + + + + for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) + { + printf("[VNF_SIM] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index); + phy.rfs.push_back(resp->pnf_phy.phy[i].rf_config[j].rf_config_index); + } + + + pnf.phys.push_back(phy); + } + for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) + { + rf_info rf; + rf.index = resp->pnf_rf.rf[i].rf_config_index; + + printf("[VNF_SIM] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); + + pnf.rfs.push_back(rf); + } + + nfapi_pnf_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; + + req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG; + req.pnf_phy_rf_config.number_phy_rf_config_info = pnf.phys.size(); + + for(unsigned i = 0; i < pnf.phys.size(); ++i) + { + req.pnf_phy_rf_config.phy_rf_config[i].phy_id = pnf.phys[i].id; + req.pnf_phy_rf_config.phy_rf_config[i].phy_config_index = pnf.phys[i].index; + req.pnf_phy_rf_config.phy_rf_config[i].rf_config_index = pnf.phys[i].rfs[0]; + } + + + nfapi_vnf_pnf_config_req(config, p5_idx, &req); + } + return 0; +} + +int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp) +{ + printf("[VNF_SIM] pnf config response idx:%d\n", p5_idx); + + if(1) + { + vnf_info* vnf = (vnf_info*)(config->user_data); + auto find_result = vnf->pnfs.find(p5_idx); + if(find_result != vnf->pnfs.end()) + { + //pnf_info& pnf = find_result->second; + + nfapi_pnf_start_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_START_REQUEST; + nfapi_vnf_pnf_start_req(config, p5_idx, &req); + } + } + else + { + // Rather than send the pnf_start_request we will demonstrate + // sending a vendor extention message. The start request will be + // send when the vendor extension response is received + + //vnf_info* vnf = (vnf_info*)(config->user_data); + vendor_ext_p5_req req; + memset(&req, 0, sizeof(req)); + req.header.message_id = P5_VENDOR_EXT_REQ; + req.dummy1 = 45; + req.dummy2 = 1977; + nfapi_vnf_vendor_extension(config, p5_idx, &req.header); + } + return 0; +} + +int pnf_start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp) +{ + printf("[VNF_SIM] pnf start response idx:%d\n", p5_idx); + + vnf_info* vnf = (vnf_info*)(config->user_data); + vnf_p7_info& p7_vnf = vnf->p7_vnfs[0]; + + if(p7_vnf.thread_started == false) + { + pthread_t vnf_p7_thread; + pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, &p7_vnf); + p7_vnf.thread_started = true; + } + else + { + // P7 thread already running. + } + + // start all the phys in the pnf. + + auto find_result = vnf->pnfs.find(p5_idx); + if(find_result != vnf->pnfs.end()) + { + pnf_info& pnf = find_result->second; + + for(unsigned i = 0; i < pnf.phys.size(); ++i) + { + pnf_info& pnf = find_result->second; + + nfapi_param_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PARAM_REQUEST; + req.header.phy_id = pnf.phys[i].id; + nfapi_vnf_param_req(config, p5_idx, &req); + } + } + + return 0; +} +int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* resp) +{ + printf("[VNF_SIM] param response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + + vnf_info* vnf = (vnf_info*)(config->user_data); + + auto find_result = vnf->pnfs.find(p5_idx); + if(find_result != vnf->pnfs.end()) + { + pnf_info& pnf = find_result->second; + + + auto found = std::find_if(pnf.phys.begin(), pnf.phys.end(), [&](phy_info& item) + { return item.id == resp->header.phy_id; }); + + if(found != pnf.phys.end()) + { + phy_info& phy = (*found); + + phy.remote_port = resp->nfapi_config.p7_pnf_port.value; + + struct sockaddr_in pnf_p7_sockaddr; + memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4); + + phy.remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr); + + // for now just 1 + vnf_p7_info& p7_vnf = vnf->p7_vnfs[0]; + + printf("[VNF_SIM] %d.%d pnf p7 %s:%d timing %d %d %d %d\n", p5_idx, phy.id, phy.remote_addr.c_str(), phy.remote_port, p7_vnf.timing_window, p7_vnf.periodic_timing_period, p7_vnf.aperiodic_timing_enabled, p7_vnf.periodic_timing_period); + + + nfapi_config_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_CONFIG_REQUEST; + req.header.phy_id = phy.id; + + + req.nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG; + req.nfapi_config.p7_vnf_port.value = p7_vnf.local_port; + req.num_tlv++; + + req.nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG; + struct sockaddr_in vnf_p7_sockaddr; + vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf.local_addr.c_str()); + memcpy(&(req.nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4); + req.num_tlv++; + + req.nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG; + req.nfapi_config.timing_window.value = p7_vnf.timing_window; + req.num_tlv++; + + if(p7_vnf.periodic_timing_enabled || p7_vnf.aperiodic_timing_enabled) + { + req.nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG; + req.nfapi_config.timing_info_mode.value = (p7_vnf.aperiodic_timing_enabled << 1) | (p7_vnf.periodic_timing_enabled); + req.num_tlv++; + + if(p7_vnf.periodic_timing_enabled) + { + req.nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG; + req.nfapi_config.timing_info_period.value = p7_vnf.periodic_timing_period; + req.num_tlv++; + } + } + + req.nfapi_config.earfcn.tl.tag = NFAPI_NFAPI_EARFCN_TAG; + req.nfapi_config.earfcn.value = phy.earfcn; + req.num_tlv++; + + + if(1) + { + // Poplate all tlv for wireshark testing + req.subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG; + req.num_tlv++; + + req.subframe_config.pcfich_power_offset.tl.tag = NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG; + req.num_tlv++; + req.subframe_config.pb.tl.tag = NFAPI_SUBFRAME_CONFIG_PB_TAG; + req.num_tlv++; + req.subframe_config.dl_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG; + req.num_tlv++; + req.subframe_config.ul_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG; + req.num_tlv++; + + req.rf_config.dl_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG; + req.num_tlv++; + req.rf_config.ul_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG; + req.num_tlv++; + req.rf_config.reference_signal_power.tl.tag = NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG; + req.num_tlv++; + req.rf_config.tx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG; + req.num_tlv++; + req.rf_config.rx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG; + req.num_tlv++; + + req.phich_config.phich_resource.tl.tag = NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG; + req.num_tlv++; + req.phich_config.phich_duration.tl.tag = NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG; + req.num_tlv++; + req.phich_config.phich_power_offset.tl.tag = NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG; + req.num_tlv++; + + req.sch_config.primary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG; + req.num_tlv++; + req.sch_config.secondary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG; + req.num_tlv++; + req.sch_config.physical_cell_id.tl.tag = NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG; + req.num_tlv++; + + req.prach_config.configuration_index.tl.tag = NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG; + req.num_tlv++; + req.prach_config.root_sequence_index.tl.tag = NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG; + req.num_tlv++; + req.prach_config.zero_correlation_zone_configuration.tl.tag = NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG; + req.num_tlv++; + req.prach_config.high_speed_flag.tl.tag = NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG; + req.num_tlv++; + req.prach_config.frequency_offset.tl.tag = NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG; + req.num_tlv++; + + req.pusch_config.hopping_mode.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG; + req.num_tlv++; + req.pusch_config.hopping_offset.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG; + req.num_tlv++; + req.pusch_config.number_of_subbands.tl.tag = NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG; + req.num_tlv++; + + req.pucch_config.delta_pucch_shift.tl.tag = NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG; + req.num_tlv++; + req.pucch_config.n_cqi_rb.tl.tag = NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG; + req.num_tlv++; + req.pucch_config.n_an_cs.tl.tag = NFAPI_PUCCH_CONFIG_N_AN_CS_TAG; + req.num_tlv++; + req.pucch_config.n1_pucch_an.tl.tag = NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG; + req.num_tlv++; + + req.srs_config.bandwidth_configuration.tl.tag = NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG; + req.num_tlv++; + req.srs_config.max_up_pts.tl.tag = NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG; + req.num_tlv++; + req.srs_config.srs_subframe_configuration.tl.tag = NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG; + req.num_tlv++; + req.srs_config.srs_acknack_srs_simultaneous_transmission.tl.tag = NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG; + req.num_tlv++; + + req.uplink_reference_signal_config.uplink_rs_hopping.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG; + req.num_tlv++; + req.uplink_reference_signal_config.group_assignment.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG; + req.num_tlv++; + req.uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG; + req.num_tlv++; + + req.laa_config.ed_threshold_lbt_pdsch.tl.tag = NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG; + req.num_tlv++; + req.laa_config.ed_threshold_lbt_drs.tl.tag = NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG; + req.num_tlv++; + req.laa_config.pd_threshold.tl.tag = NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG; + req.num_tlv++; + req.laa_config.multi_carrier_type.tl.tag = NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG; + req.num_tlv++; + req.laa_config.multi_carrier_tx.tl.tag = NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG; + req.num_tlv++; + req.laa_config.multi_carrier_freeze.tl.tag = NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG; + req.num_tlv++; + req.laa_config.tx_antenna_ports_drs.tl.tag = NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG; + req.num_tlv++; + req.laa_config.tx_power_drs.tl.tag = NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG; + req.num_tlv++; + + req.emtc_config.pbch_repetitions_enable_r13.tl.tag = NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG; + req.num_tlv++; + req.emtc_config.prach_catm_root_sequence_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG; + req.num_tlv++; + req.emtc_config.prach_catm_zero_correlation_zone_configuration.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG; + req.num_tlv++; + req.emtc_config.prach_catm_high_speed_flag.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_0_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_0_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_0_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_0_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_0_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_1_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_1_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_1_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_1_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_1_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_1_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_2_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_2_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_2_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_2_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_2_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_3_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_3_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_3_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_3_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG; + req.num_tlv++; + req.emtc_config.prach_ce_level_3_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG; + req.num_tlv++; + req.emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; + req.num_tlv++; + req.emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; + req.num_tlv++; + + req.nb_iot_config.operating_mode.tl.tag = NFAPI_NB_IOT_CONFIG_OPERATING_MODE_TAG; + req.nb_iot_config.operating_mode.value = rand_range(0, 3); + req.num_tlv++; + req.nb_iot_config.anchor.tl.tag = NFAPI_NB_IOT_CONFIG_ANCHOR_TAG; + req.nb_iot_config.anchor.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.prb_index.tl.tag = NFAPI_NB_IOT_CONFIG_PRB_INDEX_TAG; + req.nb_iot_config.prb_index.value = rand_range(0, 0x1F); + req.num_tlv++; + req.nb_iot_config.control_region_size.tl.tag = NFAPI_NB_IOT_CONFIG_CONTROL_REGION_SIZE_TAG; + req.nb_iot_config.control_region_size.value = rand_range(1, 4); + req.num_tlv++; + req.nb_iot_config.assumed_crs_aps.tl.tag = NFAPI_NB_IOT_CONFIG_ASSUMED_CRS_APS_TAG; + req.nb_iot_config.assumed_crs_aps.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.nprach_config_0_enabled.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_ENABLED_TAG; + req.nb_iot_config.nprach_config_0_enabled.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.nprach_config_0_sf_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SF_PERIODICITY_TAG; + req.nb_iot_config.nprach_config_0_sf_periodicity.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_0_start_time.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_START_TIME_TAG; + req.nb_iot_config.nprach_config_0_start_time.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_0_subcarrier_offset.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SUBCARRIER_OFFSET_TAG; + req.nb_iot_config.nprach_config_0_subcarrier_offset.value = rand_range(0, 6); + req.num_tlv++; + req.nb_iot_config.nprach_config_0_number_of_subcarriers.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_SUBCARRIERS_TAG; + req.nb_iot_config.nprach_config_0_number_of_subcarriers.value = rand_range(0, 3); + req.num_tlv++; + req.nb_iot_config.nprach_config_0_cp_length.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_CP_LENGTH_TAG; + req.nb_iot_config.nprach_config_0_cp_length.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.nprach_config_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + req.nb_iot_config.nprach_config_0_number_of_repetitions_per_attempt.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_1_enabled.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_ENABLED_TAG; + req.nb_iot_config.nprach_config_1_enabled.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.nprach_config_1_sf_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SF_PERIODICITY_TAG; + req.nb_iot_config.nprach_config_1_sf_periodicity.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_1_start_time.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_START_TIME_TAG; + req.nb_iot_config.nprach_config_1_start_time.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_1_subcarrier_offset.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SUBCARRIER_OFFSET_TAG; + req.nb_iot_config.nprach_config_1_subcarrier_offset.value = rand_range(0, 6); + req.num_tlv++; + req.nb_iot_config.nprach_config_1_number_of_subcarriers.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_SUBCARRIERS_TAG; + req.nb_iot_config.nprach_config_1_number_of_subcarriers.value = rand_range(0, 3); + req.num_tlv++; + req.nb_iot_config.nprach_config_1_cp_length.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_CP_LENGTH_TAG; + req.nb_iot_config.nprach_config_1_cp_length.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.nprach_config_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + req.nb_iot_config.nprach_config_1_number_of_repetitions_per_attempt.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_2_enabled.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_ENABLED_TAG; + req.nb_iot_config.nprach_config_2_enabled.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.nprach_config_2_sf_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SF_PERIODICITY_TAG; + req.nb_iot_config.nprach_config_2_sf_periodicity.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_2_start_time.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_START_TIME_TAG; + req.nb_iot_config.nprach_config_2_start_time.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.nprach_config_2_subcarrier_offset.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SUBCARRIER_OFFSET_TAG; + req.nb_iot_config.nprach_config_2_subcarrier_offset.value = rand_range(0, 6); + req.num_tlv++; + req.nb_iot_config.nprach_config_2_number_of_subcarriers.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_SUBCARRIERS_TAG; + req.nb_iot_config.nprach_config_2_number_of_subcarriers.value = rand_range(0, 3); + req.num_tlv++; + req.nb_iot_config.nprach_config_2_cp_length.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_CP_LENGTH_TAG; + req.nb_iot_config.nprach_config_2_cp_length.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.nprach_config_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + req.nb_iot_config.nprach_config_2_number_of_repetitions_per_attempt.value = rand_range(0, 7); + req.num_tlv++; + req.nb_iot_config.three_tone_base_sequence.tl.tag = NFAPI_NB_IOT_CONFIG_THREE_TONE_BASE_SEQUENCE_TAG; + req.nb_iot_config.three_tone_base_sequence.value = rand_range(0, 0x0F); + req.num_tlv++; + req.nb_iot_config.six_tone_base_sequence.tl.tag = NFAPI_NB_IOT_CONFIG_SIX_TONE_BASE_SEQUENCE_TAG; + req.nb_iot_config.six_tone_base_sequence.value = rand_range(0, 0x03); + req.num_tlv++; + req.nb_iot_config.twelve_tone_base_sequence.tl.tag = NFAPI_NB_IOT_CONFIG_TWELVE_TONE_BASE_SEQUENCE_TAG; + req.nb_iot_config.twelve_tone_base_sequence.value = rand_range(0, 0x1F); + req.num_tlv++; + req.nb_iot_config.three_tone_cyclic_shift.tl.tag = NFAPI_NB_IOT_CONFIG_THREE_TONE_CYCLIC_SHIFT_TAG; + req.nb_iot_config.three_tone_cyclic_shift.value = rand_range(0, 5); // what is the max + req.num_tlv++; + req.nb_iot_config.six_tone_cyclic_shift.tl.tag = NFAPI_NB_IOT_CONFIG_SIX_TONE_CYCLIC_SHIFT_TAG; + req.nb_iot_config.six_tone_cyclic_shift.value = rand_range(0, 5); // what is the max + req.num_tlv++; + req.nb_iot_config.dl_gap_config_enable.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_CONFIG_ENABLE_TAG; + req.nb_iot_config.dl_gap_config_enable.value = rand_range(0, 1); + req.num_tlv++; + req.nb_iot_config.dl_gap_threshold.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_THRESHOLD_TAG; + req.nb_iot_config.dl_gap_threshold.value = rand_range(0, 3); + req.num_tlv++; + req.nb_iot_config.dl_gap_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_PERIODICITY_TAG; + req.nb_iot_config.dl_gap_periodicity.value = rand_range(0, 3); + req.num_tlv++; + req.nb_iot_config.dl_gap_duration_coefficient.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_DURATION_COEFFICIENT_TAG; + req.nb_iot_config.dl_gap_duration_coefficient.value = rand_range(0, 3); + req.num_tlv++; + + req.tdd_frame_structure_config.subframe_assignment.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG; + req.num_tlv++; + req.tdd_frame_structure_config.special_subframe_patterns.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG; + req.num_tlv++; + + req.l23_config.data_report_mode.tl.tag = NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG; + req.num_tlv++; + req.l23_config.sfnsf.tl.tag = NFAPI_L23_CONFIG_SFNSF_TAG; + req.num_tlv++; + } + + vendor_ext_tlv_2 ve2; + memset(&ve2, 0, sizeof(ve2)); + ve2.tl.tag = VENDOR_EXT_TLV_2_TAG; + ve2.dummy = 2016; + req.vendor_extension = &ve2.tl; + + nfapi_vnf_config_req(config, p5_idx, &req); + } + else + { + printf("[VNF_SIM] param response failed to find pnf %d phy %d\n", p5_idx, resp->header.phy_id); + } + } + else + { + printf("[VNF_SIM] param response failed to find pnf %d\n", p5_idx); + } + + return 0; +} + +int config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp) +{ + printf("[VNF_SIM] config response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + + + nfapi_start_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_START_REQUEST; + req.header.phy_id = resp->header.phy_id; + nfapi_vnf_start_req(config, p5_idx, &req); + + return 0; +} + +void test_p4_requests(nfapi_vnf_config_t* config, int p5_idx, int phy_id) +{ + { + nfapi_measurement_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_MEASUREMENT_REQUEST; + req.header.phy_id = phy_id; + + req.dl_rs_tx_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG; + req.dl_rs_tx_power.value = 42; + req.received_interference_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG; + req.received_interference_power.value = 42; + req.thermal_noise_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG; + req.thermal_noise_power.value = 42; + + nfapi_vnf_measurement_req(config, p5_idx, &req); + } + { + nfapi_rssi_request_t lte_req; + memset(<e_req, 0, sizeof(lte_req)); + lte_req.header.message_id = NFAPI_RSSI_REQUEST; + lte_req.header.phy_id = phy_id; + + lte_req.rat_type = NFAPI_RAT_TYPE_LTE; + lte_req.lte_rssi_request.tl.tag = NFAPI_LTE_RSSI_REQUEST_TAG; + lte_req.lte_rssi_request.frequency_band_indicator = 2; + lte_req.lte_rssi_request.measurement_period = 1000; + lte_req.lte_rssi_request.bandwidth = 50; + lte_req.lte_rssi_request.timeout = 0; + lte_req.lte_rssi_request.number_of_earfcns = 2; + lte_req.lte_rssi_request.earfcn[0] = 389; + lte_req.lte_rssi_request.earfcn[1] = 123; + + nfapi_vnf_rssi_request(config, p5_idx, <e_req); + + nfapi_rssi_request_t utran_req; + memset(&utran_req, 0, sizeof(utran_req)); + utran_req.header.message_id = NFAPI_RSSI_REQUEST; + utran_req.header.phy_id = phy_id; + + utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN; + utran_req.utran_rssi_request.tl.tag = NFAPI_UTRAN_RSSI_REQUEST_TAG; + utran_req.utran_rssi_request.frequency_band_indicator = 2; + utran_req.utran_rssi_request.measurement_period = 1000; + utran_req.utran_rssi_request.timeout = 0; + utran_req.utran_rssi_request.number_of_uarfcns = 2; + utran_req.utran_rssi_request.uarfcn[0] = 2348; + utran_req.utran_rssi_request.uarfcn[1] = 52; + + nfapi_vnf_rssi_request(config, p5_idx, &utran_req); + + + nfapi_rssi_request_t geran_req; + memset(&geran_req, 0, sizeof(geran_req)); + geran_req.header.message_id = NFAPI_RSSI_REQUEST; + geran_req.header.phy_id = phy_id; + + geran_req.rat_type = NFAPI_RAT_TYPE_GERAN; + geran_req.geran_rssi_request.tl.tag = NFAPI_GERAN_RSSI_REQUEST_TAG; + geran_req.geran_rssi_request.frequency_band_indicator = 2; + geran_req.geran_rssi_request.measurement_period = 1000; + geran_req.geran_rssi_request.timeout = 0; + geran_req.geran_rssi_request.number_of_arfcns = 1; + geran_req.geran_rssi_request.arfcn[0].arfcn = 34; + geran_req.geran_rssi_request.arfcn[0].direction = 0; + + nfapi_vnf_rssi_request(config, p5_idx, &geran_req); + } + { + nfapi_cell_search_request_t lte_req; + memset(<e_req, 0, sizeof(lte_req)); + lte_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST; + lte_req.header.phy_id = phy_id; + + lte_req.rat_type = NFAPI_RAT_TYPE_LTE; + lte_req.lte_cell_search_request.tl.tag = NFAPI_LTE_CELL_SEARCH_REQUEST_TAG; + lte_req.lte_cell_search_request.earfcn = 1234; + lte_req.lte_cell_search_request.measurement_bandwidth = 50; + lte_req.lte_cell_search_request.exhaustive_search = 1; + lte_req.lte_cell_search_request.timeout = 1000; + lte_req.lte_cell_search_request.number_of_pci = 1; + lte_req.lte_cell_search_request.pci[0] = 234; + + nfapi_vnf_cell_search_request(config, p5_idx, <e_req); + + nfapi_cell_search_request_t utran_req; + memset(&utran_req, 0, sizeof(utran_req)); + utran_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST; + utran_req.header.phy_id = phy_id; + + utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN; + utran_req.utran_cell_search_request.tl.tag = NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG; + utran_req.utran_cell_search_request.uarfcn = 1234; + utran_req.utran_cell_search_request.exhaustive_search = 0; + utran_req.utran_cell_search_request.timeout = 1000; + utran_req.utran_cell_search_request.number_of_psc = 1; + utran_req.utran_cell_search_request.psc[0] = 234; + + nfapi_vnf_cell_search_request(config, p5_idx, &utran_req); + + nfapi_cell_search_request_t geran_req; + memset(&geran_req, 0, sizeof(geran_req)); + geran_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST; + geran_req.header.phy_id = phy_id; + + geran_req.rat_type = NFAPI_RAT_TYPE_GERAN; + geran_req.geran_cell_search_request.tl.tag = NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG; + geran_req.geran_cell_search_request.timeout = 1000; + geran_req.geran_cell_search_request.number_of_arfcn = 1; + geran_req.geran_cell_search_request.arfcn[0] = 8765; + + nfapi_vnf_cell_search_request(config, p5_idx, &geran_req); + } + { + nfapi_broadcast_detect_request_t lte_req; + memset(<e_req, 0, sizeof(lte_req)); + lte_req.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST; + lte_req.header.phy_id = phy_id; + + lte_req.rat_type = NFAPI_RAT_TYPE_LTE; + lte_req.lte_broadcast_detect_request.tl.tag = NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG; + lte_req.lte_broadcast_detect_request.earfcn = 1234; + lte_req.lte_broadcast_detect_request.pci = 50; + lte_req.lte_broadcast_detect_request.timeout = 1000; + + lte_req.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; + lte_req.pnf_cell_search_state.length = 3; + + nfapi_vnf_broadcast_detect_request(config, p5_idx, <e_req); + + nfapi_broadcast_detect_request_t utran_req; + memset(&utran_req, 0, sizeof(utran_req)); + utran_req.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST; + utran_req.header.phy_id = phy_id; + + utran_req.rat_type = NFAPI_RAT_TYPE_LTE; + utran_req.utran_broadcast_detect_request.tl.tag = NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG; + utran_req.utran_broadcast_detect_request.uarfcn = 1234; + utran_req.utran_broadcast_detect_request.psc = 50; + utran_req.utran_broadcast_detect_request.timeout = 1000; + + utran_req.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG; + utran_req.pnf_cell_search_state.length = 3; + + nfapi_vnf_broadcast_detect_request(config, p5_idx, &utran_req); + } + { + nfapi_system_information_schedule_request_t lte_req; + memset(<e_req, 0, sizeof(lte_req)); + lte_req.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST; + lte_req.header.phy_id = phy_id; + + lte_req.rat_type = NFAPI_RAT_TYPE_LTE; + lte_req.lte_system_information_schedule_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG; + lte_req.lte_system_information_schedule_request.earfcn = 1234; + lte_req.lte_system_information_schedule_request.pci = 50; + lte_req.lte_system_information_schedule_request.downlink_channel_bandwidth = 100; + lte_req.lte_system_information_schedule_request.phich_configuration = 3; + lte_req.lte_system_information_schedule_request.number_of_tx_antenna = 2; + lte_req.lte_system_information_schedule_request.retry_count = 4; + lte_req.lte_system_information_schedule_request.timeout = 1000; + + lte_req.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG; + lte_req.pnf_cell_broadcast_state.length = 3; + + nfapi_vnf_system_information_schedule_request(config, p5_idx, <e_req); + } + { + nfapi_system_information_request_t lte_req; + memset(<e_req, 0, sizeof(lte_req)); + lte_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST; + lte_req.header.phy_id = phy_id; + + lte_req.rat_type = NFAPI_RAT_TYPE_LTE; + lte_req.lte_system_information_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG; + lte_req.lte_system_information_request.earfcn = 1234; + lte_req.lte_system_information_request.pci= 456; + lte_req.lte_system_information_request.downlink_channel_bandwidth = 5; + lte_req.lte_system_information_request.phich_configuration = 2; + lte_req.lte_system_information_request.number_of_tx_antenna = 2; + lte_req.lte_system_information_request.number_of_si_periodicity = 1; + lte_req.lte_system_information_request.si_periodicity[0].si_periodicity = 3; + lte_req.lte_system_information_request.si_periodicity[0].si_index = 3; + lte_req.lte_system_information_request.si_window_length = 15; + lte_req.lte_system_information_request.timeout = 1000; + + nfapi_vnf_system_information_request(config, p5_idx, <e_req); + + nfapi_system_information_request_t utran_req; + memset(&utran_req, 0, sizeof(utran_req)); + utran_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST; + utran_req.header.phy_id = phy_id; + + utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN; + utran_req.utran_system_information_request.tl.tag = NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG; + utran_req.utran_system_information_request.uarfcn = 1234; + utran_req.utran_system_information_request.psc = 456; + utran_req.utran_system_information_request.timeout = 1000; + + nfapi_vnf_system_information_request(config, p5_idx, &utran_req); + + nfapi_system_information_request_t geran_req; + memset(&geran_req, 0, sizeof(geran_req)); + geran_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST; + geran_req.header.phy_id = phy_id; + + geran_req.rat_type = NFAPI_RAT_TYPE_GERAN; + geran_req.geran_system_information_request.tl.tag = NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG; + geran_req.geran_system_information_request.arfcn = 1234; + geran_req.geran_system_information_request.bsic = 21; + geran_req.geran_system_information_request.timeout = 1000; + + nfapi_vnf_system_information_request(config, p5_idx, &geran_req); + } + { + nfapi_nmm_stop_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_NMM_STOP_REQUEST; + req.header.phy_id = phy_id; + nfapi_vnf_nmm_stop_request(config, p5_idx, &req); + } +} + + +int start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp) +{ + printf("[VNF_SIM] start response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id); + + vnf_info* vnf = (vnf_info*)(config->user_data); + + if(vnf->wireshark_test_mode) + test_p4_requests(config, p5_idx, resp->header.phy_id); + + auto find_result = vnf->pnfs.find(p5_idx); + if(find_result != vnf->pnfs.end()) + { + pnf_info& pnf = find_result->second; + + + auto found = std::find_if(pnf.phys.begin(), pnf.phys.end(), [&](phy_info& item) + { return item.id == resp->header.phy_id; }); + + if(found != pnf.phys.end()) + { + phy_info& phy = (*found); + + vnf_p7_info& p7_vnf = vnf->p7_vnfs[0]; + + nfapi_vnf_p7_add_pnf((p7_vnf.config.get()), phy.remote_addr.c_str(), phy.remote_port, phy.id); + + + } + + + } + return 0; +} + + +nfapi_p4_p5_message_header_t* vnf_sim_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t* msg_size) +{ + if(message_id == P5_VENDOR_EXT_RSP) + { + *msg_size = sizeof(vendor_ext_p5_rsp); + return (nfapi_p4_p5_message_header_t*)malloc(sizeof(vendor_ext_p5_rsp)); + } + return 0; +} +void vnf_sim_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t* header) +{ + free(header); +} +int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg) +{ + printf("[VNF_SIM] %s\n", __FUNCTION__); + + switch(msg->message_id) + { + case P5_VENDOR_EXT_RSP: + { + vendor_ext_p5_rsp* rsp = (vendor_ext_p5_rsp*)msg; + printf("[VNF_SIM] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code); + + // send the start request + + nfapi_pnf_start_request_t req; + memset(&req, 0, sizeof(req)); + req.header.message_id = NFAPI_PNF_START_REQUEST; + nfapi_vnf_pnf_start_req(config, p5_idx, &req); + } + break; + + } + + return 0; +} + +int read_vnf_xml(vnf_info& vnf, const char* xml_file) +{ + try + { + + std::ifstream input(xml_file); + + using boost::property_tree::ptree; + ptree pt; + + read_xml(input, pt); + + + + for(const auto& v : pt.get_child("vnf.vnf_p7_list")) + { + if(v.first == "vnf_p7") + { + vnf_p7_info vnf_p7; + vnf_p7.local_port = v.second.get<unsigned>("port"); + vnf_p7.local_addr = v.second.get<std::string>("address"); + + vnf_p7.timing_window = v.second.get<unsigned>("timing_window"); + vnf_p7.periodic_timing_enabled = v.second.get<unsigned>("periodic_timing_enabled"); + vnf_p7.aperiodic_timing_enabled = v.second.get<unsigned>("aperiodic_timing_enabled"); + vnf_p7.periodic_timing_period = v.second.get<unsigned>("periodic_timing_window"); + + + boost::optional<const boost::property_tree::ptree&> d = v.second.get_child_optional("data.udp"); + if(d.is_initialized()) + { + vnf_p7.udp.enabled = true; + vnf_p7.udp.rx_port = d.get().get<unsigned>("rx_port"); + vnf_p7.udp.tx_port = d.get().get<unsigned>("tx_port"); + vnf_p7.udp.tx_addr = d.get().get<std::string>("tx_addr"); + } + else + { + vnf_p7.udp.enabled = false; + } + + vnf.wireshark_test_mode = v.second.get<unsigned>("wireshark_test_mode", 0); + + vnf_p7.mac = mac_create(vnf.wireshark_test_mode); + vnf_p7.mac->dl_config_req = &mac_dl_config_req; + vnf_p7.mac->ul_config_req = &mac_ul_config_req; + vnf_p7.mac->hi_dci0_req = &mac_hi_dci0_req; + vnf_p7.mac->tx_req = &mac_tx_req; + + if(vnf_p7.udp.enabled) + { + mac_start_data(vnf_p7.mac, + vnf_p7.udp.rx_port, + vnf_p7.udp.tx_addr.c_str(), + vnf_p7.udp.tx_port); + } + + vnf.p7_vnfs.push_back(vnf_p7); + } + } + } + catch(std::exception& e) + { + printf("%s", e.what()); + return -1; + } + catch(boost::exception& e) + { + printf("%s", boost::diagnostic_information(e).c_str()); + } + + struct ifaddrs *ifaddr; + getifaddrs(&ifaddr); + + + while(ifaddr) + { + int family = ifaddr->ifa_addr->sa_family; + if(family == AF_INET) + { + char host[128]; + getnameinfo(ifaddr->ifa_addr, sizeof(sockaddr_in), host, sizeof(host), NULL, 0, 0); + printf("%s\n", host); + } + ifaddr = ifaddr->ifa_next; + } + + return 0; + +} + + +int main(int argc, char *argv[]) +{ + if (argc < 3) + { + printf("Use parameters: <P5 Port> <xml config file>\n"); + return 0; + } + + set_thread_priority(50); + + vnf_info vnf; + + if(read_vnf_xml(vnf, argv[2]) < 0) + { + printf("Failed to read xml file>\n"); + return 0; + } + + nfapi_vnf_config_t* config = nfapi_vnf_config_create(); + + config->vnf_ipv4 = 1; + config->vnf_p5_port = atoi(argv[1]); + config->pnf_connection_indication = &pnf_connection_indication_cb; + config->pnf_disconnect_indication = &pnf_disconnection_indication_cb; + config->pnf_param_resp = &pnf_param_resp_cb; + config->pnf_config_resp = &pnf_config_resp_cb; + config->pnf_start_resp = &pnf_start_resp_cb; + config->param_resp = ¶m_resp_cb; + config->config_resp = &config_resp_cb; + config->start_resp = &start_resp_cb; + config->vendor_ext = &vendor_ext_cb; + + + + config->trace = &vnf_sim_trace; + + config->malloc = &vnf_allocate; + config->free = &vnf_deallocate; + + config->user_data = &vnf; + + config->codec_config.unpack_vendor_extension_tlv = &vnf_sim_unpack_vendor_extension_tlv; + config->codec_config.pack_vendor_extension_tlv = &vnf_sim_pack_vendor_extension_tlv; + + config->codec_config.unpack_p4_p5_vendor_extension = &vnf_sim_unpack_p4_p5_vendor_extension; + config->codec_config.pack_p4_p5_vendor_extension = &vnf_sim_pack_p4_p5_vendor_extension; + config->allocate_p4_p5_vendor_ext = &vnf_sim_allocate_p4_p5_vendor_ext; + config->deallocate_p4_p5_vendor_ext = &vnf_sim_deallocate_p4_p5_vendor_ext; + config->codec_config.allocate = &vnf_allocate; + config->codec_config.deallocate = &vnf_deallocate; + + + printf("Calling nfapi_vnf_start\n"); + return nfapi_vnf_start(config); +} diff --git a/nfapi/open-nFAPI/xml/pnf_phy_1_A.xml b/nfapi/open-nFAPI/xml/pnf_phy_1_A.xml new file mode 100644 index 0000000000000000000000000000000000000000..45f8f468319d5a9ef3fe401a5ecb8e6b644f7111 --- /dev/null +++ b/nfapi/open-nFAPI/xml/pnf_phy_1_A.xml @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<pnf> + <sync_mode>0</sync_mode> + <location_mode>0</location_mode> + <location_coordinates></location_coordinates> + + <dl_config_timing>500</dl_config_timing> + <ul_config_timing>500</ul_config_timing> + <tx_timing>500</tx_timing> + <hi_dci0_timing>500</hi_dci0_timing> + + <max_phys>1</max_phys> + <max_total_bandwidth>30</max_total_bandwidth> + <max_total_num_dl_layers>1</max_total_num_dl_layers> + <max_total_num_ul_layers>1</max_total_num_ul_layers> + + <shared_bands>0</shared_bands> + <shared_pas>0</shared_pas> + + <maximum_total_power>0</maximum_total_power> + + <oui>ALPHA</oui> + + + <phys> + <phy> + <index>88</index> + <port>2500</port> + <address>192.168.1.74</address> + + <duplex_mode>1</duplex_mode> + + <downlink_channel_bandwidth_support>22</downlink_channel_bandwidth_support> + <uplink_channel_bandwidth_support>22</uplink_channel_bandwidth_support> + + <number_of_dl_layers>1</number_of_dl_layers> + <number_of_ul_layers>1</number_of_ul_layers> + + <3gpp_release_supported>31</3gpp_release_supported> + + <nmm_modes_supported>0</nmm_modes_supported> + + <dl_ues_per_subframe>8</dl_ues_per_subframe> + <ul_ues_per_subframe>8</ul_ues_per_subframe> + + <!-- todo adn the other release parameters --> + + <rfs> + <index>0</index> + </rfs> + <excluded_rfs> + <index>1</index> + </excluded_rfs> + + <data> + <udp> + <rx_port>5201</rx_port> + <tx_addr>192.168.1.28</tx_addr> + <tx_port>5200</tx_port> + </udp> + </data> + </phy> + </phys> + <rfs> + <rf> + <index>0</index> + <band>2</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + <rf> + <index>1</index> + <band>3</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + </rfs> +</pnf> diff --git a/nfapi/open-nFAPI/xml/pnf_phy_1_A_ws.xml b/nfapi/open-nFAPI/xml/pnf_phy_1_A_ws.xml new file mode 100644 index 0000000000000000000000000000000000000000..5eb02841481391ec81e15d965d43431bd15af450 --- /dev/null +++ b/nfapi/open-nFAPI/xml/pnf_phy_1_A_ws.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8"?> +<pnf> + <wireshark_test_mode>1</wireshark_test_mode> + + <sync_mode>0</sync_mode> + <location_mode>0</location_mode> + <location_coordinates></location_coordinates> + + <dl_config_timing>500</dl_config_timing> + <ul_config_timing>500</ul_config_timing> + <tx_timing>500</tx_timing> + <hi_dci0_timing>500</hi_dci0_timing> + + <max_phys>1</max_phys> + <max_total_bandwidth>30</max_total_bandwidth> + <max_total_num_dl_layers>1</max_total_num_dl_layers> + <max_total_num_ul_layers>1</max_total_num_ul_layers> + + <shared_bands>0</shared_bands> + <shared_pas>0</shared_pas> + + <maximum_total_power>0</maximum_total_power> + + <oui>ALPHA</oui> + + + <phys> + <phy> + <index>88</index> + <port>2500</port> + <address>127.0.0.1</address> + + <duplex_mode>1</duplex_mode> + + <downlink_channel_bandwidth_support>22</downlink_channel_bandwidth_support> + <uplink_channel_bandwidth_support>22</uplink_channel_bandwidth_support> + + <number_of_dl_layers>1</number_of_dl_layers> + <number_of_ul_layers>1</number_of_ul_layers> + + <3gpp_release_supported>31</3gpp_release_supported> + + <nmm_modes_supported>0</nmm_modes_supported> + + <dl_ues_per_subframe>8</dl_ues_per_subframe> + <ul_ues_per_subframe>8</ul_ues_per_subframe> + + <!-- todo adn the other release parameters --> + + <rfs> + <index>0</index> + </rfs> + <excluded_rfs> + <index>1</index> + </excluded_rfs> + + <data> + <udp> + <rx_port>7722</rx_port> + <tx_addr>127.0.0.1</tx_addr> + <tx_port>7733</tx_port> + </udp> + </data> + </phy> + </phys> + <rfs> + <rf> + <index>0</index> + <band>2</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + <rf> + <index>1</index> + <band>3</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + </rfs> +</pnf> diff --git a/nfapi/open-nFAPI/xml/pnf_phy_1_B.xml b/nfapi/open-nFAPI/xml/pnf_phy_1_B.xml new file mode 100644 index 0000000000000000000000000000000000000000..302e1e19c537ec8a08a8f91ea8ba1715687bf4d1 --- /dev/null +++ b/nfapi/open-nFAPI/xml/pnf_phy_1_B.xml @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<pnf> + <sync_mode>0</sync_mode> + <location_mode>0</location_mode> + <location_coordinates></location_coordinates> + + <dl_config_timing>500</dl_config_timing> + <ul_config_timing>500</ul_config_timing> + <tx_timing>500</tx_timing> + <hi_dci0_timing>500</hi_dci0_timing> + + <max_phys>1</max_phys> + <max_total_bandwidth>30</max_total_bandwidth> + <max_total_num_dl_layers>1</max_total_num_dl_layers> + <max_total_num_ul_layers>1</max_total_num_ul_layers> + + <shared_bands>0</shared_bands> + <shared_pas>0</shared_pas> + + <maximum_total_power>0</maximum_total_power> + + <oui>ALPHA</oui> + + + <phys> + <phy> + <index>89</index> + <port>2510</port> + <address>127.0.0.1</address> + + <duplex_mode>1</duplex_mode> + + <downlink_channel_bandwidth_support>22</downlink_channel_bandwidth_support> + <uplink_channel_bandwidth_support>22</uplink_channel_bandwidth_support> + + <number_of_dl_layers>1</number_of_dl_layers> + <number_of_ul_layers>1</number_of_ul_layers> + + <3gpp_release_supported>31</3gpp_release_supported> + + <nmm_modes_supported>0</nmm_modes_supported> + + <dl_ues_per_subframe>8</dl_ues_per_subframe> + <ul_ues_per_subframe>8</ul_ues_per_subframe> + + <!-- todo adn the other release parameters --> + + <rfs> + <index>0</index> + </rfs> + <excluded_rfs> + <index>1</index> + </excluded_rfs> + + <data> + <udp> + <rx_port>7744</rx_port> + <tx_addr>127.0.0.1</tx_addr> + <tx_port>7755</tx_port> + </udp> + </data> + </phy> + </phys> + <rfs> + <rf> + <index>0</index> + <band>2</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + <rf> + <index>1</index> + <band>3</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + </rfs> +</pnf> diff --git a/nfapi/open-nFAPI/xml/pnf_phy_2_A.xml b/nfapi/open-nFAPI/xml/pnf_phy_2_A.xml new file mode 100644 index 0000000000000000000000000000000000000000..b820fa135e5c70bac7ee133d8509291bbb41ac9e --- /dev/null +++ b/nfapi/open-nFAPI/xml/pnf_phy_2_A.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8"?> +<pnf> + <sync_mode>0</sync_mode> + <location_mode>0</location_mode> + <location_coordinates></location_coordinates> + + <dl_config_timing>500</dl_config_timing> + <ul_config_timing>500</ul_config_timing> + <tx_timing>500</tx_timing> + <hi_dci0_timing>500</hi_dci0_timing> + + <max_phys>1</max_phys> + <max_total_bandwidth>30</max_total_bandwidth> + <max_total_num_dl_layers>1</max_total_num_dl_layers> + <max_total_num_ul_layers>1</max_total_num_ul_layers> + + <shared_bands>0</shared_bands> + <shared_pas>0</shared_pas> + + <maximum_total_power>0</maximum_total_power> + + <oui>ALPHA</oui> + + <phys> + <phy> + <index>88</index> + <port>2500</port> + <address>127.0.0.1</address> + + <duplex_mode>1</duplex_mode> + <downlink_channel_bandwidth_support>22</downlink_channel_bandwidth_support> + <uplink_channel_bandwidth_support>22</uplink_channel_bandwidth_support> + <number_of_dl_layers>1</number_of_dl_layers> + <number_of_ul_layers>1</number_of_ul_layers> + <3gpp_release_supported>31</3gpp_release_supported> + <nmm_modes_supported>0</nmm_modes_supported> + <dl_ues_per_subframe>8</dl_ues_per_subframe> + <ul_ues_per_subframe>8</ul_ues_per_subframe> + + <rfs> + <index>0</index> + </rfs> + <excluded_rfs/> + </phy> + <phy> + <index>44</index> + <port>2600</port> + <address>127.0.0.1</address> + + <duplex_mode>1</duplex_mode> + <downlink_channel_bandwidth_support>22</downlink_channel_bandwidth_support> + <uplink_channel_bandwidth_support>22</uplink_channel_bandwidth_support> + <number_of_dl_layers>1</number_of_dl_layers> + <number_of_ul_layers>1</number_of_ul_layers> + <3gpp_release_supported>31</3gpp_release_supported> + <nmm_modes_supported>0</nmm_modes_supported> + <dl_ues_per_subframe>8</dl_ues_per_subframe> + <ul_ues_per_subframe>8</ul_ues_per_subframe> + + <rfs> + <index>1</index> + </rfs> + <excluded_rfs/> + </phy> + </phys> + <rfs> + <rf> + <index>0</index> + <band>2</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + <rf> + <index>1</index> + <band>4</band> + <max_transmit_power>-30</max_transmit_power> + <min_transmit_power>-230</min_transmit_power> + <num_antennas_supported>2</num_antennas_supported> + <min_downlink_frequency>1890</min_downlink_frequency> + <max_downlink_frequency>1890</max_downlink_frequency> + <max_uplink_frequency>1890</max_uplink_frequency> + <min_uplink_frequency>1890</min_uplink_frequency> + </rf> + </rfs> +</pnf> diff --git a/nfapi/open-nFAPI/xml/vnf_A.xml b/nfapi/open-nFAPI/xml/vnf_A.xml new file mode 100644 index 0000000000000000000000000000000000000000..3791239ce7821929893d206605b487efd3e4a4f3 --- /dev/null +++ b/nfapi/open-nFAPI/xml/vnf_A.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<vnf> + <vnf_p7_list> + <vnf_p7> + <port>5201</port> + <address>192.168.1.28</address> + <timing_window>10</timing_window> + <periodic_timing_enabled>0</periodic_timing_enabled> + <periodic_timing_window>0</periodic_timing_window> + <aperiodic_timing_enabled>0</aperiodic_timing_enabled> + + <data> + <udp> + <rx_port>8891</rx_port> + <tx_addr>192.168.1.28</tx_addr> + <tx_port>8892</tx_port> + </udp> + </data> + </vnf_p7> + </vnf_p7_list> +</vnf> diff --git a/nfapi/open-nFAPI/xml/vnf_A_ws.xml b/nfapi/open-nFAPI/xml/vnf_A_ws.xml new file mode 100644 index 0000000000000000000000000000000000000000..c26adc3cfa11980c9f9697eceefe6de602eb6846 --- /dev/null +++ b/nfapi/open-nFAPI/xml/vnf_A_ws.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<vnf> + + <vnf_p7_list> + <vnf_p7> + <wireshark_test_mode>1</wireshark_test_mode> + <port>5200</port> + <address>127.0.0.1</address> + <timing_window>10</timing_window> + <periodic_timing_enabled>0</periodic_timing_enabled> + <periodic_timing_window>0</periodic_timing_window> + <aperiodic_timing_enabled>0</aperiodic_timing_enabled> + + <data> + <udp> + <rx_port>8891</rx_port> + <tx_addr>127.0.0.1</tx_addr> + <tx_port>8892</tx_port> + </udp> + </data> + </vnf_p7> + </vnf_p7_list> +</vnf> diff --git a/open-nfapi.oai.patch b/nfapi/open-nfapi.oai.patch similarity index 100% rename from open-nfapi.oai.patch rename to nfapi/open-nfapi.oai.patch diff --git a/openair1/Makefile b/openair1/Makefile deleted file mode 100644 index 04be9ff8b0ed954d4019967c5d1dc707247db9dd..0000000000000000000000000000000000000000 --- a/openair1/Makefile +++ /dev/null @@ -1,121 +0,0 @@ -# command line flags are automatically exported and thus passed down to any sub-make. -# here we set the default flags in case on command line flags are provided -# these flags have to be explicitely exported so that the sub-make is aware of them - - -include $(OPENAIR_DIR)/common/utils/Makefile.inc -ifndef OPENAIR_LTE -export OPENAIR_LTE=1 -endif - -ifndef OPENAIR1 -export OPENAIR1=1 -endif - -ifndef OPENAIR2 -export OPENAIR2=0 -endif - -ifndef EMOS -export EMOS=0 -endif - -ifndef FIRMWARE2010 -export FIRMWARE2010=0 -endif - -all: openair_rf_cbmimo1_softmodem.ko asn1_msg_kern.ko - -openair_rf_cbmimo1_softmodem.ko: - (cd ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) -C $(KERNEL_DIR)/build V=1 M=`pwd` RTAI=1 CBMIMO1=1 && mv openair_rf.ko openair_rf_softmodem.ko) - -oai_user_cbmimo1.ko: - (cd ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) -C $(KERNEL_DIR)/build V=1 M=`pwd` RTAI=1 CBMIMO1=1 BIT8_TX=1 OPENAIR1=0 OPENAIR2=0 && mv openair_rf.ko openair_rf_softmodem.ko) - -oai_user_exmimo.ko: - (cd ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) -C $(KERNEL_DIR)/build V=1 M=`pwd` RTAI=1 CBMIMO1=1 OPENAIR1=0 OPENAIR2=0 && mv openair_rf.ko openair_rf_softmodem.ko) - -asn1_msg_kern.ko: - (cd ../openair2/RRC/LITE/MESSAGES && $(MAKE) -C $(KERNEL_DIR) V=0 M=`pwd` RTAI=1 -j2) - -#Remove all but source files -cleanall: - find -name '*.o' -delete -print; \ - find -name '*.ko' -delete -print; \ - find -name '*.bak' -delete -print; \ - find -name '*.cmd' -delete -print; \ - find -name '*~' -delete -print; \ - find -name octave-core -delete -print; \ - -#Remove files created by SVN, dangerous!!! DO NOT RUN ON YOUR WORKING REPOSITORY! -#FK: Don't do this! Use svn export instead. -#cleansvn: -# rm -rf `find -name *.svn* -print`; \ -# find -name *.svn* -delete -print - -tgz: - mkdir /tmp/openair1_tmp; \ - $(MAKE) cleanall; \ - cp -r . /tmp/openair1_tmp; \ - (cd /tmp/openair1_tmp && $(MAKE) cleansvn && cd .. && tar czfv openair1.tgz openair1_tmp) ; \ - cp /tmp/openair1.tgz . ;\ - rm -rf /tmp/openair1_tmp - -fifos: - @for i in `seq 0 64`;\ - do \ - have_rtfX=`ls /dev/ |grep -c rtf$$i`;\ - if [ "$$have_rtfX" -eq 0 ] ;then \ - mknod -m 666 /dev/rtf$$i c 150 $$i; \ - fi;\ - done - -openair0: - mknod /dev/openair0 c 127 0 - chmod a+rw /dev/openair0 - -install_oai_user: - make fifos - insmod ARCH/CBMIMO1/DEVICE_DRIVER/openair_rf_softmodem.ko - -updatefw: - USERSPACE_TOOLS/OAI_FW_INIT/updatefw -f $$OPENAIR0_DIR/express-mimo/software/sdr_exmimo2/main -s 0x43fffff0 - -boot_exmimo: - sudo make install_oai_user - USERSPACE_TOOLS/OAI_FW_INIT/updatefw -f $$OPENAIR0_DIR/express-mimo/software/sdr/main -s 0x43fffff0 - sudo rmmod openair_rf - sudo make install_oai_user - -reboot_exmimo: - USERSPACE_TOOLS/OAI_FW_INIT/updatefw -f $$OPENAIR0_DIR/express-mimo/software/sdr/main -s 0x43fffff0 -b - rmmod openair_rf - make install_oai_user - USERSPACE_TOOLS/OAI_FW_INIT/updatefw -f $$OPENAIR0_DIR/express-mimo/software/sdr/main -s 0x43fffff0 - rmmod openair_rf - make install_oai_user - -install_softmodem: - make fifos -ifeq ($(OPENAIR2),1) - insmod ../openair2/RRC/LITE/MESSAGES/asn1_msg_kern.ko -endif - insmod ARCH/CBMIMO1/DEVICE_DRIVER/openair_rf_softmodem.ko ; \ - -remove: - rmmod openair_rf -ifeq ($(OPENAIR2),1) - rmmod asn1_msg_kern -endif - -test: - (cd ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) test RTAI=1 CBMIMO1=1) - (cd ../openair2/RRC/LITE/MESSAGES && $(MAKE) test) - -clean: clean_l1 - -clean_l1: - (cd ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) clean RTAI=1 CBMIMO1=1) - -clean_asn1: - (cd ../openair2/RRC/LITE/MESSAGES && $(MAKE) clean) diff --git a/openair1/PHY/CODING/Makefile.arm b/openair1/PHY/CODING/Makefile.arm index 07dbf559098a689e12c8db2d657fb16c296f363c..04598075e325aaa6b048b8a4e9ca54625793214a 100644 --- a/openair1/PHY/CODING/Makefile.arm +++ b/openair1/PHY/CODING/Makefile.arm @@ -5,7 +5,7 @@ RATE12CC_SRC = ccoding_byte.c viterbi.c crc_byte.c all: 3gpplte_sse 3gpplte_sse: $(TURBO_SRC) - gcc -O3 -gdwarf-2 -mfloat-abi=hard -mfpu=neon -lm -lgcc -lrt ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DUSER_MODE -DTC_MAIN -DNB_ANTENNAS_RX=1 -o 3gpplte_sse 3gpplte_sse.c -Wall -g -ggdb -DTC_MAIN + gcc -O3 -gdwarf-2 -mfloat-abi=hard -mfpu=neon -lm -lgcc -lrt ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DTC_MAIN -DNB_ANTENNAS_RX=1 -o 3gpplte_sse 3gpplte_sse.c -Wall -g -ggdb -DTC_MAIN diff --git a/openair1/PHY/CODING/TESTBENCH/Makefile b/openair1/PHY/CODING/TESTBENCH/Makefile index a8ddd1fcb55b59875f018b17cb8e2ca4f95b30a1..030f19b47bb0747fa1c28c944721fa74ca6a487b 100644 --- a/openair1/PHY/CODING/TESTBENCH/Makefile +++ b/openair1/PHY/CODING/TESTBENCH/Makefile @@ -7,7 +7,7 @@ OPENAIR2_TOP = $(OPENAIR2_DIR) OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -DNODE_RG -DUSER_MODE -DPC_TARGET -DNO_UL_REF -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DOPENAIR_LTE -DMAX_NUM_CCs=1 +CFLAGS += -DNODE_RG -DNO_UL_REF -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DOPENAIR_LTE -DMAX_NUM_CCs=1 ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 4f0dcf2196749111989bd5f8e9cc5567476b97b9..5ec4fcaaa4bc73f8a26aec421159a4c0286c9ecf 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -31,13 +31,6 @@ */ -#ifndef USER_MODE -#define __NO_VERSION__ - -#endif - -//#include "PHY/types.h" - #include "defs.h" diff --git a/openair1/PHY/CODING/defs.h b/openair1/PHY/CODING/defs.h index 06311a188bc9c9123162df5a3467fd0723608e9e..80e28b15867e79244181cfe8c02fc28000f22a56 100644 --- a/openair1/PHY/CODING/defs.h +++ b/openair1/PHY/CODING/defs.h @@ -29,11 +29,7 @@ #include <stdint.h> -#ifndef NO_OPENAIR1 #include "PHY/defs.h" -#else -#include "PHY/TOOLS/time_meas.h" -#endif #define CRC24_A 0 #define CRC24_B 1 diff --git a/openair1/PHY/CODING/viterbi_lte.c b/openair1/PHY/CODING/viterbi_lte.c index d112e7c10958aa91db1ef898c4575a492c886d07..5e11cb3453ab9dd2f425a175389acfd0edcca432 100644 --- a/openair1/PHY/CODING/viterbi_lte.c +++ b/openair1/PHY/CODING/viterbi_lte.c @@ -28,10 +28,6 @@ date: 21.10.2009 */ -#ifdef USER_MODE -#include <stdio.h> -#endif - #ifndef TEST_DEBUG #include "PHY/defs.h" #include "PHY/extern.h" @@ -126,7 +122,7 @@ void print_shorts(__m128i x,char *s) { } */ -#endif // USER_MODE +#endif // DEBUG_VITERBI diff --git a/openair1/PHY/INIT/init_top.c b/openair1/PHY/INIT/init_top.c index c4d5850501813961470a02f9ca90c0391f947114..43f2de92d764719d330949c4c7685eaf54901dd9 100644 --- a/openair1/PHY/INIT/init_top.c +++ b/openair1/PHY/INIT/init_top.c @@ -20,25 +20,44 @@ */ /*!\brief Initilization and reconfiguration routines for LTE PHY */ -#ifndef USER_MODE -#define __NO_VERSION__ -#endif - #include "defs.h" #include "PHY/extern.h" -#include "MAC_INTERFACE/extern.h" -//#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h" -/*! -* @addtogroup _PHY_STRUCTURES_ -* Memory Initializaion and Cleanup for LTE MODEM. -* @{ -\section _Memory_init_ Memory Initialization for LTE MODEM +void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) +{ + + crcTableInit(); + + ccodedot11_init(); + ccodedot11_init_inv(); + + ccodelte_init(); + ccodelte_init_inv(); + + treillis_table_init(); + + phy_generate_viterbi_tables(); + phy_generate_viterbi_tables_lte(); + init_td8(); + init_td16(); +#ifdef __AVX2__ + init_td16avx2(); +#endif + lte_sync_time_init(frame_parms); + + generate_ul_ref_sigs(); + generate_ul_ref_sigs_rx(); + + generate_64qam_table(); + generate_16qam_table(); + generate_RIV_tables(); + + init_unscrambling_lut(); + init_scrambling_lut(); + //set_taus_seed(1328); -*/ -//#define DEBUG_PHY -t +} /* diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index d0e6919de7b8c6e5488178034e3e3b7a227d3611..94f2da4add7f386409936b61d757897667070eb3 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -326,36 +326,6 @@ void phy_config_request(PHY_Config_t *phy_config) { LOG_I(PHY,"eNB %d/%d configured\n",Mod_id,CC_id); } - -/* Panos: New function of the UE MAC interface: This function -should copy the values assigned to the interface parameters -(within MAC/config.c) to the PHY frame configuration. It should be called at the end of -config::rrc_mac_config_request_ue()*/ - -void phy_config_request_ue (UE_PHY_Config_t* UE_config_INFO) -{ - -} - - -void phy_config_sib1_ue(uint8_t Mod_id,int CC_id, - uint8_t eNB_id, - TDD_Config_t *tdd_Config, - uint8_t SIwindowsize, - uint16_t SIperiod) -{ - - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; - - if (tdd_Config) { - fp->tdd_config = tdd_Config->subframeAssignment; - fp->tdd_config_S = tdd_Config->specialSubframePatterns; - } - - fp->SIwindowsize = SIwindowsize; - fp->SIPeriod = SIperiod; -} - /* void phy_config_sib2_eNB(uint8_t Mod_id, int CC_id, @@ -433,6 +403,7 @@ void phy_config_sib2_eNB(uint8_t Mod_id, fp->soundingrs_ul_config_common.enabled_flag = 0; if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.present==SoundingRS_UL_ConfigCommon_PR_setup) { + fp->soundingrs_ul_config_common.enabled_flag = 1; fp->soundingrs_ul_config_common.srs_BandwidthConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig; fp->soundingrs_ul_config_common.srs_SubframeConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig; @@ -499,149 +470,6 @@ void phy_config_sib2_eNB(uint8_t Mod_id, } */ -void phy_config_sib2_ue(uint8_t Mod_id,int CC_id, - uint8_t eNB_id, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - ARFCN_ValueEUTRA_t *ul_CarrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList) -{ - - PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id]; - LTE_DL_FRAME_PARMS *fp = &ue->frame_parms; - int i; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_IN); - - LOG_I(PHY,"[UE%d] Applying radioResourceConfigCommon from eNB%d\n",Mod_id,eNB_id); - - fp->prach_config_common.rootSequenceIndex =radioResourceConfigCommon->prach_Config.rootSequenceIndex; - - fp->prach_config_common.prach_Config_enabled=1; - fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex; - fp->prach_config_common.prach_ConfigInfo.highSpeedFlag =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.highSpeedFlag; - fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; - fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset; - - compute_prach_seq(fp->prach_config_common.rootSequenceIndex, - fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, - fp->prach_config_common.prach_ConfigInfo.highSpeedFlag, - fp->frame_type,ue->X_u); - - - - fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon.deltaPUCCH_Shift; - fp->pucch_config_common.nRB_CQI = radioResourceConfigCommon->pucch_ConfigCommon.nRB_CQI; - fp->pucch_config_common.nCS_AN = radioResourceConfigCommon->pucch_ConfigCommon.nCS_AN; - fp->pucch_config_common.n1PUCCH_AN = radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN; - - - - fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon.referenceSignalPower; - fp->pdsch_config_common.p_b = radioResourceConfigCommon->pdsch_ConfigCommon.p_b; - - - fp->pusch_config_common.n_SB = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; - fp->pusch_config_common.hoppingMode = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; - fp->pusch_config_common.pusch_HoppingOffset = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; - fp->pusch_config_common.enable64QAM = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = dmrs1_tab[radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift]; - - - init_ul_hopping(fp); - fp->soundingrs_ul_config_common.enabled_flag = 0; - - if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.present==SoundingRS_UL_ConfigCommon_PR_setup) { - fp->soundingrs_ul_config_common.enabled_flag = 1; - fp->soundingrs_ul_config_common.srs_BandwidthConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig; - fp->soundingrs_ul_config_common.srs_SubframeConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig; - fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; - - if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) - fp->soundingrs_ul_config_common.srs_MaxUpPts = 1; - else - fp->soundingrs_ul_config_common.srs_MaxUpPts = 0; - } - - - - fp->ul_power_control_config_common.p0_NominalPUSCH = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUSCH; - fp->ul_power_control_config_common.alpha = radioResourceConfigCommon->uplinkPowerControlCommon.alpha; - fp->ul_power_control_config_common.p0_NominalPUCCH = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUCCH; - fp->ul_power_control_config_common.deltaPreambleMsg3 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaPreambleMsg3; - fp->ul_power_control_config_common.deltaF_PUCCH_Format1 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1; - fp->ul_power_control_config_common.deltaF_PUCCH_Format1b = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b; - fp->ul_power_control_config_common.deltaF_PUCCH_Format2 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2; - fp->ul_power_control_config_common.deltaF_PUCCH_Format2a = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a; - fp->ul_power_control_config_common.deltaF_PUCCH_Format2b = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b; - - fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx; - - // Now configure some of the Physical Channels - - // PUCCH - init_ncs_cell(fp,ue->ncs_cell); - - init_ul_hopping(fp); - - // PCH - init_ue_paging_info(ue,radioResourceConfigCommon->pcch_Config.defaultPagingCycle,radioResourceConfigCommon->pcch_Config.nB); - - // MBSFN - - if (mbsfn_SubframeConfigList != NULL) { - fp->num_MBSFN_config = mbsfn_SubframeConfigList->list.count; - - for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) { - fp->MBSFN_config[i].radioframeAllocationPeriod = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod; - fp->MBSFN_config[i].radioframeAllocationOffset = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset; - - if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { - fp->MBSFN_config[i].fourFrames_flag = 0; - fp->MBSFN_config[i].mbsfn_SubframeConfig = mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]; // 6-bit subframe configuration - LOG_I(PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is %d\n", i, - fp->MBSFN_config[i].mbsfn_SubframeConfig); - } else if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_fourFrames) { // 24-bit subframe configuration - fp->MBSFN_config[i].fourFrames_flag = 1; - fp->MBSFN_config[i].mbsfn_SubframeConfig = - mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]| - (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[1]<<8)| - (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[2]<<16); - - LOG_I(PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is %d\n", i, - fp->MBSFN_config[i].mbsfn_SubframeConfig); - } - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_OUT); - -} - -void phy_config_sib13_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id,int mbsfn_Area_idx, - long mbsfn_AreaId_r9) -{ - - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; - - - LOG_I(PHY,"[UE%d] Applying MBSFN_Area_id %ld for index %d\n",Mod_id,mbsfn_AreaId_r9,mbsfn_Area_idx); - - if (mbsfn_Area_idx == 0) { - fp->Nid_cell_mbsfn = (uint16_t)mbsfn_AreaId_r9; - LOG_N(PHY,"Fix me: only called when mbsfn_Area_idx == 0)\n"); - } - - lte_gold_mbsfn(fp,PHY_vars_UE_g[Mod_id][CC_id]->lte_gold_mbsfn_table,fp->Nid_cell_mbsfn); - -} - - void phy_config_sib13_eNB(uint8_t Mod_id,int CC_id,int mbsfn_Area_idx, long mbsfn_AreaId_r9) { @@ -708,9 +536,9 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB) eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - LOG_D(PHY,"pusch_config_dedicated.betaOffset_ACK_Index %d\n",eNB->pusch_config_dedicated[UE_id].betaOffset_ACK_Index); - LOG_D(PHY,"pusch_config_dedicated.betaOffset_RI_Index %d\n",eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index); - LOG_D(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d\n",eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index); + LOG_E(PHY,"pusch_config_dedicated.betaOffset_ACK_Index %d\n",eNB->pusch_config_dedicated[UE_id].betaOffset_ACK_Index); + LOG_E(PHY,"pusch_config_dedicated.betaOffset_RI_Index %d\n",eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index); + LOG_E(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d\n",eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index); LOG_D(PHY,"\n"); @@ -780,157 +608,12 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB) } } -/* - * Configures UE MAC and PHY with radioResourceCommon received in mobilityControlInfo IE during Handover - */ -void phy_config_afterHO_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_id, MobilityControlInfo_t *mobilityControlInfo, uint8_t ho_failed) -{ - - if(mobilityControlInfo!=NULL) { - RadioResourceConfigCommon_t *radioResourceConfigCommon = &mobilityControlInfo->radioResourceConfigCommon; - LOG_I(PHY,"radioResourceConfigCommon %p\n", radioResourceConfigCommon); - memcpy((void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms_before_ho, - (void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms, - sizeof(LTE_DL_FRAME_PARMS)); - PHY_vars_UE_g[Mod_id][CC_id]->ho_triggered = 1; - //PHY_vars_UE_g[UE_id]->UE_mode[0] = PRACH; - - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; - // int N_ZC; - // uint8_t prach_fmt; - // int u; - - LOG_I(PHY,"[UE%d] Handover triggered: Applying radioResourceConfigCommon from eNB %d\n", - Mod_id,eNB_id); - - fp->prach_config_common.rootSequenceIndex =radioResourceConfigCommon->prach_Config.rootSequenceIndex; - fp->prach_config_common.prach_Config_enabled=1; - fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex; - fp->prach_config_common.prach_ConfigInfo.highSpeedFlag =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->highSpeedFlag; - fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->zeroCorrelationZoneConfig; - fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_FreqOffset; - - // prach_fmt = get_prach_fmt(radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex,fp->frame_type); - // N_ZC = (prach_fmt <4)?839:139; - // u = (prach_fmt < 4) ? prach_root_sequence_map0_3[fp->prach_config_common.rootSequenceIndex] : - // prach_root_sequence_map4[fp->prach_config_common.rootSequenceIndex]; - - //compute_prach_seq(u,N_ZC, PHY_vars_UE_g[Mod_id]->X_u); - compute_prach_seq(PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.rootSequenceIndex, - PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, - PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag, - fp->frame_type, - PHY_vars_UE_g[Mod_id][CC_id]->X_u); - - - fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon->deltaPUCCH_Shift; - fp->pucch_config_common.nRB_CQI = radioResourceConfigCommon->pucch_ConfigCommon->nRB_CQI; - fp->pucch_config_common.nCS_AN = radioResourceConfigCommon->pucch_ConfigCommon->nCS_AN; - fp->pucch_config_common.n1PUCCH_AN = radioResourceConfigCommon->pucch_ConfigCommon->n1PUCCH_AN; - fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon->referenceSignalPower; - fp->pdsch_config_common.p_b = radioResourceConfigCommon->pdsch_ConfigCommon->p_b; - - - fp->pusch_config_common.n_SB = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; - fp->pusch_config_common.hoppingMode = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; - fp->pusch_config_common.pusch_HoppingOffset = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; - fp->pusch_config_common.enable64QAM = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled; - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift; - - init_ul_hopping(fp); - fp->soundingrs_ul_config_common.enabled_flag = 0; - - if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->present==SoundingRS_UL_ConfigCommon_PR_setup) { - fp->soundingrs_ul_config_common.enabled_flag = 1; - fp->soundingrs_ul_config_common.srs_BandwidthConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_BandwidthConfig; - fp->soundingrs_ul_config_common.srs_SubframeConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig; - fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.ackNackSRS_SimultaneousTransmission; - - if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_MaxUpPts) - fp->soundingrs_ul_config_common.srs_MaxUpPts = 1; - else - fp->soundingrs_ul_config_common.srs_MaxUpPts = 0; - } - - fp->ul_power_control_config_common.p0_NominalPUSCH = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUSCH; - fp->ul_power_control_config_common.alpha = radioResourceConfigCommon->uplinkPowerControlCommon->alpha; - fp->ul_power_control_config_common.p0_NominalPUCCH = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUCCH; - fp->ul_power_control_config_common.deltaPreambleMsg3 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaPreambleMsg3; - fp->ul_power_control_config_common.deltaF_PUCCH_Format1 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1; - fp->ul_power_control_config_common.deltaF_PUCCH_Format1b = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1b; - fp->ul_power_control_config_common.deltaF_PUCCH_Format2 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2; - fp->ul_power_control_config_common.deltaF_PUCCH_Format2a = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2a; - fp->ul_power_control_config_common.deltaF_PUCCH_Format2b = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2b; - - fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon->maxHARQ_Msg3Tx; - - // Now configure some of the Physical Channels - if (radioResourceConfigCommon->antennaInfoCommon) - fp->nb_antennas_tx = (1<<radioResourceConfigCommon->antennaInfoCommon->antennaPortsCount); - else - fp->nb_antennas_tx = 1; - - //PHICH - if (radioResourceConfigCommon->antennaInfoCommon) { - fp->phich_config_common.phich_resource = radioResourceConfigCommon->phich_Config->phich_Resource; - fp->phich_config_common.phich_duration = radioResourceConfigCommon->phich_Config->phich_Duration; - } - - //Target CellId - fp->Nid_cell = mobilityControlInfo->targetPhysCellId; - fp->nushift = fp->Nid_cell%6; - - // PUCCH - init_ncs_cell(fp,PHY_vars_UE_g[Mod_id][CC_id]->ncs_cell); - - init_ul_hopping(fp); - - // RNTI - - - PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8); - PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8); - - LOG_I(PHY,"SET C-RNTI %x %x\n",PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti, - PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti); - } - - if(ho_failed) { - LOG_D(PHY,"[UE%d] Handover failed, triggering RACH procedure\n",Mod_id); - memcpy((void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms,(void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms_before_ho, sizeof(LTE_DL_FRAME_PARMS)); - PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[eNB_id] = PRACH; - } -} - -void phy_config_meas_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,unsigned int *adj_cell_id) -{ - - PHY_MEASUREMENTS *phy_meas = &PHY_vars_UE_g[Mod_id][CC_id]->measurements; - int i; - - LOG_I(PHY,"Configuring inter-cell measurements for %d cells, ids: \n",n_adj_cells); - - for (i=0; i<n_adj_cells; i++) { - LOG_I(PHY,"%d\n",adj_cell_id[i]); - lte_gold(&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms,PHY_vars_UE_g[Mod_id][CC_id]->lte_gold_table[i+1],adj_cell_id[i]); - } - - phy_meas->n_adj_cells = n_adj_cells; - memcpy((void*)phy_meas->adj_cell_id,(void *)adj_cell_id,n_adj_cells*sizeof(unsigned int)); - -} - /* void phy_config_dedicated_eNB(uint8_t Mod_id, int CC_id, uint16_t rnti, struct PhysicalConfigDedicated *physicalConfigDedicated) { - PHY_VARS_eNB *eNB = RC.eNB[Mod_id][CC_id]; int8_t UE_id = find_ue(rnti,eNB); int i; @@ -984,26 +667,15 @@ void phy_config_dedicated_eNB(uint8_t Mod_id, LOG_E(PHY,"[eNB %d] Received NULL radioResourceConfigDedicated from eNB %d\n",Mod_id, UE_id); return; } - } */ -#if defined(Rel10) || defined(Rel14) -void phy_config_dedicated_scell_ue(uint8_t Mod_id, - uint8_t eNB_index, - SCellToAddMod_r10_t *sCellToAddMod_r10, - int CC_id) -{ - -} /* void phy_config_dedicated_scell_eNB(uint8_t Mod_id, uint16_t rnti, SCellToAddMod_r10_t *sCellToAddMod_r10, int CC_id) { - - uint8_t UE_id = find_ue(rnti,RC.eNB[Mod_id][0]); struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; //struct RadioResourceConfigCommonSCell_r10 *physicalConfigCommonSCell_r10 = sCellToAddMod_r10->radioResourceConfigCommonSCell_r10; @@ -1045,252 +717,6 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id, } */ -#endif - - -void phy_config_harq_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, - uint16_t max_harq_tx ) -{ - - PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; - phy_vars_ue->ulsch[eNB_id]->Mlimit = max_harq_tx; -} - -extern uint16_t beta_cqi[16]; - -void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, - struct PhysicalConfigDedicated *physicalConfigDedicated ) -{ - - static uint8_t first_dedicated_configuration = 0; - PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; - - phy_vars_ue->total_TBS[eNB_id]=0; - phy_vars_ue->total_TBS_last[eNB_id]=0; - phy_vars_ue->bitrate[eNB_id]=0; - phy_vars_ue->total_received_bits[eNB_id]=0; - phy_vars_ue->dlsch_errors[eNB_id]=0; - phy_vars_ue->dlsch_errors_last[eNB_id]=0; - phy_vars_ue->dlsch_received[eNB_id]=0; - phy_vars_ue->dlsch_received_last[eNB_id]=0; - phy_vars_ue->dlsch_fer[eNB_id]=0; - - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; - - if (physicalConfigDedicated) { - LOG_D(PHY,"[UE %d] Received physicalConfigDedicated from eNB %d\n",Mod_id, eNB_id); - LOG_D(PHY,"------------------------------------------------------------------------\n"); - - if (physicalConfigDedicated->pdsch_ConfigDedicated) { - phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a=physicalConfigDedicated->pdsch_ConfigDedicated->p_a; - LOG_D(PHY,"pdsch_config_dedicated.p_a %d\n",phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a); - LOG_D(PHY,"\n"); - } - - if (physicalConfigDedicated->pucch_ConfigDedicated) { - if (physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.present==PUCCH_ConfigDedicated__ackNackRepetition_PR_release) - phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=0; - else { - phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=1; - } - - if (physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode) - phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = *physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; - else - phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = bundling; - - if ( phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode == multiplexing) - LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = multiplexing\n"); - else - LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = bundling\n"); - } - - if (physicalConfigDedicated->pusch_ConfigDedicated) { - phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; - phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; - phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - - - LOG_D(PHY,"pusch_config_dedicated.betaOffset_ACK_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index); - LOG_D(PHY,"pusch_config_dedicated.betaOffset_RI_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index); - LOG_D(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d => %d)\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index,beta_cqi[phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index]); - LOG_D(PHY,"\n"); - - - } - - if (physicalConfigDedicated->uplinkPowerControlDedicated) { - - phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH = physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUSCH; - phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled= physicalConfigDedicated->uplinkPowerControlDedicated->deltaMCS_Enabled; - phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled= physicalConfigDedicated->uplinkPowerControlDedicated->accumulationEnabled; - phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH= physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUCCH; - phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset= physicalConfigDedicated->uplinkPowerControlDedicated->pSRS_Offset; - phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient= *physicalConfigDedicated->uplinkPowerControlDedicated->filterCoefficient; - LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUSCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH); - LOG_D(PHY,"ul_power_control_dedicated.deltaMCS_Enabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled); - LOG_D(PHY,"ul_power_control_dedicated.accumulationEnabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled); - LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUCCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH); - LOG_D(PHY,"ul_power_control_dedicated.pSRS_Offset %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset); - LOG_D(PHY,"ul_power_control_dedicated.filterCoefficient %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient); - LOG_D(PHY,"\n"); - } - - if (physicalConfigDedicated->antennaInfo) { - phy_vars_ue->transmission_mode[eNB_id] = 1+(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode); - LOG_I(PHY,"Transmission Mode %d\n",phy_vars_ue->transmission_mode[eNB_id]); - switch(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode) { - case AntennaInfoDedicated__transmissionMode_tm1: - phy_vars_ue->transmission_mode[eNB_id] = 1; - break; - case AntennaInfoDedicated__transmissionMode_tm2: - phy_vars_ue->transmission_mode[eNB_id] = 2; - break; - case AntennaInfoDedicated__transmissionMode_tm3: - phy_vars_ue->transmission_mode[eNB_id] = 3; - break; - case AntennaInfoDedicated__transmissionMode_tm4: - phy_vars_ue->transmission_mode[eNB_id] = 4; - break; - case AntennaInfoDedicated__transmissionMode_tm5: - phy_vars_ue->transmission_mode[eNB_id] = 5; - break; - case AntennaInfoDedicated__transmissionMode_tm6: - phy_vars_ue->transmission_mode[eNB_id] = 6; - break; - case AntennaInfoDedicated__transmissionMode_tm7: - lte_gold_ue_spec_port5(phy_vars_ue->lte_gold_uespec_port5_table, phy_vars_ue->frame_parms.Nid_cell, phy_vars_ue->pdcch_vars[0][eNB_id]->crnti); - phy_vars_ue->transmission_mode[eNB_id] = 7; - break; - default: - LOG_E(PHY,"Unknown transmission mode!\n"); - break; - } - } else { - LOG_D(PHY,"[UE %d] Received NULL physicalConfigDedicated->antennaInfo from eNB %d\n",Mod_id, eNB_id); - } - - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 1 \n"); - if (physicalConfigDedicated->schedulingRequestConfig) { - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 2 \n"); - if (physicalConfigDedicated->schedulingRequestConfig->present == SchedulingRequestConfig_PR_setup) { - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 3 \n"); - phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex = physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex; - phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex=physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_ConfigIndex; - phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax=physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax; - - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 4 \n"); - LOG_D(PHY,"scheduling_request_config.sr_PUCCH_ResourceIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - LOG_D(PHY,"scheduling_request_config.sr_ConfigIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex); - LOG_D(PHY,"scheduling_request_config.dsr_TransMax %d\n",phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax); - } - - LOG_D(PHY,"------------------------------------------------------------\n"); - - } - - if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { - - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 5 \n"); - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 0; - if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 1; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].freqDomainPosition = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_Bandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth; - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].transmissionComb = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; - - - LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex); - } - - LOG_D(PHY,"------------------------------------------------------------\n"); - - } - - - if (physicalConfigDedicated->cqi_ReportConfig) { - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 6.0 \n"); - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic) { - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 6 \n"); - // configure PUSCH CQI reporting - phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; - if ((phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm12) && - (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm30) && - (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm31)) - LOG_E(PHY,"Unsupported Aperiodic CQI Feedback Mode : %d\n",phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic); - } - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) { - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 7 \n"); - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_setup) { - // configure PUCCH CQI reporting - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; - if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex; - } - else if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_release) { - // handle release - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; - } - } - } - -#ifdef CBA - - if (physicalConfigDedicated->pusch_CBAConfigDedicated_vlola) { - phy_vars_ue->pusch_ca_config_dedicated[eNB_id].betaOffset_CA_Index = (uint16_t) *physicalConfigDedicated->pusch_CBAConfigDedicated_vlola->betaOffset_CBA_Index; - phy_vars_ue->pusch_ca_config_dedicated[eNB_id].cShift = (uint16_t) *physicalConfigDedicated->pusch_CBAConfigDedicated_vlola->cShift_CBA; - LOG_D(PHY,"[UE %d ] physicalConfigDedicated pusch CBA config dedicated: beta offset %d cshift %d \n",Mod_id, - phy_vars_ue->pusch_ca_config_dedicated[eNB_id].betaOffset_CA_Index, - phy_vars_ue->pusch_ca_config_dedicated[eNB_id].cShift); - } - -#endif - } else { - LOG_D(PHY,"[PHY][UE %d] Received NULL radioResourceConfigDedicated from eNB %d\n",Mod_id,eNB_id); - return; - } - - // fill cqi parameters for periodic CQI reporting - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 8 \n"); - get_cqipmiri_params(phy_vars_ue,eNB_id); - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 9 \n"); - - // disable MIB SIB decoding once we are on connected mode - first_dedicated_configuration ++; - if(first_dedicated_configuration > 1) - { - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 10 \n"); - LOG_I(PHY,"Disable SIB MIB decoding \n"); - phy_vars_ue->decode_SIB = 0; - phy_vars_ue->decode_MIB = 0; - } - //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; - LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 11.0 \n"); - - if(nfapi_mode!=3){ - if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234) { - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 11 \n"); - phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; - } - else{ - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 12 \n"); - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; - } - //LOG_I(PHY,"Panos-D: phy_config_dedicated_ue 13 \n"); - - LOG_I(PHY,"C-RNTI %x %x \n", phy_vars_ue->pdcch_vars[0][eNB_id]->crnti, - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti); - } - -} - void phy_config_cba_rnti (module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, rnti_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups) { // uint8_t i; @@ -1308,546 +734,6 @@ void phy_config_cba_rnti (module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uin } } -void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) -{ - - crcTableInit(); - - ccodedot11_init(); - ccodedot11_init_inv(); - - ccodelte_init(); - ccodelte_init_inv(); - - treillis_table_init(); - - phy_generate_viterbi_tables(); - phy_generate_viterbi_tables_lte(); - init_td8(); - init_td16(); -#ifdef __AVX2__ - init_td16avx2(); -#endif - lte_sync_time_init(frame_parms); - - generate_ul_ref_sigs(); - generate_ul_ref_sigs_rx(); - - generate_64qam_table(); - generate_16qam_table(); - generate_RIV_tables(); - - init_unscrambling_lut(); - init_scrambling_lut(); - //set_taus_seed(1328); - - -} - -/*! \brief Helper function to allocate memory for DLSCH data structures. - * \param[out] pdsch Pointer to the LTE_UE_PDSCH structure to initialize. - * \param[in] frame_parms LTE_DL_FRAME_PARMS structure. - * \note This function is optimistic in that it expects malloc() to succeed. - */ -void phy_init_lte_ue__PDSCH( LTE_UE_PDSCH* const pdsch, const LTE_DL_FRAME_PARMS* const fp ) -{ - AssertFatal( pdsch, "pdsch==0" ); - - pdsch->pmi_ext = (uint8_t*)malloc16_clear( fp->N_RB_DL ); - pdsch->llr[0] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); - pdsch->llr128 = (int16_t**)malloc16_clear( sizeof(int16_t*) ); - // FIXME! no further allocation for (int16_t*)pdsch->llr128 !!! expect SIGSEGV - // FK, 11-3-2015: this is only as a temporary pointer, no memory is stored there - - - pdsch->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->rxdataF_uespec_pilots = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->rxdataF_comp0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->rho = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); - pdsch->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_bf_ch_estimates = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_bf_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - //pdsch->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - //pdsch->dl_ch_rho2_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_ch_mag0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_ch_magb0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - - - // the allocated memory size is fixed: - AssertFatal( fp->nb_antennas_rx <= 2, "nb_antennas_rx > 2" ); - - for (int i=0; i<fp->nb_antennas_rx; i++) { - pdsch->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); - - for (int j=0; j<4; j++) { //fp->nb_antennas_tx; j++) - const int idx = (j<<1)+i; - const size_t num = 7*2*fp->N_RB_DL*12; - pdsch->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->rxdataF_uespec_pilots[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12); - pdsch->rxdataF_comp0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_bf_ch_estimates[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2); - pdsch->dl_bf_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - //pdsch->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - //pdsch->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_mag0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_magb0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - } - } -} - -int init_lte_ue_signal(PHY_VARS_UE *ue, - int nb_connected_eNB, - uint8_t abstraction_flag) -{ - - // create shortcuts - LTE_DL_FRAME_PARMS* const fp = &ue->frame_parms; - LTE_UE_COMMON* const common_vars = &ue->common_vars; - LTE_UE_PDSCH** const pdsch_vars_SI = ue->pdsch_vars_SI; - LTE_UE_PDSCH** const pdsch_vars_ra = ue->pdsch_vars_ra; - LTE_UE_PDSCH** const pdsch_vars_p = ue->pdsch_vars_p; - LTE_UE_PDSCH** const pdsch_vars_mch = ue->pdsch_vars_MCH; - LTE_UE_PDSCH* (*pdsch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX+1] = &ue->pdsch_vars; - LTE_UE_PDCCH* (*pdcch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX] = &ue->pdcch_vars; - LTE_UE_PBCH** const pbch_vars = ue->pbch_vars; - LTE_UE_PRACH** const prach_vars = ue->prach_vars; - - - - int i,j,k,l; - int eNB_id; - int th_id; - - LOG_D(PHY,"Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); - LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST); - - - - init_frame_parms(&ue->frame_parms,1); - init_lte_top(&ue->frame_parms); - init_ul_hopping(&ue->frame_parms); - - - // many memory allocation sizes are hard coded - AssertFatal( fp->nb_antennas_rx <= 2, "hard coded allocation for ue_common_vars->dl_ch_estimates[eNB_id]" ); - AssertFatal( ue->n_connected_eNB <= NUMBER_OF_CONNECTED_eNB_MAX, "n_connected_eNB is too large" ); - // init phy_vars_ue - - for (i=0; i<4; i++) { - ue->rx_gain_max[i] = 135; - ue->rx_gain_med[i] = 128; - ue->rx_gain_byp[i] = 120; - } - - ue->n_connected_eNB = nb_connected_eNB; - - for(eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { - ue->total_TBS[eNB_id] = 0; - ue->total_TBS_last[eNB_id] = 0; - ue->bitrate[eNB_id] = 0; - ue->total_received_bits[eNB_id] = 0; - } - - for (i=0;i<10;i++) - ue->tx_power_dBm[i]=-127; - - - - // init TX buffers - - common_vars->txdata = (int32_t**)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) ); - common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) ); - - for (i=0; i<fp->nb_antennas_tx; i++) { - - common_vars->txdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); - common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); - } - - // init RX buffers - - common_vars->rxdata = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - common_vars->common_vars_rx_data_per_thread[0].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - common_vars->common_vars_rx_data_per_thread[1].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - - for (i=0; i<fp->nb_antennas_rx; i++) { - common_vars->rxdata[i] = (int32_t*) malloc16_clear( (fp->samples_per_tti*10+2048)*sizeof(int32_t) ); - common_vars->common_vars_rx_data_per_thread[0].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); - common_vars->common_vars_rx_data_per_thread[1].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); - } - - - // Channel estimates - for (eNB_id=0; eNB_id<7; eNB_id++) { - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id] = (int32_t**)malloc16_clear(8*sizeof(int32_t*)); - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id] = (int32_t**)malloc16_clear(8*sizeof(int32_t*)); - } - - for (i=0; i<fp->nb_antennas_rx; i++) - for (j=0; j<4; j++) { - int idx = (j<<1) + i; - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->symbols_per_tti*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) ); - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); - } - } - } - - // DLSCH - for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) { - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); - } - - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id] = (LTE_UE_PDCCH *)malloc16_clear(sizeof(LTE_UE_PDCCH)); - } - - pdsch_vars_SI[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); - pdsch_vars_ra[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); - pdsch_vars_p[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); - pdsch_vars_mch[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); - prach_vars[eNB_id] = (LTE_UE_PRACH *)malloc16_clear(sizeof(LTE_UE_PRACH)); - pbch_vars[eNB_id] = (LTE_UE_PBCH *)malloc16_clear(sizeof(LTE_UE_PBCH)); - - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - phy_init_lte_ue__PDSCH( (*pdsch_vars_th)[th_id][eNB_id], fp ); - } - - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts = (uint8_t*)malloc16_clear(7*2*fp->N_RB_DL*12); - (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts_p = (*pdsch_vars_th)[0][eNB_id]->llr_shifts; - (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); - (*pdsch_vars_th)[th_id][eNB_id]->llr128_2ndstream = (int16_t**)malloc16_clear( sizeof(int16_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); - } - - for (int i=0; i<fp->nb_antennas_rx; i++){ - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - } - - } - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - } - - for (i=0; i<fp->nb_antennas_rx; i++) - for (j=0; j<4; j++) { - const int idx = (j<<1)+i; - const size_t num = 7*2*fp->N_RB_DL*12+4; - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - } - - } - - //const size_t num = 7*2*fp->N_RB_DL*12+4; - for (k=0;k<8;k++) { //harq_pid - for (l=0;l<8;l++) { //round - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - } - - - for (int i=0; i<fp->nb_antennas_rx; i++) - for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++) - const int idx = (j<<1)+i; - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - } - - } - } - } - phy_init_lte_ue__PDSCH( pdsch_vars_SI[eNB_id], fp ); - phy_init_lte_ue__PDSCH( pdsch_vars_ra[eNB_id], fp ); - phy_init_lte_ue__PDSCH( pdsch_vars_p[eNB_id], fp ); - phy_init_lte_ue__PDSCH( pdsch_vars_mch[eNB_id], fp ); - - // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t*)malloc16_clear( 4*2*100*12 ); - - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - } - - for (i=0; i<fp->nb_antennas_rx; i++) { - //ue_pdcch_vars[eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(100*12*4) ); - } - - for (j=0; j<4; j++) { //fp->nb_antennas_tx; j++) - int idx = (j<<1)+i; - // size_t num = 7*2*fp->N_RB_DL*12; - size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - } - } - } - phy_init_lte_ue__PDSCH( pdsch_vars_SI[eNB_id], fp ); - phy_init_lte_ue__PDSCH( pdsch_vars_ra[eNB_id], fp ); - phy_init_lte_ue__PDSCH( pdsch_vars_p[eNB_id], fp ); - phy_init_lte_ue__PDSCH( pdsch_vars_mch[eNB_id], fp ); - - // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t*)malloc16_clear( 4*2*100*12 ); - - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - } - - for (i=0; i<fp->nb_antennas_rx; i++) { - //ue_pdcch_vars[eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); - - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(100*12*4) ); - } - - for (j=0; j<4; j++) { //fp->nb_antennas_tx; j++) - int idx = (j<<1)+i; - // size_t num = 7*2*fp->N_RB_DL*12; - size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - } - } - } - - // PBCH - pbch_vars[eNB_id]->rxdataF_ext = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - pbch_vars[eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pbch_vars[eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pbch_vars[eNB_id]->llr = (int8_t*)malloc16_clear( 1920 ); - prach_vars[eNB_id]->prachF = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); - prach_vars[eNB_id]->prach = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); - - for (i=0; i<fp->nb_antennas_rx; i++) { - pbch_vars[eNB_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); - - for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) { - int idx = (j<<1)+i; - pbch_vars[eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); - pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); - } - } - - - pbch_vars[eNB_id]->decoded_output = (uint8_t*)malloc16_clear( 64 ); - } - - // initialization for the last instance of pdsch_vars (used for MU-MIMO) - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); - } - - pdsch_vars_SI[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); - pdsch_vars_ra[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); - pdsch_vars_p[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); - - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - phy_init_lte_ue__PDSCH( (*pdsch_vars_th)[th_id][eNB_id], fp ); - (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); - } - - - ue->sinr_CQI_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) ); - - ue->init_averaging = 1; - // default value until overwritten by RRCConnectionReconfiguration - if (fp->nb_antenna_ports_eNB==2) - ue->pdsch_config_dedicated->p_a = dBm3; - else - ue->pdsch_config_dedicated->p_a = dB0; - - // set channel estimation to do linear interpolation in time - ue->high_speed_flag = 1; - ue->ch_est_alpha = 24576; - - // enable MIB/SIB decoding by default - ue->decode_MIB = 1; - ue->decode_SIB = 1; - - init_prach_tables(839); - - - return 0; -} - -void init_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) { - - int i,j,k; - - for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { - for (j=0; j<2; j++) { - for (k=0; k<2; k++) { - AssertFatal((ue->dlsch[k][i][j] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n"); - - LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[i][j]); - } - } - - AssertFatal((ue->ulsch[i] = new_ue_ulsch(ue->frame_parms.N_RB_UL, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n"); - - ue->dlsch_SI[i] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); - ue->dlsch_ra[i] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); - - ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_eNB==1 ? 1 : 2; - } - - ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; - - ue->dlsch_MCH[0] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); - -} - -int phy_init_RU(RU_t *ru) { - - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; - int i,j; - int p; - int re; - - LOG_I(PHY,"Initializing RU signal buffers (if_south %s) nb_tx %d\n",ru_if_types[ru->if_south],ru->nb_tx); - - if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so allocate memory for time-domain signals - // Time-domain signals - ru->common.txdata = (int32_t**)malloc16(ru->nb_tx*sizeof(int32_t*)); - ru->common.rxdata = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); - - - for (i=0; i<ru->nb_tx; i++) { - // Allocate 10 subframes of I/Q TX signal data (time) if not - ru->common.txdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); - - LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes)\n",i,ru->common.txdata[i], - fp->samples_per_tti*10*sizeof(int32_t)); - - } - for (i=0;i<ru->nb_rx;i++) { - ru->common.rxdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); - } - } // IF5 or local RF - else { - LOG_I(PHY,"No rxdata/txdata for RU\n"); - ru->common.txdata = (int32_t**)NULL; - ru->common.rxdata = (int32_t**)NULL; - - } - if (ru->function != NGFI_RRU_IF5) { // we need to do RX/TX RU processing - LOG_I(PHY,"nb_tx %d\n",ru->nb_tx); - ru->common.rxdata_7_5kHz = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); - for (i=0;i<ru->nb_rx;i++) { - ru->common.rxdata_7_5kHz[i] = (int32_t*)malloc16_clear( 2*fp->samples_per_tti*2*sizeof(int32_t) ); - LOG_I(PHY,"rxdata_7_5kHz[%d] %p for RU %d\n",i,ru->common.rxdata_7_5kHz[i],ru->idx); - } - - - // allocate IFFT input buffers (TX) - ru->common.txdataF_BF = (int32_t **)malloc16(ru->nb_tx*sizeof(int32_t*)); - LOG_I(PHY,"[INIT] common.txdata_BF= %p (%lu bytes)\n",ru->common.txdataF_BF, - ru->nb_tx*sizeof(int32_t*)); - for (i=0; i<ru->nb_tx; i++) { - ru->common.txdataF_BF[i] = (int32_t*)malloc16_clear(fp->symbols_per_tti*fp->ofdm_symbol_size*sizeof(int32_t) ); - LOG_I(PHY,"txdataF_BF[%d] %p for RU %d\n",i,ru->common.txdataF_BF[i],ru->idx); - } - // allocate FFT output buffers (RX) - ru->common.rxdataF = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); - for (i=0; i<ru->nb_rx; i++) { - // allocate 2 subframes of I/Q signal data (frequency) - ru->common.rxdataF[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->ofdm_symbol_size*fp->symbols_per_tti) ); - LOG_I(PHY,"rxdataF[%d] %p for RU %d\n",i,ru->common.rxdataF[i],ru->idx); - } - - /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */ - AssertFatal(ru->nb_rx <= sizeof(ru->prach_rxsigF) / sizeof(ru->prach_rxsigF[0]), - "nb_antennas_rx too large"); - ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*)); - for (j=0;j<4;j++) ru->prach_rxsigF_br[j] = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*)); - - for (i=0; i<ru->nb_rx; i++) { - ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) ); - LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,ru->prach_rxsigF[i]); -#ifdef Rel14 - for (j=0;j<4;j++) { - ru->prach_rxsigF_br[j][i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) ); - LOG_D(PHY,"[INIT] prach_vars_br->rxsigF[%d] = %p\n",i,ru->prach_rxsigF_br[j][i]); - } -#endif - } - - AssertFatal(RC.nb_L1_inst <= NUMBER_OF_eNB_MAX,"eNB instances %d > %d\n", - RC.nb_L1_inst,NUMBER_OF_eNB_MAX); - - LOG_E(PHY,"[INIT] %s() RC.nb_L1_inst:%d \n", __FUNCTION__, RC.nb_L1_inst); - - for (i=0; i<RC.nb_L1_inst; i++) { - for (p=0;p<15;p++) { - LOG_D(PHY,"[INIT] %s() nb_antenna_ports_eNB:%d \n", __FUNCTION__, ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB); - if (p<ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB || p==5) { - LOG_D(PHY,"[INIT] %s() DO BEAM WEIGHTS nb_antenna_ports_eNB:%d nb_tx:%d\n", __FUNCTION__, ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB, ru->nb_tx); - ru->beam_weights[i][p] = (int32_t **)malloc16_clear(ru->nb_tx*sizeof(int32_t*)); - for (j=0; j<ru->nb_tx; j++) { - ru->beam_weights[i][p][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t)); - // antenna ports 0-3 are mapped on antennas 0-3 - // antenna port 4 is mapped on antenna 0 - // antenna ports 5-14 are mapped on all antennas - if (((p<4) && (p==j)) || ((p==4) && (j==0))) { - for (re=0; re<fp->ofdm_symbol_size; re++) - { - ru->beam_weights[i][p][j][re] = 0x00007fff; - - //LOG_D(PHY,"[INIT] lte_common_vars->beam_weights[%d][%d][%d][%d] = %d\n", i,p,j,re,ru->beam_weights[i][p][j][re]); - } - } - else if (p>4) { - for (re=0; re<fp->ofdm_symbol_size; re++) - { - ru->beam_weights[i][p][j][re] = 0x00007fff/ru->nb_tx; - //LOG_D(PHY,"[INIT] lte_common_vars->beam_weights[%d][%d][%d][%d] = %d\n", i,p,j,re,ru->beam_weights[i][p][j][re]); - } - } - //LOG_D(PHY,"[INIT] lte_common_vars->beam_weights[%d][%d] = %p (%lu bytes)\n", i,j,ru->beam_weights[i][p][j], fp->ofdm_symbol_size*sizeof(int32_t)); - } - } - } - } - } - ru->common.sync_corr = (uint32_t*)malloc16_clear( LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(uint32_t)*fp->samples_per_tti ); - - return(0); -} - int phy_init_lte_eNB(PHY_VARS_eNB *eNB, unsigned char is_secondary_eNB, unsigned char abstraction_flag) diff --git a/openair1/PHY/INIT/lte_init_ru.c b/openair1/PHY/INIT/lte_init_ru.c new file mode 100644 index 0000000000000000000000000000000000000000..2d139e0afafcba2c2f72555744c74b5e3cd61e24 --- /dev/null +++ b/openair1/PHY/INIT/lte_init_ru.c @@ -0,0 +1,150 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "defs.h" +#include "SCHED/defs.h" +#include "PHY/extern.h" +#include "SIMULATION/TOOLS/defs.h" +#include "RadioResourceConfigCommonSIB.h" +#include "RadioResourceConfigDedicated.h" +#include "TDD-Config.h" +#include "LAYER2/MAC/extern.h" +#include "MBSFN-SubframeConfigList.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "assertions.h" +#include <math.h> + +int phy_init_RU(RU_t *ru) { + + LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; + int i,j; + int p; + int re; + + LOG_I(PHY,"Initializing RU signal buffers (if_south %s) nb_tx %d\n",ru_if_types[ru->if_south],ru->nb_tx); + + if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so allocate memory for time-domain signals + // Time-domain signals + ru->common.txdata = (int32_t**)malloc16(ru->nb_tx*sizeof(int32_t*)); + ru->common.rxdata = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); + + + for (i=0; i<ru->nb_tx; i++) { + // Allocate 10 subframes of I/Q TX signal data (time) if not + ru->common.txdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); + + LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes)\n",i,ru->common.txdata[i], + fp->samples_per_tti*10*sizeof(int32_t)); + + } + for (i=0;i<ru->nb_rx;i++) { + ru->common.rxdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); + } + } // IF5 or local RF + else { + LOG_I(PHY,"No rxdata/txdata for RU\n"); + ru->common.txdata = (int32_t**)NULL; + ru->common.rxdata = (int32_t**)NULL; + + } + if (ru->function != NGFI_RRU_IF5) { // we need to do RX/TX RU processing + LOG_I(PHY,"nb_tx %d\n",ru->nb_tx); + ru->common.rxdata_7_5kHz = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); + for (i=0;i<ru->nb_rx;i++) { + ru->common.rxdata_7_5kHz[i] = (int32_t*)malloc16_clear( 2*fp->samples_per_tti*2*sizeof(int32_t) ); + LOG_I(PHY,"rxdata_7_5kHz[%d] %p for RU %d\n",i,ru->common.rxdata_7_5kHz[i],ru->idx); + } + + + // allocate IFFT input buffers (TX) + ru->common.txdataF_BF = (int32_t **)malloc16(ru->nb_tx*sizeof(int32_t*)); + LOG_I(PHY,"[INIT] common.txdata_BF= %p (%lu bytes)\n",ru->common.txdataF_BF, + ru->nb_tx*sizeof(int32_t*)); + for (i=0; i<ru->nb_tx; i++) { + ru->common.txdataF_BF[i] = (int32_t*)malloc16_clear(fp->symbols_per_tti*fp->ofdm_symbol_size*sizeof(int32_t) ); + LOG_I(PHY,"txdataF_BF[%d] %p for RU %d\n",i,ru->common.txdataF_BF[i],ru->idx); + } + // allocate FFT output buffers (RX) + ru->common.rxdataF = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); + for (i=0; i<ru->nb_rx; i++) { + // allocate 2 subframes of I/Q signal data (frequency) + ru->common.rxdataF[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->ofdm_symbol_size*fp->symbols_per_tti) ); + LOG_I(PHY,"rxdataF[%d] %p for RU %d\n",i,ru->common.rxdataF[i],ru->idx); + } + + /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */ + AssertFatal(ru->nb_rx <= sizeof(ru->prach_rxsigF) / sizeof(ru->prach_rxsigF[0]), + "nb_antennas_rx too large"); + ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*)); + for (j=0;j<4;j++) ru->prach_rxsigF_br[j] = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*)); + + for (i=0; i<ru->nb_rx; i++) { + ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) ); + LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,ru->prach_rxsigF[i]); +#ifdef Rel14 + for (j=0;j<4;j++) { + ru->prach_rxsigF_br[j][i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) ); + LOG_D(PHY,"[INIT] prach_vars_br->rxsigF[%d] = %p\n",i,ru->prach_rxsigF_br[j][i]); + } +#endif + } + + AssertFatal(RC.nb_L1_inst <= NUMBER_OF_eNB_MAX,"eNB instances %d > %d\n", + RC.nb_L1_inst,NUMBER_OF_eNB_MAX); + + LOG_E(PHY,"[INIT] %s() RC.nb_L1_inst:%d \n", __FUNCTION__, RC.nb_L1_inst); + + for (i=0; i<RC.nb_L1_inst; i++) { + for (p=0;p<15;p++) { + LOG_D(PHY,"[INIT] %s() nb_antenna_ports_eNB:%d \n", __FUNCTION__, ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB); + if (p<ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB || p==5) { + LOG_D(PHY,"[INIT] %s() DO BEAM WEIGHTS nb_antenna_ports_eNB:%d nb_tx:%d\n", __FUNCTION__, ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB, ru->nb_tx); + ru->beam_weights[i][p] = (int32_t **)malloc16_clear(ru->nb_tx*sizeof(int32_t*)); + for (j=0; j<ru->nb_tx; j++) { + ru->beam_weights[i][p][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t)); + // antenna ports 0-3 are mapped on antennas 0-3 + // antenna port 4 is mapped on antenna 0 + // antenna ports 5-14 are mapped on all antennas + if (((p<4) && (p==j)) || ((p==4) && (j==0))) { + for (re=0; re<fp->ofdm_symbol_size; re++) + { + ru->beam_weights[i][p][j][re] = 0x00007fff; + + //LOG_D(PHY,"[INIT] lte_common_vars->beam_weights[%d][%d][%d][%d] = %d\n", i,p,j,re,ru->beam_weights[i][p][j][re]); + } + } + else if (p>4) { + for (re=0; re<fp->ofdm_symbol_size; re++) + { + ru->beam_weights[i][p][j][re] = 0x00007fff/ru->nb_tx; + //LOG_D(PHY,"[INIT] lte_common_vars->beam_weights[%d][%d][%d][%d] = %d\n", i,p,j,re,ru->beam_weights[i][p][j][re]); + } + } + //LOG_D(PHY,"[INIT] lte_common_vars->beam_weights[%d][%d] = %p (%lu bytes)\n", i,j,ru->beam_weights[i][p][j], fp->ofdm_symbol_size*sizeof(int32_t)); + } // for (j=0 + } // if (p<ru + } // for p + } //for i + } // !=IF5 + ru->common.sync_corr = (uint32_t*)malloc16_clear( LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(uint32_t)*fp->samples_per_tti ); + + return(0); +} diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..fe043ffcff0b0a25aa84060ccfd9e3046df909d2 --- /dev/null +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -0,0 +1,967 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "defs.h" +#include "SCHED/defs.h" +#include "PHY/extern.h" +#include "SIMULATION/TOOLS/defs.h" +#include "RadioResourceConfigCommonSIB.h" +#include "RadioResourceConfigDedicated.h" +#include "TDD-Config.h" +#include "LAYER2/MAC/extern.h" +#include "MBSFN-SubframeConfigList.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "assertions.h" +#include <math.h> + + +uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10}; +extern uint8_t nfapi_mode; + +void phy_config_sib1_ue(uint8_t Mod_id,int CC_id, + uint8_t eNB_id, + TDD_Config_t *tdd_Config, + uint8_t SIwindowsize, + uint16_t SIperiod) +{ + + LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; + + if (tdd_Config) { + fp->tdd_config = tdd_Config->subframeAssignment; + fp->tdd_config_S = tdd_Config->specialSubframePatterns; + } + + fp->SIwindowsize = SIwindowsize; + fp->SIPeriod = SIperiod; +} + +void phy_config_sib2_ue(uint8_t Mod_id,int CC_id, + uint8_t eNB_id, + RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, + ARFCN_ValueEUTRA_t *ul_CarrierFreq, + long *ul_Bandwidth, + AdditionalSpectrumEmission_t *additionalSpectrumEmission, + struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList) +{ + + PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id]; + LTE_DL_FRAME_PARMS *fp = &ue->frame_parms; + int i; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_IN); + + LOG_I(PHY,"[UE%d] Applying radioResourceConfigCommon from eNB%d\n",Mod_id,eNB_id); + + fp->prach_config_common.rootSequenceIndex =radioResourceConfigCommon->prach_Config.rootSequenceIndex; + + fp->prach_config_common.prach_Config_enabled=1; + fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex; + fp->prach_config_common.prach_ConfigInfo.highSpeedFlag =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.highSpeedFlag; + fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; + fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset; + + compute_prach_seq(fp->prach_config_common.rootSequenceIndex, + fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, + fp->prach_config_common.prach_ConfigInfo.highSpeedFlag, + fp->frame_type,ue->X_u); + + + + fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon.deltaPUCCH_Shift; + fp->pucch_config_common.nRB_CQI = radioResourceConfigCommon->pucch_ConfigCommon.nRB_CQI; + fp->pucch_config_common.nCS_AN = radioResourceConfigCommon->pucch_ConfigCommon.nCS_AN; + fp->pucch_config_common.n1PUCCH_AN = radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN; + + + + fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon.referenceSignalPower; + fp->pdsch_config_common.p_b = radioResourceConfigCommon->pdsch_ConfigCommon.p_b; + + + fp->pusch_config_common.n_SB = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; + fp->pusch_config_common.hoppingMode = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; + fp->pusch_config_common.pusch_HoppingOffset = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; + fp->pusch_config_common.enable64QAM = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = dmrs1_tab_ue[radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift]; + + + init_ul_hopping(fp); + fp->soundingrs_ul_config_common.enabled_flag = 0; + + if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.present==SoundingRS_UL_ConfigCommon_PR_setup) { + fp->soundingrs_ul_config_common.enabled_flag = 1; + fp->soundingrs_ul_config_common.srs_BandwidthConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig; + fp->soundingrs_ul_config_common.srs_SubframeConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig; + fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; + + if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) + fp->soundingrs_ul_config_common.srs_MaxUpPts = 1; + else + fp->soundingrs_ul_config_common.srs_MaxUpPts = 0; + } + + + + fp->ul_power_control_config_common.p0_NominalPUSCH = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUSCH; + fp->ul_power_control_config_common.alpha = radioResourceConfigCommon->uplinkPowerControlCommon.alpha; + fp->ul_power_control_config_common.p0_NominalPUCCH = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUCCH; + fp->ul_power_control_config_common.deltaPreambleMsg3 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaPreambleMsg3; + fp->ul_power_control_config_common.deltaF_PUCCH_Format1 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1; + fp->ul_power_control_config_common.deltaF_PUCCH_Format1b = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b; + fp->ul_power_control_config_common.deltaF_PUCCH_Format2 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2; + fp->ul_power_control_config_common.deltaF_PUCCH_Format2a = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a; + fp->ul_power_control_config_common.deltaF_PUCCH_Format2b = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b; + + fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx; + + // Now configure some of the Physical Channels + + // PUCCH + init_ncs_cell(fp,ue->ncs_cell); + + init_ul_hopping(fp); + + // PCH + init_ue_paging_info(ue,radioResourceConfigCommon->pcch_Config.defaultPagingCycle,radioResourceConfigCommon->pcch_Config.nB); + + // MBSFN + + if (mbsfn_SubframeConfigList != NULL) { + fp->num_MBSFN_config = mbsfn_SubframeConfigList->list.count; + + for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) { + fp->MBSFN_config[i].radioframeAllocationPeriod = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod; + fp->MBSFN_config[i].radioframeAllocationOffset = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset; + + if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { + fp->MBSFN_config[i].fourFrames_flag = 0; + fp->MBSFN_config[i].mbsfn_SubframeConfig = mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]; // 6-bit subframe configuration + LOG_I(PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is %d\n", i, + fp->MBSFN_config[i].mbsfn_SubframeConfig); + } else if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_fourFrames) { // 24-bit subframe configuration + fp->MBSFN_config[i].fourFrames_flag = 1; + fp->MBSFN_config[i].mbsfn_SubframeConfig = + mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]| + (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[1]<<8)| + (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[2]<<16); + + LOG_I(PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is %d\n", i, + fp->MBSFN_config[i].mbsfn_SubframeConfig); + } + } + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_OUT); + +} + +void phy_config_sib13_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id,int mbsfn_Area_idx, + long mbsfn_AreaId_r9) +{ + + LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; + + + LOG_I(PHY,"[UE%d] Applying MBSFN_Area_id %ld for index %d\n",Mod_id,mbsfn_AreaId_r9,mbsfn_Area_idx); + + if (mbsfn_Area_idx == 0) { + fp->Nid_cell_mbsfn = (uint16_t)mbsfn_AreaId_r9; + LOG_N(PHY,"Fix me: only called when mbsfn_Area_idx == 0)\n"); + } + + lte_gold_mbsfn(fp,PHY_vars_UE_g[Mod_id][CC_id]->lte_gold_mbsfn_table,fp->Nid_cell_mbsfn); + +} + + +/* + * Configures UE MAC and PHY with radioResourceCommon received in mobilityControlInfo IE during Handover + */ +void phy_config_afterHO_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_id, MobilityControlInfo_t *mobilityControlInfo, uint8_t ho_failed) +{ + + if(mobilityControlInfo!=NULL) { + RadioResourceConfigCommon_t *radioResourceConfigCommon = &mobilityControlInfo->radioResourceConfigCommon; + LOG_I(PHY,"radioResourceConfigCommon %p\n", radioResourceConfigCommon); + memcpy((void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms_before_ho, + (void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms, + sizeof(LTE_DL_FRAME_PARMS)); + PHY_vars_UE_g[Mod_id][CC_id]->ho_triggered = 1; + //PHY_vars_UE_g[UE_id]->UE_mode[0] = PRACH; + + LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; + // int N_ZC; + // uint8_t prach_fmt; + // int u; + + LOG_I(PHY,"[UE%d] Handover triggered: Applying radioResourceConfigCommon from eNB %d\n", + Mod_id,eNB_id); + + fp->prach_config_common.rootSequenceIndex =radioResourceConfigCommon->prach_Config.rootSequenceIndex; + fp->prach_config_common.prach_Config_enabled=1; + fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex; + fp->prach_config_common.prach_ConfigInfo.highSpeedFlag =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->highSpeedFlag; + fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->zeroCorrelationZoneConfig; + fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_FreqOffset; + + // prach_fmt = get_prach_fmt(radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex,fp->frame_type); + // N_ZC = (prach_fmt <4)?839:139; + // u = (prach_fmt < 4) ? prach_root_sequence_map0_3[fp->prach_config_common.rootSequenceIndex] : + // prach_root_sequence_map4[fp->prach_config_common.rootSequenceIndex]; + + //compute_prach_seq(u,N_ZC, PHY_vars_UE_g[Mod_id]->X_u); + compute_prach_seq(PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.rootSequenceIndex, + PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, + PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag, + fp->frame_type, + PHY_vars_UE_g[Mod_id][CC_id]->X_u); + + + fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon->deltaPUCCH_Shift; + fp->pucch_config_common.nRB_CQI = radioResourceConfigCommon->pucch_ConfigCommon->nRB_CQI; + fp->pucch_config_common.nCS_AN = radioResourceConfigCommon->pucch_ConfigCommon->nCS_AN; + fp->pucch_config_common.n1PUCCH_AN = radioResourceConfigCommon->pucch_ConfigCommon->n1PUCCH_AN; + fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon->referenceSignalPower; + fp->pdsch_config_common.p_b = radioResourceConfigCommon->pdsch_ConfigCommon->p_b; + + + fp->pusch_config_common.n_SB = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; + fp->pusch_config_common.hoppingMode = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; + fp->pusch_config_common.pusch_HoppingOffset = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; + fp->pusch_config_common.enable64QAM = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled; + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift; + + init_ul_hopping(fp); + fp->soundingrs_ul_config_common.enabled_flag = 0; + + if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->present==SoundingRS_UL_ConfigCommon_PR_setup) { + fp->soundingrs_ul_config_common.enabled_flag = 1; + fp->soundingrs_ul_config_common.srs_BandwidthConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_BandwidthConfig; + fp->soundingrs_ul_config_common.srs_SubframeConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig; + fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.ackNackSRS_SimultaneousTransmission; + + if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_MaxUpPts) + fp->soundingrs_ul_config_common.srs_MaxUpPts = 1; + else + fp->soundingrs_ul_config_common.srs_MaxUpPts = 0; + } + + fp->ul_power_control_config_common.p0_NominalPUSCH = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUSCH; + fp->ul_power_control_config_common.alpha = radioResourceConfigCommon->uplinkPowerControlCommon->alpha; + fp->ul_power_control_config_common.p0_NominalPUCCH = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUCCH; + fp->ul_power_control_config_common.deltaPreambleMsg3 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaPreambleMsg3; + fp->ul_power_control_config_common.deltaF_PUCCH_Format1 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1; + fp->ul_power_control_config_common.deltaF_PUCCH_Format1b = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1b; + fp->ul_power_control_config_common.deltaF_PUCCH_Format2 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2; + fp->ul_power_control_config_common.deltaF_PUCCH_Format2a = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2a; + fp->ul_power_control_config_common.deltaF_PUCCH_Format2b = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2b; + + fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon->maxHARQ_Msg3Tx; + + // Now configure some of the Physical Channels + if (radioResourceConfigCommon->antennaInfoCommon) + fp->nb_antennas_tx = (1<<radioResourceConfigCommon->antennaInfoCommon->antennaPortsCount); + else + fp->nb_antennas_tx = 1; + + //PHICH + if (radioResourceConfigCommon->antennaInfoCommon) { + fp->phich_config_common.phich_resource = radioResourceConfigCommon->phich_Config->phich_Resource; + fp->phich_config_common.phich_duration = radioResourceConfigCommon->phich_Config->phich_Duration; + } + + //Target CellId + fp->Nid_cell = mobilityControlInfo->targetPhysCellId; + fp->nushift = fp->Nid_cell%6; + + // PUCCH + init_ncs_cell(fp,PHY_vars_UE_g[Mod_id][CC_id]->ncs_cell); + + init_ul_hopping(fp); + + // RNTI + + + PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8); + PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8); + + LOG_I(PHY,"SET C-RNTI %x %x\n",PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti, + PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti); + } + + if(ho_failed) { + LOG_D(PHY,"[UE%d] Handover failed, triggering RACH procedure\n",Mod_id); + memcpy((void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms,(void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms_before_ho, sizeof(LTE_DL_FRAME_PARMS)); + PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[eNB_id] = PRACH; + } +} + +void phy_config_meas_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,unsigned int *adj_cell_id) +{ + + PHY_MEASUREMENTS *phy_meas = &PHY_vars_UE_g[Mod_id][CC_id]->measurements; + int i; + + LOG_I(PHY,"Configuring inter-cell measurements for %d cells, ids: \n",n_adj_cells); + + for (i=0; i<n_adj_cells; i++) { + LOG_I(PHY,"%d\n",adj_cell_id[i]); + lte_gold(&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms,PHY_vars_UE_g[Mod_id][CC_id]->lte_gold_table[i+1],adj_cell_id[i]); + } + + phy_meas->n_adj_cells = n_adj_cells; + memcpy((void*)phy_meas->adj_cell_id,(void *)adj_cell_id,n_adj_cells*sizeof(unsigned int)); + +} + +#if defined(Rel10) || defined(Rel14) +void phy_config_dedicated_scell_ue(uint8_t Mod_id, + uint8_t eNB_index, + SCellToAddMod_r10_t *sCellToAddMod_r10, + int CC_id) +{ + +} +#endif + + +void phy_config_harq_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, + uint16_t max_harq_tx ) +{ + + PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; + phy_vars_ue->ulsch[eNB_id]->Mlimit = max_harq_tx; +} + +extern uint16_t beta_cqi[16]; + +void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, + struct PhysicalConfigDedicated *physicalConfigDedicated ) +{ + + static uint8_t first_dedicated_configuration = 0; + PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; + + phy_vars_ue->total_TBS[eNB_id]=0; + phy_vars_ue->total_TBS_last[eNB_id]=0; + phy_vars_ue->bitrate[eNB_id]=0; + phy_vars_ue->total_received_bits[eNB_id]=0; + phy_vars_ue->dlsch_errors[eNB_id]=0; + phy_vars_ue->dlsch_errors_last[eNB_id]=0; + phy_vars_ue->dlsch_received[eNB_id]=0; + phy_vars_ue->dlsch_received_last[eNB_id]=0; + phy_vars_ue->dlsch_fer[eNB_id]=0; + + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; + + if (physicalConfigDedicated) { + LOG_D(PHY,"[UE %d] Received physicalConfigDedicated from eNB %d\n",Mod_id, eNB_id); + LOG_D(PHY,"------------------------------------------------------------------------\n"); + + if (physicalConfigDedicated->pdsch_ConfigDedicated) { + phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a=physicalConfigDedicated->pdsch_ConfigDedicated->p_a; + LOG_D(PHY,"pdsch_config_dedicated.p_a %d\n",phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a); + LOG_D(PHY,"\n"); + } + + if (physicalConfigDedicated->pucch_ConfigDedicated) { + if (physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.present==PUCCH_ConfigDedicated__ackNackRepetition_PR_release) + phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=0; + else { + phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=1; + } + + if (physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode) + phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = *physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode; + else + phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = bundling; + + if ( phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode == multiplexing) + LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = multiplexing\n"); + else + LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = bundling\n"); + } + + if (physicalConfigDedicated->pusch_ConfigDedicated) { + phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; + phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; + phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; + + + LOG_D(PHY,"pusch_config_dedicated.betaOffset_ACK_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index); + LOG_D(PHY,"pusch_config_dedicated.betaOffset_RI_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index); + LOG_D(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d => %d)\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index,beta_cqi[phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index]); + LOG_D(PHY,"\n"); + + + } + + if (physicalConfigDedicated->uplinkPowerControlDedicated) { + + phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH = physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUSCH; + phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled= physicalConfigDedicated->uplinkPowerControlDedicated->deltaMCS_Enabled; + phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled= physicalConfigDedicated->uplinkPowerControlDedicated->accumulationEnabled; + phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH= physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUCCH; + phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset= physicalConfigDedicated->uplinkPowerControlDedicated->pSRS_Offset; + phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient= *physicalConfigDedicated->uplinkPowerControlDedicated->filterCoefficient; + LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUSCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH); + LOG_D(PHY,"ul_power_control_dedicated.deltaMCS_Enabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled); + LOG_D(PHY,"ul_power_control_dedicated.accumulationEnabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled); + LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUCCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH); + LOG_D(PHY,"ul_power_control_dedicated.pSRS_Offset %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset); + LOG_D(PHY,"ul_power_control_dedicated.filterCoefficient %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient); + LOG_D(PHY,"\n"); + } + + if (physicalConfigDedicated->antennaInfo) { + phy_vars_ue->transmission_mode[eNB_id] = 1+(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode); + LOG_I(PHY,"Transmission Mode %d\n",phy_vars_ue->transmission_mode[eNB_id]); + switch(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode) { + case AntennaInfoDedicated__transmissionMode_tm1: + phy_vars_ue->transmission_mode[eNB_id] = 1; + break; + case AntennaInfoDedicated__transmissionMode_tm2: + phy_vars_ue->transmission_mode[eNB_id] = 2; + break; + case AntennaInfoDedicated__transmissionMode_tm3: + phy_vars_ue->transmission_mode[eNB_id] = 3; + break; + case AntennaInfoDedicated__transmissionMode_tm4: + phy_vars_ue->transmission_mode[eNB_id] = 4; + break; + case AntennaInfoDedicated__transmissionMode_tm5: + phy_vars_ue->transmission_mode[eNB_id] = 5; + break; + case AntennaInfoDedicated__transmissionMode_tm6: + phy_vars_ue->transmission_mode[eNB_id] = 6; + break; + case AntennaInfoDedicated__transmissionMode_tm7: + lte_gold_ue_spec_port5(phy_vars_ue->lte_gold_uespec_port5_table, phy_vars_ue->frame_parms.Nid_cell, phy_vars_ue->pdcch_vars[0][eNB_id]->crnti); + phy_vars_ue->transmission_mode[eNB_id] = 7; + break; + default: + LOG_E(PHY,"Unknown transmission mode!\n"); + break; + } + } else { + LOG_D(PHY,"[UE %d] Received NULL physicalConfigDedicated->antennaInfo from eNB %d\n",Mod_id, eNB_id); + } + + if (physicalConfigDedicated->schedulingRequestConfig) { + if (physicalConfigDedicated->schedulingRequestConfig->present == SchedulingRequestConfig_PR_setup) { + phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex = physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex; + phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex=physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_ConfigIndex; + phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax=physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax; + + LOG_D(PHY,"scheduling_request_config.sr_PUCCH_ResourceIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); + LOG_D(PHY,"scheduling_request_config.sr_ConfigIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex); + LOG_D(PHY,"scheduling_request_config.dsr_TransMax %d\n",phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax); + } + + LOG_D(PHY,"------------------------------------------------------------\n"); + + } + + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { + + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 0; + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 1; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].cyclicShift = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].freqDomainPosition = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_Bandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth; + phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].transmissionComb = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; + + + LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex); + } + + LOG_D(PHY,"------------------------------------------------------------\n"); + + } + + + if (physicalConfigDedicated->cqi_ReportConfig) { + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic) { + // configure PUSCH CQI reporting + phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; + if ((phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm12) && + (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm30) && + (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm31)) + LOG_E(PHY,"Unsupported Aperiodic CQI Feedback Mode : %d\n",phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic); + } + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) { + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_setup) { + // configure PUCCH CQI reporting + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex; + } + else if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_release) { + // handle release + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; + phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; + } + } + } + +#ifdef CBA + + if (physicalConfigDedicated->pusch_CBAConfigDedicated_vlola) { + phy_vars_ue->pusch_ca_config_dedicated[eNB_id].betaOffset_CA_Index = (uint16_t) *physicalConfigDedicated->pusch_CBAConfigDedicated_vlola->betaOffset_CBA_Index; + phy_vars_ue->pusch_ca_config_dedicated[eNB_id].cShift = (uint16_t) *physicalConfigDedicated->pusch_CBAConfigDedicated_vlola->cShift_CBA; + LOG_D(PHY,"[UE %d ] physicalConfigDedicated pusch CBA config dedicated: beta offset %d cshift %d \n",Mod_id, + phy_vars_ue->pusch_ca_config_dedicated[eNB_id].betaOffset_CA_Index, + phy_vars_ue->pusch_ca_config_dedicated[eNB_id].cShift); + } + +#endif + } else { + LOG_D(PHY,"[PHY][UE %d] Received NULL radioResourceConfigDedicated from eNB %d\n",Mod_id,eNB_id); + return; + } + + // fill cqi parameters for periodic CQI reporting + get_cqipmiri_params(phy_vars_ue,eNB_id); + + // disable MIB SIB decoding once we are on connected mode + first_dedicated_configuration ++; + if(first_dedicated_configuration > 1) + { + LOG_I(PHY,"Disable SIB MIB decoding \n"); + phy_vars_ue->decode_SIB = 0; + phy_vars_ue->decode_MIB = 0; + } + + if(nfapi_mode!=3){ + //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; + if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234) + phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; + else + phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; + + LOG_I(PHY,"C-RNTI %x %x \n", phy_vars_ue->pdcch_vars[0][eNB_id]->crnti, + phy_vars_ue->pdcch_vars[1][eNB_id]->crnti); + } + + +} + +/*! \brief Helper function to allocate memory for DLSCH data structures. + * \param[out] pdsch Pointer to the LTE_UE_PDSCH structure to initialize. + * \param[in] frame_parms LTE_DL_FRAME_PARMS structure. + * \note This function is optimistic in that it expects malloc() to succeed. + */ +void phy_init_lte_ue__PDSCH( LTE_UE_PDSCH* const pdsch, const LTE_DL_FRAME_PARMS* const fp ) +{ + AssertFatal( pdsch, "pdsch==0" ); + + pdsch->pmi_ext = (uint8_t*)malloc16_clear( fp->N_RB_DL ); + pdsch->llr[0] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); + pdsch->llr128 = (int16_t**)malloc16_clear( sizeof(int16_t*) ); + // FIXME! no further allocation for (int16_t*)pdsch->llr128 !!! expect SIGSEGV + // FK, 11-3-2015: this is only as a temporary pointer, no memory is stored there + + + pdsch->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->rxdataF_uespec_pilots = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->rxdataF_comp0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->rho = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); + pdsch->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->dl_bf_ch_estimates = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->dl_bf_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + //pdsch->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + //pdsch->dl_ch_rho2_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->dl_ch_mag0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->dl_ch_magb0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + + + // the allocated memory size is fixed: + AssertFatal( fp->nb_antennas_rx <= 2, "nb_antennas_rx > 2" ); + + for (int i=0; i<fp->nb_antennas_rx; i++) { + pdsch->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); + + for (int j=0; j<4; j++) { //fp->nb_antennas_tx; j++) + const int idx = (j<<1)+i; + const size_t num = 7*2*fp->N_RB_DL*12; + pdsch->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + pdsch->rxdataF_uespec_pilots[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12); + pdsch->rxdataF_comp0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_bf_ch_estimates[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2); + pdsch->dl_bf_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + //pdsch->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + //pdsch->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_ch_mag0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_ch_magb0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + } + } +} + +int init_lte_ue_signal(PHY_VARS_UE *ue, + int nb_connected_eNB, + uint8_t abstraction_flag) +{ + + // create shortcuts + LTE_DL_FRAME_PARMS* const fp = &ue->frame_parms; + LTE_UE_COMMON* const common_vars = &ue->common_vars; + LTE_UE_PDSCH** const pdsch_vars_SI = ue->pdsch_vars_SI; + LTE_UE_PDSCH** const pdsch_vars_ra = ue->pdsch_vars_ra; + LTE_UE_PDSCH** const pdsch_vars_p = ue->pdsch_vars_p; + LTE_UE_PDSCH** const pdsch_vars_mch = ue->pdsch_vars_MCH; + LTE_UE_PDSCH* (*pdsch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX+1] = &ue->pdsch_vars; + LTE_UE_PDCCH* (*pdcch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX] = &ue->pdcch_vars; + LTE_UE_PBCH** const pbch_vars = ue->pbch_vars; + LTE_UE_PRACH** const prach_vars = ue->prach_vars; + + + + int i,j,k,l; + int eNB_id; + int th_id; + + LOG_D(PHY,"Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); + LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST); + + + + init_frame_parms(&ue->frame_parms,1); + init_lte_top(&ue->frame_parms); + init_ul_hopping(&ue->frame_parms); + + + // many memory allocation sizes are hard coded + AssertFatal( fp->nb_antennas_rx <= 2, "hard coded allocation for ue_common_vars->dl_ch_estimates[eNB_id]" ); + AssertFatal( ue->n_connected_eNB <= NUMBER_OF_CONNECTED_eNB_MAX, "n_connected_eNB is too large" ); + // init phy_vars_ue + + for (i=0; i<4; i++) { + ue->rx_gain_max[i] = 135; + ue->rx_gain_med[i] = 128; + ue->rx_gain_byp[i] = 120; + } + + ue->n_connected_eNB = nb_connected_eNB; + + for(eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { + ue->total_TBS[eNB_id] = 0; + ue->total_TBS_last[eNB_id] = 0; + ue->bitrate[eNB_id] = 0; + ue->total_received_bits[eNB_id] = 0; + } + + for (i=0;i<10;i++) + ue->tx_power_dBm[i]=-127; + + + + // init TX buffers + + common_vars->txdata = (int32_t**)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) ); + common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) ); + + for (i=0; i<fp->nb_antennas_tx; i++) { + + common_vars->txdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); + common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); + } + + // init RX buffers + + common_vars->rxdata = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); + common_vars->common_vars_rx_data_per_thread[0].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); + common_vars->common_vars_rx_data_per_thread[1].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); + + for (i=0; i<fp->nb_antennas_rx; i++) { + common_vars->rxdata[i] = (int32_t*) malloc16_clear( (fp->samples_per_tti*10+2048)*sizeof(int32_t) ); + common_vars->common_vars_rx_data_per_thread[0].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); + common_vars->common_vars_rx_data_per_thread[1].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); + } + + + // Channel estimates + for (eNB_id=0; eNB_id<7; eNB_id++) { + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id] = (int32_t**)malloc16_clear(8*sizeof(int32_t*)); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id] = (int32_t**)malloc16_clear(8*sizeof(int32_t*)); + } + + for (i=0; i<fp->nb_antennas_rx; i++) + for (j=0; j<4; j++) { + int idx = (j<<1) + i; + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->symbols_per_tti*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) ); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); + } + } + } + + // DLSCH + for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) { + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); + } + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id] = (LTE_UE_PDCCH *)malloc16_clear(sizeof(LTE_UE_PDCCH)); + } + + pdsch_vars_SI[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); + pdsch_vars_ra[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); + pdsch_vars_p[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); + pdsch_vars_mch[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); + prach_vars[eNB_id] = (LTE_UE_PRACH *)malloc16_clear(sizeof(LTE_UE_PRACH)); + pbch_vars[eNB_id] = (LTE_UE_PBCH *)malloc16_clear(sizeof(LTE_UE_PBCH)); + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + phy_init_lte_ue__PDSCH( (*pdsch_vars_th)[th_id][eNB_id], fp ); + } + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts = (uint8_t*)malloc16_clear(7*2*fp->N_RB_DL*12); + (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts_p = (*pdsch_vars_th)[0][eNB_id]->llr_shifts; + (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); + (*pdsch_vars_th)[th_id][eNB_id]->llr128_2ndstream = (int16_t**)malloc16_clear( sizeof(int16_t*) ); + (*pdsch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); + } + + for (int i=0; i<fp->nb_antennas_rx; i++){ + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + } + + } + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + } + + for (i=0; i<fp->nb_antennas_rx; i++) + for (j=0; j<4; j++) { + const int idx = (j<<1)+i; + const size_t num = 7*2*fp->N_RB_DL*12+4; + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + } + + } + + //const size_t num = 7*2*fp->N_RB_DL*12+4; + for (k=0;k<8;k++) { //harq_pid + for (l=0;l<8;l++) { //round + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + } + + + for (int i=0; i<fp->nb_antennas_rx; i++) + for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++) + const int idx = (j<<1)+i; + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + } + + } + } + } + phy_init_lte_ue__PDSCH( pdsch_vars_SI[eNB_id], fp ); + phy_init_lte_ue__PDSCH( pdsch_vars_ra[eNB_id], fp ); + phy_init_lte_ue__PDSCH( pdsch_vars_p[eNB_id], fp ); + phy_init_lte_ue__PDSCH( pdsch_vars_mch[eNB_id], fp ); + + // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t*)malloc16_clear( 4*2*100*12 ); + + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + } + + for (i=0; i<fp->nb_antennas_rx; i++) { + //ue_pdcch_vars[eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(100*12*4) ); + } + + for (j=0; j<4; j++) { //fp->nb_antennas_tx; j++) + int idx = (j<<1)+i; + // size_t num = 7*2*fp->N_RB_DL*12; + size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + } + } + } + phy_init_lte_ue__PDSCH( pdsch_vars_SI[eNB_id], fp ); + phy_init_lte_ue__PDSCH( pdsch_vars_ra[eNB_id], fp ); + phy_init_lte_ue__PDSCH( pdsch_vars_p[eNB_id], fp ); + phy_init_lte_ue__PDSCH( pdsch_vars_mch[eNB_id], fp ); + + // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t*)malloc16_clear( 4*2*100*12 ); + + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + } + + for (i=0; i<fp->nb_antennas_rx; i++) { + //ue_pdcch_vars[eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(100*12*4) ); + } + + for (j=0; j<4; j++) { //fp->nb_antennas_tx; j++) + int idx = (j<<1)+i; + // size_t num = 7*2*fp->N_RB_DL*12; + size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + } + } + } + + // PBCH + pbch_vars[eNB_id]->rxdataF_ext = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); + pbch_vars[eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pbch_vars[eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pbch_vars[eNB_id]->llr = (int8_t*)malloc16_clear( 1920 ); + prach_vars[eNB_id]->prachF = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); + prach_vars[eNB_id]->prach = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); + + for (i=0; i<fp->nb_antennas_rx; i++) { + pbch_vars[eNB_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); + + for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) { + int idx = (j<<1)+i; + pbch_vars[eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); + pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); + } + } + + + pbch_vars[eNB_id]->decoded_output = (uint8_t*)malloc16_clear( 64 ); + } + + // initialization for the last instance of pdsch_vars (used for MU-MIMO) + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); + } + + pdsch_vars_SI[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); + pdsch_vars_ra[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); + pdsch_vars_p[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + phy_init_lte_ue__PDSCH( (*pdsch_vars_th)[th_id][eNB_id], fp ); + (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); + } + + + ue->sinr_CQI_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) ); + + ue->init_averaging = 1; + // default value until overwritten by RRCConnectionReconfiguration + if (fp->nb_antenna_ports_eNB==2) + ue->pdsch_config_dedicated->p_a = dBm3; + else + ue->pdsch_config_dedicated->p_a = dB0; + + // set channel estimation to do linear interpolation in time + ue->high_speed_flag = 1; + ue->ch_est_alpha = 24576; + + // enable MIB/SIB decoding by default + ue->decode_MIB = 1; + ue->decode_SIB = 1; + + init_prach_tables(839); + + + return 0; +} + +void init_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) { + + int i,j,k; + + for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { + for (j=0; j<2; j++) { + for (k=0; k<2; k++) { + AssertFatal((ue->dlsch[k][i][j] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n"); + + LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[i][j]); + } + } + + AssertFatal((ue->ulsch[i] = new_ue_ulsch(ue->frame_parms.N_RB_UL, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n"); + + ue->dlsch_SI[i] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); + ue->dlsch_ra[i] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); + + ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_eNB==1 ? 1 : 2; + } + + ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; + + ue->dlsch_MCH[0] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); + +} diff --git a/openair1/PHY/LTE_ESTIMATION/defs.h b/openair1/PHY/LTE_ESTIMATION/defs.h index aae97ecd9e9c3565120e69b57e9462466672e208..a7b5d14701874da4fb4894dca2382bfd7102708b 100644 --- a/openair1/PHY/LTE_ESTIMATION/defs.h +++ b/openair1/PHY/LTE_ESTIMATION/defs.h @@ -23,12 +23,6 @@ #define __LTE_ESTIMATION_DEFS__H__ #include "PHY/defs.h" -/* -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif - */ - /** @addtogroup _PHY_PARAMETER_ESTIMATION_BLOCKS_ * @{ */ @@ -136,18 +130,6 @@ int lte_dl_mbsfn_channel_estimation(PHY_VARS_UE *phy_vars_ue, int subframe, unsigned char l); -/* -#ifdef EMOS -int lte_dl_channel_estimation_emos(int dl_ch_estimates_emos[NB_ANTENNAS_RX*NB_ANTENNAS_TX][N_RB_DL_EMOS*N_PILOTS_PER_RB*N_SLOTS_EMOS], - int **rxdataF, - LTE_DL_FRAME_PARMS *frame_parms, - unsigned char Ns, - unsigned char p, - unsigned char l, - unsigned char sector); -#endif - */ - /*! \brief Frequency offset estimation for LTE We estimate the frequency offset by calculating the phase difference between channel estimates for symbols carrying pilots (l==0 or l==3/4). We take a moving average of the phase difference. diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c index cd032e688fab2ed984f6fc3e8415cb0699dab498..18444076f315de40ee4ef925e31ccd93043b1d37 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c @@ -149,10 +149,8 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, int temp, i, aa, max_pos = 0,ind; int max_val=0; short Re,Im,ncoef; -#ifdef USER_MODE #ifdef DEBUG_PHY char fname[100],vname[100]; -#endif #endif ncoef = 32768 - coef; @@ -187,12 +185,10 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, 1); break; } -#ifdef USER_MODE #ifdef DEBUG_PHY sprintf(fname,"srs_ch_estimates_time_%d%d.m",ind,aa); sprintf(vname,"srs_time_%d%d",ind,aa); write_output(fname,vname,lte_eNB_srs->srs_ch_estimates_time[aa],frame_parms->ofdm_symbol_size*2,2,1); -#endif #endif } diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c index 8dcf4b1c113f55e08ead44a08c02f05dc00e1aab..55d2cf6c5c5f2aae5eb34b045f394fdfeea08f24 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c @@ -19,9 +19,7 @@ * contact@openairinterface.org */ -#ifdef USER_MODE #include <string.h> -#endif #include "defs.h" #include "PHY/defs.h" #include "filt16_32.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c index fb935e47a856f3c18b5d2069ff3ebaf87b3dea33..a4b29bb25ec407efbbb4ec696bada4557bbd1ec1 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c @@ -19,9 +19,7 @@ * contact@openairinterface.org */ -#ifdef USER_MODE #include <string.h> -#endif #include "defs.h" #include "SCHED/defs.h" #include "PHY/defs.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation_emos.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation_emos.c deleted file mode 100644 index a64aa797af06b8fe7df5f207675a519c65b9e749..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation_emos.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifdef USER_MODE -#include <string.h> -#endif -#include "defs.h" -#include "PHY/defs.h" -#include "SCHED/phy_procedures_emos.h" - -// TODO: make channel estimation possible for multiple sectors (Gold sequences for pilots) - -//#define DEBUG_CH -int lte_dl_channel_estimation_emos(int dl_ch_estimates_emos[NB_ANTENNAS_RX*NB_ANTENNAS_TX][N_RB_DL_EMOS*N_PILOTS_PER_RB*N_SLOTS_EMOS], - int **rxdataF, - LTE_DL_FRAME_PARMS *frame_parms, - unsigned char Ns, - unsigned char p, - unsigned char l, - unsigned char sector) -{ - - int pilot[2][200] __attribute__((aligned(16))); - unsigned char nu,aarx; - unsigned short k; - unsigned int rb,pilot_cnt; - short ch[2],*pil,*rxF,*dl_ch,*dl_ch_prev; //*f,*f2,*fl,*f2l2,*fr,*f2r2; - int ch_offset,symbol_offset; - unsigned int n; - int i; - - unsigned char symbol = l+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame - - if ((p==0) && (l==0) ) - nu = 0; - else if ((p==0) && (l>0)) - nu = 3; - else if ((p==1) && (l==0)) - nu = 3; - else if ((p==1) && (l>0)) - nu = 0; - else { - msg("lte_dl_channel_estimation_emos: p %d, l %d -> ERROR\n",p,l); - return(-1); - } - - if (sector > 2) { - msg("lte_dl_channel_estimation_emos: sector must be 0,1, or 2\n"); - return(-1); - } - - switch (Ns) { - case 0: - ch_offset = ((l==0)?0:1)*2*frame_parms->N_RB_DL; - break; - - case 1: - ch_offset = ((l==0)?2:3)*2*frame_parms->N_RB_DL; - break; - - case 12: - ch_offset = ((l==0)?4:5)*2*frame_parms->N_RB_DL; - break; - - case 13: - ch_offset = ((l==0)?6:7)*2*frame_parms->N_RB_DL; - break; - - default: - msg("lte_dl_channel_estimation_emos: Ns must be 0, 1, 12, or 13\n"); - return(-1); - break; - - } - - symbol_offset = symbol*frame_parms->ofdm_symbol_size; // offset within rxdataF - - k = nu + sector; - - if (k > 6) - k -=6; - -#ifdef DEBUG_CH - printf("Channel Estimation : ch_offset %d, OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d, symbol=%d\n",ch_offset,frame_parms->ofdm_symbol_size,frame_parms->Ncp,l,Ns,k,symbol); -#endif - - // generate pilot - lte_dl_cell_spec_rx(&pilot[p][0], - frame_parms, - Ns, - (l==0)?0:1, - p); - - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - pil = (short *)&pilot[p][0]; - rxF = (short *)&rxdataF[aarx][((symbol_offset+k+frame_parms->first_carrier_offset)<<1)]; - dl_ch = (short *)&dl_ch_estimates_emos[(p<<1)+aarx][ch_offset]; - memset(dl_ch,0,frame_parms->N_RB_DL); - - for (pilot_cnt=0; pilot_cnt<frame_parms->N_RB_DL; pilot_cnt++) { - - dl_ch[0] = (short)(((int)pil[0]*rxF[0] - (int)pil[1]*rxF[1])>>15); - dl_ch[1] = (short)(((int)pil[0]*rxF[1] + (int)pil[1]*rxF[0])>>15); - - pil+=2; // Re Im - rxF+=24; // remember replicated format (Re0 Im0 Re0 Im0) !!! - dl_ch+=2; - - } - - // printf("Second half\n"); - // Second half of RBs - rxF = (short *)&rxdataF[aarx][((symbol_offset+1+k)<<1)]; - - for (pilot_cnt=0; pilot_cnt<frame_parms->N_RB_DL; pilot_cnt++) { - - - dl_ch[0] = (short)(((int)pil[0]*rxF[0] - (int)pil[1]*rxF[1])>>15); - dl_ch[1] = (short)(((int)pil[0]*rxF[1] + (int)pil[1]*rxF[0])>>15); - - pil+=2; - rxF+=24; - dl_ch+=2; - - } - - } - - return(0); -} - diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c index f298f8738cfb0d2ad6e7520eaf894afe3e51c5b2..17d44b22f8815442a5c10921410e685b02d64f1a 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c @@ -19,9 +19,7 @@ * contact@openairinterface.org */ -#ifdef USER_MODE #include <string.h> -#endif #include "defs.h" #include "PHY/defs.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index c7625ba083e43550036165bfb9aeb443bb1af2f0..21e33cf1c0ce5325168e1d06b6beaaf047ecb149 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -465,7 +465,7 @@ int lte_sync_time(int **rxdata, ///rx data in time domain *eNB_id = sync_source; - LOG_D(PHY,"[UE] lte_sync_time: Sync source = %d, Peak found at pos %d, val = %d (%d dB)\n",sync_source,peak_pos,peak_val,dB_fixed(peak_val)/2); + LOG_I(PHY,"[UE] lte_sync_time: Sync source = %d, Peak found at pos %d, val = %d (%d dB)\n",sync_source,peak_pos,peak_val,dB_fixed(peak_val)/2); #ifdef DEBUG_PHY @@ -578,30 +578,3 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain } -#ifdef PHY_ABSTRACTION -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" -//extern channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX]; - -int lte_sync_time_eNB_emul(PHY_VARS_eNB *phy_vars_eNB, - uint8_t sect_id, - int32_t *sync_val) -{ - - uint8_t UE_id; - uint8_t CC_id = phy_vars_eNB->CC_id; - - LOG_E(PHY,"[PHY] EMUL lte_sync_time_eNB_emul eNB %d, sect_id %d\n",phy_vars_eNB->Mod_id,sect_id); - *sync_val = 0; - - for (UE_id=0; UE_id<NB_UE_INST; UE_id++) { - //LOG_E(PHY,"[PHY] EMUL : eNB %d checking UE %d (PRACH %d) PL %d dB\n",phy_vars_eNB->Mod_id,UE_id,PHY_vars_UE_g[UE_id]->generate_prach,UE2eNB[UE_id][phy_vars_eNB->Mod_id]->path_loss_dB); - if ((PHY_vars_UE_g[UE_id][CC_id]->generate_prach == 1) && (phy_vars_eNB->Mod_id == (UE_id % NB_eNB_INST))) { - *sync_val = 1; - return(0); - } - } - - return(-1); -} -#endif diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c index acda933d388b8b66fa94638b509a7bc9a3f7458b..c4df34638bf2a06fc5a0894d35bfae6a94c1eb5c 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c @@ -38,7 +38,6 @@ int16_t cond_num_threshold = 0; -#ifdef USER_MODE void print_shorts(char *s,short *x) { @@ -57,8 +56,6 @@ void print_ints(char *s,int *x) ); } -#endif - int16_t get_PL(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) { diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index b495385612c20c37451cba56978163f3029e9a5c..18069f9759efcfdc3b48fea930d656843939ff77 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -91,7 +91,6 @@ int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32))); eNB->ulsch[UE_id]->harq_processes[harq_pid]->n_DMRS2 + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[(subframe<<1)+Ns]) % 12; -#if defined(USER_MODE) Msc_idx_ptr = (uint16_t*) bsearch(&Msc_RS, dftsizes, 33, sizeof(uint16_t), compareints); if (Msc_idx_ptr) @@ -101,26 +100,14 @@ int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32))); return(-1); } -#else - uint8_t b; - - for (b=0; b<33; b++) - if (Msc_RS==dftsizes[b]) - Msc_RS_idx = b; - -#endif - // LOG_I(PHY,"subframe %d, Ns %d, l %d, Msc_RS = %d, Msc_RS_idx = %d, u %d, v %d, cyclic_shift %d\n",subframe,Ns,l,Msc_RS, Msc_RS_idx,u,v,cyclic_shift); #ifdef DEBUG_CH -#ifdef USER_MODE - if (Ns==0) write_output("drs_seq0.m","drsseq0",ul_ref_sigs_rx[u][v][Msc_RS_idx],2*Msc_RS,2,1); else write_output("drs_seq1.m","drsseq1",ul_ref_sigs_rx[u][v][Msc_RS_idx],2*Msc_RS,2,1); -#endif #endif @@ -489,12 +476,10 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, 15, 0); -#ifdef USER_MODE #ifdef DEBUG_SRS sprintf(fname,"srs_ch_est%d.m",aa); sprintf(vname,"srs_est%d",aa); write_output(fname,vname,srs_vars->srs_ch_estimates[aa],frame_parms->ofdm_symbol_size,1,1); -#endif #endif } diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c b/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c index b715b3ffa293177b2385e94eb2f033e10514974a..5bf69578d194269b656266e0245d38fbd2a39b56 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c @@ -19,10 +19,8 @@ * contact@openairinterface.org */ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> -#endif #include "defs.h" #include "PHY/defs.h" diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c index 445c84623cb369d8285b7a0fb7ec6d7835a5aa94..35e5fe6affa62885f33bde299fe1d63a7375d475 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c @@ -21,10 +21,8 @@ // 6.10.2.2 MBSFN reference signals Mapping to resource elements -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> -#endif #include "defs.h" #include "PHY/defs.h" diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c b/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c index ed9ff1f5cd5b35b5fa775a9c76052b71b7c6359f..a7db8fd5aa321848cb1a4b903b5fb2b1cc780842 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c @@ -30,10 +30,8 @@ * \warning */ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> -#endif #include "defs.h" #include "PHY/defs.h" diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index 6ec745293fa49dcee059d112939d62e14cba786f..74ed2669e0cb09aebc3261e33661858b69c7ef7a 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -29,11 +29,9 @@ * \note * \warning */ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> #include <string.h> -#endif #include "PHY/defs.h" #include "PHY/extern.h" #include "SCHED/defs.h" @@ -2267,7 +2265,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, y[0] = &yseq0[0]; y[1] = &yseq1[0]; -#if 0 +#if 1 // reset all bits to <NIL>, here we set <NIL> elements as 2 // memset(e, 2, DCI_BITS_MAX); // here we interpret NIL as a random QPSK sequence. That makes power estimation easier. @@ -2278,7 +2276,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, /* clear all bits, the above code may generate too much false detections * (not sure about this, to be checked somehow) */ - memset(e, 0, DCI_BITS_MAX); + // memset(e, 0, DCI_BITS_MAX); e_ptr = e; @@ -3132,8 +3130,8 @@ uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue, mi, ((ue->decode_SIB == 1) ? SI_RNTI : 0), ra_rnti, - P_RNTI, - agregationLevel, + P_RNTI, + agregationLevel, format1A, format1A, format1A, @@ -3151,7 +3149,7 @@ uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue, ((format0_found==1)&&(format_c_found==1))) return(dci_cnt); - if (DCIFormat == 1) + if (DCIFormat == format1) { if ((tmode < 3) || (tmode == 7)) { //printf("Crnti decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); @@ -3194,14 +3192,14 @@ uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue, //printf("Crnti 1 decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); } - else + else if (DCIFormat == format1A) { AssertFatal(0,"Other Transmission mode not yet coded\n"); } } else { - AssertFatal(0,"DCI format %d not yet implemented \n",DCIFormat); + LOG_W(PHY,"DCI format %d wrong or not yet implemented \n",DCIFormat); } return(dci_cnt); @@ -3425,7 +3423,7 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, if (do_common == 1) { #ifdef DEBUG_DCI_DECODING - printf("[DCI search] doing common search/format0 aggregation 4\n"); + printf("[DCI search] subframe %d: doing common search/format0 aggregation 4\n",subframe); #endif if (ue->prach_resources[eNB_id]) @@ -4245,33 +4243,3 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, return(dci_cnt); } - -#ifdef PHY_ABSTRACTION -uint16_t dci_decoding_procedure_emul(LTE_UE_PDCCH **pdcch_vars, - uint8_t num_ue_spec_dci, - uint8_t num_common_dci, - DCI_ALLOC_t *dci_alloc_tx, - DCI_ALLOC_t *dci_alloc_rx, - int16_t eNB_id) -{ - - uint8_t dci_cnt=0,i; - - memcpy(dci_alloc_rx,dci_alloc_tx,num_common_dci*sizeof(DCI_ALLOC_t)); - dci_cnt = num_common_dci; - LOG_D(PHY,"[DCI][EMUL] : num_common_dci %d\n",num_common_dci); - - for (i=num_common_dci; i<(num_ue_spec_dci+num_common_dci); i++) { - LOG_D(PHY,"[DCI][EMUL] Checking dci %d => %x format %d (bit 0 %d)\n",i,pdcch_vars[eNB_id]->crnti,dci_alloc_tx[i].format, - dci_alloc_tx[i].dci_pdu[0]&0x80); - - if (dci_alloc_tx[i].rnti == pdcch_vars[eNB_id]->crnti) { - memcpy(dci_alloc_rx+dci_cnt,dci_alloc_tx+i,sizeof(DCI_ALLOC_t)); - dci_cnt++; - } - } - - - return(dci_cnt); -} -#endif diff --git a/openair1/PHY/LTE_TRANSPORT/dci.h b/openair1/PHY/LTE_TRANSPORT/dci.h index 0e74324b2c8673b86e3ccb32225ac5ee7f483e2d..9381dd63fdd1a3d49b50e6ce4b27793c1a1074c1 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci.h +++ b/openair1/PHY/LTE_TRANSPORT/dci.h @@ -482,8 +482,8 @@ typedef struct DCI1A_20MHz_FDD DCI1A_20MHz_FDD_t; /// DCI Format Type 1 (1.5 MHz, TDD, 23 bits) struct DCI1_1_5MHz_TDD { - /// Dummy bits to align to 32-bits - uint32_t dummy:9; + /// padding bits to align to 32-bits + uint32_t padding:9; /// DAI (TDD) uint32_t dai:2; /// Power Control @@ -507,8 +507,8 @@ typedef struct DCI1_1_5MHz_TDD DCI1_1_5MHz_TDD_t; /// DCI Format Type 1 (5 MHz, TDD, 30 bits) struct DCI1_5MHz_TDD { - /// Dummy bits to align to 32-bits - uint32_t dummy:2; + /// padding bits to align to 32-bits + uint32_t padding:2; /// DAI (TDD) uint32_t dai:2; /// Power Control @@ -532,8 +532,8 @@ typedef struct DCI1_5MHz_TDD DCI1_5MHz_TDD_t; /// DCI Format Type 1 (10 MHz, TDD, 34 bits) struct DCI1_10MHz_TDD { - /// Dummy bits to align to 64-bits - uint64_t dummy:30; + /// padding bits to align to 64-bits + uint64_t padding:30; /// DAI (TDD) uint64_t dai:2; /// Power Control @@ -557,8 +557,8 @@ typedef struct DCI1_10MHz_TDD DCI1_10MHz_TDD_t; /// DCI Format Type 1 (20 MHz, TDD, 42 bits) struct DCI1_20MHz_TDD { - /// Dummy bits to align to 64-bits - uint64_t dummy:22; + /// padding bits to align to 64-bits + uint64_t padding:22; /// DAI (TDD) uint64_t dai:2; /// Power Control @@ -582,8 +582,8 @@ typedef struct DCI1_20MHz_TDD DCI1_20MHz_TDD_t; /// DCI Format Type 1 (1.5 MHz, FDD, 21 bits) struct DCI1_1_5MHz_FDD { - /// Dummy bits to align to 32-bits - uint32_t dummy:11; + /// padding bits to align to 32-bits + uint32_t padding:11; /// Power Control uint32_t TPC:2; /// Redundancy version @@ -605,8 +605,8 @@ typedef struct DCI1_1_5MHz_FDD DCI1_1_5MHz_FDD_t; /// DCI Format Type 1 (5 MHz, FDD, 27 bits) struct DCI1_5MHz_FDD { - /// dummy bits (not transmitted) - uint32_t dummy:5; + /// padding its (not transmitted) + uint32_t padding:5; /// Power Control uint32_t TPC:2; /// Redundancy version @@ -628,8 +628,8 @@ typedef struct DCI1_5MHz_FDD DCI1_5MHz_FDD_t; /// DCI Format Type 1 (10 MHz, FDD, 31 bits) struct DCI1_10MHz_FDD { - /// dummy bits (not transmitted) - uint32_t dummy:1; + /// padding bits (not transmitted) + uint32_t padding:1; /// Power Control uint32_t TPC:2; /// Redundancy version @@ -651,8 +651,8 @@ typedef struct DCI1_10MHz_FDD DCI1_10MHz_FDD_t; /// DCI Format Type 1 (20 MHz, FDD, 39 bits) struct DCI1_20MHz_FDD { - /// dummy bits (not transmitted) - uint64_t dummy:25; + /// padding bits (not transmitted) + uint64_t padding:25; /// Power Control uint64_t TPC:2; /// Redundancy version @@ -674,10 +674,8 @@ typedef struct DCI1_20MHz_FDD DCI1_20MHz_FDD_t; /// DCI Format Type 1A (5 MHz, TDD, frame 1-6, 27 bits) struct DCI1A_RA_5MHz_TDD_1_6 { - /// Dummy bits to align to 32-bits - uint32_t dummy:5; - /// Padding - uint32_t padding:6; + /// padding bits to align to 32-bits + uint32_t padding:11; /// PRACH mask index uint32_t prach_mask_index:4; /// Preamble Index @@ -822,7 +820,7 @@ typedef struct DCI1B_5MHz_4A_TDD DCI1B_5MHz_4A_TDD_t; struct DCI1C_1_5MHz { /// padding to 32bits - uint32_t padding32:24; + uint32_t padding:24; uint32_t mcs:5; uint32_t rballoc:3; // N_RB_step = 2, Ngap=Ngap1=3, NDLVRBGap = 6, ceil(log2((3*4)/2)) = 3 } __attribute__ ((__packed__)); @@ -836,7 +834,7 @@ typedef struct DCI1C_1_5MHz DCI1C_1_5MHz_t; struct DCI1C_5MHz { /// padding to 32bits - uint32_t padding32:20; + uint32_t padding:20; uint32_t mcs:5; uint32_t rballoc:7; // N_RB_step = 2, Ngap1=Ngap2=12, NDLVRBGap = 24, ceil(log2((12*13)/2)) = 7 } __attribute__ ((__packed__)); @@ -848,7 +846,7 @@ typedef struct DCI1C_5MHz DCI1C_5MHz_t; struct DCI1C_10MHz { /// padding to 32bits - uint32_t padding32:19; + uint32_t padding:19; uint32_t mcs:5; uint32_t rballoc:7; // N_RB_step = 4, Ngap1=27, NDLVRBGap = 46, ceil(log2(((11*12)/2)) = 7 uint32_t Ngap:1; @@ -861,7 +859,7 @@ typedef struct DCI1C_10MHz DCI1C_10MHz_t; struct DCI1C_15MHz { /// padding to 32bits - uint32_t padding32:18; + uint32_t padding:18; uint32_t mcs:5; uint32_t rballoc:8; // N_RB_step = 4, Ngap1=64, ceil(log2((16*17)/2)) = 8 uint32_t Ngap:1; @@ -874,7 +872,7 @@ typedef struct DCI1C_15MHz DCI1C_15MHz_t; struct DCI1C_20MHz { /// padding to 32bits - uint32_t padding32:17; + uint32_t padding:17; uint32_t mcs:5; uint32_t rballoc:9; // N_RB_step = 4, Ngap1=48, ceil(log2((24*25)/2)) = 9 uint32_t Ngap:1; @@ -1006,7 +1004,7 @@ typedef struct DCI1D_5MHz_4A_TDD DCI1D_5MHz_4A_TDD_t; /// DCI Format Type 1E (5 MHz, TDD, 2 Antenna Ports, more than 10 PRBs, 34 bits) struct DCI1E_5MHz_2A_M10PRB_TDD { /// padding to 64bits - uint64_t padding64:30; + uint64_t padding:30; /// Redundancy version 2 ///uint64_t rv2:2; /// New Data Indicator 2 @@ -1045,7 +1043,7 @@ typedef struct DCI1E_5MHz_2A_M10PRB_TDD DCI1E_5MHz_2A_M10PRB_TDD_t; /// DCI Format Type 2 (1.5 MHz, TDD, 2 Antenna Ports, 34 bits) struct DCI2_1_5MHz_2A_TDD { /// padding to 64bits - uint64_t padding64:30; + uint64_t padding:30; /// TPMI information for precoding uint64_t tpmi:3; /// Redundancy version 2 @@ -1078,7 +1076,7 @@ typedef struct DCI2_1_5MHz_2A_TDD DCI2_1_5MHz_2A_TDD_t; /// DCI Format Type 2 (1.5 MHz, TDD, 4 Antenna Ports, 37 bits) struct DCI2_1_5MHz_4A_TDD { /// padding for 64-bit - uint64_t padding64:27; + uint64_t padding:27; /// TPMI information for precoding uint64_t tpmi:6; /// Redundancy version 2 @@ -1111,7 +1109,7 @@ typedef struct DCI2_1_5MHz_4A_TDD DCI2_1_5MHz_4A_TDD_t; /// DCI Format Type 2 (5 MHz, TDD, 2 Antenna Ports, 42 bits) struct DCI2_5MHz_2A_TDD { /// padding to 64bits - uint64_t padding64:22; + uint64_t padding:22; /// TPMI information for precoding uint64_t tpmi:3; /// Redundancy version 2 @@ -1146,7 +1144,7 @@ typedef struct DCI2_5MHz_2A_TDD DCI2_5MHz_2A_TDD_t; /// DCI Format Type 2 (5 MHz, TDD, 4 Antenna Ports, 45 bits) struct DCI2_5MHz_4A_TDD { /// padding for 64-bit - uint64_t padding64:19; + uint64_t padding:19; /// TPMI information for precoding uint64_t tpmi:6; /// Redundancy version 2 @@ -1181,7 +1179,7 @@ typedef struct DCI2_5MHz_4A_TDD DCI2_5MHz_4A_TDD_t; /// DCI Format Type 2 (10 MHz, TDD, 2 Antenna Ports, 46 bits) struct DCI2_10MHz_2A_TDD { /// padding to 64bits - uint64_t padding64:18; + uint64_t padding:18; /// TPMI information for precoding uint64_t tpmi:3; /// Redundancy version 2 @@ -1216,7 +1214,7 @@ typedef struct DCI2_10MHz_2A_TDD DCI2_10MHz_2A_TDD_t; /// DCI Format Type 2 (10 MHz, TDD, 4 Antenna Ports, 49 bits) struct DCI2_10MHz_4A_TDD { /// padding for 64-bit - uint64_t padding64:15; + uint64_t padding:15; /// TPMI information for precoding uint64_t tpmi:6; /// Redundancy version 2 @@ -1251,7 +1249,7 @@ typedef struct DCI2_10MHz_4A_TDD DCI2_10MHz_4A_TDD_t; /// DCI Format Type 2 (20 MHz, TDD, 2 Antenna Ports, 54 bits) struct DCI2_20MHz_2A_TDD { /// padding to 64bits - uint64_t padding64:10; + uint64_t padding:10; /// TPMI information for precoding uint64_t tpmi:3; /// Redundancy version 2 @@ -1286,7 +1284,7 @@ typedef struct DCI2_20MHz_2A_TDD DCI2_20MHz_2A_TDD_t; /// DCI Format Type 2 (20 MHz, TDD, 4 Antenna Ports, 57 bits) struct DCI2_20MHz_4A_TDD { /// padding for 64-bit - uint64_t padding64:7; + uint64_t padding:7; /// TPMI information for precoding uint64_t tpmi:6; /// Redundancy version 2 @@ -1321,7 +1319,7 @@ typedef struct DCI2_20MHz_4A_TDD DCI2_20MHz_4A_TDD_t; /// DCI Format Type 2 (1.5 MHz, FDD, 2 Antenna Ports, 31 bits) struct DCI2_1_5MHz_2A_FDD { //padding for 32 bits - uint32_t padding32:1; + uint32_t padding:1; /// precoding bits uint32_t tpmi:3; /// Redundancy version 2 @@ -1352,7 +1350,7 @@ typedef struct DCI2_1_5MHz_2A_FDD DCI2_1_5MHz_2A_FDD_t; /// DCI Format Type 2 (1.5 MHz, FDD, 4 Antenna Ports, 34 bits) struct DCI2_1_5MHz_4A_FDD { /// padding for 32 bits - uint64_t padding64:30; + uint64_t padding:30; /// precoding bits uint64_t tpmi:6; /// Redundancy version 2 @@ -1383,7 +1381,7 @@ typedef struct DCI2_1_5MHz_4A_FDD DCI2_1_5MHz_4A_FDD_t; /// DCI Format Type 2 (5 MHz, FDD, 2 Antenna Ports, 39 bits) struct DCI2_5MHz_2A_FDD { /// padding for 64-bit - uint64_t padding64:25; + uint64_t padding:25; /// TPMI information for precoding uint64_t tpmi:3; /// Redundancy version 2 @@ -1416,7 +1414,7 @@ typedef struct DCI2_5MHz_2A_FDD DCI2_5MHz_2A_FDD_t; /// DCI Format Type 2 (5 MHz, TDD, 4 Antenna Ports, 42 bits) struct DCI2_5MHz_4A_FDD { /// padding for 64-bit - uint64_t padding64:21; + uint64_t padding:21; /// TPMI information for precoding uint64_t tpmi:6; /// Redundancy version 2 @@ -1448,7 +1446,7 @@ typedef struct DCI2_5MHz_4A_FDD DCI2_5MHz_4A_FDD_t; /// DCI Format Type 2 (10 MHz, FDD, 2 Antenna Ports, 43 bits) struct DCI2_10MHz_2A_FDD { /// padding for 64-bit - uint64_t padding64:21; + uint64_t padding:21; /// TPMI information for precoding uint64_t tpmi:3; /// Redundancy version 2 @@ -1481,7 +1479,7 @@ typedef struct DCI2_10MHz_2A_FDD DCI2_10MHz_2A_FDD_t; /// DCI Format Type 2 (5 MHz, TDD, 4 Antenna Ports, 46 bits) struct DCI2_10MHz_4A_FDD { /// padding for 64-bit - uint64_t padding64:18; + uint64_t padding:18; /// TPMI information for precoding uint64_t tpmi:6; /// Redundancy version 2 @@ -1513,7 +1511,7 @@ typedef struct DCI2_10MHz_4A_FDD DCI2_10MHz_4A_FDD_t; /// DCI Format Type 2 (20 MHz, FDD, 2 Antenna Ports, 51 bits) struct DCI2_20MHz_2A_FDD { /// padding for 64-bit - uint64_t padding64:13; + uint64_t padding:13; /// TPMI information for precoding uint64_t tpmi:3; /// Redundancy version 2 @@ -1546,7 +1544,7 @@ typedef struct DCI2_20MHz_2A_FDD DCI2_20MHz_2A_FDD_t; /// DCI Format Type 2 (20 MHz, FDD, 4 Antenna Ports, 54 bits) struct DCI2_20MHz_4A_FDD { /// padding for 64-bit - uint64_t padding64:10; + uint64_t padding:10; /// TPMI information for precoding uint64_t tpmi:6; /// Redundancy version 2 @@ -2083,7 +2081,7 @@ typedef struct DCI2A_20MHz_4A_FDD DCI2A_20MHz_4A_FDD_t; // ******************************************************************* /// DCI Format Type 2B (1.5 MHz, TDD, 33 bits) struct DCI2B_1_5MHz_TDD { - uint64_t padding64:31; + uint64_t padding:31; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2109,7 +2107,7 @@ struct DCI2B_1_5MHz_TDD { /// RB Assignment (ceil(log2(N_RB_DL/P)) bits) uint64_t rballoc:6; /// Padding for ambiguity - uint64_t padding:1; + uint64_t padding0:1; } __attribute__ ((__packed__)); typedef struct DCI2B_1_5MHz_TDD DCI2B_1_5MHz_TDD_t; @@ -2118,7 +2116,7 @@ typedef struct DCI2B_1_5MHz_TDD DCI2B_1_5MHz_TDD_t; /// DCI Format Type 2B (5 MHz, TDD, 39 bits) struct DCI2B_5MHz_TDD { /// padding to 64bits - uint64_t padding64:25; + uint64_t padding:25; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2153,7 +2151,7 @@ typedef struct DCI2B_5MHz_TDD DCI2B_5MHz_TDD_t; /// DCI Format Type 2B (10 MHz, TDD, 43 bits) struct DCI2B_10MHz_TDD { /// padding to 64bits - uint64_t padding64:21; + uint64_t padding:21; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2188,7 +2186,7 @@ typedef struct DCI2B_10MHz_TDD DCI2B_10MHz_TDD_t; /// DCI Format Type 2B (20 MHz, TDD, 51 bits) struct DCI2B_20MHz_TDD { /// padding to 64bits - uint64_t padding64:13; + uint64_t padding:13; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2223,7 +2221,7 @@ typedef struct DCI2B_20MHz_TDD DCI2B_20MHz_TDD_t; /// DCI Format Type 2B (1.5 MHz, FDD, 28 bits) struct DCI2B_1_5MHz_FDD { //padding for 32 bits - uint32_t padding32:4; + uint32_t padding:4; /// Redundancy version 2 uint32_t rv2:2; /// New Data Indicator 2 @@ -2252,7 +2250,7 @@ typedef struct DCI2B_1_5MHz_FDD DCI2B_1_5MHz_FDD_t; /// DCI Format Type 2B (5 MHz, FDD, 36 bits) struct DCI2B_5MHz_FDD { /// padding for 64-bit - uint64_t padding64:28; + uint64_t padding:28; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2283,7 +2281,7 @@ typedef struct DCI2B_5MHz_FDD DCI2B_5MHz_FDD_t; /// DCI Format Type 2B (10 MHz, FDD, 41 bits) struct DCI2B_10MHz_FDD { /// padding for 64-bit - uint64_t padding64:23; + uint64_t padding:23; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2307,7 +2305,7 @@ struct DCI2B_10MHz_FDD { /// Resource Allocation Header uint64_t rah:1; /// Padding for ambiguity - uint64_t padding:1; + uint64_t padding0:1; } __attribute__ ((__packed__)); #define sizeof_DCI2B_10MHz_FDD_t 41 @@ -2316,7 +2314,7 @@ typedef struct DCI2B_10MHz_FDD DCI2B_10MHz_FDD_t; /// DCI Format Type 2B (20 MHz, FDD, 48 bits) struct DCI2B_20MHz_FDD { /// padding for 64-bit - uint64_t padding64:16; + uint64_t padding:16; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2350,7 +2348,7 @@ typedef struct DCI2B_20MHz_FDD DCI2B_20MHz_FDD_t; /// DCI Format Type 2C (1.5 MHz, TDD, 34 bits) struct DCI2C_1_5MHz_TDD { - uint64_t padding64:30; + uint64_t padding:30; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2383,7 +2381,7 @@ typedef struct DCI2C_1_5MHz_TDD DCI2C_1_5MHz_TDD_t; /// DCI Format Type 2C (5 MHz, TDD, 41 bits) struct DCI2C_5MHz_TDD { /// padding to 64bits - uint64_t padding64:23; + uint64_t padding:23; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2418,7 +2416,7 @@ typedef struct DCI2C_5MHz_TDD DCI2C_5MHz_TDD_t; /// DCI Format Type 2C (10 MHz, TDD, 45 bits) struct DCI2C_10MHz_TDD { /// padding to 64bits - uint64_t padding64:19; + uint64_t padding:19; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2453,7 +2451,7 @@ typedef struct DCI2C_10MHz_TDD DCI2C_10MHz_TDD_t; /// DCI Format Type 2C (20 MHz, TDD, 53 bits) struct DCI2C_20MHz_TDD { /// padding to 64bits - uint64_t padding64:11; + uint64_t padding:11; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2488,7 +2486,7 @@ typedef struct DCI2C_20MHz_TDD DCI2C_20MHz_TDD_t; /// DCI Format Type 2C (1.5 MHz, FDD, 30 bits) struct DCI2C_1_5MHz_FDD { //padding for 32 bits - uint32_t padding32:2; + uint32_t padding:2; /// Redundancy version 2 uint32_t rv2:2; /// New Data Indicator 2 @@ -2517,7 +2515,7 @@ typedef struct DCI2C_1_5MHz_FDD DCI2C_1_5MHz_FDD_t; /// DCI Format Type 2C (5 MHz, FDD, 38 bits) struct DCI2C_5MHz_FDD { /// padding for 64-bit - uint64_t padding64:26; + uint64_t padding:26; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2548,7 +2546,7 @@ typedef struct DCI2C_5MHz_FDD DCI2C_5MHz_FDD_t; /// DCI Format Type 2C (10 MHz, FDD, 42 bits) struct DCI2C_10MHz_FDD { /// padding for 64-bit - uint64_t padding64:22; + uint64_t padding:22; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2579,7 +2577,7 @@ typedef struct DCI2C_10MHz_FDD DCI2C_10MHz_FDD_t; /// DCI Format Type 2C (20 MHz, FDD, 50 bits) struct DCI2C_20MHz_FDD { /// padding for 64-bit - uint64_t padding64:14; + uint64_t padding:14; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 @@ -2613,7 +2611,7 @@ typedef struct DCI2C_20MHz_FDD DCI2C_20MHz_FDD_t; /// DCI Format Type 2D (1.5 MHz, TDD, 36 bits) struct DCI2D_1_5MHz_TDD { - uint64_t padding64:28; + uint64_t padding:28; /// PDSCH REsource Mapping and Quasi-Co-Location Indicator uint64_t REMQCL:2; /// Redundancy version 2 @@ -2648,7 +2646,7 @@ typedef struct DCI2D_1_5MHz_TDD DCI2D_1_5MHz_TDD_t; /// DCI Format Type 2D (5 MHz, TDD, 43 bits) struct DCI2D_5MHz_TDD { /// padding to 64bits - uint64_t padding64:21; + uint64_t padding:21; /// PDSCH REsource Mapping and Quasi-Co-Location Indicator uint64_t REMQCL:2; /// Redundancy version 2 @@ -2685,7 +2683,7 @@ typedef struct DCI2D_5MHz_TDD DCI2D_5MHz_TDD_t; /// DCI Format Type 2D (10 MHz, TDD, 47 bits) struct DCI2D_10MHz_TDD { /// padding to 64bits - uint64_t padding64:17; + uint64_t padding:17; /// PDSCH REsource Mapping and Quasi-Co-Location Indicator uint64_t REMQCL:2; /// Redundancy version 2 @@ -2722,7 +2720,7 @@ typedef struct DCI2D_10MHz_TDD DCI2D_10MHz_TDD_t; /// DCI Format Type 2D (20 MHz, TDD, 55 bits) struct DCI2D_20MHz_TDD { /// padding to 64bits - uint64_t padding64:9; + uint64_t padding:9; /// PDSCH REsource Mapping and Quasi-Co-Location Indicator uint64_t REMQCL:2; /// Redundancy version 2 @@ -2759,7 +2757,7 @@ typedef struct DCI2D_20MHz_TDD DCI2D_20MHz_TDD_t; /// DCI Format Type 2D (1.5 MHz, FDD, 33 bits) struct DCI2D_1_5MHz_FDD { //padding for 33 bits - uint64_t padding64:31; + uint64_t padding:31; /// PDSCH REsource Mapping and Quasi-Co-Location Indicator uint64_t REMQCL:2; /// Redundancy version 2 @@ -2783,7 +2781,7 @@ struct DCI2D_1_5MHz_FDD { /// RB Assignment (ceil(log2(N_RB_DL/P)) bits) uint64_t rballoc:6; /// padding for ambiguity - uint64_t padding; + uint64_t padding0; } __attribute__ ((__packed__)); typedef struct DCI2D_1_5MHz_FDD DCI2D_1_5MHz_FDD_t; @@ -2792,7 +2790,7 @@ typedef struct DCI2D_1_5MHz_FDD DCI2D_1_5MHz_FDD_t; /// DCI Format Type 2D (5 MHz, FDD, 41 bits) struct DCI2D_5MHz_FDD { /// padding for 64-bit - uint64_t padding64:23; + uint64_t padding:23; /// PDSCH REsource Mapping and Quasi-Co-Location Indicator uint64_t REMQCL:2; /// Redundancy version 2 @@ -2818,7 +2816,7 @@ struct DCI2D_5MHz_FDD { /// Resource Allocation Header uint64_t rah:1; /// padding for ambiguity - uint64_t padding:1; + uint64_t padding0:1; } __attribute__ ((__packed__)); #define sizeof_DCI2D_5MHz_FDD_t 41 @@ -2827,7 +2825,7 @@ typedef struct DCI2D_5MHz_FDD DCI2D_5MHz_FDD_t; /// DCI Format Type 2D (10 MHz, FDD, 45 bits) struct DCI2D_10MHz_FDD { /// padding for 64-bit - uint64_t padding64:19; + uint64_t padding:19; /// PDSCH REsource Mapping and Quasi-Co-Location Indicator uint64_t REMQCL:2; /// Redundancy version 2 @@ -2853,7 +2851,7 @@ struct DCI2D_10MHz_FDD { /// Resource Allocation Header uint64_t rah:1; /// padding for ambiguity - uint64_t padding:1; + uint64_t padding0:1; } __attribute__ ((__packed__)); #define sizeof_DCI2D_10MHz_FDD_t 45 @@ -2862,7 +2860,7 @@ typedef struct DCI2D_10MHz_FDD DCI2D_10MHz_FDD_t; /// DCI Format Type 2D (20 MHz, FDD, 52 bits) struct DCI2D_20MHz_FDD { /// padding for 64-bit - uint64_t padding64:12; + uint64_t padding:12; /// Redundancy version 2 uint64_t rv2:2; /// New Data Indicator 2 diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 8f8dd1e6ffe4fa300dfa09adacbddebf213a02a3..944318aac49700866e813e83a908ba0f3b844916 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -911,6 +911,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->padding = 0; } else { dci_alloc->dci_length = sizeof_DCI1A_1_5MHz_FDD_t; ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->type = 1; @@ -921,6 +922,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -935,7 +937,8 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->padding = 0; // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1A_5MHz_FDD_t; @@ -947,6 +950,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_5MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -962,6 +966,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->padding = 0; // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1A_10MHz_FDD_t; @@ -973,6 +978,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_10MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -988,6 +994,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->padding = 0; // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1A_20MHz_FDD_t; @@ -999,6 +1006,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_20MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -1008,7 +1016,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a proc->frame_tx, proc->subframe_tx, rel8->rnti); } -void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,nfapi_dl_config_dci_dl_pdu *pdu) +void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,nfapi_dl_config_dci_dl_pdu *pdu) { LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; uint8_t *dci_pdu = &dci_alloc->dci_pdu[0]; @@ -1032,7 +1040,6 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; int beamforming_mode = 0; int UE_id=-1; - int subframe = proc->subframe_tx; int NPRB; int TB0_active; int TB1_active; @@ -1045,8 +1052,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci dci_alloc->harq_pid = rel8->harq_process; dci_alloc->ra_flag = 0; - LOG_D(PHY,"NFAPI: DCI format %d, nCCE %d, L %d, rnti %x,harq_pid %d\n", - rel8->dci_format,rel8->cce_idx,rel8->aggregation_level,rel8->rnti,rel8->harq_process); + LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[SFN/SF:%04d%d] DCI format %d, nCCE %d, L %d, rnti %x, harq_pid %d\n", + frame,subframe,proc->frame_tx,proc->subframe_tx,rel8->dci_format,rel8->cce_idx,rel8->aggregation_level,rel8->rnti,rel8->harq_process); if ((rel8->rnti_type == 2 ) && (rel8->rnti != SI_RNTI) && (rel8->rnti != P_RNTI)) dci_alloc->ra_flag = 1; UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); @@ -1063,8 +1070,11 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci dlsch1_harq->codeword = 1; dlsch0->subframe_tx[subframe] = 1; - LOG_D(PHY,"NFAPI: dlsch0[rnti:%x] dci_pdu[rnti:%x rnti_type:%d harq_process:%d ndi1:%d] dlsch0_harq[round:%d harq_mask:%x ndi:%d]\n", - dlsch0->rnti, + + LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:SFN/SF:%04d%d dlsch0[rnti:%x harq_mask:%04x] dci_pdu[rnti:%x rnti_type:%d harq_process:%d ndi1:%d] dlsch0_harq[round:%d harq_mask:%x ndi:%d]\n", + frame,subframe, + proc->frame_tx,proc->subframe_tx, + dlsch0->rnti,dlsch0->harq_mask, rel8->rnti, rel8->rnti_type, rel8->harq_process, rel8->new_data_indicator_1, dlsch0_harq->round, dlsch0->harq_mask, dlsch0_harq->ndi); @@ -1085,15 +1095,18 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci if (rel8->rnti_type == 2) dlsch0_harq->round = 0; - LOG_D(PHY,"NFAPI: harq_pid %d harq_mask %x, round %d ndi (%d,%d) rnti type %d\n",rel8->harq_process,dlsch0->harq_mask,dlsch0_harq->round, - dlsch0_harq->ndi,rel8->new_data_indicator_1, rel8->rnti_type); + LOG_D(PHY,"NFAPI: rel8[rnti %x dci_format %d harq_process %d ndi1 %d rnti type %d] dlsch0[rnti %x harq_mask %x] dlsch0_harq[round %d ndi %d]\n", + rel8->rnti,rel8->dci_format,rel8->harq_process, rel8->new_data_indicator_1, rel8->rnti_type, + dlsch0->rnti,dlsch0->harq_mask, + dlsch0_harq->round,dlsch0_harq->ndi + ); switch (rel8->dci_format) { case NFAPI_DL_DCI_FORMAT_1A: - AssertFatal(rel8->resource_block_coding < 8192, "Frame %d, Subframe %d: rel8->resource_block_coding (%p) %u >= 8192 (rnti %x, rnti_type %d, format %d, harq_id %d\n", - proc->frame_tx,subframe, + AssertFatal(rel8->resource_block_coding < 8192, "SFN/SF:%04d%d proc:TX:SFN/SF:%04d%d: rel8->resource_block_coding (%p) %u >= 8192 (rnti %x, rnti_type %d, format %d, harq_id %d\n", + frame,subframe,proc->frame_tx,subframe, &rel8->resource_block_coding,rel8->resource_block_coding,rel8->rnti,rel8->rnti_type,rel8->dci_format,rel8->harq_process); @@ -1112,6 +1125,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->padding = 0; } else { dci_alloc->dci_length = sizeof_DCI1A_1_5MHz_FDD_t; @@ -1123,6 +1137,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n"); @@ -1141,7 +1156,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->padding = 0; // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1A_5MHz_FDD_t; @@ -1153,6 +1169,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_5MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n"); @@ -1171,7 +1188,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->padding = 0; // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1A_10MHz_FDD_t; @@ -1183,6 +1201,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_10MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n"); @@ -1202,7 +1221,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->padding = 0; // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1A_20MHz_FDD_t; @@ -1214,6 +1234,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1A_20MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n"); @@ -1236,7 +1257,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci NPRB = dlsch0_harq->nb_rb; I_mcs = get_I_TBS(rel8->mcs_1); } - AssertFatal(NPRB>0,"DCI 1A: NPRB = 0 (rnti %x, rnti type %d, tpc %d, round %d, resource_block_coding %d)\n",rel8->rnti,rel8->rnti_type,rel8->tpc,dlsch0_harq->round,rel8->resource_block_coding); + AssertFatal(NPRB>0,"DCI 1A: NPRB = 0 (rnti %x, rnti type %d, tpc %d, round %d, resource_block_coding %d, harq process %d)\n",rel8->rnti,rel8->rnti_type,rel8->tpc,dlsch0_harq->round,rel8->resource_block_coding,rel8->harq_process); dlsch0_harq->rvidx = rel8->redundancy_version_1; dlsch0_harq->Nl = 1; dlsch0_harq->mimo_mode = (fp->nb_antenna_ports_eNB == 1) ? SISO : ALAMOUTI; @@ -1256,7 +1277,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci dlsch0->harq_mask |= (1<<rel8->harq_process); - if (rel8->rnti_type == 1) LOG_I(PHY,"DCI 1A: round %d, mcs %d, rballoc %x,rv %d, rnti %x\n",dlsch0_harq->round,rel8->mcs_1,rel8->resource_block_coding,rel8->redundancy_version_1,rel8->rnti); + if (rel8->rnti_type == 1) LOG_I(PHY,"DCI 1A: round %d, mcs %d, rballoc %x, rv %d, rnti %x, harq process %d\n",dlsch0_harq->round,rel8->mcs_1,rel8->resource_block_coding,rel8->redundancy_version_1,rel8->rnti,rel8->harq_process); break; case NFAPI_DL_DCI_FORMAT_1: @@ -1264,7 +1285,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci dci_alloc->format = format1; dlsch0->active = 1; - LOG_D(PHY,"Frame %d, Subframe %d: Programming DLSCH for Format 1 DCI, harq_pid %d\n",proc->frame_tx,subframe,rel8->harq_process); + LOG_D(PHY,"SFN/SF:%04d%d proc:TX:SFN/SF:%04d%d: Programming DLSCH for Format 1 DCI, harq_pid %d\n",frame,subframe,proc->frame_tx,subframe,rel8->harq_process); switch (fp->N_RB_DL) { case 6: @@ -1277,7 +1298,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_1_5MHz_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_1_5MHz_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1_1_5MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_1_5MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_1_5MHz_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1_1_5MHz_FDD_t; @@ -1288,6 +1310,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_1_5MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_1_5MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1_1_5MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -1301,7 +1324,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_5MHz_TDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_5MHz_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_5MHz_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1_5MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_5MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_5MHz_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1_5MHz_FDD_t; @@ -1312,6 +1336,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_5MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_5MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_5MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1_5MHz_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -1325,7 +1350,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_10MHz_TDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_10MHz_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_10MHz_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1_10MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_10MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_10MHz_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1_10MHz_FDD_t; @@ -1336,6 +1362,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_10MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_10MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_10MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1_10MHz_FDD_t *)dci_pdu)->padding = 0; } break; case 100: @@ -1348,7 +1375,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_20MHz_TDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_20MHz_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_20MHz_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI1_20MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_20MHz_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI1_20MHz_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1_20MHz_FDD_t; @@ -1359,6 +1387,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI1_20MHz_FDD_t *)dci_pdu)->rv = rel8->redundancy_version_1; ((DCI1_20MHz_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI1_20MHz_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; + ((DCI1_20MHz_FDD_t *)dci_pdu)->padding = 0; } break; } @@ -1443,6 +1472,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + /* there is no padding in this structure, it is exactly 32 bits */ // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI2A_1_5MHz_2A_FDD_t; @@ -1457,6 +1487,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -1473,8 +1504,9 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; - ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI2A_5MHz_2A_FDD_t; @@ -1489,6 +1521,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -1505,8 +1538,9 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; - ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI2A_10MHz_2A_FDD_t; @@ -1520,7 +1554,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->padding = 0; } break; case 100: @@ -1536,8 +1571,9 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; - ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI2A_20MHz_2A_FDD_t; @@ -1551,7 +1587,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->padding = 0; } break; @@ -1754,6 +1791,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI2_1_5MHz_2A_FDD_t; @@ -1768,6 +1806,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -1787,6 +1826,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI2_5MHz_2A_FDD_t; @@ -1801,7 +1841,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; - ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->padding = 0; // printf("FDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } break; @@ -1821,6 +1862,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { dci_alloc->dci_length = sizeof_DCI2_10MHz_2A_FDD_t; @@ -1834,13 +1876,14 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->padding = 0; } break; case 100: if (fp->frame_type == TDD) { - dci_alloc->dci_length = sizeof_DCI2_20MHz_2A_TDD_t; + dci_alloc->dci_length = sizeof_DCI2_20MHz_2A_TDD_t; ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rah = rel8->resource_allocation_type; ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs1 = rel8->mcs_1; ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs2 = rel8->mcs_2; @@ -1851,12 +1894,13 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; - ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; + ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->dai = rel8->downlink_assignment_index; ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->padding = 0; // printf("TDD 1: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { - dci_alloc->dci_length = sizeof_DCI2_20MHz_2A_FDD_t; + dci_alloc->dci_length = sizeof_DCI2_20MHz_2A_FDD_t; ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rah = rel8->resource_allocation_type; ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs1 = rel8->mcs_1; ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs2 = rel8->mcs_2; @@ -1867,8 +1911,9 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv2 = rel8->redundancy_version_2; ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->TPC = rel8->tpc; ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->harq_pid = rel8->harq_process; - ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; + ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap = rel8->transport_block_to_codeword_swap_flag; ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi = rel8->precoding_information; + ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->padding = 0; } break; @@ -2121,11 +2166,11 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci } if (dlsch0_harq) { - dlsch0_harq->frame = proc->frame_tx; + dlsch0_harq->frame = frame; dlsch0_harq->subframe = subframe; } if (dlsch1_harq) { - dlsch1_harq->frame = proc->frame_tx; + dlsch1_harq->frame = frame; dlsch1_harq->subframe = subframe; } @@ -2163,7 +2208,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci #if T_TRACER if (dlsch0->active) - T(T_ENB_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(proc->frame_tx), T_INT(proc->subframe_tx), + T(T_ENB_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame), T_INT(subframe), T_INT(rel8->rnti), T_INT(rel8->dci_format), T_INT(rel8->harq_process), T_INT(rel8->mcs_1), T_INT(dlsch0_harq->TBS)); #endif @@ -2229,6 +2274,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_1A_5MHz_t *)dci_pdu)->srs_req = rel13->srs_request; ((DCI6_1A_5MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset; ((DCI6_1A_5MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_1A_5MHz_t *)dci_pdu)->padding = 0; break; case 50: @@ -2245,6 +2291,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_1A_10MHz_t *)dci_pdu)->srs_req = rel13->srs_request; ((DCI6_1A_10MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset; ((DCI6_1A_10MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_1A_10MHz_t *)dci_pdu)->padding = 0; break; case 100: dci_alloc->dci_length = sizeof_DCI6_1A_20MHz_t; @@ -2260,6 +2307,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_1A_20MHz_t *)dci_pdu)->srs_req = rel13->srs_request; ((DCI6_1A_20MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset; ((DCI6_1A_20MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_1A_20MHz_t *)dci_pdu)->padding = 0; break; } break; @@ -2278,6 +2326,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_1B_5MHz_t *)dci_pdu)->ndi = rel13->new_data_indicator; ((DCI6_1B_5MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset; ((DCI6_1B_5MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_1B_5MHz_t *)dci_pdu)->padding = 0; break; case 50: @@ -2290,6 +2339,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_1B_10MHz_t *)dci_pdu)->ndi = rel13->new_data_indicator; ((DCI6_1B_10MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset; ((DCI6_1B_10MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_1B_10MHz_t *)dci_pdu)->padding = 0; break; case 100: dci_alloc->dci_length = sizeof_DCI6_1B_20MHz_t; @@ -2301,6 +2351,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_1B_20MHz_t *)dci_pdu)->ndi = rel13->new_data_indicator; ((DCI6_1B_20MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset; ((DCI6_1B_20MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_1B_20MHz_t *)dci_pdu)->padding = 0; break; } case 12: // Format 6-2 @@ -2312,6 +2363,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d if (rel13->paging_direct_indication_differentiation_flag==0) { ((DCI6_2_di_5MHz_t *)dci_pdu)->type = 0; ((DCI6_2_di_5MHz_t *)dci_pdu)->di_info = rel13->direct_indication; + ((DCI6_2_di_5MHz_t *)dci_pdu)->padding = 0; } else { ((DCI6_2_paging_5MHz_t *)dci_pdu)->type = 1; @@ -2319,6 +2371,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_2_paging_5MHz_t *)dci_pdu)->mcs = rel13->mcs; ((DCI6_2_paging_5MHz_t *)dci_pdu)->rep = (rel13->pdsch_reptition_levels-1); ((DCI6_2_paging_5MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_2_paging_5MHz_t *)dci_pdu)->padding = 0; } break; @@ -2327,6 +2380,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d if (rel13->paging_direct_indication_differentiation_flag==0) { ((DCI6_2_di_10MHz_t *)dci_pdu)->type = 0; ((DCI6_2_di_10MHz_t *)dci_pdu)->di_info = rel13->direct_indication; + ((DCI6_2_di_10MHz_t *)dci_pdu)->padding = 0; } else { ((DCI6_2_paging_10MHz_t *)dci_pdu)->type = 1; @@ -2334,6 +2388,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_2_paging_10MHz_t *)dci_pdu)->mcs = rel13->mcs; ((DCI6_2_paging_10MHz_t *)dci_pdu)->rep = (rel13->pdsch_reptition_levels-1); ((DCI6_2_paging_10MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_2_paging_10MHz_t *)dci_pdu)->padding = 0; } break; @@ -2342,6 +2397,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d if (rel13->paging_direct_indication_differentiation_flag==0) { ((DCI6_2_di_20MHz_t *)dci_pdu)->type = 0; ((DCI6_2_di_20MHz_t *)dci_pdu)->di_info = rel13->direct_indication; + ((DCI6_2_di_20MHz_t *)dci_pdu)->padding = 0; } else { ((DCI6_2_paging_20MHz_t *)dci_pdu)->type = 1; @@ -2349,6 +2405,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d ((DCI6_2_paging_20MHz_t *)dci_pdu)->mcs = rel13->mcs; ((DCI6_2_paging_20MHz_t *)dci_pdu)->rep = (rel13->pdsch_reptition_levels-1); ((DCI6_2_paging_20MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1; + ((DCI6_2_paging_20MHz_t *)dci_pdu)->padding = 0; } break; @@ -2410,8 +2467,8 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d } -void fill_dci0(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, - nfapi_hi_dci0_dci_pdu *pdu) +void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, + DCI_ALLOC_t *dci_alloc,nfapi_hi_dci0_dci_pdu *pdu) { LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; @@ -2428,8 +2485,8 @@ void fill_dci0(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, uint32_t ndi = pdu->dci_pdu_rel8.new_data_indication_1; #ifdef T_TRACER - T(T_ENB_PHY_ULSCH_UE_DCI, T_INT(eNB->Mod_id), T_INT(proc->frame_tx), T_INT(proc->subframe_tx), - T_INT(pdu->dci_pdu_rel8.rnti), T_INT(((proc->frame_tx*10+proc->subframe_tx+4) % 8) /* TODO: correct harq pid */), + T(T_ENB_PHY_ULSCH_UE_DCI, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), + T_INT(pdu->dci_pdu_rel8.rnti), T_INT(((frame*10+subframe+4) % 8) /* TODO: correct harq pid */), T_INT(mcs), T_INT(-1 /* TODO: remove round? */), T_INT(pdu->dci_pdu_rel8.resource_block_start), T_INT(pdu->dci_pdu_rel8.number_of_resource_block), @@ -2440,10 +2497,11 @@ void fill_dci0(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, void *dci_pdu = (void*)dci_alloc->dci_pdu; - LOG_D(PHY,"Filling DCI0 with rnti %x cqi %d, mcs %d, hopping %d, rballoc %x (%d,%d) ndi %d TPC %d cshift %d\n", - pdu->dci_pdu_rel8.rnti,cqi_req, mcs,hopping,rballoc, - pdu->dci_pdu_rel8.resource_block_start, - pdu->dci_pdu_rel8.number_of_resource_block, ndi,TPC,cshift); + LOG_D(PHY,"SFN/SF:%04d%d DCI0[rnti %x cqi %d mcs %d hopping %d rballoc %x (%d,%d) ndi %d TPC %d cshift %d]\n", + frame,subframe, + pdu->dci_pdu_rel8.rnti,cqi_req, mcs,hopping,rballoc, + pdu->dci_pdu_rel8.resource_block_start, + pdu->dci_pdu_rel8.number_of_resource_block, ndi,TPC,cshift); dci_alloc->format = format0; dci_alloc->firstCCE = pdu->dci_pdu_rel8.cce_index; @@ -5021,10 +5079,10 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, if(symbol < (frame_parms->symbols_per_tti-1)) pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; - //LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); - //LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); - //LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); - //LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); + // LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); + // LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); + // LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); + // LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); @@ -5061,7 +5119,6 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, uint8_t NPRB = 0; uint8_t NPRB4TBS = 0; - uint8_t nb_rb_alloc = 0; if(dci_format == format1A) { @@ -5103,14 +5160,12 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, } */ - nb_rb_alloc = NPRB; } } else // format1 { NPRB = conv_nprb(rah, rballoc, N_RB_DL); NPRB4TBS=NPRB; - nb_rb_alloc = NPRB; } pdlsch0->current_harq_pid = harq_pid; @@ -5211,7 +5266,6 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT50_1[rballoc]; pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT50_0[rballoc]; pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT50_1[rballoc]; - printf("rballoc: %08x.%08x\n",pdlsch0_harq->rb_alloc_even[0],pdlsch0_harq->rb_alloc_even[1]); } else { // DISTRIBUTED if ((rballoc&(1<<10)) == 0) { rballoc = rballoc&(~(1<<10)); @@ -5293,7 +5347,7 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, pdcch_vars, pdsch_vars, pdlsch0_harq, - nb_rb_alloc, + NPRB, subframe); } @@ -6435,8 +6489,9 @@ uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t if (frame_parms->frame_type == FDD) { ret = (((frame*10)+subframe)&7); + //LOG_I(MAC, "Panos-D: subframe2harq_pid 1, ret: %d \n", ret); } else { - + //LOG_I(MAC, "Panos-D: subframe2harq_pid 2 \n"); switch (frame_parms->tdd_config) { case 1: @@ -6525,7 +6580,7 @@ uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) else ul_subframe = ((n+4)%10); - if (subframe_select(frame_parms,ul_subframe) != SF_UL) return(255); + // AssertFatal(frame_parms->frame_type == FDD || subframe_select(frame_parms,ul_subframe) == SF_UL,"illegal ul_subframe %d (n %d)\n",ul_subframe,n); LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe); return ul_subframe; @@ -7226,6 +7281,10 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, harq_pid = subframe2harq_pid(frame_parms, pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,subframe), pdcch_alloc2ul_subframe(frame_parms,subframe)); + LOG_D(PHY,"Frame %d, Subframe %d: Programming ULSCH for (%d.%d) => harq_pid %d\n", + proc->frame_rx,subframe, + pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,subframe), + pdcch_alloc2ul_subframe(frame_parms,subframe), harq_pid); if (harq_pid == 255) { LOG_E(PHY, "frame %d, subframe %d, rnti %x, format %d: illegal harq_pid!\n", @@ -8018,7 +8077,7 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, dlsch[0]->harq_ack[subframe].vDAI_UL = dai+1; - /*LOG_I(PHY, "[PUSCH %d] Format0 DCI %s, CQI_req=%d, cshift=%d, TPC=%d, DAI=%d, vDAI_UL[sf#%d]=%d, NDI=%d, MCS=%d, RBalloc=%d, first_rb=%d, harq_pid=%d, nb_rb=%d, subframe_scheduling_flag=%d" + LOG_D(PHY, "[PUSCH %d] Format0 DCI %s, CQI_req=%d, cshift=%d, TPC=%d, DAI=%d, vDAI_UL[sf#%d]=%d, NDI=%d, MCS=%d, RBalloc=%d, first_rb=%d, harq_pid=%d, nb_rb=%d, subframe_scheduling_flag=%d" " ulsch->bundling %d, O_ACK %d \n", harq_pid, (frame_parms->frame_type == TDD? "TDD" : "FDD"), @@ -8026,7 +8085,8 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, ulsch->harq_processes[harq_pid]->first_rb, harq_pid, ulsch->harq_processes[harq_pid]->nb_rb, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->bundling, - ulsch->harq_processes[harq_pid]->O_ACK);*/ + ulsch->harq_processes[harq_pid]->O_ACK); + LOG_D(PHY,"Setting beta_offset_cqi_times8 to %d, index %d\n", beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index], ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index); @@ -8083,7 +8143,7 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu, #ifdef UE_DEBUG_TRACE - LOG_I(PHY,"Format 0 DCI : ulsch (ue): AbsSubframe %d.%d\n",proc->frame_rx%1024,subframe); + LOG_D(PHY,"Format 0 DCI : ulsch (ue): AbsSubframe %d.%d\n",proc->frame_rx%1024,subframe); LOG_D(PHY,"Format 0 DCI : ulsch (ue): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); LOG_D(PHY,"Format 0 DCI :ulsch (ue): rballoc %d\n",rballoc); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index dbfae80840c4c76fe605fa11fb8023cfb4877b13..bd3c92454f4be0375d355b624bd83bae51415b07 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -247,6 +247,7 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) Mdlharq = dlsch->Mdlharq; dlsch->rnti = 0; dlsch->active = 0; + dlsch->harq_mask = 0; for (i=0; i<10; i++) dlsch->harq_ids[i] = Mdlharq; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c index 271de54795337416bf1ba5ec513bfda37dbcb7b8..7acf6480eb40df1d7aef3e2c4be17bdcb2dc2fa4 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c @@ -758,318 +758,3 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, return(ret); } -#ifdef PHY_ABSTRACTION -#include "SIMULATION/TOOLS/defs.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" -#endif - -int dlsch_abstraction_EESM(double* sinr_dB, uint8_t TM, uint32_t rb_alloc[4], uint8_t mcs, uint8_t dl_power_off) -{ - - int ii; - double sinr_eff = 0; - int rb_count = 0; - int offset; - double bler = 0; - - if(TM==5 && dl_power_off==1) { - //do nothing -- means there is no second UE and TM 5 is behaving like TM 6 for a singal user - } else - TM = TM-1; - - for (offset = 0; offset <= 24; offset++) { - if (rb_alloc[0] & (1<<offset)) { - rb_count++; - - for(ii=0; ii<12; ii++) { - sinr_eff += exp(-(pow(10, 0.1*(sinr_dB[(offset*12)+ii])))/beta1_dlsch[TM][mcs]); - //printf("sinr_eff1 = %f, power %lf\n",sinr_eff, exp(-pow(10,6.8))); - - // sinr_eff += exp(-(pow(10, (sinr_dB[offset*2+1])/10))/beta1_dlsch[TM][mcs]); - //printf("sinr_dB[%d]=%f\n",offset,sinr_dB[offset*2]); - } - } - } - - LOG_D(OCM,"sinr_eff (lin, unweighted) = %f\n",sinr_eff); - sinr_eff = -beta2_dlsch[TM][mcs]*log((sinr_eff)/(12*rb_count)); - LOG_D(OCM,"sinr_eff (lin, weighted) = %f\n",sinr_eff); - sinr_eff = 10 * log10(sinr_eff); - LOG_D(OCM,"sinr_eff (dB) = %f\n",sinr_eff); - - bler = interp(sinr_eff,&sinr_bler_map[mcs][0][0],&sinr_bler_map[mcs][1][0],table_length[mcs]); - -#ifdef USER_MODE // need to be adapted for the emulation in the kernel space - - if (uniformrandom() < bler) { - LOG_I(OCM,"abstraction_decoding failed (mcs=%d, sinr_eff=%f, bler=%f, TM %d)\n",mcs,sinr_eff,bler, TM); - return(1); - } else { - LOG_I(OCM,"abstraction_decoding successful (mcs=%d, sinr_eff=%f, bler=%f, TM %d)\n",mcs,sinr_eff,bler, TM); - return(1); - } - -#endif -} - -int dlsch_abstraction_MIESM(double* sinr_dB,uint8_t TM, uint32_t rb_alloc[4], uint8_t mcs,uint8_t dl_power_off) -{ - int ii; - double sinr_eff = 0; - double x = 0; - double I =0; - double qpsk_max=12.2; - double qam16_max=19.2; - double qam64_max=25.2; - double sinr_min = -20; - int rb_count = 0; - int offset=0; - double bler = 0; - - if(TM==5 && dl_power_off==1) { - //do nothing -- means there is no second UE and TM 5 is behaving like TM 6 for a singal user - } else - TM = TM-1; - - - for (offset = 0; offset <= 24; offset++) { - if (rb_alloc[0] & (1<<offset)) { - rb_count++; - - for(ii=0; ii<12; ii++) { - //x is the sinr_dB in dB - x = sinr_dB[(offset*12)+ii] - 10*log10(beta1_dlsch_MI[TM][mcs]); - - if(x<sinr_min) - I +=0; - else { - if(mcs<10) { - if(x>qpsk_max) - I += 1; - else - I += (q_qpsk[0]*pow(x,7) + q_qpsk[1]*pow(x,6) + q_qpsk[2]*pow(x,5) + q_qpsk[3]*pow(x,4) + q_qpsk[4]*pow(x,3) + q_qpsk[5]*pow(x,2) + q_qpsk[6]*x + q_qpsk[7]); - } else if(mcs>9 && mcs<17) { - if(x>qam16_max) - I += 1; - else - I += (q_qam16[0]*pow(x,7) + q_qam16[1]*pow(x,6) + q_qam16[2]*pow(x,5) + q_qam16[3]*pow(x,4) + q_qam16[4]*pow(x,3) + q_qam16[5]*pow(x,2) + q_qam16[6]*x + q_qam16[7]); - } else if(mcs>16 && mcs<23) { - - if(x>qam64_max) - I += 1; - else - I += (q_qam64[0]*pow(x,7) + q_qam64[1]*pow(x,6) + q_qam64[2]*pow(x,5) + q_qam64[3]*pow(x,4) + q_qam64[4]*pow(x,3) + q_qam64[5]*pow(x,2) + q_qam64[6]*x + q_qam64[7]); - } - } - } - } - } - - // averaging of accumulated MI - I = I/(12*rb_count); - //Now I->SINR_effective Mapping - - if(mcs<10) { - sinr_eff = (p_qpsk[0]*pow(I,7) + p_qpsk[1]*pow(I,6) + p_qpsk[2]*pow(I,5) + p_qpsk[3]*pow(I,4) + p_qpsk[4]*pow(I,3) + p_qpsk[5]*pow(I,2) + p_qpsk[6]*I + p_qpsk[7]); - } else if(mcs>9 && mcs<17) { - sinr_eff = (p_qam16[0]*pow(I,7) + p_qam16[1]*pow(I,6) + p_qam16[2]*pow(I,5) + p_qam16[3]*pow(I,4) + p_qam16[4]*pow(I,3) + p_qam16[5]*pow(I,2) + p_qam16[6]*I + p_qam16[7]); - } else if(mcs>16 && mcs<23) { - sinr_eff = (p_qam64[0]*pow(I,7) + p_qam64[1]*pow(I,6) + p_qam64[2]*pow(I,5) + p_qam64[3]*pow(I,4) + p_qam64[4]*pow(I,3) + p_qam64[5]*pow(I,2) + p_qam64[6]*I + p_qam64[7]); - } - - //sinr_eff = sinr_eff + 10*log10(beta2_dlsch_MI[TM][mcs]); - LOG_D(OCM,"SINR_Eff = %e\n",sinr_eff); - - bler = interp(sinr_eff,&sinr_bler_map[mcs][0][0],&sinr_bler_map[mcs][1][0],table_length[mcs]); - -#ifdef USER_MODE // need to be adapted for the emulation in the kernel space - - if (uniformrandom() < bler) { - LOG_N(OCM,"abstraction_decoding failed (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler); - return(0); - } else { - LOG_I(OCM,"abstraction_decoding successful (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler); - return(1); - } - -#endif -} - -/* -uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue, - uint8_t subframe, - PDSCH_t dlsch_id, - uint8_t eNB_id) -{ - - LTE_UE_DLSCH_t *dlsch_ue; - LTE_eNB_DLSCH_t *dlsch_eNB; - uint8_t harq_pid; - uint32_t eNB_id2; - uint32_t ue_id; -#ifdef DEBUG_DLSCH_DECODING - uint16_t i; -#endif - uint8_t CC_id = phy_vars_ue->CC_id; - - // may not be necessary for PMCH?? - for (eNB_id2=0; eNB_id2<NB_eNB_INST; eNB_id2++) { - if (RC.eNB[eNB_id2][CC_id]->frame_parms.Nid_cell == phy_vars_ue->frame_parms.Nid_cell) - break; - } - - AssertFatal(eNB_id2!=NB_eNB_INST, - "FATAL : Could not find attached eNB for DLSCH emulation !!!!\n"); - - LOG_D(PHY,"[UE] dlsch_decoding_emul : subframe %d, eNB_id %d, dlsch_id %d\n",subframe,eNB_id2,dlsch_id); - - // printf("dlsch_eNB_ra->harq_processes[0] %p\n",PHY_vars_eNB_g[eNB_id]->dlsch_eNB_ra->harq_processes[0]); - - - switch (dlsch_id) { - case SI_PDSCH: // SI - dlsch_ue = phy_vars_ue->dlsch_SI[eNB_id]; - dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch_SI; - // printf("Doing SI: TBS %d\n",dlsch_ue->harq_processes[0]->TBS>>3); - memcpy(dlsch_ue->harq_processes[0]->b,dlsch_eNB->harq_processes[0]->b,dlsch_ue->harq_processes[0]->TBS>>3); -#ifdef DEBUG_DLSCH_DECODING - LOG_D(PHY,"SI Decoded\n"); - - for (i=0; i<dlsch_ue->harq_processes[0]->TBS>>3; i++) - LOG_T(PHY,"%x.",dlsch_eNB->harq_processes[0]->b[i]); - - LOG_T(PHY,"\n"); -#endif - return(1); - break; - - case RA_PDSCH: // RA - dlsch_ue = phy_vars_ue->dlsch_ra[eNB_id]; - dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch_ra; - memcpy(dlsch_ue->harq_processes[0]->b,dlsch_eNB->harq_processes[0]->b,dlsch_ue->harq_processes[0]->TBS>>3); -#ifdef DEBUG_DLSCH_DECODING - LOG_D(PHY,"RA Decoded\n"); - - for (i=0; i<dlsch_ue->harq_processes[0]->TBS>>3; i++) - LOG_T(PHY,"%x.",dlsch_eNB->harq_processes[0]->b[i]); - - LOG_T(PHY,"\n"); -#endif - return(1); - break; - - case PDSCH: // TB0 - dlsch_ue = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]; - harq_pid = dlsch_ue->current_harq_pid; - ue_id= (uint32_t)find_ue((int16_t)phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][(uint32_t)eNB_id]->crnti,RC.eNB[eNB_id2][CC_id]); - DevAssert( ue_id != (uint32_t)-1 ); - dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch[ue_id][0]; - -#ifdef DEBUG_DLSCH_DECODING - - for (i=0; i<dlsch_ue->harq_processes[harq_pid]->TBS>>3; i++) - LOG_T(PHY,"%x.",dlsch_eNB->harq_processes[harq_pid]->b[i]); - - LOG_T(PHY,"\n current harq pid is %d ue id %d \n", harq_pid, ue_id); -#endif - - if (dlsch_abstraction_MIESM(phy_vars_ue->sinr_dB, - phy_vars_ue->transmission_mode[eNB_id], - dlsch_eNB->harq_processes[harq_pid]->rb_alloc, - dlsch_eNB->harq_processes[harq_pid]->mcs, - RC.eNB[eNB_id][CC_id]->mu_mimo_mode[ue_id].dl_pow_off) == 1) { - // reset HARQ - dlsch_ue->harq_processes[harq_pid]->status = SCH_IDLE; - dlsch_ue->harq_processes[harq_pid]->round = 0; - dlsch_ue->harq_ack[subframe].ack = 1; - dlsch_ue->harq_ack[subframe].harq_id = harq_pid; - dlsch_ue->harq_ack[subframe].send_harq_status = 1; - - if (dlsch_ue->harq_processes[harq_pid]->round == 0) - memcpy(dlsch_ue->harq_processes[harq_pid]->b, - dlsch_eNB->harq_processes[harq_pid]->b, - dlsch_ue->harq_processes[harq_pid]->TBS>>3); - - return(1); - } else { - // retransmission - dlsch_ue->harq_processes[harq_pid]->status = ACTIVE; - dlsch_ue->harq_processes[harq_pid]->round++; - dlsch_ue->harq_ack[subframe].ack = 0; - dlsch_ue->harq_ack[subframe].harq_id = harq_pid; - dlsch_ue->harq_ack[subframe].send_harq_status = 1; - dlsch_ue->last_iteration_cnt = 1+dlsch_ue->max_turbo_iterations; - return(1+dlsch_ue->max_turbo_iterations); - } - - break; - - case PDSCH1: { // TB1 - dlsch_ue = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][1]; - harq_pid = dlsch_ue->current_harq_pid; - int8_t UE_id = find_ue( phy_vars_ue->pdcch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->crnti, RC.eNB[eNB_id2][CC_id] ); - - DevAssert( UE_id != -1 ); - dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch[UE_id][1]; - // reset HARQ - dlsch_ue->harq_processes[harq_pid]->status = SCH_IDLE; - dlsch_ue->harq_processes[harq_pid]->round = 0; - dlsch_ue->harq_ack[subframe].ack = 1; - dlsch_ue->harq_ack[subframe].harq_id = harq_pid; - dlsch_ue->harq_ack[subframe].send_harq_status = 1; - - if (dlsch_ue->harq_processes[harq_pid]->round == 0) - memcpy(dlsch_eNB->harq_processes[harq_pid]->b,dlsch_ue->harq_processes[harq_pid]->b,dlsch_ue->harq_processes[harq_pid]->TBS>>3); - - break; - } - - case PMCH: // PMCH - - dlsch_ue = phy_vars_ue->dlsch_MCH[eNB_id]; - dlsch_eNB = RC.eNB[eNB_id2][CC_id]->dlsch_MCH; - - LOG_D(PHY,"decoding pmch emul (size is %d, enb %d %d)\n", dlsch_ue->harq_processes[0]->TBS>>3, eNB_id, eNB_id2); -#ifdef DEBUG_DLSCH_DECODING - - for (i=0; i<dlsch_ue->harq_processes[0]->TBS>>3; i++) - printf("%x.",dlsch_eNB->harq_processes[0]->b[i]); - - printf("\n"); -#endif - - - // if (dlsch_abstraction_MIESM(phy_vars_ue->sinr_dB, phy_vars_ue->transmission_mode[eNB_id], dlsch_eNB->rb_alloc, - // dlsch_eNB->harq_processes[0]->mcs,RC.eNB[eNB_id]->mu_mimo_mode[ue_id].dl_pow_off) == 1) { - - if (1) { - // reset HARQ - dlsch_ue->harq_processes[0]->status = SCH_IDLE; - dlsch_ue->harq_processes[0]->round = 0; - memcpy(dlsch_ue->harq_processes[0]->b, - dlsch_eNB->harq_processes[0]->b, - dlsch_ue->harq_processes[0]->TBS>>3); - dlsch_ue->last_iteration_cnt = 1; - return(1); - } else { - // retransmission - dlsch_ue->last_iteration_cnt = 1+dlsch_ue->max_turbo_iterations; - return(1+dlsch_ue->max_turbo_iterations); - } - - break; - - default: - dlsch_ue = phy_vars_ue->dlsch[phy_vars_ue->current_thread_id[subframe]][eNB_id][0]; - LOG_E(PHY,"dlsch_decoding_emul: FATAL, unknown DLSCH_id %d\n",dlsch_id); - dlsch_ue->last_iteration_cnt = 1+dlsch_ue->max_turbo_iterations; - return(1+dlsch_ue->max_turbo_iterations); - } - - LOG_E(PHY,"[FATAL] dlsch_decoding.c: Should never exit here ...\n"); - return(0); - }*/ -#endif - diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c index f53e83dbaf0bbea9e3ed820ef47a3bbff230f00f..c805d9408f20781e88d0a07c1181c3465c9e3bbb 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c @@ -37,11 +37,7 @@ #include "PHY/sse_intrin.h" #include "T.h" -#ifndef USER_MODE -#define NOCYGWIN_STATIC static -#else #define NOCYGWIN_STATIC -#endif /* dynamic shift for LLR computation for TM3/4 * set as command line argument, see lte-softmodem.c @@ -849,18 +845,20 @@ int rx_pdsch(PHY_VARS_UE *ue, pllr_symbol_cw1 = (int8_t*)pdsch_vars[eNB_id]->llr[1]; pllr_symbol_cw0 += llr_offset_symbol; pllr_symbol_cw1 += llr_offset_symbol; - - /*LOG_I(PHY,"compute LLRs [AbsSubframe %d.%d-%d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n", - proc->frame_rx, proc->subframe_rx,symbol, + /* + LOG_I(PHY,"compute LLRs [AbsSubframe %d.%d-%d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n", + frame, subframe,symbol, nb_rb,dlsch0_harq->Qm, pdsch_vars[eNB_id]->llr_length[symbol], pdsch_vars[eNB_id]->llr_offset[symbol], (int16_t*)pdsch_vars[eNB_id]->llr[0], - pllr_symbol);*/ - + pllr_symbol_cw0); + */ switch (dlsch0_harq->Qm) { case 2 : if ((rx_type==rx_standard) || (codeword_TB1 == -1)) { + + dlsch_qpsk_llr(frame_parms, pdsch_vars[eNB_id]->rxdataF_comp0, (int16_t*)pllr_symbol_cw0, @@ -6027,9 +6025,6 @@ unsigned short dlsch_extract_rbs_TM7(int **rxdataF, //============================================================================================== -#ifdef USER_MODE - - void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t subframe,unsigned int *coded_bits_per_codeword,int round, unsigned char harq_pid) { unsigned int nsymb = (ue->frame_parms.Ncp == 0) ? 14 : 12; @@ -6119,7 +6114,6 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t subframe,unsigned int *c // printf("log2_maxh = %d\n",ue->pdsch_vars[eNB_id]->log2_maxh); } -#endif #ifdef DEBUG_DLSCH_DEMOD /* diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c index 8ea922b85c7ea13725aab5d113cdceecc1adaaef..46689a9aaa0473a14cda15cedea92db8896c9a65 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c @@ -672,14 +672,14 @@ int dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, } - //printf("dlsch_qpsk_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust); - /*LOG_I(PHY,"dlsch_qpsk_llr: [symb %d / FirstSym %d / Length %d]: @LLR Buff %x, @LLR Buff(symb) %x \n", + /* + LOG_I(PHY,"dlsch_qpsk_llr: [symb %d / FirstSym %d / Length %d]: @LLR Buff %x, @LLR Buff(symb) %x \n", symbol, first_symbol_flag, len, dlsch_llr, - llr32);*/ - + llr32); + */ //printf("ll32p=%p , dlsch_llr=%p, symbol=%d, flag=%d \n", llr32, dlsch_llr, symbol, first_symbol_flag); for (i=0; i<len; i++) { *llr32 = *rxF; diff --git a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c b/openair1/PHY/LTE_TRANSPORT/drs_modulation.c index 2a94d77b8e0a22d207077fb75ba5f34e97272b78..a432cde4e4fb20ed7721e223475f57953623f7f5 100644 --- a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/drs_modulation.c @@ -81,7 +81,6 @@ int generate_drs_pusch(PHY_VARS_UE *ue, // cyclic_shift1 = 0; Msc_RS = 12*nb_rb; -#ifdef USER_MODE Msc_idx_ptr = (uint16_t*) bsearch(&Msc_RS, dftsizes, 33, sizeof(uint16_t), compareints); if (Msc_idx_ptr) @@ -91,20 +90,6 @@ int generate_drs_pusch(PHY_VARS_UE *ue, return(-1); } -#else - uint8_t b; - - for (b=0; b<33; b++) - if (Msc_RS==dftsizes[b]) - Msc_RS_idx = b; - -#endif -#ifdef DEBUG_DRS - printf("[PHY] drs_modulation: Msc_RS = %d, Msc_RS_idx = %d,cyclic_shift %d, u0 %d, v0 %d, u1 %d, v1 %d,cshift0 %d,cshift1 %d\n",Msc_RS, Msc_RS_idx,cyclic_shift,u0,v0,u1,v1,cyclic_shift0,cyclic_shift1); - -#endif - - for (l = (3 - frame_parms->Ncp),u=u0,v=v0,cyclic_shift=cyclic_shift0; l<frame_parms->symbols_per_tti; l += (7 - frame_parms->Ncp),u=u1,v=v1,cyclic_shift=cyclic_shift1) { diff --git a/openair1/PHY/LTE_TRANSPORT/edci.c b/openair1/PHY/LTE_TRANSPORT/edci.c index 49a60ae9e89354e210eae247739c11b6fdea1264..37b1c56349f3edbc727482e8301f47bdcbbf0c61 100755 --- a/openair1/PHY/LTE_TRANSPORT/edci.c +++ b/openair1/PHY/LTE_TRANSPORT/edci.c @@ -29,11 +29,9 @@ * \note * \warning */ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> #include <string.h> -#endif #include "PHY/defs.h" #include "PHY/extern.h" #include "SCHED/defs.h" diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 4528766676137ec8b7b84c5a21380fa11328d2b0..88312e4a4611af3cab61f73476e003429fc4e073 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -58,7 +58,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { uint16_t db_fulllength, db_halflength; int slotoffsetF=0, blockoffsetF=0; - uint16_t *data_block=NULL, *i=NULL; + uint16_t *data_block=NULL, *i=NULL, *d=NULL; IF4p5_header_t *packet_header=NULL; eth_state_t *eth = (eth_state_t*) (ru->ifdevice.priv); @@ -105,7 +105,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { if ((ru->ifdevice.trx_write_func(&ru->ifdevice, symbol_id, &tx_buffer, - db_fulllength, + db_fulllength, 1, IF4p5_PDLFFT)) < 0) { perror("ETHERNET write for IF4p5_PDLFFT\n"); @@ -138,23 +138,47 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { if (packet_type == IF4p5_PULFFT) { - for (symbol_id=fp->symbols_per_tti-nsym; symbol_id<fp->symbols_per_tti; symbol_id++) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF4_SYMBOL, symbol_id ); + for (symbol_id=fp->symbols_per_tti-nsym; symbol_id<fp->symbols_per_tti; symbol_id++) { + + uint32_t *rx0 = (uint32_t*) &rxdataF[0][blockoffsetF]; + uint32_t *rx1 = (uint32_t*) &rxdataF[0][slotoffsetF]; + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SEND_IF4_SYMBOL, symbol_id ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 1 ); - for (element_id=0; element_id<db_halflength; element_id++) { - i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id]; - data_block[element_id] = ((uint16_t) lin2alaw_if4p5[*i]) | ((uint16_t)(lin2alaw_if4p5[*(i+1)]<<8)); - - i = (uint16_t*) &rxdataF[0][slotoffsetF+element_id]; - data_block[element_id+db_halflength] = ((uint16_t) lin2alaw_if4p5[*i]) | ((uint16_t)(lin2alaw_if4p5[*(i+1)]<<8)); - //if (element_id==0) LOG_I(PHY,"send_if4p5: symbol %d rxdata0 = (%d,%d)\n",symbol_id,*i,*(i+1)); - - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 0 ); + start_meas(&ru->compression); + + for (element_id=0; element_id<db_halflength; element_id+=8) { + i = (uint16_t*) &rx0[element_id]; + d = (uint16_t*) &data_block[element_id]; + d[0] = ((uint16_t) lin2alaw_if4p5[i[0]]) | ((uint16_t)(lin2alaw_if4p5[i[1]]<<8)); + d[1] = ((uint16_t) lin2alaw_if4p5[i[2]]) | ((uint16_t)(lin2alaw_if4p5[i[3]]<<8)); + d[2] = ((uint16_t) lin2alaw_if4p5[i[4]]) | ((uint16_t)(lin2alaw_if4p5[i[5]]<<8)); + d[3] = ((uint16_t) lin2alaw_if4p5[i[6]]) | ((uint16_t)(lin2alaw_if4p5[i[7]]<<8)); + d[4] = ((uint16_t) lin2alaw_if4p5[i[8]]) | ((uint16_t)(lin2alaw_if4p5[i[9]]<<8)); + d[5] = ((uint16_t) lin2alaw_if4p5[i[10]]) | ((uint16_t)(lin2alaw_if4p5[i[11]]<<8)); + d[6] = ((uint16_t) lin2alaw_if4p5[i[12]]) | ((uint16_t)(lin2alaw_if4p5[i[13]]<<8)); + d[7] = ((uint16_t) lin2alaw_if4p5[i[14]]) | ((uint16_t)(lin2alaw_if4p5[i[15]]<<8)); + + i = (uint16_t*) &rx1[element_id]; + d = (uint16_t*) &data_block[element_id+db_halflength]; + d[0] = ((uint16_t) lin2alaw_if4p5[i[0]]) | ((uint16_t)(lin2alaw_if4p5[i[1]]<<8)); + d[1] = ((uint16_t) lin2alaw_if4p5[i[2]]) | ((uint16_t)(lin2alaw_if4p5[i[3]]<<8)); + d[2] = ((uint16_t) lin2alaw_if4p5[i[4]]) | ((uint16_t)(lin2alaw_if4p5[i[5]]<<8)); + d[3] = ((uint16_t) lin2alaw_if4p5[i[6]]) | ((uint16_t)(lin2alaw_if4p5[i[7]]<<8)); + d[4] = ((uint16_t) lin2alaw_if4p5[i[8]]) | ((uint16_t)(lin2alaw_if4p5[i[9]]<<8)); + d[5] = ((uint16_t) lin2alaw_if4p5[i[10]]) | ((uint16_t)(lin2alaw_if4p5[i[11]]<<8)); + d[6] = ((uint16_t) lin2alaw_if4p5[i[12]]) | ((uint16_t)(lin2alaw_if4p5[i[13]]<<8)); + d[7] = ((uint16_t) lin2alaw_if4p5[i[14]]) | ((uint16_t)(lin2alaw_if4p5[i[15]]<<8)); + + } + + stop_meas(&ru->compression); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 0 ); packet_header->frame_status &= ~(0x000f<<26); packet_header->frame_status |= (symbol_id&0x000f)<<26; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 ); + start_meas(&ru->transport); if ((ru->ifdevice.trx_write_func(&ru->ifdevice, symbol_id, &tx_buffer, @@ -163,6 +187,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { IF4p5_PULFFT)) < 0) { perror("ETHERNET write for IF4p5_PULFFT\n"); } + stop_meas(&ru->transport); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 ); slotoffsetF += fp->ofdm_symbol_size; blockoffsetF += fp->ofdm_symbol_size; @@ -181,7 +206,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { } else if (packet_type >= IF4p5_PRACH && packet_type <= IF4p5_PRACH+4) { // FIX: hard coded prach samples length - LOG_D(PHY,"IF4p5_PRACH: frame %d, subframe %d\n",frame,subframe); + LOG_D(PHY,"IF4p5_PRACH: frame %d, subframe %d,packet type %x\n",frame,subframe,packet_type); db_fulllength = PRACH_NUM_SAMPLES; if (eth->flags == ETH_RAW_IF4p5_MODE) { @@ -222,6 +247,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { packet_type)) < 0) { perror("ETHERNET write for IF4p5_PRACH\n"); } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 ); } else { AssertFatal(1==0, "send_IF4p5 - Unknown packet_type %x", packet_type); @@ -283,7 +309,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint *subframe = ((packet_header->frame_status)>>22)&0x000f; *packet_type = packet_header->sub_type; - + LOG_D(PHY,"recv_IF4p5: Frame %d, Subframe %d: packet_type %x\n",*frame,*subframe,*packet_type); if (*packet_type == IF4p5_PDLFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RECV_IF4_SYMBOL, *symbol_number ); @@ -313,7 +339,6 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size); blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 1 ); - if (ru->idx==0) LOG_D(PHY,"UL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",ru->idx,*frame,*subframe,*symbol_number); for (element_id=0; element_id<db_halflength; element_id++) { i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id]; *i = alaw2lin_if4p5[ (data_block[element_id] & 0xff) ]; @@ -325,6 +350,9 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint //if (element_id==0) LOG_I(PHY,"recv_if4p5: symbol %d rxdata0 = (%u,%u)\n",*symbol_number,*i,*(i+1)); } + LOG_D(PHY,"PULFFT_IF4p5: CC_id %d : frame %d, subframe %d (symbol %d)=> %d dB\n",ru->idx,*frame,*subframe,*symbol_number, + dB_fixed(signal_energy((int*)&rxdataF[0][slotoffsetF],db_halflength)+ + signal_energy((int*)&rxdataF[0][blockoffsetF],db_halflength))); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 0 ); } else if (*packet_type >= IF4p5_PRACH && *packet_type <= IF4p5_PRACH + 4) { @@ -353,8 +381,8 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint PRACH_BLOCK_SIZE_BYTES); } - //LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, - // dB_fixed(signal_energy((int*)&prach_rxsigF[0][0],839))); + LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, + dB_fixed(signal_energy((int*)&prach_rxsigF[0][0],839))); for (idx=0;idx<ru->num_eNB;idx++) ru->wakeup_prach_eNB(ru->eNB_list[idx],ru,*frame,*subframe); } else if (*packet_type == IF4p5_PULTICK) { diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h index a251c62d0d16673dcbc8649d0392a3ce1d1afc99..0a95e60ead3c7af2bad4c55e73f742fc0308e4f1 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h @@ -39,11 +39,11 @@ #define IF4p5_PULFFT 0x0019 #define IF4p5_PDLFFT 0x0020 #define IF4p5_PRACH 0x0021 -#define IF4p5_PRACH_BR_CE0 0x0021 -#define IF4p5_PRACH_BR_CE1 0x0022 -#define IF4p5_PRACH_BR_CE2 0x0023 -#define IF4p5_PRACH_BR_CE3 0x0024 -#define IF4p5_PULTICK 0x0025 +#define IF4p5_PRACH_BR_CE0 0x0022 +#define IF4p5_PRACH_BR_CE1 0x0023 +#define IF4p5_PRACH_BR_CE2 0x0024 +#define IF4p5_PRACH_BR_CE3 0x0025 +#define IF4p5_PULTICK 0x0026 struct IF4p5_header { /// Type diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_TRANSPORT/initial_sync.c index d1880b0c554fedbd746797edd106fb60f19b3c5f..918696968b373ce1830f4abe081fa01505e4e7ae 100644 --- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_TRANSPORT/initial_sync.c @@ -237,10 +237,6 @@ int pbch_detection(PHY_VARS_UE *ue, runmode_t mode) ue->proc.proc_rxtx[i].frame_rx = (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2; ue->proc.proc_rxtx[i].frame_rx = (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2; -#ifndef USER_MODE - // one frame delay - ue->proc.proc_rxtx[i].frame_rx ++; -#endif ue->proc.proc_rxtx[i].frame_tx = ue->proc.proc_rxtx[0].frame_rx; } #ifdef DEBUG_INITIAL_SYNCH diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c index 226d5ef0ca34842d9116e67b08b378c852366f48..9e5b6757fc84e9411c32e28fecd2465b575aac0b 100644 --- a/openair1/PHY/LTE_TRANSPORT/pbch.c +++ b/openair1/PHY/LTE_TRANSPORT/pbch.c @@ -37,11 +37,6 @@ #include "PHY/extern.h" #include "PHY/sse_intrin.h" -#ifdef PHY_ABSTRACTION -#include "SIMULATION/TOOLS/defs.h" -#endif - - //#define DEBUG_PBCH 1 //#define DEBUG_PBCH_ENCODING //#define INTERFERENCE_MITIGATION 1 @@ -260,13 +255,11 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch, #endif #ifdef DEBUG_PBCH - #ifdef USER_MODE write_output("pbch_encoded_output2.m","pbch_encoded_out2", pbch_coded_data2, pbch_coded_bits, 1, 4); - #endif //USER_MODE #endif //DEBUG_PBCH */ #ifdef DEBUG_PBCH_ENCODING @@ -288,8 +281,6 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch, #ifdef DEBUG_PBCH -#ifdef USER_MODE - if (frame_mod4==0) { write_output("pbch_e.m","pbch_e", eNB_pbch->pbch_e, @@ -300,8 +291,6 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch, for (i=0; i<16; i++) printf("e[%d] %d\n",i,eNB_pbch->pbch_e[i]); } - -#endif //USER_MODE #endif //DEBUG_PBCH // scrambling @@ -309,8 +298,6 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch, eNB_pbch->pbch_e, pbch_E); #ifdef DEBUG_PBCH -#ifdef USER_MODE - if (frame_mod4==0) { write_output("pbch_e_s.m","pbch_e_s", eNB_pbch->pbch_e, @@ -321,8 +308,6 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch, for (i=0; i<16; i++) printf("e_s[%d] %d\n",i,eNB_pbch->pbch_e[i]); } - -#endif //USER_MODE #endif //DEBUG_PBCH } // frame_mod4==0 @@ -1028,44 +1013,3 @@ uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars, } - -#ifdef PHY_ABSTRACTION -uint16_t rx_pbch_emul(PHY_VARS_UE *phy_vars_ue, - uint8_t eNB_id, - uint8_t pbch_phase) -{ - - double bler=0.0;//, x=0.0; - double sinr=0.0; - uint16_t nb_rb = phy_vars_ue->frame_parms.N_RB_DL; - int16_t f; - uint8_t CC_id=phy_vars_ue->CC_id; - int frame_rx = phy_vars_ue->proc.proc_rxtx[0].frame_rx; - - // compute effective sinr - // TODO: adapt this to varible bandwidth - for (f=(nb_rb*6-3*12); f<(nb_rb*6+3*12); f++) { - if (f!=0) //skip DC - sinr += pow(10, 0.1*(phy_vars_ue->sinr_dB[f])); - } - - sinr = 10*log10(sinr/(6*12)); - - bler = pbch_bler(sinr); - - LOG_D(PHY,"EMUL UE rx_pbch_emul: eNB_id %d, pbch_phase %d, sinr %f dB, bler %f \n", - eNB_id, - pbch_phase, - sinr, - bler); - - if (pbch_phase == (frame_rx % 4)) { - if (uniformrandom() >= bler) { - memcpy(phy_vars_ue->pbch_vars[eNB_id]->decoded_output,RC.eNB[eNB_id][CC_id]->pbch_pdu,PBCH_PDU_SIZE); - return(RC.eNB[eNB_id][CC_id]->frame_parms.nb_antenna_ports_eNB); - } else - return(-1); - } else - return(-1); -} -#endif diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 6e955322b8dc1331d8acb8101d7288fa14111202..2bd7140c32ccc96524b58d9e489280bae5cf7754 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -38,10 +38,6 @@ #include "LAYER2/MAC/extern.h" #include "LAYER2/MAC/defs.h" -#ifndef USER_MODE -#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h" -#endif - #include "T.h" //#define DEBUG_PHICH 1 diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index e6b2720b7700206ff627b40259dda12419f8c61b..ae31c4c4c05b8662d5aca12f34e2986596737e5a 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -342,7 +342,6 @@ uint16_t prach_root_sequence_map4[138] = { 1,138,2,137,3,136,4,135,5,134,6,133, 61,78,62,77,63,76,64,75,65,74,66,73,67,72,68,71,69,70 }; -#ifdef USER_MODE void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) { @@ -363,7 +362,6 @@ void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) fclose(fd); } -#endif // This function computes the du void fill_du(uint8_t prach_fmt) diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 5d7cae6c7c9a05534a809ac99f255af84ed8f142..a3ff0b9cda44de73ca226811e92f16d76c1b9c8d 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -1739,13 +1739,15 @@ int generate_ue_dlsch_params_from_dci(int frame, uint16_t tc_rnti); void fill_dci_and_dlsch(PHY_VARS_eNB *eNB, + int frame, + int subframe, eNB_rxtx_proc_t *proc, DCI_ALLOC_t *dci_alloc, nfapi_dl_config_dci_dl_pdu *pdu); void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *dci_alloc,nfapi_dl_config_mpdcch_pdu *pdu); -void fill_dci0(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, +void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, nfapi_hi_dci0_dci_pdu *pdu); void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe); @@ -2172,9 +2174,13 @@ void rx_prach(PHY_VARS_eNB *phy_vars_eNB,RU_t *ru, uint16_t *max_preamble, uint16_t *max_preamble_energy, uint16_t *max_preamble_delay, +#ifdef Rel14 uint16_t Nf, uint8_t tdd_mapindex, - uint8_t br_flag); - + uint8_t br_flag +#else + uint16_t Nf, uint8_t tdd_mapindex +#endif + ); /*! \brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index @param frame_parms Pointer to LTE_DL_FRAME_PARMS structure diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index 61d2cc0e9b3a841e904e45452fe511df20cab387..9a19b0ddaf3dee79997ca3af075bd9448b74d43b 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -1871,6 +1871,23 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, eNB->pucch1ab_stats_cnt[j][i]=0; } } +#if defined(USRP_REC_PLAY) + // It's probably bad to do this statically only once. + // Looks like the above is incomplete. + // Such reset needs to be done once a UE PHY structure is being used/re-used + // Don't know if this is ever possible in current architecture + for (i=0;i<10240;i++) { + for (j=0;j<NUMBER_OF_UE_MAX;j++) { + eNB->pucch1_stats[j][i]=0; + eNB->pucch1_stats_thres[j][i]=0; + } + } + for (i=0;i<20480;i++) { + for (j=0;j<NUMBER_OF_UE_MAX;j++) { + eNB->pucch1ab_stats[j][i]=0; + } + } +#endif first_call=0; } @@ -2152,8 +2169,9 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, } //phase // stat_max *= nsymb; // normalize to energy per symbol -// stat_max /= (frame_parms->N_RB_UL*12); // +// stat_max /= (frame_parms->N_RB_UL*12); // stat_max /= (nsymb*12); + #ifdef DEBUG_PUCCH_RX printf("[eNB] PUCCH: stat %d, stat_max %d, phase_max %d\n", stat,stat_max,phase_max); #endif @@ -2289,8 +2307,13 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, stat_im=0; // Do detection now +#if defined(USRP_REC_PLAY) + // It looks like the value is a bit messy when RF is replayed. + // For instance i assume to skip pucch1_thres from the test below. + if (sigma2_dB<(dB_fixed(stat_max))) {// +#else if (sigma2_dB<(dB_fixed(stat_max)-pucch1_thres)) {// - +#endif chL = (nsymb>>1)-4; chest_mag=0; cfo = (frame_parms->Ncp==0) ? &cfo_pucch_np[14*phase_max] : &cfo_pucch_ep[12*phase_max]; @@ -2431,7 +2454,11 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, if (fmt==pucch_format1b) *(1+payload) = (stat_im<0) ? 1 : 2; } else { // insufficient energy on PUCCH so NAK - LOG_I(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); +#if defined(USRP_REC_PLAY) + LOG_D(PHY,"PUCCH 1a/b: NAK subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); +#else + LOG_D(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); +#endif *payload = 4; // DTX ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[0] = (int16_t)(stat_re); ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[1] = (int16_t)(stat_im); diff --git a/openair1/PHY/LTE_TRANSPORT/rar_tools.c b/openair1/PHY/LTE_TRANSPORT/rar_tools.c index e9ae36026312f681c21847beb815c24a5f340389..9934b71d78b0165c32d9b4df855e97779c43ee33 100644 --- a/openair1/PHY/LTE_TRANSPORT/rar_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/rar_tools.c @@ -173,7 +173,9 @@ int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, &ulsch_harq->frame, &ulsch_harq->subframe); - LOG_I(PHY,"Programming msg3 reception in (%d,%d)\n",ulsch_harq->frame,ulsch_harq->subframe); + LOG_I(PHY,"Programming msg3 reception in (%d,%d) mcs:%d TBS:%d Qm:%d Mcs_intial:%d Nsymb_intial:%d round:%d\n", + ulsch_harq->frame,ulsch_harq->subframe, + mcs, ulsch_harq->TBS, ulsch_harq->Qm, ulsch_harq->Msc_initial, ulsch_harq->Nsymb_initial, ulsch_harq->round); use_srs = is_srs_occasion_common(frame_parms,ulsch_harq->frame,ulsch_harq->subframe); ulsch_harq->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); ulsch_harq->srs_active = use_srs; diff --git a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c index a360b35ff6a0733a15d8bbfd54b685e1a4593b3a..c4c02e631279a3833da27c1b2aedceb431e55b7d 100644 --- a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/srs_modulation.c @@ -180,7 +180,6 @@ int32_t generate_srs(LTE_DL_FRAME_PARMS *frame_parms, return(-1); } -#ifdef USER_MODE Msc_idx_ptr = (uint16_t*) bsearch((uint16_t*) &Msc_RS, (uint16_t*) dftsizes, 33, sizeof(uint16_t), compareints); if (Msc_idx_ptr) @@ -190,19 +189,6 @@ int32_t generate_srs(LTE_DL_FRAME_PARMS *frame_parms, return(-1); } -#else //stdlib not availiable in RTAI - - if (Msc_RS==216) - Msc_RS_idx = 12; - else if (Msc_RS==144) - Msc_RS_idx = 9; - else { - LOG_E(PHY,"generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS); - return(-1); - } - -#endif - #ifdef DEBUG_SRS LOG_D(PHY,"generate_srs_tx: Msc_RS = %d, Msc_RS_idx = %d, k0 = %d\n",Msc_RS, Msc_RS_idx,k0); #endif @@ -279,7 +265,6 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms, return(-1); } -#ifdef USER_MODE Msc_idx_ptr = (uint16_t*) bsearch((uint16_t*) &Msc_RS, (uint16_t*) dftsizes, 33, sizeof(uint16_t), compareints); if (Msc_idx_ptr) @@ -289,19 +274,6 @@ int generate_srs_rx(LTE_DL_FRAME_PARMS *frame_parms, return(-1); } -#else //stdlib not availiable in RTAI - - if (Msc_RS==216) - Msc_RS_idx = 12; - else if (Msc_RS==144) - Msc_RS_idx = 9; - else { - LOG_E(PHY,"generate_srs: index for Msc_RS=%d not implemented\n",Msc_RS); - return(-1); - } - -#endif - #ifdef DEBUG_SRS LOG_I(PHY,"generate_srs_rx: Msc_RS = %d, Msc_RS_idx = %d, k0=%d\n",Msc_RS, Msc_RS_idx,k0); #endif diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c index 71c36f7c3c206c69443e8c1efff7ea3b407cf4c5..87209e190b1749d27c9f96d3c04a3359eefb49c7 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c @@ -953,77 +953,3 @@ uint32_t ulsch_encoding(uint8_t *a, return(0); } - -#ifdef PHY_ABSTRACTION -#ifdef OPENAIR2 -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" -#endif -int ulsch_encoding_emul(uint8_t *ulsch_buffer, - PHY_VARS_UE *ue, - uint8_t eNB_id, - uint8_t subframe_rx, - uint8_t harq_pid, - uint8_t control_only_flag) -{ - - LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - LTE_UE_DLSCH_t **dlsch = ue->dlsch[0][eNB_id]; - PHY_MEASUREMENTS *meas = &ue->measurements; - uint8_t tmode = ue->transmission_mode[eNB_id]; - uint16_t rnti=ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti; - LOG_D(PHY,"EMUL UE ulsch_encoding for eNB %d,mod_id %d, harq_pid %d rnti %x, ACK(%d,%d) \n", - eNB_id,ue->Mod_id, harq_pid, rnti,ulsch->o_ACK[0],ulsch->o_ACK[1]); - - if (ulsch->O>0) { - /* - if(flag_LA==1) - sinr_eff = sinr_eff_cqi_calc(ue, eNB_id); - else - sinr_eff = meas->wideband_cqi_avg[eNB_id]; - */ - - fill_CQI(ulsch,meas,eNB_id,harq_pid,ue->frame_parms.N_RB_DL,rnti,tmode,ue->sinr_eff); - //LOG_D(PHY,"UE CQI\n"); - // print_CQI(ulsch->o,ulsch->uci_format,eNB_id); - - // save PUSCH pmi for later (transmission modes 4,5,6) - // printf("ulsch: saving pmi for DL %x\n",pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)ulsch->o)->pmi)); - // if (ulsch->uci_format != HLC_subband_cqi_mcs_CBA) - dlsch[0]->harq_processes[harq_pid]->pmi_alloc = ((wideband_cqi_rank1_2A_5MHz *)ulsch->o)->pmi; - } - - memcpy(ue->ulsch[eNB_id]->harq_processes[harq_pid]->b, - ulsch_buffer, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3); - - - //memcpy(&UE_transport_info[ue->Mod_id].transport_blocks[UE_transport_info_TB_index[ue->Mod_id]], - memcpy(&UE_transport_info[ue->Mod_id][ue->CC_id].transport_blocks, - ulsch_buffer, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3); - //UE_transport_info_TB_index[ue->Mod_id]+=ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; - // navid: currently more than one eNB is not supported in the code - UE_transport_info[ue->Mod_id][ue->CC_id].num_eNB = 1; - UE_transport_info[ue->Mod_id][ue->CC_id].rnti[0] = ue->pdcch_vars[ue->current_thread_id[subframe_rx]][0]->crnti; - UE_transport_info[ue->Mod_id][ue->CC_id].eNB_id[0] = eNB_id; - UE_transport_info[ue->Mod_id][ue->CC_id].harq_pid[0] = harq_pid; - UE_transport_info[ue->Mod_id][ue->CC_id].tbs[0] = ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3 ; - // printf("\nue->Mod_id%d\n",ue->Mod_id); - - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pusch_flag = 1; - //UE_transport_info[ue->Mod_id].cntl.pusch_uci = *(uint32_t *)ulsch->o; - memcpy(UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pusch_uci, - ulsch->o, - MAX_CQI_BYTES); - // printf("[UE]cqi is %d \n", ((HLC_subband_cqi_rank1_2A_5MHz *)ulsch->o)->cqi1); - - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.length_uci = ulsch->O; - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.uci_format = ulsch->uci_format; - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pusch_ri = (ulsch->o_RI[0]&1)+((ulsch->o_RI[1]&1)<<1); - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pusch_ack = (ulsch->o_ACK[0]&1) + ((ulsch->o_ACK[1]&1)<<1); - //printf("ack is %d %d %d\n",UE_transport_info[ue->Mod_id].cntl.pusch_ack, (ulsch->o_ACK[1]&1)<<1, ulsch->o_ACK[0]&1); - return(0); - -} -#endif diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index f885bf8eb379d0beaa3ff96023c14452a9633a13..57087051d3c9d251382809eb3425189d88625872 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -44,11 +44,6 @@ #include "PHY_INTERFACE/extern.h" #endif -#ifdef PHY_ABSTRACTION -#include "UTIL/OCG/OCG.h" -#include "UTIL/OCG/OCG_extern.h" -#endif - #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_ULSCH_DECODING @@ -170,6 +165,7 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch) //ulsch = (LTE_eNB_ULSCH_t *)malloc16(sizeof(LTE_eNB_ULSCH_t)); if (ulsch) { ulsch->rnti = 0; + ulsch->harq_mask = 0; for (i=0; i<8; i++) { if (ulsch->harq_processes[i]) { @@ -178,9 +174,26 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch) //ulsch->harq_processes[i]->phich_active = 0; //this will be done later after transmission of PHICH ulsch->harq_processes[i]->phich_ACK = 0; ulsch->harq_processes[i]->round = 0; + ulsch->harq_processes[i]->rar_alloc = 0; + ulsch->harq_processes[i]->first_rb = 0; + ulsch->harq_processes[i]->nb_rb = 0; + ulsch->harq_processes[i]->TBS = 0; + ulsch->harq_processes[i]->Or1 = 0; + ulsch->harq_processes[i]->Or2 = 0; + for ( int j = 0; j < 2; j++ ) { + ulsch->harq_processes[i]->o_RI[j] = 0; + } + ulsch->harq_processes[i]->O_ACK = 0; + ulsch->harq_processes[i]->srs_active = 0; + ulsch->harq_processes[i]->rvidx = 0; + ulsch->harq_processes[i]->Msc_initial = 0; + ulsch->harq_processes[i]->Nsymb_initial = 0; } } - + ulsch->beta_offset_cqi_times8 = 0; + ulsch->beta_offset_ri_times8 = 0; + ulsch->beta_offset_harqack_times8 = 0; + ulsch->Msg3_active = 0; } } @@ -874,12 +887,13 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, int16_t cseq[6*14*1200] __attribute__((aligned(32))); int off; + int frame = proc->frame_rx; int subframe = proc->subframe_rx; LTE_UL_eNB_HARQ_t *ulsch_harq; - harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe); + harq_pid = subframe2harq_pid(frame_parms,frame,subframe); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,1); @@ -904,7 +918,8 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, //#ifdef DEBUG_ULSCH_DECODING - LOG_D(PHY,"Frame %d, Subframe %d: ulsch_decoding (Nid_cell %d, rnti %x, x2 %x): A %d, round %d, RV %d, O_r1 %d, O_RI %d, O_ACK %d, G %d\n", + LOG_D(PHY,"[PUSCH %d] Frame %d, Subframe %d: ulsch_decoding (Nid_cell %d, rnti %x, x2 %x): A %d, round %d, RV %d, O_r1 %d, O_RI %d, O_ACK %d, G %d, Q_m %d Nsymb_pusch %d nb_rb %d\n", + harq_pid, proc->frame_rx,subframe, frame_parms->Nid_cell,ulsch->rnti,x2, A, @@ -913,7 +928,10 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, ulsch_harq->Or1, ulsch_harq->O_RI, ulsch_harq->O_ACK, - G); + G, + ulsch_harq->Qm, + ulsch_harq->Nsymb_pusch, + nb_rb); //#endif @@ -1260,7 +1278,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, } if (ulsch_harq->O_ACK > 2) { - LOG_E(PHY,"ulsch_decoding: FATAL, ACK cannot be more than 2 bits yet\n"); + LOG_E(PHY,"ulsch_decoding: FATAL, ACK cannot be more than 2 bits yet O_ACK:%d SFN/SF:%04d%d UE_id:%d rnti:%x\n",ulsch_harq->O_ACK,proc->frame_rx,proc->subframe_rx,UE_id,ulsch->rnti); return(-1); } @@ -1572,6 +1590,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, #endif } + LOG_D(PHY,"frame %d subframe %d O_ACK:%d o_ACK[]=%d:%d:%d:%d\n",frame,subframe,ulsch_harq->O_ACK,ulsch_harq->o_ACK[0],ulsch_harq->o_ACK[1],ulsch_harq->o_ACK[2],ulsch_harq->o_ACK[3]); // Do ULSCH Decoding for data portion @@ -1581,460 +1600,3 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, return(ret); } - -#ifdef PHY_ABSTRACTION - -#ifdef PHY_ABSTRACTION_UL -int ulsch_abstraction(double* sinr_dB, uint8_t TM, uint8_t mcs,uint16_t nrb, uint16_t frb) -{ - - int index,ii; - double sinr_eff = 0; - int rb_count = 0; - int offset; - double bler = 0; - TM = TM-1; - sinr_eff = sinr_dB[frb]; //the single sinr_eff value we calculated with MMSE FDE formula in init_snr_up function - - - sinr_eff *= 10; - sinr_eff = floor(sinr_eff); - sinr_eff /= 10; - - LOG_D(PHY,"[ABSTRACTION] sinr_eff after rounding = %f\n",sinr_eff); - - for (index = 0; index < 16; index++) { - if(index == 0) { - if (sinr_eff < sinr_bler_map_up[mcs][0][index]) { - bler = 1; - break; - } - } - - if (sinr_eff == sinr_bler_map_up[mcs][0][index]) { - bler = sinr_bler_map_up[mcs][1][index]; - } - } - -#ifdef USER_MODE // need to be adapted for the emulation in the kernel space - - if (uniformrandom() < bler) { - LOG_I(OCM,"abstraction_decoding failed (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler); - return(0); - } else { - LOG_I(OCM,"abstraction_decoding successful (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler); - return(1); - } - -#endif -} - - - - - - - -int ulsch_abstraction_MIESM(double* sinr_dB,uint8_t TM, uint8_t mcs,uint16_t nrb, uint16_t frb) -{ - int index; - double sinr_eff = 0; - double sinr_db1 = 0; - double sinr_db2 = 0; - double SI=0; - double RBIR=0; - int rb_count = 0; - int offset, M=0; - double bler = 0; - int start,middle,end; - TM = TM-1; - - for (offset = frb; offset <= (frb + nrb -1); offset++) { - - rb_count++; - - //we need to do the table lookups here for the mutual information corresponding to the certain sinr_dB. - - sinr_db1 = sinr_dB[offset*2]; - sinr_db2 = sinr_dB[offset*2+1]; - - printf("sinr_db1=%f\n,sinr_db2=%f\n",sinr_db1,sinr_db2); - - //rounding up for the table lookup - sinr_db1 *= 10; - sinr_db2 *= 10; - - sinr_db1 = floor(sinr_db1); - sinr_db2 = floor(sinr_db2); - - if ((int)sinr_db1%2) { - sinr_db1 += 1; - } - - if ((int)sinr_db2%2) { - sinr_db2 += 1; - } - - sinr_db1 /= 10; - sinr_db2 /= 10; - - if(mcs<10) { - //for sinr_db1 - for (index = 0; index < 162; index++) { - if (sinr_db1 < MI_map_4qam[0][0]) { - SI += (MI_map_4qam[1][0]/beta1_dlsch_MI[TM][mcs]); - M +=2; - break; - } - - if (sinr_db1 > MI_map_4qam[0][161]) { - SI += (MI_map_4qam[1][161]/beta1_dlsch_MI[TM][mcs]); - M +=2; - break; - } - - if (sinr_db1 == MI_map_4qam[0][index]) { - SI += (MI_map_4qam[1][index]/beta1_dlsch_MI[TM][mcs]); - M +=2; - break; - } - } - - //for sinr_db2 - for (index = 0; index < 162; index++) { - if (sinr_db2 < MI_map_4qam[0][0]) { - SI += (MI_map_4qam[1][0]/beta1_dlsch_MI[TM][mcs]); - M +=2; - break; - } - - if (sinr_db2 > MI_map_4qam[0][161]) { - SI += (MI_map_4qam[1][161]/beta1_dlsch_MI[TM][mcs]); - M +=2; - break; - } - - if (sinr_db2 == MI_map_4qam[0][index]) { - SI += (MI_map_4qam[1][index]/beta1_dlsch_MI[TM][mcs]); - M +=2; - break; - } - } - - } else if(mcs>9 && mcs<17) { - //for sinr_db1 - for (index = 0; index < 197; index++) { - if (sinr_db1 < MI_map_16qam[0][0]) { - SI += (MI_map_16qam[1][0]/beta1_dlsch_MI[TM][mcs]); - M +=4; - break; - } - - if (sinr_db1 > MI_map_16qam[0][196]) { - SI += (MI_map_16qam[1][196]/beta1_dlsch_MI[TM][mcs]); - M +=4; - break; - } - - if (sinr_db1 == MI_map_16qam[0][index]) { - SI += (MI_map_16qam[1][index]/beta1_dlsch_MI[TM][mcs]); - M +=4; - break; - } - } - - //for sinr_db2 - for (index = 0; index < 197; index++) { - if (sinr_db2 < MI_map_16qam[0][0]) { - SI += (MI_map_16qam[1][0]/beta1_dlsch_MI[TM][mcs]); - M +=4; - break; - } - - if (sinr_db2 > MI_map_16qam[0][196]) { - SI += (MI_map_16qam[1][196]/beta1_dlsch_MI[TM][mcs]); - M +=4; - break; - } - - if (sinr_db2 == MI_map_16qam[0][index]) { - SI += (MI_map_16qam[1][index]/beta1_dlsch_MI[TM][mcs]); - M +=4; - break; - } - } - - } else if(mcs>16 && mcs<22) { - //for sinr_db1 - for (index = 0; index < 227; index++) { - if (sinr_db1 < MI_map_64qam[0][0]) { - SI += (MI_map_64qam[1][0]/beta1_dlsch_MI[TM][mcs]); - M +=6; - break; - } - - if (sinr_db1 > MI_map_64qam[0][226]) { - SI += (MI_map_64qam[1][226]/beta1_dlsch_MI[TM][mcs]); - M +=6; - break; - } - - if (sinr_db1 == MI_map_64qam[0][index]) { - SI += (MI_map_64qam[1][index]/beta1_dlsch_MI[TM][mcs]); - M +=6; - break; - } - } - - //for sinr_db2 - for (index = 0; index < 227; index++) { - if (sinr_db2 < MI_map_64qam[0][0]) { - SI += (MI_map_64qam[1][0]/beta1_dlsch_MI[TM][mcs]); - M +=6; - break; - } - - if (sinr_db2 > MI_map_64qam[0][226]) { - SI += (MI_map_64qam[1][226]/beta1_dlsch_MI[TM][mcs]); - M +=6; - break; - } - - if (sinr_db2 == MI_map_64qam[0][index]) { - SI += (MI_map_64qam[1][index]/beta1_dlsch_MI[TM][mcs]); - M +=6; - break; - } - } - } - } - - // } - - RBIR = SI/M; - - //Now RBIR->SINR_effective Mapping - //binary search method is performed here - if(mcs<10) { - start = 0; - end = 161; - middle = end/2; - - if (RBIR <= MI_map_4qam[2][start]) { - sinr_eff = MI_map_4qam[0][start]; - } else { - if (RBIR >= MI_map_4qam[2][end]) - sinr_eff = MI_map_4qam[0][end]; - else { - //while((end-start > 1) && (RBIR >= MI_map_4qam[2])) - if (RBIR < MI_map_4qam[2][middle]) { - end = middle; - middle = end/2; - } else { - start = middle; - middle = (end-middle)/2; - } - } - - for (; end>start; end--) { - if ((RBIR < MI_map_4qam[2][end]) && (RBIR > MI_map_4qam[2][end-2])) { - sinr_eff = MI_map_4qam[0][end-1]; - break; - } - } - } - - sinr_eff = sinr_eff * beta2_dlsch_MI[TM][mcs]; - } - - - - else if (mcs>9 && mcs<17) { - - start = 0; - end = 196; - middle = end/2; - - if (RBIR <= MI_map_16qam[2][start]) { - sinr_eff = MI_map_16qam[0][start]; - } else { - if (RBIR >= MI_map_16qam[2][end]) - sinr_eff = MI_map_16qam[0][end]; - else { - //while((end-start > 1) && (RBIR >= MI_map_4qam[2])) - if (RBIR < MI_map_16qam[2][middle]) { - end = middle; - middle = end/2; - } else { - start = middle; - middle = (end-middle)/2; - } - } - - for (; end>start; end--) { - if ((RBIR < MI_map_16qam[2][end]) && (RBIR > MI_map_16qam[2][end-2])) { - sinr_eff = MI_map_16qam[0][end-1]; - break; - } - } - } - - sinr_eff = sinr_eff * beta2_dlsch_MI[TM][mcs]; - } else if (mcs>16) { - start = 0; - end = 226; - middle = end/2; - - if (RBIR <= MI_map_64qam[2][start]) { - sinr_eff = MI_map_64qam[0][start]; - } else { - if (RBIR >= MI_map_64qam[2][end]) - sinr_eff = MI_map_64qam[0][end]; - else { - //while((end-start > 1) && (RBIR >= MI_map_4qam[2])) - if (RBIR < MI_map_64qam[2][middle]) { - end = middle; - middle = end/2; - } else { - start = middle; - middle = (end-middle)/2; - } - } - - for (; end>start; end--) { - if ((RBIR < MI_map_64qam[2][end]) && (RBIR > MI_map_64qam[2][end-2])) { - sinr_eff = MI_map_64qam[0][end-1]; - break; - } - } - } - - sinr_eff = sinr_eff * beta2_dlsch_MI[TM][mcs]; - } - - printf("SINR_Eff = %e\n",sinr_eff); - - sinr_eff *= 10; - sinr_eff = floor(sinr_eff); - // if ((int)sinr_eff%2) { - // sinr_eff += 1; - // } - sinr_eff /= 10; - printf("sinr_eff after rounding = %f\n",sinr_eff); - - for (index = 0; index < 16; index++) { - if(index == 0) { - if (sinr_eff < sinr_bler_map_up[mcs][0][index]) { - bler = 1; - break; - } - } - - if (sinr_eff == sinr_bler_map_up[mcs][0][index]) { - bler = sinr_bler_map_up[mcs][1][index]; - } - } - -#ifdef USER_MODE // need to be adapted for the emulation in the kernel space - - if (uniformrandom() < bler) { - printf("abstraction_decoding failed (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler); - return(0); - } else { - printf("abstraction_decoding successful (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler); - return(1); - } - -#endif - -} - -#endif - -uint32_t ulsch_decoding_emul(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, - uint8_t UE_index, - uint16_t *crnti) -{ - - uint8_t UE_id; - uint16_t rnti; - int subframe = proc->subframe_rx; - uint8_t harq_pid; - uint8_t CC_id = eNB->CC_id; - - harq_pid = subframe2harq_pid(&eNB->frame_parms,proc->frame_rx,subframe); - - rnti = eNB->ulsch[UE_index]->rnti; -#ifdef DEBUG_PHY - LOG_D(PHY,"[eNB %d] ulsch_decoding_emul : subframe %d UE_index %d harq_pid %d rnti %x\n",eNB->Mod_id,subframe,UE_index,harq_pid,rnti); -#endif - - for (UE_id=0; UE_id<NB_UE_INST; UE_id++) { - if (rnti == PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[PHY_vars_UE_g[UE_id][CC_id]->current_thread_id[subframe]][0]->crnti) - break; - - } - - if (UE_id==NB_UE_INST) { - LOG_W(PHY,"[eNB %d] ulsch_decoding_emul: FATAL, didn't find UE with rnti %x (UE index %d)\n", - eNB->Mod_id, rnti, UE_index); - return(1+eNB->ulsch[UE_id]->max_turbo_iterations); - } else { - LOG_D(PHY,"[eNB %d] Found UE with rnti %x => UE_id %d\n",eNB->Mod_id, rnti, UE_id); - } - - if (PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->harq_processes[harq_pid]->status == CBA_ACTIVE) { - *crnti = rnti; - PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->harq_processes[harq_pid]->status=IDLE; - } else - *crnti = 0x0; - - if (1) { - LOG_D(PHY,"ulsch_decoding_emul abstraction successful\n"); - - memcpy(eNB->ulsch[UE_index]->harq_processes[harq_pid]->b, - PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->harq_processes[harq_pid]->b, - eNB->ulsch[UE_index]->harq_processes[harq_pid]->TBS>>3); - - // get local ue's ack - if ((UE_index >= oai_emulation.info.first_ue_local) ||(UE_index <(oai_emulation.info.first_ue_local+oai_emulation.info.nb_ue_local))) { - get_ack(&eNB->frame_parms, - PHY_vars_UE_g[UE_id][CC_id]->dlsch[0][0][0]->harq_ack, - proc->subframe_tx, - proc->subframe_rx, - eNB->ulsch[UE_index]->harq_processes[harq_pid]->o_ACK,0); - } else { // get remote UEs' ack - eNB->ulsch[UE_index]->harq_processes[harq_pid]->o_ACK[0] = PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->o_ACK[0]; - eNB->ulsch[UE_index]->harq_processes[harq_pid]->o_ACK[1] = PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->o_ACK[1]; - } - - // Do abstraction of PUSCH feedback -#ifdef DEBUG_PHY - LOG_D(PHY,"[eNB %d][EMUL] ue index %d UE_id %d: subframe %d : o_ACK (%d %d), cqi (val %d, len %d)\n", - eNB->Mod_id,UE_index, UE_id, subframe,eNB->ulsch[UE_index]->harq_processes[harq_pid]->o_ACK[0], - eNB->ulsch[UE_index]->harq_processes[harq_pid]->o_ACK[1], - ((HLC_subband_cqi_rank1_2A_5MHz *)PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->o)->cqi1, - PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->O); -#endif - - eNB->ulsch[UE_index]->harq_processes[harq_pid]->Or1 = PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->O; - eNB->ulsch[UE_index]->harq_processes[harq_pid]->Or2 = PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->O; - - eNB->ulsch[UE_index]->harq_processes[harq_pid]->uci_format = PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->uci_format; - memcpy(eNB->ulsch[UE_index]->harq_processes[harq_pid]->o,PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->o,MAX_CQI_BYTES); - memcpy(eNB->ulsch[UE_index]->harq_processes[harq_pid]->o_RI,PHY_vars_UE_g[UE_id][CC_id]->ulsch[0]->o_RI,2); - - eNB->ulsch[UE_index]->harq_processes[harq_pid]->cqi_crc_status = 1; - - return(1); - } else { - LOG_W(PHY,"[eNB %d] ulsch_decoding_emul abstraction failed for UE %d\n",eNB->Mod_id,UE_index); - - eNB->ulsch[UE_index]->harq_processes[harq_pid]->cqi_crc_status = 0; - - // retransmission - return(1+eNB->ulsch[UE_index]->max_turbo_iterations); - } - -} -#endif diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 795ed5896b2debb49be34b06a9d5075513b44b2a..93c1af8d9184db6cce5e16e5ab36117f949e6833 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -1360,7 +1360,6 @@ void rx_ulsch_emul(PHY_VARS_eNB *eNB, subframe,harq_pid,eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS,eNB->ulsch[UE_id]->harq_processes[harq_pid]->Qm, eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch); - //#ifndef OAI_EMU write_output("/tmp/ulsch_d.m","ulsch_dseq",&eNB->ulsch[UE_id]->harq_processes[harq_pid]->d[0][96], eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus*3,1,0); if (eNB->common_vars.rxdata) write_output("/tmp/rxsig0.m","rxs0", &eNB->common_vars.rxdata[0][0],eNB->frame_parms.samples_per_tti*10,1,1); diff --git a/openair1/PHY/MODULATION/ul_7_5_kHz.c b/openair1/PHY/MODULATION/ul_7_5_kHz.c index f2e43a533e23e86fd1d9fff77834293e51e8a8fb..80efc70c40cbe1159cdb18ea5414b21287684027 100644 --- a/openair1/PHY/MODULATION/ul_7_5_kHz.c +++ b/openair1/PHY/MODULATION/ul_7_5_kHz.c @@ -23,11 +23,7 @@ #include "PHY/extern.h" #include "extern.h" #include "kHz_7_5.h" -#ifdef USER_MODE #include <math.h> -#else -#include "rtai_math.h" -#endif #include "PHY/sse_intrin.h" short conjugate75[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; diff --git a/openair1/PHY/TOOLS/Makefile b/openair1/PHY/TOOLS/Makefile index eee9d7834426077de14d2b71b80d7011283ce276..59b6a1e03beedc51371c2a611964fb3d5a2682b6 100644 --- a/openair1/PHY/TOOLS/Makefile +++ b/openair1/PHY/TOOLS/Makefile @@ -1,14 +1,14 @@ lte_dfts_sse4: lte_dfts.c - gcc -O2 -msse4.1 -g -ggdb -o lte_dfts_sse4 lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DUSER_MODE -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS + gcc -O2 -msse4.1 -g -ggdb -o lte_dfts_sse4 lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS lte_dfts_avx2: lte_dfts.c - gcc -O2 -mavx2 -g -ggdb -o lte_dfts_avx2 lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DUSER_MODE -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS + gcc -O2 -mavx2 -g -ggdb -o lte_dfts_avx2 lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS lte_dfts_avx2.s: lte_dfts.c - gcc -O2 -mavx2 -S lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DUSER_MODE -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS + gcc -O2 -mavx2 -S lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS lte_dfts_sse4.s: lte_dfts.c - gcc -O2 -msse4.1 -S lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DUSER_MODE -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS + gcc -O2 -msse4.1 -S lte_dfts.c time_meas.c file_output.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR/COMMON -DMR_MAIN -DNB_ANTENNAS_RX=1 # -DD256STATS #-DD64STATS dft_cycles_avx2: lte_dfts_avx2 ./lte_dfts_avx2 | egrep cycles diff --git a/openair1/PHY/TOOLS/cmult_vv.c b/openair1/PHY/TOOLS/cmult_vv.c index b5b551f008ea4bd9aa1e57738ffd79a10f20b915..13facf69077a165a0f6c05378bb1f847c6c4ab0b 100644 --- a/openair1/PHY/TOOLS/cmult_vv.c +++ b/openair1/PHY/TOOLS/cmult_vv.c @@ -20,10 +20,7 @@ */ #include "defs.h" -//#include "MAC_INTERFACE/extern.h" -#ifdef USER_MODE #include <stdio.h> -#endif #if defined(__x86_64__) || defined(__i386__) int16_t conjug[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; @@ -267,4 +264,4 @@ int multadd_cpx_vector(int16_t *x1, _mm_empty(); _m_empty(); return(0); -} \ No newline at end of file +} diff --git a/openair1/PHY/TOOLS/defs.h b/openair1/PHY/TOOLS/defs.h index 41d7c9528adc52c45a79a6923b872abcf87eae56..b92c2a42367b59acae680d167af8665f3de7093e 100644 --- a/openair1/PHY/TOOLS/defs.h +++ b/openair1/PHY/TOOLS/defs.h @@ -34,13 +34,10 @@ #include "PHY/sse_intrin.h" -//defined in rtai_math.h -#ifndef _RTAI_MATH_H struct complex { double x; double y; }; -#endif struct complexf { float r; @@ -286,7 +283,6 @@ void bit8_txmux(int32_t length,int32_t offset); void bit8_rxdemux(int32_t length,int32_t offset); -#ifdef USER_MODE /*!\fn int32_t write_output(const char *fname, const char *vname, void *data, int length, int dec, char format); \brief Write output file from signal data @param fname output file name @@ -297,7 +293,6 @@ void bit8_rxdemux(int32_t length,int32_t offset); @param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit) */ int32_t write_output(const char *fname, const char *vname, void *data, int length, int dec, char format); -#endif void Zero_Buffer(void *,uint32_t); void Zero_Buffer_nommx(void *buf,uint32_t length); @@ -361,17 +356,6 @@ int16_t dB_fixed_times10(uint32_t x); int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot, uint32_t last_pilot, int32_t ignore_prefix); -/*!\fn void phy_phase_compensation (int16_t *ref_sch, int16_t *tgt_sch, int16_t *out_sym, int32_t ignore_prefix, int32_t aa, struct complex16 *perror_out); -This function is used by the EMOS to compensate the phase rotation of the RF. It has been designed for symbols of type CHSCH or SCH, but cannot be used for the data channels. -@param ref_sch reference symbol -@param tgt_sch target symbol -@param out_sym output of the operation -@param ignore_prefix set to 1 if cyclic prefix has not been removed (by the hardware) -@param aa antenna index -@param perror_out phase error (output parameter) -*/ -void phy_phase_compensation (int16_t *ref_sch, int16_t *tgt_sch, int16_t *out_sym, int32_t ignore_prefix, int32_t aa, struct complex16 *perror_out ); - int32_t dot_product(int16_t *x, int16_t *y, uint32_t N, //must be a multiple of 8 diff --git a/openair1/PHY/TOOLS/file_output.c b/openair1/PHY/TOOLS/file_output.c index c2256707b5195a7adf8b065bd724ddcf7ef792a0..1edc7afbb6dea76226a6054a41e7a53f1fa3c78c 100644 --- a/openair1/PHY/TOOLS/file_output.c +++ b/openair1/PHY/TOOLS/file_output.c @@ -19,8 +19,6 @@ * contact@openairinterface.org */ -#ifdef USER_MODE - #include <string.h> #include <stdio.h> #include <stdlib.h> @@ -182,5 +180,3 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d return 0; } - -#endif // USER_MODE diff --git a/openair1/PHY/TOOLS/lte_dfts.c b/openair1/PHY/TOOLS/lte_dfts.c index dc4708ce6cefab738e9e1e5b22b7e927323bf6a8..e0e171f6bfc601fd839fe40e4b8ead6a29a69b23 100644 --- a/openair1/PHY/TOOLS/lte_dfts.c +++ b/openair1/PHY/TOOLS/lte_dfts.c @@ -19,11 +19,9 @@ * contact@openairinterface.org */ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> #include <string.h> -#endif #include <stdint.h> diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index abefdca363c196671050d36029606f3c2bb46405..75473fc8180ab814f3996c662e2b2b0f848bbbd3 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -775,6 +775,10 @@ typedef struct RU_t_s{ time_stats_t rx_fhaul; /// Timing statistics (TX Fronthaul + Compression) time_stats_t tx_fhaul; + /// Timong statistics (Compression) + time_stats_t compression; + /// Timing statistics (Fronthaul transport) + time_stats_t transport; /// RX and TX buffers for precoder output RU_COMMON common; /// beamforming weight vectors per eNB @@ -1004,6 +1008,7 @@ typedef struct PHY_VARS_eNB_s { LTE_eNB_ULSCH_t *ulsch[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA LTE_eNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p; LTE_eNB_DLSCH_t *dlsch_MCH; + LTE_eNB_DLSCH_t *dlsch_PCH; LTE_eNB_UE_stats UE_stats[NUMBER_OF_UE_MAX]; LTE_eNB_UE_stats *UE_stats_ptr[NUMBER_OF_UE_MAX]; diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index d72a2bd8d6886823269728589d8025d6e7795170..ac54be36fb426c104d2811d40643f4f42676c431 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -153,7 +153,9 @@ typedef struct { /// prach_Config_enabled=1 means enabled. \vr{[0..1]} uint8_t prach_Config_enabled; /// PRACH Configuration Information +#ifdef Rel14 PRACH_eMTC_CONFIG_INFO prach_ConfigInfo; +#endif } PRACH_eMTC_CONFIG_COMMON; /// Enumeration for parameter \f$N_\text{ANRep}\f$ \ref PUCCH_CONFIG_DEDICATED::repetitionFactor. diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 6fe6b46a380537afe004d5e13d74932eb78fe777..1e596919dd31e96e4eee86e6fa8e33c789979eb7 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -125,10 +125,6 @@ #define FIRST_CARRIER_OFFSET (HALF_NUMBER_OF_USEFUL_CARRIERS+NUMBER_OF_ZERO_CARRIERS) #define NUMBER_OF_OFDM_SYMBOLS_PER_SLOT (NUMBER_OF_SYMBOLS_PER_FRAME/LTE_SLOTS_PER_FRAME) -#ifdef EMOS -#define EMOS_SCH_INDEX 1 -#endif //EMOS - #define EXTENSION_TYPE (PHY_config->PHY_framing.Extension_type) #define NUMBER_OF_OFDM_CARRIERS_BYTES NUMBER_OF_OFDM_CARRIERS*4 @@ -273,7 +269,7 @@ typedef struct { /// Measurement Variables -#define NUMBER_OF_SUBBANDS_MAX 13 +//#define NUMBER_OF_SUBBANDS_MAX 13 #define NUMBER_OF_HARQ_PID_MAX 8 #define MAX_FRAME_NUMBER 0x400 diff --git a/openair1/PHY/types.h b/openair1/PHY/types.h index be8ec7115a5aed02091bea5973df54ee8a333b3b..c0a9af388cfcc02643e118851719e05364c60570 100644 --- a/openair1/PHY/types.h +++ b/openair1/PHY/types.h @@ -22,11 +22,7 @@ #ifndef __openair_TYPES_H__ #define __openair_TYPES_H__ -#ifdef USER_MODE #include <stdint.h> -#else -#include <linux/types.h> -#endif #endif /*__openair_TYPES_H__ */ diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index ac41f1af0642ef09d62769c4b4ec5890315560f4..5c8840f84a8b1eb8e8c5e9d9fee355d2f9fedae6 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -221,11 +221,19 @@ void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,re @param phy_vars_eNB Pointer to eNB variables on which to act @param br_flag indicator for eMTC PRACH */ -void prach_procedures(PHY_VARS_eNB *eNB, #ifdef Rel14 - int br_flag +void prach_procedures(PHY_VARS_eNB *eNB, + int br_flag); +#else +void prach_procedures(PHY_VARS_eNB *eNB); #endif - ); + +/*! \brief Function to compute subframe Number(DL and S) as a function of Frame type and TDD Configuration + @param frame_parms Pointer to DL frame parameter descriptor + @returns Subframe Number (DL,S) +*/ +int subframe_num(LTE_DL_FRAME_PARMS *frame_parms); + /*! \brief Function to compute subframe type as a function of Frame type and TDD Configuration (implements Table 4.2.2 from 36.211, p.11 from version 8.6) and subframe index. @param frame_parms Pointer to DL frame parameter descriptor @param subframe Subframe index diff --git a/openair1/SCHED/extern.h b/openair1/SCHED/extern.h index 80a815dda769d16f63fc38f95123f8f8a7c6140d..b1e8df67ef86a5bb11c9cf9bb2d5dd57374d2eee 100644 --- a/openair1/SCHED/extern.h +++ b/openair1/SCHED/extern.h @@ -24,40 +24,6 @@ #ifndef __SCHED_EXTERN_H__ #define __SCHED_EXTERN_H__ -#ifndef USER_MODE -#define __NO_VERSION__ - - -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/module.h> -#include <linux/version.h> -#include <linux/types.h> - -#include <asm/io.h> -#include <asm/bitops.h> - -#include <asm/uaccess.h> -#include <asm/segment.h> -#include <asm/page.h> - - - - -#ifdef RTAI_ENABLED -#include <rtai.h> -//#include <rtai_posix.h> -#include <rtai_fifos.h> -#include <rtai_sched.h> -#include <rtai_sem.h> -//#include "rt_compat.h" - -#else -#include <unistd.h> -#endif - -#endif /* USER_MODE */ - #include "defs.h" //#include "dlc_engine.h" @@ -71,11 +37,5 @@ extern int synch_wait_cnt; extern int16_t hundred_times_delta_TF[100]; extern uint16_t hundred_times_log10_NPRB[100]; -/* -#ifdef EMOS -extern fifo_dump_emos_UE emos_dump_UE; -extern fifo_dump_emos_eNB emos_dump_eNB; -#endif -*/ #endif /*__SCHED_EXTERN_H__ */ diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 1f93c51eac5cd452eb5b93eb6888c11523967b87..59b36a188157e4c8c7a915edf972c29a4ef387a8 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -46,19 +46,24 @@ extern uint8_t nfapi_mode; void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, + int frame, int subframe, eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu) { - int idx = proc->subframe_tx&1; + int idx = subframe&1; LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[idx]; nfapi_dl_config_dci_dl_pdu *pdu = &dl_config_pdu->dci_dl_pdu; - LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); + LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); + // copy dci configuration into eNB structure - fill_dci_and_dlsch(eNB,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); + fill_dci_and_dlsch(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); + + LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); } +#ifdef Rel14 void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu) @@ -72,23 +77,25 @@ void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB, // copy dci configuration into eNB structure fill_mdci_and_dlsch(eNB,proc,&mpdcch_vars->mdci_alloc[mpdcch_vars->num_dci],pdu); } +#endif -void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, +void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { - int idx = proc->subframe_tx&1; + int idx = subframe&1; LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[idx]; - //LOG_D(PHY,"%s() Before num_dci:%d\n", __FUNCTION__, pdcch_vars->num_dci); + //LOG_D(PHY,"%s() SFN/SF:%04d%d Before num_dci:%d\n", __FUNCTION__,frame,subframe,pdcch_vars->num_dci); + // copy dci configuration in to eNB structure - fill_dci0(eNB,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci], &hi_dci0_config_pdu->dci_pdu); + fill_dci0(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci], &hi_dci0_config_pdu->dci_pdu); } -void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, +void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { - LTE_eNB_PHICH *phich = &eNB->phich_vars[proc->subframe_tx&1]; + LTE_eNB_PHICH *phich = &eNB->phich_vars[subframe&1]; // copy dci configuration in to eNB structure LOG_D(PHY,"Received HI PDU with value %d (rbstart %d,cshift %d)\n", @@ -131,7 +138,7 @@ extern uint32_t localRIV2alloc_LUT100_2[6000]; extern uint32_t localRIV2alloc_LUT100_3[6000]; #endif -void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, +void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t codeword_index, uint8_t *sdu) @@ -156,11 +163,25 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, dlsch1 = eNB->dlsch[UE_id][1]; #ifdef Rel14 - if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[proc->subframe_tx] = 0; + if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[subframe] = 0; #endif - harq_pid = dlsch0->harq_ids[proc->subframe_tx]; - AssertFatal((harq_pid>=0) && (harq_pid<8),"harq_pid %d not in 0...7\n",harq_pid); + harq_pid = dlsch0->harq_ids[subframe]; + AssertFatal((harq_pid>=0) && (harq_pid<8),"harq_pid %d not in 0...7 frame:%d subframe:%d subframe(TX):%d rnti:%x UE_id:%d dlsch0[harq_ids:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d]\n", + harq_pid, + frame,subframe, + proc->subframe_tx,rel8->rnti,UE_id, + dlsch0->harq_ids[0], + dlsch0->harq_ids[1], + dlsch0->harq_ids[2], + dlsch0->harq_ids[3], + dlsch0->harq_ids[4], + dlsch0->harq_ids[5], + dlsch0->harq_ids[6], + dlsch0->harq_ids[7], + dlsch0->harq_ids[8], + dlsch0->harq_ids[9] + ); dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch_harq is null\n"); @@ -177,20 +198,23 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, computeRhoB_eNB(&eNB->pdsch_config_dedicated[UE_id],&(eNB->frame_parms.pdsch_config_common),eNB->frame_parms.nb_antenna_ports_eNB,dlsch1,dlsch1_harq->dl_power_off); } - dlsch0_harq->pdsch_start = eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols; + dlsch0_harq->pdsch_start = eNB->pdcch_vars[subframe & 1].num_pdcch_symbols; if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU - AssertFatal(sdu!=NULL,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", + + AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", + frame,subframe, proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); - if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", - proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); + if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d, subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", + frame,subframe,proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); + if (codeword_index == 0) dlsch0_harq->pdu = sdu; else dlsch1_harq->pdu = sdu; } else { - if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round %d, rnti %x, UE_id %d, harq_pid %d\n", - proc->frame_tx,proc->subframe_tx,dlsch0_harq->round, + if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d, subframe %d]: programming dlsch for round %d, rnti %x, UE_id %d, harq_pid %d\n", + frame,subframe,proc->frame_tx,proc->subframe_tx,dlsch0_harq->round, rel8->rnti,UE_id,harq_pid); } @@ -202,8 +226,6 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, dlsch0->Kmimo = 1; dlsch0->Mdlharq = 4; dlsch0->Nsoft = 25344; - dlsch0->i0 = rel13->initial_transmission_sf_io; - dlsch0_harq->pdsch_start = rel10->pdsch_start; if (rel13->pdsch_payload_type == 0) dlsch0->sib1_br_flag=1; @@ -245,11 +267,16 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, dlsch0_harq->TBS = rel8->length<<3; dlsch0_harq->Qm = rel8->modulation; dlsch0_harq->codeword = 0; - } - else { - dlsch0->i0 = 0xFFFF; + dlsch0_harq->pdsch_start = rel10->pdsch_start; } #endif + dlsch0->i0 = rel13->initial_transmission_sf_io; + + LOG_D(PHY,"dlsch->i0:%04x dlsch0_harq[pdsch_start:%d nb_rb:%d vrb_type:%d rvidx:%d Nl:%d mimo_mode:%d dl_power_off:%d round:%d status:%d TBS:%d Qm:%d codeword:%d rb_alloc:%d] rel8[length:%d]\n", + dlsch0->i0, + dlsch0_harq->pdsch_start, dlsch0_harq->nb_rb, dlsch0_harq->vrb_type, dlsch0_harq->rvidx, dlsch0_harq->Nl, dlsch0_harq->mimo_mode, dlsch0_harq->dl_power_off, dlsch0_harq->round, dlsch0_harq->status, dlsch0_harq->TBS, dlsch0_harq->Qm, dlsch0_harq->codeword, dlsch0_harq->rb_alloc[0], + rel8->length + ); } uint16_t to_beta_offset_harqack[16]={16,20,25,32,40,50,64,80,101,127,160,248,400,640,1008,8}; @@ -505,8 +532,7 @@ void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) { AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, "No existing UE ULSCH for rnti %x\n",rel8->rnti); - LOG_D(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d\n", - UE_id,rel8->rnti,frame,subframe); + //LOG_D(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d\n", UE_id,rel8->rnti,frame,subframe); fill_ulsch(eNB,&ul_config_pdu->ulsch_pdu,frame,subframe); @@ -592,9 +618,14 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) AssertFatal(RC.eNB[Mod_id]!=NULL,"RC.eNB[%d] is null\n",Mod_id); AssertFatal(RC.eNB[Mod_id][CC_id]!=NULL,"RC.eNB[%d][%d] is null\n",Mod_id,CC_id); + + eNB = RC.eNB[Mod_id][CC_id]; fp = &eNB->frame_parms; proc = &eNB->proc.proc_rxtx[0]; + + if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return; + ul_subframe = pdcch_alloc2ul_subframe(fp,subframe); ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe); @@ -602,7 +633,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) // DJP - AssertFatal(proc->subframe_tx == subframe, "Current subframe %d != NFAPI subframe %d\n",proc->subframe_tx,subframe); // DJP - AssertFatal(proc->subframe_tx == subframe, "Current frame %d != NFAPI frame %d\n",proc->frame_tx,frame); - uint8_t number_dci = DL_req->dl_config_request_body.number_dci; + uint8_t number_pdcch_ofdm_symbols = DL_req->dl_config_request_body.number_pdcch_ofdm_symbols; uint8_t number_dl_pdu = DL_req->dl_config_request_body.number_pdu; @@ -616,17 +647,24 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) int i; eNB->pdcch_vars[subframe&1].num_pdcch_symbols = number_pdcch_ofdm_symbols; - eNB->pdcch_vars[subframe&1].num_dci = number_dci; + + eNB->pdcch_vars[subframe&1].num_dci = 0; eNB->phich_vars[subframe&1].num_hi = 0; - LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%d%d dl_pdu:%d tx_req:%d hi_dci0:%d ul_cfg:%d num_pdcch_symbols:%d\n", - frame,subframe,number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu, eNB->pdcch_vars[subframe&1].num_pdcch_symbols); + LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%04d%d DL_req:SFN/SF:%04d%d:dl_pdu:%d tx_req:SFN/SF:%04d%d:pdus:%d hi_dci0:SFN/SF:%04d%d:pdus:%d ul_cfg:SFN/SF:%04d%d:pdus:%d num_pdcch_symbols:%d\n", + frame,subframe, + NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),number_dl_pdu, + NFAPI_SFNSF2SFN(TX_req->sfn_sf),NFAPI_SFNSF2SF(TX_req->sfn_sf),TX_req->tx_request_body.number_of_pdus, + NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),number_hi_dci0_pdu, + NFAPI_SFNSF2SFN(UL_req->sfn_sf),NFAPI_SFNSF2SF(UL_req->sfn_sf),number_ul_pdu, + eNB->pdcch_vars[subframe&1].num_pdcch_symbols); int do_oai =0; int dont_send =0; + if ((ul_subframe<10)&& + (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is an ul_subframe that can be configured here + LOG_D(PHY,"NFAPI: Clearing dci allocations for potential UL subframe %d\n",ul_subframe); - if (ul_subframe<10) { // This means that there is an ul_subframe that can be configured here - LOG_D(PHY,"NFAPI: Clearing dci allocations for potential UL\n"); harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); // clear DCI allocation maps for new subframe @@ -644,8 +682,9 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) //LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type); switch (dl_config_pdu->pdu_type) { case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: - handle_nfapi_dci_dl_pdu(eNB,proc,dl_config_pdu); - eNB->pdcch_vars[subframe&1].num_dci++; + + handle_nfapi_dci_dl_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu); + eNB->pdcch_vars[NFAPI_SFNSF2SF(DL_req->sfn_sf)&1].num_dci++; //LOG_E(PHY,"Incremented num_dci:%d but already set??? dl_config:num_dci:%d\n", eNB->pdcch_vars[subframe&1].num_dci, number_dci); do_oai=1; break; @@ -674,8 +713,13 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) uint16_t invalid_pdu = pdu_index == -1; uint8_t *sdu = invalid_pdu ? NULL : pdu_index >= tx_pdus ? NULL : TX_req->tx_request_body.tx_pdu_list[pdu_index].segments[0].segment_data; - LOG_D(PHY,"%s() [PDU:%d] NFAPI_DL_CONFIG_DLSCH_PDU_TYPE TX:%d/%d RX:%d/%d transport_blocks:%d pdu_index:%d sdu:%p\n", - __FUNCTION__, i, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, dlsch_pdu_rel8->transport_blocks, pdu_index, sdu); + LOG_D(PHY,"%s() [PDU:%d] NFAPI_DL_CONFIG_DLSCH_PDU_TYPE SFN/SF:%04d%d TX:%d/%d RX:%d/%d transport_blocks:%d pdu_index:%d sdu:%p\n", + __FUNCTION__, i, + NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf), + proc->frame_tx, proc->subframe_tx, + proc->frame_rx, proc->subframe_rx, + dlsch_pdu_rel8->transport_blocks, pdu_index, sdu); + /* AssertFatal(dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index<TX_req->tx_request_body.number_of_pdus, @@ -689,7 +733,8 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) dlsch_pdu_rel8->transport_blocks); if (1)//sdu != NULL) { - handle_nfapi_dlsch_pdu(eNB,proc,dl_config_pdu, dlsch_pdu_rel8->transport_blocks-1, sdu); + handle_nfapi_dlsch_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu, dlsch_pdu_rel8->transport_blocks-1, sdu); + } else { @@ -726,10 +771,12 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: // handle_nfapi_epdcch_pdu(eNB,dl_config_pdu); break; +#ifdef Rel14 case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: handle_nfapi_mpdcch_pdu(eNB,proc,dl_config_pdu); eNB->mpdcch_vars[subframe&1].num_dci++; break; +#endif } } @@ -741,8 +788,8 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) if (nfapi_mode && number_hi_dci0_pdu!=0) { oai_nfapi_hi_dci0_req(HI_DCI0_req); - eNB->pdcch_vars[subframe&1].num_dci=0; - eNB->pdcch_vars[subframe&1].num_pdcch_symbols=0; + eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_dci=0; + eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_pdcch_symbols=0; } for (i=0;i<number_hi_dci0_pdu;i++) { @@ -755,37 +802,17 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) case NFAPI_HI_DCI0_DCI_PDU_TYPE: - handle_nfapi_hi_dci0_dci_pdu(eNB,proc,hi_dci0_req_pdu); + handle_nfapi_hi_dci0_dci_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu); - eNB->pdcch_vars[subframe&1].num_dci++; + eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_dci++; break; case NFAPI_HI_DCI0_HI_PDU_TYPE: - handle_nfapi_hi_dci0_hi_pdu(eNB,proc,hi_dci0_req_pdu); - + handle_nfapi_hi_dci0_hi_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu); break; } } - if (0){//nfapi_mode) { - int future_subframe=subframe; - //for (int future_subframe=0;future_subframe<10;future_subframe++) { - { - nfapi_ul_config_request_t *ul_req_tmp = &RC.mac[0]->UL_req_tmp[CC_id][future_subframe]; - - // DJP - indexing directly into the mac - not good - ?????? - if (ul_req_tmp->ul_config_request_body.number_of_pdus > 0) - { - LOG_D(PHY,"UL_CONFIG for the future future_subframe:%d UL_req_tmp[PDUs:%d SFN/SF:%d]\n", - future_subframe, - ul_req_tmp->ul_config_request_body.number_of_pdus, - NFAPI_SFNSF2DEC(ul_req_tmp->sfn_sf)); - - oai_nfapi_ul_config_req(ul_req_tmp); - } - } - } - if (nfapi_mode) { if (number_ul_pdu>0) { diff --git a/openair1/SCHED/fapi_l1.h b/openair1/SCHED/fapi_l1.h index 3f4267c7f2139061ecb7bde4f05774b49b503a10..725bb31c455fdf6e11c4b917ac0801bfb9d1faa1 100644 --- a/openair1/SCHED/fapi_l1.h +++ b/openair1/SCHED/fapi_l1.h @@ -42,13 +42,13 @@ void fill_ulsch_cqi_indication(PHY_VARS_eNB *eNB,uint16_t frame,uint8_t subframe void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat); void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe); void fill_crc_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint8_t crc_flag); -void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,nfapi_dl_config_request_pdu_t *dl_config_pdu); +void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc,nfapi_dl_config_request_pdu_t *dl_config_pdu); void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,nfapi_dl_config_request_pdu_t *dl_config_pdu); -void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, +void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); -void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, +void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); -void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, +void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t codeword_index, uint8_t *sdu); diff --git a/openair1/SCHED/phy_mac_stub.c b/openair1/SCHED/phy_mac_stub.c index 15c6fa7557da2d4eb0bed5d9a7d8b895ae1d720c..664791f7c459632d51541e413ef844384e6c8ab1 100644 --- a/openair1/SCHED/phy_mac_stub.c +++ b/openair1/SCHED/phy_mac_stub.c @@ -36,10 +36,6 @@ #include "SCHED/extern.h" #include "LAYER2/MAC/extern.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif - /* SYRTEM */ uint8_t dci_ndi_toggle_even[8] = {0, 0, 0, 0, 0, 0, 0, 0}; uint8_t dci_ndi_toggle_odd[8] = {0, 0, 0, 0, 0, 0, 0, 0}; @@ -733,181 +729,3 @@ void fill_dci(DCI_PDU *DCI_pdu,PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } */ } - -void fill_dci_emos(DCI_PDU *DCI_pdu, uint8_t subframe, PHY_VARS_eNB *eNB) -{ - - //uint8_t cooperation_flag = eNB->cooperation_flag; - uint8_t transmission_mode = eNB->transmission_mode[0]; - - //uint32_t rballoc = 0x00F0; - //uint32_t rballoc2 = 0x000F; - /* - uint32_t rand = taus(); - if ((subframe==8) || (subframe==9) || (subframe==0)) - rand = (rand%5)+5; - else - rand = (rand%4)+5; - */ - - DCI_pdu->Num_dci = 0; - - switch (subframe) { - case 5: - DCI_pdu->Num_dci = 1; - - if (transmission_mode<3) { - //user 1 - DCI_pdu->dci_alloc[0].dci_length = sizeof_DCI1_5MHz_TDD_t; - DCI_pdu->dci_alloc[0].L = 2; - DCI_pdu->dci_alloc[0].rnti = 0x1235; - DCI_pdu->dci_alloc[0].format = format1; - DCI_pdu->dci_alloc[0].ra_flag = 0; - DCI_pdu->dci_alloc[0].search_space = DCI_UE_SPACE; - - DLSCH_alloc_pdu.rballoc = eNB->ue_dl_rb_alloc; - DLSCH_alloc_pdu.TPC = 0; - DLSCH_alloc_pdu.dai = 0; - DLSCH_alloc_pdu.harq_pid = 1; - DLSCH_alloc_pdu.mcs = eNB->target_ue_dl_mcs; - DLSCH_alloc_pdu.ndi = 1; - DLSCH_alloc_pdu.rv = 0; - memcpy((void*)&DCI_pdu->dci_alloc[0].dci_pdu[0],(void *)&DLSCH_alloc_pdu,sizeof(DCI1_5MHz_TDD_t)); - - /* - //user2 - DCI_pdu->dci_alloc[1].dci_length = sizeof_DCI1_5MHz_TDD_t; - DCI_pdu->dci_alloc[1].L = 2; - DCI_pdu->dci_alloc[1].rnti = 0x1236; - DCI_pdu->dci_alloc[1].format = format1; - DCI_pdu->dci_alloc[1].ra_flag = 0; - DCI_pdu->dci_alloc[1].search_space = DCI_UE_SPACE; - - DLSCH_alloc_pdu.rballoc = rballoc2; - DLSCH_alloc_pdu.TPC = 0; - DLSCH_alloc_pdu.dai = 0; - DLSCH_alloc_pdu.harq_pid = 1; - DLSCH_alloc_pdu.mcs = eNB->target_ue_dl_mcs; - DLSCH_alloc_pdu.ndi = 1; - DLSCH_alloc_pdu.rv = 0; - memcpy((void*)&DCI_pdu->dci_alloc[1].dci_pdu[0],(void *)&DLSCH_alloc_pdu,sizeof(DCI1_5MHz_TDD_t)); - */ - } else if (transmission_mode==5) { - DCI_pdu->Num_dci = 2; - // user 1 - DCI_pdu->dci_alloc[0].dci_length = sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t; - DCI_pdu->dci_alloc[0].L = 2; - DCI_pdu->dci_alloc[0].rnti = 0x1235; - DCI_pdu->dci_alloc[0].format = format1E_2A_M10PRB; - DCI_pdu->dci_alloc[0].ra_flag = 0; - DCI_pdu->dci_alloc[0].search_space = DCI_UE_SPACE; - - DLSCH_alloc_pdu1E.tpmi = 5; //5=use feedback - DLSCH_alloc_pdu1E.rv = 0; - DLSCH_alloc_pdu1E.ndi = 1; - DLSCH_alloc_pdu1E.mcs = eNB->target_ue_dl_mcs; - DLSCH_alloc_pdu1E.harq_pid = 1; - DLSCH_alloc_pdu1E.dai = 0; - DLSCH_alloc_pdu1E.TPC = 0; - DLSCH_alloc_pdu1E.rballoc = eNB->ue_dl_rb_alloc; - DLSCH_alloc_pdu1E.rah = 0; - DLSCH_alloc_pdu1E.dl_power_off = 0; //0=second user present - memcpy((void*)&DCI_pdu->dci_alloc[0].dci_pdu[0],(void *)&DLSCH_alloc_pdu1E,sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t)); - - //user 2 - DCI_pdu->dci_alloc[1].dci_length = sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t; - DCI_pdu->dci_alloc[1].L = 2; - DCI_pdu->dci_alloc[1].rnti = 0x1236; - DCI_pdu->dci_alloc[1].format = format1E_2A_M10PRB; - DCI_pdu->dci_alloc[1].ra_flag = 0; - DCI_pdu->dci_alloc[1].search_space = DCI_UE_SPACE; - - memcpy((void*)&DCI_pdu->dci_alloc[1].dci_pdu[0],(void *)&DLSCH_alloc_pdu1E,sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t)); - - // set the precoder of the second UE orthogonal to the first - eNB->UE_stats[1].DL_pmi_single = (eNB->UE_stats[0].DL_pmi_single ^ 0x1555); - } - - break; - - case 7: - DCI_pdu->Num_dci = 1; - DCI_pdu->dci_alloc[0].dci_length = sizeof_DCI1A_5MHz_TDD_1_6_t; - DCI_pdu->dci_alloc[0].L = 2; - DCI_pdu->dci_alloc[0].rnti = 0xbeef; - DCI_pdu->dci_alloc[0].format = format1A; - DCI_pdu->dci_alloc[0].ra_flag = 1; - DCI_pdu->dci_alloc[0].search_space = DCI_COMMON_SPACE; - - RA_alloc_pdu.type = 1; - RA_alloc_pdu.vrb_type = 0; - RA_alloc_pdu.rballoc = computeRIV(25,12,3); - RA_alloc_pdu.ndi = 1; - RA_alloc_pdu.rv = 1; - RA_alloc_pdu.mcs = 4; - RA_alloc_pdu.harq_pid = 0; - RA_alloc_pdu.TPC = 1; - - memcpy((void*)&DCI_pdu->dci_alloc[0].dci_pdu[0],&RA_alloc_pdu,sizeof(DCI1A_5MHz_TDD_1_6_t)); - break; - - case 9: - DCI_pdu->Num_dci = 1; - - //user 1 - DCI_pdu->dci_alloc[0].dci_length = sizeof_DCI0_5MHz_TDD_1_6_t ; - DCI_pdu->dci_alloc[0].L = 2; - DCI_pdu->dci_alloc[0].rnti = 0x1235; - DCI_pdu->dci_alloc[0].format = format0; - DCI_pdu->dci_alloc[0].ra_flag = 0; - DCI_pdu->dci_alloc[0].search_space = DCI_UE_SPACE; - - UL_alloc_pdu.type = 0; - UL_alloc_pdu.hopping = 0; - UL_alloc_pdu.rballoc = computeRIV(25,0,eNB->ue_ul_nb_rb); - UL_alloc_pdu.mcs = eNB->target_ue_ul_mcs; - UL_alloc_pdu.ndi = 1; - UL_alloc_pdu.TPC = 0; - UL_alloc_pdu.cshift = 0; - UL_alloc_pdu.dai = 0; - UL_alloc_pdu.cqi_req = 1; - memcpy((void*)&DCI_pdu->dci_alloc[0].dci_pdu[0],(void *)&UL_alloc_pdu,sizeof(DCI0_5MHz_TDD_1_6_t)); - - /* - //user 2 - DCI_pdu->dci_alloc[1].dci_length = sizeof_DCI0_5MHz_TDD_1_6_t ; - DCI_pdu->dci_alloc[1].L = 2; - DCI_pdu->dci_alloc[1].rnti = 0x1236; - DCI_pdu->dci_alloc[1].format = format0; - DCI_pdu->dci_alloc[1].ra_flag = 0; - - UL_alloc_pdu.type = 0; - UL_alloc_pdu.hopping = 0; - if (cooperation_flag==0) - UL_alloc_pdu.rballoc = computeRIV(25,2+eNB->ue_ul_nb_rb,eNB->ue_ul_nb_rb); - else - UL_alloc_pdu.rballoc = computeRIV(25,0,eNB->ue_ul_nb_rb); - UL_alloc_pdu.mcs = eNB->target_ue_ul_mcs; - UL_alloc_pdu.ndi = 1; - UL_alloc_pdu.TPC = 0; - if ((cooperation_flag==0) || (cooperation_flag==1)) - UL_alloc_pdu.cshift = 0; - else - UL_alloc_pdu.cshift = 1; - UL_alloc_pdu.dai = 0; - UL_alloc_pdu.cqi_req = 1; - memcpy((void*)&DCI_pdu->dci_alloc[1].dci_pdu[0],(void *)&UL_alloc_pdu,sizeof(DCI0_5MHz_TDD_1_6_t)); - */ - break; - - default: - break; - } - /* - DCI_pdu->nCCE = 0; - - for (i=0; i<DCI_pdu->Num_dci; i++) { - DCI_pdu->nCCE += (1<<(DCI_pdu->dci_alloc[i].L)); - } - */ -} diff --git a/openair1/SCHED/phy_procedures_emos.h b/openair1/SCHED/phy_procedures_emos.h deleted file mode 100644 index 266a95b3c9fe42576545c8f6480e1ddae6c25166..0000000000000000000000000000000000000000 --- a/openair1/SCHED/phy_procedures_emos.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef __PHY_PROCEDURES_EMOS_H__ -#define __PHY_PROCEDURES_EMOS_H__ - -/* -#ifndef RTAI -typedef uint64_t RTIME; -#else -*/ -#ifdef RTAI -#include <rtai.h> -#include <rtai_fifos.h> -#endif - -//#include "PHY/TOOLS/defs.h" -#include "PHY/defs.h" -#define CHANSOUNDER_FIFO_SIZE 10485760 // 10 Mbytes FIFO -//#define CHANSOUNDER_FIFO_SIZE 20971520 // 20 Mbytes FIFO -#define CHANSOUNDER_FIFO_MINOR 4 // minor of the FIFO device - this is /dev/rtf3 -#define CHANSOUNDER_FIFO_DEV "/dev/rtf4" - -#define NUMBER_OF_OFDM_CARRIERS_EMOS 512 // the number of OFDM carriers used for channel sounding -#define NUMBER_OF_USEFUL_CARRIERS_EMOS 300 // the number of OFDM carriers that contain data - -#define N_RB_UL_EMOS 25 -#define N_PILOTS_DL_EMOS 2 // ofdm symbols with pilots per slot -#define N_PILOTS_UL_EMOS 2 // ofdm symbols with pilots per subframe -#define N_SLOTS_DL_EMOS 2 // we take slots 14,15 -#define N_SUBFRAMES_UL_EMOS 1 // we take subframes 4 -#define NB_ANTENNAS_TX_EMOS 2 -#define NB_ANTENNAS_RX_EMOS 2 - -struct fifo_dump_emos_struct_UE { - // RX - uint64_t timestamp; //! Timestamp of the receiver - unsigned int frame_tx; //! Framenumber of the TX (encoded in the BCH) - unsigned int frame_rx; //! Framenumber of the RX - UE_MODE_t UE_mode; - PHY_MEASUREMENTS PHY_measurements; //! Structure holding all PHY measurements (one for every slot) - unsigned int pbch_errors; /// Total number of errors on PBCH - unsigned int pbch_errors_last; /// Total number of errors on PBCH 100 frames ago - unsigned int pbch_errors_conseq; /// Total number of consecutive errors on PBCH - unsigned int pbch_fer; /// PBCH FER (in percent) - unsigned int dlsch_errors; /// Total number of error on the DLSCH (data) - unsigned int dlsch_errors_last; - unsigned int dlsch_received; - unsigned int dlsch_received_last; - unsigned int dlsch_fer; - unsigned int dlsch_cntl_errors; /// Total number of error on the DLSCH (control) - unsigned int dlsch_ra_errors; /// Total number of error on the DLSCH (random access) - unsigned int total_TBS; - unsigned int total_TBS_last; - unsigned int bitrate; - unsigned int total_received_bits; - int timing_offset; /// Timing offset - int timing_advance; /// Timing advance - int freq_offset; /// Frequency offset - int use_ia_receiver; - unsigned short pmi_saved; - unsigned short mcs; - unsigned int rx_total_gain_dB; /// Total gain - unsigned char eNb_id; /// eNb_id UE is synched to - unsigned char mimo_mode; /// Transmission mode -#ifdef EMOS_CHANNEL - int channel[NB_ANTENNAS_RX_EMOS][NB_ANTENNAS_TX_EMOS][NUMBER_OF_OFDM_CARRIERS_EMOS*N_PILOTS_DL_EMOS*N_SLOTS_DL_EMOS]; -#endif -}; - -typedef struct fifo_dump_emos_struct_UE fifo_dump_emos_UE; - - -struct fifo_dump_emos_struct_eNB { - // TX - uint64_t timestamp; //! Timestamp of the receiver - unsigned int frame_tx; //! Framenumber of the TX - unsigned char mimo_mode; /// Transmission mode - // RX - PHY_MEASUREMENTS_eNB PHY_measurements_eNB; /// UL measurements - LTE_eNB_UE_stats eNB_UE_stats[NUMBER_OF_UE_MAX]; /// Contains received feedback - unsigned int rx_total_gain_dB; /// Total gain -#ifdef EMOS_CHANNEL - int channel[NB_ANTENNAS_RX_EMOS][N_RB_UL_EMOS*12*N_PILOTS_UL_EMOS*N_SUBFRAMES_UL_EMOS]; ///UL channel estimate -#endif -}; - -typedef struct fifo_dump_emos_struct_eNB fifo_dump_emos_eNB; - -#endif diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index 01c44d6078f6df559cfaf0b99643d14d388eb736..bbb6986ce9c7c3ac375e79eb170e5c4c77b2ab72 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -709,6 +709,26 @@ uint16_t get_Np(uint8_t N_RB_DL,uint8_t nCCE,uint8_t plus1) return(Np[0+plus1]); } +int subframe_num(LTE_DL_FRAME_PARMS *frame_parms){ + if (frame_parms->frame_type == FDD) + return 10; + + switch (frame_parms->tdd_config) { + case 1: + return 6; + case 3: + return 7; + case 4: + return 8; + case 5: + return 9; + default: + LOG_E(PHY,"Unsupported TDD configuration %d\n",frame_parms->tdd_config); + AssertFatal(frame_parms->tdd_config==1 || frame_parms->tdd_config==3 || frame_parms->tdd_config==4 || frame_parms->tdd_config==5,"subframe x Unsupported TDD configuration"); + return(255); + } +} + lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) { diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 9d9c84706b514803882d6ceff94f70022db7dfc5..af581189169cb36ac25848a8c0c77f55d4f7fbc4 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -334,42 +334,50 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, } - LOG_D(PHY,"Generating DLSCH/PDSCH %d\n",ra_flag); + LOG_D(PHY,"Generating DLSCH/PDSCH pdu:%p pdsch_start:%d frame:%d subframe:%d nb_rb:%d rb_alloc:%d Qm:%d Nl:%d round:%d\n", + dlsch_harq->pdu,dlsch_harq->pdsch_start,frame,subframe,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0],dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round); // 36-212 - start_meas(&eNB->dlsch_encoding_stats); - AssertFatal(dlsch_harq->pdu!=NULL,"dlsch_harq->pdu == NULL (rnti %x)\n",dlsch->rnti); - eNB->te(eNB, - dlsch_harq->pdu, - dlsch_harq->pdsch_start, - dlsch, - frame,subframe, - &eNB->dlsch_rate_matching_stats, - &eNB->dlsch_turbo_encoding_stats, - &eNB->dlsch_interleaving_stats); - stop_meas(&eNB->dlsch_encoding_stats); + if (nfapi_mode == 0 || nfapi_mode == 1) { // monolthic OR PNF - do not need turbo encoding on VNF + + if (dlsch_harq->pdu==NULL){ + LOG_E(PHY,"dlsch_harq->pdu == NULL SFN/SF:%04d%d dlsch[rnti:%x] dlsch_harq[pdu:%p pdsch_start:%d Qm:%d Nl:%d round:%d nb_rb:%d rb_alloc[0]:%d]\n", frame,subframe,dlsch->rnti, dlsch_harq->pdu,dlsch_harq->pdsch_start,dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0]); + return; + } + + start_meas(&eNB->dlsch_encoding_stats); + + eNB->te(eNB, + dlsch_harq->pdu, + dlsch_harq->pdsch_start, + dlsch, + frame,subframe, + &eNB->dlsch_rate_matching_stats, + &eNB->dlsch_turbo_encoding_stats, + &eNB->dlsch_interleaving_stats); + stop_meas(&eNB->dlsch_encoding_stats); // 36-211 - start_meas(&eNB->dlsch_scrambling_stats); - dlsch_scrambling(fp, - 0, - dlsch, - harq_pid, - get_G(fp, - dlsch_harq->nb_rb, - dlsch_harq->rb_alloc, - dlsch_harq->Qm, - dlsch_harq->Nl, - dlsch_harq->pdsch_start, - frame,subframe, - 0), - 0, - frame, - subframe<<1); - stop_meas(&eNB->dlsch_scrambling_stats); - - start_meas(&eNB->dlsch_modulation_stats); - + start_meas(&eNB->dlsch_scrambling_stats); + dlsch_scrambling(fp, + 0, + dlsch, + harq_pid, + get_G(fp, + dlsch_harq->nb_rb, + dlsch_harq->rb_alloc, + dlsch_harq->Qm, + dlsch_harq->Nl, + dlsch_harq->pdsch_start, + frame,subframe, + 0), + 0, + frame, + subframe<<1); + stop_meas(&eNB->dlsch_scrambling_stats); + + start_meas(&eNB->dlsch_modulation_stats); + - dlsch_modulation(eNB, + dlsch_modulation(eNB, eNB->common_vars.txdataF, AMP, subframe, @@ -377,10 +385,13 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, dlsch, dlsch1); - stop_meas(&eNB->dlsch_modulation_stats); + stop_meas(&eNB->dlsch_modulation_stats); + } dlsch->active = 0; dlsch_harq->round++; + + LOG_D(PHY,"Generating DLSCH/PDSCH dlsch_harq[round:%d]\n",dlsch_harq->round); } @@ -406,6 +417,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, int offset = eNB->CC_id;//proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; + if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,1); @@ -418,12 +430,15 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, } - if (is_pmch_subframe(frame,subframe,fp)) { - pmch_procedures(eNB,proc,rn,r_type); - } - else { - // this is not a pmch subframe, so generate PSS/SSS/PBCH - common_signal_procedures(eNB,proc->frame_tx, proc->subframe_tx); + + if (nfapi_mode == 0 || nfapi_mode == 1) { + if (is_pmch_subframe(frame,subframe,fp)) { + pmch_procedures(eNB,proc,rn,r_type); + } + else { + // this is not a pmch subframe, so generate PSS/SSS/PBCH + common_signal_procedures(eNB,proc->frame_tx, proc->subframe_tx); + } } // clear existing ulsch dci allocations before applying info from MAC (this is table @@ -439,7 +454,8 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, } /* save old HARQ information needed for PHICH generation */ - if (ul_subframe < 10) { // This means that there is a potential UL subframe that will be scheduled here + if ((ul_subframe < 10)&& + (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is a potential UL subframe that will be scheduled here for (i=0; i<NUMBER_OF_UE_MAX; i++) { harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); if (eNB->ulsch[i]) { @@ -477,17 +493,17 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, num_dci = eNB->pdcch_vars[subframe&1].num_dci; // LOG_D(PHY,"num_pdcch_symbols %"PRIu8",(dci common %"PRIu8", dci uespec %"PRIu8"\n",num_pdcch_symbols, // DCI_pdu->Num_common_dci,DCI_pdu->Num_ue_spec_dci); - //LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci); + + LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,num_pdcch_symbols); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,(frame*10)+subframe); if (num_dci > 0) - { - //LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8") num_pdcch_symbols:%d\n",eNB->Mod_id,frame, subframe, num_dci, num_pdcch_symbols); - } - + + LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8") num_pdcch_symbols:%d\n",eNB->Mod_id,frame, subframe, num_dci, num_pdcch_symbols); + //LOG_D(PHY,"Before generate_dci_top num_pdcch_symbols:%d num_dci:%d dci_alloc:dci_length:%d\n", num_pdcch_symbols, num_dci, eNB->pdcch_vars[subframe&1].dci_alloc[0].dci_length); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1); @@ -524,7 +540,9 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, if (harq_pid>=8) { - LOG_E(PHY,"harq_pid:%d corrupt must be 0-7\n", harq_pid); + + LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 UE_id:%d frame:%d subframe:%d rnti:%x \n", harq_pid,UE_id,frame,subframe,dlsch0->rnti); + } else { @@ -566,182 +584,6 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, } -void prach_procedures(PHY_VARS_eNB *eNB, -#ifdef Rel14 - int br_flag -#endif - ) { - uint16_t max_preamble[4],max_preamble_energy[4],max_preamble_delay[4]; - uint16_t i; - int frame,subframe; - -#ifdef Rel14 - if (br_flag==1) { - subframe = eNB->proc.subframe_prach_br; - frame = eNB->proc.frame_prach_br; - pthread_mutex_lock(&eNB->UL_INFO_mutex); - eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles=0; - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - } - else -#endif - { - pthread_mutex_lock(&eNB->UL_INFO_mutex); - eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles=0; - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - subframe = eNB->proc.subframe_prach; - frame = eNB->proc.frame_prach; - } - RU_t *ru; - int aa=0; - int ru_aa; - - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,1); - - - - for (i=0;i<eNB->num_RU;i++) { - ru=eNB->RU_list[i]; - for (ru_aa=0,aa=0;ru_aa<ru->nb_rx;ru_aa++,aa++) { - eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[i]->prach_rxsigF[ru_aa]; -#ifdef Rel14 - int ce_level; - - if (br_flag==1) - for (ce_level=0;ce_level<4;ce_level++) eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[i]->prach_rxsigF_br[ce_level][ru_aa]; -#endif - } - } - - rx_prach(eNB, - eNB->RU_list[0], - &max_preamble[0], - &max_preamble_energy[0], - &max_preamble_delay[0], - frame, - 0 -#ifdef Rel14 - ,br_flag -#endif - ); - - //#ifdef DEBUG_PHY_PROC - if (max_preamble_energy[0]/10 > 32) - LOG_E(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d\n", - frame,subframe, - max_preamble[0], - max_preamble_energy[0]/10, - max_preamble_delay[0]); - //q#endif - -#ifdef Rel14 - if (br_flag==1) { - - int prach_mask; - - prach_mask = is_prach_subframe(&eNB->frame_parms,eNB->proc.frame_prach_br,eNB->proc.subframe_prach_br); - - eNB->UL_INFO.rach_ind_br.rach_indication_body.preamble_list = eNB->preamble_list_br; - int ind=0; - int ce_level=0; - /* Save for later, it doesn't work - for (int ind=0,ce_level=0;ce_level<4;ce_level++) { - - if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[ce_level]==1)&& - (prach_mask&(1<<(1+ce_level)) > 0) && // prach is active and CE level has finished its repetitions - (eNB->prach_vars_br.repetition_number[ce_level]== - eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level])) { - */ - if (eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0]==1){ - if ((eNB->prach_energy_counter == 100) && - (max_preamble_energy[0] > eNB->measurements.prach_I0 + 100)) { - eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles++; - - eNB->preamble_list_br[ind].preamble_rel8.timing_advance = max_preamble_delay[ind];// - eNB->preamble_list_br[ind].preamble_rel8.preamble = max_preamble[ind]; - // note: fid is implicitly 0 here, this is the rule for eMTC RA-RNTI from 36.321, Section 5.1.4 - eNB->preamble_list_br[ind].preamble_rel8.rnti = 1+subframe+(eNB->prach_vars_br.first_frame[ce_level]%40); - eNB->preamble_list_br[ind].instance_length = 0; //don't know exactly what this is - eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type = 1+ce_level; // CE Level - LOG_D(PHY,"Filling NFAPI indication for RACH %d CELevel %d (mask %x) : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", - ind, - ce_level, - prach_mask, - eNB->preamble_list_br[ind].preamble_rel8.timing_advance, - eNB->preamble_list_br[ind].preamble_rel8.preamble, - eNB->preamble_list_br[ind].preamble_rel8.rnti, - eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type); - } - /* - ind++; - } - } */// ce_level - } - } - else -#endif - - { - if ((eNB->prach_energy_counter == 100) && - (max_preamble_energy[0] > eNB->measurements.prach_I0+100)) { - - LOG_E(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", - eNB->Mod_id, - eNB->CC_id, - frame, - subframe, - max_preamble[0], - max_preamble_energy[0]/10, - max_preamble_energy[0]%10, - max_preamble_delay[0]); - - T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), - T_INT(max_preamble[0]), T_INT(max_preamble_energy[0]), T_INT(max_preamble_delay[0])); - - pthread_mutex_lock(&eNB->UL_INFO_mutex); - - eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 1; - eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = &eNB->preamble_list[0]; - eNB->UL_INFO.rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; - eNB->UL_INFO.rach_ind.header.message_id = NFAPI_RACH_INDICATION; - eNB->UL_INFO.rach_ind.sfn_sf = frame<<4 | subframe; - - eNB->preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; - eNB->preamble_list[0].preamble_rel8.timing_advance = max_preamble_delay[0]; - eNB->preamble_list[0].preamble_rel8.preamble = max_preamble[0]; - eNB->preamble_list[0].preamble_rel8.rnti = 1+subframe; // note: fid is implicitly 0 here - eNB->preamble_list[0].preamble_rel13.rach_resource_type = 0; - eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is - - if (nfapi_mode == 1) // If NFAPI PNF then we need to send the message to the VNF - { - LOG_E(PHY,"\n\n\n\nDJP - this needs to be sent to VNF **********************************************\n\n\n\n"); - LOG_E(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", - NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), - eNB->preamble_list[0].preamble_rel8.timing_advance, - eNB->preamble_list[0].preamble_rel8.preamble, - eNB->preamble_list[0].preamble_rel8.rnti, - eNB->preamble_list[0].preamble_rel13.rach_resource_type); - - oai_nfapi_rach_ind(&eNB->UL_INFO.rach_ind); - - eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 0; - } - - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - - } // max_preamble_energy > prach_I0 + 100 - else { - eNB->measurements.prach_I0 = ((eNB->measurements.prach_I0*900)>>10) + ((max_preamble_energy[0]*124)>>10); - if (frame==0) LOG_I(PHY,"prach_I0 = %d.%d dB\n",eNB->measurements.prach_I0/10,eNB->measurements.prach_I0%10); - if (eNB->prach_energy_counter < 100) eNB->prach_energy_counter++; - } - } // else br_flag - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0); -} - void srs_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; @@ -879,10 +721,10 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) if (uci->type == SR) { if (SR_payload == 1) { fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); - return; + continue; } else { - return; + continue; } } case HARQ: @@ -1323,8 +1165,9 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) for (i=0; i<NUMBER_OF_UE_MAX; i++) { ulsch = eNB->ulsch[i]; ulsch_harq = ulsch->harq_processes[harq_pid]; - if (ulsch->rnti>0) LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x ulsch_harq[status:%d frame:%d subframe:%d handled:%d]\n", - i, harq_pid, frame,subframe,harq_pid,i,ulsch->rnti, + + if (ulsch->rnti>0) LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n", + i, harq_pid, frame,subframe,i,ulsch->rnti, ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); if ((ulsch) && @@ -1342,7 +1185,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); } - //LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n", eNB->Mod_id, frame, subframe, i); + + LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n", eNB->Mod_id, frame, subframe, i); nPRS = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]; @@ -1373,8 +1217,6 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) stop_meas(&eNB->ulsch_demodulation_stats); - clock_gettime(CLOCK_MONOTONIC,&t_decode); - start_meas(&eNB->ulsch_decoding_stats); ret = ulsch_decoding(eNB,proc, @@ -1454,12 +1296,9 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) ulsch_harq->handled = 1; } // ulsch in error else { - clock_gettime(CLOCK_MONOTONIC,&t_crc); fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC - clock_gettime(CLOCK_MONOTONIC,&t_rx_ind); fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC - clock_gettime(CLOCK_MONOTONIC,&t_rx_ind_b); ulsch_harq->status = SCH_IDLE; ulsch->harq_mask &= ~(1 << harq_pid); @@ -1520,16 +1359,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) LOG_W(PHY,"Removing stale ULSCH config for UE %x harq_pid %d (harq_mask is now 0x%2.2x)\n", ulsch->rnti, harq_pid, ulsch->harq_mask); } - } // for (i=0; i<NUMBER_OF_UE_MAX; i++) { - clock_gettime(CLOCK_MONOTONIC,&t_end); - if (0)LOG_E(PHY,"%s() TIMING:decode:%ld.%09ld crc:%ld.%09ld rx_ind:%ld.%09ld-%ld.%09ld harq:%ld.%09ld-%ld.%09ld end:%ld.%09ld\n", __FUNCTION__, - t_decode.tv_sec, t_decode.tv_nsec, - t_crc.tv_sec, t_crc.tv_nsec, - t_rx_ind.tv_sec, t_rx_ind.tv_nsec, - t_rx_ind_b.tv_sec, t_rx_ind_b.tv_nsec, - t_harq_a.tv_sec, t_harq_a.tv_nsec, - t_harq_b.tv_sec, t_harq_b.tv_nsec, - t_end.tv_sec, t_end.tv_nsec); + + } // for (i=0; i<NUMBER_OF_UE_MAX; i++) } extern int oai_exit; @@ -1619,11 +1450,13 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; - LOG_D(PHY,"[PUSCH %d] Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", - harq_pid,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, + + LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", + harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, timing_advance_update); eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; + eNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | subframe; pthread_mutex_unlock(&eNB->UL_INFO_mutex); } @@ -1739,7 +1572,9 @@ void fill_ulsch_cqi_indication(PHY_VARS_eNB *eNB,uint16_t frame,uint8_t subframe pdu->ul_cqi_information.channel = 1; // PUSCH memcpy((void*)raw_pdu->pdu,ulsch_harq->o,pdu->cqi_indication_rel9.length); eNB->UL_INFO.cqi_ind.number_of_cqis++; - LOG_E(PHY,"eNB->UL_INFO.cqi_ind.number_of_cqis:%d\n", eNB->UL_INFO.cqi_ind.number_of_cqis); + + LOG_D(PHY,"eNB->UL_INFO.cqi_ind.number_of_cqis:%d\n", eNB->UL_INFO.cqi_ind.number_of_cqis); + pthread_mutex_unlock(&eNB->UL_INFO_mutex); @@ -1748,7 +1583,15 @@ void fill_ulsch_cqi_indication(PHY_VARS_eNB *eNB,uint16_t frame,uint8_t subframe void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq,uint16_t rnti, int frame,int subframe,int bundling) { int UE_id = find_dlsch(rnti,eNB,SEARCH_EXIST); - AssertFatal(UE_id>=0,"UE_id doesn't exist\n"); + //AssertFatal(UE_id>=0,"UE_id doesn't exist\n"); + + if (UE_id < 0) + { + LOG_E(PHY,"%s(eNB, ulsch_harq, rnti:%04x, frame:%d, subframe:%d, bundling:%d) harq_pdus:%d - Could not find rnti - abort fill of ulsch harq ind\n", __FUNCTION__, rnti, frame, subframe, bundling,eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); + return; + } + + LOG_D(PHY,"%s(eNB, ulsch_harq, rnti:%04x, frame:%d, subframe:%d, bundling:%d) harq_pdus:%d O_ACK:%d\n", __FUNCTION__, rnti, frame, subframe, bundling,eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs,ulsch_harq->O_ACK); LOG_I(PHY,"%s(eNB, ulsch_harq, rnti:%04x, frame:%d, subframe:%d, bundling:%d) harq_pdus:%d\n", __FUNCTION__, rnti, frame, subframe, bundling,eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); @@ -1760,6 +1603,9 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, eNB->UL_INFO.harq_ind.header.message_id = NFAPI_HARQ_INDICATION; eNB->UL_INFO.harq_ind.sfn_sf = frame<<4|subframe; + + eNB->UL_INFO.harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; @@ -1827,7 +1673,12 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, uint16_t tdd_multiplexing_mask) { int UE_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST); - AssertFatal(UE_id>=0,"UE_id doesn't exist rnti:%x\n", uci->rnti); + + //AssertFatal(UE_id>=0,"UE_id doesn't exist rnti:%x\n", uci->rnti); + if (UE_id < 0) { + LOG_E(PHY,"SFN/SF:%04d%d Unable to find rnti:%x do not send HARQ\n", frame, subframe, uci->rnti); + return; + } pthread_mutex_lock(&eNB->UL_INFO_mutex); @@ -1994,7 +1845,8 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++; - LOG_E(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); + LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); + pthread_mutex_unlock(&eNB->UL_INFO_mutex); } @@ -2013,7 +1865,8 @@ void fill_crc_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; - pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; + + pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; pdu->crc_indication_rel8.crc_flag = crc_flag; eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs++; @@ -2049,6 +1902,11 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const eNB->rb_mask_ul[2]=0; eNB->rb_mask_ul[3]=0; + + // Fix me here, these should be locked + eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus = 0; + eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs = 0; + // Call SRS first since all others depend on presence of SRS or lack thereof srs_procedures(eNB,proc); @@ -2064,8 +1922,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const uci_procedures(eNB,proc); - if (nfapi_mode == 0 || nfapi_mode == 1) // If PNF or monolithic - { + if (nfapi_mode == 0 || nfapi_mode == 1) { // If PNF or monolithic pusch_procedures(eNB,proc); } @@ -2077,7 +1934,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const #endif int min_I0=1000,max_I0=0; - if ((frame==0) && (subframe==6)) { + if ((frame==0) && (subframe==4)) { for (int i=0;i<eNB->frame_parms.N_RB_UL;i++) { if (i==(eNB->frame_parms.N_RB_UL>>1) - 1) i+=2; diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 71b94499997a030c3382e6fb5a6220ae33c9b6f4..95efbd6d71fd42376a23ff054ccbbcbdc6daf70c 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -51,10 +51,6 @@ #include "LAYER2/MAC/defs.h" #include "UTIL/LOG/log.h" -#ifdef EMOS -fifo_dump_emos_UE emos_dump_UE; -#endif - #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" @@ -68,6 +64,8 @@ fifo_dump_emos_UE emos_dump_UE; #include "T.h" +#include "PHY/TOOLS/defs.h" + #define DLSCH_RB_ALLOC 0x1fbf // skip DC RB (total 23/25 RBs) #define DLSCH_RB_ALLOC_12 0x0aaa // skip DC RB (total 23/25 RBs) @@ -83,6 +81,7 @@ extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; #endif +#define DEBUG_UE_TRACE 1 void dump_dlsch(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid) { @@ -1194,38 +1193,6 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, } -#ifdef EMOS -/* - void phy_procedures_emos_UE_TX(uint8_t next_slot,uint8_t eNB_id) { - uint8_t harq_pid; - - - if (next_slot%2==0) { - // get harq_pid from subframe relationship - harq_pid = subframe2harq_pid(&ue->frame_parms,ue->frame,(next_slot>>1)); - if (harq_pid==255) { - LOG_E(PHY,"[UE%d] Frame %d : FATAL ERROR: illegal harq_pid, returning\n", - 0,ue->frame); - return; - } - - if (ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) { - emos_dump_UE.uci_cnt[next_slot>>1] = 1; - memcpy(emos_dump_UE.UCI_data[0][next_slot>>1].o,ulsch[eNB_id]->o,MAX_CQI_BITS*sizeof(char)); - emos_dump_UE.UCI_data[0][next_slot>>1].O = ulsch[eNB_id]->O; - memcpy(emos_dump_UE.UCI_data[0][next_slot>>1].o_RI,ulsch[eNB_id]->o_RI,2*sizeof(char)); - emos_dump_UE.UCI_data[0][next_slot>>1].O_RI = ulsch[eNB_id]->O_RI; - memcpy(emos_dump_UE.UCI_data[0][next_slot>>1].o_ACK,ulsch[eNB_id]->o_ACK,4*sizeof(char)); - emos_dump_UE.UCI_data[0][next_slot>>1].O_ACK = ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK; - } - else { - emos_dump_UE.uci_cnt[next_slot>>1] = 0; - } - } - } -*/ -#endif - void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empty_subframe) { int aa; @@ -1425,9 +1392,6 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->prach_cnt=0; #ifdef SMBV ue->prach_resources[eNB_id]->ra_PreambleIndex = 19; -#endif -#ifdef OAI_EMU - ue->prach_PreambleIndex=ue->prach_resources[eNB_id]->ra_PreambleIndex; #endif LOG_I(PHY,"mode %d\n",mode); @@ -1482,39 +1446,34 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->tx_power_dBm[subframe_tx], dB_fixed(prach_power), ue->prach_vars[eNB_id]->amp); - } else { - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_flag=1; - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_id=ue->prach_resources[eNB_id]->ra_PreambleIndex; - } - if (ue->mac_enabled==1){ - // Panos: Substitute with fill_Tx_indication(ue->Mod_id, ue->CC_id, frame_tx, eNB_id, UE_MAC_Tx_IND_Msg1_TYPE) - Msg1_transmitted(ue->Mod_id, - ue->CC_id, - frame_tx, - eNB_id); - } - - LOG_I(PHY,"[UE %d][RAPROC] Frame %d, subframe %d: Generating PRACH (eNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB), l3msg \n", - ue->Mod_id,frame_tx,subframe_tx,eNB_id, - ue->prach_resources[eNB_id]->ra_PreambleIndex, - ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_PL(ue->Mod_id,ue->CC_id,eNB_id), - get_PL(ue->Mod_id,ue->CC_id,eNB_id)); - - - - // if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue - if (mode == calib_prach_tx) - ue->prach_resources[eNB_id]=NULL; - - LOG_D(PHY,"[UE %d] frame %d subframe %d : generate_prach %d, prach_cnt %d\n", - ue->Mod_id,frame_tx,subframe_tx,ue->generate_prach,ue->prach_cnt); + if (ue->mac_enabled==1){ + Msg1_transmitted(ue->Mod_id, + ue->CC_id, + frame_tx, + eNB_id); + } + + LOG_I(PHY,"[UE %d][RAPROC] Frame %d, subframe %d: Generating PRACH (eNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB), l3msg \n", + ue->Mod_id,frame_tx,subframe_tx,eNB_id, + ue->prach_resources[eNB_id]->ra_PreambleIndex, + ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_PL(ue->Mod_id,ue->CC_id,eNB_id), + get_PL(ue->Mod_id,ue->CC_id,eNB_id)); + + + + // if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue + if (mode == calib_prach_tx) + ue->prach_resources[eNB_id]=NULL; - ue->prach_cnt++; + LOG_D(PHY,"[UE %d] frame %d subframe %d : generate_prach %d, prach_cnt %d\n", + ue->Mod_id,frame_tx,subframe_tx,ue->generate_prach,ue->prach_cnt); - if (ue->prach_cnt==3) - ue->generate_prach=0; + ue->prach_cnt++; + if (ue->prach_cnt==3) + ue->generate_prach=0; + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT); } @@ -1546,18 +1505,21 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB frame_tx, subframe_tx); + LOG_D(PHY,"Frame %d, Subframe %d : ue_uespec_procedures, harq_pid %d => subframe_scheduling %d\n", + frame_tx,subframe_tx,harq_pid, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag); if (ue->mac_enabled == 1) { - if ((ue->ulsch_Msg3_active[eNB_id] == 1) && - (ue->ulsch_Msg3_frame[eNB_id] == frame_tx) && - (ue->ulsch_Msg3_subframe[eNB_id] == subframe_tx)) { // Initial Transmission of Msg3 + if ((ue->ulsch_Msg3_active[eNB_id] == 1) && + (ue->ulsch_Msg3_frame[eNB_id] == frame_tx) && + (ue->ulsch_Msg3_subframe[eNB_id] == subframe_tx)) { // Initial Transmission of Msg3 ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) - generate_ue_ulsch_params_from_rar(ue, - proc, - eNB_id); + generate_ue_ulsch_params_from_rar(ue, + proc, + eNB_id); ue->ulsch[eNB_id]->power_offset = 14; LOG_D(PHY,"[UE %d][RAPROC] Frame %d: Setting Msg3_flag in subframe %d, for harq_pid %d\n", @@ -1700,7 +1662,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB #ifdef UE_DEBUG_TRACE - LOG_I(PHY, + LOG_D(PHY, "[UE %d][PUSCH %d] AbsSubframe %d.%d Generating PUSCH : first_rb %d, nb_rb %d, round %d, mcs %d, rv %d, " "cyclic_shift %d (cyclic_shift_common %d,n_DMRS2 %d,n_PRS %d), ACK (%d,%d), O_ACK %d, ack_status_cw0 %d ack_status_cw1 %d bundling %d, Nbundled %d, CQI %d, RI %d\n", Mod_id,harq_pid,frame_tx%1024,subframe_tx, @@ -1759,7 +1721,6 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB stop_meas(&ue->phy_proc_tx); printf("------FULL TX PROC : %5.2f ------\n",ue->phy_proc_tx.p_time/(cpuf*1000.0)); #endif - return; #if UE_TIMING_TRACE stop_meas(&ue->ulsch_encoding_stats); @@ -1837,12 +1798,6 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB } } -#ifdef PHY_ABSTRACTION - else { - ulsch_encoding_emul(ulsch_input_buffer,ue,eNB_id,proc->subframe_rx,harq_pid,0); - } - -#endif #if UE_TIMING_TRACE stop_meas(&ue->ulsch_encoding_stats); #endif @@ -1871,7 +1826,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_PL(Mod_id,0,eNB_id)),T_INT(nb_rb)); #ifdef UE_DEBUG_TRACE - LOG_I(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", + LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", Mod_id,harq_pid,frame_tx%1024,subframe_tx,ue->tx_power_dBm[subframe_tx],ue->tx_power_max_dBm, tx_amp); #endif #if UE_TIMING_TRACE @@ -1896,6 +1851,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB #if UE_TIMING_TRACE stop_meas(&ue->ulsch_modulation_stats); #endif + } if (abstraction_flag==1) { @@ -2232,20 +2188,20 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin #ifdef UE_DEBUG_TRACE if(format == pucch_format1) - { - LOG_I(PHY,"[UE %d][SR %x] AbsSubframe %d.%d Generating PUCCH 1 (SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, - frame_tx%1024, subframe_tx, - frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, - isShortenPucch, - ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, - Po_PUCCH); + { + LOG_D(PHY,"[UE %d][SR %x] AbsSubframe %d.%d Generating PUCCH 1 (SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", + Mod_id, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, + frame_tx%1024, subframe_tx, + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, + isShortenPucch, + ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, + Po_PUCCH); } else { if (SR_payload>0) { - LOG_I(PHY,"[UE %d][SR %x] AbsSubFrame %d.%d Generating PUCCH %s payload %d,%d (with SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d, amp %d\n", + LOG_D(PHY,"[UE %d][SR %x] AbsSubFrame %d.%d Generating PUCCH %s payload %d,%d (with SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d, amp %d\n", Mod_id, ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, frame_tx % 1024, subframe_tx, @@ -2258,7 +2214,7 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin Po_PUCCH, tx_amp); } else { - LOG_I(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d rx_offset_diff: %d, Generating PUCCH %s, an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", + LOG_D(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d rx_offset_diff: %d, Generating PUCCH %s, an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", Mod_id, ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, frame_tx%1024, subframe_tx,ue->rx_offset_diff, @@ -2325,7 +2281,7 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch),T_INT(get_PL(ue->Mod_id,ue->CC_id,eNB_id))); #endif #ifdef UE_DEBUG_TRACE - LOG_I(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2 (RI or CQI), Po_PUCCH %d, isShortenPucch %d, amp %d\n", + LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2 (RI or CQI), Po_PUCCH %d, isShortenPucch %d, amp %d\n", Mod_id, ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, frame_tx%1024, subframe_tx, @@ -2414,10 +2370,6 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui start_meas(&ue->phy_proc_tx); #endif -#ifdef EMOS - //phy_procedures_emos_UE_TX(next_slot); -#endif - ue->tx_power_dBm[subframe_tx]=-127; @@ -2436,6 +2388,8 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui ue_ulsch_uespec_procedures(ue,proc,eNB_id,abstraction_flag); + LOG_D(PHY,"ULPOWERS After ulsch_uespec_procedures : ue->tx_power_dBm[%d]=%d, NPRB %d\n", + subframe_tx,ue->tx_power_dBm[subframe_tx],ue->tx_total_RE[subframe_tx]); } if (ue->UE_mode[eNB_id] == PUSCH) { @@ -2698,11 +2652,6 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin ue->UE_mode[eNB_id]==NOT_SYNCHED ? 1 : 0); } -#ifdef EMOS - //emos_dump_UE.frame_tx = frame_tx; - //emos_dump_UE.mimo_mode = ue->pbch_vars[eNB_id]->decoded_output[1]; -#endif - if (first_run) { first_run = 0; @@ -3009,24 +2958,24 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint // we received a CRNTI, so we're in PUSCH if (ue->UE_mode[eNB_id] != PUSCH) { #ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d] Frame %d, subframe %d: Received DCI with CRNTI %x => Mode PUSCH\n",ue->Mod_id,frame_rx,subframe_rx,ue->pdcch_vars[subframe_rx&1][eNB_id]->crnti); + LOG_D(PHY,"[UE %d] Frame %d, subframe %d: Received DCI with CRNTI %x => Mode PUSCH\n",ue->Mod_id,frame_rx,subframe_rx,ue->pdcch_vars[subframe_rx&1][eNB_id]->crnti); #endif //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); ue->UE_mode[eNB_id] = PUSCH; - - } else { + } + } else { LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Problem in DCI!\n",ue->Mod_id,frame_rx,subframe_rx); dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); } - } + } else if ((dci_alloc_rx[i].rnti == SI_RNTI) && ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { #ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); + LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); #endif if (generate_ue_dlsch_params_from_dci(frame_rx, @@ -3047,18 +2996,17 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint ue->dlsch_SI_received[eNB_id]++; - LOG_I(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); + LOG_D(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); } } - } else if ((dci_alloc_rx[i].rnti == P_RNTI) && ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { #ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); + LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); #endif @@ -3090,7 +3038,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (dci_alloc_rx[i].format == format1A)) { #ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d][RAPROC] subframe %d: Found RA rnti %x, format 1A, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,i); + LOG_D(PHY,"[UE %d][RAPROC] subframe %d: Found RA rnti %x, format 1A, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,i); #endif @@ -3156,7 +3104,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS)); #endif #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d] Generate UE ULSCH C_RNTI format 0 (subframe %d)\n",ue->Mod_id,subframe_rx); + LOG_D(PHY,"[UE %d] Generate UE ULSCH C_RNTI format 0 (subframe %d)\n",ue->Mod_id,subframe_rx); #endif } @@ -3199,7 +3147,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint else { #ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d] frame %d, subframe %d: received DCI %d with RNTI=%x (C-RNTI:%x, CBA_RNTI %x) and format %d!\n",ue->Mod_id,frame_rx,subframe_rx,i,dci_alloc_rx[i].rnti, + LOG_D(PHY,"[UE %d] frame %d, subframe %d: received DCI %d with RNTI=%x (C-RNTI:%x, CBA_RNTI %x) and format %d!\n",ue->Mod_id,frame_rx,subframe_rx,i,dci_alloc_rx[i].rnti, ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, ue->ulsch[eNB_id]->cba_rnti[0], dci_alloc_rx[i].format); @@ -3892,7 +3840,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, if(is_cw1_active) { if (ret1 == (1+dlsch0->max_turbo_iterations)) { - LOG_I(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d DLSCH CW1 in error (rv %d,mcs %d,TBS %d)\n", + LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d DLSCH CW1 in error (rv %d,mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, @@ -3900,7 +3848,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, dlsch0->harq_processes[harq_pid]->TBS); } else { - LOG_I(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: Received DLSCH CW1 (rv %d,mcs %d,TBS %d)\n", + LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: Received DLSCH CW1 (rv %d,mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, @@ -4282,7 +4230,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *pr // start timers #ifdef UE_DEBUG_TRACE - LOG_I(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); + LOG_D(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); #endif #if UE_TIMING_TRACE @@ -4756,11 +4704,6 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *pr } -#ifdef EMOS - phy_procedures_emos_UE_RX(ue,slot,eNB_id); -#endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE @@ -5245,11 +5188,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0)); #endif -#ifdef EMOS - phy_procedures_emos_UE_RX(ue,slot,eNB_id); -#endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c new file mode 100644 index 0000000000000000000000000000000000000000..d8c65850744d19ae2b99ee44d4be703d81cb07e2 --- /dev/null +++ b/openair1/SCHED/prach_procedures.c @@ -0,0 +1,226 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file phy_procedures_lte_eNB.c + * \brief Implementation of eNB procedures from 36.213 LTE specifications + * \author R. Knopp, F. Kaltenberger, N. Nikaein, X. Foukas + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,navid.nikaein@eurecom.fr, x.foukas@sms.ed.ac.uk + * \note + * \warning + */ + +#include "PHY/defs.h" +#include "PHY/extern.h" +#include "SCHED/defs.h" +#include "SCHED/extern.h" +#include "nfapi_interface.h" +#include "fapi_l1.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +#include "T.h" + +#include "assertions.h" +#include "msc.h" + +#include <time.h> + +#if defined(ENABLE_ITTI) +# include "intertask_interface.h" +#endif + +extern uint32_t nfapi_mode; + +void prach_procedures(PHY_VARS_eNB *eNB, +#ifdef Rel14 + int br_flag +#endif + ) { + uint16_t max_preamble[4],max_preamble_energy[4],max_preamble_delay[4]; + uint16_t i; + int frame,subframe; + +#ifdef Rel14 + if (br_flag==1) { + subframe = eNB->proc.subframe_prach_br; + frame = eNB->proc.frame_prach_br; + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles=0; + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + } + else +#endif + { + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles=0; + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + subframe = eNB->proc.subframe_prach; + frame = eNB->proc.frame_prach; + } + RU_t *ru; + int aa=0; + int ru_aa; + + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,1); + + + + for (i=0;i<eNB->num_RU;i++) { + ru=eNB->RU_list[i]; + for (ru_aa=0,aa=0;ru_aa<ru->nb_rx;ru_aa++,aa++) { + eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[i]->prach_rxsigF[ru_aa]; +#ifdef Rel14 + int ce_level; + + if (br_flag==1) + for (ce_level=0;ce_level<4;ce_level++) eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[i]->prach_rxsigF_br[ce_level][ru_aa]; +#endif + } + } + + rx_prach(eNB, + eNB->RU_list[0], + &max_preamble[0], + &max_preamble_energy[0], + &max_preamble_delay[0], + frame, + 0 +#ifdef Rel14 + ,br_flag +#endif + ); + + LOG_D(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", + frame,subframe, + max_preamble[0], + max_preamble_energy[0]/10, + max_preamble_delay[0], + eNB->prach_energy_counter); + +#ifdef Rel14 + if (br_flag==1) { + + int prach_mask; + + prach_mask = is_prach_subframe(&eNB->frame_parms,eNB->proc.frame_prach_br,eNB->proc.subframe_prach_br); + + eNB->UL_INFO.rach_ind_br.rach_indication_body.preamble_list = eNB->preamble_list_br; + int ind=0; + int ce_level=0; + /* Save for later, it doesn't work + for (int ind=0,ce_level=0;ce_level<4;ce_level++) { + + if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[ce_level]==1)&& + (prach_mask&(1<<(1+ce_level)) > 0) && // prach is active and CE level has finished its repetitions + (eNB->prach_vars_br.repetition_number[ce_level]== + eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level])) { + */ + if (eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0]==1){ + if ((eNB->prach_energy_counter == 100) && + (max_preamble_energy[0] > eNB->measurements.prach_I0 + 100)) { + eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles++; + + eNB->preamble_list_br[ind].preamble_rel8.timing_advance = max_preamble_delay[ind];// + eNB->preamble_list_br[ind].preamble_rel8.preamble = max_preamble[ind]; + // note: fid is implicitly 0 here, this is the rule for eMTC RA-RNTI from 36.321, Section 5.1.4 + eNB->preamble_list_br[ind].preamble_rel8.rnti = 1+subframe+(eNB->prach_vars_br.first_frame[ce_level]%40); + eNB->preamble_list_br[ind].instance_length = 0; //don't know exactly what this is + eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type = 1+ce_level; // CE Level + LOG_D(PHY,"Filling NFAPI indication for RACH %d CELevel %d (mask %x) : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + ind, + ce_level, + prach_mask, + eNB->preamble_list_br[ind].preamble_rel8.timing_advance, + eNB->preamble_list_br[ind].preamble_rel8.preamble, + eNB->preamble_list_br[ind].preamble_rel8.rnti, + eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type); + } + /* + ind++; + } + } */// ce_level + } + } + else +#endif + + { + if ((eNB->prach_energy_counter == 100) && + (max_preamble_energy[0] > eNB->measurements.prach_I0+100)) { + + LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", + eNB->Mod_id, + eNB->CC_id, + frame, + subframe, + max_preamble[0], + max_preamble_energy[0]/10, + max_preamble_energy[0]%10, + max_preamble_delay[0]); + + T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), + T_INT(max_preamble[0]), T_INT(max_preamble_energy[0]), T_INT(max_preamble_delay[0])); + + pthread_mutex_lock(&eNB->UL_INFO_mutex); + + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 1; + eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = &eNB->preamble_list[0]; + eNB->UL_INFO.rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + eNB->UL_INFO.rach_ind.header.message_id = NFAPI_RACH_INDICATION; + eNB->UL_INFO.rach_ind.sfn_sf = frame<<4 | subframe; + + eNB->preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + eNB->preamble_list[0].preamble_rel8.timing_advance = max_preamble_delay[0]; + eNB->preamble_list[0].preamble_rel8.preamble = max_preamble[0]; + eNB->preamble_list[0].preamble_rel8.rnti = 1+subframe; // note: fid is implicitly 0 here + eNB->preamble_list[0].preamble_rel13.rach_resource_type = 0; + eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is + + if (nfapi_mode == 1) { // If NFAPI PNF then we need to send the message to the VNF + + LOG_D(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), + eNB->preamble_list[0].preamble_rel8.timing_advance, + eNB->preamble_list[0].preamble_rel8.preamble, + eNB->preamble_list[0].preamble_rel8.rnti, + eNB->preamble_list[0].preamble_rel13.rach_resource_type); + + oai_nfapi_rach_ind(&eNB->UL_INFO.rach_ind); + + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 0; + } + + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + + } // max_preamble_energy > prach_I0 + 100 + else { + eNB->measurements.prach_I0 = ((eNB->measurements.prach_I0*900)>>10) + ((max_preamble_energy[0]*124)>>10); + if (frame==0) LOG_I(PHY,"prach_I0 = %d.%d dB\n",eNB->measurements.prach_I0/10,eNB->measurements.prach_I0%10); + if (eNB->prach_energy_counter < 100) eNB->prach_energy_counter++; + } + } // else br_flag + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0); +} diff --git a/openair1/SCHED/rt_compat.h b/openair1/SCHED/rt_compat.h deleted file mode 100644 index 35e99098fa37473e96dfff4c2c8b11029d1f7a97..0000000000000000000000000000000000000000 --- a/openair1/SCHED/rt_compat.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* Header file for making PLATON work on both RTLinux and RTAI using pthreads -* Copyright Frank Wartena, 2004 -* Version: 0.1 January 28th, 2004 ## First version for scheduling test -* 0.2 February 20th, 2004 ## All PLATON functions added -* It is mostly a conversion from RTLinux to RTAI, because PLATON was written -* for RTLinux. -* Not all necessary conversions can be done in this header file, other -* adjustments in the code are also necessary. -*/ - -#ifndef _RT_COMPAT_H_ -#define _RT_COMPAT_H_ - -#ifdef RTAI_ENABLED -//the conversions from RTLinux to RTAI - -//variable for containing times -#define hrtime_t RTIME - -//function for making a thread periodic -#define pthread_make_periodic_np(x,y,z) rt_task_make_periodic(x,rt_get_time(),nano2count(z)) - -//function for printing to the kernel log -#define rtl_printf printk - -//function for determining the current cpu -#define rtl_getcpuid hard_cpu_id - -//function for initialising a mutex -#define pthread_mutex_init pthread_mutex_init_rt - -//function for initialising a mutex attribute -#define pthread_mutexattr_init pthread_mutexattr_init_rt - -//function for setting a mutex protocol, does not exist in RTAI -#define pthread_mutexattr_setprotocol(x,y); - -//function for locking a mutex -#define pthread_mutex_lock pthread_mutex_lock_rt - -//function for unlocking a mutex -#define pthread_mutex_unlock pthread_mutex_unlock_rt - -//function for destroying a mutex -#define pthread_mutex_destroy pthread_mutex_destroy_rt - -//function for getting the current time -#define clock_gethrtime(x) rt_get_time_ns() -#define gethrtime rt_get_time_ns - -//function for initialising a condition -#define pthread_cond_init pthread_cond_init_rt - -//function for waiting on a condition -#define pthread_cond_wait pthread_cond_wait_rt - -//function for signalling a condition -#define pthread_cond_signal pthread_cond_signal_rt - -//function for destroying a condition -#define pthread_cond_destroy pthread_cond_destroy_rt - -//function for waking up a thread -#define pthread_wakeup_np rt_task_resume - -//function for getting the current thread -#define pthread_self rt_whoami - -//function for initialising an attribute -#define pthread_attr_init pthread_attr_init_rt - -//function for setting a schedparam -#define pthread_attr_setschedparam pthread_attr_setschedparam_rt - -//funcion for setting a schedpolicy -#define pthread_attr_setschedpolicy pthread_attr_setschedpolicy_rt - -//function for creating a thread -#define pthread_create pthread_create_rt - -//function for cancelling a thread -#define pthread_cancel pthread_cancel_rt - -//function for deleting a thread, in RTAI both by calling cancel -#define pthread_delete_np pthread_cancel_rt - -//testing if a cpuid exists -#define rtl_cpu_exists(x) x<NR_RT_CPUS - -//function for flushing a fifo does not exist in RTAI -#define rtf_flush(x); - -//function for setting the stacksize -#define pthread_attr_setstacksize pthread_attr_setstacksize_rt - -//function for sleeping the indicated amount in nanoseconds -//#define rtl_delay(x) rt_sleep(nano2count(x)) -//#define udelay(x) rt_sleep(nano2count(1000*x)) -//#define usleep(x) rt_sleep(nano2count(1000*x)) - -#define pthread_exit pthread_exit_rt - -//function for indicating that a thread uses the FPU -#define pthread_setfp_np rt_task_use_fpu - -//function for freeing a soft irq -#define rtl_free_soft_irq(x) rt_free_linux_irq(x,NULL) - -//function for triggering a soft irq -#define rtl_global_pend_irq rt_pend_linux_irq - -//function for setting the thread scheduling, does not exist in RTAI -#define pthread_setschedparam(x,y,z); - -#endif /* RTAI_ENABLED */ - -#endif /* _RT_COMPAT_H_ */ diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index ce49d72c68cf66f94b09082437db86bf2daf1639..dcab55d66f6686eea679b871150bbeb4c1d942a8 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -38,10 +38,6 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif - #include "LAYER2/MAC/extern.h" #include "LAYER2/MAC/defs.h" #include "UTIL/LOG/log.h" @@ -369,16 +365,6 @@ void feptx_prec(RU_t *ru) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC , 1); - //LOG_D(PHY, "%s() subframe:%d\n", __FUNCTION__, subframe); - - if (0) LOG_E(PHY,"%s() run->nb_tx:%u subframe:%u fp->symbols_per_tti:%u fp->ofdm_symbol_size:%u symbols:(%d, %d), (%d,%d)\n", - __FUNCTION__, ru->nb_tx, subframe, fp->symbols_per_tti, fp->ofdm_symbol_size, - ((short*)&eNB->common_vars.txdataF[0][1])[0], - ((short*)&eNB->common_vars.txdataF[0][1])[1], - ((short*)&eNB->common_vars.txdataF[0][2])[0], - ((short*)&eNB->common_vars.txdataF[0][2])[1] - ); - for (aa=0;aa<ru->nb_tx;aa++) memcpy((void*)ru->common.txdataF_BF[aa], (void*)&eNB->common_vars.txdataF[aa][subframe*fp->symbols_per_tti*fp->ofdm_symbol_size], diff --git a/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c b/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c index 01bc8f490106736c9615187c02e397b21c997a6e..e96db24521f8772a19ce1a7e0d202219604c42dd 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c @@ -38,10 +38,7 @@ #include "UTIL/OCG/OCG_extern.h" #include "UTIL/LOG/log.h" -#ifdef USER_MODE -# include "multicast_link.h" -# include "pgm_link.h" -#endif +#include "multicast_link.h" char rx_bufferP[BYPASS_RX_BUFFER_SIZE]; unsigned int num_bytesP = 0; @@ -51,10 +48,6 @@ static unsigned int byte_tx_count; unsigned int Master_list_rx; static uint64_t seq_num_tx = 0; -#if defined(ENABLE_PGM_TRANSPORT) -extern unsigned int pgm_would_block; -#endif - mapping transport_names[] = { {"WAIT PM TRANSPORT INFO", EMU_TRANSPORT_INFO_WAIT_PM}, {"WAIT SM TRANSPORT INFO", EMU_TRANSPORT_INFO_WAIT_SM}, @@ -62,9 +55,6 @@ mapping transport_names[] = { {"ENB_TRANSPORT INFO", EMU_TRANSPORT_INFO_ENB}, {"UE TRANSPORT INFO", EMU_TRANSPORT_INFO_UE}, {"RELEASE TRANSPORT INFO", EMU_TRANSPORT_INFO_RELEASE}, -#if defined(ENABLE_PGM_TRANSPORT) - {"NACK TRANSPORT INFO", EMU_TRANSPORT_NACK}, -#endif {NULL, -1} }; @@ -79,9 +69,6 @@ void init_bypass (void) pthread_mutex_init (&emul_low_mutex, NULL); pthread_cond_init (&emul_low_cond, NULL); emul_low_mutex_var = 1; -#endif -#if defined(ENABLE_PGM_TRANSPORT) - pgm_oai_init(oai_emulation.info.multicast_ifname); #endif bypass_init (emul_tx_handler, emul_rx_handler); } @@ -90,10 +77,8 @@ void init_bypass (void) void bypass_init (tx_handler_t tx_handlerP, rx_handler_t rx_handlerP) { /***************************************************************************/ -#if defined(USER_MODE) multicast_link_start (bypass_rx_handler, oai_emulation.info.multicast_group, oai_emulation.info.multicast_ifname); -#endif //USER_MODE tx_handler = tx_handlerP; rx_handler = rx_handlerP; Master_list_rx=0; @@ -322,20 +307,12 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot, frame, next_slot, is_master); #if defined(ENABLE_NEW_MULTICAST) -# if defined(ENABLE_PGM_TRANSPORT) - num_bytesP = pgm_recv_msg(oai_emulation.info.multicast_group, - (uint8_t *)&rx_bufferP[0], sizeof(rx_bufferP), - frame, next_slot); - - DevCheck(num_bytesP > 0, num_bytesP, 0, 0); -# else if (multicast_link_read_data_from_sock(is_master) == 1) { /* We got a timeout */ return -1; } -# endif #else pthread_mutex_lock(&emul_low_mutex); @@ -363,10 +340,6 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot, num_bytesP, map_int_to_str(transport_names, messg->Message_type), messg->master_id, messg->seq_num); -#if defined(ENABLE_PGM_TRANSPORT) - - if (messg->Message_type != EMU_TRANSPORT_NACK) -#endif DevCheck4((messg->frame == frame) && (messg->subframe == (next_slot>>1)), messg->frame, frame, messg->subframe, next_slot>>1); @@ -409,20 +382,6 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot, Master_list_rx = oai_emulation.info.master_list; LOG_E(EMU, "RX EMU_TRANSPORT_INFO_RELEASE\n"); break; -#if defined(ENABLE_PGM_TRANSPORT) - - case EMU_TRANSPORT_NACK: - if (messg->failing_master_id == oai_emulation.info.master_id) { - /* We simply re-send the last message */ - pgm_link_send_msg(oai_emulation.info.multicast_group, - (uint8_t *)bypass_tx_buffer, byte_tx_count); - } else { - /* Sleep awhile till other peers have recovered data */ - usleep(500); - } - - break; -#endif default: LOG_E(EMU, "[MAC][BYPASS] ERROR RX UNKNOWN MESSAGE\n"); @@ -448,35 +407,6 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot, return bytes_read; } -/******************************************************************************************************/ -#ifndef USER_MODE -int bypass_rx_handler(unsigned int fifo, int rw) -{ - /******************************************************************************************************/ - int bytes_read; - int bytes_processed=0; - int header_bytes; //, elapsed_time; - //printk("[BYPASS] BYPASS_RX_HANDLER IN...\n"); - header_bytes= rtf_get(fifo_bypass_phy_user2kern, rx_bufferP, - sizeof(bypass_proto2multicast_header_t) ); - - if (header_bytes> 0) { - bytes_read = rtf_get(fifo_bypass_phy_user2kern, &rx_bufferP[header_bytes], - ((bypass_proto2multicast_header_t *) (&rx_bufferP[0]))->size); - - // printk("BYTES_READ=%d\n",bytes_read); - if (bytes_read > 0) { - num_bytesP=header_bytes+bytes_read; - emul_low_mutex_var=0; - //printk("BYPASS_PHY SIGNAL MAC_LOW...\n"); - pthread_cond_signal(&emul_low_cond); - } - } - - // } - return 0; -} -#else //USER_MODE /******************************************************************************************************/ void bypass_rx_handler(unsigned int Num_bytes,char *Rx_buffer) { @@ -503,7 +433,6 @@ void bypass_rx_handler(unsigned int Num_bytes,char *Rx_buffer) #endif } } -#endif //USER_MODE /******************************************************************************************************/ void bypass_signal_mac_phy(unsigned int frame, unsigned int last_slot, @@ -511,57 +440,12 @@ void bypass_signal_mac_phy(unsigned int frame, unsigned int last_slot, { /******************************************************************************************************/ if (Master_list_rx != oai_emulation.info.master_list) { -#ifndef USER_MODE - rtf_put(fifo_mac_bypass, &tt, 1); - /* the Rx window is still opened (Re)signal bypass_phy (emulate MAC signal) */ -#endif bypass_rx_data(frame, last_slot, next_slot, is_master); } else { Master_list_rx = 0; } } -#ifndef USER_MODE -/***************************************************************************/ -int multicast_link_write_sock (int groupP, char *dataP, unsigned int sizeP) -{ - /***************************************************************************/ - int tx_bytes=0; - - pthread_mutex_lock(&Tx_mutex); - - while(!Tx_mutex_var) { - pthread_cond_wait(&Tx_cond,&Tx_mutex); - } - - Tx_mutex_var=0; - N_P=(int)((sizeP-sizeof (bypass_proto2multicast_header_t))/1000)+2; - tx_bytes += rtf_put (fifo_bypass_phy_kern2user, &dataP[tx_bytes], - sizeof (bypass_proto2multicast_header_t)); - - while(tx_bytes<sizeP) { - if(sizeP-tx_bytes<=1000) { - tx_bytes += rtf_put (fifo_bypass_phy_kern2user, &dataP[tx_bytes], - sizeP-tx_bytes); - } else { - tx_bytes += rtf_put (fifo_bypass_phy_kern2user, &dataP[tx_bytes],1000); - } - } - - //RG_tx_mutex_var=0; - pthread_mutex_unlock(&Tx_mutex); - - return tx_bytes; -} -#endif - -#if defined(ENABLE_PGM_TRANSPORT) -void bypass_tx_nack(unsigned int frame, unsigned int next_slot) -{ - bypass_tx_data(NACK_TRANSPORT, frame, next_slot); -} -#endif - /***************************************************************************/ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int next_slot) { @@ -591,26 +475,6 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int byte_tx_count = sizeof (bypass_msg_header_t) + sizeof ( bypass_proto2multicast_header_t); -#if defined(ENABLE_PGM_TRANSPORT) - - if (Type == NACK_TRANSPORT) { - int i; - messg->Message_type = EMU_TRANSPORT_NACK; - - for (i = 0; i < oai_emulation.info.nb_master; i++) { - /* Skip our id */ - if (i == oai_emulation.info.master_id) - continue; - - if ((Master_list_rx & (1 << i)) == 0) { - messg->failing_master_id = i; - break; - } - } - - LOG_T(EMU,"[TX_DATA] NACK TRANSPORT\n"); - } else -#endif if (Type == WAIT_PM_TRANSPORT) { messg->Message_type = EMU_TRANSPORT_INFO_WAIT_PM; LOG_T(EMU,"[TX_DATA] WAIT SYNC PM TRANSPORT\n"); @@ -702,32 +566,11 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int ((bypass_proto2multicast_header_t *) bypass_tx_buffer)->size = byte_tx_count - sizeof (bypass_proto2multicast_header_t); -#if defined(ENABLE_PGM_TRANSPORT) - pgm_link_send_msg(oai_emulation.info.multicast_group, - (uint8_t *)bypass_tx_buffer, byte_tx_count); -#else multicast_link_write_sock(oai_emulation.info.multicast_group, bypass_tx_buffer, byte_tx_count); -#endif LOG_D(EMU, "Frame %d, subframe %d (%d): Sent %d bytes [%s] with master_id %d and seq %"PRIuMAX"\n", frame, next_slot>>1, next_slot,byte_tx_count, map_int_to_str(transport_names, Type), messg->master_id, messg->seq_num); } -#ifndef USER_MODE -/*********************************************************************************************************************/ -int bypass_tx_handler(unsigned int fifo, int rw) -{ - /***************************************************************************/ - if(++N_R==N_P) { - rtf_reset(fifo_bypass_phy_kern2user); - - Tx_mutex_var=1; - N_R=0; - - pthread_cond_signal(&Tx_cond); - } -} -#endif - diff --git a/openair1/SIMULATION/ETH_TRANSPORT/defs.h b/openair1/SIMULATION/ETH_TRANSPORT/defs.h index 3b744aa859fd74b2bca76305dab11019918c9151..5cd961b61a2cb6479622355617ba6f613be40f0e 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/defs.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/defs.h @@ -41,9 +41,6 @@ typedef enum emu_transport_info_e { EMU_TRANSPORT_INFO_ENB, EMU_TRANSPORT_INFO_UE, EMU_TRANSPORT_INFO_RELEASE -#if defined(ENABLE_PGM_TRANSPORT) - ,EMU_TRANSPORT_NACK -#endif } emu_transport_info_t; #define WAIT_PM_TRANSPORT 1 @@ -52,9 +49,6 @@ typedef enum emu_transport_info_e { #define ENB_TRANSPORT 4 #define UE_TRANSPORT 5 #define RELEASE_TRANSPORT 6 -#if defined(ENABLE_PGM_TRANSPORT) -# define NACK_TRANSPORT 7 -#endif #define WAIT_SYNC_TRANSPORT 1 #define SYNCED_TRANSPORT 2 diff --git a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c b/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c index 186201cd0b19e9ed03759e2b1faa5c7e27dbe9cd..f71a8ee11727b06e7cd9379475afebe45739a99f 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c @@ -40,49 +40,17 @@ #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" -#include "pgm_link.h" - extern unsigned int Master_list_rx; extern unsigned char NB_INST; //#define DEBUG_CONTROL 1 //#define DEBUG_EMU 1 -#if defined(ENABLE_PGM_TRANSPORT) -extern unsigned int pgm_would_block; -#endif - void emu_transport_sync(void) { LOG_D(EMU, "Entering EMU transport SYNC is primary master %d\n", oai_emulation.info.is_primary_master); -#if defined(ENABLE_PGM_TRANSPORT) - - if (oai_emulation.info.is_primary_master == 0) { - bypass_tx_data(WAIT_SM_TRANSPORT,0,0); - // just wait to recieve the master 0 msg - Master_list_rx = oai_emulation.info.master_list - 1; - bypass_rx_data(0,0,0,1); - } else { - bypass_rx_data(0,0,0,0); - bypass_tx_data(WAIT_PM_TRANSPORT,0,0); - } - - if (oai_emulation.info.master_list != 0) { - bypass_tx_data(SYNC_TRANSPORT,0,0); - bypass_rx_data(0,0,0,0); - - // i received the sync from all secondary masters - if (emu_rx_status == SYNCED_TRANSPORT) { - emu_tx_status = SYNCED_TRANSPORT; - } - - LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n"); - } - -#else - if (oai_emulation.info.is_primary_master == 0) { retry: bypass_tx_data(WAIT_SM_TRANSPORT,0,0); @@ -115,8 +83,6 @@ retry2: LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n"); } -#endif - LOG_D(EMU, "Leaving EMU transport SYNC is primary master %d\n", oai_emulation.info.is_primary_master); } @@ -154,9 +120,6 @@ void emu_transport(unsigned int frame, unsigned int last_slot, } } -#if defined(ENABLE_PGM_TRANSPORT) - pgm_would_block = 0; -#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_EMU_TRANSPORT, VCD_FUNCTION_OUT); } diff --git a/openair1/SIMULATION/ETH_TRANSPORT/extern.h b/openair1/SIMULATION/ETH_TRANSPORT/extern.h index fafa7009f5480bd1ec0983b58cea8cf21f4aa863..c01b5584e23f70b44f7820ef15832e94760118ed 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/extern.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/extern.h @@ -31,11 +31,7 @@ #ifndef __BYPASS_SESSION_LAYER_EXTERN_H__ # define __BYPASS_SESSION_LAYER_EXTERN_H__ -#ifndef USER_MODE -#include <rtai_posix.h> -#else #include <pthread.h> -#endif //RTAI_ENABLED extern unsigned char Emulation_status; extern unsigned char emu_tx_status; diff --git a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c b/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c index f32823f3bb51fe66f74a8f82a996175f51dda847..1ba724976fabdd87b82c623ee50ea9b43cb8cbfb 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c @@ -54,9 +54,7 @@ #include "socket.h" #include "multicast_link.h" -#ifdef USER_MODE -# include "UTIL/LOG/log.h" -#endif //USER_MODE +#include "UTIL/LOG/log.h" extern unsigned short Master_id; @@ -316,9 +314,7 @@ void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), LOG_I(EMU, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n", (multicast_if == NULL) ? "not specified" : multicast_if, multicast_group, rx_handler); -#if !defined(ENABLE_PGM_TRANSPORT) multicast_link_init (); -#endif #if ! defined(ENABLE_NEW_MULTICAST) LOG_D(EMU, "[MULTICAST] multicast link start thread\n"); diff --git a/openair1/SIMULATION/ETH_TRANSPORT/pgm_link.c b/openair1/SIMULATION/ETH_TRANSPORT/pgm_link.c deleted file mode 100644 index 61bf9406607e4198920a8a35649daf629e9a9cd4..0000000000000000000000000000000000000000 --- a/openair1/SIMULATION/ETH_TRANSPORT/pgm_link.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file pgm_link.c - * \brief implementation a warpper for openpgm for reliable multicast transmission - * \author Navid Nikaein and S. Roux - * \date 2013 - 2014 - * \version 1.0 - * \company Eurecom - * \email: navid.nikaein@eurecom.fr - */ - -#include <pthread.h> -#include <stdint.h> -#include <string.h> -#include <errno.h> -#include <unistd.h> - -#include <arpa/inet.h> - -#if defined(ENABLE_PGM_TRANSPORT) - -#include <pgm/pgm.h> - -#include "assertions.h" - -#include "pgm_link.h" -#include "multicast_link.h" - -#include "UTIL/OCG/OCG.h" -#include "UTIL/OCG/OCG_extern.h" - -#include "UTIL/LOG/log.h" - -// #define ENABLE_PGM_DEBUG - -typedef struct { - pgm_sock_t *sock; - uint16_t port; - uint8_t rx_buffer[40000]; -} pgm_multicast_group_t; - -pgm_multicast_group_t pgm_multicast_group[MULTICAST_LINK_NUM_GROUPS]; - -static -int pgm_create_socket(int index, const char *if_addr); - -unsigned int pgm_would_block = 1; - -#if defined(ENABLE_PGM_DEBUG) -static void -log_handler ( - const int log_level, - const char* message, - void* closure -) -{ - printf("%s\n", message); -} -#endif - -int pgm_oai_init(char *if_addr) -{ - pgm_error_t* pgm_err = NULL; - - memset(pgm_multicast_group, 0, - MULTICAST_LINK_NUM_GROUPS * sizeof(pgm_multicast_group_t)); - -#if defined(ENABLE_PGM_DEBUG) - pgm_messages_init(); - pgm_min_log_level = PGM_LOG_LEVEL_DEBUG; - pgm_log_mask = 0xFFF; - - pgm_log_set_handler(log_handler, NULL); -#endif - - if (!pgm_init(&pgm_err)) { - LOG_E(EMU, "Unable to start PGM engine: %s\n", pgm_err->message); - pgm_error_free (pgm_err); - exit(EXIT_FAILURE); - } - - return pgm_create_socket(oai_emulation.info.multicast_group, if_addr); -} - -int pgm_recv_msg(int group, uint8_t *buffer, uint32_t length, - unsigned int frame, unsigned int next_slot) -{ - size_t num_bytes = 0; - int status = 0; - pgm_error_t* pgm_err = NULL; - struct pgm_sockaddr_t from; - socklen_t fromlen = sizeof(from); - uint32_t timeout = 0; - int flags = 0; - - if (pgm_would_block == 0) { - flags = MSG_DONTWAIT; - } - - DevCheck((group <= MULTICAST_LINK_NUM_GROUPS) && (group >= 0), - group, MULTICAST_LINK_NUM_GROUPS, 0); - -#ifdef DEBUG_EMU - LOG_I(EMU, "[PGM] Entering recv function for group %d\n", group); -#endif - - do { - status = pgm_recvfrom(pgm_multicast_group[group].sock, - buffer, - length, - flags, - &num_bytes, - &from, - &fromlen, - &pgm_err); - - if (PGM_IO_STATUS_NORMAL == status) { -#ifdef DEBUG_EMU - LOG_D(EMU, "[PGM] Received %d bytes for group %d\n", num_bytes, group); -#endif - return num_bytes; - } else if (PGM_IO_STATUS_TIMER_PENDING == status) { - if (pgm_would_block == 0) { - /* We sleep for 50 usec */ - usleep(50); - - timeout ++; - - if (timeout == (1000000 / 50)) { - LOG_W(EMU, "[PGM] A packet has been lost -> ask for retransmit\n"); - /* If we do not receive a packet after 10000usec - * -> send a NACK */ - bypass_tx_nack(frame, next_slot); - timeout = 0; - } - } - } else if (PGM_IO_STATUS_RESET == status) { - LOG_W(EMU, "[PGM] Got session reset\n"); - } else { -#ifdef DEBUG_EMU - LOG_D(EMU, "[PGM] Got status %d\n", status); -#endif - - if (pgm_err) { - LOG_E(EMU, "[PGM] recvform failed: %s", pgm_err->message); - pgm_error_free (pgm_err); - pgm_err = NULL; - } - } - } while(status != PGM_IO_STATUS_NORMAL); - - return -1; -} - -int pgm_link_send_msg(int group, uint8_t *data, uint32_t len) -{ - int status; - size_t bytes_written = 0; - - do { - status = pgm_send(pgm_multicast_group[group].sock, data, len, &bytes_written); - } while(status == PGM_IO_STATUS_WOULD_BLOCK); - - if (status != PGM_IO_STATUS_NORMAL) { - return -1; - } - - return bytes_written; -} - -static -int pgm_create_socket(int index, const char *if_addr) -{ - struct pgm_addrinfo_t* res = NULL; - pgm_error_t* pgm_err = NULL; - sa_family_t sa_family = AF_INET; - int udp_encap_port = 46014 + index; - int max_tpdu = 1500; - int sqns = 100; - int port = 0; - struct pgm_sockaddr_t addr; - int blocking = 1; - int multicast_loop = 0; - int multicast_hops = 0; - int dscp, i; - - port = udp_encap_port; - - /* Use PGM */ - udp_encap_port = 0; - - LOG_D(EMU, "[PGM] Preparing socket for group %d and address %s\n", - index, if_addr); - - if (!pgm_getaddrinfo(if_addr, NULL, &res, &pgm_err)) { - LOG_E(EMU, "Parsing network parameter: %s\n", pgm_err->message); - goto err_abort; - } - - if (udp_encap_port) { - LOG_I(EMU, "[PGM] Creating PGM/UDP socket for encapsulated port %d\n", - udp_encap_port); - - if (!pgm_socket (&pgm_multicast_group[index].sock, sa_family, - SOCK_SEQPACKET, IPPROTO_UDP, &pgm_err)) { - LOG_E(EMU, "[PGM] Socket: %s\n", pgm_err->message); - goto err_abort; - } - - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_UDP_ENCAP_UCAST_PORT, &udp_encap_port, - sizeof(udp_encap_port)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_UDP_ENCAP_MCAST_PORT, &udp_encap_port, - sizeof(udp_encap_port)); - } else { - LOG_I(EMU, "[PGM] Creating PGM/IP socket\n"); - - if (!pgm_socket(&pgm_multicast_group[index].sock, sa_family, - SOCK_SEQPACKET, IPPROTO_PGM, &pgm_err)) { - LOG_E(EMU, "Creating PGM/IP socket: %s\n", pgm_err->message); - goto err_abort; - } - } - - { - /* Use RFC 2113 tagging for PGM Router Assist */ - const int no_router_assist = 0; - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_IP_ROUTER_ALERT, &no_router_assist, - sizeof(no_router_assist)); - } - - // pgm_drop_superuser(); - - { - /* set PGM parameters */ - const int recv_only = 0, - passive = 0, - peer_expiry = pgm_secs (300), - spmr_expiry = pgm_msecs (250), - nak_bo_ivl = pgm_msecs (10), - nak_rpt_ivl = pgm_secs (2), - nak_rdata_ivl = pgm_secs (2), - nak_data_retries = 50, - nak_ncf_retries = 50, - ambient_spm = pgm_secs(30); - const int heartbeat_spm[] = { - pgm_msecs (100), - pgm_msecs (100), - pgm_msecs (100), - pgm_msecs (100), - pgm_msecs (1300), - pgm_secs (7), - pgm_secs (16), - pgm_secs (25), - pgm_secs (30) - }; - - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_RECV_ONLY, &recv_only, sizeof(recv_only)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_PASSIVE, &passive, sizeof(passive)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_MTU, &max_tpdu, sizeof(max_tpdu)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_RXW_SQNS, &sqns, sizeof(sqns)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_PEER_EXPIRY, &peer_expiry, sizeof(peer_expiry)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_SPMR_EXPIRY, &spmr_expiry, sizeof(spmr_expiry)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_NAK_BO_IVL, &nak_bo_ivl, sizeof(nak_bo_ivl)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_NAK_RPT_IVL, &nak_rpt_ivl, sizeof(nak_rpt_ivl)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_NAK_RDATA_IVL, &nak_rdata_ivl, sizeof(nak_rdata_ivl)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_NAK_DATA_RETRIES, &nak_data_retries, sizeof(nak_data_retries)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_NAK_NCF_RETRIES, &nak_ncf_retries, sizeof(nak_ncf_retries)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_AMBIENT_SPM, &ambient_spm, sizeof(ambient_spm)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_HEARTBEAT_SPM, &heartbeat_spm, sizeof(heartbeat_spm)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_TXW_SQNS, &sqns, sizeof(sqns)); - } - - /* create global session identifier */ - memset (&addr, 0, sizeof(addr)); - /* sa_port should be in host byte order */ - addr.sa_port = port; - addr.sa_addr.sport = DEFAULT_DATA_SOURCE_PORT + index; - - if (!pgm_gsi_create_from_hostname(&addr.sa_addr.gsi, &pgm_err)) { - LOG_E(EMU, "[PGM] Creating GSI: %s\n", pgm_err->message); - goto err_abort; - } - - LOG_D(EMU, "[PGM] Created GSI %s\n", pgm_tsi_print(&addr.sa_addr)); - - /* assign socket to specified address */ - { - struct pgm_interface_req_t if_req; - memset (&if_req, 0, sizeof(if_req)); - if_req.ir_interface = res->ai_recv_addrs[0].gsr_interface; - if_req.ir_scope_id = 0; - - if (AF_INET6 == sa_family) { - struct sockaddr_in6 sa6; - memcpy (&sa6, &res->ai_recv_addrs[0].gsr_group, sizeof(sa6)); - if_req.ir_scope_id = sa6.sin6_scope_id; - } - - if (!pgm_bind3(pgm_multicast_group[index].sock, &addr, sizeof(addr), - &if_req, sizeof(if_req), /* tx interface */ - &if_req, sizeof(if_req), /* rx interface */ - &pgm_err)) { - LOG_E(EMU, "[PGM] Error: %s\n", pgm_err->message); - goto err_abort; - } - } - - /* join IP multicast groups */ - { - struct group_req req; - struct sockaddr_in addr_in; - - memset(&req, 0, sizeof(req)); - - /* Interface index */ - req.gr_interface = res->ai_recv_addrs[0].gsr_interface; - - addr_in.sin_family = AF_INET; - addr_in.sin_port = htons(port); - - for (i = 0; i < MULTICAST_LINK_NUM_GROUPS; i++) { - addr_in.sin_addr.s_addr = inet_addr(multicast_group_list[i]); - memcpy(&req.gr_group, &addr_in, sizeof(addr_in)); - - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_JOIN_GROUP, &req, - sizeof(struct group_req)); - } - - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_SEND_GROUP, &req, - sizeof(struct group_req)); - } - - pgm_freeaddrinfo(res); - res = NULL; - - /* set IP parameters */ - multicast_hops = 64; - dscp = 0x2e << 2; /* Expedited Forwarding PHB for network elements, no ECN. */ - - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_MULTICAST_LOOP, &multicast_loop, sizeof(multicast_loop)); - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, - PGM_MULTICAST_HOPS, &multicast_hops, sizeof(multicast_hops)); - - if (AF_INET6 != sa_family) - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, PGM_TOS, - &dscp, sizeof(dscp)); - - pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, PGM_NOBLOCK, - &blocking, sizeof(blocking)); - - if (!pgm_connect(pgm_multicast_group[index].sock, &pgm_err)) { - LOG_E(EMU, "[PGM] Connecting socket: %s\n", pgm_err->message); - goto err_abort; - } - - return 0; - -err_abort: - - if (NULL != pgm_multicast_group[index].sock) { - pgm_close(pgm_multicast_group[index].sock, FALSE); - pgm_multicast_group[index].sock = NULL; - } - - if (NULL != res) { - pgm_freeaddrinfo(res); - res = NULL; - } - - if (NULL != pgm_err) { - pgm_error_free(pgm_err); - pgm_err = NULL; - } - - exit(EXIT_FAILURE); -} - -#endif diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index 6a693085c99867f2ccec551a01339df1a63b999f..25b3265757d74b9ff471021211afefc31c7790e0 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -39,14 +39,6 @@ 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, unsigned int next_slot, uint8_t is_master); -#ifndef USER_MODE -int multicast_link_write_sock (int groupP, char *dataP, unsigned int sizeP); -int bypass_tx_handler(unsigned int fifo, int rw); -int bypass_rx_handler(unsigned int fifo, int rw); -#else -void bypass_rx_handler(unsigned int Num_bytes,char *Rx_buffer); -#endif - void bypass_tx_data (emu_transport_info_t Type, unsigned int frame, unsigned int next_slot); void emulation_tx_rx(void); diff --git a/openair1/SIMULATION/ETH_TRANSPORT/socket.c b/openair1/SIMULATION/ETH_TRANSPORT/socket.c index e288dcb37896f70b79951a33491f50149931a920..2b28a6617032adf2bb0eca4f93f192e81d681326 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/socket.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/socket.c @@ -41,9 +41,7 @@ //#include "openair_defs.h" #include "socket.h" -#ifdef USER_MODE #define msg printf -#endif //------------------------------------------------------------------------------ void socket_setnonblocking (int sockP) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/vars.h b/openair1/SIMULATION/ETH_TRANSPORT/vars.h index 0ec38a8e907ad153ac8d5b4d37a3341005c60334..f49678642ed19458f41b349034a5688de544161d 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/vars.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/vars.h @@ -28,11 +28,7 @@ * \email: navid.nikaein@eurecom.fr */ -#ifndef USER_MODE -#include <rtai_posix.h> -#else #include <pthread.h> -#endif #include "defs.h" #ifndef __BYPASS_SESSION_LAYER_VARS_H__ diff --git a/openair1/SIMULATION/LTE_PHY/Makefile b/openair1/SIMULATION/LTE_PHY/Makefile deleted file mode 100644 index 713bfba3706fc0b3d086f6df1ae7bc61fd2db489..0000000000000000000000000000000000000000 --- a/openair1/SIMULATION/LTE_PHY/Makefile +++ /dev/null @@ -1,202 +0,0 @@ -include $(OPENAIR_DIR)/common/utils/Makefile.inc - -COMMON_UTILS_DIR = $(OPENAIR_DIR)/common/utils -TOP_DIR = $(OPENAIR1_DIR) -OPENAIR1_TOP = $(OPENAIR1_DIR) -OPENAIR2_TOP = $(OPENAIR2_DIR) -OPENAIR3 = $(OPENAIR3_DIR) - -CFLAGS += -DMAX_NUM_CCs=1 -Wall -DPHYSIM -DNODE_RG -DUSER_MODE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DPHY_CONTEXT=1 -DMALLOC_CHECK_=1 -DENABLE_VCD_FIFO -DLOG_NO_THREAD # -Wno-packed-bitfield-compat - -# enable C99 mode -CFLAGS += -std=gnu99 - -# DCI Debug -# CFLAGS += -DDEBUG_DCI_ENCODING -# TODO: only for framegen -#CFLAGS += -DOPENAIR2 -#CFLAGS += -DDEBUG_PHY_PROC -#CFLAGS += -DDEBUG_GROUPHOP - -ifdef OMP -CFLAGS += -DOMP -fopenmp -endif -ifdef LLR8 -CFLAGS += -DLLR8 -endif -CFLAGS += -DNEW_FFT - -LFLAGS = -lm -lblas -lxml2 -lrt -lpthread $(LFDS_DIR)/bin/liblfds611.a - -ifdef GPIB -LFLAGS += -lgpib -endif - -CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH #-DIFFT_FPGA -DIFFT_FPGA_UE -#CFLAGS += -DTBS_FIX -CFLAGS += -DCELLULAR - -ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES - -ifdef EMOS -CFLAGS += -DEMOS -endif - -ifdef DEBUG_PHY -CFLAGS += -DDEBUG_PHY -endif - -ifdef MeNBMUE -CFLAGS += -DMeNBMUE -endif - -ifdef MU_RECEIVER -CFLAGS += -DMU_RECEIVER -endif - -ifdef ZBF_ENABLED -CFLAGS += -DNULL_SHAPE_BF_ENABLED -endif - -ifdef RANDOM_BF -CFLAGS += -DRANDOM_BF -endif - -ifdef PBS_SIM -CFLAGS += -DPBS_SIM -endif - -ifdef XFORMS -CFLAGS += -DXFORMS -LFLAGS += -lforms -endif - -ifdef SMBV -CFLAGS += -DSMBV -endif - -ifdef PERFECT_CE -CFLAGS += -DPERFECT_CE -endif - -ifdef BIT8_TX -CFLAGS += -DBIT8_TX -endif - -CFLAGS += -DNO_RRM -DOPENAIR1 -DPHY_ABSTRACTION #-DOPENAIR2 - -CFLAGS += -I/usr/include/X11 -I/usr/X11R6/include - -ifdef RTAI -CFLAGS += -DRTAI_ENABLED -D__IN_RTAI__ $(shell rtai-config --lxrt-cflags) -LFLAGS += $(shell rtai-config --lxrt-ldflags) -llxrt -endif - -include $(COMMON_UTILS_DIR)/Makefile.inc -include $(TOP_DIR)/PHY/Makefile.inc -include $(TOP_DIR)/SCHED/Makefile.inc -include $(TOP_DIR)/SIMULATION/Makefile.inc -include $(OPENAIR2_DIR)/LAYER2/Makefile.inc -include $(OPENAIR2_DIR)/UTIL/Makefile.inc -include $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc - -#LOG_OBJS += $(LOG_DIR)/vcd_signal_dumper.o - -CFLAGS += $(L2_incl) -I$(ASN1_MSG_INC) -I$(TOP_DIR) -I$(OPENAIR2_DIR) -I$(OPENAIR3) $(UTIL_incl) $(UTILS_incl) -# EXTRA_CFLAGS = - -#STATS_OBJS += $(TOP_DIR)/ARCH/CBMIMO1/DEVICE_DRIVER/cbmimo1_proc.o - -#LAYER2_OBJ += $(OPENAIR2_DIR)/LAYER2/MAC/rar_tools.o -#LAYER2_OBJ = $(OPENAIR2_DIR)/LAYER2/MAC/lte_transport_init.o - -OBJ = $(PHY_OBJS) $(SIMULATION_OBJS) $(TOOLS_OBJS) $(SCHED_OBJS) $(LAYER2_OBJ) $(LOG_OBJS) $(ITTI_DIR)/backtrace.o -ifdef GPIB -OBJ += LTE_Configuration.o -endif -#OBJ2 = $(PHY_OBJS) $(SIMULATION_OBJS) $(TOOLS_OBJS) - -ifdef XFORMS -OBJ += $(OPENAIR1_DIR)/PHY/TOOLS/lte_phy_scope.o -endif - -ifdef STATIC -LFLAGS += -static -L/usr/lib/libblas -endif - -all: dlsim pbchsim pdcchsim ulsim pucchsim prachsim mbmssim scansim - -$(LFDS_DIR)/bin/liblfds611.a: - $(MAKE) -C $(LFDS_DIR) -f makefile.linux - -test: $(SIMULATION_OBJS) $(TOOLS_OBJS) $(TOP_DIR)/PHY/INIT/lte_init.o test.c - $(CC) test.c -I$(TOP_DIR) -o test $(CFLAGS) $(SIMULATION_OBJS) $(TOOLS_OBJS) -lm - -OBJ += $(LIST_OBJ) -OBJ += $(MEM_OBJ) -$(OBJ) : %.o : %.c - @echo Compiling $< ... - @$(CC) -c $(CFLAGS) -o $@ $< - -dlsim : $(OBJ) dlsim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling dlsim.c ..." - @$(CC) dlsim.c -o dlsim $(CFLAGS) $(OBJ) $(LFLAGS) - -dlsim2 : $(OBJ) dlsim2.c - @echo "Compiling dlsim2.c ..." - @$(CC) dlsim2.c -o dlsim2 $(CFLAGS) $(OBJ) $(LFLAGS) - -framegen: $(OBJ) framegen.c - @echo "Compiling framegen.c" - @$(CC) framegen.c -o framegen $(CFLAGS) $(OBJ) $(LFLAGS) - -pbchsim : $(OBJ) pbchsim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling pbchsim.c" - @$(CC) pbchsim.c -o pbchsim $(CFLAGS) $(OBJ) $(LFLAGS) - -scansim : $(OBJ) scansim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling scansim.c" - @$(CC) scansim.c -o scansim $(CFLAGS) $(OBJ) $(LFLAGS) - -mbmssim : $(OBJ) mbmssim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling mbmssim.c" - @$(CC) mbmssim.c -o mbmssim $(CFLAGS) $(OBJ) $(LFLAGS) - -pdcchsim : $(OBJ) pdcchsim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling pdcchsim.c" - @$(CC) pdcchsim.c -o pdcchsim $(CFLAGS) $(OBJ) $(LFLAGS) - -pucchsim : $(OBJ) pucchsim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling pucchsim.c" - @$(CC) pucchsim.c -o pucchsim $(CFLAGS) $(OBJ) $(LFLAGS) - -prachsim : $(OBJ) prachsim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling prachsim.c" - @$(CC) prachsim.c -o prachsim $(CFLAGS) $(OBJ) $(LFLAGS) - -ulsim : $(OBJ) ulsim.c $(LFDS_DIR)/bin/liblfds611.a #ulsim_form.c - @echo "Compiling [ulsim.c]" - @$(CC) ulsim.c -o ulsim $(CFLAGS) $(OBJ) $(LFLAGS) - -syncsim : $(OBJ) syncsim.c $(LFDS_DIR)/bin/liblfds611.a - @echo "Compiling syncsim.c" - @$(CC) syncsim.c -o syncsim $(CFLAGS) $(OBJ) $(LFLAGS) - -clean : - rm -f $(OBJ) - rm -f *.o - -cleanall : clean - rm -f dlsim pbchsim pdcchsim ulsim pucchsim mbmssim prachsim - rm -f *.exe* - -showflags : - @echo $(CFLAGS) - @echo $(LFLAGS) - -showobj: - @echo $(SCHED_OBJS) - -cppcheck: - @echo "cppcheck ..." - cppcheck $(INCLUDES) ${OBJ:.o=.c} ${OAISIM_OBJS,.o=.c} ${ASN1_RRC_MSG_OBJS1,.o=.c} diff --git a/openair1/SIMULATION/LTE_PHY/mbmssim.c b/openair1/SIMULATION/LTE_PHY/mbmssim.c index 773ec57a3e914284a6a151e9214e7ad161f99afd..fbe75fed16980180a53120747da823c7d296a849 100644 --- a/openair1/SIMULATION/LTE_PHY/mbmssim.c +++ b/openair1/SIMULATION/LTE_PHY/mbmssim.c @@ -31,9 +31,6 @@ #include "PHY/types.h" #include "PHY/defs.h" #include "PHY/vars.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #include "SCHED/defs.h" #include "SCHED/vars.h" #include "LAYER2/MAC/vars.h" diff --git a/openair1/SIMULATION/LTE_PHY/pbchsim.c b/openair1/SIMULATION/LTE_PHY/pbchsim.c index e240f88ce6665f36529871a19386591b8ffb43ed..d1e25da5c3c6b9a6bbac62ecc5df498680c1dc6f 100644 --- a/openair1/SIMULATION/LTE_PHY/pbchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pbchsim.c @@ -32,9 +32,6 @@ #include "PHY/defs.h" #include "PHY/vars.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #include "SCHED/defs.h" #include "SCHED/vars.h" #include "LAYER2/MAC/vars.h" @@ -91,9 +88,6 @@ int main(int argc, char **argv) uint8_t extended_prefix_flag=0; int8_t interf1=-21,interf2=-21; LTE_DL_FRAME_PARMS *frame_parms; -#ifdef EMOS - fifo_dump_emos emos_dump; -#endif FILE *input_fd=NULL,*pbch_file_fd=NULL; char input_val_str[50],input_val_str2[50]; diff --git a/openair1/SIMULATION/LTE_PHY/pdcchsim.c b/openair1/SIMULATION/LTE_PHY/pdcchsim.c index 71e2f881721dc7a38b1fefca9317c4e03add7745..ef0e22149141a2f3de879d8ae01e5e74acd05d61 100644 --- a/openair1/SIMULATION/LTE_PHY/pdcchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pdcchsim.c @@ -28,9 +28,6 @@ #include "PHY/defs.h" #include "PHY/vars.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #include "SCHED/defs.h" #include "SCHED/vars.h" #include "LAYER2/MAC/vars.h" diff --git a/openair1/SIMULATION/LTE_PHY/prachsim.c b/openair1/SIMULATION/LTE_PHY/prachsim.c index cab2ecb8fb06c813fc01489432a9ff41ce5cc0f9..58f89bd65bd5dba83d41b897045e9888e8f6bc88 100644 --- a/openair1/SIMULATION/LTE_PHY/prachsim.c +++ b/openair1/SIMULATION/LTE_PHY/prachsim.c @@ -27,9 +27,6 @@ #include "PHY/types.h" #include "PHY/defs.h" #include "PHY/vars.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #include "SCHED/defs.h" #include "SCHED/vars.h" #include "LAYER2/MAC/vars.h" @@ -76,10 +73,6 @@ int main(int argc, char **argv) uint8_t extended_prefix_flag=0; // int8_t interf1=-19,interf2=-19; LTE_DL_FRAME_PARMS *frame_parms; -#ifdef EMOS - fifo_dump_emos emos_dump; -#endif - SCM_t channel_model=Rayleigh1; diff --git a/openair1/SIMULATION/LTE_PHY/pucchsim.c b/openair1/SIMULATION/LTE_PHY/pucchsim.c index 1e5f47e59eaa8411d98f64804e27861381cadf63..d49367c4db4be34db1d797eee23f1850de2bc686 100644 --- a/openair1/SIMULATION/LTE_PHY/pucchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pucchsim.c @@ -27,9 +27,6 @@ #include "PHY/types.h" #include "PHY/defs.h" #include "PHY/vars.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #include "SCHED/defs.h" #include "SCHED/vars.h" #include "LAYER2/MAC/vars.h" @@ -77,9 +74,6 @@ int main(int argc, char **argv) uint8_t extended_prefix_flag=0; LTE_DL_FRAME_PARMS *frame_parms; -#ifdef EMOS - fifo_dump_emos emos_dump; -#endif SCM_t channel_model=Rayleigh1_corr; diff --git a/openair1/SIMULATION/LTE_PHY/scansim.c b/openair1/SIMULATION/LTE_PHY/scansim.c index 94bc991e3fd67e7e8382db0739e6194ff7d6ee08..69aee01b32b472db4be2d149b6453cb27aaa0064 100644 --- a/openair1/SIMULATION/LTE_PHY/scansim.c +++ b/openair1/SIMULATION/LTE_PHY/scansim.c @@ -33,9 +33,6 @@ #include "PHY/vars.h" #include "MAC_INTERFACE/vars.h" -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #include "SCHED/defs.h" #include "SCHED/vars.h" #include "LAYER2/MAC/vars.h" @@ -91,9 +88,6 @@ int main(int argc, char **argv) uint32_t nsymb,tx_lev,tx_lev1,tx_lev2; uint8_t extended_prefix_flag=0; LTE_DL_FRAME_PARMS *frame_parms; -#ifdef EMOS - fifo_dump_emos emos_dump; -#endif FILE *input_fd=NULL,*pbch_file_fd=NULL; char input_val_str[50],input_val_str2[50]; diff --git a/openair1/SIMULATION/LTE_PHY/syncsim.c b/openair1/SIMULATION/LTE_PHY/syncsim.c index acad27ca113797d96bf4edfb01d3593d56ee6926..e491944ccf555e55797d42b6a114d77e8e3fd8b6 100644 --- a/openair1/SIMULATION/LTE_PHY/syncsim.c +++ b/openair1/SIMULATION/LTE_PHY/syncsim.c @@ -30,11 +30,6 @@ #include <sys/ioctl.h> #include <sys/mman.h> -#ifdef RTAI_ENABLED -#include <rtai_mbx.h> -#include <rtai_msg.h> -#endif - #include "SIMULATION/TOOLS/defs.h" #include "SIMULATION/RF/defs.h" #include "PHY/types.h" @@ -44,9 +39,6 @@ #ifdef IFFT_FPGA #include "PHY/LTE_REFSIG/mod_table.h" #endif -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #include "SCHED/defs.h" #include "SCHED/vars.h" #include "ARCH/CBMIMO1/DEVICE_DRIVER/vars.h" @@ -381,9 +373,6 @@ int main(int argc, char **argv) uint8_t extended_prefix_flag=0,frame_type=1; int8_t interf1=-21,interf2=-21; LTE_DL_FRAME_PARMS *frame_parms; -#ifdef EMOS - fifo_dump_emos emos_dump; -#endif FILE *input_fd=NULL,*pbch_file_fd=NULL; char input_val_str[50],input_val_str2[50]; @@ -430,13 +419,6 @@ int main(int argc, char **argv) int rx_offset_mod; -#ifdef RTAI_ENABLED - int period; - RTIME expected; - RT_TASK *task; -#define PERIOD 1000000000 -#endif - logInit(); number_of_cards = 1; @@ -694,23 +676,6 @@ int main(int argc, char **argv) } } -#ifdef RTAI_ENABLED - - if (!(task = rt_task_init_schmod(nam2num("SYNCSIM"), 0, 0, 0, SCHED_FIFO, 0xF))) { - printf("CANNOT INIT MASTER TASK\n"); - exit(1); - } - - rt_set_periodic_mode(); - - period = start_rt_timer(nano2count(PERIOD)); - - mlockall(MCL_CURRENT | MCL_FUTURE); - - rt_make_hard_real_time(); - rt_task_make_periodic(task, expected = rt_get_time() + 10*period, period); -#endif - #ifdef XFORMS if (do_forms==1) { @@ -1374,11 +1339,6 @@ int main(int argc, char **argv) for (trial=0; trial<n_frames; trial++) { -#ifdef RTAI_ENABLED - ret = rt_task_wait_period(); - printf("rt_task_wait_period() returns %d, time %llu\n",ret, rt_get_time()); -#endif - if (oai_hw_input == 0) { if (awgn_flag == 0) { @@ -1752,11 +1712,6 @@ int main(int argc, char **argv) ioctl(openair_fd,openair_START_TX_SIG,(void *)NULL); } -#ifdef RTAI_ENABLED - rt_make_soft_real_time(); - rt_task_delete(task); -#endif - #ifdef XFORMS if (do_forms==1) { diff --git a/openair1/SIMULATION/LTE_PHY/ulsim2.c b/openair1/SIMULATION/LTE_PHY/ulsim2.c index d91b35782cfd5985f030d62717d7c6dccb6d8ec7..6a474332e8b4d760a33f01be987c6dd39a756952 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim2.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim2.c @@ -30,9 +30,6 @@ #ifdef IFFT_FPGA #include "PHY/LTE_REFSIG/mod_table.h" #endif -#ifdef EMOS -#include "SCHED/phy_procedures_emos.h" -#endif #define BW 10.0 #define Td 1.0 @@ -69,12 +66,6 @@ int main(int argc, char **argv) double ip =0.0; double N0W, path_loss, path_loss_dB; -#ifdef EMOS - fifo_dump_emos emos_dump; -#endif - - - if (argc>1) sigma2_dB = atoi(argv[1]); diff --git a/openair1/SIMULATION/RF/Makefile b/openair1/SIMULATION/RF/Makefile index 5b713b1d947967778658b23e3889393d44be5cc5..c6c03ad8d59f14a908ac70bc9015f3c0b0225ab3 100644 --- a/openair1/SIMULATION/RF/Makefile +++ b/openair1/SIMULATION/RF/Makefile @@ -1,6 +1,6 @@ include $(OPENAIR_DIR)/common/utils/Makefile.inc OBJS = rf.o ../../PHY/TOOLS/file_output.o ../TOOLS/rangen_double.o -CFLAGS += -DRF_MAIN -DUSER_MODE -DDEBUG_PHY +CFLAGS += -DRF_MAIN -DDEBUG_PHY all: $(OBJS) gcc -o rf $(OBJS) -lm diff --git a/openair1/SIMULATION/TOOLS/rangen_double.c b/openair1/SIMULATION/TOOLS/rangen_double.c index 5168a64ef40a667a611b4088e3763f861e2f3aaa..0fc01a8d3132233ff34502b71466e4a3886adb3a 100644 --- a/openair1/SIMULATION/TOOLS/rangen_double.c +++ b/openair1/SIMULATION/TOOLS/rangen_double.c @@ -19,12 +19,10 @@ * contact@openairinterface.org */ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> -#endif #include "defs.h" diff --git a/openair1/SIMULATION/TOOLS/taus.c b/openair1/SIMULATION/TOOLS/taus.c index a86be23aec6a5c92fa463aa356f3ce0d7c5e43ed..0be7952da71c4fa017e13c7a76a4f8a25342497d 100644 --- a/openair1/SIMULATION/TOOLS/taus.c +++ b/openair1/SIMULATION/TOOLS/taus.c @@ -19,18 +19,8 @@ * contact@openairinterface.org */ -#ifdef USER_MODE #include <time.h> #include <stdlib.h> -#else -#include <asm/io.h> -#include <asm/rtai.h> -#endif -#ifdef RTAI_ENABLED -#include <rtai.h> -#include <rtai_sched.h> -#define time(x) (unsigned int)(rt_get_time_ns()) -#endif unsigned int s0, s1, s2, b; @@ -55,21 +45,14 @@ unsigned int taus(void) void set_taus_seed(unsigned int seed_init) { -#ifdef USER_MODE struct drand48_data buffer; unsigned long result = 0; -#endif if (seed_init == 0) { s0 = (unsigned int)time(NULL); s1 = (unsigned int)time(NULL); s2 = (unsigned int)time(NULL); } else { -#ifndef USER_MODE - s0 = (unsigned int)0x1e23d852; - s1 = (unsigned int)0x81f38a1c; - s2 = (unsigned int)0xfe1a133e; -#else /* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */ srand48_r((long int)seed_init, &buffer); mrand48_r(&buffer, (long int *)&result); @@ -78,7 +61,6 @@ void set_taus_seed(unsigned int seed_init) s1 = result; mrand48_r(&buffer, (long int *)&result); s2 = result; -#endif } } #endif @@ -87,10 +69,8 @@ void set_taus_seed(unsigned int seed_init) void set_taus_seed(unsigned int seed_init) { -#ifdef USER_MODE struct drand48_data buffer; unsigned long result = 0; -#endif s0 = (unsigned int)0x1e23d852; s1 = (unsigned int)0x81f38a1c; s2 = (unsigned int)0xfe1a133e; @@ -102,11 +82,6 @@ void set_taus_seed(unsigned int seed_init) s1 = (unsigned int)time(NULL); s2 = (unsigned int)time(NULL); } else { -#ifndef USER_MODE - s0 = (unsigned int)0x1e23d852; - s1 = (unsigned int)0x81f38a1c; - s2 = (unsigned int)0xfe1a133e; -#else // Use reentrant version of rand48 to ensure that no conflicts with other generators occur */ srand48_r((long int)seed_init, &buffer); mrand48_r(&buffer, (long int *)&result); @@ -115,7 +90,6 @@ void set_taus_seed(unsigned int seed_init) s1 = result; mrand48_r(&buffer, (long int *)&result); s2 = result; -#endif } } #endif diff --git a/openair2/COMMON/mac_messages_def.h b/openair2/COMMON/mac_messages_def.h index c1135a34ae05cbae7143d4be13f5eba70f31861e..fcb45431491b940a8646600b2bccec82626b4951 100644 --- a/openair2/COMMON/mac_messages_def.h +++ b/openair2/COMMON/mac_messages_def.h @@ -40,3 +40,5 @@ MESSAGE_DEF(RRC_MAC_CCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcMacCcchDat MESSAGE_DEF(RRC_MAC_MCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcMacMcchDataReq, rrc_mac_mcch_data_req) MESSAGE_DEF(RRC_MAC_MCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcMacMcchDataInd, rrc_mac_mcch_data_ind) + +MESSAGE_DEF(RRC_MAC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcMacPcchDataReq, rrc_mac_pcch_data_req) diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index 292dc1775dc93bd7ecd30b328e10075b5d93a6ed..930a073621c712c3f08819d8a87fc36b19699b21 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -43,11 +43,13 @@ #define RRC_MAC_MCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_mcch_data_req #define RRC_MAC_MCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_mcch_data_ind +#define RRC_MAC_PCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_pcch_data_req // Some constants from "LAYER2/MAC/defs.h" #define BCCH_SDU_SIZE (512) #define CCCH_SDU_SIZE (512) #define MCCH_SDU_SIZE (512) +#define PCCH_SDU_SIZE (512) //-------------------------------------------------------------------------------------------// @@ -115,4 +117,10 @@ typedef struct RrcMacMcchDataInd_s { uint8_t mbsfn_sync_area; } RrcMacMcchDataInd; +typedef struct RrcMacPcchDataReq_s { + uint32_t frame; + uint32_t sdu_size; + uint8_t sdu[PCCH_SDU_SIZE]; + uint8_t enb_index; +} RrcMacPcchDataReq; #endif /* MAC_MESSAGES_TYPES_H_ */ diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h index df5e0848b163496ad02305d665dc2b088f528a82..6efa4e4d94b3ae9a02718354e53aa278796e6853 100644 --- a/openair2/COMMON/mac_rrc_primitives.h +++ b/openair2/COMMON/mac_rrc_primitives.h @@ -244,9 +244,7 @@ typedef struct { LCHAN_DESC Lchan_desc[2]; /*!< \brief Logical Channel QoS Descriptor (MAC component) */ uint8_t L3_info_type; uint8_t L3_info[16]; - //#ifndef CELLULAR unsigned short UE_eNB_index; - //#endif } __attribute__ ((__packed__)) MAC_CONFIG_REQ; #define MAC_CONFIG_REQ_SIZE sizeof(MAC_CONFIG_REQ) @@ -314,18 +312,12 @@ typedef struct { #ifndef OPENAIR2_IN -#ifndef CELLULAR -//#include "L3_rrc_defs.h" -#endif - typedef struct { //RRC_INTERFACE_FUNCTIONS unsigned int Frame_index; unsigned short UE_index[NB_MODULES_MAX][NB_SIG_CNX_UE]; uint8_t eNB_id[NB_MODULES_MAX][NB_CNX_UE]; -#ifndef CELLULAR // L2_ID UE_id[NB_MODULES_MAX][NB_CNX_CH]; uint8_t UE_id[NB_MODULES_MAX][NB_CNX_CH][5]; -#endif void (*openair_rrc_top_init)(void); char (*openair_rrc_eNB_init)(uint8_t ); char (*openair_rrc_UE_init)(uint8_t, uint8_t); diff --git a/openair2/COMMON/openair_defs.h b/openair2/COMMON/openair_defs.h index 908f8f98131cc5df026f635f040b9d80dd9bb1fd..4d8d50606c814a6e6ccc77ebbfbba93686c19042 100644 --- a/openair2/COMMON/openair_defs.h +++ b/openair2/COMMON/openair_defs.h @@ -22,12 +22,6 @@ #ifndef __openair_DEFS_H__ #define __openair_DEFS_H__ -#ifndef USER_MODE -#include <linux/kernel.h> -#endif //USER_MODE - - -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> #if !defined (msg) @@ -49,44 +43,7 @@ #define PAGE_MASK 0xfffff000 #define virt_to_phys(x) (x) -#else // USER_MODE -#include <rtai.h> -#define msg rt_printk - -#ifdef BIGPHYSAREA - -#define bigmalloc(x) (bigphys_malloc(x)) -#define bigmalloc16(x) (bigphys_malloc(x)) - -#define malloc16(x) (bigphys_malloc(x)) -#define free16(y,x) - -#define bigfree(y,x) - -#else // BIGPHYSAREA - -#define bigmalloc(x) (dma_alloc_coherent(pdev[0],(x),&dummy_dma_ptr,0)) -#define bigmalloc16(x) (dma_alloc_coherent(pdev[0],(x),&dummy_dma_ptr,0)) -#define bigfree(y,x) (dma_free_coherent(pdev[0],(x),(void *)(y),dummy_dma_ptr)) -#define malloc16(x) (kmalloc(x,GFP_KERNEL)) -#define free16(y,x) (kfree(y)) - -#endif // BIGPHYSAREA - - -#ifdef CBMIMO1 -#define openair_get_mbox() (*(unsigned int *)mbox) -#else //CBMIMO1 -#define openair_get_mbox() (*(unsigned int *)PHY_vars->mbox>>1) -#endif //CBMIMO1 - - -#endif // USERMODE - -// #define bzero(s,n) (memset((s),0,(n))) - #define cmax(a,b) ((a>b) ? (a) : (b)) #define cmin(a,b) ((a<b) ? (a) : (b)) #endif // /*__openair_DEFS_H__ */ - diff --git a/openair2/COMMON/openair_types.h b/openair2/COMMON/openair_types.h deleted file mode 100644 index d28380e752eb0588d4b259a91a2cb4a974e573a0..0000000000000000000000000000000000000000 --- a/openair2/COMMON/openair_types.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef __openair_TYPES_H__ -#define __openair_TYPES_H__ - -//#ifdef USER_MODE -//#include <stdint.h> -//typedef int8_t s8; /* 8 bit signed integer */ -//typedef int16_t s16; /* 16 bit signed integer */ -//typedef int32_t s32; /* 32 bit signed integer */ -//typedef int64_t s64; /* 64 bit signed integer */ - -//typedef uint8_t u8; /* 8 bit unsigned integer */ -//typedef uint16_t u16; /* 16 bit unsigned integer */ -//typedef uint32_t u32; /* 32 bit unsigned integer */ -//typedef uint64_t u64; /* 64 bit unsigned integer */ -//#else -//#include <linux/types.h> -//#endif -#endif /*__openair_TYPES_H__ */ diff --git a/openair2/COMMON/pdcp_messages_def.h b/openair2/COMMON/pdcp_messages_def.h index da0d770def60982456d1312874e6828215aed70f..c4be4b2957416ed4fcc96ee17f16514b683129a6 100644 --- a/openair2/COMMON/pdcp_messages_def.h +++ b/openair2/COMMON/pdcp_messages_def.h @@ -30,3 +30,4 @@ // Messages between RRC and PDCP layers MESSAGE_DEF(RRC_DCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataReq, rrc_dcch_data_req) MESSAGE_DEF(RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_dcch_data_ind) +MESSAGE_DEF(RRC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcPcchDataReq, rrc_pcch_data_req) diff --git a/openair2/COMMON/pdcp_messages_types.h b/openair2/COMMON/pdcp_messages_types.h index 033e73e86bbd8370f442d566238d7f01ed78e965..c90490b0fd36077c99f1c023ec33655244b01ca0 100644 --- a/openair2/COMMON/pdcp_messages_types.h +++ b/openair2/COMMON/pdcp_messages_types.h @@ -33,6 +33,7 @@ // Defines to access message fields. #define RRC_DCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_req #define RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_ind +#define RRC_PCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_pcch_data_req //-------------------------------------------------------------------------------------------// // Messages between RRC and PDCP layers @@ -60,4 +61,13 @@ typedef struct RrcDcchDataInd_s { uint8_t eNB_index; // LG: needed in UE } RrcDcchDataInd; +typedef struct RrcPcchDataReq_s { + uint32_t sdu_size; + uint8_t *sdu_p; + uint8_t mode; + uint16_t rnti; + uint8_t ue_index; + uint8_t CC_id; +} RrcPcchDataReq; + #endif /* PDCP_MESSAGES_TYPES_H_ */ diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index 533c5eaa2bfcb20cae20988d4abb792ec0161ec9..f4004bdbf991c4c87bec639aacfb13d3071caf76 100644 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -43,7 +43,6 @@ #define NL_MAX_PAYLOAD 9000 /* this should cover the max mtu size*/ #endif -#ifdef USER_MODE #ifdef LARGE_SCALE # define NB_MODULES_MAX 128 # define NB_NODE_MAX 128 @@ -51,11 +50,6 @@ # define NB_MODULES_MAX 32 # define NB_NODE_MAX 32 #endif -#else -# define NB_MODULES_MAX 1 -# define NB_NODE_MAX 1 -#endif //PHY_EMUL - #ifdef JUMBO_FRAME # define MAX_IP_PACKET_SIZE 10000 // 9000 @@ -132,9 +126,7 @@ #define UNUSED_PARAM_MBMS_SESSION_ID 0 #define UNUSED_PARAM_MBMS_SERVICE_ID 0 -#ifdef USER_MODE #define printk printf -#endif #define UNUSED_VARIABLE(vARIABLE) (void)(vARIABLE) diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index b43f06df80adca5861ce8e5b5efe8b63ca1fee48..0939bdd4c3de0e0b6561b06ab5c9791f0b23787b 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -30,7 +30,7 @@ #ifndef __PLATFORM_TYPES_H__ # define __PLATFORM_TYPES_H__ -#ifdef USER_MODE +#if !defined(NAS_NETLINK) #include <stdint.h> #endif @@ -277,29 +277,5 @@ typedef struct protocol_ctxt_s { (CTXT_Pp)->module_id, \ (CTXT_Pp)->rnti -#ifdef OAI_EMU -#define CHECK_CTXT_ARGS(CTXT_Pp) \ - if ((CTXT_Pp)->enb_flag) {\ - AssertFatal (((CTXT_Pp)->module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),\ - "eNB module id is too low (%u/%d/%d)!\n",\ - (CTXT_Pp)->module_id,\ - oai_emulation.info.first_enb_local,\ - oai_emulation.info.nb_enb_local);\ - AssertFatal (((CTXT_Pp)->module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),\ - "eNB module id is too high (%u/%d)!\n",\ - (CTXT_Pp)->module_id,\ - oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);\ - } else {\ - AssertFatal ((CTXT_Pp)->module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),\ - "UE module id is too high (%u/%d)!\n",\ - (CTXT_Pp)->module_id,\ - oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);\ - AssertFatal ((CTXT_Pp)->module_id >= oai_emulation.info.first_ue_local,\ - "UE module id is too low (%u/%d)!\n",\ - (CTXT_Pp)->module_id,\ - oai_emulation.info.first_ue_local);\ - } -#else #define CHECK_CTXT_ARGS(CTXT_Pp) #endif -#endif diff --git a/openair2/COMMON/rtos_header.h b/openair2/COMMON/rtos_header.h index 63bc57d9423994d7600f7567249c4f397dc161fa..05fc33463d6454abb7249fe217fab838f58c414a 100644 --- a/openair2/COMMON/rtos_header.h +++ b/openair2/COMMON/rtos_header.h @@ -20,45 +20,13 @@ */ #ifndef _RTOS_HEADER_H_ -# define _RTOS_HEADER_H_ -# if defined(RTAI) && !defined(USER_MODE) -// CONVERSION BETWEEN POSIX PTHREAD AND RTAI FUNCTIONS -/* -# define pthread_mutex_init pthread_mutex_init_rt -# define pthread_mutexattr_init pthread_mutexattr_init_rt -# define pthread_mutex_lock pthread_mutex_lock_rt -# define pthread_mutex_unlock pthread_mutex_unlock_rt -# define pthread_mutex_destroy pthread_mutex_destroy_rt -# define pthread_cond_init pthread_cond_init_rt -# define pthread_cond_wait pthread_cond_wait_rt -# define pthread_cond_signal pthread_cond_signal_rt -# define pthread_cond_destroy pthread_cond_destroy_rt -# define pthread_attr_init pthread_attr_init_rt -# define pthread_attr_setschedparam pthread_attr_setschedparam_rt -# define pthread_create pthread_create_rt -# define pthread_cancel pthread_cancel_rt -# define pthread_delete_np pthread_cancel_rt -# define pthread_attr_setstacksize pthread_attr_setstacksize_rt -# define pthread_self rt_whoami -*/ -# include <asm/rtai.h> -# include <rtai.h> -# include <rtai_posix.h> -# include <rtai_fifos.h> -# include <rtai_sched.h> -# ifdef CONFIG_PROC_FS -# include <rtai_proc_fs.h> -# endif -# else -# ifdef USER_MODE -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -# include <math.h> -# include <pthread.h> -# include <assert.h> -# define rtf_get read -# define rtf_put write -# endif -# endif +#define _RTOS_HEADER_H_ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <pthread.h> +#include <assert.h> +#define rtf_get read +#define rtf_put write #endif diff --git a/openair2/COMMON/s1ap_messages_def.h b/openair2/COMMON/s1ap_messages_def.h index d3d853c7e714532e36d12119e19e0f8520ccf624..a39953d8f77e777ca79b1e4644be41690ae3f799 100644 --- a/openair2/COMMON/s1ap_messages_def.h +++ b/openair2/COMMON/s1ap_messages_def.h @@ -33,6 +33,11 @@ MESSAGE_DEF(S1AP_UE_CONTEXT_RELEASE_COMPLETE_LOG, MESSAGE_PRIORITY_MED, IttiMsgT MESSAGE_DEF(S1AP_UE_CONTEXT_RELEASE_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_ue_context_release_log) MESSAGE_DEF(S1AP_E_RAB_SETUP_REQUEST_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_setup_request_log) MESSAGE_DEF(S1AP_E_RAB_SETUP_RESPONSE_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_setup_response_log) +MESSAGE_DEF(S1AP_E_RAB_MODIFY_REQUEST_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_modify_request_log) +MESSAGE_DEF(S1AP_E_RAB_MODIFY_RESPONSE_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_modify_response_log) +MESSAGE_DEF(S1AP_PAGING_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_paging_log) +MESSAGE_DEF(S1AP_E_RAB_RELEASE_REQUEST_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_release_request_log) +MESSAGE_DEF(S1AP_E_RAB_RELEASE_RESPONSE_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_release_response_log) /* eNB application layer -> S1AP messages */ MESSAGE_DEF(S1AP_REGISTER_ENB_REQ , MESSAGE_PRIORITY_MED, s1ap_register_enb_req_t , s1ap_register_enb_req) @@ -54,6 +59,8 @@ MESSAGE_DEF(S1AP_UE_CTXT_MODIFICATION_RESP , MESSAGE_PRIORITY_MED, s1ap_ue_ctxt_ MESSAGE_DEF(S1AP_UE_CTXT_MODIFICATION_FAIL , MESSAGE_PRIORITY_MED, s1ap_ue_ctxt_modification_fail_t , s1ap_ue_ctxt_modification_fail) MESSAGE_DEF(S1AP_E_RAB_SETUP_RESP , MESSAGE_PRIORITY_MED, s1ap_e_rab_setup_resp_t , s1ap_e_rab_setup_resp) MESSAGE_DEF(S1AP_E_RAB_SETUP_REQUEST_FAIL , MESSAGE_PRIORITY_MED, s1ap_e_rab_setup_req_fail_t , s1ap_e_rab_setup_request_fail) +MESSAGE_DEF(S1AP_E_RAB_MODIFY_RESP , MESSAGE_PRIORITY_MED, s1ap_e_rab_modify_resp_t , s1ap_e_rab_modify_resp) +MESSAGE_DEF(S1AP_E_RAB_RELEASE_RESPONSE , MESSAGE_PRIORITY_MED, s1ap_e_rab_release_resp_t , s1ap_e_rab_release_resp) /* S1AP -> RRC messages */ MESSAGE_DEF(S1AP_DOWNLINK_NAS , MESSAGE_PRIORITY_MED, s1ap_downlink_nas_t , s1ap_downlink_nas ) @@ -61,6 +68,8 @@ MESSAGE_DEF(S1AP_INITIAL_CONTEXT_SETUP_REQ , MESSAGE_PRIORITY_MED, s1ap_initial_ MESSAGE_DEF(S1AP_UE_CTXT_MODIFICATION_REQ , MESSAGE_PRIORITY_MED, s1ap_ue_ctxt_modification_req_t , s1ap_ue_ctxt_modification_req) MESSAGE_DEF(S1AP_PAGING_IND , MESSAGE_PRIORITY_MED, s1ap_paging_ind_t , s1ap_paging_ind ) MESSAGE_DEF(S1AP_E_RAB_SETUP_REQ , MESSAGE_PRIORITY_MED, s1ap_e_rab_setup_req_t , s1ap_e_rab_setup_req ) +MESSAGE_DEF(S1AP_E_RAB_MODIFY_REQ , MESSAGE_PRIORITY_MED, s1ap_e_rab_modify_req_t , s1ap_e_rab_modify_req ) +MESSAGE_DEF(S1AP_E_RAB_RELEASE_COMMAND , MESSAGE_PRIORITY_MED, s1ap_e_rab_release_command_t , s1ap_e_rab_release_command) MESSAGE_DEF(S1AP_UE_CONTEXT_RELEASE_COMMAND, MESSAGE_PRIORITY_MED, s1ap_ue_release_command_t , s1ap_ue_release_command) /* S1AP <-> RRC messages (can be initiated either by MME or eNB) */ diff --git a/openair2/COMMON/s1ap_messages_types.h b/openair2/COMMON/s1ap_messages_types.h index c17097d4ecb9b3b3ea02d13e8d618e863dc69df1..4a5f492b0baa3f4685c8de48f342ff6075e02d8f 100644 --- a/openair2/COMMON/s1ap_messages_types.h +++ b/openair2/COMMON/s1ap_messages_types.h @@ -41,6 +41,7 @@ #define S1AP_UE_CTXT_MODIFICATION_FAIL(mSGpTR) (mSGpTR)->ittiMsg.s1ap_ue_ctxt_modification_fail #define S1AP_E_RAB_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.s1ap_e_rab_setup_resp #define S1AP_E_RAB_SETUP_FAIL(mSGpTR) (mSGpTR)->ittiMsg.s1ap_e_rab_setup_req_fail +#define S1AP_E_RAB_MODIFY_RESP(mSGpTR) (mSGpTR)->ittiMsg.s1ap_e_rab_modify_resp #define S1AP_DOWNLINK_NAS(mSGpTR) (mSGpTR)->ittiMsg.s1ap_downlink_nas #define S1AP_INITIAL_CONTEXT_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_initial_context_setup_req @@ -48,9 +49,12 @@ #define S1AP_UE_CONTEXT_RELEASE_COMMAND(mSGpTR) (mSGpTR)->ittiMsg.s1ap_ue_release_command #define S1AP_UE_CONTEXT_RELEASE_COMPLETE(mSGpTR) (mSGpTR)->ittiMsg.s1ap_ue_release_complete #define S1AP_E_RAB_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_e_rab_setup_req -#define S1AP_PAGIND_IND(mSGpTR) (mSGpTR)->ittiMsg.s1ap_paging_ind +#define S1AP_E_RAB_MODIFY_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_e_rab_modify_req +#define S1AP_PAGING_IND(mSGpTR) (mSGpTR)->ittiMsg.s1ap_paging_ind #define S1AP_UE_CONTEXT_RELEASE_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_ue_release_req +#define S1AP_E_RAB_RELEASE_COMMAND(mSGpTR) (mSGpTR)->ittiMsg.s1ap_e_rab_release_command +#define S1AP_E_RAB_RELEASE_RESPONSE(mSGpTR) (mSGpTR)->ittiMsg.s1ap_e_rab_release_resp //-------------------------------------------------------------------------------------------// /* Maximum number of e-rabs to be setup/deleted in a single message. @@ -175,6 +179,11 @@ typedef struct s1ap_gummei_s { uint16_t mme_group_id; } s1ap_gummei_t; +typedef struct s1ap_imsi_s { + uint8_t buffer[S1AP_IMSI_LENGTH]; + uint8_t length; +} s1ap_imsi_t; + typedef struct s_tmsi_s { uint8_t mme_code; uint32_t m_tmsi; @@ -189,7 +198,7 @@ typedef enum ue_paging_identity_presenceMask_e { typedef struct ue_paging_identity_s { ue_paging_identity_presenceMask_t presenceMask; union { - char imsi[S1AP_IMSI_LENGTH]; + s1ap_imsi_t imsi; s_tmsi_t s_tmsi; } choice; } ue_paging_identity_t; @@ -260,11 +269,29 @@ typedef struct e_rab_setup_s { uint32_t gtp_teid; } e_rab_setup_t; +typedef struct e_rab_modify_s { + /* Unique e_rab_id for the UE. */ + uint8_t e_rab_id; +} e_rab_modify_t; + +typedef enum S1ap_Cause_e { + S1AP_CAUSE_NOTHING, /* No components present */ + S1AP_CAUSE_RADIO_NETWORK, + S1AP_CAUSE_TRANSPORT, + S1AP_CAUSE_NAS, + S1AP_CAUSE_PROTOCOL, + S1AP_CAUSE_MISC, + /* Extensions may appear below */ + +} s1ap_Cause_t; + typedef struct e_rab_failed_s { /* Unique e_rab_id for the UE. */ uint8_t e_rab_id; /* Cause of the failure */ // cause_t cause; + s1ap_Cause_t cause; + uint8_t cause_value; } e_rab_failed_t; typedef enum s1ap_ue_ctxt_modification_present_s { @@ -460,6 +487,12 @@ typedef struct s1ap_initial_context_setup_req_s { e_rab_t e_rab_param[S1AP_MAX_E_RAB]; } s1ap_initial_context_setup_req_t; +typedef struct tai_plmn_identity_s { + uint16_t mcc; + uint16_t mnc; + uint8_t mnc_digit_length; +} plmn_identity_t; + typedef struct s1ap_paging_ind_s { /* UE identity index value. * Specified in 3GPP TS 36.304 @@ -472,6 +505,15 @@ typedef struct s1ap_paging_ind_s { /* Indicates origin of paging */ cn_domain_t cn_domain; + /* PLMN_identity in TAI of Paging*/ + plmn_identity_t plmn_identity[256]; + + /* TAC in TAIList of Paging*/ + int16_t tac[256]; + + /* size of TAIList*/ + int16_t tai_size; + /* Optional fields */ paging_drx_t paging_drx; @@ -520,16 +562,6 @@ typedef struct s1ap_ue_release_command_s { //-------------------------------------------------------------------------------------------// -typedef enum S1ap_Cause_e { - S1AP_CAUSE_NOTHING, /* No components present */ - S1AP_CAUSE_RADIO_NETWORK, - S1AP_CAUSE_TRANSPORT, - S1AP_CAUSE_NAS, - S1AP_CAUSE_PROTOCOL, - S1AP_CAUSE_MISC, - /* Extensions may appear below */ - -} s1ap_Cause_t; // S1AP <-- RRC messages typedef struct s1ap_ue_release_req_s { unsigned eNB_ue_s1ap_id:24; @@ -537,4 +569,78 @@ typedef struct s1ap_ue_release_req_s { long cause_value; } s1ap_ue_release_req_t, s1ap_ue_release_resp_t; +typedef struct s1ap_e_rab_modify_req_s { + /* UE id for initial connection to S1AP */ + uint16_t ue_initial_id; + + /* MME UE id */ + uint16_t mme_ue_s1ap_id; + + /* eNB ue s1ap id as initialized by S1AP layer */ + unsigned eNB_ue_s1ap_id:24; + + /* Number of e_rab to be modify in the list */ + uint8_t nb_e_rabs_tomodify; + + /* E RAB modify request */ + e_rab_t e_rab_modify_params[S1AP_MAX_E_RAB]; +} s1ap_e_rab_modify_req_t; + +typedef struct s1ap_e_rab_modify_resp_s { + unsigned eNB_ue_s1ap_id:24; + + /* Number of e_rab modify-ed in the list */ + uint8_t nb_of_e_rabs; + /* list of e_rab modify-ed by RRC layers */ + e_rab_modify_t e_rabs[S1AP_MAX_E_RAB]; + + /* Number of e_rab failed to be modify in list */ + uint8_t nb_of_e_rabs_failed; + /* list of e_rabs that failed to be modify */ + e_rab_failed_t e_rabs_failed[S1AP_MAX_E_RAB]; +} s1ap_e_rab_modify_resp_t; + +typedef struct e_rab_release_s { + /* Unique e_rab_id for the UE. */ + uint8_t e_rab_id; +} e_rab_release_t; + +typedef struct s1ap_e_rab_release_command_s { + /* MME UE id */ + uint16_t mme_ue_s1ap_id; + + /* eNB ue s1ap id as initialized by S1AP layer */ + unsigned eNB_ue_s1ap_id:24; + + /* The NAS PDU should be forwarded by the RRC layer to the NAS layer */ + nas_pdu_t nas_pdu; + + /* Number of e_rab to be released in the list */ + uint8_t nb_e_rabs_torelease; + + /* E RAB release command */ + e_rab_release_t e_rab_release_params[S1AP_MAX_E_RAB]; + +} s1ap_e_rab_release_command_t; + +typedef struct s1ap_e_rab_release_resp_s { + /* MME UE id */ + uint16_t mme_ue_s1ap_id; + + /* eNB ue s1ap id as initialized by S1AP layer */ + unsigned eNB_ue_s1ap_id:24; + + /* Number of e_rab released in the list */ + uint8_t nb_of_e_rabs_released; + + /* list of e_rabs released */ + e_rab_release_t e_rab_release[S1AP_MAX_E_RAB]; + + /* Number of e_rab failed to be released in list */ + uint8_t nb_of_e_rabs_failed; + /* list of e_rabs that failed to be released */ + e_rab_failed_t e_rabs_failed[S1AP_MAX_E_RAB]; + +} s1ap_e_rab_release_resp_t; + #endif /* S1AP_MESSAGES_TYPES_H_ */ diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 790d95a6d5939d214e95519195ac613ffd640b13..17675070140d0b00086b0b097e431cf8074789a3 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -36,10 +36,6 @@ #include "common/ran_context.h" #include "log.h" -#if defined(OAI_EMU) -# include "OCG.h" -# include "OCG_extern.h" -#endif #if defined(ENABLE_ITTI) # include "intertask_interface.h" @@ -217,9 +213,6 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)//, uint32_t register_enb_pending = 0; for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { -# if defined(OAI_EMU) - if (oai_emulation.info.cli_start_enb[enb_id] == 1) -# endif { s1ap_register_enb_req_t *s1ap_register_eNB; @@ -308,10 +301,9 @@ void *eNB_app_task(void *args_p) LOG_I(PHY, "%s() Task ready initialise structures\n", __FUNCTION__); - // Panos - //if (nfapi_mode!= 2 && nfapi_mode!= 3){ + RCconfig_L1(); - //} + RCconfig_macrlc(); @@ -319,19 +311,6 @@ void *eNB_app_task(void *args_p) if (RC.nb_L1_inst>0) AssertFatal(l1_north_init_eNB()==0,"could not initialize L1 north interface\n"); - # if defined(ENABLE_ITTI) -# if defined(OAI_EMU) - enb_nb = oai_emulation.info.nb_enb_local; - enb_id_start = oai_emulation.info.first_enb_local; - enb_id_end = oai_emulation.info.first_enb_local + enb_nb; - - AssertFatal (enb_id_end <= NUMBER_OF_eNB_MAX, - "Last eNB index is greater or equal to maximum eNB index (%d/%d)!", - enb_id_end, NUMBER_OF_eNB_MAX); -# endif - # endif - - AssertFatal (enb_nb <= RC.nb_inst, "Number of eNB is greater than eNB defined in configuration file (%d/%d)!", enb_nb, RC.nb_inst); @@ -407,16 +386,6 @@ void *eNB_app_task(void *args_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); -# if defined(OAI_EMU) - - /* Also inform all NAS UE tasks */ - for (instance = NB_eNB_INST + oai_emulation.info.first_ue_local; - instance < (NB_eNB_INST + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); instance ++) { - msg_init_p = itti_alloc_new_message (TASK_ENB_APP, INITIALIZE_MESSAGE); - itti_send_msg_to_task (TASK_NAS_UE, instance, msg_init_p); - } - -# endif } else { uint32_t not_associated = enb_nb - registered_enb; diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index c20e447c07efcd1a21ab7362e6f8c7fd646134dd..3041b696e39230f414c97d1b89fdeec54508b6dc 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -36,10 +36,6 @@ #include "enb_config.h" #include "UTIL/OTG/otg.h" #include "UTIL/OTG/otg_externs.h" -#if defined(OAI_EMU) -# include "OCG.h" -# include "OCG_extern.h" -#endif #if defined(ENABLE_ITTI) # include "intertask_interface.h" # if defined(ENABLE_USE_MME) @@ -103,139 +99,6 @@ static int enb_check_band_frequencies(char* lib_config_file_name_pP, } -/* --------------------------------------------------------*/ -/* 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); - - - if ( RUParamList.numelt > 0) { - - RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*)); - - - - - RC.ru_mask=(1<<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]->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]; - - - 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)); - 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]; - } //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; - } - RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); - RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); - } /* 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); - - }// j=0..num_rus - } else { - RC.nb_RU = 0; - } // setting != NULL - - return; - -} - - - void UE_config_stub_pnf(void) { int j; paramdef_t L1_Params[] = L1PARAMS_DESC; @@ -282,37 +145,10 @@ void UE_config_stub_pnf(void) { } else { - /*LOG_I(PHY,"No " CONFIG_STRING_L1_LIST " configuration found"); - - // DJP need to create some structures for VNF - - j = 0; - - RC.nb_L1_CC = malloc((1+RC.nb_L1_inst)*sizeof(int)); // DJP - 1 lot then??? - - RC.nb_L1_CC[j]=1; // DJP - hmmm - - if (RC.eNB[j] == NULL) { - RC.eNB[j] = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB**)); - LOG_I(PHY,"RC.eNB[%d] = %p\n",j,RC.eNB[j]); - memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB***)); - } - - for (i=0;i<RC.nb_L1_CC[j];i++) { - if (RC.eNB[j][i] == NULL) { - RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB)); - memset((void*)RC.eNB[j][i],0,sizeof(PHY_VARS_eNB)); - LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]); - RC.eNB[j][i]->Mod_id = j; - RC.eNB[j][i]->CC_id = i; - } - }*/ } } - - void RCconfig_L1(void) { int i,j; paramdef_t L1_Params[] = L1PARAMS_DESC; @@ -332,17 +168,14 @@ void RCconfig_L1(void) { RC.nb_L1_CC[j] = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr); if (RC.eNB[j] == NULL) { - RC.eNB[j] = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB**)); + RC.eNB[j] = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB*)); LOG_I(PHY,"RC.eNB[%d] = %p\n",j,RC.eNB[j]); - memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB***)); - //printf("Panos-D: RCconfig_L1 99"); + memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB*)); } for (i=0;i<RC.nb_L1_CC[j];i++) { - //printf("Panos-D: RCconfig_L1 9"); if (RC.eNB[j][i] == NULL) { - //printf("Panos-D: RCconfig_L1 10"); - RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB)); + RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB)); memset((void*)RC.eNB[j][i],0,sizeof(PHY_VARS_eNB)); LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]); RC.eNB[j][i]->Mod_id = j; @@ -364,7 +197,6 @@ void RCconfig_L1(void) { RC.eNB[j][0]->eth_params_n.remote_portd = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); RC.eNB[j][0]->eth_params_n.transp_preference = ETH_UDP_MODE; - //printf("Panos-D: RCconfig_L1 11"); sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2 RC.nb_macrlc_inst = 1; // This is used by mac_top_init_eNB() @@ -400,22 +232,16 @@ void RCconfig_L1(void) { RC.nb_L1_CC[j]=1; // DJP - hmmm - //printf("Panos-D: RCconfig_L1 13 \n"); if (RC.eNB[j] == NULL) { - RC.eNB[j] = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB*)); - //printf("Panos-D: RCconfig_L1 13 \n"); + RC.eNB[j] = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB**)); LOG_I(PHY,"RC.eNB[%d] = %p\n",j,RC.eNB[j]); - memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB*)); - //printf("Panos-D: RCconfig_L1 14 \n"); + memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB***)); } for (i=0;i<RC.nb_L1_CC[j];i++) { if (RC.eNB[j][i] == NULL) { - //printf("Panos-D: RCconfig_L1 15 \n"); RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB)); - //printf("Panos-D: RCconfig_L1 16 \n"); memset((void*)RC.eNB[j][i],0,sizeof(PHY_VARS_eNB)); - //printf("Panos-D: RCconfig_L1 17 \n"); LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]); RC.eNB[j][i]->Mod_id = j; RC.eNB[j][i]->CC_id = i; @@ -3030,7 +2856,9 @@ 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); RC.nb_inst = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 97f520ed0d3b0f237bac533cdb3bbdba403783d3..bc7486b5231e60af214532ec81d9a0fca42fa588 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -61,97 +61,60 @@ extern RAN_CONTEXT_t RC; extern int l2_init_eNB(void); extern void mac_top_init_eNB(void); extern void mac_init_cell_params(int Mod_idP,int CC_idP); -extern void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); extern uint8_t nfapi_mode; - -/* sec 5.9, 36.321: MAC Reset Procedure */ -void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) -{ - - //Resetting Bj - UE_mac_inst[module_idP].scheduling_info.Bj[0] = 0; - UE_mac_inst[module_idP].scheduling_info.Bj[1] = 0; - UE_mac_inst[module_idP].scheduling_info.Bj[2] = 0; - - //Stopping all timers - - //timeAlignmentTimer expires - - // PHY changes for UE MAC reset - phy_reset_ue(module_idP,0,eNB_index); - - // notify RRC to relase PUCCH/SRS - // cancel all pending SRs - UE_mac_inst[module_idP].scheduling_info.SR_pending=0; - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - -//Set BSR Trigger Bmp and remove timer flags - UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; - - // stop ongoing RACH procedure - - // discard explicitly signaled ra_PreambleIndex and ra_RACH_MaskIndex, if any - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = 0; // check! - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; - - - ue_init_mac(module_idP); //This will hopefully do the rest of the MAC reset procedure - -} - int32_t **rxdata; int32_t **txdata; typedef struct eutra_bandentry_s { - int16_t band; - uint32_t ul_min; - uint32_t ul_max; - uint32_t dl_min; - uint32_t dl_max; - uint32_t N_OFFs_DL; + int16_t band; + uint32_t ul_min; + uint32_t ul_max; + uint32_t dl_min; + uint32_t dl_max; + uint32_t N_OFFs_DL; } eutra_bandentry_t; typedef struct band_info_s { - int nbands; - eutra_bandentry_t band_info[100]; + int nbands; + eutra_bandentry_t band_info[100]; } band_info_t; static const eutra_bandentry_t eutra_bandtable[] = { - { 1, 19200, 19800, 21100, 21700, 0}, - { 2, 18500, 19100, 19300, 19900, 6000}, - { 3, 17100, 17850, 18050, 18800, 12000}, - { 4, 17100, 17550, 21100, 21550, 19500}, - { 5, 8240, 8490, 8690, 8940, 24000}, - { 6, 8300, 8400, 8750, 8850, 26500}, - { 7, 25000, 25700, 26200, 26900, 27500}, - { 8, 8800, 9150 , 9250, 9600, 34500}, - { 9, 17499, 17849, 18449, 18799, 38000}, + {1, 19200, 19800, 21100, 21700, 0}, + {2, 18500, 19100, 19300, 19900, 6000}, + {3, 17100, 17850, 18050, 18800, 12000}, + {4, 17100, 17550, 21100, 21550, 19500}, + {5, 8240, 8490, 8690, 8940, 24000}, + {6, 8300, 8400, 8750, 8850, 26500}, + {7, 25000, 25700, 26200, 26900, 27500}, + {8, 8800, 9150, 9250, 9600, 34500}, + {9, 17499, 17849, 18449, 18799, 38000}, {10, 17100, 17700, 21100, 21700, 41500}, {11, 14279, 14529, 14759, 15009, 47500}, - {12, 6980, 7160, 7280, 7460, 50100}, - {13, 7770, 7870, 7460, 7560, 51800}, - {14, 7880, 7980, 7580, 7680, 52800}, - {17, 7040, 7160, 7340, 7460, 57300}, - {18, 8150, 9650, 8600, 10100, 58500}, - {19, 8300, 8450, 8750, 8900, 60000}, - {20, 8320, 8620, 7910, 8210, 61500}, + {12, 6980, 7160, 7280, 7460, 50100}, + {13, 7770, 7870, 7460, 7560, 51800}, + {14, 7880, 7980, 7580, 7680, 52800}, + {17, 7040, 7160, 7340, 7460, 57300}, + {18, 8150, 9650, 8600, 10100, 58500}, + {19, 8300, 8450, 8750, 8900, 60000}, + {20, 8320, 8620, 7910, 8210, 61500}, {21, 14479, 14629, 14959, 15109, 64500}, {22, 34100, 34900, 35100, 35900, 66000}, {23, 20000, 20200, 21800, 22000, 75000}, {24, 16126, 16605, 15250, 15590, 77000}, {25, 18500, 19150, 19300, 19950, 80400}, - {26, 8140 , 8490, 8590, 8940, 86900}, - {27, 8070 , 8240, 8520, 8690, 90400}, - {28, 7030 , 7580, 7580, 8130, 92100}, - {29, 0 , 0 , 7170, 7280, 96600}, + {26, 8140, 8490, 8590, 8940, 86900}, + {27, 8070, 8240, 8520, 8690, 90400}, + {28, 7030, 7580, 7580, 8130, 92100}, + {29, 0, 0, 7170, 7280, 96600}, {30, 23050, 23250, 23500, 23600, 97700}, {31, 45250, 34900, 46250, 35900, 98700}, - {32, 0 , 0 , 14520, 14960, 99200}, + {32, 0, 0, 14520, 14960, 99200}, {33, 19000, 19200, 19000, 19200, 36000}, {34, 20100, 20250, 20100, 20250, 36200}, {35, 18500, 19100, 18500, 19100, 36350}, @@ -163,51 +126,60 @@ static const eutra_bandentry_t eutra_bandtable[] = { {41, 24960, 26900, 24960, 26900, 39650}, {42, 34000, 36000, 34000, 36000, 41590}, {43, 36000, 38000, 36000, 38000, 43590}, - {44, 7030 , 8030, 7030, 8030, 45590}, + {44, 7030, 8030, 7030, 8030, 45590}, {45, 14470, 14670, 14470, 14670, 46590}, {46, 51500, 59250, 51500, 59250, 46790}, {65, 19200, 20100, 21100, 22000, 65536}, {66, 17100, 18000, 21100, 22000, 66436}, - {67, 0 , 0 , 7380, 7580, 67336}, - {68, 6980 , 7280 , 7530, 7830, 67536}}; + {67, 0, 0, 7380, 7580, 67336}, + {68, 6980, 7280, 7530, 7830, 67536} +}; -uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw) { +uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw) +{ - uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq/100000; - int bw_by_100 = bw/100; + uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000; + int bw_by_100 = bw / 100; int i; - AssertFatal(eutra_bandP < 69,"eutra_band %d > 68\n",eutra_bandP); - for (i=0;i<69 && eutra_bandtable[i].band!=eutra_bandP;i++); + AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); + for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++); - AssertFatal(dl_CarrierFreq_by_100k>=eutra_bandtable[i].dl_min, + AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min, "Band %d, bw %u : DL carrier frequency %u Hz < %u\n", - eutra_bandP,bw,dl_CarrierFreq,eutra_bandtable[i].dl_min); - AssertFatal(dl_CarrierFreq_by_100k<=(eutra_bandtable[i].dl_max-bw_by_100), + eutra_bandP, bw, dl_CarrierFreq, + eutra_bandtable[i].dl_min); + AssertFatal(dl_CarrierFreq_by_100k <= + (eutra_bandtable[i].dl_max - bw_by_100), "Band %d, bw %u: DL carrier frequency %u Hz > %d\n", - eutra_bandP,bw,dl_CarrierFreq,eutra_bandtable[i].dl_max-bw_by_100); + eutra_bandP, bw, dl_CarrierFreq, + eutra_bandtable[i].dl_max - bw_by_100); - return(dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + (eutra_bandtable[i].N_OFFs_DL/10)); + return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + + (eutra_bandtable[i].N_OFFs_DL / 10)); } -uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn) { +uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) +{ int i; - AssertFatal(eutra_bandP < 69,"eutra_band %d > 68\n",eutra_bandP); - for (i=0;i<69 && eutra_bandtable[i].band!=eutra_bandP;i++); + AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); + for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++); - return(eutra_bandtable[i].dl_min + (dl_earfcn-(eutra_bandtable[i].N_OFFs_DL/10)))*100000; + return (eutra_bandtable[i].dl_min + + (dl_earfcn - (eutra_bandtable[i].N_OFFs_DL / 10))) * 100000; } -int32_t get_uldl_offset(int eutra_bandP) { +int32_t get_uldl_offset(int eutra_bandP) +{ int i; - for (i=0;i<69 && eutra_bandtable[i].band!=eutra_bandP;i++); - return(eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min); + for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++); + return (eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min); } uint32_t bw_table[6] = {6*180,15*180,25*180,50*180,75*180,100*180}; @@ -300,7 +272,7 @@ LOG_E(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, dl_BandwidthP); "%s() NFAPI_CONFIG_REQUEST(num_tlv:%u) DL_BW:%u UL_BW:%u Ncp %d,p_eNB %d,earfcn %d,band %d,phich_resource %u phich_duration %u phich_power_offset %u PSS %d SSS %d PCI %d" #ifdef Rel14 " PBCH repetition %d" -#endif +#endif "\n" ,__FUNCTION__ ,cfg->num_tlv @@ -317,15 +289,14 @@ LOG_E(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, dl_BandwidthP); ,cfg->sch_config.physical_cell_id.value #ifdef Rel14 ,cfg->emtc_config.pbch_repetitions_enable_r13.value -#endif +#endif ); } -void config_sib1(int Mod_idP, - int CC_idP, - TDD_Config_t *tdd_ConfigP) { +void config_sib1(int Mod_idP, int CC_idP, TDD_Config_t * tdd_ConfigP) +{ - nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; + nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; if (tdd_ConfigP) { //TDD cfg->subframe_config.duplex_mode.value = 0; @@ -346,23 +317,21 @@ void config_sib1(int Mod_idP, cfg->num_tlv++; // Note no half-duplex here } - - } +int power_off_dB[6] = { 78, 118, 140, 170, 188, 200 }; -int power_off_dB[6] = {78,118,140,170,188,200}; - -void config_sib2(int Mod_idP, - int CC_idP, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommonP, +void +config_sib2(int Mod_idP, + int CC_idP, + RadioResourceConfigCommonSIB_t * radioResourceConfigCommonP, #ifdef Rel14 - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BRP, + RadioResourceConfigCommonSIB_t * radioResourceConfigCommon_BRP, #endif - ARFCN_ValueEUTRA_t *ul_CArrierFreqP, - long *ul_BandwidthP, - AdditionalSpectrumEmission_t *additionalSpectrumEmissionP, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigListP) { + ARFCN_ValueEUTRA_t *ul_CArrierFreqP, + long *ul_BandwidthP, + AdditionalSpectrumEmission_t *additionalSpectrumEmissionP, + struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigListP) { nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; @@ -411,9 +380,6 @@ void config_sib2(int Mod_idP, cfg->pusch_config.hopping_offset.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG; cfg->num_tlv++; - - - cfg->pucch_config.delta_pucch_shift.value = radioResourceConfigCommonP->pucch_ConfigCommon.deltaPUCCH_Shift; cfg->pucch_config.delta_pucch_shift.tl.tag = NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG; cfg->num_tlv++; @@ -430,7 +396,6 @@ void config_sib2(int Mod_idP, cfg->pucch_config.n1_pucch_an.tl.tag = NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG; cfg->num_tlv++; - if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == true) { cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 1; @@ -468,62 +433,76 @@ void config_sib2(int Mod_idP, cfg->srs_config.srs_acknack_srs_simultaneous_transmission.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; cfg->srs_config.srs_acknack_srs_simultaneous_transmission.tl.tag = NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG; cfg->num_tlv++; - - - if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) { - cfg->srs_config.max_up_pts.value = 1; - } - else { - cfg->srs_config.max_up_pts.value = 0; + + + nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; + + cfg->subframe_config.pb.value = radioResourceConfigCommonP->pdsch_ConfigCommon.p_b; + cfg->rf_config.reference_signal_power.value = radioResourceConfigCommonP->pdsch_ConfigCommon.referenceSignalPower; + cfg->nfapi_config.max_transmit_power.value = cfg->rf_config.reference_signal_power.value + + power_off_dB[cfg->rf_config.dl_channel_bandwidth.value]; + + cfg->prach_config.configuration_index.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_ConfigIndex; + cfg->prach_config.root_sequence_index.value = radioResourceConfigCommonP->prach_Config.rootSequenceIndex; + cfg->prach_config.zero_correlation_zone_configuration.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; + cfg->prach_config.high_speed_flag.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.highSpeedFlag; + cfg->prach_config.frequency_offset.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_FreqOffset; + + cfg->pusch_config.hopping_mode.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; + cfg->pusch_config.number_of_subbands.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; + cfg->pusch_config.hopping_offset.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; + + cfg->pucch_config.delta_pucch_shift.value = radioResourceConfigCommonP->pucch_ConfigCommon.deltaPUCCH_Shift; + cfg->pucch_config.n_cqi_rb.value = radioResourceConfigCommonP->pucch_ConfigCommon.nRB_CQI; + cfg->pucch_config.n_an_cs.value = radioResourceConfigCommonP->pucch_ConfigCommon.nCS_AN; + cfg->pucch_config.n1_pucch_an.value = radioResourceConfigCommonP->pucch_ConfigCommon.n1PUCCH_AN; + + if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == true) + cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 1; + else if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled == true) + cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 2; + else // No hopping + cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 0; + + cfg->uplink_reference_signal_config.group_assignment.value = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; + cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.value = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift; + + // how to enable/disable SRS? + if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.present == SoundingRS_UL_ConfigCommon_PR_setup) { + cfg->srs_config.bandwidth_configuration.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig; + cfg->srs_config.srs_subframe_configuration.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig; + cfg->srs_config.srs_acknack_srs_simultaneous_transmission.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; + + if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) + cfg->srs_config.max_up_pts.value = 1; + else + cfg->srs_config.max_up_pts.value = 0; } - cfg->srs_config.max_up_pts.tl.tag = NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG; - cfg->num_tlv++; } - #ifdef Rel14 - if (RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.schedulingInfoSIB1_BR_r13>0) { - AssertFatal(radioResourceConfigCommon_BRP!=NULL,"radioResource rou is missing\n"); - AssertFatal(radioResourceConfigCommon_BRP->ext4!=NULL,"ext4 is missing\n"); - cfg->emtc_config.prach_catm_root_sequence_index.value = radioResourceConfigCommon_BRP->prach_Config.rootSequenceIndex; - cfg->emtc_config.prach_catm_root_sequence_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG; - cfg->num_tlv++; - + if (RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0) { + AssertFatal(radioResourceConfigCommon_BRP != NULL, + "radioResource rou is missing\n"); + AssertFatal(radioResourceConfigCommon_BRP->ext4 != NULL, + "ext4 is missing\n"); + cfg->emtc_config.prach_catm_root_sequence_index.value = radioResourceConfigCommon_BRP->prach_Config.rootSequenceIndex; cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; - cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG; - cfg->num_tlv++; + cfg->emtc_config.prach_catm_high_speed_flag.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.highSpeedFlag; - cfg->emtc_config.prach_catm_high_speed_flag.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.highSpeedFlag; - cfg->emtc_config.prach_catm_high_speed_flag.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG; - cfg->num_tlv++; - - struct PRACH_ConfigSIB_v1310 *ext4_prach=radioResourceConfigCommon_BRP->ext4->prach_ConfigCommon_v1310; + struct PRACH_ConfigSIB_v1310 *ext4_prach = radioResourceConfigCommon_BRP->ext4->prach_ConfigCommon_v1310; - PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; + PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; PRACH_ParametersCE_r13_t *p; - cfg->emtc_config.prach_ce_level_0_enable.value=0; - cfg->emtc_config.prach_ce_level_0_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_1_enable.value=0; - cfg->emtc_config.prach_ce_level_1_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_2_enable.value=0; - cfg->emtc_config.prach_ce_level_2_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_3_enable.value=0; - cfg->emtc_config.prach_ce_level_3_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; - cfg->num_tlv++; - + + cfg->emtc_config.prach_ce_level_0_enable.value = 0; + cfg->emtc_config.prach_ce_level_1_enable.value = 0; + cfg->emtc_config.prach_ce_level_2_enable.value = 0; + cfg->emtc_config.prach_ce_level_3_enable.value = 0; switch (prach_ParametersListCE_r13->list.count) { case 4: - p=prach_ParametersListCE_r13->list.array[3]; - cfg->emtc_config.prach_ce_level_3_enable.value = 1; - cfg->emtc_config.prach_ce_level_3_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; - cfg->num_tlv++; - + p = prach_ParametersListCE_r13->list.array[3]; + cfg->emtc_config.prach_ce_level_3_enable.value = 1; cfg->emtc_config.prach_ce_level_3_configuration_index.value = p->prach_ConfigIndex_r13; cfg->emtc_config.prach_ce_level_3_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG; cfg->num_tlv++; @@ -533,8 +512,6 @@ void config_sib2(int Mod_idP, cfg->num_tlv++; cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; @@ -543,19 +520,10 @@ void config_sib2(int Mod_idP, } cfg->emtc_config.prach_ce_level_3_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_3_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value-6; - cfg->emtc_config.prach_ce_level_3_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG; - cfg->num_tlv++; - + cfg->emtc_config.prach_ce_level_3_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; case 3: - p=prach_ParametersListCE_r13->list.array[2]; - cfg->emtc_config.prach_ce_level_2_enable.value = 1; - cfg->emtc_config.prach_ce_level_2_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; - cfg->num_tlv++; - + p = prach_ParametersListCE_r13->list.array[2]; + cfg->emtc_config.prach_ce_level_2_enable.value = 1; cfg->emtc_config.prach_ce_level_2_configuration_index.value = p->prach_ConfigIndex_r13; cfg->emtc_config.prach_ce_level_2_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG; cfg->num_tlv++; @@ -565,9 +533,6 @@ void config_sib2(int Mod_idP, cfg->num_tlv++; cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; - if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG; @@ -575,19 +540,10 @@ void config_sib2(int Mod_idP, } cfg->emtc_config.prach_ce_level_2_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_2_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_2_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value-6; - cfg->emtc_config.prach_ce_level_2_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG; - cfg->num_tlv++; - + cfg->emtc_config.prach_ce_level_2_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; case 2: - p=prach_ParametersListCE_r13->list.array[1]; - cfg->emtc_config.prach_ce_level_1_enable.value = 1; - cfg->emtc_config.prach_ce_level_1_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; - cfg->num_tlv++; - + p = prach_ParametersListCE_r13->list.array[1]; + cfg->emtc_config.prach_ce_level_1_enable.value = 1; cfg->emtc_config.prach_ce_level_1_configuration_index.value = p->prach_ConfigIndex_r13; cfg->emtc_config.prach_ce_level_1_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG; cfg->num_tlv++; @@ -597,8 +553,6 @@ void config_sib2(int Mod_idP, cfg->num_tlv++; cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; @@ -607,15 +561,10 @@ void config_sib2(int Mod_idP, } cfg->emtc_config.prach_ce_level_1_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_1_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_1_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value-6; - cfg->emtc_config.prach_ce_level_1_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG; - cfg->num_tlv++; - + cfg->emtc_config.prach_ce_level_1_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + case 1: - p=prach_ParametersListCE_r13->list.array[0]; + p = prach_ParametersListCE_r13->list.array[0]; cfg->emtc_config.prach_ce_level_0_enable.value = 1; cfg->emtc_config.prach_ce_level_0_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; cfg->num_tlv++; @@ -629,9 +578,7 @@ void config_sib2(int Mod_idP, cfg->num_tlv++; cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; - + if (p->prach_StartingSubframe_r13) { cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value = *p->prach_StartingSubframe_r13; cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG; @@ -639,114 +586,123 @@ void config_sib2(int Mod_idP, } cfg->emtc_config.prach_ce_level_0_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_0_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_0_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value-6; - cfg->emtc_config.prach_ce_level_0_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG; - cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; } struct FreqHoppingParameters_r13 *ext4_freqHoppingParameters = radioResourceConfigCommonP->ext4->freqHoppingParameters_r13; - if ((ext4_freqHoppingParameters) && - (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)){ - switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->present) { - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_NOTHING: /* No components present */ - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_FDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; - cfg->num_tlv++; - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_TDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; - cfg->num_tlv++; - break; + if ((ext4_freqHoppingParameters)&& + (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)) + { + switch (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->present) { + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_NOTHING: /* No components present */ + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = + ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13-> + choice.interval_FDD_r13; + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13: + cfg->emtc_config. + pucch_interval_ulhoppingconfigcommonmodea.value = + ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13-> + choice.interval_TDD_r13; + break; + } } - } - if ((ext4_freqHoppingParameters) && - (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13)){ - switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->present) { - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_NOTHING: /* No components present */ - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_FDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; - cfg->num_tlv++; - break; - case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_TDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; - cfg->num_tlv++; - break; + if ((ext4_freqHoppingParameters) && + (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13)) + { + switch + (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13-> + present) { + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_NOTHING: /* No components present */ + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13: + cfg->emtc_config. + pucch_interval_ulhoppingconfigcommonmodeb.value = + ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13-> + choice.interval_FDD_r13; + break; + case FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13: + cfg->emtc_config. + pucch_interval_ulhoppingconfigcommonmodeb.value = + ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13-> + choice.interval_TDD_r13; + break; + } } - } } #endif } +void +config_dedicated(int Mod_idP, + int CC_idP, + uint16_t rnti, + struct PhysicalConfigDedicated *physicalConfigDedicated) +{ - - -void config_dedicated(int Mod_idP, - int CC_idP, - uint16_t rnti, - struct PhysicalConfigDedicated *physicalConfigDedicated) { - } -void config_dedicated_scell(int Mod_idP, - uint16_t rnti, - SCellToAddMod_r10_t *sCellToAddMod_r10) { +void +config_dedicated_scell(int Mod_idP, + uint16_t rnti, + SCellToAddMod_r10_t * sCellToAddMod_r10) +{ } -int rrc_mac_config_req_eNB(module_id_t Mod_idP, - int CC_idP, - int physCellId, - int p_eNB, - int Ncp, - int eutra_band, - uint32_t dl_CarrierFreq, + +int +rrc_mac_config_req_eNB(module_id_t Mod_idP, + int CC_idP, + int physCellId, + int p_eNB, + int Ncp, int eutra_band, uint32_t dl_CarrierFreq, #ifdef Rel14 - int pbch_repetition, + int pbch_repetition, #endif - rnti_t rntiP, - BCCH_BCH_Message_t *mib, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, + rnti_t rntiP, + BCCH_BCH_Message_t * mib, + RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon, #ifdef Rel14 - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR, + RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon_BR, #endif - struct PhysicalConfigDedicated *physicalConfigDedicated, + struct PhysicalConfigDedicated + *physicalConfigDedicated, #if defined(Rel10) || defined(Rel14) - SCellToAddMod_r10_t *sCellToAddMod_r10, - //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, + SCellToAddMod_r10_t * sCellToAddMod_r10, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif - MeasObjectToAddMod_t **measObj, - MAC_MainConfig_t *mac_MainConfig, - long logicalChannelIdentity, - LogicalChannelConfig_t *logicalChannelConfig, - MeasGapConfig_t *measGapConfig, - TDD_Config_t *tdd_Config, - MobilityControlInfo_t *mobilityControlInfo, - SchedulingInfoList_t *schedulingInfoList, - uint32_t ul_CarrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList + MeasObjectToAddMod_t ** measObj, + MAC_MainConfig_t * mac_MainConfig, + long logicalChannelIdentity, + LogicalChannelConfig_t * logicalChannelConfig, + MeasGapConfig_t * measGapConfig, + TDD_Config_t * tdd_Config, + MobilityControlInfo_t * mobilityControlInfo, + SchedulingInfoList_t * schedulingInfoList, + uint32_t ul_CarrierFreq, + long *ul_Bandwidth, + AdditionalSpectrumEmission_t * + additionalSpectrumEmission, + struct MBSFN_SubframeConfigList + *mbsfn_SubframeConfigList #if defined(Rel10) || defined(Rel14) - ,uint8_t MBMS_Flag, - MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, - PMCH_InfoList_r9_t *pmch_InfoList + , uint8_t MBMS_Flag, + MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, + PMCH_InfoList_r9_t * pmch_InfoList #endif #ifdef Rel14 - , - SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext + , + SystemInformationBlockType1_v1310_IEs_t * + sib1_v13ext #endif - ) { + ) { int i; @@ -758,24 +714,22 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, LOG_E(MAC, "RC.mac:%p mib:%p\n", RC.mac, mib); - if (RC.mac == NULL) { - LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - l2_init_eNB(); + if (mib != NULL) { + if (RC.mac == NULL) + l2_init_eNB(); - LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); mac_top_init_eNB(); - LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - } + //LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - if (mib!=NULL) { - LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - RC.mac[Mod_idP]->common_channels[CC_idP].mib = mib; - RC.mac[Mod_idP]->common_channels[CC_idP].physCellId = physCellId; - RC.mac[Mod_idP]->common_channels[CC_idP].p_eNB = p_eNB; - RC.mac[Mod_idP]->common_channels[CC_idP].Ncp = Ncp; - RC.mac[Mod_idP]->common_channels[CC_idP].eutra_band = eutra_band; - RC.mac[Mod_idP]->common_channels[CC_idP].dl_CarrierFreq = dl_CarrierFreq; + + + RC.mac[Mod_idP]->common_channels[CC_idP].mib = mib; + RC.mac[Mod_idP]->common_channels[CC_idP].physCellId = physCellId; + RC.mac[Mod_idP]->common_channels[CC_idP].p_eNB = p_eNB; + RC.mac[Mod_idP]->common_channels[CC_idP].Ncp = Ncp; + RC.mac[Mod_idP]->common_channels[CC_idP].eutra_band = eutra_band; + RC.mac[Mod_idP]->common_channels[CC_idP].dl_CarrierFreq = dl_CarrierFreq; LOG_I(MAC, "Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n", @@ -799,78 +753,115 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, dl_CarrierFreq, ul_CarrierFreq #ifdef Rel14 - ,pbch_repetition + , pbch_repetition #endif ); mac_init_cell_params(Mod_idP,CC_idP); - if (schedulingInfoList!=NULL) { - RC.mac[Mod_idP]->common_channels[CC_idP].tdd_Config = tdd_Config; - RC.mac[Mod_idP]->common_channels[CC_idP].schedulingInfoList = schedulingInfoList; - config_sib1(Mod_idP,CC_idP,tdd_Config); - } + + if (schedulingInfoList!=NULL) { + RC.mac[Mod_idP]->common_channels[CC_idP].tdd_Config = tdd_Config; + RC.mac[Mod_idP]->common_channels[CC_idP].schedulingInfoList = schedulingInfoList; + config_sib1(Mod_idP,CC_idP,tdd_Config); + } #ifdef Rel14 - if (sib1_v13ext != NULL) { - RC.mac[Mod_idP]->common_channels[CC_idP].sib1_v13ext = sib1_v13ext; - } + if (sib1_v13ext != NULL) { + RC.mac[Mod_idP]->common_channels[CC_idP].sib1_v13ext = sib1_v13ext; + } #endif - if (radioResourceConfigCommon!=NULL) { - LOG_I(MAC,"[CONFIG]SIB2/3 Contents (partial)\n"); - LOG_I(MAC,"[CONFIG]pusch_config_common.n_SB = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB); - LOG_I(MAC,"[CONFIG]pusch_config_common.hoppingMode = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); - LOG_I(MAC,"[CONFIG]pusch_config_common.pusch_HoppingOffset = %ld\n", radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset); - LOG_I(MAC,"[CONFIG]pusch_config_common.enable64QAM = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM); - LOG_I(MAC,"[CONFIG]pusch_config_common.groupHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled); - LOG_I(MAC,"[CONFIG]pusch_config_common.groupAssignmentPUSCH = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); - LOG_I(MAC,"[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); - LOG_I(MAC,"[CONFIG]pusch_config_common.cyclicShift = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); - - AssertFatal(radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx > 0, - "radioResourceconfigCommon %d == 0\n", - (int)radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); - - RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon; - if (ul_CarrierFreq>0) RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq = ul_CarrierFreq; - if (ul_Bandwidth) RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth = *ul_Bandwidth; - else RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth = RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.dl_Bandwidth; - - config_sib2(Mod_idP, CC_idP, - radioResourceConfigCommon, + if (radioResourceConfigCommon != NULL) { + LOG_I(MAC, "[CONFIG]SIB2/3 Contents (partial)\n"); + LOG_I(MAC, "[CONFIG]pusch_config_common.n_SB = %ld\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.pusch_ConfigBasic.n_SB); + LOG_I(MAC, "[CONFIG]pusch_config_common.hoppingMode = %ld\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); + LOG_I(MAC, + "[CONFIG]pusch_config_common.pusch_HoppingOffset = %ld\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset); + LOG_I(MAC, "[CONFIG]pusch_config_common.enable64QAM = %d\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM); + LOG_I(MAC, + "[CONFIG]pusch_config_common.groupHoppingEnabled = %d\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.ul_ReferenceSignalsPUSCH. + groupHoppingEnabled); + LOG_I(MAC, + "[CONFIG]pusch_config_common.groupAssignmentPUSCH = %ld\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.ul_ReferenceSignalsPUSCH. + groupAssignmentPUSCH); + LOG_I(MAC, + "[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.ul_ReferenceSignalsPUSCH. + sequenceHoppingEnabled); + LOG_I(MAC, "[CONFIG]pusch_config_common.cyclicShift = %ld\n", + radioResourceConfigCommon-> + pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); + + AssertFatal(radioResourceConfigCommon-> + rach_ConfigCommon.maxHARQ_Msg3Tx > 0, + "radioResourceconfigCommon %d == 0\n", + (int) radioResourceConfigCommon-> + rach_ConfigCommon.maxHARQ_Msg3Tx); + + RC.mac[Mod_idP]->common_channels[CC_idP]. + radioResourceConfigCommon = radioResourceConfigCommon; + if (ul_CarrierFreq > 0) + RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq = + ul_CarrierFreq; + if (ul_Bandwidth) + RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth = + *ul_Bandwidth; + else + RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth = + RC.mac[Mod_idP]->common_channels[CC_idP].mib->message. + dl_Bandwidth; + + config_sib2(Mod_idP, CC_idP, radioResourceConfigCommon, #ifdef Rel14 - radioResourceConfigCommon_BR, + radioResourceConfigCommon_BR, #endif - NULL, ul_Bandwidth, additionalSpectrumEmission, mbsfn_SubframeConfigList); - + NULL, ul_Bandwidth, additionalSpectrumEmission, + mbsfn_SubframeConfigList); - } + } } // mib != NULL - // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup - if (logicalChannelConfig!= NULL) { // check for eMTC specific things + if (logicalChannelConfig != NULL) { // check for eMTC specific things UE_id = find_UE_id(Mod_idP, rntiP); if (UE_id == -1) { - LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); + LOG_E(MAC, "%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, + __LINE__, __FUNCTION__); } else { if (logicalChannelConfig) - UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup; + UE_list-> + UE_template[CC_idP][UE_id].lcgidmap + [logicalChannelIdentity] = + *logicalChannelConfig-> + ul_SpecificParameters->logicalChannelGroup; else - UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = 0; + UE_list-> + UE_template[CC_idP][UE_id].lcgidmap + [logicalChannelIdentity] = 0; } } - + if (physicalConfigDedicated != NULL) { UE_id = find_UE_id(Mod_idP, rntiP); if (UE_id == -1) - LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); + LOG_E(MAC, "%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); else - UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated=physicalConfigDedicated; - } - - + UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated = physicalConfigDedicated; + } #if defined(Rel10) || defined(Rel14) @@ -878,32 +869,38 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, if (sCellToAddMod_r10 != NULL) { UE_id = find_UE_id(Mod_idP, rntiP); if (UE_id == -1) - LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); + LOG_E(MAC, "%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, + __LINE__, __FUNCTION__); else - config_dedicated_scell(Mod_idP,rntiP,sCellToAddMod_r10); - + config_dedicated_scell(Mod_idP, rntiP, sCellToAddMod_r10); } - #endif if (mbsfn_SubframeConfigList != NULL) { - LOG_I(MAC,"[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_idP, mbsfn_SubframeConfigList->list.count); - RC.mac[Mod_idP]->common_channels[0].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count; - - for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) { - RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i]; - LOG_I(MAC, "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is %x\n", Mod_idP, i, - RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); + LOG_I(MAC, + "[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", + Mod_idP, mbsfn_SubframeConfigList->list.count); + RC.mac[Mod_idP]->common_channels[0].num_sf_allocation_pattern = + mbsfn_SubframeConfigList->list.count; + + for (i = 0; i < mbsfn_SubframeConfigList->list.count; i++) { + RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i] = + mbsfn_SubframeConfigList->list.array[i]; + LOG_I(MAC, + "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is %x\n", + Mod_idP, i, + RC.mac[Mod_idP]-> + common_channels[0].mbsfn_SubframeConfig[i]-> + subframeAllocation.choice.oneFrame.buf[0]); } - + #ifdef Rel10 RC.mac[Mod_idP]->common_channels[0].MBMS_flag = MBMS_Flag; #endif } - #if defined(Rel10) || defined(Rel14) if (mbsfn_AreaInfoList != NULL) { @@ -921,55 +918,65 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); if (pmch_InfoList != NULL) { - + // LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9)); - - LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", pmch_InfoList->list.count); - for (i =0; i< pmch_InfoList->list.count; i++) { - RC.mac[Mod_idP]->common_channels[0].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9; + LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", + pmch_InfoList->list.count); + + for (i = 0; i < pmch_InfoList->list.count; i++) { + RC.mac[Mod_idP]->common_channels[0].pmch_Config[i] = + &pmch_InfoList->list.array[i]->pmch_Config_r9; - LOG_I(MAC, "[CONFIG] PMCH[%d]: This PMCH stop (sf_AllocEnd_r9) at subframe %ldth\n", i, - RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->sf_AllocEnd_r9); - LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", i, - RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->mch_SchedulingPeriod_r9); + LOG_I(MAC, + "[CONFIG] PMCH[%d]: This PMCH stop (sf_AllocEnd_r9) at subframe %ldth\n", + i, + RC.mac[Mod_idP]->common_channels[0]. + pmch_Config[i]->sf_AllocEnd_r9); + LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", + i, + RC.mac[Mod_idP]->common_channels[0]. + pmch_Config[i]->mch_SchedulingPeriod_r9); LOG_I(MAC, "[CONFIG] PMCH[%d]: dataMCS = %ld\n", i, - RC.mac[Mod_idP]->common_channels[0].pmch_Config[i]->dataMCS_r9); + RC.mac[Mod_idP]->common_channels[0]. + pmch_Config[i]->dataMCS_r9); // MBMS session info list in each MCH - RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i] = &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9; - LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n",i, RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i]->list.count); + RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i] = + &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9; + LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n", i, + RC.mac[Mod_idP]->common_channels[0]. + mbms_SessionList[i]->list.count); } } #endif - LOG_E(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req); - - // if in nFAPI mode - if ( - (nfapi_mode == 1 || nfapi_mode == 2) && - (RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) - ) - { - while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) { - // DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); - usleep(100 * 1000); - printf("Waiting for PHY_config_req\n"); - } - } + //<<<<<<< HEAD - PHY_Config_t phycfg; - phycfg.Mod_id = Mod_idP; - phycfg.CC_id = CC_idP; - phycfg.cfg = &RC.mac[Mod_idP]->config[CC_idP]; + LOG_E(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req); + // if in nFAPI mode + if ( + (nfapi_mode == 1 || nfapi_mode == 2) && + (RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) + ) { + while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) { + // DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); + usleep(100 * 1000); + printf("Waiting for PHY_config_req\n"); + } + } - LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - if (RC.mac[Mod_idP]->if_inst->PHY_config_req) RC.mac[Mod_idP]->if_inst->PHY_config_req(&phycfg); - LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); + if (radioResourceConfigCommon != NULL) { + PHY_Config_t phycfg; + phycfg.Mod_id = Mod_idP; + phycfg.CC_id = CC_idP; + phycfg.cfg = &RC.mac[Mod_idP]->config[CC_idP]; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); + if (RC.mac[Mod_idP]->if_inst->PHY_config_req) RC.mac[Mod_idP]->if_inst->PHY_config_req(&phycfg); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); + } return(0); } @@ -981,40 +988,8 @@ void config_sib1_ue() } -// P: New function supporting the MAC interface -void config_sib2_ue() -{ - -} - -// P: New function supporting the MAC interface -void config_meas_ue() -{ - -} - -// P: New function supporting the MAC interface -// to substitute call to phy_config_afterHO_ue(). -void config_afterHO_ue() -{ - -} - -// P: New function supporting the MAC interface -void config_sib13_ue() -{ - -} - - -// P: New function supporting the MAC interface -void config_dedicated_ue() -{ -} -*/ - -int +/*int rrc_mac_config_req_ue( module_id_t Mod_idP, int CC_idP, @@ -1226,110 +1201,9 @@ rrc_mac_config_req_ue( for (i=0; i<UE_mac_inst[Mod_idP].n_adj_cells; i++) { UE_mac_inst[Mod_idP].adj_cell_id[i] = measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList->list.array[i]->physCellId; LOG_I(MAC,"Cell %d : Nid_cell %d\n",i,UE_mac_inst[Mod_idP].adj_cell_id[i]); - } - - phy_config_meas_ue(Mod_idP,0,eNB_index,UE_mac_inst[Mod_idP].n_adj_cells,UE_mac_inst[Mod_idP].adj_cell_id); - } - } - - - if(mobilityControlInfo != NULL) { - - LOG_D(MAC,"[UE%d] MAC Reset procedure triggered by RRC eNB %d \n",Mod_idP,eNB_index); - ue_mac_reset(Mod_idP,eNB_index); - - if(mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->rach_ConfigCommon, - (void *)mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon, - sizeof(RACH_ConfigCommon_t)); - } - - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->prach_Config.prach_ConfigInfo, - (void *)mobilityControlInfo->radioResourceConfigCommon.prach_Config.prach_ConfigInfo, - sizeof(PRACH_ConfigInfo_t)); - UE_mac_inst[Mod_idP].radioResourceConfigCommon->prach_Config.rootSequenceIndex = mobilityControlInfo->radioResourceConfigCommon.prach_Config.rootSequenceIndex; - - if(mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pdsch_ConfigCommon, - (void *)mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon, - sizeof(PDSCH_ConfigCommon_t)); - } - - // not a pointer: mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pusch_ConfigCommon, - (void *)&mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon, - sizeof(PUSCH_ConfigCommon_t)); - - if(mobilityControlInfo->radioResourceConfigCommon.phich_Config) { - /* memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->phich_Config, - (void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config, - sizeof(PHICH_Config_t)); */ - } - - if(mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->pucch_ConfigCommon, - (void *)mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon, - sizeof(PUCCH_ConfigCommon_t)); - } - - if(mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->soundingRS_UL_ConfigCommon, - (void *)mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon, - sizeof(SoundingRS_UL_ConfigCommon_t)); - } - - if(mobilityControlInfo->radioResourceConfigCommon.uplinkPowerControlCommon) { - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->uplinkPowerControlCommon, - (void *)mobilityControlInfo->radioResourceConfigCommon.uplinkPowerControlCommon, - sizeof(UplinkPowerControlCommon_t)); - } - - //configure antennaInfoCommon somewhere here.. - if(mobilityControlInfo->radioResourceConfigCommon.p_Max) { - //to be configured - } - - if(mobilityControlInfo->radioResourceConfigCommon.tdd_Config) { - UE_mac_inst[Mod_idP].tdd_Config = mobilityControlInfo->radioResourceConfigCommon.tdd_Config; - } - - if(mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength) { - memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->ul_CyclicPrefixLength, - (void *)mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength, - sizeof(UL_CyclicPrefixLength_t)); - } - - // store the previous rnti in case of failure, and set thenew rnti - UE_mac_inst[Mod_idP].crnti_before_ho = UE_mac_inst[Mod_idP].crnti; - UE_mac_inst[Mod_idP].crnti = ((mobilityControlInfo->newUE_Identity.buf[0])|(mobilityControlInfo->newUE_Identity.buf[1]<<8)); - LOG_I(MAC,"[UE %d] Received new identity %x from %d\n", Mod_idP, UE_mac_inst[Mod_idP].crnti, eNB_index); - UE_mac_inst[Mod_idP].rach_ConfigDedicated = malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated)); - - if (mobilityControlInfo->rach_ConfigDedicated) { - memcpy((void*)UE_mac_inst[Mod_idP].rach_ConfigDedicated, - (void*)mobilityControlInfo->rach_ConfigDedicated, - sizeof(*mobilityControlInfo->rach_ConfigDedicated)); - } - - phy_config_afterHO_ue(Mod_idP,0,eNB_index,mobilityControlInfo,0); - } - - - if (mbsfn_SubframeConfigList != NULL) { - LOG_I(MAC,"[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_idP, mbsfn_SubframeConfigList->list.count); - UE_mac_inst[Mod_idP].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count; - - for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) { - LOG_I(MAC, "[UE %d] Configuring MBSFN_SubframeConfig %d from received SIB2 \n", Mod_idP, i); - UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i]; - // LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is %ld\n", Mod_idP, - // UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); - } - } - -#if defined(Rel10) || defined(Rel14) +<<<<<<< HEAD if (mbsfn_AreaInfoList != NULL) { LOG_I(MAC,"[UE %d][CONFIG] Received %d MBSFN Area Info\n", Mod_idP, mbsfn_AreaInfoList->list.count); UE_mac_inst[Mod_idP].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count; @@ -1403,5 +1277,7 @@ rrc_mac_config_req_ue( #endif return(0); -} - +======= + return(0); +>>>>>>> main/develop +}*/ diff --git a/openair2/LAYER2/MAC/config_ue.c b/openair2/LAYER2/MAC/config_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..a166c5fdf26f0311c7a5595e41f648f966c52506 --- /dev/null +++ b/openair2/LAYER2/MAC/config_ue.c @@ -0,0 +1,620 @@ + +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file config.c + * \brief UE and eNB configuration performed by RRC or as a consequence of RRC procedures + * \author Navid Nikaein and Raymond Knopp + * \date 2010 - 2014 + * \version 0.1 + * \email: navid.nikaein@eurecom.fr + * @ingroup _mac + + */ + +#include "COMMON/platform_types.h" +#include "COMMON/platform_constants.h" +#include "SCHED/defs.h" +#include "SystemInformationBlockType2.h" +//#include "RadioResourceConfigCommonSIB.h" +#include "RadioResourceConfigDedicated.h" +#ifdef Rel14 +#include "PRACH-ConfigSIB-v1310.h" +#endif +#include "MeasGapConfig.h" +#include "MeasObjectToAddModList.h" +#include "TDD-Config.h" +#include "MAC-MainConfig.h" +#include "defs.h" +#include "proto.h" +#include "extern.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +#include "common/ran_context.h" +#if defined(Rel10) || defined(Rel14) +#include "MBSFN-AreaInfoList-r9.h" +#include "MBSFN-AreaInfo-r9.h" +#include "MBSFN-SubframeConfigList.h" +#include "PMCH-InfoList-r9.h" +#endif + +extern void mac_init_cell_params(int Mod_idP,int CC_idP); +extern void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +extern uint8_t nfapi_mode; + + +/* sec 5.9, 36.321: MAC Reset Procedure */ +void ue_mac_reset(module_id_t module_idP, uint8_t eNB_index) +{ + + //Resetting Bj + UE_mac_inst[module_idP].scheduling_info.Bj[0] = 0; + UE_mac_inst[module_idP].scheduling_info.Bj[1] = 0; + UE_mac_inst[module_idP].scheduling_info.Bj[2] = 0; + + //Stopping all timers + + //timeAlignmentTimer expires + + // PHY changes for UE MAC reset + phy_reset_ue(module_idP, 0, eNB_index); + + // notify RRC to relase PUCCH/SRS + // cancel all pending SRs + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; + + //Set BSR Trigger Bmp and remove timer flags + UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; + + // stop ongoing RACH procedure + + // discard explicitly signaled ra_PreambleIndex and ra_RACH_MaskIndex, if any + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = 0; // check! + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + + + ue_init_mac(module_idP); //This will hopefully do the rest of the MAC reset procedure + +} + +int32_t **rxdata; +int32_t **txdata; + + +int +rrc_mac_config_req_ue(module_id_t Mod_idP, + int CC_idP, + uint8_t eNB_index, + RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon, + struct PhysicalConfigDedicated + *physicalConfigDedicated, +#if defined(Rel10) || defined(Rel14) + SCellToAddMod_r10_t * sCellToAddMod_r10, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, +#endif + MeasObjectToAddMod_t ** measObj, + MAC_MainConfig_t * mac_MainConfig, + long logicalChannelIdentity, + LogicalChannelConfig_t * logicalChannelConfig, + MeasGapConfig_t * measGapConfig, + TDD_Config_t * tdd_Config, + MobilityControlInfo_t * mobilityControlInfo, + uint8_t * SIwindowsize, + uint16_t * SIperiod, + ARFCN_ValueEUTRA_t * ul_CarrierFreq, + long *ul_Bandwidth, + AdditionalSpectrumEmission_t * + additionalSpectrumEmission, + struct MBSFN_SubframeConfigList + *mbsfn_SubframeConfigList +#if defined(Rel10) || defined(Rel14) + , uint8_t MBMS_Flag, + MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, + PMCH_InfoList_r9_t * pmch_InfoList +#endif +#ifdef CBA + , uint8_t num_active_cba_groups, uint16_t cba_rnti +#endif +#if defined(Rel14) + ,config_action_t config_action + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id +#endif + ) +{ + + int i; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); + + LOG_I(MAC, "[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n", + Mod_idP, eNB_index); + + if (tdd_Config != NULL) { + UE_mac_inst[Mod_idP].tdd_Config = tdd_Config; + } + + + if (tdd_Config && SIwindowsize && SIperiod) { + phy_config_sib1_ue(Mod_idP, 0, eNB_index, tdd_Config, + *SIwindowsize, *SIperiod); + } + + if (radioResourceConfigCommon != NULL) { + UE_mac_inst[Mod_idP].radioResourceConfigCommon = + radioResourceConfigCommon; + phy_config_sib2_ue(Mod_idP, 0, eNB_index, + radioResourceConfigCommon, ul_CarrierFreq, + ul_Bandwidth, additionalSpectrumEmission, + mbsfn_SubframeConfigList); + } + // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup + if (logicalChannelConfig != NULL) { + LOG_I(MAC, + "[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n", + Mod_idP, eNB_index); + UE_mac_inst[Mod_idP].logicalChannelConfig[logicalChannelIdentity] = + logicalChannelConfig; + UE_mac_inst[Mod_idP].scheduling_info.Bj[logicalChannelIdentity] = 0; // initilize the bucket for this lcid + + AssertFatal(logicalChannelConfig->ul_SpecificParameters != NULL, + "[UE %d] LCID %ld NULL ul_SpecificParameters\n", + Mod_idP, logicalChannelIdentity); + UE_mac_inst[Mod_idP].scheduling_info.bucket_size[logicalChannelIdentity] = logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate * logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size + if (logicalChannelConfig->ul_SpecificParameters-> + logicalChannelGroup != NULL) { + UE_mac_inst[Mod_idP].scheduling_info. + LCGID[logicalChannelIdentity] = + *logicalChannelConfig->ul_SpecificParameters-> + logicalChannelGroup; + LOG_D(MAC, + "[CONFIG][UE %d] LCID %ld is attached to the LCGID %ld\n", + Mod_idP, logicalChannelIdentity, + *logicalChannelConfig-> + ul_SpecificParameters->logicalChannelGroup); + } else { + UE_mac_inst[Mod_idP].scheduling_info. + LCGID[logicalChannelIdentity] = MAX_NUM_LCGID; + } + UE_mac_inst[Mod_idP]. + scheduling_info.LCID_buffer_remain[logicalChannelIdentity] = 0; + } + + if (mac_MainConfig != NULL) { + LOG_I(MAC, + "[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n", + Mod_idP, eNB_index); + UE_mac_inst[Mod_idP].macConfig = mac_MainConfig; + UE_mac_inst[Mod_idP].measGapConfig = measGapConfig; + + if (mac_MainConfig->ul_SCH_Config) { + + if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) { + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = + (uint16_t) * + mac_MainConfig->ul_SCH_Config->periodicBSR_Timer; + } else { + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = +#ifndef Rel14 + (uint16_t) + MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity +#else + (uint16_t) PeriodicBSR_Timer_r12_infinity; +#endif + ; + } + + if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) { + UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx = + (uint16_t) * mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; + } else { + UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx = + (uint16_t) + MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + } + if(nfapi_mode!=3) + phy_config_harq_ue(Mod_idP, 0, eNB_index, + UE_mac_inst[Mod_idP]. + scheduling_info.maxHARQ_Tx); + + if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) { + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = + (uint16_t) mac_MainConfig->ul_SCH_Config-> + retxBSR_Timer; + } else { +#ifndef Rel14 + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = + (uint16_t) + MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; +#else + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = + (uint16_t) RetxBSR_Timer_r12_sf2560; +#endif + } + } +#if defined(Rel10) || defined(Rel14) + + if (mac_MainConfig->ext1 + && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { + UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = + (uint16_t) * mac_MainConfig->ext1->sr_ProhibitTimer_r9; + } else { + UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = 0; + } + + if (mac_MainConfig->ext2 + && mac_MainConfig->ext2->mac_MainConfig_v1020) { + if (mac_MainConfig->ext2-> + mac_MainConfig_v1020->extendedBSR_Sizes_r10) { + UE_mac_inst[Mod_idP].scheduling_info. + extendedBSR_Sizes_r10 = + (uint16_t) * + mac_MainConfig->ext2-> + mac_MainConfig_v1020->extendedBSR_Sizes_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info. + extendedBSR_Sizes_r10 = (uint16_t) 0; + } + if (mac_MainConfig->ext2->mac_MainConfig_v1020-> + extendedPHR_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = + (uint16_t) * + mac_MainConfig->ext2->mac_MainConfig_v1020-> + extendedPHR_r10; + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = + (uint16_t) 0; + } + } else { + UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = + (uint16_t) 0; + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = + (uint16_t) 0; + } +#endif + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + + UE_mac_inst[Mod_idP].BSR_reporting_active = BSR_TRIGGER_NONE; + + LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", + Mod_idP, + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF, + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF); + + UE_mac_inst[Mod_idP].scheduling_info.drx_config = + mac_MainConfig->drx_Config; + UE_mac_inst[Mod_idP].scheduling_info.phr_config = + mac_MainConfig->phr_Config; + + if (mac_MainConfig->phr_Config) { + UE_mac_inst[Mod_idP].PHR_state = + mac_MainConfig->phr_Config->present; + UE_mac_inst[Mod_idP].PHR_reconfigured = 1; + UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = + mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer; + UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = + mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer; + UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = + mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange; + } else { + UE_mac_inst[Mod_idP].PHR_reconfigured = 0; + UE_mac_inst[Mod_idP].PHR_state = + MAC_MainConfig__phr_Config_PR_setup; + UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = + MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; + UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = + MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; + UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = + MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; + } + + UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = + get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP]. + scheduling_info.periodicPHR_Timer); + UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = + get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP]. + scheduling_info.prohibitPHR_Timer); + UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = + get_db_dl_PathlossChange(UE_mac_inst[Mod_idP]. + scheduling_info.PathlossChange); + UE_mac_inst[Mod_idP].PHR_reporting_active = 0; + LOG_D(MAC, + "[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", + Mod_idP, + (mac_MainConfig->phr_Config) ? mac_MainConfig-> + phr_Config->present : -1, + UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF, + UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF, + UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db); + } + + + if (physicalConfigDedicated != NULL) { + phy_config_dedicated_ue(Mod_idP, 0, eNB_index, + physicalConfigDedicated); + UE_mac_inst[Mod_idP].physicalConfigDedicated = physicalConfigDedicated; // for SR proc + } +#if defined(Rel10) || defined(Rel14) + + if (sCellToAddMod_r10 != NULL) { + + + phy_config_dedicated_scell_ue(Mod_idP, eNB_index, + sCellToAddMod_r10, 1); + UE_mac_inst[Mod_idP].physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; // using SCell index 0 + } +#endif + + if (measObj != NULL) { + if (measObj[0] != NULL) { + UE_mac_inst[Mod_idP].n_adj_cells = + measObj[0]->measObject.choice. + measObjectEUTRA.cellsToAddModList->list.count; + LOG_I(MAC, "Number of adjacent cells %d\n", + UE_mac_inst[Mod_idP].n_adj_cells); + + for (i = 0; i < UE_mac_inst[Mod_idP].n_adj_cells; i++) { + UE_mac_inst[Mod_idP].adj_cell_id[i] = + measObj[0]->measObject.choice. + measObjectEUTRA.cellsToAddModList->list.array[i]-> + physCellId; + LOG_I(MAC, "Cell %d : Nid_cell %d\n", i, + UE_mac_inst[Mod_idP].adj_cell_id[i]); + } + + phy_config_meas_ue(Mod_idP, 0, eNB_index, + UE_mac_inst[Mod_idP].n_adj_cells, + UE_mac_inst[Mod_idP].adj_cell_id); + } + } + + + if (mobilityControlInfo != NULL) { + + LOG_D(MAC, "[UE%d] MAC Reset procedure triggered by RRC eNB %d \n", + Mod_idP, eNB_index); + ue_mac_reset(Mod_idP, eNB_index); + + if (mobilityControlInfo->radioResourceConfigCommon. + rach_ConfigCommon) { + memcpy((void *) + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + rach_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.rach_ConfigCommon, + sizeof(RACH_ConfigCommon_t)); + } + + memcpy((void *) &UE_mac_inst[Mod_idP]. + radioResourceConfigCommon->prach_Config.prach_ConfigInfo, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.prach_Config.prach_ConfigInfo, + sizeof(PRACH_ConfigInfo_t)); + UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + prach_Config.rootSequenceIndex = + mobilityControlInfo->radioResourceConfigCommon. + prach_Config.rootSequenceIndex; + + if (mobilityControlInfo->radioResourceConfigCommon. + pdsch_ConfigCommon) { + memcpy((void *) + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + pdsch_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.pdsch_ConfigCommon, + sizeof(PDSCH_ConfigCommon_t)); + } + // not a pointer: mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon + memcpy((void *) &UE_mac_inst[Mod_idP]. + radioResourceConfigCommon->pusch_ConfigCommon, + (void *) &mobilityControlInfo-> + radioResourceConfigCommon.pusch_ConfigCommon, + sizeof(PUSCH_ConfigCommon_t)); + + if (mobilityControlInfo->radioResourceConfigCommon.phich_Config) { + /* memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->phich_Config, + (void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config, + sizeof(PHICH_Config_t)); */ + } + + if (mobilityControlInfo->radioResourceConfigCommon. + pucch_ConfigCommon) { + memcpy((void *) + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + pucch_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.pucch_ConfigCommon, + sizeof(PUCCH_ConfigCommon_t)); + } + + if (mobilityControlInfo-> + radioResourceConfigCommon.soundingRS_UL_ConfigCommon) { + memcpy((void *) + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + soundingRS_UL_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.soundingRS_UL_ConfigCommon, + sizeof(SoundingRS_UL_ConfigCommon_t)); + } + + if (mobilityControlInfo-> + radioResourceConfigCommon.uplinkPowerControlCommon) { + memcpy((void *) + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + uplinkPowerControlCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.uplinkPowerControlCommon, + sizeof(UplinkPowerControlCommon_t)); + } + //configure antennaInfoCommon somewhere here.. + if (mobilityControlInfo->radioResourceConfigCommon.p_Max) { + //to be configured + } + + if (mobilityControlInfo->radioResourceConfigCommon.tdd_Config) { + UE_mac_inst[Mod_idP].tdd_Config = + mobilityControlInfo->radioResourceConfigCommon.tdd_Config; + } + + if (mobilityControlInfo-> + radioResourceConfigCommon.ul_CyclicPrefixLength) { + memcpy((void *) + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + ul_CyclicPrefixLength, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.ul_CyclicPrefixLength, + sizeof(UL_CyclicPrefixLength_t)); + } + // store the previous rnti in case of failure, and set thenew rnti + UE_mac_inst[Mod_idP].crnti_before_ho = UE_mac_inst[Mod_idP].crnti; + UE_mac_inst[Mod_idP].crnti = + ((mobilityControlInfo-> + newUE_Identity.buf[0]) | (mobilityControlInfo-> + newUE_Identity.buf[1] << 8)); + LOG_I(MAC, "[UE %d] Received new identity %x from %d\n", Mod_idP, + UE_mac_inst[Mod_idP].crnti, eNB_index); + UE_mac_inst[Mod_idP].rach_ConfigDedicated = + malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated)); + + if (mobilityControlInfo->rach_ConfigDedicated) { + memcpy((void *) UE_mac_inst[Mod_idP].rach_ConfigDedicated, + (void *) mobilityControlInfo->rach_ConfigDedicated, + sizeof(*mobilityControlInfo->rach_ConfigDedicated)); + } + + phy_config_afterHO_ue(Mod_idP, 0, eNB_index, mobilityControlInfo, + 0); + } + + + if (mbsfn_SubframeConfigList != NULL) { + LOG_I(MAC, + "[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", + Mod_idP, mbsfn_SubframeConfigList->list.count); + UE_mac_inst[Mod_idP].num_sf_allocation_pattern = + mbsfn_SubframeConfigList->list.count; + + for (i = 0; i < mbsfn_SubframeConfigList->list.count; i++) { + LOG_I(MAC, + "[UE %d] Configuring MBSFN_SubframeConfig %d from received SIB2 \n", + Mod_idP, i); + UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i] = + mbsfn_SubframeConfigList->list.array[i]; + // LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is %ld\n", Mod_idP, + // UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); + } + } +#if defined(Rel10) || defined(Rel14) + + if (mbsfn_AreaInfoList != NULL) { + LOG_I(MAC, "[UE %d][CONFIG] Received %d MBSFN Area Info\n", + Mod_idP, mbsfn_AreaInfoList->list.count); + UE_mac_inst[Mod_idP].num_active_mbsfn_area = + mbsfn_AreaInfoList->list.count; + + for (i = 0; i < mbsfn_AreaInfoList->list.count; i++) { + UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i] = + mbsfn_AreaInfoList->list.array[i]; + LOG_I(MAC, + "[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", + Mod_idP, i, + UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_RepetitionPeriod_r9); + phy_config_sib13_ue(Mod_idP, 0, eNB_index, i, + UE_mac_inst[Mod_idP]. + mbsfn_AreaInfo[i]->mbsfn_AreaId_r9); + } + } + + if (pmch_InfoList != NULL) { + + // LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9)); + + LOG_I(MAC, "[UE %d] Configuring PMCH_config from MCCH MESSAGE \n", + Mod_idP); + + for (i = 0; i < pmch_InfoList->list.count; i++) { + UE_mac_inst[Mod_idP].pmch_Config[i] = + &pmch_InfoList->list.array[i]->pmch_Config_r9; + LOG_I(MAC, "[UE %d] PMCH[%d]: MCH_Scheduling_Period = %ld\n", + Mod_idP, i, + UE_mac_inst[Mod_idP]. + pmch_Config[i]->mch_SchedulingPeriod_r9); + } + + UE_mac_inst[Mod_idP].mcch_status = 1; + } +#endif +#ifdef CBA + + if (cba_rnti) { + UE_mac_inst[Mod_idP].cba_rnti[num_active_cba_groups - 1] = + cba_rnti; + LOG_D(MAC, + "[UE %d] configure CBA group %d RNTI %x for eNB %d (total active cba group %d)\n", + Mod_idP, Mod_idP % num_active_cba_groups, cba_rnti, + eNB_index, num_active_cba_groups); + phy_config_cba_rnti(Mod_idP, CC_idP, eNB_flagP, eNB_index, + cba_rnti, num_active_cba_groups - 1, + num_active_cba_groups); + } +#endif + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); + //for D2D + #if defined(Rel10) || defined(Rel14) + switch (config_action) { + case CONFIG_ACTION_ADD: + if (sourceL2Id){ + UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id; + LOG_I(MAC,"[UE %d] Configure source L2Id 0x%08x \n", Mod_idP, *sourceL2Id ); + } + if (destinationL2Id) { + LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id ); + int j = 0; + int i = 0; + for (i=0; i< MAX_NUM_DEST; i++) { + if ((UE_mac_inst[Mod_idP].destinationList[i] == 0) && (j == 0)) j = i+1; + if (UE_mac_inst[Mod_idP].destinationList[i] == *destinationL2Id) break; //destination already exists! + } + if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[Mod_idP].destinationList[j-1] = *destinationL2Id; + UE_mac_inst[Mod_idP].numCommFlows++; + } + break; + case CONFIG_ACTION_REMOVE: + //TODO + break; + default: + break; + } + + #endif + + return (0); +} diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index cf23477513c0fd2ff7f2a80ce9e4fa76dca2e2ff..febae955d2ca7e6f2a767d76bd82d5daf048c3a9 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -39,15 +39,9 @@ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> #include <string.h> -#endif - -//#include "COMMON/openair_defs.h" - - #include "PHY/defs.h" #include "PHY/LTE_TRANSPORT/defs.h" @@ -92,12 +86,12 @@ #if defined(Rel10) || defined(Rel14) // Mask for identifying subframe for MBMS -#define MBSFN_TDD_SF3 0x80// for TDD +#define MBSFN_TDD_SF3 0x80 // for TDD #define MBSFN_TDD_SF4 0x40 #define MBSFN_TDD_SF7 0x20 #define MBSFN_TDD_SF8 0x10 #define MBSFN_TDD_SF9 0x08 -#define MBSFN_FDD_SF1 0x80// for FDD +#define MBSFN_FDD_SF1 0x80 // for FDD #define MBSFN_FDD_SF2 0x40 #define MBSFN_FDD_SF3 0x20 #define MBSFN_FDD_SF6 0x10 @@ -111,9 +105,7 @@ //#define MCH_PAYLOAD_SIZE_MAX 16384// this value is using in case mcs and TBS index are high #endif -#ifdef USER_MODE #define printk printf -#endif //USER_MODE /*!\brief Maximum number of logical channl group IDs */ #define MAX_NUM_LCGID 4 @@ -130,13 +122,17 @@ /*!\brief Maximum number od control elemenets */ #define MAX_NUM_CE 5 /*!\brief Maximum number of random access process */ +#if defined(USRP_REC_PLAY) +#define NB_RA_PROC_MAX 1 +#else #define NB_RA_PROC_MAX 4 +#endif /*!\brief size of buffer status report table */ #define BSR_TABLE_SIZE 64 /*!\brief The power headroom reporting range is from -23 ...+40 dB and beyond, with step 1 */ -#define PHR_MAPPING_OFFSET 23 // if ( x>= -23 ) val = floor (x + 23) +#define PHR_MAPPING_OFFSET 23 // if ( x>= -23 ) val = floor (x + 23) /*!\brief maximum number of resource block groups */ -#define N_RBG_MAX 25 // for 20MHz channel BW +#define N_RBG_MAX 25 // for 20MHz channel BW /*!\brief minimum value for channel quality indicator */ #define MIN_CQI_VALUE 0 /*!\brief maximum value for channel quality indicator */ @@ -161,28 +157,31 @@ /*!\brief maximum number of slices / groups */ #define MAX_NUM_SLICES 4 -/* - * eNB part + +#define U_PLANE_INACTIVITY_VALUE 6000 + +/* + * eNB part */ -/* - * UE/ENB common part +/* + * UE/ENB common part */ /*!\brief MAC header of Random Access Response for Random access preamble identifier (RAPID) */ typedef struct { - uint8_t RAPID:6; - uint8_t T:1; - uint8_t E:1; -} __attribute__((__packed__))RA_HEADER_RAPID; + uint8_t RAPID:6; + uint8_t T:1; + uint8_t E:1; +} __attribute__ ((__packed__)) RA_HEADER_RAPID; /*!\brief MAC header of Random Access Response for backoff indicator (BI)*/ typedef struct { - uint8_t BI:4; - uint8_t R:2; - uint8_t T:1; - uint8_t E:1; -} __attribute__((__packed__))RA_HEADER_BI; + uint8_t BI:4; + uint8_t R:2; + uint8_t T:1; + uint8_t E:1; +} __attribute__ ((__packed__)) RA_HEADER_BI; /* typedef struct { uint64_t padding:16; @@ -214,28 +213,28 @@ typedef struct { */ /*!\brief MAC subheader short with 7bit Length field */ typedef struct { - uint8_t LCID:5; // octet 1 LSB - uint8_t E:1; - uint8_t R:2; // octet 1 MSB - uint8_t L:7; // octet 2 LSB - uint8_t F:1; // octet 2 MSB -} __attribute__((__packed__))SCH_SUBHEADER_SHORT; + uint8_t LCID:5; // octet 1 LSB + uint8_t E:1; + uint8_t R:2; // octet 1 MSB + uint8_t L:7; // octet 2 LSB + uint8_t F:1; // octet 2 MSB +} __attribute__ ((__packed__)) SCH_SUBHEADER_SHORT; /*!\brief MAC subheader long with 15bit Length field */ typedef struct { - uint8_t LCID:5; // octet 1 LSB - uint8_t E:1; - uint8_t R:2; // octet 1 MSB - uint8_t L_MSB:7; - uint8_t F:1; // octet 2 MSB - uint8_t L_LSB:8; - uint8_t padding; -} __attribute__((__packed__))SCH_SUBHEADER_LONG; + uint8_t LCID:5; // octet 1 LSB + uint8_t E:1; + uint8_t R:2; // octet 1 MSB + uint8_t L_MSB:7; + uint8_t F:1; // octet 2 MSB + uint8_t L_LSB:8; + uint8_t padding; +} __attribute__ ((__packed__)) SCH_SUBHEADER_LONG; /*!\brief MAC subheader short without length field */ typedef struct { - uint8_t LCID:5; - uint8_t E:1; - uint8_t R:2; -} __attribute__((__packed__))SCH_SUBHEADER_FIXED; + uint8_t LCID:5; + uint8_t E:1; + uint8_t R:2; +} __attribute__ ((__packed__)) SCH_SUBHEADER_FIXED; @@ -308,18 +307,18 @@ typedef struct { /*!\brief mac control element: short buffer status report for a specific logical channel group ID*/ typedef struct { - uint8_t Buffer_size:6; // octet 1 LSB - uint8_t LCGID:2; // octet 1 MSB -} __attribute__((__packed__))BSR_SHORT; + uint8_t Buffer_size:6; // octet 1 LSB + uint8_t LCGID:2; // octet 1 MSB +} __attribute__ ((__packed__)) BSR_SHORT; typedef BSR_SHORT BSR_TRUNCATED; /*!\brief mac control element: long buffer status report for all logical channel group ID*/ typedef struct { - uint8_t Buffer_size3:6; - uint8_t Buffer_size2:6; - uint8_t Buffer_size1:6; - uint8_t Buffer_size0:6; -} __attribute__((__packed__))BSR_LONG; + uint8_t Buffer_size3:6; + uint8_t Buffer_size2:6; + uint8_t Buffer_size1:6; + uint8_t Buffer_size0:6; +} __attribute__ ((__packed__)) BSR_LONG; // Panos: /*!\brief mac control element: sidelink buffer status report */ @@ -348,79 +347,79 @@ typedef struct { #define BSR_LONG_SIZE (sizeof(BSR_LONG)) /*!\brief mac control element: timing advance */ typedef struct { - uint8_t TA:6; - uint8_t R:2; -} __attribute__((__packed__))TIMING_ADVANCE_CMD; + uint8_t TA:6; + uint8_t R:2; +} __attribute__ ((__packed__)) TIMING_ADVANCE_CMD; /*!\brief mac control element: power headroom report */ typedef struct { - uint8_t PH:6; - uint8_t R:2; -} __attribute__((__packed__))POWER_HEADROOM_CMD; + uint8_t PH:6; + uint8_t R:2; +} __attribute__ ((__packed__)) POWER_HEADROOM_CMD; /*! \brief MIB payload */ typedef struct { - uint8_t payload[3] ; -} __attribute__((__packed__))MIB_PDU; + uint8_t payload[3]; +} __attribute__ ((__packed__)) MIB_PDU; /*! \brief CCCH payload */ typedef struct { - uint8_t payload[CCCH_PAYLOAD_SIZE_MAX] ; -} __attribute__((__packed__))CCCH_PDU; + uint8_t payload[CCCH_PAYLOAD_SIZE_MAX]; +} __attribute__ ((__packed__)) CCCH_PDU; /*! \brief BCCH payload */ typedef struct { - uint8_t payload[BCCH_PAYLOAD_SIZE_MAX] ; -} __attribute__((__packed__))BCCH_PDU; + uint8_t payload[BCCH_PAYLOAD_SIZE_MAX]; +} __attribute__ ((__packed__)) BCCH_PDU; /*! \brief RAR payload */ typedef struct { - uint8_t payload[RAR_PAYLOAD_SIZE_MAX]; + uint8_t payload[RAR_PAYLOAD_SIZE_MAX]; } __attribute__ ((__packed__)) RAR_PDU; /*! \brief BCCH payload */ typedef struct { - uint8_t payload[PCCH_PAYLOAD_SIZE_MAX] ; -} __attribute__((__packed__))PCCH_PDU; + uint8_t payload[PCCH_PAYLOAD_SIZE_MAX]; +} __attribute__ ((__packed__)) PCCH_PDU; #if defined(Rel10) || defined(Rel14) /*! \brief MCCH payload */ typedef struct { - uint8_t payload[MCCH_PAYLOAD_SIZE_MAX] ; -} __attribute__((__packed__))MCCH_PDU; + uint8_t payload[MCCH_PAYLOAD_SIZE_MAX]; +} __attribute__ ((__packed__)) MCCH_PDU; /*!< \brief MAC control element for activation and deactivation of component carriers */ typedef struct { - uint8_t C7:1;/*!< \brief Component carrier 7 */ - uint8_t C6:1;/*!< \brief Component carrier 6 */ - uint8_t C5:1;/*!< \brief Component carrier 5 */ - uint8_t C4:1;/*!< \brief Component carrier 4 */ - uint8_t C3:1;/*!< \brief Component carrier 3 */ - uint8_t C2:1;/*!< \brief Component carrier 2 */ - uint8_t C1:1;/*!< \brief Component carrier 1 */ - uint8_t R:1;/*!< \brief Reserved */ -} __attribute__((__packed__))CC_ELEMENT; + uint8_t C7:1; /*!< \brief Component carrier 7 */ + uint8_t C6:1; /*!< \brief Component carrier 6 */ + uint8_t C5:1; /*!< \brief Component carrier 5 */ + uint8_t C4:1; /*!< \brief Component carrier 4 */ + uint8_t C3:1; /*!< \brief Component carrier 3 */ + uint8_t C2:1; /*!< \brief Component carrier 2 */ + uint8_t C1:1; /*!< \brief Component carrier 1 */ + uint8_t R:1; /*!< \brief Reserved */ +} __attribute__ ((__packed__)) CC_ELEMENT; /*! \brief MAC control element: MCH Scheduling Information */ typedef struct { - uint8_t stop_sf_MSB:3; // octet 1 LSB - uint8_t lcid:5; // octet 2 MSB - uint8_t stop_sf_LSB:8; -} __attribute__((__packed__))MSI_ELEMENT; + uint8_t stop_sf_MSB:3; // octet 1 LSB + uint8_t lcid:5; // octet 2 MSB + uint8_t stop_sf_LSB:8; +} __attribute__ ((__packed__)) MSI_ELEMENT; #endif /*! \brief Values of CCCH LCID for DLSCH */ #define CCCH_LCHANID 0 /*!\brief Values of BCCH logical channel (fake)*/ -#define BCCH 3 // SI +#define BCCH 3 // SI /*!\brief Values of PCCH logical channel (fake)*/ -#define PCCH 4 // Paging +#define PCCH 4 // Paging /*!\brief Values of PCCH logical channel (fake) */ -#define MIBCH 5 // MIB +#define MIBCH 5 // MIB /*!\brief Values of BCCH SIB1_BR logical channel (fake) */ -#define BCCH_SIB1_BR 6 // SIB1_BR +#define BCCH_SIB1_BR 6 // SIB1_BR /*!\brief Values of BCCH SIB_BR logical channel (fake) */ -#define BCCH_SI_BR 7 // SI-BR +#define BCCH_SI_BR 7 // SI-BR /*!\brief Value of CCCH / SRB0 logical channel */ -#define CCCH 0 // srb0 +#define CCCH 0 // srb0 /*!\brief DCCH / SRB1 logical channel */ -#define DCCH 1 // srb1 +#define DCCH 1 // srb1 /*!\brief DCCH1 / SRB2 logical channel */ -#define DCCH1 2 // srb2 +#define DCCH1 2 // srb2 /*!\brief DTCH DRB1 logical channel */ -#define DTCH 3 // LCID +#define DTCH 3 // LCID /*!\brief MCCH logical channel */ #define MCCH 4 /*!\brief MTCH logical channel */ @@ -462,34 +461,34 @@ typedef struct { /*!\brief LCID of long BSR for ULSCH */ #define LONG_BSR 30 /*!\bitmaps for BSR Triggers */ -#define BSR_TRIGGER_NONE (0) /* No BSR Trigger */ -#define BSR_TRIGGER_REGULAR (1) /* For Regular and ReTxBSR Expiry Triggers */ -#define BSR_TRIGGER_PERIODIC (2) /* For BSR Periodic Timer Expiry Trigger */ -#define BSR_TRIGGER_PADDING (4) /* For Padding BSR Trigger */ +#define BSR_TRIGGER_NONE (0) /* No BSR Trigger */ +#define BSR_TRIGGER_REGULAR (1) /* For Regular and ReTxBSR Expiry Triggers */ +#define BSR_TRIGGER_PERIODIC (2) /* For BSR Periodic Timer Expiry Trigger */ +#define BSR_TRIGGER_PADDING (4) /* For Padding BSR Trigger */ /*! \brief Downlink SCH PDU Structure */ typedef struct { - uint8_t payload[8][SCH_PAYLOAD_SIZE_MAX]; - uint16_t Pdu_size[8]; + uint8_t payload[8][SCH_PAYLOAD_SIZE_MAX]; + uint16_t Pdu_size[8]; } __attribute__ ((__packed__)) DLSCH_PDU; /*! \brief MCH PDU Structure */ typedef struct { - int8_t payload[SCH_PAYLOAD_SIZE_MAX]; - uint16_t Pdu_size; - uint8_t mcs; - uint8_t sync_area; - uint8_t msi_active; - uint8_t mcch_active; - uint8_t mtch_active; + int8_t payload[SCH_PAYLOAD_SIZE_MAX]; + uint16_t Pdu_size; + uint8_t mcs; + uint8_t sync_area; + uint8_t msi_active; + uint8_t mcch_active; + uint8_t mtch_active; } __attribute__ ((__packed__)) MCH_PDU; /*! \brief Uplink SCH PDU Structure */ typedef struct { - int8_t payload[SCH_PAYLOAD_SIZE_MAX]; /*!< \brief SACH payload */ - uint16_t Pdu_size; + int8_t payload[SCH_PAYLOAD_SIZE_MAX]; /*!< \brief SACH payload */ + uint16_t Pdu_size; } __attribute__ ((__packed__)) ULSCH_PDU; @@ -501,822 +500,833 @@ typedef struct { #include "PHY/impl_defs_top.h" +/*!\brief RA process state*/ +typedef enum { + IDLE = 0, + MSG2, + WAITMSG3, + MSG4, + WAITMSG4ACK +} RA_state; + /*!\brief UE ULSCH scheduling states*/ typedef enum { - S_UL_NONE =0, - S_UL_WAITING, - S_UL_SCHEDULED, - S_UL_BUFFERED, - S_UL_NUM_STATUS + S_UL_NONE = 0, + S_UL_WAITING, + S_UL_SCHEDULED, + S_UL_BUFFERED, + S_UL_NUM_STATUS } UE_ULSCH_STATUS; /*!\brief UE DLSCH scheduling states*/ typedef enum { - S_DL_NONE =0, - S_DL_WAITING, - S_DL_SCHEDULED, - S_DL_BUFFERED, - S_DL_NUM_STATUS + S_DL_NONE = 0, + S_DL_WAITING, + S_DL_SCHEDULED, + S_DL_BUFFERED, + S_DL_NUM_STATUS } UE_DLSCH_STATUS; /*!\brief scheduling policy for the contention-based access */ typedef enum { - CBA_ES=0, /// equal share of RB among groups w - CBA_ES_S, /// equal share of RB among groups with small allocation - CBA_PF, /// proportional fair (kind of) - CBA_PF_S, /// proportional fair (kind of) with small RB allocation - CBA_RS /// random allocation + CBA_ES = 0, /// equal share of RB among groups w + CBA_ES_S, /// equal share of RB among groups with small allocation + CBA_PF, /// proportional fair (kind of) + CBA_PF_S, /// proportional fair (kind of) with small RB allocation + CBA_RS /// random allocation } CBA_POLICY; /*! \brief temporary struct for ULSCH sched */ typedef struct { - rnti_t rnti; - uint16_t subframe; - uint16_t serving_num; - UE_ULSCH_STATUS status; + rnti_t rnti; + uint16_t subframe; + uint16_t serving_num; + UE_ULSCH_STATUS status; } eNB_ULSCH_INFO; /*! \brief temp struct for DLSCH sched */ typedef struct { - rnti_t rnti; - uint16_t weight; - uint16_t subframe; - uint16_t serving_num; - UE_DLSCH_STATUS status; + rnti_t rnti; + uint16_t weight; + uint16_t subframe; + uint16_t serving_num; + UE_DLSCH_STATUS status; } eNB_DLSCH_INFO; /*! \brief eNB overall statistics */ typedef struct { - /// num BCCH PDU per CC - uint32_t total_num_bcch_pdu; - /// BCCH buffer size - uint32_t bcch_buffer; - /// total BCCH buffer size - uint32_t total_bcch_buffer; - /// BCCH MCS - uint32_t bcch_mcs; - - /// num CCCH PDU per CC - uint32_t total_num_ccch_pdu; - /// BCCH buffer size - uint32_t ccch_buffer; - /// total BCCH buffer size - uint32_t total_ccch_buffer; + + /// num BCCH PDU per CC + uint32_t total_num_bcch_pdu; + /// BCCH buffer size + uint32_t bcch_buffer; + /// total BCCH buffer size + uint32_t total_bcch_buffer; + /// BCCH MCS + uint32_t bcch_mcs; + + /// num CCCH PDU per CC + uint32_t total_num_ccch_pdu; + /// BCCH buffer size + uint32_t ccch_buffer; + /// total BCCH buffer size + uint32_t total_ccch_buffer; + /// BCCH MCS + uint32_t ccch_mcs; + + /// num PCCH PDU per CC + uint32_t total_num_pcch_pdu; + /// PCCH buffer size + uint32_t pcch_buffer; + /// total PCCH buffer size + uint32_t total_pcch_buffer; /// BCCH MCS - uint32_t ccch_mcs; + uint32_t pcch_mcs; /// num active users - uint16_t num_dlactive_UEs; - /// available number of PRBs for a give SF - uint16_t available_prbs; - /// total number of PRB available for the user plane - uint32_t total_available_prbs; - /// aggregation - /// total avilable nccc : num control channel element - uint16_t available_ncces; - // only for a new transmission, should be extended for retransmission - // current dlsch bit rate for all transport channels - uint32_t dlsch_bitrate; - // - uint32_t dlsch_bytes_tx; - // - uint32_t dlsch_pdus_tx; - // - uint32_t total_dlsch_bitrate; - // - uint32_t total_dlsch_bytes_tx; - // - uint32_t total_dlsch_pdus_tx; - - // here for RX - // - uint32_t ulsch_bitrate; - // - uint32_t ulsch_bytes_rx; - // - uint64_t ulsch_pdus_rx; - - uint32_t total_ulsch_bitrate; - // - uint32_t total_ulsch_bytes_rx; - // - uint32_t total_ulsch_pdus_rx; - - - /// MAC agent-related stats - /// total number of scheduling decisions - int sched_decisions; - /// missed deadlines - int missed_deadlines; + uint16_t num_dlactive_UEs; + /// available number of PRBs for a give SF + uint16_t available_prbs; + /// total number of PRB available for the user plane + uint32_t total_available_prbs; + /// aggregation + /// total avilable nccc : num control channel element + uint16_t available_ncces; + // only for a new transmission, should be extended for retransmission + // current dlsch bit rate for all transport channels + uint32_t dlsch_bitrate; + // + uint32_t dlsch_bytes_tx; + // + uint32_t dlsch_pdus_tx; + // + uint32_t total_dlsch_bitrate; + // + uint32_t total_dlsch_bytes_tx; + // + uint32_t total_dlsch_pdus_tx; + + // here for RX + // + uint32_t ulsch_bitrate; + // + uint32_t ulsch_bytes_rx; + // + uint64_t ulsch_pdus_rx; + + uint32_t total_ulsch_bitrate; + // + uint32_t total_ulsch_bytes_rx; + // + uint32_t total_ulsch_pdus_rx; + + + /// MAC agent-related stats + /// total number of scheduling decisions + int sched_decisions; + /// missed deadlines + int missed_deadlines; } eNB_STATS; /*! \brief eNB statistics for the connected UEs*/ typedef struct { - - /// CRNTI of UE - rnti_t crnti; ///user id (rnti) of connected UEs - // rrc status - uint8_t rrc_status; - /// harq pid - uint8_t harq_pid; - /// harq rounf - uint8_t harq_round; - /// total available number of PRBs for a new transmission - uint16_t rbs_used; - /// total available number of PRBs for a retransmission - uint16_t rbs_used_retx; - /// total nccc used for a new transmission: num control channel element - uint16_t ncce_used; - /// total avilable nccc for a retransmission: num control channel element - uint16_t ncce_used_retx; - - // mcs1 before the rate adaptaion - uint8_t dlsch_mcs1; - /// Target mcs2 after rate-adaptation - uint8_t dlsch_mcs2; - // current TBS with mcs2 - uint32_t TBS; - // total TBS with mcs2 - // uint32_t total_TBS; - // total rb used for a new transmission - uint32_t total_rbs_used; - // total rb used for retransmission - uint32_t total_rbs_used_retx; - - /// TX - /// Num pkt - uint32_t num_pdu_tx[NB_RB_MAX]; - /// num bytes - uint32_t num_bytes_tx[NB_RB_MAX]; - /// num retransmission / harq - uint32_t num_retransmission; - /// instantaneous tx throughput for each TTI - // uint32_t tti_throughput[NB_RB_MAX]; - - /// overall - // - uint32_t dlsch_bitrate; - //total - uint32_t total_dlsch_bitrate; - /// headers+ CE + padding bytes for a MAC PDU - uint64_t overhead_bytes; - /// headers+ CE + padding bytes for a MAC PDU - uint64_t total_overhead_bytes; - /// headers+ CE + padding bytes for a MAC PDU - uint64_t avg_overhead_bytes; - // MAC multiplexed payload - uint64_t total_sdu_bytes; - // total MAC pdu bytes - uint64_t total_pdu_bytes; - - // total num pdu - uint32_t total_num_pdus; - // - // uint32_t avg_pdu_size; - - /// RX - - /// PUCCH1a/b power (dBm) - int32_t Po_PUCCH_dBm; - /// Indicator that Po_PUCCH has been updated by PHY - int32_t Po_PUCCH_update; - /// Uplink measured RSSI - int32_t UL_rssi; - /// preassigned mcs after rate adaptation - uint8_t ulsch_mcs1; - /// adjusted mcs - uint8_t ulsch_mcs2; - - /// estimated average pdu inter-departure time - uint32_t avg_pdu_idt; - /// estimated average pdu size - uint32_t avg_pdu_ps; - /// - uint32_t aggregated_pdu_size; - uint32_t aggregated_pdu_arrival; - - /// uplink transport block size - uint32_t ulsch_TBS; - - /// total rb used for a new uplink transmission - uint32_t num_retransmission_rx; - /// total rb used for a new uplink transmission - uint32_t rbs_used_rx; - /// total rb used for a new uplink retransmission - uint32_t rbs_used_retx_rx; - /// total rb used for a new uplink transmission - uint32_t total_rbs_used_rx; - /// normalized rx power - int32_t normalized_rx_power; - /// target rx power - int32_t target_rx_power; - - /// num rx pdu - uint32_t num_pdu_rx[NB_RB_MAX]; - /// num bytes rx - uint32_t num_bytes_rx[NB_RB_MAX]; - /// instantaneous rx throughput for each TTI - // uint32_t tti_goodput[NB_RB_MAX]; - /// errors - uint32_t num_errors_rx; - - uint64_t overhead_bytes_rx; - /// headers+ CE + padding bytes for a MAC PDU - uint64_t total_overhead_bytes_rx; - /// headers+ CE + padding bytes for a MAC PDU - uint64_t avg_overhead_bytes_rx; - // - uint32_t ulsch_bitrate; - //total - uint32_t total_ulsch_bitrate; - /// overall - /// MAC pdu bytes - uint64_t pdu_bytes_rx; - /// total MAC pdu bytes - uint64_t total_pdu_bytes_rx; - /// total num pdu - uint32_t total_num_pdus_rx; - /// num of error pdus - uint32_t total_num_errors_rx; + /// CRNTI of UE + rnti_t crnti; ///user id (rnti) of connected UEs + // rrc status + uint8_t rrc_status; + /// harq pid + uint8_t harq_pid; + /// harq rounf + uint8_t harq_round; + /// total available number of PRBs for a new transmission + uint16_t rbs_used; + /// total available number of PRBs for a retransmission + uint16_t rbs_used_retx; + /// total nccc used for a new transmission: num control channel element + uint16_t ncce_used; + /// total avilable nccc for a retransmission: num control channel element + uint16_t ncce_used_retx; + + // mcs1 before the rate adaptaion + uint8_t dlsch_mcs1; + /// Target mcs2 after rate-adaptation + uint8_t dlsch_mcs2; + // current TBS with mcs2 + uint32_t TBS; + // total TBS with mcs2 + // uint32_t total_TBS; + // total rb used for a new transmission + uint32_t total_rbs_used; + // total rb used for retransmission + uint32_t total_rbs_used_retx; + + /// TX + /// Num pkt + uint32_t num_pdu_tx[NB_RB_MAX]; + /// num bytes + uint32_t num_bytes_tx[NB_RB_MAX]; + /// num retransmission / harq + uint32_t num_retransmission; + /// instantaneous tx throughput for each TTI + // uint32_t tti_throughput[NB_RB_MAX]; + + /// overall + // + uint32_t dlsch_bitrate; + //total + uint32_t total_dlsch_bitrate; + /// headers+ CE + padding bytes for a MAC PDU + uint64_t overhead_bytes; + /// headers+ CE + padding bytes for a MAC PDU + uint64_t total_overhead_bytes; + /// headers+ CE + padding bytes for a MAC PDU + uint64_t avg_overhead_bytes; + // MAC multiplexed payload + uint64_t total_sdu_bytes; + // total MAC pdu bytes + uint64_t total_pdu_bytes; + + // total num pdu + uint32_t total_num_pdus; + // + // uint32_t avg_pdu_size; + + /// RX + + /// PUCCH1a/b power (dBm) + int32_t Po_PUCCH_dBm; + /// Indicator that Po_PUCCH has been updated by PHY + int32_t Po_PUCCH_update; + /// Uplink measured RSSI + int32_t UL_rssi; + /// preassigned mcs after rate adaptation + uint8_t ulsch_mcs1; + /// adjusted mcs + uint8_t ulsch_mcs2; + + /// estimated average pdu inter-departure time + uint32_t avg_pdu_idt; + /// estimated average pdu size + uint32_t avg_pdu_ps; + /// + uint32_t aggregated_pdu_size; + uint32_t aggregated_pdu_arrival; + + /// uplink transport block size + uint32_t ulsch_TBS; + + /// total rb used for a new uplink transmission + uint32_t num_retransmission_rx; + /// total rb used for a new uplink transmission + uint32_t rbs_used_rx; + /// total rb used for a new uplink retransmission + uint32_t rbs_used_retx_rx; + /// total rb used for a new uplink transmission + uint32_t total_rbs_used_rx; + /// normalized rx power + int32_t normalized_rx_power; + /// target rx power + int32_t target_rx_power; + + /// num rx pdu + uint32_t num_pdu_rx[NB_RB_MAX]; + /// num bytes rx + uint32_t num_bytes_rx[NB_RB_MAX]; + /// instantaneous rx throughput for each TTI + // uint32_t tti_goodput[NB_RB_MAX]; + /// errors + uint32_t num_errors_rx; + + uint64_t overhead_bytes_rx; + /// headers+ CE + padding bytes for a MAC PDU + uint64_t total_overhead_bytes_rx; + /// headers+ CE + padding bytes for a MAC PDU + uint64_t avg_overhead_bytes_rx; + // + uint32_t ulsch_bitrate; + //total + uint32_t total_ulsch_bitrate; + /// overall + /// MAC pdu bytes + uint64_t pdu_bytes_rx; + /// total MAC pdu bytes + uint64_t total_pdu_bytes_rx; + /// total num pdu + uint32_t total_num_pdus_rx; + /// num of error pdus + uint32_t total_num_errors_rx; } eNB_UE_STATS; /*! \brief eNB template for UE context information */ typedef struct { - /// C-RNTI of UE - rnti_t rnti; - /// NDI from last scheduling - uint8_t oldNDI[8]; - /// mcs1 from last scheduling - uint8_t oldmcs1[8]; - /// mcs2 from last scheduling - uint8_t oldmcs2[8]; - /// NDI from last UL scheduling - uint8_t oldNDI_UL[8]; - /// mcs from last UL scheduling - uint8_t mcs_UL[8]; - /// TBS from last UL scheduling - uint8_t TBS_UL[8]; - /// Flag to indicate UL has been scheduled at least once - boolean_t ul_active; - /// Flag to indicate UE has been configured (ACK from RRCConnectionSetup received) - boolean_t configured; - - /// MCS from last scheduling - uint8_t mcs[8]; - - /// TPC from last scheduling - uint8_t oldTPC[8]; - - // PHY interface info - - /// Number of Allocated RBs for DL after scheduling (prior to frequency allocation) - uint16_t nb_rb[8]; // num_max_harq - - /// Number of Allocated RBs for UL after scheduling - uint16_t nb_rb_ul[8]; // num_max_harq - - /// Number of Allocated RBs for UL after scheduling - uint16_t first_rb_ul[8]; // num_max_harq - - /// Cyclic shift for DMRS after scheduling - uint16_t cshift[8]; // num_max_harq - - /// Number of Allocated RBs by the ulsch preprocessor - uint8_t pre_allocated_nb_rb_ul; - - /// index of Allocated RBs by the ulsch preprocessor - int8_t pre_allocated_rb_table_index_ul; - - /// total allocated RBs - int8_t total_allocated_rbs; - - /// pre-assigned MCS by the ulsch preprocessor - uint8_t pre_assigned_mcs_ul; - - /// assigned MCS by the ulsch scheduler - uint8_t assigned_mcs_ul; - - /// DL DAI - uint8_t DAI; - - /// UL DAI - uint8_t DAI_ul[10]; - - /// UL Scheduling Request Received - uint8_t ul_SR; - - ///Resource Block indication for each sub-band in MU-MIMO - uint8_t rballoc_subband[8][50]; - - // Logical channel info for link with RLC - - /// Last received UE BSR info for each logical channel group id - uint8_t bsr_info[MAX_NUM_LCGID]; - - /// LCGID mapping - long lcgidmap[11]; - - /// phr information - int8_t phr_info; - - /// phr information - int8_t phr_info_configured; - - ///dl buffer info - uint32_t dl_buffer_info[MAX_NUM_LCID]; - /// total downlink buffer info - uint32_t dl_buffer_total; - /// total downlink pdus - uint32_t dl_pdus_total; - /// downlink pdus for each LCID - uint32_t dl_pdus_in_buffer[MAX_NUM_LCID]; - /// creation time of the downlink buffer head for each LCID - uint32_t dl_buffer_head_sdu_creation_time[MAX_NUM_LCID]; - /// maximum creation time of the downlink buffer head across all LCID - uint32_t dl_buffer_head_sdu_creation_time_max; - /// a flag indicating that the downlink head SDU is segmented - uint8_t dl_buffer_head_sdu_is_segmented[MAX_NUM_LCID]; - /// size of remaining size to send for the downlink head SDU - uint32_t dl_buffer_head_sdu_remaining_size_to_send[MAX_NUM_LCID]; - - /// total uplink buffer size - uint32_t ul_total_buffer; - /// uplink buffer creation time for each LCID - uint32_t ul_buffer_creation_time[MAX_NUM_LCGID]; - /// maximum uplink buffer creation time across all the LCIDs - uint32_t ul_buffer_creation_time_max; - /// uplink buffer size per LCID - uint32_t ul_buffer_info[MAX_NUM_LCGID]; - - /// UE tx power - int32_t ue_tx_power; + /// C-RNTI of UE + rnti_t rnti; + /// NDI from last scheduling + uint8_t oldNDI[8]; + /// mcs1 from last scheduling + uint8_t oldmcs1[8]; + /// mcs2 from last scheduling + uint8_t oldmcs2[8]; + /// NDI from last UL scheduling + uint8_t oldNDI_UL[8]; + /// mcs from last UL scheduling + uint8_t mcs_UL[8]; + /// TBS from last UL scheduling + uint8_t TBS_UL[8]; + /// Flag to indicate UL has been scheduled at least once + boolean_t ul_active; + /// Flag to indicate UE has been configured (ACK from RRCConnectionSetup received) + boolean_t configured; + + /// MCS from last scheduling + uint8_t mcs[8]; + + /// TPC from last scheduling + uint8_t oldTPC[8]; + + // PHY interface info + + /// Number of Allocated RBs for DL after scheduling (prior to frequency allocation) + uint16_t nb_rb[8]; // num_max_harq + + /// Number of Allocated RBs for UL after scheduling + uint16_t nb_rb_ul[8]; // num_max_harq + + /// Number of Allocated RBs for UL after scheduling + uint16_t first_rb_ul[8]; // num_max_harq + + /// Cyclic shift for DMRS after scheduling + uint16_t cshift[8]; // num_max_harq + + /// Number of Allocated RBs by the ulsch preprocessor + uint8_t pre_allocated_nb_rb_ul; + + /// index of Allocated RBs by the ulsch preprocessor + int8_t pre_allocated_rb_table_index_ul; + + /// total allocated RBs + int8_t total_allocated_rbs; + + /// pre-assigned MCS by the ulsch preprocessor + uint8_t pre_assigned_mcs_ul; + + /// assigned MCS by the ulsch scheduler + uint8_t assigned_mcs_ul; + + /// DL DAI + uint8_t DAI; + + /// UL DAI + uint8_t DAI_ul[10]; + + /// UL Scheduling Request Received + uint8_t ul_SR; + + ///Resource Block indication for each sub-band in MU-MIMO + uint8_t rballoc_subband[8][50]; + + // Logical channel info for link with RLC + + /// Last received UE BSR info for each logical channel group id + uint8_t bsr_info[MAX_NUM_LCGID]; + + /// LCGID mapping + long lcgidmap[11]; + + /// phr information + int8_t phr_info; + + /// phr information + int8_t phr_info_configured; + + ///dl buffer info + uint32_t dl_buffer_info[MAX_NUM_LCID]; + /// total downlink buffer info + uint32_t dl_buffer_total; + /// total downlink pdus + uint32_t dl_pdus_total; + /// downlink pdus for each LCID + uint32_t dl_pdus_in_buffer[MAX_NUM_LCID]; + /// creation time of the downlink buffer head for each LCID + uint32_t dl_buffer_head_sdu_creation_time[MAX_NUM_LCID]; + /// maximum creation time of the downlink buffer head across all LCID + uint32_t dl_buffer_head_sdu_creation_time_max; + /// a flag indicating that the downlink head SDU is segmented + uint8_t dl_buffer_head_sdu_is_segmented[MAX_NUM_LCID]; + /// size of remaining size to send for the downlink head SDU + uint32_t dl_buffer_head_sdu_remaining_size_to_send[MAX_NUM_LCID]; + + /// total uplink buffer size + uint32_t ul_total_buffer; + /// uplink buffer creation time for each LCID + uint32_t ul_buffer_creation_time[MAX_NUM_LCGID]; + /// maximum uplink buffer creation time across all the LCIDs + uint32_t ul_buffer_creation_time_max; + /// uplink buffer size per LCID + uint32_t ul_buffer_info[MAX_NUM_LCGID]; + + /// UE tx power + int32_t ue_tx_power; - /// stores the frame where the last TPC was transmitted - uint32_t pusch_tpc_tx_frame; - uint32_t pusch_tpc_tx_subframe; - uint32_t pucch_tpc_tx_frame; - uint32_t pucch_tpc_tx_subframe; + /// stores the frame where the last TPC was transmitted + uint32_t pusch_tpc_tx_frame; + uint32_t pusch_tpc_tx_subframe; + uint32_t pucch_tpc_tx_frame; + uint32_t pucch_tpc_tx_subframe; #ifdef LOCALIZATION - eNB_UE_estimated_distances distance; + eNB_UE_estimated_distances distance; #endif #ifdef Rel14 - uint8_t rach_resource_type; - uint16_t mpdcch_repetition_cnt; - frame_t Msg2_frame; + uint8_t rach_resource_type; + uint16_t mpdcch_repetition_cnt; + frame_t Msg2_frame; #endif - sub_frame_t Msg2_subframe; + sub_frame_t Msg2_subframe; - PhysicalConfigDedicated_t *physicalConfigDedicated; + PhysicalConfigDedicated_t *physicalConfigDedicated; } UE_TEMPLATE; /*! \brief scheduling control information set through an API (not used)*/ typedef struct { - ///UL transmission bandwidth in RBs - uint8_t ul_bandwidth[MAX_NUM_LCID]; - ///DL transmission bandwidth in RBs - uint8_t dl_bandwidth[MAX_NUM_LCID]; - - //To do GBR bearer - uint8_t min_ul_bandwidth[MAX_NUM_LCID]; - - uint8_t min_dl_bandwidth[MAX_NUM_LCID]; - - ///aggregated bit rate of non-gbr bearer per UE - uint64_t ue_AggregatedMaximumBitrateDL; - ///aggregated bit rate of non-gbr bearer per UE - uint64_t ue_AggregatedMaximumBitrateUL; - ///CQI scheduling interval in subframes. - uint16_t cqiSchedInterval; - ///Contention resolution timer used during random access - uint8_t mac_ContentionResolutionTimer; - - uint16_t max_allowed_rbs[MAX_NUM_LCID]; - - uint8_t max_mcs[MAX_NUM_LCID]; - - uint16_t priority[MAX_NUM_LCID]; - - // resource scheduling information - - /// Current DL harq round per harq_pid on each CC - uint8_t round[MAX_NUM_CCs][10]; - /// Current Active TBs per harq_pid on each CC - uint8_t tbcnt[MAX_NUM_CCs][10]; - /// Current UL harq round per harq_pid on each CC - uint8_t round_UL[MAX_NUM_CCs][8]; - uint8_t dl_pow_off[MAX_NUM_CCs]; - uint16_t pre_nb_available_rbs[MAX_NUM_CCs]; - unsigned char rballoc_sub_UE[MAX_NUM_CCs][N_RBG_MAX]; - uint16_t ta_timer; - int16_t ta_update; - uint16_t ul_consecutive_errors; - int32_t context_active_timer; - int32_t cqi_req_timer; - int32_t ul_inactivity_timer; - int32_t ul_failure_timer; - int32_t ul_scheduled; - int32_t ra_pdcch_order_sent; - int32_t ul_out_of_sync; - int32_t phr_received; - uint8_t periodic_ri_received[NFAPI_CC_MAX]; - uint8_t aperiodic_ri_received[NFAPI_CC_MAX]; - uint8_t pucch1_cqi_update[NFAPI_CC_MAX]; - uint8_t pucch1_snr[NFAPI_CC_MAX]; - uint8_t pucch2_cqi_update[NFAPI_CC_MAX]; - uint8_t pucch2_snr[NFAPI_CC_MAX]; - uint8_t pucch3_cqi_update[NFAPI_CC_MAX]; - uint8_t pucch3_snr[NFAPI_CC_MAX]; - uint8_t pusch_snr[NFAPI_CC_MAX]; - uint16_t feedback_cnt[NFAPI_CC_MAX]; - uint16_t timing_advance; - uint16_t timing_advance_r9; - uint8_t periodic_wideband_cqi[NFAPI_CC_MAX]; - uint8_t periodic_wideband_spatial_diffcqi[NFAPI_CC_MAX]; - uint8_t periodic_wideband_pmi[NFAPI_CC_MAX]; - uint8_t periodic_subband_cqi[NFAPI_CC_MAX][16]; - uint8_t periodic_subband_spatial_diffcqi[NFAPI_CC_MAX][16]; - uint8_t aperiodic_subband_cqi0[NFAPI_CC_MAX][25]; - uint8_t aperiodic_subband_pmi[NFAPI_CC_MAX][25]; - uint8_t aperiodic_subband_diffcqi0[NFAPI_CC_MAX][25]; - uint8_t aperiodic_subband_cqi1[NFAPI_CC_MAX][25]; - uint8_t aperiodic_subband_diffcqi1[NFAPI_CC_MAX][25]; - uint8_t aperiodic_wideband_cqi0[NFAPI_CC_MAX]; - uint8_t aperiodic_wideband_pmi[NFAPI_CC_MAX]; - uint8_t aperiodic_wideband_cqi1[NFAPI_CC_MAX]; - uint8_t aperiodic_wideband_pmi1[NFAPI_CC_MAX]; - uint8_t dl_cqi[NFAPI_CC_MAX]; + ///UL transmission bandwidth in RBs + uint8_t ul_bandwidth[MAX_NUM_LCID]; + ///DL transmission bandwidth in RBs + uint8_t dl_bandwidth[MAX_NUM_LCID]; + + //To do GBR bearer + uint8_t min_ul_bandwidth[MAX_NUM_LCID]; + + uint8_t min_dl_bandwidth[MAX_NUM_LCID]; + + ///aggregated bit rate of non-gbr bearer per UE + uint64_t ue_AggregatedMaximumBitrateDL; + ///aggregated bit rate of non-gbr bearer per UE + uint64_t ue_AggregatedMaximumBitrateUL; + ///CQI scheduling interval in subframes. + uint16_t cqiSchedInterval; + ///Contention resolution timer used during random access + uint8_t mac_ContentionResolutionTimer; + + uint16_t max_allowed_rbs[MAX_NUM_LCID]; + + uint8_t max_mcs[MAX_NUM_LCID]; + + uint16_t priority[MAX_NUM_LCID]; + + // resource scheduling information + + /// Current DL harq round per harq_pid on each CC + uint8_t round[MAX_NUM_CCs][10]; + /// Current Active TBs per harq_pid on each CC + uint8_t tbcnt[MAX_NUM_CCs][10]; + /// Current UL harq round per harq_pid on each CC + uint8_t round_UL[MAX_NUM_CCs][8]; + uint8_t dl_pow_off[MAX_NUM_CCs]; + uint16_t pre_nb_available_rbs[MAX_NUM_CCs]; + unsigned char rballoc_sub_UE[MAX_NUM_CCs][N_RBG_MAX]; + uint16_t ta_timer; + int16_t ta_update; + uint16_t ul_consecutive_errors; + int32_t context_active_timer; + int32_t cqi_req_timer; + int32_t ul_inactivity_timer; + int32_t ul_failure_timer; + uint32_t ue_reestablishment_reject_timer; + uint32_t ue_reestablishment_reject_timer_thres; + int32_t ul_scheduled; + int32_t ra_pdcch_order_sent; + int32_t ul_out_of_sync; + int32_t phr_received; + uint8_t periodic_ri_received[NFAPI_CC_MAX]; + uint8_t aperiodic_ri_received[NFAPI_CC_MAX]; + uint8_t pucch1_cqi_update[NFAPI_CC_MAX]; + uint8_t pucch1_snr[NFAPI_CC_MAX]; + uint8_t pucch2_cqi_update[NFAPI_CC_MAX]; + uint8_t pucch2_snr[NFAPI_CC_MAX]; + uint8_t pucch3_cqi_update[NFAPI_CC_MAX]; + uint8_t pucch3_snr[NFAPI_CC_MAX]; + uint8_t pusch_snr[NFAPI_CC_MAX]; + uint16_t feedback_cnt[NFAPI_CC_MAX]; + uint16_t timing_advance; + uint16_t timing_advance_r9; + uint8_t periodic_wideband_cqi[NFAPI_CC_MAX]; + uint8_t periodic_wideband_spatial_diffcqi[NFAPI_CC_MAX]; + uint8_t periodic_wideband_pmi[NFAPI_CC_MAX]; + uint8_t periodic_subband_cqi[NFAPI_CC_MAX][16]; + uint8_t periodic_subband_spatial_diffcqi[NFAPI_CC_MAX][16]; + uint8_t aperiodic_subband_cqi0[NFAPI_CC_MAX][25]; + uint8_t aperiodic_subband_pmi[NFAPI_CC_MAX][25]; + uint8_t aperiodic_subband_diffcqi0[NFAPI_CC_MAX][25]; + uint8_t aperiodic_subband_cqi1[NFAPI_CC_MAX][25]; + uint8_t aperiodic_subband_diffcqi1[NFAPI_CC_MAX][25]; + uint8_t aperiodic_wideband_cqi0[NFAPI_CC_MAX]; + uint8_t aperiodic_wideband_pmi[NFAPI_CC_MAX]; + uint8_t aperiodic_wideband_cqi1[NFAPI_CC_MAX]; + uint8_t aperiodic_wideband_pmi1[NFAPI_CC_MAX]; + uint8_t dl_cqi[NFAPI_CC_MAX]; + int32_t uplane_inactivity_timer; } UE_sched_ctrl; /*! \brief eNB template for the Random access information */ typedef struct { - /// Flag to indicate this process is active - boolean_t RA_active; - /// Size of DCI for RA-Response (bytes) - uint8_t RA_dci_size_bytes1; - /// Size of DCI for RA-Response (bits) - uint8_t RA_dci_size_bits1; - /// Actual DCI to transmit for RA-Response - uint8_t RA_alloc_pdu1[(MAX_DCI_SIZE_BITS>>3)+1]; - /// DCI format for RA-Response (should be 1A) - uint8_t RA_dci_fmt1; - /// Size of DCI for Msg4/ContRes (bytes) - uint8_t RA_dci_size_bytes2; - /// Size of DCI for Msg4/ContRes (bits) - uint8_t RA_dci_size_bits2; - /// Actual DCI to transmit for Msg4/ContRes - uint8_t RA_alloc_pdu2[(MAX_DCI_SIZE_BITS>>3)+1]; - /// DCI format for Msg4/ContRes (should be 1A) - uint8_t RA_dci_fmt2; - /// Flag to indicate the eNB should generate RAR. This is triggered by detection of PRACH - uint8_t generate_rar; - /// Subframe where preamble was received - uint8_t preamble_subframe; - /// Subframe where Msg2 is to be sent - uint8_t Msg2_subframe; - /// Frame where Msg2 is to be sent - frame_t Msg2_frame; - /// Subframe where Msg3 is to be sent - sub_frame_t Msg3_subframe; - /// Frame where Msg3 is to be sent - frame_t Msg3_frame; - /// Subframe where Msg4 is to be sent - sub_frame_t Msg4_subframe; - /// Frame where Msg4 is to be sent - frame_t Msg4_frame; - /// Flag to indicate the eNB should generate Msg4 upon reception of SDU from RRC. This is triggered by first ULSCH reception at eNB for new user. - uint8_t generate_Msg4; - /// Flag to indicate that eNB is waiting for ACK that UE has received Msg3. - uint8_t wait_ack_Msg4; - /// harq_pid used for Msg4 transmission - uint8_t harq_pid; - /// UE RNTI allocated during RAR - rnti_t rnti; - /// RA RNTI allocated from received PRACH - uint16_t RA_rnti; - /// Received preamble_index - uint8_t preamble_index; - /// Received UE Contention Resolution Identifier - uint8_t cont_res_id[6]; - /// Timing offset indicated by PHY - int16_t timing_offset; - /// Timeout for RRC connection - int16_t RRC_timer; - /// Msg3 first RB - uint8_t msg3_first_rb; - /// Msg3 number of RB - uint8_t msg3_nb_rb; - /// Msg3 MCS - uint8_t msg3_mcs; - /// Msg3 TPC command - uint8_t msg3_TPC; - /// Msg3 ULdelay command - uint8_t msg3_ULdelay; - /// Msg3 cqireq command - uint8_t msg3_cqireq; - /// Round of Msg3 HARQ - uint8_t msg3_round; - /// TBS used for Msg4 - int msg4_TBsize; - /// MCS used for Msg4 - int msg4_mcs; + /// Flag to indicate this process is active + RA_state state; + /// Subframe where preamble was received + uint8_t preamble_subframe; + /// Subframe where Msg2 is to be sent + uint8_t Msg2_subframe; + /// Frame where Msg2 is to be sent + frame_t Msg2_frame; + /// Subframe where Msg3 is to be sent + sub_frame_t Msg3_subframe; + /// Frame where Msg3 is to be sent + frame_t Msg3_frame; + /// Subframe where Msg4 is to be sent + sub_frame_t Msg4_subframe; + /// Frame where Msg4 is to be sent + frame_t Msg4_frame; + /// harq_pid used for Msg4 transmission + uint8_t harq_pid; + /// UE RNTI allocated during RAR + rnti_t rnti; + /// RA RNTI allocated from received PRACH + uint16_t RA_rnti; + /// Received preamble_index + uint8_t preamble_index; + /// Received UE Contention Resolution Identifier + uint8_t cont_res_id[6]; + /// Timing offset indicated by PHY + int16_t timing_offset; + /// Timeout for RRC connection + int16_t RRC_timer; + /// Msg3 first RB + uint8_t msg3_first_rb; + /// Msg3 number of RB + uint8_t msg3_nb_rb; + /// Msg3 MCS + uint8_t msg3_mcs; + /// Msg3 TPC command + uint8_t msg3_TPC; + /// Msg3 ULdelay command + uint8_t msg3_ULdelay; + /// Msg3 cqireq command + uint8_t msg3_cqireq; + /// Round of Msg3 HARQ + uint8_t msg3_round; + /// TBS used for Msg4 + int msg4_TBsize; + /// MCS used for Msg4 + int msg4_mcs; #ifdef Rel14 - uint8_t rach_resource_type; - uint8_t msg2_mpdcch_repetition_cnt; - uint8_t msg4_mpdcch_repetition_cnt; - uint8_t msg2_narrowband; - uint8_t msg34_narrowband; + uint8_t rach_resource_type; + uint8_t msg2_mpdcch_repetition_cnt; + uint8_t msg4_mpdcch_repetition_cnt; + uint8_t msg2_narrowband; + uint8_t msg34_narrowband; #endif -} RA_TEMPLATE; +} RA_t; /*! \brief subband bitmap confguration (for ALU icic algo purpose), in test phase */ typedef struct { - uint8_t sbmap[13]; - uint8_t periodicity; - uint8_t first_subframe; - uint8_t sb_size; - uint8_t nb_active_sb; + uint8_t sbmap[13]; //13 = number of SB MAX for 100 PRB + uint8_t periodicity; + uint8_t first_subframe; + uint8_t sb_size; + uint8_t nb_active_sb; } SBMAP_CONF; /*! \brief UE list used by eNB to order UEs/CC for scheduling*/ typedef struct { - /// Dedicated information for UEs - struct PhysicalConfigDedicated *physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - /// DLSCH pdu - DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX]; - /// DCI template and MAC connection parameters for UEs - UE_TEMPLATE UE_template[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - /// DCI template and MAC connection for RA processes - int pCC_id[NUMBER_OF_UE_MAX]; - /// sorted downlink component carrier for the scheduler - int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - /// number of downlink active component carrier - int numactiveCCs[NUMBER_OF_UE_MAX]; - /// sorted uplink component carrier for the scheduler - int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - /// number of uplink active component carrier - int numactiveULCCs[NUMBER_OF_UE_MAX]; - /// number of downlink active component carrier - uint8_t dl_CC_bitmap[NUMBER_OF_UE_MAX]; - /// eNB to UE statistics - eNB_UE_STATS eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - /// scheduling control info - UE_sched_ctrl UE_sched_ctrl[NUMBER_OF_UE_MAX]; - int next[NUMBER_OF_UE_MAX]; - int head; - int next_ul[NUMBER_OF_UE_MAX]; - int head_ul; - int avail; - int num_UEs; - boolean_t active[NUMBER_OF_UE_MAX]; + /// Dedicated information for UEs + struct PhysicalConfigDedicated + *physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + /// DLSCH pdu + DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX]; + /// DCI template and MAC connection parameters for UEs + UE_TEMPLATE UE_template[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + /// DCI template and MAC connection for RA processes + int pCC_id[NUMBER_OF_UE_MAX]; + /// sorted downlink component carrier for the scheduler + int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + /// number of downlink active component carrier + int numactiveCCs[NUMBER_OF_UE_MAX]; + /// sorted uplink component carrier for the scheduler + int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + /// number of uplink active component carrier + int numactiveULCCs[NUMBER_OF_UE_MAX]; + /// number of downlink active component carrier + uint8_t dl_CC_bitmap[NUMBER_OF_UE_MAX]; + /// eNB to UE statistics + eNB_UE_STATS eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + /// scheduling control info + UE_sched_ctrl UE_sched_ctrl[NUMBER_OF_UE_MAX]; + int next[NUMBER_OF_UE_MAX]; + int head; + int next_ul[NUMBER_OF_UE_MAX]; + int head_ul; + int avail; + int num_UEs; + boolean_t active[NUMBER_OF_UE_MAX]; } UE_list_t; /*! \brief eNB common channels */ typedef struct { - int physCellId; - int p_eNB; - int Ncp; - int eutra_band; - uint32_t dl_CarrierFreq; - BCCH_BCH_Message_t *mib; - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon; + int physCellId; + int p_eNB; + int Ncp; + int eutra_band; + uint32_t dl_CarrierFreq; + BCCH_BCH_Message_t *mib; + RadioResourceConfigCommonSIB_t *radioResourceConfigCommon; #ifdef Rel14 - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR; + RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR; #endif - TDD_Config_t *tdd_Config; - SchedulingInfoList_t *schedulingInfoList; - ARFCN_ValueEUTRA_t ul_CarrierFreq; - long ul_Bandwidth; - /// Outgoing MIB PDU for PHY - MIB_PDU MIB_pdu; - /// Outgoing BCCH pdu for PHY - BCCH_PDU BCCH_pdu; - /// Outgoing BCCH DCI allocation - uint32_t BCCH_alloc_pdu; - /// Outgoing CCCH pdu for PHY - CCCH_PDU CCCH_pdu; - /// Outgoing RAR pdu for PHY - RAR_PDU RAR_pdu; - /// Template for RA computations - RA_TEMPLATE RA_template[NB_RA_PROC_MAX]; - /// VRB map for common channels - uint8_t vrb_map[100]; - /// VRB map for common channels and retransmissions by PHICH - uint8_t vrb_map_UL[100]; - /// MBSFN SubframeConfig - struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; - /// number of subframe allocation pattern available for MBSFN sync area - uint8_t num_sf_allocation_pattern; + TDD_Config_t *tdd_Config; + SchedulingInfoList_t *schedulingInfoList; + ARFCN_ValueEUTRA_t ul_CarrierFreq; + long ul_Bandwidth; + /// Outgoing MIB PDU for PHY + MIB_PDU MIB_pdu; + /// Outgoing BCCH pdu for PHY + BCCH_PDU BCCH_pdu; + /// Outgoing BCCH DCI allocation + uint32_t BCCH_alloc_pdu; + /// Outgoing CCCH pdu for PHY + CCCH_PDU CCCH_pdu; + /// Outgoing PCCH DCI allocation + uint32_t PCCH_alloc_pdu; + /// Outgoing PCCH pdu for PHY + PCCH_PDU PCCH_pdu; + /// Outgoing RAR pdu for PHY + RAR_PDU RAR_pdu; + /// Template for RA computations + RA_t ra[NB_RA_PROC_MAX]; + /// VRB map for common channels + uint8_t vrb_map[100]; + /// VRB map for common channels and retransmissions by PHICH + uint8_t vrb_map_UL[100]; + /// MBSFN SubframeConfig + struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; + /// number of subframe allocation pattern available for MBSFN sync area + uint8_t num_sf_allocation_pattern; #if defined(Rel10) || defined(Rel14) - /// MBMS Flag - uint8_t MBMS_flag; - /// Outgoing MCCH pdu for PHY - MCCH_PDU MCCH_pdu; - /// MCCH active flag - uint8_t msi_active; - /// MCCH active flag - uint8_t mcch_active; - /// MTCH active flag - uint8_t mtch_active; - /// number of active MBSFN area - uint8_t num_active_mbsfn_area; - /// MBSFN Area Info - struct MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA]; - /// PMCH Config - struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN]; - /// MBMS session info list - struct MBMS_SessionInfoList_r9 *mbms_SessionList[MAX_PMCH_perMBSFN]; - /// Outgoing MCH pdu for PHY - MCH_PDU MCH_pdu; + /// MBMS Flag + uint8_t MBMS_flag; + /// Outgoing MCCH pdu for PHY + MCCH_PDU MCCH_pdu; + /// MCCH active flag + uint8_t msi_active; + /// MCCH active flag + uint8_t mcch_active; + /// MTCH active flag + uint8_t mtch_active; + /// number of active MBSFN area + uint8_t num_active_mbsfn_area; + /// MBSFN Area Info + struct MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA]; + /// PMCH Config + struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN]; + /// MBMS session info list + struct MBMS_SessionInfoList_r9 *mbms_SessionList[MAX_PMCH_perMBSFN]; + /// Outgoing MCH pdu for PHY + MCH_PDU MCH_pdu; #endif #ifdef Rel14 - /// Rel13 parameters from SIB1 - SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext; - /// Counter for SIB1-BR scheduling - int SIB1_BR_cnt; - /// Outgoing BCCH-BR pdu for PHY - BCCH_PDU BCCH_BR_pdu[20]; + /// Rel13 parameters from SIB1 + SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext; + /// Counter for SIB1-BR scheduling + int SIB1_BR_cnt; + /// Outgoing BCCH-BR pdu for PHY + BCCH_PDU BCCH_BR_pdu[20]; #endif } COMMON_channels_t; /*! \brief top level eNB MAC structure */ typedef struct eNB_MAC_INST_s { - /// Ethernet parameters for northbound midhaul interface - eth_params_t eth_params_n; - /// Ethernet parameters for fronthaul interface - eth_params_t eth_params_s; - /// - module_id_t Mod_id; - /// frame counter - frame_t frame; - /// subframe counter - sub_frame_t subframe; - /// Pointer to IF module instance for PHY - IF_Module_t *if_inst; - /// Common cell resources - COMMON_channels_t common_channels[MAX_NUM_CCs]; - /// current PDU index (BCH,MCH,DLSCH) - uint16_t pdu_index[MAX_NUM_CCs]; - - /// NFAPI Config Request Structure - nfapi_config_request_t config[MAX_NUM_CCs]; - /// Preallocated DL pdu list - nfapi_dl_config_request_pdu_t dl_config_pdu_list[MAX_NUM_CCs][MAX_NUM_DL_PDU]; - /// NFAPI DL Config Request Structure - nfapi_dl_config_request_t DL_req[MAX_NUM_CCs]; - /// Preallocated UL pdu list - nfapi_ul_config_request_pdu_t ul_config_pdu_list[MAX_NUM_CCs][MAX_NUM_UL_PDU]; - /// Preallocated UL pdu list for ULSCH (n+k delay) - nfapi_ul_config_request_pdu_t ul_config_pdu_list_tmp[MAX_NUM_CCs][10][MAX_NUM_UL_PDU]; - /// NFAPI UL Config Request Structure, send to L1 4 subframes before processing takes place - nfapi_ul_config_request_t UL_req[MAX_NUM_CCs]; - /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests - nfapi_ul_config_request_t UL_req_tmp[MAX_NUM_CCs][10]; - /// Preallocated HI_DCI0 pdu list - nfapi_hi_dci0_request_pdu_t hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU]; - /// NFAPI HI/DCI0 Config Request Structure - nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs]; - /// Prealocated TX pdu list - nfapi_tx_request_pdu_t tx_request_pdu[MAX_NUM_CCs][MAX_NUM_TX_REQUEST_PDU]; - /// NFAPI DL PDU structure - nfapi_tx_request_t TX_req[MAX_NUM_CCs]; - /// UL handle - uint32_t ul_handle; - UE_list_t UE_list; - - ///subband bitmap configuration - SBMAP_CONF sbmap_conf; - /// CCE table used to build DCI scheduling information - int CCE_table[MAX_NUM_CCs][800]; - /// active flag for Other lcid - uint8_t lcid_active[NB_RB_MAX]; - /// eNB stats - eNB_STATS eNB_stats[MAX_NUM_CCs]; - // MAC function execution peformance profiler - /// processing time of eNB scheduler - time_stats_t eNB_scheduler; - /// processing time of eNB scheduler for SI - time_stats_t schedule_si; - /// processing time of eNB scheduler for Random access - time_stats_t schedule_ra; - /// processing time of eNB ULSCH scheduler - time_stats_t schedule_ulsch; - /// processing time of eNB DCI generation - time_stats_t fill_DLSCH_dci; - /// processing time of eNB MAC preprocessor - time_stats_t schedule_dlsch_preprocessor; - /// processing time of eNB DLSCH scheduler - time_stats_t schedule_dlsch; // include rlc_data_req + MAC header + preprocessor - /// processing time of eNB MCH scheduler - time_stats_t schedule_mch; - /// processing time of eNB ULSCH reception - time_stats_t rx_ulsch_sdu; // include rlc_data_ind + /// Ethernet parameters for northbound midhaul interface + eth_params_t eth_params_n; + /// Ethernet parameters for fronthaul interface + eth_params_t eth_params_s; + /// + module_id_t Mod_id; + /// frame counter + frame_t frame; + /// subframe counter + sub_frame_t subframe; + /// Pointer to IF module instance for PHY + IF_Module_t *if_inst; + /// Common cell resources + COMMON_channels_t common_channels[MAX_NUM_CCs]; + /// current PDU index (BCH,MCH,DLSCH) + uint16_t pdu_index[MAX_NUM_CCs]; + + /// NFAPI Config Request Structure + nfapi_config_request_t config[MAX_NUM_CCs]; + /// Preallocated DL pdu list + nfapi_dl_config_request_pdu_t + dl_config_pdu_list[MAX_NUM_CCs][MAX_NUM_DL_PDU]; + /// NFAPI DL Config Request Structure + nfapi_dl_config_request_t DL_req[MAX_NUM_CCs]; + /// Preallocated UL pdu list + nfapi_ul_config_request_pdu_t + ul_config_pdu_list[MAX_NUM_CCs][MAX_NUM_UL_PDU]; + /// Preallocated UL pdu list for ULSCH (n+k delay) + nfapi_ul_config_request_pdu_t + ul_config_pdu_list_tmp[MAX_NUM_CCs][10][MAX_NUM_UL_PDU]; + /// NFAPI UL Config Request Structure, send to L1 4 subframes before processing takes place + nfapi_ul_config_request_t UL_req[MAX_NUM_CCs]; + /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests + nfapi_ul_config_request_t UL_req_tmp[MAX_NUM_CCs][10]; + /// Preallocated HI_DCI0 pdu list + nfapi_hi_dci0_request_pdu_t + hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU]; + /// NFAPI HI/DCI0 Config Request Structure + nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs]; + /// Prealocated TX pdu list + nfapi_tx_request_pdu_t + tx_request_pdu[MAX_NUM_CCs][MAX_NUM_TX_REQUEST_PDU]; + /// NFAPI DL PDU structure + nfapi_tx_request_t TX_req[MAX_NUM_CCs]; + /// UL handle + uint32_t ul_handle; + UE_list_t UE_list; + + ///subband bitmap configuration + SBMAP_CONF sbmap_conf; + /// CCE table used to build DCI scheduling information + int CCE_table[MAX_NUM_CCs][800]; + /// active flag for Other lcid + uint8_t lcid_active[NB_RB_MAX]; + /// eNB stats + eNB_STATS eNB_stats[MAX_NUM_CCs]; + // MAC function execution peformance profiler + /// processing time of eNB scheduler + time_stats_t eNB_scheduler; + /// processing time of eNB scheduler for SI + time_stats_t schedule_si; + /// processing time of eNB scheduler for Random access + time_stats_t schedule_ra; + /// processing time of eNB ULSCH scheduler + time_stats_t schedule_ulsch; + /// processing time of eNB DCI generation + time_stats_t fill_DLSCH_dci; + /// processing time of eNB MAC preprocessor + time_stats_t schedule_dlsch_preprocessor; + /// processing time of eNB DLSCH scheduler + time_stats_t schedule_dlsch; // include rlc_data_req + MAC header + preprocessor + /// processing time of eNB MCH scheduler + time_stats_t schedule_mch; + /// processing time of eNB ULSCH reception + time_stats_t rx_ulsch_sdu; // include rlc_data_ind + /// processing time of eNB PCH scheduler + time_stats_t schedule_pch; } eNB_MAC_INST; -/* - * UE part +/* + * UE part */ typedef enum { - TYPE0, - TYPE1, - TYPE1A, - TYPE2, - TYPE2A, - TYPEUESPEC + TYPE0, + TYPE1, + TYPE1A, + TYPE2, + TYPE2A, + TYPEUESPEC } MPDCCH_TYPES_t; /*!\brief UE layer 2 status */ typedef enum { - CONNECTION_OK=0, - CONNECTION_LOST, - PHY_RESYNCH, - PHY_HO_PRACH + CONNECTION_OK = 0, + CONNECTION_LOST, + PHY_RESYNCH, + PHY_HO_PRACH } UE_L2_STATE_t; /*!\brief UE scheduling info */ typedef struct { - /// buffer status for each lcgid - uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology - /// keep the number of bytes in rlc buffer for each lcgid - int32_t BSR_bytes[MAX_NUM_LCGID]; - /// after multiplexing buffer remain for each lcid - int32_t LCID_buffer_remain[MAX_NUM_LCID]; - /// sum of all lcid buffer size - uint16_t All_lcid_buffer_size_lastTTI; - /// buffer status for each lcid - uint8_t LCID_status[MAX_NUM_LCID]; - /// SR pending as defined in 36.321 - uint8_t SR_pending; - /// SR_COUNTER as defined in 36.321 - uint16_t SR_COUNTER; - /// logical channel group ide for each LCID - uint8_t LCGID[MAX_NUM_LCID]; - /// retxBSR-Timer, default value is sf2560 - uint16_t retxBSR_Timer; - /// retxBSR_SF, number of subframe before triggering a regular BSR - uint16_t retxBSR_SF; - /// periodicBSR-Timer, default to infinity - uint16_t periodicBSR_Timer; - /// periodicBSR_SF, number of subframe before triggering a periodic BSR - uint16_t periodicBSR_SF; - /// default value is 0: not configured - uint16_t sr_ProhibitTimer; - /// sr ProhibitTime running - uint8_t sr_ProhibitTimer_Running; - /// default value to n5 - uint16_t maxHARQ_Tx; - /// default value is false - uint16_t ttiBundling; - /// default value is release - struct DRX_Config *drx_config; - /// default value is release - struct MAC_MainConfig__phr_Config *phr_config; - ///timer before triggering a periodic PHR - uint16_t periodicPHR_Timer; - ///timer before triggering a prohibit PHR - uint16_t prohibitPHR_Timer; - ///DL Pathloss change value - uint16_t PathlossChange; - ///number of subframe before triggering a periodic PHR - int16_t periodicPHR_SF; - ///number of subframe before triggering a prohibit PHR - int16_t prohibitPHR_SF; - ///DL Pathloss Change in db - uint16_t PathlossChange_db; - - /// default value is false - uint16_t extendedBSR_Sizes_r10; - /// default value is false - uint16_t extendedPHR_r10; - - //Bj bucket usage per lcid - int16_t Bj[MAX_NUM_LCID]; - // Bucket size per lcid - int16_t bucket_size[MAX_NUM_LCID]; + /// buffer status for each lcgid + uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology + /// keep the number of bytes in rlc buffer for each lcgid + int32_t BSR_bytes[MAX_NUM_LCGID]; + /// after multiplexing buffer remain for each lcid + int32_t LCID_buffer_remain[MAX_NUM_LCID]; + /// sum of all lcid buffer size + uint16_t All_lcid_buffer_size_lastTTI; + /// buffer status for each lcid + uint8_t LCID_status[MAX_NUM_LCID]; + /// SR pending as defined in 36.321 + uint8_t SR_pending; + /// SR_COUNTER as defined in 36.321 + uint16_t SR_COUNTER; + /// logical channel group ide for each LCID + uint8_t LCGID[MAX_NUM_LCID]; + /// retxBSR-Timer, default value is sf2560 + uint16_t retxBSR_Timer; + /// retxBSR_SF, number of subframe before triggering a regular BSR + uint16_t retxBSR_SF; + /// periodicBSR-Timer, default to infinity + uint16_t periodicBSR_Timer; + /// periodicBSR_SF, number of subframe before triggering a periodic BSR + uint16_t periodicBSR_SF; + /// default value is 0: not configured + uint16_t sr_ProhibitTimer; + /// sr ProhibitTime running + uint8_t sr_ProhibitTimer_Running; + /// default value to n5 + uint16_t maxHARQ_Tx; + /// default value is false + uint16_t ttiBundling; + /// default value is release + struct DRX_Config *drx_config; + /// default value is release + struct MAC_MainConfig__phr_Config *phr_config; + ///timer before triggering a periodic PHR + uint16_t periodicPHR_Timer; + ///timer before triggering a prohibit PHR + uint16_t prohibitPHR_Timer; + ///DL Pathloss change value + uint16_t PathlossChange; + ///number of subframe before triggering a periodic PHR + int16_t periodicPHR_SF; + ///number of subframe before triggering a prohibit PHR + int16_t prohibitPHR_SF; + ///DL Pathloss Change in db + uint16_t PathlossChange_db; + + /// default value is false + uint16_t extendedBSR_Sizes_r10; + /// default value is false + uint16_t extendedPHR_r10; + + //Bj bucket usage per lcid + int16_t Bj[MAX_NUM_LCID]; + // Bucket size per lcid + int16_t bucket_size[MAX_NUM_LCID]; } UE_SCHEDULING_INFO; /*!\brief Top level UE MAC structure */ typedef struct { - uint16_t Node_id; - /// RX frame counter - frame_t rxFrame; - /// RX subframe counter - sub_frame_t rxSubframe; - /// TX frame counter - frame_t txFrame; - /// TX subframe counter - sub_frame_t txSubframe; - /// C-RNTI of UE - uint16_t crnti; - /// C-RNTI of UE before HO - rnti_t crnti_before_ho; ///user id (rnti) of connected UEs - /// uplink active flag - uint8_t ul_active; - /// pointer to RRC PHY configuration - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon; - /// pointer to RACH_ConfigDedicated (NULL when not active, i.e. upon HO completion or T304 expiry) - struct RACH_ConfigDedicated *rach_ConfigDedicated; - /// pointer to RRC PHY configuration - struct PhysicalConfigDedicated *physicalConfigDedicated; + uint16_t Node_id; + /// RX frame counter + frame_t rxFrame; + /// RX subframe counter + sub_frame_t rxSubframe; + /// TX frame counter + frame_t txFrame; + /// TX subframe counter + sub_frame_t txSubframe; + /// C-RNTI of UE + uint16_t crnti; + /// C-RNTI of UE before HO + rnti_t crnti_before_ho; ///user id (rnti) of connected UEs + /// uplink active flag + uint8_t ul_active; + /// pointer to RRC PHY configuration + RadioResourceConfigCommonSIB_t *radioResourceConfigCommon; + /// pointer to RACH_ConfigDedicated (NULL when not active, i.e. upon HO completion or T304 expiry) + struct RACH_ConfigDedicated *rach_ConfigDedicated; + /// pointer to RRC PHY configuration + struct PhysicalConfigDedicated *physicalConfigDedicated; #if defined(Rel10) || defined(Rel14) /// pointer to RRC PHY configuration SCEll struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10; @@ -1360,16 +1370,6 @@ typedef struct { /// Pointers to LogicalChannelConfig indexed by LogicalChannelIdentity. Note NULL means LCHAN is inactive. LogicalChannelConfig_t *logicalChannelConfig[MAX_NUM_LCID]; - /*/// Panos: Pointer to IF_Module_UE instance of the UE - IF_Module_UE_t *if_inst_ue; - /// Panos: UE_MAC interface: Config request structure. - UE_PHY_Config_t UE_config; - /// Panos: UE_MAC interface: UL Config Request Structure - UE_MAC_ul_config_request_t UL_req_ue[MAX_NUM_CCs]; - /// Panos: UE_MAC interface: UL Transmission request structure. - UE_MAC_tx_request_t UL_TX_req[MAX_NUM_CCs];*/ - - /// Scheduling Information UE_SCHEDULING_INFO scheduling_info; /// Outgoing CCCH pdu for PHY @@ -1438,16 +1438,16 @@ typedef struct { /// number of subframe allocation pattern available for MBSFN sync area uint8_t num_sf_allocation_pattern; #if defined(Rel10) || defined(Rel14) - /// number of active MBSFN area - uint8_t num_active_mbsfn_area; - /// MBSFN Area Info - struct MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA]; - /// PMCH Config - struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN]; - /// MCCH status - uint8_t mcch_status; - /// MSI status - uint8_t msi_status;// could be an array if there are >1 MCH in one MBSFN area + /// number of active MBSFN area + uint8_t num_active_mbsfn_area; + /// MBSFN Area Info + struct MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA]; + /// PMCH Config + struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN]; + /// MCCH status + uint8_t mcch_status; + /// MSI status + uint8_t msi_status; // could be an array if there are >1 MCH in one MBSFN area #endif //#ifdef CBA /// CBA RNTI for each group @@ -1487,13 +1487,11 @@ typedef struct { eth_params_t eth_params_n; - - } UE_MAC_INST; /*! \brief ID of the neighboring cells used for HO*/ typedef struct { - uint16_t cell_ids[6]; - uint8_t n_adj_cells; + uint16_t cell_ids[6]; + uint8_t n_adj_cells; } neigh_cell_id_t; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index efb3615a8184851288c1f5596a6b5f71c475092a..1cc9bf594d744173e82379cb32b73d53eecf5a72 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -60,7 +60,7 @@ #endif #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif #define ENABLE_MAC_PAYLOAD_DEBUG @@ -68,532 +68,691 @@ extern RAN_CONTEXT_t RC; -uint16_t pdcch_order_table[6] = {31,31,511,2047,2047,8191}; +uint16_t pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; -void schedule_SRS(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) +void +schedule_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - eNB_MAC_INST *eNB = RC.mac[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; - nfapi_ul_config_request_body_t *ul_req; - int CC_id,UE_id; - COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; - SoundingRS_UL_ConfigCommon_t *soundingRS_UL_ConfigCommon; - struct SoundingRS_UL_ConfigDedicated *soundingRS_UL_ConfigDedicated; - uint8_t TSFC; - uint16_t deltaTSFC; // bitmap - uint8_t srs_SubframeConfig; - - // table for TSFC (Period) and deltaSFC (offset) - const uint16_t deltaTSFCTabType1[15][2] = { {1,1},{1,2},{2,2},{1,5},{2,5},{4,5},{8,5},{3,5},{12,5},{1,10},{2,10},{4,10},{8,10},{351,10},{383,10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD - const uint16_t deltaTSFCTabType2[14][2] = { {2,5},{6,5},{10,5},{18,5},{14,5},{22,5},{26,5},{30,5},{70,10},{74,10},{194,10},{326,10},{586,10},{210,10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD - - uint16_t srsPeriodicity,srsOffset; - - for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { - soundingRS_UL_ConfigCommon = &cc[CC_id].radioResourceConfigCommon->soundingRS_UL_ConfigCommon; - // check if SRS is enabled in this frame/subframe - if (soundingRS_UL_ConfigCommon) { - srs_SubframeConfig = soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig; - if (cc[CC_id].tdd_Config == NULL) { // FDD - deltaTSFC = deltaTSFCTabType1[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType1[srs_SubframeConfig][1]; - } - else { // TDD - deltaTSFC = deltaTSFCTabType2[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType2[srs_SubframeConfig][1]; - } - // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC - uint16_t tmp = (subframeP % TSFC); - - if((1<<tmp) & deltaTSFC) { - // This is an SRS subframe, loop over UEs - for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - if (RC.mac[module_idP]->UE_list.active[UE_id]!=TRUE) continue; - ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; - - - // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet - if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED) continue; - - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",UE_id); - - if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) { - if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { - get_srs_pos(&cc[CC_id], soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex, &srsPeriodicity, &srsOffset); - if (((10*frameP+subframeP) % srsPeriodicity) == srsOffset) { - // Prorgram SRS - ul_req->srs_present = 1; - nfapi_ul_config_request_pdu_t* ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - memset((void*)ul_config_pdu,0,sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_SRS_PDU_TYPE; - ul_config_pdu->pdu_size = 2+(uint8_t)(2+sizeof(nfapi_ul_config_srs_pdu)); - ul_config_pdu->srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG; - ul_config_pdu->srs_pdu.srs_pdu_rel8.size = (uint8_t)sizeof(nfapi_ul_config_srs_pdu); - ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; - ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; - ul_config_pdu->srs_pdu.srs_pdu_rel8.frequency_domain_position = soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; - ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;; - ul_config_pdu->srs_pdu.srs_pdu_rel8.transmission_comb = soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; - ul_config_pdu->srs_pdu.srs_pdu_rel8.i_srs = soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; - ul_config_pdu->srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift = soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; - // ul_config_pdu->srs_pdu.srs_pdu_rel10.antenna_port = ;// - // ul_config_pdu->srs_pdu.srs_pdu_rel13.number_of_combs = ;// - RC.mac[module_idP]->UL_req[CC_id].sfn_sf = (frameP<<4)+subframeP; - RC.mac[module_idP]->UL_req[CC_id].header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req->number_of_pdus++; - } // if (((10*frameP+subframeP) % srsPeriodicity) == srsOffset) - } // if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) - } // if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) - } // for (UE_id ... - } // if((1<<tmp) & deltaTSFC) - - }// SRS config - } + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; + nfapi_ul_config_request_body_t *ul_req; + int CC_id, UE_id; + COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; + SoundingRS_UL_ConfigCommon_t *soundingRS_UL_ConfigCommon; + struct SoundingRS_UL_ConfigDedicated *soundingRS_UL_ConfigDedicated; + uint8_t TSFC; + uint16_t deltaTSFC; // bitmap + uint8_t srs_SubframeConfig; + + // table for TSFC (Period) and deltaSFC (offset) + const uint16_t deltaTSFCTabType1[15][2] = { {1, 1}, {1, 2}, {2, 2}, {1, 5}, {2, 5}, {4, 5}, {8, 5}, {3, 5}, {12, 5}, {1, 10}, {2, 10}, {4, 10}, {8, 10}, {351, 10}, {383, 10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD + const uint16_t deltaTSFCTabType2[14][2] = { {2, 5}, {6, 5}, {10, 5}, {18, 5}, {14, 5}, {22, 5}, {26, 5}, {30, 5}, {70, 10}, {74, 10}, {194, 10}, {326, 10}, {586, 10}, {210, 10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD + + uint16_t srsPeriodicity, srsOffset; + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + soundingRS_UL_ConfigCommon = &cc[CC_id].radioResourceConfigCommon->soundingRS_UL_ConfigCommon; + // check if SRS is enabled in this frame/subframe + if (soundingRS_UL_ConfigCommon) { + srs_SubframeConfig =soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig; + if (cc[CC_id].tdd_Config == NULL) { // FDD + deltaTSFC = deltaTSFCTabType1[srs_SubframeConfig][0]; + TSFC = deltaTSFCTabType1[srs_SubframeConfig][1]; + } else { // TDD + deltaTSFC = deltaTSFCTabType2[srs_SubframeConfig][0]; + TSFC = deltaTSFCTabType2[srs_SubframeConfig][1]; + } + // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC + uint16_t tmp = (subframeP % TSFC); + if ((1 << tmp) & deltaTSFC) { + // This is an SRS subframe, loop over UEs + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE) continue; + ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; + + // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet + if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; + + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL,"physicalConfigDedicated is null for UE %d\n",UE_id); + + if ((soundingRS_UL_ConfigDedicated =UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!= NULL) { + if (soundingRS_UL_ConfigDedicated->present ==SoundingRS_UL_ConfigDedicated_PR_setup) { + get_srs_pos(&cc[CC_id],soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex,&srsPeriodicity, &srsOffset); + if (((10 * frameP +subframeP) % srsPeriodicity) ==srsOffset) { + // Program SRS + ul_req->srs_present = 1; + nfapi_ul_config_request_pdu_t* ul_config_pdu =&ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; + memset((void *) ul_config_pdu, 0,sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type =NFAPI_UL_CONFIG_SRS_PDU_TYPE; + ul_config_pdu->pdu_size =2 + (uint8_t) (2 +sizeof(nfapi_ul_config_srs_pdu)); + ul_config_pdu->srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG; + ul_config_pdu->srs_pdu.srs_pdu_rel8.size =(uint8_t)sizeof(nfapi_ul_config_srs_pdu); + ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; + ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_bandwidth =soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; + ul_config_pdu->srs_pdu.srs_pdu_rel8.frequency_domain_position=soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; + ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth =soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;; + ul_config_pdu->srs_pdu.srs_pdu_rel8.transmission_comb =soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; + ul_config_pdu->srs_pdu.srs_pdu_rel8.i_srs = soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; + ul_config_pdu->srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift=soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift; + // ul_config_pdu->srs_pdu.srs_pdu_rel10.antenna_port = ;// + // ul_config_pdu->srs_pdu.srs_pdu_rel13.number_of_combs = ;// + RC.mac[module_idP]->UL_req[CC_id].sfn_sf =(frameP << 4) + subframeP; + RC.mac[module_idP]->UL_req[CC_id].header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req->number_of_pdus++; + } // if (((10*frameP+subframeP) % srsPeriodicity) == srsOffset) + } // if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) + } // if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) + } // for (UE_id ... + } // if((1<<tmp) & deltaTSFC) + } // SRS config + } } -void schedule_CSI(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) +void +schedule_CSI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - eNB_MAC_INST *eNB = RC.mac[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; - COMMON_channels_t *cc; - nfapi_ul_config_request_body_t *ul_req; - int CC_id,UE_id; - struct CQI_ReportPeriodic *cqi_ReportPeriodic; - uint16_t Npd,N_OFFSET_CQI; - int H; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - cc = &eNB->common_channels[CC_id]; - for (UE_id=0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) continue; - - ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; - - // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet - if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED) continue; - - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",UE_id); - - if (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig) { - if ((cqi_ReportPeriodic = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic)!=NULL && - (cqi_ReportPeriodic->present!=CQI_ReportPeriodic_PR_release)) { - //Rel8 Periodic CQI/PMI/RI reporting - - get_csi_params(cc,cqi_ReportPeriodic,&Npd,&N_OFFSET_CQI,&H); - - if ((((frameP*10)+subframeP)%Npd) == N_OFFSET_CQI) { // CQI opportunity - UE_list->UE_sched_ctrl[UE_id].feedback_cnt[CC_id]=(((frameP*10)+subframeP)/Npd)%H; - // Program CQI - nfapi_ul_config_request_pdu_t* ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - memset((void*)ul_config_pdu,0,sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; - ul_config_pdu->pdu_size = 2+(uint8_t)(2+sizeof(nfapi_ul_config_uci_cqi_pdu)); - ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; - ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.pucch_index = cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.dl_cqi_pmi_size = get_rel8_dl_cqi_pmi_size(&UE_list->UE_sched_ctrl[UE_id], - CC_id, - cc, - get_tmode(module_idP,CC_id,UE_id), - cqi_ReportPeriodic); - ul_req->number_of_pdus++; - ul_req->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; + COMMON_channels_t *cc; + nfapi_ul_config_request_body_t *ul_req; + int CC_id, UE_id; + struct CQI_ReportPeriodic *cqi_ReportPeriodic; + uint16_t Npd, N_OFFSET_CQI; + int H; + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + + cc = &eNB->common_channels[CC_id]; + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) + continue; + + ul_req = + &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; + + // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet + if (mac_eNB_get_rrc_status + (module_idP, UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) + continue; + + AssertFatal(UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated + != NULL, + "physicalConfigDedicated is null for UE %d\n", + UE_id); + + if (UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated-> + cqi_ReportConfig) { + if ((cqi_ReportPeriodic = + UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated-> + cqi_ReportConfig->cqi_ReportPeriodic) != NULL + && (cqi_ReportPeriodic->present != + CQI_ReportPeriodic_PR_release)) { + //Rel8 Periodic CQI/PMI/RI reporting + + get_csi_params(cc, cqi_ReportPeriodic, &Npd, + &N_OFFSET_CQI, &H); + + if ((((frameP * 10) + subframeP) % Npd) == N_OFFSET_CQI) { // CQI opportunity + UE_list->UE_sched_ctrl[UE_id].feedback_cnt[CC_id] = + (((frameP * 10) + subframeP) / Npd) % H; + // Program CQI + nfapi_ul_config_request_pdu_t *ul_config_pdu = + &ul_req->ul_config_pdu_list[ul_req-> + number_of_pdus]; + memset((void *) ul_config_pdu, 0, + sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; + ul_config_pdu->pdu_size = + 2 + (uint8_t) (2 + + sizeof + (nfapi_ul_config_uci_cqi_pdu)); + ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_config_pdu->uci_cqi_pdu. + ue_information.ue_information_rel8.rnti = + UE_list->UE_template[CC_id][UE_id].rnti; + ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG; + ul_config_pdu->uci_cqi_pdu. + cqi_information.cqi_information_rel8. + pucch_index = + cqi_ReportPeriodic->choice. + setup.cqi_PUCCH_ResourceIndex; + ul_config_pdu->uci_cqi_pdu. + cqi_information.cqi_information_rel8. + dl_cqi_pmi_size = + get_rel8_dl_cqi_pmi_size + (&UE_list->UE_sched_ctrl[UE_id], CC_id, cc, + get_tmode(module_idP, CC_id, UE_id), + cqi_ReportPeriodic); + ul_req->number_of_pdus++; + ul_req->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; #if defined(Rel10) || defined(Rel14) - // PUT rel10-13 UCI options here + // PUT rel10-13 UCI options here #endif - } - else if ((cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) && - ((((frameP*10)+subframeP)%((H*Npd)<<(*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex/161)))== - N_OFFSET_CQI + (*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex%161))) { // RI opportunity - // Program RI - nfapi_ul_config_request_pdu_t* ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - memset((void*)ul_config_pdu,0,sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; - ul_config_pdu->pdu_size = 2+(uint8_t)(2+sizeof(nfapi_ul_config_uci_cqi_pdu)); - ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; - ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.pucch_index = cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.dl_cqi_pmi_size = (cc->p_eNB==2)?1:2; - RC.mac[module_idP]->UL_req[CC_id].sfn_sf = (frameP<<4)+subframeP; - ul_req->number_of_pdus++; - ul_req->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - } - - } // if ((cqi_ReportPeriodic = cqi_ReportConfig->cqi_ReportPeriodic)!=NULL) { - } // if (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig) - } // for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - } // for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + + } else + if ((cqi_ReportPeriodic->choice.setup. + ri_ConfigIndex) + && ((((frameP * 10) + subframeP) % ((H * Npd) << (*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex / 161))) == N_OFFSET_CQI + (*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex % 161))) { // RI opportunity + // Program RI + nfapi_ul_config_request_pdu_t *ul_config_pdu = + &ul_req->ul_config_pdu_list[ul_req-> + number_of_pdus]; + memset((void *) ul_config_pdu, 0, + sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; + ul_config_pdu->pdu_size = + 2 + (uint8_t) (2 + + sizeof + (nfapi_ul_config_uci_cqi_pdu)); + ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_config_pdu->uci_cqi_pdu. + ue_information.ue_information_rel8.rnti = + UE_list->UE_template[CC_id][UE_id].rnti; + ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG; + ul_config_pdu->uci_cqi_pdu. + cqi_information.cqi_information_rel8. + pucch_index = + cqi_ReportPeriodic->choice. + setup.cqi_PUCCH_ResourceIndex; + ul_config_pdu->uci_cqi_pdu. + cqi_information.cqi_information_rel8. + dl_cqi_pmi_size = (cc->p_eNB == 2) ? 1 : 2; + RC.mac[module_idP]->UL_req[CC_id].sfn_sf = + (frameP << 4) + subframeP; + ul_req->number_of_pdus++; + ul_req->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + } + } // if ((cqi_ReportPeriodic = cqi_ReportConfig->cqi_ReportPeriodic)!=NULL) { + } // if (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig) + } // for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + } // for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { } -void schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) +void +schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - eNB_MAC_INST *eNB = RC.mac[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; - nfapi_ul_config_request_t *ul_req; - nfapi_ul_config_request_body_t *ul_req_body; - int CC_id; - int UE_id; - SchedulingRequestConfig_t *SRconfig; - int skip_ue; - int is_harq; - nfapi_ul_config_sr_information sr; - int i; - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - RC.mac[module_idP]->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP; - - for (UE_id = 0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - if (RC.mac[module_idP]->UE_list.active[UE_id]!=TRUE) continue; - - ul_req = &RC.mac[module_idP]->UL_req[CC_id]; - ul_req_body = &ul_req->ul_config_request_body; - - //LOG_D(MAC, "UE active UE_id:%d ul_req_body->number_of_pdus:%d\n", UE_id, ul_req_body->number_of_pdus); - - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",UE_id); - - // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet - if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED) continue; - - if ((SRconfig = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig)!=NULL) { - if (SRconfig->present == SchedulingRequestConfig_PR_setup) { - if (SRconfig->choice.setup.sr_ConfigIndex <= 4) { // 5 ms SR period - if ((subframeP%5) != SRconfig->choice.setup.sr_ConfigIndex) - continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 14) { // 10 ms SR period - if (subframeP!=(SRconfig->choice.setup.sr_ConfigIndex-5)) - continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 34) { // 20 ms SR period - if ((10*(frameP&1)+subframeP) != (SRconfig->choice.setup.sr_ConfigIndex-15)) - continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 74) { // 40 ms SR period - if ((10*(frameP&3)+subframeP) != (SRconfig->choice.setup.sr_ConfigIndex-35)) - continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 154) { // 80 ms SR period - if ((10*(frameP&7)+subframeP) != (SRconfig->choice.setup.sr_ConfigIndex-75)) - continue; - } - } // SRconfig->present == SchedulingRequestConfig_PR_setup) - } // SRconfig = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig)!=NULL) - - // if we get here there is some PUCCH1 reception to schedule for SR - - skip_ue=0; - is_harq = 0; - // check that there is no existing UL grant for ULSCH which overrides the SR - for (i = 0; i < ul_req_body->number_of_pdus; i++) { - if (((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE)|| - (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE)|| - (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE)|| - (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE))&& - (ul_req_body->ul_config_pdu_list[i].ulsch_pdu.ulsch_pdu_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { - skip_ue=1; - break; - } - /* if there is already an HARQ pdu, convert to SR_HARQ */ - else if ((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE)&& - (ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.ue_information.ue_information_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { - is_harq = 1; - break; - } - } - - // drop the allocation because ULSCH with handle it with BSR - if (skip_ue==1) continue; - - LOG_D(MAC,"Frame %d, Subframe %d : Scheduling SR for UE %d/%x is_harq:%d\n",frameP,subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].rnti, is_harq); - - // check Rel10 or Rel8 SR + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; + nfapi_ul_config_request_t *ul_req; + nfapi_ul_config_request_body_t *ul_req_body; + int CC_id; + int UE_id; + SchedulingRequestConfig_t *SRconfig; + int skip_ue; + int is_harq; + nfapi_ul_config_sr_information sr; + int i; + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + RC.mac[module_idP]->UL_req[CC_id].sfn_sf = + (frameP << 4) + subframeP; + + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE) + continue; + + ul_req = &RC.mac[module_idP]->UL_req[CC_id]; + ul_req_body = &ul_req->ul_config_request_body; + + // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet + if (mac_eNB_get_rrc_status + (module_idP, UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) + continue; + + AssertFatal(UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated + != NULL, + "physicalConfigDedicated is null for UE %d\n", + UE_id); + + if ((SRconfig = + UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated-> + schedulingRequestConfig) != NULL) { + if (SRconfig->present == SchedulingRequestConfig_PR_setup) { + if (SRconfig->choice.setup.sr_ConfigIndex <= 4) { // 5 ms SR period + if ((subframeP % 5) != + SRconfig->choice.setup.sr_ConfigIndex) + continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 14) { // 10 ms SR period + if (subframeP != + (SRconfig->choice.setup.sr_ConfigIndex - 5)) + continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 34) { // 20 ms SR period + if ((10 * (frameP & 1) + subframeP) != + (SRconfig->choice.setup.sr_ConfigIndex - 15)) + continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 74) { // 40 ms SR period + if ((10 * (frameP & 3) + subframeP) != + (SRconfig->choice.setup.sr_ConfigIndex - 35)) + continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 154) { // 80 ms SR period + if ((10 * (frameP & 7) + subframeP) != + (SRconfig->choice.setup.sr_ConfigIndex - 75)) + continue; + } + } // SRconfig->present == SchedulingRequestConfig_PR_setup) + } // SRconfig = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig)!=NULL) + + // if we get here there is some PUCCH1 reception to schedule for SR + + skip_ue = 0; + is_harq = 0; + // check that there is no existing UL grant for ULSCH which overrides the SR + for (i = 0; i < ul_req_body->number_of_pdus; i++) { + if (((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) || + (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) || + (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) || + (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE)) && + (ul_req_body->ul_config_pdu_list[i].ulsch_pdu.ulsch_pdu_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { + skip_ue = 1; + break; + } + /* if there is already an HARQ pdu, convert to SR_HARQ */ + else if ((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.ue_information.ue_information_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { + is_harq = 1; + break; + } + } + + // drop the allocation because ULSCH with handle it with BSR + if (skip_ue == 1) + continue; + + LOG_D(MAC,"Frame %d, Subframe %d : Scheduling SR for UE %d/%x is_harq:%d\n",frameP,subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].rnti, is_harq); + + // check Rel10 or Rel8 SR #if defined(Rel10) || defined(Rel14) - if ((UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2) && - (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020)) { - sr.sr_information_rel8.tl.tag = 0; - sr.sr_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG; - sr.sr_information_rel10.number_of_pucch_resources = 1; - sr.sr_information_rel10.pucch_index_p1 = *UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020->sr_PUCCH_ResourceIndexP1_r10; - - LOG_D(MAC,"REL10 PUCCH INDEX P1:%d\n", sr.sr_information_rel10.pucch_index_p1); - } else + if ((UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated->ext2) + && (UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated-> + ext2->schedulingRequestConfig_v1020) + && (UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated-> + ext2->schedulingRequestConfig_v1020)) { + sr.sr_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG; + sr.sr_information_rel10.number_of_pucch_resources = 1; + sr.sr_information_rel10.pucch_index_p1 = + *UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated-> + ext2-> + schedulingRequestConfig_v1020->sr_PUCCH_ResourceIndexP1_r10; + LOG_D(MAC,"REL10 PUCCH INDEX P1:%d\n", sr.sr_information_rel10.pucch_index_p1); + } else #endif - { - sr.sr_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG; - sr.sr_information_rel8.pucch_index = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex; - sr.sr_information_rel10.tl.tag = 0; + { + sr.sr_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG; + sr.sr_information_rel8.pucch_index = + UE_list-> + UE_template[CC_id][UE_id].physicalConfigDedicated-> + schedulingRequestConfig->choice.setup. + sr_PUCCH_ResourceIndex; + LOG_D(MAC,"REL8 PUCCH INDEX:%d\n", sr.sr_information_rel8.pucch_index); + } + + /* if there is already an HARQ pdu, convert to SR_HARQ */ + if (is_harq) { + nfapi_ul_config_harq_information h = ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.harq_information; + ul_req_body->ul_config_pdu_list[i].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; + ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.sr_information = sr; + ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.harq_information = h; + } else { + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel11.tl.tag = 0; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel13.tl.tag = 0; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.sr_information = sr; + ul_req_body->number_of_pdus++; + } /* if (is_harq) */ + ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + } // for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) + } // for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) +} - LOG_D(MAC,"REL8 PUCCH INDEX:%d\n", sr.sr_information_rel8.pucch_index); - } +extern uint8_t nfapi_mode; - /* if there is already an HARQ pdu, convert to SR_HARQ */ - if (is_harq) { - nfapi_ul_config_harq_information h = ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.harq_information; - ul_req_body->ul_config_pdu_list[i].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; - ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.sr_information = sr; - ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.harq_information = h; - } else { - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel11.tl.tag = 0; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel13.tl.tag = 0; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.sr_information = sr; - ul_req_body->number_of_pdus++; - } /* if (is_harq) */ - ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - - } // for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) - } // for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) +void +check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, + frame_t frameP, sub_frame_t subframeP) +{ + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; + nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; + uint16_t rnti = UE_RNTI(module_idP, UE_id); + COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; + + // check uplink failure + if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 0) && + (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0)) { + LOG_I(MAC, "UE %d rnti %x: UL Failure timer %d \n", UE_id, rnti, + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); + if (UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) { + UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1; + + // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe) + nfapi_dl_config_request_pdu_t *dl_config_pdu = + &DL_req[CC_id]. + dl_config_request_body.dl_config_pdu_list[DL_req[CC_id]. + dl_config_request_body.number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = + NFAPI_DL_DCI_FORMAT_1A; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = + get_aggregation(get_bw_index(module_idP, CC_id), + UE_list->UE_sched_ctrl[UE_id]. + dl_cqi[CC_id], format1A); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + AssertFatal((cc[CC_id].mib->message.dl_Bandwidth >= 0) + && (cc[CC_id].mib->message.dl_Bandwidth < 6), + "illegal dl_Bandwidth %d\n", + (int) cc[CC_id].mib->message.dl_Bandwidth); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + resource_block_coding = + pdcch_order_table[cc[CC_id].mib->message.dl_Bandwidth]; + DL_req[CC_id].dl_config_request_body.number_dci++; + DL_req[CC_id].dl_config_request_body.number_pdu++; + DL_req[CC_id].dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + LOG_I(MAC, + "UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n", + UE_id, rnti, + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding); + } else { // ra_pdcch_sent==1 + LOG_I(MAC, + "UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n", + UE_id, rnti, + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); + if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) + UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames + } + + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer++; + // check threshold + if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) { + // inform RRC of failure and clear timer + LOG_I(MAC, + "UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n", + UE_id, rnti); + mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, subframeP, + rnti); + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; + } + } // ul_failure_timer>0 + + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer++; + if(UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer > (U_PLANE_INACTIVITY_VALUE*subframe_num(&RC.eNB[module_idP][CC_id]->frame_parms))){ + LOG_D(MAC,"UE %d rnti %x: U-Plane Failure after repeated PDCCH orders: Triggering RRC \n",UE_id,rnti); + mac_eNB_rrc_uplane_failure(module_idP,CC_id,frameP,subframeP,rnti); + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + }// time > 60s } -void check_ul_failure(module_id_t module_idP,int CC_id,int UE_id, - frame_t frameP, sub_frame_t subframeP) +void +clear_nfapi_information(eNB_MAC_INST * eNB, int CC_idP, + frame_t frameP, sub_frame_t subframeP) { - UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; - uint16_t rnti = UE_RNTI(module_idP,UE_id); - COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; - - // check uplink failure - if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer>0)&& - (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync==0)) { - LOG_I(MAC,"UE %d rnti %x: UL Failure timer %d \n",UE_id,rnti,UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - if (UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent==0) { - UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent=1; - - // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe) - nfapi_dl_config_request_pdu_t* dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[DL_req[CC_id].dl_config_request_body.number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id],format1A); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - AssertFatal((cc[CC_id].mib->message.dl_Bandwidth >=0) && (cc[CC_id].mib->message.dl_Bandwidth<6), - "illegal dl_Bandwidth %d\n",(int)cc[CC_id].mib->message.dl_Bandwidth); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = pdcch_order_table[cc[CC_id].mib->message.dl_Bandwidth]; - DL_req[CC_id].dl_config_request_body.number_dci++; - LOG_E(MAC, "%s() number_dci:%u\n", __FUNCTION__, DL_req[CC_id].dl_config_request_body.number_dci); - - DL_req[CC_id].dl_config_request_body.number_pdu++; - DL_req[CC_id].dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - LOG_I(MAC,"UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n",UE_id,rnti,UE_list->UE_sched_ctrl[UE_id].ul_failure_timer,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding); - } - else { // ra_pdcch_sent==1 - LOG_I(MAC,"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",UE_id,rnti,UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) - UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent=0; // resend every 4 frames - } + nfapi_dl_config_request_t *DL_req = &eNB->DL_req[0]; + nfapi_ul_config_request_t *UL_req = &eNB->UL_req[0]; + nfapi_hi_dci0_request_t *HI_DCI0_req = &eNB->HI_DCI0_req[0]; + nfapi_tx_request_t *TX_req = &eNB->TX_req[0]; - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer++; - // check threshold - if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 200) { - // inform RRC of failure and clear timer - LOG_I(MAC,"UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n",UE_id,rnti); - mac_eNB_rrc_ul_failure(module_idP,CC_id,frameP,subframeP,rnti); - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0; - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=1; - } - } // ul_failure_timer>0 + eNB->pdu_index[CC_idP] = 0; -} + if (nfapi_mode==0 || nfapi_mode == 1) { // monolithic or PNF -extern uint8_t nfapi_mode; + DL_req[CC_idP].dl_config_request_body.number_pdcch_ofdm_symbols = 1; + DL_req[CC_idP].dl_config_request_body.number_dci = 0; + DL_req[CC_idP].dl_config_request_body.number_pdu = 0; + DL_req[CC_idP].dl_config_request_body.number_pdsch_rnti = 0; + DL_req[CC_idP].dl_config_request_body.transmission_power_pcfich = 6000; -void clear_nfapi_information(eNB_MAC_INST *eNB,int CC_idP,frame_t frameP,sub_frame_t subframeP) -{ - nfapi_dl_config_request_t *DL_req = &eNB->DL_req[0]; - nfapi_ul_config_request_t *UL_req = &eNB->UL_req[0]; - nfapi_hi_dci0_request_t *HI_DCI0_req = &eNB->HI_DCI0_req[0]; - nfapi_tx_request_t *TX_req = &eNB->TX_req[0]; - - eNB->pdu_index[CC_idP] = 0; - - if (nfapi_mode==0 || nfapi_mode == 1) // monolithic or PNF - { - DL_req[CC_idP].dl_config_request_body.number_pdcch_ofdm_symbols = 1; - DL_req[CC_idP].dl_config_request_body.number_dci = 0; - DL_req[CC_idP].dl_config_request_body.number_pdu = 0; - DL_req[CC_idP].dl_config_request_body.number_pdsch_rnti = 0; - DL_req[CC_idP].dl_config_request_body.transmission_power_pcfich = 6000; - - HI_DCI0_req[CC_idP].hi_dci0_request_body.sfnsf = subframeP + (frameP<<4); - HI_DCI0_req[CC_idP].hi_dci0_request_body.number_of_dci = 0; - - - UL_req[CC_idP].ul_config_request_body.number_of_pdus = 0; - UL_req[CC_idP].ul_config_request_body.rach_prach_frequency_resources = 0; // ignored, handled by PHY for now - UL_req[CC_idP].ul_config_request_body.srs_present = 0; // ignored, handled by PHY for now - - - TX_req[CC_idP].tx_request_body.number_of_pdus = 0; - - if (0) LOG_D(MAC,"%s() SFN_SF:%d%d ZERO PDUs of TX_req:(SFN_SF:%d):%d UL_req:(SFN_SF:%d):%d HI_DCI0_req:(SFN_SF:%d):dci:%d hi:%d DL:(SFN_SF:%d):dci:%d DL:pdu:%d\n", - __FUNCTION__, - frameP, subframeP, - NFAPI_SFNSF2DEC(TX_req[CC_idP].sfn_sf), - TX_req[CC_idP].tx_request_body.number_of_pdus, - NFAPI_SFNSF2DEC(UL_req[CC_idP].sfn_sf), - UL_req[CC_idP].ul_config_request_body.number_of_pdus, - NFAPI_SFNSF2DEC(HI_DCI0_req[CC_idP].sfn_sf), - HI_DCI0_req[CC_idP].hi_dci0_request_body.number_of_dci, - HI_DCI0_req[CC_idP].hi_dci0_request_body.number_of_hi, - NFAPI_SFNSF2DEC(DL_req[CC_idP].sfn_sf), - DL_req[CC_idP].dl_config_request_body.number_dci, - DL_req[CC_idP].dl_config_request_body.number_pdu); - } + HI_DCI0_req[CC_idP].hi_dci0_request_body.sfnsf = subframeP + (frameP<<4); + HI_DCI0_req[CC_idP].hi_dci0_request_body.number_of_dci = 0; + + + UL_req[CC_idP].ul_config_request_body.number_of_pdus = 0; + UL_req[CC_idP].ul_config_request_body.rach_prach_frequency_resources = 0; // ignored, handled by PHY for now + UL_req[CC_idP].ul_config_request_body.srs_present = 0; // ignored, handled by PHY for now + + TX_req[CC_idP].tx_request_body.number_of_pdus = 0; + + } } -void copy_ulreq(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP) +void +copy_ulreq(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - int CC_id; - eNB_MAC_INST *eNB = RC.mac[module_idP]; + int CC_id; + eNB_MAC_INST *mac = RC.mac[module_idP]; - for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - nfapi_ul_config_request_t *ul_req_tmp = &eNB->UL_req_tmp[CC_id][subframeP]; - nfapi_ul_config_request_t *ul_req = &eNB->UL_req[CC_id]; - nfapi_ul_config_request_pdu_t *ul_req_pdu = ul_req->ul_config_request_body.ul_config_pdu_list; + nfapi_ul_config_request_t *ul_req_tmp = &mac->UL_req_tmp[CC_id][subframeP]; + nfapi_ul_config_request_t *ul_req = &mac->UL_req[CC_id]; + nfapi_ul_config_request_pdu_t *ul_req_pdu = ul_req->ul_config_request_body.ul_config_pdu_list; - *ul_req = *ul_req_tmp; + *ul_req = *ul_req_tmp; - // Restore the pointer - ul_req->ul_config_request_body.ul_config_pdu_list = ul_req_pdu; + // Restore the pointer + ul_req->ul_config_request_body.ul_config_pdu_list = ul_req_pdu; - ul_req->sfn_sf = (frameP<<4) + subframeP; + ul_req->sfn_sf = (frameP<<4) + subframeP; - ul_req_tmp->ul_config_request_body.number_of_pdus = 0; + ul_req_tmp->ul_config_request_body.number_of_pdus = 0; - if (ul_req->ul_config_request_body.number_of_pdus>0) - { - LOG_D(PHY, "%s() active NOW (frameP:%d subframeP:%d) pdus:%d\n", __FUNCTION__, frameP, subframeP, ul_req->ul_config_request_body.number_of_pdus); - } + if (ul_req->ul_config_request_body.number_of_pdus>0) + { + LOG_D(PHY, "%s() active NOW (frameP:%d subframeP:%d) pdus:%d\n", __FUNCTION__, frameP, subframeP, ul_req->ul_config_request_body.number_of_pdus); + } - memcpy((void*)ul_req->ul_config_request_body.ul_config_pdu_list, - (void*)ul_req_tmp->ul_config_request_body.ul_config_pdu_list, - ul_req->ul_config_request_body.number_of_pdus*sizeof(nfapi_ul_config_request_pdu_t)); + memcpy((void*)ul_req->ul_config_request_body.ul_config_pdu_list, + (void*)ul_req_tmp->ul_config_request_body.ul_config_pdu_list, + ul_req->ul_config_request_body.number_of_pdus*sizeof(nfapi_ul_config_request_pdu_t)); } } -void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) +void +eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP) { - int mbsfn_status[MAX_NUM_CCs]; - protocol_ctxt_t ctxt; + int mbsfn_status[MAX_NUM_CCs]; + protocol_ctxt_t ctxt; - int CC_id,i; //,next_i; - UE_list_t *UE_list=&RC.mac[module_idP]->UE_list; - rnti_t rnti; + int CC_id, i; //,next_i; + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; + rnti_t rnti; - COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; + COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; #if defined(FLEXRAN_AGENT_SB_IF) - Protocol__FlexranMessage *msg; + Protocol__FlexranMessage *msg; #endif - start_meas(&RC.mac[module_idP]->eNB_scheduler); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); + start_meas(&RC.mac[module_idP]->eNB_scheduler); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, + VCD_FUNCTION_IN); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - mbsfn_status[CC_id]=0; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + mbsfn_status[CC_id] = 0; - // clear vrb_maps - memset(cc[CC_id].vrb_map,0,100); - memset(cc[CC_id].vrb_map_UL,0,100); + // clear vrb_maps + memset(cc[CC_id].vrb_map, 0, 100); + memset(cc[CC_id].vrb_map_UL, 0, 100); #if defined(Rel10) || defined(Rel14) - cc[CC_id].mcch_active =0; + cc[CC_id].mcch_active = 0; #endif - RC.mac[module_idP]->frame = frameP; - RC.mac[module_idP]->subframe = subframeP; - } - // refresh UE list based on UEs dropped by PHY in previous subframe - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) continue; + RC.mac[module_idP]->frame = frameP; + RC.mac[module_idP]->subframe = subframeP; - rnti = UE_RNTI(module_idP, i); - CC_id = UE_PCCID(module_idP, i); - - if ((frameP==0)&&(subframeP==0)) { - LOG_I(MAC,"UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", rnti, - UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync", - UE_list->UE_template[CC_id][i].phr_info, - UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], - (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id]-128)/2, - (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id]-128)/2); + clear_nfapi_information(RC.mac[module_idP], CC_id, frameP, + subframeP); } - RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63; - if (i==UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]); - // increment this, it is cleared when we receive an sdu - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; - - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++; - LOG_D(MAC,"UE %d/%x : ul_inactivity %d, cqi_req %d\n",i,rnti, - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer, - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer); - check_ul_failure(module_idP,CC_id,i,frameP,subframeP); + // refresh UE list based on UEs dropped by PHY in previous subframe + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; + + rnti = UE_RNTI(module_idP, i); + CC_id = UE_PCCID(module_idP, i); + + if ((frameP == 0) && (subframeP == 0)) { + LOG_I(MAC, + "UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", + rnti, + UE_list->UE_sched_ctrl[i].ul_out_of_sync == + 0 ? "in synch" : "out of sync", + UE_list->UE_template[CC_id][i].phr_info, + UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], + (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2, + (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2); + } + + RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) + + subframeP] = -63; + if (i == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME + (VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, + RC.eNB[module_idP][CC_id]-> + pusch_stats_bsr[i][(frameP * 10) + subframeP]); + // increment this, it is cleared when we receive an sdu + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; + + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++; + LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", i, rnti, + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i]. + ul_inactivity_timer, + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer); + check_ul_failure(module_idP, CC_id, i, frameP, subframeP); + + if (RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer > 0) { + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer++; + if(RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer >= + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres) { + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer = 0; + for (int ue_id_l = 0; ue_id_l < NUMBER_OF_UE_MAX; ue_id_l++) { + if (reestablish_rnti_map[ue_id_l][0] == rnti) { + // clear currentC-RNTI from map + reestablish_rnti_map[ue_id_l][0] = 0; + reestablish_rnti_map[ue_id_l][1] = 0; + break; + } + } + for (int ii=0; ii<NUMBER_OF_UE_MAX; ii++) { + LTE_eNB_ULSCH_t *ulsch = RC.eNB[module_idP][CC_id]->ulsch[ii]; + if((ulsch != NULL) && (ulsch->rnti == rnti)){ + LOG_I(MAC, "clean_eNb_ulsch UE %x \n", rnti); + clean_eNb_ulsch(ulsch); + } + } + for (int ii=0; ii<NUMBER_OF_UE_MAX; ii++) { + LTE_eNB_DLSCH_t *dlsch = RC.eNB[module_idP][CC_id]->dlsch[ii][0]; + if((dlsch != NULL) && (dlsch->rnti == rnti)){ + LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); + clean_eNb_dlsch(dlsch); + } + } + + for(int j = 0; j < 10; j++){ + nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body; + if(ul_req_tmp){ + int pdu_number = ul_req_tmp->number_of_pdus; + for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ + if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ + LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); + if(pdu_index < pdu_number -1){ + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + } + ul_req_tmp->number_of_pdus--; + } + } + } + } + rrc_mac_remove_ue(module_idP,rnti); + } + } - } + } - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, subframeP,module_idP); - pdcp_run(&ctxt); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, + NOT_A_RNTI, frameP, subframeP, + module_idP); + pdcp_run(&ctxt); - rrc_rx_tx(&ctxt, - 0, // eNB index, unused in eNB - CC_id); + rrc_rx_tx(&ctxt, CC_id); #if defined(Rel10) || defined(Rel14) - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - if (cc[CC_id].MBMS_flag >0) { - start_meas(&RC.mac[module_idP]->schedule_mch); - mbsfn_status[CC_id] = schedule_MBMS(module_idP,CC_id,frameP,subframeP); - stop_meas(&RC.mac[module_idP]->schedule_mch); + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + if (cc[CC_id].MBMS_flag > 0) { + start_meas(&RC.mac[module_idP]->schedule_mch); + mbsfn_status[CC_id] = + schedule_MBMS(module_idP, CC_id, frameP, subframeP); + stop_meas(&RC.mac[module_idP]->schedule_mch); + } } - } #endif - // This schedules MIB - //if ((subframeP==0) && (frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); - if (subframeP==0) schedule_mib(module_idP,frameP,subframeP); - // This schedules SI for legacy LTE and eMTC starting in subframeP - schedule_SI(module_idP,frameP,subframeP); - // This schedules Random-Access for legacy LTE and eMTC starting in subframeP - schedule_RA(module_idP,frameP,subframeP); - // copy previously scheduled UL resources (ULSCH + HARQ) - copy_ulreq(module_idP,frameP,subframeP); - // This schedules SRS in subframeP - schedule_SRS(module_idP,frameP,subframeP); - // This schedules ULSCH in subframeP (dci0) - schedule_ulsch(module_idP,frameP,subframeP); - // This schedules UCI_SR in subframeP - //schedule_SR(module_idP,frameP,subframeP); - // This schedules UCI_CSI in subframeP - schedule_CSI(module_idP, frameP, subframeP); - - // This schedules DLSCH in subframeP - schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); - - // Allocate CCEs for good after scheduling is done - - for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) allocate_CCEs(module_idP,CC_id,subframeP,0); - - - stop_meas(&RC.mac[module_idP]->eNB_scheduler); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT); + // This schedules MIB + if ((subframeP == 0) && (frameP & 3) == 0) + schedule_mib(module_idP, frameP, subframeP); + // This schedules SI for legacy LTE and eMTC starting in subframeP + schedule_SI(module_idP, frameP, subframeP); + // This schedules Paging in subframeP + schedule_PCH(module_idP,frameP,subframeP); + // This schedules Random-Access for legacy LTE and eMTC starting in subframeP + schedule_RA(module_idP, frameP, subframeP); + // copy previously scheduled UL resources (ULSCH + HARQ) + copy_ulreq(module_idP, frameP, subframeP); + // This schedules SRS in subframeP + schedule_SRS(module_idP, frameP, subframeP); + // This schedules ULSCH in subframeP (dci0) + schedule_ulsch(module_idP, frameP, subframeP); + // This schedules UCI_SR in subframeP + schedule_SR(module_idP, frameP, subframeP); + // This schedules UCI_CSI in subframeP + schedule_CSI(module_idP, frameP, subframeP); + + // This schedules DLSCH in subframeP + schedule_ue_spec(module_idP, frameP, subframeP, mbsfn_status); + + // Allocate CCEs for good after scheduling is done + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) + allocate_CCEs(module_idP, CC_id, subframeP, 0); + + + stop_meas(&RC.mac[module_idP]->eNB_scheduler); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, + VCD_FUNCTION_OUT); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 8b2b47c450789a4f05714849c9ee31ad17576c0e..394b3c7e9f19888dae326008c1075b08f536d86f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -29,6 +29,9 @@ */ +/* indented with: indent -kr eNB_scheduler_RA.c */ + + #include "assertions.h" #include "platform_types.h" #include "PHY/defs.h" @@ -55,20 +58,19 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/defs.h" // for taus #include "T.h" extern uint8_t nfapi_mode; -extern uint8_t sf_ahead; extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset) { - *frameP = *frameP + ((*subframeP + offset) / 10); + *frameP = (*frameP + ((*subframeP + offset) / 10)) % 1024; *subframeP = ((*subframeP + offset) % 10); } @@ -94,493 +96,636 @@ uint16_t sfnsf_subtract_subframe(uint16_t frameP, uint16_t subframeP, int offset return frameP<<4|subframeP; } -void add_msg3(module_id_t module_idP,int CC_id, RA_TEMPLATE *RA_template, frame_t frameP, sub_frame_t subframeP) { - - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = &eNB->common_channels[CC_id]; - uint8_t j; - nfapi_ul_config_request_t *ul_req; - nfapi_ul_config_request_pdu_t *ul_config_pdu; - nfapi_ul_config_request_body_t *ul_req_body; - nfapi_hi_dci0_request_t *hi_dci0_req = &eNB->HI_DCI0_req[CC_id]; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; +void +add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, + sub_frame_t subframeP) +{ + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = &mac->common_channels[CC_id]; + uint8_t j; + nfapi_ul_config_request_t *ul_req; + nfapi_ul_config_request_body_t *ul_req_body; + nfapi_ul_config_request_pdu_t *ul_config_pdu; + nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_id]; + nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - uint8_t rvseq[4] = {0,2,3,1}; + uint8_t rvseq[4] = { 0, 2, 3, 1 }; - ul_req = &eNB->UL_req_tmp[CC_id][RA_template->Msg3_subframe]; - ul_req_body = &ul_req->ul_config_request_body; - AssertFatal(RA_template->RA_active == TRUE,"RA is not active for RA %X\n",RA_template->rnti); + ul_req = &mac->UL_req_tmp[CC_id][ra->Msg3_subframe]; + ul_req_body = &ul_req->ul_config_request_body; + AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n", + ra->rnti); #ifdef Rel14 - if (RA_template->rach_resource_type>0) { - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d CE level %d is active, Msg3 in (%d,%d)\n", - module_idP,frameP,subframeP,CC_id,RA_template->rach_resource_type-1, - RA_template->Msg3_frame,RA_template->Msg3_subframe); - LOG_D(MAC,"Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d)\n", - frameP,subframeP,RA_template->Msg3_frame,RA_template->Msg3_subframe,RA_template->msg3_nb_rb,RA_template->msg3_round); - - ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; - - memset((void*)ul_config_pdu,0,sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; - ul_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_ul_config_ulsch_pdu)); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = eNB->ul_handle++; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = RA_template->rnti; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = narrowband_to_first_rb(cc,RA_template->msg34_narrowband)+RA_template->msg3_first_rb; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = RA_template->msg3_nb_rb; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rvseq[RA_template->msg3_round]; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = ((10*RA_template->Msg3_frame)+RA_template->Msg3_subframe)&7; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL(RA_template->msg3_mcs, - RA_template->msg3_nb_rb); - // Re13 fields - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type = RA_template->rach_resource_type>2 ? 2 : 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number = 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = (RA_template->Msg3_frame*10)+RA_template->Msg3_subframe; - - ul_req_body->number_of_pdus++; - ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - - ul_req->sfn_sf = RA_template->Msg3_frame<<4|RA_template->Msg3_subframe; //sfnsf_add_subframe(RA_template->Msg3_frame, RA_template->Msg3_subframe, 0); - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - } // if (RA_template->rach_resource_type>0) { - else + if (ra->rach_resource_type > 0) { + LOG_D(MAC, + "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d CE level %d is active, Msg3 in (%d,%d)\n", + module_idP, frameP, subframeP, CC_id, + ra->rach_resource_type - 1, ra->Msg3_frame, + ra->Msg3_subframe); + LOG_D(MAC, + "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d)\n", + frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, + ra->msg3_nb_rb, ra->msg3_round); + + ul_config_pdu = + &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; + + memset((void *) ul_config_pdu, 0, + sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; + ul_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu)); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = mac->ul_handle++; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = ra->rnti; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = + narrowband_to_first_rb(cc, + ra->msg34_narrowband) + + ra->msg3_first_rb; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = + ra->msg3_nb_rb; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = + 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8. + frequency_hopping_enabled_flag = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = + rvseq[ra->msg3_round]; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = + ((10 * ra->Msg3_frame) + ra->Msg3_subframe) & 7; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = + get_TBS_UL(ra->msg3_mcs, ra->msg3_nb_rb); + // Re13 fields + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type = + ra->rach_resource_type > 2 ? 2 : 1; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13. + total_number_of_repetitions = 1; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number = 1; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13. + initial_transmission_sf_io = + (ra->Msg3_frame * 10) + ra->Msg3_subframe; + ul_req_body->number_of_pdus++; + ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req->sfn_sf = ra->Msg3_frame<<4|ra->Msg3_subframe; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + } // if (ra->rach_resource_type>0) { + else #endif { - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", - module_idP,frameP,subframeP,CC_id,RA_template->Msg3_frame,RA_template->Msg3_subframe); - - LOG_D(MAC,"Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d)\n", - frameP,subframeP,RA_template->Msg3_frame,RA_template->Msg3_subframe, - RA_template->msg3_nb_rb,RA_template->msg3_first_rb,RA_template->msg3_round); - - ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; - - memset((void*)ul_config_pdu,0,sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; - ul_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_ul_config_ulsch_pdu)); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = eNB->ul_handle++; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = RA_template->rnti; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = RA_template->msg3_first_rb; - AssertFatal(RA_template->msg3_nb_rb > 0, "nb_rb = 0\n"); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = RA_template->msg3_nb_rb; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rvseq[RA_template->msg3_round]; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = subframe2harqpid(cc,RA_template->Msg3_frame,RA_template->Msg3_subframe); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL(10,RA_template->msg3_nb_rb); - ul_req_body->number_of_pdus++; - ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - ul_req->sfn_sf = sfnsf_add_subframe(RA_template->Msg3_frame, RA_template->Msg3_subframe, 0); - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - // save UL scheduling information for preprocessor - for (j=0;j<RA_template->msg3_nb_rb;j++) cc->vrb_map_UL[RA_template->msg3_first_rb+j]=1; - - LOG_D(MAC, "MSG3: UL_CONFIG SFN/SF:%d number_of_pdus:%d RA_template->msg3_round:%d\n", NFAPI_SFNSF2DEC(ul_req->sfn_sf), ul_req_body->number_of_pdus, RA_template->msg3_round); - - if (RA_template->msg3_round != 0) { // program HI too - hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci+hi_dci0_req_body->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = RA_template->msg3_first_rb; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; - hi_dci0_req_body->number_of_hi++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(RA_template->Msg3_frame, RA_template->Msg3_subframe, 0); - hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - - hi_dci0_req->sfn_sf = sfnsf_add_subframe(RA_template->Msg3_frame, RA_template->Msg3_subframe, 4); - hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - oai_nfapi_hi_dci0_req(hi_dci0_req); - hi_dci0_req_body->number_of_hi=0; - - LOG_D(MAC, "MSG3: HI_DCI0 SFN/SF:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req_body->number_of_dci, hi_dci0_req_body->number_of_hi); - + LOG_D(MAC, + "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", + module_idP, frameP, subframeP, CC_id, ra->Msg3_frame, + ra->Msg3_subframe); + + LOG_D(MAC, + "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d)\n", + frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, + ra->msg3_nb_rb, ra->msg3_first_rb, ra->msg3_round); + + ul_config_pdu = + &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; + + memset((void *) ul_config_pdu, 0, + sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; + ul_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu)); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = mac->ul_handle++; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = ra->rnti; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = + ra->msg3_first_rb; + AssertFatal(ra->msg3_nb_rb > 0, "nb_rb = 0\n"); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = + ra->msg3_nb_rb; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = + 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8. + frequency_hopping_enabled_flag = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = + rvseq[ra->msg3_round]; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = + subframe2harqpid(cc, ra->Msg3_frame, ra->Msg3_subframe); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = + get_TBS_UL(10, ra->msg3_nb_rb); + ul_req_body->number_of_pdus++; + ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req->sfn_sf = ra->Msg3_frame<<4|ra->Msg3_subframe; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; // save UL scheduling information for preprocessor - for (j=0;j<RA_template->msg3_nb_rb;j++) cc->vrb_map_UL[RA_template->msg3_first_rb+j]=1; - - LOG_I(MAC,"[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n", - module_idP,RA_template->rnti,CC_id,frameP,subframeP,10, - 1,1, - RA_template->msg3_round-1); - } // if (RA_template->msg3_round != 0) { // program HI too - } // non-BL/CE UE case + for (j = 0; j < ra->msg3_nb_rb; j++) + cc->vrb_map_UL[ra->msg3_first_rb + j] = 1; + + LOG_D(MAC, "MSG3: UL_CONFIG SFN/SF:%d number_of_pdus:%d ra->msg3_round:%d\n", NFAPI_SFNSF2DEC(ul_req->sfn_sf), ul_req_body->number_of_pdus, ra->msg3_round); + + if (ra->msg3_round != 0) { // program HI too + hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; + memset((void *) hi_dci0_pdu, 0, + sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = + ra->msg3_first_rb; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; + hi_dci0_req_body->number_of_hi++; + + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 0); + hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + + hi_dci0_req->sfn_sf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 4); + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + + if (nfapi_mode) { + oai_nfapi_hi_dci0_req(hi_dci0_req); + hi_dci0_req_body->number_of_hi=0; + } + + LOG_D(MAC, "MSG3: HI_DCI0 SFN/SF:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req_body->number_of_dci, hi_dci0_req_body->number_of_hi); + + // save UL scheduling information for preprocessor + for (j = 0; j < ra->msg3_nb_rb; j++) + cc->vrb_map_UL[ra->msg3_first_rb + j] = 1; + + LOG_D(MAC, + "[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n", + module_idP, ra->rnti, CC_id, frameP, subframeP, 10, 1, 1, + ra->msg3_round - 1); + } // if (ra->msg3_round != 0) { // program HI too + } // non-BL/CE UE case } -void generate_Msg2(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t subframeP,RA_TEMPLATE *RA_template) { +void +generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP, + sub_frame_t subframeP, RA_t * ra) +{ - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - - uint8_t *vrb_map; - int first_rb; - int N_RB_DL; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - nfapi_tx_request_pdu_t *TX_req; - nfapi_dl_config_request_body_t *dl_req; + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + + uint8_t *vrb_map; + int first_rb; + int N_RB_DL; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + nfapi_tx_request_pdu_t *TX_req; + nfapi_dl_config_request_body_t *dl_req; - vrb_map = cc[CC_idP].vrb_map; - dl_req = &eNB->DL_req[CC_idP].dl_config_request_body; - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); + vrb_map = cc[CC_idP].vrb_map; + dl_req = &mac->DL_req[CC_idP].dl_config_request_body; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); #ifdef Rel14 - int rmax = 0; - int rep = 0; - int reps = 0; - int num_nb = 0; - - first_rb = 0; - struct PRACH_ConfigSIB_v1310 *ext4_prach; - PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; - PRACH_ParametersCE_r13_t *p[4]={NULL,NULL,NULL,NULL}; - - uint16_t absSF = (10*frameP)+subframeP; - uint16_t absSF_Msg2 = (10*RA_template->Msg2_frame)+RA_template->Msg2_subframe; - - if (absSF>absSF_Msg2) return; // we're not ready yet, need to be to start == - - if (cc[CC_idP].radioResourceConfigCommon_BR) { - - ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - - switch (prach_ParametersListCE_r13->list.count) { - case 4: - p[3]=prach_ParametersListCE_r13->list.array[3]; - case 3: - p[2]=prach_ParametersListCE_r13->list.array[2]; - case 2: - p[1]=prach_ParametersListCE_r13->list.array[1]; - case 1: - p[0]=prach_ParametersListCE_r13->list.array[0]; - break; - default: - AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",(int)prach_ParametersListCE_r13->list.count); - break; + int rmax = 0; + int rep = 0; + int reps = 0; + int num_nb = 0; + + first_rb = 0; + struct PRACH_ConfigSIB_v1310 *ext4_prach; + PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; + PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL }; + + uint16_t absSF = (10 * frameP) + subframeP; + uint16_t absSF_Msg2 = (10 * ra->Msg2_frame) + ra->Msg2_subframe; + + LOG_D(MAC,"absSF:%d absSF_Msg2:%d ra->rach_resource_type:%d\n",absSF,absSF_Msg2,ra->rach_resource_type); + + if (absSF > absSF_Msg2) + return; // we're not ready yet, need to be to start == + + if (cc[CC_idP].radioResourceConfigCommon_BR) { + + ext4_prach = + cc[CC_idP].radioResourceConfigCommon_BR->ext4-> + prach_ConfigCommon_v1310; + prach_ParametersListCE_r13 = + &ext4_prach->prach_ParametersListCE_r13; + + switch (prach_ParametersListCE_r13->list.count) { + case 4: + p[3] = prach_ParametersListCE_r13->list.array[3]; + case 3: + p[2] = prach_ParametersListCE_r13->list.array[2]; + case 2: + p[1] = prach_ParametersListCE_r13->list.array[1]; + case 1: + p[0] = prach_ParametersListCE_r13->list.array[0]; + break; + default: + AssertFatal(1 == 0, + "Illegal count for prach_ParametersListCE_r13 %d\n", + (int) prach_ParametersListCE_r13->list.count); + break; + } } - } - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, RA_template[rach_resource_type:%d Msg2:%d/%d]\n",module_idP,frameP,subframeP, - RA_template->rach_resource_type,RA_template->Msg2_frame,RA_template->Msg2_subframe); - - if (RA_template->rach_resource_type > 0) { - - // This uses an MPDCCH Type 2 common allocation according to Section 9.1.5 36-213 - // Parameters: - // p=2+4 PRB set (number of PRB pairs 3) - // rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3 - // if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates - // if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates - // distributed transmission - - // rmax from SIB2 information - AssertFatal(rmax<9,"rmax>8!\n"); - rmax = 1<<p[RA_template->rach_resource_type-1]->mpdcch_NumRepetition_RA_r13; - // choose r1 by default for RAR (Table 9.1.5-5) - rep = 0; - // get actual repetition count from Table 9.1.5-3 - reps = (rmax<=8)?(1<<rep):(rmax>>(3-rep)); - // get narrowband according to higher-layer config - num_nb = p[RA_template->rach_resource_type-1]->mpdcch_NarrowbandsToMonitor_r13.list.count; - RA_template->msg2_narrowband = *p[RA_template->rach_resource_type-1]->mpdcch_NarrowbandsToMonitor_r13.list.array[RA_template->preamble_index%num_nb]; - first_rb = narrowband_to_first_rb(&cc[CC_idP],RA_template->msg2_narrowband); - - if ((RA_template->msg2_mpdcch_repetition_cnt == 0) && - (mpdcch_sf_condition(eNB,CC_idP,frameP,subframeP,rmax,TYPE2,-1)>0)){ - // MPDCCH configuration for RAR - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming MPDCCH %d repetitions\n", - module_idP,frameP,subframeP,reps); - - - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_mpdcch_pdu)); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (RA_template->rach_resource_type > 1) ? 11 : 10; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = RA_template->msg2_narrowband; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1; // imposed (9.1.5 in 213) for Type 2 Common search space - AssertFatal(cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13!=NULL, - "cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n"); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 16; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 2; // RA-RNTI - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = RA_template->RA_rnti; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (RA_template->rach_resource_type < 3) ? 1 : 2; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP*10)+subframeP; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6,0,6); // Note: still to be checked if it should not be (getRIV(N_RB_DL,first_rb,6)) : Check nFAPI specifications and what is done L1 with this parameter - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3 - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rep; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1;// N1A_PRB=3 (36.212); => 208 bits for mcs=4, choose mcs according t message size TBD - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1; - RA_template->msg2_mpdcch_repetition_cnt++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - RA_template->Msg2_subframe = (RA_template->Msg2_subframe+9)%10; - - eNB->DL_req[CC_idP].sfn_sf = sfnsf_add_subframe(RA_template->Msg2_frame, RA_template->Msg2_subframe, 4); // nFAPI is runnning at TX SFN/SF - ie 4 ahead - eNB->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - } //repetition_count==0 && SF condition met - if (RA_template->msg2_mpdcch_repetition_cnt>0) { // we're in a stream of repetitions - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n", - module_idP,frameP,subframeP,RA_template->msg2_mpdcch_repetition_cnt); - - if (RA_template->msg2_mpdcch_repetition_cnt==reps) { // this is the last mpdcch repetition - if (cc[CC_idP].tdd_Config==NULL) { // FDD case - // wait 2 subframes for PDSCH transmission - if (subframeP>7) RA_template->Msg2_frame = (frameP+1)&1023; - else RA_template->Msg2_frame = frameP; - RA_template->Msg2_subframe = (subframeP+2)%10; // +2 is the "n+x" from Section 7.1.11 in 36.213 - } - else { - AssertFatal(1==0,"TDD case not done yet\n"); + if (ra->rach_resource_type > 0) { + + // This uses an MPDCCH Type 2 common allocation according to Section 9.1.5 36-213 + // Parameters: + // p=2+4 PRB set (number of PRB pairs 3) + // rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3 + // if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates + // if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates + // distributed transmission + + // rmax from SIB2 information + AssertFatal(rmax < 9, "rmax>8!\n"); + rmax = + 1 << p[ra->rach_resource_type - + 1]->mpdcch_NumRepetition_RA_r13; + // choose r1 by default for RAR (Table 9.1.5-5) + rep = 0; + // get actual repetition count from Table 9.1.5-3 + reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep)); + // get narrowband according to higher-layer config + num_nb = + p[ra->rach_resource_type - + 1]->mpdcch_NarrowbandsToMonitor_r13.list.count; + ra->msg2_narrowband = + *p[ra->rach_resource_type - + 1]->mpdcch_NarrowbandsToMonitor_r13.list.array[ra-> + preamble_index + % num_nb]; + first_rb = + narrowband_to_first_rb(&cc[CC_idP], ra->msg2_narrowband); + + if ((ra->msg2_mpdcch_repetition_cnt == 0) && + (mpdcch_sf_condition + (mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) { + // MPDCCH configuration for RAR + LOG_D(MAC, + "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming MPDCCH %d repetitions\n", + module_idP, frameP, subframeP, reps); + + + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_mpdcch_pdu)); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = + (ra->rach_resource_type > 1) ? 11 : 10; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = + ra->msg2_narrowband; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + number_of_prb_pairs = 6; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1; // imposed (9.1.5 in 213) for Type 2 Common search space + AssertFatal(cc[CC_idP]. + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 + != NULL, + "cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n"); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = + cc[CC_idP].sib1_v13ext-> + bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 16; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 2; // RA-RNTI + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = ra->RA_rnti; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = + (ra->rach_resource_type < 3) ? 1 : 2; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + drms_scrambling_init = cc[CC_idP].physCellId; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + initial_transmission_sf_io = (frameP * 10) + subframeP; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6); // Note: still to be checked if it should not be (getRIV(N_RB_DL,first_rb,6)) : Check nFAPI specifications and what is done L1 with this parameter + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3 + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + harq_resource_offset = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.dci_subframe_repetition_number = rep; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1; // N1A_PRB=3 (36.212); => 208 bits for mcs=4, choose mcs according t message size TBD + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.downlink_assignment_index_length = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + downlink_assignment_index = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + allocate_prach_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag + = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag + = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + number_of_tx_antenna_ports = 1; + ra->msg2_mpdcch_repetition_cnt++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + ra->Msg2_subframe = (ra->Msg2_subframe + 9) % 10; + + mac->DL_req[CC_idP].sfn_sf = sfnsf_add_subframe(ra->Msg2_frame, ra->Msg2_subframe, 4); // nFAPI is runnning at TX SFN/SF - ie 4 ahead + mac->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST; + } //repetition_count==0 && SF condition met + if (ra->msg2_mpdcch_repetition_cnt > 0) { // we're in a stream of repetitions + LOG_D(MAC, + "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n", + module_idP, frameP, subframeP, + ra->msg2_mpdcch_repetition_cnt); + + if (ra->msg2_mpdcch_repetition_cnt == reps) { // this is the last mpdcch repetition + if (cc[CC_idP].tdd_Config == NULL) { // FDD case + // wait 2 subframes for PDSCH transmission + if (subframeP > 7) + ra->Msg2_frame = (frameP + 1) & 1023; + else + ra->Msg2_frame = frameP; + ra->Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11 in 36.213 + } else { + AssertFatal(1 == 0, "TDD case not done yet\n"); + } + } // mpdcch_repetition_count == reps + ra->msg2_mpdcch_repetition_cnt++; + + if ((ra->Msg2_frame == frameP) + && (ra->Msg2_subframe == subframeP)) { + // Program PDSCH + LOG_D(MAC, + "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n", + module_idP, frameP, subframeP); + ra->state = WAITMSG3; + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG3\n", module_idP, frameP, subframeP); + + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = + mac->pdu_index[CC_idP]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + resource_allocation_type = 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + resource_block_coding = getRIV(N_RB_DL, first_rb, 6); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + redundancy_version = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = + 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + transmission_scheme = (cc->p_eNB == 1) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = + 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = + (cc->p_eNB == 1) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + + // Rel10 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = + cc[CC_idP]. + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13-> + startSymbolBR_r13; + // Rel13 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = + (ra->rach_resource_type < 3) ? 1 : 2;; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13. + initial_transmission_sf_io = (10 * frameP) + subframeP; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = + 0; + dl_req->number_pdu++; + + mac->DL_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; + mac->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST; + + LOG_D(MAC,"DL_CONFIG SFN/SF:%d/%d MESSAGE2\n", frameP, subframeP); + + // Program UL processing for Msg3, same as regular LTE + get_Msg3alloc(&cc[CC_idP], subframeP, frameP, + &ra->Msg3_frame, &ra->Msg3_subframe); + add_msg3(module_idP, CC_idP, ra, frameP, subframeP); + fill_rar_br(mac, CC_idP, ra, frameP, subframeP, + cc[CC_idP].RAR_pdu.payload, + ra->rach_resource_type - 1); + // DL request + mac->TX_req[CC_idP].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + mac->TX_req[CC_idP].header.message_id = NFAPI_TX_REQUEST; + mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP; + TX_req = + &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac-> + TX_req + [CC_idP]. + tx_request_body.number_of_pdus]; + TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble + TX_req->pdu_index = mac->pdu_index[CC_idP]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = 7; + TX_req->segments[0].segment_data = + cc[CC_idP].RAR_pdu.payload; + mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; + } } - }// mpdcch_repetition_count == reps - RA_template->msg2_mpdcch_repetition_cnt++; - - if ((RA_template->Msg2_frame == frameP) && (RA_template->Msg2_subframe == subframeP)) { - // Program PDSCH - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n", - module_idP,frameP,subframeP); - RA_template->generate_rar = 0; - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_idP]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = RA_template->RA_rnti; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,6); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - - // Rel10 fields - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; - // Rel13 fields - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (RA_template->rach_resource_type < 3) ? 1 : 2;; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10*frameP)+subframeP; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; - eNB->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - LOG_E(MAC,"DL_CONFIG SFN/SF:%d/%d MESSAGE2\n", frameP, subframeP); - - // Program UL processing for Msg3, same as regular LTE - get_Msg3alloc(&cc[CC_idP],subframeP,frameP,&RA_template->Msg3_frame,&RA_template->Msg3_subframe); - add_msg3(module_idP,CC_idP, RA_template,frameP,subframeP); - fill_rar_br(eNB,CC_idP,RA_template,frameP,subframeP,cc[CC_idP].RAR_pdu.payload,RA_template->rach_resource_type-1); - // DL request - eNB->TX_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; - eNB->TX_req[CC_idP].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_idP].header.message_id = NFAPI_TX_REQUEST; - TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus]; - TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble - TX_req->pdu_index = eNB->pdu_index[CC_idP]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = 7; - TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload; - eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++; - - LOG_E(MAC,"TX_REQ SFN/SF:%d/%d MESSAGE2\n", frameP, subframeP); - } - } - - } - else + + } else #endif { - LOG_E(MAC,"%s() Compare SFN/SF:%04d%d Msg2:%04d%d\n", __FUNCTION__,frameP,subframeP,RA_template->Msg2_frame,RA_template->Msg2_subframe); - - if ((RA_template->Msg2_frame == frameP) && (RA_template->Msg2_subframe == subframeP)) { - struct timespec t; - clock_gettime(CLOCK_MONOTONIC, &t); - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, RA_active %d format 1A (%d,%d)) t:%ld.%09ld\n", - module_idP, CC_idP, frameP, subframeP, - RA_template->RA_active, - RA_template->RA_dci_fmt1, - RA_template->RA_dci_size_bits1, t.tv_sec,t.tv_nsec); - - // Allocate 4 PRBS starting in RB 0 - first_rb = 0; - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = RA_template->RA_rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // RA-RNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,4); - - // This checks if the above DCI allocation is feasible in current subframe - if (!CCE_allocation_infeasible(module_idP,CC_idP,0,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,RA_template->RA_rnti)) { - LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x pdu_index:%d\n", - frameP,subframeP,RA_template->RA_rnti, eNB->pdu_index[CC_idP]); - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_idP]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = RA_template->RA_rnti; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,4); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; - eNB->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - LOG_E(MAC,"DL_CONFIG SFN/SF:%d/%d MESSAGE2\n", frameP, subframeP); - - // Program UL processing for Msg3 - get_Msg3alloc(&cc[CC_idP],subframeP,frameP,&RA_template->Msg3_frame,&RA_template->Msg3_subframe); - - LOG_D(MAC,"Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n", - frameP,subframeP,RA_template->Msg3_frame,RA_template->Msg3_subframe); - - fill_rar(module_idP,CC_idP,frameP,cc[CC_idP].RAR_pdu.payload,N_RB_DL,7); - add_msg3(module_idP,CC_idP, RA_template,frameP,subframeP); - - // DL request - eNB->TX_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; - eNB->TX_req[CC_idP].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_idP].header.message_id = NFAPI_TX_REQUEST; - TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus]; - TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble - TX_req->pdu_index = eNB->pdu_index[CC_idP]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = 7; - TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload; - eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++; - - LOG_E(MAC,"TX_REQ SFN/SF:%d/%d MESSAGE2\n", frameP, subframeP); - - } // PDCCH CCE allocation is feasible - } // Msg2 frame/subframe condition - } // else BL/CE -} -void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t subframeP,RA_TEMPLATE *RA_template){ + if ((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) { + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, state %d\n", + module_idP, CC_idP, frameP, subframeP, ra->state); + + // Allocate 4 PRBS starting in RB 0 + first_rb = 0; + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = + NFAPI_DL_DCI_FORMAT_1A; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = + 4; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = ra->RA_rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // RA-RNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + new_data_indicator_1 = 1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + redundancy_version_1 = 0; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + resource_block_coding = getRIV(N_RB_DL, first_rb, 4); + + // This checks if the above DCI allocation is feasible in current subframe + if (!CCE_allocation_infeasible + (module_idP, CC_idP, 0, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, ra->RA_rnti)) { + LOG_D(MAC, + "Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x\n", + frameP, subframeP, ra->RA_rnti); + dl_req->number_dci++; + dl_req->number_pdu++; + + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = + mac->pdu_index[CC_idP]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + resource_block_coding = getRIV(N_RB_DL, first_rb, 4); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + redundancy_version = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = + 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + transmission_scheme = (cc->p_eNB == 1) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = + 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = + (cc->p_eNB == 1) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + dl_req->number_pdu++; + mac->DL_req[CC_idP].sfn_sf = frameP<<4 | subframeP; + + // Program UL processing for Msg3 + get_Msg3alloc(&cc[CC_idP], subframeP, frameP, + &ra->Msg3_frame, &ra->Msg3_subframe); + + LOG_D(MAC, + "Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n", + frameP, subframeP, ra->Msg3_frame, + ra->Msg3_subframe); + + fill_rar(module_idP, CC_idP, ra, frameP, + cc[CC_idP].RAR_pdu.payload, N_RB_DL, 7); + add_msg3(module_idP, CC_idP, ra, frameP, subframeP); + ra->state = WAITMSG3; + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG3\n", module_idP, frameP, subframeP); + + // DL request + mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP; + TX_req = + &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac-> + TX_req + [CC_idP]. + tx_request_body.number_of_pdus]; + TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble + TX_req->pdu_index = mac->pdu_index[CC_idP]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = 7; + TX_req->segments[0].segment_data = + cc[CC_idP].RAR_pdu.payload; + mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; + } // PDCCH CCE allocation is feasible + } // Msg2 frame/subframe condition + } // else BL/CE +} +void +generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, + sub_frame_t subframeP, RA_t * ra) +{ - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - int16_t rrc_sdu_length; - int UE_id = -1; - uint16_t msg4_padding; - uint16_t msg4_post_padding; - uint16_t msg4_header; + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + int16_t rrc_sdu_length; + int UE_id = -1; + uint16_t msg4_padding; + uint16_t msg4_post_padding; + uint16_t msg4_header; uint8_t *vrb_map; int first_rb; @@ -588,7 +733,7 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t nfapi_dl_config_request_pdu_t *dl_config_pdu; nfapi_ul_config_request_pdu_t *ul_config_pdu; nfapi_tx_request_pdu_t *TX_req; - UE_list_t *UE_list=&eNB->UE_list; + UE_list_t *UE_list=&mac->UE_list; nfapi_dl_config_request_t *dl_req; nfapi_dl_config_request_body_t *dl_req_body; nfapi_ul_config_request_body_t *ul_req_body; @@ -598,867 +743,1075 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t #ifdef Rel14 - int rmax = 0; - int rep = 0; - int reps = 0; - - - first_rb = 0; - struct PRACH_ConfigSIB_v1310 *ext4_prach; - struct PUCCH_ConfigCommon_v1310 *ext4_pucch; - PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; - struct N1PUCCH_AN_InfoList_r13 *pucch_N1PUCCH_AN_InfoList_r13; - PRACH_ParametersCE_r13_t *p[4]={NULL,NULL,NULL,NULL}; - int pucchreps[4]={1,1,1,1}; - int n1pucchan[4]={0,0,0,0}; - - if (cc[CC_idP].radioResourceConfigCommon_BR) { - - ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - ext4_pucch = cc[CC_idP].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310; - prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13; - AssertFatal(prach_ParametersListCE_r13!=NULL,"prach_ParametersListCE_r13 is null\n"); - AssertFatal(pucch_N1PUCCH_AN_InfoList_r13!=NULL,"pucch_N1PUCCH_AN_InfoList_r13 is null\n"); - // check to verify CE-Level compatibility in SIB2_BR - AssertFatal(prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count, - "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n"); - - switch (prach_ParametersListCE_r13->list.count) { - case 4: - p[3] = prach_ParametersListCE_r13->list.array[3]; - n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3]; - AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13!=NULL,"pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n"); - pucchreps[3] = (int)(4<<*ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13); - - case 3: - p[2] = prach_ParametersListCE_r13->list.array[2]; - n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2]; - AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13!=NULL,"pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n"); - pucchreps[2] = (int)(4<<*ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13); - case 2: - p[1] =prach_ParametersListCE_r13->list.array[1]; - n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1]; - AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13!=NULL,"pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n"); - pucchreps[1] = (int)(1<<*ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13); - case 1: - p[0] = prach_ParametersListCE_r13->list.array[0]; - n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0]; - AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13!=NULL,"pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n"); - pucchreps[0] = (int)(1<<*ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13); - default: - AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",prach_ParametersListCE_r13->list.count); + int rmax = 0; + int rep = 0; + int reps = 0; + + + first_rb = 0; + struct PRACH_ConfigSIB_v1310 *ext4_prach; + struct PUCCH_ConfigCommon_v1310 *ext4_pucch; + PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; + struct N1PUCCH_AN_InfoList_r13 *pucch_N1PUCCH_AN_InfoList_r13; + PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL }; + int pucchreps[4] = { 1, 1, 1, 1 }; + int n1pucchan[4] = { 0, 0, 0, 0 }; + + if (cc[CC_idP].radioResourceConfigCommon_BR) { + + ext4_prach = + cc[CC_idP].radioResourceConfigCommon_BR->ext4-> + prach_ConfigCommon_v1310; + ext4_pucch = + cc[CC_idP].radioResourceConfigCommon_BR->ext4-> + pucch_ConfigCommon_v1310; + prach_ParametersListCE_r13 = + &ext4_prach->prach_ParametersListCE_r13; + pucch_N1PUCCH_AN_InfoList_r13 = + ext4_pucch->n1PUCCH_AN_InfoList_r13; + AssertFatal(prach_ParametersListCE_r13 != NULL, + "prach_ParametersListCE_r13 is null\n"); + AssertFatal(pucch_N1PUCCH_AN_InfoList_r13 != NULL, + "pucch_N1PUCCH_AN_InfoList_r13 is null\n"); + // check to verify CE-Level compatibility in SIB2_BR + AssertFatal(prach_ParametersListCE_r13->list.count == + pucch_N1PUCCH_AN_InfoList_r13->list.count, + "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n"); + + switch (prach_ParametersListCE_r13->list.count) { + case 4: + p[3] = prach_ParametersListCE_r13->list.array[3]; + n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3]; + AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 + != NULL, + "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n"); + pucchreps[3] = + (int) (4 << *ext4_pucch-> + pucch_NumRepetitionCE_Msg4_Level3_r13); + + case 3: + p[2] = prach_ParametersListCE_r13->list.array[2]; + n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2]; + AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 + != NULL, + "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n"); + pucchreps[2] = + (int) (4 << *ext4_pucch-> + pucch_NumRepetitionCE_Msg4_Level2_r13); + case 2: + p[1] = prach_ParametersListCE_r13->list.array[1]; + n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1]; + AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 + != NULL, + "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n"); + pucchreps[1] = + (int) (1 << *ext4_pucch-> + pucch_NumRepetitionCE_Msg4_Level1_r13); + case 1: + p[0] = prach_ParametersListCE_r13->list.array[0]; + n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0]; + AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 + != NULL, + "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n"); + pucchreps[0] = + (int) (1 << *ext4_pucch-> + pucch_NumRepetitionCE_Msg4_Level0_r13); + default: + AssertFatal(1 == 0, + "Illegal count for prach_ParametersListCE_r13 %d\n", + prach_ParametersListCE_r13->list.count); + } } - } #endif - vrb_map = cc[CC_idP].vrb_map; - - dl_req = &eNB->DL_req[CC_idP]; - dl_req_body = &dl_req->dl_config_request_body; - dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; - N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); - - UE_id = find_UE_id(module_idP,RA_template->rnti); - AssertFatal(UE_id>=0,"Can't find UE for t-crnti\n"); - - // set HARQ process round to 0 for this UE - - if (cc->tdd_Config) RA_template->harq_pid = ((RA_template->Msg4_frame*10)+RA_template->Msg4_subframe)%10; - else RA_template->harq_pid = ((RA_template->Msg4_frame*10)+RA_template->Msg4_subframe)&7; - - // Get RRCConnectionSetup for Piggyback - rrc_sdu_length = mac_rrc_data_req(module_idP, - CC_idP, - frameP, - CCCH, - 1, // 1 transport block - &cc[CC_idP].CCCH_pdu.payload[0], - ENB_FLAG_YES, - module_idP, - 0); // not used in this case - - AssertFatal(rrc_sdu_length>0, - "[MAC][eNB Scheduler] CCCH not allocated\n"); - - - LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d MSG4:SFN/SF:%d%d UE_id %d, rrc_sdu_length %d harq_pid %d\n", - module_idP, CC_idP, frameP, subframeP,RA_template->Msg4_frame,RA_template->Msg4_subframe,UE_id, rrc_sdu_length, RA_template->harq_pid); - - -#ifdef Rel14 - if (RA_template->rach_resource_type>0) { - - // Generate DCI + repetitions first - // This uses an MPDCCH Type 2 allocation according to Section 9.1.5 36-213, Type2 common allocation according to Table 7.1-8 (36-213) - // Parameters: - // p=2+4 PRB set (number of PRB pairs 6) - // rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3 - // if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates - // if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates - // distributed transmission - - // rmax from SIB2 information - rmax = p[RA_template->rach_resource_type-1]->mpdcch_NumRepetition_RA_r13; - AssertFatal(rmax>=4,"choose rmax>=4 for enough repeititions, or reduce rep to 1 or 2\n"); - - // choose r3 by default for Msg4 (this is ok from table 9.1.5-3 for rmax = >=4, if we choose rmax <4 it has to be less - rep = 2; - // get actual repetition count from Table 9.1.5-3 - reps = (rmax<=8)?(1<<rep):(rmax>>(3-rep)); - // get first narrowband - first_rb = narrowband_to_first_rb(&cc[CC_idP],RA_template->msg34_narrowband); - - if ((RA_template->msg4_mpdcch_repetition_cnt == 0) && - (mpdcch_sf_condition(eNB,CC_idP,RA_template->Msg4_frame,RA_template->Msg4_subframe,rmax,TYPE2,-1)>0)){ - // MPDCCH configuration for RAR - - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_mpdcch_pdu)); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (RA_template->rach_resource_type > 1) ? 11 : 10; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = RA_template->msg34_narrowband; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1; - AssertFatal(cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13!=NULL, - "cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n"); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 16; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 0; // t-C-RNTI - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = RA_template->RA_rnti; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (RA_template->rach_resource_type < 3) ? 1 : 2; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId; /// Check this is still N_id_cell for type2 common - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (RA_template->Msg4_frame*10)+RA_template->Msg4_subframe; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6,0,6);// check if not getRIV(N_RB_DL,first_rb,6); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4; // adjust according to size of Msg4, 208 bits with N1A_PRB=3 - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = RA_template->harq_pid; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rep; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1;// N1A_PRB=3; => 208 bits - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1; - RA_template->msg4_mpdcch_repetition_cnt++; - dl_req_body->number_pdu++; - dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - dl_req->sfn_sf = (RA_template->Msg4_frame<<4)+RA_template->Msg4_subframe; - dl_req->header.message_id = NFAPI_DL_CONFIG_REQUEST; - - } //repetition_count==0 && SF condition met - else if (RA_template->msg4_mpdcch_repetition_cnt>0) { // we're in a stream of repetitions - RA_template->msg4_mpdcch_repetition_cnt++; - if (RA_template->msg4_mpdcch_repetition_cnt==reps) { // this is the last mpdcch repetition - if (cc[CC_idP].tdd_Config==NULL) { // FDD case - // wait 2 subframes for PDSCH transmission - if (RA_template->Msg4_subframe>7) RA_template->Msg4_frame = (frameP+1)&1023; - else RA_template->Msg4_frame = frameP; - RA_template->Msg4_subframe = (RA_template->Msg4_subframe+2)%10; - } - else { - AssertFatal(1==0,"TDD case not done yet\n"); - } - } // mpdcch_repetition_count == reps - if ((RA_template->Msg4_frame == frameP) && (RA_template->Msg4_subframe == subframeP)) { - - // Program PDSCH - - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 BR with RRC Piggyback (ce_level %d RNTI %x)\n", - module_idP, CC_idP, frameP, subframeP,RA_template->rach_resource_type-1,RA_template->rnti); - - AssertFatal(1==0,"Msg4 generation not finished for BL/CE UE\n"); - dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_idP]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = RA_template->rnti; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,6); // check that this isn't getRIV(6,0,6) - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; - - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (RA_template->rach_resource_type < 3) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10*frameP)+subframeP; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0; - dl_req_body->number_pdu++; - dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; - eNB->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d DL_CONFIG frame:%d subframe:%d\n", module_idP,CC_idP,frameP,subframeP); + vrb_map = cc[CC_idP].vrb_map; - RA_template->generate_Msg4=0; - RA_template->wait_ack_Msg4=1; + dl_req = &mac->DL_req[CC_idP]; + dl_req_body = &dl_req->dl_config_request_body; + dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; + N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); - lcid=0; - - UE_list->UE_sched_ctrl[UE_id].round[CC_idP][RA_template->harq_pid] = 0; - msg4_header = 1+6+1; // CR header, CR CE, SDU header - - if ((RA_template->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) { - msg4_padding = RA_template->msg4_TBsize - rrc_sdu_length - msg4_header; - msg4_post_padding = 0; - } else { - msg4_padding = 0; - msg4_post_padding = RA_template->msg4_TBsize - rrc_sdu_length - msg4_header -1; - } - - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", - module_idP,CC_idP,frameP,subframeP,RA_template->msg4_TBsize,rrc_sdu_length,msg4_header,msg4_padding,msg4_post_padding); - DevAssert( UE_id != UE_INDEX_INVALID ); // FIXME not sure how to gracefully return - // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0] - offset = generate_dlsch_header((unsigned char*)eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], - 1, //num_sdus - (unsigned short*)&rrc_sdu_length, // - &lcid, // sdu_lcid - 255, // no drx - 31, // no timing advance - RA_template->cont_res_id, // contention res id - msg4_padding, // no padding - msg4_post_padding); - - memcpy((void*)&eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0][(unsigned char)offset], - &cc[CC_idP].CCCH_pdu.payload[0], - rrc_sdu_length); - - // Tx request - eNB->TX_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; - eNB->TX_req[CC_idP].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_idP].header.message_id = NFAPI_TX_REQUEST; - - TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus]; - TX_req->pdu_length = rrc_sdu_length; - TX_req->pdu_index = eNB->pdu_index[CC_idP]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = rrc_sdu_length; - TX_req->segments[0].segment_data = eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0]; - eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++; - - // Program ACK/NAK for Msg4 PDSCH - int absSF = (RA_template->Msg3_frame*10)+RA_template->Msg3_subframe; - // see Section 10.2 from 36.213 - int ackNAK_absSF = absSF + reps + 4; - AssertFatal(reps>2,"Have to handle programming of ACK when PDSCH repetitions is > 2\n"); - - ul_req = &eNB->UL_req_tmp[CC_idP][ackNAK_absSF%10]; - ul_req_body = &ul_req->ul_config_request_body; - ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; - - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; - ul_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_ul_config_uci_harq_pdu)); - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = RA_template->rnti; - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG; - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.ue_type = (RA_template->rach_resource_type < 3) ? 1 : 2; - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.empty_symbols = 0; - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions = pucchreps[RA_template->rach_resource_type-1]; - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0; - - ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - - ul_req->sfn_sf = sfnsf_add_subframe(RA_template->Msg3_frame, RA_template->Msg3_subframe, 4); - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - - LOG_D(MAC,"UL_req_tmp[CC_idP:%d][ackNAK_absSF mod 10:%d] RA_template->Msg3_frame:%d RA_template->Msg3_subframe:%d + 4 sfn_sf:%d\n", CC_idP, ackNAK_absSF%10, RA_template->Msg3_frame, RA_template->Msg3_subframe, NFAPI_SFNSF2DEC(ul_req->sfn_sf)); - - // Note need to keep sending this across reptitions!!!! Not really for PUCCH, to ask small-cell forum, we'll see for the other messages, maybe parameters change across repetitions and FAPI has to provide for that - if (cc[CC_idP].tdd_Config==NULL) { // FDD case - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG; - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.n_pucch_1_0 = n1pucchan[RA_template->rach_resource_type-1]; - // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case - // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level] - // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 => - // Delta_ARO = 0 from Table 10.1.2.1-1 - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.harq_size = 1; // 1-bit ACK/NAK - } - else { - AssertFatal(1==0,"PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n"); - } - ul_req_body->number_of_pdus++; - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_idP), T_INT(RA_template->rnti), T_INT(frameP), T_INT(subframeP), - T_INT(0 /*harq_pid always 0?*/), T_BUFFER(&eNB->UE_list.DLSCH_pdu[CC_idP][0][UE_id].payload[0], RA_template->msg4_TBsize)); + UE_id = find_UE_id(module_idP, ra->rnti); + AssertFatal(UE_id >= 0, "Can't find UE for t-crnti\n"); + + // set HARQ process round to 0 for this UE + + if (cc->tdd_Config) + ra->harq_pid = ((frameP * 10) + subframeP) % 10; + else + ra->harq_pid = ((frameP * 10) + subframeP) & 7; + + /* // Get RRCConnectionSetup for Piggyback + rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case + + AssertFatal(rrc_sdu_length > 0, + "[MAC][eNB Scheduler] CCCH not allocated\n"); + + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);*/ + + +#ifdef Rel14 + if (ra->rach_resource_type > 0) { + + // Generate DCI + repetitions first + // This uses an MPDCCH Type 2 allocation according to Section 9.1.5 36-213, Type2 common allocation according to Table 7.1-8 (36-213) + // Parameters: + // p=2+4 PRB set (number of PRB pairs 6) + // rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3 + // if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates + // if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates + // distributed transmission + + // rmax from SIB2 information + rmax = p[ra->rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13; + AssertFatal(rmax >= 4, + "choose rmax>=4 for enough repeititions, or reduce rep to 1 or 2\n"); + + // choose r3 by default for Msg4 (this is ok from table 9.1.5-3 for rmax = >=4, if we choose rmax <4 it has to be less + rep = 2; + // get actual repetition count from Table 9.1.5-3 + reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep)); + // get first narrowband + first_rb = + narrowband_to_first_rb(&cc[CC_idP], ra->msg34_narrowband); + + if ((ra->msg4_mpdcch_repetition_cnt == 0) && + (mpdcch_sf_condition + (mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) { + // MPDCCH configuration for RAR + + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_mpdcch_pdu)); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = + (ra->rach_resource_type > 1) ? 11 : 10; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = + ra->msg34_narrowband; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + number_of_prb_pairs = 6; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + mpdcch_tansmission_type = 1; + AssertFatal(cc[CC_idP]. + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 + != NULL, + "cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n"); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = + cc[CC_idP].sib1_v13ext-> + bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 16; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 0; // t-C-RNTI + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = ra->RA_rnti; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = + (ra->rach_resource_type < 3) ? 1 : 2; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId; /// Check this is still N_id_cell for type2 common + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + initial_transmission_sf_io = (frameP * 10) + subframeP; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6); // check if not getRIV(N_RB_DL,first_rb,6); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4; // adjust according to size of Msg4, 208 bits with N1A_PRB=3 + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = + ra->harq_pid; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + harq_resource_offset = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.dci_subframe_repetition_number = rep; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1; // N1A_PRB=3; => 208 bits + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.downlink_assignment_index_length = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + downlink_assignment_index = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + allocate_prach_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag + = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0; + dl_config_pdu->mpdcch_pdu. + mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag + = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = + 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13. + number_of_tx_antenna_ports = 1; + ra->msg4_mpdcch_repetition_cnt++; + dl_req_body->number_pdu++; + dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + dl_req->sfn_sf = (ra->Msg4_frame<<4)+ra->Msg4_subframe; + dl_req->header.message_id = NFAPI_DL_CONFIG_REQUEST; + + } //repetition_count==0 && SF condition met + else if (ra->msg4_mpdcch_repetition_cnt > 0) { // we're in a stream of repetitions + ra->msg4_mpdcch_repetition_cnt++; + if (ra->msg4_mpdcch_repetition_cnt == reps) { // this is the last mpdcch repetition + if (cc[CC_idP].tdd_Config == NULL) { // FDD case + // wait 2 subframes for PDSCH transmission + if (subframeP > 7) + ra->Msg4_frame = (frameP + 1) & 1023; + else + ra->Msg4_frame = frameP; + ra->Msg4_subframe = (subframeP + 2) % 10; + } else { + AssertFatal(1 == 0, "TDD case not done yet\n"); + } + } // mpdcch_repetition_count == reps + if ((ra->Msg4_frame == frameP) + && (ra->Msg4_subframe == subframeP)) { + + // Program PDSCH + + // Get RRCConnectionSetup for Piggyback + /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/ + + rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); + + AssertFatal(rrc_sdu_length > 0, + "[MAC][eNB Scheduler] CCCH not allocated\n"); + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 BR with RRC Piggyback (ce_level %d RNTI %x)\n", + module_idP, CC_idP, frameP, subframeP, + ra->rach_resource_type - 1, ra->rnti); + + AssertFatal(1 == 0, + "Msg4 generation not finished for BL/CE UE\n"); + dl_config_pdu = + &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = + mac->pdu_index[CC_idP]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->rnti; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 6); // check that this isn't getRIV(6,0,6) + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + redundancy_version = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = + 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + transmission_scheme = (cc->p_eNB == 1) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = + 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = + (cc->p_eNB == 1) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = + cc[CC_idP]. + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13-> + startSymbolBR_r13; + + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = + (ra->rach_resource_type < 3) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13. + initial_transmission_sf_io = (10 * frameP) + subframeP; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = + 0; + dl_req_body->number_pdu++; + dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + mac->DL_req[CC_idP].sfn_sf = (frameP<<4)+subframeP; + mac->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST; - if (opt_enabled==1) { - trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], - rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id), - eNB->frame, eNB->subframe,0,0); - LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", - module_idP, CC_idP, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length); - } - } // Msg4 frame/subframe - } // msg4_mpdcch_repetition_count - } // rach_resource_type > 0 - else + ra->state = WAITMSG4ACK; + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG4ACK\n", module_idP, frameP, subframeP); + + lcid = 0; + + UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = + 0; + msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header + + if ((ra->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) { + msg4_padding = + ra->msg4_TBsize - rrc_sdu_length - msg4_header; + msg4_post_padding = 0; + } else { + msg4_padding = 0; + msg4_post_padding = + ra->msg4_TBsize - rrc_sdu_length - msg4_header - 1; + } + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", + module_idP, CC_idP, frameP, subframeP, + ra->msg4_TBsize, rrc_sdu_length, msg4_header, + msg4_padding, msg4_post_padding); + DevAssert(UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return + // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0] + offset = generate_dlsch_header((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], 1, //num_sdus + (unsigned short *) &rrc_sdu_length, // + &lcid, // sdu_lcid + 255, // no drx + 31, // no timing advance + ra->cont_res_id, // contention res id + msg4_padding, // no padding + msg4_post_padding); + + memcpy((void *) &mac->UE_list. + DLSCH_pdu[CC_idP][0][(unsigned char) + UE_id].payload[0][(unsigned + char) + offset], + &cc[CC_idP].CCCH_pdu.payload[0], rrc_sdu_length); + + // DL request + mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP; + mac->TX_req[CC_idP].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + mac->TX_req[CC_idP].header.message_id = NFAPI_TX_REQUEST; + + TX_req = + &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac-> + TX_req + [CC_idP]. + tx_request_body.number_of_pdus]; + TX_req->pdu_length = rrc_sdu_length; + TX_req->pdu_index = mac->pdu_index[CC_idP]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = rrc_sdu_length; + TX_req->segments[0].segment_data = + mac->UE_list. + DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0]; + mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; + + // Program ACK/NAK for Msg4 PDSCH + int absSF = (ra->Msg3_frame * 10) + ra->Msg3_subframe; + // see Section 10.2 from 36.213 + int ackNAK_absSF = absSF + reps + 4; + AssertFatal(reps > 2, + "Have to handle programming of ACK when PDSCH repetitions is > 2\n"); + ul_req = &mac->UL_req_tmp[CC_idP][ackNAK_absSF % 10]; + ul_req_body = &ul_req->ul_config_request_body; + ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; + + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; + ul_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_ul_config_uci_harq_pdu)); + ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this + ul_config_pdu->uci_harq_pdu. + ue_information.ue_information_rel8.rnti = ra->rnti; + ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG; + ul_config_pdu->uci_harq_pdu. + ue_information.ue_information_rel13.ue_type = + (ra->rach_resource_type < 3) ? 1 : 2; + ul_config_pdu->uci_harq_pdu. + ue_information.ue_information_rel13.empty_symbols = 0; + ul_config_pdu->uci_harq_pdu.ue_information. + ue_information_rel13.total_number_of_repetitions = + pucchreps[ra->rach_resource_type - 1]; + ul_config_pdu->uci_harq_pdu. + ue_information.ue_information_rel13.repetition_number = + 0; + + ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + + ul_req->sfn_sf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 4); + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + + LOG_D(MAC,"UL_req_tmp[CC_idP:%d][ackNAK_absSF mod 10:%d] ra->Msg3_frame:%d ra->Msg3_subframe:%d + 4 sfn_sf:%d\n", CC_idP, ackNAK_absSF%10, ra->Msg3_frame, ra->Msg3_subframe, NFAPI_SFNSF2DEC(ul_req->sfn_sf)); + + // Note need to keep sending this across reptitions!!!! Not really for PUCCH, to ask small-cell forum, we'll see for the other messages, maybe parameters change across repetitions and FAPI has to provide for that + if (cc[CC_idP].tdd_Config == NULL) { // FDD case + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG; + ul_config_pdu->uci_harq_pdu. + harq_information.harq_information_rel8_fdd. + n_pucch_1_0 = + n1pucchan[ra->rach_resource_type - 1]; + // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case + // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level] + // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 => + // Delta_ARO = 0 from Table 10.1.2.1-1 + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.harq_size = 1; // 1-bit ACK/NAK + } else { + AssertFatal(1 == 0, + "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n"); + } + ul_req_body->number_of_pdus++; + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), + T_INT(CC_idP), T_INT(ra->rnti), T_INT(frameP), + T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ), + T_BUFFER(&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id]. + payload[0], ra->msg4_TBsize)); + + if (opt_enabled == 1) { + trace_pdu(1, + (uint8_t *) mac-> + UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) + UE_id].payload + [0], rrc_sdu_length, UE_id, 3, + UE_RNTI(module_idP, UE_id), mac->frame, + mac->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", + module_idP, CC_idP, frameP, UE_RNTI(module_idP, + UE_id), + rrc_sdu_length); + } + } // Msg4 frame/subframe + } // msg4_mpdcch_repetition_count + } // rach_resource_type > 0 + else #endif - { // This is normal LTE case - if (1){ // || (RA_template->Msg4_frame == frameP) && (RA_template->Msg4_subframe == subframeP)) { - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", - module_idP, CC_idP, frameP, subframeP,RA_template->rnti); - - /// Choose first 4 RBs for Msg4, should really check that these are free! - first_rb=0; - - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - - - // Compute MCS/TBS for 3 PRB (coded on 4 vrb) - msg4_header = 1+6+1; // CR header, CR CE, SDU header - - if ((rrc_sdu_length+msg4_header) <= 22) { - RA_template->msg4_mcs = 4; - RA_template->msg4_TBsize = 22; - } else if ((rrc_sdu_length+msg4_header) <= 28) { - RA_template->msg4_mcs = 5; - RA_template->msg4_TBsize = 28; - } else if ((rrc_sdu_length+msg4_header) <= 32) { - RA_template->msg4_mcs = 6; - RA_template->msg4_TBsize = 32; - } else if ((rrc_sdu_length+msg4_header) <= 41) { - RA_template->msg4_mcs = 7; - RA_template->msg4_TBsize = 41; - } else if ((rrc_sdu_length+msg4_header) <= 49) { - RA_template->msg4_mcs = 8; - RA_template->msg4_TBsize = 49; - } else if ((rrc_sdu_length+msg4_header) <= 57) { - RA_template->msg4_mcs = 9; - RA_template->msg4_TBsize = 57; - } - - fill_nfapi_dl_dci_1A(dl_config_pdu, - 4, // aggregation_level - RA_template->rnti, // rnti - 1, // rnti_type, CRNTI - RA_template->harq_pid, // harq_process - 1, // tpc, none - getRIV(N_RB_DL,first_rb,4), // resource_block_coding - RA_template->msg4_mcs, // mcs - 1, // ndi - 0, // rv - 0); // vrb_flag - struct timespec t; - clock_gettime(CLOCK_MONOTONIC, &t); - LOG_D(MAC,"Frame %d, subframe %d: Msg4 SFN/SF:%d%d DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d t:%ld.%09ld\n", - frameP, - subframeP, - RA_template->Msg4_frame, RA_template->Msg4_subframe, - dl_req_body->number_pdu, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process, - &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding,t.tv_sec,t.tv_nsec); - AssertFatal(dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding < 8192, - "resource_block_coding %u < 8192\n", - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding); - if (!CCE_allocation_infeasible(module_idP,CC_idP,1, - RA_template->Msg4_subframe,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - RA_template->rnti)) { - dl_req_body->number_dci++; - dl_req_body->number_pdu++; - dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - dl_req->sfn_sf = RA_template->Msg4_frame<<4|RA_template->Msg4_subframe; - dl_req->header.message_id = NFAPI_DL_CONFIG_REQUEST; - - RA_template->generate_Msg4=0; - RA_template->wait_ack_Msg4=1; - - uint16_t orig_Msg4_frame = RA_template->Msg4_frame; - uint16_t orig_Msg4_subframe = RA_template->Msg4_subframe; - - // increment Absolute subframe by 8 for Msg4 retransmission - LOG_D(MAC,"Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n", - frameP,subframeP,RA_template->Msg4_frame,RA_template->Msg4_subframe); - - //if (RA_template->Msg4_subframe > 1) RA_template->Msg4_frame++; - //RA_template->Msg4_frame&=1023; - //RA_template->Msg4_subframe = (RA_template->Msg4_subframe+8)%10; - - // Expect +8 for TX->UL:ACK - uint16_t retrans_frame = RA_template->Msg4_frame; - uint16_t retrans_subframe = RA_template->Msg4_subframe; - - add_subframe(&retrans_frame, &retrans_subframe, 8+sf_ahead); - - RA_template->Msg4_frame = retrans_frame; - RA_template->Msg4_subframe = retrans_subframe; - - LOG_D(MAC,"Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n", - frameP,subframeP,RA_template->Msg4_frame,RA_template->Msg4_subframe); - lcid=0; - - // DJP - FIXME TODO TDD broken - // - // put HARQ process round to 0 - if (cc->tdd_Config) RA_template->harq_pid = ((RA_template->Msg4_frame*10)+RA_template->Msg4_subframe)%10; - else RA_template->harq_pid = dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process; - //else RA_template->harq_pid = ((RA_template->Msg4_frame*10)+RA_template->Msg4_subframe)&7; - UE_list->UE_sched_ctrl[UE_id].round[CC_idP][RA_template->harq_pid] = 0; - - if ((RA_template->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) { - msg4_padding = RA_template->msg4_TBsize - rrc_sdu_length - msg4_header; - msg4_post_padding = 0; - } else { - msg4_padding = 0; - msg4_post_padding = RA_template->msg4_TBsize - rrc_sdu_length - msg4_header -1; - } - - LOG_D(MAC,"[eNB %d][RAPROC] CC_idP %d Frame %d subframeP %d Msg4 : SFN/SF:%d%d TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", - module_idP,CC_idP,frameP,subframeP,orig_Msg4_frame,orig_Msg4_subframe,RA_template->msg4_TBsize,rrc_sdu_length,msg4_header,msg4_padding,msg4_post_padding); - DevAssert( UE_id != UE_INDEX_INVALID ); // FIXME not sure how to gracefully return - // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0] - offset = generate_dlsch_header((unsigned char*)eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], - 1, //num_sdus - (unsigned short*)&rrc_sdu_length, // - &lcid, // sdu_lcid - 255, // no drx - 31, // no timing advance - RA_template->cont_res_id, // contention res id - msg4_padding, // no padding - msg4_post_padding); - - memcpy((void*)&eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0][(unsigned char)offset], - &cc[CC_idP].CCCH_pdu.payload[0], - rrc_sdu_length); - - // DLSCH Config - fill_nfapi_dlsch_config(eNB, - dl_req_body, - RA_template->msg4_TBsize, - eNB->pdu_index[CC_idP], - RA_template->rnti, - 2, // resource_allocation_type : format 1A/1B/1D - 0, // virtual_resource_block_assignment_flag : localized - getRIV(N_RB_DL,first_rb,4), // resource_block_coding : RIV, 4 PRB - 2, // modulation: QPSK - 0, // redundancy version - 1, // transport_blocks - 0, // transport_block_to_codeword_swap_flag (0) - (cc->p_eNB==1 ) ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - //0, // codebook index - 1, // ue_category_capacity - 4, // pa: 0 dB - 0, // delta_power_offset_index - 0, // ngap - 1, // NPRB = 3 like in DCI - (cc->p_eNB==1 ) ? 1 : 2, // transmission mode - 1, // num_bf_prb_per_subband - 1); // num_bf_vector - LOG_D(MAC,"Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n",dl_req_body->number_pdu,eNB->pdu_index[CC_idP]); - - // DL request - eNB->TX_req[CC_idP].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_idP].tx_request_body, - (orig_Msg4_frame*10)+orig_Msg4_subframe, - rrc_sdu_length, - eNB->pdu_index[CC_idP], - eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0]); - eNB->TX_req[CC_idP].header.message_id = NFAPI_TX_REQUEST; - eNB->pdu_index[CC_idP]++; - - LOG_D(MAC,"Filling UCI ACK/NAK information, cce_idx %d\n",dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - // Program PUCCH1a for ACK/NAK - // Program ACK/NAK for Msg4 PDSCH - fill_nfapi_uci_acknak(module_idP, - CC_idP, - RA_template->rnti, - (orig_Msg4_frame*10)+orig_Msg4_subframe, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - - - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_idP), T_INT(RA_template->rnti), T_INT(frameP), T_INT(subframeP), - T_INT(0 /*harq_pid always 0?*/), T_BUFFER(&eNB->UE_list.DLSCH_pdu[CC_idP][0][UE_id].payload[0], RA_template->msg4_TBsize)); - - if (opt_enabled==1) { - trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], - rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id), - eNB->frame, eNB->subframe,0,0); - LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", - module_idP, CC_idP, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length); - } - - } // CCE Allocation feasible - } // msg4 frame/subframe - } // else rach_resource_type + { + // This is normal LTE case + LOG_I(MAC, "Panos-D: generate_Msg4 1 ra->Msg4_frame SFN/SF: %d.%d, SFN/SF: %d.%d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP); + if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) { + + // Get RRCConnectionSetup for Piggyback + /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/ + + rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); + + AssertFatal(rrc_sdu_length > 0, + "[MAC][eNB Scheduler] CCCH not allocated\n"); + + + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", + module_idP, CC_idP, frameP, subframeP, ra->rnti); + + /// Choose first 4 RBs for Msg4, should really check that these are free! + first_rb = 0; + + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + + + // Compute MCS/TBS for 3 PRB (coded on 4 vrb) + msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header + + if ((rrc_sdu_length + msg4_header) <= 22) { + ra->msg4_mcs = 4; + ra->msg4_TBsize = 22; + } else if ((rrc_sdu_length + msg4_header) <= 28) { + ra->msg4_mcs = 5; + ra->msg4_TBsize = 28; + } else if ((rrc_sdu_length + msg4_header) <= 32) { + ra->msg4_mcs = 6; + ra->msg4_TBsize = 32; + } else if ((rrc_sdu_length + msg4_header) <= 41) { + ra->msg4_mcs = 7; + ra->msg4_TBsize = 41; + } else if ((rrc_sdu_length + msg4_header) <= 49) { + ra->msg4_mcs = 8; + ra->msg4_TBsize = 49; + } else if ((rrc_sdu_length + msg4_header) <= 57) { + ra->msg4_mcs = 9; + ra->msg4_TBsize = 57; + } + + fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level + ra->rnti, // rnti + 1, // rnti_type, CRNTI + ra->harq_pid, // harq_process + 1, // tpc, none + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding + ra->msg4_mcs, // mcs + 1, // ndi + 0, // rv + 0); // vrb_flag + + LOG_D(MAC, + "Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n", + frameP, subframeP, dl_req_body->number_pdu, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process, + &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + resource_block_coding, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + resource_block_coding); + AssertFatal(dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding < 8192, + "resource_block_coding %u < 8192\n", + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding); + if (!CCE_allocation_infeasible + (module_idP, CC_idP, 1, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, ra->rnti)) { + dl_req_body->number_dci++; + dl_req_body->number_pdu++; + + ra->state = WAITMSG4ACK; + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG4ACK\n", module_idP, frameP, subframeP); + + // increment Absolute subframe by 8 for Msg4 retransmission + LOG_D(MAC, + "Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n", + frameP, subframeP, ra->Msg4_frame, + ra->Msg4_subframe); + if (ra->Msg4_subframe > 1) + ra->Msg4_frame++; + ra->Msg4_frame &= 1023; + ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; + LOG_D(MAC, + "Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n", + frameP, subframeP, ra->Msg4_frame, + ra->Msg4_subframe); + lcid = 0; + + // put HARQ process round to 0 + if (cc->tdd_Config) + ra->harq_pid = ((frameP * 10) + subframeP) % 10; + else + ra->harq_pid = ((frameP * 10) + subframeP) & 7; + UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = + 0; + + if ((ra->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) { + msg4_padding = + ra->msg4_TBsize - rrc_sdu_length - msg4_header; + msg4_post_padding = 0; + } else { + msg4_padding = 0; + msg4_post_padding = + ra->msg4_TBsize - rrc_sdu_length - msg4_header - 1; + } + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_idP %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", + module_idP, CC_idP, frameP, subframeP, + ra->msg4_TBsize, rrc_sdu_length, msg4_header, + msg4_padding, msg4_post_padding); + DevAssert(UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return + // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0] + offset = generate_dlsch_header((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], 1, //num_sdus + (unsigned short *) &rrc_sdu_length, // + &lcid, // sdu_lcid + 255, // no drx + 31, // no timing advance + ra->cont_res_id, // contention res id + msg4_padding, // no padding + msg4_post_padding); + + memcpy((void *) &mac->UE_list. + DLSCH_pdu[CC_idP][0][(unsigned char) + UE_id].payload[0][(unsigned + char) + offset], + &cc[CC_idP].CCCH_pdu.payload[0], rrc_sdu_length); + + // DLSCH Config + fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, mac->pdu_index[CC_idP], ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D + 0, // virtual_resource_block_assignment_flag : localized + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB + 2, // modulation: QPSK + 0, // redundancy version + 1, // transport_blocks + 0, // transport_block_to_codeword_swap_flag (0) + (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + //0, // codebook index + 1, // ue_category_capacity + 4, // pa: 0 dB + 0, // delta_power_offset_index + 0, // ngap + 1, // NPRB = 3 like in DCI + (cc->p_eNB == 1) ? 1 : 2, // transmission mode + 1, // num_bf_prb_per_subband + 1); // num_bf_vector + LOG_D(MAC, + "Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n", + dl_req_body->number_pdu, mac->pdu_index[CC_idP]); + + // Tx request + mac->TX_req[CC_idP].sfn_sf = + fill_nfapi_tx_req(&mac->TX_req[CC_idP].tx_request_body, + (frameP * 10) + subframeP, + rrc_sdu_length, + mac->pdu_index[CC_idP], + mac->UE_list. + DLSCH_pdu[CC_idP][0][(unsigned char) + UE_id].payload + [0]); + mac->pdu_index[CC_idP]++; + + dl_req->sfn_sf = mac->TX_req[CC_idP].sfn_sf; + + LOG_D(MAC, "Filling UCI ACK/NAK information, cce_idx %d\n", + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + // Program PUCCH1a for ACK/NAK + // Program ACK/NAK for Msg4 PDSCH + fill_nfapi_uci_acknak(module_idP, + CC_idP, + ra->rnti, + (frameP * 10) + subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.cce_idx); + + + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), + T_INT(CC_idP), T_INT(ra->rnti), T_INT(frameP), + T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ), + T_BUFFER(&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id]. + payload[0], ra->msg4_TBsize)); + + if (opt_enabled == 1) { + trace_pdu(1, + (uint8_t *) mac-> + UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) + UE_id].payload + [0], rrc_sdu_length, UE_id, 3, + UE_RNTI(module_idP, UE_id), mac->frame, + mac->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", + module_idP, CC_idP, frameP, UE_RNTI(module_idP, + UE_id), + rrc_sdu_length); + } + + } // CCE Allocation feasible + } // msg4 frame/subframe + } // else rach_resource_type } -void check_Msg4_retransmission(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t subframeP,RA_TEMPLATE *RA_template) { - - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - int UE_id = -1; - uint8_t *vrb_map; - int first_rb; - int N_RB_DL; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - UE_list_t *UE_list=&eNB->UE_list; - nfapi_dl_config_request_t *dl_req; - nfapi_dl_config_request_body_t *dl_req_body; +void +check_Msg4_retransmission(module_id_t module_idP, int CC_idP, + frame_t frameP, sub_frame_t subframeP, RA_t * ra) +{ + + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + int UE_id = -1; + uint8_t *vrb_map; + int first_rb; + int N_RB_DL; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + UE_list_t *UE_list = &mac->UE_list; + nfapi_dl_config_request_t *dl_req; + nfapi_dl_config_request_body_t *dl_req_body; + + int round; + /* + #ifdef Rel14 + COMMON_channels_t *cc = mac->common_channels; + + int rmax = 0; + int rep = 0; + int reps = 0; + + first_rb = 0; + struct PRACH_ConfigSIB_v1310 *ext4_prach; + PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; + PRACH_ParametersCE_r13_t *p[4]; + + if (cc[CC_idP].radioResourceConfigCommon_BR) { + + ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; + prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; + + switch (prach_ParametersListCE_r13->list.count) { + case 4: + p[3]=prach_ParametersListCE_r13->list.array[3]; + case 3: + p[2]=prach_ParametersListCE_r13->list.array[2]; + case 2: + p[1]=prach_ParametersListCE_r13->list.array[1]; + case 1: + p[0]=prach_ParametersListCE_r13->list.array[0]; + default: + AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",prach_ParametersListCE_r13->list.count); + } + } + #endif + */ + + // check HARQ status and retransmit if necessary + + + UE_id = find_UE_id(module_idP, ra->rnti); + AssertFatal(UE_id >= 0, "Can't find UE for t-crnti\n"); + + round = UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid]; + vrb_map = cc[CC_idP].vrb_map; + + dl_req = &mac->DL_req[CC_idP]; + dl_req_body = &dl_req->dl_config_request_body; + dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; + N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); + + LOG_I(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d)\n", + module_idP, CC_idP, frameP, subframeP, ra->harq_pid, round); + + if (round != 8) { - int round; - /* #ifdef Rel14 - COMMON_channels_t *cc = eNB->common_channels; - - int rmax = 0; - int rep = 0; - int reps = 0; - - first_rb = 0; - struct PRACH_ConfigSIB_v1310 *ext4_prach; - PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; - PRACH_ParametersCE_r13_t *p[4]; - - if (cc[CC_idP].radioResourceConfigCommon_BR) { - - ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - - switch (prach_ParametersListCE_r13->list.count) { - case 4: - p[3]=prach_ParametersListCE_r13->list.array[3]; - case 3: - p[2]=prach_ParametersListCE_r13->list.array[2]; - case 2: - p[1]=prach_ParametersListCE_r13->list.array[1]; - case 1: - p[0]=prach_ParametersListCE_r13->list.array[0]; - default: - AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",prach_ParametersListCE_r13->list.count); - } - } + if (ra->rach_resource_type > 0) { + AssertFatal(1 == 0, + "Msg4 Retransmissions not handled yet for BL/CE UEs\n"); + } else #endif - */ - - // check HARQ status and retransmit if necessary - - - UE_id = find_UE_id(module_idP,RA_template->rnti); - AssertFatal(UE_id>=0,"Can't find UE for t-crnti\n"); - - round = UE_list->UE_sched_ctrl[UE_id].round[CC_idP][RA_template->harq_pid]; - vrb_map = cc[CC_idP].vrb_map; - - dl_req = &eNB->DL_req[CC_idP]; - dl_req_body = &dl_req->dl_config_request_body; - dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; - N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); - - LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d) RA_template[Msg4:SFN/SF:%d/%d]\n", - module_idP,CC_idP,frameP,subframeP,RA_template->harq_pid,round, RA_template->Msg4_frame, RA_template->Msg4_subframe); - - if (round!=8) { - -#ifdef Rel14 - if (RA_template->rach_resource_type>0) { - AssertFatal(1==0,"Msg4 Retransmissions not handled yet for BL/CE UEs\n"); + { + if ((ra->Msg4_frame == frameP) + && (ra->Msg4_subframe == subframeP)) { + + //ra->wait_ack_Msg4++; + // we have to schedule a retransmission + + dl_req->sfn_sf = frameP<<4 | subframeP; + + first_rb = 0; + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + + fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level + ra->rnti, // rnti + 1, // rnti_type, CRNTI + ra->harq_pid, // harq_process + 1, // tpc, none + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding + ra->msg4_mcs, // mcs + 1, // ndi + round & 3, // rv + 0); // vrb_flag + + if (!CCE_allocation_infeasible + (module_idP, CC_idP, 1, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, ra->rnti)) { + dl_req_body->number_dci++; + dl_req_body->number_pdu++; + dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + LOG_D(MAC, + "msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", + ra->rnti, round, frameP, subframeP); + // DLSCH Config + //DJP - fix this pdu_index = -1 + fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, + -1 + /* retransmission, no pdu_index */ + , ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D + 0, // virtual_resource_block_assignment_flag : localized + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB + 2, // modulation: QPSK + round & 3, // redundancy version + 1, // transport_blocks + 0, // transport_block_to_codeword_swap_flag (0) + (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + //0, // codebook index + 1, // ue_category_capacity + 4, // pa: 0 dB + 0, // delta_power_offset_index + 0, // ngap + 1, // NPRB = 3 like in DCI + (cc->p_eNB == 1) ? 1 : 2, // transmission mode + 1, // num_bf_prb_per_subband + 1); // num_bf_vector + } else + LOG_D(MAC, + "msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n", + ra->rnti, round, frameP, subframeP); + + + // Program PUCCH1a for ACK/NAK + + + fill_nfapi_uci_acknak(module_idP, CC_idP, + ra->rnti, + (frameP * 10) + subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.cce_idx); + + // prepare frame for retransmission + if (ra->Msg4_subframe > 1) + ra->Msg4_frame++; + ra->Msg4_frame &= 1023; + ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; + + LOG_W(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n", + module_idP, CC_idP, frameP, subframeP, ra->rnti, + round, ra->Msg4_frame, ra->Msg4_subframe); + + } // Msg4 frame/subframe + } // regular LTE case + } else { + LOG_I(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n", + module_idP, CC_idP, frameP, subframeP); + ra->state = IDLE; + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:IDLE\n", module_idP, frameP, subframeP); + UE_id = find_UE_id(module_idP, ra->rnti); + DevAssert(UE_id != -1); + mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id]. + configured = TRUE; } - else -#endif - { - if ( (RA_template->Msg4_frame == frameP) && (RA_template->Msg4_subframe == subframeP)) { - - //RA_template->wait_ack_Msg4++; - // we have to schedule a retransmission - - dl_req->sfn_sf = frameP<<4 | subframeP; - - first_rb=0; - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - - fill_nfapi_dl_dci_1A(dl_config_pdu, - 4, // aggregation_level - RA_template->rnti, // rnti - 1, // rnti_type, CRNTI - RA_template->harq_pid, // harq_process - 1, // tpc, none - getRIV(N_RB_DL,first_rb,4), // resource_block_coding - RA_template->msg4_mcs, // mcs - 1, // ndi - round&3, // rv - 0); // vrb_flag - - if (!CCE_allocation_infeasible(module_idP,CC_idP,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,RA_template->rnti)) { - dl_req_body->number_dci++; - dl_req_body->number_pdu++; - dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - LOG_D(MAC,"msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP); - // DLSCH Config - fill_nfapi_dlsch_config(eNB, - dl_req_body, - RA_template->msg4_TBsize, - -1 /* retransmission, no pdu_index */, - RA_template->rnti, - 2, // resource_allocation_type : format 1A/1B/1D - 0, // virtual_resource_block_assignment_flag : localized - getRIV(N_RB_DL,first_rb,4), // resource_block_coding : RIV, 4 PRB - 2, // modulation: QPSK - round&3, // redundancy version - 1, // transport_blocks - 0, // transport_block_to_codeword_swap_flag (0) - (cc->p_eNB==1 ) ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - //0, // codebook index - 1, // ue_category_capacity - 4, // pa: 0 dB - 0, // delta_power_offset_index - 0, // ngap - 1, // NPRB = 3 like in DCI - (cc->p_eNB==1 ) ? 1 : 2, // transmission mode - 1, // num_bf_prb_per_subband - 1); // num_bf_vector - } - else - LOG_D(MAC,"msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n", RA_template->rnti, round, frameP, subframeP); - - - // Program PUCCH1a for ACK/NAK - - - fill_nfapi_uci_acknak(module_idP,CC_idP, - RA_template->rnti, - (frameP*10)+subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - - // prepare frame for retransmission - if (RA_template->Msg4_subframe>1) RA_template->Msg4_frame++; - RA_template->Msg4_frame&=1023; - RA_template->Msg4_subframe=(RA_template->Msg4_subframe+8)%10; - - LOG_W(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n", - module_idP,CC_idP,frameP,subframeP,RA_template->rnti,round,RA_template->Msg4_frame,RA_template->Msg4_subframe); - - } // Msg4 frame/subframe - } // regular LTE case - } else { - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n",module_idP,CC_idP,frameP,subframeP); - RA_template->wait_ack_Msg4=0; - RA_template->RA_active=FALSE; - UE_id = find_UE_id(module_idP,RA_template->rnti); - DevAssert( UE_id != -1 ); - eNB->UE_list.UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured=TRUE; - } -} +} -void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP) +void +schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - int CC_id; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - RA_TEMPLATE *RA_template; - uint8_t i; - - start_meas(&eNB->schedule_ra); + int CC_id; + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + RA_t *ra; + uint8_t i; + start_meas(&mac->schedule_ra); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - // skip UL component carriers if TDD - if (is_UL_sf(&cc[CC_id],subframeP)==1) continue; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + // skip UL component carriers if TDD + if (is_UL_sf(&cc[CC_id], subframeP) == 1) + continue; - for (i=0; i<NB_RA_PROC_MAX; i++) { - RA_template = (RA_TEMPLATE *)&cc[CC_id].RA_template[i]; + for (i = 0; i < NB_RA_PROC_MAX; i++) { - if (RA_template->RA_active == TRUE) { + ra = (RA_t *) & cc[CC_id].ra[i]; - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA %d is active (generate RAR %d[SFN/SF:%d%d], generate_Msg4 %d[SFN/SF:%d%d], wait_ack_Msg4 %d, rnti %x)\n", - module_idP,frameP,subframeP,CC_id,i,RA_template->generate_rar,RA_template->Msg2_frame,RA_template->Msg2_subframe,RA_template->generate_Msg4,RA_template->Msg4_frame,RA_template->Msg4_subframe,RA_template->wait_ack_Msg4, RA_template->rnti); + //LOG_D(MAC,"RA[state:%d]\n",ra->state); - if (RA_template->generate_rar == 1) generate_Msg2(module_idP,CC_id,frameP,subframeP,RA_template); - else if (RA_template->generate_Msg4 == 1) generate_Msg4(module_idP,CC_id,frameP,subframeP,RA_template); - else if (RA_template->wait_ack_Msg4==1) check_Msg4_retransmission(module_idP,CC_id,frameP,subframeP,RA_template); + if (ra->state == MSG2) + generate_Msg2(module_idP, CC_id, frameP, subframeP, ra); + else if (ra->state == MSG4) + generate_Msg4(module_idP, CC_id, frameP, subframeP, ra); + else if (ra->state == WAITMSG4ACK) + check_Msg4_retransmission(module_idP, CC_id, frameP, + subframeP, ra); + } // for i=0 .. N_RA_PROC-1 + } // CC_id - } // RA_active == TRUE - } // for i=0 .. N_RA_PROC-1 - } // CC_id - - stop_meas(&eNB->schedule_ra); + stop_meas(&mac->schedule_ra); } // handles the event of MSG1 reception -void initiate_ra_proc(module_id_t module_idP, - int CC_id, - frame_t frameP, - sub_frame_t subframeP, - uint16_t preamble_index, - int16_t timing_offset, - uint16_t ra_rnti +void +initiate_ra_proc(module_id_t module_idP, + int CC_id, + frame_t frameP, + sub_frame_t subframeP, + uint16_t preamble_index, + int16_t timing_offset, uint16_t ra_rnti #ifdef Rel14 - , - uint8_t rach_resource_type + , uint8_t rach_resource_type #endif - ) + ) { - uint8_t i; + uint8_t i; - COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; - RA_TEMPLATE *RA_template = &cc->RA_template[0]; + COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; + RA_t *ra = &cc->ra[0]; - struct PRACH_ConfigSIB_v1310 *ext4_prach = NULL; - PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; + struct PRACH_ConfigSIB_v1310 *ext4_prach = NULL; + PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; - if (cc->radioResourceConfigCommon_BR && cc->radioResourceConfigCommon_BR->ext4) { - ext4_prach=cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - prach_ParametersListCE_r13= &ext4_prach->prach_ParametersListCE_r13; - } - LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,subframeP,preamble_index); + if (cc->radioResourceConfigCommon_BR + && cc->radioResourceConfigCommon_BR->ext4) { + ext4_prach = + cc->radioResourceConfigCommon_BR->ext4-> + prach_ConfigCommon_v1310; + prach_ParametersListCE_r13 = + &ext4_prach->prach_ParametersListCE_r13; + } + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n", + module_idP, CC_id, frameP, subframeP, preamble_index); #ifdef Rel14 - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n",module_idP,CC_id,frameP,subframeP,rach_resource_type); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n", + module_idP, CC_id, frameP, subframeP, rach_resource_type); #endif - if (prach_ParametersListCE_r13 && - prach_ParametersListCE_r13->list.count<rach_resource_type) { - LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Received impossible PRACH resource type %d, only %d CE levels configured\n", - module_idP,CC_id, - rach_resource_type, - (int)prach_ParametersListCE_r13->list.count); - return; - } + uint16_t msg2_frame = frameP; + uint16_t msg2_subframe = subframeP; + int offset; + + if (prach_ParametersListCE_r13 && + prach_ParametersListCE_r13->list.count < rach_resource_type) { + LOG_E(MAC, + "[eNB %d][RAPROC] CC_id %d Received impossible PRACH resource type %d, only %d CE levels configured\n", + module_idP, CC_id, rach_resource_type, + (int) prach_ParametersListCE_r13->list.count); + return; + } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC,1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC,0); - - for (i=0; i<NB_RA_PROC_MAX; i++) { - if (RA_template[i].RA_active==FALSE && - RA_template[i].wait_ack_Msg4 == 0) { - int loop = 0; - uint16_t msg2_frame = frameP; - uint16_t msg2_subframe = subframeP; - int offset; - RA_template[i].RA_active = TRUE; - RA_template[i].generate_rar = 1; - RA_template[i].generate_Msg4 = 0; - RA_template[i].wait_ack_Msg4 = 0; - RA_template[i].timing_offset = timing_offset; - RA_template[i].preamble_subframe = subframeP; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); + + for (i = 0; i < NB_RA_PROC_MAX; i++) { + if (ra[i].state == IDLE) { + int loop = 0; + LOG_D(MAC, "Frame %d, Subframe %d: Activating RA process %d\n", + frameP, subframeP, i); + ra[i].state = MSG2; + ra[i].timing_offset = timing_offset; + ra[i].preamble_subframe = subframeP; #ifdef Rel14 - RA_template[i].rach_resource_type = rach_resource_type; - RA_template[i].msg2_mpdcch_repetition_cnt = 0; - RA_template[i].msg4_mpdcch_repetition_cnt = 0; + ra[i].rach_resource_type = rach_resource_type; + ra[i].msg2_mpdcch_repetition_cnt = 0; + ra[i].msg4_mpdcch_repetition_cnt = 0; #endif - // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes - if (nfapi_mode) - offset = 7; - else - offset = 5; - - add_subframe(&msg2_frame, &msg2_subframe, offset); - - RA_template[i].Msg2_frame = msg2_frame; - RA_template[i].Msg2_subframe = msg2_subframe; - - LOG_E(MAC,"%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__,RA_template[i].Msg2_frame,RA_template[i].Msg2_subframe,frameP,subframeP,offset); - - /* TODO: find better procedure to allocate RNTI */ - do { - RA_template[i].rnti = taus(); - loop++; - } while (loop != 100 && - /* TODO: this is not correct, the rnti may be in use without - * being in the MAC yet. To be refined. - */ - !(find_UE_id(module_idP, RA_template[i].rnti) == -1 && - /* 1024 and 60000 arbirarily chosen, not coming from standard */ - RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000)); - if (loop == 100) { printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); } - RA_template[i].RA_rnti = ra_rnti; - RA_template[i].preamble_index = preamble_index; - - LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Subframe %d: Activating RAR generation (Msg2) in Frame %d, subframe %d for process %d, rnti %x, RA_active %d\n", - module_idP,CC_id,frameP,subframeP, - RA_template[i].Msg2_frame, - RA_template[i].Msg2_subframe, - i,RA_template[i].rnti, - RA_template[i].RA_active); - - return; + // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes + if (nfapi_mode) + offset = 7; + else + offset = 5; + + add_subframe(&msg2_frame, &msg2_subframe, offset); + + ra[i].Msg2_frame = msg2_frame; + ra[i].Msg2_subframe = msg2_subframe; + + LOG_D(MAC,"%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__,ra[i].Msg2_frame,ra[i].Msg2_subframe,frameP,subframeP,offset); + + ra[i].Msg2_subframe = (subframeP + offset) % 10; + /* TODO: find better procedure to allocate RNTI */ + do { +#if defined(USRP_REC_PLAY) // deterministic rnti in usrp record/playback mode + static int drnti[NUMBER_OF_UE_MAX] = { 0xbda7, 0x71da, 0x9c40, 0xc350, 0x2710, 0x4e20, 0x7530, 0x1388, 0x3a98, 0x61a8, 0x88b8, 0xafc8, 0xd6d8, 0x1b58, 0x4268, 0x6978 }; + int j = 0; + int nb_ue = 0; + for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + if (UE_RNTI(module_idP, j) > 0) { + nb_ue++; + } else { + break; + } + } + if (nb_ue >= NUMBER_OF_UE_MAX) { + printf("No more free RNTI available, increase NUMBER_OF_UE_MAX\n"); + abort(); + } + ra[i].rnti = drnti[nb_ue]; +#else + ra[i].rnti = taus(); +#endif + loop++; + } + while (loop != 100 && + /* TODO: this is not correct, the rnti may be in use without + * being in the MAC yet. To be refined. + */ + !(find_UE_id(module_idP, ra[i].rnti) == -1 && + /* 1024 and 60000 arbirarily chosen, not coming from standard */ + ra[i].rnti >= 1024 && ra[i].rnti < 60000)); + if (loop == 100) { + printf("%s:%d:%s: FATAL ERROR! contact the authors\n", + __FILE__, __LINE__, __FUNCTION__); + abort(); + } + ra[i].RA_rnti = ra_rnti; + ra[i].preamble_index = preamble_index; + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation in Frame %d, subframe %d for process %d, rnti %x, state %d\n", + module_idP, CC_id, frameP, ra[i].Msg2_frame, + ra[i].Msg2_subframe, i, ra[i].rnti, ra[i].state); + + return; + } } - } - LOG_E(MAC,"[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,preamble_index); + LOG_E(MAC, + "[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n", + module_idP, CC_id, frameP, preamble_index); } -void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, rnti_t rnti) +void +cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, + rnti_t rnti) { - unsigned char i; - RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&RC.mac[module_idP]->common_channels[CC_id].RA_template[0]; - - MSC_LOG_EVENT(MSC_PHY_ENB, "RA Cancelling procedure ue %"PRIx16" ", rnti); - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Cancelling RA procedure for UE rnti %x\n",module_idP,CC_id,frameP,rnti); - - for (i=0; i<NB_RA_PROC_MAX; i++) { - if (rnti == RA_template[i].rnti) { - RA_template[i].RA_active=FALSE; - RA_template[i].generate_rar=0; - RA_template[i].generate_Msg4=0; - RA_template[i].wait_ack_Msg4=0; - RA_template[i].timing_offset=0; - RA_template[i].RRC_timer=20; - RA_template[i].rnti = 0; - RA_template[i].msg3_round = 0; + unsigned char i; + RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0]; + + MSC_LOG_EVENT(MSC_PHY_ENB, "RA Cancelling procedure ue %" PRIx16 " ", + rnti); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d Cancelling RA procedure for UE rnti %x\n", + module_idP, CC_id, frameP, rnti); + + for (i = 0; i < NB_RA_PROC_MAX; i++) { + if (rnti == ra[i].rnti) { + ra[i].state = IDLE; + ra[i].timing_offset = 0; + ra[i].RRC_timer = 20; + ra[i].rnti = 0; + ra[i].msg3_round = 0; + } } - } } - diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index 119df4e8339367117048e78dd2d0cd7ee350a2d0..7ab2ee855c8fce2b23875f9195bb4ebc24368014 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -52,7 +52,7 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif #define ENABLE_MAC_PAYLOAD_DEBUG @@ -65,777 +65,843 @@ #ifdef Rel14 #define size_Sj25 2 -int Sj25[size_Sj25]={0,3}; +int Sj25[size_Sj25] = { 0, 3 }; + #define size_Sj50 6 -int Sj50[size_Sj50]={0,1,2,5,6,7}; +int Sj50[size_Sj50] = { 0, 1, 2, 5, 6, 7 }; + #define size_Sj75 10 -int Sj75[size_Sj75]={0,1,2,3,4,7,8,9,10,11}; +int Sj75[size_Sj75] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 11 }; + #define size_Sj100 14 -int Sj100[size_Sj100]={0,1,2,3,4,5,6,9,10,11,12,13,14,15}; +int Sj100[size_Sj100] = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15 }; -int SIB1_BR_TBS_table[6] = {208,256,328,504,712,936}; +int SIB1_BR_TBS_table[6] = { 208, 256, 328, 504, 712, 936 }; //------------------------------------------------------------------------------ void -schedule_SIB1_BR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP) - +schedule_SIB1_BR(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP) //------------------------------------------------------------------------------ { + int8_t bcch_sdu_length; + int CC_id; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc; + uint8_t *vrb_map; + int first_rb = -1; + int N_RB_DL; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + nfapi_tx_request_pdu_t *TX_req; + nfapi_dl_config_request_body_t *dl_req; + int m, i, N_S_NB; + int *Sj; + int n_NB = 0; + int TBS; + int k = 0, rvidx; + uint16_t sfn_sf = frameP<<4|subframeP; + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + + cc = &eNB->common_channels[CC_id]; + vrb_map = (void *) &cc->vrb_map; + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + + int foffset = cc->physCellId & 1; + int sfoffset = (cc->tdd_Config == NULL) ? 0 : 1; + + // Time-domain scheduling + if (cc->mib->message.schedulingInfoSIB1_BR_r13 == 0) + continue; + else + switch ((cc->mib->message.schedulingInfoSIB1_BR_r13 - 1) % 3) { + case 0: // repetition 4 + k = (frameP >> 1) & 3; + if ((subframeP != (4 + sfoffset)) + || ((frameP & 1) != foffset)) + continue; + break; + case 1: // repetition 8 + k = frameP & 3; + AssertFatal(N_RB_DL > 15, + "SIB1-BR repetition 8 not allowed for N_RB_DL= %d\n", + N_RB_DL); + if ((foffset == 0) && (subframeP != (4 + sfoffset))) + continue; + else if ((foffset == 1) + && (subframeP != ((9 + sfoffset) % 10))) + continue; + break; + case 2: // repetition 16 + k = ((10 * frameP) + subframeP) & 3; + AssertFatal(N_RB_DL > 15, + "SIB1-BR repetition 16 not allowed for N_RB_DL= %d\n", + N_RB_DL); + if ((sfoffset == 1) + && ((subframeP != 0) || (subframeP != 5))) + continue; + else if ((sfoffset == 0) && (foffset == 0) + && (subframeP != 4) && (subframeP != 9)) + continue; + else if ((sfoffset == 0) && (foffset == 1) + && (subframeP != 0) && (subframeP != 9)) + continue; + break; + } + // if we get here we have to schedule SIB1_BR in this frame/subframe - int8_t bcch_sdu_length; - int CC_id; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc; - uint8_t *vrb_map; - int first_rb = -1; - int N_RB_DL; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - nfapi_tx_request_pdu_t *TX_req; - nfapi_dl_config_request_body_t *dl_req; - int m,i,N_S_NB; - int *Sj; - int n_NB = 0; - int TBS; - int k=0,rvidx; - uint16_t sfn_sf = frameP << 4 | subframeP; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - cc = &eNB->common_channels[CC_id]; - vrb_map = (void*)&cc->vrb_map; - N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); - dl_req = &eNB->DL_req[CC_id].dl_config_request_body; - - int foffset = cc->physCellId&1; - int sfoffset = (cc->tdd_Config==NULL) ? 0 : 1; - - // Time-domain scheduling - if (cc->mib->message.schedulingInfoSIB1_BR_r13==0) continue; - else - switch ((cc->mib->message.schedulingInfoSIB1_BR_r13-1)%3) { - case 0: // repetition 4 - k = (frameP>>1)&3; - if ((subframeP!=(4+sfoffset)) || ((frameP&1)!=foffset)) continue; - break; - case 1: // repetition 8 - k = frameP&3; - AssertFatal(N_RB_DL>15,"SIB1-BR repetition 8 not allowed for N_RB_DL= %d\n",N_RB_DL); - if ((foffset==0) && (subframeP!=(4+sfoffset))) continue; - else if ((foffset==1) && (subframeP!=((9+sfoffset)%10))) continue; - break; - case 2: // repetition 16 - k = ((10*frameP) + subframeP)&3; - AssertFatal(N_RB_DL>15,"SIB1-BR repetition 16 not allowed for N_RB_DL= %d\n",N_RB_DL); - if ((sfoffset == 1) && ((subframeP!=0)||(subframeP!=5))) continue; - else if ((sfoffset == 0) && (foffset==0) && (subframeP!=4) && (subframeP!=9)) continue; - else if ((sfoffset == 0) && (foffset==1) && (subframeP!=0) && (subframeP!=9)) continue; - break; - } - // if we get here we have to schedule SIB1_BR in this frame/subframe - - // keep counter of SIB1_BR repetitions in 8 frame period to choose narrowband on which to transmit - if ((frameP&7) == 0) cc->SIB1_BR_cnt=0; - else cc->SIB1_BR_cnt++; - - // Frequency-domain scheduling - switch (N_RB_DL) { - case 6: - case 15: - default: - m=1; - n_NB=0; - N_S_NB=0; - Sj=NULL; - break; - case 25: - m=2; - N_S_NB = 2; - Sj = Sj25; - break; - case 50: - m=2; - N_S_NB = 6; - Sj = Sj50; - break; - case 75: - m=4; - N_S_NB = 10; - Sj = Sj75; - break; - case 100: - m=4; - N_S_NB = 14; - Sj = Sj100; - break; - } - // Note: definition of k above and rvidx from 36.321 section 5.3.1 - rvidx = (((3*k)>>1) + (k&1))&3; - - i = cc->SIB1_BR_cnt & (m-1); - - n_NB = Sj[((cc->physCellId % N_S_NB) + (i*N_S_NB/m))%N_S_NB]; - - - bcch_sdu_length = mac_rrc_data_req(module_idP, - CC_id, - frameP, - BCCH_SIB1_BR,1, - &cc->BCCH_BR_pdu[0].payload[0], - 1, - module_idP, - 0); // not used in this case - - AssertFatal(cc->mib->message.schedulingInfoSIB1_BR_r13<19,"schedulingInfoSIB1_BR_r13 %d > 18\n", - (int)cc->mib->message.schedulingInfoSIB1_BR_r13); - - AssertFatal(bcch_sdu_length>0,"RRC returned 0 bytes for SIB1-BR\n"); - - TBS = SIB1_BR_TBS_table[(cc->mib->message.schedulingInfoSIB1_BR_r13-1)/3]>>3; - - AssertFatal(bcch_sdu_length <= TBS, "length returned by RRC %d is not compatible with the TBS %d from MIB\n",bcch_sdu_length,TBS); - - if ((frameP&1023) < 200) LOG_D(MAC,"[eNB %d] Frame %d Subframe %d: SIB1_BR->DLSCH CC_id %d, Received %d bytes, scheduling on NB %d (i %d,m %d,N_S_NB %d) rvidx %d\n",module_idP,frameP,subframeP,CC_id,bcch_sdu_length,n_NB,i,m,N_S_NB,rvidx); - - // allocate all 6 PRBs in narrowband for SIB1_BR - - first_rb = narrowband_to_first_rb(cc,n_NB); - - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - vrb_map[first_rb+4] = 1; - vrb_map[first_rb+5] = 1; - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = TBS; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFF; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,6); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = rvidx; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // Rel10 fields - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; - // Rel13 fields - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 1; // CEModeA UE - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 0; // SIB1-BR - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; // absolute SF - - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - // Program TX Request - TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = bcch_sdu_length; - TX_req->pdu_index = eNB->pdu_index[CC_id]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = bcch_sdu_length; - TX_req->segments[0].segment_data = cc->BCCH_BR_pdu[0].payload; - eNB->TX_req[CC_id].sfn_sf = sfn_sf; - eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; - eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - - if (frameP%100==0) LOG_E(MAC,"%s() TX_REQ: sfn_sf:%u pdus:%u pdu_length:%u pdu_index:%u segments:%u segment_length:%u\n", - __FUNCTION__, eNB->TX_req[CC_id].sfn_sf, eNB->TX_req[CC_id].tx_request_body.number_of_pdus, - TX_req->pdu_length, TX_req->pdu_index, TX_req->num_segments, TX_req->segments[0].segment_length); - - - if (opt_enabled == 1) { - trace_pdu(1, - &cc->BCCH_BR_pdu[0].payload[0], - bcch_sdu_length, - 0xffff, - 4, - 0xffff, - eNB->frame, - eNB->subframe, - 0, - 0); - LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, 0xffff, bcch_sdu_length); - } - if (cc->tdd_Config!=NULL) { //TDD - LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH-BR 0->DLSCH (TDD) for CC_id %d SIB1-BR %d bytes\n", - frameP, - CC_id, - bcch_sdu_length); - } else { - LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH-BR 0->DLSCH (FDD) for CC_id %d SIB1-BR %d bytes\n", - frameP, - CC_id, - bcch_sdu_length); - } + // keep counter of SIB1_BR repetitions in 8 frame period to choose narrowband on which to transmit + if ((frameP & 7) == 0) + cc->SIB1_BR_cnt = 0; + else + cc->SIB1_BR_cnt++; + + // Frequency-domain scheduling + switch (N_RB_DL) { + case 6: + case 15: + default: + m = 1; + n_NB = 0; + N_S_NB = 0; + Sj = NULL; + break; + case 25: + m = 2; + N_S_NB = 2; + Sj = Sj25; + break; + case 50: + m = 2; + N_S_NB = 6; + Sj = Sj50; + break; + case 75: + m = 4; + N_S_NB = 10; + Sj = Sj75; + break; + case 100: + m = 4; + N_S_NB = 14; + Sj = Sj100; + break; + } + // Note: definition of k above and rvidx from 36.321 section 5.3.1 + rvidx = (((3 * k) >> 1) + (k & 1)) & 3; + + i = cc->SIB1_BR_cnt & (m - 1); + + n_NB = Sj[((cc->physCellId % N_S_NB) + (i * N_S_NB / m)) % N_S_NB]; - } - return; + bcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, BCCH_SIB1_BR, 1, &cc->BCCH_BR_pdu[0].payload[0], 0); // not used in this case + + AssertFatal(cc->mib->message.schedulingInfoSIB1_BR_r13 < 19, + "schedulingInfoSIB1_BR_r13 %d > 18\n", + (int) cc->mib->message.schedulingInfoSIB1_BR_r13); + + AssertFatal(bcch_sdu_length > 0, + "RRC returned 0 bytes for SIB1-BR\n"); + + TBS = + SIB1_BR_TBS_table[(cc->mib->message.schedulingInfoSIB1_BR_r13 - + 1) / 3] >> 3; + + AssertFatal(bcch_sdu_length <= TBS, + "length returned by RRC %d is not compatible with the TBS %d from MIB\n", + bcch_sdu_length, TBS); + + if ((frameP & 1023) < 200) + LOG_D(MAC, + "[eNB %d] Frame %d Subframe %d: SIB1_BR->DLSCH CC_id %d, Received %d bytes, scheduling on NB %d (i %d,m %d,N_S_NB %d) rvidx %d\n", + module_idP, frameP, subframeP, CC_id, bcch_sdu_length, + n_NB, i, m, N_S_NB, rvidx); + + // allocate all 6 PRBs in narrowband for SIB1_BR + + first_rb = narrowband_to_first_rb(cc, n_NB); + + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + vrb_map[first_rb + 4] = 1; + vrb_map[first_rb + 5] = 1; + + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = TBS; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = + eNB->pdu_index[CC_id]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFF; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = + getRIV(N_RB_DL, first_rb, 6); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = rvidx; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = + (cc->p_eNB == 1) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = + 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = + (cc->p_eNB == 1) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // Rel10 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; + // Rel13 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 1; // CEModeA UE + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 0; // SIB1-BR + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; // absolute SFx + + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + // Program TX Request + TX_req = + &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB-> + TX_req + [CC_id].tx_request_body.number_of_pdus]; + TX_req->pdu_length = bcch_sdu_length; + TX_req->pdu_index = eNB->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = bcch_sdu_length; + TX_req->segments[0].segment_data = cc->BCCH_BR_pdu[0].payload; + eNB->TX_req[CC_id].sfn_sf = sfn_sf; + eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; + eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; + + if (opt_enabled == 1) { + trace_pdu(1, + &cc->BCCH_BR_pdu[0].payload[0], + bcch_sdu_length, + 0xffff, 4, 0xffff, eNB->frame, eNB->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, bcch_sdu_length); + } + if (cc->tdd_Config != NULL) { //TDD + LOG_D(MAC, + "[eNB] Frame %d : Scheduling BCCH-BR 0->DLSCH (TDD) for CC_id %d SIB1-BR %d bytes\n", + frameP, CC_id, bcch_sdu_length); + } else { + LOG_D(MAC, + "[eNB] Frame %d : Scheduling BCCH-BR 0->DLSCH (FDD) for CC_id %d SIB1-BR %d bytes\n", + frameP, CC_id, bcch_sdu_length); + } + } } -int si_WindowLength_BR_r13tab[SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_spare] = - {20,40,60,80,120,160,200}; -int si_TBS_r13tab[SchedulingInfo_BR_r13__si_TBS_r13_b936+1] = {152,208,256,328,408,504,600,712,808,936}; +int si_WindowLength_BR_r13tab + [SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_spare] += { 20, 40, 60, 80, 120, 160, 200 }; +int si_TBS_r13tab[SchedulingInfo_BR_r13__si_TBS_r13_b936 + 1] = + { 152, 208, 256, 328, 408, 504, 600, 712, 808, 936 }; //------------------------------------------------------------------------------ void -schedule_SI_BR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP) - +schedule_SI_BR(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP) //------------------------------------------------------------------------------ +{ + int8_t bcch_sdu_length; + int CC_id; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc; + uint8_t *vrb_map; + int first_rb = -1; + int N_RB_DL; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + nfapi_tx_request_pdu_t *TX_req; + nfapi_dl_config_request_body_t *dl_req; + int i; + int rvidx; + int absSF = (frameP * 10) + subframeP; + uint16_t sfn_sf = frameP << 4 | subframeP; + + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + + cc = &eNB->common_channels[CC_id]; + vrb_map = (void *) &cc->vrb_map; + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + + // Time-domain scheduling + if (cc->mib->message.schedulingInfoSIB1_BR_r13 == 0) + continue; + else { + AssertFatal(cc-> + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 + != NULL, + "sib_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n"); + + SchedulingInfoList_BR_r13_t *schedulingInfoList_BR_r13 = + cc->sib1_v13ext-> + bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13; + AssertFatal(schedulingInfoList_BR_r13 != NULL, + "sib_v13ext->schedulingInfoList_BR_r13 is null\n"); + + SchedulingInfoList_t *schedulingInfoList = + cc->schedulingInfoList; + AssertFatal(schedulingInfoList_BR_r13->list.count == + schedulingInfoList->list.count, + "schedulingInfolist_BR.r13->list.count %d != schedulingInfoList.list.count %d\n", + schedulingInfoList_BR_r13->list.count, + schedulingInfoList->list.count); + + AssertFatal(cc-> + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13 + <= + SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200, + "si_WindowLength_BR_r13 %d > %d\n", + (int) cc-> + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13, + SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200); + + // check that SI frequency-hopping is disabled + AssertFatal(cc-> + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_HoppingConfigCommon_r13 + == + SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_HoppingConfigCommon_r13_off, + "Deactivate SI_HoppingConfigCommon_r13 in configuration file, not supported for now\n"); + long si_WindowLength_BR_r13 = + si_WindowLength_BR_r13tab[cc-> + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13]; + + long si_RepetitionPattern_r13 = + cc->sib1_v13ext-> + bandwidthReducedAccessRelatedInfo_r13->si_RepetitionPattern_r13; + AssertFatal(si_RepetitionPattern_r13 <= + SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF, + "si_RepetitionPattern_r13 %d > %d\n", + (int) si_RepetitionPattern_r13, + SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF); + // cycle through SIB list + + for (i = 0; i < schedulingInfoList_BR_r13->list.count; i++) { + long si_Periodicity = + schedulingInfoList->list.array[i]->si_Periodicity; + long si_Narrowband_r13 = + schedulingInfoList_BR_r13->list.array[i]-> + si_Narrowband_r13; + long si_TBS_r13 = + si_TBS_r13tab[schedulingInfoList_BR_r13-> + list.array[i]->si_TBS_r13]; + + // check if the SI is to be scheduled now + int period_in_sf = 80 << si_Periodicity; // 2^i * 80 subframes, note: si_Periodicity is 2^i * 80ms + int sf_mod_period = absSF % period_in_sf; + int k = sf_mod_period & 3; + // Note: definition of k and rvidx from 36.321 section 5.3.1 + rvidx = (((3 * k) >> 1) + (k & 1)) & 3; + + if ((sf_mod_period < si_WindowLength_BR_r13) + && ((frameP & (((1 << si_RepetitionPattern_r13) - 1))) == 0)) { // this SIB is to be scheduled + + bcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, BCCH_SI_BR + i, 1, &cc->BCCH_BR_pdu[i + 1].payload[0], 0); // not used in this case + + AssertFatal(bcch_sdu_length > 0, + "RRC returned 0 bytes for SI-BR %d\n", i); + + if (bcch_sdu_length > 0) { + AssertFatal(bcch_sdu_length <= (si_TBS_r13 >> 3), + "RRC provided bcch with length %d > %d (si_TBS_r13 %d)\n", + bcch_sdu_length, + (int) (si_TBS_r13 >> 3), + (int) schedulingInfoList_BR_r13-> + list.array[i]->si_TBS_r13); + + // allocate all 6 PRBs in narrowband for SIB1_BR + + // check that SIB1 didn't take this narrowband + if (vrb_map[first_rb] > 0) + continue; + + first_rb = + narrowband_to_first_rb(cc, + si_Narrowband_r13 - 1); + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 4] = 1; + vrb_map[first_rb + 5] = 1; + + if ((frameP & 1023) < 200) + LOG_D(MAC, + "[eNB %d] Frame %d Subframe %d: SI_BR->DLSCH CC_id %d, Narrowband %d rvidx %d (sf_mod_period %d : si_WindowLength_BR_r13 %d : si_RepetitionPattern_r13 %d) bcch_sdu_length %d\n", + module_idP, frameP, subframeP, CC_id, + (int) si_Narrowband_r13 - 1, rvidx, + sf_mod_period, + (int) si_WindowLength_BR_r13, + (int) si_RepetitionPattern_r13, + bcch_sdu_length); + + + + + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req-> + number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = + NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = + si_TBS_r13 >> 3; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = + eNB->pdu_index[CC_id]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = + 0xFFFF; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.resource_block_coding = + getRIV(N_RB_DL, first_rb, 6); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.redundancy_version = rvidx; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transport_block_to_codeword_swap_flag + = 0; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transmission_scheme = + (cc->p_eNB == 1) ? 0 : 1; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.number_of_layers = 1; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transmission_mode = + (cc->p_eNB == 1) ? 1 : 2; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + num_bf_vector = 1; + // Rel10 fields (for PDSCH starting symbol) + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10. + pdsch_start = + cc[CC_id]. + sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; + // Rel13 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 1; // CEModeA UE + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 1; // SI-BR + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel13.initial_transmission_sf_io = + absSF - sf_mod_period; + + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + // Program TX Request + TX_req = + &eNB->TX_req[CC_id]. + tx_request_body.tx_pdu_list[eNB->TX_req[CC_id]. + tx_request_body.number_of_pdus]; + TX_req->pdu_length = bcch_sdu_length; + TX_req->pdu_index = eNB->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = + bcch_sdu_length; + TX_req->segments[0].segment_data = + cc->BCCH_BR_pdu[i + 1].payload; + eNB->TX_req[CC_id].tx_request_body. + number_of_pdus++; + eNB->TX_req[CC_id].sfn_sf = sfn_sf; + eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; + + if (opt_enabled == 1) { + trace_pdu(1, + &cc->BCCH_BR_pdu[i + 1].payload[0], + bcch_sdu_length, + 0xffff, + 4, + 0xffff, eNB->frame, eNB->subframe, 0, + 0); + LOG_D(OPT, + "[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, + bcch_sdu_length); + } + if (cc->tdd_Config != NULL) { //TDD + LOG_D(MAC, + "[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (TDD) for CC_id %d SI-BR %d bytes\n", + frameP, i, CC_id, bcch_sdu_length); + } else { + LOG_D(MAC, + "[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (FDD) for CC_id %d SI-BR %d bytes\n", + frameP, i, CC_id, bcch_sdu_length); + } + } + } // scheduling in current frame/subframe + } //for SI List + } // eMTC is activated + } // CC_id + return; +} +#endif + +void +schedule_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - int8_t bcch_sdu_length; - int CC_id; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc; - uint8_t *vrb_map; - int first_rb = -1; - int N_RB_DL; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - nfapi_tx_request_pdu_t *TX_req; - nfapi_dl_config_request_body_t *dl_req; - int i; - int rvidx; - int absSF = (frameP*10)+subframeP; - uint16_t sfn_sf = frameP << 4 | subframeP; - - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - cc = &eNB->common_channels[CC_id]; - vrb_map = (void*)&cc->vrb_map; - N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); - dl_req = &eNB->DL_req[CC_id].dl_config_request_body; - - // Time-domain scheduling - if (cc->mib->message.schedulingInfoSIB1_BR_r13==0) continue; - else { - - - AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13!=NULL, - "sib_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n"); - - SchedulingInfoList_BR_r13_t *schedulingInfoList_BR_r13 = cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13; - AssertFatal(schedulingInfoList_BR_r13!=NULL, - "sib_v13ext->schedulingInfoList_BR_r13 is null\n"); - - SchedulingInfoList_t *schedulingInfoList = cc->schedulingInfoList; - AssertFatal(schedulingInfoList_BR_r13->list.count==schedulingInfoList->list.count, - "schedulingInfolist_BR.r13->list.count %d != schedulingInfoList.list.count %d\n", - schedulingInfoList_BR_r13->list.count,schedulingInfoList->list.count); - - AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13<=SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200, - "si_WindowLength_BR_r13 %d > %d\n", - (int)cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13, - SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200); - - // check that SI frequency-hopping is disabled - AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_HoppingConfigCommon_r13==SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_HoppingConfigCommon_r13_off, - "Deactivate SI_HoppingConfigCommon_r13 in configuration file, not supported for now\n"); - long si_WindowLength_BR_r13 = si_WindowLength_BR_r13tab[cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13]; - - long si_RepetitionPattern_r13 = cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_RepetitionPattern_r13; - AssertFatal(si_RepetitionPattern_r13<=SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF, - "si_RepetitionPattern_r13 %d > %d\n", - (int)si_RepetitionPattern_r13, - SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF); - // cycle through SIB list - - for (i=0;i<schedulingInfoList_BR_r13->list.count;i++) { - long si_Periodicity = schedulingInfoList->list.array[i]->si_Periodicity; - long si_Narrowband_r13 = schedulingInfoList_BR_r13->list.array[i]->si_Narrowband_r13; - long si_TBS_r13 = si_TBS_r13tab[schedulingInfoList_BR_r13->list.array[i]->si_TBS_r13]; - - // check if the SI is to be scheduled now - int period_in_sf = 80<<si_Periodicity; // 2^i * 80 subframes, note: si_Periodicity is 2^i * 80ms - int sf_mod_period = absSF%period_in_sf; - int k = sf_mod_period&3; - // Note: definition of k and rvidx from 36.321 section 5.3.1 - rvidx = (((3*k)>>1) + (k&1))&3; - - if ((sf_mod_period < si_WindowLength_BR_r13) && - ((frameP&(((1<<si_RepetitionPattern_r13)-1)))==0)) { // this SIB is to be scheduled - - bcch_sdu_length = mac_rrc_data_req(module_idP, - CC_id, - frameP, - BCCH_SI_BR+i,1, - &cc->BCCH_BR_pdu[i+1].payload[0], - 1, - module_idP, - 0); // not used in this case - - AssertFatal(bcch_sdu_length>0,"RRC returned 0 bytes for SI-BR %d\n",i); - - if (bcch_sdu_length > 0) { - AssertFatal(bcch_sdu_length <= (si_TBS_r13>>3), - "RRC provided bcch with length %d > %d (si_TBS_r13 %d)\n", - bcch_sdu_length,(int)(si_TBS_r13>>3),(int)schedulingInfoList_BR_r13->list.array[i]->si_TBS_r13); - - // allocate all 6 PRBs in narrowband for SIB1_BR - - // check that SIB1 didn't take this narrowband - if (vrb_map[first_rb] > 0) continue; - - first_rb = narrowband_to_first_rb(cc,si_Narrowband_r13-1); - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+4] = 1; - vrb_map[first_rb+5] = 1; - - if ((frameP&1023) < 200) LOG_D(MAC,"[eNB %d] Frame %d Subframe %d: SI_BR->DLSCH CC_id %d, Narrowband %ld rvidx %d (sf_mod_period %d : si_WindowLength_BR_r13 %ld : si_RepetitionPattern_r13 %ld) bcch_sdu_length %d\n", - module_idP,frameP,subframeP,CC_id,si_Narrowband_r13-1,rvidx, - sf_mod_period,si_WindowLength_BR_r13,si_RepetitionPattern_r13, - bcch_sdu_length); - - - - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = si_TBS_r13>>3; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFF; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,6); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = rvidx; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // Rel10 fields (for PDSCH starting symbol) - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; - // Rel13 fields - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 1; // CEModeA UE - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 1; // SI-BR - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = absSF - sf_mod_period; - - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - dl_req->number_pdu++; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + nfapi_tx_request_pdu_t *TX_req; + int mib_sdu_length; + int CC_id; + nfapi_dl_config_request_t *dl_config_request; + nfapi_dl_config_request_body_t *dl_req; + uint16_t sfn_sf = frameP << 4 | subframeP; + + AssertFatal(subframeP == 0, "Subframe must be 0\n"); + AssertFatal((frameP & 3) == 0, "Frame must be a multiple of 4\n"); + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + + dl_config_request = &eNB->DL_req[CC_id]; + dl_req = &dl_config_request->dl_config_request_body; + cc = &eNB->common_channels[CC_id]; + + mib_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0], 0); // not used in this case + + LOG_D(MAC, "Frame %d, subframe %d: BCH PDU length %d\n", frameP, subframeP, mib_sdu_length); + + if (mib_sdu_length > 0) { + + LOG_D(MAC, "Frame %d, subframe %d: Adding BCH PDU in position %d (length %d)\n", frameP, subframeP, dl_req->number_pdu, mib_sdu_length); + + if ((frameP & 1023) < 40) + LOG_D(MAC, + "[eNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes (cc->mib->message.schedulingInfoSIB1_BR_r13 %d)\n", + module_idP, frameP, CC_id, mib_sdu_length, + (int) cc->mib->message.schedulingInfoSIB1_BR_r13); + + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = + NFAPI_DL_CONFIG_BCH_PDU_TYPE, dl_config_pdu->pdu_size = + 2 + sizeof(nfapi_dl_config_bch_pdu); + dl_config_pdu->bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG; + dl_config_pdu->bch_pdu.bch_pdu_rel8.length = mib_sdu_length; + dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index = + eNB->pdu_index[CC_id]; + dl_config_pdu->bch_pdu.bch_pdu_rel8.transmission_power = 6000; dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - // Program TX Request - TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = bcch_sdu_length; - TX_req->pdu_index = eNB->pdu_index[CC_id]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = bcch_sdu_length; - TX_req->segments[0].segment_data = cc->BCCH_BR_pdu[i+1].payload; + dl_req->number_pdu++; + + dl_config_request->header.message_id = NFAPI_DL_CONFIG_REQUEST; + dl_config_request->sfn_sf = sfn_sf; + + LOG_D(MAC, "eNB->DL_req[0].number_pdu %d (%p)\n", dl_req->number_pdu, &dl_req->number_pdu); + // DL request + + TX_req = + &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req + [CC_id].tx_request_body.number_of_pdus]; + TX_req->pdu_length = 3; + TX_req->pdu_index = eNB->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = 3; + TX_req->segments[0].segment_data = cc[CC_id].MIB_pdu.payload; eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; eNB->TX_req[CC_id].sfn_sf = sfn_sf; eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - - if (frameP%100==0) LOG_E(MAC,"%s() TX_REQ: sfn_sf:%u pdus:%u pdu_length:%u pdu_index:%u segments:%u segment_length:%u\n", - __FUNCTION__, eNB->TX_req[CC_id].sfn_sf, eNB->TX_req[CC_id].tx_request_body.number_of_pdus, - TX_req->pdu_length, TX_req->pdu_index, TX_req->num_segments, TX_req->segments[0].segment_length); - - if (opt_enabled == 1) { - trace_pdu(1, - &cc->BCCH_BR_pdu[i+1].payload[0], - bcch_sdu_length, - 0xffff, - 4, - 0xffff, - eNB->frame, - eNB->subframe, - 0, - 0); - LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, 0xffff, bcch_sdu_length); - } - if (cc->tdd_Config!=NULL) { //TDD - LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (TDD) for CC_id %d SI-BR %d bytes\n", - frameP,i, - CC_id, - bcch_sdu_length); - } else { - LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (FDD) for CC_id %d SI-BR %d bytes\n", - frameP,i, - CC_id, - bcch_sdu_length); - } - } - } // scheduling in current frame/subframe - } //for SI List - } // eMTC is activated - } // CC_id - return; -} -#endif - -void schedule_mib(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP) { - - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc; - nfapi_dl_config_request_t *dl_config_request; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - nfapi_tx_request_pdu_t *TX_req; - int mib_sdu_length; - int CC_id; - nfapi_dl_config_request_body_t *dl_req; - uint16_t sfn_sf = frameP << 4 | subframeP; - -// DJP - commented out because I am going to try and send MIB every frame - //AssertFatal(subframeP==0,"Subframe must be 0\n"); - //AssertFatal((frameP&3)==0,"Frame must be a multiple of 4\n"); - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - dl_config_request = &eNB->DL_req[CC_id]; - dl_req = &dl_config_request->dl_config_request_body; - cc = &eNB->common_channels[CC_id]; - - mib_sdu_length = mac_rrc_data_req(module_idP, - CC_id, - frameP, - MIBCH,1, - &cc->MIB_pdu.payload[0], - 1, - module_idP, - 0); // not used in this case - - //LOG_D(MAC,"Frame %d, subframe %d: BCH PDU length %d\n", frameP,subframeP,mib_sdu_length); - - if (mib_sdu_length > 0) { - - //LOG_D(MAC,"Frame %d, subframe %d: Adding BCH PDU in position %d (length %d)\n", frameP,subframeP,dl_req->number_pdu,mib_sdu_length); - - if (0 && (frameP&1023) < 40) LOG_D(MAC,"[eNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes (cc->mib->message.schedulingInfoSIB1_BR_r13 %ld)\n",module_idP,frameP,CC_id,mib_sdu_length,cc->mib->message.schedulingInfoSIB1_BR_r13); - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_BCH_PDU_TYPE; - dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_bch_pdu); - dl_config_pdu->bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG; - dl_config_pdu->bch_pdu.bch_pdu_rel8.length = mib_sdu_length; - dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; - dl_config_pdu->bch_pdu.bch_pdu_rel8.transmission_power = 6000; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - dl_req->number_pdu++; - - dl_config_request->header.message_id = NFAPI_DL_CONFIG_REQUEST; - dl_config_request->sfn_sf = sfn_sf; - - //LOG_D(MAC,"eNB->DL_req[0].number_pdu %d (%p) sfn_sf:%d\n", dl_req->number_pdu,&dl_req->number_pdu, NFAPI_SFNSF2DEC(dl_config_request->sfn_sf)); - // DL request - - TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = 3; - TX_req->pdu_index = eNB->pdu_index[CC_id]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = mib_sdu_length; - TX_req->segments[0].segment_data = cc[CC_id].MIB_pdu.payload; - eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; - eNB->TX_req[CC_id].sfn_sf = sfn_sf; - eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - - if (0 && frameP%100==0) - LOG_D(MAC,"%s() TX_REQ: sfn_sf:%u pdus:%u pdu_length:%u pdu_index:%u segments:%u segment_length:%u\n", - __FUNCTION__, NFAPI_SFNSF2DEC(eNB->TX_req[CC_id].sfn_sf), eNB->TX_req[CC_id].tx_request_body.number_of_pdus, - TX_req->pdu_length, TX_req->pdu_index, TX_req->num_segments, TX_req->segments[0].segment_length); + } } - } } //------------------------------------------------------------------------------ void -schedule_SI( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP) - +schedule_SI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) //------------------------------------------------------------------------------ { - int8_t bcch_sdu_length; - int mcs = -1; - int CC_id; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc; - uint8_t *vrb_map; - int first_rb = -1; - int N_RB_DL; - nfapi_dl_config_request_t *dl_config_request; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - nfapi_tx_request_pdu_t *TX_req; - nfapi_dl_config_request_body_t *dl_req; - uint16_t sfn_sf = frameP << 4 | subframeP; - - start_meas(&eNB->schedule_si); - - // Only schedule LTE System Information in subframe 5 - if (subframeP == 5) { - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - cc = &eNB->common_channels[CC_id]; - vrb_map = (void*)&cc->vrb_map; - N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); - dl_config_request = &eNB->DL_req[CC_id]; - dl_req = &eNB->DL_req[CC_id].dl_config_request_body; - - bcch_sdu_length = mac_rrc_data_req(module_idP, - CC_id, - frameP, - BCCH,1, - &cc->BCCH_pdu.payload[0], - 1, - module_idP, - 0); // not used in this case - - if (bcch_sdu_length > 0) { - //LOG_D(MAC,"[eNB %d] Frame %d subframe %d : BCCH->DLSCH CC_id %d, Received %d bytes \n",module_idP,frameP,subframeP,CC_id,bcch_sdu_length); - - // Allocate 4 PRBs in a random location - /* - while (1) { - first_rb = (unsigned char)(taus()%(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL-4)); - if ((vrb_map[first_rb] != 1) && - (vrb_map[first_rb+1] != 1) && - (vrb_map[first_rb+2] != 1) && - (vrb_map[first_rb+3] != 1)) - break; - } - */ - switch (N_RB_DL) { - case 6: - first_rb = 0; - break; - case 15: - first_rb = 6; - break; - case 25: - first_rb = 11; - break; - case 50: - first_rb = 23; - break; - case 100: - first_rb = 48; - break; - } - - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - - // Get MCS for length of SI, 3 PRBs - if (bcch_sdu_length <= 7) { - mcs=0; - } else if (bcch_sdu_length <= 11) { - mcs=1; - } else if (bcch_sdu_length <= 18) { - mcs=2; - } else if (bcch_sdu_length <= 22) { - mcs=3; - } else if (bcch_sdu_length <= 26) { - mcs=4; - } else if (bcch_sdu_length <= 28) { - mcs=5; - } else if (bcch_sdu_length <= 32) { - mcs=6; - } else if (bcch_sdu_length <= 41) { - mcs=7; - } else if (bcch_sdu_length <= 49) { - mcs=8; - } - - - //dl_req->number_pdcch_ofdm_symbols = &RC.mac[module_idP]->DL_req[CC_id].dl_config_request_body; - - - - - - //LOG_D(MAC,"%s() Before ADDING SI dl_req->number_pdu:%d dl_req->number_dci:%d eNB->TX_req[CC_id].tx_request_body.number_of_pdus:%d\n", __FUNCTION__, dl_req->number_pdu, dl_req->number_dci, eNB->TX_req[CC_id].tx_request_body.number_of_pdus); - - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_req->number_dci++; - //LOG_D(MAC, "%s() number_dci:%u\n", __FUNCTION__, dl_req->number_dci); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = 0xFFFF; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // S-RNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,4); - dl_config_request->header.message_id = NFAPI_DL_CONFIG_REQUEST; - dl_config_request->sfn_sf = sfn_sf; - - //LOG_D(MAC, "%s() mcs:%d bcch_sdu_length:%d N_RB_DL:%d first_rb:%d resource_block_coding:%d\n", __FUNCTION__, mcs, bcch_sdu_length, N_RB_DL, first_rb, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding); - - if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,SI_RNTI)) { - //LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for S_RNTI\n", frameP,subframeP); - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - //LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for S_RNTI\n", frameP,subframeP); - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; - - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = bcch_sdu_length; // DJP - is the BCCH size the thing to put here? to match TX_REQ??? - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFF; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,4); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = 1; // DJP - wireshark whinges - get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 0; // DJP - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 0; // DJP - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - dl_req->number_pdu++; - dl_config_request->header.message_id = NFAPI_DL_CONFIG_REQUEST; - dl_config_request->sfn_sf = sfn_sf; - - //dl_config_pdu->dlsch_pdu.dlsch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG; - //dl_config_pdu->dlsch_pdu.dlsch_pdu_rel9.nscid = 0; - - //dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; - - //dl_config_pdu->dlsch_pdu.dlsch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG; - //dl_config_pdu->dlsch_pdu.dlsch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG; - //dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; - - // Program TX Request - TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = bcch_sdu_length; - TX_req->pdu_index = eNB->pdu_index[CC_id]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = bcch_sdu_length; - TX_req->segments[0].segment_data = cc->BCCH_pdu.payload; - eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; - eNB->TX_req[CC_id].sfn_sf = sfn_sf; - eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - - if (0 && frameP%100==0) LOG_D(MAC,"%s() TX_REQ: sfn_sf:%u pdus:%u pdu_length:%u pdu_index:%u segments:%u segment_length:%u\n", - __FUNCTION__, NFAPI_SFNSF2DEC(eNB->TX_req[CC_id].sfn_sf), eNB->TX_req[CC_id].tx_request_body.number_of_pdus, - TX_req->pdu_length, TX_req->pdu_index, TX_req->num_segments, TX_req->segments[0].segment_length); - } - else { - LOG_E(MAC,"[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A for SI\n",module_idP, CC_id,frameP,subframeP); - } - - if (opt_enabled == 1) { - trace_pdu(1, - &cc->BCCH_pdu.payload[0], - bcch_sdu_length, - 0xffff, - 4, - 0xffff, - eNB->frame, - eNB->subframe, - 0, - 0); - LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, 0xffff, bcch_sdu_length); - } - if (cc->tdd_Config!=NULL) { //TDD - LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for CC_id %d SI %d bytes (mcs %d, rb 3)\n", - frameP, - CC_id, - bcch_sdu_length, - mcs); - } else { - if (0) LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (FDD) for CC_id %d SI %d bytes (mcs %d, rb 3)\n", - frameP, - CC_id, - bcch_sdu_length, - mcs); + int8_t bcch_sdu_length; + int mcs = -1; + int CC_id; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc; + uint8_t *vrb_map; + int first_rb = -1; + int N_RB_DL; + nfapi_dl_config_request_t *dl_config_request; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + nfapi_tx_request_pdu_t *TX_req; + nfapi_dl_config_request_body_t *dl_req; + uint16_t sfn_sf = frameP << 4 | subframeP; + + start_meas(&eNB->schedule_si); + + // Only schedule LTE System Information in subframe 5 + if (subframeP == 5) { + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + + cc = &eNB->common_channels[CC_id]; + vrb_map = (void *) &cc->vrb_map; + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + dl_config_request = &eNB->DL_req[CC_id]; + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + + + bcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, BCCH, 1, &cc->BCCH_pdu.payload[0], 0); // not used in this case + + if (bcch_sdu_length > 0) { + LOG_D(MAC, "[eNB %d] Frame %d : BCCH->DLSCH CC_id %d, Received %d bytes \n", module_idP, frameP, CC_id, bcch_sdu_length); + + // Allocate 4 PRBs in a random location + /* + while (1) { + first_rb = (unsigned char)(taus()%(PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL-4)); + if ((vrb_map[first_rb] != 1) && + (vrb_map[first_rb+1] != 1) && + (vrb_map[first_rb+2] != 1) && + (vrb_map[first_rb+3] != 1)) + break; + } + */ + switch (N_RB_DL) { + case 6: + first_rb = 0; + break; + case 15: + first_rb = 6; + break; + case 25: + first_rb = 11; + break; + case 50: + first_rb = 23; + break; + case 100: + first_rb = 48; + break; + } + + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + + // Get MCS for length of SI, 3 PRBs + if (bcch_sdu_length <= 7) { + mcs = 0; + } else if (bcch_sdu_length <= 11) { + mcs = 1; + } else if (bcch_sdu_length <= 18) { + mcs = 2; + } else if (bcch_sdu_length <= 22) { + mcs = 3; + } else if (bcch_sdu_length <= 26) { + mcs = 4; + } else if (bcch_sdu_length <= 28) { + mcs = 5; + } else if (bcch_sdu_length <= 32) { + mcs = 6; + } else if (bcch_sdu_length <= 41) { + mcs = 7; + } else if (bcch_sdu_length <= 49) { + mcs = 8; + } + + + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = + NFAPI_DL_DCI_FORMAT_1A; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level = 4; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = 0xFFFF; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // S-RNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + new_data_indicator_1 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + redundancy_version_1 = 0; + + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding = + getRIV(N_RB_DL, first_rb, 4); + dl_config_request->sfn_sf = sfn_sf; + + if (!CCE_allocation_infeasible + (module_idP, CC_id, 0, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, SI_RNTI)) { + LOG_D(MAC, "Frame %d: Subframe %d : Adding common DCI for S_RNTI\n", frameP, subframeP); + dl_req->number_dci++; + dl_req->number_pdu++; + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = + NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = + eNB->pdu_index[CC_id]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = bcch_sdu_length; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFF; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.resource_block_coding = + getRIV(N_RB_DL, first_rb, 4); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + redundancy_version = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transport_block_to_codeword_swap_flag + = 0; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transmission_scheme = + (cc->p_eNB == 1) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + number_of_layers = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + transmission_mode = (cc->p_eNB == 1) ? 1 : 2; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = + 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + dl_req->number_pdu++; + + // Rel10 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; + // Rel13 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 0; // regular UE + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not BR + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; // absolute SF + + dl_config_request->header.message_id = NFAPI_DL_CONFIG_REQUEST; + dl_config_request->sfn_sf = sfn_sf; + + // Program TX Request + TX_req = + &eNB->TX_req[CC_id]. + tx_request_body.tx_pdu_list[eNB->TX_req[CC_id]. + tx_request_body.number_of_pdus]; + TX_req->pdu_length = bcch_sdu_length; + TX_req->pdu_index = eNB->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = bcch_sdu_length; + TX_req->segments[0].segment_data = + cc->BCCH_pdu.payload; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; + eNB->TX_req[CC_id].sfn_sf = sfn_sf; + eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; + + } else { + LOG_E(MAC, + "[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A for SI\n", + module_idP, CC_id, frameP, subframeP); + } + + if (opt_enabled == 1) { + trace_pdu(1, + &cc->BCCH_pdu.payload[0], + bcch_sdu_length, + 0xffff, + 4, 0xffff, eNB->frame, eNB->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, + bcch_sdu_length); + } + if (cc->tdd_Config != NULL) { //TDD + LOG_D(MAC, + "[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for CC_id %d SI %d bytes (mcs %d, rb 3)\n", + frameP, CC_id, bcch_sdu_length, mcs); + } else { + LOG_D(MAC, "[eNB] Frame %d : Scheduling BCCH->DLSCH (FDD) for CC_id %d SI %d bytes (mcs %d, rb 3)\n", frameP, CC_id, bcch_sdu_length, mcs); + } + + + eNB->eNB_stats[CC_id].total_num_bcch_pdu += 1; + eNB->eNB_stats[CC_id].bcch_buffer = bcch_sdu_length; + eNB->eNB_stats[CC_id].total_bcch_buffer += bcch_sdu_length; + eNB->eNB_stats[CC_id].bcch_mcs = mcs; + } else { + + //LOG_D(MAC,"[eNB %d] Frame %d : BCCH not active \n",Mod_id,frame); + } } - - - eNB->eNB_stats[CC_id].total_num_bcch_pdu+=1; - eNB->eNB_stats[CC_id].bcch_buffer=bcch_sdu_length; - eNB->eNB_stats[CC_id].total_bcch_buffer+=bcch_sdu_length; - eNB->eNB_stats[CC_id].bcch_mcs=mcs; - } else { - - //LOG_D(MAC,"[eNB %d] Frame %d : BCCH not active \n",Mod_id,frame); - } } - } - #ifdef Rel14 - schedule_SIB1_BR(module_idP,frameP,subframeP); - schedule_SI_BR(module_idP,frameP,subframeP); + schedule_SIB1_BR(module_idP, frameP, subframeP); + schedule_SI_BR(module_idP, frameP, subframeP); #endif stop_meas(&eNB->schedule_si); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 6caaae67a524366d0cc3502e5857b9f039a99ba7..10bbeb81c02232f2b574fe7172e6181ad037e56f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -51,10 +51,10 @@ //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/defs.h" // for taus #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif #include "T.h" @@ -63,351 +63,351 @@ //#define DEBUG_eNB_SCHEDULER 1 extern RAN_CONTEXT_t RC; +extern uint8_t nfapi_mode; //------------------------------------------------------------------------------ void -add_ue_dlsch_info( - module_id_t module_idP, - int CC_id, - int UE_id, - sub_frame_t subframeP, - UE_DLSCH_STATUS status -) +add_ue_dlsch_info(module_id_t module_idP, + int CC_id, + int UE_id, sub_frame_t subframeP, UE_DLSCH_STATUS status) //------------------------------------------------------------------------------ { //LOG_D(MAC, "%s(module_idP:%d, CC_id:%d, UE_id:%d, subframeP:%d, status:%d) serving_num:%d rnti:%x\n", __FUNCTION__, module_idP, CC_id, UE_id, subframeP, status, eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num, UE_RNTI(module_idP,UE_id)); - eNB_dlsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP,UE_id); - // eNB_dlsch_info[module_idP][CC_id][ue_mod_idP].weight = weight; - eNB_dlsch_info[module_idP][CC_id][UE_id].subframe = subframeP; - eNB_dlsch_info[module_idP][CC_id][UE_id].status = status; + eNB_dlsch_info[module_idP][CC_id][UE_id].rnti = + UE_RNTI(module_idP, UE_id); + // eNB_dlsch_info[module_idP][CC_id][ue_mod_idP].weight = weight; + eNB_dlsch_info[module_idP][CC_id][UE_id].subframe = subframeP; + eNB_dlsch_info[module_idP][CC_id][UE_id].status = status; - eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num++; + eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num++; } //------------------------------------------------------------------------------ int -schedule_next_dlue( - module_id_t module_idP, - int CC_id, - sub_frame_t subframeP -) +schedule_next_dlue(module_id_t module_idP, int CC_id, + sub_frame_t subframeP) //------------------------------------------------------------------------------ { - int next_ue; - UE_list_t *UE_list=&RC.mac[module_idP]->UE_list; + int next_ue; + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ) { - if (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_WAITING) { - return next_ue; + for (next_ue = UE_list->head; next_ue >= 0; + next_ue = UE_list->next[next_ue]) { + if (eNB_dlsch_info[module_idP][CC_id][next_ue].status == + S_DL_WAITING) { + return next_ue; + } } - } - for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ) { - if (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_BUFFERED) { - eNB_dlsch_info[module_idP][CC_id][next_ue].status = S_DL_WAITING; + for (next_ue = UE_list->head; next_ue >= 0; + next_ue = UE_list->next[next_ue]) { + if (eNB_dlsch_info[module_idP][CC_id][next_ue].status == + S_DL_BUFFERED) { + eNB_dlsch_info[module_idP][CC_id][next_ue].status = + S_DL_WAITING; + } } - } - return(-1);//next_ue; + return (-1); //next_ue; } //------------------------------------------------------------------------------ unsigned char -generate_dlsch_header( - unsigned char* mac_header, - unsigned char num_sdus, - unsigned short *sdu_lengths, - unsigned char *sdu_lcids, - unsigned char drx_cmd, - unsigned short timing_advance_cmd, - unsigned char *ue_cont_res_id, - unsigned char short_padding, - unsigned short post_padding -) +generate_dlsch_header(unsigned char *mac_header, + unsigned char num_sdus, + unsigned short *sdu_lengths, + unsigned char *sdu_lcids, + unsigned char drx_cmd, + unsigned short timing_advance_cmd, + unsigned char *ue_cont_res_id, + unsigned char short_padding, + unsigned short post_padding) //------------------------------------------------------------------------------ { - SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *)mac_header; - uint8_t first_element=0,last_size=0,i; - uint8_t mac_header_control_elements[16],*ce_ptr; + SCH_SUBHEADER_FIXED *mac_header_ptr = + (SCH_SUBHEADER_FIXED *) mac_header; + uint8_t first_element = 0, last_size = 0, i; + uint8_t mac_header_control_elements[16], *ce_ptr; - ce_ptr = &mac_header_control_elements[0]; + ce_ptr = &mac_header_control_elements[0]; - // compute header components + // compute header components - if ((short_padding == 1) || (short_padding == 2)) { - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - first_element=1; - last_size=1; - } - - if (short_padding == 2) { - mac_header_ptr->E = 1; - mac_header_ptr++; - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - last_size=1; - } + if ((short_padding == 1) || (short_padding == 2)) { + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + first_element = 1; + last_size = 1; + } - if (drx_cmd != 255) { - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } else { - first_element=1; + if (short_padding == 2) { + mac_header_ptr->E = 1; + mac_header_ptr++; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + last_size = 1; } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = DRX_CMD; - last_size=1; - } + if (drx_cmd != 255) { + if (first_element > 0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } else { + first_element = 1; + } - if (timing_advance_cmd != 31) { - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } else { - first_element=1; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = DRX_CMD; + last_size = 1; } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = TIMING_ADV_CMD; - last_size=1; - // msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - ((TIMING_ADVANCE_CMD *)ce_ptr)->R=0; - AssertFatal(timing_advance_cmd < 64,"timing_advance_cmd %d > 63\n",timing_advance_cmd); - ((TIMING_ADVANCE_CMD *)ce_ptr)->TA=timing_advance_cmd;//(timing_advance_cmd+31)&0x3f; - LOG_D(MAC,"timing advance =%d (%d)\n",timing_advance_cmd,((TIMING_ADVANCE_CMD *)ce_ptr)->TA); - ce_ptr+=sizeof(TIMING_ADVANCE_CMD); - //msg("offset %d\n",ce_ptr-mac_header_control_elements); - } + if (timing_advance_cmd != 31) { + if (first_element > 0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } else { + first_element = 1; + } - if (ue_cont_res_id) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* - printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } else { - first_element=1; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = TIMING_ADV_CMD; + last_size = 1; + // msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + ((TIMING_ADVANCE_CMD *) ce_ptr)->R = 0; + AssertFatal(timing_advance_cmd < 64, + "timing_advance_cmd %d > 63\n", timing_advance_cmd); + ((TIMING_ADVANCE_CMD *) ce_ptr)->TA = timing_advance_cmd; //(timing_advance_cmd+31)&0x3f; + LOG_D(MAC, "timing advance =%d (%d)\n", timing_advance_cmd, + ((TIMING_ADVANCE_CMD *) ce_ptr)->TA); + ce_ptr += sizeof(TIMING_ADVANCE_CMD); + //msg("offset %d\n",ce_ptr-mac_header_control_elements); } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = UE_CONT_RES; - last_size=1; - - LOG_T(MAC,"[eNB ][RAPROC] Generate contention resolution msg: %x.%x.%x.%x.%x.%x\n", - ue_cont_res_id[0], - ue_cont_res_id[1], - ue_cont_res_id[2], - ue_cont_res_id[3], - ue_cont_res_id[4], - ue_cont_res_id[5]); - - memcpy(ce_ptr,ue_cont_res_id,6); - ce_ptr+=6; - // msg("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); - } + if (ue_cont_res_id) { + if (first_element > 0) { + mac_header_ptr->E = 1; + /* + printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr++; + } else { + first_element = 1; + } - //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = UE_CONT_RES; + last_size = 1; - for (i=0; i<num_sdus; i++) { - LOG_T(MAC,"[eNB] Generate DLSCH header num sdu %d len sdu %d\n",num_sdus, sdu_lengths[i]); + LOG_T(MAC, + "[eNB ][RAPROC] Generate contention resolution msg: %x.%x.%x.%x.%x.%x\n", + ue_cont_res_id[0], ue_cont_res_id[1], ue_cont_res_id[2], + ue_cont_res_id[3], ue_cont_res_id[4], ue_cont_res_id[5]); - if (first_element>0) { - mac_header_ptr->E = 1; - /*msg("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr+=last_size; - //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - } else { - first_element=1; + memcpy(ce_ptr, ue_cont_res_id, 6); + ce_ptr += 6; + // msg("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } + //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + + for (i = 0; i < num_sdus; i++) { + LOG_T(MAC, "[eNB] Generate DLSCH header num sdu %d len sdu %d\n", + num_sdus, sdu_lengths[i]); + + if (first_element > 0) { + mac_header_ptr->E = 1; + /*msg("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr += last_size; + //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + } else { + first_element = 1; + } - if (sdu_lengths[i] < 128) { - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; - last_size=2; - } else { - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; - last_size=3; + if (sdu_lengths[i] < 128) { + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F = 0; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L = + (unsigned char) sdu_lengths[i]; + last_size = 2; + } else { + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->F = 1; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB = + ((unsigned short) sdu_lengths[i] >> 8) & 0x7f; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB = + (unsigned short) sdu_lengths[i] & 0xff; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->padding = 0x00; + last_size = 3; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", - sdu_lengths[i], - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB, - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB); + LOG_D(MAC, + "[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", + sdu_lengths[i], + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB, + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB); #endif + } } - } - /* - - printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - - printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - - - if (((SCH_SUBHEADER_FIXED*)mac_header_ptr)->LCID < UE_CONT_RES) { - if (((SCH_SUBHEADER_SHORT*)mac_header_ptr)->F == 0) - printf("F = 0, sdu len (L field) %d\n",(((SCH_SUBHEADER_SHORT*)mac_header_ptr)->L)); - else - printf("F = 1, sdu len (L field) %d\n",(((SCH_SUBHEADER_LONG*)mac_header_ptr)->L)); + /* + + printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + + + if (((SCH_SUBHEADER_FIXED*)mac_header_ptr)->LCID < UE_CONT_RES) { + if (((SCH_SUBHEADER_SHORT*)mac_header_ptr)->F == 0) + printf("F = 0, sdu len (L field) %d\n",(((SCH_SUBHEADER_SHORT*)mac_header_ptr)->L)); + else + printf("F = 1, sdu len (L field) %d\n",(((SCH_SUBHEADER_LONG*)mac_header_ptr)->L)); + } + */ + if (post_padding > 0) { // we have lots of padding at the end of the packet + mac_header_ptr->E = 1; + mac_header_ptr += last_size; + // add a padding element + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + mac_header_ptr++; + } else { // no end of packet padding + // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) + mac_header_ptr++; } - */ - if (post_padding>0) {// we have lots of padding at the end of the packet - mac_header_ptr->E = 1; - mac_header_ptr+=last_size; - // add a padding element - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - mac_header_ptr++; - } else { // no end of packet padding - // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) - mac_header_ptr++; - } - - //msg("After subheaders %d\n",(uint8_t*)mac_header_ptr - mac_header); - if ((ce_ptr-mac_header_control_elements) > 0) { - // printf("Copying %d bytes for control elements\n",ce_ptr-mac_header_control_elements); - memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements); - mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements); - } + //msg("After subheaders %d\n",(uint8_t*)mac_header_ptr - mac_header); - //msg("After CEs %d\n",(uint8_t*)mac_header_ptr - mac_header); + if ((ce_ptr - mac_header_control_elements) > 0) { + // printf("Copying %d bytes for control elements\n",ce_ptr-mac_header_control_elements); + memcpy((void *) mac_header_ptr, mac_header_control_elements, + ce_ptr - mac_header_control_elements); + mac_header_ptr += + (unsigned char) (ce_ptr - mac_header_control_elements); + } + //msg("After CEs %d\n",(uint8_t*)mac_header_ptr - mac_header); - return((unsigned char*)mac_header_ptr - mac_header); + return ((unsigned char *) mac_header_ptr - mac_header); } //------------------------------------------------------------------------------ void -set_ul_DAI( - int module_idP, - int UE_idP, - int CC_idP, - int frameP, - int subframeP -) +set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, + int subframeP) //------------------------------------------------------------------------------ { - eNB_MAC_INST *eNB = RC.mac[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; - unsigned char DAI; - COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - if (cc->tdd_Config != NULL) { //TDD - DAI = (UE_list->UE_template[CC_idP][UE_idP].DAI-1)&3; - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframe %d: DAI %d for UE %d\n",module_idP,CC_idP,frameP,subframeP,DAI,UE_idP); - // Save DAI for Format 0 DCI - - switch (cc->tdd_Config->subframeAssignment) { - case 0: - // if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6)) - break; - - case 1: - switch (subframeP) { - case 1: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI; - break; - - case 4: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI; - break; - - case 6: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; - break; - - case 9: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; - break; - } - - case 2: - // if ((subframeP==3)||(subframeP==8)) - // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; - break; - - case 3: + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; + unsigned char DAI; + COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; + if (cc->tdd_Config != NULL) { //TDD + DAI = (UE_list->UE_template[CC_idP][UE_idP].DAI - 1) & 3; + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d, subframe %d: DAI %d for UE %d\n", + module_idP, CC_idP, frameP, subframeP, DAI, UE_idP); + // Save DAI for Format 0 DCI + + switch (cc->tdd_Config->subframeAssignment) { + case 0: + // if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6)) + break; + + case 1: + switch (subframeP) { + case 1: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI; + break; + + case 4: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI; + break; + + case 6: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; + break; + + case 9: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; + break; + } - //if ((subframeP==6)||(subframeP==8)||(subframeP==0)) { - // LOG_D(MAC,"schedule_ue_spec: setting UL DAI to %d for subframeP %d => %d\n",DAI,subframeP, ((subframeP+8)%10)>>1); - // UE_list->UE_template[CC_idP][UE_idP].DAI_ul[((subframeP+8)%10)>>1] = DAI; - //} - switch (subframeP) { - case 5: - case 6: - case 1: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; - break; - - case 7: - case 8: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; - break; - - case 9: - case 0: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[4] = DAI; - break; - - default: - break; - } + case 2: + // if ((subframeP==3)||(subframeP==8)) + // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; + break; + + case 3: + + //if ((subframeP==6)||(subframeP==8)||(subframeP==0)) { + // LOG_D(MAC,"schedule_ue_spec: setting UL DAI to %d for subframeP %d => %d\n",DAI,subframeP, ((subframeP+8)%10)>>1); + // UE_list->UE_template[CC_idP][UE_idP].DAI_ul[((subframeP+8)%10)>>1] = DAI; + //} + switch (subframeP) { + case 5: + case 6: + case 1: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; + break; + + case 7: + case 8: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; + break; + + case 9: + case 0: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[4] = DAI; + break; + + default: + break; + } - break; + break; - case 4: - // if ((subframeP==8)||(subframeP==9)) - // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; - break; + case 4: + // if ((subframeP==8)||(subframeP==9)) + // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; + break; - case 5: - // if (subframeP==8) - // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; - break; + case 5: + // if (subframeP==8) + // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; + break; - case 6: - // if ((subframeP==1)||(subframeP==4)||(subframeP==6)||(subframeP==9)) - // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; - break; + case 6: + // if ((subframeP==1)||(subframeP==4)||(subframeP==6)||(subframeP==9)) + // UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI; + break; - default: - break; + default: + break; + } } - } } @@ -415,1171 +415,1735 @@ set_ul_DAI( //------------------------------------------------------------------------------ void -schedule_ue_spec( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - int* mbsfn_flag -) +schedule_ue_spec(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) //------------------------------------------------------------------------------ { - uint8_t CC_id; - int UE_id; - unsigned char aggregation; - mac_rlc_status_resp_t rlc_status; - unsigned char header_len_dcch=0, header_len_dcch_tmp=0; - unsigned char header_len_dtch=0, header_len_dtch_tmp=0, header_len_dtch_last=0; - unsigned char ta_len=0; - unsigned char sdu_lcids[NB_RB_MAX],lcid,offset,num_sdus=0; - uint16_t nb_rb,nb_rb_temp,nb_available_rb; - uint16_t TBS,j,sdu_lengths[NB_RB_MAX],rnti,padding=0,post_padding=0; - unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - unsigned char round = 0; - unsigned char harq_pid = 0; - eNB_UE_STATS *eNB_UE_stats = NULL; - uint16_t sdu_length_total = 0; - - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - UE_list_t *UE_list = &eNB->UE_list; - int continue_flag=0; - int32_t normalized_rx_power, target_rx_power; - int32_t tpc=1; - static int32_t tpc_accumulated=0; - UE_sched_ctrl *ue_sched_ctl; - int mcs; - int i; - int min_rb_unit[MAX_NUM_CCs]; - int N_RB_DL[MAX_NUM_CCs]; - int total_nb_available_rb[MAX_NUM_CCs]; - int N_RBG[MAX_NUM_CCs]; - nfapi_dl_config_request_body_t *dl_req; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - int tdd_sfa; - int ta_update; + uint8_t CC_id; + int UE_id; + unsigned char aggregation; + mac_rlc_status_resp_t rlc_status; + unsigned char header_len_dcch = 0, header_len_dcch_tmp = 0; + unsigned char header_len_dtch = 0, header_len_dtch_tmp = + 0, header_len_dtch_last = 0; + unsigned char ta_len = 0; + unsigned char sdu_lcids[NB_RB_MAX], lcid, offset, num_sdus = 0; + uint16_t nb_rb, nb_rb_temp, nb_available_rb; + uint16_t TBS, j, sdu_lengths[NB_RB_MAX], rnti, padding = + 0, post_padding = 0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + unsigned char round = 0; + unsigned char harq_pid = 0; + eNB_UE_STATS *eNB_UE_stats = NULL; + uint16_t sdu_length_total = 0; + + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + UE_list_t *UE_list = &eNB->UE_list; + int continue_flag = 0; + int32_t normalized_rx_power, target_rx_power; + int32_t tpc = 1; + static int32_t tpc_accumulated = 0; + UE_sched_ctrl *ue_sched_ctl; + int mcs; + int i; + int min_rb_unit[MAX_NUM_CCs]; + int N_RB_DL[MAX_NUM_CCs]; + int total_nb_available_rb[MAX_NUM_CCs]; + int N_RBG[MAX_NUM_CCs]; + nfapi_dl_config_request_body_t *dl_req; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + int tdd_sfa; + int ta_update; #if 0 - if (UE_list->head==-1) { - return; - } + if (UE_list->head == -1) { + return; + } #endif - start_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); + start_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); + + + // for TDD: check that we have to act here, otherwise return + if (cc[0].tdd_Config) { + tdd_sfa = cc[0].tdd_Config->subframeAssignment; + switch (subframeP) { + case 0: + // always continue + break; + case 1: + return; + break; + case 2: + return; + break; + case 3: + if ((tdd_sfa != 2) && (tdd_sfa != 5)) + return; + break; + case 4: + if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + break; + case 5: + break; + case 6: + case 7: + if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + break; + case 8: + if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + break; + case 9: + if ((tdd_sfa != 1) && (tdd_sfa != 3) && (tdd_sfa != 4) + && (tdd_sfa != 6)) + return; + break; - - // for TDD: check that we have to act here, otherwise return - if (cc[0].tdd_Config) { - tdd_sfa = cc[0].tdd_Config->subframeAssignment; - switch (subframeP) { - case 0: - // always continue - break; - case 1: - return; - break; - case 2: - return; - break; - case 3: - if ((tdd_sfa!=2) && (tdd_sfa!=5)) return; - break; - case 4: - if ((tdd_sfa!=1)&&(tdd_sfa!=2)&&(tdd_sfa!=4)&&(tdd_sfa!=5)) return; - break; - case 5: - break; - case 6: - case 7: - if ((tdd_sfa!=1)&&(tdd_sfa!=2)&&(tdd_sfa!=4)&&(tdd_sfa!=5)) return; - break; - case 8: - if ((tdd_sfa!=2)&&(tdd_sfa!=3)&&(tdd_sfa!=4)&&(tdd_sfa!=5)) return; - break; - case 9: - if ((tdd_sfa!=1)&&(tdd_sfa!=3)&&(tdd_sfa!=4)&&(tdd_sfa!=6)) return; - break; - + } + } + //weight = get_ue_weight(module_idP,UE_id); + aggregation = 2; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); + min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); + // get number of PRBs less those used by common channels + total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; + for (i = 0; i < N_RB_DL[CC_id]; i++) + if (cc[CC_id].vrb_map[i] != 0) + total_nb_available_rb[CC_id]--; + + N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); + + // store the global enb stats: + eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; + eNB->eNB_stats[CC_id].available_prbs = + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].total_available_prbs += + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; + eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; } - } - //weight = get_ue_weight(module_idP,UE_id); - aggregation = 2; - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); - min_rb_unit[CC_id]=get_min_rb_unit(module_idP,CC_id); - // get number of PRBs less those used by common channels - total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; - for (i=0;i<N_RB_DL[CC_id];i++) - if (cc[CC_id].vrb_map[i]!=0) - total_nb_available_rb[CC_id]--; - - N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); - - // store the global enb stats: - eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; - eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].total_available_prbs += total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; - eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; - } + /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) - /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_IN); + start_meas(&eNB->schedule_dlsch_preprocessor); + dlsch_scheduler_pre_processor(module_idP, + frameP, subframeP, N_RBG, mbsfn_flag); + stop_meas(&eNB->schedule_dlsch_preprocessor); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_OUT); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); - start_meas(&eNB->schedule_dlsch_preprocessor); - dlsch_scheduler_pre_processor(module_idP, - frameP, - subframeP, - N_RBG, - mbsfn_flag); - stop_meas(&eNB->schedule_dlsch_preprocessor); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n", CC_id); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - //LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n",CC_id); + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; - dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + if (mbsfn_flag[CC_id] > 0) + continue; - if (mbsfn_flag[CC_id]>0) - continue; - - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - continue_flag=0; // reset the flag to allow allocation for the remaining UEs - rnti = UE_RNTI(module_idP,UE_id); - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + for (UE_id = UE_list->head; UE_id >= 0; + UE_id = UE_list->next[UE_id]) { + continue_flag = 0; // reset the flag to allow allocation for the remaining UEs + rnti = UE_RNTI(module_idP, UE_id); + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; //LOG_D(MAC,"%s() rnti:%x, eNB_UE_stats:%p, ue_sched_ctl:%p tmode:%d\n", __FUNCTION__, rnti, eNB_UE_stats, ue_sched_ctl, get_tmode(module_idP,CC_id,UE_id)); - if (rnti==NOT_A_RNTI) { - LOG_D(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n",UE_id,UE_list->num_UEs); - continue_flag=1; - } + if (rnti == NOT_A_RNTI) { + LOG_D(MAC, "Cannot find rnti for UE_id %d (num_UEs %d)\n", + UE_id, UE_list->num_UEs); + continue_flag = 1; + } - if (eNB_UE_stats==NULL) { - LOG_D(MAC,"[eNB] Cannot find eNB_UE_stats\n"); - continue_flag=1; - } + if (eNB_UE_stats == NULL) { + LOG_D(MAC, "[eNB] Cannot find eNB_UE_stats\n"); + continue_flag = 1; + } - if (continue_flag != 1){ - switch(get_tmode(module_idP,CC_id,UE_id)){ - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + if (continue_flag != 1) { + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + aggregation = + get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + break; + case 3: + aggregation = + get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - } - } /* if (continue_flag != 1 */ - - if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated - CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,aggregation,rnti) - ) { - //LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", module_idP, frameP, UE_id, CC_id); - continue_flag=1; //to next user (there might be rbs availiable for other UEs in TM5 - } - - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } + break; + default: + LOG_W(MAC, "Unsupported transmission mode %d\n", + get_tmode(module_idP, CC_id, UE_id)); + aggregation = 2; + } + } + /* if (continue_flag != 1 */ + if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated + CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, + aggregation, rnti)) { + LOG_D(MAC, + "[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", + module_idP, frameP, UE_id, CC_id); + continue_flag = 1; //to next user (there might be rbs availiable for other UEs in TM5 + } - if (continue_flag == 1 ) { - //LOG_D(MAC,"[eNB %d] Frame %d : UE %d on CC_id %d: continue flag - add_ue_dlsch_info\n", module_idP, frameP, UE_id, CC_id); - add_ue_dlsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_DL_NONE); - continue; - } + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai(subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP, UE_id, CC_id, frameP, subframeP); + } + if (continue_flag == 1) { + add_ue_dlsch_info(module_idP, + CC_id, UE_id, subframeP, S_DL_NONE); + continue; + } #warning RK->CR This old API call has to be revisited for FAPI, or logic must be changed #if 0 - /* add "fake" DCI to have CCE_allocation_infeasible work properly for next allocations */ - /* if we don't add it, next allocations may succeed but overall allocations may fail */ - /* will be removed at the end of this function */ - add_ue_spec_dci(&eNB->common_channels[CC_id].DCI_pdu, - &(char[]){0}, - rnti, - 1, - aggregation, - 1, - format1, - 0); + /* add "fake" DCI to have CCE_allocation_infeasible work properly for next allocations */ + /* if we don't add it, next allocations may succeed but overall allocations may fail */ + /* will be removed at the end of this function */ + add_ue_spec_dci(&eNB->common_channels[CC_id].DCI_pdu, &(char[]) { + 0}, rnti, 1, aggregation, 1, format1, 0); #endif - nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - - if (cc->tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; - - round = ue_sched_ctl->round[CC_id][harq_pid]; + nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - UE_list->eNB_UE_stats[CC_id][UE_id].crnti= rnti; - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status=mac_eNB_get_rrc_status(module_idP,rnti); - UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; - UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; + if (cc->tdd_Config) + harq_pid = ((frameP * 10) + subframeP) % 10; + else + harq_pid = ((frameP * 10) + subframeP) & 7; + round = ue_sched_ctl->round[CC_id][harq_pid]; - if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < RRC_CONNECTED) continue; + UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = + mac_eNB_get_rrc_status(module_idP, rnti); + UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; + UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; - sdu_length_total=0; - num_sdus=0; - /* - DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), - eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); - */ - eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; - - - // store stats - //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi; - - // initializing the rb allocation indicator for each UE - for(j=0; j<N_RBG[CC_id]; j++) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0; - } + if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < + RRC_CONNECTED) + continue; - LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", - module_idP, frameP, UE_id,CC_id,rnti,harq_pid, round,nb_available_rb, - ue_sched_ctl->dl_cqi[CC_id], eNB_UE_stats->dlsch_mcs1, - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); + sdu_length_total = 0; + num_sdus = 0; - - - /* process retransmission */ - - if (round != 8) { - - // get freq_allocation - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - TBS = get_TBS_DL(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid],nb_rb); - - if (nb_rb <= nb_available_rb) { - if (cc[CC_id].tdd_Config != NULL) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI); - LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", CC_id,subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - } - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for(j=0; j<N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + /* + DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), + eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); + */ + if (nfapi_mode) { + eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; } - } else { - nb_rb_temp = nb_rb; - j = 0; - - while((nb_rb_temp > 0) && (j<N_RBG[CC_id])) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - if (UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]) printf("WARN: rballoc_subband not free for retrans?\n"); - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if((j == N_RBG[CC_id]-1) && - ((N_RB_DL[CC_id] == 25)|| - (N_RB_DL[CC_id] == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - - j = j+1; + else { + eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; } - } + eNB_UE_stats->dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); - nb_available_rb -= nb_rb; - /* - eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + // store stats + //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi; - for(j=0; j<N_RBG[CC_id]; j++) { - eNB->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - */ - - switch (get_tmode(module_idP,CC_id,UE_id)) { - case 1: - case 2: - case 7: - default: - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = round&3; - - if (cc[CC_id].tdd_Config != NULL) { //TDD - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", - module_idP,CC_id,harq_pid,round, - (UE_list->UE_template[CC_id][UE_id].DAI-1), - UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]); - } else { - LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", - module_idP,CC_id,harq_pid,round, - UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]); - - } - if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - rnti)) { - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - fill_nfapi_dlsch_config(eNB,dl_req, - TBS, - -1 /* retransmission, no pdu_index */, - rnti, - 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]), - round&3 , // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, - 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - - LOG_D(MAC,"Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n",eNB->pdu_index[CC_id],round); - - - program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - // No TX request for retransmission (check if null request for FAPI) + // initializing the rb allocation indicator for each UE + for (j = 0; j < N_RBG[CC_id]; j++) { + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] + = 0; } - else { - LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n", - frameP,subframeP,UE_id,rnti); - } - } - - - add_ue_dlsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_DL_SCHEDULED); - - //eNB_UE_stats->dlsch_trials[round]++; - UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx=nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx+=nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=eNB_UE_stats->dlsch_mcs1; - } else { - LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", - module_idP, frameP, CC_id, UE_id); - } - } else { /* This is a potentially new SDU opportunity */ - - rlc_status.bytes_in_buffer = 0; - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_available_rb); - // check first for RLC data on DCCH - // add the length for all the control elements (timing adv, drx, etc) : header + payload - - if (ue_sched_ctl->ta_timer == 0) { - ta_update = ue_sched_ctl->ta_update; - /* if we send TA then set timer to not send it for a while */ - if (ta_update != 31) - ue_sched_ctl->ta_timer = 20; - /* reset ta_update */ - ue_sched_ctl->ta_update = 31; - } else { - ta_update = 31; - } - ta_len = (ta_update != 31) ? 2 : 0; - - header_len_dcch = 2; // 2 bytes DCCH SDU subheader - - if ( TBS-ta_len-header_len_dcch > 0 ) { - rlc_status = mac_rlc_status_ind( - module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH, - (TBS-ta_len-header_len_dcch) // transport block set size + LOG_D(MAC, + "[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", + module_idP, frameP, UE_id, CC_id, rnti, harq_pid, round, + nb_available_rb, ue_sched_ctl->dl_cqi[CC_id], + eNB_UE_stats->dlsch_mcs1, + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); + + + + /* process retransmission */ + + if (round != 8) { + + // get freq_allocation + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + TBS = + get_TBS_DL(UE_list-> + UE_template[CC_id][UE_id].oldmcs1[harq_pid], + nb_rb); + + if (nb_rb <= nb_available_rb) { + if (cc[CC_id].tdd_Config != NULL) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id]. + DAI); + LOG_D(MAC, + "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframeP, UE_id, + UE_list->UE_template[CC_id][UE_id].DAI); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + if (UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j]) + printf + ("WARN: rballoc_subband not free for retrans?\n"); + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[CC_id] == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + + j = j + 1; + } + } + + nb_available_rb -= nb_rb; + /* + eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + + for(j=0; j<N_RBG[CC_id]; j++) { + eNB->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } + */ + + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + default: + LOG_D(MAC,"retransmission DL_REQ: rnti:%x\n",rnti); + + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req-> + number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level = + get_aggregation(get_bw_index + (module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = + rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.new_data_indicator_1 = + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = + UE_list->UE_template[CC_id][UE_id]. + oldmcs1[harq_pid]; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.redundancy_version_1 = + round & 3; + + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.downlink_assignment_index = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + (UE_list->UE_template[CC_id][UE_id].DAI - + 1), + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + } else { + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + + } + if (!CCE_allocation_infeasible + (module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, rnti)) { + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; + + fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 + /* retransmission, no pdu_index */ + , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]), round & 3, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + + LOG_D(MAC, + "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", + eNB->pdu_index[CC_id], round); + + program_dlsch_acknak(module_idP, CC_id, UE_id, + frameP, subframeP, + dl_config_pdu-> + dci_dl_pdu.dci_dl_pdu_rel8. + cce_idx); + // No TX request for retransmission (check if null request for FAPI) + } else { + LOG_W(MAC, + "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n", + frameP, subframeP, UE_id, rnti); + } + } + + + add_ue_dlsch_info(module_idP, + CC_id, UE_id, subframeP, + S_DL_SCHEDULED); + + //eNB_UE_stats->dlsch_trials[round]++; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_retransmission += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = + nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id]. + total_rbs_used_retx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = + eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = + eNB_UE_stats->dlsch_mcs1; + } else { + LOG_D(MAC, + "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", + module_idP, frameP, CC_id, UE_id); + } + } else { /* This is a potentially new SDU opportunity */ + + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); + // check first for RLC data on DCCH + // add the length for all the control elements (timing adv, drx, etc) : header + payload + + if (ue_sched_ctl->ta_timer == 0) { + ta_update = ue_sched_ctl->ta_update; + /* if we send TA then set timer to not send it for a while */ + if (ta_update != 31) + ue_sched_ctl->ta_timer = 20; + /* reset ta_update */ + ue_sched_ctl->ta_update = 31; + } else { + ta_update = 31; + } + + ta_len = (ta_update != 31) ? 2 : 0; + + header_len_dcch = 2; // 2 bytes DCCH SDU subheader + + if (TBS - ta_len - header_len_dcch > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, (TBS - ta_len - header_len_dcch) // transport block set size #ifdef Rel14 ,0, 0 #endif - ); + ); // transport block set size + + sdu_lengths[0] = 0; - sdu_lengths[0]=0; - - if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit - LOG_D(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP,frameP,CC_id,TBS-header_len_dcch); - sdu_lengths[0] = mac_rlc_data_req( - module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH, - TBS, //not used - (char *)&dlsch_buffer[0] + if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit + LOG_D(MAC, + "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, subframeP, CC_id, + TBS - header_len_dcch); + sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used + (char *)&dlsch_buffer[0] #ifdef Rel14 - ,0, - 0 + ,0, 0 #endif - ); - - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0])); - - LOG_D(MAC,"[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n",module_idP,CC_id,sdu_lengths[0]); - sdu_length_total = sdu_lengths[0]; - sdu_lcids[0] = DCCH; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH]+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH]+=sdu_lengths[0]; - num_sdus = 1; + ); + + + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), + T_INT(sdu_lengths[0])); + + LOG_D(MAC, + "[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", + module_idP, CC_id, sdu_lengths[0]); + sdu_length_total = sdu_lengths[0]; + sdu_lcids[0] = DCCH; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] + += sdu_lengths[0]; + num_sdus = 1; #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC,"[eNB %d][DCCH] CC_id %d Got %d bytes :",module_idP,CC_id,sdu_lengths[0]); + LOG_T(MAC, + "[eNB %d][DCCH] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[0]); - for (j=0; j<sdu_lengths[0]; j++) { - LOG_T(MAC,"%x ",dlsch_buffer[j]); - } + for (j = 0; j < sdu_lengths[0]; j++) { + LOG_T(MAC, "%x ", dlsch_buffer[j]); + } - LOG_T(MAC,"\n"); + LOG_T(MAC, "\n"); #endif - } else { - header_len_dcch = 0; - sdu_length_total = 0; - } - } - - // check for DCCH1 and update header information (assume 2 byte sub-header) - if (TBS-ta_len-header_len_dcch-sdu_length_total > 0 ) { - rlc_status = mac_rlc_status_ind( - module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH+1, - (TBS-ta_len-header_len_dcch-sdu_length_total) // transport block set size less allocations for timing advance and + + } else { + header_len_dcch = 0; + sdu_length_total = 0; + } + } + // check for DCCH1 and update header information (assume 2 byte sub-header) + if (TBS - ta_len - header_len_dcch - sdu_length_total > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, (TBS - ta_len - header_len_dcch - sdu_length_total) // transport block set size less allocations for timing advance and #ifdef Rel14 ,0, 0 #endif ); - // DCCH SDU - sdu_lengths[num_sdus] = 0; - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP,frameP,CC_id,TBS-header_len_dcch-sdu_length_total); - sdu_lengths[num_sdus] += mac_rlc_data_req( - module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH+1, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total] -#ifdef Rel14 - ,0, - 0 -#endif - ); - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), T_INT(DCCH+1), T_INT(sdu_lengths[num_sdus])); + // DCCH SDU + sdu_lengths[num_sdus] = 0; - sdu_lcids[num_sdus] = DCCH1; - sdu_length_total += sdu_lengths[num_sdus]; - header_len_dcch += 2; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1]+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1]+=sdu_lengths[num_sdus]; - num_sdus++; + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, + "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, CC_id, + TBS - header_len_dcch - sdu_length_total); + sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] +#ifdef Rel14 + ,0, + 0 +#endif + ); + + + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); + + sdu_lcids[num_sdus] = DCCH1; + sdu_length_total += sdu_lengths[num_sdus]; + header_len_dcch += 2; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH1] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] + += sdu_lengths[num_sdus]; + num_sdus++; #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC,"[eNB %d][DCCH1] CC_id %d Got %d bytes :",module_idP,CC_id,sdu_lengths[num_sdus]); + LOG_T(MAC, + "[eNB %d][DCCH1] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[num_sdus]); - for (j=0; j<sdu_lengths[num_sdus]; j++) { - LOG_T(MAC,"%x ",dlsch_buffer[j]); - } + for (j = 0; j < sdu_lengths[num_sdus]; j++) { + LOG_T(MAC, "%x ", dlsch_buffer[j]); + } - LOG_T(MAC,"\n"); + LOG_T(MAC, "\n"); #endif - - } - } - - // assume the max dtch header size, and adjust it later - header_len_dtch=0; - header_len_dtch_last=0; // the header length of the last mac sdu - // lcid has to be sorted before the actual allocation (similar struct as ue_list). - for (lcid=NB_RB_MAX-1; lcid>=DTCH ; lcid--){ - // TBD: check if the lcid is active - - header_len_dtch+=3; - header_len_dtch_last=3; - if (0)LOG_D(MAC,"[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP,frameP,lcid,TBS, - TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch); - - if (TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch > 0 ) { // NN: > 2 ? - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch + } + } + // assume the max dtch header size, and adjust it later + header_len_dtch = 0; + header_len_dtch_last = 0; // the header length of the last mac sdu + // lcid has to be sorted before the actual allocation (similar struct as ue_list). + for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { + // TBD: check if the lcid is active + + header_len_dtch += 3; + header_len_dtch_last = 3; + LOG_D(MAC, + "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, frameP, lcid, TBS, + TBS - ta_len - header_len_dcch - + sdu_length_total - header_len_dtch); + + if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - + header_len_dcch - + sdu_length_total - + header_len_dtch #ifdef Rel14 - ,0, 0 + ,0, 0 #endif ); - - - if (rlc_status.bytes_in_buffer > 0) { - - LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP,frameP,TBS-header_len_dcch-sdu_length_total-header_len_dtch,lcid, header_len_dtch); - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS, //not used - (char*)&dlsch_buffer[sdu_length_total] -#ifdef Rel14 - ,0, - 0 -#endif - ); - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), T_INT(lcid), T_INT(sdu_lengths[num_sdus])); - - LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",module_idP,sdu_lengths[num_sdus],lcid); - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid]+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid]+=sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) { - header_len_dtch--; - header_len_dtch_last--; - } - num_sdus++; - } // no data for this LCID - else { - header_len_dtch-=3; - } - } // no TBS left - else { - header_len_dtch-=3; - break; - } - } - if (header_len_dtch == 0 ) - header_len_dtch_last= 0; - // there is at least one SDU - // if (num_sdus > 0 ){ - if ((sdu_length_total + header_len_dcch + header_len_dtch )> 0) { - - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - // adjust header lengths - header_len_dcch_tmp = header_len_dcch; - header_len_dtch_tmp = header_len_dtch; - if (header_len_dtch==0) { - header_len_dcch = (header_len_dcch >0) ? 1 : 0;//header_len_dcch; // remove length field - } else { - header_len_dtch_last-=1; // now use it to find how many bytes has to be removed for the last MAC SDU - header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last :header_len_dtch; // remove length field for the last SDU - } - - mcs = eNB_UE_stats->dlsch_mcs1; - - if (mcs==0) { - nb_rb = 4; // don't let the TBS get too small - } else { - nb_rb=min_rb_unit[CC_id]; - } - TBS = get_TBS_DL(mcs,nb_rb); - while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) { - nb_rb += min_rb_unit[CC_id]; // - if (nb_rb>nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_available_rb); - nb_rb = nb_available_rb; - break; - } - - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rb); - } + if (rlc_status.bytes_in_buffer > 0) { - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for(j=0; j<N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - - while((nb_rb_temp > 0) && (j<N_RBG[CC_id])) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if ((j == N_RBG[CC_id]-1) && - ((N_RB_DL[CC_id] == 25)|| - (N_RB_DL[CC_id] == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - - j = j+1; - } - } - - // decrease mcs until TBS falls below required length - while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs>0)) { - mcs--; - TBS = get_TBS_DL(mcs,nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && ((( ue_sched_ctl->dl_pow_off[CC_id]>0) && (mcs<28)) - || ( (ue_sched_ctl->dl_pow_off[CC_id]==0) && (mcs<=15)))) { - mcs++; - TBS = get_TBS_DL(mcs,nb_rb); - } - - //LOG_D(MAC,"dlsch_mcs before and after the rate matching = (%d, %d)\n",eNB_UE_stats->dlsch_mcs1, mcs); + LOG_D(MAC, + "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, frameP, + TBS - header_len_dcch - + sdu_length_total - header_len_dtch, lcid, + header_len_dtch); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, TBS, //not used + (char*)&dlsch_buffer[sdu_length_total] +#ifdef Rel14 + ,0, + 0 +#endif + ); + + + + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(lcid), T_INT(sdu_lengths[num_sdus])); + + LOG_D(MAC, + "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, sdu_lengths[num_sdus], lcid); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] + += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx + [lcid] += sdu_lengths[num_sdus]; + if (sdu_lengths[num_sdus] < 128) { + header_len_dtch--; + header_len_dtch_last--; + } + num_sdus++; + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + } // no data for this LCID + else { + header_len_dtch -= 3; + } + } // no TBS left + else { + header_len_dtch -= 3; + break; + } + } + if (header_len_dtch == 0) + header_len_dtch_last = 0; + // there is at least one SDU + // if (num_sdus > 0 ){ + if ((sdu_length_total + header_len_dcch + + header_len_dtch) > 0) { + + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 + // adjust header lengths + header_len_dcch_tmp = header_len_dcch; + header_len_dtch_tmp = header_len_dtch; + if (header_len_dtch == 0) { + header_len_dcch = (header_len_dcch > 0) ? 1 : 0; //header_len_dcch; // remove length field + } else { + header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU + header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU + } + + mcs = eNB_UE_stats->dlsch_mcs1; + + if (mcs == 0) { + nb_rb = 4; // don't let the TBS get too small + } else { + nb_rb = min_rb_unit[CC_id]; + } + + TBS = get_TBS_DL(mcs, nb_rb); + + while (TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) { + nb_rb += min_rb_unit[CC_id]; // + + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, + nb_available_rb); + nb_rb = nb_available_rb; + break; + } + + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[CC_id] == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + + j = j + 1; + } + } + + // decrease mcs until TBS falls below required length + while ((TBS > + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) && (mcs > 0)) { + mcs--; + TBS = get_TBS_DL(mcs, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) + && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) + && (mcs < 28)) + || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) + && (mcs <= 15)))) { + mcs++; + TBS = get_TBS_DL(mcs, nb_rb); + } + + LOG_D(MAC, + "dlsch_mcs before and after the rate matching = (%d, %d)\n", + eNB_UE_stats->dlsch_mcs1, mcs); #ifdef DEBUG_eNB_SCHEDULER - LOG_D(MAC,"[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", - module_idP,CC_id,mcs,TBS,nb_rb); - // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", - // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); + LOG_D(MAC, + "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP, CC_id, mcs, TBS, nb_rb); + // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", + // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); #endif - if ((TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len) <= 2) { - padding = (TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len); - post_padding = 0; - } else { - padding = 0; - - // adjust the header len - if (header_len_dtch==0) { - header_len_dcch = header_len_dcch_tmp; - } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) - header_len_dtch = header_len_dtch_tmp; - } - - post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len ; // 1 is for the postpadding header - } - - - offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], - num_sdus, //num_sdus - sdu_lengths, // - sdu_lcids, - 255, // no drx - ta_update, // timing advance - NULL, // contention res id - padding, - post_padding); - - //#ifdef DEBUG_eNB_SCHEDULER - if (ta_update != 31) { - LOG_D(MAC, - "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", - module_idP,frameP, UE_id, CC_id, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset, - ta_update,padding,post_padding,mcs,TBS,nb_rb,header_len_dcch,header_len_dtch); - } - //#endif + if ((TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len) <= 2) { + padding = + (TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len); + post_padding = 0; + } else { + padding = 0; + + // adjust the header len + if (header_len_dtch == 0) { + header_len_dcch = header_len_dcch_tmp; + } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) + header_len_dtch = header_len_dtch_tmp; + } + + post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header + } + + + offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, post_padding); + + //#ifdef DEBUG_eNB_SCHEDULER + if (ta_update != 31) { + LOG_D(MAC, + "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", + module_idP, frameP, UE_id, CC_id, + sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], offset, ta_update, padding, + post_padding, mcs, TBS, nb_rb, + header_len_dcch, header_len_dtch); + } + //#endif #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC,"[eNB %d] First 16 bytes of DLSCH : \n"); + LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n"); - for (i=0; i<16; i++) { - LOG_T(MAC,"%x.",dlsch_buffer[i]); - } + for (i = 0; i < 16; i++) { + LOG_T(MAC, "%x.", dlsch_buffer[i]); + } - LOG_T(MAC,"\n"); + LOG_T(MAC, "\n"); #endif - // cycle through SDUs and place in dlsch_buffer - memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total); - // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); - - // fill remainder of DLSCH with random data - for (j=0; j<(TBS-sdu_length_total-offset); j++) { - UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff); - } - - - if (opt_enabled == 1) { - trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], - TBS, module_idP, 3, UE_RNTI(module_idP,UE_id), - eNB->frame, eNB->subframe,0,0); - LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", - module_idP, CC_id, frameP, UE_RNTI(module_idP,UE_id), TBS); - } - - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); - - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - - add_ue_dlsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_DL_SCHEDULED); - // store stats - eNB->eNB_stats[CC_id].dlsch_bytes_tx+=sdu_length_total; - eNB->eNB_stats[CC_id].dlsch_pdus_tx+=1; - - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=mcs; - UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; - - UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes= TBS- sdu_length_total; - UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes+= sdu_length_total; - UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes+= TBS; - UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus+=1; - - if (cc[CC_id].tdd_Config != NULL) { // TDD - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI); - } - - // do PUCCH power control - // this is the normalized RX power - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - - /* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */ - normalized_rx_power = ue_sched_ctl->pucch1_snr[CC_id]; - target_rx_power = 208; - - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; - if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { - ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; - - if (normalized_rx_power>(target_rx_power+4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - - if(0)LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP,frameP, subframeP,harq_pid,tpc, - tpc_accumulated,normalized_rx_power,target_rx_power); - - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; - //deactivate second codeword - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; - if (cc[CC_id].tdd_Config != NULL) { //TDD - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", - module_idP,CC_id,harq_pid, - (UE_list->UE_template[CC_id][UE_id].DAI-1), - mcs); - } else { - struct timespec t; - clock_gettime(CLOCK_MONOTONIC, &t); - LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d t:%ld.%09ld\n", - module_idP,CC_id,harq_pid,mcs,t.tv_sec,t.tv_nsec); - - } - //LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); - if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { - - - ue_sched_ctl->round[CC_id][harq_pid] = 0; - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - // Toggle NDI for next time - LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", - CC_id, frameP,subframeP,UE_id, - rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); - - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); - - fill_nfapi_dlsch_config(eNB,dl_req, - TBS, - eNB->pdu_index[CC_id], - rnti, - 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(mcs), - 0, // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, - 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, - (frameP*10)+subframeP, - TBS, - eNB->pdu_index[CC_id], - eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); - - LOG_D(MAC,"SFN/SF:%d Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n",NFAPI_SFNSF2DEC(eNB->TX_req[CC_id].sfn_sf), eNB->pdu_index[CC_id]); - - eNB->pdu_index[CC_id]++; - program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - - } - else { - LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", - frameP,subframeP,UE_id,rnti); - } - } else { // There is no data from RLC or MAC header, so don't schedule - - } - } + // cycle through SDUs and place in dlsch_buffer + memcpy(&UE_list-> + DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], + dlsch_buffer, sdu_length_total); + // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); + + // fill remainder of DLSCH with random data + for (j = 0; j < (TBS - sdu_length_total - offset); j++) { + UE_list->DLSCH_pdu[CC_id][0][UE_id]. + payload[0][offset + sdu_length_total + j] = + (char) (taus() & 0xff); + } + + + if (opt_enabled == 1) { + trace_pdu(1, (uint8_t *) + UE_list->DLSCH_pdu[CC_id][0][UE_id]. + payload[0], TBS, module_idP, 3, + UE_RNTI(module_idP, UE_id), eNB->frame, + eNB->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", + module_idP, CC_id, frameP, + UE_RNTI(module_idP, UE_id), TBS); + } + + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id]. + payload[0], TBS)); + + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = + nb_rb; + + add_ue_dlsch_info(module_idP, + CC_id, UE_id, subframeP, + S_DL_SCHEDULED); + // store stats + eNB->eNB_stats[CC_id].dlsch_bytes_tx += + sdu_length_total; + eNB->eNB_stats[CC_id].dlsch_pdus_tx += 1; + + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += + nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = + eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = mcs; + UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; + + UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes = + TBS - sdu_length_total; + UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes += + sdu_length_total; + UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes += + TBS; + UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus += + 1; + + if (cc[CC_id].tdd_Config != NULL) { // TDD + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id]. + DAI); + } + // do PUCCH power control + // this is the normalized RX power + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + + /* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */ + normalized_rx_power = ue_sched_ctl->pucch1_snr[CC_id]; + target_rx_power = 208; + + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = + UE_list->UE_template[CC_id][UE_id]. + pucch_tpc_tx_frame * 10 + + UE_list->UE_template[CC_id][UE_id]. + pucch_tpc_tx_subframe; + if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case + ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; + + UE_list-> + UE_template[CC_id] + [UE_id].pucch_tpc_tx_frame = frameP; + UE_list-> + UE_template[CC_id] + [UE_id].pucch_tpc_tx_subframe = subframeP; + + if (normalized_rx_power > + (target_rx_power + 4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power < + (target_rx_power - 4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + + LOG_D(MAC, + "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + module_idP, frameP, subframeP, harq_pid, + tpc, tpc_accumulated, + normalized_rx_power, target_rx_power); + + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } + + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = + NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level = + get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.new_data_indicator_1 = + 1 - + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.redundancy_version_1 = 0; + //deactivate second codeword + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.redundancy_version_2 = 1; + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.downlink_assignment_index = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + LOG_D(MAC, + "[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", + module_idP, CC_id, harq_pid, + (UE_list->UE_template[CC_id][UE_id].DAI - 1), + mcs); + } else { + LOG_D(MAC, + "[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", + module_idP, CC_id, harq_pid, mcs); + + } + LOG_D(MAC, "Checking feasibility pdu %d (new sdu)\n", + dl_req->number_pdu); + if (!CCE_allocation_infeasible + (module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, rnti)) { + + + ue_sched_ctl->round[CC_id][harq_pid] = 0; + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; + + // Toggle NDI for next time + LOG_D(MAC, + "CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frameP, subframeP, UE_id, rnti, + harq_pid, + UE_list-> + UE_template[CC_id][UE_id].oldNDI[harq_pid]); + + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid] = + 1 - + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id]. + oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id]. + oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id] + [UE_id].physicalConfigDedicated != + NULL, + "physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id] + [UE_id]. + physicalConfigDedicated->pdsch_ConfigDedicated + != NULL, + "physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + + fill_nfapi_dlsch_config(eNB, dl_req, TBS, eNB->pdu_index[CC_id], rnti, 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(mcs), 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + eNB->TX_req[CC_id].sfn_sf = + fill_nfapi_tx_req(&eNB-> + TX_req + [CC_id].tx_request_body, + (frameP * 10) + subframeP, + TBS, eNB->pdu_index[CC_id], + eNB-> + UE_list.DLSCH_pdu[CC_id][0][(unsigned char) + UE_id].payload + [0]); + + LOG_D(MAC, + "Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n", + eNB->pdu_index[CC_id]); + + eNB->pdu_index[CC_id]++; + program_dlsch_acknak(module_idP, CC_id, UE_id, + frameP, subframeP, + dl_config_pdu-> + dci_dl_pdu.dci_dl_pdu_rel8. + cce_idx); + + } else { + LOG_W(MAC, + "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", + frameP, subframeP, UE_id, rnti); + } + } else { // There is no data from RLC or MAC header, so don't schedule + + } + } - if (cc[CC_id].tdd_Config != NULL){ // TDD - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } + if (cc[CC_id].tdd_Config != NULL) { // TDD + set_ul_DAI(module_idP, UE_id, CC_id, frameP, subframeP); + } - } // round != 8 - } // UE_id loop + } // UE_id loop + } // CC_id loop - //LOG_D(MAC,"%s() AFTER dl_config dci:%d pdu:%d TX_REQ[pdus:%d]\n", __FUNCTION__, dl_req->number_dci, dl_req->number_pdu, eNB->TX_req[0].tx_request_body.number_of_pdus); - - fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_flag); + fill_DLSCH_dci(module_idP, frameP, subframeP, mbsfn_flag); - stop_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); + stop_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); } //------------------------------------------------------------------------------ void -fill_DLSCH_dci( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - int* mbsfn_flagP - ) +fill_DLSCH_dci(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP, int *mbsfn_flagP) //------------------------------------------------------------------------------ { - // loop over all allocated UEs and compute frequency allocations for PDSCH - int UE_id = -1; - uint8_t /* first_rb, */ nb_rb=3; - rnti_t rnti; - //unsigned char *vrb_map; - uint8_t rballoc_sub[25]; - //uint8_t number_of_subbands=13; - - //unsigned char round; - unsigned char harq_pid; - int i; - int CC_id; - eNB_MAC_INST *eNB =RC.mac[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; - int N_RBG; - int N_RB_DL; - COMMON_channels_t *cc; - - start_meas(&eNB->fill_DLSCH_dci); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_IN); - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - //LOG_D(MAC,"Doing fill DCI for CC_id %d\n",CC_id); - - if (mbsfn_flagP[CC_id]>0) - continue; - - cc = &eNB->common_channels[CC_id]; - N_RBG = to_rbg(cc->mib->message.dl_Bandwidth); - N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); - - // UE specific DCIs - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - LOG_T(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status); - - if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) { - - // clear scheduling flag - eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING; - rnti = UE_RNTI(module_idP,UE_id); - if (cc->tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - - - - /// Synchronizing rballoc with rballoc_sub - for(i=0; i<N_RBG; i++) { - rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; - } - - nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; - nfapi_dl_config_request_pdu_t* dl_config_pdu; - - for (i=0;i<DL_req[CC_id].dl_config_request_body.number_pdu;i++) { - dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[i]; - if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& - (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && - (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; - } - else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE)&& - (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && - (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type==0)) { - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); - } + // loop over all allocated UEs and compute frequency allocations for PDSCH + int UE_id = -1; + uint8_t /* first_rb, */ nb_rb = 3; + rnti_t rnti; + //unsigned char *vrb_map; + uint8_t rballoc_sub[25]; + //uint8_t number_of_subbands=13; + + //unsigned char round; + unsigned char harq_pid; + int i; + int CC_id; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; + int N_RBG; + int N_RB_DL; + COMMON_channels_t *cc; + + start_meas(&eNB->fill_DLSCH_dci); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_IN); + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + LOG_D(MAC, "Doing fill DCI for CC_id %d\n", CC_id); + + if (mbsfn_flagP[CC_id] > 0) + continue; + + cc = &eNB->common_channels[CC_id]; + N_RBG = to_rbg(cc->mib->message.dl_Bandwidth); + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + + // UE specific DCIs + for (UE_id = UE_list->head; UE_id >= 0; + UE_id = UE_list->next[UE_id]) { + LOG_T(MAC, "CC_id %d, UE_id: %d => status %d\n", CC_id, UE_id, + eNB_dlsch_info[module_idP][CC_id][UE_id].status); + + if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == + S_DL_SCHEDULED) { + + // clear scheduling flag + eNB_dlsch_info[module_idP][CC_id][UE_id].status = + S_DL_WAITING; + rnti = UE_RNTI(module_idP, UE_id); + if (cc->tdd_Config) + harq_pid = ((frameP * 10) + subframeP) % 10; + else + harq_pid = ((frameP * 10) + subframeP) & 7; + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + + + + /// Synchronizing rballoc with rballoc_sub + for (i = 0; i < N_RBG; i++) { + rballoc_sub[i] = + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband[harq_pid] + [i]; + } + + nfapi_dl_config_request_t *DL_req = + &RC.mac[module_idP]->DL_req[0]; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + + for (i = 0; + i < DL_req[CC_id].dl_config_request_body.number_pdu; + i++) { + dl_config_pdu = + &DL_req[CC_id]. + dl_config_request_body.dl_config_pdu_list[i]; + if ((dl_config_pdu->pdu_type == + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + && (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + rnti == rnti) + && (dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.dci_format != 1)) { + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding = + allocate_prbs_sub(nb_rb, N_RB_DL, N_RBG, + rballoc_sub); + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_allocation_type = 0; + } else + if ((dl_config_pdu->pdu_type == + NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) + && (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8. + rnti == rnti) + && (dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.resource_allocation_type == + 0)) { + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.resource_block_coding = + allocate_prbs_sub(nb_rb, N_RB_DL, N_RBG, + rballoc_sub); + } + } + } } - } } - } - - stop_meas(&eNB->fill_DLSCH_dci); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_OUT); + stop_meas(&eNB->fill_DLSCH_dci); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_OUT); } //------------------------------------------------------------------------------ -unsigned char* -get_dlsch_sdu( - module_id_t module_idP, - int CC_id, - frame_t frameP, - rnti_t rntiP, - uint8_t TBindex -) +unsigned char *get_dlsch_sdu(module_id_t module_idP, + int CC_id, frame_t frameP, rnti_t rntiP, + uint8_t TBindex) //------------------------------------------------------------------------------ { - int UE_id; - eNB_MAC_INST *eNB=RC.mac[module_idP]; + int UE_id; + eNB_MAC_INST *eNB = RC.mac[module_idP]; - if (rntiP==SI_RNTI) { - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d Get DLSCH sdu for BCCH \n", module_idP, CC_id, frameP); + if (rntiP == SI_RNTI) { + LOG_D(MAC, "[eNB %d] CC_id %d Frame %d Get DLSCH sdu for BCCH \n", + module_idP, CC_id, frameP); - return((unsigned char *)&eNB->common_channels[CC_id].BCCH_pdu.payload[0]); - } + return ((unsigned char *) &eNB->common_channels[CC_id]. + BCCH_pdu.payload[0]); + } + + if (rntiP==P_RNTI) { + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d Get PCH sdu for PCCH \n", module_idP, CC_id, frameP); + + return((unsigned char *)&eNB->common_channels[CC_id].PCCH_pdu.payload[0]); + } UE_id = find_UE_id(module_idP,rntiP); - if (UE_id != -1) { - LOG_D(MAC,"[eNB %d] Frame %d: CC_id %d Get DLSCH sdu for rnti %x => UE_id %d\n",module_idP,frameP,CC_id,rntiP,UE_id); - return((unsigned char *)&eNB->UE_list.DLSCH_pdu[CC_id][TBindex][UE_id].payload[0]); - } else { - LOG_E(MAC,"[eNB %d] Frame %d: CC_id %d UE with RNTI %x does not exist\n", module_idP,frameP,CC_id,rntiP); - return NULL; - } + if (UE_id != -1) { + LOG_D(MAC, + "[eNB %d] Frame %d: CC_id %d Get DLSCH sdu for rnti %x => UE_id %d\n", + module_idP, frameP, CC_id, rntiP, UE_id); + return ((unsigned char *) &eNB-> + UE_list.DLSCH_pdu[CC_id][TBindex][UE_id].payload[0]); + } else { + LOG_E(MAC, + "[eNB %d] Frame %d: CC_id %d UE with RNTI %x does not exist\n", + module_idP, frameP, CC_id, rntiP); + return NULL; + } } //------------------------------------------------------------------------------ -void update_ul_dci(module_id_t module_idP, - uint8_t CC_idP, - rnti_t rntiP, - uint8_t daiP) +void +update_ul_dci(module_id_t module_idP, + uint8_t CC_idP, rnti_t rntiP, uint8_t daiP) //------------------------------------------------------------------------------ { - nfapi_hi_dci0_request_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP]; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; - COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_idP]; - int i; + nfapi_hi_dci0_request_t *HI_DCI0_req = + &RC.mac[module_idP]->HI_DCI0_req[CC_idP]; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = + &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; + COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_idP]; + int i; - if (cc->tdd_Config != NULL) { // TDD - for (i=0; i<HI_DCI0_req->hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_dci; i++) { + if (cc->tdd_Config != NULL) { // TDD + for (i = 0; + i < + HI_DCI0_req->hi_dci0_request_body.number_of_dci + + HI_DCI0_req->hi_dci0_request_body.number_of_dci; i++) { - if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) && - (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) - hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.dl_assignment_index = (daiP-1)&3; - + if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) && + (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) + hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.dl_assignment_index = + (daiP - 1) & 3; + + } } - } } //------------------------------------------------------------------------------ -void set_ue_dai( - sub_frame_t subframeP, - int UE_id, - uint8_t CC_id, - uint8_t tdd_config, - UE_list_t* UE_list -) +void +set_ue_dai(sub_frame_t subframeP, + int UE_id, uint8_t CC_id, uint8_t tdd_config, + UE_list_t * UE_list) //------------------------------------------------------------------------------ { - switch (tdd_config) { - case 0: - if ((subframeP==0)||(subframeP==1)||(subframeP==3)||(subframeP==5)||(subframeP==6)||(subframeP==8)) { - UE_list->UE_template[CC_id][UE_id].DAI = 0; - } + switch (tdd_config) { + case 0: + if ((subframeP == 0) || (subframeP == 1) || (subframeP == 3) + || (subframeP == 5) || (subframeP == 6) || (subframeP == 8)) { + UE_list->UE_template[CC_id][UE_id].DAI = 0; + } - break; + break; - case 1: - if ((subframeP==0)||(subframeP==4)||(subframeP==5)||(subframeP==9)) { - UE_list->UE_template[CC_id][UE_id].DAI = 0; - } + case 1: + if ((subframeP == 0) || (subframeP == 4) || (subframeP == 5) + || (subframeP == 9)) { + UE_list->UE_template[CC_id][UE_id].DAI = 0; + } - break; + break; - case 2: - if ((subframeP==4)||(subframeP==5)) { - UE_list->UE_template[CC_id][UE_id].DAI = 0; - } + case 2: + if ((subframeP == 4) || (subframeP == 5)) { + UE_list->UE_template[CC_id][UE_id].DAI = 0; + } - break; + break; - case 3: - if ((subframeP==5)||(subframeP==7)||(subframeP==9)) { - UE_list->UE_template[CC_id][UE_id].DAI = 0; - } + case 3: + if ((subframeP == 5) || (subframeP == 7) || (subframeP == 9)) { + UE_list->UE_template[CC_id][UE_id].DAI = 0; + } - break; + break; - case 4: - if ((subframeP==0)||(subframeP==6)) { - UE_list->UE_template[CC_id][UE_id].DAI = 0; - } + case 4: + if ((subframeP == 0) || (subframeP == 6)) { + UE_list->UE_template[CC_id][UE_id].DAI = 0; + } - break; + break; - case 5: - if (subframeP==9) { - UE_list->UE_template[CC_id][UE_id].DAI = 0; - } + case 5: + if (subframeP == 9) { + UE_list->UE_template[CC_id][UE_id].DAI = 0; + } - break; + break; - case 6: - if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6)||(subframeP==9)) { - UE_list->UE_template[CC_id][UE_id].DAI = 0; + case 6: + if ((subframeP == 0) || (subframeP == 1) || (subframeP == 5) + || (subframeP == 6) || (subframeP == 9)) { + UE_list->UE_template[CC_id][UE_id].DAI = 0; + } + + break; + + default: + UE_list->UE_template[CC_id][UE_id].DAI = 0; + LOG_N(MAC, "unknow TDD config %d\n", tdd_config); + break; } +} + +void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) +{ + /* DCI:format 1A/1C P-RNTI:0xFFFE */ + /* PDU:eNB_rrc_inst[Mod_idP].common_channels[CC_id].PCCH_pdu.payload */ + uint16_t pcch_sdu_length; + int mcs = -1; + int CC_id; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc; + uint8_t *vrb_map; + int n_rb_dl; + int first_rb = -1; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + nfapi_tx_request_pdu_t *TX_req; + nfapi_dl_config_request_body_t *dl_req; +#ifdef FORMAT1C + int gap_index = 0; /* indicate which gap(1st or 2nd) is used (0:1st) */ + const int GAP_MAP [9][2] = { + {-1, 0}, /* N_RB_DL [6-10] -1: |N_RB/2| 0: N/A*/ + {4, 0}, /* N_RB_DL [11] */ + {8, 0}, /* N_RB_DL [12-19] */ + {12, 0}, /* N_RB_DL [20-26] */ + {18, 0}, /* N_RB_DL [27-44] */ + {27, 0}, /* N_RB_DL [45-49] */ + {27, 9}, /* N_RB_DL [50-63] */ + {32, 16}, /* N_RB_DL [64-79] */ + {48, 16} /* N_RB_DL [80-110] */ + }; + uint8_t n_rb_step = 0; + uint8_t n_gap = 0; + uint8_t n_vrb_dl = 0; + uint8_t Lcrbs = 0; + uint16_t rb_bit = 168; /* RB bit number value is unsure */ + #endif + + start_meas(&eNB->schedule_pch); + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + cc = &eNB->common_channels[CC_id]; + vrb_map = (void*)&cc->vrb_map; + n_rb_dl = to_prb(cc->mib->message.dl_Bandwidth); + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (uint16_t i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_PF_PO[CC_id][i].enable_flag != TRUE) { + continue; + } + if (frameP % UE_PF_PO[CC_id][i].T == UE_PF_PO[CC_id][i].PF_min && subframeP == UE_PF_PO[CC_id][i].PO) { + pcch_sdu_length = mac_rrc_data_req(module_idP, + CC_id, + frameP, + PCCH,1, + &cc->PCCH_pdu.payload[0], + i); // used for ue index + if (pcch_sdu_length == 0) { + LOG_D(MAC,"[eNB %d] Frame %d subframe %d: PCCH not active(size = 0 byte)\n", module_idP,frameP, subframeP); + continue; + } + LOG_D(MAC,"[eNB %d] Frame %d subframe %d: PCCH->PCH CC_id %d UE_id %d, Received %d bytes \n", module_idP, frameP, subframeP, CC_id,i, pcch_sdu_length); +#ifdef FORMAT1C + //NO SIB + if ((subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { + switch (n_rb_dl) { +#if 0 + case 6: + n_gap = n_rb_dl/2; /* expect: 3 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap));; /* expect: 6 */ + first_rb = 0; + break; + case 15: + n_gap = GAP_MAP[2][0]; /* expect: 8 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 14 */ + first_rb = 6; + break; +#endif + case 25: + n_gap = GAP_MAP[3][0]; /* expect: 12 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ + first_rb = 10; + break; + case 50: + n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ + } + first_rb = 24; + break; + case 100: + n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ + } + first_rb = 48; + break; + } + } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging + switch (n_rb_dl) { +#if 0 + case 6: + n_gap = n_rb_dl/2; /* expect: 3 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap));; /* expect: 6 */ + first_rb = 0; + break; + case 15: + n_gap = GAP_MAP[2][0]; /* expect: 8 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 14 */ + first_rb = 10; + break; +#endif + case 25: + n_gap = GAP_MAP[3][0]; /* expect: 12 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ + first_rb = 14; + break; + case 50: + n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ + } + first_rb = 28; + break; + case 100: + n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ + } + first_rb = 52; + break; + } + } + /* Get MCS for length of PCH */ + if (pcch_sdu_length <= TBStable1C[0]) { + mcs=0; + } else if (pcch_sdu_length <= TBStable1C[1]) { + mcs=1; + } else if (pcch_sdu_length <= TBStable1C[2]) { + mcs=2; + } else if (pcch_sdu_length <= TBStable1C[3]) { + mcs=3; + } else if (pcch_sdu_length <= TBStable1C[4]) { + mcs=4; + } else if (pcch_sdu_length <= TBStable1C[5]) { + mcs=5; + } else if (pcch_sdu_length <= TBStable1C[6]) { + mcs=6; + } else if (pcch_sdu_length <= TBStable1C[7]) { + mcs=7; + } else if (pcch_sdu_length <= TBStable1C[8]) { + mcs=8; + } else if (pcch_sdu_length <= TBStable1C[9]) { + mcs=9; + } else { + /* unexpected: pcch sdb size is over max value*/ + LOG_E(MAC,"[eNB %d] Frame %d : PCCH->PCH CC_id %d, Received %d bytes is over max length(256) \n", + module_idP, frameP,CC_id, pcch_sdu_length); + return; + } + rb_num = TBStable1C[mcs] / rb_bit + ( (TBStable1C[mcs] % rb_bit == 0)? 0: 1) + 1; + /* calculate N_RB_STEP and Lcrbs */ + if (n_rb_dl < 50) { + n_rb_step = 2; + Lcrbs = rb_num / 2 + ((rb_num % 2 == 0) ? 0:2); + } else { + n_rb_step = 4; + Lcrbs = rb_num / 4 + ((rb_num % 4 == 0) ? 0:4); + } + for(i = 0;i < Lcrbs ;i++){ + vrb_map[first_rb+i] = 1; + } +#else + //NO SIB + if ((subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { + switch (n_rb_dl) { + case 25: + first_rb = 10; + break; + case 50: + first_rb = 24; + break; + case 100: + first_rb = 48; + break; + } + } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging + switch (n_rb_dl) { + case 25: + first_rb = 14; + break; + case 50: + first_rb = 28; + break; + case 100: + first_rb = 52; + break; + } + } - break; + vrb_map[first_rb] = 1; + vrb_map[first_rb+1] = 1; + vrb_map[first_rb+2] = 1; + vrb_map[first_rb+3] = 1; + /* Get MCS for length of PCH */ + if (pcch_sdu_length <= get_TBS_DL(0,3)) { + mcs=0; + } else if (pcch_sdu_length <= get_TBS_DL(1,3)) { + mcs=1; + } else if (pcch_sdu_length <= get_TBS_DL(2,3)) { + mcs=2; + } else if (pcch_sdu_length <= get_TBS_DL(3,3)) { + mcs=3; + } else if (pcch_sdu_length <= get_TBS_DL(4,3)) { + mcs=4; + } else if (pcch_sdu_length <= get_TBS_DL(5,3)) { + mcs=5; + } else if (pcch_sdu_length <= get_TBS_DL(6,3)) { + mcs=6; + } else if (pcch_sdu_length <= get_TBS_DL(7,3)) { + mcs=7; + } else if (pcch_sdu_length <= get_TBS_DL(8,3)) { + mcs=8; + } else if (pcch_sdu_length <= get_TBS_DL(9,3)) { + mcs=9; + } +#endif + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); +#ifdef FORMAT1C + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1C; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(n_vrb_dl/n_rb_step, first_rb/n_rb_step, Lcrbs/n_rb_step); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.ngap = n_gap; +#else + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(n_rb_dl,first_rb,4); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; +#endif + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = 0xFFFE; // P-RNTI + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // P-RNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + + // Rel10 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; + // Rel13 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 0; // regular UE + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not BR + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; + + if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, P_RNTI)) { + LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for P_RNTI\n", frameP,subframeP); + dl_req->number_dci++; + dl_req->number_pdu++; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFE; +#ifdef FORMAT1C + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 3; // format 1C + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_vrb_dl/n_rb_step, first_rb/n_rb_step, Lcrbs/n_rb_step); +#else + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_rb_dl,first_rb,4); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized +#endif + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + dl_req->number_pdu++; + + eNB->TX_req[CC_id].sfn_sf = (frameP<<4)+subframeP; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; + TX_req->pdu_length = pcch_sdu_length; + TX_req->pdu_index = eNB->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = pcch_sdu_length; + TX_req->segments[0].segment_data = cc[CC_id].PCCH_pdu.payload; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; + } else { + LOG_E(MAC,"[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A/1C for Paging\n",module_idP, CC_id, frameP, subframeP); + continue; + } - default: - UE_list->UE_template[CC_id][UE_id].DAI = 0; - LOG_N(MAC,"unknow TDD config %d\n",tdd_config); - break; + if (opt_enabled == 1) { + trace_pdu(1, + &eNB->common_channels[CC_id].PCCH_pdu.payload[0], + pcch_sdu_length, + 0xffff, + PCCH, + P_RNTI, + eNB->frame, + eNB->subframe, + 0, + 0); + LOG_D(OPT,"[eNB %d][PCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, pcch_sdu_length); + } + eNB->eNB_stats[CC_id].total_num_pcch_pdu+=1; + eNB->eNB_stats[CC_id].pcch_buffer=pcch_sdu_length; + eNB->eNB_stats[CC_id].total_pcch_buffer+=pcch_sdu_length; + eNB->eNB_stats[CC_id].pcch_mcs=mcs; + //paging first_rb log + LOG_D(MAC,"[eNB %d] Frame %d subframe %d PCH: paging_ue_index %d pcch_sdu_length %d mcs %d first_rb %d\n", + module_idP, frameP, subframeP, UE_PF_PO[CC_id][i].ue_index_value, pcch_sdu_length, mcs, first_rb); + + pthread_mutex_lock(&ue_pf_po_mutex); + memset(&UE_PF_PO[CC_id][i], 0, sizeof(UE_PF_PO_t)); + pthread_mutex_unlock(&ue_pf_po_mutex); + } + } } + /* this might be misleading when pcch is inactive */ + stop_meas(&eNB->schedule_pch); + return; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index f6b4d02f0abc945869ce8069964c3dca02d721a5..9e2deca20252a554446944cd7defdde471949f69 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -52,10 +52,10 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/defs.h" // for taus #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 @@ -63,616 +63,756 @@ extern RAN_CONTEXT_t RC; #if defined(Rel10) || defined(Rel14) -int8_t get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t CC_id, uint8_t mbsfn_sync_area) +int8_t +get_mbsfn_sf_alloction(module_id_t module_idP, uint8_t CC_id, + uint8_t mbsfn_sync_area) { - // currently there is one-to-one mapping between sf allocation pattern and sync area - if (mbsfn_sync_area > MAX_MBSFN_AREA) { - LOG_W(MAC,"[eNB %d] CC_id %d MBSFN synchronization area %d out of range\n ", module_idP, CC_id, mbsfn_sync_area); - return -1; - } else if (RC.mac[module_idP]->common_channels[CC_id].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) { - return mbsfn_sync_area; - } else { - LOG_W(MAC,"[eNB %d] CC_id %d MBSFN Subframe Config pattern %d not found \n ", module_idP, CC_id, mbsfn_sync_area); - return -1; - } + // currently there is one-to-one mapping between sf allocation pattern and sync area + if (mbsfn_sync_area > MAX_MBSFN_AREA) { + LOG_W(MAC, + "[eNB %d] CC_id %d MBSFN synchronization area %d out of range\n ", + module_idP, CC_id, mbsfn_sync_area); + return -1; + } else if (RC.mac[module_idP]-> + common_channels[CC_id].mbsfn_SubframeConfig[mbsfn_sync_area] + != NULL) { + return mbsfn_sync_area; + } else { + LOG_W(MAC, + "[eNB %d] CC_id %d MBSFN Subframe Config pattern %d not found \n ", + module_idP, CC_id, mbsfn_sync_area); + return -1; + } } -int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_frame_t subframeP) +int +schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, + sub_frame_t subframeP) { - int mcch_flag=0,mtch_flag=0, msi_flag=0; - int mbsfn_period =0;// 1<<(RC.mac[module_idP]->mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); - int mcch_period = 0;//32<<(RC.mac[module_idP]->mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - int mch_scheduling_period = 8<<(RC.mac[module_idP]->common_channels[CC_id].pmch_Config[0]->mch_SchedulingPeriod_r9); - unsigned char mcch_sdu_length; - unsigned char header_len_mcch=0,header_len_msi=0,header_len_mtch=0, header_len_mtch_temp=0, header_len_mcch_temp=0, header_len_msi_temp=0; - int ii=0, msi_pos=0; - int mcch_mcs = -1; - uint16_t TBS,j=-1,padding=0,post_padding=0; - mac_rlc_status_resp_t rlc_status; - int num_mtch; - int msi_length,i,k; - unsigned char sdu_lcids[11], num_sdus=0, offset=0; - uint16_t sdu_lengths[11], sdu_length_total=0; - unsigned char mch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; // check the max value, this is for dlsch only - - COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; - - cc->MCH_pdu.Pdu_size=0; - - for (i=0; - i< cc->num_active_mbsfn_area; - i++ ) { - // assume, that there is always a mapping - if ((j=get_mbsfn_sf_alloction(module_idP,CC_id,i)) == -1) { - return 0; + int mcch_flag = 0, mtch_flag = 0, msi_flag = 0; + int mbsfn_period = 0; // 1<<(RC.mac[module_idP]->mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); + int mcch_period = 0; //32<<(RC.mac[module_idP]->mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + int mch_scheduling_period = + 8 << (RC.mac[module_idP]->common_channels[CC_id]. + pmch_Config[0]->mch_SchedulingPeriod_r9); + unsigned char mcch_sdu_length; + unsigned char header_len_mcch = 0, header_len_msi = + 0, header_len_mtch = 0, header_len_mtch_temp = + 0, header_len_mcch_temp = 0, header_len_msi_temp = 0; + int ii = 0, msi_pos = 0; + int mcch_mcs = -1; + uint16_t TBS, j = -1, padding = 0, post_padding = 0; + mac_rlc_status_resp_t rlc_status; + int num_mtch; + int msi_length, i, k; + unsigned char sdu_lcids[11], num_sdus = 0, offset = 0; + uint16_t sdu_lengths[11], sdu_length_total = 0; + unsigned char mch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; // check the max value, this is for dlsch only + + COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; + + cc->MCH_pdu.Pdu_size = 0; + + for (i = 0; i < cc->num_active_mbsfn_area; i++) { + // assume, that there is always a mapping + if ((j = get_mbsfn_sf_alloction(module_idP, CC_id, i)) == -1) { + return 0; + } + + mbsfn_period = + 1 << (cc->mbsfn_SubframeConfig[j]->radioframeAllocationPeriod); + mcch_period = + 32 << (cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_RepetitionPeriod_r9); + msi_pos = 0; + ii = 0; + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d subframeP %d : Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d)\n", + module_idP, CC_id, frameP, subframeP, i, + cc->num_active_mbsfn_area, j, cc->num_sf_allocation_pattern, + mbsfn_period, mcch_period); + + + switch (cc->mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { + case 0: + mcch_mcs = 2; + break; + + case 1: + mcch_mcs = 7; + break; + + case 2: + mcch_mcs = 13; + break; + + case 3: + mcch_mcs = 19; + break; + } + + // 1st: Check the MBSFN subframes from SIB2 info (SF allocation pattern i, max 8 non-overlapping patterns exist) + if (frameP % mbsfn_period == cc->mbsfn_SubframeConfig[j]->radioframeAllocationOffset) { // MBSFN frameP + if (cc->mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format + + // Find the first subframeP in this MCH to transmit MSI + if (frameP % mch_scheduling_period == + cc->mbsfn_SubframeConfig[j]-> + radioframeAllocationOffset) { + while (ii == 0) { + ii = cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & (0x80 >> msi_pos); + msi_pos++; + } + + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d subframeP %d : sync area %d sf allocation pattern %d sf alloc %x msi pos is %d \n", + module_idP, CC_id, frameP, subframeP, i, j, + cc->mbsfn_SubframeConfig[j]-> + subframeAllocation.choice.oneFrame.buf[0], + msi_pos); + } + // Check if the subframeP is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 + switch (subframeP) { + case 1: + if (cc->tdd_Config == NULL) { + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == + MBSFN_FDD_SF1) { + if (msi_pos == 1) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF1) == + MBSFN_FDD_SF1)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + + case 2: + if (cc->tdd_Config == NULL) { + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == + MBSFN_FDD_SF2) { + if (msi_pos == 2) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF2) == + MBSFN_FDD_SF2)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + + case 3: + if (cc->tdd_Config != NULL) { // TDD + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == + MBSFN_TDD_SF3) { + if (msi_pos == 1) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF3) == + MBSFN_TDD_SF3)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } else { // FDD + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == + MBSFN_FDD_SF3) { + if (msi_pos == 3) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF3) == + MBSFN_FDD_SF3)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + + case 4: + if (cc->tdd_Config != NULL) { + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == + MBSFN_TDD_SF4) { + if (msi_pos == 2) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF4) == + MBSFN_TDD_SF4)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + + case 6: + if (cc->tdd_Config == NULL) { + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == + MBSFN_FDD_SF6) { + if (msi_pos == 4) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF6) == + MBSFN_FDD_SF6)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + + case 7: + if (cc->tdd_Config != NULL) { // TDD + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == + MBSFN_TDD_SF7) { + if (msi_pos == 3) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF7) == + MBSFN_TDD_SF7)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } else { // FDD + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == + MBSFN_FDD_SF7) { + if (msi_pos == 5) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF7) == + MBSFN_FDD_SF7)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + + case 8: + if (cc->tdd_Config != NULL) { //TDD + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == + MBSFN_TDD_SF8) { + if (msi_pos == 4) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF8) == + MBSFN_TDD_SF8)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } else { // FDD + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == + MBSFN_FDD_SF8) { + if (msi_pos == 6) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF8) == + MBSFN_FDD_SF8)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + + case 9: + if (cc->tdd_Config != NULL) { + if ((cc-> + mbsfn_SubframeConfig[j]->subframeAllocation. + choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == + MBSFN_TDD_SF9) { + if (msi_pos == 5) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_Offset_r9) + && + ((cc->mbsfn_AreaInfo[i]-> + mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF9) == + MBSFN_TDD_SF9)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } + + break; + } // end switch + + // sf allocation is non-overlapping + if ((msi_flag == 1) || (mcch_flag == 1) + || (mtch_flag == 1)) { + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", + module_idP, CC_id, frameP, subframeP, i, j, + msi_flag, mcch_flag, mtch_flag); + break; + } + } else { // four-frameP format + } + } + } // end of for loop + + cc->msi_active = 0; + cc->mcch_active = 0; + cc->mtch_active = 0; + + // Calculate the mcs + if ((msi_flag == 1) || (mcch_flag == 1)) { + cc->MCH_pdu.mcs = mcch_mcs; + } else if (mtch_flag == 1) { // only MTCH in this subframeP + cc->MCH_pdu.mcs = cc->pmch_Config[0]->dataMCS_r9; } - - mbsfn_period = 1<<(cc->mbsfn_SubframeConfig[j]->radioframeAllocationPeriod); - mcch_period = 32<<(cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - msi_pos=0; - ii=0; - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d : Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d)\n", - module_idP, CC_id, frameP, subframeP,i,cc->num_active_mbsfn_area, - j,cc->num_sf_allocation_pattern,mbsfn_period,mcch_period); - - - switch (cc->mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { - case 0: - mcch_mcs = 2; - break; - - case 1: - mcch_mcs = 7; - break; - - case 2: - mcch_mcs = 13; - break; - - case 3: - mcch_mcs = 19; - break; - } - - // 1st: Check the MBSFN subframes from SIB2 info (SF allocation pattern i, max 8 non-overlapping patterns exist) - if (frameP % mbsfn_period == cc->mbsfn_SubframeConfig[j]->radioframeAllocationOffset) { // MBSFN frameP - if (cc->mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format - - // Find the first subframeP in this MCH to transmit MSI - if (frameP % mch_scheduling_period == cc->mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) { - while (ii == 0) { - ii = cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos); - msi_pos++; - } - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d : sync area %d sf allocation pattern %d sf alloc %x msi pos is %d \n", - module_idP, CC_id, frameP, subframeP,i,j, - cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0], msi_pos); - } - - // Check if the subframeP is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 - switch (subframeP) { - case 1: - if (cc->tdd_Config == NULL) { - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { - if (msi_pos == 1) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 2: - if (cc->tdd_Config == NULL) { - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { - if (msi_pos == 2) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 3: - if (cc->tdd_Config != NULL) { // TDD - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { - if (msi_pos == 1) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } else { // FDD - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { - if (msi_pos == 3) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 4: - if (cc->tdd_Config != NULL) { - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { - if (msi_pos == 2) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 6: - if (cc->tdd_Config == NULL) { - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { - if (msi_pos == 4) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 7: - if (cc->tdd_Config != NULL) { // TDD - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { - if (msi_pos == 3) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } else { // FDD - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { - if (msi_pos == 5) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 8: - if (cc->tdd_Config != NULL) { //TDD - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { - if (msi_pos == 4) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } else { // FDD - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { - if (msi_pos == 6) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 9: - if (cc->tdd_Config != NULL) { - if ((cc->mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { - if (msi_pos == 5) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == cc->mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((cc->mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - }// end switch - - // sf allocation is non-overlapping - if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)) { - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", - module_idP, CC_id, frameP, subframeP,i,j,msi_flag,mcch_flag,mtch_flag); - break; - } - } else { // four-frameP format - } - } - } // end of for loop - - cc->msi_active=0; - cc->mcch_active=0; - cc->mtch_active=0; - - // Calculate the mcs - if ((msi_flag==1) || (mcch_flag==1)) { - cc->MCH_pdu.mcs = mcch_mcs; - } else if (mtch_flag == 1) { // only MTCH in this subframeP - cc->MCH_pdu.mcs = cc->pmch_Config[0]->dataMCS_r9; - } - - - // 2nd: Create MSI, get MCCH from RRC and MTCHs from RLC - - // there is MSI (MCH Scheduling Info) - if (msi_flag == 1) { - // Create MSI here - uint16_t msi_control_element[29], *msi_ptr; - - msi_ptr = &msi_control_element[0]; - ((MSI_ELEMENT *) msi_ptr)->lcid = MCCH_LCHANID; //MCCH - - if (mcch_flag==1) { - ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; - ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0; - } else { // no mcch for this MSP - ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0x7;// stop value is 2047 - ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xff; - } - - msi_ptr+= sizeof(MSI_ELEMENT); - - //Header for MTCHs - num_mtch = cc->mbms_SessionList[0]->list.count; - - for (k=0; k<num_mtch; k++) { // loop for all session in this MCH (MCH[0]) at this moment - ((MSI_ELEMENT *) msi_ptr)->lcid = cc->mbms_SessionList[0]->list.array[k]->logicalChannelIdentity_r9;//mtch_lcid; - ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; // last subframeP of this mtch (only one mtch now) - ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xB; - msi_ptr+=sizeof(MSI_ELEMENT); - } - - msi_length = msi_ptr-msi_control_element; - - if (msi_length<128) { - header_len_msi = 2; - } else { - header_len_msi = 3; + // 2nd: Create MSI, get MCCH from RRC and MTCHs from RLC + + // there is MSI (MCH Scheduling Info) + if (msi_flag == 1) { + // Create MSI here + uint16_t msi_control_element[29], *msi_ptr; + + msi_ptr = &msi_control_element[0]; + ((MSI_ELEMENT *) msi_ptr)->lcid = MCCH_LCHANID; //MCCH + + if (mcch_flag == 1) { + ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; + ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0; + } else { // no mcch for this MSP + ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0x7; // stop value is 2047 + ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xff; + } + + msi_ptr += sizeof(MSI_ELEMENT); + + //Header for MTCHs + num_mtch = cc->mbms_SessionList[0]->list.count; + + for (k = 0; k < num_mtch; k++) { // loop for all session in this MCH (MCH[0]) at this moment + ((MSI_ELEMENT *) msi_ptr)->lcid = cc->mbms_SessionList[0]->list.array[k]->logicalChannelIdentity_r9; //mtch_lcid; + ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; // last subframeP of this mtch (only one mtch now) + ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xB; + msi_ptr += sizeof(MSI_ELEMENT); + } + + msi_length = msi_ptr - msi_control_element; + + if (msi_length < 128) { + header_len_msi = 2; + } else { + header_len_msi = 3; + } + + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d : MSI->MCH, length of MSI is %d bytes \n", + module_idP, CC_id, frameP, msi_length); + //LOG_D(MAC,"Scheduler: MSI is transmitted in this subframeP \n" ); + + // LOG_D(MAC,"Scheduler: MSI length is %d bytes\n",msi_length); + // Store MSI data to mch_buffer[0] + memcpy((char *) &mch_buffer[sdu_length_total], + msi_control_element, msi_length); + + sdu_lcids[num_sdus] = MCH_SCHDL_INFO; + sdu_lengths[num_sdus] = msi_length; + sdu_length_total += sdu_lengths[num_sdus]; + LOG_I(MAC, "[eNB %d] CC_id %d Create %d bytes for MSI\n", + module_idP, CC_id, sdu_lengths[num_sdus]); + num_sdus++; + cc->msi_active = 1; } - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : MSI->MCH, length of MSI is %d bytes \n", - module_idP,CC_id,frameP,msi_length); - //LOG_D(MAC,"Scheduler: MSI is transmitted in this subframeP \n" ); - - // LOG_D(MAC,"Scheduler: MSI length is %d bytes\n",msi_length); - // Store MSI data to mch_buffer[0] - memcpy((char *)&mch_buffer[sdu_length_total], - msi_control_element, - msi_length); - - sdu_lcids[num_sdus] = MCH_SCHDL_INFO; - sdu_lengths[num_sdus] = msi_length; - sdu_length_total += sdu_lengths[num_sdus]; - LOG_I(MAC,"[eNB %d] CC_id %d Create %d bytes for MSI\n", module_idP, CC_id, sdu_lengths[num_sdus]); - num_sdus++; - cc->msi_active=1; - } - - // there is MCCH - if (mcch_flag == 1) { - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d Subframe %d: Schedule MCCH MESSAGE (area %d, sfAlloc %d)\n", - module_idP, CC_id, frameP, subframeP, i, j); - - mcch_sdu_length = mac_rrc_data_req(module_idP, - CC_id, - frameP, - MCCH,1, - &cc->MCCH_pdu.payload[0], - 1,// this is eNB - module_idP, // index - i); // this is the mbsfn sync area index - - if (mcch_sdu_length > 0) { - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d : MCCH->MCH, Received %d bytes from RRC \n", - module_idP,CC_id,frameP,subframeP,mcch_sdu_length); - - header_len_mcch = 2; - - if (cc->tdd_Config != NULL) { - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d: Scheduling MCCH->MCH (TDD) for MCCH message %d bytes (mcs %d )\n", - module_idP, CC_id, - frameP,subframeP, - mcch_sdu_length, - mcch_mcs); - } else { - LOG_I(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d: Scheduling MCCH->MCH (FDD) for MCCH message %d bytes (mcs %d)\n", - module_idP, CC_id, - frameP, subframeP, - mcch_sdu_length, - mcch_mcs); - } - - cc->mcch_active=1; - - memcpy((char *)&mch_buffer[sdu_length_total], - &cc->MCCH_pdu.payload[0], - mcch_sdu_length); - sdu_lcids[num_sdus] = MCCH_LCHANID; - sdu_lengths[num_sdus] = mcch_sdu_length; - - if (sdu_lengths[num_sdus]>128) { - header_len_mcch = 3; - } - - sdu_length_total += sdu_lengths[num_sdus]; - LOG_D(MAC,"[eNB %d] CC_id %d Got %d bytes for MCCH from RRC \n",module_idP,CC_id,sdu_lengths[num_sdus]); - num_sdus++; + // there is MCCH + if (mcch_flag == 1) { + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d Subframe %d: Schedule MCCH MESSAGE (area %d, sfAlloc %d)\n", + module_idP, CC_id, frameP, subframeP, i, j); + + mcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, MCCH, 1, &cc->MCCH_pdu.payload[0], + i); // this is the mbsfn sync area index + + if (mcch_sdu_length > 0) { + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d subframeP %d : MCCH->MCH, Received %d bytes from RRC \n", + module_idP, CC_id, frameP, subframeP, mcch_sdu_length); + + header_len_mcch = 2; + + if (cc->tdd_Config != NULL) { + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d subframeP %d: Scheduling MCCH->MCH (TDD) for MCCH message %d bytes (mcs %d )\n", + module_idP, CC_id, frameP, subframeP, + mcch_sdu_length, mcch_mcs); + } else { + LOG_I(MAC, + "[eNB %d] CC_id %d Frame %d subframeP %d: Scheduling MCCH->MCH (FDD) for MCCH message %d bytes (mcs %d)\n", + module_idP, CC_id, frameP, subframeP, + mcch_sdu_length, mcch_mcs); + } + + cc->mcch_active = 1; + + memcpy((char *) &mch_buffer[sdu_length_total], + &cc->MCCH_pdu.payload[0], mcch_sdu_length); + sdu_lcids[num_sdus] = MCCH_LCHANID; + sdu_lengths[num_sdus] = mcch_sdu_length; + + if (sdu_lengths[num_sdus] > 128) { + header_len_mcch = 3; + } + + sdu_length_total += sdu_lengths[num_sdus]; + LOG_D(MAC, + "[eNB %d] CC_id %d Got %d bytes for MCCH from RRC \n", + module_idP, CC_id, sdu_lengths[num_sdus]); + num_sdus++; + } } - } - TBS = get_TBS_DL(cc->MCH_pdu.mcs, to_prb(cc->mib->message.dl_Bandwidth)); + TBS = + get_TBS_DL(cc->MCH_pdu.mcs, to_prb(cc->mib->message.dl_Bandwidth)); #if defined(Rel10) || defined(Rel14) - // do not let mcch and mtch multiplexing when relaying is active - // for sync area 1, so not transmit data - //if ((i == 0) && ((RC.mac[module_idP]->MBMS_flag != multicast_relay) || (RC.mac[module_idP]->mcch_active==0))) { + // do not let mcch and mtch multiplexing when relaying is active + // for sync area 1, so not transmit data + //if ((i == 0) && ((RC.mac[module_idP]->MBMS_flag != multicast_relay) || (RC.mac[module_idP]->mcch_active==0))) { #endif - // there is MTCHs, loop if there are more than 1 - if (mtch_flag == 1) { - // Calculate TBS - /* if ((msi_flag==1) || (mcch_flag==1)) { - TBS = mac_xface->get_TBS(mcch_mcs, mac_xface->frame_parms->N_RB_DL); - } - else { // only MTCH in this subframeP - TBS = mac_xface->get_TBS(RC.mac[module_idP]->pmch_Config[0]->dataMCS_r9, mac_xface->frame_parms->N_RB_DL); - } - - // get MTCH data from RLC (like for DTCH) - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframe %d: Schedule MTCH (area %d, sfAlloc %d)\n",Mod_id,CC_id,frame,subframe,i,j); - - header_len_mtch = 3; - LOG_D(MAC,"[eNB %d], CC_id %d, Frame %d, MTCH->MCH, Checking RLC status (rab %d, tbs %d, len %d)\n", - Mod_id,CC_id,frame,MTCH,TBS, - TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); - - rlc_status = mac_rlc_status_ind(Mod_id,frame,1,RLC_MBMS_YES,MTCH+ (maxDRB + 3) * MAX_MOBILES_PER_RG, - TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); - printf("frame %d, subframe %d, rlc_status.bytes_in_buffer is %d\n",frame,subframe, rlc_status.bytes_in_buffer); - - */ - - // get MTCH data from RLC (like for DTCH) - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframeP %d: Schedule MTCH (area %d, sfAlloc %d)\n",module_idP,CC_id,frameP,subframeP,i,j); - - header_len_mtch = 3; - LOG_D(MAC,"[eNB %d], CC_id %d, Frame %d, MTCH->MCH, Checking RLC status (rab %d, tbs %d, len %d)\n", - module_idP,CC_id,frameP,MTCH,TBS, - TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); - - rlc_status = mac_rlc_status_ind(module_idP,0,frameP,subframeP,module_idP,ENB_FLAG_YES,MBMS_FLAG_YES,MTCH, - TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch + // there is MTCHs, loop if there are more than 1 + if (mtch_flag == 1) { + // Calculate TBS + /* if ((msi_flag==1) || (mcch_flag==1)) { + TBS = mac_xface->get_TBS(mcch_mcs, mac_xface->frame_parms->N_RB_DL); + } + else { // only MTCH in this subframeP + TBS = mac_xface->get_TBS(RC.mac[module_idP]->pmch_Config[0]->dataMCS_r9, mac_xface->frame_parms->N_RB_DL); + } + + // get MTCH data from RLC (like for DTCH) + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d subframe %d: Schedule MTCH (area %d, sfAlloc %d)\n",Mod_id,CC_id,frame,subframe,i,j); + + header_len_mtch = 3; + LOG_D(MAC,"[eNB %d], CC_id %d, Frame %d, MTCH->MCH, Checking RLC status (rab %d, tbs %d, len %d)\n", + Mod_id,CC_id,frame,MTCH,TBS, + TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); + + rlc_status = mac_rlc_status_ind(Mod_id,frame,1,RLC_MBMS_YES,MTCH+ (maxDRB + 3) * MAX_MOBILES_PER_RG, + TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); + printf("frame %d, subframe %d, rlc_status.bytes_in_buffer is %d\n",frame,subframe, rlc_status.bytes_in_buffer); + + */ + + // get MTCH data from RLC (like for DTCH) + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d subframeP %d: Schedule MTCH (area %d, sfAlloc %d)\n", + module_idP, CC_id, frameP, subframeP, i, j); + + header_len_mtch = 3; + LOG_D(MAC, + "[eNB %d], CC_id %d, Frame %d, MTCH->MCH, Checking RLC status (rab %d, tbs %d, len %d)\n", + module_idP, CC_id, frameP, MTCH, TBS, + TBS - header_len_mcch - header_len_msi - sdu_length_total - + header_len_mtch); + + rlc_status = + mac_rlc_status_ind(module_idP, 0, frameP, subframeP, + module_idP, ENB_FLAG_YES, MBMS_FLAG_YES, + MTCH, + TBS - header_len_mcch - header_len_msi - + sdu_length_total - header_len_mtch #ifdef Rel14 ,0, 0 #endif ); - LOG_D(MAC,"e-MBMS log channel %u frameP %d, subframeP %d, rlc_status.bytes_in_buffer is %d\n", - MTCH,frameP,subframeP, rlc_status.bytes_in_buffer); - - if (rlc_status.bytes_in_buffer >0) { - LOG_I(MAC,"[eNB %d][MBMS USER-PLANE], CC_id %d, Frame %d, MTCH->MCH, Requesting %d bytes from RLC (header len mtch %d)\n", - module_idP,CC_id,frameP,TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch,header_len_mtch); - - sdu_lengths[num_sdus] = mac_rlc_data_req( - module_idP, - 0, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_YES, - MTCH, - 0, //not used - (char*)&mch_buffer[sdu_length_total] + + LOG_D(MAC, + "e-MBMS log channel %u frameP %d, subframeP %d, rlc_status.bytes_in_buffer is %d\n", + MTCH, frameP, subframeP, rlc_status.bytes_in_buffer); + + if (rlc_status.bytes_in_buffer > 0) { + LOG_I(MAC, + "[eNB %d][MBMS USER-PLANE], CC_id %d, Frame %d, MTCH->MCH, Requesting %d bytes from RLC (header len mtch %d)\n", + module_idP, CC_id, frameP, + TBS - header_len_mcch - header_len_msi - + sdu_length_total - header_len_mtch, header_len_mtch); + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, 0, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_YES, MTCH, 0, //not used + (char *) + &mch_buffer[sdu_length_total] #ifdef Rel14 ,0, 0 #endif ); - //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, MBMS_FLAG_NO, MTCH+(MAX_NUM_RB*(NUMBER_OF_UE_MAX+1)), (char*)&mch_buffer[sdu_length_total]); - LOG_I(MAC,"[eNB %d][MBMS USER-PLANE] CC_id %d Got %d bytes for MTCH %d\n",module_idP,CC_id,sdu_lengths[num_sdus],MTCH); - cc->mtch_active=1; - sdu_lcids[num_sdus] = MTCH; - sdu_length_total += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) { - header_len_mtch = 2; - } - num_sdus++; - } else { - header_len_mtch = 0; - } - } + //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, MBMS_FLAG_NO, MTCH+(MAX_NUM_RB*(NUMBER_OF_UE_MAX+1)), (char*)&mch_buffer[sdu_length_total]); + LOG_I(MAC, + "[eNB %d][MBMS USER-PLANE] CC_id %d Got %d bytes for MTCH %d\n", + module_idP, CC_id, sdu_lengths[num_sdus], MTCH); + cc->mtch_active = 1; + sdu_lcids[num_sdus] = MTCH; + sdu_length_total += sdu_lengths[num_sdus]; + + if (sdu_lengths[num_sdus] < 128) { + header_len_mtch = 2; + } + num_sdus++; + } else { + header_len_mtch = 0; + } + } #if defined(Rel10) || defined(Rel14) - // } + // } #endif - // FINAL STEP: Prepare and multiplexe MSI, MCCH and MTCHs - if ((sdu_length_total + header_len_msi + header_len_mcch + header_len_mtch) >0) { - // Adjust the last subheader - /* if ((msi_flag==1) || (mcch_flag==1)) { - RC.mac[module_idP]->MCH_pdu.mcs = mcch_mcs; - } - else if (mtch_flag == 1) { // only MTCH in this subframeP - RC.mac[module_idP]->MCH_pdu.mcs = RC.mac[module_idP]->pmch_Config[0]->dataMCS_r9; - } - */ - header_len_mtch_temp = header_len_mtch; - header_len_mcch_temp = header_len_mcch; - header_len_msi_temp = header_len_msi; - - if (header_len_mtch>0) { - header_len_mtch=1; // remove Length field in the subheader for the last PDU - } else if (header_len_mcch>0) { - header_len_mcch=1; + // FINAL STEP: Prepare and multiplexe MSI, MCCH and MTCHs + if ((sdu_length_total + header_len_msi + header_len_mcch + + header_len_mtch) > 0) { + // Adjust the last subheader + /* if ((msi_flag==1) || (mcch_flag==1)) { + RC.mac[module_idP]->MCH_pdu.mcs = mcch_mcs; + } + else if (mtch_flag == 1) { // only MTCH in this subframeP + RC.mac[module_idP]->MCH_pdu.mcs = RC.mac[module_idP]->pmch_Config[0]->dataMCS_r9; + } + */ + header_len_mtch_temp = header_len_mtch; + header_len_mcch_temp = header_len_mcch; + header_len_msi_temp = header_len_msi; + + if (header_len_mtch > 0) { + header_len_mtch = 1; // remove Length field in the subheader for the last PDU + } else if (header_len_mcch > 0) { + header_len_mcch = 1; + } else { + header_len_msi = 1; + } + + // Calculate the padding + if ((TBS - header_len_mtch - header_len_mcch - header_len_msi - + sdu_length_total) < 0) { + LOG_E(MAC, "Error in building MAC PDU, TBS %d < PDU %d \n", + TBS, + header_len_mtch + header_len_mcch + header_len_msi + + sdu_length_total); + return 0; + } else + if ((TBS - header_len_mtch - header_len_mcch - header_len_msi - + sdu_length_total) <= 2) { + padding = + (TBS - header_len_mtch - header_len_mcch - header_len_msi - + sdu_length_total); + post_padding = 0; + } else { // using post_padding, give back the Length field of subheader for the last PDU + padding = 0; + + if (header_len_mtch > 0) { + header_len_mtch = header_len_mtch_temp; + } else if (header_len_mcch > 0) { + header_len_mcch = header_len_mcch_temp; + } else { + header_len_msi = header_len_msi_temp; + } + + post_padding = + TBS - sdu_length_total - header_len_msi - header_len_mcch - + header_len_mtch; + } + + // Generate the MAC Header for MCH + // here we use the function for DLSCH because DLSCH & MCH have the same Header structure + offset = generate_dlsch_header((unsigned char *) cc->MCH_pdu.payload, num_sdus, sdu_lengths, sdu_lcids, 255, // no drx + 31, // no timing advance + NULL, // no contention res id + padding, post_padding); + + cc->MCH_pdu.Pdu_size = TBS; + cc->MCH_pdu.sync_area = i; + cc->MCH_pdu.msi_active = cc->msi_active; + cc->MCH_pdu.mcch_active = cc->mcch_active; + cc->MCH_pdu.mtch_active = cc->mtch_active; + LOG_D(MAC, + " MCS for this sf is %d (mcch active %d, mtch active %d)\n", + cc->MCH_pdu.mcs, cc->MCH_pdu.mcch_active, + cc->MCH_pdu.mtch_active); + LOG_I(MAC, + "[eNB %d][MBMS USER-PLANE ] CC_id %d Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,padding %d,post_padding %d (mcs %d, TBS %d), header MTCH %d, header MCCH %d, header MSI %d\n", + module_idP, CC_id, sdu_length_total, num_sdus, + sdu_lengths[0], sdu_lcids[0], offset, padding, post_padding, + cc->MCH_pdu.mcs, TBS, header_len_mtch, header_len_mcch, + header_len_msi); + // copy SDU to mch_pdu after the MAC Header + memcpy(&cc->MCH_pdu.payload[offset], mch_buffer, sdu_length_total); + + // filling remainder of MCH with random data if necessery + for (j = 0; j < (TBS - sdu_length_total - offset); j++) { + cc->MCH_pdu.payload[offset + sdu_length_total + j] = + (char) (taus() & 0xff); + } + + /* Tracing of PDU is done on UE side */ + if (opt_enabled == 1) { + trace_pdu(1, (uint8_t *) cc->MCH_pdu.payload, TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark + RC.mac[module_idP]->frame, + RC.mac[module_idP]->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][MCH] CC_id %d Frame %d : MAC PDU with size %d\n", + module_idP, CC_id, frameP, TBS); + } + + /* + for (j=0;j<sdu_length_total;j++) + printf("%2x.",RC.mac[module_idP]->MCH_pdu.payload[j+offset]); + printf(" \n"); */ + return 1; } else { - header_len_msi=1; - } - - // Calculate the padding - if ((TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total) < 0) { - LOG_E(MAC,"Error in building MAC PDU, TBS %d < PDU %d \n", - TBS, header_len_mtch + header_len_mcch + header_len_msi + sdu_length_total); - return 0; - } else if ((TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total) <= 2) { - padding = (TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total); - post_padding = 0; - } else { // using post_padding, give back the Length field of subheader for the last PDU - padding = 0; - - if (header_len_mtch>0) { - header_len_mtch = header_len_mtch_temp; - } else if (header_len_mcch>0) { - header_len_mcch = header_len_mcch_temp; - } else { - header_len_msi = header_len_msi_temp; - } - - post_padding = TBS - sdu_length_total - header_len_msi - header_len_mcch - header_len_mtch; - } - - // Generate the MAC Header for MCH - // here we use the function for DLSCH because DLSCH & MCH have the same Header structure - offset = generate_dlsch_header((unsigned char*)cc->MCH_pdu.payload, - num_sdus, - sdu_lengths, - sdu_lcids, - 255, // no drx - 31, // no timing advance - NULL, // no contention res id - padding, - post_padding); - - cc->MCH_pdu.Pdu_size=TBS; - cc->MCH_pdu.sync_area=i; - cc->MCH_pdu.msi_active= cc->msi_active; - cc->MCH_pdu.mcch_active= cc->mcch_active; - cc->MCH_pdu.mtch_active= cc->mtch_active; - LOG_D(MAC," MCS for this sf is %d (mcch active %d, mtch active %d)\n", cc->MCH_pdu.mcs, - cc->MCH_pdu.mcch_active,cc->MCH_pdu.mtch_active ); - LOG_I(MAC, - "[eNB %d][MBMS USER-PLANE ] CC_id %d Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,padding %d,post_padding %d (mcs %d, TBS %d), header MTCH %d, header MCCH %d, header MSI %d\n", - module_idP,CC_id,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,padding,post_padding,cc->MCH_pdu.mcs,TBS, - header_len_mtch, header_len_mcch, header_len_msi); - // copy SDU to mch_pdu after the MAC Header - memcpy(&cc->MCH_pdu.payload[offset],mch_buffer,sdu_length_total); - - // filling remainder of MCH with random data if necessery - for (j=0; j<(TBS-sdu_length_total-offset); j++) { - cc->MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); - } - - /* Tracing of PDU is done on UE side */ - if (opt_enabled ==1 ) { - trace_pdu(1, (uint8_t *)cc->MCH_pdu.payload, - TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark - RC.mac[module_idP]->frame, RC.mac[module_idP]->subframe,0,0); - LOG_D(OPT,"[eNB %d][MCH] CC_id %d Frame %d : MAC PDU with size %d\n", - module_idP, CC_id, frameP, TBS); + cc->MCH_pdu.Pdu_size = 0; + cc->MCH_pdu.sync_area = 0; + cc->MCH_pdu.msi_active = 0; + cc->MCH_pdu.mcch_active = 0; + cc->MCH_pdu.mtch_active = 0; + // for testing purpose, fill with random data + //for (j=0;j<(TBS-sdu_length_total-offset);j++) + // RC.mac[module_idP]->MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); + return 0; } + //this is for testing /* - for (j=0;j<sdu_length_total;j++) - printf("%2x.",RC.mac[module_idP]->MCH_pdu.payload[j+offset]); - printf(" \n");*/ - return 1; - } else { - cc->MCH_pdu.Pdu_size=0; - cc->MCH_pdu.sync_area=0; - cc->MCH_pdu.msi_active=0; - cc->MCH_pdu.mcch_active=0; - cc->MCH_pdu.mtch_active=0; - // for testing purpose, fill with random data - //for (j=0;j<(TBS-sdu_length_total-offset);j++) - // RC.mac[module_idP]->MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); - return 0; - } - - //this is for testing - /* - if (mtch_flag == 1) { - // LOG_D(MAC,"DUY: mch_buffer length so far is : %ld\n", &mch_buffer[sdu_length_total]-&mch_buffer[0]); - return 1; - } - else - return 0; - */ + if (mtch_flag == 1) { + // LOG_D(MAC,"DUY: mch_buffer length so far is : %ld\n", &mch_buffer[sdu_length_total]-&mch_buffer[0]); + return 1; + } + else + return 0; + */ } -MCH_PDU *get_mch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t subframeP) +MCH_PDU *get_mch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, + sub_frame_t subframeP) { - // RC.mac[module_idP]->MCH_pdu.mcs=0; - //LOG_D(MAC," MCH_pdu.mcs is %d\n", RC.mac[module_idP]->MCH_pdu.mcs); + // RC.mac[module_idP]->MCH_pdu.mcs=0; + //LOG_D(MAC," MCH_pdu.mcs is %d\n", RC.mac[module_idP]->MCH_pdu.mcs); //#warning "MCH pdu should take the CC_id index" - return(&RC.mac[module_idP]->common_channels[CC_id].MCH_pdu); + return (&RC.mac[module_idP]->common_channels[CC_id].MCH_pdu); } #endif diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7ecb0778ef0069b5778caad4e1e039d44d4a8fef..7cc23d02d2561781cc6a09e4c4bc6e91ff16bd76 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -53,7 +53,7 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif #include "T.h" @@ -61,1499 +61,1808 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 -int choose(int n,int k) +int choose(int n, int k) { - int res = 1; - int res2 = 1; - int i; + int res = 1; + int res2 = 1; + int i; - if (k>n) return(0); - if (n==k) return(1); + if (k > n) + return (0); + if (n == k) + return (1); - for (i=n;i>k;i--) res*=i; - for (i=2;i<=(n-k);i++) res2*=i; + for (i = n; i > k; i--) + res *= i; + for (i = 2; i <= (n - k); i++) + res2 *= i; - return(res/res2); + return (res / res2); } // Patented algorithm from Yang et al, US Patent 2009, "Channel Quality Indexing and Reverse Indexing" -void reverse_index(int N,int M,int r,int *v) -{ - int BaseValue=0; - int IncreaseValue,ThresholdValue; - int sumV; - int i; - - r = choose(N,M) - 1 - r; - memset((void*)v,0,M*sizeof(int)); - - sumV=0; - i=M; - while (i>0 && r>0) { - IncreaseValue = choose(N-M+1-sumV-v[i-1]+i-2,i-1); - ThresholdValue = BaseValue+IncreaseValue; - if (r>=ThresholdValue) { - v[i-1]++; - BaseValue=ThresholdValue; - } - else { - r=r-BaseValue; - sumV+=v[i-1]; - i--; - BaseValue=0; +void reverse_index(int N, int M, int r, int *v) +{ + int BaseValue = 0; + int IncreaseValue, ThresholdValue; + int sumV; + int i; + + r = choose(N, M) - 1 - r; + memset((void *) v, 0, M * sizeof(int)); + + sumV = 0; + i = M; + while (i > 0 && r > 0) { + IncreaseValue = choose(N - M + 1 - sumV - v[i - 1] + i - 2, i - 1); + ThresholdValue = BaseValue + IncreaseValue; + if (r >= ThresholdValue) { + v[i - 1]++; + BaseValue = ThresholdValue; + } else { + r = r - BaseValue; + sumV += v[i - 1]; + i--; + BaseValue = 0; + } } - } } int to_prb(int dl_Bandwidth) { - int prbmap[6] = {6,15,25,50,75,100}; + int prbmap[6] = { 6, 15, 25, 50, 75, 100 }; - AssertFatal(dl_Bandwidth < 6,"dl_Bandwidth is 0..5\n"); - return(prbmap[dl_Bandwidth]); + AssertFatal(dl_Bandwidth < 6, "dl_Bandwidth is 0..5\n"); + return (prbmap[dl_Bandwidth]); } int to_rbg(int dl_Bandwidth) { - int rbgmap[6] = {6,8,13,17,19,25}; + int rbgmap[6] = { 6, 8, 13, 17, 19, 25 }; - AssertFatal(dl_Bandwidth < 6,"dl_Bandwidth is 0..5\n"); - return(rbgmap[dl_Bandwidth]); + AssertFatal(dl_Bandwidth < 6, "dl_Bandwidth is 0..5\n"); + return (rbgmap[dl_Bandwidth]); } -int get_phich_resource_times6(COMMON_channels_t *cc) +int get_phich_resource_times6(COMMON_channels_t * cc) { - int phichmap[4] = {1,3,6,12}; - AssertFatal(cc!=NULL,"cc is null\n"); - AssertFatal(cc->mib!=NULL,"cc->mib is null\n"); - AssertFatal((cc->mib->message.phich_Config.phich_Resource>=0) && - (cc->mib->message.phich_Config.phich_Resource<4), - "phich_Resource %d not in 0..3\n",(int)cc->mib->message.phich_Config.phich_Resource); - - return(phichmap[cc->mib->message.phich_Config.phich_Resource]); + int phichmap[4] = { 1, 3, 6, 12 }; + AssertFatal(cc != NULL, "cc is null\n"); + AssertFatal(cc->mib != NULL, "cc->mib is null\n"); + AssertFatal((cc->mib->message.phich_Config.phich_Resource >= 0) && + (cc->mib->message.phich_Config.phich_Resource < 4), + "phich_Resource %d not in 0..3\n", + (int) cc->mib->message.phich_Config.phich_Resource); + + return (phichmap[cc->mib->message.phich_Config.phich_Resource]); } -uint16_t mac_computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs) +uint16_t mac_computeRIV(uint16_t N_RB_DL, uint16_t RBstart, uint16_t Lcrbs) { - uint16_t RIV; + uint16_t RIV; - if (Lcrbs<=(1+(N_RB_DL>>1))) - RIV = (N_RB_DL*(Lcrbs-1)) + RBstart; - else - RIV = (N_RB_DL*(N_RB_DL+1-Lcrbs)) + (N_RB_DL-1-RBstart); + if (Lcrbs <= (1 + (N_RB_DL >> 1))) + RIV = (N_RB_DL * (Lcrbs - 1)) + RBstart; + else + RIV = (N_RB_DL * (N_RB_DL + 1 - Lcrbs)) + (N_RB_DL - 1 - RBstart); - return(RIV); + return (RIV); } uint8_t getQm(uint8_t mcs) { - if (mcs<10) return(2); - else if (mcs<17) return(4); - else return (6); + if (mcs < 10) + return (2); + else if (mcs < 17) + return (4); + else + return (6); } -void get_Msg3alloc(COMMON_channels_t *cc, - - sub_frame_t current_subframe, - frame_t current_frame, - frame_t *frame, - sub_frame_t *subframe) +void +get_Msg3alloc(COMMON_channels_t * cc, + sub_frame_t current_subframe, + frame_t current_frame, frame_t * frame, + sub_frame_t * subframe) { - // Fill in other TDD Configuration!!!! - - if (cc->tdd_Config==NULL) { // FDD - *subframe = current_subframe+6; - - if (*subframe>9) { - *subframe = *subframe-10; - *frame = (current_frame+1) & 1023; - } else { - *frame=current_frame; - } - } else { // TDD - if (cc->tdd_Config->subframeAssignment == 1) { - switch (current_subframe) { - - case 0: - *subframe = 7; - *frame = current_frame; - break; - - case 4: - *subframe = 2; - *frame = (current_frame+1) & 1023; - break; - - case 5: - *subframe = 2; - *frame = (current_frame+1) & 1023; - break; - - case 9: - *subframe = 7; - *frame = (current_frame+1) & 1023; - break; - } - } else if (cc->tdd_Config->subframeAssignment == 3) { - switch (current_subframe) { - - case 0: - case 5: - case 6: - *subframe = 2; - *frame = (current_frame+1) & 1023; - break; - - case 7: - *subframe = 3; - *frame = (current_frame+1) & 1023; - break; - - case 8: - *subframe = 4; - *frame = (current_frame+1) & 1023; - break; - - case 9: - *subframe = 2; - *frame = (current_frame+2) & 1023; - break; - } - } else if (cc->tdd_Config->subframeAssignment == 4) { - switch (current_subframe) { - - case 0: - case 4: - case 5: - case 6: - *subframe = 2; - *frame = (current_frame+1) & 1023; - break; - - case 7: - *subframe = 3; - *frame = (current_frame+1) & 1023; - break; - - case 8: - case 9: - *subframe = 2; - *frame = (current_frame+2) & 1023; - break; - } - } else if (cc->tdd_Config->subframeAssignment == 5) { - switch (current_subframe) { - - case 0: - case 4: - case 5: - case 6: - *subframe = 2; - *frame = (current_frame+1) & 1023; - break; - - case 7: - case 8: - case 9: - *subframe = 2; - *frame = (current_frame+2) & 1023; - break; - } + // Fill in other TDD Configuration!!!! + + if (cc->tdd_Config == NULL) { // FDD + *subframe = current_subframe + 6; + + if (*subframe > 9) { + *subframe = *subframe - 10; + *frame = (current_frame + 1) & 1023; + } else { + *frame = current_frame; + } + } else { // TDD + if (cc->tdd_Config->subframeAssignment == 1) { + switch (current_subframe) { + + case 0: + *subframe = 7; + *frame = current_frame; + break; + + case 4: + *subframe = 2; + *frame = (current_frame + 1) & 1023; + break; + + case 5: + *subframe = 2; + *frame = (current_frame + 1) & 1023; + break; + + case 9: + *subframe = 7; + *frame = (current_frame + 1) & 1023; + break; + } + } else if (cc->tdd_Config->subframeAssignment == 3) { + switch (current_subframe) { + + case 0: + case 5: + case 6: + *subframe = 2; + *frame = (current_frame + 1) & 1023; + break; + + case 7: + *subframe = 3; + *frame = (current_frame + 1) & 1023; + break; + + case 8: + *subframe = 4; + *frame = (current_frame + 1) & 1023; + break; + + case 9: + *subframe = 2; + *frame = (current_frame + 2) & 1023; + break; + } + } else if (cc->tdd_Config->subframeAssignment == 4) { + switch (current_subframe) { + + case 0: + case 4: + case 5: + case 6: + *subframe = 2; + *frame = (current_frame + 1) & 1023; + break; + + case 7: + *subframe = 3; + *frame = (current_frame + 1) & 1023; + break; + + case 8: + case 9: + *subframe = 2; + *frame = (current_frame + 2) & 1023; + break; + } + } else if (cc->tdd_Config->subframeAssignment == 5) { + switch (current_subframe) { + + case 0: + case 4: + case 5: + case 6: + *subframe = 2; + *frame = (current_frame + 1) & 1023; + break; + + case 7: + case 8: + case 9: + *subframe = 2; + *frame = (current_frame + 2) & 1023; + break; + } + } } - } } -void get_Msg3allocret(COMMON_channels_t *cc, - sub_frame_t current_subframe, - frame_t current_frame, - frame_t *frame, - sub_frame_t *subframe) +void +get_Msg3allocret(COMMON_channels_t * cc, + sub_frame_t current_subframe, + frame_t current_frame, + frame_t * frame, sub_frame_t * subframe) { - if (cc->tdd_Config == NULL) { //FDD - /* always retransmit in n+8 */ - *subframe = current_subframe + 8; - - if (*subframe > 9) { - *subframe = *subframe - 10; - *frame = (current_frame + 1) & 1023; + if (cc->tdd_Config == NULL) { //FDD + /* always retransmit in n+8 */ + *subframe = current_subframe + 8; + + if (*subframe > 9) { + *subframe = *subframe - 10; + *frame = (current_frame + 1) & 1023; + } else { + *frame = current_frame; + } } else { - *frame = current_frame; - } - } else { - if (cc->tdd_Config->subframeAssignment == 1) { - // original PUSCH in 2, PHICH in 6 (S), ret in 2 - // original PUSCH in 3, PHICH in 9, ret in 3 - // original PUSCH in 7, PHICH in 1 (S), ret in 7 - // original PUSCH in 8, PHICH in 4, ret in 8 - *frame = (current_frame+1) & 1023; - } else if (cc->tdd_Config->subframeAssignment == 3) { - // original PUSCH in 2, PHICH in 8, ret in 2 next frame - // original PUSCH in 3, PHICH in 9, ret in 3 next frame - // original PUSCH in 4, PHICH in 0, ret in 4 next frame - *frame=(current_frame+1) & 1023; - } else if (cc->tdd_Config->subframeAssignment == 4) { - // original PUSCH in 2, PHICH in 8, ret in 2 next frame - // original PUSCH in 3, PHICH in 9, ret in 3 next frame - *frame=(current_frame+1) & 1023; - } else if (cc->tdd_Config->subframeAssignment == 5) { - // original PUSCH in 2, PHICH in 8, ret in 2 next frame - *frame=(current_frame+1) & 1023; + if (cc->tdd_Config->subframeAssignment == 1) { + // original PUSCH in 2, PHICH in 6 (S), ret in 2 + // original PUSCH in 3, PHICH in 9, ret in 3 + // original PUSCH in 7, PHICH in 1 (S), ret in 7 + // original PUSCH in 8, PHICH in 4, ret in 8 + *frame = (current_frame + 1) & 1023; + } else if (cc->tdd_Config->subframeAssignment == 3) { + // original PUSCH in 2, PHICH in 8, ret in 2 next frame + // original PUSCH in 3, PHICH in 9, ret in 3 next frame + // original PUSCH in 4, PHICH in 0, ret in 4 next frame + *frame = (current_frame + 1) & 1023; + } else if (cc->tdd_Config->subframeAssignment == 4) { + // original PUSCH in 2, PHICH in 8, ret in 2 next frame + // original PUSCH in 3, PHICH in 9, ret in 3 next frame + *frame = (current_frame + 1) & 1023; + } else if (cc->tdd_Config->subframeAssignment == 5) { + // original PUSCH in 2, PHICH in 8, ret in 2 next frame + *frame = (current_frame + 1) & 1023; + } } - } } -uint8_t subframe2harqpid(COMMON_channels_t *cc,frame_t frame,sub_frame_t subframe) +uint8_t +subframe2harqpid(COMMON_channels_t * cc, frame_t frame, + sub_frame_t subframe) { - uint8_t ret = 255; + uint8_t ret = 255; - AssertFatal(cc!=NULL,"cc is null\n"); + AssertFatal(cc != NULL, "cc is null\n"); - if (cc->tdd_Config == NULL) { // FDD - ret = (((frame*10)+subframe)&7); - } else { - switch (cc->tdd_Config->subframeAssignment) { - case 1: - if ((subframe==2) || - (subframe==3) || - (subframe==7) || - (subframe==8)) - switch (subframe) { - case 2: - case 3: - ret = (subframe-2); - break; - - case 7: - case 8: - ret = (subframe-5); - break; - - default: - AssertFatal(1==0,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); - break; - } - - break; + if (cc->tdd_Config == NULL) { // FDD + ret = (((frame << 1) + subframe) & 7); + } else { + switch (cc->tdd_Config->subframeAssignment) { + case 1: + if ((subframe == 2) || + (subframe == 3) || (subframe == 7) || (subframe == 8)) + switch (subframe) { + case 2: + case 3: + ret = (subframe - 2); + break; + + case 7: + case 8: + ret = (subframe - 5); + break; + + default: + AssertFatal(1 == 0, + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframe, + (int) cc->tdd_Config->subframeAssignment); + break; + } + + break; + + case 2: + AssertFatal((subframe == 2) || (subframe == 7), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframe, + (int) cc->tdd_Config->subframeAssignment); + + ret = (subframe / 7); + break; + + case 3: + AssertFatal((subframe > 1) && (subframe < 5), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframe, + (int) cc->tdd_Config->subframeAssignment); + ret = (subframe - 2); + break; + + case 4: + AssertFatal((subframe > 1) && (subframe < 4), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframe, + (int) cc->tdd_Config->subframeAssignment); + ret = (subframe - 2); + break; + + case 5: + AssertFatal(subframe == 2, + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframe, + (int) cc->tdd_Config->subframeAssignment); + ret = (subframe - 2); + break; + + default: + AssertFatal(1 == 0, + "subframe2_harq_pid, Unsupported TDD mode %d\n", + (int) cc->tdd_Config->subframeAssignment); + } + } + return ret; +} - case 2: - AssertFatal((subframe==2) || (subframe==7), - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); +uint8_t +get_Msg3harqpid(COMMON_channels_t * cc, + frame_t frame, sub_frame_t current_subframe) +{ + uint8_t ul_subframe = 0; + uint32_t ul_frame = 0; + + if (cc->tdd_Config == NULL) { // FDD + ul_subframe = + (current_subframe > + 3) ? (current_subframe - 4) : (current_subframe + 6); + ul_frame = (current_subframe > 3) ? ((frame + 1) & 1023) : frame; + } else { + switch (cc->tdd_Config->subframeAssignment) { + case 1: + switch (current_subframe) { + case 9: + case 0: + ul_subframe = 7; + break; + + case 5: + case 7: + ul_subframe = 2; + break; + + } + + break; + + case 3: + switch (current_subframe) { + case 0: + case 5: + case 6: + ul_subframe = 2; + break; + + case 7: + ul_subframe = 3; + break; + + case 8: + ul_subframe = 4; + break; + + case 9: + ul_subframe = 2; + break; + } + + break; + + case 4: + switch (current_subframe) { + case 0: + case 5: + case 6: + case 8: + case 9: + ul_subframe = 2; + break; + + case 7: + ul_subframe = 3; + break; + } + + break; + + case 5: + ul_subframe = 2; + break; + + default: + LOG_E(PHY, + "get_Msg3_harq_pid: Unsupported TDD configuration %d\n", + (int) cc->tdd_Config->subframeAssignment); + AssertFatal(1 == 0, + "get_Msg3_harq_pid: Unsupported TDD configuration"); + break; + } + } - ret = (subframe/7); - break; + return (subframe2harqpid(cc, ul_frame, ul_subframe)); +} - case 3: - AssertFatal((subframe>1) && (subframe<5), - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); - ret = (subframe-2); - break; +uint32_t +pdcchalloc2ulframe(COMMON_channels_t * ccP, uint32_t frame, uint8_t n) +{ + uint32_t ul_frame; + + if ((ccP->tdd_Config) && (ccP->tdd_Config->subframeAssignment == 1) && ((n == 1) || (n == 6))) // tdd_config 0,1 SF 1,5 + ul_frame = (frame + (n == 1 ? 0 : 1)); + else if ((ccP->tdd_Config) && + (ccP->tdd_Config->subframeAssignment == 6) && + ((n == 0) || (n == 1) || (n == 5) || (n == 6))) + ul_frame = (frame + (n >= 5 ? 1 : 0)); + else if ((ccP->tdd_Config) && (ccP->tdd_Config->subframeAssignment == 6) && (n == 9)) // tdd_config 6 SF 9 + ul_frame = (frame + 1); + else + ul_frame = (frame + (n >= 6 ? 1 : 0)); - case 4: - AssertFatal((subframe>1) && (subframe<4), - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); - ret = (subframe-2); - break; + LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, + ul_frame); + return ul_frame; +} - case 5: - AssertFatal(subframe==2, - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); - ret = (subframe-2); - break; +uint8_t pdcchalloc2ulsubframe(COMMON_channels_t * ccP, uint8_t n) +{ + uint8_t ul_subframe; + + if ((ccP->tdd_Config) && (ccP->tdd_Config->subframeAssignment == 1) && ((n == 1) || (n == 6))) // tdd_config 0,1 SF 1,5 + ul_subframe = ((n + 6) % 10); + else if ((ccP->tdd_Config) && + (ccP->tdd_Config->subframeAssignment == 6) && + ((n == 0) || (n == 1) || (n == 5) || (n == 6))) + ul_subframe = ((n + 7) % 10); + else if ((ccP->tdd_Config) && (ccP->tdd_Config->subframeAssignment == 6) && (n == 9)) // tdd_config 6 SF 9 + ul_subframe = ((n + 5) % 10); + else + ul_subframe = ((n + 4) % 10); - default: - AssertFatal(1==0,"subframe2_harq_pid, Unsupported TDD mode %d\n",(int)cc->tdd_Config->subframeAssignment); - } - } - return ret; + LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe); + return ul_subframe; } -uint8_t get_Msg3harqpid(COMMON_channels_t *cc, - frame_t frame, - sub_frame_t current_subframe) +int is_UL_sf(COMMON_channels_t * ccP, sub_frame_t subframeP) { - uint8_t ul_subframe=0; - uint32_t ul_frame=0; + // if FDD return dummy value + if (ccP->tdd_Config == NULL) + return (0); - if (cc->tdd_Config == NULL) { // FDD - ul_subframe = (current_subframe>3) ? (current_subframe-4) : (current_subframe+6); - ul_frame = (current_subframe>3) ? ((frame+1)&1023) : frame; - } else { - switch (cc->tdd_Config->subframeAssignment) { + switch (ccP->tdd_Config->subframeAssignment) { case 1: - switch (current_subframe) { - case 9: - case 0: - ul_subframe = 7; - break; - - case 5: - case 7: - ul_subframe = 2; - break; - - } - - break; + switch (subframeP) { + case 0: + case 4: + case 5: + case 9: + return (0); + break; + + case 2: + case 3: + case 7: + case 8: + return (1); + break; + + default: + return (0); + break; + } + break; case 3: - switch (current_subframe) { - case 0: - case 5: - case 6: - ul_subframe = 2; - break; - - case 7: - ul_subframe = 3; - break; - - case 8: - ul_subframe = 4; - break; - - case 9: - ul_subframe = 2; - break; - } - - break; + if ((subframeP <= 1) || (subframeP >= 5)) + return (0); + else if ((subframeP > 1) && (subframeP < 5)) + return (1); + else + AssertFatal(1 == 0, "Unknown subframe number\n"); + break; case 4: - switch (current_subframe) { - case 0: - case 5: - case 6: - case 8: - case 9: - ul_subframe = 2; - break; - - case 7: - ul_subframe = 3; - break; - } - - break; + if ((subframeP <= 1) || (subframeP >= 4)) + return (0); + else if ((subframeP > 1) && (subframeP < 4)) + return (1); + else + AssertFatal(1 == 0, "Unknown subframe number\n"); + break; case 5: - ul_subframe =2; - break; + if ((subframeP <= 1) || (subframeP >= 3)) + return (0); + else if ((subframeP > 1) && (subframeP < 3)) + return (1); + else + AssertFatal(1 == 0, "Unknown subframe number\n"); + break; default: - LOG_E(PHY,"get_Msg3_harq_pid: Unsupported TDD configuration %d\n",(int)cc->tdd_Config->subframeAssignment); - AssertFatal(1==0,"get_Msg3_harq_pid: Unsupported TDD configuration"); - break; + AssertFatal(1 == 0, + "subframe %d Unsupported TDD configuration %d\n", + subframeP, (int) ccP->tdd_Config->subframeAssignment); + break; } - } - - return(subframe2harqpid(cc,ul_frame,ul_subframe)); } -uint32_t pdcchalloc2ulframe(COMMON_channels_t *ccP,uint32_t frame, uint8_t n) +uint16_t get_pucch1_absSF(COMMON_channels_t * cc, uint16_t dlsch_absSF) { - uint32_t ul_frame; - - if ((ccP->tdd_Config) && - (ccP->tdd_Config->subframeAssignment == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_frame = (frame + (n==1 ? 0 : 1)); - else if ((ccP->tdd_Config) && - (ccP->tdd_Config->subframeAssignment == 6) && - ((n==0)||(n==1)||(n==5)||(n==6))) - ul_frame = (frame + (n>=5 ? 1 : 0)); - else if ((ccP->tdd_Config) && - (ccP->tdd_Config->subframeAssignment == 6) && - (n==9)) // tdd_config 6 SF 9 - ul_frame = (frame+1); - else - ul_frame = (frame+(n>=6 ? 1 : 0)); + uint16_t sf, f, nextf; - LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame); - return ul_frame; + if (cc->tdd_Config == NULL) { //FDD n+4 + return ((dlsch_absSF + 4) % 10240); + } else { + sf = dlsch_absSF % 10; + f = dlsch_absSF / 10; + nextf = (f + 1) & 1023; + + switch (cc->tdd_Config->subframeAssignment) { + case 0: + AssertFatal(1 == 0, "SFA 0 to be filled in now, :-)\n"); + break; + case 1: + if ((sf == 5) || (sf == 6)) + return ((10 * nextf) + 2); // ACK/NAK in SF 2 next frame + else if (sf == 9) + return ((10 * nextf) + 3); // ACK/NAK in SF 3 next frame + else if ((sf == 0) || (sf == 1)) + return ((10 * f) + 2); // ACK/NAK in SF 7 same frame + else + AssertFatal(1 == 0, + "Impossible dlsch subframe %d for TDD configuration 3\n", + sf); + break; + case 2: + if ((sf == 4) || (sf == 5) || (sf == 6) || (sf == 8)) + return ((10 * nextf) + 2); // ACK/NAK in SF 2 next frame + else if (sf == 9) + return ((10 * nextf) + 7); // ACK/NAK in SF 7 next frame + else if ((sf == 0) || (sf == 1) || (sf == 3)) + return ((10 * f) + 7); // ACK/NAK in SF 7 same frame + else + AssertFatal(1 == 0, + "Impossible dlsch subframe %d for TDD configuration 3\n", + sf); + break; + case 3: + if ((sf == 5) || (sf == 6) || (sf == 7) || (sf == 8) + || (sf == 9)) + return ((10 * nextf) + (sf >> 1)); // ACK/NAK in 2,3,4 resp. next frame + else if (sf == 1) + return ((10 * nextf) + 2); // ACK/NAK in 2 next frame + else if (sf == 0) + return ((10 * f) + 4); // ACK/NAK in 4 same frame + else + AssertFatal(1 == 0, + "Impossible dlsch subframe %d for TDD configuration 3\n", + sf); + break; + case 4: + if ((sf == 6) || (sf == 7) || (sf == 8) || (sf == 9)) + return (((10 * nextf) + 3) % 10240); // ACK/NAK in SF 3 next frame + else if ((sf == 0) || (sf == 1) || (sf == 4) || (sf == 5)) + return (((10 * nextf) + 2) % 10240); // ACK/NAK in SF 2 next frame + else + AssertFatal(1 == 0, + "Impossible dlsch subframe %d for TDD configuration 4\n", + sf); + break; + case 5: + if ((sf == 0) || (sf == 1) || (sf == 3) || (sf == 4) + || (sf == 5) || (sf == 6) || (sf == 7) || (sf == 8)) + return (((10 * nextf) + 2) % 10240); // ACK/NAK in SF 3 next frame + else if (sf == 9) + return (((10 * (1 + nextf)) + 2) % 10240); // ACK/NAK in SF 2 next frame + else + AssertFatal(1 == 0, + "Impossible dlsch subframe %d for TDD configuration 5\n", + sf); + break; + case 6: + AssertFatal(1 == 0, "SFA 6 To be filled in now, :-)\n"); + break; + default: + AssertFatal(1 == 0, "Illegal TDD subframe Assigment %d\n", + (int) cc->tdd_Config->subframeAssignment); + break; + } + } + AssertFatal(1 == 0, "Shouldn't get here\n"); } -uint8_t pdcchalloc2ulsubframe(COMMON_channels_t *ccP,uint8_t n) +void +get_srs_pos(COMMON_channels_t * cc, uint16_t isrs, + uint16_t * psrsPeriodicity, uint16_t * psrsOffset) { - uint8_t ul_subframe; - - if ((ccP->tdd_Config) && - (ccP->tdd_Config->subframeAssignment == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_subframe = ((n+6)%10); - else if ((ccP->tdd_Config) && - (ccP->tdd_Config->subframeAssignment == 6) && - ((n==0)||(n==1)||(n==5)||(n==6))) - ul_subframe = ((n+7)%10); - else if ((ccP->tdd_Config) && - (ccP->tdd_Config->subframeAssignment == 6) && - (n==9)) // tdd_config 6 SF 9 - ul_subframe = ((n+5)%10); - else - ul_subframe = ((n+4)%10); - - LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe); - return ul_subframe; + if (cc->tdd_Config) { // TDD + AssertFatal(isrs >= 10, "2 ms SRS periodicity not supported"); + + if ((isrs > 9) && (isrs < 15)) { + *psrsPeriodicity = 5; + *psrsOffset = isrs - 10; + } + if ((isrs > 14) && (isrs < 25)) { + *psrsPeriodicity = 10; + *psrsOffset = isrs - 15; + } + if ((isrs > 24) && (isrs < 45)) { + *psrsPeriodicity = 20; + *psrsOffset = isrs - 25; + } + if ((isrs > 44) && (isrs < 85)) { + *psrsPeriodicity = 40; + *psrsOffset = isrs - 45; + } + if ((isrs > 84) && (isrs < 165)) { + *psrsPeriodicity = 80; + *psrsOffset = isrs - 85; + } + if ((isrs > 164) && (isrs < 325)) { + *psrsPeriodicity = 160; + *psrsOffset = isrs - 165; + } + if ((isrs > 324) && (isrs < 645)) { + *psrsPeriodicity = 320; + *psrsOffset = isrs - 325; + } + + AssertFatal(isrs <= 644, "Isrs out of range %d>644\n", isrs); + } // TDD + else { // FDD + if (isrs < 2) { + *psrsPeriodicity = 2; + *psrsOffset = isrs; + } + if ((isrs > 1) && (isrs < 7)) { + *psrsPeriodicity = 5; + *psrsOffset = isrs - 2; + } + if ((isrs > 6) && (isrs < 17)) { + *psrsPeriodicity = 10; + *psrsOffset = isrs - 7; + } + if ((isrs > 16) && (isrs < 37)) { + *psrsPeriodicity = 20; + *psrsOffset = isrs - 17; + } + if ((isrs > 36) && (isrs < 77)) { + *psrsPeriodicity = 40; + *psrsOffset = isrs - 37; + } + if ((isrs > 76) && (isrs < 157)) { + *psrsPeriodicity = 80; + *psrsOffset = isrs - 77; + } + if ((isrs > 156) && (isrs < 317)) { + *psrsPeriodicity = 160; + *psrsOffset = isrs - 157; + } + if ((isrs > 316) && (isrs < 637)) { + *psrsPeriodicity = 320; + *psrsOffset = isrs - 317; + } + AssertFatal(isrs <= 636, "Isrs out of range %d>636\n", isrs); + } } -int is_UL_sf(COMMON_channels_t *ccP,sub_frame_t subframeP) +void +get_csi_params(COMMON_channels_t * cc, + struct CQI_ReportPeriodic *cqi_ReportPeriodic, + uint16_t * Npd, uint16_t * N_OFFSET_CQI, int *H) { - // if FDD return dummy value - if (ccP->tdd_Config == NULL) - return(0); - - switch (ccP->tdd_Config->subframeAssignment) { - case 1: - switch (subframeP) { - case 0: - case 4: - case 5: - case 9: - return(0); - break; - - case 2: - case 3: - case 7: - case 8: - return(1); - break; - - default: - return(0); - break; + uint16_t cqi_PMI_ConfigIndex = + cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; + uint8_t Jtab[6] = { 0, 2, 2, 3, 4, 4 }; + + AssertFatal(cqi_ReportPeriodic != NULL, + "cqi_ReportPeriodic is null!\n"); + + if (cc->tdd_Config == NULL) { //FDD + if (cqi_PMI_ConfigIndex <= 1) { // 2 ms CQI_PMI period + *Npd = 2; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex; + } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period + *Npd = 5; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 2; + } else if (cqi_PMI_ConfigIndex <= 16) { // 10ms CQI_PMI period + *Npd = 10; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 7; + } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period + *Npd = 20; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 17; + } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period + *Npd = 40; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 37; + } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period + *Npd = 80; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 77; + } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period + *Npd = 160; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 157; + } else if (cqi_PMI_ConfigIndex > 317) { + + if (cqi_PMI_ConfigIndex <= 349) { // 32 ms CQI_PMI period + *Npd = 32; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 318; + } else if (cqi_PMI_ConfigIndex <= 413) { // 64 ms CQI_PMI period + *Npd = 64; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 350; + } else if (cqi_PMI_ConfigIndex <= 541) { // 128 ms CQI_PMI period + *Npd = 128; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 414; + } + } + } else { // TDD + if (cqi_PMI_ConfigIndex == 0) { // all UL subframes + *Npd = 1; + *N_OFFSET_CQI = 0; + } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period + *Npd = 5; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 1; + } else if (cqi_PMI_ConfigIndex <= 16) { // 10ms CQI_PMI period + *Npd = 10; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 6; + } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period + *Npd = 20; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 16; + } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period + *Npd = 40; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 36; + } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period + *Npd = 80; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 76; + } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period + *Npd = 160; + *N_OFFSET_CQI = cqi_PMI_ConfigIndex - 156; + } } - break; - - case 3: - if ((subframeP<=1) || (subframeP>=5)) - return(0); - else if ((subframeP>1) && (subframeP < 5)) - return(1); - else AssertFatal(1==0,"Unknown subframe number\n"); - break; - - case 4: - if ((subframeP<=1) || (subframeP>=4)) - return(0); - else if ((subframeP>1) && (subframeP < 4)) - return(1); - else AssertFatal(1==0,"Unknown subframe number\n"); - break; - - case 5: - if ((subframeP<=1) || (subframeP>=3)) - return(0); - else if ((subframeP>1) && (subframeP < 3)) - return(1); - else AssertFatal(1==0,"Unknown subframe number\n"); - break; - default: - AssertFatal(1==0,"subframe %d Unsupported TDD configuration %d\n", - subframeP,(int)ccP->tdd_Config->subframeAssignment); - break; - } + // get H + if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic. + present == + CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) + *H = 1 + + (Jtab[cc->mib->message.dl_Bandwidth] * + cqi_ReportPeriodic->choice.setup. + cqi_FormatIndicatorPeriodic.choice.subbandCQI.k); + else + *H = 1; } -uint16_t get_pucch1_absSF(COMMON_channels_t *cc,uint16_t dlsch_absSF) +uint8_t +get_dl_cqi_pmi_size_pusch(COMMON_channels_t * cc, uint8_t tmode, + uint8_t ri, + CQI_ReportModeAperiodic_t * + cqi_ReportModeAperiodic) { - uint16_t sf,f,nextf; - - if (cc->tdd_Config==NULL) { //FDD n+4 - return((dlsch_absSF + 4)%10240); - } - else { - sf = dlsch_absSF%10; - f = dlsch_absSF/10; - nextf = (f+1)&1023; + int Ntab[6] = { 0, 4, 7, 9, 10, 13 }; + int N = Ntab[cc->mib->message.dl_Bandwidth]; + int Ltab_uesel[6] = { 0, 6, 9, 13, 15, 18 }; + int L = Ltab_uesel[cc->mib->message.dl_Bandwidth]; + + AssertFatal(cqi_ReportModeAperiodic != NULL, + "cqi_ReportPeriodic is null!\n"); + + switch (*cqi_ReportModeAperiodic) { + case CQI_ReportModeAperiodic_rm12: + AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal TM (%d) for CQI_ReportModeAperiodic_rm12\n", + tmode); + AssertFatal(cc->p_eNB <= 4, + "only up to 4 antenna ports supported here\n"); + if (ri == 1 && cc->p_eNB == 2) + return (4 + (N << 1)); + else if (ri == 2 && cc->p_eNB == 2) + return (8 + N); + else if (ri == 1 && cc->p_eNB == 4) + return (4 + (N << 2)); + else if (ri > 1 && cc->p_eNB == 4) + return (8 + (N << 2)); + break; + case CQI_ReportModeAperiodic_rm20: + // Table 5.2.2.6.3-1 (36.212) + AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 || tmode == 7 + || tmode == 9 + || tmode == 10, + "Illegal TM (%d) for CQI_ReportModeAperiodic_rm20\n", + tmode); + AssertFatal(tmode != 9 + && tmode != 10, + "TM9/10 will be handled later for CQI_ReportModeAperiodic_rm20\n"); + return (4 + 2 + L); + break; + case CQI_ReportModeAperiodic_rm22: + // Table 5.2.2.6.3-2 (36.212) + AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal TM (%d) for CQI_ReportModeAperiodic_rm22\n", + tmode); + AssertFatal(tmode != 9 + && tmode != 10, + "TM9/10 will be handled later for CQI_ReportModeAperiodic_rm22\n"); + if (ri == 1 && cc->p_eNB == 2) + return (4 + 2 + 0 + 0 + L + 4); + if (ri == 2 && cc->p_eNB == 2) + return (4 + 2 + 4 + 2 + L + 2); + if (ri == 1 && cc->p_eNB == 4) + return (4 + 2 + 0 + 0 + L + 8); + if (ri >= 2 && cc->p_eNB == 4) + return (4 + 2 + 4 + 2 + L + 8); + break; + case CQI_ReportModeAperiodic_rm30: + // Table 5.2.2.6.2-1 (36.212) + AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 || tmode == 7 + || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal TM (%d) for CQI_ReportModeAperiodic_rm30\n", + tmode); + AssertFatal(tmode != 8 && tmode != 9 + && tmode != 10, + "TM8/9/10 will be handled later for CQI_ReportModeAperiodic_rm30\n"); + return (4 + (N << 1)); + break; + case CQI_ReportModeAperiodic_rm31: + // Table 5.2.2.6.2-2 (36.212) + AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal TM (%d) for CQI_ReportModeAperiodic_rm31\n", + tmode); + AssertFatal(tmode != 8 && tmode != 9 + && tmode != 10, + "TM8/9/10 will be handled later for CQI_ReportModeAperiodic_rm31\n"); + if (ri == 1 && cc->p_eNB == 2) + return (4 + (N << 1) + 0 + 0 + 2); + else if (ri == 2 && cc->p_eNB == 2) + return (4 + (N << 1) + 4 + (N << 1) + 1); + else if (ri == 1 && cc->p_eNB == 4) + return (4 + (N << 1) + 0 + 0 + 4); + else if (ri >= 2 && cc->p_eNB == 4) + return (4 + (N << 1) + 4 + (N << 1) + 4); + break; + case CQI_ReportModeAperiodic_rm32_v1250: + AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal TM (%d) for CQI_ReportModeAperiodic_rm32\n", + tmode); + AssertFatal(1 == 0, + "CQI_ReportModeAperiodic_rm32_v1250 not supported yet\n"); + break; + case CQI_ReportModeAperiodic_rm10_v1310: + // Table 5.2.2.6.1-1F/G (36.212) + if (ri == 1) + return (4); // F + else + return (7); // G + break; + case CQI_ReportModeAperiodic_rm11_v1310: + // Table 5.2.2.6.1-1H (36.212) + AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal TM (%d) for CQI_ReportModeAperiodic_rm11\n", + tmode); + AssertFatal(cc->p_eNB <= 4, + "only up to 4 antenna ports supported here\n"); + if (ri == 1 && cc->p_eNB == 2) + return (4 + 0 + 2); + else if (ri == 2 && cc->p_eNB == 2) + return (4 + 4 + 1); + else if (ri == 1 && cc->p_eNB == 4) + return (4 + 0 + 4); + else if (ri > 1 && cc->p_eNB == 4) + return (4 + 4 + 4); + + break; + } + AssertFatal(1 == 0, "Shouldn't get here\n"); + return (0); +} - switch (cc->tdd_Config->subframeAssignment) { - case 0: - AssertFatal(1==0,"SFA 0 to be filled in now, :-)\n"); - break; +uint8_t +get_rel8_dl_cqi_pmi_size(UE_sched_ctrl * sched_ctl, int CC_idP, + COMMON_channels_t * cc, uint8_t tmode, + struct CQI_ReportPeriodic * cqi_ReportPeriodic) +{ + int no_pmi = 0; + // Ltab[6] = {0,log2(15/4/2),log2(25/4/2),log2(50/6/3),log2(75/8/4),log2(100/8/4)}; + + uint8_t Ltab[6] = { 0, 1, 2, 2, 2, 2 }; + uint8_t ri = sched_ctl->periodic_ri_received[CC_idP]; + + AssertFatal(cqi_ReportPeriodic != NULL, + "cqi_ReportPeriodic is null!\n"); + AssertFatal(cqi_ReportPeriodic->present != + CQI_ReportPeriodic_PR_NOTHING, + "cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_NOTHING!\n"); + AssertFatal(cqi_ReportPeriodic->choice. + setup.cqi_FormatIndicatorPeriodic.present != + CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING, + "cqi_ReportPeriodic->cqi_FormatIndicatorPeriodic.choice.setup.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING!\n"); + + switch (tmode) { case 1: - if ((sf==5) || (sf==6)) return((10*nextf) + 2); // ACK/NAK in SF 2 next frame - else if (sf==9) return((10*nextf) + 3); // ACK/NAK in SF 3 next frame - else if ((sf==0) || (sf==1)) return((10*f) + 2); // ACK/NAK in SF 7 same frame - else AssertFatal(1==0,"Impossible dlsch subframe %d for TDD configuration 3\n",sf); - break; case 2: - if ((sf==4) || (sf==5) || (sf==6) || (sf==8)) return((10*nextf) + 2); // ACK/NAK in SF 2 next frame - else if (sf==9) return((10*nextf) + 7); // ACK/NAK in SF 7 next frame - else if ((sf==0) || (sf==1) || (sf==3)) return((10*f) + 7); // ACK/NAK in SF 7 same frame - else AssertFatal(1==0,"Impossible dlsch subframe %d for TDD configuration 3\n",sf); - break; - case 3: - if ((sf==5) || (sf==6) || (sf==7) || (sf==8) || (sf==9)) return((10*nextf) + (sf>>1)); // ACK/NAK in 2,3,4 resp. next frame - else if (sf==1) return((10*nextf) + 2); // ACK/NAK in 2 next frame - else if (sf==0) return((10*f) + 4); // ACK/NAK in 4 same frame - else AssertFatal(1==0,"Impossible dlsch subframe %d for TDD configuration 3\n",sf); - break; - case 4: - if ((sf==6) || (sf==7) || (sf==8) || (sf==9)) return(((10*nextf) + 3)%10240); // ACK/NAK in SF 3 next frame - else if ((sf==0) || (sf==1) || (sf==4) || (sf==5)) return(((10*nextf) + 2)%10240); // ACK/NAK in SF 2 next frame - else AssertFatal(1==0,"Impossible dlsch subframe %d for TDD configuration 4\n",sf); - break; case 5: - if ((sf==0) || (sf==1) || (sf==3) || (sf==4) || (sf==5) || (sf==6) || (sf==7) || (sf==8)) return(((10*nextf) + 2)%10240); // ACK/NAK in SF 3 next frame - else if (sf==9) return(((10*(1+nextf)) + 2)%10240); // ACK/NAK in SF 2 next frame - else AssertFatal(1==0,"Impossible dlsch subframe %d for TDD configuration 5\n",sf); - break; case 6: - AssertFatal(1==0,"SFA 6 To be filled in now, :-)\n"); - break; + case 7: + no_pmi = 1; + break; default: - AssertFatal(1==0,"Illegal TDD subframe Assigment %d\n",(int)cc->tdd_Config->subframeAssignment); - break; - } - } - AssertFatal(1==0,"Shouldn't get here\n"); -} - -void get_srs_pos(COMMON_channels_t *cc,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset) -{ - if(cc->tdd_Config) { // TDD - AssertFatal(isrs>=10,"2 ms SRS periodicity not supported"); - - if ((isrs>9)&&(isrs<15)) { - *psrsPeriodicity=5; - *psrsOffset=isrs-10; - } - if ((isrs>14)&&(isrs<25)) { - *psrsPeriodicity=10; - *psrsOffset=isrs-15; - } - if ((isrs>24)&&(isrs<45)) { - *psrsPeriodicity=20; - *psrsOffset=isrs-25; - } - if ((isrs>44)&&(isrs<85)) { - *psrsPeriodicity=40; - *psrsOffset=isrs-45; - } - if ((isrs>84)&&(isrs<165)) { - *psrsPeriodicity=80; - *psrsOffset=isrs-85; - } - if ((isrs>164)&&(isrs<325)) { - *psrsPeriodicity=160; - *psrsOffset=isrs-165; - } - if ((isrs>324)&&(isrs<645)) { - *psrsPeriodicity=320; - *psrsOffset=isrs-325; - } - - AssertFatal(isrs<=644,"Isrs out of range %d>644\n",isrs); - } // TDD - else { // FDD - if (isrs<2) { - *psrsPeriodicity=2; - *psrsOffset=isrs; - } - if ((isrs>1)&&(isrs<7)) { - *psrsPeriodicity=5; - *psrsOffset=isrs-2; - } - if ((isrs>6)&&(isrs<17)) { - *psrsPeriodicity=10; - *psrsOffset=isrs-7; - } - if ((isrs>16)&&(isrs<37)) { - *psrsPeriodicity=20; - *psrsOffset=isrs-17; + no_pmi = 0; } - if ((isrs>36)&&(isrs<77)) { - *psrsPeriodicity=40; - *psrsOffset=isrs-37; - } - if ((isrs>76)&&(isrs<157)) { - *psrsPeriodicity=80; - *psrsOffset=isrs-77; - } - if ((isrs>156)&&(isrs<317)) { - *psrsPeriodicity=160; - *psrsOffset=isrs-157; - } - if ((isrs>316)&&(isrs<637)) { - *psrsPeriodicity=320; - *psrsOffset=isrs-317; - } - AssertFatal(isrs<=636,"Isrs out of range %d>636\n",isrs); - } -} - -void get_csi_params(COMMON_channels_t *cc,struct CQI_ReportPeriodic *cqi_ReportPeriodic,uint16_t *Npd,uint16_t *N_OFFSET_CQI,int *H) -{ - uint16_t cqi_PMI_ConfigIndex = cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; - uint8_t Jtab[6] = {0,2,2,3,4,4}; - - AssertFatal(cqi_ReportPeriodic!=NULL,"cqi_ReportPeriodic is null!\n"); - - if (cc->tdd_Config==NULL) { //FDD - if (cqi_PMI_ConfigIndex <= 1) { // 2 ms CQI_PMI period - *Npd = 2; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex; - } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period - *Npd = 5; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-2; - } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period - *Npd = 10; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-7; - } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period - *Npd = 20; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-17; - } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period - *Npd = 40; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-37; - } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period - *Npd = 80; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-77; - } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period - *Npd = 160; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-157; - } - else if (cqi_PMI_ConfigIndex > 317) { - if (cqi_PMI_ConfigIndex <= 349) { // 32 ms CQI_PMI period - *Npd = 32; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-318; - } - else if (cqi_PMI_ConfigIndex <= 413) { // 64 ms CQI_PMI period - *Npd = 64; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-350; - } - else if (cqi_PMI_ConfigIndex <= 541) { // 128 ms CQI_PMI period - *Npd = 128; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-414; - } + if ((cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic. + present == + CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_widebandCQI) + || (sched_ctl->feedback_cnt[CC_idP] == 0)) { + // send wideband report every opportunity if wideband reporting mode is selected, else every H opportunities + if (no_pmi == 1) + return (4); + else if ((cc->p_eNB == 2) && (ri == 1)) + return (6); + else if ((cc->p_eNB == 2) && (ri == 2)) + return (8); + else if ((cc->p_eNB == 4) && (ri == 1)) + return (8); + else if ((cc->p_eNB == 4) && (ri == 2)) + return (11); + else + AssertFatal(1 == 0, + "illegal combination p %d, ri %d, no_pmi %d\n", + cc->p_eNB, ri, no_pmi); + } else if (cqi_ReportPeriodic->choice. + setup.cqi_FormatIndicatorPeriodic.present == + CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) + { + if ((no_pmi == 1) || ri == 1) + return (4 + Ltab[cc->mib->message.dl_Bandwidth]); + else + return (7 + Ltab[cc->mib->message.dl_Bandwidth]); } - } - else { // TDD - if (cqi_PMI_ConfigIndex == 0) { // all UL subframes - *Npd = 1; - *N_OFFSET_CQI = 0; - } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period - *Npd = 5; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-1; - } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period - *Npd = 10; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-6; - } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period - *Npd = 20; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-16; - } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period - *Npd = 40; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-36; - } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period - *Npd = 80; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-76; - } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period - *Npd = 160; - *N_OFFSET_CQI = cqi_PMI_ConfigIndex-156; - } - } - // get H - if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) - *H = 1+(Jtab[cc->mib->message.dl_Bandwidth]*cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k); - else - *H=1; + AssertFatal(1 == 0, + "Shouldn't get here : cqi_ReportPeriodic->present %d\n", + cqi_ReportPeriodic->choice. + setup.cqi_FormatIndicatorPeriodic.present); } -uint8_t get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc,uint8_t tmode,uint8_t ri, CQI_ReportModeAperiodic_t *cqi_ReportModeAperiodic) +void +fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t * dl_config_pdu, + uint8_t aggregation_level, + uint16_t rnti, + uint8_t rnti_type, + uint8_t harq_process, + uint8_t tpc, + uint16_t resource_block_coding, + uint8_t mcs, uint8_t ndi, uint8_t rv, + uint8_t vrb_flag) { - int Ntab[6] = {0,4,7,9,10,13}; - int N = Ntab[cc->mib->message.dl_Bandwidth]; - int Ltab_uesel[6] = {0,6,9,13,15,18}; - int L = Ltab_uesel[cc->mib->message.dl_Bandwidth]; - - AssertFatal(cqi_ReportModeAperiodic != NULL,"cqi_ReportPeriodic is null!\n"); - - switch (*cqi_ReportModeAperiodic) { - case CQI_ReportModeAperiodic_rm12: - AssertFatal(tmode==4 || tmode==6 || tmode==8 || tmode==9 || tmode==10,"Illegal TM (%d) for CQI_ReportModeAperiodic_rm12\n",tmode); - AssertFatal(cc->p_eNB<=4,"only up to 4 antenna ports supported here\n"); - if (ri==1 && cc->p_eNB==2) return(4+(N<<1)); - else if (ri==2 && cc->p_eNB==2) return(8+N); - else if (ri==1 && cc->p_eNB==4) return(4+(N<<2)); - else if (ri>1 && cc->p_eNB==4) return(8+(N<<2)); - break; - case CQI_ReportModeAperiodic_rm20: - // Table 5.2.2.6.3-1 (36.212) - AssertFatal(tmode==1 || tmode==2 || tmode==3 || tmode==7 || tmode==9 || tmode==10,"Illegal TM (%d) for CQI_ReportModeAperiodic_rm20\n",tmode); - AssertFatal(tmode!=9 && tmode!=10,"TM9/10 will be handled later for CQI_ReportModeAperiodic_rm20\n"); - return(4+2+L); - break; - case CQI_ReportModeAperiodic_rm22: - // Table 5.2.2.6.3-2 (36.212) - AssertFatal(tmode==4 || tmode==6 || tmode==8 || tmode==9 || tmode==10,"Illegal TM (%d) for CQI_ReportModeAperiodic_rm22\n",tmode); - AssertFatal(tmode!=9 && tmode!=10,"TM9/10 will be handled later for CQI_ReportModeAperiodic_rm22\n"); - if (ri==1 && cc->p_eNB==2) return(4+2+0+0+L+4); - if (ri==2 && cc->p_eNB==2) return(4+2+4+2+L+2); - if (ri==1 && cc->p_eNB==4) return(4+2+0+0+L+8); - if (ri>=2 && cc->p_eNB==4) return(4+2+4+2+L+8); - break; - case CQI_ReportModeAperiodic_rm30: - // Table 5.2.2.6.2-1 (36.212) - AssertFatal(tmode==1 || tmode==2 || tmode==3 || tmode==7 || tmode==8 || tmode==9 || tmode==10,"Illegal TM (%d) for CQI_ReportModeAperiodic_rm30\n",tmode); - AssertFatal(tmode!=8 && tmode!=9 && tmode!=10,"TM8/9/10 will be handled later for CQI_ReportModeAperiodic_rm30\n"); - return(4+(N<<1)); - break; - case CQI_ReportModeAperiodic_rm31: - // Table 5.2.2.6.2-2 (36.212) - AssertFatal(tmode==4 || tmode==6 || tmode==8 || tmode==9 || tmode==10,"Illegal TM (%d) for CQI_ReportModeAperiodic_rm31\n",tmode); - AssertFatal(tmode!=8 && tmode!=9 && tmode!=10,"TM8/9/10 will be handled later for CQI_ReportModeAperiodic_rm31\n"); - if (ri==1 && cc->p_eNB==2) return(4+(N<<1)+0+0+2); - else if (ri==2 && cc->p_eNB==2) return(4+(N<<1)+4+(N<<1)+1); - else if (ri==1 && cc->p_eNB==4) return(4+(N<<1)+0+0+4); - else if (ri>=2 && cc->p_eNB==4) return(4+(N<<1)+4+(N<<1)+4); - break; - case CQI_ReportModeAperiodic_rm32_v1250: - AssertFatal(tmode==4 || tmode==6 || tmode==8 || tmode==9 || tmode==10,"Illegal TM (%d) for CQI_ReportModeAperiodic_rm32\n",tmode); - AssertFatal(1==0,"CQI_ReportModeAperiodic_rm32_v1250 not supported yet\n"); - break; - case CQI_ReportModeAperiodic_rm10_v1310: - // Table 5.2.2.6.1-1F/G (36.212) - if (ri==1) return(4); // F - else return(7); // G - break; - case CQI_ReportModeAperiodic_rm11_v1310: - // Table 5.2.2.6.1-1H (36.212) - AssertFatal(tmode==4 || tmode==6 || tmode==8 || tmode==9 || tmode==10,"Illegal TM (%d) for CQI_ReportModeAperiodic_rm11\n",tmode); - AssertFatal(cc->p_eNB<=4,"only up to 4 antenna ports supported here\n"); - if (ri==1 && cc->p_eNB==2) return(4+0+2); - else if (ri==2 && cc->p_eNB==2) return(4+4+1); - else if (ri==1 && cc->p_eNB==4) return(4+0+4); - else if (ri>1 && cc->p_eNB==4) return(4+4+4); - - break; - } - AssertFatal(1==0,"Shouldn't get here\n"); - return(0); + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = + NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = + NFAPI_DL_DCI_FORMAT_1A; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = + aggregation_level; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = rnti_type; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_process; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // no TPC + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = + resource_block_coding; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = ndi; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = rv; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = vrb_flag; } -uint8_t get_rel8_dl_cqi_pmi_size(UE_sched_ctrl *sched_ctl,int CC_idP,COMMON_channels_t *cc,uint8_t tmode, struct CQI_ReportPeriodic *cqi_ReportPeriodic) +void +program_dlsch_acknak(module_id_t module_idP, int CC_idP, int UE_idP, + frame_t frameP, sub_frame_t subframeP, + uint8_t cce_idx) { - int no_pmi=0; - // Ltab[6] = {0,log2(15/4/2),log2(25/4/2),log2(50/6/3),log2(75/8/4),log2(100/8/4)}; - - uint8_t Ltab[6] = {0,1,2,2,2,2}; - uint8_t ri = sched_ctl->periodic_ri_received[CC_idP]; - - AssertFatal(cqi_ReportPeriodic != NULL,"cqi_ReportPeriodic is null!\n"); - AssertFatal(cqi_ReportPeriodic->present != CQI_ReportPeriodic_PR_NOTHING, - "cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_NOTHING!\n"); - AssertFatal(cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present != CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING, - "cqi_ReportPeriodic->cqi_FormatIndicatorPeriodic.choice.setup.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING!\n"); + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + UE_list_t *UE_list = &eNB->UE_list; + rnti_t rnti = UE_RNTI(module_idP, UE_idP); + nfapi_ul_config_request_body_t *ul_req; + nfapi_ul_config_request_pdu_t *ul_config_pdu; - switch(tmode) { - case 1: - case 2: - case 5: - case 6: - case 7: - no_pmi=1; - break; - default: - no_pmi=0; - } - if ((cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_widebandCQI) || - (sched_ctl->feedback_cnt[CC_idP] == 0)) { - // send wideband report every opportunity if wideband reporting mode is selected, else every H opportunities - if (no_pmi == 1) - return(4); - else if ((cc->p_eNB==2) && (ri==1)) return(6); - else if ((cc->p_eNB==2) && (ri==2)) return(8); - else if ((cc->p_eNB==4) && (ri==1)) return(8); - else if ((cc->p_eNB==4) && (ri==2)) return(11); - else AssertFatal(1==0,"illegal combination p %d, ri %d, no_pmi %d\n",cc->p_eNB,ri,no_pmi); - } - else if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) { - if ((no_pmi == 1)||ri==1) return(4+Ltab[cc->mib->message.dl_Bandwidth]); - else - return(7+Ltab[cc->mib->message.dl_Bandwidth]); - } - AssertFatal(1==0,"Shouldn't get here : cqi_ReportPeriodic->present %d\n",cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present); -} - -void fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t *dl_config_pdu, - uint8_t aggregation_level, - uint16_t rnti, - uint8_t rnti_type, - uint8_t harq_process, - uint8_t tpc, - uint16_t resource_block_coding, - uint8_t mcs, - uint8_t ndi, - uint8_t rv, - uint8_t vrb_flag) -{ - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation_level; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = rnti_type; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_process; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // no TPC - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = resource_block_coding; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = ndi; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = rv; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = vrb_flag; -} - -void program_dlsch_acknak(module_id_t module_idP, int CC_idP,int UE_idP, frame_t frameP, sub_frame_t subframeP,uint8_t cce_idx) -{ - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - UE_list_t *UE_list = &eNB->UE_list; - rnti_t rnti = UE_RNTI(module_idP,UE_idP); - nfapi_ul_config_request_body_t *ul_req; - nfapi_ul_config_request_pdu_t *ul_config_pdu; - - int use_simultaneous_pucch_pusch=0; - nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = NULL; - nfapi_ul_config_harq_information *harq_information = NULL; + int use_simultaneous_pucch_pusch = 0; + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = NULL; + nfapi_ul_config_harq_information *harq_information = NULL; #if defined(Rel10) || defined(Rel14) - if ((UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2) && - (UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2->pucch_ConfigDedicated_v1020) && - (UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2->pucch_ConfigDedicated_v1020->simultaneousPUCCH_PUSCH_r10) && - (*UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2->pucch_ConfigDedicated_v1020->simultaneousPUCCH_PUSCH_r10 == - PUCCH_ConfigDedicated_v1020__simultaneousPUCCH_PUSCH_r10_true)) - use_simultaneous_pucch_pusch=1; + if ((UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated-> + ext2) + && (UE_list->UE_template[CC_idP][UE_idP]. + physicalConfigDedicated->ext2->pucch_ConfigDedicated_v1020) + && (UE_list->UE_template[CC_idP][UE_idP]. + physicalConfigDedicated->ext2->pucch_ConfigDedicated_v1020-> + simultaneousPUCCH_PUSCH_r10) + && (*UE_list->UE_template[CC_idP][UE_idP]. + physicalConfigDedicated->ext2->pucch_ConfigDedicated_v1020-> + simultaneousPUCCH_PUSCH_r10 == + PUCCH_ConfigDedicated_v1020__simultaneousPUCCH_PUSCH_r10_true)) + use_simultaneous_pucch_pusch = 1; #endif - // pucch1 and pusch feedback is similar, namely in n+k subframes from now - // This is used in the following "if/else" condition to check if there isn't or is already an UL grant in n+k - int16_t ul_absSF = get_pucch1_absSF(&cc[CC_idP],subframeP+(10*frameP)); - - if ((ul_config_pdu = has_ul_grant(module_idP,CC_idP, - ul_absSF, - rnti)) == NULL) { - // no UL grant so - // Program ACK/NAK alone Format 1a/b or 3 - - ul_req = &RC.mac[module_idP]->UL_req_tmp[CC_idP][ul_absSF%10].ul_config_request_body; - ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - // Do PUCCH - fill_nfapi_uci_acknak(module_idP, - CC_idP, - rnti, - (frameP*10)+subframeP, - cce_idx); - } - else { - /* there is already an existing UL grant so update it if needed - * on top of some other UL resource (PUSCH,combined SR/CQI/HARQ on PUCCH, etc) - */ - switch(ul_config_pdu->pdu_type) { - - /* [ulsch] to [ulsch + harq] or [ulsch + harq on pucch] */ - - case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: - if (use_simultaneous_pucch_pusch==1) { - // Convert it to an NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE - harq_information = &ul_config_pdu->ulsch_uci_harq_pdu.harq_information; - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE; - LOG_D(MAC,"Frame %d, Subframe %d: Switched UCI HARQ to ULSCH UCI HARQ\n",frameP,subframeP); - } - else { - // Convert it to an NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE - ulsch_harq_information = &ul_config_pdu->ulsch_harq_pdu.harq_information; - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ul_config_pdu->ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_config_pdu->ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial=0; // last symbol not punctured - ul_config_pdu->ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks= - ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks; // we don't change the number of resource blocks across retransmissions yet - LOG_D(MAC,"Frame %d, Subframe %d: Switched UCI HARQ to ULSCH HARQ\n",frameP,subframeP); - } - break; - case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: - AssertFatal(use_simultaneous_pucch_pusch == 1, - "Cannot be NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE, simultaneous_pucch_pusch is active"); - break; - case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: - AssertFatal(use_simultaneous_pucch_pusch == 0, - "Cannot be NFAPI_UL_CONFIG_ULSCH_UCI_PDU_TYPE, simultaneous_pucch_pusch is inactive\n"); - break; - - /* [ulsch + cqi] to [ulsch + cqi + harq] */ - - case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: - // Convert it to an NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE - ulsch_harq_information = &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information; - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - /* TODO: check this - when converting from nfapi_ul_config_ulsch_cqi_ri_pdu to - * nfapi_ul_config_ulsch_cqi_harq_ri_pdu, shouldn't we copy initial_transmission_parameters - * from the one to the other? - * Those two types are not compatible. 'initial_transmission_parameters' is not at the - * place in both. - */ - ul_config_pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_config_pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial=0; // last symbol not punctured - ul_config_pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks= - ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks; // we don't change the number of resource blocks across retransmissions yet - break; - case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: - AssertFatal(use_simultaneous_pucch_pusch == 0, - "Cannot be NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE, simultaneous_pucch_pusch is active\n"); - break; - - /* [ulsch + cqi on pucch] to [ulsch + cqi on pucch + harq on pucch] */ - - case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: - // convert it to an NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE - harq_information = &ul_config_pdu->ulsch_csi_uci_harq_pdu.harq_information; - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE; - break; - case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: - AssertFatal(use_simultaneous_pucch_pusch == 1, - "Cannot be NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE, simultaneous_pucch_pusch is inactive\n"); - break; - - /* [sr] to [sr + harq] */ - - case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: - // convert to NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; - harq_information = &ul_config_pdu->uci_sr_harq_pdu.harq_information; - break; - case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: - /* nothing to do */ - break; - - /* [cqi] to [cqi + harq] */ - - case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: - // convert to NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE; - harq_information = &ul_config_pdu->uci_cqi_harq_pdu.harq_information; - break; - case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: - /* nothing to do */ - break; - - /* [cqi + sr] to [cqr + sr + harq] */ - - case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: - // convert to NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE; - harq_information = &ul_config_pdu->uci_cqi_sr_harq_pdu.harq_information; - break; - case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: - /* nothing to do */ - break; + // pucch1 and pusch feedback is similar, namely in n+k subframes from now + // This is used in the following "if/else" condition to check if there isn't or is already an UL grant in n+k + int16_t ul_absSF = + get_pucch1_absSF(&cc[CC_idP], subframeP + (10 * frameP)); + + if ((ul_config_pdu = has_ul_grant(module_idP, CC_idP, + ul_absSF, rnti)) == NULL) { + // no UL grant so + // Program ACK/NAK alone Format 1a/b or 3 + + ul_req = + &RC.mac[module_idP]->UL_req_tmp[CC_idP][ul_absSF % + 10]. + ul_config_request_body; + ul_config_pdu = + &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; + // Do PUCCH + fill_nfapi_uci_acknak(module_idP, + CC_idP, + rnti, (frameP * 10) + subframeP, cce_idx); + } else { + /* there is already an existing UL grant so update it if needed + * on top of some other UL resource (PUSCH,combined SR/CQI/HARQ on PUCCH, etc) + */ + switch (ul_config_pdu->pdu_type) { + + /* [ulsch] to [ulsch + harq] or [ulsch + harq on pucch] */ + + case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: + if (use_simultaneous_pucch_pusch == 1) { + // Convert it to an NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE + harq_information = + &ul_config_pdu->ulsch_uci_harq_pdu.harq_information; + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE; + LOG_D(MAC, + "Frame %d, Subframe %d: Switched UCI HARQ to ULSCH UCI HARQ\n", + frameP, subframeP); + } else { + // Convert it to an NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE + ulsch_harq_information = + &ul_config_pdu->ulsch_harq_pdu.harq_information; + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ul_config_pdu->ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_config_pdu->ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_config_pdu->ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks; // we don't change the number of resource blocks across retransmissions yet + LOG_D(MAC, + "Frame %d, Subframe %d: Switched UCI HARQ to ULSCH HARQ\n", + frameP, subframeP); + } + break; + case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: + AssertFatal(use_simultaneous_pucch_pusch == 1, + "Cannot be NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE, simultaneous_pucch_pusch is active"); + break; + case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: + AssertFatal(use_simultaneous_pucch_pusch == 0, + "Cannot be NFAPI_UL_CONFIG_ULSCH_UCI_PDU_TYPE, simultaneous_pucch_pusch is inactive\n"); + break; + + /* [ulsch + cqi] to [ulsch + cqi + harq] */ + + case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: + // Convert it to an NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE + ulsch_harq_information = + &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information; + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + /* TODO: check this - when converting from nfapi_ul_config_ulsch_cqi_ri_pdu to + * nfapi_ul_config_ulsch_cqi_harq_ri_pdu, shouldn't we copy initial_transmission_parameters + * from the one to the other? + * Those two types are not compatible. 'initial_transmission_parameters' is not at the + * place in both. + */ + ul_config_pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_config_pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_config_pdu->ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks; // we don't change the number of resource blocks across retransmissions yet + break; + case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: + AssertFatal(use_simultaneous_pucch_pusch == 0, + "Cannot be NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE, simultaneous_pucch_pusch is active\n"); + break; + + /* [ulsch + cqi on pucch] to [ulsch + cqi on pucch + harq on pucch] */ + + case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: + // convert it to an NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE + harq_information = + &ul_config_pdu->ulsch_csi_uci_harq_pdu.harq_information; + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE; + break; + case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: + AssertFatal(use_simultaneous_pucch_pusch == 1, + "Cannot be NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE, simultaneous_pucch_pusch is inactive\n"); + break; + + /* [sr] to [sr + harq] */ + + case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: + // convert to NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; + harq_information = + &ul_config_pdu->uci_sr_harq_pdu.harq_information; + break; + case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: + /* nothing to do */ + break; + + /* [cqi] to [cqi + harq] */ + + case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: + // convert to NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE; + harq_information = + &ul_config_pdu->uci_cqi_harq_pdu.harq_information; + break; + case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: + /* nothing to do */ + break; + + /* [cqi + sr] to [cqr + sr + harq] */ + + case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: + // convert to NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE + ul_config_pdu->pdu_type = + NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE; + harq_information = + &ul_config_pdu->uci_cqi_sr_harq_pdu.harq_information; + break; + case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: + /* nothing to do */ + break; + } } - } - if (ulsch_harq_information) fill_nfapi_ulsch_harq_information(module_idP,CC_idP, - rnti, - ulsch_harq_information); + if (ulsch_harq_information) + fill_nfapi_ulsch_harq_information(module_idP, CC_idP, + rnti, ulsch_harq_information); - if (harq_information) fill_nfapi_harq_information(module_idP,CC_idP, - rnti, - (frameP*10)+subframeP, - harq_information, - cce_idx); + if (harq_information) + fill_nfapi_harq_information(module_idP, CC_idP, + rnti, + (frameP * 10) + subframeP, + harq_information, cce_idx); } -uint8_t get_V_UL_DAI(module_id_t module_idP,int CC_idP,uint16_t rntiP) +uint8_t get_V_UL_DAI(module_id_t module_idP, int CC_idP, uint16_t rntiP) { - nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[0]; - - for (int i=0;i<HI_DCI0_req->number_of_dci;i++) { - if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE)&& - (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) - return(hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.dl_assignment_index); - } - return(4); // this is rule from Section 7.3 in 36.213 + nfapi_hi_dci0_request_body_t *HI_DCI0_req = + &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = + &HI_DCI0_req->hi_dci0_pdu_list[0]; + + for (int i = 0; i < HI_DCI0_req->number_of_dci; i++) { + if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) && + (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) + return (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8. + dl_assignment_index); + } + return (4); // this is rule from Section 7.3 in 36.213 } -void fill_nfapi_ulsch_harq_information(module_id_t module_idP, - int CC_idP, - uint16_t rntiP, - nfapi_ul_config_ulsch_harq_information *harq_information) +void +fill_nfapi_ulsch_harq_information(module_id_t module_idP, + int CC_idP, + uint16_t rntiP, + nfapi_ul_config_ulsch_harq_information + * harq_information) { - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - UE_list_t *UE_list = &eNB->UE_list; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; + UE_list_t *UE_list = &eNB->UE_list; + + int UE_id = find_UE_id(module_idP, rntiP); + + PUSCH_ConfigDedicated_t *puschConfigDedicated; + // PUSCH_ConfigDedicated_v1020_t *puschConfigDedicated_v1020; + // PUSCH_ConfigDedicated_v1130_t *puschConfigDedicated_v1130; + // PUSCH_ConfigDedicated_v1250_t *puschConfigDedicated_v1250; + + AssertFatal(UE_id >= 0, "UE_id cannot be found, impossible\n"); + AssertFatal(UE_list != NULL, "UE_list is null\n"); + AssertFatal(UE_list->UE_template[CC_idP][UE_id]. + physicalConfigDedicated != NULL, + "physicalConfigDedicated for rnti %x is null\n", rntiP); + AssertFatal((puschConfigDedicated = (PUSCH_ConfigDedicated_t *) + UE_list->UE_template[CC_idP][UE_id]. + physicalConfigDedicated->pusch_ConfigDedicated) != NULL, + "physicalConfigDedicated->puschConfigDedicated for rnti %x is null\n", + rntiP); +#if defined(Rel14) || defined(Rel14) + /* if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2) puschConfigDedicated_v1020 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2->pusch_ConfigDedicated_v1020; + #endif + #ifdef Rel14 + if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext4) puschConfigDedicated_v1130 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext4->pusch_ConfigDedicated_v1130; + if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext5) puschConfigDedicated_v1250 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext5->pusch_ConfigDedicated_v1250; + */ +#endif + harq_information->harq_information_rel10.delta_offset_harq = + puschConfigDedicated->betaOffset_ACK_Index; + AssertFatal(UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated != NULL, + "pucch_ConfigDedicated is null!\n"); + if ((UE_list->UE_template[CC_idP][UE_id]. + physicalConfigDedicated->pucch_ConfigDedicated-> + tdd_AckNackFeedbackMode != NULL) + && (*UE_list->UE_template[CC_idP][UE_id]. + physicalConfigDedicated->pucch_ConfigDedicated-> + tdd_AckNackFeedbackMode == + PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) + harq_information->harq_information_rel10.ack_nack_mode = 1; // multiplexing + else + harq_information->harq_information_rel10.ack_nack_mode = 0; // bundling - int UE_id = find_UE_id(module_idP,rntiP); + switch (get_tmode(module_idP, CC_idP, UE_id)) { + case 1: + case 2: + case 5: + case 6: + case 7: + if (cc->tdd_Config == NULL) // FDD + harq_information->harq_information_rel10.harq_size = 1; + else { + if (harq_information->harq_information_rel10.ack_nack_mode == + 1) + harq_information->harq_information_rel10.harq_size = + get_V_UL_DAI(module_idP, CC_idP, rntiP); + else + harq_information->harq_information_rel10.harq_size = 1; + } + break; + default: // for any other TM we need 2 bits harq + if (cc->tdd_Config == NULL) { + harq_information->harq_information_rel10.harq_size = 2; + } else { + if (harq_information->harq_information_rel10.ack_nack_mode == + 1) + harq_information->harq_information_rel10.harq_size = + get_V_UL_DAI(module_idP, CC_idP, rntiP); + else + harq_information->harq_information_rel10.harq_size = 2; + } + break; + } // get Tmode +} - PUSCH_ConfigDedicated_t *puschConfigDedicated; - // PUSCH_ConfigDedicated_v1020_t *puschConfigDedicated_v1020; - // PUSCH_ConfigDedicated_v1130_t *puschConfigDedicated_v1130; - // PUSCH_ConfigDedicated_v1250_t *puschConfigDedicated_v1250; +void +fill_nfapi_harq_information(module_id_t module_idP, + int CC_idP, + uint16_t rntiP, + uint16_t absSFP, + nfapi_ul_config_harq_information * + harq_information, uint8_t cce_idxP) +{ + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; + UE_list_t *UE_list = &eNB->UE_list; - AssertFatal(UE_id>=0,"UE_id cannot be found, impossible\n"); - AssertFatal(UE_list!=NULL,"UE_list is null\n"); - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated for rnti %x is null\n",rntiP); - AssertFatal((puschConfigDedicated = (PUSCH_ConfigDedicated_t *)UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pusch_ConfigDedicated)!=NULL,"physicalConfigDedicated->puschConfigDedicated for rnti %x is null\n",rntiP); -#if defined(Rel14) || defined(Rel14) - /* if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2) puschConfigDedicated_v1020 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2->pusch_ConfigDedicated_v1020; -#endif -#ifdef Rel14 - if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext4) puschConfigDedicated_v1130 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext4->pusch_ConfigDedicated_v1130; - if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext5) puschConfigDedicated_v1250 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext5->pusch_ConfigDedicated_v1250; - */ + int UE_id = find_UE_id(module_idP, rntiP); + + AssertFatal(UE_id >= 0, "UE_id cannot be found, impossible\n"); + AssertFatal(UE_list != NULL, "UE_list is null\n"); +#if 0 + /* TODO: revisit, don't use Assert, it's perfectly possible to + * have physicalConfigDedicated NULL here + */ + AssertFatal(UE_list->UE_template[CC_idP][UE_id]. + physicalConfigDedicated != NULL, + "physicalConfigDedicated for rnti %x is null\n", rntiP); #endif - harq_information->harq_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG; - harq_information->harq_information_rel10.delta_offset_harq = puschConfigDedicated->betaOffset_ACK_Index; - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated!=NULL,"pucch_ConfigDedicated is null!\n"); - if ((UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode!=NULL)&& - (*UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode==PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) - harq_information->harq_information_rel10.ack_nack_mode = 1; // multiplexing - else - harq_information->harq_information_rel10.ack_nack_mode = 0; // bundling - - switch(get_tmode(module_idP,CC_idP,UE_id)) { - case 1: - case 2: - case 5: - case 6: - case 7: - if (cc->tdd_Config==NULL) // FDD - harq_information->harq_information_rel10.harq_size = 1; - else { - if (harq_information->harq_information_rel10.ack_nack_mode == 1) - harq_information->harq_information_rel10.harq_size = get_V_UL_DAI(module_idP,CC_idP,rntiP); - else - harq_information->harq_information_rel10.harq_size = 1; - } - break; - default: // for any other TM we need 2 bits harq - if (cc->tdd_Config==NULL) { - harq_information->harq_information_rel10.harq_size = 2; - } - else { - if (harq_information->harq_information_rel10.ack_nack_mode == 1) - harq_information->harq_information_rel10.harq_size = get_V_UL_DAI(module_idP,CC_idP,rntiP); - else - harq_information->harq_information_rel10.harq_size = 2; - } - break; - } // get Tmode + + harq_information->harq_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG; + harq_information->harq_information_rel11.num_ant_ports = 1; + + switch (get_tmode(module_idP, CC_idP, UE_id)) { + case 1: + case 2: + case 5: + case 6: + case 7: + if (cc->tdd_Config != NULL) { + AssertFatal(UE_list-> + UE_template[CC_idP] + [UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated != NULL, + "pucch_ConfigDedicated is null for TDD!\n"); + if ((UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated->tdd_AckNackFeedbackMode != NULL) + && (*UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated->tdd_AckNackFeedbackMode == + PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) + { + harq_information->harq_information_rel10_tdd.harq_size = 2; // 2-bit ACK/NAK + harq_information->harq_information_rel10_tdd.ack_nack_mode = 1; // multiplexing + } else { + harq_information->harq_information_rel10_tdd.harq_size = 1; // 1-bit ACK/NAK + harq_information->harq_information_rel10_tdd.ack_nack_mode = 0; // bundling + } + harq_information->harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; + harq_information->harq_information_rel10_tdd.n_pucch_1_0 = + cc->radioResourceConfigCommon->pucch_ConfigCommon. + n1PUCCH_AN + cce_idxP; + harq_information-> + harq_information_rel10_tdd.number_of_pucch_resources = 1; + } else { + harq_information->harq_information_rel9_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG; + harq_information-> + harq_information_rel9_fdd.number_of_pucch_resources = 1; + harq_information->harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK + harq_information->harq_information_rel9_fdd.n_pucch_1_0 = + cc->radioResourceConfigCommon->pucch_ConfigCommon. + n1PUCCH_AN + cce_idxP; + } + break; + default: // for any other TM we need 2 bits harq + if (cc->tdd_Config != NULL) { + AssertFatal(UE_list-> + UE_template[CC_idP] + [UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated != NULL, + "pucch_ConfigDedicated is null for TDD!\n"); + if ((UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated->tdd_AckNackFeedbackMode != NULL) + && (*UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated->tdd_AckNackFeedbackMode == + PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) + { + harq_information->harq_information_rel10_tdd.ack_nack_mode = 1; // multiplexing + } else { + harq_information->harq_information_rel10_tdd.ack_nack_mode = 0; // bundling + } + harq_information->harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; + harq_information->harq_information_rel10_tdd.harq_size = 2; + harq_information->harq_information_rel10_tdd.n_pucch_1_0 = + cc->radioResourceConfigCommon->pucch_ConfigCommon. + n1PUCCH_AN + cce_idxP; + harq_information-> + harq_information_rel10_tdd.number_of_pucch_resources = 1; + } else { + harq_information->harq_information_rel9_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG; + harq_information-> + harq_information_rel9_fdd.number_of_pucch_resources = 1; + harq_information->harq_information_rel9_fdd.ack_nack_mode = 0; // 1a/b + harq_information->harq_information_rel9_fdd.harq_size = 2; + harq_information->harq_information_rel9_fdd.n_pucch_1_0 = + cc->radioResourceConfigCommon->pucch_ConfigCommon. + n1PUCCH_AN + cce_idxP; + } + break; + } // get Tmode } -void fill_nfapi_harq_information(module_id_t module_idP, - int CC_idP, - uint16_t rntiP, - uint16_t absSFP, - nfapi_ul_config_harq_information *harq_information, - uint8_t cce_idxP) +uint16_t +fill_nfapi_uci_acknak(module_id_t module_idP, + int CC_idP, + uint16_t rntiP, uint16_t absSFP, uint8_t cce_idxP) { - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - UE_list_t *UE_list = &eNB->UE_list; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; + + int ackNAK_absSF = get_pucch1_absSF(cc, absSFP); + nfapi_ul_config_request_t *ul_req = &eNB->UL_req_tmp[CC_idP][ackNAK_absSF % 10]; + nfapi_ul_config_request_body_t *ul_req_body = &ul_req->ul_config_request_body; + nfapi_ul_config_request_pdu_t *ul_config_pdu = + &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; + + memset((void *) ul_config_pdu, 0, + sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; + ul_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_ul_config_uci_harq_pdu)); + ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this + ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = + rntiP; + + fill_nfapi_harq_information(module_idP, CC_idP, + rntiP, + absSFP, + &ul_config_pdu->uci_harq_pdu. + harq_information, cce_idxP); + LOG_D(MAC, + "Filled in UCI HARQ request for rnti %x SF %d.%d acknakSF %d.%d, cce_idxP %d-> n1_pucch %d\n", + rntiP, absSFP / 10, absSFP % 10, ackNAK_absSF / 10, + ackNAK_absSF % 10, cce_idxP, + ul_config_pdu->uci_harq_pdu. + harq_information.harq_information_rel9_fdd.n_pucch_1_0); + + ul_req_body->number_of_pdus++; + ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req->sfn_sf = (ackNAK_absSF/10) << 4 | ackNAK_absSF%10; + + return (((ackNAK_absSF / 10) << 4) + (ackNAK_absSF % 10)); +} - int UE_id = find_UE_id(module_idP,rntiP); - AssertFatal(UE_id>=0,"UE_id cannot be found, impossible\n"); - AssertFatal(UE_list!=NULL,"UE_list is null\n"); - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated for rnti %x is null CC_idP:%d UE_id:%d UE_list:rnti:%04x\n",rntiP,CC_idP,UE_id,UE_list->UE_template[CC_idP][UE_id].rnti); +void +fill_nfapi_dlsch_config(eNB_MAC_INST * eNB, + nfapi_dl_config_request_body_t * dl_req, + uint16_t length, + uint16_t pdu_index, + uint16_t rnti, + uint8_t resource_allocation_type, + uint8_t + virtual_resource_block_assignment_flag, + uint16_t resource_block_coding, + uint8_t modulation, + uint8_t redundancy_version, + uint8_t transport_blocks, + uint8_t transport_block_to_codeword_swap_flag, + uint8_t transmission_scheme, + uint8_t number_of_layers, + uint8_t number_of_subbands, + // uint8_t codebook_index, + uint8_t ue_category_capacity, + uint8_t pa, + uint8_t delta_power_offset_index, + uint8_t ngap, + uint8_t nprb, + uint8_t transmission_mode, + uint8_t num_bf_prb_per_subband, + uint8_t num_bf_vector) +{ + nfapi_dl_config_request_pdu_t *dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = length; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = pdu_index; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = rnti; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = + resource_allocation_type; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.virtual_resource_block_assignment_flag = + virtual_resource_block_assignment_flag; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = + resource_block_coding; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = modulation; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = + redundancy_version; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = + transport_blocks; + dl_config_pdu->dlsch_pdu. + dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = + transport_block_to_codeword_swap_flag; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = + transmission_scheme; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = + number_of_layers; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = + number_of_subbands; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = codebook_index; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = + ue_category_capacity; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = pa; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = + delta_power_offset_index; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = ngap; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = nprb; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = + transmission_mode; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = + num_bf_prb_per_subband; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = num_bf_vector; + dl_req->number_pdu++; +} - harq_information->harq_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG; - harq_information->harq_information_rel11.num_ant_ports = 1; +uint16_t +fill_nfapi_tx_req(nfapi_tx_request_body_t * tx_req_body, + uint16_t absSF, uint16_t pdu_length, + uint16_t pdu_index, uint8_t * pdu) +{ + nfapi_tx_request_pdu_t *TX_req = + &tx_req_body->tx_pdu_list[tx_req_body->number_of_pdus]; + LOG_D(MAC, "Filling TX_req %d for pdu length %d\n", + tx_req_body->number_of_pdus, pdu_length); + TX_req->pdu_length = pdu_length; + TX_req->pdu_index = pdu_index; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = pdu_length; + TX_req->segments[0].segment_data = pdu; + tx_req_body->tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + tx_req_body->number_of_pdus++; + + return (((absSF / 10) << 4) + (absSF % 10)); +} - switch(get_tmode(module_idP,CC_idP,UE_id)) { - case 1: - case 2: - case 5: - case 6: - case 7: - if (cc->tdd_Config!=NULL) { - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated!=NULL, - "pucch_ConfigDedicated is null for TDD!\n"); - if ((UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode!=NULL)&& - (*UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode==PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) { - harq_information->harq_information_rel10_tdd.harq_size = 2; // 2-bit ACK/NAK - harq_information->harq_information_rel10_tdd.ack_nack_mode = 1; // multiplexing - } - else { - harq_information->harq_information_rel10_tdd.harq_size = 1; // 1-bit ACK/NAK - harq_information->harq_information_rel10_tdd.ack_nack_mode = 0; // bundling - } - harq_information->harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; - harq_information->harq_information_rel10_tdd.n_pucch_1_0 = cc->radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN + cce_idxP; - harq_information->harq_information_rel10_tdd.number_of_pucch_resources = 1; - } else { - harq_information->harq_information_rel9_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG; - harq_information->harq_information_rel9_fdd.number_of_pucch_resources = 1; - harq_information->harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK - harq_information->harq_information_rel9_fdd.n_pucch_1_0 = cc->radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN + cce_idxP; - } - break; - default: // for any other TM we need 2 bits harq - if (cc->tdd_Config!=NULL) { - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated for rnti %x is null\n",rntiP); - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated!=NULL, - "pucch_ConfigDedicated is null for TDD!\n"); - if ((UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode!=NULL)&& - (*UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode==PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) { - harq_information->harq_information_rel10_tdd.ack_nack_mode = 1; // multiplexing - } - else { - harq_information->harq_information_rel10_tdd.ack_nack_mode = 0; // bundling - } - harq_information->harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; - harq_information->harq_information_rel10_tdd.n_pucch_1_0 = cc->radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN + cce_idxP; - harq_information->harq_information_rel10_tdd.number_of_pucch_resources = 1; - } - else { - harq_information->harq_information_rel9_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG; - harq_information->harq_information_rel9_fdd.number_of_pucch_resources = 1; - harq_information->harq_information_rel9_fdd.ack_nack_mode = 0; // 1a/b - harq_information->harq_information_rel9_fdd.harq_size = 2; - harq_information->harq_information_rel9_fdd.n_pucch_1_0 = cc->radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN + cce_idxP; +void +fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t * + ul_config_pdu, uint8_t cqi_req, + COMMON_channels_t * cc, + struct PhysicalConfigDedicated + *physicalConfigDedicated, + uint8_t tmode, uint32_t handle, + uint16_t rnti, + uint8_t resource_block_start, + uint8_t + number_of_resource_blocks, + uint8_t mcs, + uint8_t cyclic_shift_2_for_drms, + uint8_t + frequency_hopping_enabled_flag, + uint8_t frequency_hopping_bits, + uint8_t new_data_indication, + uint8_t redundancy_version, + uint8_t harq_process_number, + uint8_t ul_tx_mode, + uint8_t current_tx_nb, + uint8_t n_srs, uint16_t size) +{ + memset((void *) ul_config_pdu, 0, + sizeof(nfapi_ul_config_request_pdu_t)); + + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; + ul_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu)); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = handle; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = rnti; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = + resource_block_start; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = + number_of_resource_blocks; + if (mcs < 11) + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; + else if (mcs < 21) + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 4; + else + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 6; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = + cyclic_shift_2_for_drms; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8. + frequency_hopping_enabled_flag = frequency_hopping_enabled_flag; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = + frequency_hopping_bits; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = + new_data_indication; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = + redundancy_version; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = + harq_process_number; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = ul_tx_mode; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = current_tx_nb; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = n_srs; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = size; + + if (cqi_req == 1) { + // Add CQI portion + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE; + ul_config_pdu->pdu_size = + (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_cqi_ri_pdu)); + ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG; + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9.report_type = 1; + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9. + aperiodic_cqi_pmi_ri_report.number_of_cc = 1; + LOG_D(MAC, "report_type %d\n", + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9.report_type); + + if (cc->p_eNB <= 2 + && (tmode == 3 || tmode == 4 || tmode == 8 || tmode == 9 + || tmode == 10)) + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9. + aperiodic_cqi_pmi_ri_report.cc[0].ri_size = 1; + else if (cc->p_eNB <= 2) + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9. + aperiodic_cqi_pmi_ri_report.cc[0].ri_size = 0; + else if (cc->p_eNB == 4) + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9. + aperiodic_cqi_pmi_ri_report.cc[0].ri_size = 2; + + AssertFatal(physicalConfigDedicated->cqi_ReportConfig != NULL, + "physicalConfigDedicated->cqi_ReportConfig is null!\n"); + AssertFatal(physicalConfigDedicated-> + cqi_ReportConfig->cqi_ReportModeAperiodic != NULL, + "physicalConfigDedicated->cqi_ReportModeAperiodic is null!\n"); + AssertFatal(physicalConfigDedicated->pusch_ConfigDedicated != NULL, + "physicalConfigDedicated->puschConfigDedicated is null!\n"); + + for (int ri = 0; + ri < + (1 << ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9. + aperiodic_cqi_pmi_ri_report.cc[0].ri_size); ri++) + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9. + aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[ri] = + get_dl_cqi_pmi_size_pusch(cc, tmode, 1 + ri, + physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic); + + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9.delta_offset_cqi = + physicalConfigDedicated->pusch_ConfigDedicated-> + betaOffset_CQI_Index; + ul_config_pdu->ulsch_cqi_ri_pdu. + cqi_ri_information.cqi_ri_information_rel9.delta_offset_ri = + physicalConfigDedicated->pusch_ConfigDedicated-> + betaOffset_RI_Index; } - break; - } // get Tmode -} - -uint16_t fill_nfapi_uci_acknak(module_id_t module_idP, - int CC_idP, - uint16_t rntiP, - uint16_t absSFP, - uint8_t cce_idxP) -{ - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - - int ackNAK_absSF = get_pucch1_absSF(cc,absSFP); - nfapi_ul_config_request_t *ul_req = &eNB->UL_req_tmp[CC_idP][ackNAK_absSF%10]; - nfapi_ul_config_request_body_t *ul_req_body = &ul_req->ul_config_request_body; - nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; - - memset((void*)ul_config_pdu,0,sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; - ul_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_ul_config_uci_harq_pdu)); - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this - ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = rntiP; - - fill_nfapi_harq_information(module_idP,CC_idP, - rntiP, - absSFP, - &ul_config_pdu->uci_harq_pdu.harq_information, - cce_idxP); - LOG_D(MAC,"Filled in UCI HARQ request for rnti %x SF %d.%d acknakSF %d.%d, cce_idxP %d-> n1_pucch %d\n",rntiP, - absSFP/10,absSFP%10,ackNAK_absSF/10,ackNAK_absSF%10,cce_idxP,ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0); - - ul_req_body->number_of_pdus++; - ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - //ul_req->sfn_sf = sfnsf_add_subframe(ackNAK_absSF/10, ackNAK_absSF%10, 4); // Still need to add 4 to ACK/NAK SFN/SF because of NFAPI running off TX frame - ul_req->sfn_sf = (ackNAK_absSF/10) << 4 | ackNAK_absSF%10; - - return(((ackNAK_absSF/10)<<4) + (ackNAK_absSF%10)); -} - -void fill_nfapi_dlsch_config(eNB_MAC_INST *eNB, - nfapi_dl_config_request_body_t *dl_req, - uint16_t length, - uint16_t pdu_index, - uint16_t rnti, - uint8_t resource_allocation_type, - uint8_t virtual_resource_block_assignment_flag, - uint16_t resource_block_coding, - uint8_t modulation, - uint8_t redundancy_version, - uint8_t transport_blocks, - uint8_t transport_block_to_codeword_swap_flag, - uint8_t transmission_scheme, - uint8_t number_of_layers, - uint8_t number_of_subbands, - // uint8_t codebook_index, - uint8_t ue_category_capacity, - uint8_t pa, - uint8_t delta_power_offset_index, - uint8_t ngap, - uint8_t nprb, - uint8_t transmission_mode, - uint8_t num_bf_prb_per_subband, - uint8_t num_bf_vector - ) -{ - nfapi_dl_config_request_pdu_t *dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = length; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = pdu_index; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = rnti; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = resource_allocation_type; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = virtual_resource_block_assignment_flag; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = resource_block_coding; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = modulation; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = redundancy_version; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = transport_blocks; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = transport_block_to_codeword_swap_flag; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = transmission_scheme; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = number_of_layers; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = number_of_subbands; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = codebook_index; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = ue_category_capacity; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = pa; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = delta_power_offset_index; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = ngap; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = nprb; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = transmission_mode; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = num_bf_prb_per_subband; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = num_bf_vector; - dl_req->number_pdu++; - dl_req->tl.tag=NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - //LOG_D(MAC,"Filled DL_CONFIG_PDU - DLSCH - dl_req->number_pdu:%d pdu_index:%d\n", dl_req->number_pdu, pdu_index); -} - -uint16_t fill_nfapi_tx_req(nfapi_tx_request_body_t *tx_req_body,uint16_t absSF,uint16_t pdu_length, uint16_t pdu_index, uint8_t *pdu) -{ - nfapi_tx_request_pdu_t *TX_req = &tx_req_body->tx_pdu_list[tx_req_body->number_of_pdus]; - - TX_req->pdu_length = pdu_length; - TX_req->pdu_index = pdu_index; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = pdu_length; - TX_req->segments[0].segment_data = pdu; - tx_req_body->tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - tx_req_body->number_of_pdus++; - - //LOG_D(MAC,"Filling TX_req SFN/SF:%d/%d PDUs:%d for pdu length %d pdu_index:%d\n",absSF/10,absSF%10,tx_req_body->number_of_pdus,pdu_length,pdu_index); - - return(((absSF/10)<<4) + (absSF%10)); -} - -void fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint8_t cqi_req, - COMMON_channels_t *cc, - struct PhysicalConfigDedicated *physicalConfigDedicated, - uint8_t tmode, - uint32_t handle, - uint16_t rnti, - uint8_t resource_block_start, - uint8_t number_of_resource_blocks, - uint8_t mcs, - uint8_t cyclic_shift_2_for_drms, - uint8_t frequency_hopping_enabled_flag, - uint8_t frequency_hopping_bits, - uint8_t new_data_indication, - uint8_t redundancy_version, - uint8_t harq_process_number, - uint8_t ul_tx_mode, - uint8_t current_tx_nb, - uint8_t n_srs, - uint16_t size - ) -{ - memset((void*)ul_config_pdu,0,sizeof(nfapi_ul_config_request_pdu_t)); - - if (cqi_req == 1) { - - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE; - ul_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_ul_config_ulsch_cqi_ri_pdu)); - - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.handle = handle; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti = rnti; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.resource_block_start = resource_block_start; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = number_of_resource_blocks; - if (mcs<11) ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; - else if (mcs<21) ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.modulation_type = 4; - else ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.modulation_type = 6; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = cyclic_shift_2_for_drms; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = frequency_hopping_enabled_flag; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = frequency_hopping_bits; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.new_data_indication = new_data_indication; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.redundancy_version = redundancy_version; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.harq_process_number = harq_process_number; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = ul_tx_mode; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = current_tx_nb; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.n_srs = n_srs; - ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size = size; - - // Add CQI portion - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG; - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.report_type = 1; - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.number_of_cc = 1; - LOG_D(MAC,"report_type %d\n",ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.report_type); - - if (cc->p_eNB<=2 && (tmode==3||tmode==4||tmode==8||tmode==9||tmode==10)) - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = 1; - else if (cc->p_eNB<=2) - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = 0; - else if (cc->p_eNB==4) - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = 2; - - AssertFatal(physicalConfigDedicated->cqi_ReportConfig!=NULL,"physicalConfigDedicated->cqi_ReportConfig is null!\n"); - AssertFatal(physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic!=NULL,"physicalConfigDedicated->cqi_ReportModeAperiodic is null!\n"); - AssertFatal(physicalConfigDedicated->pusch_ConfigDedicated!=NULL,"physicalConfigDedicated->puschConfigDedicated is null!\n"); - - for (int ri=0; - ri<(1<<ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size); - ri++) - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[ri] = - get_dl_cqi_pmi_size_pusch(cc, - tmode, - 1+ri, - physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic); - - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.delta_offset_cqi = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.delta_offset_ri = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; - - LOG_D(MAC,"%s() ri_size:%d\n",__FUNCTION__, ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size); - } - else - { - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; - ul_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_ul_config_ulsch_pdu)); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = handle; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = rnti; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = resource_block_start; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = number_of_resource_blocks; - if (mcs<11) ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; - else if (mcs<21) ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 4; - else ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 6; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = cyclic_shift_2_for_drms; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = frequency_hopping_enabled_flag; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = frequency_hopping_bits; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = new_data_indication; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = redundancy_version; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = harq_process_number; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = ul_tx_mode; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = current_tx_nb; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = n_srs; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = size; - } } #ifdef Rel14 -void fill_nfapi_ulsch_config_request_emtc(nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint8_t ue_type, - uint16_t total_number_of_repetitions, - uint16_t repetition_number, - uint16_t initial_transmission_sf_io) +void +fill_nfapi_ulsch_config_request_emtc(nfapi_ul_config_request_pdu_t * + ul_config_pdu, uint8_t ue_type, + uint16_t + total_number_of_repetitions, + uint16_t repetition_number, + uint16_t initial_transmission_sf_io) { - // Re13 fields - - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type = ue_type; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = total_number_of_repetitions; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number = repetition_number; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = initial_transmission_sf_io; + // Re13 fields + + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type = ue_type; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = + total_number_of_repetitions; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number = + repetition_number; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = + initial_transmission_sf_io; } int get_numnarrowbands(long dl_Bandwidth) { - int nb_tab[6] = {1,2,4,8,12,16}; + int nb_tab[6] = { 1, 2, 4, 8, 12, 16 }; - AssertFatal(dl_Bandwidth<7 || dl_Bandwidth>=0,"dl_Bandwidth not in [0..6]\n"); - return(nb_tab[dl_Bandwidth]); + AssertFatal(dl_Bandwidth < 7 + || dl_Bandwidth >= 0, "dl_Bandwidth not in [0..6]\n"); + return (nb_tab[dl_Bandwidth]); } int get_numnarrowbandbits(long dl_Bandwidth) { - int nbbits_tab[6] = {0,1,2,3,4,4}; + int nbbits_tab[6] = { 0, 1, 2, 3, 4, 4 }; - AssertFatal(dl_Bandwidth<7 || dl_Bandwidth>=0,"dl_Bandwidth not in [0..6]\n"); - return(nbbits_tab[dl_Bandwidth]); + AssertFatal(dl_Bandwidth < 7 + || dl_Bandwidth >= 0, "dl_Bandwidth not in [0..6]\n"); + return (nbbits_tab[dl_Bandwidth]); } //This implements the frame/subframe condition for first subframe of MPDCCH transmission (Section 9.1.5 36.213, Rel 13/14) -int startSF_fdd_RA_times2[8] = {2,3,4,5,8,10,16,20}; -int startSF_tdd_RA[7] = {1,2,4,5,8,10,20}; +int startSF_fdd_RA_times2[8] = { 2, 3, 4, 5, 8, 10, 16, 20 }; +int startSF_tdd_RA[7] = { 1, 2, 4, 5, 8, 10, 20 }; -int mpdcch_sf_condition(eNB_MAC_INST *eNB,int CC_id, frame_t frameP,sub_frame_t subframeP,int rmax,MPDCCH_TYPES_t mpdcch_type,int UE_id) +int +mpdcch_sf_condition(eNB_MAC_INST * eNB, int CC_id, frame_t frameP, + sub_frame_t subframeP, int rmax, + MPDCCH_TYPES_t mpdcch_type, int UE_id) { - struct PRACH_ConfigSIB_v1310 *ext4_prach = eNB->common_channels[CC_id].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - - int T; - EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11; - - switch (mpdcch_type) { - case TYPE0: - AssertFatal(1==0,"MPDCCH Type 0 not handled yet\n"); - break; - case TYPE1: - AssertFatal(1==0,"MPDCCH Type 1 not handled yet\n"); - break; - case TYPE1A: - AssertFatal(1==0,"MPDCCH Type 1A not handled yet\n"); - break; - case TYPE2: // RAR - AssertFatal(ext4_prach->mpdcch_startSF_CSS_RA_r13!=NULL, - "mpdcch_startSF_CSS_RA_r13 is null\n"); - AssertFatal(rmax>0,"rmax is 0!\b"); - if (eNB->common_channels[CC_id].tdd_Config==NULL) //FDD - T = rmax*startSF_fdd_RA_times2[ext4_prach->mpdcch_startSF_CSS_RA_r13->choice.fdd_r13]>>1; - else //TDD - T = rmax*startSF_tdd_RA[ext4_prach->mpdcch_startSF_CSS_RA_r13->choice.tdd_r13]; - break; - case TYPE2A: - AssertFatal(1==0,"MPDCCH Type 2A not handled yet\n"); - break; - case TYPEUESPEC: - epdcch_setconfig_r11= eNB->UE_list.UE_template[CC_id][UE_id].physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0] ; - - AssertFatal(epdcch_setconfig_r11 != NULL," epdcch_setconfig_r11 is null for UE specific \n"); - AssertFatal(epdcch_setconfig_r11->ext2 != NULL," ext2 doesn't exist in epdcch config ' \n"); - - if (eNB->common_channels[CC_id].tdd_Config==NULL) //FDD - T = rmax*startSF_fdd_RA_times2[epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_StartSF_UESS_r13.choice.fdd_r13]>>1; - else //TDD - T = rmax*startSF_tdd_RA[epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_StartSF_UESS_r13.choice.tdd_r13]; - - break; - default: - return(0); - } + struct PRACH_ConfigSIB_v1310 *ext4_prach = + eNB->common_channels[CC_id].radioResourceConfigCommon_BR-> + ext4->prach_ConfigCommon_v1310; + + int T; + EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11; + + switch (mpdcch_type) { + case TYPE0: + AssertFatal(1 == 0, "MPDCCH Type 0 not handled yet\n"); + break; + case TYPE1: + AssertFatal(1 == 0, "MPDCCH Type 1 not handled yet\n"); + break; + case TYPE1A: + AssertFatal(1 == 0, "MPDCCH Type 1A not handled yet\n"); + break; + case TYPE2: // RAR + AssertFatal(ext4_prach->mpdcch_startSF_CSS_RA_r13 != NULL, + "mpdcch_startSF_CSS_RA_r13 is null\n"); + AssertFatal(rmax > 0, "rmax is 0!\b"); + if (eNB->common_channels[CC_id].tdd_Config == NULL) //FDD + T = rmax * + startSF_fdd_RA_times2[ext4_prach-> + mpdcch_startSF_CSS_RA_r13-> + choice.fdd_r13] >> 1; + else //TDD + T = rmax * + startSF_tdd_RA[ext4_prach-> + mpdcch_startSF_CSS_RA_r13->choice.tdd_r13]; + break; + case TYPE2A: + AssertFatal(1 == 0, "MPDCCH Type 2A not handled yet\n"); + break; + case TYPEUESPEC: + epdcch_setconfig_r11 = + eNB->UE_list.UE_template[CC_id][UE_id]. + physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11. + choice.setup.setConfigToAddModList_r11->list.array[0]; + + AssertFatal(epdcch_setconfig_r11 != NULL, + " epdcch_setconfig_r11 is null for UE specific \n"); + AssertFatal(epdcch_setconfig_r11->ext2 != NULL, + " ext2 doesn't exist in epdcch config ' \n"); + + if (eNB->common_channels[CC_id].tdd_Config == NULL) //FDD + T = rmax * + startSF_fdd_RA_times2[epdcch_setconfig_r11-> + ext2->mpdcch_config_r13->choice. + setup.mpdcch_StartSF_UESS_r13.choice. + fdd_r13] >> 1; + else //TDD + T = rmax * + startSF_tdd_RA[epdcch_setconfig_r11-> + ext2->mpdcch_config_r13->choice. + setup.mpdcch_StartSF_UESS_r13.choice. + tdd_r13]; + + break; + default: + return (0); + } - AssertFatal(T>0,"T is 0!\n"); - if (((10*frameP) + subframeP)%T == 0) return(1); - else return(0); + AssertFatal(T > 0, "T is 0!\n"); + if (((10 * frameP) + subframeP) % T == 0) + return (1); + else + return (0); } -int narrowband_to_first_rb(COMMON_channels_t *cc, int nb_index) +int narrowband_to_first_rb(COMMON_channels_t * cc, int nb_index) { - switch (cc->mib->message.dl_Bandwidth) { - case 0: // 6 PRBs, N_NB=1, i_0=0 - return(0); - break; - case 3: // 50 PRBs, N_NB=8, i_0=1 - return((int)(1+(6*nb_index))); - break; - case 5: // 100 PRBs, N_NB=16, i_0=2 - return((int)(2+(6*nb_index))); - break; - case 1: // 15 PRBs N_NB=2, i_0=1 - if (nb_index>0) return(1); - else return(0); - break; - case 2: // 25 PRBs, N_NB=4, i_0=0 - if (nb_index>1) return(1+(6*nb_index)); - else return((6*nb_index)); - break; - case 4: // 75 PRBs, N_NB=12, i_0=1 - if (nb_index>5) return(2+(6*nb_index)); - else return(1+(6*nb_index)); - break; - default: - AssertFatal(1==0,"Impossible dl_Bandwidth %d\n",(int)cc->mib->message.dl_Bandwidth); - break; - } + switch (cc->mib->message.dl_Bandwidth) { + case 0: // 6 PRBs, N_NB=1, i_0=0 + return (0); + break; + case 3: // 50 PRBs, N_NB=8, i_0=1 + return ((int) (1 + (6 * nb_index))); + break; + case 5: // 100 PRBs, N_NB=16, i_0=2 + return ((int) (2 + (6 * nb_index))); + break; + case 1: // 15 PRBs N_NB=2, i_0=1 + if (nb_index > 0) + return (1); + else + return (0); + break; + case 2: // 25 PRBs, N_NB=4, i_0=0 + if (nb_index > 1) + return (1 + (6 * nb_index)); + else + return ((6 * nb_index)); + break; + case 4: // 75 PRBs, N_NB=12, i_0=1 + if (nb_index > 5) + return (2 + (6 * nb_index)); + else + return (1 + (6 * nb_index)); + break; + default: + AssertFatal(1 == 0, "Impossible dl_Bandwidth %d\n", + (int) cc->mib->message.dl_Bandwidth); + break; + } } #endif @@ -1561,23 +1870,23 @@ int narrowband_to_first_rb(COMMON_channels_t *cc, int nb_index) void init_ue_sched_info(void) //------------------------------------------------------------------------------ { - module_id_t i,j,k; - - for (i=0; i<NUMBER_OF_eNB_MAX; i++) { - for (k=0; k<MAX_NUM_CCs; k++) { - for (j=0; j<NUMBER_OF_UE_MAX; j++) { - // init DL - eNB_dlsch_info[i][k][j].weight = 0; - eNB_dlsch_info[i][k][j].subframe = 0; - eNB_dlsch_info[i][k][j].serving_num = 0; - eNB_dlsch_info[i][k][j].status = S_DL_NONE; - // init UL - eNB_ulsch_info[i][k][j].subframe = 0; - eNB_ulsch_info[i][k][j].serving_num = 0; - eNB_ulsch_info[i][k][j].status = S_UL_NONE; - } + module_id_t i, j, k; + + for (i = 0; i < NUMBER_OF_eNB_MAX; i++) { + for (k = 0; k < MAX_NUM_CCs; k++) { + for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + // init DL + eNB_dlsch_info[i][k][j].weight = 0; + eNB_dlsch_info[i][k][j].subframe = 0; + eNB_dlsch_info[i][k][j].serving_num = 0; + eNB_dlsch_info[i][k][j].status = S_DL_NONE; + // init UL + eNB_ulsch_info[i][k][j].subframe = 0; + eNB_ulsch_info[i][k][j].serving_num = 0; + eNB_ulsch_info[i][k][j].status = S_UL_NONE; + } + } } - } } @@ -1586,83 +1895,86 @@ void init_ue_sched_info(void) unsigned char get_ue_weight(module_id_t module_idP, int CC_idP, int ue_idP) //------------------------------------------------------------------------------ { - return(eNB_dlsch_info[module_idP][CC_idP][ue_idP].weight); + return (eNB_dlsch_info[module_idP][CC_idP][ue_idP].weight); } //------------------------------------------------------------------------------ int find_UE_id(module_id_t mod_idP, rnti_t rntiP) //------------------------------------------------------------------------------ { - int UE_id; - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - //LOG_D(PHY,"%s(mod_idP:%d, rntiP:%04x) UE_id:%d active:%d UE_PCCID(mod_idP,UE_id):%d UE_list->UE_template[UE_PCCID(mod_idP,UE_id)][UE_id].rnti:%04x\n", - //__FUNCTION__, mod_idP, rntiP, UE_id, UE_list->active[UE_id], UE_PCCID(mod_idP,UE_id), UE_list->UE_template[UE_PCCID(mod_idP,UE_id)][UE_id].rnti); + int UE_id; + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - if (UE_list->active[UE_id] != TRUE) continue; - if (UE_list->UE_template[UE_PCCID(mod_idP,UE_id)][UE_id].rnti==rntiP) { - return(UE_id); + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) + continue; + if (UE_list->UE_template[UE_PCCID(mod_idP, UE_id)][UE_id].rnti == + rntiP) { + return (UE_id); + } } - } - return(-1); + return (-1); } //------------------------------------------------------------------------------ int find_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP) //------------------------------------------------------------------------------ { - int RA_id; - AssertFatal(RC.mac[mod_idP],"RC.mac[%d] is null\n",mod_idP); + int RA_id; + AssertFatal(RC.mac[mod_idP], "RC.mac[%d] is null\n", mod_idP); - RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&RC.mac[mod_idP]->common_channels[CC_idP].RA_template[0]; + RA_t *ra = (RA_t *) & RC.mac[mod_idP]->common_channels[CC_idP].ra[0]; - for (RA_id = 0; RA_id < NB_RA_PROC_MAX; RA_id++) { - //LOG_D(MAC,"Checking RA_id %d for %x : RA_active %d, wait_ack_Msg4 %d\n", RA_id,rntiP, RA_template[RA_id].RA_active, RA_template[RA_id].wait_ack_Msg4); + for (RA_id = 0; RA_id < NB_RA_PROC_MAX; RA_id++) { + LOG_D(MAC, + "Checking RA_id %d for %x : state %d\n", + RA_id, rntiP, ra[RA_id].state); - if (RA_template[RA_id].RA_active==TRUE && - RA_template[RA_id].wait_ack_Msg4 == 0 && - RA_template[RA_id].rnti == rntiP) return(RA_id); - } - return(-1); + if (ra[RA_id].state != IDLE && + ra[RA_id].rnti == rntiP) + return (RA_id); + } + return (-1); } //------------------------------------------------------------------------------ -int UE_num_active_CC(UE_list_t *listP,int ue_idP) +int UE_num_active_CC(UE_list_t * listP, int ue_idP) //------------------------------------------------------------------------------ { - return(listP->numactiveCCs[ue_idP]); + return (listP->numactiveCCs[ue_idP]); } //------------------------------------------------------------------------------ -int UE_PCCID(module_id_t mod_idP,int ue_idP) +int UE_PCCID(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { - return(RC.mac[mod_idP]->UE_list.pCC_id[ue_idP]); + return (RC.mac[mod_idP]->UE_list.pCC_id[ue_idP]); } //------------------------------------------------------------------------------ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { - rnti_t rnti = RC.mac[mod_idP]->UE_list.UE_template[UE_PCCID(mod_idP,ue_idP)][ue_idP].rnti; + rnti_t rnti = + RC.mac[mod_idP]-> + UE_list.UE_template[UE_PCCID(mod_idP, ue_idP)][ue_idP].rnti; - if (rnti>0) { - return (rnti); - } + if (rnti > 0) { + return (rnti); + } - LOG_D(MAC,"[eNB %d] Couldn't find RNTI for UE %d\n",mod_idP,ue_idP); - //display_backtrace(); - return(NOT_A_RNTI); + LOG_D(MAC, "[eNB %d] Couldn't find RNTI for UE %d\n", mod_idP, ue_idP); + //display_backtrace(); + return (NOT_A_RNTI); } //------------------------------------------------------------------------------ boolean_t is_UE_active(module_id_t mod_idP, int ue_idP) //------------------------------------------------------------------------------ { - return(RC.mac[mod_idP]->UE_list.active[ue_idP]); + return (RC.mac[mod_idP]->UE_list.active[ue_idP]); } /* @@ -1690,316 +2002,358 @@ uint8_t find_active_UEs(module_id_t module_idP,int CC_id){ // get aggregation (L) form phy for a give UE -unsigned char get_aggregation (uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt) +unsigned char +get_aggregation(uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt) { - unsigned char aggregation=3; - - switch (dci_fmt){ - case format0: - aggregation = cqi2fmt0_agg[bw_index][cqi]; - break; - case format1: - case format1A: - case format1B: - case format1D: - aggregation = cqi2fmt1x_agg[bw_index][cqi]; - break; - case format2: - case format2A: - case format2B: - case format2C: - case format2D: - aggregation = cqi2fmt2x_agg[bw_index][cqi]; - break; - case format1C: - case format1E_2A_M10PRB: - case format3: - case format3A: - case format4: - default: - LOG_W(MAC,"unsupported DCI format %d\n",dci_fmt); - } + unsigned char aggregation = 3; + + switch (dci_fmt) { + case format0: + aggregation = cqi2fmt0_agg[bw_index][cqi]; + break; + case format1: + case format1A: + case format1B: + case format1D: + aggregation = cqi2fmt1x_agg[bw_index][cqi]; + break; + case format2: + case format2A: + case format2B: + case format2C: + case format2D: + aggregation = cqi2fmt2x_agg[bw_index][cqi]; + break; + case format1C: + case format1E_2A_M10PRB: + case format3: + case format3A: + case format4: + default: + LOG_W(MAC, "unsupported DCI format %d\n", dci_fmt); + } + - //LOG_D(MAC,"Aggregation level %d (cqi %d, bw_index %d, format %d)\n", 1<<aggregation, cqi,bw_index,dci_fmt); + LOG_D(MAC, "Aggregation level %d (cqi %d, bw_index %d, format %d)\n", 1 << aggregation, cqi, bw_index, dci_fmt); - return 1<<aggregation; + return 1 << aggregation; } -void dump_ue_list(UE_list_t *listP, int ul_flag) +void dump_ue_list(UE_list_t * listP, int ul_flag) { - int j; + int j; - if ( ul_flag == 0 ) { - for (j=listP->head; j>=0; j=listP->next[j]) { - LOG_T(MAC,"node %d => %d\n",j,listP->next[j]); - } - } else { - for (j=listP->head_ul; j>=0; j=listP->next_ul[j]) { - LOG_T(MAC,"node %d => %d\n",j,listP->next_ul[j]); + if (ul_flag == 0) { + for (j = listP->head; j >= 0; j = listP->next[j]) { + LOG_T(MAC, "node %d => %d\n", j, listP->next[j]); + } + } else { + for (j = listP->head_ul; j >= 0; j = listP->next_ul[j]) { + LOG_T(MAC, "node %d => %d\n", j, listP->next_ul[j]); + } } - } } -int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP - #ifdef Rel14 - ,uint8_t rach_resource_type - #endif - ) +int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP, int harq_pidP +#ifdef Rel14 + , uint8_t rach_resource_type +#endif + ) { - int UE_id; - int i, j; - - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - - LOG_D(MAC,"[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",mod_idP,cc_idP,rntiP,UE_list->avail,UE_list->num_UEs); - dump_ue_list(UE_list,0); - - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] == TRUE) continue; - UE_id = i; - memset(&UE_list->UE_template[cc_idP][UE_id], 0, sizeof(UE_TEMPLATE)); - UE_list->UE_template[cc_idP][UE_id].rnti = rntiP; - UE_list->UE_template[cc_idP][UE_id].configured = FALSE; - UE_list->numactiveCCs[UE_id] = 1; - UE_list->numactiveULCCs[UE_id] = 1; - UE_list->pCC_id[UE_id] = cc_idP; - UE_list->ordered_CCids[0][UE_id] = cc_idP; - UE_list->ordered_ULCCids[0][UE_id] = cc_idP; - UE_list->num_UEs++; - UE_list->active[UE_id] = TRUE; + int UE_id; + int i, j; + + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + + LOG_D(MAC, + "[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n", + mod_idP, cc_idP, rntiP, UE_list->avail, UE_list->num_UEs); + dump_ue_list(UE_list, 0); + + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] == TRUE) + continue; + UE_id = i; + memset(&UE_list->UE_template[cc_idP][UE_id], 0, + sizeof(UE_TEMPLATE)); + UE_list->UE_template[cc_idP][UE_id].rnti = rntiP; + UE_list->UE_template[cc_idP][UE_id].configured = FALSE; + UE_list->numactiveCCs[UE_id] = 1; + UE_list->numactiveULCCs[UE_id] = 1; + UE_list->pCC_id[UE_id] = cc_idP; + UE_list->ordered_CCids[0][UE_id] = cc_idP; + UE_list->ordered_ULCCids[0][UE_id] = cc_idP; + UE_list->num_UEs++; + UE_list->active[UE_id] = TRUE; +#if defined(USRP_REC_PLAY) // not specific to record/playback ? + UE_list->UE_template[cc_idP][UE_id].pre_assigned_mcs_ul = 0; +#endif #ifdef Rel14 - UE_list->UE_template[cc_idP][UE_id].rach_resource_type = rach_resource_type ; + UE_list->UE_template[cc_idP][UE_id].rach_resource_type = + rach_resource_type; #endif - memset((void*)&UE_list->UE_sched_ctrl[UE_id],0,sizeof(UE_sched_ctrl)); - memset((void*)&UE_list->eNB_UE_stats[cc_idP][UE_id],0,sizeof(eNB_UE_STATS)); - - UE_list->UE_sched_ctrl[UE_id].ta_update = 31; - - for (j=0; j<8; j++) { - UE_list->UE_template[cc_idP][UE_id].oldNDI[j] = (j==0)?1:0; // 1 because first transmission is with format1A (Msg4) for harq_pid 0 - UE_list->UE_template[cc_idP][UE_id].oldNDI_UL[j] = (j==harq_pidP)?0:1; // 1st transmission is with Msg3; - UE_list->UE_sched_ctrl[UE_id].round[cc_idP][j] = 8; - UE_list->UE_sched_ctrl[UE_id].round_UL[cc_idP][j] = 0; + memset((void *) &UE_list->UE_sched_ctrl[UE_id], 0, + sizeof(UE_sched_ctrl)); + memset((void *) &UE_list->eNB_UE_stats[cc_idP][UE_id], 0, + sizeof(eNB_UE_STATS)); + UE_list->UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0; + + UE_list->UE_sched_ctrl[UE_id].ta_update = 31; + + for (j = 0; j < 8; j++) { + UE_list->UE_template[cc_idP][UE_id].oldNDI[j] = (j == 0) ? 1 : 0; // 1 because first transmission is with format1A (Msg4) for harq_pid 0 + UE_list->UE_template[cc_idP][UE_id].oldNDI_UL[j] = (j == harq_pidP) ? 0 : 1; // 1st transmission is with Msg3; + UE_list->UE_sched_ctrl[UE_id].round[cc_idP][j] = 8; + UE_list->UE_sched_ctrl[UE_id].round_UL[cc_idP][j] = 0; + } + + eNB_ulsch_info[mod_idP][cc_idP][UE_id].status = S_UL_WAITING; + eNB_dlsch_info[mod_idP][cc_idP][UE_id].status = S_DL_WAITING; + LOG_D(MAC, "[eNB %d] Add UE_id %d on Primary CC_id %d: rnti %x\n", + mod_idP, UE_id, cc_idP, rntiP); + dump_ue_list(UE_list, 0); + return (UE_id); } - eNB_ulsch_info[mod_idP][cc_idP][UE_id].status = S_UL_WAITING; - eNB_dlsch_info[mod_idP][cc_idP][UE_id].status = S_DL_WAITING; - LOG_D(MAC,"[eNB %d] Add UE_id %d on Primary CC_id %d: rnti %x\n",mod_idP,UE_id,cc_idP,rntiP); - dump_ue_list(UE_list,0); - return(UE_id); - } - - printf("MAC: cannot add new UE for rnti %x\n", rntiP); - LOG_E(MAC,"error in add_new_ue(), could not find space in UE_list, Dumping UE list\n"); - dump_ue_list(UE_list,0); - return(-1); + printf("MAC: cannot add new UE for rnti %x\n", rntiP); + LOG_E(MAC, + "error in add_new_ue(), could not find space in UE_list, Dumping UE list\n"); + dump_ue_list(UE_list, 0); + return (-1); } //------------------------------------------------------------------------------ -int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) +int rrc_mac_remove_ue(module_id_t mod_idP, rnti_t rntiP) //------------------------------------------------------------------------------ { - int i; - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - int UE_id = find_UE_id(mod_idP,rntiP); - int pCC_id; - - if (UE_id == -1) { - LOG_W(MAC,"rrc_mac_remove_ue: UE %x not found\n", rntiP); - return 0; - } - - pCC_id = UE_PCCID(mod_idP,UE_id); - - LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP); - dump_ue_list(UE_list,0); - - UE_list->active[UE_id] = FALSE; - UE_list->num_UEs--; - - if (UE_list->head == UE_id) UE_list->head=UE_list->next[UE_id]; - else UE_list->next[prev(UE_list,UE_id,0)]=UE_list->next[UE_id]; - if (UE_list->head_ul == UE_id) UE_list->head_ul=UE_list->next_ul[UE_id]; - else UE_list->next_ul[prev(UE_list,UE_id,0)]=UE_list->next_ul[UE_id]; - - // clear all remaining pending transmissions - UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0] = 0; - UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID1] = 0; - UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID2] = 0; - UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID3] = 0; - - UE_list->UE_template[pCC_id][UE_id].ul_SR = 0; - UE_list->UE_template[pCC_id][UE_id].rnti = NOT_A_RNTI; - UE_list->UE_template[pCC_id][UE_id].ul_active = FALSE; - eNB_ulsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI; - eNB_ulsch_info[mod_idP][pCC_id][UE_id].status = S_UL_NONE; - eNB_dlsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI; - eNB_dlsch_info[mod_idP][pCC_id][UE_id].status = S_DL_NONE; - - // check if this has an RA process active - RA_TEMPLATE *RA_template; - for (i=0;i<NB_RA_PROC_MAX;i++) { - RA_template = (RA_TEMPLATE *)&RC.mac[mod_idP]->common_channels[pCC_id].RA_template[i]; - if (RA_template->rnti == rntiP){ - RA_template->RA_active=FALSE; - RA_template->generate_rar=0; - RA_template->generate_Msg4=0; - RA_template->wait_ack_Msg4=0; - RA_template->timing_offset=0; - RA_template->RRC_timer=20; - RA_template->rnti = 0; - //break; + int i; + int j; + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + int UE_id = find_UE_id(mod_idP,rntiP); + int pCC_id; + + if (UE_id == -1) { + LOG_W(MAC,"rrc_mac_remove_ue: UE %x not found\n", rntiP); + return 0; } - } - return 0; -} + pCC_id = UE_PCCID(mod_idP,UE_id); -int prev(UE_list_t *listP, int nodeP, int ul_flag) -{ - int j; - - if (ul_flag == 0 ) { - if (nodeP==listP->head) { - return(nodeP); - } + LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP); + dump_ue_list(UE_list,0); - for (j=listP->head; j>=0; j=listP->next[j]) { - if (listP->next[j]==nodeP) { - return(j); + UE_list->active[UE_id] = FALSE; + UE_list->num_UEs--; + + if (UE_list->head == UE_id) UE_list->head=UE_list->next[UE_id]; + else UE_list->next[prev(UE_list,UE_id,0)]=UE_list->next[UE_id]; + if (UE_list->head_ul == UE_id) UE_list->head_ul=UE_list->next_ul[UE_id]; + else UE_list->next_ul[prev(UE_list,UE_id,0)]=UE_list->next_ul[UE_id]; + + // clear all remaining pending transmissions + /* UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0] = 0; + UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID1] = 0; + UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID2] = 0; + UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID3] = 0; + + UE_list->UE_template[pCC_id][UE_id].ul_SR = 0; + UE_list->UE_template[pCC_id][UE_id].rnti = NOT_A_RNTI; + UE_list->UE_template[pCC_id][UE_id].ul_active = FALSE; + */ + memset (&UE_list->UE_template[pCC_id][UE_id],0,sizeof(UE_TEMPLATE)); + + UE_list->eNB_UE_stats[pCC_id][UE_id].total_rbs_used = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_rbs_used_retx = 0; + for ( j = 0; j < NB_RB_MAX; j++ ) { + UE_list->eNB_UE_stats[pCC_id][UE_id].num_pdu_tx[j] = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].num_bytes_tx[j] = 0; } + UE_list->eNB_UE_stats[pCC_id][UE_id].num_retransmission = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_sdu_bytes = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_pdu_bytes = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_num_pdus = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_rbs_used_rx = 0; + for ( j = 0; j < NB_RB_MAX; j++ ) { + UE_list->eNB_UE_stats[pCC_id][UE_id].num_pdu_rx[j] = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].num_bytes_rx[j] = 0; } - } else { - if (nodeP==listP->head_ul) { - return(nodeP); - } - - for (j=listP->head_ul; j>=0; j=listP->next_ul[j]) { - if (listP->next_ul[j]==nodeP) { - return(j); - } + UE_list->eNB_UE_stats[pCC_id][UE_id].num_errors_rx = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_pdu_bytes_rx = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_num_pdus_rx = 0; + UE_list->eNB_UE_stats[pCC_id][UE_id].total_num_errors_rx = 0; + + eNB_ulsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI; + eNB_ulsch_info[mod_idP][pCC_id][UE_id].status = S_UL_NONE; + eNB_dlsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI; + eNB_dlsch_info[mod_idP][pCC_id][UE_id].status = S_DL_NONE; + + eNB_ulsch_info[mod_idP][pCC_id][UE_id].serving_num = 0; + eNB_dlsch_info[mod_idP][pCC_id][UE_id].serving_num = 0; + + // check if this has an RA process active + RA_t *ra; + for (i = 0; i < NB_RA_PROC_MAX; i++) { + ra = (RA_t *) & RC.mac[mod_idP]->common_channels[pCC_id].ra[i]; + if (ra->rnti == rntiP) { + ra->state = IDLE; + ra->timing_offset = 0; + ra->RRC_timer = 20; + ra->rnti = 0; + //break; + } } - } - - LOG_E(MAC,"error in prev(), could not find previous to %d in UE_list %s, should never happen, Dumping UE list\n", - nodeP, (ul_flag == 0)? "DL" : "UL"); - dump_ue_list(listP, ul_flag); - return(-1); + return 0; } -void swap_UEs(UE_list_t *listP,int nodeiP, int nodejP, int ul_flag) +int prev(UE_list_t * listP, int nodeP, int ul_flag) { - int prev_i,prev_j,next_i,next_j; - - LOG_T(MAC,"Swapping UE %d,%d\n",nodeiP,nodejP); - dump_ue_list(listP,ul_flag); - - prev_i = prev(listP,nodeiP,ul_flag); - prev_j = prev(listP,nodejP,ul_flag); + int j; + + if (ul_flag == 0) { + if (nodeP == listP->head) { + return (nodeP); + } + + for (j = listP->head; j >= 0; j = listP->next[j]) { + if (listP->next[j] == nodeP) { + return (j); + } + } + } else { + if (nodeP == listP->head_ul) { + return (nodeP); + } + + for (j = listP->head_ul; j >= 0; j = listP->next_ul[j]) { + if (listP->next_ul[j] == nodeP) { + return (j); + } + } + } - AssertFatal((prev_i>=0) && (prev_j>=0), - "swap_UEs: problem"); + LOG_E(MAC, + "error in prev(), could not find previous to %d in UE_list %s, should never happen, Dumping UE list\n", + nodeP, (ul_flag == 0) ? "DL" : "UL"); + dump_ue_list(listP, ul_flag); - if (ul_flag == 0) { - next_i = listP->next[nodeiP]; - next_j = listP->next[nodejP]; - } else { - next_i = listP->next_ul[nodeiP]; - next_j = listP->next_ul[nodejP]; - } + return (-1); +} - LOG_T(MAC,"[%s] next_i %d, next_i, next_j %d, head %d \n", - (ul_flag == 0)? "DL" : "UL", - next_i,next_j,listP->head); +void swap_UEs(UE_list_t * listP, int nodeiP, int nodejP, int ul_flag) +{ + int prev_i, prev_j, next_i, next_j; - if (ul_flag == 0 ) { + LOG_T(MAC, "Swapping UE %d,%d\n", nodeiP, nodejP); + dump_ue_list(listP, ul_flag); - if (next_i == nodejP) { // case ... p(i) i j n(j) ... => ... p(j) j i n(i) ... - LOG_T(MAC,"Case ... p(i) i j n(j) ... => ... p(j) j i n(i) ...\n"); + prev_i = prev(listP, nodeiP, ul_flag); + prev_j = prev(listP, nodejP, ul_flag); - listP->next[nodeiP] = next_j; - listP->next[nodejP] = nodeiP; + AssertFatal((prev_i >= 0) && (prev_j >= 0), "swap_UEs: problem"); - if (nodeiP==listP->head) { // case i j n(j) - listP->head = nodejP; - } else { - listP->next[prev_i] = nodejP; - } - } else if (next_j == nodeiP) { // case ... p(j) j i n(i) ... => ... p(i) i j n(j) ... - LOG_T(MAC,"Case ... p(j) j i n(i) ... => ... p(i) i j n(j) ...\n"); - listP->next[nodejP] = next_i; - listP->next[nodeiP] = nodejP; - - if (nodejP==listP->head) { // case j i n(i) - listP->head = nodeiP; - } else { - listP->next[prev_j] = nodeiP; - } - } else { // case ... p(i) i n(i) ... p(j) j n(j) ... - listP->next[nodejP] = next_i; - listP->next[nodeiP] = next_j; - - if (nodeiP==listP->head) { - LOG_T(MAC,"changing head to %d\n",nodejP); - listP->head=nodejP; - listP->next[prev_j] = nodeiP; - } else if (nodejP==listP->head) { - LOG_D(MAC,"changing head to %d\n",nodeiP); - listP->head=nodeiP; - listP->next[prev_i] = nodejP; - } else { - listP->next[prev_i] = nodejP; - listP->next[prev_j] = nodeiP; - } + if (ul_flag == 0) { + next_i = listP->next[nodeiP]; + next_j = listP->next[nodejP]; + } else { + next_i = listP->next_ul[nodeiP]; + next_j = listP->next_ul[nodejP]; } - } else { // ul_flag - - if (next_i == nodejP) { // case ... p(i) i j n(j) ... => ... p(j) j i n(i) ... - LOG_T(MAC,"[UL] Case ... p(i) i j n(j) ... => ... p(j) j i n(i) ...\n"); - - listP->next_ul[nodeiP] = next_j; - listP->next_ul[nodejP] = nodeiP; - if (nodeiP==listP->head_ul) { // case i j n(j) - listP->head_ul = nodejP; - } else { - listP->next_ul[prev_i] = nodejP; - } - } else if (next_j == nodeiP) { // case ... p(j) j i n(i) ... => ... p(i) i j n(j) ... - LOG_T(MAC,"[UL]Case ... p(j) j i n(i) ... => ... p(i) i j n(j) ...\n"); - listP->next_ul[nodejP] = next_i; - listP->next_ul[nodeiP] = nodejP; - - if (nodejP==listP->head_ul) { // case j i n(i) - listP->head_ul = nodeiP; - } else { - listP->next_ul[prev_j] = nodeiP; - } - } else { // case ... p(i) i n(i) ... p(j) j n(j) ... - - listP->next_ul[nodejP] = next_i; - listP->next_ul[nodeiP] = next_j; - - if (nodeiP==listP->head_ul) { - LOG_T(MAC,"[UL]changing head to %d\n",nodejP); - listP->head_ul=nodejP; - listP->next_ul[prev_j] = nodeiP; - } else if (nodejP==listP->head_ul) { - LOG_T(MAC,"[UL]changing head to %d\n",nodeiP); - listP->head_ul=nodeiP; - listP->next_ul[prev_i] = nodejP; - } else { - listP->next_ul[prev_i] = nodejP; - listP->next_ul[prev_j] = nodeiP; - } + LOG_T(MAC, "[%s] next_i %d, next_i, next_j %d, head %d \n", + (ul_flag == 0) ? "DL" : "UL", next_i, next_j, listP->head); + + if (ul_flag == 0) { + + if (next_i == nodejP) { // case ... p(i) i j n(j) ... => ... p(j) j i n(i) ... + LOG_T(MAC, + "Case ... p(i) i j n(j) ... => ... p(j) j i n(i) ...\n"); + + listP->next[nodeiP] = next_j; + listP->next[nodejP] = nodeiP; + + if (nodeiP == listP->head) { // case i j n(j) + listP->head = nodejP; + } else { + listP->next[prev_i] = nodejP; + } + } else if (next_j == nodeiP) { // case ... p(j) j i n(i) ... => ... p(i) i j n(j) ... + LOG_T(MAC, + "Case ... p(j) j i n(i) ... => ... p(i) i j n(j) ...\n"); + listP->next[nodejP] = next_i; + listP->next[nodeiP] = nodejP; + + if (nodejP == listP->head) { // case j i n(i) + listP->head = nodeiP; + } else { + listP->next[prev_j] = nodeiP; + } + } else { // case ... p(i) i n(i) ... p(j) j n(j) ... + listP->next[nodejP] = next_i; + listP->next[nodeiP] = next_j; + + if (nodeiP == listP->head) { + LOG_T(MAC, "changing head to %d\n", nodejP); + listP->head = nodejP; + listP->next[prev_j] = nodeiP; + } else if (nodejP == listP->head) { + LOG_D(MAC, "changing head to %d\n", nodeiP); + listP->head = nodeiP; + listP->next[prev_i] = nodejP; + } else { + listP->next[prev_i] = nodejP; + listP->next[prev_j] = nodeiP; + } + } + } else { // ul_flag + + if (next_i == nodejP) { // case ... p(i) i j n(j) ... => ... p(j) j i n(i) ... + LOG_T(MAC, + "[UL] Case ... p(i) i j n(j) ... => ... p(j) j i n(i) ...\n"); + + listP->next_ul[nodeiP] = next_j; + listP->next_ul[nodejP] = nodeiP; + + if (nodeiP == listP->head_ul) { // case i j n(j) + listP->head_ul = nodejP; + } else { + listP->next_ul[prev_i] = nodejP; + } + } else if (next_j == nodeiP) { // case ... p(j) j i n(i) ... => ... p(i) i j n(j) ... + LOG_T(MAC, + "[UL]Case ... p(j) j i n(i) ... => ... p(i) i j n(j) ...\n"); + listP->next_ul[nodejP] = next_i; + listP->next_ul[nodeiP] = nodejP; + + if (nodejP == listP->head_ul) { // case j i n(i) + listP->head_ul = nodeiP; + } else { + listP->next_ul[prev_j] = nodeiP; + } + } else { // case ... p(i) i n(i) ... p(j) j n(j) ... + + listP->next_ul[nodejP] = next_i; + listP->next_ul[nodeiP] = next_j; + + if (nodeiP == listP->head_ul) { + LOG_T(MAC, "[UL]changing head to %d\n", nodejP); + listP->head_ul = nodejP; + listP->next_ul[prev_j] = nodeiP; + } else if (nodejP == listP->head_ul) { + LOG_T(MAC, "[UL]changing head to %d\n", nodeiP); + listP->head_ul = nodeiP; + listP->next_ul[prev_i] = nodejP; + } else { + listP->next_ul[prev_i] = nodejP; + listP->next_ul[prev_j] = nodeiP; + } + } } - } - LOG_T(MAC,"After swap\n"); - dump_ue_list(listP,ul_flag); + LOG_T(MAC, "After swap\n"); + dump_ue_list(listP, ul_flag); } /* @@ -2116,819 +2470,960 @@ void swap_UEs(UE_list_t *listP,int nodeiP, int nodejP, int ul_flag) */ // This has to be updated to include BSR information -uint8_t UE_is_to_be_scheduled(module_id_t module_idP,int CC_id,uint8_t UE_id) +uint8_t +UE_is_to_be_scheduled(module_id_t module_idP, int CC_id, uint8_t UE_id) { - UE_TEMPLATE *UE_template = &RC.mac[module_idP]->UE_list.UE_template[CC_id][UE_id]; - UE_sched_ctrl *UE_sched_ctl = &RC.mac[module_idP]->UE_list.UE_sched_ctrl[UE_id]; - - // do not schedule UE if UL is not working - if (UE_sched_ctl->ul_failure_timer>0) - return(0); - if (UE_sched_ctl->ul_out_of_sync>0) - return(0); - //LOG_D(MAC,"[eNB %d][PUSCH] Checking UL requirements UE %d/%x bsr_info:%d:%d:%d:%d ul_SR:%d ul_inactivity_timer:%d ul_scheduled:%d rrc_status:%d\n",module_idP,UE_id,UE_RNTI(module_idP,UE_id),UE_template->bsr_info[LCGID0], UE_template->bsr_info[LCGID1],UE_template->bsr_info[LCGID2],UE_template->bsr_info[LCGID3],UE_template->ul_SR, UE_sched_ctl->ul_inactivity_timer, UE_sched_ctl->ul_scheduled,mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id))); - - if (1|| // DJP - no check in - (UE_template->bsr_info[LCGID0]>0) || - (UE_template->bsr_info[LCGID1]>0) || - (UE_template->bsr_info[LCGID2]>0) || - (UE_template->bsr_info[LCGID3]>0) || - (UE_template->ul_SR>0) || // uplink scheduling request - ((UE_sched_ctl->ul_inactivity_timer>20)&& - (UE_sched_ctl->ul_scheduled==0))|| // every 2 frames when RRC_CONNECTED - ((UE_sched_ctl->ul_inactivity_timer>10)&& - (UE_sched_ctl->ul_scheduled==0)&& - (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) // every Frame when not RRC_CONNECTED - { - LOG_D(MAC,"[eNB %d][PUSCH] UE %d/%x should be scheduled (BSR0 %d,SR %d)\n",module_idP,UE_id,UE_RNTI(module_idP,UE_id), - UE_template->bsr_info[LCGID0], - UE_template->ul_SR); - return(1); - } else { - return(0); - } + UE_TEMPLATE *UE_template = + &RC.mac[module_idP]->UE_list.UE_template[CC_id][UE_id]; + UE_sched_ctrl *UE_sched_ctl = + &RC.mac[module_idP]->UE_list.UE_sched_ctrl[UE_id]; + + // do not schedule UE if UL is not working + if (UE_sched_ctl->ul_failure_timer > 0) + return (0); + if (UE_sched_ctl->ul_out_of_sync > 0) + return (0); + + LOG_D(MAC, "[eNB %d][PUSCH] Checking UL requirements UE %d/%x\n", + module_idP, UE_id, UE_RNTI(module_idP, UE_id)); + + if ((UE_template->bsr_info[LCGID0] > 0) || (UE_template->bsr_info[LCGID1] > 0) || (UE_template->bsr_info[LCGID2] > 0) || (UE_template->bsr_info[LCGID3] > 0) || (UE_template->ul_SR > 0) || // uplink scheduling request + ((UE_sched_ctl->ul_inactivity_timer > 20) && (UE_sched_ctl->ul_scheduled == 0)) || // every 2 frames when RRC_CONNECTED + ((UE_sched_ctl->ul_inactivity_timer > 10) && (UE_sched_ctl->ul_scheduled == 0) && (mac_eNB_get_rrc_status(module_idP, UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED))) // every Frame when not RRC_CONNECTED + { + LOG_D(MAC, + "[eNB %d][PUSCH] UE %d/%x should be scheduled (BSR0 %d,SR %d)\n", + module_idP, UE_id, UE_RNTI(module_idP, UE_id), + UE_template->bsr_info[LCGID0], UE_template->ul_SR); + return (1); + } else { + return (0); + } } -uint8_t get_tmode(module_id_t module_idP,int CC_idP,int UE_idP) +uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP) { - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - - struct PhysicalConfigDedicated *physicalConfigDedicated = eNB->UE_list.physicalConfigDedicated[CC_idP][UE_idP]; - - if (physicalConfigDedicated == NULL ) { // RRCConnectionSetup not received by UE yet - AssertFatal(cc->p_eNB<=2,"p_eNB is %d, should be <2\n",cc->p_eNB); - return(cc->p_eNB); - } - else { - AssertFatal(physicalConfigDedicated->antennaInfo!=NULL, - "antennaInfo is null for CCId %d, UEid %d\n",CC_idP,UE_idP); + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - AssertFatal(physicalConfigDedicated->antennaInfo->present != PhysicalConfigDedicated__antennaInfo_PR_NOTHING, - "antennaInfo (mod_id %d, CC_id %d) is set to NOTHING\n",module_idP,CC_idP); + struct PhysicalConfigDedicated *physicalConfigDedicated = + eNB->UE_list.physicalConfigDedicated[CC_idP][UE_idP]; - if (physicalConfigDedicated->antennaInfo->present == PhysicalConfigDedicated__antennaInfo_PR_explicitValue) { - return(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode); - } - else if (physicalConfigDedicated->antennaInfo->present == PhysicalConfigDedicated__antennaInfo_PR_defaultValue) { - AssertFatal(cc->p_eNB<=2,"p_eNB is %d, should be <2\n",cc->p_eNB); - return(cc->p_eNB); + if (physicalConfigDedicated == NULL) { // RRCConnectionSetup not received by UE yet + AssertFatal(cc->p_eNB <= 2, "p_eNB is %d, should be <2\n", + cc->p_eNB); + return (cc->p_eNB); + } else { + AssertFatal(physicalConfigDedicated->antennaInfo != NULL, + "antennaInfo is null for CCId %d, UEid %d\n", CC_idP, + UE_idP); + + AssertFatal(physicalConfigDedicated->antennaInfo->present != + PhysicalConfigDedicated__antennaInfo_PR_NOTHING, + "antennaInfo (mod_id %d, CC_id %d) is set to NOTHING\n", + module_idP, CC_idP); + + if (physicalConfigDedicated->antennaInfo->present == + PhysicalConfigDedicated__antennaInfo_PR_explicitValue) { + return (physicalConfigDedicated->antennaInfo-> + choice.explicitValue.transmissionMode); + } else if (physicalConfigDedicated->antennaInfo->present == + PhysicalConfigDedicated__antennaInfo_PR_defaultValue) { + AssertFatal(cc->p_eNB <= 2, "p_eNB is %d, should be <2\n", + cc->p_eNB); + return (cc->p_eNB); + } else + AssertFatal(1 == 0, "Shouldn't be here\n"); } - else AssertFatal(1==0,"Shouldn't be here\n"); - } } -int8_t get_ULharq(module_id_t module_idP,int CC_idP,uint16_t frameP,uint8_t subframeP) +int8_t +get_ULharq(module_id_t module_idP, int CC_idP, uint16_t frameP, + uint8_t subframeP) { - uint8_t ret = -1; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - - if (cc->tdd_Config==NULL) { // FDD - ret = (((frameP<<1)+subframeP)&7); - } else { - switch (cc->tdd_Config->subframeAssignment) { - case 1: - if ((subframeP==2) || - (subframeP==3) || - (subframeP==7) || - (subframeP==8)) - switch (subframeP) { - case 2: - case 3: - ret = (subframeP-2); - break; - - case 7: - case 8: - ret = (subframeP-5); - break; - - default: - AssertFatal(1==0,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); - break; - } - - break; + uint8_t ret = -1; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - case 2: - AssertFatal((subframeP==2) || (subframeP==7), - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); - ret = (subframeP/7); - break; - - case 3: - AssertFatal((subframeP>1) && (subframeP<5), - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); - ret = (subframeP-2); - break; - - case 4: - AssertFatal((subframeP>1) && (subframeP<4), - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); - ret = (subframeP-2); - break; - - case 5: - AssertFatal(subframeP==2, - "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); - ret = (subframeP-2); - break; - - default: - AssertFatal(1==0,"subframe2_harq_pid, Unsupported TDD mode %d\n",(int)cc->tdd_Config->subframeAssignment); - break; + if (cc->tdd_Config == NULL) { // FDD + ret = (((frameP << 1) + subframeP) & 7); + } else { + switch (cc->tdd_Config->subframeAssignment) { + case 1: + if ((subframeP == 2) || + (subframeP == 3) || (subframeP == 7) || (subframeP == 8)) + switch (subframeP) { + case 2: + case 3: + ret = (subframeP - 2); + break; + + case 7: + case 8: + ret = (subframeP - 5); + break; + + default: + AssertFatal(1 == 0, + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframeP, + (int) cc->tdd_Config->subframeAssignment); + break; + } + + break; + + case 2: + AssertFatal((subframeP == 2) || (subframeP == 7), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframeP, + (int) cc->tdd_Config->subframeAssignment); + ret = (subframeP / 7); + break; + + case 3: + AssertFatal((subframeP > 1) && (subframeP < 5), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframeP, + (int) cc->tdd_Config->subframeAssignment); + ret = (subframeP - 2); + break; + + case 4: + AssertFatal((subframeP > 1) && (subframeP < 4), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframeP, + (int) cc->tdd_Config->subframeAssignment); + ret = (subframeP - 2); + break; + + case 5: + AssertFatal(subframeP == 2, + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n", + subframeP, + (int) cc->tdd_Config->subframeAssignment); + ret = (subframeP - 2); + break; + + default: + AssertFatal(1 == 0, + "subframe2_harq_pid, Unsupported TDD mode %d\n", + (int) cc->tdd_Config->subframeAssignment); + break; + } } - } - AssertFatal(ret!=-1, - "invalid harq_pid(%d) at SFN/SF = %d/%d\n", (int8_t)ret, frameP, subframeP); - return ret; + AssertFatal(ret != -1, + "invalid harq_pid(%d) at SFN/SF = %d/%d\n", (int8_t) ret, + frameP, subframeP); + return ret; } -uint16_t getRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs) +uint16_t getRIV(uint16_t N_RB_DL, uint16_t RBstart, uint16_t Lcrbs) { - uint16_t RIV; + uint16_t RIV; - if (Lcrbs<=(1+(N_RB_DL>>1))) - RIV = (N_RB_DL*(Lcrbs-1)) + RBstart; - else - RIV = (N_RB_DL*(N_RB_DL+1-Lcrbs)) + (N_RB_DL-1-RBstart); + if (Lcrbs <= (1 + (N_RB_DL >> 1))) + RIV = (N_RB_DL * (Lcrbs - 1)) + RBstart; + else + RIV = (N_RB_DL * (N_RB_DL + 1 - Lcrbs)) + (N_RB_DL - 1 - RBstart); - return(RIV); + return (RIV); } -uint32_t allocate_prbs(int UE_id,unsigned char nb_rb, int N_RB_DL, uint32_t *rballoc) +uint32_t +allocate_prbs(int UE_id, unsigned char nb_rb, int N_RB_DL, + uint32_t * rballoc) { - int i; - uint32_t rballoc_dci=0; - unsigned char nb_rb_alloc=0; - - for (i=0; i<(N_RB_DL-2); i+=2) { - if (((*rballoc>>i)&3)==0) { - *rballoc |= (3<<i); - rballoc_dci |= (1<<((12-i)>>1)); - nb_rb_alloc+=2; + int i; + uint32_t rballoc_dci = 0; + unsigned char nb_rb_alloc = 0; + + for (i = 0; i < (N_RB_DL - 2); i += 2) { + if (((*rballoc >> i) & 3) == 0) { + *rballoc |= (3 << i); + rballoc_dci |= (1 << ((12 - i) >> 1)); + nb_rb_alloc += 2; + } + + if (nb_rb_alloc == nb_rb) { + return (rballoc_dci); + } } - if (nb_rb_alloc==nb_rb) { - return(rballoc_dci); + if ((N_RB_DL & 1) == 1) { + if ((*rballoc >> (N_RB_DL - 1) & 1) == 0) { + *rballoc |= (1 << (N_RB_DL - 1)); + rballoc_dci |= 1; + } } - } - if ((N_RB_DL&1)==1) { - if ((*rballoc>>(N_RB_DL-1)&1)==0) { - *rballoc |= (1<<(N_RB_DL-1)); - rballoc_dci |= 1; - } - } - - return(rballoc_dci); + return (rballoc_dci); } int get_bw_index(module_id_t module_id, uint8_t CC_id) { - int bw_index=0; + int bw_index = 0; - int N_RB_DL = to_prb(RC.mac[module_id]->common_channels[CC_id].mib->message.dl_Bandwidth); + int N_RB_DL = + to_prb(RC.mac[module_id]->common_channels[CC_id].mib-> + message.dl_Bandwidth); - switch (N_RB_DL) { - case 6: // 1.4 MHz - bw_index=0; - break; + switch (N_RB_DL) { + case 6: // 1.4 MHz + bw_index = 0; + break; - case 25: // 5HMz - bw_index=1; - break; + case 25: // 5HMz + bw_index = 1; + break; - case 50: // 10HMz - bw_index=2; - break; + case 50: // 10HMz + bw_index = 2; + break; - case 100: // 20HMz - bw_index=3; - break; + case 100: // 20HMz + bw_index = 3; + break; - default: - bw_index=1; - LOG_W(MAC,"[eNB %d] N_RB_DL %d unknown for CC_id %d, setting bw_index to 1\n", module_id, N_RB_DL,CC_id); - break; - } + default: + bw_index = 1; + LOG_W(MAC, + "[eNB %d] N_RB_DL %d unknown for CC_id %d, setting bw_index to 1\n", + module_id, N_RB_DL, CC_id); + break; + } - return bw_index; + return bw_index; } int get_min_rb_unit(module_id_t module_id, uint8_t CC_id) { - int min_rb_unit=0; - int N_RB_DL = to_prb(RC.mac[module_id]->common_channels[CC_id].mib->message.dl_Bandwidth); + int min_rb_unit = 0; + int N_RB_DL = + to_prb(RC.mac[module_id]->common_channels[CC_id].mib-> + message.dl_Bandwidth); - switch (N_RB_DL) { - case 6: // 1.4 MHz - min_rb_unit=1; - break; + switch (N_RB_DL) { + case 6: // 1.4 MHz + min_rb_unit = 1; + break; - case 25: // 5HMz - min_rb_unit=2; - break; + case 25: // 5HMz + min_rb_unit = 2; + break; - case 50: // 10HMz - min_rb_unit=3; - break; + case 50: // 10HMz + min_rb_unit = 3; + break; - case 100: // 20HMz - min_rb_unit=4; - break; + case 100: // 20HMz + min_rb_unit = 4; + break; - default: - min_rb_unit=2; - LOG_W(MAC,"[eNB %d] N_DL_RB %d unknown for CC_id %d, setting min_rb_unit to 2\n", - module_id, N_RB_DL, CC_id); - break; - } + default: + min_rb_unit = 2; + LOG_W(MAC, + "[eNB %d] N_DL_RB %d unknown for CC_id %d, setting min_rb_unit to 2\n", + module_id, N_RB_DL, CC_id); + break; + } - return min_rb_unit; + return min_rb_unit; } -uint32_t allocate_prbs_sub(int nb_rb, int N_RB_DL, int N_RBG, uint8_t *rballoc) +uint32_t +allocate_prbs_sub(int nb_rb, int N_RB_DL, int N_RBG, uint8_t * rballoc) { - int check=0;//check1=0,check2=0; - uint32_t rballoc_dci=0; - //uint8_t number_of_subbands=13; - - LOG_T(MAC,"*****Check1RBALLOC****: %d%d%d%d (nb_rb %d,N_RBG %d)\n", - rballoc[3],rballoc[2],rballoc[1],rballoc[0],nb_rb,N_RBG); - - while((nb_rb >0) && (check < N_RBG)) { - //printf("rballoc[%d] %d\n",check,rballoc[check]); - if(rballoc[check] == 1) { - rballoc_dci |= (1<<((N_RBG-1)-check)); - - switch (N_RB_DL) { - case 6: - nb_rb--; - break; - - case 25: - if ((check == N_RBG-1)) { - nb_rb--; - } else { - nb_rb-=2; - } - - break; - - case 50: - if ((check == N_RBG-1)) { - nb_rb-=2; - } else { - nb_rb-=3; - } - - break; - - case 100: - nb_rb-=4; - break; - } + int check = 0; //check1=0,check2=0; + uint32_t rballoc_dci = 0; + //uint8_t number_of_subbands=13; + + LOG_T(MAC, "*****Check1RBALLOC****: %d%d%d%d (nb_rb %d,N_RBG %d)\n", + rballoc[3], rballoc[2], rballoc[1], rballoc[0], nb_rb, N_RBG); + + while ((nb_rb > 0) && (check < N_RBG)) { + //printf("rballoc[%d] %d\n",check,rballoc[check]); + if (rballoc[check] == 1) { + rballoc_dci |= (1 << ((N_RBG - 1) - check)); + + switch (N_RB_DL) { + case 6: + nb_rb--; + break; + + case 25: + if ((check == N_RBG - 1)) { + nb_rb--; + } else { + nb_rb -= 2; + } + + break; + + case 50: + if ((check == N_RBG - 1)) { + nb_rb -= 2; + } else { + nb_rb -= 3; + } + + break; + + case 100: + nb_rb -= 4; + break; + } + } + // printf("rb_alloc %x\n",rballoc_dci); + check = check + 1; + // check1 = check1+2; } - // printf("rb_alloc %x\n",rballoc_dci); - check = check+1; - // check1 = check1+2; - } - - // rballoc_dci = (rballoc_dci)&(0x1fff); - LOG_T(MAC,"*********RBALLOC : %x\n",rballoc_dci); - // exit(-1); - return (rballoc_dci); + // rballoc_dci = (rballoc_dci)&(0x1fff); + LOG_T(MAC, "*********RBALLOC : %x\n", rballoc_dci); + // exit(-1); + return (rballoc_dci); } int get_subbandsize(uint8_t dl_Bandwidth) { - uint8_t ss[6] = {6,4,4,6,8,8}; + uint8_t ss[6] = { 6, 4, 4, 6, 8, 8 }; - AssertFatal(dl_Bandwidth<6,"dl_Bandwidth %d is out of bounds\n",dl_Bandwidth); + AssertFatal(dl_Bandwidth < 6, "dl_Bandwidth %d is out of bounds\n", + dl_Bandwidth); - return(ss[dl_Bandwidth]); + return (ss[dl_Bandwidth]); } int get_nb_subband(int N_RB_DL) { - int nb_sb=0; + int nb_sb = 0; - switch (N_RB_DL) { - case 6: - nb_sb=0; - break; + switch (N_RB_DL) { + case 6: + nb_sb = 0; + break; - case 15: - nb_sb = 4; // sb_size =4 + case 15: + nb_sb = 4; // sb_size =4 - case 25: - nb_sb = 7; // sb_size =4, 1 sb with 1PRB, 6 with 2 RBG, each has 2 PRBs - break; + case 25: + nb_sb = 7; // sb_size =4, 1 sb with 1PRB, 6 with 2 RBG, each has 2 PRBs + break; - case 50: // sb_size =6 - nb_sb = 9; - break; + case 50: // sb_size =6 + nb_sb = 9; + break; - case 75: // sb_size =8 - nb_sb = 10; - break; + case 75: // sb_size =8 + nb_sb = 10; + break; - case 100: // sb_size =8 , 1 sb with 1 RBG + 12 sb with 2RBG, each RBG has 4 PRBs - nb_sb = 13; - break; + case 100: // sb_size =8 , 1 sb with 1 RBG + 12 sb with 2RBG, each RBG has 4 PRBs + nb_sb = 13; + break; - default: - nb_sb=0; - break; - } + default: + nb_sb = 0; + break; + } - return nb_sb; + return nb_sb; } -void init_CCE_table(int module_idP,int CC_idP) +void init_CCE_table(int module_idP, int CC_idP) { - memset(RC.mac[module_idP]->CCE_table[CC_idP],0,800*sizeof(int)); + memset(RC.mac[module_idP]->CCE_table[CC_idP], 0, 800 * sizeof(int)); } -int get_nCCE_offset(int *CCE_table, - const unsigned char L, - const int nCCE, - const int common_dci, - const unsigned short rnti, - const unsigned char subframe) +int +get_nCCE_offset(int *CCE_table, + const unsigned char L, + const int nCCE, + const int common_dci, + const unsigned short rnti, const unsigned char subframe) { - int search_space_free,m,nb_candidates = 0,l,i; - unsigned int Yk; - /* - printf("CCE Allocation: "); - for (i=0;i<nCCE;i++) - printf("%d.",CCE_table[i]); - printf("\n"); - */ - if (common_dci == 1) { - // check CCE(0 ... L-1) - nb_candidates = (L==4) ? 4 : 2; - nb_candidates = min(nb_candidates,nCCE/L); + int search_space_free, m, nb_candidates = 0, l, i; + unsigned int Yk; + /* + printf("CCE Allocation: "); + for (i=0;i<nCCE;i++) + printf("%d.",CCE_table[i]); + printf("\n"); + */ + if (common_dci == 1) { + // check CCE(0 ... L-1) + nb_candidates = (L == 4) ? 4 : 2; + nb_candidates = min(nb_candidates, nCCE / L); - // printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); + // printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); - for (m = nb_candidates-1 ; m >=0 ; m--) { + for (m = nb_candidates - 1; m >= 0; m--) { - search_space_free = 1; - for (l=0; l<L; l++) { + search_space_free = 1; + for (l = 0; l < L; l++) { - // printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]); - if (CCE_table[(m*L) + l] == 1) { - search_space_free = 0; - break; - } - } + // printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]); + if (CCE_table[(m * L) + l] == 1) { + search_space_free = 0; + break; + } + } - if (search_space_free == 1) { + if (search_space_free == 1) { - // printf("returning %d\n",m*L); + // printf("returning %d\n",m*L); - for (l=0; l<L; l++) - CCE_table[(m*L)+l]=1; - return(m*L); - } - } + for (l = 0; l < L; l++) + CCE_table[(m * L) + l] = 1; + return (m * L); + } + } - return(-1); + return (-1); - } else { // Find first available in ue specific search space - // according to procedure in Section 9.1.1 of 36.213 (v. 8.6) - // compute Yk - Yk = (unsigned int)rnti; + } else { // Find first available in ue specific search space + // according to procedure in Section 9.1.1 of 36.213 (v. 8.6) + // compute Yk + Yk = (unsigned int) rnti; - for (i=0; i<=subframe; i++) - Yk = (Yk*39827)%65537; + for (i = 0; i <= subframe; i++) + Yk = (Yk * 39827) % 65537; - Yk = Yk % (nCCE/L); + Yk = Yk % (nCCE / L); - switch (L) { - case 1: - case 2: - nb_candidates = 6; - break; + switch (L) { + case 1: + case 2: + nb_candidates = 6; + break; - case 4: - case 8: - nb_candidates = 2; - break; + case 4: + case 8: + nb_candidates = 2; + break; - default: - DevParam(L, nCCE, rnti); - break; - } + default: + DevParam(L, nCCE, rnti); + break; + } - LOG_D(MAC,"rnti %x, Yk = %d, nCCE %d (nCCE/L %d),nb_cand %d\n",rnti,Yk,nCCE,nCCE/L,nb_candidates); + LOG_D(MAC, "rnti %x, Yk = %d, nCCE %d (nCCE/L %d),nb_cand %d\n", + rnti, Yk, nCCE, nCCE / L, nb_candidates); - for (m = 0 ; m < nb_candidates ; m++) { - search_space_free = 1; + for (m = 0; m < nb_candidates; m++) { + search_space_free = 1; - for (l=0; l<L; l++) { - int cce = (((Yk+m)%(nCCE/L))*L) + l; - if (cce >= nCCE || CCE_table[cce] == 1) { - search_space_free = 0; - break; - } - } + for (l = 0; l < L; l++) { + int cce = (((Yk + m) % (nCCE / L)) * L) + l; + if (cce >= nCCE || CCE_table[cce] == 1) { + search_space_free = 0; + break; + } + } - if (search_space_free == 1) { - for (l=0; l<L; l++) - CCE_table[(((Yk+m)%(nCCE/L))*L)+l]=1; + if (search_space_free == 1) { + for (l = 0; l < L; l++) + CCE_table[(((Yk + m) % (nCCE / L)) * L) + l] = 1; - return(((Yk+m)%(nCCE/L))*L); - } - } + return (((Yk + m) % (nCCE / L)) * L); + } + } - return(-1); - } + return (-1); + } } -void dump_CCE_table(int *CCE_table,const int nCCE,const unsigned short rnti,const int subframe,int L) +void +dump_CCE_table(int *CCE_table, const int nCCE, + const unsigned short rnti, const int subframe, int L) { - int nb_candidates = 0,i; - unsigned int Yk; - - printf("CCE 0: "); - for (i=0;i<nCCE;i++) { - printf("%1d.",CCE_table[i]); - if ((i&7) == 7) - printf("\n CCE %d: ",i); - } + int nb_candidates = 0, i; + unsigned int Yk; + + printf("CCE 0: "); + for (i = 0; i < nCCE; i++) { + printf("%1d.", CCE_table[i]); + if ((i & 7) == 7) + printf("\n CCE %d: ", i); + } - Yk = (unsigned int)rnti; + Yk = (unsigned int) rnti; - for (i=0; i<=subframe; i++) - Yk = (Yk*39827)%65537; + for (i = 0; i <= subframe; i++) + Yk = (Yk * 39827) % 65537; - Yk = Yk % (nCCE/L); + Yk = Yk % (nCCE / L); - switch (L) { - case 1: - case 2: - nb_candidates = 6; - break; + switch (L) { + case 1: + case 2: + nb_candidates = 6; + break; - case 4: - case 8: - nb_candidates = 2; - break; + case 4: + case 8: + nb_candidates = 2; + break; - default: - DevParam(L, nCCE, rnti); - break; - } + default: + DevParam(L, nCCE, rnti); + break; + } - printf("rnti %x, Yk*L = %d, nCCE %d (nCCE/L %d),nb_cand*L %d\n",rnti,Yk*L,nCCE,nCCE/L,nb_candidates*L); + printf("rnti %x, Yk*L = %d, nCCE %d (nCCE/L %d),nb_cand*L %d\n", rnti, + Yk * L, nCCE, nCCE / L, nb_candidates * L); } -uint16_t getnquad(COMMON_channels_t *cc, uint8_t num_pdcch_symbols,uint8_t mi) +uint16_t +getnquad(COMMON_channels_t * cc, uint8_t num_pdcch_symbols, uint8_t mi) { - uint16_t Nreg=0; + uint16_t Nreg = 0; - AssertFatal(cc!=NULL,"cc is null\n"); - AssertFatal(cc->mib!=NULL,"cc->mib is null\n"); + AssertFatal(cc != NULL, "cc is null\n"); + AssertFatal(cc->mib != NULL, "cc->mib is null\n"); - int N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); - int phich_resource = get_phich_resource_times6(cc); + int N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + int phich_resource = get_phich_resource_times6(cc); - uint8_t Ngroup_PHICH = (phich_resource*N_RB_DL)/48; + uint8_t Ngroup_PHICH = (phich_resource * N_RB_DL) / 48; - if (((phich_resource*N_RB_DL)%48) > 0) - Ngroup_PHICH++; + if (((phich_resource * N_RB_DL) % 48) > 0) + Ngroup_PHICH++; - if (cc->Ncp == 1) { - Ngroup_PHICH<<=1; - } - - Ngroup_PHICH*=mi; + if (cc->Ncp == 1) { + Ngroup_PHICH <<= 1; + } - if ((num_pdcch_symbols>0) && (num_pdcch_symbols<4)) - switch (N_RB_DL) { - case 6: - Nreg=12+(num_pdcch_symbols-1)*18; - break; + Ngroup_PHICH *= mi; - case 25: - Nreg=50+(num_pdcch_symbols-1)*75; - break; + if ((num_pdcch_symbols > 0) && (num_pdcch_symbols < 4)) + switch (N_RB_DL) { + case 6: + Nreg = 12 + (num_pdcch_symbols - 1) * 18; + break; - case 50: - Nreg=100+(num_pdcch_symbols-1)*150; - break; + case 25: + Nreg = 50 + (num_pdcch_symbols - 1) * 75; + break; - case 100: - Nreg=200+(num_pdcch_symbols-1)*300; - break; + case 50: + Nreg = 100 + (num_pdcch_symbols - 1) * 150; + break; - default: - return(0); - } + case 100: + Nreg = 200 + (num_pdcch_symbols - 1) * 300; + break; - // printf("Nreg %d (%d)\n",Nreg,Nreg - 4 - (3*Ngroup_PHICH)); - return(Nreg - 4 - (3*Ngroup_PHICH)); + default: + return (0); + } + // printf("Nreg %d (%d)\n",Nreg,Nreg - 4 - (3*Ngroup_PHICH)); + return (Nreg - 4 - (3 * Ngroup_PHICH)); } -uint16_t getnCCE(COMMON_channels_t *cc, uint8_t num_pdcch_symbols, uint8_t mi) +uint16_t +getnCCE(COMMON_channels_t * cc, uint8_t num_pdcch_symbols, uint8_t mi) { - AssertFatal(cc!=NULL,"cc is null\n"); - return(getnquad(cc,num_pdcch_symbols,mi)/9); + AssertFatal(cc != NULL, "cc is null\n"); + return (getnquad(cc, num_pdcch_symbols, mi) / 9); } -uint8_t getmi(COMMON_channels_t *cc,int subframe) +uint8_t getmi(COMMON_channels_t * cc, int subframe) { - AssertFatal(cc!=NULL,"cc is null\n"); + AssertFatal(cc != NULL, "cc is null\n"); - // for FDD - if (cc->tdd_Config==NULL) // FDD - return 1; + // for FDD + if (cc->tdd_Config == NULL) // FDD + return 1; - // for TDD - switch (cc->tdd_Config->subframeAssignment) { - case 0: - if ((subframe==0) || (subframe==5)) - return(2); - else return(1); + // for TDD + switch (cc->tdd_Config->subframeAssignment) { + case 0: + if ((subframe == 0) || (subframe == 5)) + return (2); + else + return (1); - break; + break; - case 1: - if ((subframe==0) || (subframe==5)) - return(0); - else return(1); + case 1: + if ((subframe == 0) || (subframe == 5)) + return (0); + else + return (1); - break; + break; - case 2: - if ((subframe==3) || (subframe==8)) - return(1); - else return(0); + case 2: + if ((subframe == 3) || (subframe == 8)) + return (1); + else + return (0); - break; + break; - case 3: - if ((subframe==0) || (subframe==8) || (subframe==9)) - return(1); - else return(0); + case 3: + if ((subframe == 0) || (subframe == 8) || (subframe == 9)) + return (1); + else + return (0); - break; + break; - case 4: - if ((subframe==8) || (subframe==9)) - return(1); - else return(0); + case 4: + if ((subframe == 8) || (subframe == 9)) + return (1); + else + return (0); - break; + break; - case 5: - if (subframe==8) - return(1); - else return(0); + case 5: + if (subframe == 8) + return (1); + else + return (0); - break; + break; - case 6: - return(1); - break; + case 6: + return (1); + break; - default: - return(0); - } + default: + return (0); + } } -uint16_t get_nCCE_max(COMMON_channels_t *cc, int num_pdcch_symbols,int subframe) +uint16_t +get_nCCE_max(COMMON_channels_t * cc, int num_pdcch_symbols, int subframe) { - AssertFatal(cc!=NULL,"cc is null\n"); - return(getnCCE(cc,num_pdcch_symbols, - getmi(cc,subframe))); + AssertFatal(cc != NULL, "cc is null\n"); + return (getnCCE(cc, num_pdcch_symbols, getmi(cc, subframe))); } // Allocate the CCEs -int allocate_CCEs(int module_idP, - int CC_idP, - int subframeP, - int test_onlyP) -{ - int *CCE_table = RC.mac[module_idP]->CCE_table[CC_idP]; - nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[CC_idP].dl_config_request_body; - nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; - nfapi_dl_config_request_pdu_t *dl_config_pdu = &DL_req->dl_config_pdu_list[0]; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[0]; - int nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],1,subframeP); - int fCCE; - int i,j,idci; - int nCCE=0; - - //LOG_D(MAC,"Allocate CCEs subframe %d, test %d : (DL PDU %d, DL DCI %d, UL %d)\n",subframeP,test_onlyP,DL_req->number_pdu,DL_req->number_dci,HI_DCI0_req->number_of_dci); - DL_req->number_pdcch_ofdm_symbols=1; - -try_again: - init_CCE_table(module_idP,CC_idP); - nCCE=0; - - for (i=0,idci=0;i<DL_req->number_pdu;i++) { - // allocate DL common DCIs first - if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& - (dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type==2) - ) { - if (0) LOG_D(MAC,"Trying to allocate COMMON DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", - idci,DL_req->number_dci+HI_DCI0_req->number_of_dci, - DL_req->number_dci,HI_DCI0_req->number_of_dci, - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti, - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - nCCE,nCCE_max, DL_req->number_pdcch_ofdm_symbols); - - if (nCCE + (dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level) > nCCE_max) { - if (DL_req->number_pdcch_ofdm_symbols == 3) - goto failed; - //LOG_D(MAC,"Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n",DL_req->number_pdcch_ofdm_symbols); - DL_req->number_pdcch_ofdm_symbols++; - nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],DL_req->number_pdcch_ofdm_symbols,subframeP); - goto try_again; - } - - // number of CCEs left can potentially hold this allocation - fCCE = get_nCCE_offset(CCE_table, - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - nCCE_max, - 1, - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti, - subframeP); - if (fCCE == -1) { - if (DL_req->number_pdcch_ofdm_symbols == 3) { - LOG_D(MAC,"subframe %d: Dropping Allocation for RNTI %x\n", - subframeP,dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti); - for (j=0;j<=i;j++){ - if (dl_config_pdu[j].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) - LOG_D(MAC,"DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", - j,DL_req->number_dci+HI_DCI0_req->number_of_dci, - DL_req->number_dci,HI_DCI0_req->number_of_dci, - dl_config_pdu[j].dci_dl_pdu.dci_dl_pdu_rel8.rnti, - dl_config_pdu[j].dci_dl_pdu.dci_dl_pdu_rel8.dci_format, - dl_config_pdu[j].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - nCCE,nCCE_max,DL_req->number_pdcch_ofdm_symbols); - } - //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); - goto failed; - } - //LOG_D(MAC,"Can't fit DCI allocations with %d PDCCH symbols (rnti condition), increasing by 1\n",DL_req->number_pdcch_ofdm_symbols); - - DL_req->number_pdcch_ofdm_symbols++; - nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],DL_req->number_pdcch_ofdm_symbols,subframeP); - goto try_again; - } // fCCE==-1 - - // the allocation is feasible, rnti rule passes - nCCE += dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level; - //LOG_D(MAC,"Allocating at nCCE %d\n",fCCE); - if (test_onlyP == 0) { - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx=fCCE; - //LOG_D(MAC,"Allocate COMMON DCI CCEs subframe %d, test %d => L %d fCCE %d\n",subframeP,test_onlyP,dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,fCCE); - } - idci++; - } - } // for i = 0 ... num_DL_DCIs - - // no try to allocate UL DCIs - for (i=0;i<HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi;i++) { - - // allocate UL DCIs - if (hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) { - - if (0)LOG_D(MAC,"Trying to allocate format 0 DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", - idci,DL_req->number_dci+HI_DCI0_req->number_of_dci, - DL_req->number_dci,HI_DCI0_req->number_of_dci, - hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti,hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level, - nCCE,nCCE_max, DL_req->number_pdcch_ofdm_symbols); - - if (nCCE + (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level) > nCCE_max) { - if (DL_req->number_pdcch_ofdm_symbols == 3) - goto failed; - //LOG_D(MAC,"Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n",DL_req->number_pdcch_ofdm_symbols); - - DL_req->number_pdcch_ofdm_symbols++; - nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],DL_req->number_pdcch_ofdm_symbols,subframeP); - goto try_again; - } - - // number of CCEs left can potentially hold this allocation - fCCE = get_nCCE_offset(CCE_table, - hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level, - nCCE_max, - 0, - hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti, - subframeP); - if (fCCE == -1) { - if (DL_req->number_pdcch_ofdm_symbols == 3) { - LOG_D(MAC,"subframe %d: Dropping Allocation for RNTI %x\n", - subframeP,hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti); - for (j=0;j<=i;j++){ - if (hi_dci0_pdu[j].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) - LOG_D(MAC,"DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", - j,DL_req->number_dci+HI_DCI0_req->number_of_dci, - DL_req->number_dci,HI_DCI0_req->number_of_dci, - hi_dci0_pdu[j].dci_pdu.dci_pdu_rel8.rnti, - hi_dci0_pdu[j].dci_pdu.dci_pdu_rel8.dci_format, - hi_dci0_pdu[j].dci_pdu.dci_pdu_rel8.aggregation_level, - nCCE,nCCE_max,DL_req->number_pdcch_ofdm_symbols); - } - //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); - goto failed; - } - //LOG_D(MAC,"Can't fit DCI allocations with %d PDCCH symbols (rnti condition), increasing by 1\n",DL_req->number_pdcch_ofdm_symbols); - - DL_req->number_pdcch_ofdm_symbols++; - nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],DL_req->number_pdcch_ofdm_symbols,subframeP); - goto try_again; - } // fCCE==-1 - - // the allocation is feasible, rnti rule passes - nCCE += hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level; - //LOG_D(MAC,"Allocating at nCCE %d\n",fCCE); - if (test_onlyP == 0) { - hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.cce_index=fCCE; - //LOG_D(MAC,"Allocate CCEs subframe %d, test %d\n",subframeP,test_onlyP); - } - idci++; - } - } // for i = 0 ... num_UL_DCIs - - for (i=0;i<DL_req->number_pdu;i++) { - // allocate DL UE specific DCIs - if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& - (dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type==1)) { - if (0)LOG_D(MAC,"Trying to allocate DL UE-SPECIFIC DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", - idci,DL_req->number_dci+HI_DCI0_req->number_of_dci, - DL_req->number_dci,HI_DCI0_req->number_of_dci, - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti,dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - nCCE,nCCE_max, DL_req->number_pdcch_ofdm_symbols); - - if (nCCE + (dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level) > nCCE_max) { - if (DL_req->number_pdcch_ofdm_symbols == 3) - goto failed; - //LOG_D(MAC,"Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n",DL_req->number_pdcch_ofdm_symbols); - - DL_req->number_pdcch_ofdm_symbols++; - nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],DL_req->number_pdcch_ofdm_symbols,subframeP); - goto try_again; - } - - // number of CCEs left can potentially hold this allocation - fCCE = get_nCCE_offset(CCE_table, - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - nCCE_max, - 0, - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti, - subframeP); - if (fCCE == -1) { - if (DL_req->number_pdcch_ofdm_symbols == 3) { - LOG_I(MAC,"subframe %d: Dropping Allocation for RNTI %x\n", - subframeP,dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti); - for (j=0;j<=i;j++){ - if (dl_config_pdu[j].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) - LOG_I(MAC,"DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", - j,DL_req->number_dci+HI_DCI0_req->number_of_dci, - DL_req->number_dci,HI_DCI0_req->number_of_dci, - dl_config_pdu[j].dci_dl_pdu.dci_dl_pdu_rel8.rnti, - dl_config_pdu[j].dci_dl_pdu.dci_dl_pdu_rel8.dci_format, - dl_config_pdu[j].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - nCCE,nCCE_max,DL_req->number_pdcch_ofdm_symbols); - } - //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); - goto failed; - } - //LOG_D(MAC,"Can't fit DCI allocations with %d PDCCH symbols (rnti condition), increasing by 1\n",DL_req->number_pdcch_ofdm_symbols); - - DL_req->number_pdcch_ofdm_symbols++; - nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],DL_req->number_pdcch_ofdm_symbols,subframeP); - goto try_again; - } // fCCE==-1 - - // the allocation is feasible, rnti rule passes - nCCE += dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level; - //LOG_D(MAC,"Allocating at nCCE %d\n",fCCE); - if (test_onlyP == 0) { - dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx=fCCE; - //LOG_D(MAC,"Allocate CCEs subframe %d, test %d\n",subframeP,test_onlyP); - } - idci++; - } - } // for i = 0 ... num_DL_DCIs +int +allocate_CCEs(int module_idP, int CC_idP, int subframeP, int test_onlyP) +{ + int *CCE_table = RC.mac[module_idP]->CCE_table[CC_idP]; + nfapi_dl_config_request_body_t *DL_req = + &RC.mac[module_idP]->DL_req[CC_idP].dl_config_request_body; + nfapi_hi_dci0_request_body_t *HI_DCI0_req = + &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; + nfapi_dl_config_request_pdu_t *dl_config_pdu = + &DL_req->dl_config_pdu_list[0]; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = + &HI_DCI0_req->hi_dci0_pdu_list[0]; + int nCCE_max = + get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP], 1, + subframeP); + int fCCE; + int i, j, idci; + int nCCE = 0; + + LOG_D(MAC, + "Allocate CCEs subframe %d, test %d : (DL PDU %d, DL DCI %d, UL %d)\n", + subframeP, test_onlyP, DL_req->number_pdu, DL_req->number_dci, + HI_DCI0_req->number_of_dci); + DL_req->number_pdcch_ofdm_symbols = 1; + + try_again: + init_CCE_table(module_idP, CC_idP); + nCCE = 0; + + for (i = 0, idci = 0; i < DL_req->number_pdu; i++) { + // allocate DL common DCIs first + if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + && (dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == + 2)) { + LOG_D(MAC, + "Trying to allocate COMMON DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", + idci, DL_req->number_dci + HI_DCI0_req->number_of_dci, + DL_req->number_dci, HI_DCI0_req->number_of_dci, + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti, + dl_config_pdu[i].dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, nCCE, nCCE_max, + DL_req->number_pdcch_ofdm_symbols); + + if (nCCE + + (dl_config_pdu[i].dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level) > nCCE_max) { + if (DL_req->number_pdcch_ofdm_symbols == 3) + goto failed; + LOG_D(MAC, + "Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n", + DL_req->number_pdcch_ofdm_symbols); + DL_req->number_pdcch_ofdm_symbols++; + nCCE_max = + get_nCCE_max(&RC.mac[module_idP]-> + common_channels[CC_idP], + DL_req->number_pdcch_ofdm_symbols, + subframeP); + goto try_again; + } + // number of CCEs left can potentially hold this allocation + fCCE = get_nCCE_offset(CCE_table, + dl_config_pdu[i]. + dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, nCCE_max, 1, + dl_config_pdu[i]. + dci_dl_pdu.dci_dl_pdu_rel8.rnti, + subframeP); + if (fCCE == -1) { + if (DL_req->number_pdcch_ofdm_symbols == 3) { + LOG_D(MAC, + "subframe %d: Dropping Allocation for RNTI %x\n", + subframeP, + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8. + rnti); + for (j = 0; j <= i; j++) { + if (dl_config_pdu[j].pdu_type == + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + LOG_D(MAC, + "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", + j, + DL_req->number_dci + + HI_DCI0_req->number_of_dci, + DL_req->number_dci, + HI_DCI0_req->number_of_dci, + dl_config_pdu[j]. + dci_dl_pdu.dci_dl_pdu_rel8.rnti, + dl_config_pdu[j]. + dci_dl_pdu.dci_dl_pdu_rel8.dci_format, + dl_config_pdu[j]. + dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, nCCE, nCCE_max, + DL_req->number_pdcch_ofdm_symbols); + } + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); + goto failed; + } + LOG_D(MAC, + "Can't fit DCI allocations with %d PDCCH symbols (rnti condition), increasing by 1\n", + DL_req->number_pdcch_ofdm_symbols); + + DL_req->number_pdcch_ofdm_symbols++; + nCCE_max = + get_nCCE_max(&RC.mac[module_idP]-> + common_channels[CC_idP], + DL_req->number_pdcch_ofdm_symbols, + subframeP); + goto try_again; + } // fCCE==-1 + + // the allocation is feasible, rnti rule passes + nCCE += + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level; + LOG_D(MAC, "Allocating at nCCE %d\n", fCCE); + if (test_onlyP == 0) { + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx = fCCE; + LOG_D(MAC, + "Allocate COMMON DCI CCEs subframe %d, test %d => L %d fCCE %d\n", + subframeP, test_onlyP, + dl_config_pdu[i].dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, fCCE); + } + idci++; + } + } // for i = 0 ... num_DL_DCIs + + // no try to allocate UL DCIs + for (i = 0; i < HI_DCI0_req->number_of_dci + HI_DCI0_req->number_of_hi; + i++) { + + // allocate UL DCIs + if (hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) { + + LOG_D(MAC, + "Trying to allocate format 0 DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", + idci, DL_req->number_dci + HI_DCI0_req->number_of_dci, + DL_req->number_dci, HI_DCI0_req->number_of_dci, + hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti, + hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level, + nCCE, nCCE_max, DL_req->number_pdcch_ofdm_symbols); + + if (nCCE + + (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level) > + nCCE_max) { + if (DL_req->number_pdcch_ofdm_symbols == 3) + goto failed; + LOG_D(MAC, + "Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n", + DL_req->number_pdcch_ofdm_symbols); + + DL_req->number_pdcch_ofdm_symbols++; + nCCE_max = + get_nCCE_max(&RC.mac[module_idP]-> + common_channels[CC_idP], + DL_req->number_pdcch_ofdm_symbols, + subframeP); + goto try_again; + } + // number of CCEs left can potentially hold this allocation + fCCE = get_nCCE_offset(CCE_table, + hi_dci0_pdu[i].dci_pdu. + dci_pdu_rel8.aggregation_level, + nCCE_max, 0, + hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8. + rnti, subframeP); + if (fCCE == -1) { + if (DL_req->number_pdcch_ofdm_symbols == 3) { + LOG_D(MAC, + "subframe %d: Dropping Allocation for RNTI %x\n", + subframeP, + hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti); + for (j = 0; j <= i; j++) { + if (hi_dci0_pdu[j].pdu_type == + NFAPI_HI_DCI0_DCI_PDU_TYPE) + LOG_D(MAC, + "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", + j, + DL_req->number_dci + + HI_DCI0_req->number_of_dci, + DL_req->number_dci, + HI_DCI0_req->number_of_dci, + hi_dci0_pdu[j].dci_pdu.dci_pdu_rel8.rnti, + hi_dci0_pdu[j].dci_pdu.dci_pdu_rel8. + dci_format, + hi_dci0_pdu[j].dci_pdu. + dci_pdu_rel8.aggregation_level, nCCE, + nCCE_max, + DL_req->number_pdcch_ofdm_symbols); + } + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); + goto failed; + } + LOG_D(MAC, + "Can't fit DCI allocations with %d PDCCH symbols (rnti condition), increasing by 1\n", + DL_req->number_pdcch_ofdm_symbols); + + DL_req->number_pdcch_ofdm_symbols++; + nCCE_max = + get_nCCE_max(&RC.mac[module_idP]-> + common_channels[CC_idP], + DL_req->number_pdcch_ofdm_symbols, + subframeP); + goto try_again; + } // fCCE==-1 + + // the allocation is feasible, rnti rule passes + nCCE += hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level; + LOG_D(MAC, "Allocating at nCCE %d\n", fCCE); + if (test_onlyP == 0) { + hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.cce_index = fCCE; + LOG_D(MAC, "Allocate CCEs subframe %d, test %d\n", + subframeP, test_onlyP); + } + idci++; + } + } // for i = 0 ... num_UL_DCIs + + for (i = 0; i < DL_req->number_pdu; i++) { + // allocate DL UE specific DCIs + if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + && (dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == + 1)) { + LOG_D(MAC, + "Trying to allocate DL UE-SPECIFIC DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", + idci, DL_req->number_dci + HI_DCI0_req->number_of_dci, + DL_req->number_dci, HI_DCI0_req->number_of_dci, + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti, + dl_config_pdu[i].dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, nCCE, nCCE_max, + DL_req->number_pdcch_ofdm_symbols); + + if (nCCE + + (dl_config_pdu[i].dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level) > nCCE_max) { + if (DL_req->number_pdcch_ofdm_symbols == 3) + goto failed; + LOG_D(MAC, + "Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n", + DL_req->number_pdcch_ofdm_symbols); + + DL_req->number_pdcch_ofdm_symbols++; + nCCE_max = + get_nCCE_max(&RC.mac[module_idP]-> + common_channels[CC_idP], + DL_req->number_pdcch_ofdm_symbols, + subframeP); + goto try_again; + } + // number of CCEs left can potentially hold this allocation + fCCE = get_nCCE_offset(CCE_table, + dl_config_pdu[i]. + dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, nCCE_max, 0, + dl_config_pdu[i]. + dci_dl_pdu.dci_dl_pdu_rel8.rnti, + subframeP); + if (fCCE == -1) { + if (DL_req->number_pdcch_ofdm_symbols == 3) { + LOG_I(MAC, + "subframe %d: Dropping Allocation for RNTI %x\n", + subframeP, + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8. + rnti); + for (j = 0; j <= i; j++) { + if (dl_config_pdu[j].pdu_type == + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + LOG_I(MAC, + "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", + j, + DL_req->number_dci + + HI_DCI0_req->number_of_dci, + DL_req->number_dci, + HI_DCI0_req->number_of_dci, + dl_config_pdu[j]. + dci_dl_pdu.dci_dl_pdu_rel8.rnti, + dl_config_pdu[j]. + dci_dl_pdu.dci_dl_pdu_rel8.dci_format, + dl_config_pdu[j]. + dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, nCCE, nCCE_max, + DL_req->number_pdcch_ofdm_symbols); + } + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); + goto failed; + } + LOG_D(MAC, + "Can't fit DCI allocations with %d PDCCH symbols (rnti condition), increasing by 1\n", + DL_req->number_pdcch_ofdm_symbols); + + DL_req->number_pdcch_ofdm_symbols++; + nCCE_max = + get_nCCE_max(&RC.mac[module_idP]-> + common_channels[CC_idP], + DL_req->number_pdcch_ofdm_symbols, + subframeP); + goto try_again; + } // fCCE==-1 + + // the allocation is feasible, rnti rule passes + nCCE += + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level; + LOG_D(MAC, "Allocating at nCCE %d\n", fCCE); + if (test_onlyP == 0) { + dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx = fCCE; + LOG_D(MAC, "Allocate CCEs subframe %d, test %d\n", + subframeP, test_onlyP); + } + idci++; + } + } // for i = 0 ... num_DL_DCIs - return 0; + return 0; -failed: - return -1; + failed: + return -1; } /* @@ -2968,757 +3463,1052 @@ uint8_t get_ul_req_index(module_id_t module_idP, int CC_idP, sub_frame_t subfram } */ -nfapi_ul_config_request_pdu_t* has_ul_grant(module_id_t module_idP,int CC_idP,uint16_t absSFP,uint16_t rnti) -{ - nfapi_ul_config_request_body_t *ul_req; - nfapi_ul_config_request_pdu_t *ul_config_pdu; - - ul_req = &RC.mac[module_idP]->UL_req_tmp[CC_idP][absSFP%10].ul_config_request_body; - ul_config_pdu = &ul_req->ul_config_pdu_list[0]; - //LOG_D(MAC,"Checking for rnti %x UL grant in subframeP %d (num pdu %d)\n",rnti,absSFP%10,ul_req->number_of_pdus); - - for (int i=0; i<ul_req->number_of_pdus;i++){ - LOG_D(MAC,"PDU %d : type %d,rnti %x\n",i,ul_config_pdu[i].pdu_type,rnti); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE)&& - (ul_config_pdu[i].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE)&& - (ul_config_pdu[i].ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE)&& - (ul_config_pdu[i].ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE)&& - (ul_config_pdu[i].ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE)&& - (ul_config_pdu[i].uci_cqi_pdu.ue_information.ue_information_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE)&& - (ul_config_pdu[i].uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE)&& - (ul_config_pdu[i].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE)&& - (ul_config_pdu[i].uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE)&& - (ul_config_pdu[i].uci_cqi_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE)&& - (ul_config_pdu[i].uci_cqi_sr_pdu.ue_information.ue_information_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE) && - (ul_config_pdu[i].uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE)&& - (ul_config_pdu[i].ulsch_uci_csi_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE)&& - (ul_config_pdu[i].ulsch_uci_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE)&& - (ul_config_pdu[i].ulsch_csi_uci_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) return(&ul_config_pdu[i]); - } +nfapi_ul_config_request_pdu_t *has_ul_grant(module_id_t module_idP, + int CC_idP, uint16_t absSFP, + uint16_t rnti) +{ + nfapi_ul_config_request_body_t *ul_req; + nfapi_ul_config_request_pdu_t *ul_config_pdu; + + ul_req = + &RC.mac[module_idP]->UL_req_tmp[CC_idP][absSFP % + 10].ul_config_request_body; + ul_config_pdu = &ul_req->ul_config_pdu_list[0]; + LOG_D(MAC, + "Checking for rnti %x UL grant in subframeP %d (num pdu %d)\n", + rnti, absSFP % 10, ul_req->number_of_pdus); + + for (int i = 0; i < ul_req->number_of_pdus; i++) { + LOG_D(MAC, "PDU %d : type %d,rnti %x\n", i, + ul_config_pdu[i].pdu_type, rnti); + if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) + && (ul_config_pdu[i].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) + && (ul_config_pdu[i].ulsch_cqi_ri_pdu.ulsch_pdu. + ulsch_pdu_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) + && (ul_config_pdu[i].ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8. + rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) + && (ul_config_pdu[i].ulsch_cqi_harq_ri_pdu. + ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + + if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) + && (ul_config_pdu[i].uci_cqi_pdu. + ue_information.ue_information_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) + && (ul_config_pdu[i].uci_sr_pdu. + ue_information.ue_information_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) + && (ul_config_pdu[i].uci_harq_pdu. + ue_information.ue_information_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) + && (ul_config_pdu[i].uci_sr_harq_pdu. + ue_information.ue_information_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) + && (ul_config_pdu[i].uci_cqi_harq_pdu. + ue_information.ue_information_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) + && (ul_config_pdu[i].uci_cqi_sr_pdu. + ue_information.ue_information_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE) + && (ul_config_pdu[i].uci_cqi_sr_harq_pdu. + ue_information.ue_information_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE) + && (ul_config_pdu[i].ulsch_uci_csi_pdu. + ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE) + && (ul_config_pdu[i].ulsch_uci_harq_pdu. + ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + if ((ul_config_pdu[i].pdu_type == + NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE) + && (ul_config_pdu[i].ulsch_csi_uci_harq_pdu. + ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)) + return (&ul_config_pdu[i]); + } + - return(NULL); // no ul grant at all for this UE + return (NULL); // no ul grant at all for this UE } -boolean_t CCE_allocation_infeasible(int module_idP, - int CC_idP, - int format_flag, - int subframe, - int aggregation, - int rnti) +boolean_t +CCE_allocation_infeasible(int module_idP, + int CC_idP, + int format_flag, + int subframe, int aggregation, int rnti) { - nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[CC_idP].dl_config_request_body; - nfapi_dl_config_request_pdu_t *dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; - int ret; - boolean_t res = FALSE; - if (format_flag != 2) { // DL DCI - if (DL_req->number_pdu == MAX_NUM_DL_PDU) { - LOG_W(MAC, "Subframe %d: FAPI DL structure is full, skip scheduling UE %d\n", - subframe, rnti); - } else { - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - if(0)LOG_D(MAC,"Subframe %d: Checking CCE feasibility format %d : (%x,%d) (%x,%d,%d)\n", - subframe,format_flag,rnti,aggregation, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type); - ret = allocate_CCEs(module_idP,CC_idP,subframe,0); - if (ret==-1) - res = TRUE; - DL_req->number_pdu--; - } - } - else { // ue-specific UL DCI - if (HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi == MAX_NUM_HI_DCI0_PDU) { - LOG_W(MAC, "Subframe %d: FAPI UL structure is full, skip scheduling UE %d\n", - subframe, rnti); - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - ret = allocate_CCEs(module_idP,CC_idP,subframe,0); - if (ret==-1) - res = TRUE; - HI_DCI0_req->number_of_dci--; + nfapi_dl_config_request_body_t *DL_req = + &RC.mac[module_idP]->DL_req[CC_idP].dl_config_request_body; + nfapi_dl_config_request_pdu_t *dl_config_pdu = + &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + nfapi_hi_dci0_request_body_t *HI_DCI0_req = + &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = + &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci + + HI_DCI0_req->number_of_hi]; + int ret; + boolean_t res = FALSE; + + if (format_flag != 2) { // DL DCI + if (DL_req->number_pdu == MAX_NUM_DL_PDU) { + LOG_W(MAC, + "Subframe %d: FAPI DL structure is full, skip scheduling UE %d\n", + subframe, rnti); + } else { + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = + (format_flag == 0) ? 2 : 1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = + aggregation; + DL_req->number_pdu++; + LOG_D(MAC, + "Subframe %d: Checking CCE feasibility format %d : (%x,%d) (%x,%d,%d)\n", + subframe, format_flag, rnti, aggregation, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type); + ret = allocate_CCEs(module_idP, CC_idP, subframe, 0); + if (ret == -1) + res = TRUE; + DL_req->number_pdu--; + } + } else { // ue-specific UL DCI + if (HI_DCI0_req->number_of_dci + HI_DCI0_req->number_of_hi == + MAX_NUM_HI_DCI0_PDU) { + LOG_W(MAC, + "Subframe %d: FAPI UL structure is full, skip scheduling UE %d\n", + subframe, rnti); + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = + aggregation; + HI_DCI0_req->number_of_dci++; + ret = allocate_CCEs(module_idP, CC_idP, subframe, 0); + if (ret == -1) + res = TRUE; + HI_DCI0_req->number_of_dci--; + } } - } - return res; + return res; } -void extract_harq(module_id_t mod_idP,int CC_idP,int UE_id,frame_t frameP,sub_frame_t subframeP,void *harq_indication,int format) +void +extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, + frame_t frameP, sub_frame_t subframeP, + void *harq_indication, int format) { - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - rnti_t rnti = UE_RNTI(mod_idP,UE_id); - COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; - nfapi_harq_indication_fdd_rel13_t *harq_indication_fdd; - nfapi_harq_indication_tdd_rel13_t *harq_indication_tdd; - uint16_t num_ack_nak; - int numCC = UE_list->numactiveCCs[UE_id]; - int pCCid = UE_list->pCC_id[UE_id]; - int spatial_bundling = 0; - int tmode[5]; - int i,j; - uint8_t *pdu; + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + rnti_t rnti = UE_RNTI(mod_idP, UE_id); + COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; + nfapi_harq_indication_fdd_rel13_t *harq_indication_fdd; + nfapi_harq_indication_tdd_rel13_t *harq_indication_tdd; + uint16_t num_ack_nak; + int numCC = UE_list->numactiveCCs[UE_id]; + int pCCid = UE_list->pCC_id[UE_id]; + int spatial_bundling = 0; + int tmode[5]; + int i, j; + uint8_t *pdu; #ifdef Rel14 - AssertFatal(UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->pucch_ConfigDedicated!=NULL,"pucch_ConfigDedicated is null!\n"); - if ((UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->ext7) && - (UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13) && - (((UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13->spatialBundlingPUCCH_r13) && - (format==0)) || - ((UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13->spatialBundlingPUSCH_r13) && - (format==1)))) - spatial_bundling = 1; + if (UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated != NULL && + UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->pucch_ConfigDedicated != NULL && + (UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->ext7) + && (UE_list->UE_template[pCCid][UE_id]. + physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13) + && + (((UE_list->UE_template[pCCid][UE_id]. + physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13-> + spatialBundlingPUCCH_r13) + && (format == 0)) + || + ((UE_list->UE_template[pCCid][UE_id]. + physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13-> + spatialBundlingPUSCH_r13) + && (format == 1)))) + spatial_bundling = 1; #endif - for (i=0;i<numCC;i++) tmode[i] = get_tmode(mod_idP,i,UE_id); - - if (cc->tdd_Config) { - harq_indication_tdd = (nfapi_harq_indication_tdd_rel13_t *)harq_indication; - // pdu = &harq_indication_tdd->harq_tb_n[0]; - - num_ack_nak = harq_indication_tdd->number_of_ack_nack; - - switch (harq_indication_tdd->mode) { - case 0: // Format 1a/b - AssertFatal(numCC==1,"numCC %d > 1, should not be using Format1a/b\n",numCC); - break; - case 1: // Channel Selection - break; - case 2: // Format 3 - break; - case 3: // Format 4 - break; - case 4: // Format 5 - break; - } - } - else { - harq_indication_fdd = (nfapi_harq_indication_fdd_rel13_t *)harq_indication; - num_ack_nak = harq_indication_fdd->number_of_ack_nack; - pdu = &harq_indication_fdd->harq_tb_n[0]; - - uint8_t harq_pid = ((10*frameP) + subframeP + 10236)&7; - - switch (harq_indication_fdd->mode) { - case 0: // Format 1a/b (10.1.2.1) - AssertFatal(numCC==1,"numCC %d > 1, should not be using Format1a/b\n",numCC); - if (tmode[0]==1 || tmode[0]==2 || tmode[0]==5 || tmode[0]==6 || tmode[0]==7) { // NOTE: have to handle the case of TM9-10 with 1 antenna port - // single ACK/NAK bit - AssertFatal(num_ack_nak==1,"num_ack_nak %d > 1 for 1 CC and single-layer transmission\n",num_ack_nak); - AssertFatal(sched_ctl->round[CC_idP][harq_pid]<8,"Got ACK/NAK for inactive harq_pid %d for UE %d/%x SFN/SF:%d%d\n",harq_pid,UE_id,rnti,frameP,subframeP); - AssertFatal(pdu[0] == 1 || pdu[0] == 2 || pdu[0] == 4, - "Received ACK/NAK %d which is not 1 or 2 for harq_pid %d from UE %d/%x\n",pdu[0],harq_pid,UE_id,rnti); - - if (pdu[0] == 1) { // ACK - sched_ctl->round[CC_idP][harq_pid]=8; // release HARQ process - sched_ctl->tbcnt[CC_idP][harq_pid]=0; - } - else if (pdu[0] == 2 || pdu[0] == 4) // NAK (treat DTX as NAK) - sched_ctl->round[CC_idP][harq_pid]++; // increment round - - LOG_D(MAC,"Received PDU[0]:%d for harq_pid %d [round:%d tbcnt:%d]\n",pdu[0],harq_pid,sched_ctl->round[CC_idP][harq_pid],sched_ctl->tbcnt[CC_idP][harq_pid]); - } - else { - // one or two ACK/NAK bits - AssertFatal(num_ack_nak>2,"num_ack_nak %d > 2 for 1 CC and TM3/4/8/9/10\n",num_ack_nak); - LOG_D(MAC,"Received PDU[0]:%d:[1]:%d for harq_pid %d [round:%d tbcnt:%d]\n",pdu[0],pdu[1],harq_pid,sched_ctl->round[CC_idP][harq_pid],sched_ctl->tbcnt[CC_idP][harq_pid]); - if ((num_ack_nak==2) && (sched_ctl->round[CC_idP][harq_pid]<8) && (sched_ctl->tbcnt[CC_idP][harq_pid]==1) && (pdu[0] == 1) && (pdu[1] == 1)) { - sched_ctl->round[CC_idP][harq_pid]=8; - sched_ctl->tbcnt[CC_idP][harq_pid]=0; - } - if ((num_ack_nak==2) && (sched_ctl->round[CC_idP][harq_pid]<8) && (sched_ctl->tbcnt[CC_idP][harq_pid]==1) && (pdu[0] == 2) && (pdu[1] == 2)) - sched_ctl->round[CC_idP][harq_pid]++; - else if (((num_ack_nak==2) && (sched_ctl->round[CC_idP][harq_pid]<8) && (sched_ctl->tbcnt[0][harq_pid]==2) && (pdu[0] == 1) && (pdu[1] == 2)) || - ((num_ack_nak==2) && (sched_ctl->round[CC_idP][harq_pid]<8) && (sched_ctl->tbcnt[CC_idP][harq_pid]==2) && (pdu[0] == 2) && (pdu[1] == 1))) { - sched_ctl->round[CC_idP][harq_pid]++; - sched_ctl->tbcnt[CC_idP][harq_pid]=1; - } - else if ((num_ack_nak==2) && (sched_ctl->round[CC_idP][harq_pid]<8) && (sched_ctl->tbcnt[CC_idP][harq_pid]==2) && (pdu[0] == 2) && (pdu[1] == 2)) - sched_ctl->round[CC_idP][harq_pid]++; - else AssertFatal(1==0,"Illegal ACK/NAK/round combination (%d,%d,%d,%d,%d) for harq_pid %d, UE %d/%x\n", - num_ack_nak,sched_ctl->round[CC_idP][harq_pid],sched_ctl->round[CC_idP][harq_pid],pdu[0],pdu[1], harq_pid,UE_id, - rnti); - LOG_D(MAC,"AFTER Received PDU[0]:%d:[1]:%d for harq_pid %d [round:%d tbcnt:%d]\n",pdu[0],pdu[1],harq_pid,sched_ctl->round[CC_idP][harq_pid],sched_ctl->tbcnt[CC_idP][harq_pid]); - } - break; - case 1: // FDD Channel Selection (10.1.2.2.1), must be received for 2 serving cells - AssertFatal(numCC==2,"Should not receive harq indication with channel selection with %d active CCs\n", - numCC); - - if ((num_ack_nak == 2) && (sched_ctl->round[pCCid][harq_pid]<8) && (sched_ctl->round[1-pCCid][harq_pid]<8) && (sched_ctl->tbcnt[pCCid][harq_pid]==1) && (sched_ctl->tbcnt[1-pCCid][harq_pid]==1)) { - AssertFatal(pdu[0]<=3,"pdu[0] %d is not ACK/NAK/DTX\n",pdu[0]); - AssertFatal(pdu[1]<=3,"pdu[1] %d is not ACK/NAK/DTX\n",pdu[1]); - if (pdu[0] == 1) sched_ctl->round[pCCid][harq_pid]=8; - else sched_ctl->round[pCCid][harq_pid]++; - if (pdu[1] == 1) sched_ctl->round[1-pCCid][harq_pid]=8; - else sched_ctl->round[1-pCCid][harq_pid]++; - } // A=2 - else if ((num_ack_nak == 3) && (sched_ctl->round[pCCid][harq_pid]<8) && (sched_ctl->tbcnt[pCCid][harq_pid]==2) && (sched_ctl->round[1-pCCid][harq_pid]<8) && (sched_ctl->tbcnt[1-pCCid][harq_pid]==1)) { - AssertFatal(pdu[0]<=3,"pdu[0] %d is not ACK/NAK/DTX\n",pdu[0]); - AssertFatal(pdu[1]<=3,"pdu[1] %d is not ACK/NAK/DTX\n",pdu[1]); - AssertFatal(pdu[2]<=3,"pdu[2] %d is not ACK/NAK/DTX\n",pdu[2]); - AssertFatal(sched_ctl->tbcnt[pCCid][harq_pid] == 2,"sched_ctl->tbcnt[%d][%d] != 2 for UE %d/%x\n",pCCid,harq_pid,UE_id,rnti); - AssertFatal(sched_ctl->tbcnt[1-pCCid][harq_pid] == 1,"sched_ctl->tbcnt[%d][%d] != 1 for UE %d/%x\n",1-pCCid,harq_pid,UE_id,rnti); - if ((pdu[0] == 1) && (pdu[1] == 1)) { // both ACK - sched_ctl->round[pCCid][harq_pid]=8; - sched_ctl->tbcnt[pCCid][harq_pid]=0; - } - else if (((pdu[0] == 2) && (pdu[1] == 1))|| - ((pdu[0] == 1) && (pdu[1] == 2))){ - sched_ctl->round[pCCid][harq_pid]++; - sched_ctl->tbcnt[pCCid][harq_pid]=1; - } - else - sched_ctl->round[pCCid][harq_pid]++; - - if (pdu[2] == 1) sched_ctl->round[1-pCCid][harq_pid]=8; - else sched_ctl->round[1-pCCid][harq_pid]++; - } // A=3 primary cell has 2 TBs - else if ((num_ack_nak == 3) && (sched_ctl->round[1-pCCid][harq_pid]<8) && (sched_ctl->round[pCCid][harq_pid]<8) && (sched_ctl->tbcnt[1-pCCid][harq_pid]==2) && (sched_ctl->tbcnt[pCCid][harq_pid]==1)) { - AssertFatal(pdu[0]<=3,"pdu[0] %d is not ACK/NAK/DTX\n",pdu[0]); - AssertFatal(pdu[1]<=3,"pdu[1] %d is not ACK/NAK/DTX\n",pdu[1]); - AssertFatal(pdu[2]<=3,"pdu[2] %d is not ACK/NAK/DTX\n",pdu[2]); - AssertFatal(sched_ctl->tbcnt[1-pCCid][harq_pid] == 2,"sched_ctl->tbcnt[%d][%d] != 2 for UE %d/%x\n",1-pCCid,harq_pid,UE_id,rnti); - AssertFatal(sched_ctl->tbcnt[pCCid][harq_pid] == 1,"sched_ctl->tbcnt[%d][%d] != 1 for UE %d/%x\n",pCCid,harq_pid,UE_id,rnti); - if ((pdu[0] == 1) && (pdu[1] == 1)) { // both ACK - sched_ctl->round[1-pCCid][harq_pid]=8; - sched_ctl->tbcnt[1-pCCid][harq_pid]=0; - } - else if (((pdu[0] >= 2) && (pdu[1] == 1))|| - ((pdu[0] == 1) && (pdu[1] >= 2))){ // one ACK - sched_ctl->round[1-pCCid][harq_pid]++; - sched_ctl->tbcnt[1-pCCid][harq_pid]=1; - } - else // both NAK/DTX - sched_ctl->round[1-pCCid][harq_pid]++; - - if (pdu[2] == 1) sched_ctl->round[pCCid][harq_pid]=8; - else sched_ctl->round[pCCid][harq_pid]++; - } // A=3 secondary cell has 2 TBs + for (i = 0; i < numCC; i++) + tmode[i] = get_tmode(mod_idP, i, UE_id); + + if (cc->tdd_Config) { + harq_indication_tdd = + (nfapi_harq_indication_tdd_rel13_t *) harq_indication; + // pdu = &harq_indication_tdd->harq_tb_n[0]; + + num_ack_nak = harq_indication_tdd->number_of_ack_nack; + + switch (harq_indication_tdd->mode) { + case 0: // Format 1a/b + AssertFatal(numCC == 1, + "numCC %d > 1, should not be using Format1a/b\n", + numCC); + break; + case 1: // Channel Selection + break; + case 2: // Format 3 + break; + case 3: // Format 4 + break; + case 4: // Format 5 + break; + } + } else { + harq_indication_fdd = + (nfapi_harq_indication_fdd_rel13_t *) harq_indication; + num_ack_nak = harq_indication_fdd->number_of_ack_nack; + pdu = &harq_indication_fdd->harq_tb_n[0]; + + uint8_t harq_pid = ((10 * frameP) + subframeP + 10236) & 7; + + LOG_D(MAC,"frame %d subframe %d harq_pid %d mode %d tmode[0] %d num_ack_nak %d round %d\n",frameP,subframeP,harq_pid,harq_indication_fdd->mode,tmode[0],num_ack_nak,sched_ctl->round[CC_idP][harq_pid]); + + switch (harq_indication_fdd->mode) { + case 0: // Format 1a/b (10.1.2.1) + AssertFatal(numCC == 1, + "numCC %d > 1, should not be using Format1a/b\n", + numCC); + if (tmode[0] == 1 || tmode[0] == 2 || tmode[0] == 5 || tmode[0] == 6 || tmode[0] == 7) { // NOTE: have to handle the case of TM9-10 with 1 antenna port + // single ACK/NAK bit + AssertFatal(num_ack_nak == 1, + "num_ack_nak %d > 1 for 1 CC and single-layer transmission frame:%d subframe:%d\n", + num_ack_nak,frameP,subframeP); + AssertFatal(sched_ctl->round[CC_idP][harq_pid] < 8, + "Got ACK/NAK for inactive harq_pid %d for UE %d/%x\n", + harq_pid, UE_id, rnti); + AssertFatal(pdu[0] == 1 || pdu[0] == 2 + || pdu[0] == 4, + "Received ACK/NAK %d which is not 1 or 2 for harq_pid %d from UE %d/%x\n", + pdu[0], harq_pid, UE_id, rnti); + LOG_D(MAC, "Received %d for harq_pid %d\n", pdu[0], + harq_pid); + + if (pdu[0] == 1) { // ACK + sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + } else if (pdu[0] == 2 || pdu[0] == 4) // NAK (treat DTX as NAK) + sched_ctl->round[CC_idP][harq_pid]++; // increment round + } else { + // one or two ACK/NAK bits + AssertFatal(num_ack_nak > 2, + "num_ack_nak %d > 2 for 1 CC and TM3/4/8/9/10\n", + num_ack_nak); + if ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 1) + && (pdu[0] == 1) && (pdu[1] == 1)) { + sched_ctl->round[CC_idP][harq_pid] = 8; + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + } + if ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 1) + && (pdu[0] == 2) && (pdu[1] == 2)) + sched_ctl->round[CC_idP][harq_pid]++; + else if (((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[0][harq_pid] == 2) + && (pdu[0] == 1) && (pdu[1] == 2)) + || ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 2) + && (pdu[0] == 2) && (pdu[1] == 1))) { + sched_ctl->round[CC_idP][harq_pid]++; + sched_ctl->tbcnt[CC_idP][harq_pid] = 1; + } else if ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 2) + && (pdu[0] == 2) && (pdu[1] == 2)) + sched_ctl->round[CC_idP][harq_pid]++; + else + AssertFatal(1 == 0, + "Illegal ACK/NAK/round combination (%d,%d,%d,%d,%d) for harq_pid %d, UE %d/%x\n", + num_ack_nak, + sched_ctl->round[CC_idP][harq_pid], + sched_ctl->round[CC_idP][harq_pid], pdu[0], + pdu[1], harq_pid, UE_id, rnti); + } + break; + case 1: // FDD Channel Selection (10.1.2.2.1), must be received for 2 serving cells + AssertFatal(numCC == 2, + "Should not receive harq indication with channel selection with %d active CCs\n", + numCC); + + if ((num_ack_nak == 2) + && (sched_ctl->round[pCCid][harq_pid] < 8) + && (sched_ctl->round[1 - pCCid][harq_pid] < 8) + && (sched_ctl->tbcnt[pCCid][harq_pid] == 1) + && (sched_ctl->tbcnt[1 - pCCid][harq_pid] == 1)) { + AssertFatal(pdu[0] <= 3, "pdu[0] %d is not ACK/NAK/DTX\n", + pdu[0]); + AssertFatal(pdu[1] <= 3, "pdu[1] %d is not ACK/NAK/DTX\n", + pdu[1]); + if (pdu[0] == 1) + sched_ctl->round[pCCid][harq_pid] = 8; + else + sched_ctl->round[pCCid][harq_pid]++; + if (pdu[1] == 1) + sched_ctl->round[1 - pCCid][harq_pid] = 8; + else + sched_ctl->round[1 - pCCid][harq_pid]++; + } // A=2 + else if ((num_ack_nak == 3) + && (sched_ctl->round[pCCid][harq_pid] < 8) + && (sched_ctl->tbcnt[pCCid][harq_pid] == 2) + && (sched_ctl->round[1 - pCCid][harq_pid] < 8) + && (sched_ctl->tbcnt[1 - pCCid][harq_pid] == 1)) { + AssertFatal(pdu[0] <= 3, "pdu[0] %d is not ACK/NAK/DTX\n", + pdu[0]); + AssertFatal(pdu[1] <= 3, "pdu[1] %d is not ACK/NAK/DTX\n", + pdu[1]); + AssertFatal(pdu[2] <= 3, "pdu[2] %d is not ACK/NAK/DTX\n", + pdu[2]); + AssertFatal(sched_ctl->tbcnt[pCCid][harq_pid] == 2, + "sched_ctl->tbcnt[%d][%d] != 2 for UE %d/%x\n", + pCCid, harq_pid, UE_id, rnti); + AssertFatal(sched_ctl->tbcnt[1 - pCCid][harq_pid] == 1, + "sched_ctl->tbcnt[%d][%d] != 1 for UE %d/%x\n", + 1 - pCCid, harq_pid, UE_id, rnti); + if ((pdu[0] == 1) && (pdu[1] == 1)) { // both ACK + sched_ctl->round[pCCid][harq_pid] = 8; + sched_ctl->tbcnt[pCCid][harq_pid] = 0; + } else if (((pdu[0] == 2) && (pdu[1] == 1)) || + ((pdu[0] == 1) && (pdu[1] == 2))) { + sched_ctl->round[pCCid][harq_pid]++; + sched_ctl->tbcnt[pCCid][harq_pid] = 1; + } else + sched_ctl->round[pCCid][harq_pid]++; + + if (pdu[2] == 1) + sched_ctl->round[1 - pCCid][harq_pid] = 8; + else + sched_ctl->round[1 - pCCid][harq_pid]++; + } // A=3 primary cell has 2 TBs + else if ((num_ack_nak == 3) + && (sched_ctl->round[1 - pCCid][harq_pid] < 8) + && (sched_ctl->round[pCCid][harq_pid] < 8) + && (sched_ctl->tbcnt[1 - pCCid][harq_pid] == 2) + && (sched_ctl->tbcnt[pCCid][harq_pid] == 1)) { + AssertFatal(pdu[0] <= 3, "pdu[0] %d is not ACK/NAK/DTX\n", + pdu[0]); + AssertFatal(pdu[1] <= 3, "pdu[1] %d is not ACK/NAK/DTX\n", + pdu[1]); + AssertFatal(pdu[2] <= 3, "pdu[2] %d is not ACK/NAK/DTX\n", + pdu[2]); + AssertFatal(sched_ctl->tbcnt[1 - pCCid][harq_pid] == 2, + "sched_ctl->tbcnt[%d][%d] != 2 for UE %d/%x\n", + 1 - pCCid, harq_pid, UE_id, rnti); + AssertFatal(sched_ctl->tbcnt[pCCid][harq_pid] == 1, + "sched_ctl->tbcnt[%d][%d] != 1 for UE %d/%x\n", + pCCid, harq_pid, UE_id, rnti); + if ((pdu[0] == 1) && (pdu[1] == 1)) { // both ACK + sched_ctl->round[1 - pCCid][harq_pid] = 8; + sched_ctl->tbcnt[1 - pCCid][harq_pid] = 0; + } else if (((pdu[0] >= 2) && (pdu[1] == 1)) + || ((pdu[0] == 1) && (pdu[1] >= 2))) { // one ACK + sched_ctl->round[1 - pCCid][harq_pid]++; + sched_ctl->tbcnt[1 - pCCid][harq_pid] = 1; + } else // both NAK/DTX + sched_ctl->round[1 - pCCid][harq_pid]++; + + if (pdu[2] == 1) + sched_ctl->round[pCCid][harq_pid] = 8; + else + sched_ctl->round[pCCid][harq_pid]++; + } // A=3 secondary cell has 2 TBs #if MAX_NUM_CCs>1 - else if ((num_ack_nak == 4) && (sched_ctl->round[0][harq_pid]<8) && (sched_ctl->round[1][harq_pid]<8) && (sched_ctl->tbcnt[1-pCCid][harq_pid]==2) && (sched_ctl->tbcnt[pCCid][harq_pid]==2)) { - AssertFatal(pdu[0]<=3,"pdu[0] %d is not ACK/NAK/DTX\n",pdu[0]); - AssertFatal(pdu[1]<=3,"pdu[1] %d is not ACK/NAK/DTX\n",pdu[1]); - AssertFatal(pdu[2]<=3,"pdu[2] %d is not ACK/NAK/DTX\n",pdu[2]); - AssertFatal(pdu[3]<=3,"pdu[3] %d is not ACK/NAK/DTX\n",pdu[3]); - AssertFatal(sched_ctl->tbcnt[0][harq_pid] == 2,"sched_ctl->tbcnt[0][%d] != 2 for UE %d/%x\n",harq_pid,UE_id,rnti); - AssertFatal(sched_ctl->tbcnt[1][harq_pid] == 2,"sched_ctl->tbcnt[1][%d] != 2 for UE %d/%x\n",harq_pid,UE_id,rnti); - if ((pdu[0] == 1) && (pdu[1] == 1)) { // both ACK - sched_ctl->round[0][harq_pid]=8; - sched_ctl->tbcnt[0][harq_pid]=0; - } - else if (((pdu[0] >= 2) && (pdu[1] == 1))|| - ((pdu[0] == 1) && (pdu[1] >= 2))){ // one ACK - sched_ctl->round[0][harq_pid]++; - sched_ctl->tbcnt[0][harq_pid]=1; - } - else // both NAK/DTX - sched_ctl->round[0][harq_pid]++; - - if ((pdu[2] == 1) && (pdu[3] == 1)) { // both ACK - sched_ctl->round[1][harq_pid]=8; - sched_ctl->tbcnt[1][harq_pid]=0; - } - else if (((pdu[2] >= 2) && (pdu[3] == 1))|| - ((pdu[2] == 1) && (pdu[3] >= 2))){ // one ACK - sched_ctl->round[1][harq_pid]++; - sched_ctl->tbcnt[1][harq_pid]=1; - } - else // both NAK/DTX - sched_ctl->round[1][harq_pid]++; - } // A=4 both serving cells have 2 TBs + else if ((num_ack_nak == 4) + && (sched_ctl->round[0][harq_pid] < 8) + && (sched_ctl->round[1][harq_pid] < 8) + && (sched_ctl->tbcnt[1 - pCCid][harq_pid] == 2) + && (sched_ctl->tbcnt[pCCid][harq_pid] == 2)) { + AssertFatal(pdu[0] <= 3, "pdu[0] %d is not ACK/NAK/DTX\n", + pdu[0]); + AssertFatal(pdu[1] <= 3, "pdu[1] %d is not ACK/NAK/DTX\n", + pdu[1]); + AssertFatal(pdu[2] <= 3, "pdu[2] %d is not ACK/NAK/DTX\n", + pdu[2]); + AssertFatal(pdu[3] <= 3, "pdu[3] %d is not ACK/NAK/DTX\n", + pdu[3]); + AssertFatal(sched_ctl->tbcnt[0][harq_pid] == 2, + "sched_ctl->tbcnt[0][%d] != 2 for UE %d/%x\n", + harq_pid, UE_id, rnti); + AssertFatal(sched_ctl->tbcnt[1][harq_pid] == 2, + "sched_ctl->tbcnt[1][%d] != 2 for UE %d/%x\n", + harq_pid, UE_id, rnti); + if ((pdu[0] == 1) && (pdu[1] == 1)) { // both ACK + sched_ctl->round[0][harq_pid] = 8; + sched_ctl->tbcnt[0][harq_pid] = 0; + } else if (((pdu[0] >= 2) && (pdu[1] == 1)) + || ((pdu[0] == 1) && (pdu[1] >= 2))) { // one ACK + sched_ctl->round[0][harq_pid]++; + sched_ctl->tbcnt[0][harq_pid] = 1; + } else // both NAK/DTX + sched_ctl->round[0][harq_pid]++; + + if ((pdu[2] == 1) && (pdu[3] == 1)) { // both ACK + sched_ctl->round[1][harq_pid] = 8; + sched_ctl->tbcnt[1][harq_pid] = 0; + } else if (((pdu[2] >= 2) && (pdu[3] == 1)) + || ((pdu[2] == 1) && (pdu[3] >= 2))) { // one ACK + sched_ctl->round[1][harq_pid]++; + sched_ctl->tbcnt[1][harq_pid] = 1; + } else // both NAK/DTX + sched_ctl->round[1][harq_pid]++; + } // A=4 both serving cells have 2 TBs #endif - break; - case 2: // Format 3 - AssertFatal(numCC>2,"Should not receive harq indication with FDD format 3 with %d < 3 active CCs\n", - numCC); - for (i=0,j=0;i<numCC;i++) { - if ((sched_ctl->round[i][harq_pid]<8)) { - if (tmode[i]==1 || tmode[i]==2 || tmode[0]==5 || tmode[0]==6 || tmode[0]==7) { - if (pdu[j] == 1) { - sched_ctl->round[i][harq_pid]=8; - sched_ctl->tbcnt[i][harq_pid]=0; - } - else if (pdu[j] == 2) sched_ctl->round[i][harq_pid]++; - else AssertFatal(1==0,"Illegal harq_ack value for CC %d harq_pid %d (%d) UE %d/%x\n", - i,harq_pid,pdu[j],UE_id,rnti); - j++; - } - else if (spatial_bundling == 0) { - if ((sched_ctl->tbcnt[i][harq_pid]==2) && (pdu[j] == 1) && (pdu[j+1]==1)) { - sched_ctl->round[i][harq_pid]=8; - sched_ctl->tbcnt[i][harq_pid]=0; - } - else if ((sched_ctl->tbcnt[i][harq_pid]==2) && (pdu[j] == 1) && (pdu[j+1]==2)) { - sched_ctl->round[i][harq_pid]++; - sched_ctl->tbcnt[i][harq_pid]=1; - } - else if ((sched_ctl->tbcnt[i][harq_pid]==2) && (pdu[j] == 2) && (pdu[j+1]==1)) { - sched_ctl->round[i][harq_pid]++; - sched_ctl->tbcnt[i][harq_pid]=1; - } - else if ((sched_ctl->tbcnt[i][harq_pid]==2) && (pdu[j] == 2) && (pdu[j+1]==2)) { - sched_ctl->round[i][harq_pid]++; - } - else AssertFatal(1==0,"Illegal combination for CC %d harq_pid %d (%d,%d,%d) UE %d/%x\n", - i,harq_pid,sched_ctl->tbcnt[i][harq_pid],pdu[j],pdu[j+1],UE_id,rnti); - j+=2; - } - else if (spatial_bundling == 1) { - if (pdu[j] == 1) { - sched_ctl->round[i][harq_pid]=8; - sched_ctl->tbcnt[i][harq_pid]=0; - } - else if (pdu[j] == 2) { - sched_ctl->round[i][harq_pid]++; - } - else AssertFatal(1==0,"Illegal hack_nak value %d for CC %d harq_pid %d UE %d/%x\n", - pdu[j],i,harq_pid,UE_id,rnti); - j++; - } - else AssertFatal(1==0,"Illegal value for spatial_bundling %d\n",spatial_bundling); - } - } - break; - case 3: // Format 4 - AssertFatal(1==0,"Should not receive harq indication with Format 4\n"); - break; - case 4: // Format 5 - AssertFatal(1==0,"Should not receive harq indication with Format 5\n"); - break; + break; + case 2: // Format 3 + AssertFatal(numCC > 2, + "Should not receive harq indication with FDD format 3 with %d < 3 active CCs\n", + numCC); + for (i = 0, j = 0; i < numCC; i++) { + if ((sched_ctl->round[i][harq_pid] < 8)) { + if (tmode[i] == 1 || tmode[i] == 2 || tmode[0] == 5 + || tmode[0] == 6 || tmode[0] == 7) { + if (pdu[j] == 1) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } else if (pdu[j] == 2) + sched_ctl->round[i][harq_pid]++; + else + AssertFatal(1 == 0, + "Illegal harq_ack value for CC %d harq_pid %d (%d) UE %d/%x\n", + i, harq_pid, pdu[j], UE_id, rnti); + j++; + } else if (spatial_bundling == 0) { + if ((sched_ctl->tbcnt[i][harq_pid] == 2) + && (pdu[j] == 1) && (pdu[j + 1] == 1)) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } else if ((sched_ctl->tbcnt[i][harq_pid] == 2) + && (pdu[j] == 1) && (pdu[j + 1] == 2)) { + sched_ctl->round[i][harq_pid]++; + sched_ctl->tbcnt[i][harq_pid] = 1; + } else if ((sched_ctl->tbcnt[i][harq_pid] == 2) + && (pdu[j] == 2) && (pdu[j + 1] == 1)) { + sched_ctl->round[i][harq_pid]++; + sched_ctl->tbcnt[i][harq_pid] = 1; + } else if ((sched_ctl->tbcnt[i][harq_pid] == 2) + && (pdu[j] == 2) && (pdu[j + 1] == 2)) { + sched_ctl->round[i][harq_pid]++; + } else + AssertFatal(1 == 0, + "Illegal combination for CC %d harq_pid %d (%d,%d,%d) UE %d/%x\n", + i, harq_pid, + sched_ctl->tbcnt[i][harq_pid], + pdu[j], pdu[j + 1], UE_id, rnti); + j += 2; + } else if (spatial_bundling == 1) { + if (pdu[j] == 1) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } else if (pdu[j] == 2) { + sched_ctl->round[i][harq_pid]++; + } else + AssertFatal(1 == 0, + "Illegal hack_nak value %d for CC %d harq_pid %d UE %d/%x\n", + pdu[j], i, harq_pid, UE_id, rnti); + j++; + } else + AssertFatal(1 == 0, + "Illegal value for spatial_bundling %d\n", + spatial_bundling); + } + } + break; + case 3: // Format 4 + AssertFatal(1 == 0, + "Should not receive harq indication with Format 4\n"); + break; + case 4: // Format 5 + AssertFatal(1 == 0, + "Should not receive harq indication with Format 5\n"); + break; + } } - } } -void extract_pucch_csi(module_id_t mod_idP,int CC_idP,int UE_id, frame_t frameP,sub_frame_t subframeP,uint8_t *pdu, uint8_t length) +void +extract_pucch_csi(module_id_t mod_idP, int CC_idP, int UE_id, + frame_t frameP, sub_frame_t subframeP, + uint8_t * pdu, uint8_t length) { - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - COMMON_channels_t *cc=&RC.mac[mod_idP]->common_channels[CC_idP]; - struct CQI_ReportPeriodic *cqi_ReportPeriodic; - int no_pmi; - uint8_t Ltab[6] = {0,2,4,4,4,4}; - uint8_t Jtab[6] = {0,2,2,3,4,4}; - int feedback_cnt; - - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",UE_id); - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->cqi_ReportConfig != NULL,"cqi_ReportConfig is null for UE %d\n",UE_id); - AssertFatal((cqi_ReportPeriodic = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic)!=NULL, - "cqi_ReportPeriodic is null for UE %d\n",UE_id); - - // determine feedback mode - AssertFatal(cqi_ReportPeriodic->present != CQI_ReportPeriodic_PR_NOTHING, - "cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_NOTHING!\n"); - AssertFatal(cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present != CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING, - "cqi_ReportPeriodic->cqi_FormatIndicatorPeriodic.choice.setup.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING!\n"); - - uint16_t Npd,N_OFFSET_CQI; - int H,K,bandwidth_part,L,Lmask; - int ri = sched_ctl->periodic_ri_received[CC_idP]; - - get_csi_params(cc,cqi_ReportPeriodic,&Npd,&N_OFFSET_CQI,&H); - K =(H-1)/Jtab[cc->mib->message.dl_Bandwidth]; - L = Ltab[cc->mib->message.dl_Bandwidth]; - Lmask =L-1; - feedback_cnt = (((frameP*10)+subframeP)/Npd)%H; - - if (feedback_cnt>0) bandwidth_part = (feedback_cnt-1)%K; - else bandwidth_part = 0; - - switch(get_tmode(mod_idP,CC_idP,UE_id)) { - case 1: - case 2: - case 3: - case 7: - no_pmi=1; - break; - case 4: - case 5: - case 6: - no_pmi=0; - break; - default: - // note: need to check TM8-10 without PMI/RI or with 1 antenna port (see Section 5.2.3.3.1 from 36.213) - no_pmi=0; - } - - if ((cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_widebandCQI) || - (feedback_cnt==0)){ - // Note: This implements only Tables: 5.3.3.1-1,5.3.3.1-1A and 5.3.3.1-2 from 36.213 (1,2,4 antenna ports Wideband CQI/PMI) + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; + struct CQI_ReportPeriodic *cqi_ReportPeriodic; + int no_pmi; + uint8_t Ltab[6] = { 0, 2, 4, 4, 4, 4 }; + uint8_t Jtab[6] = { 0, 2, 2, 3, 4, 4 }; + int feedback_cnt; + + AssertFatal(UE_list->UE_template[CC_idP][UE_id]. + physicalConfigDedicated != NULL, + "physicalConfigDedicated is null for UE %d\n", UE_id); + AssertFatal(UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + cqi_ReportConfig != NULL, + "cqi_ReportConfig is null for UE %d\n", UE_id); + AssertFatal((cqi_ReportPeriodic = + UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + cqi_ReportConfig->cqi_ReportPeriodic) != NULL, + "cqi_ReportPeriodic is null for UE %d\n", UE_id); + + // determine feedback mode + AssertFatal(cqi_ReportPeriodic->present != + CQI_ReportPeriodic_PR_NOTHING, + "cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_NOTHING!\n"); + AssertFatal(cqi_ReportPeriodic->choice. + setup.cqi_FormatIndicatorPeriodic.present != + CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING, + "cqi_ReportPeriodic->cqi_FormatIndicatorPeriodic.choice.setup.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING!\n"); + + uint16_t Npd, N_OFFSET_CQI; + int H, K, bandwidth_part, L, Lmask; + int ri = sched_ctl->periodic_ri_received[CC_idP]; + + get_csi_params(cc, cqi_ReportPeriodic, &Npd, &N_OFFSET_CQI, &H); + K = (H - 1) / Jtab[cc->mib->message.dl_Bandwidth]; + L = Ltab[cc->mib->message.dl_Bandwidth]; + Lmask = L - 1; + feedback_cnt = (((frameP * 10) + subframeP) / Npd) % H; + + if (feedback_cnt > 0) + bandwidth_part = (feedback_cnt - 1) % K; + else + bandwidth_part = 0; - if (no_pmi == 1) { // get spatial_diffcqi if needed - sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0]&0xF; - sched_ctl->periodic_wideband_spatial_diffcqi[CC_idP] = (pdu[0]>>4)&7; - } - else if ((cc->p_eNB==2) && (ri==1)) { - // p=2 Rank 1 wideband CQI/PMI 6 bits - sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0]&0xF; - sched_ctl->periodic_wideband_pmi[CC_idP] = (pdu[0]>>4)&3; - } - else if ((cc->p_eNB==2) && (ri>1)) { - // p=2 Rank 2 wideband CQI/PMI 8 bits - sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0]&0xF; - sched_ctl->periodic_wideband_spatial_diffcqi[CC_idP] = (pdu[0]>>4)&7; - sched_ctl->periodic_wideband_pmi[CC_idP] = (pdu[0]>>7)&1; + switch (get_tmode(mod_idP, CC_idP, UE_id)) { + case 1: + case 2: + case 3: + case 7: + no_pmi = 1; + break; + case 4: + case 5: + case 6: + no_pmi = 0; + break; + default: + // note: need to check TM8-10 without PMI/RI or with 1 antenna port (see Section 5.2.3.3.1 from 36.213) + no_pmi = 0; } - else if ((cc->p_eNB==4) && (ri==1)) { - // p=4 Rank 1 wideband CQI/PMI 8 bits - sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0]&0xF; - sched_ctl->periodic_wideband_pmi[CC_idP] = (pdu[0]>>4)&0x0F; + if ((cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic. + present == + CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_widebandCQI) + || (feedback_cnt == 0)) { + // Note: This implements only Tables: 5.3.3.1-1,5.3.3.1-1A and 5.3.3.1-2 from 36.213 (1,2,4 antenna ports Wideband CQI/PMI) + + if (no_pmi == 1) { // get spatial_diffcqi if needed + sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0] & 0xF; + sched_ctl->periodic_wideband_spatial_diffcqi[CC_idP] = + (pdu[0] >> 4) & 7; + } else if ((cc->p_eNB == 2) && (ri == 1)) { + // p=2 Rank 1 wideband CQI/PMI 6 bits + sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0] & 0xF; + sched_ctl->periodic_wideband_pmi[CC_idP] = (pdu[0] >> 4) & 3; + } else if ((cc->p_eNB == 2) && (ri > 1)) { + // p=2 Rank 2 wideband CQI/PMI 8 bits + sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0] & 0xF; + sched_ctl->periodic_wideband_spatial_diffcqi[CC_idP] = + (pdu[0] >> 4) & 7; + sched_ctl->periodic_wideband_pmi[CC_idP] = (pdu[0] >> 7) & 1; + } else if ((cc->p_eNB == 4) && (ri == 1)) { + // p=4 Rank 1 wideband CQI/PMI 8 bits + sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0] & 0xF; + sched_ctl->periodic_wideband_pmi[CC_idP] = + (pdu[0] >> 4) & 0x0F; + + } else if ((cc->p_eNB == 4) && (ri > 1)) { + // p=4 Rank 2 wideband CQI/PMI 11 bits + sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0] & 0xF; + sched_ctl->periodic_wideband_spatial_diffcqi[CC_idP] = + (pdu[0] >> 4) & 7; + sched_ctl->periodic_wideband_pmi[CC_idP] = (pdu[0] >> 7) & 0xF; + } else + AssertFatal(1 == 0, + "illegal combination p %d, ri %d, no_pmi %d\n", + cc->p_eNB, ri, no_pmi); + } else if (cqi_ReportPeriodic->choice. + setup.cqi_FormatIndicatorPeriodic.present == + CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) + { + // This is Table 5.2.3.3.2-2 for 36.213 + if (ri == 1) { + //4+Ltab[cc->mib->message.dl_Bandwidth] bits + sched_ctl->periodic_subband_cqi[CC_idP][(bandwidth_part * L) + + ((pdu[0] >> 4) & + Lmask)] = + pdu[0] & 0xF; + } else if (ri > 1) { + //7+Ltab[cc->mib->message.dl_Bandwidth] bits; + sched_ctl-> + periodic_subband_spatial_diffcqi[CC_idP][(bandwidth_part * + L) + + ((pdu[0] >> 7) & + Lmask)] = + (pdu[0] >> 4) & 7; + sched_ctl->periodic_subband_cqi[CC_idP][(bandwidth_part * L) + + ((pdu[0] >> 7) & + Lmask)] = + pdu[0] & 0xF; + } } - else if ((cc->p_eNB==4) && (ri>1)) { - // p=4 Rank 2 wideband CQI/PMI 11 bits - sched_ctl->periodic_wideband_cqi[CC_idP] = pdu[0]&0xF; - sched_ctl->periodic_wideband_spatial_diffcqi[CC_idP] = (pdu[0]>>4)&7; - sched_ctl->periodic_wideband_pmi[CC_idP] = (pdu[0]>>7)&0xF; - } - else AssertFatal(1==0,"illegal combination p %d, ri %d, no_pmi %d\n",cc->p_eNB,ri,no_pmi); - } - else if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) { - // This is Table 5.2.3.3.2-2 for 36.213 - if (ri==1) { - //4+Ltab[cc->mib->message.dl_Bandwidth] bits - sched_ctl->periodic_subband_cqi[CC_idP][(bandwidth_part*L)+((pdu[0]>>4)&Lmask)] = pdu[0]&0xF; - } - else if (ri>1) { - //7+Ltab[cc->mib->message.dl_Bandwidth] bits; - sched_ctl->periodic_subband_spatial_diffcqi[CC_idP][(bandwidth_part*L)+((pdu[0]>>7)&Lmask)] = (pdu[0]>>4)&7; - sched_ctl->periodic_subband_cqi[CC_idP][(bandwidth_part*L)+((pdu[0]>>7)&Lmask)] = pdu[0]&0xF; - } - } } -void extract_pusch_csi(module_id_t mod_idP,int CC_idP,int UE_id, frame_t frameP,sub_frame_t subframeP,uint8_t *pdu, uint8_t length) -{ - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; - UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - int Ntab[6] = {0,4,7,9,10,13}; - int Ntab_uesel[6] = {0,8,13,17,19,25}; - int Ltab_uesel[6] = {0,6,9,13,15,18}; - int Mtab_uesel[6] = {0,1,3,5,6,6}; - int v[6]; - int i; - uint64_t p = *(uint64_t*)pdu; - int curbyte, curbit; - CQI_ReportModeAperiodic_t *cqi_ReportModeAperiodic; - - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",UE_id); - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->cqi_ReportConfig != NULL,"cqi_ReportConfig is null for UE %d\n",UE_id); - AssertFatal((cqi_ReportModeAperiodic = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic)!=NULL, - "cqi_ReportModeAperiodic is null for UE %d\n",UE_id); - - int N = Ntab[cc->mib->message.dl_Bandwidth]; - int tmode = get_tmode(mod_idP,CC_idP,UE_id); - int ri = sched_ctl->aperiodic_ri_received[CC_idP]; - int r,diffcqi0=0,diffcqi1=0,pmi_uesel=0; - int bw = cc->mib->message.dl_Bandwidth; - int m; - - switch(*cqi_ReportModeAperiodic) { - case CQI_ReportModeAperiodic_rm12: - AssertFatal(0==1, "to be fixed, don't use p but pdu directly\n"); - // wideband multiple PMI (TM4/6), Table 5.2.2.6.1-1 (for TM4/6) - AssertFatal(tmode==4 || tmode==6 || tmode==8|| tmode==9 || tmode==10,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm12\n",tmode); - if (tmode <= 6) { //Table 5.2.2.6.1-1 36.213 - if ((ri==1) && (cc->p_eNB==2)) { - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x03); - p>>=2; - } - } - if ((ri==2) && (cc->p_eNB==2)) { - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - sched_ctl->aperiodic_wideband_cqi1[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x01); - p>>=1; - } - } - if ((ri==1) && (cc->p_eNB==4)) { - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x03); - p>>=4; - } - } - if ((ri==2) && (cc->p_eNB==4)) { - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - sched_ctl->aperiodic_wideband_cqi1[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x01); - p>>=4; - } - } - } // if (tmode <= 6) { //Table 5.2.2.6.1-1 36.213 - else { - AssertFatal(1==0,"support for TM 8-10 to be done\n"); +void +extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, + frame_t frameP, sub_frame_t subframeP, + uint8_t * pdu, uint8_t length) +{ + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; + UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + int Ntab[6] = { 0, 4, 7, 9, 10, 13 }; + int Ntab_uesel[6] = { 0, 8, 13, 17, 19, 25 }; + int Ltab_uesel[6] = { 0, 6, 9, 13, 15, 18 }; + int Mtab_uesel[6] = { 0, 1, 3, 5, 6, 6 }; + int v[6]; + int i; + uint64_t p = *(uint64_t *) pdu; + int curbyte, curbit; + CQI_ReportModeAperiodic_t *cqi_ReportModeAperiodic; + + AssertFatal(UE_list->UE_template[CC_idP][UE_id]. + physicalConfigDedicated != NULL, + "physicalConfigDedicated is null for UE %d\n", UE_id); + AssertFatal(UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + cqi_ReportConfig != NULL, + "cqi_ReportConfig is null for UE %d\n", UE_id); + AssertFatal((cqi_ReportModeAperiodic = + UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + cqi_ReportConfig->cqi_ReportModeAperiodic) != NULL, + "cqi_ReportModeAperiodic is null for UE %d\n", UE_id); + + int N = Ntab[cc->mib->message.dl_Bandwidth]; + int tmode = get_tmode(mod_idP, CC_idP, UE_id); + int ri = sched_ctl->aperiodic_ri_received[CC_idP]; + int r, diffcqi0 = 0, diffcqi1 = 0, pmi_uesel = 0; + int bw = cc->mib->message.dl_Bandwidth; + int m; + + switch (*cqi_ReportModeAperiodic) { + case CQI_ReportModeAperiodic_rm12: + AssertFatal(0 == 1, "to be fixed, don't use p but pdu directly\n"); + // wideband multiple PMI (TM4/6), Table 5.2.2.6.1-1 (for TM4/6) + AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm12\n", + tmode); + if (tmode <= 6) { //Table 5.2.2.6.1-1 36.213 + if ((ri == 1) && (cc->p_eNB == 2)) { + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x03); + p >>= 2; + } + } + if ((ri == 2) && (cc->p_eNB == 2)) { + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + sched_ctl->aperiodic_wideband_cqi1[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x01); + p >>= 1; + } + } + if ((ri == 1) && (cc->p_eNB == 4)) { + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x03); + p >>= 4; + } + } + if ((ri == 2) && (cc->p_eNB == 4)) { + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + sched_ctl->aperiodic_wideband_cqi1[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x01); + p >>= 4; + } + } + } // if (tmode <= 6) { //Table 5.2.2.6.1-1 36.213 + else { + AssertFatal(1 == 0, "support for TM 8-10 to be done\n"); + } + + break; + case CQI_ReportModeAperiodic_rm20: + AssertFatal(0 == 1, "to be fixed, don't use p but pdu directly\n"); + // UE-selected subband CQI no PMI (TM1/2/3/7) , Table 5.2.2.6.3-1 from 36.213 + AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 + || tmode == 7, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm20\n", + tmode); + + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t) (p & 0x0F); + p >>= 4; + diffcqi0 = (uint8_t) (p & 0x03); + p >>= 2; + r = (uint8_t) (p & ((1 >> Ltab_uesel[bw]) - 1)); + reverse_index(Ntab_uesel[bw], Mtab_uesel[bw], r, v); + for (m = 0; m < Mtab_uesel[bw]; m++) + sched_ctl->aperiodic_subband_diffcqi0[CC_idP][v[m]] = diffcqi0; + break; + case CQI_ReportModeAperiodic_rm22: + AssertFatal(0 == 1, "to be fixed, don't use p but pdu directly\n"); + // UE-selected subband CQI multiple PMI (TM4/6) Table 5.2.2.6.3-2 from 36.213 + + AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 + || tmode == 10, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm22\n", + tmode); + + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t) (p & 0x0F); + p >>= 4; + diffcqi0 = (uint8_t) (p & 0x03); + p >>= 2; + + if (ri > 1) { + sched_ctl->aperiodic_wideband_cqi1[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + diffcqi1 = (uint8_t) (p & 0x03); + p >>= 2; + } + r = (uint8_t) (p & ((1 >> Ltab_uesel[bw]) - 1)); + p >>= Ltab_uesel[bw]; + reverse_index(Ntab_uesel[bw], Mtab_uesel[bw], r, v); + if ((ri == 1) && (cc->p_eNB == 2)) { + pmi_uesel = p & 0x3; + p >>= 2; + sched_ctl->aperiodic_wideband_pmi[CC_idP] = p & 0x3; + } else if ((ri == 2) && (cc->p_eNB == 2)) { + pmi_uesel = p & 0x1; + p >>= 1; + sched_ctl->aperiodic_wideband_pmi[CC_idP] = p & 0x1; + } else if (cc->p_eNB == 4) { + pmi_uesel = p & 0x0F; + p >>= 4; + sched_ctl->aperiodic_wideband_pmi[CC_idP] = p & 0x0F; + } + for (m = 0; m < Mtab_uesel[bw]; m++) { + sched_ctl->aperiodic_subband_diffcqi0[CC_idP][v[m]] = diffcqi0; + if (ri > 1) + sched_ctl->aperiodic_subband_diffcqi1[CC_idP][v[m]] = + diffcqi1; + sched_ctl->aperiodic_subband_pmi[CC_idP][v[m]] = pmi_uesel; + } + break; + case CQI_ReportModeAperiodic_rm30: + //subband CQI no PMI (TM1/2/3/7) + AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 + || tmode == 7, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm30\n", + tmode); + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = pdu[0] >> 4; + curbyte = 0; + curbit = 3; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_diffcqi0[CC_idP][i] = + (pdu[curbyte] >> (curbit - 1)) & 0x03; + curbit -= 2; + if (curbit < 0) { + curbit = 7; + curbyte++; + } + } + sched_ctl->dl_cqi[CC_idP] = + sched_ctl->aperiodic_wideband_cqi0[CC_idP]; + break; + case CQI_ReportModeAperiodic_rm31: + AssertFatal(0 == 1, "to be fixed, don't use p but pdu directly\n"); + //subband CQI single PMI (TM4/5/6) + AssertFatal(tmode == 4 || tmode == 5 || tmode == 6 || tmode == 8 + || tmode == 9 + || tmode == 10, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm31\n", + tmode); + + if ((ri == 1) && (cc->p_eNB == 2)) { + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_diffcqi0[CC_idP][i] = + (uint8_t) (p & 0x03); + p >>= 2; + } + sched_ctl->aperiodic_wideband_pmi[CC_idP] = p & 0x03; + } + if ((ri == 2) && (cc->p_eNB == 2)) { + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x01); + p >>= 1; + } + sched_ctl->aperiodic_wideband_cqi1[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x01); + p >>= 1; + } + sched_ctl->aperiodic_wideband_pmi[CC_idP] = p & 0x01; + } + if ((ri == 1) && (cc->p_eNB == 4)) { + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_diffcqi0[CC_idP][i] = + (uint8_t) (p & 0x03); + p >>= 2; + } + sched_ctl->aperiodic_wideband_pmi[CC_idP] = p & 0x0F; + } + if ((ri > 1) && (cc->p_eNB == 4)) { // Note : 64 bits for 20 MHz + sched_ctl->aperiodic_wideband_cqi0[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x01); + p >>= 1; + } + sched_ctl->aperiodic_wideband_cqi1[CC_idP] = + (uint8_t) (p & 0x0F); + p >>= 4; + for (i = 0; i < N; i++) { + sched_ctl->aperiodic_subband_pmi[CC_idP][i] = + (uint8_t) (p & 0x01); + p >>= 2; + } + sched_ctl->aperiodic_wideband_pmi[CC_idP] = p & 0x0F; + } + + break; + case CQI_ReportModeAperiodic_rm32_v1250: + AssertFatal(tmode == 4 || tmode == 5 || tmode == 6 || tmode == 8 + || tmode == 9 + || tmode == 10, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm32\n", + tmode); + AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm32 to be done\n"); + break; + case CQI_ReportModeAperiodic_rm10_v1310: + AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 + || tmode == 7, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm10\n", + tmode); + AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm10 to be done\n"); + break; + case CQI_ReportModeAperiodic_rm11_v1310: + AssertFatal(tmode == 4 || tmode == 5 || tmode == 6 || tmode == 8 + || tmode == 9 + || tmode == 10, + "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm11\n", + tmode); + AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm11 to be done\n"); + break; } +} - break; - case CQI_ReportModeAperiodic_rm20: - AssertFatal(0==1, "to be fixed, don't use p but pdu directly\n"); - // UE-selected subband CQI no PMI (TM1/2/3/7) , Table 5.2.2.6.3-1 from 36.213 - AssertFatal(tmode==1 || tmode==2 || tmode==3 || tmode==7,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm20\n",tmode); - - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - diffcqi0 = (uint8_t)(p&0x03); p>>=2; - r = (uint8_t)(p&((1>>Ltab_uesel[bw])-1)); - reverse_index(Ntab_uesel[bw],Mtab_uesel[bw],r,v); - for (m=0;m<Mtab_uesel[bw];m++) sched_ctl->aperiodic_subband_diffcqi0[CC_idP][v[m]] = diffcqi0; - break; - case CQI_ReportModeAperiodic_rm22: - AssertFatal(0==1, "to be fixed, don't use p but pdu directly\n"); - // UE-selected subband CQI multiple PMI (TM4/6) Table 5.2.2.6.3-2 from 36.213 - - AssertFatal(tmode==4 || tmode==6 || tmode==8|| tmode==9 || tmode==10,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm22\n",tmode); - - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - diffcqi0 = (uint8_t)(p&0x03); p>>=2; - - if (ri>1) { - sched_ctl->aperiodic_wideband_cqi1[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - diffcqi1 = (uint8_t)(p&0x03); p>>=2; - } - r = (uint8_t)(p&((1>>Ltab_uesel[bw])-1)); p>>=Ltab_uesel[bw]; - reverse_index(Ntab_uesel[bw],Mtab_uesel[bw],r,v); - if ((ri==1)&&(cc->p_eNB==2)) { - pmi_uesel = p&0x3; p>>=2; - sched_ctl->aperiodic_wideband_pmi[CC_idP] = p&0x3; - } - else if ((ri==2)&&(cc->p_eNB==2)) { - pmi_uesel = p&0x1; p>>=1; - sched_ctl->aperiodic_wideband_pmi[CC_idP] = p&0x1; - } - else if (cc->p_eNB==4) { - pmi_uesel = p&0x0F; p>>=4; - sched_ctl->aperiodic_wideband_pmi[CC_idP] = p&0x0F; - } - for (m=0;m<Mtab_uesel[bw];m++) { - sched_ctl->aperiodic_subband_diffcqi0[CC_idP][v[m]] = diffcqi0; - if (ri>1) sched_ctl->aperiodic_subband_diffcqi1[CC_idP][v[m]] = diffcqi1; - sched_ctl->aperiodic_subband_pmi[CC_idP][v[m]] = pmi_uesel; - } - break; - case CQI_ReportModeAperiodic_rm30: - //subband CQI no PMI (TM1/2/3/7) - AssertFatal(tmode==1 || tmode==2 || tmode==3 || tmode==7,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm30\n",tmode); - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = pdu[0]>>4; - curbyte = 0; - curbit = 3; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_diffcqi0[CC_idP][i] = (pdu[curbyte] >> (curbit-1)) & 0x03; - curbit -= 2; - if (curbit < 0) { - curbit = 7; - curbyte++; - } - } - sched_ctl->dl_cqi[CC_idP] = sched_ctl->aperiodic_wideband_cqi0[CC_idP]; - break; - case CQI_ReportModeAperiodic_rm31: - AssertFatal(0==1, "to be fixed, don't use p but pdu directly\n"); - //subband CQI single PMI (TM4/5/6) - AssertFatal(tmode==4 || tmode==5 || tmode==6 || tmode==8|| tmode==9|| tmode==10,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm31\n",tmode); - - if ((ri==1) && (cc->p_eNB==2)) { - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_diffcqi0[CC_idP][i] = (uint8_t)(p&0x03); - p>>=2; - } - sched_ctl->aperiodic_wideband_pmi[CC_idP] = p&0x03; - } - if ((ri==2) && (cc->p_eNB==2)) { - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x01); - p>>=1; - } - sched_ctl->aperiodic_wideband_cqi1[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x01); - p>>=1; - } - sched_ctl->aperiodic_wideband_pmi[CC_idP] = p&0x01; - } - if ((ri==1) && (cc->p_eNB==4)) { - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_diffcqi0[CC_idP][i] = (uint8_t)(p&0x03); - p>>=2; - } - sched_ctl->aperiodic_wideband_pmi[CC_idP] = p&0x0F; - } - if ((ri>1) && (cc->p_eNB==4)) { // Note : 64 bits for 20 MHz - sched_ctl->aperiodic_wideband_cqi0[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x01); - p>>=1; - } - sched_ctl->aperiodic_wideband_cqi1[CC_idP] = (uint8_t)(p&0x0F); p>>=4; - for (i=0;i<N;i++) { - sched_ctl->aperiodic_subband_pmi[CC_idP][i] = (uint8_t)(p&0x01); - p>>=2; - } - sched_ctl->aperiodic_wideband_pmi[CC_idP] = p&0x0F; +void +cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, + sub_frame_t subframeP, rnti_t rntiP, + nfapi_cqi_indication_rel9_t * rel9, uint8_t * pdu, + nfapi_ul_cqi_information_t * ul_cqi_information) +{ + int UE_id = find_UE_id(mod_idP, rntiP); + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + if (UE_id == -1) { + LOG_W(MAC, "cqi_indication: UE %x not found\n", rntiP); + return; } + UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - break; - case CQI_ReportModeAperiodic_rm32_v1250: - AssertFatal(tmode==4 || tmode==5 || tmode==6 || tmode==8|| tmode==9|| tmode==10,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm32\n",tmode); - AssertFatal(1==0,"CQI_ReportModeAperiodic_rm32 to be done\n"); - break; - case CQI_ReportModeAperiodic_rm10_v1310: - AssertFatal(tmode==1 || tmode==2 || tmode==3 || tmode==7,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm10\n",tmode); - AssertFatal(1==0,"CQI_ReportModeAperiodic_rm10 to be done\n"); - break; - case CQI_ReportModeAperiodic_rm11_v1310: - AssertFatal(tmode==4 || tmode==5 || tmode==6 || tmode==8|| tmode==9|| tmode==10,"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm11\n",tmode); - AssertFatal(1==0,"CQI_ReportModeAperiodic_rm11 to be done\n"); - break; - } -} + if (UE_id >= 0) { -void cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, rnti_t rntiP, - nfapi_cqi_indication_rel9_t *rel9,uint8_t *pdu, - nfapi_ul_cqi_information_t *ul_cqi_information) -{ - int UE_id = find_UE_id(mod_idP, rntiP); - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - if (UE_id == -1) { - LOG_W(MAC, "cqi_indication: UE %x not found\n", rntiP); - return; - } - UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + LOG_D(MAC,"%s() UE_id:%d channel:%d cqi:%d\n", __FUNCTION__, UE_id, ul_cqi_information->channel, ul_cqi_information->ul_cqi); - if (UE_id >= 0) { + if (ul_cqi_information->channel == 0) { // PUCCH - if (ul_cqi_information->channel == 0) { // PUCCH + // extract pucch csi information before changing RI information + extract_pucch_csi(mod_idP, CC_idP, UE_id, frameP, subframeP, + pdu, rel9->length); - // extract pucch csi information before changing RI information - extract_pucch_csi(mod_idP,CC_idP,UE_id,frameP,subframeP,pdu,rel9->length); + memcpy((void *) sched_ctl->periodic_ri_received, + (void *) rel9->ri, rel9->number_of_cc_reported); - memcpy((void*)sched_ctl->periodic_ri_received, - (void*)rel9->ri, - rel9->number_of_cc_reported); + // SNR for PUCCH2 + sched_ctl->pucch2_snr[CC_idP] = ul_cqi_information->ul_cqi; + } else { //PUSCH + memcpy((void *) sched_ctl->aperiodic_ri_received, + (void *) rel9->ri, rel9->number_of_cc_reported); - // SNR for PUCCH2 - sched_ctl->pucch2_snr[CC_idP] = ul_cqi_information->ul_cqi; - } - else { //PUSCH - memcpy((void*)sched_ctl->aperiodic_ri_received, - (void*)rel9->ri, - rel9->number_of_cc_reported); + extract_pusch_csi(mod_idP, CC_idP, UE_id, frameP, subframeP, + pdu, rel9->length); - extract_pusch_csi(mod_idP,CC_idP,UE_id,frameP,subframeP,pdu,rel9->length); + } + // timing advance + sched_ctl->timing_advance = rel9->timing_advance; + sched_ctl->timing_advance_r9 = rel9->timing_advance_r9; } - - // timing advance - sched_ctl->timing_advance = rel9->timing_advance; - sched_ctl->timing_advance_r9 = rel9->timing_advance_r9; - } } -void SR_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, sub_frame_t subframeP, rnti_t rntiP, uint8_t ul_cqi) +void +SR_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, + sub_frame_t subframeP, rnti_t rntiP, uint8_t ul_cqi) { - T(T_ENB_MAC_SCHEDULING_REQUEST, T_INT(mod_idP), T_INT(cc_idP), T_INT(frameP), T_INT(subframeP), T_INT(rntiP)); + T(T_ENB_MAC_SCHEDULING_REQUEST, T_INT(mod_idP), T_INT(cc_idP), + T_INT(frameP), T_INT(subframeP), T_INT(rntiP)); - int UE_id = find_UE_id(mod_idP, rntiP); - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + int UE_id = find_UE_id(mod_idP, rntiP); + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - LOG_D(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d on CC_id %d\n",mod_idP,rntiP,frameP,subframeP,UE_id,cc_idP); - - if (UE_id != -1) { - //if (mac_eNB_get_rrc_status(mod_idP,UE_RNTI(mod_idP,UE_id)) < RRC_CONNECTED) - //LOG_D(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d on CC_id %d\n",mod_idP,rntiP,frameP,subframeP,UE_id,cc_idP); + if (UE_id != -1) { + if (mac_eNB_get_rrc_status(mod_idP, UE_RNTI(mod_idP, UE_id)) < + RRC_CONNECTED) + LOG_D(MAC, + "[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d on CC_id %d\n", + mod_idP, rntiP, frameP, subframeP, UE_id, cc_idP); #if 0 - UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - /* for the moment don't use ul_cqi from SR, value is too different from harq */ - sched_ctl->pucch1_snr[cc_idP] = ul_cqi; - sched_ctl->pucch1_cqi_update[cc_idP] = 1; + /* for the moment don't use ul_cqi from SR, value is too different from harq */ + sched_ctl->pucch1_snr[cc_idP] = ul_cqi; + sched_ctl->pucch1_cqi_update[cc_idP] = 1; #endif - UE_list->UE_template[cc_idP][UE_id].ul_SR = 1; - UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION,1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION,0); - } else { - // AssertFatal(0, "find_UE_id(%u,rnti %d) not found", enb_mod_idP, rntiP); - // AssertError(0, 0, "Frame %d: find_UE_id(%u,rnti %d) not found\n", frameP, enb_mod_idP, rntiP); - LOG_D(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d (unknown UEid) on CC_id %d\n",mod_idP,rntiP,frameP,subframeP, UE_id,cc_idP); - } + UE_list->UE_template[cc_idP][UE_id].ul_SR = 1; + UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION, 1); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION, 0); + } else { + // AssertFatal(0, "find_UE_id(%u,rnti %d) not found", enb_mod_idP, rntiP); + // AssertError(0, 0, "Frame %d: find_UE_id(%u,rnti %d) not found\n", frameP, enb_mod_idP, rntiP); + LOG_D(MAC, + "[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d (unknown UEid) on CC_id %d\n", + mod_idP, rntiP, frameP, subframeP, UE_id, cc_idP); + } } -void UL_failure_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, rnti_t rntiP, sub_frame_t subframeP) +void +UL_failure_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, + rnti_t rntiP, sub_frame_t subframeP) { - int UE_id = find_UE_id(mod_idP, rntiP); - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - - if (UE_id != -1) { - LOG_D(MAC,"[eNB %d][UE %d/%x] Frame %d subframeP %d Signaling UL Failure for UE %d on CC_id %d (timer %d)\n", - mod_idP,UE_id,rntiP,frameP,subframeP, UE_id,cc_idP, - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0) - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=1; - } else { - // AssertFatal(0, "find_UE_id(%u,rnti %d) not found", enb_mod_idP, rntiP); - // AssertError(0, 0, "Frame %d: find_UE_id(%u,rnti %d) not found\n", frameP, enb_mod_idP, rntiP); - LOG_W(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling UL Failure for UE %d (unknown UEid) on CC_id %d\n",mod_idP,rntiP,frameP,subframeP, UE_id,cc_idP); - } + int UE_id = find_UE_id(mod_idP, rntiP); + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + + if (UE_id != -1) { + LOG_D(MAC, + "[eNB %d][UE %d/%x] Frame %d subframeP %d Signaling UL Failure for UE %d on CC_id %d (timer %d)\n", + mod_idP, UE_id, rntiP, frameP, subframeP, UE_id, cc_idP, + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); + if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0) + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; + } else { + // AssertFatal(0, "find_UE_id(%u,rnti %d) not found", enb_mod_idP, rntiP); + // AssertError(0, 0, "Frame %d: find_UE_id(%u,rnti %d) not found\n", frameP, enb_mod_idP, rntiP); + LOG_W(MAC, + "[eNB %d][SR %x] Frame %d subframeP %d Signaling UL Failure for UE %d (unknown UEid) on CC_id %d\n", + mod_idP, rntiP, frameP, subframeP, UE_id, cc_idP); + } } -void harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, nfapi_harq_indication_pdu_t *harq_pdu) +void +harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, + sub_frame_t subframeP, + nfapi_harq_indication_pdu_t * harq_pdu) { - rnti_t rnti = harq_pdu->rx_ue_information.rnti; - uint8_t ul_cqi = harq_pdu->ul_cqi_information.ul_cqi; - uint8_t channel = harq_pdu->ul_cqi_information.channel; - int UE_id = find_UE_id(mod_idP, rnti); - if (UE_id == -1) { - LOG_W(MAC, "harq_indication: UE %x not found\n", rnti); - return; - } - UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; + rnti_t rnti = harq_pdu->rx_ue_information.rnti; + uint8_t ul_cqi = harq_pdu->ul_cqi_information.ul_cqi; + uint8_t channel = harq_pdu->ul_cqi_information.channel; + int UE_id = find_UE_id(mod_idP, rnti); + if (UE_id == -1) { + LOG_W(MAC, "harq_indication: UE %x not found\n", rnti); + return; + } + UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; // extract HARQ Information - LOG_D(MAC,"Frame %d, subframe %d: Received harq indication (%d) from UE %d/%x, ul_cqi %d\n",frameP,subframeP,channel,UE_id,rnti,ul_cqi); - if (cc->tdd_Config) extract_harq(mod_idP,CC_idP,UE_id,frameP,subframeP,(void*)&harq_pdu->harq_indication_tdd_rel13,channel); - else extract_harq(mod_idP,CC_idP,UE_id,frameP,subframeP,(void*)&harq_pdu->harq_indication_fdd_rel13,channel); - if (channel == 0) { - sched_ctl->pucch1_snr[CC_idP] = ul_cqi; - sched_ctl->pucch1_cqi_update[CC_idP] = 1; - } + LOG_D(MAC, + "Frame %d, subframe %d: Received harq indication (%d) from UE %d/%x, ul_cqi %d\n", + frameP, subframeP, channel, UE_id, rnti, ul_cqi); + if (cc->tdd_Config) + extract_harq(mod_idP, CC_idP, UE_id, frameP, subframeP, + (void *) &harq_pdu->harq_indication_tdd_rel13, + channel); + else + extract_harq(mod_idP, CC_idP, UE_id, frameP, subframeP, + (void *) &harq_pdu->harq_indication_fdd_rel13, + channel); + if (channel == 0) { + sched_ctl->pucch1_snr[CC_idP] = ul_cqi; + sched_ctl->pucch1_cqi_update[CC_idP] = 1; + } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 4afd40e27b1dee0add0a832b8df47f5e4ebece53..2de2a6729637d1dcd3c48ddb8612dc90cab3e33e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -29,6 +29,8 @@ */ +/* indented with: indent -kr eNB_scheduler_RA.c */ + #include "assertions.h" #include "PHY/defs.h" #include "PHY/extern.h" @@ -52,7 +54,7 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif #include "T.h" @@ -60,667 +62,853 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 -extern void add_msg3(module_id_t module_idP,int CC_id, RA_TEMPLATE *RA_template, frame_t frameP, sub_frame_t subframeP); extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); extern uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset); extern int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req); +extern uint8_t nfapi_mode; + +extern uint8_t nfapi_mode; // This table holds the allowable PRB sizes for ULSCH transmissions -uint8_t rb_table[34] = {1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,64,72,75,80,81,90,96,100}; - -void rx_sdu(const module_id_t enb_mod_idP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP, - uint8_t *sduP, - const uint16_t sdu_lenP, - const uint16_t timing_advance, - const uint8_t ul_cqi) +uint8_t rb_table[34] = + { 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, + 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100 +}; + +void +rx_sdu(const module_id_t enb_mod_idP, + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP, + uint8_t * sduP, + const uint16_t sdu_lenP, + const uint16_t timing_advance, const uint8_t ul_cqi) { - int current_rnti = rntiP; - unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; - unsigned char rx_lcids[NB_RB_MAX]; - unsigned short rx_lengths[NB_RB_MAX]; - int UE_id = find_UE_id(enb_mod_idP, current_rnti); - int RA_id; - int ii,j; - eNB_MAC_INST *eNB = RC.mac[enb_mod_idP]; - int harq_pid = subframe2harqpid(&eNB->common_channels[CC_idP],frameP,subframeP); - - UE_list_t *UE_list= &eNB->UE_list; - int crnti_rx=0; - int old_buffer_info; - RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&RC.mac[enb_mod_idP]->common_channels[CC_idP].RA_template[0]; - int first_rb = 0; - - start_meas(&eNB->rx_ulsch_sdu); - - LOG_D(PHY,"%s() rntiP:%04x UE_id:%d harq_pid:%d\n", __FUNCTION__, rntiP, UE_id, harq_pid); - - if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1) ) - for(ii=0; ii<NB_RB_MAX; ii++) { - rx_lengths[ii] = 0; + int current_rnti = rntiP; + unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr; + unsigned char rx_lcids[NB_RB_MAX]; + unsigned short rx_lengths[NB_RB_MAX]; + int UE_id = find_UE_id(enb_mod_idP, current_rnti); + int RA_id; + int ii, j; + eNB_MAC_INST *mac = RC.mac[enb_mod_idP]; + int harq_pid = + subframe2harqpid(&mac->common_channels[CC_idP], frameP, subframeP); + + UE_list_t *UE_list = &mac->UE_list; + int crnti_rx = 0; + int old_buffer_info; + RA_t *ra = + (RA_t *) & RC.mac[enb_mod_idP]->common_channels[CC_idP].ra[0]; + int first_rb = 0; + + start_meas(&mac->rx_ulsch_sdu); + + if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1)) + for (ii = 0; ii < NB_RB_MAX; ii++) { + rx_lengths[ii] = 0; + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1); + if (opt_enabled == 1) { + trace_pdu(0, sduP, sdu_lenP, 0, 3, current_rnti, frameP, subframeP, + 0, 0); + LOG_D(OPT, "[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", + enb_mod_idP, frameP, current_rnti, sdu_lenP); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,1); - if (opt_enabled == 1) { - trace_pdu(0, sduP,sdu_lenP, 0, 3, current_rnti, frameP, subframeP, 0,0); - LOG_D(OPT,"[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", - enb_mod_idP, frameP, current_rnti, sdu_lenP); - } - - if (UE_id!=-1) { - LOG_D(MAC,"[eNB %d][PUSCH %d] CC_id %d Received ULSCH sdu(%p) round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n",enb_mod_idP,harq_pid,CC_idP,sduP,UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], - current_rnti, UE_id,ul_cqi); - - AssertFatal(UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] < 8, - "round >= 8\n"); - if (sduP!=NULL) { - UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; - UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pid)); - /* Update with smoothing: 3/4 of old value and 1/4 of new. - * This is the logic that was done in the function - * lte_est_timing_advance_pusch, maybe it's not necessary? - * maybe it's even not correct at all? - */ - UE_list->UE_sched_ctrl[UE_id].ta_update = - (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance)/4; - UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; - UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0; - first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; - - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0; - mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,UE_RNTI(enb_mod_idP,UE_id)); - } - } - else { // we've got an error - LOG_D(MAC,"[eNB %d][PUSCH %d] CC_id %d ULSCH in error in round %d, ul_cqi %d\n",enb_mod_idP,harq_pid,CC_idP, - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid],ul_cqi); - - // AssertFatal(1==0,"ulsch in error\n"); - if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == 3) { - UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pid)); - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]=0; - if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10) - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; - } - else UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; - return; + if (UE_id != -1) { + LOG_D(MAC, + "[eNB %d][PUSCH %d] CC_id %d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], + current_rnti, UE_id, ul_cqi); + + AssertFatal(UE_list->UE_sched_ctrl[UE_id]. + round_UL[CC_idP][harq_pid] < 8, "round >= 8\n"); + if (sduP != NULL) { + UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= + (~(1 << harq_pid)); + /* Update with smoothing: 3/4 of old value and 1/4 of new. + * This is the logic that was done in the function + * lte_est_timing_advance_pusch, maybe it's not necessary? + * maybe it's even not correct at all? + */ + UE_list->UE_sched_ctrl[UE_id].ta_update = + (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + + timing_advance) / 4; + UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; + UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0; + first_rb = + UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; + + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 0; + mac_eNB_rrc_ul_in_sync(enb_mod_idP, CC_idP, frameP, + subframeP, UE_RNTI(enb_mod_idP, + UE_id)); + } + } else { // we've got an error + LOG_D(MAC, + "[eNB %d][PUSCH %d] CC_id %d ULSCH in error in round %d, ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], + ul_cqi); + + // AssertFatal(1==0,"ulsch in error\n"); + if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == + 3) { + UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= + (~(1 << harq_pid)); + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = + 0; + if (UE_list->UE_sched_ctrl[UE_id]. + ul_consecutive_errors++ == 10) + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; + } else + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; + return; + + } + } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti + AssertFatal(mac->common_channels[CC_idP]. + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx > 1, + "maxHARQ %d should be greater than 1\n", + (int) mac->common_channels[CC_idP]. + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx); + + LOG_D(MAC, + "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP, ra[RA_id].msg3_round, + current_rnti, RA_id, ul_cqi); + + first_rb = ra->msg3_first_rb; + + if (sduP == NULL) { // we've got an error on Msg3 + LOG_D(MAC, + "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", + enb_mod_idP, CC_idP, RA_id, + ra[RA_id].msg3_round, + (int) mac->common_channels[CC_idP]. + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx); + if (ra[RA_id].msg3_round == + mac->common_channels[CC_idP].radioResourceConfigCommon-> + rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); + } + else { + first_rb = + UE_list->UE_template[CC_idP][UE_id]. + first_rb_ul[harq_pid]; + ra[RA_id].msg3_round++; + // prepare handling of retransmission + ra[RA_id].Msg3_frame = (ra[RA_id].Msg3_frame + ((ra[RA_id].Msg3_subframe > 1) ? 1 : 0)) % 1024; + ra[RA_id].Msg3_subframe = (ra[RA_id].Msg3_subframe + 8) % 10; + add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, + subframeP); + } + return; + } + } else { + LOG_W(MAC, + "Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", + current_rnti); + return; } - } - else if ((RA_id = find_RA_id(enb_mod_idP,CC_idP,current_rnti))!=-1) { // Check if this is an RA process for the rnti - AssertFatal(eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx>1, - "maxHARQ %d should be greater than 1\n", - (int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); - - LOG_D(MAC,"[eNB %d][PUSCH %d] CC_id %d Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n",enb_mod_idP,harq_pid,CC_idP, - RA_template[RA_id].msg3_round, - current_rnti,RA_id,ul_cqi); - - first_rb = RA_template->msg3_first_rb; - - if (sduP==NULL) { // we've got an error on Msg3 - LOG_D(MAC,"[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n",enb_mod_idP,CC_idP,RA_id, - RA_template[RA_id].msg3_round, - (int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); - if (RA_template[RA_id].msg3_round == eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx-1) { - cancel_ra_proc(enb_mod_idP,CC_idP,frameP,current_rnti); - } - - else { - first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; - RA_template[RA_id].msg3_round++; - // prepare handling of retransmission - RA_template[RA_id].Msg3_frame += ((RA_template[RA_id].Msg3_subframe>1) ? 1 : 0); - RA_template[RA_id].Msg3_subframe = (RA_template[RA_id].Msg3_subframe+8)%10; - add_msg3(enb_mod_idP,CC_idP, &RA_template[RA_id],frameP,subframeP); - } - return; - } - } - else { - LOG_W(MAC,"Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", current_rnti); - return; - } - payload_ptr = parse_ulsch_header(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP); - - T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu)); - T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); - - eNB->eNB_stats[CC_idP].ulsch_bytes_rx=sdu_lenP; - eNB->eNB_stats[CC_idP].total_ulsch_bytes_rx+=sdu_lenP; - eNB->eNB_stats[CC_idP].total_ulsch_pdus_rx+=1; - - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; - - // control element - for (i=0; i<num_ce; i++) { - - T(T_ENB_MAC_UE_UL_CE, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), - T_INT(rx_ces[i])); - - switch (rx_ces[i]) { // implement and process BSR + CRNTI + - case POWER_HEADROOM: - if (UE_id != -1) { - UE_list->UE_template[CC_idP][UE_id].phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET; - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n", - enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].phr_info); - UE_list->UE_template[CC_idP][UE_id].phr_info_configured=1; - UE_list->UE_sched_ctrl[UE_id].phr_received = 1; - } - payload_ptr+=sizeof(POWER_HEADROOM_CMD); - break; - - case CRNTI: { - int old_rnti = (((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]; - int old_UE_id = find_UE_id(enb_mod_idP, old_rnti); - LOG_D(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n", - enb_mod_idP, frameP, subframeP, CC_idP, rx_ces[i], i, num_ce, old_rnti, old_UE_id); - if (old_UE_id != -1) { - /* TODO: if the UE did random access (followed by a MAC uplink with - * CRNTI) because none of its scheduling request was granted, then - * according to 36.321 5.4.4 the UE's MAC will notify RRC to release - * PUCCH/SRS. According to 36.331 5.3.13 the UE will then apply - * default configuration for CQI reporting and scheduling requests, - * which basically means that the CQI requests won't work anymore and - * that the UE won't do any scheduling request anymore as long as the - * eNB doesn't reconfigure the UE. - * We have to take care of this. As the code is, nothing is done and - * the UE state in the eNB is wrong. - */ - UE_id = old_UE_id; - UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 0; - mac_eNB_rrc_ul_in_sync(enb_mod_idP, CC_idP, frameP, subframeP, old_rnti); - } - /* receiving CRNTI means that the current rnti has to go away */ - cancel_ra_proc(enb_mod_idP,CC_idP,frameP,current_rnti); - current_rnti = old_rnti; - } - crnti_rx=1; - payload_ptr+=2; - break; - } + payload_ptr = + parse_ulsch_header(sduP, &num_ce, &num_sdu, rx_ces, rx_lcids, + rx_lengths, sdu_lenP); + + T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), + T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), + T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu)); + T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), + T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), + T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), + T_BUFFER(sduP, sdu_lenP)); + + mac->eNB_stats[CC_idP].ulsch_bytes_rx = sdu_lenP; + mac->eNB_stats[CC_idP].total_ulsch_bytes_rx += sdu_lenP; + mac->eNB_stats[CC_idP].total_ulsch_pdus_rx += 1; + + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; + + // control element + for (i = 0; i < num_ce; i++) { + + T(T_ENB_MAC_UE_UL_CE, T_INT(enb_mod_idP), T_INT(CC_idP), + T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), + T_INT(rx_ces[i])); + + switch (rx_ces[i]) { // implement and process BSR + CRNTI + + case POWER_HEADROOM: + if (UE_id != -1) { + UE_list->UE_template[CC_idP][UE_id].phr_info = + (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET; + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n", + enb_mod_idP, CC_idP, rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].phr_info); + UE_list->UE_template[CC_idP][UE_id].phr_info_configured = + 1; + UE_list->UE_sched_ctrl[UE_id].phr_received = 1; + } + payload_ptr += sizeof(POWER_HEADROOM_CMD); + break; - case TRUNCATED_BSR: - case SHORT_BSR: { - uint8_t lcgid; - lcgid = (payload_ptr[0] >> 6); - - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", - enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f); - - if (crnti_rx==1) - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", - enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f); - if (UE_id != -1) { - - UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f); - - // update buffer info - - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid]]; - - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]; - - RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP] = (payload_ptr[0] & 0x3f); - if (UE_id == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP]); - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] == 0 ) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid]=frameP; - } - if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP,UE_id)) < RRC_CONNECTED) - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : ul_total_buffer = %d (lcg increment %d)\n", - enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_total_buffer, - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); - } - else { - - } - payload_ptr += 1;//sizeof(SHORT_BSR); // fixme - } - break; - - case LONG_BSR: - if (UE_id != -1) { - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] = ((payload_ptr[0] & 0xFC) >> 2); - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] = - ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] = - ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] = (payload_ptr[2] & 0x3F); - - // update buffer info - old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0]]; - - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0]; - if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; - else - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - - old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1]]; - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1]; - if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; - else - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - - old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2]]; - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2]; - if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; - else - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - - old_buffer_info = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]=BSR_TABLE[UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]]; - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer+= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; - if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= old_buffer_info) - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= old_buffer_info; - else - UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = 0; - - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " - "%u LCGID2 = %u LCGID3 = %u\n", - enb_mod_idP, CC_idP, - rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]); - if (crnti_rx==1) - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " - "%u LCGID2 = %u LCGID3 = %u\n", - enb_mod_idP, CC_idP, - rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2], - UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3]); - - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] == 0 ) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0]=0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0]=frameP; - } - - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] == 0 ) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1]=0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1]=frameP; - } - - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] == 0 ) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2]=0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2]=frameP; - } - - if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] == 0 ) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3]= 0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3]=frameP; - - } - } - - payload_ptr += 3;////sizeof(LONG_BSR); - break; - - default: - LOG_E(MAC, "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", enb_mod_idP, CC_idP, rx_ces[i]); - break; + case CRNTI: + { + int old_rnti = + (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1]; + int old_UE_id = find_UE_id(enb_mod_idP, old_rnti); + LOG_D(MAC, + "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n", + enb_mod_idP, frameP, subframeP, CC_idP, rx_ces[i], i, + num_ce, old_rnti, old_UE_id); + /* receiving CRNTI means that the current rnti has to go away */ + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, + current_rnti); + if (old_UE_id != -1) { + /* TODO: if the UE did random access (followed by a MAC uplink with + * CRNTI) because none of its scheduling request was granted, then + * according to 36.321 5.4.4 the UE's MAC will notify RRC to release + * PUCCH/SRS. According to 36.331 5.3.13 the UE will then apply + * default configuration for CQI reporting and scheduling requests, + * which basically means that the CQI requests won't work anymore and + * that the UE won't do any scheduling request anymore as long as the + * eNB doesn't reconfigure the UE. + * We have to take care of this. As the code is, nothing is done and + * the UE state in the eNB is wrong. + */ + UE_id = old_UE_id; + UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 0; + mac_eNB_rrc_ul_in_sync(enb_mod_idP, CC_idP, frameP, + subframeP, old_rnti); + } + current_rnti = old_rnti; + } + crnti_rx = 1; + payload_ptr += 2; + break; + } + + case TRUNCATED_BSR: + case SHORT_BSR: + { + uint8_t lcgid; + lcgid = (payload_ptr[0] >> 6); + + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", + enb_mod_idP, CC_idP, rx_ces[i], lcgid, + payload_ptr[0] & 0x3f); + + if (crnti_rx == 1) + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", + enb_mod_idP, CC_idP, rx_ces[i], lcgid, + payload_ptr[0] & 0x3f); + if (UE_id != -1) { + + UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid] = + (payload_ptr[0] & 0x3f); + + // update buffer info + + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[lcgid] = + BSR_TABLE[UE_list->UE_template[CC_idP][UE_id]. + bsr_info[lcgid]]; + + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[lcgid]; + + RC.eNB[enb_mod_idP][CC_idP]-> + pusch_stats_bsr[UE_id][(frameP * 10) + subframeP] + = (payload_ptr[0] & 0x3f); + if (UE_id == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME + (VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, + RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr + [UE_id][(frameP * 10) + subframeP]); + if (UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[lcgid] + == 0) { + UE_list->UE_template[CC_idP] + [UE_id].ul_buffer_creation_time[lcgid] = + frameP; + } + if (mac_eNB_get_rrc_status + (enb_mod_idP, + UE_RNTI(enb_mod_idP, UE_id)) < RRC_CONNECTED) + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : ul_total_buffer = %d (lcg increment %d)\n", + enb_mod_idP, CC_idP, rx_ces[i], + UE_list->UE_template[CC_idP][UE_id]. + ul_total_buffer, + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[lcgid]); + } else { + + } + payload_ptr += 1; //sizeof(SHORT_BSR); // fixme + } + break; + + case LONG_BSR: + if (UE_id != -1) { + UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] = + ((payload_ptr[0] & 0xFC) >> 2); + UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] = + ((payload_ptr[0] & 0x03) << 4) | + ((payload_ptr[1] & 0xF0) >> 4); + UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] = + ((payload_ptr[1] & 0x0F) << 2) | + ((payload_ptr[2] & 0xC0) >> 6); + UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] = + (payload_ptr[2] & 0x3F); + + // update buffer info + old_buffer_info = + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID0]; + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID0] = + BSR_TABLE[UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID0]]; + + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer += + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID0]; + if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= + old_buffer_info) + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= + old_buffer_info; + else + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = + 0; + + old_buffer_info = + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID1]; + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID1] = + BSR_TABLE[UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID1]]; + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer += + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID1]; + if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= + old_buffer_info) + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= + old_buffer_info; + else + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = + 0; + + old_buffer_info = + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID2]; + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID2] = + BSR_TABLE[UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID2]]; + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer += + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID2]; + if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= + old_buffer_info) + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= + old_buffer_info; + else + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = + 0; + + old_buffer_info = + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID3]; + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID3] = + BSR_TABLE[UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID3]]; + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer += + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[LCGID3]; + if (UE_list->UE_template[CC_idP][UE_id].ul_total_buffer >= + old_buffer_info) + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer -= + old_buffer_info; + else + UE_list->UE_template[CC_idP][UE_id].ul_total_buffer = + 0; + + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " + "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, CC_idP, + rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0], + UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1], + UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2], + UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID3]); + if (crnti_rx == 1) + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " + "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, + CC_idP, rx_ces[i], + UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID0], + UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID1], + UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID2], + UE_list->UE_template[CC_idP][UE_id]. + bsr_info[LCGID3]); + + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID0] == + 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID0] = 0; + } else if (UE_list->UE_template[CC_idP] + [UE_id].ul_buffer_creation_time[LCGID0] == 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID0] = frameP; + } + + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID1] == + 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID1] = 0; + } else if (UE_list->UE_template[CC_idP] + [UE_id].ul_buffer_creation_time[LCGID1] == 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID1] = frameP; + } + + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID2] == + 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID2] = 0; + } else if (UE_list->UE_template[CC_idP] + [UE_id].ul_buffer_creation_time[LCGID2] == 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID2] = frameP; + } + + if (UE_list->UE_template[CC_idP][UE_id].bsr_info[LCGID3] == + 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID3] = 0; + } else if (UE_list->UE_template[CC_idP] + [UE_id].ul_buffer_creation_time[LCGID3] == 0) { + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_creation_time[LCGID3] = frameP; + + } + } + + payload_ptr += 3; ////sizeof(LONG_BSR); + break; + + default: + LOG_E(MAC, + "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", + enb_mod_idP, CC_idP, rx_ces[i]); + break; + } } - } - - for (i=0; i<num_sdu; i++) { - LOG_D(MAC,"SDU Number %d MAC Subheader SDU_LCID %d, length %d UE_id %d\n",i,rx_lcids[i],rx_lengths[i],UE_id); - - T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), - T_INT(rx_lcids[i]), T_INT(rx_lengths[i])); - T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), - T_INT(rx_lcids[i]), T_INT(rx_lengths[i]), T_BUFFER(payload_ptr, rx_lengths[i])); - - switch (rx_lcids[i]) { - case CCCH : - if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) { - LOG_E(MAC, "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n", - enb_mod_idP, CC_idP, frameP, rx_lengths[i], CCCH_PAYLOAD_SIZE_MAX,sdu_lenP); - break; - } - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", - enb_mod_idP,CC_idP,frameP, - payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4], payload_ptr[5], current_rnti); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,0); - for (ii=0; ii<NB_RA_PROC_MAX; ii++) { - RA_TEMPLATE *RA_template = &eNB->common_channels[CC_idP].RA_template[ii]; - - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), active %d\n", - enb_mod_idP, CC_idP, ii, - RA_template->rnti, current_rnti, - RA_template->RA_active); - - if ((RA_template->rnti==current_rnti) && - (RA_template->RA_active==TRUE)) { - - //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); - - if (UE_id < 0) { - memcpy(&RA_template->cont_res_id[0],payload_ptr,6); - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", - enb_mod_idP,CC_idP,frameP,rx_lengths[i],payload_ptr-sduP); - - if ((UE_id=add_new_ue(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pid - #ifdef Rel14 - ,eNB->common_channels[CC_idP].RA_template[ii].rach_resource_type - #endif - )) == -1 ) { - AssertFatal(1==0,"[MAC][eNB] Max user count reached\n"); - // kill RA procedure - } else - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", - enb_mod_idP,CC_idP,frameP,RA_template->rnti,UE_id); - } else { - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n", - enb_mod_idP,CC_idP,frameP,UE_id,rx_lengths[i],payload_ptr-sduP); - // kill RA procedure - } - - mac_rrc_data_ind( - enb_mod_idP, - CC_idP, - frameP,subframeP, - current_rnti, - CCCH, - (uint8_t*)payload_ptr, - rx_lengths[i], - ENB_FLAG_YES, - enb_mod_idP, - 0 - ); - - - if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest - // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); - } - - // prepare transmission of Msg4 - RA_template->generate_Msg4 = 1; - RA_template->wait_ack_Msg4 = 0; - - - - // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different - RA_template->Msg4_frame = frameP + ((subframeP>5) ? 1 : 0); - RA_template->Msg4_subframe = (subframeP+4)%10; - - LOG_D(MAC,"CCCH: rnti matches RA_active : Msg4 scheduled for frame:%d subframe:%d (current frame:%d subframe:%d)\n",RA_template->Msg4_frame, RA_template->Msg4_subframe,frameP,subframeP); - - } // if process is active - } // loop on RA processes - - break ; - - case DCCH : - case DCCH1 : - // if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){ - + + for (i = 0; i < num_sdu; i++) { + LOG_D(MAC, "SDU Number %d MAC Subheader SDU_LCID %d, length %d\n", + i, rx_lcids[i], rx_lengths[i]); + + T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), + T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), + T_INT(rx_lcids[i]), T_INT(rx_lengths[i])); + T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), + T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), + T_INT(rx_lcids[i]), T_INT(rx_lengths[i]), T_BUFFER(payload_ptr, + rx_lengths + [i])); + + switch (rx_lcids[i]) { + case CCCH: + if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) { + LOG_E(MAC, + "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], + CCCH_PAYLOAD_SIZE_MAX, sdu_lenP); + break; + } + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", + enb_mod_idP, CC_idP, frameP, payload_ptr[0], + payload_ptr[1], payload_ptr[2], payload_ptr[3], + payload_ptr[4], payload_ptr[5], current_rnti); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 1); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 0); + for (ii = 0; ii < NB_RA_PROC_MAX; ii++) { + RA_t *ra = &mac->common_channels[CC_idP].ra[ii]; + + LOG_D(MAC, + "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n", + enb_mod_idP, CC_idP, ii, ra->rnti, + current_rnti, ra->state); + + if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { + + //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); + + if (UE_id < 0) { + memcpy(&ra->cont_res_id[0], payload_ptr, 6); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], + payload_ptr - sduP); + + if ((UE_id = + add_new_ue(enb_mod_idP, CC_idP, + mac->common_channels[CC_idP]. + ra[ii].rnti, harq_pid +#ifdef Rel14 + , + mac->common_channels[CC_idP]. + ra[ii].rach_resource_type +#endif + )) == -1) { + AssertFatal(1 == 0, + "[MAC][eNB] Max user count reached\n"); + // kill RA procedure + } else + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", + enb_mod_idP, CC_idP, frameP, ra->rnti, + UE_id); + } else { + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n", + enb_mod_idP, CC_idP, frameP, UE_id, + rx_lengths[i], payload_ptr - sduP); + // kill RA procedure + } + + mac_rrc_data_ind(enb_mod_idP, + CC_idP, + frameP, subframeP, + current_rnti, + CCCH, + (uint8_t *) payload_ptr, + rx_lengths[i], + 0); + + + if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest + // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); + } + // prepare transmission of Msg4 + ra->state = MSG4; + + + + // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different + ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 4) % 10; + LOG_D(MAC, "Panos-D: rx_sdu 1, SFN/SF:%d.%d \n", ra->Msg4_frame, ra->Msg4_subframe); + + } // if process is active + } // loop on RA processes + + break; + + case DCCH: + case DCCH1: + // if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){ + #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sduP)); - for (j=0; j<32; j++) { - LOG_T(MAC,"%x ",payload_ptr[j]); - } - LOG_T(MAC,"\n"); + LOG_T(MAC, "offset: %d\n", + (unsigned char) ((unsigned char *) payload_ptr - sduP)); + for (j = 0; j < 32; j++) { + LOG_T(MAC, "%x ", payload_ptr[j]); + } + LOG_T(MAC, "\n"); #endif - if (UE_id != -1) { - // adjust buffer occupancy of the correponding logical channel group - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; - else - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes from UE %d on LCID %d \n", - enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]); - - mac_rlc_data_ind( - enb_mod_idP, - current_rnti, - enb_mod_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcids[i], - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL);//(unsigned int*)crc_status); - UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1; - UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; - - - } /* UE_id != -1 */ - - - // } - break; - - // all the DRBS - case DTCH: - default : + if (UE_id != -1) { + // adjust buffer occupancy of the correponding logical channel group + if (UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[UE_list->UE_template[CC_idP] + [UE_id].lcgidmap[rx_lcids[i]]] >= + rx_lengths[i]) + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[UE_list->UE_template[CC_idP] + [UE_id].lcgidmap[rx_lcids[i]]] -= + rx_lengths[i]; + else + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[UE_list->UE_template[CC_idP] + [UE_id].lcgidmap[rx_lcids[i]]] = 0; + + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], UE_id, + rx_lcids[i]); + + mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); //(unsigned int*)crc_status); + UE_list->eNB_UE_stats[CC_idP][UE_id]. + num_pdu_rx[rx_lcids[i]] += 1; + UE_list->eNB_UE_stats[CC_idP][UE_id]. + num_bytes_rx[rx_lcids[i]] + += rx_lengths[i]; + + + } + + /* UE_id != -1 */ + // } + break; + + // all the DRBS + case DTCH: + default: #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sduP)); - for (j=0; j<32; j++) { - LOG_T(MAC,"%x ",payload_ptr[j]); - } - LOG_T(MAC,"\n"); + LOG_T(MAC, "offset: %d\n", + (unsigned char) ((unsigned char *) payload_ptr - sduP)); + for (j = 0; j < 32; j++) { + LOG_T(MAC, "%x ", payload_ptr[j]); + } + LOG_T(MAC, "\n"); #endif - if (rx_lcids[i] < NB_RB_MAX ) { - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n", - enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]); - - if (UE_id != -1) { - // adjust buffer occupancy of the correponding logical channel group - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n", - enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i], - UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]]); - - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; - else - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; - if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0) ) { // MAX SIZE OF transport block - mac_rlc_data_ind( - enb_mod_idP, - current_rnti, - enb_mod_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcids[i], - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL);//(unsigned int*)crc_status); - - UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1; - UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; - } - else { /* rx_length[i] */ - UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx+=1; - LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ", - enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); - } - } - else {/*(UE_id != -1*/ - LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ", - enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); - } - } - - break; + if (rx_lcids[i] < NB_RB_MAX) { + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], UE_id, + rx_lcids[i]); + + if (UE_id != -1) { + // adjust buffer occupancy of the correponding logical channel group + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], + UE_id, rx_lcids[i], + UE_list->UE_template[CC_idP][UE_id]. + lcgidmap[rx_lcids[i]], + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[UE_list->UE_template[CC_idP] + [UE_id].lcgidmap[rx_lcids[i]]]); + + if (UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[UE_list->UE_template[CC_idP] + [UE_id].lcgidmap[rx_lcids[i]]] + >= rx_lengths[i]) + UE_list->UE_template[CC_idP][UE_id]. + ul_buffer_info[UE_list->UE_template[CC_idP] + [UE_id].lcgidmap[rx_lcids[i]]] + -= rx_lengths[i]; + else + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info + [UE_list->UE_template[CC_idP][UE_id].lcgidmap + [rx_lcids[i]]] = 0; + if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) + && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block + mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); //(unsigned int*)crc_status); + + UE_list->eNB_UE_stats[CC_idP][UE_id]. + num_pdu_rx[rx_lcids[i]] += 1; + UE_list->eNB_UE_stats[CC_idP][UE_id]. + num_bytes_rx[rx_lcids[i]] += rx_lengths[i]; + //clear uplane_inactivity_timer + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + } else { /* rx_length[i] */ + UE_list->eNB_UE_stats[CC_idP][UE_id]. + num_errors_rx += 1; + LOG_E(MAC, + "[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ", + enb_mod_idP, CC_idP, frameP, rx_lcids[i], + UE_id); + } + } else { /*(UE_id != -1 */ + LOG_E(MAC, + "[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ", + enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); + } + } + + break; + } + + payload_ptr += rx_lengths[i]; } - - payload_ptr+=rx_lengths[i]; - } - - // Program ACK for PHICH - LOG_D(MAC,"SFN/SF:%d%d Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n",frameP,subframeP,rntiP,harq_pid,first_rb); - nfapi_hi_dci0_request_t *hi_dci0_req = &eNB->HI_DCI0_req[CC_idP]; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci+hi_dci0_req_body->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = first_rb; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 1; - //hi_dci0_pdu->hi_pdu.hi_pdu_rel8.transmission_power = 6000; // DJP - TODO FIXME - not used?? - hi_dci0_req_body->number_of_hi++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP,subframeP, 0); - hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP, 4); - hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - //oai_nfapi_hi_dci0_req(hi_dci0_req); - //hi_dci0_req_body->number_of_hi=0; - - /* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */ - if ((num_sdu == 0) && (num_ce==0)) { - if (UE_id != -1) - UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx+=1; - /* - if (msg3_flagP != NULL) { - if( *msg3_flagP == 1 ) { - LOG_N(MAC,"[eNB %d] CC_id %d frame %d : false msg3 detection: signal phy to canceling RA and remove the UE\n", enb_mod_idP, CC_idP, frameP); - *msg3_flagP=0; - } - }*/ - } else { - if (UE_id != -1) { - UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx=sdu_lenP; - UE_list->eNB_UE_stats[CC_idP][UE_id].total_pdu_bytes_rx+=sdu_lenP; - UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_pdus_rx+=1; + + // Program ACK for PHICH + LOG_D(MAC, + "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n", + current_rnti, harq_pid, first_rb); + nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_idP]; + nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = + &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; + memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = first_rb; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 1; + hi_dci0_req_body->number_of_hi++; + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP,subframeP, 0); + hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP, 4); + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + + /* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */ + if ((num_sdu == 0) && (num_ce == 0)) { + if (UE_id != -1) + UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx += 1; + /* + if (msg3_flagP != NULL) { + if( *msg3_flagP == 1 ) { + LOG_N(MAC,"[eNB %d] CC_id %d frame %d : false msg3 detection: signal phy to canceling RA and remove the UE\n", enb_mod_idP, CC_idP, frameP); + *msg3_flagP=0; + } + } */ + } else { + if (UE_id != -1) { + UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx = sdu_lenP; + UE_list->eNB_UE_stats[CC_idP][UE_id].total_pdu_bytes_rx += + sdu_lenP; + UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_pdus_rx += 1; + } } - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,0); - stop_meas(&eNB->rx_ulsch_sdu); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 0); + stop_meas(&mac->rx_ulsch_sdu); } uint32_t bytes_to_bsr_index(int32_t nbytes) { - uint32_t i=0; + uint32_t i = 0; - if (nbytes<0) { - return(0); - } + if (nbytes < 0) { + return (0); + } - while ((i<BSR_TABLE_SIZE)&& - (BSR_TABLE[i]<=nbytes)) { - i++; - } + while ((i < BSR_TABLE_SIZE) && (BSR_TABLE[i] <= nbytes)) { + i++; + } - return(i-1); + return (i - 1); } -void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, sub_frame_t subframeP, UE_ULSCH_STATUS status) +void +add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, + sub_frame_t subframeP, UE_ULSCH_STATUS status) { - eNB_ulsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP,UE_id); - eNB_ulsch_info[module_idP][CC_id][UE_id].subframe = subframeP; - eNB_ulsch_info[module_idP][CC_id][UE_id].status = status; + eNB_ulsch_info[module_idP][CC_id][UE_id].rnti = + UE_RNTI(module_idP, UE_id); + eNB_ulsch_info[module_idP][CC_id][UE_id].subframe = subframeP; + eNB_ulsch_info[module_idP][CC_id][UE_id].status = status; - eNB_ulsch_info[module_idP][CC_id][UE_id].serving_num++; + eNB_ulsch_info[module_idP][CC_id][UE_id].serving_num++; } unsigned char *parse_ulsch_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { - unsigned char not_done=1,num_ces=0,num_sdus=0,lcid,num_sdu_cnt; - unsigned char *mac_header_ptr = mac_header; - unsigned short length, ce_len=0; + unsigned char not_done = 1, num_ces = 0, num_sdus = + 0, lcid, num_sdu_cnt; + unsigned char *mac_header_ptr = mac_header; + unsigned short length, ce_len = 0; - while (not_done==1) { + while (not_done == 1) { - if (((SCH_SUBHEADER_FIXED*)mac_header_ptr)->E == 0) { - not_done = 0; - } + if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { + not_done = 0; + } + + lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; + + if (lcid < EXTENDED_POWER_HEADROOM) { + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = + tb_length - (mac_header_ptr - mac_header) - ce_len; + + for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus; + num_sdu_cnt++) { + length -= rx_lengths[num_sdu_cnt]; + } + } else { + if (((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F == 0) { + length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; + mac_header_ptr += 2; //sizeof(SCH_SUBHEADER_SHORT); + } else { // F = 1 + length = + ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB & + 0x7f) << 8) | (((SCH_SUBHEADER_LONG *) + mac_header_ptr)->L_LSB & 0xff); + mac_header_ptr += 3; //sizeof(SCH_SUBHEADER_LONG); + } + } - lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; - - if (lcid < EXTENDED_POWER_HEADROOM) { - if (not_done==0) { // last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length-(mac_header_ptr-mac_header)-ce_len; - - for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) { - length -= rx_lengths[num_sdu_cnt]; - } - } else { - if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { - length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; - mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT); - } else { // F = 1 - length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); - mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG); - } - } - - LOG_D(MAC,"[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n", - num_sdus,lcid,tb_length, length,mac_header_ptr-mac_header); - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI - if (lcid == SHORT_PADDING) { - mac_header_ptr++; - } else { - rx_ces[num_ces] = lcid; - num_ces++; - mac_header_ptr++; - - if (lcid==LONG_BSR) { - ce_len+=3; - } else if (lcid==CRNTI) { - ce_len+=2; - } else if ((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) { - ce_len++; - } else { - LOG_E(MAC,"unknown CE %d \n", lcid); - AssertFatal(1==0,"unknown CE"); - } - } + LOG_D(MAC, + "[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n", + num_sdus, lcid, tb_length, length, + mac_header_ptr - mac_header); + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; + } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI + if (lcid == SHORT_PADDING) { + mac_header_ptr++; + } else { + rx_ces[num_ces] = lcid; + num_ces++; + mac_header_ptr++; + + if (lcid == LONG_BSR) { + ce_len += 3; + } else if (lcid == CRNTI) { + ce_len += 2; + } else if ((lcid == POWER_HEADROOM) + || (lcid == TRUNCATED_BSR) + || (lcid == SHORT_BSR)) { + ce_len++; + } else { + LOG_E(MAC, "unknown CE %d \n", lcid); + AssertFatal(1 == 0, "unknown CE"); + } + } + } } - } - *num_ce = num_ces; - *num_sdu = num_sdus; + *num_ce = num_ces; + *num_sdu = num_sdus; - return(mac_header_ptr); + return (mac_header_ptr); } /* This function is called by PHY layer when it schedules some @@ -728,599 +916,645 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, * The MAC scheduler has to skip the RBs used by this message 3 * (done below in schedule_ulsch). */ -void set_msg3_subframe(module_id_t Mod_id, - int CC_id, - int frame, - int subframe, - int rnti, - int Msg3_frame, - int Msg3_subframe) +void +set_msg3_subframe(module_id_t Mod_id, + int CC_id, + int frame, + int subframe, int rnti, int Msg3_frame, + int Msg3_subframe) { - eNB_MAC_INST *eNB=RC.mac[Mod_id]; - int i; - for (i=0; i<NB_RA_PROC_MAX; i++) { - if (eNB->common_channels[CC_id].RA_template[i].RA_active == TRUE && - eNB->common_channels[CC_id].RA_template[i].rnti == rnti) { - eNB->common_channels[CC_id].RA_template[i].Msg3_subframe = Msg3_subframe; - break; + eNB_MAC_INST *mac = RC.mac[Mod_id]; + int i; + for (i = 0; i < NB_RA_PROC_MAX; i++) { + if (mac->common_channels[CC_id].ra[i].state != IDLE && + mac->common_channels[CC_id].ra[i].rnti == rnti) { + mac->common_channels[CC_id].ra[i].Msg3_subframe = + Msg3_subframe; + break; + } } - } } -void schedule_ulsch(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP) +void +schedule_ulsch(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP) { - uint16_t first_rb[MAX_NUM_CCs],i; - int CC_id; - eNB_MAC_INST *eNB=RC.mac[module_idP]; - COMMON_channels_t *cc; - - start_meas(&eNB->schedule_ulsch); - - int sched_subframe = (subframeP+4)%10; - - cc = &eNB->common_channels[0]; - int tdd_sfa; - // for TDD: check subframes where we have to act and return if nothing should be done now - if (cc->tdd_Config) { - tdd_sfa = cc->tdd_Config->subframeAssignment; - switch (subframeP) { - case 0: - if ((tdd_sfa == 0)|| - (tdd_sfa == 3)|| - (tdd_sfa == 6)) sched_subframe = 4; - else return; - break; - case 1: - if ((tdd_sfa==0)|| - (tdd_sfa==1)) sched_subframe = 7; - else if (tdd_sfa==6) sched_subframe = 8; - break; - default: - return; - - case 2: // Don't schedule UL in subframe 2 for TDD - return; - case 3: - if (tdd_sfa==2) sched_subframe = 7; - else return; - break; - case 4: - if (tdd_sfa==1) sched_subframe = 8; - else return; - break; - case 5: - if (tdd_sfa==0) sched_subframe = 9; - else if (tdd_sfa==6) sched_subframe = 3; - else return; - break; - case 6: - if (tdd_sfa==1) sched_subframe = 2; - else if (tdd_sfa==6) sched_subframe = 3; - else return; - break; - case 7: - return; - case 8: - if ((tdd_sfa>=2) || (tdd_sfa<=5)) sched_subframe=2; - else return; - break; - case 9: - if ((tdd_sfa==1) || (tdd_sfa==3) || (tdd_sfa==4)) sched_subframe=3; - else if (tdd_sfa==6) sched_subframe=4; - else return; - break; - } - } - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - - - //leave out first RB for PUCCH - first_rb[CC_id] = 1; - - // UE data info; - // check which UE has data to transmit - // function to decide the scheduling - // e.g. scheduling_rslt = Greedy(granted_UEs, nb_RB) - - // default function for default scheduling - // - - // output of scheduling, the UE numbers in RBs, where it is in the code??? - // check if RA (Msg3) is active in this subframeP, if so skip the PRBs used for Msg3 - // Msg3 is using 1 PRB so we need to increase first_rb accordingly - // not sure about the break (can there be more than 1 active RA procedure?) - - - for (i=0; i<NB_RA_PROC_MAX; i++) { - if ((cc->RA_template[i].RA_active == TRUE) && - (cc->RA_template[i].generate_rar == 0) && - (cc->RA_template[i].generate_Msg4 == 0) && - (cc->RA_template[i].wait_ack_Msg4 == 0) && - (cc->RA_template[i].Msg3_subframe == sched_subframe)) { - first_rb[CC_id]++; - // cc->RA_template[i].Msg3_subframe = -1; - break; - } + uint16_t first_rb[MAX_NUM_CCs], i; + int CC_id; + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc; + + start_meas(&mac->schedule_ulsch); + + int sched_subframe = (subframeP + 4) % 10; + + cc = &mac->common_channels[0]; + int tdd_sfa; + // for TDD: check subframes where we have to act and return if nothing should be done now + if (cc->tdd_Config) { + tdd_sfa = cc->tdd_Config->subframeAssignment; + switch (subframeP) { + case 0: + if ((tdd_sfa == 0) || (tdd_sfa == 3) || (tdd_sfa == 6)) + sched_subframe = 4; + else + return; + break; + case 1: + if ((tdd_sfa == 0) || (tdd_sfa == 1)) + sched_subframe = 7; + else if (tdd_sfa == 6) + sched_subframe = 8; + break; + default: + return; + + case 2: // Don't schedule UL in subframe 2 for TDD + return; + case 3: + if (tdd_sfa == 2) + sched_subframe = 7; + else + return; + break; + case 4: + if (tdd_sfa == 1) + sched_subframe = 8; + else + return; + break; + case 5: + if (tdd_sfa == 0) + sched_subframe = 9; + else if (tdd_sfa == 6) + sched_subframe = 3; + else + return; + break; + case 6: + if (tdd_sfa == 1) + sched_subframe = 2; + else if (tdd_sfa == 6) + sched_subframe = 3; + else + return; + break; + case 7: + return; + case 8: + if ((tdd_sfa >= 2) || (tdd_sfa <= 5)) + sched_subframe = 2; + else + return; + break; + case 9: + if ((tdd_sfa == 1) || (tdd_sfa == 3) || (tdd_sfa == 4)) + sched_subframe = 3; + else if (tdd_sfa == 6) + sched_subframe = 4; + else + return; + break; + } } - } + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - //schedule_ulsch_rnti(module_idP, frameP, subframeP, subframeP,first_rb); sunday - schedule_ulsch_rnti(module_idP, frameP, subframeP, sched_subframe,first_rb); - stop_meas(&eNB->schedule_ulsch); -} -void schedule_ulsch_rnti(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, - uint16_t *first_rb) -{ - int UE_id; - uint8_t aggregation = 2; - rnti_t rnti = -1; - uint8_t round = 0; - uint8_t harq_pid = 0; - uint8_t status = 0; - uint8_t rb_table_index = -1; - uint32_t cqi_req,cshift,ndi,tpc; - int32_t normalized_rx_power; - int32_t target_rx_power=-90; - static int32_t tpc_accumulated=0; - int n; - int CC_id = 0; - int drop_ue=0; - int N_RB_UL; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - UE_list_t *UE_list=&eNB->UE_list; - UE_TEMPLATE *UE_template; - UE_sched_ctrl *UE_sched_ctrl; - int sched_frame=frameP; - int rvidx_tab[4] = {0,2,3,1}; - - if (sched_subframeP<subframeP) sched_frame++; - - nfapi_hi_dci0_request_t *hi_dci0_req = &eNB->HI_DCI0_req[CC_id]; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - - nfapi_ul_config_request_t *ul_req_tmp = &eNB->UL_req_tmp[CC_id][sched_subframeP]; - nfapi_ul_config_request_body_t *ul_req_tmp_body = &ul_req_tmp->ul_config_request_body; - - //LOG_D(MAC,"entering ulsch preprocesor\n"); - ulsch_scheduler_pre_processor(module_idP, - frameP, - subframeP, - first_rb); - - //LOG_D(MAC,"exiting ulsch preprocesor\n"); - - // loop over all active UEs - for (UE_id=UE_list->head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) { - - // don't schedule if Msg4 is not received yet - if (UE_list->UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured==FALSE) { - //LOG_D(MAC,"[eNB %d] frame %d subframe %d, UE %d: not configured, skipping UE scheduling \n", module_idP,frameP,subframeP,UE_id); - continue; - } + //leave out first RB for PUCCH + first_rb[CC_id] = 1; - rnti = UE_RNTI(module_idP,UE_id); + // UE data info; + // check which UE has data to transmit + // function to decide the scheduling + // e.g. scheduling_rslt = Greedy(granted_UEs, nb_RB) - if (rnti==NOT_A_RNTI) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d: no RNTI \n", module_idP,frameP,subframeP,UE_id); - continue; - } + // default function for default scheduling + // - drop_ue = 0; - /* let's drop the UE if get_eNB_UE_stats returns NULL when calling it with any of the UE's active UL CCs */ - /* TODO: refine? - - for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - - if (mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti) == NULL) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); - drop_ue = 1; - break; - } - }*/ - if (drop_ue == 1) { -/* we can't come here, ulsch_scheduler_pre_processor won't put in the list a UE with no PHY context */ -abort(); - /* TODO: this is a hack. Sometimes the UE has no PHY context but - * is still present in the MAC with 'ul_failure_timer' = 0 and - * 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's - * start an UL out of sync procedure in this case. - * The root cause of this problem has to be found and corrected. - * In the meantime, this hack... - */ - if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0 && - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: UE in weird state, let's put it 'out of sync'\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - // inform RRC of failure and clear timer - mac_eNB_rrc_ul_failure(module_idP,CC_id,frameP,subframeP,rnti); - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0; - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=1; - } - continue; + // output of scheduling, the UE numbers in RBs, where it is in the code??? + // check if RA (Msg3) is active in this subframeP, if so skip the PRBs used for Msg3 + // Msg3 is using 1 PRB so we need to increase first_rb accordingly + // not sure about the break (can there be more than 1 active RA procedure?) + + for (i = 0; i < NB_RA_PROC_MAX; i++) { + if ((cc->ra[i].state == WAITMSG3) && + (cc->ra[i].Msg3_subframe == sched_subframe)) { + first_rb[CC_id]++; + // cc->ray[i].Msg3_subframe = -1; + break; + } + } } - // loop over all active UL CC_ids for this UE - for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth); - - /* - aggregation=get_aggregation(get_bw_index(module_idP,CC_id), - eNB_UE_stats->dl_cqi, - format0); - */ - - if (CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,aggregation,rnti)) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); - continue; // break; - } - - /* be sure that there are some free RBs */ - if (first_rb[CC_id] >= N_RB_UL-1) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - continue; - } - - // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel - - UE_template = &UE_list->UE_template[CC_id][UE_id]; - UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - { - uint16_t ul_sched_frame = sched_frame; - uint16_t ul_sched_subframeP = sched_subframeP; - - add_subframe(&ul_sched_frame, &ul_sched_subframeP, 0); - - harq_pid = subframe2harqpid(&cc[CC_id],ul_sched_frame,ul_sched_subframeP); - } - - round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; - AssertFatal(round<8,"round %d > 7 for UE %d/%x\n",round,UE_id,rnti); - //LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, aggregation,N_RB_UL); - - RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); - if (UE_is_to_be_scheduled(module_idP,CC_id,UE_id) > 0 || round > 0)// || ((frameP%10)==0)) - // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames - { - LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", - module_idP,harq_pid,frameP,subframeP,UE_id,rnti,round,UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - - UE_sched_ctrl->ul_failure_timer, - - UE_sched_ctrl->cqi_req_timer); - // reset the scheduling request - UE_template->ul_SR = 0; - status = mac_eNB_get_rrc_status(module_idP,rnti); - if (status < RRC_CONNECTED) - cqi_req = 0; - else if (UE_sched_ctrl->cqi_req_timer>30) { - // - // - // - // - // - // - // - // - cqi_req = 0; - - // - // - // - // - // - // - // - // - UE_sched_ctrl->cqi_req_timer=0; - } - else - cqi_req = 0; - - LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x cqi_req %d RRC Status %d\n", - module_idP,harq_pid,frameP,subframeP,UE_id,rnti,cqi_req,status); - - //power control - //compute the expected ULSCH RX power (for the stats) - - // this is the normalized RX power and this should be constant (regardless of mcs - normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; - target_rx_power = 178; - - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe; - if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - { - UE_template->pusch_tpc_tx_frame=frameP; - UE_template->pusch_tpc_tx_subframe=subframeP; - if (normalized_rx_power>(target_rx_power+4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - } else { - tpc = 1; //0 - } - //tpc = 1; - if (tpc!=1) { - LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP,frameP,subframeP,harq_pid,tpc, - tpc_accumulated,normalized_rx_power,target_rx_power); - } - - // new transmission - if (round==0) { - - ndi = 1-UE_template->oldNDI_UL[harq_pid]; - UE_template->oldNDI_UL[harq_pid]=ndi; - UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; - UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS - if (UE_template->pre_allocated_rb_table_index_ul >=0) { - rb_table_index=UE_template->pre_allocated_rb_table_index_ul; - } else { - UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index=5; // for PHR + schedule_ulsch_rnti(module_idP, frameP, subframeP, sched_subframe, + first_rb); + stop_meas(&mac->schedule_ulsch); +} + +void +schedule_ulsch_rnti(module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, uint16_t * first_rb) +{ + + int UE_id; + uint8_t aggregation = 2; + rnti_t rnti = -1; + uint8_t round = 0; + uint8_t harq_pid = 0; + uint8_t status = 0; + uint8_t rb_table_index = -1; + uint32_t cqi_req, cshift, ndi, tpc; + int32_t normalized_rx_power; + int32_t target_rx_power = -90; + static int32_t tpc_accumulated = 0; + int n; + int CC_id = 0; + int drop_ue = 0; + int N_RB_UL; + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + UE_list_t *UE_list = &mac->UE_list; + UE_TEMPLATE *UE_template; + UE_sched_ctrl *UE_sched_ctrl; + int sched_frame = frameP; + int rvidx_tab[4] = { 0, 2, 3, 1 }; + + if (sched_subframeP < subframeP) + sched_frame++; + + nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_id]; + nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; + + nfapi_ul_config_request_t *ul_req_tmp = &mac->UL_req_tmp[CC_id][sched_subframeP]; + nfapi_ul_config_request_body_t *ul_req_tmp_body = &ul_req_tmp->ul_config_request_body; + + //LOG_D(MAC, "entering ulsch preprocesor\n"); + ulsch_scheduler_pre_processor(module_idP, frameP, subframeP, first_rb); + + //LOG_D(MAC, "exiting ulsch preprocesor\n"); + + hi_dci0_req->sfn_sf = (frameP << 4) + subframeP; + + // loop over all active UEs + for (UE_id = UE_list->head_ul; UE_id >= 0; + UE_id = UE_list->next_ul[UE_id]) { + + // don't schedule if Msg4 is not received yet + if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id]. + configured == FALSE) { + LOG_D(MAC, + "[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n", + module_idP, frameP, subframeP, UE_id); + continue; + } + + rnti = UE_RNTI(module_idP, UE_id); + + if (rnti == NOT_A_RNTI) { + LOG_W(MAC, "[eNB %d] frame %d subfarme %d, UE %d: no RNTI \n", + module_idP, frameP, subframeP, UE_id); + continue; + } + + drop_ue = 0; + /* let's drop the UE if get_eNB_UE_stats returns NULL when calling it with any of the UE's active UL CCs */ + /* TODO: refine? + + for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + + if (mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti) == NULL) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: no PHY context\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); + drop_ue = 1; + break; + } + } */ + if (drop_ue == 1) { +/* we can't come here, ulsch_scheduler_pre_processor won't put in the list a UE with no PHY context */ + abort(); + /* TODO: this is a hack. Sometimes the UE has no PHY context but + * is still present in the MAC with 'ul_failure_timer' = 0 and + * 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's + * start an UL out of sync procedure in this case. + * The root cause of this problem has to be found and corrected. + * In the meantime, this hack... + */ + if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0 && + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0) { + LOG_W(MAC, + "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: UE in weird state, let's put it 'out of sync'\n", + module_idP, frameP, subframeP, UE_id, rnti, CC_id); + // inform RRC of failure and clear timer + mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, + subframeP, rnti); + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; + } + continue; + } + // loop over all active UL CC_ids for this UE + for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth); + + /* + aggregation=get_aggregation(get_bw_index(module_idP,CC_id), + eNB_UE_stats->dl_cqi, + format0); + */ + + if (CCE_allocation_infeasible + (module_idP, CC_id, 1, subframeP, aggregation, rnti)) { + LOG_W(MAC, + "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", + module_idP, frameP, subframeP, UE_id, rnti, CC_id); + continue; // break; } - - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; - // buffer_occupancy = UE_template->ul_total_buffer; - - - while (((rb_table[rb_table_index]>(N_RB_UL-1-first_rb[CC_id])) || - (rb_table[rb_table_index]>45)) && - (rb_table_index>0)) { - rb_table_index--; - } - - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; - // buffer_occupancy -= TBS; - - T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); - - if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) - LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d frame %d subframe %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid], - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid, sched_frame, sched_subframeP); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; - UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; - - UE_sched_ctrl->ul_scheduled |= (1<<harq_pid); - if (UE_id == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled); - - // adjust total UL buffer status by TBS, wait for UL sdus to do final update - LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]); - if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) - UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; - else - UE_template->ul_total_buffer = 0; - LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer); - // Cyclic shift for DM RS - cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) - // save it for a potential retransmission - UE_template->cshift[harq_pid] = cshift; - - hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci+hi_dci0_req_body->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - - hi_dci0_req_body->number_of_dci++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP, subframeP, 4); - hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - - hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! - hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - first_rb[CC_id], // resource_block_start - rb_table[rb_table_index], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - ndi, // new_data_indication - 0, // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - get_TBS_UL(UE_template->mcs_UL[harq_pid], - rb_table[rb_table_index]) - ); -#ifdef Rel14 - if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], - UE_template->rach_resource_type>2 ? 2 : 1, - 1, //total_number_of_repetitions - 1, //repetition_number - (frameP*10)+subframeP); + /* be sure that there are some free RBs */ + if (first_rb[CC_id] >= N_RB_UL - 1) { + LOG_W(MAC, + "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP, frameP, subframeP, UE_id, rnti, CC_id); + continue; } + // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel + + UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + harq_pid = + subframe2harqpid(&cc[CC_id], sched_frame, sched_subframeP); + round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; + AssertFatal(round < 8, "round %d > 7 for UE %d/%x\n", round, + UE_id, rnti); + LOG_D(MAC, + "[eNB %d] frame %d subframe %d (sched_frame %d, sched_subframe %d), Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", + module_idP, frameP, subframeP, sched_frame, sched_subframeP, harq_pid, UE_id, rnti, + CC_id, aggregation, N_RB_UL); + + RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP * + 10) + + subframeP] = + UE_template->ul_total_buffer; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME + (VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO, + RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP * + 10) + + subframeP]); + if (UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0 || round > 0) // || ((frameP%10)==0)) + // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames + { + LOG_D(MAC, + "[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", + module_idP, harq_pid, frameP, subframeP, UE_id, rnti, + round, UE_template->ul_SR, + UE_sched_ctrl->ul_inactivity_timer, + UE_sched_ctrl->ul_failure_timer, + UE_sched_ctrl->cqi_req_timer); + // reset the scheduling request + UE_template->ul_SR = 0; + status = mac_eNB_get_rrc_status(module_idP, rnti); + if (status < RRC_CONNECTED) + cqi_req = 0; + else if (UE_sched_ctrl->cqi_req_timer > 30) { + if (nfapi_mode) { + cqi_req = 0; + } else { + cqi_req = 1; + } + UE_sched_ctrl->cqi_req_timer = 0; + } else + cqi_req = 0; + + //power control + //compute the expected ULSCH RX power (for the stats) + + // this is the normalized RX power and this should be constant (regardless of mcs + normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; + target_rx_power = 178; + + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = + UE_template->pusch_tpc_tx_frame * 10 + + UE_template->pusch_tpc_tx_subframe; + if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case + ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around + { + UE_template->pusch_tpc_tx_frame = frameP; + UE_template->pusch_tpc_tx_subframe = subframeP; + if (normalized_rx_power > (target_rx_power + 4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power < (target_rx_power - 4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + } else { + tpc = 1; //0 + } + //tpc = 1; + if (tpc != 1) { + LOG_D(MAC, + "[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + module_idP, frameP, subframeP, harq_pid, tpc, + tpc_accumulated, normalized_rx_power, + target_rx_power); + } + // new transmission + if (round == 0) { + + ndi = 1 - UE_template->oldNDI_UL[harq_pid]; + UE_template->oldNDI_UL[harq_pid] = ndi; + UE_list->eNB_UE_stats[CC_id][UE_id]. + normalized_rx_power = normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power = + target_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1 = + UE_template->pre_assigned_mcs_ul; + UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul; //cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + if (UE_template->pre_allocated_rb_table_index_ul >= 0) { + rb_table_index = + UE_template->pre_allocated_rb_table_index_ul; + } else { + UE_template->mcs_UL[harq_pid] = 10; //cmin (10, openair_daq_vars.target_ue_ul_mcs); + rb_table_index = 5; // for PHR + } + + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = + UE_template->mcs_UL[harq_pid]; + // buffer_occupancy = UE_template->ul_total_buffer; + + + while (((rb_table[rb_table_index] > + (N_RB_UL - 1 - first_rb[CC_id])) + || (rb_table[rb_table_index] > 45)) + && (rb_table_index > 0)) { + rb_table_index--; + } + + UE_template->TBS_UL[harq_pid] = + get_TBS_UL(UE_template->mcs_UL[harq_pid], + rb_table[rb_table_index]); + UE_list->eNB_UE_stats[CC_id][UE_id]. + total_rbs_used_rx += rb_table[rb_table_index]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = + UE_template->TBS_UL[harq_pid]; + // buffer_occupancy -= TBS; + + T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(UE_template->mcs_UL[harq_pid]), + T_INT(first_rb[CC_id]), + T_INT(rb_table[rb_table_index]), + T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); + + if (mac_eNB_get_rrc_status(module_idP, rnti) < + RRC_CONNECTED) + LOG_D(MAC, + "[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", + module_idP, harq_pid, rnti, CC_id, frameP, + subframeP, UE_id, + UE_template->mcs_UL[harq_pid], + first_rb[CC_id], rb_table[rb_table_index], + rb_table_index, + UE_template->TBS_UL[harq_pid], harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = + rb_table[rb_table_index]; + UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; + + UE_sched_ctrl->ul_scheduled |= (1 << harq_pid); + if (UE_id == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME + (VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED, + UE_sched_ctrl->ul_scheduled); + + // adjust total UL buffer status by TBS, wait for UL sdus to do final update + LOG_D(MAC, + "[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", + module_idP, CC_id, UE_id, rnti, + UE_template->ul_total_buffer, + UE_template->TBS_UL[harq_pid]); + if (UE_template->ul_total_buffer > + UE_template->TBS_UL[harq_pid]) + UE_template->ul_total_buffer -= + UE_template->TBS_UL[harq_pid]; + else + UE_template->ul_total_buffer = 0; + LOG_D(MAC, "ul_total_buffer, new %d\n", + UE_template->ul_total_buffer); + // Cyclic shift for DM RS + cshift = 0; // values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + // save it for a potential retransmission + UE_template->cshift[harq_pid] = cshift; + + hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; + memset((void *) hi_dci0_pdu, 0, + sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = + 2 + sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = + NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = + aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = + 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8. + resource_block_start = first_rb[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8. + number_of_resource_block = + rb_table[rb_table_index]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = + UE_template->mcs_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8. + cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8. + frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8. + new_data_indication_1 = ndi; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = + cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = + UE_template->DAI_ul[sched_subframeP]; + + hi_dci0_req_body->number_of_dci++; + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP, subframeP, 4); + hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + + hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + + + LOG_D(MAC, + "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid, frameP, subframeP, UE_id, rnti, + sched_frame, sched_subframeP); + + // Add UL_config PDUs + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, first_rb[CC_id], // resource_block_start + rb_table[rb_table_index], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL + (UE_template-> + mcs_UL[harq_pid], + rb_table + [rb_table_index])); +#ifdef Rel14 + if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + 1, //repetition_number + (frameP * + 10) + + subframeP); + } #endif - ul_req_tmp_body->number_of_pdus++; - eNB->ul_handle++; - - ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - - //ul_req_tmp->sfn_sf = sfnsf_add_subframe(sched_frame, sched_subframeP, 4); sunday - ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; - ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; - - //LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); - - - // Scheduler dips into this structure to work out if UE has a grant, so in nfapi mode we still need to populate it - // but we can send it right here, right now - - //if (nfapi_mode) - { - //LOG_D(MAC,"Sending out future UE UL_CONFIG_REQ now in nFAPI mode for future frame:%d subframe:%d\n", sched_frame, sched_subframeP); - //oai_nfapi_ul_config_req(ul_req_tmp); - } - - add_ue_ulsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_UL_SCHEDULED); - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); - - // increment first rb for next UE allocation - first_rb[CC_id]+=rb_table[rb_table_index]; - } - else { // round > 0 => retransmission - T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(round)); - - // fill in NAK information - - hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci+hi_dci0_req_body->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = UE_template->first_rb_ul[harq_pid]; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = UE_template->cshift[harq_pid]; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; - hi_dci0_req_body->number_of_hi++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); - hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - - hi_dci0_req->sfn_sf = frameP<<4|subframeP; //sfnsf_add_subframe(sched_frame, sched_subframeP, 0); - sunday - hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, TBS %d, harq_pid %d,round %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid], - UE_template->first_rb_ul[harq_pid], UE_template->nb_rb_ul[harq_pid], - UE_template->TBS_UL[harq_pid],harq_pid,round); - // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - UE_template->first_rb_ul[harq_pid], // resource_block_start - UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round&3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template->TBS_UL[harq_pid] - ); + ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp_body->number_of_pdus++; + ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + mac->ul_handle++; + + uint16_t ul_sched_frame = sched_frame; + uint16_t ul_sched_subframeP = sched_subframeP; + + add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); + ul_req_tmp->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; + + add_ue_ulsch_info(module_idP, + CC_id, UE_id, subframeP, + S_UL_SCHEDULED); + + //LOG_D(MAC, "[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP, CC_id, frameP, subframeP, UE_id); + LOG_D(MAC,"[PUSCH %d] SFN/SF:%04d%d UL_CFG:SFN/SF:%04d%d CQI:%d for UE %d/%x\n", harq_pid,frameP,subframeP,ul_sched_frame,ul_sched_subframeP,cqi_req,UE_id,rnti); + + // increment first rb for next UE allocation + first_rb[CC_id] += rb_table[rb_table_index]; + } else { // round > 0 => retransmission + T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, + T_INT(module_idP), T_INT(CC_id), T_INT(rnti), + T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), + T_INT(UE_template->mcs_UL[harq_pid]), + T_INT(first_rb[CC_id]), + T_INT(rb_table[rb_table_index]), T_INT(round)); + + // fill in NAK information + + hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; + memset((void *) hi_dci0_pdu, 0, + sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = + 2 + sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = + UE_template->first_rb_ul[harq_pid]; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8. + cyclic_shift_2_for_drms = + UE_template->cshift[harq_pid]; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; + hi_dci0_req_body->number_of_hi++; + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); + hi_dci0_req->sfn_sf = frameP<<4|subframeP; + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + + LOG_D(MAC, + "[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, TBS %d, round %d)\n", + module_idP, harq_pid, rnti, CC_id, frameP, + subframeP, UE_id, UE_template->mcs_UL[harq_pid], + UE_template->first_rb_ul[harq_pid], + UE_template->nb_rb_ul[harq_pid], + UE_template->TBS_UL[harq_pid], round); + // Add UL_config PDUs + LOG_D(MAC, + "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid, frameP, subframeP, UE_id, rnti, + sched_frame, sched_subframeP); + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, UE_template->first_rb_ul[harq_pid], // resource_block_start + UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round & 3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template-> + TBS_UL[harq_pid]); #ifdef Rel14 - if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], - UE_template->rach_resource_type>2 ? 2 : 1, - 1, //total_number_of_repetitions - 1, //repetition_number - (frameP*10)+subframeP); - } + if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + 1, //repetition_number + (frameP * + 10) + + subframeP); + } #endif - ul_req_tmp_body->number_of_pdus++; - eNB->ul_handle++; - - ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - - ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; - ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; - - LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n", - harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,cqi_req); - }/* - else if (round > 0) { //we schedule a retransmission - - ndi = UE_template->oldNDI_UL[harq_pid]; - - if ((round&3)==0) { - mcs = openair_daq_vars.target_ue_ul_mcs; - } else { - mcs = rvidx_tab[round&3] + 28; //not correct for round==4! - - } - - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, harq_pid %d, round %d)\n", - module_idP,UE_id,rnti,CC_id,frameP,subframeP,mcs, - first_rb[CC_id],UE_template->nb_rb_ul[harq_pid], - harq_pid, round); - - rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, - first_rb[CC_id], - UE_template->nb_rb_ul[harq_pid]); - first_rb[CC_id]+=UE_template->nb_rb_ul[harq_pid]; // increment for next UE allocation - - UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; - } - */ - - } // UE_is_to_be_scheduled - } // loop over UE_id - } // loop of CC_id + ul_req_tmp_body->number_of_pdus++; + mac->ul_handle++; + + ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + + ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; + ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; + + LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n", + harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,cqi_req); + } /* + else if (round > 0) { //we schedule a retransmission + + ndi = UE_template->oldNDI_UL[harq_pid]; + + if ((round&3)==0) { + mcs = openair_daq_vars.target_ue_ul_mcs; + } else { + mcs = rvidx_tab[round&3] + 28; //not correct for round==4! + + } + + LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, harq_pid %d, round %d)\n", + module_idP,UE_id,rnti,CC_id,frameP,subframeP,mcs, + first_rb[CC_id],UE_template->nb_rb_ul[harq_pid], + harq_pid, round); + + rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, + first_rb[CC_id], + UE_template->nb_rb_ul[harq_pid]); + first_rb[CC_id]+=UE_template->nb_rb_ul[harq_pid]; // increment for next UE allocation + + UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; + } + */ + + } // UE_is_to_be_scheduled + } // loop over UE_id + } // loop of CC_id } diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index f192cd7e127ef01b1ea66adc14c03c4d2217f7a3..e7489ca8e6fffcabb25c34cbb188b1dc7f25dd7c 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -32,10 +32,6 @@ #ifndef __MAC_EXTERN_H__ #define __MAC_EXTERN_H__ - -#ifdef USER_MODE -//#include "stdio.h" -#endif //USER_MODE #include "PHY/defs.h" #include "defs.h" @@ -56,8 +52,8 @@ extern UE_RRC_INST *UE_rrc_inst; extern UE_MAC_INST *UE_mac_inst; -extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 -extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 +extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 +extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 @@ -79,28 +75,26 @@ extern uint32_t RRC_CONNECTION_FLAG; extern uint8_t rb_table[34]; -extern DCI0_5MHz_TDD_1_6_t UL_alloc_pdu; +extern DCI0_5MHz_TDD_1_6_t UL_alloc_pdu; -extern DCI1A_5MHz_TDD_1_6_t RA_alloc_pdu; -extern DCI1A_5MHz_TDD_1_6_t DLSCH_alloc_pdu1A; -extern DCI1A_5MHz_TDD_1_6_t BCCH_alloc_pdu; +extern DCI1A_5MHz_TDD_1_6_t RA_alloc_pdu; +extern DCI1A_5MHz_TDD_1_6_t DLSCH_alloc_pdu1A; +extern DCI1A_5MHz_TDD_1_6_t BCCH_alloc_pdu; -extern DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; -extern DCI1_5MHz_TDD_t DLSCH_alloc_pdu; +extern DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; +extern DCI1_5MHz_TDD_t DLSCH_alloc_pdu; -extern DCI0_5MHz_FDD_t UL_alloc_pdu_fdd; +extern DCI0_5MHz_FDD_t UL_alloc_pdu_fdd; -extern DCI1A_5MHz_FDD_t DLSCH_alloc_pdu1A_fdd; -extern DCI1A_5MHz_FDD_t RA_alloc_pdu_fdd; -extern DCI1A_5MHz_FDD_t BCCH_alloc_pdu_fdd; +extern DCI1A_5MHz_FDD_t DLSCH_alloc_pdu1A_fdd; +extern DCI1A_5MHz_FDD_t RA_alloc_pdu_fdd; +extern DCI1A_5MHz_FDD_t BCCH_alloc_pdu_fdd; -extern DCI1A_5MHz_FDD_t CCCH_alloc_pdu_fdd; -extern DCI1_5MHz_FDD_t DLSCH_alloc_pdu_fdd; +extern DCI1A_5MHz_FDD_t CCCH_alloc_pdu_fdd; +extern DCI1_5MHz_FDD_t DLSCH_alloc_pdu_fdd; extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu1; extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2; extern DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu1E; #endif //DEF_H - - diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index 5b152a1138c80536876d0e83335368aeb90392c9..d3170aaf919e2a24e4599399729b4078e9d6c254 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -17,7 +17,7 @@ *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org - */ + */ /*! \file flexran_agent_mac_proto.h * \brief MAC functions for FlexRAN agent @@ -39,150 +39,178 @@ /* * slice specific scheduler */ -typedef void (*slice_scheduler)(module_id_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); +typedef void (*slice_scheduler) (module_id_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); /* * top level flexran scheduler used by the eNB scheduler */ -void flexran_schedule_ue_spec_default(mid_t mod_id, - uint32_t frame, +void flexran_schedule_ue_spec_default(mid_t mod_id, + uint32_t frame, uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); /* * slice specific scheduler for embb */ void -flexran_schedule_ue_spec_embb(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); +flexran_schedule_ue_spec_embb(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); /* * slice specific scheduler for urllc */ void -flexran_schedule_ue_spec_urllc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); +flexran_schedule_ue_spec_urllc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); /* * slice specific scheduler for mmtc */ void -flexran_schedule_ue_spec_mmtc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); +flexran_schedule_ue_spec_mmtc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); /* * slice specific scheduler for best effort traffic */ void -flexran_schedule_ue_spec_be(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); +flexran_schedule_ue_spec_be(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); /* * common flexran scheduler function */ void -flexran_schedule_ue_spec_common(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info); - -uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, - int total_rbs); - -int flexran_slice_member(int UE_id, - int slice_id); - -int flexran_slice_maxmcs(int slice_id) ; - -void _store_dlsch_buffer (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP); - - -void _assign_rbs_required (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], - int min_rb_unit[MAX_NUM_CCs]); - -void _dlsch_scheduler_pre_processor (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag); - -void _dlsch_scheduler_pre_processor_reset (int module_idP, - int UE_id, - uint8_t CC_id, - int frameP, - int subframeP, - int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); - -void _dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, - int UE_id, - uint8_t CC_id, - int N_RBG, - int transmission_mode, - int min_rb_unit, - uint8_t N_RB_DL, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); +flexran_schedule_ue_spec_common(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); + +uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs); + +int flexran_slice_member(int UE_id, int slice_id); + +int flexran_slice_maxmcs(int slice_id); + +void _store_dlsch_buffer(module_id_t Mod_id, + int slice_id, + frame_t frameP, sub_frame_t subframeP); + + +void _assign_rbs_required(module_id_t Mod_id, + int slice_id, + frame_t frameP, + sub_frame_t subframe, + uint16_t + nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_allowed_slice[MAX_NUM_CCs] + [MAX_NUM_SLICES], int min_rb_unit[MAX_NUM_CCs]); + +void _dlsch_scheduler_pre_processor(module_id_t Mod_id, + int slice_id, + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], + int *mbsfn_flag); + +void _dlsch_scheduler_pre_processor_reset(int module_idP, + int UE_id, + uint8_t CC_id, + int frameP, + int subframeP, + int N_RBG, + uint16_t + nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_allowed_slice[MAX_NUM_CCs] + [MAX_NUM_SLICES], + unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], + unsigned char + MIMO_mode_indicator[MAX_NUM_CCs] + [N_RBG_MAX]); + +void _dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, + int UE_id, + uint8_t CC_id, + int N_RBG, + int transmission_mode, + int min_rb_unit, + uint8_t N_RB_DL, + uint16_t + nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], + unsigned char + MIMO_mode_indicator + [MAX_NUM_CCs][N_RBG_MAX]); /* * Default scheduler used by the eNB agent */ -void flexran_schedule_ue_spec_default(mid_t mod_id, uint32_t frame, uint32_t subframe, - int *mbsfn_flag, Protocol__FlexranMessage **dl_info); +void flexran_schedule_ue_spec_default(mid_t mod_id, uint32_t frame, + uint32_t subframe, int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); /* * Data plane function for applying the DL decisions of the scheduler */ -void flexran_apply_dl_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, - Protocol__FlexranMessage *dl_scheduling_info); +void flexran_apply_dl_scheduling_decisions(mid_t mod_id, uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage * + dl_scheduling_info); /* * Data plane function for applying the UE specific DL decisions of the scheduler */ -void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, - uint32_t n_dl_ue_data, Protocol__FlexDlData **dl_ue_data); +void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + uint32_t n_dl_ue_data, + Protocol__FlexDlData ** + dl_ue_data); /* * Data plane function for filling the DCI structure */ -void flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, Protocol__FlexDlDci *dl_dci); +void flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, + Protocol__FlexDlDci * dl_dci); #endif diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c index 1fb7d9ad47b18f97f8eaca150ded9c4cfb4e901a..0054a2b6f4a2de077f229353ba66d7c3ed295b80 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c @@ -17,7 +17,7 @@ *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org - */ + */ /*! \file flexran_agent_scheduler_dataplane.c * \brief data plane procedures related to eNB scheduling @@ -57,508 +57,541 @@ #include "flexran_agent_common.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/defs.h" // for taus + +void +flexran_apply_dl_scheduling_decisions(mid_t mod_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage * + dl_scheduling_info) +{ + + Protocol__FlexDlMacConfig *mac_config = + dl_scheduling_info->dl_mac_config_msg; + + // Check if there is anything to schedule for random access + if (mac_config->n_dl_rar > 0) { + /*TODO: call the random access data plane function */ + } + // Check if there is anything to schedule for paging/broadcast + if (mac_config->n_dl_broadcast > 0) { + /*TODO: call the broadcast/paging data plane function */ + } + // Check if there is anything to schedule for the UEs + if (mac_config->n_dl_ue_data > 0) { + flexran_apply_ue_spec_scheduling_decisions(mod_id, frame, subframe, + mbsfn_flag, + mac_config-> + n_dl_ue_data, + mac_config->dl_ue_data); + } + +} -void flexran_apply_dl_scheduling_decisions(mid_t mod_id, + +void +flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, uint32_t frame, uint32_t subframe, int *mbsfn_flag, - Protocol__FlexranMessage *dl_scheduling_info) { - - Protocol__FlexDlMacConfig *mac_config = dl_scheduling_info->dl_mac_config_msg; - - // Check if there is anything to schedule for random access - if (mac_config->n_dl_rar > 0) { - /*TODO: call the random access data plane function*/ - } - - // Check if there is anything to schedule for paging/broadcast - if (mac_config->n_dl_broadcast > 0) { - /*TODO: call the broadcast/paging data plane function*/ - } - - // Check if there is anything to schedule for the UEs - if (mac_config->n_dl_ue_data > 0) { - flexran_apply_ue_spec_scheduling_decisions(mod_id, frame, subframe, mbsfn_flag, - mac_config->n_dl_ue_data, mac_config->dl_ue_data); - } - -} + uint32_t n_dl_ue_data, + Protocol__FlexDlData ** + dl_ue_data) +{ + + uint8_t CC_id; + int UE_id; + mac_rlc_status_resp_t rlc_status; + unsigned char ta_len = 0; + unsigned char header_len = 0, header_len_tmp = 0; + unsigned char sdu_lcids[11], offset, num_sdus = 0; + uint16_t nb_rb; + uint16_t TBS, sdu_lengths[11], rnti, padding = 0, post_padding = 0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + uint8_t round = 0; + uint8_t harq_pid = 0; + // LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + uint16_t sdu_length_total = 0; + short ta_update = 0; + eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; + UE_list_t *UE_list = &eNB->UE_list; + // static int32_t tpc_accumulated=0; + UE_sched_ctrl *ue_sched_ctl; + + int last_sdu_header_len = 0; + + int i, j; + + Protocol__FlexDlData *dl_data; + Protocol__FlexDlDci *dl_dci; + + uint32_t rlc_size, n_lc, lcid; + + // For each UE-related command + for (i = 0; i < n_dl_ue_data; i++) { + + dl_data = dl_ue_data[i]; + dl_dci = dl_data->dl_dci; + + CC_id = dl_data->serv_cell_index; + // frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); + + rnti = dl_data->rnti; + UE_id = find_ue(rnti, PHY_vars_eNB_g[mod_id][CC_id]); + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + + round = dl_dci->rv[0]; + harq_pid = dl_dci->harq_process; + + //LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] Scheduling harq %d\n", frame, subframe, harq_pid); + // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d]Now scheduling harq_pid %d (round %d)\n", frame, subframe, harq_pid, round); + + // If this is a new transmission + if (round == 0) { + // First we have to deal with the creation of the PDU based on the message instructions + rlc_status.bytes_in_buffer = 0; + + TBS = dl_dci->tbs_size[0]; + + if (dl_data->n_ce_bitmap > 0) { + //Check if there is TA command and set the length appropriately + ta_len = + (dl_data-> + ce_bitmap[0] & PROTOCOL__FLEX_CE_TYPE__FLPCET_TA) ? 2 + : 0; + } + + num_sdus = 0; + sdu_length_total = 0; + + n_lc = dl_data->n_rlc_pdu; + // Go through each one of the channel commands and create SDUs + header_len = 0; + last_sdu_header_len = 0; + for (j = 0; j < n_lc; j++) { + sdu_lengths[j] = 0; + lcid = + dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->logical_channel_id; + rlc_size = dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->size; + LOG_D(MAC, + "[TEST] [eNB %d] [Frame %d] [Subframe %d], LCID %d, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + mod_id, frame, subframe, lcid, CC_id, rlc_size); + if (rlc_size > 0) { + + rlc_status = mac_rlc_status_ind(mod_id, + rnti, + mod_id, + frame, + subframe, + ENB_FLAG_YES, + MBMS_FLAG_NO, lcid, 0 +#ifdef Rel14 + ,0, 0 +#endif + ); -void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - uint32_t n_dl_ue_data, - Protocol__FlexDlData **dl_ue_data) { - - uint8_t CC_id; - int UE_id; - mac_rlc_status_resp_t rlc_status; - unsigned char ta_len=0; - unsigned char header_len = 0, header_len_tmp = 0; - unsigned char sdu_lcids[11],offset,num_sdus=0; - uint16_t nb_rb; - uint16_t TBS, sdu_lengths[11],rnti,padding=0,post_padding=0; - unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - uint8_t round = 0; - uint8_t harq_pid = 0; - // LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint16_t sdu_length_total = 0; - short ta_update = 0; - eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; - UE_list_t *UE_list = &eNB->UE_list; - // static int32_t tpc_accumulated=0; - UE_sched_ctrl *ue_sched_ctl; - - int last_sdu_header_len = 0; - - int i, j; - - Protocol__FlexDlData *dl_data; - Protocol__FlexDlDci *dl_dci; - - uint32_t rlc_size, n_lc, lcid; - - // For each UE-related command - for (i = 0; i < n_dl_ue_data; i++) { - - dl_data = dl_ue_data[i]; - dl_dci = dl_data->dl_dci; - - CC_id = dl_data->serv_cell_index; - // frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); - - rnti = dl_data->rnti; - UE_id = find_ue(rnti, PHY_vars_eNB_g[mod_id][CC_id]); - - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); - - round = dl_dci->rv[0]; - harq_pid = dl_dci->harq_process; - - //LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] Scheduling harq %d\n", frame, subframe, harq_pid); - // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d]Now scheduling harq_pid %d (round %d)\n", frame, subframe, harq_pid, round); - - // If this is a new transmission - if (round == 0) { - // First we have to deal with the creation of the PDU based on the message instructions - rlc_status.bytes_in_buffer = 0; - - TBS = dl_dci->tbs_size[0]; - - if (dl_data->n_ce_bitmap > 0) { - //Check if there is TA command and set the length appropriately - ta_len = (dl_data->ce_bitmap[0] & PROTOCOL__FLEX_CE_TYPE__FLPCET_TA) ? 2 : 0; - } - - num_sdus = 0; - sdu_length_total = 0; - - n_lc = dl_data->n_rlc_pdu; - // Go through each one of the channel commands and create SDUs - header_len = 0; - last_sdu_header_len = 0; - for (j = 0; j < n_lc; j++) { - sdu_lengths[j] = 0; - lcid = dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->logical_channel_id; - rlc_size = dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->size; - LOG_D(MAC,"[TEST] [eNB %d] [Frame %d] [Subframe %d], LCID %d, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - mod_id, frame, subframe, lcid, CC_id, rlc_size); - if (rlc_size > 0) { - - rlc_status = mac_rlc_status_ind(mod_id, - rnti, - mod_id, - frame, - subframe, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - 0 + if (rlc_status.bytes_in_buffer > 0) { + + if (rlc_status.bytes_in_buffer < rlc_size) { + rlc_size = rlc_status.bytes_in_buffer; + } + + if (rlc_size <= 2) { + rlc_size = 3; + } + + rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, subframe, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, rlc_size // transport block set size #ifdef Rel14 ,0, 0 #endif ); - if (rlc_status.bytes_in_buffer > 0) { - if (rlc_status.bytes_in_buffer < rlc_size) { - rlc_size = rlc_status.bytes_in_buffer; - } + LOG_D(MAC, + "[TEST] RLC can give %d bytes for LCID %d during second call\n", + rlc_status.bytes_in_buffer, lcid); - if (rlc_size <= 2) { - rlc_size = 3; - } - - rlc_status = mac_rlc_status_ind(mod_id, - rnti, - mod_id, - frame, - subframe, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - rlc_size // transport block set size + if (rlc_status.bytes_in_buffer > 0) { + + sdu_lengths[j] = mac_rlc_data_req(mod_id, rnti, mod_id, frame, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, rlc_size, //not used + (char *)&dlsch_buffer[sdu_length_total] #ifdef Rel14 ,0, 0 #endif ); - - LOG_D(MAC, "[TEST] RLC can give %d bytes for LCID %d during second call\n", rlc_status.bytes_in_buffer, lcid); - - if (rlc_status.bytes_in_buffer > 0) { - - sdu_lengths[j] = mac_rlc_data_req(mod_id, - rnti, - mod_id, - frame, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - rlc_size, //not used - (char *)&dlsch_buffer[sdu_length_total] -#ifdef Rel14 - ,0, - 0 + + + LOG_D(MAC, + "[eNB %d][LCID %d] CC_id %d Got %d bytes from RLC\n", + mod_id, lcid, CC_id, sdu_lengths[j]); + sdu_length_total += sdu_lengths[j]; + sdu_lcids[j] = lcid; + + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] + += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx + [lcid] += sdu_lengths[j]; + + if (sdu_lengths[j] < 128) { + header_len += 2; + last_sdu_header_len = 2; + } else { + header_len += 3; + last_sdu_header_len = 3; + } + num_sdus++; + } + } + } + } // SDU creation end + + + if (((sdu_length_total + header_len + ta_len) > 0)) { + + header_len_tmp = header_len; + + // If we have only a single SDU, header length becomes 1 + if ((num_sdus) == 1) { + //if (header_len == 2 || header_len == 3) { + header_len = 1; + } else { + header_len = (header_len - last_sdu_header_len) + 1; + } + + // If we need a 1 or 2 bit padding or no padding at all + if ((TBS - header_len - sdu_length_total - ta_len) <= 2 || (TBS - header_len - sdu_length_total - ta_len) > TBS) { //protect from overflow + padding = + (TBS - header_len - sdu_length_total - ta_len); + post_padding = 0; + } else { // The last sdu needs to have a length field, since we add padding + padding = 0; + header_len = header_len_tmp; + post_padding = TBS - sdu_length_total - header_len - ta_len; // 1 is for the postpadding header + } + + if (ta_len > 0) { + // Reset the measurement + ta_update = flexran_get_TA(mod_id, UE_id, CC_id); + ue_sched_ctl->ta_timer = 20; + eNB_UE_stats->timing_advance_update = 0; + } else { + ta_update = 0; + } + + // If there is nothing to schedule, just leave + if ((sdu_length_total) <= 0) { + harq_pid_updated[UE_id][harq_pid] = 1; + harq_pid_round[UE_id][harq_pid] = 0; + continue; + } + // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] TBS is %d and bytes are %d\n", frame, subframe, TBS, sdu_length_total); + + offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, post_padding); + +#ifdef DEBUG_eNB_SCHEDULER + LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n"); + + for (i = 0; i < 16; i++) { + LOG_T(MAC, "%x.", dlsch_buffer[i]); + } + + LOG_T(MAC, "\n"); #endif - ); - - LOG_D(MAC,"[eNB %d][LCID %d] CC_id %d Got %d bytes from RLC\n",mod_id, lcid, CC_id, sdu_lengths[j]); - sdu_length_total += sdu_lengths[j]; - sdu_lcids[j] = lcid; - - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[j]; - - if (sdu_lengths[j] < 128) { - header_len += 2; - last_sdu_header_len = 2; - } else { - header_len += 3; - last_sdu_header_len = 3; - } - num_sdus++; + // cycle through SDUs and place in dlsch_buffer + memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id]. + payload[0][offset], dlsch_buffer, sdu_length_total); + // memcpy(&eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); + + // fill remainder of DLSCH with random data + for (j = 0; j < (TBS - sdu_length_total - offset); j++) { + UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + + sdu_length_total + + j] = + (char) (taus() & 0xff); + } + + //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff); + if (opt_enabled == 1) { + trace_pdu(1, + (uint8_t *) + UE_list->DLSCH_pdu[CC_id][0][UE_id]. + payload[0], TBS, mod_id, 3, UE_RNTI(mod_id, + UE_id), + eNB->frame, eNB->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", + mod_id, CC_id, frame, UE_RNTI(mod_id, UE_id), + TBS); + } + // store stats + eNB->eNB_stats[CC_id].dlsch_bytes_tx += sdu_length_total; + eNB->eNB_stats[CC_id].dlsch_pdus_tx += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi = + eNB_UE_stats->DL_cqi[0]; + + UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = + mac_eNB_get_rrc_status(mod_id, rnti); + UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; + UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; + + //nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + //Find the number of resource blocks and set them to the template for retransmissions + nb_rb = get_min_rb_unit(mod_id, CC_id); + uint16_t stats_tbs = + mac_xface->get_TBS_DL(dl_dci->mcs[0], nb_rb); + + while (stats_tbs < TBS) { + nb_rb += get_min_rb_unit(mod_id, CC_id); + stats_tbs = + mac_xface->get_TBS_DL(dl_dci->mcs[0], nb_rb); + } + + // LOG_I(FLEXRAN_AGENT, "The MCS was %d\n", dl_dci->mcs[0]); + + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += + nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = + dl_dci->mcs[0]; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = + dl_dci->mcs[0]; + UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; + + UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes = + TBS - sdu_length_total; + UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes += + sdu_length_total; + UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes += TBS; + UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus += 1; + + //eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]]; + //eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); + } else { + LOG_D(FLEXRAN_AGENT, + "No need to schedule a dci after all. Just drop it\n"); + harq_pid_updated[UE_id][harq_pid] = 1; + harq_pid_round[UE_id][harq_pid] = 0; + continue; } - } - } - } // SDU creation end - - - if (((sdu_length_total + header_len + ta_len) > 0)) { - - header_len_tmp = header_len; - - // If we have only a single SDU, header length becomes 1 - if ((num_sdus) == 1) { - //if (header_len == 2 || header_len == 3) { - header_len = 1; - } else { - header_len = (header_len - last_sdu_header_len) + 1; - } - - // If we need a 1 or 2 bit padding or no padding at all - if ((TBS - header_len - sdu_length_total - ta_len) <= 2 - || (TBS - header_len - sdu_length_total - ta_len) > TBS) { //protect from overflow - padding = (TBS - header_len - sdu_length_total - ta_len); - post_padding = 0; - } else { // The last sdu needs to have a length field, since we add padding - padding = 0; - header_len = header_len_tmp; - post_padding = TBS - sdu_length_total - header_len - ta_len; // 1 is for the postpadding header - } - - if (ta_len > 0) { - // Reset the measurement - ta_update = flexran_get_TA(mod_id, UE_id, CC_id); - ue_sched_ctl->ta_timer = 20; - eNB_UE_stats->timing_advance_update = 0; } else { - ta_update = 0; + // No need to create anything apart of DCI in case of retransmission + /*TODO: Must add these */ + // eNB_UE_stats->dlsch_trials[round]++; + //UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission+=1; + //UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx=nb_rb; + //UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx+=nb_rb; + //UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx=nCCECC_id]; } - // If there is nothing to schedule, just leave - if ((sdu_length_total) <= 0) { - harq_pid_updated[UE_id][harq_pid] = 1; - harq_pid_round[UE_id][harq_pid] = 0; - continue; - } + // UE_list->UE_template[CC_id][UE_id].oldNDI[dl_dci->harq_process] = dl_dci->ndi[0]; + // eNB_UE_stats->dlsch_mcs1 = dl_dci->mcs[0]; + + //Fill the proper DCI of OAI + flexran_fill_oai_dci(mod_id, CC_id, rnti, dl_dci); + } +} - // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] TBS is %d and bytes are %d\n", frame, subframe, TBS, sdu_length_total); - - offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], - num_sdus, //num_sdus - sdu_lengths, // - sdu_lcids, - 255, // no drx - ta_update, // timing advance - NULL, // contention res id - padding, - post_padding); +void +flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, + Protocol__FlexDlDci * dl_dci) +{ - + void *DLSCH_dci = NULL; + DCI_PDU *DCI_pdu; + unsigned char harq_pid = 0; + // unsigned char round = 0; + LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; + int size_bits = 0, size_bytes = 0; + eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; + UE_list_t *UE_list = &eNB->UE_list; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; - -#ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC,"[eNB %d] First 16 bytes of DLSCH : \n"); - - for (i=0; i<16; i++) { - LOG_T(MAC,"%x.",dlsch_buffer[i]); + int UE_id = find_ue(rnti, PHY_vars_eNB_g[mod_id][CC_id]); + + uint32_t format; + + harq_pid = dl_dci->harq_process; + // round = dl_dci->rv[0]; + + // Note this code is for a specific DCI format + DLSCH_dci = + (void *) UE_list->UE_template[CC_id][UE_id].DLSCH_DCI[harq_pid]; + DCI_pdu = &eNB->common_channels[CC_id].DCI_pdu; + + frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); + + if (dl_dci->has_tpc == 1) { + // Check if tpc has been set and reset measurement */ + if ((dl_dci->tpc == 0) || (dl_dci->tpc == 2)) { + eNB_UE_stats = + mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + eNB_UE_stats->Po_PUCCH_update = 0; } - - LOG_T(MAC,"\n"); -#endif - // cycle through SDUs and place in dlsch_buffer - memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total); - // memcpy(&eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); - - // fill remainder of DLSCH with random data - for (j=0; j<(TBS-sdu_length_total-offset); j++) { - UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff); + } + + + switch (frame_parms[CC_id]->N_RB_DL) { + case 6: + if (frame_parms[CC_id]->frame_type == TDD) { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_TDD_1(DCI1_1_5MHz_TDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_1_5MHz_TDD_t); + size_bits = sizeof_DCI1_1_5MHz_TDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } + } else { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_FDD_1(DCI1_1_5MHz_FDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_1_5MHz_FDD_t); + size_bits = sizeof_DCI1_1_5MHz_FDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } + } + break; + case 25: + if (frame_parms[CC_id]->frame_type == TDD) { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_TDD_1(DCI1_5MHz_TDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_5MHz_TDD_t); + size_bits = sizeof_DCI1_5MHz_TDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } + } else { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_FDD_1(DCI1_5MHz_FDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_5MHz_FDD_t); + size_bits = sizeof_DCI1_5MHz_FDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } } - - //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff); - if (opt_enabled == 1) { - trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], - TBS, mod_id, 3, UE_RNTI(mod_id, UE_id), - eNB->frame, eNB->subframe,0,0); - LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", - mod_id, CC_id, frame, UE_RNTI(mod_id,UE_id), TBS); + break; + case 50: + if (frame_parms[CC_id]->frame_type == TDD) { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_TDD_1(DCI1_10MHz_TDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_10MHz_TDD_t); + size_bits = sizeof_DCI1_10MHz_TDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } + } else { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_FDD_1(DCI1_10MHz_FDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_10MHz_FDD_t); + size_bits = sizeof_DCI1_10MHz_FDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } } - - // store stats - eNB->eNB_stats[CC_id].dlsch_bytes_tx+=sdu_length_total; - eNB->eNB_stats[CC_id].dlsch_pdus_tx+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->DL_cqi[0]; - - UE_list->eNB_UE_stats[CC_id][UE_id].crnti= rnti; - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status=mac_eNB_get_rrc_status(mod_id, rnti); - UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; - UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; - - //nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - //Find the number of resource blocks and set them to the template for retransmissions - nb_rb = get_min_rb_unit(mod_id, CC_id); - uint16_t stats_tbs = mac_xface->get_TBS_DL(dl_dci->mcs[0], nb_rb); - - while (stats_tbs < TBS) { - nb_rb += get_min_rb_unit(mod_id, CC_id); - stats_tbs = mac_xface->get_TBS_DL(dl_dci->mcs[0], nb_rb); + break; + case 100: + if (frame_parms[CC_id]->frame_type == TDD) { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_TDD_1(DCI1_20MHz_TDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_20MHz_TDD_t); + size_bits = sizeof_DCI1_20MHz_TDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } + } else { + if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { + FILL_DCI_FDD_1(DCI1_20MHz_FDD_t, DLSCH_dci, dl_dci); + size_bytes = sizeof(DCI1_20MHz_FDD_t); + size_bits = sizeof_DCI1_20MHz_FDD_t; + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { + //TODO + } else if (dl_dci->format == + PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { + //TODO + } } - - // LOG_I(FLEXRAN_AGENT, "The MCS was %d\n", dl_dci->mcs[0]); - - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=dl_dci->mcs[0]; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=dl_dci->mcs[0]; - UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; - - UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes= TBS - sdu_length_total; - UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes+= sdu_length_total; - UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes+= TBS; - UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus+=1; - - //eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]]; - //eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); - } else { - LOG_D(FLEXRAN_AGENT, "No need to schedule a dci after all. Just drop it\n"); - harq_pid_updated[UE_id][harq_pid] = 1; - harq_pid_round[UE_id][harq_pid] = 0; - continue; - } - } else { - // No need to create anything apart of DCI in case of retransmission - /*TODO: Must add these */ - // eNB_UE_stats->dlsch_trials[round]++; - //UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission+=1; - //UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx=nb_rb; - //UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx+=nb_rb; - //UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx=nCCECC_id]; + break; } - // UE_list->UE_template[CC_id][UE_id].oldNDI[dl_dci->harq_process] = dl_dci->ndi[0]; - // eNB_UE_stats->dlsch_mcs1 = dl_dci->mcs[0]; - - //Fill the proper DCI of OAI - flexran_fill_oai_dci(mod_id, CC_id, rnti, dl_dci); - } -} -void flexran_fill_oai_dci(mid_t mod_id, uint32_t CC_id, uint32_t rnti, - Protocol__FlexDlDci *dl_dci) { - - void *DLSCH_dci = NULL; - DCI_PDU *DCI_pdu; - - unsigned char harq_pid = 0; - // unsigned char round = 0; - LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; - int size_bits = 0, size_bytes = 0; - eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; - UE_list_t *UE_list = &eNB->UE_list; - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - - int UE_id = find_ue(rnti, PHY_vars_eNB_g[mod_id][CC_id]); - - uint32_t format; - - harq_pid = dl_dci->harq_process; - // round = dl_dci->rv[0]; - - // Note this code is for a specific DCI format - DLSCH_dci = (void *)UE_list->UE_template[CC_id][UE_id].DLSCH_DCI[harq_pid]; - DCI_pdu = &eNB->common_channels[CC_id].DCI_pdu; - - frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id); - - if (dl_dci->has_tpc == 1) { - // Check if tpc has been set and reset measurement */ - if ((dl_dci->tpc == 0) || (dl_dci->tpc == 2)) { - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - eNB_UE_stats->Po_PUCCH_update = 0; - } - } - - - switch (frame_parms[CC_id]->N_RB_DL) { - case 6: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_1_5MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - size_bits = sizeof_DCI1_1_5MHz_TDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_1_5MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_1_5MHz_FDD_t); - size_bits = sizeof_DCI1_1_5MHz_FDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } + //Set format to the proper type + switch (dl_dci->format) { + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1: + format = format1; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1A: + format = format1A; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1B: + format = format1B; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1C: + format = format1C; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D: + format = format1E_2A_M10PRB; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2: + format = format2; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A: + format = format2A; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2B: + format = format2B; + break; + case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_3: + format = 3; + break; + default: + /*TODO: Need to deal with unsupported DCI type */ + return; } - break; - case 25: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_5MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_5MHz_TDD_t); - size_bits = sizeof_DCI1_5MHz_TDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_5MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_5MHz_FDD_t); - size_bits = sizeof_DCI1_5MHz_FDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } - break; - case 50: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_10MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_10MHz_TDD_t); - size_bits = sizeof_DCI1_10MHz_TDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_10MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_10MHz_FDD_t); - size_bits = sizeof_DCI1_10MHz_FDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } - break; - case 100: - if (frame_parms[CC_id]->frame_type == TDD) { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_TDD_1(DCI1_20MHz_TDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_20MHz_TDD_t); - size_bits = sizeof_DCI1_20MHz_TDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } else { - if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1) { - FILL_DCI_FDD_1(DCI1_20MHz_FDD_t, DLSCH_dci, dl_dci); - size_bytes = sizeof(DCI1_20MHz_FDD_t); - size_bits = sizeof_DCI1_20MHz_FDD_t; - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A) { - //TODO - } else if (dl_dci->format == PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D) { - //TODO - } - } - break; - } - - //Set format to the proper type - switch(dl_dci->format) { - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1: - format = format1; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1A: - format = format1A; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1B: - format = format1B; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1C: - format = format1C; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D: - format = format1E_2A_M10PRB; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2: - format = format2; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A: - format = format2A; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2B: - format = format2B; - break; - case PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_3: - format = 3; - break; - default: - /*TODO: Need to deal with unsupported DCI type*/ - return; - } - - add_ue_spec_dci(DCI_pdu, - DLSCH_dci, - rnti, - size_bytes, - dl_dci->aggr_level, - size_bits, - format, - 0); + + add_ue_spec_dci(DCI_pdu, + DLSCH_dci, + rnti, + size_bytes, dl_dci->aggr_level, size_bits, format, 0); } diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index d6f7e5a900c37f8c66c93e64bd73e9b343ab8f4c..c19949ab1df216ca39538ec3b17763828ac5c5b6 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -17,7 +17,7 @@ *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org - */ + */ /*! \file flexran_agent_scheduler_dlsch_ue.c * \brief procedures related to eNB for the DLSCH transport channel @@ -58,10 +58,10 @@ #include "flexran_agent_mac.h" #include <dlfcn.h> -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/defs.h" // for taus #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif #define ENABLE_MAC_PAYLOAD_DEBUG @@ -74,14 +74,14 @@ /*!\brief UE ULSCH scheduling states*/ typedef enum { - MIN_SLICE_STRATEGY = 0, - SLICE_MASK, - UEID_TO_SLICEID, - MAX_SLICE_STRATEGY + MIN_SLICE_STRATEGY = 0, + SLICE_MASK, + UEID_TO_SLICEID, + MAX_SLICE_STRATEGY } SLICING_STRATEGY; // this assumes a max of of 16 UE per eNB/CC -#define SLICE0_MASK 0x000f +#define SLICE0_MASK 0x000f #define SLICE1_MASK 0x00f0 #define SLICE2_MASK 0x0f00 #define SLICE3_MASK 0xf000 @@ -96,26 +96,28 @@ int slicing_strategy = UEID_TO_SLICEID; int slicing_strategy_current = UEID_TO_SLICEID; // RB share for each slice for past and current time -float slice_percentage[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; -float slice_percentage_current[MAX_NUM_SLICES] = {1.0, 0.0, 0.0, 0.0}; +float slice_percentage[MAX_NUM_SLICES] = { 1.0, 0.0, 0.0, 0.0 }; +float slice_percentage_current[MAX_NUM_SLICES] = { 1.0, 0.0, 0.0, 0.0 }; + float total_slice_percentage = 0; // MAX MCS for each slice for past and current time -int slice_maxmcs[MAX_NUM_SLICES] = {28, 28, 28, 28}; -int slice_maxmcs_current[MAX_NUM_SLICES] = {28, 28, 28, 28}; +int slice_maxmcs[MAX_NUM_SLICES] = { 28, 28, 28, 28 }; +int slice_maxmcs_current[MAX_NUM_SLICES] = { 28, 28, 28, 28 }; -int update_dl_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; -int update_dl_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; +int update_dl_scheduler[MAX_NUM_SLICES] = { 1, 1, 1, 1 }; +int update_dl_scheduler_current[MAX_NUM_SLICES] = { 1, 1, 1, 1 }; // name of available scheduler -char *dl_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_spec_embb", - "flexran_schedule_ue_spec_urllc", - "flexran_schedule_ue_spec_mmtc", - "flexran_schedule_ue_spec_be" // best effort +char *dl_scheduler_type[MAX_NUM_SLICES] = + { "flexran_schedule_ue_spec_embb", + "flexran_schedule_ue_spec_urllc", + "flexran_schedule_ue_spec_mmtc", + "flexran_schedule_ue_spec_be" // best effort }; // pointer to the slice specific scheduler -slice_scheduler slice_sched[MAX_NUM_SLICES] = {0}; +slice_scheduler slice_sched[MAX_NUM_SLICES] = { 0 }; /** @@ -125,589 +127,699 @@ slice_scheduler slice_sched[MAX_NUM_SLICES] = {0}; // This function stores the downlink buffer for all the logical channels -void _store_dlsch_buffer (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP) +void +_store_dlsch_buffer(module_id_t Mod_id, + int slice_id, frame_t frameP, sub_frame_t subframeP) { - int UE_id,i; - rnti_t rnti; - mac_rlc_status_resp_t rlc_status; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - UE_TEMPLATE *UE_template; - - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) continue; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - UE_template = &UE_list->UE_template[UE_PCCID(Mod_id,UE_id)][UE_id]; - - // clear logical channel interface variables - UE_template->dl_buffer_total = 0; - UE_template->dl_pdus_total = 0; - - for(i=0; i< MAX_NUM_LCID; i++) { - UE_template->dl_buffer_info[i]=0; - UE_template->dl_pdus_in_buffer[i]=0; - UE_template->dl_buffer_head_sdu_creation_time[i]=0; - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i]=0; - } + int UE_id, i; + rnti_t rnti; + mac_rlc_status_resp_t rlc_status; + UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; + UE_TEMPLATE *UE_template; - rnti = UE_RNTI(Mod_id,UE_id); + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) + continue; + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; - for(i=0; i< MAX_NUM_LCID; i++) { // loop over all the logical channels + UE_template = + &UE_list->UE_template[UE_PCCID(Mod_id, UE_id)][UE_id]; - rlc_status = mac_rlc_status_ind(Mod_id,rnti, Mod_id,frameP,subframeP,ENB_FLAG_YES,MBMS_FLAG_NO,i,0 + // clear logical channel interface variables + UE_template->dl_buffer_total = 0; + UE_template->dl_pdus_total = 0; + + for (i = 0; i < MAX_NUM_LCID; i++) { + UE_template->dl_buffer_info[i] = 0; + UE_template->dl_pdus_in_buffer[i] = 0; + UE_template->dl_buffer_head_sdu_creation_time[i] = 0; + UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = 0; + } + + rnti = UE_RNTI(Mod_id, UE_id); + + for (i = 0; i < MAX_NUM_LCID; i++) { // loop over all the logical channels + + rlc_status = + mac_rlc_status_ind(Mod_id, rnti, Mod_id, frameP, subframeP, + ENB_FLAG_YES, MBMS_FLAG_NO, i, 0 #ifdef Rel14 - ,0, 0 + ,0, 0 #endif - ); - UE_template->dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel - UE_template->dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; - UE_template->dl_buffer_head_sdu_creation_time[i] = rlc_status.head_sdu_creation_time ; - UE_template->dl_buffer_head_sdu_creation_time_max = cmax(UE_template->dl_buffer_head_sdu_creation_time_max, - rlc_status.head_sdu_creation_time ); - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = rlc_status.head_sdu_remaining_size_to_send; - UE_template->dl_buffer_head_sdu_is_segmented[i] = rlc_status.head_sdu_is_segmented; - UE_template->dl_buffer_total += UE_template->dl_buffer_info[i];//storing the total dlsch buffer - UE_template->dl_pdus_total += UE_template->dl_pdus_in_buffer[i]; + ); + + UE_template->dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel + UE_template->dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; + UE_template->dl_buffer_head_sdu_creation_time[i] = + rlc_status.head_sdu_creation_time; + UE_template->dl_buffer_head_sdu_creation_time_max = + cmax(UE_template->dl_buffer_head_sdu_creation_time_max, + rlc_status.head_sdu_creation_time); + UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = + rlc_status.head_sdu_remaining_size_to_send; + UE_template->dl_buffer_head_sdu_is_segmented[i] = + rlc_status.head_sdu_is_segmented; + UE_template->dl_buffer_total += UE_template->dl_buffer_info[i]; //storing the total dlsch buffer + UE_template->dl_pdus_total += + UE_template->dl_pdus_in_buffer[i]; #ifdef DEBUG_eNB_SCHEDULER - /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : - * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent - */ - if (UE_template->dl_buffer_info[i]>0) - LOG_D(MAC, - "[eNB %d][SLICE %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmented %d \n", - Mod_id, slice_id,frameP, subframeP, UE_id, - i, UE_template->dl_pdus_in_buffer[i],UE_template->dl_buffer_info[i], - UE_template->dl_buffer_head_sdu_creation_time[i], - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i], - UE_template->dl_buffer_head_sdu_is_segmented[i] - ); - + /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : + * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent + */ + if (UE_template->dl_buffer_info[i] > 0) + LOG_D(MAC, + "[eNB %d][SLICE %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", + Mod_id, slice_id, frameP, subframeP, UE_id, + i, UE_template->dl_pdus_in_buffer[i], + UE_template->dl_buffer_info[i], + UE_template->dl_buffer_head_sdu_creation_time[i], + UE_template-> + dl_buffer_head_sdu_remaining_size_to_send[i], + UE_template->dl_buffer_head_sdu_is_segmented[i]); #endif - } + } - //#ifdef DEBUG_eNB_SCHEDULER - if ( UE_template->dl_buffer_total>0) - LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", - Mod_id, frameP, subframeP, UE_id, - UE_template->dl_buffer_total, - UE_template->dl_pdus_total - ); + //#ifdef DEBUG_eNB_SCHEDULER + if (UE_template->dl_buffer_total > 0) + LOG_D(MAC, + "[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", + Mod_id, frameP, subframeP, UE_id, + UE_template->dl_buffer_total, + UE_template->dl_pdus_total); - //#endif - } + //#endif + } } // This function returns the estimated number of RBs required by each UE for downlink scheduling -void _assign_rbs_required (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], - int min_rb_unit[MAX_NUM_CCs]) +void +_assign_rbs_required(module_id_t Mod_id, + int slice_id, + frame_t frameP, + sub_frame_t subframe, + uint16_t + nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs] + [MAX_NUM_SLICES], int min_rb_unit[MAX_NUM_CCs]) { - rnti_t rnti; - uint16_t TBS = 0; - LTE_eNB_UE_stats *eNB_UE_stats[MAX_NUM_CCs]; - int UE_id,n,i,j,CC_id,pCCid,tmp; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - // UE_TEMPLATE *UE_template; - - // clear rb allocations across all CC_ids - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) continue; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - pCCid = UE_PCCID(Mod_id,UE_id); - rnti = UE_list->UE_template[pCCid][UE_id].rnti; - - /* skip UE not present in PHY (for any of its active CCs) */ - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - //update CQI information across component carriers - for (n=0; n<UE_list->numactiveCCs[UE_id]; n++) { - CC_id = UE_list->ordered_CCids[n][UE_id]; - eNB_UE_stats[CC_id] = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti); - eNB_UE_stats[CC_id]->dlsch_mcs1 = cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]; - } + rnti_t rnti; + uint16_t TBS = 0; + LTE_eNB_UE_stats *eNB_UE_stats[MAX_NUM_CCs]; + int UE_id, n, i, j, CC_id, pCCid, tmp; + UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; + // UE_TEMPLATE *UE_template; - // provide the list of CCs sorted according to MCS - for (i=0; i<UE_list->numactiveCCs[UE_id]; i++) { - for (j=i+1; j<UE_list->numactiveCCs[UE_id]; j++) { - DevAssert( j < MAX_NUM_CCs ); - - if (eNB_UE_stats[UE_list->ordered_CCids[i][UE_id]]->dlsch_mcs1 > - eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]]->dlsch_mcs1) { - tmp = UE_list->ordered_CCids[i][UE_id]; - UE_list->ordered_CCids[i][UE_id] = UE_list->ordered_CCids[j][UE_id]; - UE_list->ordered_CCids[j][UE_id] = tmp; - } - } - } + // clear rb allocations across all CC_ids + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) + continue; + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + + pCCid = UE_PCCID(Mod_id, UE_id); + rnti = UE_list->UE_template[pCCid][UE_id].rnti; + + /* skip UE not present in PHY (for any of its active CCs) */ + if (!phy_stats_exist(Mod_id, rnti)) + continue; - /* NN --> RK - * check the index of UE_template" - */ - if (UE_list->UE_template[pCCid][UE_id].dl_buffer_total> 0) { - LOG_D(MAC,"[preprocessor] assign RB for UE %d\n",UE_id); - - for (i=0; i<UE_list->numactiveCCs[UE_id]; i++) { - CC_id = UE_list->ordered_CCids[i][UE_id]; - eNB_UE_stats[CC_id] = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti); - - if (cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)] == 0) {//eNB_UE_stats[CC_id]->dlsch_mcs1==0) { - nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small - } else { - nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; - } - - TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_required[CC_id][UE_id]); - nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage[slice_id], - flexran_get_N_RB_DL(Mod_id, CC_id)); - LOG_D(MAC,"[preprocessor] start RB assignment for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", - UE_id, CC_id, UE_list->UE_template[pCCid][UE_id].dl_buffer_total, - nb_rbs_required[CC_id][UE_id], flexran_get_ue_wcqi(Mod_id, UE_id), TBS); - - /* calculating required number of RBs for each UE */ - while (TBS < UE_list->UE_template[pCCid][UE_id].dl_buffer_total) { - nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; - - if (nb_rbs_required[CC_id][UE_id] > nb_rbs_allowed_slice[CC_id][slice_id]) { - TBS = mac_xface->get_TBS_DL(flexran_get_ue_wcqi(Mod_id, UE_id), nb_rbs_allowed_slice[CC_id][slice_id]); - nb_rbs_required[CC_id][UE_id] = nb_rbs_allowed_slice[CC_id][slice_id]; - break; - } - - TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_required[CC_id][UE_id]); - } // end of while - - LOG_D(MAC,"[eNB %d][SLICE %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", - Mod_id, slice_id,frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]); - } + //update CQI information across component carriers + for (n = 0; n < UE_list->numactiveCCs[UE_id]; n++) { + CC_id = UE_list->ordered_CCids[n][UE_id]; + eNB_UE_stats[CC_id] = + mac_xface->get_eNB_UE_stats(Mod_id, CC_id, rnti); + eNB_UE_stats[CC_id]->dlsch_mcs1 = + cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]; + } + + // provide the list of CCs sorted according to MCS + for (i = 0; i < UE_list->numactiveCCs[UE_id]; i++) { + for (j = i + 1; j < UE_list->numactiveCCs[UE_id]; j++) { + DevAssert(j < MAX_NUM_CCs); + + if (eNB_UE_stats[UE_list->ordered_CCids[i][UE_id]]-> + dlsch_mcs1 > + eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]]-> + dlsch_mcs1) { + tmp = UE_list->ordered_CCids[i][UE_id]; + UE_list->ordered_CCids[i][UE_id] = + UE_list->ordered_CCids[j][UE_id]; + UE_list->ordered_CCids[j][UE_id] = tmp; + } + } + } + + /* NN --> RK + * check the index of UE_template" + */ + if (UE_list->UE_template[pCCid][UE_id].dl_buffer_total > 0) { + LOG_D(MAC, "[preprocessor] assign RB for UE %d\n", UE_id); + + for (i = 0; i < UE_list->numactiveCCs[UE_id]; i++) { + CC_id = UE_list->ordered_CCids[i][UE_id]; + eNB_UE_stats[CC_id] = + mac_xface->get_eNB_UE_stats(Mod_id, CC_id, rnti); + + if (cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)] == 0) { //eNB_UE_stats[CC_id]->dlsch_mcs1==0) { + nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small + } else { + nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; + } + + TBS = + mac_xface->get_TBS_DL(cqi_to_mcs + [flexran_get_ue_wcqi + (Mod_id, UE_id)], + nb_rbs_required[CC_id][UE_id]); + nb_rbs_allowed_slice[CC_id][slice_id] = + flexran_nb_rbs_allowed_slice(slice_percentage + [slice_id], + flexran_get_N_RB_DL + (Mod_id, CC_id)); + LOG_D(MAC, + "[preprocessor] start RB assignement for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", + UE_id, CC_id, + UE_list->UE_template[pCCid][UE_id].dl_buffer_total, + nb_rbs_required[CC_id][UE_id], + flexran_get_ue_wcqi(Mod_id, UE_id), TBS); + + /* calculating required number of RBs for each UE */ + while (TBS < + UE_list->UE_template[pCCid][UE_id]. + dl_buffer_total) { + nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; + + if (nb_rbs_required[CC_id][UE_id] > + nb_rbs_allowed_slice[CC_id][slice_id]) { + TBS = + mac_xface->get_TBS_DL(flexran_get_ue_wcqi + (Mod_id, UE_id), + nb_rbs_allowed_slice + [CC_id] + [slice_id]); + nb_rbs_required[CC_id][UE_id] = + nb_rbs_allowed_slice[CC_id][slice_id]; + break; + } + + TBS = + mac_xface->get_TBS_DL(cqi_to_mcs + [flexran_get_ue_wcqi + (Mod_id, UE_id)], + nb_rbs_required[CC_id] + [UE_id]); + } // end of while + + LOG_D(MAC, + "[eNB %d][SLICE %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", + Mod_id, slice_id, frameP, UE_id, CC_id, + min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], + TBS, cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]); + } + } } - } } -void _dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, - int UE_id, - uint8_t CC_id, - int N_RBG, - int transmission_mode, - int min_rb_unit, - uint8_t N_RB_DL, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]) { - int i; - UE_list_t *UE_list=&eNB_mac_inst[Mod_id].UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - for(i=0; i<N_RBG; i++) { - - if((rballoc_sub[CC_id][i] == 0) && - (ue_sched_ctl->rballoc_sub_UE[CC_id][i] == 0) && - (nb_rbs_required_remaining[CC_id][UE_id]>0) && - (ue_sched_ctl->pre_nb_available_rbs[CC_id] < nb_rbs_required[CC_id][UE_id])) { - - // if this UE is not scheduled for TM5 - if (ue_sched_ctl->dl_pow_off[CC_id] != 0 ) { - - if ((i == N_RBG-1) && ((N_RB_DL == 25) || (N_RB_DL == 50))) { - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5 ) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit+1; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit - 1; - } else { - if (nb_rbs_required_remaining[CC_id][UE_id] >= min_rb_unit){ - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5 ) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit; - } +void +_dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, + int UE_id, + uint8_t CC_id, + int N_RBG, + int transmission_mode, + int min_rb_unit, + uint8_t N_RB_DL, + uint16_t + nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], unsigned char + MIMO_mode_indicator + [MAX_NUM_CCs][N_RBG_MAX]) +{ + int i; + UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + for (i = 0; i < N_RBG; i++) { + + if ((rballoc_sub[CC_id][i] == 0) && + (ue_sched_ctl->rballoc_sub_UE[CC_id][i] == 0) && + (nb_rbs_required_remaining[CC_id][UE_id] > 0) && + (ue_sched_ctl->pre_nb_available_rbs[CC_id] < + nb_rbs_required[CC_id][UE_id])) { + + // if this UE is not scheduled for TM5 + if (ue_sched_ctl->dl_pow_off[CC_id] != 0) { + + if ((i == N_RBG - 1) + && ((N_RB_DL == 25) || (N_RB_DL == 50))) { + rballoc_sub[CC_id][i] = 1; + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; + MIMO_mode_indicator[CC_id][i] = 1; + if (transmission_mode == 5) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + nb_rbs_required_remaining[CC_id][UE_id] = + nb_rbs_required_remaining[CC_id][UE_id] - + min_rb_unit + 1; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = + ue_sched_ctl->pre_nb_available_rbs[CC_id] + + min_rb_unit - 1; + } else { + if (nb_rbs_required_remaining[CC_id][UE_id] >= + min_rb_unit) { + rballoc_sub[CC_id][i] = 1; + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; + MIMO_mode_indicator[CC_id][i] = 1; + if (transmission_mode == 5) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + nb_rbs_required_remaining[CC_id][UE_id] = + nb_rbs_required_remaining[CC_id][UE_id] - + min_rb_unit; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = + ue_sched_ctl->pre_nb_available_rbs[CC_id] + + min_rb_unit; + } + } + } // dl_pow_off[CC_id][UE_id] ! = 0 } - } // dl_pow_off[CC_id][UE_id] ! = 0 } - } } -void _dlsch_scheduler_pre_processor_reset (int module_idP, - int UE_id, - uint8_t CC_id, - int frameP, - int subframeP, - int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]) { - int i,j; - UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - uint8_t *vrb_map = eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; - int RBGsize = PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL/N_RBG; +void +_dlsch_scheduler_pre_processor_reset(int module_idP, + int UE_id, + uint8_t CC_id, + int frameP, + int subframeP, + int N_RBG, + uint16_t nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs][NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_allowed_slice[MAX_NUM_CCs] + [MAX_NUM_SLICES], unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], unsigned char + MIMO_mode_indicator[MAX_NUM_CCs] + [N_RBG_MAX]) +{ + int i, j; + UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + uint8_t *vrb_map = + eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; + int RBGsize = + PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.N_RB_DL / N_RBG; #ifdef SF05_LIMIT - //int subframe05_limit=0; - int sf05_upper=-1,sf05_lower=-1; + //int subframe05_limit=0; + int sf05_upper = -1, sf05_lower = -1; #endif - // LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - - flexran_update_TA(module_idP, UE_id, CC_id); - - if (UE_id==0) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_TIMING_ADVANCE,ue_sched_ctl->ta_update); - } - nb_rbs_required[CC_id][UE_id]=0; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; - ue_sched_ctl->dl_pow_off[CC_id] = 2; - nb_rbs_required_remaining[CC_id][UE_id] = 0; - for (i=0; i<n_active_slices;i++) - nb_rbs_allowed_slice[CC_id][i] = 0; -#ifdef SF05_LIMIT - switch (N_RBG) { - case 6: - sf05_lower=0; - sf05_upper=5; - break; - case 8: - sf05_lower=2; - sf05_upper=5; - break; - case 13: - sf05_lower=4; - sf05_upper=7; - break; - case 17: - sf05_lower=7; - sf05_upper=9; - break; - case 25: - sf05_lower=11; - sf05_upper=13; - break; - } + // LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); + + flexran_update_TA(module_idP, UE_id, CC_id); + + if (UE_id == 0) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME + (VCD_SIGNAL_DUMPER_VARIABLES_UE0_TIMING_ADVANCE, + ue_sched_ctl->ta_update); + } + nb_rbs_required[CC_id][UE_id] = 0; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; + ue_sched_ctl->dl_pow_off[CC_id] = 2; + nb_rbs_required_remaining[CC_id][UE_id] = 0; + for (i = 0; i < n_active_slices; i++) + nb_rbs_allowed_slice[CC_id][i] = 0; +#ifdef SF05_LIMIT + switch (N_RBG) { + case 6: + sf05_lower = 0; + sf05_upper = 5; + break; + case 8: + sf05_lower = 2; + sf05_upper = 5; + break; + case 13: + sf05_lower = 4; + sf05_upper = 7; + break; + case 17: + sf05_lower = 7; + sf05_upper = 9; + break; + case 25: + sf05_lower = 11; + sf05_upper = 13; + break; + } #endif - // Initialize Subbands according to VRB map - for (i=0; i<N_RBG; i++) { - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 0; - rballoc_sub[CC_id][i] = 0; + // Initialize Subbands according to VRB map + for (i = 0; i < N_RBG; i++) { + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 0; + rballoc_sub[CC_id][i] = 0; #ifdef SF05_LIMIT - // for avoiding 6+ PRBs around DC in subframe 0-5 (avoid excessive errors) + // for avoiding 6+ PRBs around DC in subframe 0-5 (avoid excessive errors) - if ((subframeP==0 || subframeP==5) && - (i>=sf05_lower && i<=sf05_upper)) - rballoc_sub[CC_id][i]=1; + if ((subframeP == 0 || subframeP == 5) && + (i >= sf05_lower && i <= sf05_upper)) + rballoc_sub[CC_id][i] = 1; #endif - // for SI-RNTI,RA-RNTI and P-RNTI allocations - for (j=0;j<RBGsize;j++) { - if (vrb_map[j+(i*RBGsize)]!=0) { - rballoc_sub[CC_id][i] = 1; - LOG_D(MAC,"Frame %d, subframe %d : vrb %d allocated\n",frameP,subframeP,j+(i*RBGsize)); - break; - } + // for SI-RNTI,RA-RNTI and P-RNTI allocations + for (j = 0; j < RBGsize; j++) { + if (vrb_map[j + (i * RBGsize)] != 0) { + rballoc_sub[CC_id][i] = 1; + LOG_D(MAC, "Frame %d, subframe %d : vrb %d allocated\n", + frameP, subframeP, j + (i * RBGsize)); + break; + } + } + LOG_D(MAC, "Frame %d Subframe %d CC_id %d RBG %i : rb_alloc %d\n", + frameP, subframeP, CC_id, i, rballoc_sub[CC_id][i]); + MIMO_mode_indicator[CC_id][i] = 2; } - LOG_D(MAC,"Frame %d Subframe %d CC_id %d RBG %i : rb_alloc %d\n",frameP,subframeP,CC_id,i,rballoc_sub[CC_id][i]); - MIMO_mode_indicator[CC_id][i] = 2; - } } // This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done -void _dlsch_scheduler_pre_processor (module_id_t Mod_id, - int slice_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag) +void +_dlsch_scheduler_pre_processor(module_id_t Mod_id, + int slice_id, + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], int *mbsfn_flag) { - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], total_ue_count; - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; - int UE_id, i; - uint8_t round = 0; - uint8_t harq_pid = 0; - uint16_t ii,j; - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t average_rbs_per_user[MAX_NUM_CCs] = {0}; - rnti_t rnti; - int min_rb_unit[MAX_NUM_CCs]; - uint16_t r1=0; - uint8_t CC_id; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs] = {0}; - - int transmission_mode = 0; - UE_sched_ctrl *ue_sched_ctl; - - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - if (mbsfn_flag[CC_id]>0) // If this CC is allocated for MBSFN skip it here - continue; - - frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); - - - min_rb_unit[CC_id]=get_min_rb_unit(Mod_id,CC_id); - - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) continue; - - UE_id = i; - // Initialize scheduling information for all active UEs - - //if (flexran_slice_member(UE_id, slice_id) == 0) - //continue; - _dlsch_scheduler_pre_processor_reset(Mod_id, - UE_id, - CC_id, - frameP, - subframeP, - N_RBG[CC_id], - nb_rbs_required, - nb_rbs_required_remaining, - nb_rbs_allowed_slice, - rballoc_sub, - MIMO_mode_indicator); + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], total_ue_count; + unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; + int UE_id, i; + uint8_t round = 0; + uint8_t harq_pid = 0; + uint16_t ii, j; + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; + uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t average_rbs_per_user[MAX_NUM_CCs] = { 0 }; + rnti_t rnti; + int min_rb_unit[MAX_NUM_CCs]; + uint16_t r1 = 0; + uint8_t CC_id; + UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; + LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs] = { 0 }; + + int transmission_mode = 0; + UE_sched_ctrl *ue_sched_ctl; + + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + + if (mbsfn_flag[CC_id] > 0) // If this CC is allocated for MBSFN skip it here + continue; + frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id, CC_id); + + + min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); + + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; + + UE_id = i; + // Initialize scheduling information for all active UEs + + //if (flexran_slice_member(UE_id, slice_id) == 0) + //continue; + _dlsch_scheduler_pre_processor_reset(Mod_id, + UE_id, + CC_id, + frameP, + subframeP, + N_RBG[CC_id], + nb_rbs_required, + nb_rbs_required_remaining, + nb_rbs_allowed_slice, + rballoc_sub, + MIMO_mode_indicator); + + } } - } - - // Store the DLSCH buffer for each logical channel - _store_dlsch_buffer (Mod_id,slice_id,frameP,subframeP); - - // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - _assign_rbs_required (Mod_id,slice_id, frameP,subframeP,nb_rbs_required,nb_rbs_allowed_slice,min_rb_unit); - - // Sorts the user on the basis of dlsch logical channel buffer and CQI - sort_UEs (Mod_id,frameP,subframeP); - - total_ue_count = 0; - - // loop over all active UEs - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { - rnti = flexran_get_ue_crnti(Mod_id, i); - if(rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - UE_id = i; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - for (ii=0; ii < UE_num_active_CC(UE_list,UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id]; - flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round); - - // if there is no available harq_process, skip the UE - if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) - continue; - - average_rbs_per_user[CC_id]=0; - - frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); - - // mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); - - if(round>0) { - nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - } - - //nb_rbs_required_remaining[UE_id] = nb_rbs_required[UE_id]; - if (nb_rbs_required[CC_id][UE_id] > 0) { - total_ue_count = total_ue_count + 1; - } - - - // hypotetical assignment - /* - * If schedule is enabled and if the priority of the UEs is modified - * The average rbs per logical channel per user will depend on the level of - * priority. Concerning the hypothetical assignment, we should assign more - * rbs to prioritized users. Maybe, we can do a mapping between the - * average rbs per user and the level of priority or multiply the average rbs - * per user by a coefficient which represents the degree of priority. - */ - - if (total_ue_count == 0) { - average_rbs_per_user[CC_id] = 0; - } else if( (min_rb_unit[CC_id] * total_ue_count) <= nb_rbs_allowed_slice[CC_id][slice_id] ) { - average_rbs_per_user[CC_id] = (uint16_t) floor(nb_rbs_allowed_slice[CC_id][slice_id]/total_ue_count); - } else { - average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE - } - } - } - - // note: nb_rbs_required is assigned according to total_buffer_dl - // extend nb_rbs_required to capture per LCID RB required - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - rnti = UE_RNTI(Mod_id,i); - - if(rnti == NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - if (flexran_slice_member(i, slice_id) == 0) - continue; - - for (ii=0; ii<UE_num_active_CC(UE_list,i); ii++) { - CC_id = UE_list->ordered_CCids[ii][i]; - - // control channel - if (mac_eNB_get_rrc_status(Mod_id,rnti) < RRC_RECONFIGURED) { - nb_rbs_required_remaining_1[CC_id][i] = nb_rbs_required[CC_id][i]; - } else { - nb_rbs_required_remaining_1[CC_id][i] = cmin(average_rbs_per_user[CC_id],nb_rbs_required[CC_id][i]); - - } + + // Store the DLSCH buffer for each logical channel + _store_dlsch_buffer(Mod_id, slice_id, frameP, subframeP); + + // Calculate the number of RBs required by each UE on the basis of logical channel's buffer + _assign_rbs_required(Mod_id, slice_id, frameP, subframeP, + nb_rbs_required, nb_rbs_allowed_slice, + min_rb_unit); + + // Sorts the user on the basis of dlsch logical channel buffer and CQI + sort_UEs(Mod_id, frameP, subframeP); + + total_ue_count = 0; + + // loop over all active UEs + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + rnti = flexran_get_ue_crnti(Mod_id, i); + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + + UE_id = i; + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + + if (!phy_stats_exist(Mod_id, rnti)) + continue; + + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + ue_sched_ctl->max_allowed_rbs[CC_id] = + nb_rbs_allowed_slice[CC_id][slice_id]; + flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, + &harq_pid, &round); + + // if there is no available harq_process, skip the UE + if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id] < 0) + continue; + + average_rbs_per_user[CC_id] = 0; + + frame_parms[CC_id] = + mac_xface->get_lte_frame_parms(Mod_id, CC_id); + + // mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); + + if (round > 0) { + nb_rbs_required[CC_id][UE_id] = + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + } + //nb_rbs_required_remaining[UE_id] = nb_rbs_required[UE_id]; + if (nb_rbs_required[CC_id][UE_id] > 0) { + total_ue_count = total_ue_count + 1; + } + // hypotetical assignement + /* + * If schedule is enabled and if the priority of the UEs is modified + * The average rbs per logical channel per user will depend on the level of + * priority. Concerning the hypothetical assignement, we should assign more + * rbs to prioritized users. Maybe, we can do a mapping between the + * average rbs per user and the level of priority or multiply the average rbs + * per user by a coefficient which represents the degree of priority. + */ + + if (total_ue_count == 0) { + average_rbs_per_user[CC_id] = 0; + } else if ((min_rb_unit[CC_id] * total_ue_count) <= + nb_rbs_allowed_slice[CC_id][slice_id]) { + average_rbs_per_user[CC_id] = + (uint16_t) floor(nb_rbs_allowed_slice[CC_id][slice_id] + / total_ue_count); + } else { + average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE + } + } } - } - - //Allocation to UEs is done in 2 rounds, - // 1st stage: average number of RBs allocated to each UE - // 2nd stage: remaining RBs are allocated to high priority UEs - for(r1=0; r1<2; r1++) { - - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - - if (flexran_slice_member(i, slice_id) == 0) - continue; - - for (ii=0; ii<UE_num_active_CC(UE_list,i); ii++) { - CC_id = UE_list->ordered_CCids[ii][i]; - - if(r1 == 0) { - nb_rbs_required_remaining[CC_id][i] = nb_rbs_required_remaining_1[CC_id][i]; - } else { // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round - nb_rbs_required_remaining[CC_id][i] = nb_rbs_required[CC_id][i]-nb_rbs_required_remaining_1[CC_id][i]+nb_rbs_required_remaining[CC_id][i]; - } - - if (nb_rbs_required[CC_id][i]> 0 ) - LOG_D(MAC,"round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d, pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", - r1, CC_id, i, - nb_rbs_required_remaining[CC_id][i], - nb_rbs_required_remaining_1[CC_id][i], - nb_rbs_required[CC_id][i], - UE_list->UE_sched_ctrl[i].pre_nb_available_rbs[CC_id], - N_RBG[CC_id], - min_rb_unit[CC_id]); - - } + + // note: nb_rbs_required is assigned according to total_buffer_dl + // extend nb_rbs_required to capture per LCID RB required + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + rnti = UE_RNTI(Mod_id, i); + + if (rnti == NOT_A_RNTI) + continue; + + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + + if (!phy_stats_exist(Mod_id, rnti)) + continue; + + if (flexran_slice_member(i, slice_id) == 0) + continue; + + for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { + CC_id = UE_list->ordered_CCids[ii][i]; + + // control channel + if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED) { + nb_rbs_required_remaining_1[CC_id][i] = + nb_rbs_required[CC_id][i]; + } else { + nb_rbs_required_remaining_1[CC_id][i] = + cmin(average_rbs_per_user[CC_id], + nb_rbs_required[CC_id][i]); + + } + } } - if (total_ue_count > 0 ) { - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - UE_id = i; - + //Allocation to UEs is done in 2 rounds, + // 1st stage: average number of RBs allocated to each UE + // 2nd stage: remaining RBs are allocated to high priority UEs + for (r1 = 0; r1 < 2; r1++) { + + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + + if (flexran_slice_member(i, slice_id) == 0) + continue; + + for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { + CC_id = UE_list->ordered_CCids[ii][i]; + + if (r1 == 0) { + nb_rbs_required_remaining[CC_id][i] = + nb_rbs_required_remaining_1[CC_id][i]; + } else { // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round + nb_rbs_required_remaining[CC_id][i] = + nb_rbs_required[CC_id][i] - + nb_rbs_required_remaining_1[CC_id][i] + + nb_rbs_required_remaining[CC_id][i]; + } + + if (nb_rbs_required[CC_id][i] > 0) + LOG_D(MAC, + "round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d, pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", + r1, CC_id, i, + nb_rbs_required_remaining[CC_id][i], + nb_rbs_required_remaining_1[CC_id][i], + nb_rbs_required[CC_id][i], + UE_list->UE_sched_ctrl[i]. + pre_nb_available_rbs[CC_id], N_RBG[CC_id], + min_rb_unit[CC_id]); + + } + } + + if (total_ue_count > 0) { + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + UE_id = i; + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + flexran_get_harq(Mod_id, CC_id, UE_id, frameP, + subframeP, &harq_pid, &round); + rnti = UE_RNTI(Mod_id, UE_id); + + // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); + if (rnti == NOT_A_RNTI) + continue; + + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + continue; + + if (!phy_stats_exist(Mod_id, rnti)) + continue; + + transmission_mode = + mac_xface->get_transmission_mode(Mod_id, CC_id, + rnti); + //rrc_status = mac_eNB_get_rrc_status(Mod_id,rnti); + /* 1st allocate for the retx */ + + // retransmission in data channels + // control channel in the 1st transmission + // data channel for all TM + LOG_T(MAC, + "calling dlsch_scheduler_pre_processor_allocate .. \n "); + _dlsch_scheduler_pre_processor_allocate(Mod_id, UE_id, + CC_id, + N_RBG[CC_id], + transmission_mode, + min_rb_unit + [CC_id], + frame_parms + [CC_id]-> + N_RB_DL, + nb_rbs_required, + nb_rbs_required_remaining, + rballoc_sub, + MIMO_mode_indicator); + } + } + } // total_ue_count + } // end of for for r1 and r2 + + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + UE_id = i; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - for (ii=0; ii<UE_num_active_CC(UE_list,UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round); - rnti = UE_RNTI(Mod_id,UE_id); - - // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); - if(rnti == NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) continue; - if (!phy_stats_exist(Mod_id, rnti)) - continue; - - transmission_mode = mac_xface->get_transmission_mode(Mod_id,CC_id,rnti); - //rrc_status = mac_eNB_get_rrc_status(Mod_id,rnti); - /* 1st allocate for the retx */ - - // retransmission in data channels - // control channel in the 1st transmission - // data channel for all TM - LOG_T(MAC,"calling dlsch_scheduler_pre_processor_allocate .. \n "); - _dlsch_scheduler_pre_processor_allocate (Mod_id, - UE_id, - CC_id, - N_RBG[CC_id], - transmission_mode, - min_rb_unit[CC_id], - frame_parms[CC_id]->N_RB_DL, - nb_rbs_required, - nb_rbs_required_remaining, - rballoc_sub, - MIMO_mode_indicator); - } - } - } // total_ue_count - } // end of for for r1 and r2 - - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - UE_id = i; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - for (ii=0; ii<UE_num_active_CC(UE_list,UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; - - if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0 ) { - LOG_D(MAC,"******************DL Scheduling Information for UE%d ************************\n",UE_id); - LOG_D(MAC,"dl power offset UE%d = %d \n",UE_id,ue_sched_ctl->dl_pow_off[CC_id]); - LOG_D(MAC,"***********RB Alloc for every subband for UE%d ***********\n",UE_id); - - for(j=0; j<N_RBG[CC_id]; j++) { - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; - LOG_D(MAC,"RB Alloc for UE%d and Subband%d = %d\n",UE_id,j,ue_sched_ctl->rballoc_sub_UE[CC_id][j]); - } - - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; - LOG_D(MAC,"[eNB %d][SLICE %d] Total RBs allocated for UE%d = %d\n", - Mod_id, slice_id, UE_id,ue_sched_ctl->pre_nb_available_rbs[CC_id]); - } + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; + + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { + LOG_D(MAC, + "******************DL Scheduling Information for UE%d ************************\n", + UE_id); + LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, + ue_sched_ctl->dl_pow_off[CC_id]); + LOG_D(MAC, + "***********RB Alloc for every subband for UE%d ***********\n", + UE_id); + + for (j = 0; j < N_RBG[CC_id]; j++) { + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; + LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", + UE_id, j, + ue_sched_ctl->rballoc_sub_UE[CC_id][j]); + } + + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; + LOG_D(MAC, + "[eNB %d][SLICE %d] Total RBs allocated for UE%d = %d\n", + Mod_id, slice_id, UE_id, + ue_sched_ctl->pre_nb_available_rbs[CC_id]); + } + } } - } } #define SF05_LIMIT 1 @@ -718,960 +830,1185 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, */ void -flexran_schedule_ue_spec_default(mid_t mod_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) +flexran_schedule_ue_spec_default(mid_t mod_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info) //------------------------------------------------------------------------------ { - int i=0; - - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - - for (i = 0; i < n_active_slices; i++) { - - // Load any updated functions - if (update_dl_scheduler[i] > 0 ) { - slice_sched[i] = dlsym(NULL, dl_scheduler_type[i]); - update_dl_scheduler[i] = 0; - update_dl_scheduler_current[i] = 0; - slice_percentage_current[i]= slice_percentage[i]; - total_slice_percentage+=slice_percentage[i]; - LOG_N(MAC,"update dl scheduler slice %d\n", i); - } - - // check if the number of slices has changed, and log - if (n_active_slices_current != n_active_slices ){ - if ((n_active_slices > 0) && (n_active_slices <= MAX_NUM_SLICES)) { - LOG_N(MAC,"[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", - mod_id, frame, subframe, n_active_slices_current, n_active_slices); - n_active_slices_current = n_active_slices; - } else { - LOG_W(MAC,"invalid number of slices %d, revert to the previous value %d\n",n_active_slices, n_active_slices_current); - n_active_slices = n_active_slices_current; - } - } - - // check if the slice rb share has changed, and log the console - if (slice_percentage_current[i] != slice_percentage[i]){ - if ((slice_percentage[i] >= 0.0) && (slice_percentage[i] <= 1.0)){ - if ((total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]) <= 1.0) { - total_slice_percentage=total_slice_percentage - slice_percentage_current[i] + slice_percentage[i]; - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", - mod_id, i, frame, subframe, total_slice_percentage, slice_percentage_current[i], slice_percentage[i]); - slice_percentage_current[i] = slice_percentage[i]; - } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", - mod_id,i, - total_slice_percentage, - total_slice_percentage - slice_percentage_current[i] + slice_percentage[i], - slice_percentage[i],slice_percentage_current[i]); - slice_percentage[i]= slice_percentage_current[i]; + int i = 0; + flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); + + for (i = 0; i < n_active_slices; i++) { + + // Load any updated functions + if (update_dl_scheduler[i] > 0) { + slice_sched[i] = dlsym(NULL, dl_scheduler_type[i]); + update_dl_scheduler[i] = 0; + update_dl_scheduler_current[i] = 0; + slice_percentage_current[i] = slice_percentage[i]; + total_slice_percentage += slice_percentage[i]; + LOG_N(MAC, "update dl scheduler slice %d\n", i); + } + // check if the number of slices has changed, and log + if (n_active_slices_current != n_active_slices) { + if ((n_active_slices > 0) + && (n_active_slices <= MAX_NUM_SLICES)) { + LOG_N(MAC, + "[eNB %d]frame %d subframe %d: number of active slices has changed: %d-->%d\n", + mod_id, frame, subframe, n_active_slices_current, + n_active_slices); + n_active_slices_current = n_active_slices; + } else { + LOG_W(MAC, + "invalid number of slices %d, revert to the previous value %d\n", + n_active_slices, n_active_slices_current); + n_active_slices = n_active_slices_current; + } } - } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n",mod_id, i, slice_percentage[i],slice_percentage_current[i]); - slice_percentage[i]= slice_percentage_current[i]; + // check if the slice rb share has changed, and log the console + if (slice_percentage_current[i] != slice_percentage[i]) { + if ((slice_percentage[i] >= 0.0) + && (slice_percentage[i] <= 1.0)) { + if ((total_slice_percentage - slice_percentage_current[i] + + slice_percentage[i]) <= 1.0) { + total_slice_percentage = + total_slice_percentage - + slice_percentage_current[i] + slice_percentage[i]; + LOG_N(MAC, + "[eNB %d][SLICE %d] frame %d subframe %d: total percentage %f, slice RB percentage has changed: %f-->%f\n", + mod_id, i, frame, subframe, + total_slice_percentage, + slice_percentage_current[i], + slice_percentage[i]); + slice_percentage_current[i] = slice_percentage[i]; + } else { + LOG_W(MAC, + "[eNB %d][SLICE %d] invalid total RB share (%f->%f), revert the previous value (%f->%f)\n", + mod_id, i, total_slice_percentage, + total_slice_percentage - + slice_percentage_current[i] + + slice_percentage[i], slice_percentage[i], + slice_percentage_current[i]); + slice_percentage[i] = slice_percentage_current[i]; - } - } - - // check if the slice max MCS, and log the console - if (slice_maxmcs_current[i] != slice_maxmcs[i]){ - if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)){ - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", - mod_id, i, frame, subframe, slice_maxmcs_current[i], slice_maxmcs[i]); - slice_maxmcs_current[i] = slice_maxmcs[i]; - } else { - LOG_W(MAC,"[eNB %d][SLICE %d] invalid slice max mcs %d, revert the previous value %d\n",mod_id, i, slice_percentage[i],slice_percentage[i]); - slice_maxmcs[i]= slice_maxmcs_current[i]; - } - } - - // check if a new scheduler, and log the console - if (update_dl_scheduler_current[i] != update_dl_scheduler[i]){ - LOG_N(MAC,"[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", - mod_id, i, frame, subframe, dl_scheduler_type[i]); - update_dl_scheduler_current[i] = update_dl_scheduler[i]; - } + } + } else { + LOG_W(MAC, + "[eNB %d][SLICE %d] invalid slice RB share, revert the previous value (%f->%f)\n", + mod_id, i, slice_percentage[i], + slice_percentage_current[i]); + slice_percentage[i] = slice_percentage_current[i]; + + } + } + // check if the slice max MCS, and log the console + if (slice_maxmcs_current[i] != slice_maxmcs[i]) { + if ((slice_maxmcs[i] >= 0) && (slice_maxmcs[i] < 29)) { + LOG_N(MAC, + "[eNB %d][SLICE %d] frame %d subframe %d: slice MAX MCS has changed: %d-->%d\n", + mod_id, i, frame, subframe, slice_maxmcs_current[i], + slice_maxmcs[i]); + slice_maxmcs_current[i] = slice_maxmcs[i]; + } else { + LOG_W(MAC, + "[eNB %d][SLICE %d] invalid slice max mcs %d, revert the previous value %d\n", + mod_id, i, slice_percentage[i], slice_percentage[i]); + slice_maxmcs[i] = slice_maxmcs_current[i]; + } + } + // check if a new scheduler, and log the console + if (update_dl_scheduler_current[i] != update_dl_scheduler[i]) { + LOG_N(MAC, + "[eNB %d][SLICE %d] frame %d subframe %d: DL scheduler for this slice is updated: %s \n", + mod_id, i, frame, subframe, dl_scheduler_type[i]); + update_dl_scheduler_current[i] = update_dl_scheduler[i]; + } + // Run each enabled slice-specific schedulers one by one + //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); + slice_sched[i] (mod_id, i, frame, subframe, mbsfn_flag, dl_info); - // Run each enabled slice-specific schedulers one by one - //LOG_N(MAC,"[eNB %d]frame %d subframe %d slice %d: calling the scheduler\n", mod_id, frame, subframe,i); - slice_sched[i](mod_id, i, frame, subframe, mbsfn_flag,dl_info); + } - } - } -uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs){ - return (uint16_t) floor(rb_percentage * total_rbs); +uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs) +{ + return (uint16_t) floor(rb_percentage * total_rbs); } -int flexran_slice_maxmcs(int slice_id) { - return slice_maxmcs[slice_id]; +int flexran_slice_maxmcs(int slice_id) +{ + return slice_maxmcs[slice_id]; } -int flexran_slice_member(int UE_id, int slice_id){ - // group membership definition - int slice_member = 0 ; - - if ((slice_id < 0) || (slice_id > n_active_slices)) - LOG_W(MAC,"out of range slice id %d\n",slice_id); - - switch (slicing_strategy) { - case SLICE_MASK: - switch (slice_id){ - case 0: - if (SLICE0_MASK&UE_id){ - slice_member=1; - } - break; - case 1: - if (SLICE1_MASK&UE_id){ - slice_member=1; - } - break; - case 2: - if (SLICE2_MASK&UE_id){ - slice_member=1; - } - break; - case 3: - if (SLICE3_MASK&UE_id){ - slice_member=1; - } - break; - default : - LOG_W(MAC,"unknown slice_id %d\n", slice_id); - break; - - } - break; - case UEID_TO_SLICEID: - default: - if ((UE_id % n_active_slices) == slice_id){ - slice_member= 1; // this ue is a member of this slice +int flexran_slice_member(int UE_id, int slice_id) +{ + // group membership definition + int slice_member = 0; + + if ((slice_id < 0) || (slice_id > n_active_slices)) + LOG_W(MAC, "out of range slice id %d\n", slice_id); + + switch (slicing_strategy) { + case SLICE_MASK: + switch (slice_id) { + case 0: + if (SLICE0_MASK & UE_id) { + slice_member = 1; + } + break; + case 1: + if (SLICE1_MASK & UE_id) { + slice_member = 1; + } + break; + case 2: + if (SLICE2_MASK & UE_id) { + slice_member = 1; + } + break; + case 3: + if (SLICE3_MASK & UE_id) { + slice_member = 1; + } + break; + default: + LOG_W(MAC, "unknown slice_id %d\n", slice_id); + break; + + } + break; + case UEID_TO_SLICEID: + default: + if ((UE_id % n_active_slices) == slice_id) { + slice_member = 1; // this ue is a member of this slice + } + break; } - break; - } - - return slice_member; + + return slice_member; } + /* more aggressive rb and mcs allocation with medium priority and the traffic qci */ void -flexran_schedule_ue_spec_embb(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) - +flexran_schedule_ue_spec_embb(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info) { - flexran_schedule_ue_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); - + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, subframe, mbsfn_flag, dl_info); + } + /* more conservative mcs allocation with high priority and the traffic qci */ void -flexran_schedule_ue_spec_urllc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) - +flexran_schedule_ue_spec_urllc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info) { - flexran_schedule_ue_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); - + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, subframe, mbsfn_flag, dl_info); + } + /* constant rb allocation with low mcs with low priority and given the UE capabilities */ void -flexran_schedule_ue_spec_mmtc(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) - +flexran_schedule_ue_spec_mmtc(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info) { - - flexran_schedule_ue_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); - + + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, subframe, mbsfn_flag, dl_info); + } + /* regular rb and mcs allocation with low priority */ void -flexran_schedule_ue_spec_be(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) - +flexran_schedule_ue_spec_be(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info) { - - flexran_schedule_ue_spec_common(mod_id, - slice_id, - frame, - subframe, - mbsfn_flag, - dl_info); - + + flexran_schedule_ue_spec_common(mod_id, + slice_id, + frame, subframe, mbsfn_flag, dl_info); + } //------------------------------------------------------------------------------ void -flexran_schedule_ue_spec_common(mid_t mod_id, - int slice_id, - uint32_t frame, - uint32_t subframe, - int *mbsfn_flag, - Protocol__FlexranMessage **dl_info) +flexran_schedule_ue_spec_common(mid_t mod_id, + int slice_id, + uint32_t frame, + uint32_t subframe, + int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info) //------------------------------------------------------------------------------ { - uint8_t CC_id; - int UE_id; - int N_RBG[MAX_NUM_CCs]; - unsigned char aggregation; - mac_rlc_status_resp_t rlc_status; - unsigned char header_len = 0, header_len_last = 0, ta_len = 0; - uint16_t nb_rb, nb_rb_temp, total_nb_available_rb[MAX_NUM_CCs], nb_available_rb; - uint16_t TBS, j, rnti; - uint8_t round = 0; - uint8_t harq_pid = 0; - uint16_t sdu_length_total = 0; - int mcs, mcs_tmp; - uint16_t min_rb_unit[MAX_NUM_CCs]; - eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; - /* TODO: Must move the helper structs to scheduler implementation */ - UE_list_t *UE_list = &eNB->UE_list; - int32_t normalized_rx_power, target_rx_power; - int32_t tpc = 1; - static int32_t tpc_accumulated=0; - UE_sched_ctrl *ue_sched_ctl; - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - Protocol__FlexDlData *dl_data[NUM_MAX_UE]; - int num_ues_added = 0; - int channels_added = 0; - - Protocol__FlexDlDci *dl_dci; - Protocol__FlexRlcPdu *rlc_pdus[11]; - uint32_t ce_flags = 0; - - uint8_t rballoc_sub[25]; - int i; - uint32_t data_to_request; - uint32_t dci_tbs; - uint8_t ue_has_transmission = 0; - uint32_t ndi; - + uint8_t CC_id; + int UE_id; + int N_RBG[MAX_NUM_CCs]; + unsigned char aggregation; + mac_rlc_status_resp_t rlc_status; + unsigned char header_len = 0, header_len_last = 0, ta_len = 0; + uint16_t nb_rb, nb_rb_temp, total_nb_available_rb[MAX_NUM_CCs], + nb_available_rb; + uint16_t TBS, j, rnti; + uint8_t round = 0; + uint8_t harq_pid = 0; + uint16_t sdu_length_total = 0; + int mcs, mcs_tmp; + uint16_t min_rb_unit[MAX_NUM_CCs]; + eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id]; + /* TODO: Must move the helper structs to scheduler implementation */ + UE_list_t *UE_list = &eNB->UE_list; + int32_t normalized_rx_power, target_rx_power; + int32_t tpc = 1; + static int32_t tpc_accumulated = 0; + UE_sched_ctrl *ue_sched_ctl; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + Protocol__FlexDlData *dl_data[NUM_MAX_UE]; + int num_ues_added = 0; + int channels_added = 0; + + Protocol__FlexDlDci *dl_dci; + Protocol__FlexRlcPdu *rlc_pdus[11]; + uint32_t ce_flags = 0; + + uint8_t rballoc_sub[25]; + int i; + uint32_t data_to_request; + uint32_t dci_tbs; + uint8_t ue_has_transmission = 0; + uint32_t ndi; + #if 0 - - if (UE_list->head==-1) { - return; - } - + + if (UE_list->head == -1) { + return; + } #endif - start_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); - - //weight = get_ue_weight(module_idP,UE_id); - aggregation = 1; // set to the maximum aggregation level - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - min_rb_unit[CC_id] = get_min_rb_unit(mod_id, CC_id); - // get number of PRBs less those used by common channels - total_nb_available_rb[CC_id] = flexran_get_N_RB_DL(mod_id, CC_id); - for (i=0;i < flexran_get_N_RB_DL(mod_id, CC_id); i++) - if (eNB->common_channels[CC_id].vrb_map[i] != 0) - total_nb_available_rb[CC_id]--; - - N_RBG[CC_id] = flexran_get_N_RBG(mod_id, CC_id); - - // store the global enb stats: - eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; - eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].total_available_prbs += total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].dlsch_bytes_tx=0; - eNB->eNB_stats[CC_id].dlsch_pdus_tx=0; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); - - start_meas(&eNB->schedule_dlsch_preprocessor); - _dlsch_scheduler_pre_processor(mod_id, - slice_id, - frame, - subframe, - N_RBG, - mbsfn_flag); - stop_meas(&eNB->schedule_dlsch_preprocessor); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n",CC_id); - - if (mbsfn_flag[CC_id]>0) - continue; - - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - - rnti = flexran_get_ue_crnti(mod_id, UE_id); - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - if (eNB_UE_stats==NULL) { - LOG_D(MAC,"[eNB] Cannot find eNB_UE_stats\n"); - // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - continue; - } - - if (flexran_slice_member(UE_id, slice_id) == 0) - continue; - - if (rnti==NOT_A_RNTI) { - LOG_D(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n", UE_id,UE_list->num_UEs); - // mac_xface->macphy_exit("Cannot find rnti for UE_id"); - continue; - } - - switch(mac_xface->get_transmission_mode(mod_id,CC_id,rnti)){ - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(mod_id,CC_id), - eNB_UE_stats->DL_cqi[0], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(mod_id,CC_id), - eNB_UE_stats->DL_cqi[0], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", mac_xface->get_transmission_mode(mod_id,CC_id,rnti)); - aggregation = 2; - } - - if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated - CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, aggregation, rnti)) { - LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", - mod_id, frame, UE_id, CC_id); - //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) - continue; //to next user (there might be rbs availiable for other UEs in TM5 - // else - // break; - } - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - set_ue_dai (subframe, - flexran_get_subframe_assignment(mod_id, CC_id), - UE_id, - CC_id, - UE_list); - //TODO: update UL DAI after DLSCH scheduling - //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe,frame_parms); - } - - channels_added = 0; - - // After this point all the UEs will be scheduled - dl_data[num_ues_added] = (Protocol__FlexDlData *) malloc(sizeof(Protocol__FlexDlData)); - protocol__flex_dl_data__init(dl_data[num_ues_added]); - dl_data[num_ues_added]->has_rnti = 1; - dl_data[num_ues_added]->rnti = rnti; - dl_data[num_ues_added]->n_rlc_pdu = 0; - dl_data[num_ues_added]->has_serv_cell_index = 1; - dl_data[num_ues_added]->serv_cell_index = CC_id; - - nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round); - sdu_length_total=0; - mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; - // LOG_I(FLEXRAN_AGENT, "The MCS is %d\n", mcs); - mcs = cmin(mcs,flexran_slice_maxmcs(slice_id)); -#ifdef EXMIMO + start_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); + + //weight = get_ue_weight(module_idP,UE_id); + aggregation = 1; // set to the maximum aggregation level + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + min_rb_unit[CC_id] = get_min_rb_unit(mod_id, CC_id); + // get number of PRBs less those used by common channels + total_nb_available_rb[CC_id] = flexran_get_N_RB_DL(mod_id, CC_id); + for (i = 0; i < flexran_get_N_RB_DL(mod_id, CC_id); i++) + if (eNB->common_channels[CC_id].vrb_map[i] != 0) + total_nb_available_rb[CC_id]--; + + N_RBG[CC_id] = flexran_get_N_RBG(mod_id, CC_id); + + // store the global enb stats: + eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; + eNB->eNB_stats[CC_id].available_prbs = + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].total_available_prbs += + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; + eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_IN); + + start_meas(&eNB->schedule_dlsch_preprocessor); + _dlsch_scheduler_pre_processor(mod_id, + slice_id, + frame, subframe, N_RBG, mbsfn_flag); + stop_meas(&eNB->schedule_dlsch_preprocessor); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_OUT); + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n", CC_id); + + if (mbsfn_flag[CC_id] > 0) + continue; - if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { - mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; - mcs = cmin(mcs,16); - } + for (UE_id = UE_list->head; UE_id >= 0; + UE_id = UE_list->next[UE_id]) { + + rnti = flexran_get_ue_crnti(mod_id, UE_id); + eNB_UE_stats = + mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + if (eNB_UE_stats == NULL) { + LOG_D(MAC, "[eNB] Cannot find eNB_UE_stats\n"); + // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); + continue; + } + + if (flexran_slice_member(UE_id, slice_id) == 0) + continue; + + if (rnti == NOT_A_RNTI) { + LOG_D(MAC, "Cannot find rnti for UE_id %d (num_UEs %d)\n", + UE_id, UE_list->num_UEs); + // mac_xface->macphy_exit("Cannot find rnti for UE_id"); + continue; + } + + switch (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)) { + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(mod_id, CC_id), + eNB_UE_stats->DL_cqi[0], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(mod_id, CC_id), + eNB_UE_stats->DL_cqi[0], + format2A); + break; + default: + LOG_W(MAC, "Unsupported transmission mode %d\n", + mac_xface->get_transmission_mode(mod_id, CC_id, + rnti)); + aggregation = 2; + } + + if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated + CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, + aggregation, rnti)) { + LOG_D(MAC, + "[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", + mod_id, frame, UE_id, CC_id); + //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) + continue; //to next user (there might be rbs availiable for other UEs in TM5 + // else + // break; + } + + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + set_ue_dai(subframe, + flexran_get_subframe_assignment(mod_id, CC_id), + UE_id, CC_id, UE_list); + //TODO: update UL DAI after DLSCH scheduling + //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe,frame_parms); + } + + channels_added = 0; + + // After this point all the UEs will be scheduled + dl_data[num_ues_added] = + (Protocol__FlexDlData *) + malloc(sizeof(Protocol__FlexDlData)); + protocol__flex_dl_data__init(dl_data[num_ues_added]); + dl_data[num_ues_added]->has_rnti = 1; + dl_data[num_ues_added]->rnti = rnti; + dl_data[num_ues_added]->n_rlc_pdu = 0; + dl_data[num_ues_added]->has_serv_cell_index = 1; + dl_data[num_ues_added]->serv_cell_index = CC_id; + + nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, + &harq_pid, &round); + sdu_length_total = 0; + mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; + // LOG_I(FLEXRAN_AGENT, "The MCS is %d\n", mcs); + mcs = cmin(mcs, flexran_slice_maxmcs(slice_id)); +#ifdef EXMIMO + if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti) == 5) { + mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; + mcs = cmin(mcs, 16); + } #endif - // initializing the rb allocation indicator for each UE - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0; - rballoc_sub[j] = 0; - } - - /* LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", */ - /* mod_id, frame, UE_id, CC_id, rnti, harq_pid, round, nb_available_rb, */ - /* eNB_UE_stats->DL_cqi[0], mcs, */ - /* UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); */ - - dl_dci = (Protocol__FlexDlDci*) malloc(sizeof(Protocol__FlexDlDci)); - protocol__flex_dl_dci__init(dl_dci); - dl_data[num_ues_added]->dl_dci = dl_dci; - - - dl_dci->has_rnti = 1; - dl_dci->rnti = rnti; - dl_dci->has_harq_process = 1; - dl_dci->harq_process = harq_pid; - - /* process retransmission */ - if (round > 0) { - - LOG_D(FLEXRAN_AGENT, "There was a retransmission just now and the round was %d\n", round); - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframe,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - } + // initializing the rb allocation indicator for each UE + for (j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] + = 0; + rballoc_sub[j] = 0; + } + + /* LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", */ + /* mod_id, frame, UE_id, CC_id, rnti, harq_pid, round, nb_available_rb, */ + /* eNB_UE_stats->DL_cqi[0], mcs, */ + /* UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); */ + + dl_dci = + (Protocol__FlexDlDci *) + malloc(sizeof(Protocol__FlexDlDci)); + protocol__flex_dl_dci__init(dl_dci); + dl_data[num_ues_added]->dl_dci = dl_dci; + + + dl_dci->has_rnti = 1; + dl_dci->rnti = rnti; + dl_dci->has_harq_process = 1; + dl_dci->harq_process = harq_pid; + + /* process retransmission */ + if (round > 0) { + + LOG_D(FLEXRAN_AGENT, + "There was a retransmission just now and the round was %d\n", + round); + + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(mod_id, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id].DAI); + LOG_D(MAC, + "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframe, UE_id, + UE_list->UE_template[CC_id][UE_id].DAI); + } - mcs = UE_list->UE_template[CC_id][UE_id].mcs[harq_pid]; - - // get freq_allocation - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - - /*TODO: Must add this to FlexRAN agent API */ - dci_tbs = mac_xface->get_TBS_DL(mcs, nb_rb); - - if (nb_rb <= nb_available_rb) { - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - - while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && - ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| - (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1; + mcs = UE_list->UE_template[CC_id][UE_id].mcs[harq_pid]; + + // get freq_allocation + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + + /*TODO: Must add this to FlexRAN agent API */ + dci_tbs = mac_xface->get_TBS_DL(mcs, nb_rb); + + if (nb_rb <= nb_available_rb) { + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) + && (j < flexran_get_N_RBG(mod_id, CC_id))) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == + flexran_get_N_RBG(mod_id, CC_id) - 1) + && + ((flexran_get_N_RB_DL(mod_id, CC_id) == + 25) + || (flexran_get_N_RB_DL(mod_id, CC_id) + == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + j = j + 1; + } + } + + nb_available_rb -= nb_rb; + PHY_vars_eNB_g[mod_id][CC_id]-> + mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + PHY_vars_eNB_g[mod_id][CC_id]-> + mu_mimo_mode[UE_id].dl_pow_off = + ue_sched_ctl->dl_pow_off[CC_id]; + + for (j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { + PHY_vars_eNB_g[mod_id][CC_id]-> + mu_mimo_mode[UE_id].rballoc_sub[j] = + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband + [harq_pid][j]; + rballoc_sub[j] = + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband + [harq_pid][j]; + } + + // Keep the old NDI, do not toggle + ndi = + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + tpc = + UE_list->UE_template[CC_id][UE_id]. + oldTPC[harq_pid]; + UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; + + ue_has_transmission = 1; + num_ues_added++; } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; + LOG_D(MAC, + "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", + mod_id, frame, CC_id, UE_id); + ue_has_transmission = 0; + } + //End of retransmission + } else { /* This is a potentially new SDU opportunity */ + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); + TBS = mac_xface->get_TBS_DL(mcs, nb_available_rb); + dci_tbs = TBS; + LOG_D(FLEXRAN_AGENT, "TBS is %d\n", TBS); + + // check first for RLC data on DCCH + // add the length for all the control elements (timing adv, drx, etc) : header + payload + + ta_len = (ue_sched_ctl->ta_update != 0) ? 2 : 0; + + dl_data[num_ues_added]->n_ce_bitmap = 2; + dl_data[num_ues_added]->ce_bitmap = + (uint32_t *) calloc(2, sizeof(uint32_t)); + + if (ta_len > 0) { + ce_flags |= PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; } - } - j = j + 1; - } - } - - nb_available_rb -= nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j=0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - - // Keep the old NDI, do not toggle - ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - tpc = UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid]; - UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; - - ue_has_transmission = 1; - num_ues_added++; - } else { - LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", - mod_id, frame, CC_id, UE_id); - ue_has_transmission = 0; - } - //End of retransmission - } else { /* This is a potentially new SDU opportunity */ - rlc_status.bytes_in_buffer = 0; - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); - TBS = mac_xface->get_TBS_DL(mcs, nb_available_rb); - dci_tbs = TBS; - LOG_D(FLEXRAN_AGENT, "TBS is %d\n", TBS); - - // check first for RLC data on DCCH - // add the length for all the control elements (timing adv, drx, etc) : header + payload - - ta_len = (ue_sched_ctl->ta_update != 0) ? 2 : 0; - - dl_data[num_ues_added]->n_ce_bitmap = 2; - dl_data[num_ues_added]->ce_bitmap = (uint32_t *) calloc(2, sizeof(uint32_t)); - - if (ta_len > 0) { - ce_flags |= PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; - } - /*TODO: Add other flags if DRX and other CE are required*/ - - // Add the control element flags to the flexran message - dl_data[num_ues_added]->ce_bitmap[0] = ce_flags; - dl_data[num_ues_added]->ce_bitmap[1] = ce_flags; - - // TODO : Need to prioritize DRBs - // Loop through the UE logical channels (DCCH, DCCH1, DTCH for now) - header_len = 0; - header_len_last = 0; - sdu_length_total = 0; - for (j = 1; j < NB_RB_MAX; j++) { - header_len += 3; - // Need to see if we have space for data from this channel - if (dci_tbs - ta_len - header_len - sdu_length_total > 0) { - LOG_D(MAC, "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", dci_tbs-ta_len-header_len); - //If we have space, we need to see how much data we can request at most (if any available) - rlc_status = mac_rlc_status_ind(mod_id, - rnti, - mod_id, - frame, - subframe, - ENB_FLAG_YES, - MBMS_FLAG_NO, - j, - (dci_tbs - ta_len - header_len - sdu_length_total) // transport block set size + /*TODO: Add other flags if DRX and other CE are required */ + + // Add the control element flags to the flexran message + dl_data[num_ues_added]->ce_bitmap[0] = ce_flags; + dl_data[num_ues_added]->ce_bitmap[1] = ce_flags; + + // TODO : Need to prioritize DRBs + // Loop through the UE logical channels (DCCH, DCCH1, DTCH for now) + header_len = 0; + header_len_last = 0; + sdu_length_total = 0; + for (j = 1; j < NB_RB_MAX; j++) { + header_len += 3; + // Need to see if we have space for data from this channel + if (dci_tbs - ta_len - header_len - sdu_length_total > + 0) { + LOG_D(MAC, + "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", + dci_tbs - ta_len - header_len); + //If we have space, we need to see how much data we can request at most (if any available) + rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, subframe, ENB_FLAG_YES, MBMS_FLAG_NO, j, (dci_tbs - ta_len - header_len - sdu_length_total) // transport block set size #ifdef Rel14 - ,0, 0 + ,0, 0 #endif - ); - - //If data are available in channel j - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[TEST]Have %d bytes in DCCH buffer during first call\n", rlc_status.bytes_in_buffer); - //Fill in as much as possible - data_to_request = cmin(dci_tbs - ta_len - header_len - sdu_length_total, rlc_status.bytes_in_buffer); - LOG_D(FLEXRAN_AGENT, "Will request %d bytes from channel %d\n", data_to_request, j); - if (data_to_request < 128) { //The header will be one byte less - header_len--; - header_len_last = 2; - } else { - header_len_last = 3; - } - /* if (j == 1 || j == 2) { - data_to_request+=0; - } */ - LOG_D(MAC, "[TEST]Will request %d from channel %d\n", data_to_request, j); - rlc_pdus[channels_added] = (Protocol__FlexRlcPdu *) malloc(sizeof(Protocol__FlexRlcPdu)); - protocol__flex_rlc_pdu__init(rlc_pdus[channels_added]); - rlc_pdus[channels_added]->n_rlc_pdu_tb = 2; - rlc_pdus[channels_added]->rlc_pdu_tb = (Protocol__FlexRlcPduTb **) malloc(sizeof(Protocol__FlexRlcPduTb *) * 2); - rlc_pdus[channels_added]->rlc_pdu_tb[0] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); - protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[0]); - rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_logical_channel_id = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->logical_channel_id = j; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->has_size = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[0]->size = data_to_request; - rlc_pdus[channels_added]->rlc_pdu_tb[1] = (Protocol__FlexRlcPduTb *) malloc(sizeof(Protocol__FlexRlcPduTb)); - protocol__flex_rlc_pdu_tb__init(rlc_pdus[channels_added]->rlc_pdu_tb[1]); - rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_logical_channel_id = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->logical_channel_id = j; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->has_size = 1; - rlc_pdus[channels_added]->rlc_pdu_tb[1]->size = data_to_request; - dl_data[num_ues_added]->n_rlc_pdu++; - channels_added++; - //Set this to the max value that we might request - sdu_length_total += data_to_request; - } else { - //Take back the assumption of a header for this channel - header_len -= 3; - } //End rlc_status.bytes_in_buffer <= 0 - } //end of if dci_tbs - ta_len - header_len > 0 - } // End of iterating the logical channels - - // Add rlc_pdus to the dl_data message - dl_data[num_ues_added]->rlc_pdu = (Protocol__FlexRlcPdu **) malloc(sizeof(Protocol__FlexRlcPdu *) * - dl_data[num_ues_added]->n_rlc_pdu); - for (i = 0; i < dl_data[num_ues_added]->n_rlc_pdu; i++) { - dl_data[num_ues_added]->rlc_pdu[i] = rlc_pdus[i]; - } - - if (header_len == 0) { - LOG_D(FLEXRAN_AGENT, "Header was empty\n"); - header_len_last = 0; - } - - // there is a payload - if ((dl_data[num_ues_added]->n_rlc_pdu > 0)) { - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - // adjust header lengths - LOG_D(FLEXRAN_AGENT, "We have %d bytes to transfer\n", sdu_length_total); - if (header_len != 0) { - LOG_D(FLEXRAN_AGENT, "Header length was %d ", header_len); - header_len_last--; - header_len -= header_len_last; - LOG_D(FLEXRAN_AGENT, "so we resized it to %d\n", header_len); - } - - /* if (header_len == 2 || header_len == 3) { //Only one SDU, remove length field */ - /* header_len = 1; */ - /* } else { //Remove length field from the last SDU */ - /* header_len--; */ - /* } */ - - mcs_tmp = mcs; - if (mcs_tmp == 0) { - nb_rb = 4; // don't let the TBS get too small - } else { - nb_rb=min_rb_unit[CC_id]; - } - - LOG_D(MAC,"[TEST]The initial number of resource blocks was %d\n", nb_rb); - LOG_D(MAC,"[TEST] The initial mcs was %d\n", mcs_tmp); - - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - LOG_D(MAC,"[TEST]The TBS during rate matching was %d\n", TBS); - - while (TBS < (sdu_length_total + header_len + ta_len)) { - nb_rb += min_rb_unit[CC_id]; // - LOG_D(MAC, "[TEST]Had to increase the number of RBs\n"); - if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_available_rb); - nb_rb = nb_available_rb; - break; - } - - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - LOG_D(MAC, "[TEST]We had the exact number of rbs. Time to fill the rballoc subband\n"); - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - LOG_D(MAC, "[TEST]Will only partially fill the bitmap\n"); - while((nb_rb_temp > 0) && (j < flexran_get_N_RBG(mod_id, CC_id))) { - if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { - UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - if ((j == flexran_get_N_RBG(mod_id, CC_id) - 1) && - ((flexran_get_N_RB_DL(mod_id, CC_id) == 25)|| - (flexran_get_N_RB_DL(mod_id, CC_id) == 50))) { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1; - } else { - nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]; - } - } - j = j+1; - } - } - - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - - // decrease mcs until TBS falls below required length - while ((TBS > (sdu_length_total + header_len + ta_len)) && (mcs_tmp > 0)) { - mcs_tmp--; - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < (sdu_length_total + header_len + ta_len)) && - ((( ue_sched_ctl->dl_pow_off[CC_id] > 0) && (mcs_tmp < 28)) || ( (ue_sched_ctl->dl_pow_off[CC_id]==0) && (mcs_tmp <= 15)))) { - mcs_tmp++; - TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); - } - - dci_tbs = TBS; - mcs = mcs_tmp; - LOG_D(FLEXRAN_AGENT, "Final mcs was %d\n", mcs); - - dl_dci->has_aggr_level = 1; - dl_dci->aggr_level = aggregation; - - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - UE_list->UE_template[CC_id][UE_id].DAI++; - // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); - //#warning only for 5MHz channel - update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); - } - - // do PUCCH power control - // this is the normalized RX power - normalized_rx_power = flexran_get_p0_pucch_dbm(mod_id,UE_id, CC_id); //eNB_UE_stats->Po_PUCCH_dBm; - target_rx_power = flexran_get_p0_nominal_pucch(mod_id, CC_id) + 20; //mac_xface->get_target_pucch_rx_power(mod_id, CC_id) + 20; - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; - - if (((framex10psubframe+10)<=(frame*10+subframe)) || //normal case - ((framex10psubframe>(frame*10+subframe)) && (((10240-framex10psubframe+frame*10+subframe)>=10)))) //frame wrap-around - if (flexran_get_p0_pucch_status(mod_id, UE_id, CC_id) == 1) { - flexran_update_p0_pucch(mod_id, UE_id, CC_id); - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frame; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframe; - if (normalized_rx_power>(target_rx_power+1)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-1)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - mod_id, frame, subframe, harq_pid, tpc, - tpc_accumulated, normalized_rx_power, target_rx_power); - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } - - for(i=0; i<PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.N_RBG; i++) { - rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; - } - - // Toggle NDI - LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", - CC_id, frame, subframe, UE_id, - UE_list->UE_template[CC_id][UE_id].rnti,harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]= 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - ndi = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - - UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid] = tpc; - - // Increase the pointer for the number of scheduled UEs - num_ues_added++; - ue_has_transmission = 1; - } else { // There is no data from RLC or MAC header, so don't schedule - ue_has_transmission = 0; + ); + + + //If data are available in channel j + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, + "[TEST]Have %d bytes in DCCH buffer during first call\n", + rlc_status.bytes_in_buffer); + //Fill in as much as possible + data_to_request = + cmin(dci_tbs - ta_len - header_len - + sdu_length_total, + rlc_status.bytes_in_buffer); + LOG_D(FLEXRAN_AGENT, + "Will request %d bytes from channel %d\n", + data_to_request, j); + if (data_to_request < 128) { //The header will be one byte less + header_len--; + header_len_last = 2; + } else { + header_len_last = 3; + } + /* if (j == 1 || j == 2) { + data_to_request+=0; + } */ + LOG_D(MAC, + "[TEST]Will request %d from channel %d\n", + data_to_request, j); + rlc_pdus[channels_added] = + (Protocol__FlexRlcPdu *) + malloc(sizeof(Protocol__FlexRlcPdu)); + protocol__flex_rlc_pdu__init(rlc_pdus + [channels_added]); + rlc_pdus[channels_added]->n_rlc_pdu_tb = 2; + rlc_pdus[channels_added]->rlc_pdu_tb = + (Protocol__FlexRlcPduTb **) + malloc(sizeof(Protocol__FlexRlcPduTb *) * + 2); + rlc_pdus[channels_added]->rlc_pdu_tb[0] = + (Protocol__FlexRlcPduTb *) + malloc(sizeof(Protocol__FlexRlcPduTb)); + protocol__flex_rlc_pdu_tb__init(rlc_pdus + [channels_added]->rlc_pdu_tb + [0]); + rlc_pdus[channels_added]-> + rlc_pdu_tb[0]->has_logical_channel_id = 1; + rlc_pdus[channels_added]-> + rlc_pdu_tb[0]->logical_channel_id = j; + rlc_pdus[channels_added]->rlc_pdu_tb[0]-> + has_size = 1; + rlc_pdus[channels_added]->rlc_pdu_tb[0]->size = + data_to_request; + rlc_pdus[channels_added]->rlc_pdu_tb[1] = + (Protocol__FlexRlcPduTb *) + malloc(sizeof(Protocol__FlexRlcPduTb)); + protocol__flex_rlc_pdu_tb__init(rlc_pdus + [channels_added]->rlc_pdu_tb + [1]); + rlc_pdus[channels_added]-> + rlc_pdu_tb[1]->has_logical_channel_id = 1; + rlc_pdus[channels_added]-> + rlc_pdu_tb[1]->logical_channel_id = j; + rlc_pdus[channels_added]->rlc_pdu_tb[1]-> + has_size = 1; + rlc_pdus[channels_added]->rlc_pdu_tb[1]->size = + data_to_request; + dl_data[num_ues_added]->n_rlc_pdu++; + channels_added++; + //Set this to the max value that we might request + sdu_length_total += data_to_request; + } else { + //Take back the assumption of a header for this channel + header_len -= 3; + } //End rlc_status.bytes_in_buffer <= 0 + } //end of if dci_tbs - ta_len - header_len > 0 + } // End of iterating the logical channels + + // Add rlc_pdus to the dl_data message + dl_data[num_ues_added]->rlc_pdu = (Protocol__FlexRlcPdu **) + malloc(sizeof(Protocol__FlexRlcPdu *) * + dl_data[num_ues_added]->n_rlc_pdu); + for (i = 0; i < dl_data[num_ues_added]->n_rlc_pdu; i++) { + dl_data[num_ues_added]->rlc_pdu[i] = rlc_pdus[i]; + } + + if (header_len == 0) { + LOG_D(FLEXRAN_AGENT, "Header was empty\n"); + header_len_last = 0; + } + // there is a payload + if ((dl_data[num_ues_added]->n_rlc_pdu > 0)) { + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 + // adjust header lengths + LOG_D(FLEXRAN_AGENT, "We have %d bytes to transfer\n", + sdu_length_total); + if (header_len != 0) { + LOG_D(FLEXRAN_AGENT, "Header length was %d ", + header_len); + header_len_last--; + header_len -= header_len_last; + LOG_D(FLEXRAN_AGENT, "so we resized it to %d\n", + header_len); + } + + /* if (header_len == 2 || header_len == 3) { //Only one SDU, remove length field */ + /* header_len = 1; */ + /* } else { //Remove length field from the last SDU */ + /* header_len--; */ + /* } */ + + mcs_tmp = mcs; + if (mcs_tmp == 0) { + nb_rb = 4; // don't let the TBS get too small + } else { + nb_rb = min_rb_unit[CC_id]; + } + + LOG_D(MAC, + "[TEST]The initial number of resource blocks was %d\n", + nb_rb); + LOG_D(MAC, "[TEST] The initial mcs was %d\n", mcs_tmp); + + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + LOG_D(MAC, + "[TEST]The TBS during rate matching was %d\n", + TBS); + + while (TBS < (sdu_length_total + header_len + ta_len)) { + nb_rb += min_rb_unit[CC_id]; // + LOG_D(MAC, + "[TEST]Had to increase the number of RBs\n"); + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = + mac_xface->get_TBS_DL(mcs_tmp, + nb_available_rb); + nb_rb = nb_available_rb; + break; + } + + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + LOG_D(MAC, + "[TEST]We had the exact number of rbs. Time to fill the rballoc subband\n"); + for (j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + LOG_D(MAC, + "[TEST]Will only partially fill the bitmap\n"); + while ((nb_rb_temp > 0) + && (j < flexran_get_N_RBG(mod_id, CC_id))) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + if ((j == + flexran_get_N_RBG(mod_id, CC_id) - 1) + && + ((flexran_get_N_RB_DL(mod_id, CC_id) == + 25) + || (flexran_get_N_RB_DL(mod_id, CC_id) + == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + j = j + 1; + } + } + + PHY_vars_eNB_g[mod_id][CC_id]-> + mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + PHY_vars_eNB_g[mod_id][CC_id]-> + mu_mimo_mode[UE_id].dl_pow_off = + ue_sched_ctl->dl_pow_off[CC_id]; + + for (j = 0; j < flexran_get_N_RBG(mod_id, CC_id); j++) { + PHY_vars_eNB_g[mod_id][CC_id]-> + mu_mimo_mode[UE_id].rballoc_sub[j] = + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband + [harq_pid][j]; + } + + // decrease mcs until TBS falls below required length + while ((TBS > (sdu_length_total + header_len + ta_len)) + && (mcs_tmp > 0)) { + mcs_tmp--; + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < (sdu_length_total + header_len + ta_len)) + && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) + && (mcs_tmp < 28)) + || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) + && (mcs_tmp <= 15)))) { + mcs_tmp++; + TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb); + } + + dci_tbs = TBS; + mcs = mcs_tmp; + LOG_D(FLEXRAN_AGENT, "Final mcs was %d\n", mcs); + + dl_dci->has_aggr_level = 1; + dl_dci->aggr_level = aggregation; + + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = + nb_rb; + + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + UE_list->UE_template[CC_id][UE_id].DAI++; + // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); + //#warning only for 5MHz channel + update_ul_dci(mod_id, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id]. + DAI); + } + // do PUCCH power control + // this is the normalized RX power + normalized_rx_power = flexran_get_p0_pucch_dbm(mod_id, UE_id, CC_id); //eNB_UE_stats->Po_PUCCH_dBm; + target_rx_power = flexran_get_p0_nominal_pucch(mod_id, CC_id) + 20; //mac_xface->get_target_pucch_rx_power(mod_id, CC_id) + 20; + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = + UE_list->UE_template[CC_id][UE_id]. + pucch_tpc_tx_frame * 10 + + UE_list->UE_template[CC_id][UE_id]. + pucch_tpc_tx_subframe; + + if (((framex10psubframe + 10) <= (frame * 10 + subframe)) || //normal case + ((framex10psubframe > (frame * 10 + subframe)) && (((10240 - framex10psubframe + frame * 10 + subframe) >= 10)))) //frame wrap-around + if (flexran_get_p0_pucch_status + (mod_id, UE_id, CC_id) == 1) { + flexran_update_p0_pucch(mod_id, UE_id, CC_id); + + UE_list-> + UE_template[CC_id] + [UE_id].pucch_tpc_tx_frame = frame; + UE_list-> + UE_template[CC_id] + [UE_id].pucch_tpc_tx_subframe = subframe; + if (normalized_rx_power > + (target_rx_power + 1)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power < + (target_rx_power - 1)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + LOG_D(MAC, + "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + mod_id, frame, subframe, harq_pid, tpc, + tpc_accumulated, normalized_rx_power, + target_rx_power); + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } + + for (i = 0; + i < + PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.N_RBG; + i++) { + rballoc_sub[i] = + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband + [harq_pid][i]; + } + + // Toggle NDI + LOG_D(MAC, + "CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frame, subframe, UE_id, + UE_list->UE_template[CC_id][UE_id].rnti, + harq_pid, + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]); + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = + 1 - + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + ndi = + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + + UE_list->UE_template[CC_id][UE_id].mcs[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldTPC[harq_pid] = + tpc; + + // Increase the pointer for the number of scheduled UEs + num_ues_added++; + ue_has_transmission = 1; + } else { // There is no data from RLC or MAC header, so don't schedule + ue_has_transmission = 0; + } + } // End of new scheduling + + // If we has transmission or retransmission + if (ue_has_transmission) { + switch (mac_xface-> + get_transmission_mode(mod_id, CC_id, rnti)) { + case 1: + case 2: + default: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = + PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = + allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->n_tbs_size = 1; + dl_dci->tbs_size = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + } + break; + case 3: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = + PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = + allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 2; + dl_dci->ndi = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->ndi[1] = ndi; + dl_dci->n_rv = 2; + dl_dci->rv = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->rv[1] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 2; + dl_dci->mcs = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->mcs[1] = mcs; + dl_dci->n_tbs_size = 2; + dl_dci->tbs_size = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + dl_dci->tbs_size[1] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + } + break; + case 4: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = + PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = + allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 2; + dl_dci->ndi = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->ndi[1] = ndi; + dl_dci->n_rv = 2; + dl_dci->rv = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->rv[1] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 2; + dl_dci->mcs = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->mcs[1] = mcs; + dl_dci->n_tbs_size = 2; + dl_dci->tbs_size = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + dl_dci->tbs_size[1] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + } + break; + case 5: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = + PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = + allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + dl_dci->n_tbs_size = 1; + dl_dci->tbs_size = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_tbs_size); + dl_dci->tbs_size[0] = dci_tbs; + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + } + + if (ue_sched_ctl->dl_pow_off[CC_id] == 2) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + + dl_dci->has_dl_power_offset = 1; + dl_dci->dl_power_offset = + ue_sched_ctl->dl_pow_off[CC_id]; + dl_dci->has_precoding_info = 1; + dl_dci->precoding_info = 5; // Is this right?? + + break; + case 6: + dl_dci->has_res_alloc = 1; + dl_dci->res_alloc = 0; + dl_dci->has_vrb_format = 1; + dl_dci->vrb_format = + PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; + dl_dci->has_format = 1; + dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; + dl_dci->has_rb_bitmap = 1; + dl_dci->rb_bitmap = + allocate_prbs_sub(nb_rb, rballoc_sub); + dl_dci->has_rb_shift = 1; + dl_dci->rb_shift = 0; + dl_dci->n_ndi = 1; + dl_dci->ndi = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_ndi); + dl_dci->ndi[0] = ndi; + dl_dci->n_rv = 1; + dl_dci->rv = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_rv); + dl_dci->rv[0] = round & 3; + dl_dci->has_tpc = 1; + dl_dci->tpc = tpc; + dl_dci->n_mcs = 1; + dl_dci->mcs = + (uint32_t *) malloc(sizeof(uint32_t) * + dl_dci->n_mcs); + dl_dci->mcs[0] = mcs; + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + dl_dci->has_dai = 1; + dl_dci->dai = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + } + + dl_dci->has_dl_power_offset = 1; + dl_dci->dl_power_offset = + ue_sched_ctl->dl_pow_off[CC_id]; + dl_dci->has_precoding_info = 1; + dl_dci->precoding_info = 5; // Is this right?? + break; + } + } + + if (flexran_get_duplex_mode(mod_id, CC_id) == + PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { + + /* TODO */ + //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe, frame_parms); + } + } // UE_id loop + } // CC_id loop + + // Add all the dl_data elements to the flexran message + int offset = (*dl_info)->dl_mac_config_msg->n_dl_ue_data; + (*dl_info)->dl_mac_config_msg->n_dl_ue_data += num_ues_added; + if (num_ues_added > 0) { + (*dl_info)->dl_mac_config_msg->dl_ue_data = + (Protocol__FlexDlData **) + realloc((*dl_info)->dl_mac_config_msg->dl_ue_data, + sizeof(Protocol__FlexDlData *) * + ((*dl_info)->dl_mac_config_msg->n_dl_ue_data)); + if ((*dl_info)->dl_mac_config_msg->dl_ue_data == NULL) { + LOG_E(MAC, "Request for memory reallocation failed\n"); + return; } - } // End of new scheduling - - // If we has transmission or retransmission - if (ue_has_transmission) { - switch (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)) { - case 1: - case 2: - default: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 3: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 4: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_2A; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 2; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->ndi[1] = ndi; - dl_dci->n_rv = 2; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->rv[1] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 2; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->mcs[1] = mcs; - dl_dci->n_tbs_size = 2; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - dl_dci->tbs_size[1] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - break; - case 5: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - dl_dci->n_tbs_size = 1; - dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size); - dl_dci->tbs_size[0] = dci_tbs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - - if(ue_sched_ctl->dl_pow_off[CC_id] == 2) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - - break; - case 6: - dl_dci->has_res_alloc = 1; - dl_dci->res_alloc = 0; - dl_dci->has_vrb_format = 1; - dl_dci->vrb_format = PROTOCOL__FLEX_VRB_FORMAT__FLVRBF_LOCALIZED; - dl_dci->has_format = 1; - dl_dci->format = PROTOCOL__FLEX_DCI_FORMAT__FLDCIF_1D; - dl_dci->has_rb_bitmap = 1; - dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub); - dl_dci->has_rb_shift = 1; - dl_dci->rb_shift = 0; - dl_dci->n_ndi = 1; - dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi); - dl_dci->ndi[0] = ndi; - dl_dci->n_rv = 1; - dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv); - dl_dci->rv[0] = round & 3; - dl_dci->has_tpc = 1; - dl_dci->tpc = tpc; - dl_dci->n_mcs = 1; - dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs); - dl_dci->mcs[0] = mcs; - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - dl_dci->has_dai = 1; - dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - } - - dl_dci->has_dl_power_offset = 1; - dl_dci->dl_power_offset = ue_sched_ctl->dl_pow_off[CC_id]; - dl_dci->has_precoding_info = 1; - dl_dci->precoding_info = 5; // Is this right?? - break; + for (i = 0; i < num_ues_added; i++) { + (*dl_info)->dl_mac_config_msg->dl_ue_data[offset + i] = + dl_data[i]; } - } - - if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { - - /* TODO */ - //set_ul_DAI(mod_id, UE_id, CC_id, frame, subframe, frame_parms); - } - } // UE_id loop - } // CC_id loop - - // Add all the dl_data elements to the flexran message - int offset = (*dl_info)->dl_mac_config_msg->n_dl_ue_data; - (*dl_info)->dl_mac_config_msg->n_dl_ue_data += num_ues_added; - if ( num_ues_added > 0 ){ - (*dl_info)->dl_mac_config_msg->dl_ue_data = (Protocol__FlexDlData **) realloc( (*dl_info)->dl_mac_config_msg->dl_ue_data, - sizeof(Protocol__FlexDlData *) * ((*dl_info)->dl_mac_config_msg->n_dl_ue_data)); - if ((*dl_info)->dl_mac_config_msg->dl_ue_data == NULL ){ - LOG_E(MAC, "Request for memory reallocation failed\n"); - return; - } - for (i = 0; i < num_ues_added; i++) { - (*dl_info)->dl_mac_config_msg->dl_ue_data[offset+i] = dl_data[i]; - } - } - - stop_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); + } + + stop_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); } diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c index 17424b27970c806dd1bb8413e4ed852530d9b878..68c86f1da54671e4110c5bb6bb8a610be210725a 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.c @@ -17,7 +17,7 @@ *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org - */ + */ /*! \file flexran_agent_scheduler_dlsch_ue_remote.c * \brief procedures related to remote scheduling in the DLSCH transport channel @@ -44,137 +44,159 @@ int queue_initialized = 0; //uint32_t period = 10; //uint32_t sched [] = {1, 2, 3}; -void flexran_schedule_ue_spec_remote(mid_t mod_id, uint32_t frame, uint32_t subframe, - int *mbsfn_flag, Protocol__FlexranMessage **dl_info) { - - - //if ((subframe == skip_subframe) && (frame % period == 0)) { - // LOG_I(MAC, "Will skip subframe %d %d\n", subframe, frame); - // for (int i = 0; i < 3; i++) { - // LOG_I(MAC, "%d\n", sched[i]); - // } - //} - - /* if (frame == 500 && subframe == 1) { */ - /* char policy[] = "rrc: \n - ul_scheduler: \n behavior : tester_function\n parameters:\n period: !!int 3\nmac: \n - dl_scheduler: \n parameters: \n period : !!int 40\n skip_subframe : !!int 3\n sched : [!!int 4, !!int 5, !!int 6]"; */ - /* apply_reconfiguration_policy(mod_id, policy, strlen(policy)); */ - /* } */ - - eNB_MAC_INST *eNB; - - if (!queue_initialized) { - TAILQ_INIT(&queue_head); - queue_initialized = 1; - } - - eNB = &eNB_mac_inst[mod_id]; - - dl_mac_config_element_t *dl_config_elem; - - int diff; - LOG_D(MAC, "[TEST] Current frame and subframe %d, %d\n", frame, subframe); - // First we check to see if we have a scheduling decision for this sfn_sf already in our queue - while(queue_head.tqh_first != NULL) { - dl_config_elem = queue_head.tqh_first; - - diff = get_sf_difference(mod_id, dl_config_elem->dl_info->dl_mac_config_msg->sfn_sf); - // Check if this decision is for now, for a later or a previous subframe - if ( diff == 0) { // Now - LOG_D(MAC, "Found a decision for this subframe in the queue. Let's use it!\n"); - TAILQ_REMOVE(&queue_head, queue_head.tqh_first, configs); - *dl_info = dl_config_elem->dl_info; - free(dl_config_elem); - eNB->eNB_stats[mod_id].sched_decisions++; - return; - } else if (diff < 0) { //previous subframe , delete message and free memory - LOG_D(MAC, "Found a decision for a previous subframe in the queue. Let's get rid of it\n"); - TAILQ_REMOVE(&queue_head, queue_head.tqh_first, configs); - flexran_agent_mac_destroy_dl_config(dl_config_elem->dl_info); - free(dl_config_elem); - eNB->eNB_stats[mod_id].sched_decisions++; - eNB->eNB_stats[mod_id].missed_deadlines++; - } else { // next subframe, nothing to do now - LOG_D(MAC, "Found a decision for a future subframe in the queue. Nothing to do now\n"); - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - return; +void +flexran_schedule_ue_spec_remote(mid_t mod_id, uint32_t frame, + uint32_t subframe, int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info) +{ + + + //if ((subframe == skip_subframe) && (frame % period == 0)) { + // LOG_I(MAC, "Will skip subframe %d %d\n", subframe, frame); + // for (int i = 0; i < 3; i++) { + // LOG_I(MAC, "%d\n", sched[i]); + // } + //} + + /* if (frame == 500 && subframe == 1) { */ + /* char policy[] = "rrc: \n - ul_scheduler: \n behavior : tester_function\n parameters:\n period: !!int 3\nmac: \n - dl_scheduler: \n parameters: \n period : !!int 40\n skip_subframe : !!int 3\n sched : [!!int 4, !!int 5, !!int 6]"; */ + /* apply_reconfiguration_policy(mod_id, policy, strlen(policy)); */ + /* } */ + + eNB_MAC_INST *eNB; + + if (!queue_initialized) { + TAILQ_INIT(&queue_head); + queue_initialized = 1; } - } - - //Done with the local cache. Now we need to check if something new arrived - flexran_agent_get_pending_dl_mac_config(mod_id, dl_info); - while (*dl_info != NULL) { - - diff = get_sf_difference(mod_id, (*dl_info)->dl_mac_config_msg->sfn_sf); - if (diff == 0) { // Got a command for this sfn_sf - LOG_D(MAC, "Found a decision for this subframe pending. Let's use it\n"); - eNB->eNB_stats[mod_id].sched_decisions++; - return; - } else if (diff < 0) { - LOG_D(MAC, "Found a decision for a previous subframe. Let's get rid of it\n"); - flexran_agent_mac_destroy_dl_config(*dl_info); - *dl_info = NULL; - flexran_agent_get_pending_dl_mac_config(mod_id, dl_info); - eNB->eNB_stats[mod_id].sched_decisions++; - eNB->eNB_stats[mod_id].missed_deadlines++; - } else { // Intended for future subframe. Store it in local cache - LOG_D(MAC, "Found a decision for a future subframe in the queue. Let's store it in the cache\n"); - dl_mac_config_element_t *e = malloc(sizeof(dl_mac_config_element_t)); - e->dl_info = *dl_info; - TAILQ_INSERT_TAIL(&queue_head, e, configs); - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); - // No need to look for another. Messages arrive ordered - return; + + eNB = &eNB_mac_inst[mod_id]; + + dl_mac_config_element_t *dl_config_elem; + + int diff; + LOG_D(MAC, "[TEST] Current frame and subframe %d, %d\n", frame, + subframe); + // First we check to see if we have a scheduling decision for this sfn_sf already in our queue + while (queue_head.tqh_first != NULL) { + dl_config_elem = queue_head.tqh_first; + + diff = + get_sf_difference(mod_id, + dl_config_elem->dl_info-> + dl_mac_config_msg->sfn_sf); + // Check if this decision is for now, for a later or a previous subframe + if (diff == 0) { // Now + LOG_D(MAC, + "Found a decision for this subframe in the queue. Let's use it!\n"); + TAILQ_REMOVE(&queue_head, queue_head.tqh_first, configs); + *dl_info = dl_config_elem->dl_info; + free(dl_config_elem); + eNB->eNB_stats[mod_id].sched_decisions++; + return; + } else if (diff < 0) { //previous subframe , delete message and free memory + LOG_D(MAC, + "Found a decision for a previous subframe in the queue. Let's get rid of it\n"); + TAILQ_REMOVE(&queue_head, queue_head.tqh_first, configs); + flexran_agent_mac_destroy_dl_config(dl_config_elem->dl_info); + free(dl_config_elem); + eNB->eNB_stats[mod_id].sched_decisions++; + eNB->eNB_stats[mod_id].missed_deadlines++; + } else { // next subframe, nothing to do now + LOG_D(MAC, + "Found a decision for a future subframe in the queue. Nothing to do now\n"); + flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); + return; + } } - } - - // We found no pending command, so we will simply pass an empty one - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); + + //Done with the local cache. Now we need to check if something new arrived + flexran_agent_get_pending_dl_mac_config(mod_id, dl_info); + while (*dl_info != NULL) { + + diff = + get_sf_difference(mod_id, + (*dl_info)->dl_mac_config_msg->sfn_sf); + if (diff == 0) { // Got a command for this sfn_sf + LOG_D(MAC, + "Found a decision for this subframe pending. Let's use it\n"); + eNB->eNB_stats[mod_id].sched_decisions++; + return; + } else if (diff < 0) { + LOG_D(MAC, + "Found a decision for a previous subframe. Let's get rid of it\n"); + flexran_agent_mac_destroy_dl_config(*dl_info); + *dl_info = NULL; + flexran_agent_get_pending_dl_mac_config(mod_id, dl_info); + eNB->eNB_stats[mod_id].sched_decisions++; + eNB->eNB_stats[mod_id].missed_deadlines++; + } else { // Intended for future subframe. Store it in local cache + LOG_D(MAC, + "Found a decision for a future subframe in the queue. Let's store it in the cache\n"); + dl_mac_config_element_t *e = + malloc(sizeof(dl_mac_config_element_t)); + e->dl_info = *dl_info; + TAILQ_INSERT_TAIL(&queue_head, e, configs); + flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); + // No need to look for another. Messages arrive ordered + return; + } + } + + // We found no pending command, so we will simply pass an empty one + flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); } -int get_sf_difference(mid_t mod_id, uint32_t sfn_sf) { - int diff_in_subframes; - - uint16_t current_frame = flexran_get_current_system_frame_num(mod_id); - uint16_t current_subframe = flexran_get_current_subframe(mod_id); - uint32_t current_sfn_sf = flexran_get_sfn_sf(mod_id); - - if (sfn_sf == current_sfn_sf) { - return 0; - } - - uint16_t frame_mask = ((1<<12) - 1); - uint16_t frame = (sfn_sf & (frame_mask << 4)) >> 4; - - uint16_t sf_mask = ((1<<4) - 1); - uint16_t subframe = (sfn_sf & sf_mask); - - LOG_D(MAC, "[TEST] Target frame and subframe %d, %d\n", frame, subframe); - - if (frame == current_frame) { - return subframe - current_subframe; - } else if (frame > current_frame) { - diff_in_subframes = ((frame*10)+subframe) - ((current_frame*10)+current_subframe); - - // diff_in_subframes = 9 - current_subframe; - //diff_in_subframes += (subframe + 1); - //diff_in_subframes += (frame-2) * 10; - if (diff_in_subframes > SCHED_AHEAD_SUBFRAMES) { - return -1; - } else { - return 1; +int get_sf_difference(mid_t mod_id, uint32_t sfn_sf) +{ + int diff_in_subframes; + + uint16_t current_frame = flexran_get_current_system_frame_num(mod_id); + uint16_t current_subframe = flexran_get_current_subframe(mod_id); + uint32_t current_sfn_sf = flexran_get_sfn_sf(mod_id); + + if (sfn_sf == current_sfn_sf) { + return 0; } - } else { //frame < current_frame - //diff_in_subframes = 9 - current_subframe; - //diff_in_subframes += (subframe + 1); - //if (frame > 0) { - // diff_in_subframes += (frame - 1) * 10; - //} - //diff_in_subframes += (1023 - current_frame) * 10; - diff_in_subframes = 10240 - ((current_frame*10)+current_subframe) + ((frame*10)+subframe); - if (diff_in_subframes > SCHED_AHEAD_SUBFRAMES) { - return -1; - } else { - return 1; + + uint16_t frame_mask = ((1 << 12) - 1); + uint16_t frame = (sfn_sf & (frame_mask << 4)) >> 4; + + uint16_t sf_mask = ((1 << 4) - 1); + uint16_t subframe = (sfn_sf & sf_mask); + + LOG_D(MAC, "[TEST] Target frame and subframe %d, %d\n", frame, + subframe); + + if (frame == current_frame) { + return subframe - current_subframe; + } else if (frame > current_frame) { + diff_in_subframes = + ((frame * 10) + subframe) - ((current_frame * 10) + + current_subframe); + + // diff_in_subframes = 9 - current_subframe; + //diff_in_subframes += (subframe + 1); + //diff_in_subframes += (frame-2) * 10; + if (diff_in_subframes > SCHED_AHEAD_SUBFRAMES) { + return -1; + } else { + return 1; + } + } else { //frame < current_frame + //diff_in_subframes = 9 - current_subframe; + //diff_in_subframes += (subframe + 1); + //if (frame > 0) { + // diff_in_subframes += (frame - 1) * 10; + //} + //diff_in_subframes += (1023 - current_frame) * 10; + diff_in_subframes = + 10240 - ((current_frame * 10) + current_subframe) + + ((frame * 10) + subframe); + if (diff_in_subframes > SCHED_AHEAD_SUBFRAMES) { + return -1; + } else { + return 1; + } } - } } diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h index 997b9d1d24d5dc4b9cc454decf2cb7563b781e8b..449ba1e8cde85e8c6001178f9e68534590b9952f 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue_remote.h @@ -17,7 +17,7 @@ *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org - */ + */ /*! \file flexran_agent_scheduler_dlsch_ue_remote.h * \brief Local stub for remote scheduler used by the controller @@ -46,8 +46,8 @@ #define SCHED_AHEAD_SUBFRAMES 20 typedef struct dl_mac_config_element_s { - Protocol__FlexranMessage *dl_info; - TAILQ_ENTRY(dl_mac_config_element_s) configs; + Protocol__FlexranMessage *dl_info; + TAILQ_ENTRY(dl_mac_config_element_s) configs; } dl_mac_config_element_t; TAILQ_HEAD(DlMacConfigHead, dl_mac_config_element_s); @@ -55,8 +55,9 @@ TAILQ_HEAD(DlMacConfigHead, dl_mac_config_element_s); /* * Default scheduler used by the eNB agent */ -void flexran_schedule_ue_spec_remote(mid_t mod_id, uint32_t frame, uint32_t subframe, - int *mbsfn_flag, Protocol__FlexranMessage **dl_info); +void flexran_schedule_ue_spec_remote(mid_t mod_id, uint32_t frame, + uint32_t subframe, int *mbsfn_flag, + Protocol__FlexranMessage ** dl_info); // Find the difference in subframes from the given subframe diff --git a/openair2/LAYER2/MAC/flexran_dci_conversions.h b/openair2/LAYER2/MAC/flexran_dci_conversions.h index f52ae5b807207426cdc6e79298bd1d11515436cd..5c18b431043f47033b739f314c1ea98ea3ab20cb 100644 --- a/openair2/LAYER2/MAC/flexran_dci_conversions.h +++ b/openair2/LAYER2/MAC/flexran_dci_conversions.h @@ -17,7 +17,7 @@ *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org - */ + */ /*! \file flexran_dci_conversions.h * \brief Conversion helpers from flexran messages to OAI formats DCI @@ -47,5 +47,5 @@ ((TYPE*)DCI)->mcs = FLEXRAN_DCI->mcs[0]; \ ((TYPE*)DCI)->TPC = FLEXRAN_DCI->tpc; \ ((TYPE*)DCI)->ndi = FLEXRAN_DCI->ndi[0]; - + #endif diff --git a/openair2/LAYER2/MAC/l1_helpers.c b/openair2/LAYER2/MAC/l1_helpers.c index 2b5a38eda7cfc802e84da5391ab0724591676010..6e71f66ec5f56d32a52863db3fde89d6594b9b20 100644 --- a/openair2/LAYER2/MAC/l1_helpers.c +++ b/openair2/LAYER2/MAC/l1_helpers.c @@ -34,28 +34,36 @@ #include "UTIL/LOG/log.h" #include "proto.h" -int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP,uint8_t CC_id) +int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id) { - RACH_ConfigCommon_t *rach_ConfigCommon = NULL; + RACH_ConfigCommon_t *rach_ConfigCommon = NULL; - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); - AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon!=NULL, - "[UE %d] CCid %d FATAL radioResourceConfigCommon is NULL !!!\n",module_idP,CC_id); + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon != NULL, + "[UE %d] CCid %d FATAL radioResourceConfigCommon is NULL !!!\n", + module_idP, CC_id); - rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; + rach_ConfigCommon = + &UE_mac_inst[module_idP].radioResourceConfigCommon-> + rach_ConfigCommon; - return(-120 + (rach_ConfigCommon->powerRampingParameters.preambleInitialReceivedTargetPower<<1) + - get_DELTA_PREAMBLE(module_idP,CC_id)); + return (-120 + + (rach_ConfigCommon-> + powerRampingParameters.preambleInitialReceivedTargetPower << + 1) + get_DELTA_PREAMBLE(module_idP, CC_id)); } -int8_t get_deltaP_rampup(module_id_t module_idP,uint8_t CC_id) +int8_t get_deltaP_rampup(module_id_t module_idP, uint8_t CC_id) { - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); - LOG_D(MAC,"[PUSCH]%d dB\n",UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER<<1); - return((int8_t)(UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER<<1)); + LOG_D(MAC, "[PUSCH]%d dB\n", + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER << 1); + return ((int8_t) + (UE_mac_inst[module_idP]. + RA_PREAMBLE_TRANSMISSION_COUNTER << 1)); } diff --git a/openair2/LAYER2/MAC/lte_transport_init.c b/openair2/LAYER2/MAC/lte_transport_init.c index 1f67d8913c9c7392a959cb2a6282c8307b646aaa..e1f21f21e44935e7bf071b9377e6e69548201506 100644 --- a/openair2/LAYER2/MAC/lte_transport_init.c +++ b/openair2/LAYER2/MAC/lte_transport_init.c @@ -29,104 +29,104 @@ void init_transport_channels(unsigned char transmission_mode) { - // init DCI structures for testing - - UL_alloc_pdu.type = 0; - UL_alloc_pdu.hopping = 0; - UL_alloc_pdu.rballoc = UL_RB_ALLOC; - UL_alloc_pdu.mcs = 2; - UL_alloc_pdu.ndi = 1; - UL_alloc_pdu.TPC = 0; - UL_alloc_pdu.cqi_req = 1; - - /* - BCCH_alloc_pdu.type = 1; - BCCH_alloc_pdu.vrb_type = 0; - BCCH_alloc_pdu.rballoc = BCCH_RB_ALLOC; - BCCH_alloc_pdu.ndi = 1; - BCCH_alloc_pdu.rv = 1; - BCCH_alloc_pdu.mcs = 1; - BCCH_alloc_pdu.harq_pid = 0; - BCCH_alloc_pdu.TPC = 1; // set to 3 PRB - - // for FDD mode - BCCH_alloc_pdu_fdd.type = 1; - BCCH_alloc_pdu_fdd.vrb_type = 0; - BCCH_alloc_pdu_fdd.rballoc = BCCH_RB_ALLOC; - BCCH_alloc_pdu_fdd.ndi = 1; - BCCH_alloc_pdu_fdd.rv = 1; - BCCH_alloc_pdu_fdd.mcs = 1; - BCCH_alloc_pdu_fdd.harq_pid = 0; - BCCH_alloc_pdu_fdd.TPC = 1; // set to 3 PRB - */ - - DLSCH_alloc_pdu1A.type = 1; - DLSCH_alloc_pdu1A.vrb_type = 0; - DLSCH_alloc_pdu1A.rballoc = BCCH_RB_ALLOC; - DLSCH_alloc_pdu1A.ndi = 1; - DLSCH_alloc_pdu1A.rv = 1; - DLSCH_alloc_pdu1A.mcs = 2; - DLSCH_alloc_pdu1A.harq_pid = 0; - DLSCH_alloc_pdu1A.TPC = 1; // set to 3 PRB - - DLSCH_alloc_pdu1A_fdd.type = 1; - DLSCH_alloc_pdu1A_fdd.vrb_type = 0; - DLSCH_alloc_pdu1A_fdd.rballoc = BCCH_RB_ALLOC; - DLSCH_alloc_pdu1A_fdd.ndi = 1; - DLSCH_alloc_pdu1A_fdd.rv = 1; - DLSCH_alloc_pdu1A_fdd.mcs = 2; - DLSCH_alloc_pdu1A_fdd.harq_pid = 0; - DLSCH_alloc_pdu1A_fdd.TPC = 1; // set to 3 PRB - - RA_alloc_pdu.type = 1; - RA_alloc_pdu.vrb_type = 0; - RA_alloc_pdu.rballoc = RA_RB_ALLOC; - RA_alloc_pdu.ndi = 1; - RA_alloc_pdu.rv = 0; - RA_alloc_pdu.mcs = 0; - RA_alloc_pdu.harq_pid = 0; - RA_alloc_pdu.TPC = 1; - - RA_alloc_pdu_fdd.type = 1; - RA_alloc_pdu_fdd.vrb_type = 0; - RA_alloc_pdu_fdd.rballoc = RA_RB_ALLOC; - RA_alloc_pdu_fdd.ndi = 1; - RA_alloc_pdu_fdd.rv = 1; - RA_alloc_pdu_fdd.mcs = 1; - RA_alloc_pdu_fdd.harq_pid = 0; - RA_alloc_pdu_fdd.TPC = 1; - - - DLSCH_alloc_pdu1.rballoc = 0xf; - DLSCH_alloc_pdu1.TPC = 0; - DLSCH_alloc_pdu1.dai = 0; - DLSCH_alloc_pdu1.harq_pid = 0; - DLSCH_alloc_pdu1.tb_swap = 0; - DLSCH_alloc_pdu1.mcs1 = 4; - DLSCH_alloc_pdu1.ndi1 = 1; - DLSCH_alloc_pdu1.rv1 = 0; - - // Forget second codeword - if (transmission_mode == 6) { - DLSCH_alloc_pdu1.tpmi = 5; // PUSCH_PRECODING0 - } else { - DLSCH_alloc_pdu1.tpmi = 0; - } - - DLSCH_alloc_pdu2.rah = 0; - DLSCH_alloc_pdu2.rballoc = DLSCH_RB_ALLOC; - DLSCH_alloc_pdu2.TPC = 0; - DLSCH_alloc_pdu2.dai = 0; - DLSCH_alloc_pdu2.harq_pid = 0; - DLSCH_alloc_pdu2.tb_swap = 0; - DLSCH_alloc_pdu2.mcs1 = 4; - DLSCH_alloc_pdu2.ndi1 = 1; - DLSCH_alloc_pdu2.rv1 = 0; - - // Forget second codeword - if (transmission_mode == 6) { - DLSCH_alloc_pdu2.tpmi = 5; // PUSCH_PRECODING0 - } else { - DLSCH_alloc_pdu2.tpmi = 0; - } + // init DCI structures for testing + + UL_alloc_pdu.type = 0; + UL_alloc_pdu.hopping = 0; + UL_alloc_pdu.rballoc = UL_RB_ALLOC; + UL_alloc_pdu.mcs = 2; + UL_alloc_pdu.ndi = 1; + UL_alloc_pdu.TPC = 0; + UL_alloc_pdu.cqi_req = 1; + + /* + BCCH_alloc_pdu.type = 1; + BCCH_alloc_pdu.vrb_type = 0; + BCCH_alloc_pdu.rballoc = BCCH_RB_ALLOC; + BCCH_alloc_pdu.ndi = 1; + BCCH_alloc_pdu.rv = 1; + BCCH_alloc_pdu.mcs = 1; + BCCH_alloc_pdu.harq_pid = 0; + BCCH_alloc_pdu.TPC = 1; // set to 3 PRB + + // for FDD mode + BCCH_alloc_pdu_fdd.type = 1; + BCCH_alloc_pdu_fdd.vrb_type = 0; + BCCH_alloc_pdu_fdd.rballoc = BCCH_RB_ALLOC; + BCCH_alloc_pdu_fdd.ndi = 1; + BCCH_alloc_pdu_fdd.rv = 1; + BCCH_alloc_pdu_fdd.mcs = 1; + BCCH_alloc_pdu_fdd.harq_pid = 0; + BCCH_alloc_pdu_fdd.TPC = 1; // set to 3 PRB + */ + + DLSCH_alloc_pdu1A.type = 1; + DLSCH_alloc_pdu1A.vrb_type = 0; + DLSCH_alloc_pdu1A.rballoc = BCCH_RB_ALLOC; + DLSCH_alloc_pdu1A.ndi = 1; + DLSCH_alloc_pdu1A.rv = 1; + DLSCH_alloc_pdu1A.mcs = 2; + DLSCH_alloc_pdu1A.harq_pid = 0; + DLSCH_alloc_pdu1A.TPC = 1; // set to 3 PRB + + DLSCH_alloc_pdu1A_fdd.type = 1; + DLSCH_alloc_pdu1A_fdd.vrb_type = 0; + DLSCH_alloc_pdu1A_fdd.rballoc = BCCH_RB_ALLOC; + DLSCH_alloc_pdu1A_fdd.ndi = 1; + DLSCH_alloc_pdu1A_fdd.rv = 1; + DLSCH_alloc_pdu1A_fdd.mcs = 2; + DLSCH_alloc_pdu1A_fdd.harq_pid = 0; + DLSCH_alloc_pdu1A_fdd.TPC = 1; // set to 3 PRB + + RA_alloc_pdu.type = 1; + RA_alloc_pdu.vrb_type = 0; + RA_alloc_pdu.rballoc = RA_RB_ALLOC; + RA_alloc_pdu.ndi = 1; + RA_alloc_pdu.rv = 0; + RA_alloc_pdu.mcs = 0; + RA_alloc_pdu.harq_pid = 0; + RA_alloc_pdu.TPC = 1; + + RA_alloc_pdu_fdd.type = 1; + RA_alloc_pdu_fdd.vrb_type = 0; + RA_alloc_pdu_fdd.rballoc = RA_RB_ALLOC; + RA_alloc_pdu_fdd.ndi = 1; + RA_alloc_pdu_fdd.rv = 1; + RA_alloc_pdu_fdd.mcs = 1; + RA_alloc_pdu_fdd.harq_pid = 0; + RA_alloc_pdu_fdd.TPC = 1; + + + DLSCH_alloc_pdu1.rballoc = 0xf; + DLSCH_alloc_pdu1.TPC = 0; + DLSCH_alloc_pdu1.dai = 0; + DLSCH_alloc_pdu1.harq_pid = 0; + DLSCH_alloc_pdu1.tb_swap = 0; + DLSCH_alloc_pdu1.mcs1 = 4; + DLSCH_alloc_pdu1.ndi1 = 1; + DLSCH_alloc_pdu1.rv1 = 0; + + // Forget second codeword + if (transmission_mode == 6) { + DLSCH_alloc_pdu1.tpmi = 5; // PUSCH_PRECODING0 + } else { + DLSCH_alloc_pdu1.tpmi = 0; + } + + DLSCH_alloc_pdu2.rah = 0; + DLSCH_alloc_pdu2.rballoc = DLSCH_RB_ALLOC; + DLSCH_alloc_pdu2.TPC = 0; + DLSCH_alloc_pdu2.dai = 0; + DLSCH_alloc_pdu2.harq_pid = 0; + DLSCH_alloc_pdu2.tb_swap = 0; + DLSCH_alloc_pdu2.mcs1 = 4; + DLSCH_alloc_pdu2.ndi1 = 1; + DLSCH_alloc_pdu2.rv1 = 0; + + // Forget second codeword + if (transmission_mode == 6) { + DLSCH_alloc_pdu2.tpmi = 5; // PUSCH_PRECODING0 + } else { + DLSCH_alloc_pdu2.tpmi = 0; + } } diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index 56f53b4e0b7451c9d8f723c86ed0b23025aacd8f..a939c1f7d52416c51ffe6226dab8e45ef79f8856 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -49,250 +49,111 @@ extern RAN_CONTEXT_t RC; 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); - } -} -void mac_UE_out_of_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB_index) +void mac_top_init_eNB(void) { - // Mac_rlc_xface->mac_out_of_sync_ind(Mod_id, frameP, eNB_index); -} - + module_id_t i, j; + int list_el; + UE_list_t *UE_list; + eNB_MAC_INST *mac; + + LOG_I(MAC, "[MAIN] Init function start:nb_macrlc_inst=%d\n", + RC.nb_macrlc_inst); + + if (RC.nb_macrlc_inst > 0) { + RC.mac = + (eNB_MAC_INST **) malloc16(RC.nb_macrlc_inst * + sizeof(eNB_MAC_INST *)); + AssertFatal(RC.mac != NULL, + "can't ALLOCATE %zu Bytes for %d eNB_MAC_INST with size %zu \n", + RC.nb_macrlc_inst * sizeof(eNB_MAC_INST *), + RC.nb_macrlc_inst, sizeof(eNB_MAC_INST)); + for (i = 0; i < RC.nb_macrlc_inst; i++) { + RC.mac[i] = (eNB_MAC_INST *) malloc16(sizeof(eNB_MAC_INST)); + AssertFatal(RC.mac != NULL, + "can't ALLOCATE %zu Bytes for %d eNB_MAC_INST with size %zu \n", + RC.nb_macrlc_inst * sizeof(eNB_MAC_INST *), + RC.nb_macrlc_inst, sizeof(eNB_MAC_INST)); + LOG_D(MAC, + "[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n", + sizeof(eNB_MAC_INST), RC.nb_macrlc_inst, RC.mac); + bzero(RC.mac[i], sizeof(eNB_MAC_INST)); + RC.mac[i]->Mod_id = i; + for (j = 0; j < MAX_NUM_CCs; j++) { + RC.mac[i]->DL_req[j].dl_config_request_body. + dl_config_pdu_list = RC.mac[i]->dl_config_pdu_list[j]; + RC.mac[i]->UL_req[j].ul_config_request_body. + ul_config_pdu_list = RC.mac[i]->ul_config_pdu_list[j]; + for (int k = 0; k < 10; k++) + RC.mac[i]->UL_req_tmp[j][k]. + ul_config_request_body.ul_config_pdu_list = + RC.mac[i]->ul_config_pdu_list_tmp[j][k]; + RC.mac[i]->HI_DCI0_req[j]. + hi_dci0_request_body.hi_dci0_pdu_list = + RC.mac[i]->hi_dci0_pdu_list[j]; + RC.mac[i]->TX_req[j].tx_request_body.tx_pdu_list = + RC.mac[i]->tx_request_pdu[j]; + RC.mac[i]->ul_handle = 0; + } + } + + AssertFatal(rlc_module_init() == 0, + "Could not initialize RLC layer\n"); + + // These should be out of here later + pdcp_layer_init(); + + rrc_init_global_param(); -int mac_top_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active) -{ + } else { + RC.mac = NULL; + } - int i; + // Initialize Linked-List for Active UEs + for (i = 0; i < RC.nb_macrlc_inst; i++) { + mac = RC.mac[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)); + mac->if_inst = IF_Module_init(i); - 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)); + UE_list = &mac->UE_list; - 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); + UE_list->num_UEs = 0; + UE_list->head = -1; + UE_list->head_ul = -1; + UE_list->avail = 0; - bzero(UE_mac_inst,NB_UE_INST*sizeof(UE_MAC_INST)); + for (list_el = 0; list_el < NUMBER_OF_UE_MAX - 1; list_el++) { + UE_list->next[list_el] = list_el + 1; + UE_list->next_ul[list_el] = list_el + 1; + } - for(i=0; i<NB_UE_INST; i++) { - ue_init_mac(i); + UE_list->next[list_el] = -1; + UE_list->next_ul[list_el] = -1; } - } else { - UE_mac_inst = 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); } - -void mac_top_init_eNB(void) +void mac_init_cell_params(int Mod_idP, int CC_idP) { - module_id_t i,j; - int list_el; - UE_list_t *UE_list; - eNB_MAC_INST *mac; - - LOG_I(MAC,"[MAIN] Init function start:nb_macrlc_inst=%d\n",RC.nb_macrlc_inst); - - if (RC.nb_macrlc_inst>0) { - RC.mac = (eNB_MAC_INST**)malloc16(RC.nb_macrlc_inst*sizeof(eNB_MAC_INST*)); - AssertFatal(RC.mac != NULL,"can't ALLOCATE %zu Bytes for %d eNB_MAC_INST with size %zu \n", - RC.nb_macrlc_inst*sizeof(eNB_MAC_INST*), - RC.nb_macrlc_inst, - sizeof(eNB_MAC_INST)); - for (i=0;i<RC.nb_macrlc_inst;i++) { - RC.mac[i] = (eNB_MAC_INST*)malloc16(sizeof(eNB_MAC_INST)); - AssertFatal(RC.mac != NULL, - "can't ALLOCATE %zu Bytes for %d eNB_MAC_INST with size %zu \n", - RC.nb_macrlc_inst*sizeof(eNB_MAC_INST*),RC.nb_macrlc_inst,sizeof(eNB_MAC_INST)); - LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),RC.nb_macrlc_inst,RC.mac); - bzero(RC.mac[i],sizeof(eNB_MAC_INST)); - RC.mac[i]->Mod_id = i; - for (j=0;j<MAX_NUM_CCs;j++) { - RC.mac[i]->DL_req[j].dl_config_request_body.dl_config_pdu_list = RC.mac[i]->dl_config_pdu_list[j]; - RC.mac[i]->UL_req[j].ul_config_request_body.ul_config_pdu_list = RC.mac[i]->ul_config_pdu_list[j]; - for (int k=0;k<10;k++) RC.mac[i]->UL_req_tmp[j][k].ul_config_request_body.ul_config_pdu_list = RC.mac[i]->ul_config_pdu_list_tmp[j][k]; - RC.mac[i]->HI_DCI0_req[j].hi_dci0_request_body.hi_dci0_pdu_list = RC.mac[i]->hi_dci0_pdu_list[j]; - RC.mac[i]->TX_req[j].tx_request_body.tx_pdu_list = RC.mac[i]->tx_request_pdu[j]; - RC.mac[i]->ul_handle = 0; - } - } - - AssertFatal(rlc_module_init()==0,"Could not initialize RLC layer\n"); - - // These should be out of here later - pdcp_layer_init (); - - rrc_init_global_param(); + int j; + UE_TEMPLATE *UE_template; - } else { - RC.mac = NULL; - } - - // Initialize Linked-List for Active UEs - for(i=0; i<RC.nb_macrlc_inst; i++) { - mac = RC.mac[i]; + LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", Mod_idP); + //COMMON_channels_t *cc = &RC.mac[Mod_idP]->common_channels[CC_idP]; + memset(&RC.mac[Mod_idP]->eNB_stats, 0, sizeof(eNB_STATS)); + UE_template = + (UE_TEMPLATE *) & RC.mac[Mod_idP]->UE_list.UE_template[CC_idP][0]; - mac->if_inst = IF_Module_init(i); - - UE_list = &mac->UE_list; - - UE_list->num_UEs=0; - UE_list->head=-1; - UE_list->head_ul=-1; - UE_list->avail=0; - - for (list_el=0; list_el<NUMBER_OF_UE_MAX-1; list_el++) { - UE_list->next[list_el]=list_el+1; - UE_list->next_ul[list_el]=list_el+1; - } - - UE_list->next[list_el]=-1; - UE_list->next_ul[list_el]=-1; - } - -} - -void mac_init_cell_params(int Mod_idP,int CC_idP) { - - int j; - RA_TEMPLATE *RA_template; - UE_TEMPLATE *UE_template; - int size_bytes1,size_bytes2,size_bits1,size_bits2; - - LOG_D(MAC,"[MAIN][eNB %d] CC_id %d initializing RA_template\n",Mod_idP, CC_idP); - LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", Mod_idP); - COMMON_channels_t *cc = &RC.mac[Mod_idP]->common_channels[CC_idP]; - - RA_template = (RA_TEMPLATE *)&cc->RA_template[0]; - - for (j=0; j<NB_RA_PROC_MAX; j++) { - if ( cc->tdd_Config != NULL) { - switch (cc->mib->message.dl_Bandwidth) { - case MasterInformationBlock__dl_Bandwidth_n6: - size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - break; - - case MasterInformationBlock__dl_Bandwidth_n25: - size_bytes1 = sizeof(DCI1A_5MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_5MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_5MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_5MHz_TDD_1_6_t; - break; - - case MasterInformationBlock__dl_Bandwidth_n50: - size_bytes1 = sizeof(DCI1A_10MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_10MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_10MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_10MHz_TDD_1_6_t; - break; - - case MasterInformationBlock__dl_Bandwidth_n100: - size_bytes1 = sizeof(DCI1A_20MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_20MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_20MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_20MHz_TDD_1_6_t; - break; - - default: - size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - break; - } - - } else { - switch (cc->mib->message.dl_Bandwidth) { - case MasterInformationBlock__dl_Bandwidth_n6: - size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t; - size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t; - break; - - case MasterInformationBlock__dl_Bandwidth_n25: - size_bytes1 = sizeof(DCI1A_5MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_5MHz_FDD_t); - size_bits1 = sizeof_DCI1A_5MHz_FDD_t; - size_bits2 = sizeof_DCI1A_5MHz_FDD_t; - break; - - case MasterInformationBlock__dl_Bandwidth_n50: - size_bytes1 = sizeof(DCI1A_10MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_10MHz_FDD_t); - size_bits1 = sizeof_DCI1A_10MHz_FDD_t; - size_bits2 = sizeof_DCI1A_10MHz_FDD_t; - break; - - case MasterInformationBlock__dl_Bandwidth_n100: - size_bytes1 = sizeof(DCI1A_20MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_20MHz_FDD_t); - size_bits1 = sizeof_DCI1A_20MHz_FDD_t; - size_bits2 = sizeof_DCI1A_20MHz_FDD_t; - break; - - default: - size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t; - size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t; - break; - } + for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + UE_template[j].rnti = 0; + // initiallize the eNB to UE statistics + memset(&RC.mac[Mod_idP]->UE_list.eNB_UE_stats[CC_idP][j], 0, + sizeof(eNB_UE_STATS)); } - - memcpy((void *)&RA_template[j].RA_alloc_pdu1[0],(void *)&RA_alloc_pdu,size_bytes1); - memcpy((void *)&RA_template[j].RA_alloc_pdu2[0],(void *)&DLSCH_alloc_pdu1A,size_bytes2); - RA_template[j].RA_dci_size_bytes1 = size_bytes1; - RA_template[j].RA_dci_size_bytes2 = size_bytes2; - RA_template[j].RA_dci_size_bits1 = size_bits1; - RA_template[j].RA_dci_size_bits2 = size_bits2; - - RA_template[j].RA_dci_fmt1 = format1A; - RA_template[j].RA_dci_fmt2 = format1A; - } - - memset (&RC.mac[Mod_idP]->eNB_stats,0,sizeof(eNB_STATS)); - UE_template = (UE_TEMPLATE *)&RC.mac[Mod_idP]->UE_list.UE_template[CC_idP][0]; - - for (j=0; j<NUMBER_OF_UE_MAX; j++) { - UE_template[j].rnti=0; - // initiallize the eNB to UE statistics - memset (&RC.mac[Mod_idP]->UE_list.eNB_UE_stats[CC_idP][j],0,sizeof(eNB_UE_STATS)); - } } @@ -301,47 +162,31 @@ int rlcmac_init_global_param(void) { - LOG_I(MAC,"[MAIN] CALLING RLC_MODULE_INIT...\n"); + LOG_I(MAC, "[MAIN] CALLING RLC_MODULE_INIT...\n"); - if (rlc_module_init()!=0) { - return(-1); - } + if (rlc_module_init() != 0) { + return (-1); + } - pdcp_layer_init (); + pdcp_layer_init(); - LOG_I(MAC,"[MAIN] Init Global Param Done\n"); + LOG_I(MAC, "[MAIN] Init Global Param Done\n"); - return 0; + return 0; } void mac_top_cleanup(void) { -#ifndef USER_MODE - pdcp_module_cleanup (); -#endif - - if (NB_UE_INST>0) { - free (UE_mac_inst); - } - - if (RC.nb_macrlc_inst>0) { - free(RC.mac); - } + if (NB_UE_INST > 0) { + free(UE_mac_inst); + } -} + if (RC.nb_macrlc_inst > 0) { + free(RC.mac); + } -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(); - LOG_I(MAC,"[MAIN] init UE MAC functions \n"); - mac_top_init_ue(eMBMS_active,uecap_xer,cba_group_active,HO_active); - return(1); } int l2_init_eNB(void) @@ -349,13 +194,12 @@ int l2_init_eNB(void) - LOG_I(MAC,"[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n"); + LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n"); - rlcmac_init_global_param(); + rlcmac_init_global_param(); - LOG_D(MAC,"[MAIN] ALL INIT OK\n"); + LOG_D(MAC, "[MAIN] ALL INIT OK\n"); - return(1); + return (1); } - diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..64326dec614dc9ea452c7ce7bebf73692050167b --- /dev/null +++ b/openair2/LAYER2/MAC/main_ue.c @@ -0,0 +1,150 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file main.c + * \brief top init of Layer 2 + * \author Navid Nikaein and Raymond Knopp + * \date 2010 - 2014 + * \version 1.0 + * \email: navid.nikaein@eurecom.fr + * @ingroup _mac + + */ + +#include "defs.h" +#include "proto.h" +#include "extern.h" +#include "assertions.h" +#include "PHY_INTERFACE/extern.h" +#include "PHY/defs.h" +#include "SCHED/defs.h" +#include "LAYER2/PDCP_v10.1.0/pdcp.h" +#include "RRC/LITE/defs.h" +#include "UTIL/LOG/log.h" +#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" + +#include "SCHED/defs.h" + + +#include "common/ran_context.h" + +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); + } +} + +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); +} + + +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; + } + + + 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(); + + 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); +} + diff --git a/openair2/LAYER2/MAC/openair2_proc.c b/openair2/LAYER2/MAC/openair2_proc.c deleted file mode 100644 index ab78be3c61048577790325f1b83d4a5f29af1058..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/MAC/openair2_proc.c +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* \file openair2_proc.c - \brief MAC layer online statistics - \author Navid Nikaein - \date 2013 - 2014 - \version 1.0 - @ingroup _mac -*/ - -#ifndef USER_MODE -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/proc_fs.h> - -#endif -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -//#include "RRC/LITE/extern.h" -//#include "LAYER2/PDCP/pdcp.h" -#include "proto.h" - -extern RAN_CONTEXT_t RC; - -int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) - -{ - - int len = 0,fg,Overhead, Sign; - unsigned int i,j,k,kk; - unsigned int ue_id, eNB_id; - unsigned int Mod_id = 0,CH_index; - unsigned int stat_tx_pdcp_sdu; - unsigned int stat_tx_pdcp_bytes; - unsigned int stat_tx_pdcp_sdu_discarded; - unsigned int stat_tx_pdcp_bytes_discarded; - unsigned int stat_tx_data_pdu; - unsigned int stat_tx_data_bytes; - unsigned int stat_tx_retransmit_pdu_by_status; - unsigned int stat_tx_retransmit_bytes_by_status; - unsigned int stat_tx_retransmit_pdu; - unsigned int stat_tx_retransmit_bytes; - unsigned int stat_tx_control_pdu; - unsigned int stat_tx_control_bytes; - unsigned int stat_rx_pdcp_sdu; - unsigned int stat_rx_pdcp_bytes; - unsigned int stat_rx_data_pdus_duplicate; - unsigned int stat_rx_data_bytes_duplicate; - unsigned int stat_rx_data_pdu; - unsigned int stat_rx_data_bytes; - unsigned int stat_rx_data_pdu_dropped; - unsigned int stat_rx_data_bytes_dropped; - unsigned int stat_rx_data_pdu_out_of_window; - unsigned int stat_rx_data_bytes_out_of_window; - unsigned int stat_rx_control_pdu; - unsigned int stat_rx_control_bytes; - unsigned int stat_timer_reordering_timed_out; - unsigned int stat_timer_poll_retransmit_timed_out; - unsigned int stat_timer_status_prohibit_timed_out; - - // UE part - for (ue_id=0; ue_id<NUM_UE_INST; ue_id++) { - // mod_id used for PDCP and RLC - Mod_id = NB_eNB_INST + ue_id ; - - len+=sprintf(&buffer[len],"UE RX TTI: %d\n",UE_mac_inst[ue_id].rxFrame); - - for (enb_id= 0; enb_id <NB_SIG_CNX_UE; enb_id++) { - - switch (mac_get_rrc_status(ue_id,0,enb_id) > RRC_CONNECTED) { - case RRC_RECONFIGURED : - case RRC_CONNECTED: - case RRC_SI_RECEIVED: - case RRC_IDLE: - break; - - if (mac_get_rrc_status(ue_id,0,enb_id) > RRC_CONNECTED) { - // if (UE_mac_inst[ue_id].Dcch_lchan[CH_index].Active==1) { - len+=sprintf(&buffer[len],"eNB %d: Wideband SINR %d dB---\n", - CH_index,UE_mac_inst[Mod_id].Def_meas[CH_index].Wideband_sinr); - len+=sprintf(&buffer[len],"CH %d: Subband SINR (dB) :", - CH_index); - - for (fg=0; fg<NUMBER_OF_MEASUREMENT_SUBBANDS; fg++) { - len+=sprintf(&buffer[len],"%d ",UE_mac_inst[Mod_id].Def_meas[CH_index].Sinr_meas[0][fg]); - } - - len+=sprintf(&buffer[len],"\n"); - - - len+=sprintf(&buffer[len],"BCCH %d, NB_RX_MAC = %d (%d errors)\n", - UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.Lchan_id.Index, - UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.NB_RX, - UE_mac_inst[Mod_id].Bcch_lchan[CH_index].Lchan_info.NB_RX_ERRORS); - - - - len+=sprintf(&buffer[len],"CCCH %d, NB_RX_MAC = %d (%d errors)\n", - UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.Lchan_id.Index, - UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.NB_RX, - UE_mac_inst[Mod_id].Ccch_lchan[CH_index].Lchan_info.NB_RX_ERRORS); - - - len+=sprintf(&buffer[len],"LCHAN %d (DCCH), NB_TX_MAC = %d (%d bits/TTI, %d kbits/sec), NB_RX_MAC = %d (%d errors)\n", - UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.Lchan_id.Index, - UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.NB_TX, - UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.output_rate, - (10*UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.output_rate)>>5, - UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.NB_RX, - UE_mac_inst[Mod_id].Dcch_lchan[CH_index].Lchan_info.NB_RX_ERRORS); - - for(i=1; i<NB_RAB_MAX; i++) { - if (UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Active==1) { - Overhead=UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.output_rate - Pdcp_stats_tx_rate[k][CH_index][i]; - - if(Overhead<0) { - Overhead=-Overhead; - Sign=-1; - } else { - Sign=1; - } - - len+=sprintf(&buffer[len],"[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s) , LAYER2 TX OVERHEAD: %d Kbits/s\n", - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, - Pdcp_stats_tx[k][CH_index][i], - Pdcp_stats_tx_rate[k][CH_index][i], - (10*Pdcp_stats_tx_rate[k][CH_index][i])>>5, - Pdcp_stats_rx[k][CH_index][i], - Pdcp_stats_rx_rate[k][CH_index][i], - (10*Pdcp_stats_rx_rate[k][CH_index][i])>>5, - Sign*(10*Overhead)>>5); - - - int status = rlc_stat_req (k, - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, - &stat_tx_pdcp_sdu, - &stat_tx_pdcp_bytes, - &stat_tx_pdcp_sdu_discarded, - &stat_tx_pdcp_bytes_discarded, - &stat_tx_data_pdu, - &stat_tx_data_bytes, - &stat_tx_retransmit_pdu_by_status, - &stat_tx_retransmit_bytes_by_status, - &stat_tx_retransmit_pdu, - &stat_tx_retransmit_bytes, - &stat_tx_control_pdu, - &stat_tx_control_bytes, - &stat_rx_pdcp_sdu, - &stat_rx_pdcp_bytes, - &stat_rx_data_pdus_duplicate, - &stat_rx_data_bytes_duplicate, - &stat_rx_data_pdu, - &stat_rx_data_bytes, - &stat_rx_data_pdu_dropped, - &stat_rx_data_bytes_dropped, - &stat_rx_data_pdu_out_of_window, - &stat_rx_data_bytes_out_of_window, - &stat_rx_control_pdu, - &stat_rx_control_bytes, - &stat_timer_reordering_timed_out, - &stat_timer_poll_retransmit_timed_out, - &stat_timer_status_prohibit_timed_out) ; - - if (status == RLC_OP_STATUS_OK) { - len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_SDU_TO_TX = %d\tNB_SDU_DISC %d\tNB_RX_SDU %d\n", - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, - tx_pdcp_sdu, - tx_pdcp_sdu_discarded, - rx_sdu); - len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_TB_TX_DATA = %d\tNB_TB_TX_CONTROL %d\tNB_TX_TB_RETRANS %d", - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, - tx_data_pdu, - tx_control_pdu, - tx_retransmit_pdu); - len+=sprintf(&buffer[len],"\tRLC LCHAN %d, NB_TX_TB_RETRANS_BY_STATUS = %d\tNB_TX_TB_RETRANS_PADD %d\n", - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, - tx_retransmit_pdu_by_status, - tx_retransmit_pdu_unblock); - len+=sprintf(&buffer[len],"RLC LCHAN %d, NB_RX_DATA = %d\tNB_RX_TB_OUT_WIN %d\tNB_RX_TB_CORRUPT %d\n", - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, - rx_data_pdu, - rx_data_pdu_out_of_window, - rx_error_pdu); - } - - len+=sprintf(&buffer[len],"[MAC]: LCHAN %d, NB_TX_MAC = %d (%d bits/TTI, %d kbits/s), NB_RX_MAC = %d (%d errors)\n", - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.Lchan_id.Index, - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_TX, - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.output_rate, - (10*UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.output_rate)>>5, - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX, - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX_ERRORS); - len+=sprintf(&buffer[len]," TX per TB: "); - - for(kk=0; kk<MAX_NUMBER_TB_PER_LCHAN/2; kk++) { - len+=sprintf(&buffer[len],"%d . ",UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_TX_TB[kk]); - } - - len+=sprintf(&buffer[len],"\n"); - len+=sprintf(&buffer[len]," RXerr per TB: "); - - for(kk=0; kk<MAX_NUMBER_TB_PER_LCHAN/2; kk++) - len+=sprintf(&buffer[len],"%d/%d . ",UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX_ERRORS_TB[kk], - UE_mac_inst[Mod_id].Dtch_lchan[i][CH_index].Lchan_info.NB_RX_TB[kk]); - - len+=sprintf(&buffer[len],"\n"); - - - - } - - } - } - } - -#endif //PHY_EMUL_ONE_MACHINE - } - - else if(Mac_rlc_xface->Is_cluster_head[k] ==1) { - - Mod_id=k; - len+=sprintf(&buffer[len], - "-------------------------------------------------------------------CH %d: TTI: %d------------------------------------------------------------------\n", - NODE_ID[Mod_id],Mac_rlc_xface->frame); - - for(i=1; i<=NB_CNX_CH; i++) { - if (CH_mac_inst[Mod_id].Dcch_lchan[i].Active==1) { - len+=sprintf(&buffer[len],"\nMR index %d: DL SINR (feedback) %d dB, CQI: %s\n\n", - i,//CH_rrc_inst[Mod_id].Info.UE_list[i].L2_id[0], - CH_mac_inst[Mod_id].Def_meas[i].Wideband_sinr); - //print_cqi(CH_mac_inst[Mod_id].Def_meas[i].cqi)); - - len+=sprintf(&buffer[len], - "[MAC] LCHAN %d (DCCH), NB_TX_MAC= %d (%d bits/TTI, %d kbits/s), NB_RX_MAC= %d (errors %d, sacch errors %d, sach errors %d, sach_missing %d)\n\n", - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.Lchan_id.Index, - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_TX, - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.output_rate, - (10*CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.output_rate)>>5, - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_RX, - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_RX_ERRORS, - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_RX_SACCH_ERRORS, - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_RX_SACH_ERRORS, - CH_mac_inst[Mod_id].Dcch_lchan[i].Lchan_info.NB_RX_SACH_MISSING); - - for(j=0; j<NB_RAB_MAX; j++) { - if (CH_mac_inst[Mod_id].Dtch_lchan[j][i].Active==1) { - Overhead=CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.output_rate - Pdcp_stats_tx_rate[k][i][j]; - - if(Overhead<0) { - Overhead=-Overhead; - Sign=-1; - } else { - Sign=1; - } - - len+=sprintf(&buffer[len], - "[PDCP]LCHAN %d: NB_TX = %d ,Tx_rate =(%d bits/TTI ,%d Kbits/s), NB_RX = %d ,Rx_rate =(%d bits/TTI ,%d Kbits/s), LAYER2 TX OVERHEAD= %d Kbits/s\n", - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, - Pdcp_stats_tx[k][i][j], - Pdcp_stats_tx_rate[k][i][j], - (10*Pdcp_stats_tx_rate[k][i][j])>>5, - Pdcp_stats_rx[k][i][j], - Pdcp_stats_rx_rate[k][i][j], - (10*Pdcp_stats_rx_rate[k][i][j])>>5, - Sign*(10*Overhead)>>5); - int status = rlc_stat_req (k, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, - &tx_pdcp_sdu, - &tx_pdcp_sdu_discarded, - &tx_retransmit_pdu_unblock, - &tx_retransmit_pdu_by_status, - &tx_retransmit_pdu, - &tx_data_pdu, - &tx_control_pdu, - &rx_sdu, - &rx_error_pdu, - &rx_data_pdu, - &rx_data_pdu_out_of_window, - &rx_control_pdu) ; - /* - if (status == RLC_OP_STATUS_OK) { - len+=sprintf(&buffer[len],"\t[RLC] LCHAN %d, NB_SDU_TO_TX = %d\tNB_SDU_DISC %d\tNB_RX_SDU %d\n", - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, - tx_pdcp_sdu, - tx_pdcp_sdu_discarded, - rx_sdu); - len+=sprintf(&buffer[len],"\t[RLC] LCHAN %d, NB_TB_TX_DATA = %d\tNB_TB_TX_CONTROL %d\tNB_TX_TB_RETRANS %\n", - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, - tx_data_pdu, - tx_control_pdu, - tx_retransmit_pdu); - len+=sprintf(&buffer[len],"\t[RLC] LCHAN %d, NB_TX_TB_RETRANS_BY_STATUS = %d\tNB_TX_TB_RETRANS_PADD %d\n", - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, - tx_retransmit_pdu_by_status, - tx_retransmit_pdu_unblock); - len+=sprintf(&buffer[len],"\t[RLC] LCHAN %d, NB_RX_DATA = %d\tNB_RX_TB_OUT_WIN %d\tNB_RX_TB_CORRUPT %d\n", - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, - rx_data_pdu, - rx_data_pdu_out_of_window, - rx_error_pdu); - } - */ - len+=sprintf(&buffer[len], - "[MAC]LCHAN %d (CNX %d,RAB %d), NB_TX_MAC= %d (%d bits/TTI, %d kbit/s), NB_RX_MAC= %d (errors %d, sacch_errors %d, sach_errors %d, sach_missing %d)\n", - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Lchan_id.Index, - i,j, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_TX, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.output_rate, - (10*CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.output_rate)>>5, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_RX, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_RX_ERRORS, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_RX_SACCH_ERRORS, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_RX_SACH_ERRORS, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_RX_SACH_MISSING); - len+=sprintf(&buffer[len],"[MAC][SCHEDULER] TX Arrival Rate %d, TX Service Rate %d, RX Arrival rate %d, RX Service rate %d, NB_BW_REQ_RX %d\n\n", - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Arrival_rate, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Tx_rate, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Req_rate, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.Rx_rate, - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_BW_REQ_RX); - - /* - len+=sprintf(&buffer[len]," TX per TB: "); - for(kk=0;kk<MAX_NUMBER_TB_PER_LCHAN/2;kk++) - len+=sprintf(&buffer[len],"%d.",CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_TX_TB[kk]); - len+=sprintf(&buffer[len],"\n"); - len+=sprintf(&buffer[len]," RXerr per TB: "); - for(kk=0;kk<MAX_NUMBER_TB_PER_LCHAN/2;kk++) - len+=sprintf(&buffer[len],"%d/%d . ",CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_RX_ERRORS_TB[kk], - CH_mac_inst[Mod_id].Dtch_lchan[j][i].Lchan_info.NB_RX_TB[kk]); - len+=sprintf(&buffer[len],"\n"); - */ - } - } - } - } - - } - } - - return len; -} - -#ifndef USER_MODE -static struct proc_dir_entry *proc_openair2_root; -/* - * Initialize the module and add the /proc file. - */ -int add_openair2_stats() -{ - //#ifdef KERNEL_VERSION_GREATER_THAN_2629 - struct proc_dir_entry *pde; - //#endif - - proc_openair2_root = proc_mkdir("openair2",0); - //#ifdef KERNEL_VERSION_GREATER_THAN_2629 - // pde = proc_create_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root); - pde = create_proc_read_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root, (read_proc_t*)&openair2_stats_read, NULL); - - if (!pde) { - printk("[OPENAIR][ERROR] can't create proc entry !\n"); - } - - //#else - //create_proc_info_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root, openair2_stats_read); - //#endif - - return 0; -} -/* - * Unregister the file when the module is closed. - */ -void remove_openair2_stats() -{ - - if (proc_openair2_root) { - printk("[OPENAIR][CLEANUP] Removing openair proc entry\n"); - remove_proc_entry("lchan_stats", proc_openair2_root); - //#ifdef KERNEL_VERSION_GREATER_THAN_2629 - - //#else - remove_proc_entry("openair2",NULL); - //#endif; - } -} -#endif diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 8a7f7a7064d82c2ecae5c24869693f26cc42eaf7..9821dc29f3c02dec864115473d4bdf3caa0e92e1 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -59,12 +59,6 @@ //#define ICIC 0 -/* - #ifndef USER_MODE - #define msg debug_msg - #endif -*/ - /* this function checks that get_eNB_UE_stats returns * a non-NULL pointer for all the active CCs of an UE */ @@ -95,393 +89,463 @@ int phy_stats_exist(module_id_t Mod_id, int rnti) */ // This function stores the downlink buffer for all the logical channels -void store_dlsch_buffer (module_id_t Mod_id, - frame_t frameP, - sub_frame_t subframeP) +void +store_dlsch_buffer(module_id_t Mod_id, frame_t frameP, + sub_frame_t subframeP) { - int UE_id,i; - rnti_t rnti; - mac_rlc_status_resp_t rlc_status; - UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; - UE_TEMPLATE *UE_template; + int UE_id, i; + rnti_t rnti; + mac_rlc_status_resp_t rlc_status; + UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; + UE_TEMPLATE *UE_template; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) continue; + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) + continue; - UE_template = &UE_list->UE_template[UE_PCCID(Mod_id,UE_id)][UE_id]; + UE_template = + &UE_list->UE_template[UE_PCCID(Mod_id, UE_id)][UE_id]; - // clear logical channel interface variables - UE_template->dl_buffer_total = 0; - UE_template->dl_pdus_total = 0; + // clear logical channel interface variables + UE_template->dl_buffer_total = 0; + UE_template->dl_pdus_total = 0; + + for (i = 0; i < MAX_NUM_LCID; i++) { + UE_template->dl_buffer_info[i] = 0; + UE_template->dl_pdus_in_buffer[i] = 0; + UE_template->dl_buffer_head_sdu_creation_time[i] = 0; + UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = 0; + } - for(i=0; i< MAX_NUM_LCID; i++) { - UE_template->dl_buffer_info[i]=0; - UE_template->dl_pdus_in_buffer[i]=0; - UE_template->dl_buffer_head_sdu_creation_time[i]=0; - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i]=0; - } - rnti = UE_RNTI(Mod_id,UE_id); + rnti = UE_RNTI(Mod_id, UE_id); - for(i=0; i< MAX_NUM_LCID; i++) { // loop over all the logical channels + for (i = 0; i < MAX_NUM_LCID; i++) { // loop over all the logical channels - rlc_status = mac_rlc_status_ind(Mod_id,rnti, Mod_id,frameP,subframeP,ENB_FLAG_YES,MBMS_FLAG_NO,i,0 + rlc_status = + mac_rlc_status_ind(Mod_id, rnti, Mod_id, frameP, subframeP, + ENB_FLAG_YES, MBMS_FLAG_NO, i, 0 #ifdef Rel14 - ,0, 0 + ,0, 0 #endif - ); - UE_template->dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel - UE_template->dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; - UE_template->dl_buffer_head_sdu_creation_time[i] = rlc_status.head_sdu_creation_time ; - UE_template->dl_buffer_head_sdu_creation_time_max = cmax(UE_template->dl_buffer_head_sdu_creation_time_max, - rlc_status.head_sdu_creation_time ); - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = rlc_status.head_sdu_remaining_size_to_send; - UE_template->dl_buffer_head_sdu_is_segmented[i] = rlc_status.head_sdu_is_segmented; - UE_template->dl_buffer_total += UE_template->dl_buffer_info[i];//storing the total dlsch buffer - UE_template->dl_pdus_total += UE_template->dl_pdus_in_buffer[i]; + ); + + UE_template->dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel + UE_template->dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; + UE_template->dl_buffer_head_sdu_creation_time[i] = + rlc_status.head_sdu_creation_time; + UE_template->dl_buffer_head_sdu_creation_time_max = + cmax(UE_template->dl_buffer_head_sdu_creation_time_max, + rlc_status.head_sdu_creation_time); + UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = + rlc_status.head_sdu_remaining_size_to_send; + UE_template->dl_buffer_head_sdu_is_segmented[i] = + rlc_status.head_sdu_is_segmented; + UE_template->dl_buffer_total += UE_template->dl_buffer_info[i]; //storing the total dlsch buffer + UE_template->dl_pdus_total += + UE_template->dl_pdus_in_buffer[i]; #ifdef DEBUG_eNB_SCHEDULER - /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : - * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent - */ - if (UE_template->dl_buffer_info[i]>0) - LOG_D(MAC, - "[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmented %d \n", - Mod_id, frameP, subframeP, UE_id, - i, UE_template->dl_pdus_in_buffer[i],UE_template->dl_buffer_info[i], - UE_template->dl_buffer_head_sdu_creation_time[i], - UE_template->dl_buffer_head_sdu_remaining_size_to_send[i], - UE_template->dl_buffer_head_sdu_is_segmented[i] - ); + /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : + * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent + */ + if (UE_template->dl_buffer_info[i] > 0) + LOG_D(MAC, + "[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", + Mod_id, frameP, subframeP, UE_id, + i, UE_template->dl_pdus_in_buffer[i], + UE_template->dl_buffer_info[i], + UE_template->dl_buffer_head_sdu_creation_time[i], + UE_template-> + dl_buffer_head_sdu_remaining_size_to_send[i], + UE_template->dl_buffer_head_sdu_is_segmented[i]); #endif - } + } - //#ifdef DEBUG_eNB_SCHEDULER - if ( UE_template->dl_buffer_total>0) - LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", - Mod_id, frameP, subframeP, UE_id, - UE_template->dl_buffer_total, - UE_template->dl_pdus_total - ); + //#ifdef DEBUG_eNB_SCHEDULER + if (UE_template->dl_buffer_total > 0) + LOG_D(MAC, + "[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", + Mod_id, frameP, subframeP, UE_id, + UE_template->dl_buffer_total, + UE_template->dl_pdus_total); - //#endif - } + //#endif + } } // This function returns the estimated number of RBs required by each UE for downlink scheduling -void assign_rbs_required (module_id_t Mod_id, - frame_t frameP, - sub_frame_t subframe, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - int min_rb_unit[MAX_NUM_CCs]) +void +assign_rbs_required(module_id_t Mod_id, + frame_t frameP, + sub_frame_t subframe, + uint16_t + nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + int min_rb_unit[MAX_NUM_CCs]) { - uint16_t TBS = 0; - - int UE_id,n,i,j,CC_id,pCCid,tmp; - UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; - eNB_UE_STATS *eNB_UE_stats,*eNB_UE_stats_i,*eNB_UE_stats_j; - int N_RB_DL; - - // clear rb allocations across all CC_id - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) continue; + uint16_t TBS = 0; - pCCid = UE_PCCID(Mod_id,UE_id); + int UE_id, n, i, j, CC_id, pCCid, tmp; + UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; + eNB_UE_STATS *eNB_UE_stats, *eNB_UE_stats_i, *eNB_UE_stats_j; + int N_RB_DL; - //update CQI information across component carriers - for (n=0; n<UE_list->numactiveCCs[UE_id]; n++) { - - CC_id = UE_list->ordered_CCids[n][UE_id]; - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - - eNB_UE_stats->dlsch_mcs1=cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; - - } - - // provide the list of CCs sorted according to MCS - for (i=0; i<UE_list->numactiveCCs[UE_id]; i++) { - eNB_UE_stats_i = &UE_list->eNB_UE_stats[UE_list->ordered_CCids[i][UE_id]][UE_id]; - for (j=i+1; j<UE_list->numactiveCCs[UE_id]; j++) { - DevAssert( j < MAX_NUM_CCs ); - eNB_UE_stats_j = &UE_list->eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]][UE_id]; - if (eNB_UE_stats_j->dlsch_mcs1 > - eNB_UE_stats_i->dlsch_mcs1) { - tmp = UE_list->ordered_CCids[i][UE_id]; - UE_list->ordered_CCids[i][UE_id] = UE_list->ordered_CCids[j][UE_id]; - UE_list->ordered_CCids[j][UE_id] = tmp; - } - } - } - - if (UE_list->UE_template[pCCid][UE_id].dl_buffer_total> 0) { - //LOG_D(MAC,"[preprocessor] assign RB for UE %d\n",UE_id); - - for (i=0; i<UE_list->numactiveCCs[UE_id]; i++) { - CC_id = UE_list->ordered_CCids[i][UE_id]; - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - - if (eNB_UE_stats->dlsch_mcs1==0) { - nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small - } else { - nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; - } - - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); + // clear rb allocations across all CC_id + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) + continue; - if(0)LOG_D(MAC,"[preprocessor] start RB assignment for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", - UE_id, CC_id, UE_list->UE_template[pCCid][UE_id].dl_buffer_total, - nb_rbs_required[CC_id][UE_id],eNB_UE_stats->dlsch_mcs1,TBS); + pCCid = UE_PCCID(Mod_id, UE_id); - N_RB_DL = to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth); + //update CQI information across component carriers + for (n = 0; n < UE_list->numactiveCCs[UE_id]; n++) { + CC_id = UE_list->ordered_CCids[n][UE_id]; + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - /* calculating required number of RBs for each UE */ - while (TBS < UE_list->UE_template[pCCid][UE_id].dl_buffer_total) { - nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; + eNB_UE_stats->dlsch_mcs1 = + cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; - if (nb_rbs_required[CC_id][UE_id] > N_RB_DL) { - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1,N_RB_DL); - nb_rbs_required[CC_id][UE_id] = N_RB_DL; - break; - } + } - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); - } // end of while + // provide the list of CCs sorted according to MCS + for (i = 0; i < UE_list->numactiveCCs[UE_id]; i++) { + eNB_UE_stats_i = + &UE_list->eNB_UE_stats[UE_list-> + ordered_CCids[i][UE_id]][UE_id]; + for (j = i + 1; j < UE_list->numactiveCCs[UE_id]; j++) { + DevAssert(j < MAX_NUM_CCs); + eNB_UE_stats_j = + &UE_list-> + eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]][UE_id]; + if (eNB_UE_stats_j->dlsch_mcs1 > + eNB_UE_stats_i->dlsch_mcs1) { + tmp = UE_list->ordered_CCids[i][UE_id]; + UE_list->ordered_CCids[i][UE_id] = + UE_list->ordered_CCids[j][UE_id]; + UE_list->ordered_CCids[j][UE_id] = tmp; + } + } + } - LOG_D(MAC,"[eNB %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", - Mod_id, frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, eNB_UE_stats->dlsch_mcs1); - } + if (UE_list->UE_template[pCCid][UE_id].dl_buffer_total > 0) { + LOG_D(MAC, "[preprocessor] assign RB for UE %d\n", UE_id); + + for (i = 0; i < UE_list->numactiveCCs[UE_id]; i++) { + CC_id = UE_list->ordered_CCids[i][UE_id]; + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + + if (eNB_UE_stats->dlsch_mcs1 == 0) { + nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small + } else { + nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; + } + + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, + nb_rbs_required[CC_id][UE_id]); + + LOG_D(MAC, + "[preprocessor] start RB assignement for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", + UE_id, CC_id, + UE_list->UE_template[pCCid][UE_id].dl_buffer_total, + nb_rbs_required[CC_id][UE_id], + eNB_UE_stats->dlsch_mcs1, TBS); + + N_RB_DL = + to_prb(RC.mac[Mod_id]->common_channels[CC_id]. + mib->message.dl_Bandwidth); + + /* calculating required number of RBs for each UE */ + while (TBS < + UE_list->UE_template[pCCid][UE_id]. + dl_buffer_total) { + nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; + + if (nb_rbs_required[CC_id][UE_id] > N_RB_DL) { + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, N_RB_DL); + nb_rbs_required[CC_id][UE_id] = N_RB_DL; + break; + } + + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, + nb_rbs_required[CC_id][UE_id]); + } // end of while + + LOG_D(MAC, + "[eNB %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", + Mod_id, frameP, UE_id, CC_id, min_rb_unit[CC_id], + nb_rbs_required[CC_id][UE_id], TBS, + eNB_UE_stats->dlsch_mcs1); + } + } } - } } // This function scans all CC_ids for a particular UE to find the maximum round index of its HARQ processes -int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uint8_t ul_flag ) +int +maxround(module_id_t Mod_id, uint16_t rnti, int frame, + sub_frame_t subframe, uint8_t ul_flag) { - uint8_t round,round_max=0,UE_id; - int CC_id,harq_pid; - UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; - COMMON_channels_t *cc; + uint8_t round, round_max = 0, UE_id; + int CC_id, harq_pid; + UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; + COMMON_channels_t *cc; - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - cc = &RC.mac[Mod_id]->common_channels[CC_id]; + cc = &RC.mac[Mod_id]->common_channels[CC_id]; - UE_id = find_UE_id(Mod_id,rnti); - if (cc->tdd_Config) harq_pid = ((frame*10)+subframe)%10; - else harq_pid = ((frame*10)+subframe)&7; + UE_id = find_UE_id(Mod_id, rnti); + if (cc->tdd_Config) + harq_pid = ((frame * 10) + subframe) % 10; + else + harq_pid = ((frame * 10) + subframe) & 7; - round = UE_list->UE_sched_ctrl[UE_id].round[CC_id][harq_pid]; - if (round > round_max) { - round_max = round; + round = UE_list->UE_sched_ctrl[UE_id].round[CC_id][harq_pid]; + if (round > round_max) { + round_max = round; + } } - } - return round_max; + return round_max; } // This function scans all CC_ids for a particular UE to find the maximum DL CQI // it returns -1 if the UE is not found in PHY layer (get_eNB_UE_stats gives NULL) -int maxcqi(module_id_t Mod_id,int32_t UE_id) +int maxcqi(module_id_t Mod_id, int32_t UE_id) { - UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; - int CC_id,n; - int CQI = 0; + UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; + int CC_id, n; + int CQI = 0; - for (n=0; n<UE_list->numactiveCCs[UE_id]; n++) { - CC_id = UE_list->ordered_CCids[n][UE_id]; + for (n = 0; n < UE_list->numactiveCCs[UE_id]; n++) { + CC_id = UE_list->ordered_CCids[n][UE_id]; - if (UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id] > CQI) { - CQI = UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]; + if (UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id] > CQI) { + CQI = UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]; + } } - } - return CQI; + return CQI; } struct sort_ue_dl_params { - int Mod_idP; - int frameP; - int subframeP; + int Mod_idP; + int frameP; + int subframeP; }; static int ue_dl_compare(const void *_a, const void *_b, void *_params) { - struct sort_ue_dl_params *params = _params; - UE_list_t *UE_list = &RC.mac[params->Mod_idP]->UE_list; - - int UE_id1 = *(const int *)_a; - int UE_id2 = *(const int *)_b; - - int rnti1 = UE_RNTI(params->Mod_idP, UE_id1); - int pCC_id1 = UE_PCCID(params->Mod_idP, UE_id1); - int round1 = maxround(params->Mod_idP, rnti1, params->frameP, params->subframeP, 1); - - int rnti2 = UE_RNTI(params->Mod_idP, UE_id2); - int pCC_id2 = UE_PCCID(params->Mod_idP, UE_id2); - int round2 = maxround(params->Mod_idP, rnti2, params->frameP, params->subframeP, 1); - - int cqi1 = maxcqi(params->Mod_idP, UE_id1); - int cqi2 = maxcqi(params->Mod_idP, UE_id2); - - if (round1 > round2) return -1; - if (round1 < round2) return 1; - - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] > - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) - return -1; - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) - return 1; - - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max > - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) - return -1; - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) - return 1; - - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total > - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) - return -1; - if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) - return 1; - - if (cqi1 > cqi2) return -1; - if (cqi1 < cqi2) return 1; - - return 0; + struct sort_ue_dl_params *params = _params; + UE_list_t *UE_list = &RC.mac[params->Mod_idP]->UE_list; + + int UE_id1 = *(const int *) _a; + int UE_id2 = *(const int *) _b; + + int rnti1 = UE_RNTI(params->Mod_idP, UE_id1); + int pCC_id1 = UE_PCCID(params->Mod_idP, UE_id1); + int round1 = + maxround(params->Mod_idP, rnti1, params->frameP, params->subframeP, + 1); + + int rnti2 = UE_RNTI(params->Mod_idP, UE_id2); + int pCC_id2 = UE_PCCID(params->Mod_idP, UE_id2); + int round2 = + maxround(params->Mod_idP, rnti2, params->frameP, params->subframeP, + 1); + + int cqi1 = maxcqi(params->Mod_idP, UE_id1); + int cqi2 = maxcqi(params->Mod_idP, UE_id2); + + if (round1 > round2) + return -1; + if (round1 < round2) + return 1; + + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] > + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) + return -1; + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2] < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) + return 1; + + if (UE_list-> + UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max > + UE_list-> + UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) + return -1; + if (UE_list-> + UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < + UE_list-> + UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max) + return 1; + + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total > + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) + return -1; + if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) + return 1; + + if (cqi1 > cqi2) + return -1; + if (cqi1 < cqi2) + return 1; + + return 0; #if 0 - /* The above order derives from the following. */ - if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (round2 == round1) { - // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. - // for(j=0;j<MAX_NUM_LCID;j++){ - // if (eNB_mac_inst[Mod_id][pCC_id1].UE_template[UE_id1].dl_buffer_info[j] < - // eNB_mac_inst[Mod_id][pCC_id2].UE_template[UE_id2].dl_buffer_info[j]){ - - // first check the buffer status for SRB1 and SRB2 - - if ( (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2]) < - (UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (cqi1 < cqi2) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } - } + /* The above order derives from the following. */ + if (round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (round2 == round1) { + // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. + // for(j=0;j<MAX_NUM_LCID;j++){ + // if (eNB_mac_inst[Mod_id][pCC_id1].UE_template[UE_id1].dl_buffer_info[j] < + // eNB_mac_inst[Mod_id][pCC_id2].UE_template[UE_id2].dl_buffer_info[j]){ + + // first check the buffer status for SRB1 and SRB2 + + if ((UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2]) < + (UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2])) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (UE_list->UE_template[pCC_id1] + [UE_id1].dl_buffer_head_sdu_creation_time_max < + UE_list->UE_template[pCC_id2] + [UE_id2].dl_buffer_head_sdu_creation_time_max) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (cqi1 < cqi2) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } + } #endif } // This fuction sorts the UE in order their dlsch buffer and CQI -void sort_UEs (module_id_t Mod_idP, - int frameP, - sub_frame_t subframeP) +void sort_UEs(module_id_t Mod_idP, int frameP, sub_frame_t subframeP) { - int i; - int list[NUMBER_OF_UE_MAX]; - int list_size = 0; - int rnti; - struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP }; + int i; + int list[NUMBER_OF_UE_MAX]; + int list_size = 0; + int rnti; + struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP }; - UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; + UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i]==FALSE) continue; - if ((rnti = UE_RNTI(Mod_idP, i)) == NOT_A_RNTI) continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + if (UE_list->active[i] == FALSE) + continue; + if ((rnti = UE_RNTI(Mod_idP, i)) == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; - list[list_size] = i; - list_size++; - } + list[list_size] = i; + list_size++; + } - qsort_r(list, list_size, sizeof(int), ue_dl_compare, ¶ms); + qsort_r(list, list_size, sizeof(int), ue_dl_compare, ¶ms); - if (list_size) { - for (i = 0; i < list_size-1; i++) - UE_list->next[list[i]] = list[i+1]; - UE_list->next[list[list_size-1]] = -1; - UE_list->head = list[0]; - } else { - UE_list->head = -1; - } + if (list_size) { + for (i = 0; i < list_size - 1; i++) + UE_list->next[list[i]] = list[i + 1]; + UE_list->next[list[list_size - 1]] = -1; + UE_list->head = list[0]; + } else { + UE_list->head = -1; + } #if 0 - int UE_id1,UE_id2; - int pCC_id1,pCC_id2; - int cqi1,cqi2,round1,round2; - int i=0,ii=0;//,j=0; - rnti_t rnti1,rnti2; - - UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; - - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { - - for(ii=UE_list->next[i]; ii>=0; ii=UE_list->next[ii]) { - - UE_id1 = i; - rnti1 = UE_RNTI(Mod_idP,UE_id1); - if(rnti1 == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[UE_id1].ul_out_of_sync == 1) - continue; - pCC_id1 = UE_PCCID(Mod_idP,UE_id1); - cqi1 = maxcqi(Mod_idP,UE_id1); // - round1 = maxround(Mod_idP,rnti1,frameP,subframeP,0); - - UE_id2 = ii; - rnti2 = UE_RNTI(Mod_idP,UE_id2); - if(rnti2 == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) - continue; - cqi2 = maxcqi(Mod_idP,UE_id2); - round2 = maxround(Mod_idP,rnti2,frameP,subframeP,0); //mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); - pCC_id2 = UE_PCCID(Mod_idP,UE_id2); - - if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (round2 == round1) { - // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. - // for(j=0;j<MAX_NUM_LCID;j++){ - // if (eNB_mac_inst[Mod_id][pCC_id1].UE_template[UE_id1].dl_buffer_info[j] < - // eNB_mac_inst[Mod_id][pCC_id2].UE_template[UE_id2].dl_buffer_info[j]){ - - // first check the buffer status for SRB1 and SRB2 - - if ( (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2]) < - (UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (cqi1 < cqi2) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } - } + int UE_id1, UE_id2; + int pCC_id1, pCC_id2; + int cqi1, cqi2, round1, round2; + int i = 0, ii = 0; //,j=0; + rnti_t rnti1, rnti2; + + UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; + + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + + for (ii = UE_list->next[i]; ii >= 0; ii = UE_list->next[ii]) { + + UE_id1 = i; + rnti1 = UE_RNTI(Mod_idP, UE_id1); + if (rnti1 == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[UE_id1].ul_out_of_sync == 1) + continue; + pCC_id1 = UE_PCCID(Mod_idP, UE_id1); + cqi1 = maxcqi(Mod_idP, UE_id1); // + round1 = maxround(Mod_idP, rnti1, frameP, subframeP, 0); + + UE_id2 = ii; + rnti2 = UE_RNTI(Mod_idP, UE_id2); + if (rnti2 == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) + continue; + cqi2 = maxcqi(Mod_idP, UE_id2); + round2 = maxround(Mod_idP, rnti2, frameP, subframeP, 0); //mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); + pCC_id2 = UE_PCCID(Mod_idP, UE_id2); + + if (round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (round2 == round1) { + // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. + // for(j=0;j<MAX_NUM_LCID;j++){ + // if (eNB_mac_inst[Mod_id][pCC_id1].UE_template[UE_id1].dl_buffer_info[j] < + // eNB_mac_inst[Mod_id][pCC_id2].UE_template[UE_id2].dl_buffer_info[j]){ + + // first check the buffer status for SRB1 and SRB2 + + if ((UE_list->UE_template[pCC_id1][UE_id1]. + dl_buffer_info[1] + + UE_list->UE_template[pCC_id1][UE_id1]. + dl_buffer_info[2]) < + (UE_list->UE_template[pCC_id2][UE_id2]. + dl_buffer_info[1] + + UE_list->UE_template[pCC_id2][UE_id2]. + dl_buffer_info[2])) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (UE_list->UE_template[pCC_id1] + [UE_id1].dl_buffer_head_sdu_creation_time_max < + UE_list->UE_template[pCC_id2] + [UE_id2].dl_buffer_head_sdu_creation_time_max) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (UE_list->UE_template[pCC_id1][UE_id1]. + dl_buffer_total < + UE_list->UE_template[pCC_id2][UE_id2]. + dl_buffer_total) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } else if (cqi1 < cqi2) { + swap_UEs(UE_list, UE_id1, UE_id2, 0); + } + } + } } - } #endif } @@ -489,1054 +553,1295 @@ void sort_UEs (module_id_t Mod_idP, // This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done -void dlsch_scheduler_pre_processor (module_id_t Mod_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag) +void +dlsch_scheduler_pre_processor(module_id_t Mod_id, + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], int *mbsfn_flag) { - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX],harq_pid=0,round=0,total_ue_count; - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; - int UE_id, i; - uint16_t ii,j; - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t average_rbs_per_user[MAX_NUM_CCs] = {0}; - rnti_t rnti; - int min_rb_unit[MAX_NUM_CCs]; - uint16_t r1=0; - uint8_t CC_id; - UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; - - int N_RB_DL; - int transmission_mode = 0; - UE_sched_ctrl *ue_sched_ctl; - // int rrc_status = RRC_IDLE; - COMMON_channels_t *cc; + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], harq_pid = + 0, round = 0, total_ue_count; + unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; + int UE_id, i; + uint16_t ii, j; + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t average_rbs_per_user[MAX_NUM_CCs] = { 0 }; + rnti_t rnti; + int min_rb_unit[MAX_NUM_CCs]; + uint16_t r1 = 0; + uint8_t CC_id; + UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; + + int N_RB_DL; + int transmission_mode = 0; + UE_sched_ctrl *ue_sched_ctl; + // int rrc_status = RRC_IDLE; + COMMON_channels_t *cc; #ifdef TM5 - int harq_pid1=0; - int round1=0,round2=0; - int UE_id2; - uint16_t i1,i2,i3; - rnti_t rnti1,rnti2; - LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; - LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; - UE_sched_ctrl *ue_sched_ctl1,*ue_sched_ctl2; + int harq_pid1 = 0; + int round1 = 0, round2 = 0; + int UE_id2; + uint16_t i1, i2, i3; + rnti_t rnti1, rnti2; + LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; + LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; + UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2; #endif - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) // If this CC is allocated for MBSFN skip it here - continue; + if (mbsfn_flag[CC_id] > 0) // If this CC is allocated for MBSFN skip it here + continue; - min_rb_unit[CC_id]=get_min_rb_unit(Mod_id,CC_id); + min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) continue; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; - UE_id = i; - // Initialize scheduling information for all active UEs - + UE_id = i; + // Initialize scheduling information for all active UEs - dlsch_scheduler_pre_processor_reset(Mod_id, - UE_id, - CC_id, - frameP, - subframeP, - N_RBG[CC_id], - nb_rbs_required, - nb_rbs_required_remaining, - rballoc_sub, - MIMO_mode_indicator); - - } - } + dlsch_scheduler_pre_processor_reset(Mod_id, + UE_id, + CC_id, + frameP, + subframeP, + N_RBG[CC_id], + nb_rbs_required, + nb_rbs_required_remaining, + rballoc_sub, + MIMO_mode_indicator); - // Store the DLSCH buffer for each logical channel - store_dlsch_buffer (Mod_id,frameP,subframeP); + } + } + // Store the DLSCH buffer for each logical channel + store_dlsch_buffer(Mod_id, frameP, subframeP); - // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - assign_rbs_required (Mod_id,frameP,subframeP,nb_rbs_required,min_rb_unit); + // Calculate the number of RBs required by each UE on the basis of logical channel's buffer + assign_rbs_required(Mod_id, frameP, subframeP, nb_rbs_required, + min_rb_unit); - // Sorts the user on the basis of dlsch logical channel buffer and CQI - sort_UEs (Mod_id,frameP,subframeP); + // Sorts the user on the basis of dlsch logical channel buffer and CQI + sort_UEs(Mod_id, frameP, subframeP); - total_ue_count =0; - // loop over all active UEs - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { - rnti = UE_RNTI(Mod_id,i); - if(rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - UE_id = i; + total_ue_count = 0; - for (ii=0; ii<UE_num_active_CC(UE_list,UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - cc=&RC.mac[Mod_id]->common_channels[ii]; - if (cc->tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; - round = ue_sched_ctl->round[CC_id][harq_pid]; + // loop over all active UEs + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + rnti = UE_RNTI(Mod_id, i); - average_rbs_per_user[CC_id]=0; + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + UE_id = i; + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + cc = &RC.mac[Mod_id]->common_channels[ii]; + if (cc->tdd_Config) + harq_pid = ((frameP * 10) + subframeP) % 10; + else + harq_pid = ((frameP * 10) + subframeP) & 7; + round = ue_sched_ctl->round[CC_id][harq_pid]; - if(round != 8) { - nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - } + average_rbs_per_user[CC_id] = 0; - //nb_rbs_required_remaining[UE_id] = nb_rbs_required[UE_id]; - if (nb_rbs_required[CC_id][UE_id] > 0) { - total_ue_count = total_ue_count + 1; - } + if (round != 8) { + nb_rbs_required[CC_id][UE_id] = + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + } + //nb_rbs_required_remaining[UE_id] = nb_rbs_required[UE_id]; + if (nb_rbs_required[CC_id][UE_id] > 0) { + total_ue_count = total_ue_count + 1; + } + // hypothetical assignment + /* + * If schedule is enabled and if the priority of the UEs is modified + * The average rbs per logical channel per user will depend on the level of + * priority. Concerning the hypothetical assignement, we should assign more + * rbs to prioritized users. Maybe, we can do a mapping between the + * average rbs per user and the level of priority or multiply the average rbs + * per user by a coefficient which represents the degree of priority. + */ + + N_RB_DL = + to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib-> + message.dl_Bandwidth); + + if (total_ue_count == 0) { + average_rbs_per_user[CC_id] = 0; + } else if ((min_rb_unit[CC_id] * total_ue_count) <= (N_RB_DL)) { + average_rbs_per_user[CC_id] = + (uint16_t) floor(N_RB_DL / total_ue_count); + } else { + average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE + } + } + } - // hypothetical assignment - /* - * If schedule is enabled and if the priority of the UEs is modified - * The average rbs per logical channel per user will depend on the level of - * priority. Concerning the hypothetical assignment, we should assign more - * rbs to prioritized users. Maybe, we can do a mapping between the - * average rbs per user and the level of priority or multiply the average rbs - * per user by a coefficient which represents the degree of priority. - */ + // note: nb_rbs_required is assigned according to total_buffer_dl + // extend nb_rbs_required to capture per LCID RB required + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + rnti = UE_RNTI(Mod_id, i); - N_RB_DL = to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth); + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; - if (total_ue_count == 0) { - average_rbs_per_user[CC_id] = 0; - } else if( (min_rb_unit[CC_id] * total_ue_count) <= (N_RB_DL) ) { - average_rbs_per_user[CC_id] = (uint16_t) floor(N_RB_DL/total_ue_count); - } else { - average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; // consider the total number of use that can be scheduled UE - } - } - } + for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { + CC_id = UE_list->ordered_CCids[ii][i]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[i]; + round = ue_sched_ctl->round[CC_id][harq_pid]; + + // control channel or retransmission + /* TODO: do we have to check for retransmission? */ + if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED + || round > 0) { + nb_rbs_required_remaining_1[CC_id][i] = + nb_rbs_required[CC_id][i]; + } else { + nb_rbs_required_remaining_1[CC_id][i] = + cmin(average_rbs_per_user[CC_id], + nb_rbs_required[CC_id][i]); - // note: nb_rbs_required is assigned according to total_buffer_dl - // extend nb_rbs_required to capture per LCID RB required - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - rnti = UE_RNTI(Mod_id,i); - - if(rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - for (ii=0; ii<UE_num_active_CC(UE_list,i); ii++) { - CC_id = UE_list->ordered_CCids[ii][i]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[i]; - round = ue_sched_ctl->round[CC_id][harq_pid]; - - // control channel or retransmission - /* TODO: do we have to check for retransmission? */ - if (mac_eNB_get_rrc_status(Mod_id,rnti) < RRC_RECONFIGURED || round > 0) { - nb_rbs_required_remaining_1[CC_id][i] = nb_rbs_required[CC_id][i]; - } else { - nb_rbs_required_remaining_1[CC_id][i] = cmin(average_rbs_per_user[CC_id],nb_rbs_required[CC_id][i]); - - } + } + } } - } - //Allocation to UEs is done in 2 rounds, - // 1st stage: average number of RBs allocated to each UE - // 2nd stage: remaining RBs are allocated to high priority UEs - for(r1=0; r1<2; r1++) { - - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - for (ii=0; ii<UE_num_active_CC(UE_list,i); ii++) { - CC_id = UE_list->ordered_CCids[ii][i]; - - if(r1 == 0) { - nb_rbs_required_remaining[CC_id][i] = nb_rbs_required_remaining_1[CC_id][i]; - } else { // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round - nb_rbs_required_remaining[CC_id][i] = nb_rbs_required[CC_id][i]-nb_rbs_required_remaining_1[CC_id][i]+nb_rbs_required_remaining[CC_id][i]; -if (nb_rbs_required_remaining[CC_id][i]<0) abort(); - } - - if (nb_rbs_required[CC_id][i]> 0 ) - if (0)LOG_D(MAC,"round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d, pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", - r1, CC_id, i, - nb_rbs_required_remaining[CC_id][i], - nb_rbs_required_remaining_1[CC_id][i], - nb_rbs_required[CC_id][i], - UE_list->UE_sched_ctrl[i].pre_nb_available_rbs[CC_id], - N_RBG[CC_id], - min_rb_unit[CC_id]); - - } - } + //Allocation to UEs is done in 2 rounds, + // 1st stage: average number of RBs allocated to each UE + // 2nd stage: remaining RBs are allocated to high priority UEs + for (r1 = 0; r1 < 2; r1++) { + + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + for (ii = 0; ii < UE_num_active_CC(UE_list, i); ii++) { + CC_id = UE_list->ordered_CCids[ii][i]; + + if (r1 == 0) { + nb_rbs_required_remaining[CC_id][i] = + nb_rbs_required_remaining_1[CC_id][i]; + } else { // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round + nb_rbs_required_remaining[CC_id][i] = + nb_rbs_required[CC_id][i] - + nb_rbs_required_remaining_1[CC_id][i] + + nb_rbs_required_remaining[CC_id][i]; + if (nb_rbs_required_remaining[CC_id][i] < 0) + abort(); + } + + if (nb_rbs_required[CC_id][i] > 0) + LOG_D(MAC, + "round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d, pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", + r1, CC_id, i, + nb_rbs_required_remaining[CC_id][i], + nb_rbs_required_remaining_1[CC_id][i], + nb_rbs_required[CC_id][i], + UE_list->UE_sched_ctrl[i]. + pre_nb_available_rbs[CC_id], N_RBG[CC_id], + min_rb_unit[CC_id]); + } + } - if (total_ue_count > 0 ) { - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - UE_id = i; + if (total_ue_count > 0) { + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + UE_id = i; + + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + round = ue_sched_ctl->round[CC_id][harq_pid]; + + rnti = UE_RNTI(Mod_id, UE_id); + + // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + continue; + + transmission_mode = get_tmode(Mod_id, CC_id, UE_id); + // mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); + //rrc_status = mac_eNB_get_rrc_status(Mod_id,rnti); + /* 1st allocate for the retx */ + + // retransmission in data channels + // control channel in the 1st transmission + // data channel for all TM + LOG_T(MAC, + "calling dlsch_scheduler_pre_processor_allocate .. \n "); + dlsch_scheduler_pre_processor_allocate(Mod_id, UE_id, + CC_id, + N_RBG[CC_id], + transmission_mode, + min_rb_unit + [CC_id], + to_prb(RC.mac + [Mod_id]->common_channels + [CC_id].mib->message.dl_Bandwidth), + nb_rbs_required, + nb_rbs_required_remaining, + rballoc_sub, + MIMO_mode_indicator); - for (ii=0; ii<UE_num_active_CC(UE_list,UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - round = ue_sched_ctl->round[CC_id][harq_pid]; +#ifdef TM5 - rnti = UE_RNTI(Mod_id,UE_id); + // data chanel TM5: to be revisted + if ((round == 0) && + (transmission_mode == 5) && + (ue_sched_ctl->dl_pow_off[CC_id] != 1)) { + + for (j = 0; j < N_RBG[CC_id]; j += 2) { + + if ((((j == (N_RBG[CC_id] - 1)) + && (rballoc_sub[CC_id][j] == 0) + && (ue_sched_ctl-> + rballoc_sub_UE[CC_id][j] == 0)) + || ((j < (N_RBG[CC_id] - 1)) + && (rballoc_sub[CC_id][j + 1] == 0) + && + (ue_sched_ctl->rballoc_sub_UE + [CC_id][j + 1] == 0))) + && (nb_rbs_required_remaining[CC_id][UE_id] + > 0)) { + + for (ii = UE_list->next[i + 1]; ii >= 0; + ii = UE_list->next[ii]) { + + UE_id2 = ii; + rnti2 = UE_RNTI(Mod_id, UE_id2); + ue_sched_ctl2 = + &UE_list->UE_sched_ctrl[UE_id2]; + round2 = ue_sched_ctl2->round[CC_id]; + if (rnti2 == NOT_A_RNTI) + continue; + if (UE_list-> + UE_sched_ctrl + [UE_id2].ul_out_of_sync == 1) + continue; + + eNB_UE_stats2 = + UE_list-> + eNB_UE_stats[CC_id][UE_id2]; + //mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti2,frameP,subframeP,&harq_pid2,&round2,0); + + if ((mac_eNB_get_rrc_status + (Mod_id, + rnti2) >= RRC_RECONFIGURED) + && (round2 == 0) + && + (get_tmode(Mod_id, CC_id, UE_id2) + == 5) + && (ue_sched_ctl-> + dl_pow_off[CC_id] != 1)) { + + if ((((j == (N_RBG[CC_id] - 1)) + && + (ue_sched_ctl->rballoc_sub_UE + [CC_id][j] == 0)) + || ((j < (N_RBG[CC_id] - 1)) + && + (ue_sched_ctl-> + rballoc_sub_UE[CC_id][j + + 1] + == 0))) + && + (nb_rbs_required_remaining + [CC_id] + [UE_id2] > 0)) { + + if ((((eNB_UE_stats2-> + DL_pmi_single ^ + eNB_UE_stats1-> + DL_pmi_single) + << (14 - j)) & 0xc000) == 0x4000) { //MU-MIMO only for 25 RBs configuration + + rballoc_sub[CC_id][j] = 1; + ue_sched_ctl-> + rballoc_sub_UE[CC_id] + [j] = 1; + ue_sched_ctl2-> + rballoc_sub_UE[CC_id] + [j] = 1; + MIMO_mode_indicator[CC_id] + [j] = 0; + + if (j < N_RBG[CC_id] - 1) { + rballoc_sub[CC_id][j + + 1] = + 1; + ue_sched_ctl-> + rballoc_sub_UE + [CC_id][j + 1] = 1; + ue_sched_ctl2->rballoc_sub_UE + [CC_id][j + 1] = 1; + MIMO_mode_indicator + [CC_id][j + 1] + = 0; + } + + ue_sched_ctl-> + dl_pow_off[CC_id] + = 0; + ue_sched_ctl2-> + dl_pow_off[CC_id] + = 0; + + + if ((j == N_RBG[CC_id] - 1) + && ((N_RB_DL == 25) + || (N_RB_DL == + 50))) { + + nb_rbs_required_remaining + [CC_id][UE_id] = + nb_rbs_required_remaining + [CC_id][UE_id] - + min_rb_unit[CC_id] + + 1; + ue_sched_ctl->pre_nb_available_rbs + [CC_id] = + ue_sched_ctl->pre_nb_available_rbs + [CC_id] + + min_rb_unit[CC_id] + - 1; + nb_rbs_required_remaining + [CC_id][UE_id2] = + nb_rbs_required_remaining + [CC_id][UE_id2] - + min_rb_unit[CC_id] + + 1; + ue_sched_ctl2->pre_nb_available_rbs + [CC_id] = + ue_sched_ctl2->pre_nb_available_rbs + [CC_id] + + min_rb_unit[CC_id] + - 1; + } else { + + nb_rbs_required_remaining + [CC_id][UE_id] = + nb_rbs_required_remaining + [CC_id][UE_id] - 4; + ue_sched_ctl->pre_nb_available_rbs + [CC_id] = + ue_sched_ctl->pre_nb_available_rbs + [CC_id] + 4; + nb_rbs_required_remaining + [CC_id][UE_id2] = + nb_rbs_required_remaining + [CC_id][UE_id2] - + 4; + ue_sched_ctl2->pre_nb_available_rbs + [CC_id] = + ue_sched_ctl2->pre_nb_available_rbs + [CC_id] + 4; + } + + break; + } + } + } + } + } + } + } +#endif + } + } + } // total_ue_count + } // end of for for r1 and r2 - // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); - if(rnti == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) - continue; +#ifdef TM5 - transmission_mode = get_tmode(Mod_id,CC_id,UE_id); - // mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); - //rrc_status = mac_eNB_get_rrc_status(Mod_id,rnti); - /* 1st allocate for the retx */ - - // retransmission in data channels - // control channel in the 1st transmission - // data channel for all TM - LOG_T(MAC,"calling dlsch_scheduler_pre_processor_allocate .. \n "); - dlsch_scheduler_pre_processor_allocate (Mod_id, - UE_id, - CC_id, - N_RBG[CC_id], - transmission_mode, - min_rb_unit[CC_id], - to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth), - nb_rbs_required, - nb_rbs_required_remaining, - rballoc_sub, - MIMO_mode_indicator); + // This has to be revisited!!!! + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + i1 = 0; + i2 = 0; + i3 = 0; + + for (j = 0; j < N_RBG[CC_id]; j++) { + if (MIMO_mode_indicator[CC_id][j] == 2) { + i1 = i1 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 1) { + i2 = i2 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 0) { + i3 = i3 + 1; + } + } -#ifdef TM5 + if ((i1 < N_RBG[CC_id]) && (i2 > 0) && (i3 == 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_SUMIMO_transmissions + 1; + } - // data chanel TM5: to be revisted - if ((round == 0 ) && - (transmission_mode == 5) && - (ue_sched_ctl->dl_pow_off[CC_id] != 1)) { - - for(j=0; j<N_RBG[CC_id]; j+=2) { - - if( (((j == (N_RBG[CC_id]-1))&& (rballoc_sub[CC_id][j] == 0) && (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 0)) || - ((j < (N_RBG[CC_id]-1)) && (rballoc_sub[CC_id][j+1] == 0) && (ue_sched_ctl->rballoc_sub_UE[CC_id][j+1] == 0)) ) && - (nb_rbs_required_remaining[CC_id][UE_id]>0)) { - - for (ii = UE_list->next[i+1]; ii >=0; ii=UE_list->next[ii]) { - - UE_id2 = ii; - rnti2 = UE_RNTI(Mod_id,UE_id2); - ue_sched_ctl2 = &UE_list->UE_sched_ctrl[UE_id2]; - round2 = ue_sched_ctl2->round[CC_id]; - if(rnti2 == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) - continue; - - eNB_UE_stats2 = UE_list->eNB_UE_stats[CC_id][UE_id2]; - //mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti2,frameP,subframeP,&harq_pid2,&round2,0); - - if ((mac_eNB_get_rrc_status(Mod_id,rnti2) >= RRC_RECONFIGURED) && - (round2==0) && - (get_tmode(Mod_id,CC_id,UE_id2)==5) && - (ue_sched_ctl->dl_pow_off[CC_id] != 1)) { - - if( (((j == (N_RBG[CC_id]-1)) && (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 0)) || - ((j < (N_RBG[CC_id]-1)) && (ue_sched_ctl->rballoc_sub_UE[CC_id][j+1] == 0)) ) && - (nb_rbs_required_remaining[CC_id][UE_id2]>0)) { - - if((((eNB_UE_stats2->DL_pmi_single^eNB_UE_stats1->DL_pmi_single)<<(14-j))&0xc000)== 0x4000) { //MU-MIMO only for 25 RBs configuration - - rballoc_sub[CC_id][j] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][j] = 1; - ue_sched_ctl2->rballoc_sub_UE[CC_id][j] = 1; - MIMO_mode_indicator[CC_id][j] = 0; - - if (j< N_RBG[CC_id]-1) { - rballoc_sub[CC_id][j+1] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][j+1] = 1; - ue_sched_ctl2->rballoc_sub_UE[CC_id][j+1] = 1; - MIMO_mode_indicator[CC_id][j+1] = 0; - } - - ue_sched_ctl->dl_pow_off[CC_id] = 0; - ue_sched_ctl2->dl_pow_off[CC_id] = 0; - - - if ((j == N_RBG[CC_id]-1) && - ((N_RB_DL == 25) || - (N_RB_DL == 50))) { - - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit[CC_id]+1; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit[CC_id]-1; - nb_rbs_required_remaining[CC_id][UE_id2] = nb_rbs_required_remaining[CC_id][UE_id2] - min_rb_unit[CC_id]+1; - ue_sched_ctl2->pre_nb_available_rbs[CC_id] = ue_sched_ctl2->pre_nb_available_rbs[CC_id] + min_rb_unit[CC_id]-1; - } else { - - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - 4; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + 4; - nb_rbs_required_remaining[CC_id][UE_id2] = nb_rbs_required_remaining[CC_id][UE_id2] - 4; - ue_sched_ctl2->pre_nb_available_rbs[CC_id] = ue_sched_ctl2->pre_nb_available_rbs[CC_id] + 4; - } - - break; - } - } - } - } - } - } - } + if (i3 == N_RBG[CC_id] && i1 == 0 && i2 == 0) { + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + + 1; + } -#endif - } - } - } // total_ue_count - } // end of for for r1 and r2 + if ((i1 < N_RBG[CC_id]) && (i3 > 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_MUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_MUMIMO_transmissions + 1; + } -#ifdef TM5 + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + + 1; - // This has to be revisited!!!! - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - i1=0; - i2=0; - i3=0; - - for (j=0; j<N_RBG[CC_id]; j++) { - if(MIMO_mode_indicator[CC_id][j] == 2) { - i1 = i1+1; - } else if(MIMO_mode_indicator[CC_id][j] == 1) { - i2 = i2+1; - } else if(MIMO_mode_indicator[CC_id][j] == 0) { - i3 = i3+1; - } } - if((i1 < N_RBG[CC_id]) && (i2>0) && (i3==0)) { - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions + 1; - } +#endif - if(i3 == N_RBG[CC_id] && i1==0 && i2==0) { - PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + 1; + for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { + UE_id = i; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + for (ii = 0; ii < UE_num_active_CC(UE_list, UE_id); ii++) { + CC_id = UE_list->ordered_CCids[ii][UE_id]; + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; + + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { + LOG_D(MAC, + "******************DL Scheduling Information for UE%d ************************\n", + UE_id); + LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, + ue_sched_ctl->dl_pow_off[CC_id]); + LOG_D(MAC, + "***********RB Alloc for every subband for UE%d ***********\n", + UE_id); + + for (j = 0; j < N_RBG[CC_id]; j++) { + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; + LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", + UE_id, j, + ue_sched_ctl->rballoc_sub_UE[CC_id][j]); + } + + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; + LOG_D(MAC, "Total RBs allocated for UE%d = %d\n", UE_id, + ue_sched_ctl->pre_nb_available_rbs[CC_id]); + } + } } +} - if((i1 < N_RBG[CC_id]) && (i3 > 0)) { - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_MUMIMO_transmissions + 1; - } +#define SF0_LIMIT 1 - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + 1; +void +dlsch_scheduler_pre_processor_reset(int module_idP, + int UE_id, + uint8_t CC_id, + int frameP, + int subframeP, + int N_RBG, + uint16_t nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs][NUMBER_OF_UE_MAX], + unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], unsigned char + MIMO_mode_indicator[MAX_NUM_CCs] + [N_RBG_MAX]) +{ + int i, j; + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + rnti_t rnti = UE_RNTI(module_idP, UE_id); + + uint8_t *vrb_map = RC.mac[module_idP]->common_channels[CC_id].vrb_map; + int N_RB_DL = + to_prb(RC.mac[module_idP]->common_channels[CC_id].mib-> + message.dl_Bandwidth); + int RBGsize = N_RB_DL / N_RBG, RBGsize_last; +#ifdef SF0_LIMIT + int sf0_upper = -1, sf0_lower = -1; +#endif - } -#endif + LOG_D(MAC, "Running preprocessor for UE %d (%x)\n", UE_id, rnti); + // initialize harq_pid and round - for(i=UE_list->head; i>=0; i=UE_list->next[i]) { - UE_id = i; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + if (ue_sched_ctl->ta_timer) + ue_sched_ctl->ta_timer--; - for (ii=0; ii<UE_num_active_CC(UE_list,UE_id); ii++) { - CC_id = UE_list->ordered_CCids[ii][UE_id]; - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; + /* + eNB_UE_stats *eNB_UE_stats; - if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0 ) { - //LOG_D(MAC,"******************DL Scheduling Information for UE%d ************************\n",UE_id); - //LOG_D(MAC,"dl power offset UE%d = %d \n",UE_id,ue_sched_ctl->dl_pow_off[CC_id]); - //LOG_D(MAC,"***********RB Alloc for every subband for UE%d ***********\n",UE_id); + if (eNB_UE_stats == NULL) + return; - for(j=0; j<N_RBG[CC_id]; j++) { - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; - //LOG_D(MAC,"RB Alloc for UE%d and Subband%d = %d\n",UE_id,j,ue_sched_ctl->rballoc_sub_UE[CC_id][j]); - } - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; - //LOG_D(MAC,"Total RBs allocated for UE%d = %d\n",UE_id,ue_sched_ctl->pre_nb_available_rbs[CC_id]); - } - } - } -} + mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti, + frameP,subframeP, + &ue_sched_ctl->harq_pid[CC_id], + &ue_sched_ctl->round[CC_id], + openair_harq_DL); -#define SF0_LIMIT 1 + if (ue_sched_ctl->ta_timer == 0) { -void dlsch_scheduler_pre_processor_reset (int module_idP, - int UE_id, - uint8_t CC_id, - int frameP, - int subframeP, - int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]) - -{ - int i,j; - UE_list_t *UE_list=&RC.mac[module_idP]->UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ... - uint8_t *vrb_map = RC.mac[module_idP]->common_channels[CC_id].vrb_map; - int N_RB_DL = to_prb(RC.mac[module_idP]->common_channels[CC_id].mib->message.dl_Bandwidth); - int RBGsize = N_RB_DL/N_RBG,RBGsize_last; -#ifdef SF0_LIMIT - int sf0_upper=-1,sf0_lower=-1; -#endif + ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY + switch (N_RB_DL) { + case 6: + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update; + break; + case 15: + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/2; + break; - //rnti_t rnti = UE_RNTI(module_idP,UE_id); - //LOG_D(MAC,"Running preprocessor for UE %d (%x)\n",UE_id,rnti); - // initialize harq_pid and round + case 25: + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/4; + break; - if (ue_sched_ctl->ta_timer) ue_sched_ctl->ta_timer--; + case 50: + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/8; + break; - /* - eNB_UE_stats *eNB_UE_stats; + case 75: + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/12; + break; - if (eNB_UE_stats == NULL) - return; + case 100: + ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16; + break; + } + // clear the update in case PHY does not have a new measurement after timer expiry + eNB_UE_stats->timing_advance_update = 0; + } + else { + ue_sched_ctl->ta_timer--; + ue_sched_ctl->ta_update =0; // don't trigger a timing advance command + } - - mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti, - frameP,subframeP, - &ue_sched_ctl->harq_pid[CC_id], - &ue_sched_ctl->round[CC_id], - openair_harq_DL); - - if (ue_sched_ctl->ta_timer == 0) { + if (UE_id==0) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_TIMING_ADVANCE,ue_sched_ctl->ta_update); + } + */ - // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ... + nb_rbs_required[CC_id][UE_id] = 0; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; + ue_sched_ctl->dl_pow_off[CC_id] = 2; + nb_rbs_required_remaining[CC_id][UE_id] = 0; - ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY switch (N_RB_DL) { case 6: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update; - break; - + RBGsize = 1; + RBGsize_last = 1; + break; case 15: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/2; - break; - + RBGsize = 2; + RBGsize_last = 1; + break; case 25: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/4; - break; - + RBGsize = 2; + RBGsize_last = 1; + break; case 50: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/8; - break; - + RBGsize = 3; + RBGsize_last = 2; + break; case 75: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/12; - break; - + RBGsize = 4; + RBGsize_last = 3; + break; case 100: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16; - break; + RBGsize = 4; + RBGsize_last = 4; + break; + default: + AssertFatal(1 == 0, "unsupported RBs (%d)\n", N_RB_DL); } - // clear the update in case PHY does not have a new measurement after timer expiry - eNB_UE_stats->timing_advance_update = 0; - } - else { - ue_sched_ctl->ta_timer--; - ue_sched_ctl->ta_update =0; // don't trigger a timing advance command - } - - if (UE_id==0) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_TIMING_ADVANCE,ue_sched_ctl->ta_update); - } - */ - - nb_rbs_required[CC_id][UE_id]=0; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = 0; - ue_sched_ctl->dl_pow_off[CC_id] = 2; - nb_rbs_required_remaining[CC_id][UE_id] = 0; - - switch (N_RB_DL) { - case 6: RBGsize = 1; RBGsize_last = 1; break; - case 15: RBGsize = 2; RBGsize_last = 1; break; - case 25: RBGsize = 2; RBGsize_last = 1; break; - case 50: RBGsize = 3; RBGsize_last = 2; break; - case 75: RBGsize = 4; RBGsize_last = 3; break; - case 100: RBGsize = 4; RBGsize_last = 4; break; - default: AssertFatal(1==0,"unsupported RBs (%d)\n", N_RB_DL); - } - #ifdef SF0_LIMIT - switch (N_RBG) { - case 6: - sf0_lower=0; - sf0_upper=5; - break; - case 8: - sf0_lower=2; - sf0_upper=5; - break; - case 13: - sf0_lower=4; - sf0_upper=7; - break; - case 17: - sf0_lower=7; - sf0_upper=9; - break; - case 25: - sf0_lower=11; - sf0_upper=13; - break; - default: AssertFatal(1==0,"unsupported RBs (%d)\n", N_RB_DL); - } + switch (N_RBG) { + case 6: + sf0_lower = 0; + sf0_upper = 5; + break; + case 8: + sf0_lower = 2; + sf0_upper = 5; + break; + case 13: + sf0_lower = 4; + sf0_upper = 7; + break; + case 17: + sf0_lower = 7; + sf0_upper = 9; + break; + case 25: + sf0_lower = 11; + sf0_upper = 13; + break; + default: + AssertFatal(1 == 0, "unsupported RBs (%d)\n", N_RB_DL); + } #endif - // Initialize Subbands according to VRB map - for (i=0; i<N_RBG; i++) { - int rb_size = i==N_RBG-1 ? RBGsize_last : RBGsize; + // Initialize Subbands according to VRB map + for (i = 0; i < N_RBG; i++) { + int rb_size = i == N_RBG - 1 ? RBGsize_last : RBGsize; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 0; - rballoc_sub[CC_id][i] = 0; + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 0; + rballoc_sub[CC_id][i] = 0; #ifdef SF0_LIMIT - // for avoiding 6+ PRBs around DC in subframe 0 (avoid excessive errors) - /* TODO: make it proper - allocate those RBs, do not "protect" them, but - * compute number of available REs and limit MCS according to the - * TBS table 36.213 7.1.7.2.1-1 (can be done after pre-processor) - */ - if (subframeP==0 && - i >= sf0_lower && i <= sf0_upper) - rballoc_sub[CC_id][i]=1; + // for avoiding 6+ PRBs around DC in subframe 0 (avoid excessive errors) + /* TODO: make it proper - allocate those RBs, do not "protect" them, but + * compute number of available REs and limit MCS according to the + * TBS table 36.213 7.1.7.2.1-1 (can be done after pre-processor) + */ + if (subframeP == 0 && i >= sf0_lower && i <= sf0_upper) + rballoc_sub[CC_id][i] = 1; #endif - // for SI-RNTI,RA-RNTI and P-RNTI allocations - for (j = 0; j < rb_size; j++) { - if (vrb_map[j+(i*RBGsize)] != 0) { - rballoc_sub[CC_id][i] = 1; - //LOG_D(MAC,"Frame %d, subframe %d : vrb %d allocated\n",frameP,subframeP,j+(i*RBGsize)); - break; - } + // for SI-RNTI,RA-RNTI and P-RNTI allocations + for (j = 0; j < rb_size; j++) { + if (vrb_map[j + (i * RBGsize)] != 0) { + rballoc_sub[CC_id][i] = 1; + LOG_D(MAC, "Frame %d, subframe %d : vrb %d allocated\n", + frameP, subframeP, j + (i * RBGsize)); + break; + } + } + LOG_D(MAC, "Frame %d Subframe %d CC_id %d RBG %i : rb_alloc %d\n", + frameP, subframeP, CC_id, i, rballoc_sub[CC_id][i]); + MIMO_mode_indicator[CC_id][i] = 2; } - //LOG_D(MAC,"Frame %d Subframe %d CC_id %d RBG %i : rb_alloc %d\n",frameP,subframeP,CC_id,i,rballoc_sub[CC_id][i]); - MIMO_mode_indicator[CC_id][i] = 2; - } } -void dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, - int UE_id, - uint8_t CC_id, - int N_RBG, - int transmission_mode, - int min_rb_unit, - uint8_t N_RB_DL, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]) +void +dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, + int UE_id, + uint8_t CC_id, + int N_RBG, + int transmission_mode, + int min_rb_unit, + uint8_t N_RB_DL, + uint16_t + nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], unsigned char + MIMO_mode_indicator + [MAX_NUM_CCs][N_RBG_MAX]) { - int i; - UE_list_t *UE_list=&RC.mac[Mod_id]->UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - for(i=0; i<N_RBG; i++) { - - if((rballoc_sub[CC_id][i] == 0) && - (ue_sched_ctl->rballoc_sub_UE[CC_id][i] == 0) && - (nb_rbs_required_remaining[CC_id][UE_id]>0) && - (ue_sched_ctl->pre_nb_available_rbs[CC_id] < nb_rbs_required[CC_id][UE_id])) { - - // if this UE is not scheduled for TM5 - if (ue_sched_ctl->dl_pow_off[CC_id] != 0 ) { - - if ((i == N_RBG-1) && ((N_RB_DL == 25) || (N_RB_DL == 50))) { - if (nb_rbs_required_remaining[CC_id][UE_id] >= min_rb_unit-1){ - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5 ) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit+1; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit - 1; - } - } else { - if (nb_rbs_required_remaining[CC_id][UE_id] >= min_rb_unit){ - rballoc_sub[CC_id][i] = 1; - ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; - MIMO_mode_indicator[CC_id][i] = 1; - if (transmission_mode == 5 ) { - ue_sched_ctl->dl_pow_off[CC_id] = 1; - } - nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit; - ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit; - } + int i; + UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + for (i = 0; i < N_RBG; i++) { + + if ((rballoc_sub[CC_id][i] == 0) && + (ue_sched_ctl->rballoc_sub_UE[CC_id][i] == 0) && + (nb_rbs_required_remaining[CC_id][UE_id] > 0) && + (ue_sched_ctl->pre_nb_available_rbs[CC_id] < + nb_rbs_required[CC_id][UE_id])) { + + // if this UE is not scheduled for TM5 + if (ue_sched_ctl->dl_pow_off[CC_id] != 0) { + + if ((i == N_RBG - 1) + && ((N_RB_DL == 25) || (N_RB_DL == 50))) { + if (nb_rbs_required_remaining[CC_id][UE_id] >= + min_rb_unit - 1) { + rballoc_sub[CC_id][i] = 1; + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; + MIMO_mode_indicator[CC_id][i] = 1; + if (transmission_mode == 5) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + nb_rbs_required_remaining[CC_id][UE_id] = + nb_rbs_required_remaining[CC_id][UE_id] - + min_rb_unit + 1; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = + ue_sched_ctl->pre_nb_available_rbs[CC_id] + + min_rb_unit - 1; + } + } else { + if (nb_rbs_required_remaining[CC_id][UE_id] >= + min_rb_unit) { + rballoc_sub[CC_id][i] = 1; + ue_sched_ctl->rballoc_sub_UE[CC_id][i] = 1; + MIMO_mode_indicator[CC_id][i] = 1; + if (transmission_mode == 5) { + ue_sched_ctl->dl_pow_off[CC_id] = 1; + } + nb_rbs_required_remaining[CC_id][UE_id] = + nb_rbs_required_remaining[CC_id][UE_id] - + min_rb_unit; + ue_sched_ctl->pre_nb_available_rbs[CC_id] = + ue_sched_ctl->pre_nb_available_rbs[CC_id] + + min_rb_unit; + } + } + } // dl_pow_off[CC_id][UE_id] ! = 0 } - } // dl_pow_off[CC_id][UE_id] ! = 0 } - } } /// ULSCH PRE_PROCESSOR -void ulsch_scheduler_pre_processor(module_id_t module_idP, - int frameP, - sub_frame_t subframeP, - uint16_t *first_rb) +void +ulsch_scheduler_pre_processor(module_id_t module_idP, + int frameP, + sub_frame_t subframeP, uint16_t * first_rb) { - int16_t i; - uint16_t UE_id,n,r; - uint8_t CC_id, harq_pid; - uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX],total_allocated_rbs[MAX_NUM_CCs],average_rbs_per_user[MAX_NUM_CCs]; - int16_t total_remaining_rbs[MAX_NUM_CCs]; - uint16_t max_num_ue_to_be_scheduled = 0; - uint16_t total_ue_count = 0; - rnti_t rnti = -1; - UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - UE_TEMPLATE *UE_template = 0; - int N_RB_DL; - int N_RB_UL; - //LOG_D(MAC,"In ulsch_preprocessor: assign max mcs min rb\n"); - // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB - assign_max_mcs_min_rb(module_idP,frameP, subframeP, first_rb); - - //LOG_D(MAC,"In ulsch_preprocessor: sort ue \n"); - // sort ues - sort_ue_ul (module_idP,frameP, subframeP); - - - // we need to distribute RBs among UEs - // step1: reset the vars - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - N_RB_DL = to_prb(RC.mac[module_idP]->common_channels[CC_id].mib->message.dl_Bandwidth); - N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth); - total_allocated_rbs[CC_id] = 0; - total_remaining_rbs[CC_id] = 0; - average_rbs_per_user[CC_id] = 0; - - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - nb_allocated_rbs[CC_id][i]=0; + int16_t i; + uint16_t UE_id, n, r; + uint8_t CC_id, harq_pid; + uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + total_allocated_rbs[MAX_NUM_CCs], + average_rbs_per_user[MAX_NUM_CCs]; + int16_t total_remaining_rbs[MAX_NUM_CCs]; + uint16_t max_num_ue_to_be_scheduled = 0; + uint16_t total_ue_count = 0; + rnti_t rnti = -1; + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; + UE_TEMPLATE *UE_template = 0; + int N_RB_DL; + int N_RB_UL; + LOG_D(MAC, "In ulsch_preprocessor: assign max mcs min rb\n"); + // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB + assign_max_mcs_min_rb(module_idP, frameP, subframeP, first_rb); + + LOG_D(MAC, "In ulsch_preprocessor: sort ue \n"); + // sort ues + sort_ue_ul(module_idP, frameP, subframeP); + + + // we need to distribute RBs among UEs + // step1: reset the vars + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + N_RB_DL = + to_prb(RC.mac[module_idP]->common_channels[CC_id].mib-> + message.dl_Bandwidth); + N_RB_UL = + to_prb(RC.mac[module_idP]->common_channels[CC_id]. + ul_Bandwidth); + total_allocated_rbs[CC_id] = 0; + total_remaining_rbs[CC_id] = 0; + average_rbs_per_user[CC_id] = 0; + + for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { + nb_allocated_rbs[CC_id][i] = 0; + } } - } - //LOG_D(MAC,"In ulsch_preprocessor: step2 \n"); - // step 2: calculate the average rb per UE - total_ue_count =0; - max_num_ue_to_be_scheduled=0; - - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - - rnti = UE_RNTI(module_idP,i); - - if (rnti==NOT_A_RNTI) - continue; - - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - - UE_id = i; - - //LOG_D(MAC,"In ulsch_preprocessor: handling UE %d/%x\n",UE_id,rnti); - for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - //LOG_D(MAC,"In ulsch_preprocessor: handling UE %d/%x CCid %d\n",UE_id,rnti,CC_id); - UE_template = &UE_list->UE_template[CC_id][UE_id]; - average_rbs_per_user[CC_id]=0; - - if (UE_template->pre_allocated_nb_rb_ul > 0) { - total_ue_count+=1; - } - /* - if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1<<aggregation)) { - nCCE_to_be_used[CC_id] = nCCE_to_be_used[CC_id] + (1<<aggregation); - max_num_ue_to_be_scheduled+=1; - }*/ - - max_num_ue_to_be_scheduled+=1; - - if (total_ue_count == 0) { - average_rbs_per_user[CC_id] = 0; - } else if (total_ue_count == 1 ) { // increase the available RBs, special case, - average_rbs_per_user[CC_id] = N_RB_UL-first_rb[CC_id]+1; - } else if( (total_ue_count <= (N_RB_DL-first_rb[CC_id])) && - (total_ue_count <= max_num_ue_to_be_scheduled)) { - average_rbs_per_user[CC_id] = (uint16_t) floor((N_RB_UL-first_rb[CC_id])/total_ue_count); - } else if (max_num_ue_to_be_scheduled > 0 ) { - average_rbs_per_user[CC_id] = (uint16_t) floor((N_RB_UL-first_rb[CC_id])/max_num_ue_to_be_scheduled); - } else { - average_rbs_per_user[CC_id]=1; - LOG_W(MAC,"[eNB %d] frame %d subframe %d: UE %d CC %d: can't get average rb per user (should not be here)\n", - module_idP,frameP,subframeP,UE_id,CC_id); - } + LOG_D(MAC, "In ulsch_preprocessor: step2 \n"); + // step 2: calculate the average rb per UE + total_ue_count = 0; + max_num_ue_to_be_scheduled = 0; + + for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { + + rnti = UE_RNTI(module_idP, i); + + if (rnti == NOT_A_RNTI) + continue; + + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + + + UE_id = i; + + LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x\n", UE_id, + rnti); + for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + LOG_D(MAC, + "In ulsch_preprocessor: handling UE %d/%x CCid %d\n", + UE_id, rnti, CC_id); + UE_template = &UE_list->UE_template[CC_id][UE_id]; + average_rbs_per_user[CC_id] = 0; + + if (UE_template->pre_allocated_nb_rb_ul > 0) { + total_ue_count += 1; + } + /* + if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1<<aggregation)) { + nCCE_to_be_used[CC_id] = nCCE_to_be_used[CC_id] + (1<<aggregation); + max_num_ue_to_be_scheduled+=1; + } */ + + max_num_ue_to_be_scheduled += 1; + + if (total_ue_count == 0) { + average_rbs_per_user[CC_id] = 0; + } else if (total_ue_count == 1) { // increase the available RBs, special case, + average_rbs_per_user[CC_id] = + N_RB_UL - first_rb[CC_id] + 1; + } else if ((total_ue_count <= (N_RB_DL - first_rb[CC_id])) + && (total_ue_count <= max_num_ue_to_be_scheduled)) { + average_rbs_per_user[CC_id] = + (uint16_t) floor((N_RB_UL - first_rb[CC_id]) / + total_ue_count); + } else if (max_num_ue_to_be_scheduled > 0) { + average_rbs_per_user[CC_id] = + (uint16_t) floor((N_RB_UL - first_rb[CC_id]) / + max_num_ue_to_be_scheduled); + } else { + average_rbs_per_user[CC_id] = 1; + LOG_W(MAC, + "[eNB %d] frame %d subframe %d: UE %d CC %d: can't get average rb per user (should not be here)\n", + module_idP, frameP, subframeP, UE_id, CC_id); + } + } } - } - //if (total_ue_count > 0) LOG_D(MAC,"[eNB %d] Frame %d subframe %d: total ue to be scheduled %d/%d\n", module_idP, frameP, subframeP,total_ue_count, max_num_ue_to_be_scheduled); + if (total_ue_count > 0) + LOG_D(MAC, + "[eNB %d] Frame %d subframe %d: total ue to be scheduled %d/%d\n", + module_idP, frameP, subframeP, total_ue_count, + max_num_ue_to_be_scheduled); - //LOG_D(MAC,"step3\n"); + //LOG_D(MAC,"step3\n"); - // step 3: assigne RBS - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - rnti = UE_RNTI(module_idP,i); + // step 3: assigne RBS + for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { + rnti = UE_RNTI(module_idP, i); - if (rnti==NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; - UE_id = i; + UE_id = i; - for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - harq_pid = subframe2harqpid(&RC.mac[module_idP]->common_channels[CC_id],frameP,subframeP); + for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + harq_pid = + subframe2harqpid(&RC.mac[module_idP]-> + common_channels[CC_id], frameP, + subframeP); - // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); + // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); - if(UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id]>0) { - nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; - } else { - nb_allocated_rbs[CC_id][UE_id] = cmin(UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul, average_rbs_per_user[CC_id]); - } + if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id] > 0) { + nb_allocated_rbs[CC_id][UE_id] = + UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; + } else { + nb_allocated_rbs[CC_id][UE_id] = + cmin(UE_list-> + UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul, + average_rbs_per_user[CC_id]); + } - total_allocated_rbs[CC_id]+= nb_allocated_rbs[CC_id][UE_id]; - //LOG_D(MAC,"In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d\n",nb_allocated_rbs[CC_id][UE_id],UE_id,rnti,CC_id,harq_pid); + total_allocated_rbs[CC_id] += nb_allocated_rbs[CC_id][UE_id]; + LOG_D(MAC, + "In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d\n", + nb_allocated_rbs[CC_id][UE_id], UE_id, rnti, CC_id, + harq_pid); + } } - } - // step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly - for(r=0; r<2; r++) { - - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - rnti = UE_RNTI(module_idP,i); - - if (rnti==NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - UE_id = i; - - for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - UE_template = &UE_list->UE_template[CC_id][UE_id]; - total_remaining_rbs[CC_id]=N_RB_UL - first_rb[CC_id] - total_allocated_rbs[CC_id]; - - if (total_ue_count == 1 ) { - total_remaining_rbs[CC_id]+=1; - } - - if ( r == 0 ) { - while ( (UE_template->pre_allocated_nb_rb_ul > 0 ) && - (nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul) && - (total_remaining_rbs[CC_id] > 0)) { - nb_allocated_rbs[CC_id][UE_id] = cmin(nb_allocated_rbs[CC_id][UE_id]+1,UE_template->pre_allocated_nb_rb_ul); - total_remaining_rbs[CC_id]--; - total_allocated_rbs[CC_id]++; - } - } else { - UE_template->pre_allocated_nb_rb_ul= nb_allocated_rbs[CC_id][UE_id]; - //LOG_D(MAC,"******************UL Scheduling Information for UE%d CC_id %d ************************\n",UE_id, CC_id); - //LOG_D(MAC,"[eNB %d] total RB allocated for UE%d CC_id %d = %d\n", module_idP, UE_id, CC_id, UE_template->pre_allocated_nb_rb_ul); - } - } + // step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly + for (r = 0; r < 2; r++) { + + for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { + rnti = UE_RNTI(module_idP, i); + + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + UE_id = i; + + for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; + UE_template = &UE_list->UE_template[CC_id][UE_id]; + total_remaining_rbs[CC_id] = + N_RB_UL - first_rb[CC_id] - total_allocated_rbs[CC_id]; + + if (total_ue_count == 1) { + total_remaining_rbs[CC_id] += 1; + } + + if (r == 0) { + while ((UE_template->pre_allocated_nb_rb_ul > 0) && + (nb_allocated_rbs[CC_id][UE_id] < + UE_template->pre_allocated_nb_rb_ul) + && (total_remaining_rbs[CC_id] > 0)) { + nb_allocated_rbs[CC_id][UE_id] = + cmin(nb_allocated_rbs[CC_id][UE_id] + 1, + UE_template->pre_allocated_nb_rb_ul); + total_remaining_rbs[CC_id]--; + total_allocated_rbs[CC_id]++; + } + } else { + UE_template->pre_allocated_nb_rb_ul = + nb_allocated_rbs[CC_id][UE_id]; + LOG_D(MAC, + "******************UL Scheduling Information for UE%d CC_id %d ************************\n", + UE_id, CC_id); + LOG_D(MAC, + "[eNB %d] total RB allocated for UE%d CC_id %d = %d\n", + module_idP, UE_id, CC_id, + UE_template->pre_allocated_nb_rb_ul); + } + } + } } - } - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (total_allocated_rbs[CC_id]>0) { - //LOG_D(MAC,"[eNB %d] total RB allocated for all UEs = %d/%d\n", module_idP, total_allocated_rbs[CC_id], N_RB_UL - first_rb[CC_id]); + if (total_allocated_rbs[CC_id] > 0) { + LOG_D(MAC, "[eNB %d] total RB allocated for all UEs = %d/%d\n", + module_idP, total_allocated_rbs[CC_id], + N_RB_UL - first_rb[CC_id]); + } } - } } -void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subframeP, uint16_t *first_rb) +void +assign_max_mcs_min_rb(module_id_t module_idP, int frameP, + sub_frame_t subframeP, uint16_t * first_rb) { - int i; - uint16_t n,UE_id; - uint8_t CC_id; - rnti_t rnti = -1; - int mcs; - int rb_table_index=0,tbs,tx_power; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - UE_list_t *UE_list = &eNB->UE_list; - - UE_TEMPLATE *UE_template; - int Ncp; - int N_RB_UL; - - //LOG_D(MAC, "%s() Enter\n", __FUNCTION__); - - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) continue; - - rnti = UE_RNTI(module_idP,i); - - //LOG_D(MAC, "%s() UE active rnti:%04x UE_list->UE_sched_ctrl[i].ul_out_of_sync:%d UE_list->UE_sched_ctrl[i].phr_received:%d numactiveULCCs[UE_id]:%d UE_list->UE_template[CC_id][UE_id].ul_total_buffer:%d\n", __FUNCTION__, rnti, UE_list->UE_sched_ctrl[i].ul_out_of_sync, UE_list->UE_sched_ctrl[i].phr_received, UE_list->numactiveULCCs[i], UE_list->UE_template[CC_id][i].ul_total_buffer); - - if (rnti==NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - if (UE_list->UE_sched_ctrl[i].phr_received == 1) - mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs - else - mcs = 10; // otherwise, limit to QPSK PUSCH - - UE_id = i; - - for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { - // This is the actual CC_id in the list - CC_id = UE_list->ordered_ULCCids[n][UE_id]; - - if (CC_id >= MAX_NUM_CCs) { - LOG_E( MAC, "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", - CC_id, - MAX_NUM_CCs, - n, - UE_id, - UE_list->numactiveULCCs[UE_id]); - } - - AssertFatal( CC_id < MAX_NUM_CCs, "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", - CC_id, - MAX_NUM_CCs, - n, - UE_id, - UE_list->numactiveULCCs[UE_id]); - - UE_template = &UE_list->UE_template[CC_id][UE_id]; - - Ncp = RC.mac[module_idP]->common_channels[CC_id].Ncp; - N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth); - // if this UE has UL traffic - if (UE_template->ul_total_buffer > 0 ) { - - - tbs = get_TBS_UL(mcs,3)<<3; // 1 or 2 PRB with cqi enabled does not work well! - rb_table_index = 2; - - // fixme: set use_srs flag - tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,Ncp,0); - - while ((((UE_template->phr_info - tx_power) < 0 ) || (tbs > UE_template->ul_total_buffer))&& - (mcs > 3)) { - LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); - mcs--; - tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; - tx_power = estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,Ncp,0); // fixme: set use_srs - } - - while ((tbs < UE_template->ul_total_buffer) && - (rb_table[rb_table_index]<(N_RB_UL-first_rb[CC_id])) && - ((UE_template->phr_info - tx_power) > 0) && - (rb_table_index < 32 )) { - - rb_table_index++; - tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; - tx_power = estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,Ncp,0); - } - - UE_template->ue_tx_power = tx_power; - - if (rb_table[rb_table_index]>(N_RB_UL-first_rb[CC_id]-1)) { - rb_table_index--; - } - - // 1 or 2 PRB with cqi enabled does not work well - if (rb_table[rb_table_index]<3) { - rb_table_index=2; //3PRB - } - - UE_template->pre_assigned_mcs_ul=mcs; - UE_template->pre_allocated_rb_table_index_ul=rb_table_index; - UE_template->pre_allocated_nb_rb_ul= rb_table[rb_table_index]; - LOG_D(MAC,"[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n", - module_idP, frameP, subframeP, UE_id, CC_id, - UE_template->pre_assigned_mcs_ul, - UE_template->pre_allocated_rb_table_index_ul, - UE_template->pre_allocated_nb_rb_ul, - UE_template->phr_info,tx_power); - } else { - //LOG_E(MAC,"no ul buffer"); - - /* if UE has pending scheduling request then pre-allocate 3 RBs */ - //if (UE_template->ul_active == 1 && UE_template->ul_SR == 1) { - if (UE_is_to_be_scheduled(module_idP, CC_id, i)) { - /* use QPSK mcs */ - UE_template->pre_assigned_mcs_ul = 10; - UE_template->pre_allocated_rb_table_index_ul = 2; - UE_template->pre_allocated_nb_rb_ul = 3; - } else { - UE_template->pre_assigned_mcs_ul = 0; - UE_template->pre_allocated_rb_table_index_ul = -1; - UE_template->pre_allocated_nb_rb_ul = 0; - } - } - } - } -} + int i; + uint16_t n, UE_id; + uint8_t CC_id; + rnti_t rnti = -1; + int mcs; + int rb_table_index = 0, tbs, tx_power; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; -struct sort_ue_ul_params { - int module_idP; - int frameP; - int subframeP; -}; + UE_TEMPLATE *UE_template; + int Ncp; + int N_RB_UL; -static int ue_ul_compare(const void *_a, const void *_b, void *_params) -{ - struct sort_ue_ul_params *params = _params; - UE_list_t *UE_list = &RC.mac[params->module_idP]->UE_list; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; + + rnti = UE_RNTI(module_idP, i); + + if (rnti == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; - int UE_id1 = *(const int *)_a; - int UE_id2 = *(const int *)_b; + if (UE_list->UE_sched_ctrl[i].phr_received == 1) + mcs = 20; // if we've received the power headroom information the UE, we can go to maximum mcs + else + mcs = 10; // otherwise, limit to QPSK PUSCH - int rnti1 = UE_RNTI(params->module_idP, UE_id1); - int pCCid1 = UE_PCCID(params->module_idP, UE_id1); - int round1 = maxround(params->module_idP, rnti1, params->frameP, params->subframeP, 1); + UE_id = i; - int rnti2 = UE_RNTI(params->module_idP, UE_id2); - int pCCid2 = UE_PCCID(params->module_idP, UE_id2); - int round2 = maxround(params->module_idP, rnti2, params->frameP, params->subframeP, 1); + for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { + // This is the actual CC_id in the list + CC_id = UE_list->ordered_ULCCids[n][UE_id]; - if (round1 > round2) return -1; - if (round1 < round2) return 1; + if (CC_id >= MAX_NUM_CCs) { + LOG_E(MAC, + "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", + CC_id, MAX_NUM_CCs, n, UE_id, + UE_list->numactiveULCCs[UE_id]); + } - if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] > UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) - return -1; - if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) - return 1; + AssertFatal(CC_id < MAX_NUM_CCs, + "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", + CC_id, MAX_NUM_CCs, n, UE_id, + UE_list->numactiveULCCs[UE_id]); + + UE_template = &UE_list->UE_template[CC_id][UE_id]; + + Ncp = RC.mac[module_idP]->common_channels[CC_id].Ncp; + N_RB_UL = + to_prb(RC.mac[module_idP]->common_channels[CC_id]. + ul_Bandwidth); + // if this UE has UL traffic + if (UE_template->ul_total_buffer > 0) { + + + tbs = get_TBS_UL(mcs, 3) << 3; // 1 or 2 PRB with cqi enabled does not work well! + rb_table_index = 2; + + // fixme: set use_srs flag + tx_power = + estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, + Ncp, 0); + + while ((((UE_template->phr_info - tx_power) < 0) + || (tbs > UE_template->ul_total_buffer)) + && (mcs > 3)) { + // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); + mcs--; + tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; + tx_power = estimate_ue_tx_power(tbs, rb_table[rb_table_index], 0, Ncp, 0); // fixme: set use_srs + } + + while ((tbs < UE_template->ul_total_buffer) && + (rb_table[rb_table_index] < + (N_RB_UL - first_rb[CC_id])) + && ((UE_template->phr_info - tx_power) > 0) + && (rb_table_index < 32)) { + + rb_table_index++; + tbs = get_TBS_UL(mcs, rb_table[rb_table_index]) << 3; + tx_power = + estimate_ue_tx_power(tbs, rb_table[rb_table_index], + 0, Ncp, 0); + } + + UE_template->ue_tx_power = tx_power; + + if (rb_table[rb_table_index] > + (N_RB_UL - first_rb[CC_id] - 1)) { + rb_table_index--; + } + // 1 or 2 PRB with cqi enabled does not work well + if (rb_table[rb_table_index] < 3) { + rb_table_index = 2; //3PRB + } + + UE_template->pre_assigned_mcs_ul = mcs; + UE_template->pre_allocated_rb_table_index_ul = + rb_table_index; + UE_template->pre_allocated_nb_rb_ul = + rb_table[rb_table_index]; + LOG_D(MAC, + "[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n", + module_idP, frameP, subframeP, UE_id, CC_id, + UE_template->pre_assigned_mcs_ul, + UE_template->pre_allocated_rb_table_index_ul, + UE_template->pre_allocated_nb_rb_ul, + UE_template->phr_info, tx_power); + } else { + /* if UE has pending scheduling request then pre-allocate 3 RBs */ + //if (UE_template->ul_active == 1 && UE_template->ul_SR == 1) { + if (UE_is_to_be_scheduled(module_idP, CC_id, i)) { + /* use QPSK mcs */ + UE_template->pre_assigned_mcs_ul = 10; + UE_template->pre_allocated_rb_table_index_ul = 2; + UE_template->pre_allocated_nb_rb_ul = 3; + } else { + UE_template->pre_assigned_mcs_ul = 0; + UE_template->pre_allocated_rb_table_index_ul = -1; + UE_template->pre_allocated_nb_rb_ul = 0; + } + } + } + } +} - if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer > UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) - return -1; - if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) - return 1; +struct sort_ue_ul_params { + int module_idP; + int frameP; + int subframeP; +}; - if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul > UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) - return -1; - if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul < UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) - return 1; +static int ue_ul_compare(const void *_a, const void *_b, void *_params) +{ + struct sort_ue_ul_params *params = _params; + UE_list_t *UE_list = &RC.mac[params->module_idP]->UE_list; + + int UE_id1 = *(const int *) _a; + int UE_id2 = *(const int *) _b; + + int rnti1 = UE_RNTI(params->module_idP, UE_id1); + int pCCid1 = UE_PCCID(params->module_idP, UE_id1); + int round1 = maxround(params->module_idP, rnti1, params->frameP, + params->subframeP, 1); + + int rnti2 = UE_RNTI(params->module_idP, UE_id2); + int pCCid2 = UE_PCCID(params->module_idP, UE_id2); + int round2 = maxround(params->module_idP, rnti2, params->frameP, + params->subframeP, 1); + + if (round1 > round2) + return -1; + if (round1 < round2) + return 1; + + if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] > + UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) + return -1; + if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < + UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) + return 1; + + if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer > + UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) + return -1; + if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < + UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) + return 1; + + if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul > + UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) + return -1; + if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul < + UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) + return 1; - return 0; + return 0; #if 0 - /* The above order derives from the following. - * The last case is not handled: "if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 )" - * I don't think it makes a big difference. - */ - if(round2 > round1) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } else if (round2 == round1) { - if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } else if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } else if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul < UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) { - if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 ) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } - } - } + /* The above order derives from the following. + * The last case is not handled: "if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 )" + * I don't think it makes a big difference. + */ + if (round2 > round1) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } else if (round2 == round1) { + if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < + UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } else if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < + UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } else if (UE_list->UE_template[pCCid1][UE_id1]. + pre_assigned_mcs_ul < + UE_list->UE_template[pCCid2][UE_id2]. + pre_assigned_mcs_ul) { + if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } + } + } #endif } -void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) +void sort_ue_ul(module_id_t module_idP, int frameP, sub_frame_t subframeP) { - int i; - int list[NUMBER_OF_UE_MAX]; - int list_size = 0; - int rnti; - struct sort_ue_ul_params params = { module_idP, frameP, subframeP }; + int i; + int list[NUMBER_OF_UE_MAX]; + int list_size = 0; + int rnti; + struct sort_ue_ul_params params = { module_idP, frameP, subframeP }; - UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] == FALSE) continue; - if ((rnti = UE_RNTI(module_idP, i)) == NOT_A_RNTI) continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] == FALSE) + continue; + if ((rnti = UE_RNTI(module_idP, i)) == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; - list[list_size] = i; - list_size++; - } + list[list_size] = i; + list_size++; + } - qsort_r(list, list_size, sizeof(int), ue_ul_compare, ¶ms); + qsort_r(list, list_size, sizeof(int), ue_ul_compare, ¶ms); - if (list_size) { - for (i = 0; i < list_size-1; i++) - UE_list->next_ul[list[i]] = list[i+1]; - UE_list->next_ul[list[list_size-1]] = -1; - UE_list->head_ul = list[0]; - } else { - UE_list->head_ul = -1; - } + if (list_size) { + for (i = 0; i < list_size - 1; i++) + UE_list->next_ul[list[i]] = list[i + 1]; + UE_list->next_ul[list[list_size - 1]] = -1; + UE_list->head_ul = list[0]; + } else { + UE_list->head_ul = -1; + } #if 0 - int UE_id1,UE_id2; - int pCCid1,pCCid2; - int round1,round2; - int i=0,ii=0; - rnti_t rnti1,rnti2; - - UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - - for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { - - //LOG_I(MAC,"sort ue ul i %d\n",i); - for (ii=UE_list->next_ul[i]; ii>=0; ii=UE_list->next_ul[ii]) { - //LOG_I(MAC,"sort ul ue 2 ii %d\n",ii); - - UE_id1 = i; - rnti1 = UE_RNTI(module_idP,UE_id1); - - if(rnti1 == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) - continue; - - - pCCid1 = UE_PCCID(module_idP,UE_id1); - round1 = maxround(module_idP,rnti1,frameP,subframeP,1); - - UE_id2 = ii; - rnti2 = UE_RNTI(module_idP,UE_id2); - - if(rnti2 == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) - continue; - - pCCid2 = UE_PCCID(module_idP,UE_id2); - round2 = maxround(module_idP,rnti2,frameP,subframeP,1); - - if(round2 > round1) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } else if (round2 == round1) { - if (UE_list->UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < UE_list->UE_template[pCCid2][UE_id2].ul_buffer_info[LCGID0]) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } else if (UE_list->UE_template[pCCid1][UE_id1].ul_total_buffer < UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } else if (UE_list->UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul < UE_list->UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) { - if (UE_list->UE_template[pCCid2][UE_id2].ul_total_buffer > 0 ) { - swap_UEs(UE_list,UE_id1,UE_id2,1); - } - } - } + int UE_id1, UE_id2; + int pCCid1, pCCid2; + int round1, round2; + int i = 0, ii = 0; + rnti_t rnti1, rnti2; + + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; + + for (i = UE_list->head_ul; i >= 0; i = UE_list->next_ul[i]) { + + //LOG_I(MAC,"sort ue ul i %d\n",i); + for (ii = UE_list->next_ul[i]; ii >= 0; ii = UE_list->next_ul[ii]) { + //LOG_I(MAC,"sort ul ue 2 ii %d\n",ii); + + UE_id1 = i; + rnti1 = UE_RNTI(module_idP, UE_id1); + + if (rnti1 == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + + + pCCid1 = UE_PCCID(module_idP, UE_id1); + round1 = maxround(module_idP, rnti1, frameP, subframeP, 1); + + UE_id2 = ii; + rnti2 = UE_RNTI(module_idP, UE_id2); + + if (rnti2 == NOT_A_RNTI) + continue; + if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) + continue; + + pCCid2 = UE_PCCID(module_idP, UE_id2); + round2 = maxround(module_idP, rnti2, frameP, subframeP, 1); + + if (round2 > round1) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } else if (round2 == round1) { + if (UE_list-> + UE_template[pCCid1][UE_id1].ul_buffer_info[LCGID0] < + UE_list->UE_template[pCCid2][UE_id2]. + ul_buffer_info[LCGID0]) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } else if (UE_list->UE_template[pCCid1][UE_id1]. + ul_total_buffer < + UE_list->UE_template[pCCid2][UE_id2]. + ul_total_buffer) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } else if (UE_list-> + UE_template[pCCid1][UE_id1].pre_assigned_mcs_ul + < + UE_list-> + UE_template[pCCid2][UE_id2].pre_assigned_mcs_ul) + { + if (UE_list->UE_template[pCCid2][UE_id2]. + ul_total_buffer > 0) { + swap_UEs(UE_list, UE_id1, UE_id2, 1); + } + } + } + } } - } #endif } diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 25377e4043dd538695e1576f4452d6fb0fe1882f..4468ce29e70099347630933002ed4b27034aec2c 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -43,12 +43,11 @@ */ -void schedule_mib(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP); +void schedule_mib(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP); /** \fn void schedule_RA(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); -\brief First stage of Random-Access Scheduling. Loops over the RA_templates and checks if RAR, Msg3 or its retransmission are to be scheduled in the subframe. It returns the total number of PRB used for RA SDUs. For Msg3 it retrieves the L3msg from RRC and fills the appropriate buffers. For the others it just computes the number of PRBs. Each DCI uses 3 PRBs (format 1A) +\brief First stage of Random-Access Scheduling. Loops over the ras and checks if RAR, Msg3 or its retransmission are to be scheduled in the subframe. It returns the total number of PRB used for RA SDUs. For Msg3 it retrieves the L3msg from RRC and fills the appropriate buffers. For the others it just computes the number of PRBs. Each DCI uses 3 PRBs (format 1A) for the message. @param Mod_id Instance ID of eNB @param frame Frame index @@ -56,28 +55,32 @@ for the message. */ -void schedule_RA(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); +void schedule_RA(module_id_t module_idP, frame_t frameP, + sub_frame_t subframe); /** \brief First stage of SI Scheduling. Gets a SI SDU from RRC if available and computes the MCS required to transport it as a function of the SDU length. It assumes a length less than or equal to 64 bytes (MCS 6, 3 PRBs). @param Mod_id Instance ID of eNB @param frame Frame index @param subframe Subframe number on which to act */ -void schedule_SI(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP); +void schedule_SI(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP); /** \brief MBMS scheduling: Checking the position for MBSFN subframes. Create MSI, transfer MCCH from RRC to MAC, transfer MTCHs from RLC to MAC. Multiplexing MSI,MCCH&MTCHs. Return 1 if there are MBSFN data being allocated, otherwise return 0; @param Mod_id Instance ID of eNB @param frame Frame index @param subframe Subframe number on which to act */ -int schedule_MBMS(module_id_t module_idP,uint8_t CC_id, frame_t frameP, sub_frame_t subframe); +int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, + sub_frame_t subframe); /** \brief check the mapping between sf allocation and sync area, Currently only supports 1:1 mapping @param Mod_id Instance ID of eNB @param mbsfn_sync_area index of mbsfn sync area @param[out] index of sf pattern */ -int8_t get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t CC_id, uint8_t mbsfn_sync_area); +int8_t get_mbsfn_sf_alloction(module_id_t module_idP, uint8_t CC_id, + uint8_t mbsfn_sync_area); /** \brief check the mapping between sf allocation and sync area, Currently only supports 1:1 mapping @param Mod_id Instance ID of eNB @@ -85,14 +88,17 @@ int8_t get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t CC_id, uint8_t mb @param eNB_index index of eNB @param[out] index of sf pattern */ -int8_t ue_get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t mbsfn_sync_area, unsigned char eNB_index); +int8_t ue_get_mbsfn_sf_alloction(module_id_t module_idP, + uint8_t mbsfn_sync_area, + unsigned char eNB_index); /** \brief top ULSCH Scheduling for TDD (config 1-6). @param Mod_id Instance ID of eNB @param frame Frame index @param subframe Subframe number on which to act */ -void schedule_ulsch(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); +void schedule_ulsch(module_id_t module_idP, frame_t frameP, + sub_frame_t subframe); /** \brief ULSCH Scheduling per RNTI @param Mod_id Instance ID of eNB @@ -100,7 +106,10 @@ void schedule_ulsch(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); @param subframe Subframe number on which to act @param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup) */ -void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, uint16_t *first_rb); +void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, + sub_frame_t subframe, + unsigned char sched_subframe, + uint16_t * first_rb); /** \brief Second stage of DLSCH scheduling, after schedule_SI, schedule_RA and schedule_dlsch have been called. This routine first allocates random frequency assignments for SI and RA SDUs using distributed VRB allocations and adds the corresponding DCI SDU to the DCI buffer for PHY. It then loops over the UE specific DCIs previously allocated and fills in the remaining DCI fields related to frequency allocation. It assumes localized allocation of type 0 (DCI.rah=0). The allocation is done for tranmission modes 1,2,4. @param Mod_id Instance of eNB @@ -108,7 +117,8 @@ void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, sub_frame_t sub @param subframe Index of subframe @param mbsfn_flag Indicates that this subframe is for MCH/MCCH */ -void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag); +void fill_DLSCH_dci(module_id_t module_idP, frame_t frameP, + sub_frame_t subframe, int *mbsfn_flag); /** \brief UE specific DLSCH scheduling. Retrieves next ue to be schduled from round-robin scheduler and gets the appropriate harq_pid for the subframe from PHY. If the process is active and requires a retransmission, it schedules the retransmission with the same PRB count and MCS as the first transmission. Otherwise it consults RLC for DCCH/DTCH SDUs (status with maximum number of available PRBS), builds the MAC header (timing advance sent by default) and copies @param Mod_id Instance ID of eNB @@ -117,39 +127,43 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,i @param mbsfn_flag Indicates that MCH/MCCH is in this subframe */ -void schedule_ue_spec(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag); +void schedule_ue_spec(module_id_t module_idP, frame_t frameP, + sub_frame_t subframe, int *mbsfn_flag); /** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure. @param Mod_id Module id of UE @returns Po_NOMINAL_PUSCH (PREAMBLE_RECEIVED_TARGET_POWER+DELTA_PREAMBLE */ -int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP,uint8_t CC_id); +int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id); /** \brief Function to compute DELTA_PREAMBLE from 36.321 (for RA power ramping procedure and Msg3 PUSCH power control policy) @param Mod_id Module id of UE @returns DELTA_PREAMBLE */ -int8_t get_DELTA_PREAMBLE(module_id_t module_idP,int CC_id); +int8_t get_DELTA_PREAMBLE(module_id_t module_idP, int CC_id); /** \brief Function for compute deltaP_rampup from 36.321 (for RA power ramping procedure and Msg3 PUSCH power control policy) @param Mod_id Module id of UE @param CC_id carrier component id of UE @returns deltaP_rampup */ -int8_t get_deltaP_rampup(module_id_t module_idP,uint8_t CC_id); +int8_t get_deltaP_rampup(module_id_t module_idP, uint8_t CC_id); -uint16_t mac_computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); +uint16_t mac_computeRIV(uint16_t N_RB_DL, uint16_t RBstart, + uint16_t Lcrbs); -void add_msg3(module_id_t module_idP,int CC_id, RA_TEMPLATE *RA_template, frame_t frameP, sub_frame_t subframeP); +void add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, + sub_frame_t subframeP); //main.c -int mac_top_init(int eMBMS_active, char *uecap_xer,uint8_t cba_group_active, uint8_t HO_active); +int mac_top_init(int eMBMS_active, char *uecap_xer, + uint8_t cba_group_active, uint8_t HO_active); void mac_top_init_eNB(void); -void mac_init_cell_params(int Mod_idP,int CC_idP); +void mac_init_cell_params(int Mod_idP, int CC_idP); char layer2_init_UE(module_id_t module_idP); @@ -161,19 +175,29 @@ int mac_init_global_param(void); void mac_top_cleanup(void); -void mac_UE_out_of_sync_ind(module_id_t module_idP,frame_t frameP, uint16_t eNB_index); - -void clear_nfapi_information(eNB_MAC_INST *eNB,int CC_idP,frame_t frameP,sub_frame_t subframeP); - -void dlsch_scheduler_pre_processor_reset (int module_idP,int UE_id, - uint8_t CC_id, - int frameP, - int subframeP, - int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); +void mac_UE_out_of_sync_ind(module_id_t module_idP, frame_t frameP, + uint16_t eNB_index); + +void clear_nfapi_information(eNB_MAC_INST * eNB, int CC_idP, + frame_t frameP, sub_frame_t subframeP); + +void dlsch_scheduler_pre_processor_reset(int module_idP, int UE_id, + uint8_t CC_id, + int frameP, + int subframeP, + int N_RBG, + uint16_t + nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs][NUMBER_OF_UE_MAX], + unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], + unsigned char + MIMO_mode_indicator[MAX_NUM_CCs] + [N_RBG_MAX]); // eNB functions /* \brief This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done @@ -184,24 +208,33 @@ void dlsch_scheduler_pre_processor_reset (int module_idP,int UE_id, */ -void dlsch_scheduler_pre_processor (module_id_t module_idP, - frame_t frameP, - sub_frame_t subframe, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag); - - -void dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, - int UE_id, - uint8_t CC_id, - int N_RBG, - int transmission_mode, - int min_rb_unit, - uint8_t N_RB_DL, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); +void dlsch_scheduler_pre_processor(module_id_t module_idP, + frame_t frameP, + sub_frame_t subframe, + int N_RBG[MAX_NUM_CCs], + int *mbsfn_flag); + + +void dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, + int UE_id, + uint8_t CC_id, + int N_RBG, + int transmission_mode, + int min_rb_unit, + uint8_t N_RB_DL, + uint16_t + nb_rbs_required[MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + uint16_t + nb_rbs_required_remaining + [MAX_NUM_CCs] + [NUMBER_OF_UE_MAX], + unsigned char + rballoc_sub[MAX_NUM_CCs] + [N_RBG_MAX], + unsigned char + MIMO_mode_indicator + [MAX_NUM_CCs][N_RBG_MAX]); /* \brief Function to trigger the eNB scheduling procedure. It is called by PHY at the beginning of each subframe, \f$n$\f and generates all DLSCH allocations for subframe \f$n\f$ and ULSCH allocations for subframe \f$n+k$\f. @@ -209,7 +242,7 @@ void dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, @param subframe Index of current subframe @param calibration_flag Flag to indicate that eNB scheduler should schedule TDD auto-calibration PUSCH. */ -void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP);//, int calibration_flag); +void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); //, int calibration_flag); /* \brief Function to indicate a received preamble on PRACH. It initiates the RA procedure. @param Mod_id Instance ID of eNB @@ -218,12 +251,13 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame @param rnti RA rnti corresponding to this PRACH preamble @param rach_resource type (0=non BL/CE,1 CE level 0,2 CE level 1, 3 CE level 2,4 CE level 3) */ -void initiate_ra_proc(module_id_t module_idP,int CC_id,frame_t frameP, sub_frame_t subframeP, uint16_t preamble_index,int16_t timing_offset,uint16_t rnti +void initiate_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, + sub_frame_t subframeP, uint16_t preamble_index, + int16_t timing_offset, uint16_t rnti #ifdef Rel14 - , - uint8_t rach_resource_type + , uint8_t rach_resource_type #endif - ); + ); /* \brief Function in eNB to fill RAR pdu when requested by PHY. This provides a single RAR SDU for the moment and returns the t-CRNTI. @param Mod_id Instance ID of eNB @@ -231,31 +265,30 @@ void initiate_ra_proc(module_id_t module_idP,int CC_id,frame_t frameP, sub_frame @param N_RB_UL Number of UL resource blocks @returns t_CRNTI */ -unsigned short fill_rar( - const module_id_t module_idP, - const int CC_id, - const frame_t frameP, - uint8_t * const dlsch_buffer, - const uint16_t N_RB_UL, - const uint8_t input_buffer_length -); +unsigned short fill_rar(const module_id_t module_idP, + const int CC_id, + RA_t *ra, + const frame_t frameP, + uint8_t * const dlsch_buffer, + const uint16_t N_RB_UL, + const uint8_t input_buffer_length); #ifdef Rel14 -unsigned short fill_rar_br(eNB_MAC_INST *eNB, +unsigned short fill_rar_br(eNB_MAC_INST * eNB, int CC_id, - RA_TEMPLATE *RA_template, - const frame_t frameP, - const sub_frame_t subframeP, - uint8_t* const dlsch_buffer, - const uint8_t ce_level - ); + RA_t * ra, + const frame_t frameP, + const sub_frame_t subframeP, + uint8_t * const dlsch_buffer, + const uint8_t ce_level); #endif /* \brief Function to indicate a failed RA response. It removes all temporary variables related to the initial connection of a UE @param Mod_id Instance ID of eNB @param preamble_index index of the received RA request. */ -void cancel_ra_proc(module_id_t module_idP,int CC_id,frame_t frameP, uint16_t preamble_index); +void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, + uint16_t preamble_index); /* \brief Function used by PHY to inform MAC that an uplink is scheduled for Msg3 in given subframe. This is used so that the MAC @@ -269,12 +302,10 @@ void cancel_ra_proc(module_id_t module_idP,int CC_id,frame_t frameP, uint16_t pr @param Msg3_subframe subframe where scheduling takes place */ void set_msg3_subframe(module_id_t Mod_id, - int CC_id, - int frame, - int subframe, - int rnti, - int Msg3_frame, - int Msg3_subframe); + int CC_id, + int frame, + int subframe, + int rnti, int Msg3_frame, int Msg3_subframe); /* \brief Function to indicate a received SDU on ULSCH. @param Mod_id Instance ID of eNB @@ -286,14 +317,13 @@ void set_msg3_subframe(module_id_t Mod_id, @param ul_cqi Uplink CQI estimate after this pdu (SNR quantized to 8 bits, -64 ... 63.5 dB in .5dB steps) */ void rx_sdu(const module_id_t enb_mod_idP, - const int CC_idP, - const frame_t frameP, + const int CC_idP, + const frame_t frameP, const sub_frame_t subframeP, - const rnti_t rntiP, - uint8_t *sduP, - const uint16_t sdu_lenP, - const uint16_t timing_advance, - const uint8_t ul_cqi); + const rnti_t rntiP, + uint8_t * sduP, + const uint16_t sdu_lenP, + const uint16_t timing_advance, const uint8_t ul_cqi); /* \brief Function to indicate a scheduled schduling request (SR) was received by eNB. @@ -304,7 +334,8 @@ void rx_sdu(const module_id_t enb_mod_idP, @param rnti RNTI of UE transmitting the SR @param ul_cqi SNR measurement of PUCCH (SNR quantized to 8 bits, -64 ... 63.5 dB in .5dB steps) */ -void SR_indication(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframe,rnti_t rnti,uint8_t ul_cqi); +void SR_indication(module_id_t module_idP, int CC_id, frame_t frameP, + sub_frame_t subframe, rnti_t rnti, uint8_t ul_cqi); /* \brief Function to indicate a UL failure was detected by eNB PHY. @param Mod_id Instance ID of eNB @@ -313,7 +344,8 @@ void SR_indication(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t s @param rnti RNTI of UE transmitting the SR @param subframe Index of subframe where SR was received */ -void UL_failure_indication(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe); +void UL_failure_indication(module_id_t Mod_id, int CC_id, frame_t frameP, + rnti_t rnti, sub_frame_t subframe); /* \brief Function to indicate an HARQ ACK/NAK. @param Mod_id Instance ID of eNB @@ -322,7 +354,9 @@ void UL_failure_indication(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rn @param subframeP subframe index @param harq_pdu NFAPI HARQ PDU descriptor */ -void harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, nfapi_harq_indication_pdu_t *harq_pdu); +void harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, + sub_frame_t subframeP, + nfapi_harq_indication_pdu_t * harq_pdu); /* \brief Function to indicate a received CQI pdu @param Mod_id Instance ID of eNB @@ -332,11 +366,13 @@ void harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_ @param rntiP RNTI of incoming CQI information @param ul_cqi_information NFAPI UL CQI measurement */ -void cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, rnti_t rntiP, - nfapi_cqi_indication_rel9_t *rel9,uint8_t *pdu, - nfapi_ul_cqi_information_t *ul_cqi_information); +void cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, + sub_frame_t subframeP, rnti_t rntiP, + nfapi_cqi_indication_rel9_t * rel9, uint8_t * pdu, + nfapi_ul_cqi_information_t * ul_cqi_information); -uint8_t *get_dlsch_sdu(module_id_t module_idP,int CC_id,frame_t frameP,rnti_t rnti,uint8_t TBindex); +uint8_t *get_dlsch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, + rnti_t rnti, uint8_t TBindex); /* \brief Function to retrieve MCH transport block and MCS used for MCH in this MBSFN subframe. Returns null if no MCH is to be transmitted @param Mod_id Instance ID of eNB @@ -345,69 +381,78 @@ uint8_t *get_dlsch_sdu(module_id_t module_idP,int CC_id,frame_t frameP,rnti_t rn @param mcs Pointer to mcs used by PHY (to be filled by MAC) @returns Pointer to MCH transport block and mcs for subframe */ -MCH_PDU *get_mch_sdu( module_id_t Mod_id, int CC_id, frame_t frame, sub_frame_t subframe); +MCH_PDU *get_mch_sdu(module_id_t Mod_id, int CC_id, frame_t frame, + sub_frame_t subframe); -void ue_mac_reset (module_id_t module_idP,uint8_t eNB_index); -void ue_init_mac (module_id_t module_idP); -void init_ue_sched_info(void); -void add_ue_ulsch_info (module_id_t module_idP, int CC_id, int UE_id, sub_frame_t subframe,UE_ULSCH_STATUS status); -void add_ue_dlsch_info (module_id_t module_idP, int CC_id,int UE_id, sub_frame_t subframe,UE_DLSCH_STATUS status); -int find_UE_id (module_id_t module_idP, rnti_t rnti) ; -int find_RA_id (module_id_t mod_idP, int CC_idP, rnti_t rntiP); -rnti_t UE_RNTI (module_id_t module_idP, int UE_id); -int UE_PCCID (module_id_t module_idP, int UE_id); -uint8_t find_active_UEs (module_id_t module_idP); -boolean_t is_UE_active (module_id_t module_idP, int UE_id); -uint8_t get_aggregation (uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt); +void ue_mac_reset(module_id_t module_idP, uint8_t eNB_index); +void ue_init_mac(module_id_t module_idP); +void init_ue_sched_info(void); +void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, + sub_frame_t subframe, UE_ULSCH_STATUS status); +void add_ue_dlsch_info(module_id_t module_idP, int CC_id, int UE_id, + sub_frame_t subframe, UE_DLSCH_STATUS status); +int find_UE_id(module_id_t module_idP, rnti_t rnti); +int find_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); +rnti_t UE_RNTI(module_id_t module_idP, int UE_id); +int UE_PCCID(module_id_t module_idP, int UE_id); +uint8_t find_active_UEs(module_id_t module_idP); +boolean_t is_UE_active(module_id_t module_idP, int UE_id); +uint8_t get_aggregation(uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt); int8_t find_active_UEs_with_traffic(module_id_t module_idP); -void init_CCE_table(int module_idP,int CC_idP); +void init_CCE_table(int module_idP, int CC_idP); int get_nCCE_offset(int *CCE_table, - const unsigned char L, - const int nCCE, - const int common_dci, - const unsigned short rnti, + const unsigned char L, + const int nCCE, + const int common_dci, + const unsigned short rnti, const unsigned char subframe); -int allocate_CCEs(int module_idP, - int CC_idP, - int subframe, - int test_only); +int allocate_CCEs(int module_idP, int CC_idP, int subframe, int test_only); boolean_t CCE_allocation_infeasible(int module_idP, - int CC_idP, - int common_flag, - int subframe, - int aggregation, - int rnti); - -void set_ue_dai(sub_frame_t subframeP, - int UE_id, - uint8_t CC_id, - uint8_t tdd_config, - UE_list_t *UE_list); - -uint8_t find_num_active_UEs_in_cbagroup(module_id_t module_idP, unsigned char group_id); -uint8_t UE_is_to_be_scheduled(module_id_t module_idP,int CC_id,uint8_t UE_id); + int CC_idP, + int common_flag, + int subframe, + int aggregation, int rnti); + +void set_ue_dai(sub_frame_t subframeP, + int UE_id, + uint8_t CC_id, uint8_t tdd_config, UE_list_t * UE_list); + +/** \brief First stage of PCH Scheduling. Gets a PCH SDU from RRC if available and computes the MCS required to transport it as a function of the SDU length. It assumes a length less than or equal to 64 bytes (MCS 6, 3 PRBs). +@param Mod_id Instance ID of eNB +@param frame Frame index +@param subframe Subframe number on which to act +@param paging_ue_index +*/ +void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP); + +uint8_t find_num_active_UEs_in_cbagroup(module_id_t module_idP, + unsigned char group_id); +uint8_t UE_is_to_be_scheduled(module_id_t module_idP, int CC_id, + uint8_t UE_id); /** \brief Round-robin scheduler for ULSCH traffic. @param Mod_id Instance ID for eNB @param subframe Subframe number on which to act @returns UE index that is to be scheduled if needed/room */ -module_id_t schedule_next_ulue(module_id_t module_idP, int UE_id,sub_frame_t subframe); +module_id_t schedule_next_ulue(module_id_t module_idP, int UE_id, + sub_frame_t subframe); /** \brief Round-robin scheduler for DLSCH traffic. @param Mod_id Instance ID for eNB @param subframe Subframe number on which to act @returns UE index that is to be scheduled if needed/room */ -int schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframe); +int schedule_next_dlue(module_id_t module_idP, int CC_id, + sub_frame_t subframe); /* \brief Allocates a set of PRBS for a particular UE. This is a simple function for the moment, later it should process frequency-domain CQI information and/or PMI information. Currently it just returns the first PRBS that are available in the subframe based on the number requested. @param UE_id Index of UE on which to act @@ -416,7 +461,8 @@ int schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframe); @param rballoc Pointer to bit-map of current PRB allocation given to previous users/control channels. This is updated for subsequent calls to the routine. @returns an rballoc bitmap for resource type 0 allocation (DCI). */ -uint32_t allocate_prbs(int UE_id,uint8_t nb_rb, int N_RB_DL, uint32_t *rballoc); +uint32_t allocate_prbs(int UE_id, uint8_t nb_rb, int N_RB_DL, + uint32_t * rballoc); /* \fn uint32_t req_new_ulsch(module_id_t module_idP) \brief check for a new transmission in any drb @@ -433,19 +479,25 @@ uint32_t req_new_ulsch(module_id_t module_idP); @param subframe subframe number @returns 0 for no SR, 1 for SR */ -uint32_t ue_get_SR(module_id_t module_idP, int CC_id,frame_t frameP, uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe); +uint32_t ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, + uint8_t eNB_id, rnti_t rnti, sub_frame_t subframe); uint8_t get_ue_weight(module_id_t module_idP, int CC_id, int UE_id); // UE functions -void mac_out_of_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t CH_index); +void mac_out_of_sync_ind(module_id_t module_idP, frame_t frameP, + uint16_t CH_index); -void ue_decode_si(module_id_t module_idP, int CC_id,frame_t frame, uint8_t CH_index, void *pdu, uint16_t len); +void ue_decode_si(module_id_t module_idP, int CC_id, frame_t frame, + uint8_t CH_index, void *pdu, uint16_t len); -void ue_decode_p(module_id_t module_idP, int CC_id,frame_t frame, uint8_t CH_index, void *pdu, uint16_t len); +void ue_decode_p(module_id_t module_idP, int CC_id, frame_t frame, + uint8_t CH_index, void *pdu, uint16_t len); -void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frame, sub_frame_t subframe, uint8_t *sdu,uint16_t sdu_len,uint8_t CH_index); +void ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frame, + sub_frame_t subframe, uint8_t * sdu, uint16_t sdu_len, + uint8_t CH_index); void ue_send_sl_sdu(module_id_t module_idP, uint8_t CC_id, @@ -466,7 +518,9 @@ void ue_send_sl_sdu(module_id_t module_idP, @param eNB_index Index of attached eNB @param sync_area the index of MBSFN sync area */ -void ue_send_mch_sdu(module_id_t module_idP,uint8_t CC_id, frame_t frameP,uint8_t *sdu,uint16_t sdu_len,uint8_t eNB_index,uint8_t sync_area) ; +void ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, + uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index, + uint8_t sync_area); /*\brief Function to check if UE PHY needs to decode MCH for MAC. @param Mod_id Index of protocol instance @@ -476,7 +530,9 @@ void ue_send_mch_sdu(module_id_t module_idP,uint8_t CC_id, frame_t frameP,uint8_ @param[out] sync_area return the sync area @param[out] mcch_active flag indicating whether this MCCH is active in this SF */ -int ue_query_mch(uint8_t Mod_id,uint8_t CC_id, uint32_t frame,sub_frame_t subframe, uint8_t eNB_index, uint8_t *sync_area, uint8_t *mcch_active); +int ue_query_mch(uint8_t Mod_id, uint8_t CC_id, uint32_t frame, + sub_frame_t subframe, uint8_t eNB_index, + uint8_t * sync_area, uint8_t * mcch_active); #endif @@ -486,7 +542,10 @@ int ue_query_mch(uint8_t Mod_id,uint8_t CC_id, uint32_t frame,sub_frame_t subfra @param rnti C_RNTI of UE @param subframe subframe number */ -void ue_get_sdu(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe, uint8_t eNB_index,uint8_t *ulsch_buffer,uint16_t buflen,uint8_t *access_mode); +void ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, + sub_frame_t subframe, uint8_t eNB_index, + uint8_t * ulsch_buffer, uint16_t buflen, + uint8_t * access_mode); /* \brief Called by PHY to get sdu for PSBCH/SSS/PSS transmission. @param Mod_id Instance id of UE in machine @@ -518,7 +577,9 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP, int CC_id,frame_t frameP, sub_fram @param New_Msg3 Flag to indicate this call is for a new Msg3 @param subframe Index of subframe for PRACH transmission (0 ... 9) @returns A pointer to a PRACH_RESOURCES_t */ -PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t new_Msg3,sub_frame_t subframe); +PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, + frame_t frameP, uint8_t new_Msg3, + sub_frame_t subframe); /* \brief Function called by PHY to process the received RAR. It checks that the preamble matches what was sent by the eNB and provides the timing advance and t-CRNTI. @param Mod_id Index of UE instance @@ -533,16 +594,14 @@ random-access procedure @returns timing advance or 0xffff if preamble doesn't match */ uint16_t -ue_process_rar( - const module_id_t module_idP, - const int CC_id, - const frame_t frameP, - const rnti_t ra_rnti, - uint8_t * const dlsch_buffer, - rnti_t * const t_crnti, - const uint8_t preamble_index, - uint8_t* selected_rar_buffer -); +ue_process_rar(const module_id_t module_idP, + const int CC_id, + const frame_t frameP, + const rnti_t ra_rnti, + uint8_t * const dlsch_buffer, + rnti_t * const t_crnti, + const uint8_t preamble_index, + uint8_t * selected_rar_buffer); /* \brief Generate header for UL-SCH. This function parses the desired control elements and sdus and generates the header as described @@ -561,17 +620,17 @@ in the ULSCH buffer. @param post_padding Number of bytes for padding at the end of MAC PDU @returns Number of bytes used for header */ -unsigned char generate_ulsch_header(uint8_t *mac_header, - uint8_t num_sdus, - uint8_t short_padding, - uint16_t *sdu_lengths, - uint8_t *sdu_lcids, - POWER_HEADROOM_CMD *power_headroom, - uint16_t *crnti, - BSR_SHORT *truncated_bsr, - BSR_SHORT *short_bsr, - BSR_LONG *long_bsr, - unsigned short post_padding); +unsigned char generate_ulsch_header(uint8_t * mac_header, + uint8_t num_sdus, + uint8_t short_padding, + uint16_t * sdu_lengths, + uint8_t * sdu_lcids, + POWER_HEADROOM_CMD * power_headroom, + uint16_t * crnti, + BSR_SHORT * truncated_bsr, + BSR_SHORT * short_bsr, + BSR_LONG * long_bsr, + unsigned short post_padding); /* \brief Parse header for UL-SCH. This function parses the received UL-SCH header as described in 36-321 MAC layer specifications. It returns the number of bytes used for the header to be used as an offset for the payload @@ -584,40 +643,46 @@ in the ULSCH buffer. @param rx_lengths Pointer to array of SDU lengths @returns Pointer to payload following header */ -uint8_t *parse_ulsch_header(uint8_t *mac_header, - uint8_t *num_ce, - uint8_t *num_sdu, - uint8_t *rx_ces, - uint8_t *rx_lcids, - uint16_t *rx_lengths, - uint16_t tx_lenght); +uint8_t *parse_ulsch_header(uint8_t * mac_header, + uint8_t * num_ce, + uint8_t * num_sdu, + uint8_t * rx_ces, + uint8_t * rx_lcids, + uint16_t * rx_lengths, uint16_t tx_lenght); int to_prb(int); int to_rbg(int); -int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); +int l2_init(LTE_DL_FRAME_PARMS * frame_parms, int eMBMS_active, + char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); int mac_init(void); -int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti,int harq_pid - #ifdef Rel14 - ,uint8_t rach_resource_type - #endif - ); +int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti, int harq_pid +#ifdef Rel14 + , uint8_t rach_resource_type +#endif + ); int rrc_mac_remove_ue(module_id_t Mod_id, rnti_t rntiP); -int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uint8_t ul_flag); -void swap_UEs(UE_list_t *listP,int nodeiP, int nodejP, int ul_flag); -int prev(UE_list_t *listP, int nodeP, int ul_flag); -void dump_ue_list(UE_list_t *listP, int ul_flag); -int UE_num_active_CC(UE_list_t *listP,int ue_idP); -int UE_PCCID(module_id_t mod_idP,int ue_idP); +int maxround(module_id_t Mod_id, uint16_t rnti, int frame, + sub_frame_t subframe, uint8_t ul_flag); +void swap_UEs(UE_list_t * listP, int nodeiP, int nodejP, int ul_flag); +int prev(UE_list_t * listP, int nodeP, int ul_flag); +void dump_ue_list(UE_list_t * listP, int ul_flag); +int UE_num_active_CC(UE_list_t * listP, int ue_idP); +int UE_PCCID(module_id_t mod_idP, int ue_idP); rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP); -void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, uint16_t *first_rb); -void store_ulsch_buffer(module_id_t module_idP, int frameP, sub_frame_t subframeP); -void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP); -void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subframeP,uint16_t *first_rb); -void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, UE_TEMPLATE *UE_template); +void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, + sub_frame_t subframeP, + uint16_t * first_rb); +void store_ulsch_buffer(module_id_t module_idP, int frameP, + sub_frame_t subframeP); +void sort_ue_ul(module_id_t module_idP, int frameP, sub_frame_t subframeP); +void assign_max_mcs_min_rb(module_id_t module_idP, int frameP, + sub_frame_t subframeP, uint16_t * first_rb); +void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, + UE_TEMPLATE * UE_template); int phy_stats_exist(module_id_t Mod_id, int rnti); /*! \fn UE_L2_state_t ue_scheduler(const module_id_t module_idP,const frame_t frameP, const sub_frame_t subframe, const lte_subframe_t direction,const uint8_t eNB_index) @@ -631,15 +696,13 @@ int phy_stats_exist(module_id_t Mod_id, int rnti); \param[in] eNB_index instance of eNB @returns L2 state (CONNETION_OK or CONNECTION_LOST or PHY_RESYNCH) */ -UE_L2_STATE_t ue_scheduler( - const module_id_t module_idP, - const frame_t rxFrameP, - const sub_frame_t rxSubframe, - const frame_t txFrameP, - const sub_frame_t txSubframe, - const lte_subframe_t direction, - const uint8_t eNB_index, - const int CC_id); +UE_L2_STATE_t ue_scheduler(const module_id_t module_idP, + const frame_t rxFrameP, + const sub_frame_t rxSubframe, + const frame_t txFrameP, + const sub_frame_t txSubframe, + const lte_subframe_t direction, + const uint8_t eNB_index, const int CC_id); /*! \fn int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen); \brief determine whether to use cba resource to transmit or not @@ -649,7 +712,8 @@ UE_L2_STATE_t ue_scheduler( \param[in] eNB_index instance of eNB \param[out] access(1) or postpone (0) */ -int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen); +int cba_access(module_id_t module_idP, frame_t frameP, + sub_frame_t subframe, uint8_t eNB_index, uint16_t buflen); /*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len) \brief get short bsr level @@ -665,14 +729,15 @@ BSR_SHORT *get_bsr_short(module_id_t module_idP, uint8_t bsr_len); \param[in] bsr_len indicator for no, short, or long bsr \param[out] bsr_l pointer to long bsr */ -BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len); +BSR_LONG *get_bsr_long(module_id_t module_idP, uint8_t bsr_len); /*! \fn boolean_t update_bsr(module_id_t module_idP, frame_t frameP,sub_frame_t subframeP) \brief get the rlc stats and update the bsr level for each lcid \param[in] Mod_id instance of the UE \param[in] frame Frame index */ -boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP,eNB_index_t eNB_index); +boolean_t update_bsr(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP, eNB_index_t eNB_index); /*! \fn locate_BsrIndexByBufferSize (int *table, int size, int value) \brief locate the BSR level in the table as defined in 36.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table. @@ -681,7 +746,8 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfram \param[in] value Value of the buffer \return the index in the BSR_LEVEL table */ -uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value); +uint8_t locate_BsrIndexByBufferSize(const uint32_t * table, int size, + int value); /*! \fn int get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer) @@ -732,7 +798,8 @@ int get_db_dl_PathlossChange(uint8_t dl_PathlossChange); \param[in] CC_id Component Carrier Index \return phr mapping */ -uint8_t get_phr_mapping (module_id_t module_idP, int CC_id, uint8_t eNB_index); +uint8_t get_phr_mapping(module_id_t module_idP, int CC_id, + uint8_t eNB_index); /*! \fn void update_phr (module_id_t module_idP) \brief update/reset the phr timers @@ -740,13 +807,14 @@ uint8_t get_phr_mapping (module_id_t module_idP, int CC_id, uint8_t eNB_index); \param[in] CC_id Component carrier index \return void */ -void update_phr (module_id_t module_idP,int CC_id); +void update_phr(module_id_t module_idP, int CC_id); /*! \brief Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer \param[in] Mod_id Instance index of UE \param[in] eNB_id Index of eNB */ -void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP,uint8_t eNB_id); +void Msg3_tx(module_id_t module_idP, uint8_t CC_id, frame_t frameP, + uint8_t eNB_id); /*! \brief Function to indicate the transmission of msg1/rach @@ -754,12 +822,12 @@ void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP,uint8_t eNB_id) \param[in] eNB_id Index of eNB */ -void Msg1_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); +void Msg1_tx(module_id_t module_idP, uint8_t CC_id, frame_t frameP, + uint8_t eNB_id); -void dl_phy_sync_success(module_id_t module_idP, - frame_t frameP, - unsigned char eNB_index, - uint8_t first_sync); +void dl_phy_sync_success(module_id_t module_idP, + frame_t frameP, + unsigned char eNB_index, uint8_t first_sync); int dump_eNB_l2_stats(char *buffer, int length); @@ -776,9 +844,11 @@ void add_common_dci(DCI_PDU *DCI_pdu, uint8_t ra_flag); */ -uint32_t allocate_prbs_sub(int nb_rb, int N_RB_DL, int N_RBG, uint8_t *rballoc); +uint32_t allocate_prbs_sub(int nb_rb, int N_RB_DL, int N_RBG, + uint8_t * rballoc); -void update_ul_dci(module_id_t module_idP,uint8_t CC_id,rnti_t rnti,uint8_t dai); +void update_ul_dci(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, + uint8_t dai); int get_bw_index(module_id_t module_id, uint8_t CC_id); @@ -799,14 +869,14 @@ in the DLSCH buffer. @returns Number of bytes used for header */ unsigned char generate_dlsch_header(unsigned char *mac_header, - unsigned char num_sdus, - unsigned short *sdu_lengths, - unsigned char *sdu_lcids, - unsigned char drx_cmd, - unsigned short timing_advance_cmd, - unsigned char *ue_cont_res_id, - unsigned char short_padding, - unsigned short post_padding); + unsigned char num_sdus, + unsigned short *sdu_lengths, + unsigned char *sdu_lcids, + unsigned char drx_cmd, + unsigned short timing_advance_cmd, + unsigned char *ue_cont_res_id, + unsigned char short_padding, + unsigned short post_padding); /** \brief RRC eNB Configuration primitive for PHY/MAC. Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages. @param Mod_id Instance ID of eNB @@ -830,51 +900,55 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, @param sib1_ext_r13 SI Scheduling information for SI-BR UEs */ -int rrc_mac_config_req_eNB(module_id_t module_idP, - int CC_id, - int physCellId, - int p_eNB, - int Ncp, - int eutra_band, - uint32_t dl_CarrierFreq, +int rrc_mac_config_req_eNB(module_id_t module_idP, + int CC_id, + int physCellId, + int p_eNB, + int Ncp, + int eutra_band, uint32_t dl_CarrierFreq, #ifdef Rel14 - int pbch_repetition, + int pbch_repetition, #endif - rnti_t rntiP, - BCCH_BCH_Message_t *mib, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, + rnti_t rntiP, + BCCH_BCH_Message_t * mib, + RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon, #ifdef Rel14 - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR, + RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon_BR, #endif - struct PhysicalConfigDedicated *physicalConfigDedicated, + struct PhysicalConfigDedicated + *physicalConfigDedicated, #if defined(Rel10) || defined(Rel14) - SCellToAddMod_r10_t *sCellToAddMod_r10, + SCellToAddMod_r10_t * sCellToAddMod_r10, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif - MeasObjectToAddMod_t **measObj, - MAC_MainConfig_t *mac_MainConfig, - long logicalChannelIdentity, - LogicalChannelConfig_t *logicalChannelConfig, - MeasGapConfig_t *measGapConfig, - TDD_Config_t *tdd_Config, - MobilityControlInfo_t *mobilityControlInfo, - SchedulingInfoList_t *schedulingInfoList, - uint32_t ul_CarrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList + MeasObjectToAddMod_t ** measObj, + MAC_MainConfig_t * mac_MainConfig, + long logicalChannelIdentity, + LogicalChannelConfig_t * logicalChannelConfig, + MeasGapConfig_t * measGapConfig, + TDD_Config_t * tdd_Config, + MobilityControlInfo_t * mobilityControlInfo, + SchedulingInfoList_t * schedulingInfoList, + uint32_t ul_CarrierFreq, + long *ul_Bandwidth, + AdditionalSpectrumEmission_t * + additionalSpectrumEmission, + struct MBSFN_SubframeConfigList + *mbsfn_SubframeConfigList #if defined(Rel10) || defined(Rel14) , - uint8_t MBMS_Flag, - MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, - PMCH_InfoList_r9_t *pmch_InfoList - + uint8_t MBMS_Flag, + MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, + PMCH_InfoList_r9_t * pmch_InfoList #endif #ifdef Rel14 , - SystemInformationBlockType1_v1310_IEs_t *sib1_ext_r13 + SystemInformationBlockType1_v1310_IEs_t * + sib1_ext_r13 #endif - ); + ); /** \brief RRC eNB Configuration primitive for PHY/MAC. Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages. @param Mod_id Instance ID of ue @@ -896,39 +970,41 @@ int rrc_mac_config_req_eNB(module_id_t module_idP, @param mbsfn_AreaInfoList pointer to MBSFN Area Info list from SIB13 @param pmch_InfoList pointer to PMCH_InfoList from MBSFNAreaConfiguration Message (MCCH Message) */ -int rrc_mac_config_req_ue(module_id_t module_idP, - int CC_id, - uint8_t eNB_index, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - struct PhysicalConfigDedicated *physicalConfigDedicated, +int rrc_mac_config_req_ue(module_id_t module_idP, + int CC_id, + uint8_t eNB_index, + RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon, + struct PhysicalConfigDedicated + *physicalConfigDedicated, #if defined(Rel10) || defined(Rel14) - SCellToAddMod_r10_t *sCellToAddMod_r10, + SCellToAddMod_r10_t * sCellToAddMod_r10, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif - MeasObjectToAddMod_t **measObj, - MAC_MainConfig_t *mac_MainConfig, + MeasObjectToAddMod_t ** measObj, + MAC_MainConfig_t * mac_MainConfig, long logicalChannelIdentity, - LogicalChannelConfig_t *logicalChannelConfig, - MeasGapConfig_t *measGapConfig, - TDD_Config_t *tdd_Config, - MobilityControlInfo_t *mobilityControlInfo, - uint8_t *SIwindowsize, - uint16_t *SIperiod, - ARFCN_ValueEUTRA_t *ul_CarrierFreq, + LogicalChannelConfig_t * logicalChannelConfig, + MeasGapConfig_t * measGapConfig, + TDD_Config_t * tdd_Config, + MobilityControlInfo_t * mobilityControlInfo, + uint8_t * SIwindowsize, + uint16_t * SIperiod, + ARFCN_ValueEUTRA_t * ul_CarrierFreq, long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList + AdditionalSpectrumEmission_t * + additionalSpectrumEmission, + struct MBSFN_SubframeConfigList + *mbsfn_SubframeConfigList #if defined(Rel10) || defined(Rel14) , uint8_t MBMS_Flag, - MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, - PMCH_InfoList_r9_t *pmch_InfoList - + MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, + PMCH_InfoList_r9_t * pmch_InfoList #endif #ifdef CBA , - uint8_t num_active_cba_groups, - uint16_t cba_rnti + uint8_t num_active_cba_groups, uint16_t cba_rnti #endif #if defined(Rel14) ,config_action_t config_action @@ -937,96 +1013,117 @@ int rrc_mac_config_req_ue(module_id_t module_idP, #endif ); -uint16_t getRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); + +uint16_t getRIV(uint16_t N_RB_DL, uint16_t RBstart, uint16_t Lcrbs); int get_subbandsize(uint8_t dl_bandwidth); -void get_Msg3allocret(COMMON_channels_t *cc, +void get_Msg3allocret(COMMON_channels_t * cc, sub_frame_t current_subframe, frame_t current_frame, - frame_t *frame, - sub_frame_t *subframe); + frame_t * frame, sub_frame_t * subframe); -void get_Msg3alloc(COMMON_channels_t *cc, +void get_Msg3alloc(COMMON_channels_t * cc, sub_frame_t current_subframe, frame_t current_frame, - frame_t *frame, - sub_frame_t *subframe); + frame_t * frame, sub_frame_t * subframe); -uint16_t mac_computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); +uint16_t mac_computeRIV(uint16_t N_RB_DL, uint16_t RBstart, + uint16_t Lcrbs); -int get_phich_resource_times6(COMMON_channels_t *cc); +int get_phich_resource_times6(COMMON_channels_t * cc); int to_rbg(int dl_Bandwidth); int to_prb(int dl_Bandwidth); -uint8_t get_Msg3harqpid(COMMON_channels_t *cc, - frame_t frame, - sub_frame_t current_subframe); +uint8_t get_Msg3harqpid(COMMON_channels_t * cc, + frame_t frame, sub_frame_t current_subframe); -uint32_t pdcchalloc2ulframe(COMMON_channels_t *ccP,uint32_t frame, uint8_t n); +uint32_t pdcchalloc2ulframe(COMMON_channels_t * ccP, uint32_t frame, + uint8_t n); -uint8_t pdcchalloc2ulsubframe(COMMON_channels_t *ccP,uint8_t n); +uint8_t pdcchalloc2ulsubframe(COMMON_channels_t * ccP, uint8_t n); -int is_UL_sf(COMMON_channels_t *ccP,sub_frame_t subframeP); +int is_UL_sf(COMMON_channels_t * ccP, sub_frame_t subframeP); uint8_t getQm(uint8_t mcs); -uint8_t subframe2harqpid(COMMON_channels_t *cc,frame_t frame,sub_frame_t subframe); - -void get_srs_pos(COMMON_channels_t *cc,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); - -void get_csi_params(COMMON_channels_t *cc,struct CQI_ReportPeriodic *cqi_PMI_ConfigIndex,uint16_t *Npd,uint16_t *N_OFFSET_CQI,int *H); - -uint8_t get_rel8_dl_cqi_pmi_size(UE_sched_ctrl *sched_ctl,int CC_idP,COMMON_channels_t *cc,uint8_t tmode, struct CQI_ReportPeriodic *cqi_ReportPeriodic); - -uint8_t get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc,uint8_t tmode, uint8_t ri, CQI_ReportModeAperiodic_t *cqi_ReportModeAperiodic); -void extract_pucch_csi(module_id_t mod_idP,int CC_idP,int UE_id, frame_t frameP,sub_frame_t subframeP, uint8_t *pdu, uint8_t length); - -void extract_pusch_csi(module_id_t mod_idP,int CC_idP,int UE_id, frame_t frameP,sub_frame_t subframeP,uint8_t *pdu, uint8_t length); - -uint16_t fill_nfapi_tx_req(nfapi_tx_request_body_t *tx_req_body,uint16_t absSF,uint16_t pdu_length, uint16_t pdu_index, uint8_t *pdu ); - -void fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint8_t cqi_req, - COMMON_channels_t *cc, - struct PhysicalConfigDedicated *physicalConfigDedicated, - uint8_t tmode, - uint32_t handle, - uint16_t rnti, - uint8_t resource_block_start, - uint8_t number_of_resource_blocks, - uint8_t mcs, - uint8_t cyclic_shift_2_for_drms, - uint8_t frequency_hopping_enabled_flag, - uint8_t frequency_hopping_bits, - uint8_t new_data_indication, - uint8_t redundancy_version, - uint8_t harq_process_number, - uint8_t ul_tx_mode, - uint8_t current_tx_nb, - uint8_t n_srs, - uint16_t size - ); +uint8_t subframe2harqpid(COMMON_channels_t * cc, frame_t frame, + sub_frame_t subframe); + +void get_srs_pos(COMMON_channels_t * cc, uint16_t isrs, + uint16_t * psrsPeriodicity, uint16_t * psrsOffset); + +void get_csi_params(COMMON_channels_t * cc, + struct CQI_ReportPeriodic *cqi_PMI_ConfigIndex, + uint16_t * Npd, uint16_t * N_OFFSET_CQI, int *H); + +uint8_t get_rel8_dl_cqi_pmi_size(UE_sched_ctrl * sched_ctl, int CC_idP, + COMMON_channels_t * cc, uint8_t tmode, + struct CQI_ReportPeriodic + *cqi_ReportPeriodic); + +uint8_t get_dl_cqi_pmi_size_pusch(COMMON_channels_t * cc, uint8_t tmode, + uint8_t ri, + CQI_ReportModeAperiodic_t * + cqi_ReportModeAperiodic); +void extract_pucch_csi(module_id_t mod_idP, int CC_idP, int UE_id, + frame_t frameP, sub_frame_t subframeP, + uint8_t * pdu, uint8_t length); + +void extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, + frame_t frameP, sub_frame_t subframeP, + uint8_t * pdu, uint8_t length); + +uint16_t fill_nfapi_tx_req(nfapi_tx_request_body_t * tx_req_body, + uint16_t absSF, uint16_t pdu_length, + uint16_t pdu_index, uint8_t * pdu); + +void fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t * + ul_config_pdu, uint8_t cqi_req, + COMMON_channels_t * cc, + struct PhysicalConfigDedicated + *physicalConfigDedicated, + uint8_t tmode, uint32_t handle, + uint16_t rnti, + uint8_t resource_block_start, + uint8_t + number_of_resource_blocks, + uint8_t mcs, + uint8_t cyclic_shift_2_for_drms, + uint8_t + frequency_hopping_enabled_flag, + uint8_t frequency_hopping_bits, + uint8_t new_data_indication, + uint8_t redundancy_version, + uint8_t harq_process_number, + uint8_t ul_tx_mode, + uint8_t current_tx_nb, + uint8_t n_srs, uint16_t size); #ifdef Rel14 -void fill_nfapi_ulsch_config_request_emtc(nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint8_t ue_type, - uint16_t total_number_of_repetitions, +void fill_nfapi_ulsch_config_request_emtc(nfapi_ul_config_request_pdu_t * + ul_config_pdu, uint8_t ue_type, + uint16_t + total_number_of_repetitions, uint16_t repetition_number, - uint16_t initial_transmission_sf_io); + uint16_t + initial_transmission_sf_io); #endif -void program_dlsch_acknak(module_id_t module_idP, int CC_idP,int UE_idP, frame_t frameP, sub_frame_t subframeP,uint8_t cce_idx); +void program_dlsch_acknak(module_id_t module_idP, int CC_idP, int UE_idP, + frame_t frameP, sub_frame_t subframeP, + uint8_t cce_idx); -void fill_nfapi_dlsch_config(eNB_MAC_INST *eNB, nfapi_dl_config_request_body_t *dl_req, - uint16_t length, - uint16_t pdu_index, +void fill_nfapi_dlsch_config(eNB_MAC_INST * eNB, + nfapi_dl_config_request_body_t * dl_req, + uint16_t length, uint16_t pdu_index, uint16_t rnti, uint8_t resource_allocation_type, - uint8_t virtual_resource_block_assignment_flag, + uint8_t + virtual_resource_block_assignment_flag, uint16_t resource_block_coding, uint8_t modulation, uint8_t redundancy_version, @@ -1035,7 +1132,7 @@ void fill_nfapi_dlsch_config(eNB_MAC_INST *eNB, nfapi_dl_config_request_body_t * uint8_t transmission_scheme, uint8_t number_of_layers, uint8_t number_of_subbands, - // uint8_t codebook_index, + // uint8_t codebook_index, uint8_t ue_category_capacity, uint8_t pa, uint8_t delta_power_offset_index, @@ -1043,28 +1140,27 @@ void fill_nfapi_dlsch_config(eNB_MAC_INST *eNB, nfapi_dl_config_request_body_t * uint8_t nprb, uint8_t transmission_mode, uint8_t num_bf_prb_per_subband, - uint8_t num_bf_vector - ); + uint8_t num_bf_vector); void fill_nfapi_harq_information(module_id_t module_idP, int CC_idP, uint16_t rntiP, uint16_t absSFP, - nfapi_ul_config_harq_information *harq_information, - uint8_t cce_idxP); + nfapi_ul_config_harq_information * + harq_information, uint8_t cce_idxP); void fill_nfapi_ulsch_harq_information(module_id_t module_idP, int CC_idP, uint16_t rntiP, - nfapi_ul_config_ulsch_harq_information *harq_information); + nfapi_ul_config_ulsch_harq_information + * harq_information); uint16_t fill_nfapi_uci_acknak(module_id_t module_idP, int CC_idP, uint16_t rntiP, - uint16_t absSFP, - uint8_t cce_idxP); + uint16_t absSFP, uint8_t cce_idxP); -void fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t *dl_config_pdu, +void fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t * dl_config_pdu, uint8_t aggregation_level, uint16_t rnti, uint8_t rnti_type, @@ -1072,34 +1168,40 @@ void fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t tpc, uint16_t resource_block_coding, uint8_t mcs, - uint8_t ndi, - uint8_t rv, - uint8_t vrb_flag); + uint8_t ndi, uint8_t rv, uint8_t vrb_flag); -nfapi_ul_config_request_pdu_t* has_ul_grant(module_id_t module_idP,int CC_idP,uint16_t subframeP,uint16_t rnti); +nfapi_ul_config_request_pdu_t *has_ul_grant(module_id_t module_idP, + int CC_idP, uint16_t subframeP, + uint16_t rnti); -uint8_t get_tmode(module_id_t module_idP,int CC_idP,int UE_idP); +uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP); -uint8_t get_ul_req_index(module_id_t module_idP, int CC_idP, sub_frame_t subframeP); +uint8_t get_ul_req_index(module_id_t module_idP, int CC_idP, + sub_frame_t subframeP); #ifdef Rel14 int get_numnarrowbandbits(long dl_Bandwidth); -int mpdcch_sf_condition(eNB_MAC_INST *eNB,int CC_id, frame_t frameP,sub_frame_t subframeP,int rmax,MPDCCH_TYPES_t mpdcch_type,int UE_id); +int mpdcch_sf_condition(eNB_MAC_INST * eNB, int CC_id, frame_t frameP, + sub_frame_t subframeP, int rmax, + MPDCCH_TYPES_t mpdcch_type, int UE_id); int get_numnarrowbands(long dl_Bandwidth); -int narrowband_to_first_rb(COMMON_channels_t *cc, int nb_index); +int narrowband_to_first_rb(COMMON_channels_t * cc, int nb_index); #endif int l2_init_eNB(void); -void Msg1_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); -void Msg3_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); -uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn); +void Msg1_transmitted(module_id_t module_idP, uint8_t CC_id, + frame_t frameP, uint8_t eNB_id); +void Msg3_transmitted(module_id_t module_idP, uint8_t CC_id, + frame_t frameP, uint8_t eNB_id); +uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn); int32_t get_uldl_offset(int eutra_bandP); -int l2_init_ue(int eMBMS_active, char *uecap_xer,uint8_t cba_group_active, uint8_t HO_active); +int l2_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, + uint8_t HO_active); #endif /** @}*/ diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 7e7c48ad66d93181bc1787887dd76af093a334ec..ac18fe3e7cd167494fb53816ea31eb68235a5b3f 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -47,7 +47,7 @@ #include "SIMULATION/simulation_defs.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/defs.h" // for taus extern uint8_t nfapi_mode; extern UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); @@ -56,504 +56,1194 @@ extern UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); int8_t get_DELTA_PREAMBLE(module_id_t module_idP,int CC_id) { - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); - uint8_t prachConfigIndex = UE_mac_inst[module_idP].radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex; - uint8_t preambleformat; - - if (UE_mac_inst[module_idP].tdd_Config) { // TDD - if (prachConfigIndex < 20) { - preambleformat = 0; - } else if (prachConfigIndex < 30) { - preambleformat = 1; - } else if (prachConfigIndex < 40) { - preambleformat = 2; - } else if (prachConfigIndex < 48) { - preambleformat = 3; - } else { - preambleformat = 4; + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + uint8_t prachConfigIndex = + UE_mac_inst[module_idP].radioResourceConfigCommon-> + prach_Config.prach_ConfigInfo.prach_ConfigIndex; + uint8_t preambleformat; + + if (UE_mac_inst[module_idP].tdd_Config) { // TDD + if (prachConfigIndex < 20) { + preambleformat = 0; + } else if (prachConfigIndex < 30) { + preambleformat = 1; + } else if (prachConfigIndex < 40) { + preambleformat = 2; + } else if (prachConfigIndex < 48) { + preambleformat = 3; + } else { + preambleformat = 4; + } + } else { // FDD + preambleformat = prachConfigIndex >> 2; } - } else { // FDD - preambleformat = prachConfigIndex>>2; - } - switch (preambleformat) { - case 0: - case 1: - return(0); + switch (preambleformat) { + case 0: + case 1: + return (0); - case 2: - case 3: - return(-3); + case 2: + case 3: + return (-3); - case 4: - return(8); + case 4: + return (8); - default: - AssertFatal(1==0,"[UE %d] ue_procedures.c: FATAL, Illegal preambleformat %d, prachConfigIndex %d\n", - module_idP, - preambleformat,prachConfigIndex); - } + default: + AssertFatal(1 == 0, + "[UE %d] ue_procedures.c: FATAL, Illegal preambleformat %d, prachConfigIndex %d\n", + module_idP, preambleformat, prachConfigIndex); + } } /// This routine implements Section 5.1.2 (UE Random Access Resource Selection) from 36.321 -void get_prach_resources(module_id_t module_idP, - int CC_id, - uint8_t eNB_index, - uint8_t t_id, - uint8_t first_Msg3, - RACH_ConfigDedicated_t *rach_ConfigDedicated) +void +get_prach_resources(module_id_t module_idP, + int CC_id, + uint8_t eNB_index, + uint8_t t_id, + uint8_t first_Msg3, + RACH_ConfigDedicated_t * rach_ConfigDedicated) { LOG_I(MAC, "Panos-D: get_prach_resources 1"); - uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size; - PRACH_RESOURCES_t *prach_resources = &UE_mac_inst[module_idP].RA_prach_resources; - RACH_ConfigCommon_t *rach_ConfigCommon = NULL; - uint8_t noGroupB = 0; - uint8_t f_id = 0,num_prach=0; - int numberOfRA_Preambles; - int messageSizeGroupA; - int sizeOfRA_PreamblesGroupA; - int messagePowerOffsetGroupB; - int PLThreshold; - - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); - AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon!=NULL, - "[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",module_idP); - - rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; - numberOfRA_Preambles = (1+rach_ConfigCommon->preambleInfo.numberOfRA_Preambles)<<2; - - if (rach_ConfigDedicated) { // This is for network controlled Mobility, later - if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) { - prach_resources->ra_PreambleIndex = rach_ConfigDedicated->ra_PreambleIndex; - prach_resources->ra_RACH_MaskIndex = rach_ConfigDedicated->ra_PRACH_MaskIndex; - return; - } - } + uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size; + PRACH_RESOURCES_t *prach_resources = + &UE_mac_inst[module_idP].RA_prach_resources; + RACH_ConfigCommon_t *rach_ConfigCommon = NULL; + uint8_t noGroupB = 0; + uint8_t f_id = 0, num_prach = 0; + int numberOfRA_Preambles; + int messageSizeGroupA; + int sizeOfRA_PreamblesGroupA; + int messagePowerOffsetGroupB; + int PLThreshold; - /* TODO: gcc warns if this variable is not always set, let's put -1 for no more warning */ - messageSizeGroupA = -1; + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon != NULL, + "[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n", + module_idP); - if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { - noGroupB = 1; - } else { - sizeOfRA_PreamblesGroupA = (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA+1)<<2; - switch (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->messageSizeGroupA) { - case 0: - messageSizeGroupA = 56; - break; - case 1: - messageSizeGroupA = 144; - break; - case 2: - messageSizeGroupA = 208; - break; - case 3: - messageSizeGroupA = 256; - break; - } + rach_ConfigCommon = + &UE_mac_inst[module_idP].radioResourceConfigCommon-> + rach_ConfigCommon; + numberOfRA_Preambles = + (1 + rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) << 2; - /* TODO: what value to use as default? */ - messagePowerOffsetGroupB = -9999; - switch (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->messagePowerOffsetGroupB) { - case 0: - messagePowerOffsetGroupB = -9999; - break; - case 1: - messagePowerOffsetGroupB = 0; - break; - case 2: - messagePowerOffsetGroupB = 5; - break; - case 3: - messagePowerOffsetGroupB = 8; - break; - case 4: - messagePowerOffsetGroupB = 10; - break; - case 5: - messagePowerOffsetGroupB = 12; - break; - case 6: - messagePowerOffsetGroupB = 15; - break; - case 7: - messagePowerOffsetGroupB = 18; - break; + if (rach_ConfigDedicated) { // This is for network controlled Mobility, later + if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) { + prach_resources->ra_PreambleIndex = + rach_ConfigDedicated->ra_PreambleIndex; + prach_resources->ra_RACH_MaskIndex = + rach_ConfigDedicated->ra_PRACH_MaskIndex; + return; + } } - PLThreshold = 0 - get_DELTA_PREAMBLE(module_idP,CC_id) - get_Po_NOMINAL_PUSCH(module_idP,CC_id) - messagePowerOffsetGroupB; - // Note Pcmax is set to 0 here, we have to fix this + /* TODO: gcc warns if this variable is not always set, let's put -1 for no more warning */ + messageSizeGroupA = -1; - if (sizeOfRA_PreamblesGroupA == numberOfRA_Preambles) { - noGroupB = 1; - } - } - - if (first_Msg3 == 1) { - if (noGroupB == 1) { - LOG_I(MAC, "Panos-D: get_prach_resources 2"); - // use Group A procedure - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%numberOfRA_Preambles; - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; - UE_mac_inst[module_idP].RA_usedGroupA = 1; - } else if ((Msg3_size <messageSizeGroupA) || - (get_PL(module_idP,0,eNB_index) > PLThreshold)) { - LOG_I(MAC, "Panos-D: get_prach_resources 3"); - // use Group A procedure - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%sizeOfRA_PreamblesGroupA; - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; - UE_mac_inst[module_idP].RA_usedGroupA = 1; - } else { // use Group B - LOG_I(MAC, "Panos-D: get_prach_resources 4"); - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = sizeOfRA_PreamblesGroupA + - (taus())%(numberOfRA_Preambles - sizeOfRA_PreamblesGroupA); - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; - UE_mac_inst[module_idP].RA_usedGroupA = 0; - } + if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { + noGroupB = 1; + } else { + sizeOfRA_PreamblesGroupA = + (rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + 1) << 2; + switch (rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->messageSizeGroupA) { + case 0: + messageSizeGroupA = 56; + break; + case 1: + messageSizeGroupA = 144; + break; + case 2: + messageSizeGroupA = 208; + break; + case 3: + messageSizeGroupA = 256; + break; + } - UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP,CC_id); - } else { // Msg3 is being retransmitted - if (UE_mac_inst[module_idP].RA_usedGroupA == 1) { - if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; - } else { - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())&0x3f; - } + /* TODO: what value to use as default? */ + messagePowerOffsetGroupB = -9999; + switch (rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->messagePowerOffsetGroupB) { + case 0: + messagePowerOffsetGroupB = -9999; + break; + case 1: + messagePowerOffsetGroupB = 0; + break; + case 2: + messagePowerOffsetGroupB = 5; + break; + case 3: + messagePowerOffsetGroupB = 8; + break; + case 4: + messagePowerOffsetGroupB = 10; + break; + case 5: + messagePowerOffsetGroupB = 12; + break; + case 6: + messagePowerOffsetGroupB = 15; + break; + case 7: + messagePowerOffsetGroupB = 18; + break; + } - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; - } else { - // FIXME rach_ConfigCommon->preambleInfo.preamblesGroupAConfig may be zero - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = - rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + - (taus())%(rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - - rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + PLThreshold = + 0 - get_DELTA_PREAMBLE(module_idP, + CC_id) - + get_Po_NOMINAL_PUSCH(module_idP, + CC_id) - messagePowerOffsetGroupB; + // Note Pcmax is set to 0 here, we have to fix this + + + if (sizeOfRA_PreamblesGroupA == numberOfRA_Preambles) { + noGroupB = 1; + } } - } - // choose random PRACH resource in TDD - if (UE_mac_inst[module_idP].tdd_Config) { - num_prach = get_num_prach_tdd(module_idP); + if (first_Msg3 == 1) { + if (noGroupB == 1) { + // use Group A procedure + LOG_I(MAC, "Panos-D: get_prach_resources 2"); + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + (taus()) % numberOfRA_Preambles; + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + UE_mac_inst[module_idP].RA_usedGroupA = 1; + } else if ((Msg3_size < messageSizeGroupA) || + (get_PL(module_idP, 0, eNB_index) > PLThreshold)) { + // use Group A procedure + LOG_I(MAC, "Panos-D: get_prach_resources 3"); + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + (taus()) % sizeOfRA_PreamblesGroupA; + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + UE_mac_inst[module_idP].RA_usedGroupA = 1; + } else { // use Group B + LOG_I(MAC, "Panos-D: get_prach_resources 4"); + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + sizeOfRA_PreamblesGroupA + + (taus()) % (numberOfRA_Preambles - + sizeOfRA_PreamblesGroupA); + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + UE_mac_inst[module_idP].RA_usedGroupA = 0; + } + + UE_mac_inst[module_idP]. + RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = + get_Po_NOMINAL_PUSCH(module_idP, CC_id); + } else { // Msg3 is being retransmitted + if (UE_mac_inst[module_idP].RA_usedGroupA == 1) { + if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { + UE_mac_inst[module_idP].RA_prach_resources. + ra_PreambleIndex = + (taus()) % + rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; + } else { + UE_mac_inst[module_idP].RA_prach_resources. + ra_PreambleIndex = (taus()) & 0x3f; + } - if ((num_prach>0) && (num_prach<6)) { - UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index = (taus()%num_prach); + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + } else { + // FIXME rach_ConfigCommon->preambleInfo.preamblesGroupAConfig may be zero + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + + (taus()) % + (rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - + rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + } } - f_id = get_fid_prach_tdd(module_idP, - UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index); - } + // choose random PRACH resource in TDD + if (UE_mac_inst[module_idP].tdd_Config) { + num_prach = get_num_prach_tdd(module_idP); + + if ((num_prach > 0) && (num_prach < 6)) { + UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index = + (taus() % num_prach); + } - // choose RA-RNTI - UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI = 1 + t_id + 10*f_id; - LOG_I(MAC, "Panos-D: get_prach_resources 4"); + f_id = get_fid_prach_tdd(module_idP, + UE_mac_inst + [module_idP].RA_prach_resources. + ra_TDD_map_index); + } + // choose RA-RNTI + UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI = + 1 + t_id + 10 * f_id; + LOG_I(MAC, "Panos-D: get_prach_resources 4"); } -void Msg1_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id) +void +Msg1_transmitted(module_id_t module_idP, uint8_t CC_id, + frame_t frameP, uint8_t eNB_id) { - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); - // start contention resolution timer - UE_mac_inst[module_idP].RA_attempt_number++; + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + // start contention resolution timer + UE_mac_inst[module_idP].RA_attempt_number++; - if (opt_enabled) { - trace_pdu(0, NULL, 0, module_idP, 0 , UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex, - UE_mac_inst[module_idP].txFrame, UE_mac_inst[module_idP].txSubframe, 0, UE_mac_inst[module_idP].RA_attempt_number); - LOG_D(OPT,"[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", - module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size); - } + if (opt_enabled) { + trace_pdu(0, NULL, 0, module_idP, 0, + UE_mac_inst[module_idP].RA_prach_resources. + ra_PreambleIndex, UE_mac_inst[module_idP].txFrame, + UE_mac_inst[module_idP].txSubframe, 0, + UE_mac_inst[module_idP].RA_attempt_number); + LOG_D(OPT, + "[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size); + } } -void Msg3_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id) +void +Msg3_transmitted(module_id_t module_idP, uint8_t CC_id, + frame_t frameP, uint8_t eNB_id) { - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); - // start contention resolution timer - LOG_D(MAC,"[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n",module_idP,frameP); - UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0; - UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1; + // start contention resolution timer + LOG_D(MAC, + "[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0; + UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1; - if (opt_enabled) { // msg3 - trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size, - module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].txFrame, UE_mac_inst[module_idP].txSubframe, 0, 0); - LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", - module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size); - } + if (opt_enabled) { // msg3 + trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], + UE_mac_inst[module_idP].RA_Msg3_size, module_idP, 3, + UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].txFrame, + UE_mac_inst[module_idP].txSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", + module_idP, frameP, UE_mac_inst[module_idP].crnti + /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex */ + , UE_mac_inst[module_idP].RA_Msg3_size); + } } -PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, uint8_t eNB_indexP,sub_frame_t subframeP) + +PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, + frame_t frameP, uint8_t eNB_indexP, + sub_frame_t subframeP) { - LOG_I(MAC, "Panos-D: ue_get_rach 1"); - uint8_t Size = 0; - UE_MODE_t UE_mode; - // Panos: Modification for phy_stub_ue operation - if(nfapi_mode == 3) { // Panos: phy_stub_ue mode - UE_mode = UE_mac_inst[module_idP].UE_mode[0]; - LOG_I(MAC, "Panos-D: ue_get_rach 2, E_mode: %d", UE_mode); - } - else { // Full stack mode - UE_mode = get_ue_mode(module_idP,0,eNB_indexP); - } - - - uint8_t lcid = CCCH; - uint16_t Size16; - struct RACH_ConfigCommon *rach_ConfigCommon = (struct RACH_ConfigCommon *)NULL; - int32_t frame_diff = 0; - mac_rlc_status_resp_t rlc_status; - uint8_t dcch_header_len = 0; - uint16_t sdu_lengths[8]; - uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; - - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); - - if (UE_mode == PRACH) { - LOG_I(MAC, "Panos-D: ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active); - if (UE_mac_inst[module_idP].radioResourceConfigCommon) { - rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; - } else { - //AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon!=NULL,"RadioResourceConfigCommon Null"); - return(NULL); + uint8_t Size = 0; + UE_MODE_t UE_mode; + // Panos: Modification for phy_stub_ue operation + if(nfapi_mode == 3) { // Panos: phy_stub_ue mode + UE_mode = UE_mac_inst[module_idP].UE_mode[0]; + LOG_I(MAC, "Panos-D: ue_get_rach 2, UE_mode: %d", UE_mode); + } + else { // Full stack mode + UE_mode = get_ue_mode(module_idP,0,eNB_indexP); } - if (UE_mac_inst[module_idP].RA_active == 0) { - LOG_I(MAC, "Panos-D: ue_get_rach 4"); - LOG_I(MAC,"RA not active\n"); - // check if RRC is ready to initiate the RA procedure - Size = mac_rrc_data_req(module_idP, - CC_id, - frameP, - CCCH,1, - &UE_mac_inst[module_idP].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0, - eNB_indexP, - 0); - Size16 = (uint16_t)Size; - - // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); - LOG_I(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, module_idP, eNB_indexP, module_idP); - LOG_I(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); - - if (Size>0) { - LOG_I(MAC, "Panos-D: ue_get_rach 5"); - UE_mac_inst[module_idP].RA_active = 1; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; - UE_mac_inst[module_idP].RA_Msg3_size = Size+sizeof(SCH_SUBHEADER_SHORT)+sizeof(SCH_SUBHEADER_SHORT); - UE_mac_inst[module_idP].RA_prachMaskIndex = 0; - UE_mac_inst[module_idP].RA_prach_resources.Msg3 = UE_mac_inst[module_idP].CCCH_pdu.payload; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - - AssertFatal(rach_ConfigCommon!=NULL, - "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); - UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - - if (UE_mac_inst[module_idP].RA_window_cnt == 9) { - UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + + uint8_t lcid = CCCH; + uint16_t Size16; + struct RACH_ConfigCommon *rach_ConfigCommon = + (struct RACH_ConfigCommon *) NULL; + int32_t frame_diff = 0; + mac_rlc_status_resp_t rlc_status; + uint8_t dcch_header_len = 0; + uint16_t sdu_lengths[8]; + uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; + + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + + if (UE_mode == PRACH) { + LOG_I(MAC, "Panos-D: ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active); + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { + rach_ConfigCommon = + &UE_mac_inst[module_idP]. + radioResourceConfigCommon->rach_ConfigCommon; + } else { + return (NULL); } - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - // Fill in preamble and PRACH resource - get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); - - generate_ulsch_header((uint8_t*)&UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - NULL, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 1); //post_padding - return(&UE_mac_inst[module_idP].RA_prach_resources); - - } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { - // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) - dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element - rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, - DCCH, - 6 + + if (UE_mac_inst[module_idP].RA_active == 0) { + LOG_I(MAC, "RA not active\n"); + // check if RRC is ready to initiate the RA procedure + Size = mac_rrc_data_req_ue(module_idP, + CC_id, + frameP, + CCCH, 1, + &UE_mac_inst[module_idP]. + CCCH_pdu.payload[sizeof + (SCH_SUBHEADER_SHORT) + + 1], eNB_indexP, + 0); + Size16 = (uint16_t) Size; + + // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + LOG_I(RRC, + "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, module_idP, eNB_indexP, module_idP); + LOG_I(MAC, + "[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", + module_idP, frameP, Size); + + if (Size > 0) { + LOG_I(MAC, "Panos-D: ue_get_rach 5"); + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = + 1; + UE_mac_inst[module_idP].RA_Msg3_size = + Size + sizeof(SCH_SUBHEADER_SHORT) + + sizeof(SCH_SUBHEADER_SHORT); + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = + UE_mac_inst[module_idP].CCCH_pdu.payload; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon != NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 1, NULL); + + generate_ulsch_header((uint8_t *) & UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + NULL, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 1); //post_padding + return (&UE_mac_inst[module_idP].RA_prach_resources); + + } else if (UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [DCCH]] > 0) { + // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) + dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element + rlc_status = + mac_rlc_status_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_indexP, frameP, subframeP, + ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6 #ifdef Rel14 ,0, 0 #endif ); - - if (UE_mac_inst[module_idP].crnti_before_ho) - LOG_D(MAC, - "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", - module_idP,frameP, UE_mac_inst[module_idP].crnti,UE_mac_inst[module_idP].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len); - else - LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", - module_idP,frameP, rlc_status.bytes_in_buffer,dcch_header_len); - - sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, - eNB_indexP, frameP,ENB_FLAG_NO, MBMS_FLAG_NO, - DCCH, - 6, //not used - (char *)&ulsch_buff[0] + + + if (UE_mac_inst[module_idP].crnti_before_ho) + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", + module_idP, frameP, + UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].crnti_before_ho, + rlc_status.bytes_in_buffer, dcch_header_len); + else + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", + module_idP, frameP, rlc_status.bytes_in_buffer, + dcch_header_len); + + sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6, //not used + (char *) &ulsch_buff[0] #ifdef Rel14 - ,0, - 0 + ,0, + 0 #endif - ); - - LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); - update_bsr(module_idP, frameP, subframeP,eNB_indexP); - UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = - locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]]); - - //TO DO: fill BSR infos in UL TBS - - //header_len +=2; - UE_mac_inst[module_idP].RA_active = 1; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; - UE_mac_inst[module_idP].RA_Msg3_size = Size+dcch_header_len; - UE_mac_inst[module_idP].RA_prachMaskIndex = 0; - UE_mac_inst[module_idP].RA_prach_resources.Msg3 = ulsch_buff; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - - AssertFatal(rach_ConfigCommon!=NULL, - "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); - UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - - if (UE_mac_inst[module_idP].RA_window_cnt == 9) { - UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! - } - - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - // Fill in preamble and PRACH resource - get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); - generate_ulsch_header((uint8_t*)ulsch_buff, // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - &UE_mac_inst[module_idP].crnti, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 0); //post_padding - - return(&UE_mac_inst[module_idP].RA_prach_resources); - } - } else { // RACH is active - LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",module_idP, - frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt, - UE_mac_inst[module_idP].RA_tx_frame,UE_mac_inst[module_idP].RA_tx_subframe); - - // compute backoff parameters - if (UE_mac_inst[module_idP].RA_backoff_cnt>0) { - frame_diff = (sframe_t)frameP - UE_mac_inst[module_idP].RA_backoff_frame; - - if (frame_diff < 0) { - frame_diff = -frame_diff; - } - - UE_mac_inst[module_idP].RA_backoff_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_backoff_subframe)); - - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - } - - // compute RA window parameters - if (UE_mac_inst[module_idP].RA_window_cnt>0) { - frame_diff = (frame_t)frameP - UE_mac_inst[module_idP].RA_tx_frame; - - if (frame_diff < 0) { - frame_diff = -frame_diff; - } - - UE_mac_inst[module_idP].RA_window_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_tx_subframe)); - LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",module_idP, - frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt); - } - - if ((UE_mac_inst[module_idP].RA_window_cnt<=0) && - (UE_mac_inst[module_idP].RA_backoff_cnt<=0)) { - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; - UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += - (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition - int preambleTransMax = -1; - switch (rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { - case PreambleTransMax_n3: - preambleTransMax = 3; - break; - case PreambleTransMax_n4: - preambleTransMax = 4; - break; - case PreambleTransMax_n5: - preambleTransMax = 5; - break; - case PreambleTransMax_n6: - preambleTransMax = 6; - break; - case PreambleTransMax_n7: - preambleTransMax = 7; - break; - case PreambleTransMax_n8: - preambleTransMax = 8; - break; - case PreambleTransMax_n10: - preambleTransMax = 10; - break; - case PreambleTransMax_n20: - preambleTransMax = 20; - break; - case PreambleTransMax_n50: - preambleTransMax = 50; - break; - case PreambleTransMax_n100: - preambleTransMax = 100; - break; - case PreambleTransMax_n200: - preambleTransMax = 200; - break; - } - - if (UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { - LOG_D(MAC,"[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",module_idP,frameP,preambleTransMax); - // send message to RRC - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER=1; - UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP,CC_id); + ); + + + LOG_D(MAC, "[UE %d] TX Got %d bytes for DCCH\n", + module_idP, sdu_lengths[0]); + update_bsr(module_idP, frameP, subframeP, eNB_indexP); + UE_mac_inst[module_idP]. + scheduling_info.BSR[UE_mac_inst[module_idP]. + scheduling_info.LCGID[DCCH]] = + locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, + UE_mac_inst + [module_idP].scheduling_info.BSR_bytes + [UE_mac_inst + [module_idP].scheduling_info.LCGID + [DCCH]]); + + //TO DO: fill BSR infos in UL TBS + + //header_len +=2; + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = + 1; + UE_mac_inst[module_idP].RA_Msg3_size = + Size + dcch_header_len; + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = + ulsch_buff; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon != NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 1, NULL); + generate_ulsch_header((uint8_t *) ulsch_buff, // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + &UE_mac_inst[module_idP].crnti, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 0); //post_padding + + return (&UE_mac_inst[module_idP].RA_prach_resources); + } + } else { // RACH is active + LOG_D(MAC, + "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n", + module_idP, frameP, subframeP, + UE_mac_inst[module_idP].RA_window_cnt, + UE_mac_inst[module_idP].RA_tx_frame, + UE_mac_inst[module_idP].RA_tx_subframe); + + // compute backoff parameters + if (UE_mac_inst[module_idP].RA_backoff_cnt > 0) { + frame_diff = + (sframe_t) frameP - + UE_mac_inst[module_idP].RA_backoff_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_backoff_cnt -= + ((10 * frame_diff) + + (subframeP - + UE_mac_inst[module_idP].RA_backoff_subframe)); + + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + } + // compute RA window parameters + if (UE_mac_inst[module_idP].RA_window_cnt > 0) { + frame_diff = + (frame_t) frameP - UE_mac_inst[module_idP].RA_tx_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_window_cnt -= + ((10 * frame_diff) + + (subframeP - UE_mac_inst[module_idP].RA_tx_subframe)); + LOG_D(MAC, + "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n", + module_idP, frameP, subframeP, + UE_mac_inst[module_idP].RA_window_cnt); + } + + if ((UE_mac_inst[module_idP].RA_window_cnt <= 0) && + (UE_mac_inst[module_idP].RA_backoff_cnt <= 0)) { + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep << 1); // 2dB increments in ASN.1 definition + int preambleTransMax = -1; + switch (rach_ConfigCommon->ra_SupervisionInfo. + preambleTransMax) { + case PreambleTransMax_n3: + preambleTransMax = 3; + break; + case PreambleTransMax_n4: + preambleTransMax = 4; + break; + case PreambleTransMax_n5: + preambleTransMax = 5; + break; + case PreambleTransMax_n6: + preambleTransMax = 6; + break; + case PreambleTransMax_n7: + preambleTransMax = 7; + break; + case PreambleTransMax_n8: + preambleTransMax = 8; + break; + case PreambleTransMax_n10: + preambleTransMax = 10; + break; + case PreambleTransMax_n20: + preambleTransMax = 20; + break; + case PreambleTransMax_n50: + preambleTransMax = 50; + break; + case PreambleTransMax_n100: + preambleTransMax = 100; + break; + case PreambleTransMax_n200: + preambleTransMax = 200; + break; + } + + if (UE_mac_inst[module_idP]. + RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { + LOG_D(MAC, + "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n", + module_idP, frameP, preambleTransMax); + // send message to RRC + UE_mac_inst[module_idP]. + RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP]. + RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER + = get_Po_NOMINAL_PUSCH(module_idP, CC_id); + } + + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; + + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 0, NULL); + return (&UE_mac_inst[module_idP].RA_prach_resources); + } } - - UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; - - // Fill in preamble and PRACH resource - get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,0,NULL); - return(&UE_mac_inst[module_idP].RA_prach_resources); - } + } else if (UE_mode == PUSCH) { + LOG_D(MAC, + "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...", + module_idP); + AssertFatal(1 == 0, ""); } - } else if (UE_mode == PUSCH) { - LOG_D(MAC,"[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...",module_idP); - AssertFatal(1==0,""); - } - - return(NULL); + + return (NULL); } + + + + + + + + + + /*PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, + frame_t frameP, uint8_t eNB_indexP, + sub_frame_t subframeP) + { + + <<<<<<< HEAD + LOG_I(MAC, "Panos-D: ue_get_rach 1"); + uint8_t Size = 0; + UE_MODE_t UE_mode; + // Panos: Modification for phy_stub_ue operation + if(nfapi_mode == 3) { // Panos: phy_stub_ue mode + UE_mode = UE_mac_inst[module_idP].UE_mode[0]; + LOG_I(MAC, "Panos-D: ue_get_rach 2, UE_mode: %d", UE_mode); + } + else { // Full stack mode + UE_mode = get_ue_mode(module_idP,0,eNB_indexP); + } + + + uint8_t lcid = CCCH; + uint16_t Size16; + struct RACH_ConfigCommon *rach_ConfigCommon = (struct RACH_ConfigCommon *)NULL; + int32_t frame_diff = 0; + mac_rlc_status_resp_t rlc_status; + uint8_t dcch_header_len = 0; + uint16_t sdu_lengths[8]; + uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; + + AssertFatal(CC_id==0, + "Transmission on secondary CCs is not supported yet\n"); + + if (UE_mode == PRACH) { + LOG_I(MAC, "Panos-D: ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active); + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { + rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; + } else { + //AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon!=NULL,"RadioResourceConfigCommon Null"); + return(NULL); + } + + if (UE_mac_inst[module_idP].RA_active == 0) { + LOG_I(MAC, "Panos-D: ue_get_rach 4"); + LOG_I(MAC,"RA not active\n"); + // check if RRC is ready to initiate the RA procedure + Size = mac_rrc_data_req(module_idP, + CC_id, + frameP, + CCCH,1, + &UE_mac_inst[module_idP].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0, + eNB_indexP, + 0); + Size16 = (uint16_t)Size; + + // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + LOG_I(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, module_idP, eNB_indexP, module_idP); + LOG_I(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + + if (Size>0) { + LOG_I(MAC, "Panos-D: ue_get_rach 5"); + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP].RA_Msg3_size = Size+sizeof(SCH_SUBHEADER_SHORT)+sizeof(SCH_SUBHEADER_SHORT); + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = UE_mac_inst[module_idP].CCCH_pdu.payload; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon!=NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); + + generate_ulsch_header((uint8_t*)&UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + NULL, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 1); //post_padding + return(&UE_mac_inst[module_idP].RA_prach_resources); + + } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { + // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) + dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element + rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, + DCCH, + 6 + #ifdef Rel14 + ,0, 0 + #endif + ); + + if (UE_mac_inst[module_idP].crnti_before_ho) + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", + module_idP,frameP, UE_mac_inst[module_idP].crnti,UE_mac_inst[module_idP].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len); + else + LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", + module_idP,frameP, rlc_status.bytes_in_buffer,dcch_header_len); + + sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, + eNB_indexP, frameP,ENB_FLAG_NO, MBMS_FLAG_NO, + DCCH, + 6, //not used + (char *)&ulsch_buff[0] + #ifdef Rel14 + ,0, + 0 + #endif + ); + + LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); + update_bsr(module_idP, frameP, subframeP,eNB_indexP); + UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = + locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]]); + + //TO DO: fill BSR infos in UL TBS + + //header_len +=2; + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP].RA_Msg3_size = Size+dcch_header_len; + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = ulsch_buff; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon!=NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); + generate_ulsch_header((uint8_t*)ulsch_buff, // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + &UE_mac_inst[module_idP].crnti, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 0); //post_padding + + return(&UE_mac_inst[module_idP].RA_prach_resources); + } + } else { // RACH is active + LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",module_idP, + frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt, + UE_mac_inst[module_idP].RA_tx_frame,UE_mac_inst[module_idP].RA_tx_subframe); + + // compute backoff parameters + if (UE_mac_inst[module_idP].RA_backoff_cnt>0) { + frame_diff = (sframe_t)frameP - UE_mac_inst[module_idP].RA_backoff_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_backoff_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_backoff_subframe)); + + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + } + + // compute RA window parameters + if (UE_mac_inst[module_idP].RA_window_cnt>0) { + frame_diff = (frame_t)frameP - UE_mac_inst[module_idP].RA_tx_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_window_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_tx_subframe)); + LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",module_idP, + frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt); + } + + if ((UE_mac_inst[module_idP].RA_window_cnt<=0) && + (UE_mac_inst[module_idP].RA_backoff_cnt<=0)) { + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += + (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition + int preambleTransMax = -1; + switch (rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { + case PreambleTransMax_n3: + preambleTransMax = 3; + break; + case PreambleTransMax_n4: + preambleTransMax = 4; + break; + case PreambleTransMax_n5: + preambleTransMax = 5; + break; + case PreambleTransMax_n6: + preambleTransMax = 6; + break; + case PreambleTransMax_n7: + preambleTransMax = 7; + break; + case PreambleTransMax_n8: + preambleTransMax = 8; + break; + case PreambleTransMax_n10: + preambleTransMax = 10; + break; + case PreambleTransMax_n20: + preambleTransMax = 20; + break; + case PreambleTransMax_n50: + preambleTransMax = 50; + break; + case PreambleTransMax_n100: + preambleTransMax = 100; + break; + case PreambleTransMax_n200: + preambleTransMax = 200; + break; + } + + if (UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { + LOG_D(MAC,"[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",module_idP,frameP,preambleTransMax); + // send message to RRC + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER=1; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP,CC_id); + ======= + + uint8_t Size = 0; + UE_MODE_t UE_mode = get_ue_mode(module_idP, 0, eNB_indexP); + uint8_t lcid = CCCH; + uint16_t Size16; + struct RACH_ConfigCommon *rach_ConfigCommon = + (struct RACH_ConfigCommon *) NULL; + int32_t frame_diff = 0; + mac_rlc_status_resp_t rlc_status; + uint8_t dcch_header_len = 0; + uint16_t sdu_lengths[8]; + uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; + + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + + if (UE_mode == PRACH) { + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { + rach_ConfigCommon = + &UE_mac_inst[module_idP]. + radioResourceConfigCommon->rach_ConfigCommon; + } else { + return (NULL); + } + + if (UE_mac_inst[module_idP].RA_active == 0) { + LOG_I(MAC, "RA not active\n"); + // check if RRC is ready to initiate the RA procedure + Size = mac_rrc_data_req_ue(module_idP, + CC_id, + frameP, + CCCH, 1, + &UE_mac_inst[module_idP]. + CCCH_pdu.payload[sizeof + (SCH_SUBHEADER_SHORT) + + 1], eNB_indexP, + 0); + Size16 = (uint16_t) Size; + + // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + LOG_I(RRC, + "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, module_idP, eNB_indexP, module_idP); + LOG_I(MAC, + "[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", + module_idP, frameP, Size); + + if (Size > 0) { + + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = + 1; + UE_mac_inst[module_idP].RA_Msg3_size = + Size + sizeof(SCH_SUBHEADER_SHORT) + + sizeof(SCH_SUBHEADER_SHORT); + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = + UE_mac_inst[module_idP].CCCH_pdu.payload; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon != NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 1, NULL); + + generate_ulsch_header((uint8_t *) & UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + NULL, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 1); //post_padding + return (&UE_mac_inst[module_idP].RA_prach_resources); + + } else if (UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [DCCH]] > 0) { + // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) + dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element + rlc_status = + mac_rlc_status_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_indexP, frameP, subframeP, + ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6); + + if (UE_mac_inst[module_idP].crnti_before_ho) + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", + module_idP, frameP, + UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].crnti_before_ho, + rlc_status.bytes_in_buffer, dcch_header_len); + else + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", + module_idP, frameP, rlc_status.bytes_in_buffer, + dcch_header_len); + + sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6, //not used + (char *) &ulsch_buff[0]); + + LOG_D(MAC, "[UE %d] TX Got %d bytes for DCCH\n", + module_idP, sdu_lengths[0]); + update_bsr(module_idP, frameP, subframeP, eNB_indexP); + UE_mac_inst[module_idP]. + scheduling_info.BSR[UE_mac_inst[module_idP]. + scheduling_info.LCGID[DCCH]] = + locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, + UE_mac_inst + [module_idP].scheduling_info.BSR_bytes + [UE_mac_inst + [module_idP].scheduling_info.LCGID + [DCCH]]); + + //TO DO: fill BSR infos in UL TBS + + //header_len +=2; + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = + 1; + UE_mac_inst[module_idP].RA_Msg3_size = + Size + dcch_header_len; + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = + ulsch_buff; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon != NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 1, NULL); + generate_ulsch_header((uint8_t *) ulsch_buff, // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + &UE_mac_inst[module_idP].crnti, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 0); //post_padding + + return (&UE_mac_inst[module_idP].RA_prach_resources); + } + } else { // RACH is active + LOG_D(MAC, + "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n", + module_idP, frameP, subframeP, + UE_mac_inst[module_idP].RA_window_cnt, + UE_mac_inst[module_idP].RA_tx_frame, + UE_mac_inst[module_idP].RA_tx_subframe); + + // compute backoff parameters + if (UE_mac_inst[module_idP].RA_backoff_cnt > 0) { + frame_diff = + (sframe_t) frameP - + UE_mac_inst[module_idP].RA_backoff_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_backoff_cnt -= + ((10 * frame_diff) + + (subframeP - + UE_mac_inst[module_idP].RA_backoff_subframe)); + + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + } + // compute RA window parameters + if (UE_mac_inst[module_idP].RA_window_cnt > 0) { + frame_diff = + (frame_t) frameP - UE_mac_inst[module_idP].RA_tx_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_window_cnt -= + ((10 * frame_diff) + + (subframeP - UE_mac_inst[module_idP].RA_tx_subframe)); + LOG_D(MAC, + "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n", + module_idP, frameP, subframeP, + UE_mac_inst[module_idP].RA_window_cnt); + } + + if ((UE_mac_inst[module_idP].RA_window_cnt <= 0) && + (UE_mac_inst[module_idP].RA_backoff_cnt <= 0)) { + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep << 1); // 2dB increments in ASN.1 definition + int preambleTransMax = -1; + switch (rach_ConfigCommon->ra_SupervisionInfo. + preambleTransMax) { + case PreambleTransMax_n3: + preambleTransMax = 3; + break; + case PreambleTransMax_n4: + preambleTransMax = 4; + break; + case PreambleTransMax_n5: + preambleTransMax = 5; + break; + case PreambleTransMax_n6: + preambleTransMax = 6; + break; + case PreambleTransMax_n7: + preambleTransMax = 7; + break; + case PreambleTransMax_n8: + preambleTransMax = 8; + break; + case PreambleTransMax_n10: + preambleTransMax = 10; + break; + case PreambleTransMax_n20: + preambleTransMax = 20; + break; + case PreambleTransMax_n50: + preambleTransMax = 50; + break; + case PreambleTransMax_n100: + preambleTransMax = 100; + break; + case PreambleTransMax_n200: + preambleTransMax = 200; + break; + } + + if (UE_mac_inst[module_idP]. + RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { + LOG_D(MAC, + "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n", + module_idP, frameP, preambleTransMax); + // send message to RRC + UE_mac_inst[module_idP]. + RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP]. + RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER + = get_Po_NOMINAL_PUSCH(module_idP, CC_id); + } + + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; + + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 0, NULL); + return (&UE_mac_inst[module_idP].RA_prach_resources); + } + >>>>>>> main/develop + } + } else if (UE_mode == PUSCH) { + LOG_D(MAC, + "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...", + module_idP); + AssertFatal(1 == 0, ""); + } + + return (NULL); + } */ + diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index ad870b63879f4dd05bd3faea7d550f8b9ec3062c..6261eaf35690f672225209e7972aa333d6bd9087 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -40,269 +40,145 @@ #define DEBUG_RAR -extern unsigned int localRIV2alloc_LUT25[512]; -extern unsigned int distRIV2alloc_LUT25[512]; +extern unsigned int localRIV2alloc_LUT25[512]; +extern unsigned int distRIV2alloc_LUT25[512]; extern unsigned short RIV2nb_rb_LUT25[512]; extern unsigned short RIV2first_rb_LUT25[512]; extern RAN_CONTEXT_t RC; //------------------------------------------------------------------------------ -unsigned short fill_rar( - const module_id_t module_idP, - const int CC_id, - const frame_t frameP, - uint8_t* const dlsch_buffer, - const uint16_t N_RB_UL, - const uint8_t input_buffer_length -) +unsigned short +fill_rar(const module_id_t module_idP, + const int CC_id, + RA_t * ra, + const frame_t frameP, + uint8_t * const dlsch_buffer, + const uint16_t N_RB_UL, const uint8_t input_buffer_length) //------------------------------------------------------------------------------ { - RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; - // RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1); - uint8_t *rar = (uint8_t *)(dlsch_buffer+1); - int i,ra_idx = -1; - RA_TEMPLATE *RA_template; - - AssertFatal(CC_id < MAX_NUM_CCs, "CC_id %u < MAX_NUM_CCs %u", CC_id, MAX_NUM_CCs); - - for (i=0; i<NB_RA_PROC_MAX; i++) { - if (RC.mac[module_idP]->common_channels[CC_id].RA_template[i].generate_rar == 1) { - ra_idx=i; - RC.mac[module_idP]->common_channels[CC_id].RA_template[i].generate_rar = 0; - break; + RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *) dlsch_buffer; + uint8_t *rar = (uint8_t *) (dlsch_buffer + 1); + + + // subheader fixed + rarh->E = 0; // First and last RAR + rarh->T = 1; // 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader + rarh->RAPID = ra->preamble_index; // Respond to Preamble 0 only for the moment + rar[4] = (uint8_t) (ra->rnti >> 8); + rar[5] = (uint8_t) (ra->rnti & 0xff); + //ra->timing_offset = 0; + ra->timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps + rar[0] = (uint8_t) (ra->timing_offset >> (2 + 4)); // 7 MSBs of timing advance + divide by 4 + rar[1] = (uint8_t) (ra->timing_offset << (4 - 2)) & 0xf0; // 4 LSBs of timing advance + divide by 4 + ra->msg3_first_rb = 6; + ra->msg3_nb_rb = 1; + uint16_t rballoc = mac_computeRIV(N_RB_UL, ra->msg3_first_rb, ra->msg3_nb_rb); // first PRB only for UL Grant + rar[1] |= (rballoc >> 7) & 7; // Hopping = 0 (bit 3), 3 MSBs of rballoc + rar[2] = ((uint8_t) (rballoc & 0xff)) << 1; // 7 LSBs of rballoc + ra->msg3_mcs = 10; + ra->msg3_TPC = 3; + ra->msg3_ULdelay = 0; + ra->msg3_cqireq = 0; + rar[2] |= ((ra->msg3_mcs & 0x8) >> 3); // mcs 10 + rar[3] = + (((ra->msg3_mcs & 0x7) << 5)) | ((ra->msg3_TPC & 7) << 2) | + ((ra->msg3_ULdelay & 1) << 1) | (ra->msg3_cqireq & 1); + + if (opt_enabled) { + trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1, + RC.mac[module_idP]->frame, RC.mac[module_idP]->subframe, + 0, 0); + LOG_D(OPT, + "[eNB %d][RAPROC] CC_id %d RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", + module_idP, CC_id, frameP, ra->rnti, rarh->RAPID, + input_buffer_length); } - } - RA_template = &RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx]; - - //DevAssert( ra_idx != -1 ); - if (ra_idx==-1) - return(0); - - // subheader fixed - rarh->E = 0; // First and last RAR - rarh->T = 1; // 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader - rarh->RAPID = RA_template->preamble_index; // Respond to Preamble 0 only for the moment - rar[4] = (uint8_t)(RA_template->rnti>>8); - rar[5] = (uint8_t)(RA_template->rnti&0xff); - //RA_template->timing_offset = 0; - RA_template->timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps - rar[0] = (uint8_t)(RA_template->timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4 - rar[1] = (uint8_t)(RA_template->timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4 - RA_template->msg3_first_rb=6; - RA_template->msg3_nb_rb=1; - uint16_t rballoc = mac_computeRIV(N_RB_UL,RA_template->msg3_first_rb,RA_template->msg3_nb_rb); // first PRB only for UL Grant - rar[1] |= (rballoc>>7)&7; // Hopping = 0 (bit 3), 3 MSBs of rballoc - rar[2] = ((uint8_t)(rballoc&0xff))<<1; // 7 LSBs of rballoc - RA_template->msg3_mcs = 10; - RA_template->msg3_TPC = 3; - RA_template->msg3_ULdelay = 0; - RA_template->msg3_cqireq = 0; - rar[2] |= ((RA_template->msg3_mcs&0x8)>>3); // mcs 10 - rar[3] = (((RA_template->msg3_mcs&0x7)<<5)) | ((RA_template->msg3_TPC&7)<<2) | ((RA_template->msg3_ULdelay&1)<<1) | (RA_template->msg3_cqireq&1); - - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Generating RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ra_idx %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n", - module_idP, CC_id, - frameP, - *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], - ra_idx, - RA_template->rnti, - rarh->RAPID,RC.mac[module_idP]->common_channels[CC_id].RA_template[0].preamble_index, - RA_template->timing_offset); - if (opt_enabled) { - trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1, - RC.mac[module_idP]->frame, RC.mac[module_idP]->subframe, 0, 0); - LOG_D(OPT,"[eNB %d][RAPROC] CC_id %d RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", - module_idP, CC_id, frameP, RA_template->rnti, - rarh->RAPID, input_buffer_length); - } - - return(RA_template->rnti); + return (ra->rnti); } #ifdef Rel14 //------------------------------------------------------------------------------ -unsigned short fill_rar_br(eNB_MAC_INST *eNB, - int CC_id, - RA_TEMPLATE *RA_template, - const frame_t frameP, - const sub_frame_t subframeP, - uint8_t* const dlsch_buffer, - const uint8_t ce_level -) +unsigned short +fill_rar_br(eNB_MAC_INST * eNB, + int CC_id, + RA_t * ra, + const frame_t frameP, + const sub_frame_t subframeP, + uint8_t * const dlsch_buffer, const uint8_t ce_level) //------------------------------------------------------------------------------ { - RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; - COMMON_channels_t *cc = &eNB->common_channels[CC_id]; - uint8_t *rar = (uint8_t *)(dlsch_buffer+1); - // uint8_t nb,reps; - uint8_t rballoc; - uint8_t mcs,TPC,ULdelay,cqireq; - int input_buffer_length; - + RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *) dlsch_buffer; + COMMON_channels_t *cc = &eNB->common_channels[CC_id]; + uint8_t *rar = (uint8_t *) (dlsch_buffer + 1); + // uint8_t nb,reps; + uint8_t rballoc; + uint8_t mcs, TPC, ULdelay, cqireq; + int input_buffer_length; - AssertFatal(RA_template != NULL, "RA is null \n"); - // subheader fixed - rarh->E = 0; // First and last RAR - rarh->T = 1; // 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader - rarh->RAPID = RA_template->preamble_index; // Respond to Preamble 0 only for the moment - RA_template->timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps - rar[0] = (uint8_t)(RA_template->timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4 - rar[1] = (uint8_t)(RA_template->timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4 + AssertFatal(ra != NULL, "RA is null \n"); - int N_NB_index; + // subheader fixed + rarh->E = 0; // First and last RAR + rarh->T = 1; // 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader + rarh->RAPID = ra->preamble_index; // Respond to Preamble 0 only for the moment + ra->timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps + rar[0] = (uint8_t) (ra->timing_offset >> (2 + 4)); // 7 MSBs of timing advance + divide by 4 + rar[1] = (uint8_t) (ra->timing_offset << (4 - 2)) & 0xf0; // 4 LSBs of timing advance + divide by 4 - AssertFatal(1==0,"RAR for BL/CE Still to be finished ...\n"); + int N_NB_index; - // Copy the Msg2 narrowband - RA_template->msg34_narrowband = RA_template->msg2_narrowband; + AssertFatal(1 == 0, "RAR for BL/CE Still to be finished ...\n"); - if (ce_level<2) { //CE Level 0,1, CEmodeA - input_buffer_length =6; + // Copy the Msg2 narrowband + ra->msg34_narrowband = ra->msg2_narrowband; - N_NB_index = get_numnarrowbandbits(cc->mib->message.dl_Bandwidth); + if (ce_level < 2) { //CE Level 0,1, CEmodeA + input_buffer_length = 6; - rar[4] = (uint8_t)(RA_template->rnti>>8); - rar[5] = (uint8_t)(RA_template->rnti&0xff); - //cc->RA_template[ra_idx].timing_offset = 0; - // nb = 0; - rballoc = mac_computeRIV(6,1+ce_level,1); // one PRB only for UL Grant in position 1+ce_level within Narrowband - rar[1] |= (rballoc&15)<<(4-N_NB_index); // Hopping = 0 (bit 3), 3 MSBs of rballoc + N_NB_index = get_numnarrowbandbits(cc->mib->message.dl_Bandwidth); - // reps = 4; - mcs = 7; - TPC = 3; // no power increase - ULdelay = 0; - cqireq = 0; - rar[2] |= ((mcs&0x8)>>3); // mcs 10 - rar[3] = (((mcs&0x7)<<5)) | ((TPC&7)<<2) | ((ULdelay&1)<<1) | (cqireq&1); - } - else { // CE level 2,3 => CEModeB + rar[4] = (uint8_t) (ra->rnti >> 8); + rar[5] = (uint8_t) (ra->rnti & 0xff); + //cc->ra[ra_idx].timing_offset = 0; + // nb = 0; + rballoc = mac_computeRIV(6, 1 + ce_level, 1); // one PRB only for UL Grant in position 1+ce_level within Narrowband + rar[1] |= (rballoc & 15) << (4 - N_NB_index); // Hopping = 0 (bit 3), 3 MSBs of rballoc - input_buffer_length =5; + // reps = 4; + mcs = 7; + TPC = 3; // no power increase + ULdelay = 0; + cqireq = 0; + rar[2] |= ((mcs & 0x8) >> 3); // mcs 10 + rar[3] = + (((mcs & 0x7) << 5)) | ((TPC & 7) << 2) | ((ULdelay & 1) << 1) + | (cqireq & 1); + } else { // CE level 2,3 => CEModeB - rar[3] = (uint8_t)(RA_template->rnti>>8); - rar[4] = (uint8_t)(RA_template->rnti&0xff); - } - LOG_D(MAC,"[RAPROC] Frame %d Generating RAR BR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ce_level %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n", - frameP, - *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], - ce_level, - RA_template->rnti, - rarh->RAPID,RA_template->preamble_index, - RA_template->timing_offset); + input_buffer_length = 5; - if (opt_enabled) { - trace_pdu(1, dlsch_buffer, input_buffer_length, eNB->Mod_id, 2, 1, - eNB->frame, eNB->subframe, 0, 0); - LOG_D(OPT,"[RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", - frameP, RA_template->rnti, - rarh->RAPID, input_buffer_length); - } + rar[3] = (uint8_t) (ra->rnti >> 8); + rar[4] = (uint8_t) (ra->rnti & 0xff); + } + LOG_D(MAC, + "[RAPROC] Frame %d Generating RAR BR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ce_level %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n", + frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], + rar[4], rar[5], ce_level, ra->rnti, rarh->RAPID, + ra->preamble_index, ra->timing_offset); + + if (opt_enabled) { + trace_pdu(1, dlsch_buffer, input_buffer_length, eNB->Mod_id, 2, 1, + eNB->frame, eNB->subframe, 0, 0); + LOG_D(OPT, + "[RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", + frameP, ra->rnti, rarh->RAPID, input_buffer_length); + } - return(RA_template->rnti); + return (ra->rnti); } #endif -//------------------------------------------------------------------------------ -uint16_t -ue_process_rar( - const module_id_t module_idP, - const int CC_id, - const frame_t frameP, - const rnti_t ra_rnti, - uint8_t* const dlsch_buffer, - rnti_t* const t_crnti, - const uint8_t preamble_index, - uint8_t* selected_rar_buffer // output argument for storing the selected RAR header and RAR payload -) -//------------------------------------------------------------------------------ -{ - uint16_t ret = 0; // return value - - RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; - // RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1); - uint8_t *rar = (uint8_t *)(dlsch_buffer+1); - - // get the last RAR payload for working with CMW500 - uint8_t n_rarpy = 0; // number of RAR payloads - uint8_t n_rarh = 0; // number of MAC RAR subheaders - uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs - while (1) { - n_rarh++; - if (rarh->T == 1) { - n_rarpy++; - LOG_D(MAC, "RAPID %d\n", rarh->RAPID); - } - - if (rarh->RAPID == preamble_index) { - LOG_D(PHY, "Found RAR with the intended RAPID %d\n", rarh->RAPID); - rar = (uint8_t *)(dlsch_buffer+n_rarh + (n_rarpy-1)*6); - break; - } - - if (abs((int)rarh->RAPID - (int)preamble_index) < abs((int)best_rx_rapid - (int)preamble_index)) { - best_rx_rapid = rarh->RAPID; - rar = (uint8_t *)(dlsch_buffer+n_rarh + (n_rarpy-1)*6); - } - - if (rarh->E == 0) { - LOG_I(PHY, "No RAR found with the intended RAPID. The closest RAPID in all RARs is %d\n", best_rx_rapid); - break; - } else { - rarh++; - } - }; - LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", n_rarh, n_rarpy); - - if (CC_id>0) { - LOG_W(MAC,"Should not have received RAR on secondary CCs! \n"); - return(0xffff); - } - - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",module_idP,frameP, - *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], - rarh->RAPID,preamble_index); -#ifdef DEBUG_RAR - LOG_D(MAC,"[UE %d][RAPROC] rarh->E %d\n",module_idP,rarh->E); - LOG_D(MAC,"[UE %d][RAPROC] rarh->T %d\n",module_idP,rarh->T); - LOG_D(MAC,"[UE %d][RAPROC] rarh->RAPID %d\n",module_idP,rarh->RAPID); - - // LOG_I(MAC,"[UE %d][RAPROC] rar->R %d\n",module_idP,rar->R); - LOG_D(MAC,"[UE %d][RAPROC] rar->Timing_Advance_Command %d\n",module_idP,(((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); - // LOG_I(MAC,"[UE %d][RAPROC] rar->hopping_flag %d\n",module_idP,rar->hopping_flag); - // LOG_I(MAC,"[UE %d][RAPROC] rar->rb_alloc %d\n",module_idP,rar->rb_alloc); - // LOG_I(MAC,"[UE %d][RAPROC] rar->mcs %d\n",module_idP,rar->mcs); - // LOG_I(MAC,"[UE %d][RAPROC] rar->TPC %d\n",module_idP,rar->TPC); - // LOG_I(MAC,"[UE %d][RAPROC] rar->UL_delay %d\n",module_idP,rar->UL_delay); - // LOG_I(MAC,"[UE %d][RAPROC] rar->cqi_req %d\n",module_idP,rar->cqi_req); - LOG_D(MAC,"[UE %d][RAPROC] rar->t_crnti %x\n",module_idP,(uint16_t)rar[5]+(rar[4]<<8)); -#endif - - if (opt_enabled) { - LOG_D(OPT,"[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n", - module_idP, CC_id, frameP, ra_rnti); - trace_pdu(1, (uint8_t*)dlsch_buffer, n_rarh + n_rarpy*6, module_idP, 2, ra_rnti, - UE_mac_inst[module_idP].rxFrame, UE_mac_inst[module_idP].rxSubframe, 0, 0); - } - - if (preamble_index == rarh->RAPID) { - *t_crnti = (uint16_t)rar[5]+(rar[4]<<8);//rar->t_crnti; - UE_mac_inst[module_idP].crnti = *t_crnti;//rar->t_crnti; - //return(rar->Timing_Advance_Command); - ret = ((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); - } else { - UE_mac_inst[module_idP].crnti=0; - ret = (0xffff); - } - - // move the selected RAR to the front of the RA_PDSCH buffer - memcpy(selected_rar_buffer+0, (uint8_t*)rarh, 1); - memcpy(selected_rar_buffer+1, (uint8_t*)rar , 6); - - return ret; - -} diff --git a/openair2/LAYER2/MAC/rar_tools_ue.c b/openair2/LAYER2/MAC/rar_tools_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..ab193c7a66b2422473dd208af125fc815c4a7259 --- /dev/null +++ b/openair2/LAYER2/MAC/rar_tools_ue.c @@ -0,0 +1,143 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file rar_tools.c + * \brief random access tools + * \author Raymond Knopp and navid nikaein + * \date 2011 - 2014 + * \version 1.0 + * @ingroup _mac + + */ + +#include "defs.h" +#include "proto.h" +#include "extern.h" +#include "SIMULATION/TOOLS/defs.h" +#include "UTIL/LOG/log.h" +#include "OCG.h" +#include "OCG_extern.h" +#include "UTIL/OPT/opt.h" +#include "common/ran_context.h" + +#define DEBUG_RAR + +//------------------------------------------------------------------------------ +uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const frame_t frameP, const rnti_t ra_rnti, uint8_t * const dlsch_buffer, rnti_t * const t_crnti, const uint8_t preamble_index, uint8_t * selected_rar_buffer // output argument for storing the selected RAR header and RAR payload + ) +//------------------------------------------------------------------------------ +{ + uint16_t ret = 0; // return value + + RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *) dlsch_buffer; + // RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1); + uint8_t *rar = (uint8_t *) (dlsch_buffer + 1); + + // get the last RAR payload for working with CMW500 + uint8_t n_rarpy = 0; // number of RAR payloads + uint8_t n_rarh = 0; // number of MAC RAR subheaders + uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs + while (1) { + n_rarh++; + if (rarh->T == 1) { + n_rarpy++; + LOG_D(MAC, "RAPID %d\n", rarh->RAPID); + } + + if (rarh->RAPID == preamble_index) { + LOG_D(PHY, "Found RAR with the intended RAPID %d\n", + rarh->RAPID); + rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6); + break; + } + + if (abs((int) rarh->RAPID - (int) preamble_index) < + abs((int) best_rx_rapid - (int) preamble_index)) { + best_rx_rapid = rarh->RAPID; + rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6); + } + + if (rarh->E == 0) { + LOG_I(PHY, + "No RAR found with the intended RAPID. The closest RAPID in all RARs is %d\n", + best_rx_rapid); + break; + } else { + rarh++; + } + }; + LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", + n_rarh, n_rarpy); + + if (CC_id > 0) { + LOG_W(MAC, "Should not have received RAR on secondary CCs! \n"); + return (0xffff); + } + + LOG_I(MAC, + "[eNB %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", + module_idP, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], + rar[3], rar[4], rar[5], rarh->RAPID, preamble_index); +#ifdef DEBUG_RAR + LOG_D(MAC, "[UE %d][RAPROC] rarh->E %d\n", module_idP, rarh->E); + LOG_D(MAC, "[UE %d][RAPROC] rarh->T %d\n", module_idP, rarh->T); + LOG_D(MAC, "[UE %d][RAPROC] rarh->RAPID %d\n", module_idP, + rarh->RAPID); + + // LOG_I(MAC,"[UE %d][RAPROC] rar->R %d\n",module_idP,rar->R); + LOG_D(MAC, "[UE %d][RAPROC] rar->Timing_Advance_Command %d\n", + module_idP, (((uint16_t) (rar[0] & 0x7f)) << 4) + (rar[1] >> 4)); + // LOG_I(MAC,"[UE %d][RAPROC] rar->hopping_flag %d\n",module_idP,rar->hopping_flag); + // LOG_I(MAC,"[UE %d][RAPROC] rar->rb_alloc %d\n",module_idP,rar->rb_alloc); + // LOG_I(MAC,"[UE %d][RAPROC] rar->mcs %d\n",module_idP,rar->mcs); + // LOG_I(MAC,"[UE %d][RAPROC] rar->TPC %d\n",module_idP,rar->TPC); + // LOG_I(MAC,"[UE %d][RAPROC] rar->UL_delay %d\n",module_idP,rar->UL_delay); + // LOG_I(MAC,"[UE %d][RAPROC] rar->cqi_req %d\n",module_idP,rar->cqi_req); + LOG_D(MAC, "[UE %d][RAPROC] rar->t_crnti %x\n", module_idP, + (uint16_t) rar[5] + (rar[4] << 8)); +#endif + + if (opt_enabled) { + LOG_D(OPT, + "[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n", + module_idP, CC_id, frameP, ra_rnti); + trace_pdu(1, (uint8_t *) dlsch_buffer, n_rarh + n_rarpy * 6, + module_idP, 2, ra_rnti, UE_mac_inst[module_idP].rxFrame, + UE_mac_inst[module_idP].rxSubframe, 0, 0); + } + + if (preamble_index == rarh->RAPID) { + *t_crnti = (uint16_t) rar[5] + (rar[4] << 8); //rar->t_crnti; + UE_mac_inst[module_idP].crnti = *t_crnti; //rar->t_crnti; + //return(rar->Timing_Advance_Command); + ret = ((((uint16_t) (rar[0] & 0x7f)) << 4) + (rar[1] >> 4)); + } else { + UE_mac_inst[module_idP].crnti = 0; + ret = (0xffff); + } + + // move the selected RAR to the front of the RA_PDSCH buffer + memcpy(selected_rar_buffer + 0, (uint8_t *) rarh, 1); + memcpy(selected_rar_buffer + 1, (uint8_t *) rar, 6); + + return ret; + +} diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 4c285edbfc39b11d4103c2b132752468e56fd9ce..2687f6eb263bd635532899300401f556e440eb47 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -37,10 +37,10 @@ #include "defs.h" #include "proto.h" #ifdef PHY_EMUL -# include "SIMULATION/PHY_EMULATION/impl_defs.h" +#include "SIMULATION/PHY_EMULATION/impl_defs.h" #else -# include "SCHED/defs.h" -# include "PHY/impl_defs_top.h" +#include "SCHED/defs.h" +#include "PHY/impl_defs_top.h" #endif #include "PHY_INTERFACE/extern.h" #include "COMMON/mac_rrc_primitives.h" @@ -55,17 +55,17 @@ #include "openair2/PHY_INTERFACE/phy_stub_UE.h" #ifdef PHY_EMUL -# include "SIMULATION/simulation_defs.h" +#include "SIMULATION/simulation_defs.h" #endif #include "pdcp.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" +#include "intertask_interface.h" #endif #include "assertions.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/defs.h" // for taus #define DEBUG_HEADER_PARSING 1 #define ENABLE_MAC_PAYLOAD_DEBUG 1 @@ -82,61 +82,81 @@ extern uint8_t nfapi_mode; #define msg debug_msg #endif */ + mapping BSR_names[] = { - {"NONE", 0}, - {"SHORT BSR", 1}, - {"TRUNCATED BSR", 2}, - {"LONG BSR", 3}, - {"PADDING BSR", 4}, - {NULL, -1} + {"NONE", 0}, + {"SHORT BSR", 1}, + {"TRUNCATED BSR", 2}, + {"LONG BSR", 3}, + {"PADDING BSR", 4}, + {NULL, -1} }; void ue_init_mac(module_id_t module_idP) { - int i; - // default values as deined in 36.331 sec 9.2.2 - LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); - //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL; - UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer= RetxBSR_Timer_r12_sf10240; - UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer=PeriodicBSR_Timer_r12_infinity; - UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; - UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; - UE_mac_inst[module_idP].PHR_state = MAC_MainConfig__phr_Config_PR_setup; - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer=0; - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; - UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; - UE_mac_inst[module_idP].scheduling_info.ttiBundling=0; - UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10=0; - UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10=0; - UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; - UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; - // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW. - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; - UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; - - UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); - UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange); - UE_mac_inst[module_idP].PHR_reporting_active = 0; - - for (i=0; i < MAX_NUM_LCID; i++) { - LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i); - UE_mac_inst[module_idP].scheduling_info.Bj[i]=-1; - UE_mac_inst[module_idP].scheduling_info.bucket_size[i]=-1; - - if (i < DTCH) { // initilize all control channels lcgid to 0 - UE_mac_inst[module_idP].scheduling_info.LCGID[i]=0; - } else { // initialize all the data channels lcgid to 1 - UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; - } - - UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=LCID_EMPTY; - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0; - } + + int i; + // default values as deined in 36.331 sec 9.2.2 + LOG_I(MAC, "[UE%d] Applying default macMainConfig\n", module_idP); + //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL; + UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer = + RetxBSR_Timer_r12_sf10240; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer = + PeriodicBSR_Timer_r12_infinity; + UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer = + MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer = + MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; + UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = + MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; + UE_mac_inst[module_idP].PHR_state = + MAC_MainConfig__phr_Config_PR_setup; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer = 0; + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running = 0; + UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx = + MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + UE_mac_inst[module_idP].scheduling_info.ttiBundling = 0; + UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 = 0; + UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10 = 0; + UE_mac_inst[module_idP].scheduling_info.drx_config = NULL; + UE_mac_inst[module_idP].scheduling_info.phr_config = NULL; + // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW. + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; + + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = + get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.periodicPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = + get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.prohibitPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = + get_db_dl_PathlossChange(UE_mac_inst[module_idP]. + scheduling_info.PathlossChange); + UE_mac_inst[module_idP].PHR_reporting_active = 0; + + for (i = 0; i < MAX_NUM_LCID; i++) { + LOG_D(MAC, + "[UE%d] Applying default logical channel config for LCGID %d\n", + module_idP, i); + UE_mac_inst[module_idP].scheduling_info.Bj[i] = -1; + UE_mac_inst[module_idP].scheduling_info.bucket_size[i] = -1; + + if (i < DTCH) { // initilize all control channels lcgid to 0 + UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 0; + } else { // initialize all the data channels lcgid to 1 + UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 1; + } + + UE_mac_inst[module_idP].scheduling_info.LCID_status[i] = + LCID_EMPTY; + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0; + } if(nfapi_mode == 3) { pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL); @@ -150,299 +170,357 @@ void ue_init_mac(module_id_t module_idP) #ifdef CBA - for (i=0; i <NUM_MAX_CBA_GROUP; i++) { - UE_mac_inst[module_idP].cba_last_access[i]= round(uniform_rngen(1,30)); - } + for (i = 0; i < NUM_MAX_CBA_GROUP; i++) { + UE_mac_inst[module_idP].cba_last_access[i] = + round(uniform_rngen(1, 30)); + } #endif } unsigned char *parse_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { - unsigned char not_done=1,num_ces=0,num_cont_res = 0,num_padding = 0,num_sdus=0,lcid, num_sdu_cnt; - unsigned char *mac_header_ptr = mac_header; - unsigned short length,ce_len=0; - - while (not_done==1) { - - if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) { - // printf("E=0\n"); - not_done = 0; - } - - lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; - - if (lcid < UE_CONT_RES) { - //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); - if (not_done==0) {// last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length-(mac_header_ptr-mac_header)-ce_len; - - for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) { - length -= rx_lengths[num_sdu_cnt]; - } - } else { - if (((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) { - length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); - mac_header_ptr += 3; + unsigned char not_done = 1, num_ces = 0, num_cont_res = + 0, num_padding = 0, num_sdus = 0, lcid, num_sdu_cnt; + unsigned char *mac_header_ptr = mac_header; + unsigned short length, ce_len = 0; + + while (not_done == 1) { + + if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { + // printf("E=0\n"); + not_done = 0; + } + + lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; + + if (lcid < UE_CONT_RES) { + //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = + tb_length - (mac_header_ptr - mac_header) - ce_len; + + for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus; + num_sdu_cnt++) { + length -= rx_lengths[num_sdu_cnt]; + } + } else { + if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { + length = + ((((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_MSB & 0x7f) + << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_LSB & 0xff); + mac_header_ptr += 3; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] parse long sdu, size %x \n",length); + LOG_D(MAC, "[UE] parse long sdu, size %x \n", length); #endif - } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { - length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; - mac_header_ptr += 2; - } - } + } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { + length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; + mac_header_ptr += 2; + } + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] sdu %d lcid %d length %d (offset now %ld)\n", - num_sdus,lcid,length,mac_header_ptr-mac_header); + LOG_D(MAC, "[UE] sdu %d lcid %d length %d (offset now %ld)\n", + num_sdus, lcid, length, mac_header_ptr - mac_header); #endif - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } else { // This is a control element subheader - if (lcid == SHORT_PADDING) { - num_padding ++; - mac_header_ptr++; - } else { - rx_ces[num_ces] = lcid; - num_ces++; - mac_header_ptr ++; - - if (lcid==TIMING_ADV_CMD) { - ce_len++; - } else if (lcid==UE_CONT_RES) { - - // FNA: check MAC Header is one of thoses defined in Annex B of 36.321 - // Check there is only 1 Contention Resolution - if (num_cont_res) { - LOG_W(MAC,"[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n"); - // exit parsing - return NULL; - - } - - // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader - if ((not_done == 0) && ((num_sdus) || (num_ces > 1) || (num_padding))) { - LOG_W(MAC,"[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n",num_ces,num_sdus,num_padding); - // exit parsing - return NULL; - } - num_cont_res ++; - ce_len+=6; - } - } + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; + } else { // This is a control element subheader + if (lcid == SHORT_PADDING) { + num_padding++; + mac_header_ptr++; + } else { + rx_ces[num_ces] = lcid; + num_ces++; + mac_header_ptr++; + + if (lcid == TIMING_ADV_CMD) { + ce_len++; + } else if (lcid == UE_CONT_RES) { + + // FNA: check MAC Header is one of thoses defined in Annex B of 36.321 + // Check there is only 1 Contention Resolution + if (num_cont_res) { + LOG_W(MAC, + "[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n"); + // exit parsing + return NULL; + + } + // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader + if ((not_done == 0) + && ((num_sdus) || (num_ces > 1) || (num_padding))) { + LOG_W(MAC, + "[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n", + num_ces, num_sdus, num_padding); + // exit parsing + return NULL; + } + num_cont_res++; + ce_len += 6; + } + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] ce %d lcid %d (offset now %ld)\n",num_ces,lcid,mac_header_ptr-mac_header); + LOG_D(MAC, "[UE] ce %d lcid %d (offset now %ld)\n", num_ces, + lcid, mac_header_ptr - mac_header); #endif + } } - } - *num_ce = num_ces; - *num_sdu = num_sdus; + *num_ce = num_ces; + *num_sdu = num_sdus; - return(mac_header_ptr); + return (mac_header_ptr); } -uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_id,uint16_t rnti, sub_frame_t subframe) +uint32_t +ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, + uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe) { - // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti - // int MGL=6;// measurement gap length in ms - int MGRP = 0; // measurement gap repetition period in ms - int gapOffset = -1; - int T = 0; - - DevCheck(module_idP < (int)NB_UE_INST, module_idP, NB_UE_INST, 0); - - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); - - // determin the measurement gap - if (UE_mac_inst[module_idP].measGapConfig !=NULL) { - if (UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { - MGRP= 40; - gapOffset= UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.choice.gp0; - } else if (UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1) { - MGRP= 80; - gapOffset= UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.choice.gp1; - } else { - LOG_W(MAC, "Measurement GAP offset is unknown\n"); - } - - T=MGRP/10; - DevAssert( T != 0 ); - - //check the measurement gap and sr prohibit timer - if ((subframe == gapOffset %10) && ((frameP %T) == (floor(gapOffset/10))) - && (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running ==0)) { - UE_mac_inst[module_idP].scheduling_info.SR_pending=1; - return(0); + // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti + // int MGL=6;// measurement gap length in ms + int MGRP = 0; // measurement gap repetition period in ms + int gapOffset = -1; + int T = 0; + + DevCheck(module_idP < (int) NB_UE_INST, module_idP, NB_UE_INST, 0); + + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + + // determin the measurement gap + if (UE_mac_inst[module_idP].measGapConfig != NULL) { + if (UE_mac_inst[module_idP].measGapConfig->choice.setup. + gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0) { + MGRP = 40; + gapOffset = + UE_mac_inst[module_idP].measGapConfig->choice. + setup.gapOffset.choice.gp0; + } else if (UE_mac_inst[module_idP].measGapConfig->choice. + setup.gapOffset.present == + MeasGapConfig__setup__gapOffset_PR_gp1) { + MGRP = 80; + gapOffset = + UE_mac_inst[module_idP].measGapConfig->choice. + setup.gapOffset.choice.gp1; + } else { + LOG_W(MAC, "Measurement GAP offset is unknown\n"); + } + + T = MGRP / 10; + DevAssert(T != 0); + + //check the measurement gap and sr prohibit timer + if ((subframe == gapOffset % 10) + && ((frameP % T) == (floor(gapOffset / 10))) + && (UE_mac_inst[module_idP]. + scheduling_info.sr_ProhibitTimer_Running == 0)) { + UE_mac_inst[module_idP].scheduling_info.SR_pending = 1; + return (0); + } } - } - if ((UE_mac_inst[module_idP].physicalConfigDedicated != NULL) && - (UE_mac_inst[module_idP].scheduling_info.SR_pending==1) && - (UE_mac_inst[module_idP].scheduling_info.SR_COUNTER < - (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax))) - ) { - LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", - module_idP,rnti,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, - (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)), - UE_mac_inst[module_idP].scheduling_info.SR_pending); - - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER++; - - // start the sr-prohibittimer : rel 9 and above - if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--; - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=1; + if ((UE_mac_inst[module_idP].physicalConfigDedicated != NULL) && + (UE_mac_inst[module_idP].scheduling_info.SR_pending == 1) && + (UE_mac_inst[module_idP].scheduling_info.SR_COUNTER < + (1 << + (2 + + UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->choice.setup. + dsr_TransMax)))) { + LOG_D(MAC, + "[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", + module_idP, rnti, frameP, subframe, + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, + (1 << + (2 + + UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->choice. + setup.dsr_TransMax)), + UE_mac_inst[module_idP].scheduling_info.SR_pending); + + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER++; + + // start the sr-prohibittimer : rel 9 and above + if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--; + UE_mac_inst[module_idP].scheduling_info. + sr_ProhibitTimer_Running = 1; + } else { + UE_mac_inst[module_idP].scheduling_info. + sr_ProhibitTimer_Running = 0; + } + + LOG_D(MAC, + "[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", + module_idP, rnti, frameP, subframe, + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, + (1 << + (2 + + UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->choice. + setup.dsr_TransMax)), + UE_mac_inst[module_idP].scheduling_info.SR_pending); + + //UE_mac_inst[module_idP].ul_active =1; + return (1); //instruct phy to signal SR } else { - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; - } - - LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", - module_idP,rnti,frameP,subframe, - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, - (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)), - UE_mac_inst[module_idP].scheduling_info.SR_pending); - - //UE_mac_inst[module_idP].ul_active =1; - return(1); //instruct phy to signal SR - } else { - // notify RRC to relase PUCCH/SRS - // clear any configured dl/ul - // initiate RA - if (UE_mac_inst[module_idP].scheduling_info.SR_pending){ - // release all pucch resource - UE_mac_inst[module_idP].physicalConfigDedicated = NULL; - UE_mac_inst[module_idP].ul_active=0; - UE_mac_inst[module_idP].BSR_reporting_active=BSR_TRIGGER_NONE; - - LOG_I(MAC,"[UE %d] Release all SRs \n", module_idP); - } - UE_mac_inst[module_idP].scheduling_info.SR_pending=0; - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - return(0); - } + // notify RRC to relase PUCCH/SRS + // clear any configured dl/ul + // initiate RA + if (UE_mac_inst[module_idP].scheduling_info.SR_pending) { + // release all pucch resource + UE_mac_inst[module_idP].physicalConfigDedicated = NULL; + UE_mac_inst[module_idP].ul_active = 0; + UE_mac_inst[module_idP].BSR_reporting_active = + BSR_TRIGGER_NONE; + + LOG_I(MAC, "[UE %d] Release all SRs \n", module_idP); + } + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; + return (0); + } } //------------------------------------------------------------------------------ void -ue_send_sdu( - module_id_t module_idP, +ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, - sub_frame_t subframeP, - uint8_t* sdu, - uint16_t sdu_len, - uint8_t eNB_index -) + sub_frame_t subframeP, + uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index) //------------------------------------------------------------------------------ { - unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; - unsigned char rx_lcids[NB_RB_MAX]; - unsigned short rx_lengths[NB_RB_MAX]; - unsigned char *tx_sdu; + unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr; + unsigned char rx_lcids[NB_RB_MAX]; + unsigned short rx_lengths[NB_RB_MAX]; + unsigned char *tx_sdu; #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); + start_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN); - LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]); - if (opt_enabled) { - trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti, - frameP, subframeP, 0, 0); - LOG_D(OPT,"[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", - module_idP, frameP, UE_mac_inst[module_idP].crnti, sdu_len); - } + //LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]); - payload_ptr = parse_header(sdu,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_len); + if (opt_enabled) { + trace_pdu(1, sdu, sdu_len, module_idP, 3, + UE_mac_inst[module_idP].crnti, frameP, subframeP, 0, 0); + LOG_D(OPT, + "[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, UE_mac_inst[module_idP].crnti, sdu_len); + } + + payload_ptr = + parse_header(sdu, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, + sdu_len); #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n",module_idP, - frameP,eNB_index,num_ce,num_sdu); + LOG_D(MAC, + "[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n", + module_idP, frameP, eNB_index, num_ce, num_sdu); #endif #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC,"[UE %d] First 32 bytes of DLSCH : \n", module_idP); + LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); - for (i=0; i<32; i++) { - LOG_T(MAC,"%x.",sdu[i]); - } + for (i = 0; i < 32; i++) { + LOG_T(MAC, "%x.", sdu[i]); + } - LOG_T(MAC,"\n"); + LOG_T(MAC, "\n"); #endif - if (payload_ptr != NULL) { - - for (i=0; i<num_ce; i++) { - // printf("ce %d : %d\n",i,rx_ces[i]); - switch (rx_ces[i]) { - case UE_CONT_RES: - - LOG_I(MAC,"[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", - module_idP,frameP,payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4],payload_ptr[5]); - - if (UE_mac_inst[module_idP].RA_active == 1) { - LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n", module_idP, frameP); - UE_mac_inst[module_idP].RA_active=0; - // check if RA procedure has finished completely (no contention) - tx_sdu = &UE_mac_inst[module_idP].CCCH_pdu.payload[3]; - - //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits) - // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT) - for (i=0; i<6; i++) - if (tx_sdu[i] != payload_ptr[i]) { - LOG_E(MAC,"[UE %d][RAPROC] Contention detected, RA failed\n",module_idP); - if(nfapi_mode == 3) { // Panos: phy_stub mode - // Panos: Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to - // PRACH state. - UE_mac_inst[module_idP].UE_mode[eNB_index] = PRACH; - //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; - } - else { // Full stack mode - ra_failed(module_idP,CC_id,eNB_index); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); - return; - } - - LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n", module_idP, frameP); - UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; - - if(nfapi_mode == 3) // phy_stub mode - { - //Panos: Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH - UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH; - } - else { // Full stack mode - ra_succeeded(module_idP,CC_id,eNB_index); - } - } + if (payload_ptr != NULL) { + + for (i = 0; i < num_ce; i++) { + // printf("ce %d : %d\n",i,rx_ces[i]); + switch (rx_ces[i]) { + case UE_CONT_RES: + + LOG_I(MAC, + "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", + module_idP, frameP, payload_ptr[0], payload_ptr[1], + payload_ptr[2], payload_ptr[3], payload_ptr[4], + payload_ptr[5]); + + if (UE_mac_inst[module_idP].RA_active == 1) { + LOG_I(MAC, + "[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_active = 0; + // check if RA procedure has finished completely (no contention) + tx_sdu = &UE_mac_inst[module_idP].CCCH_pdu.payload[3]; + + //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits) + // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT) + for (i = 0; i < 6; i++) + if (tx_sdu[i] != payload_ptr[i]) { + LOG_E(MAC, + "[UE %d][RAPROC] Contention detected, RA failed\n", + module_idP); + if(nfapi_mode == 3) { // Panos: phy_stub mode + // Panos: Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to + // PRACH state. + UE_mac_inst[module_idP].UE_mode[eNB_index] = PRACH; + //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + } + else{ + ra_failed(module_idP, CC_id, eNB_index); + } + UE_mac_inst + [module_idP]. + RA_contention_resolution_timer_active = 0; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, + VCD_FUNCTION_OUT); + return; + } + + LOG_I(MAC, + "[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n", + module_idP, frameP); + UE_mac_inst + [module_idP]. + RA_contention_resolution_timer_active = 0; + if(nfapi_mode == 3) // phy_stub mode + { + //Panos: Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH + UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH; + } + else { // Full stack mode + ra_succeeded(module_idP,CC_id,eNB_index); + } + } - payload_ptr+=6; - break; + payload_ptr += 6; + break; - case TIMING_ADV_CMD: + case TIMING_ADV_CMD: #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] CE %d : UE Timing Advance : %d\n",i,payload_ptr[0]); + LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, + payload_ptr[0]); #endif - // Panos: Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct? + + // Panos: Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct? if (nfapi_mode!=3) { process_timing_advance(module_idP,CC_id,payload_ptr[0]); @@ -450,299 +528,300 @@ ue_send_sdu( payload_ptr++; break; - case DRX_CMD: + case DRX_CMD: #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] CE %d : UE DRX :",i); + LOG_D(MAC, "[UE] CE %d : UE DRX :", i); #endif - payload_ptr++; - break; - } - } + payload_ptr++; + break; + } + } - for (i=0; i<num_sdu; i++) { + for (i = 0; i < num_sdu; i++) { #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] SDU %d : LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]); + LOG_D(MAC, "[UE] SDU %d : LCID %d, length %d\n", i, + rx_lcids[i], rx_lengths[i]); #endif + if (rx_lcids[i] == CCCH) { - if (rx_lcids[i] == CCCH) { - - LOG_D(MAC,"[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n", - module_idP, - UE_mac_inst[module_idP].crnti, - frameP, - eNB_index, - rx_lengths[i]); + LOG_D(MAC, + "[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n", + module_idP, UE_mac_inst[module_idP].crnti, frameP, + eNB_index, rx_lengths[i]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - int j; + int j; - for (j=0; j<rx_lengths[i]; j++) { - LOG_T(MAC,"%x.",(uint8_t)payload_ptr[j]); - } + for (j = 0; j < rx_lengths[i]; j++) { + LOG_T(MAC, "%x.", (uint8_t) payload_ptr[j]); + } - LOG_T(MAC,"\n"); + LOG_T(MAC, "\n"); #endif - mac_rrc_data_ind(module_idP, - CC_id, - frameP,subframeP, - UE_mac_inst[module_idP].crnti, - CCCH, - (uint8_t*)payload_ptr, - rx_lengths[i], - ENB_FLAG_NO, - eNB_index, - 0); - - } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) { - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i],eNB_index,rx_lengths[i]); - mac_rlc_data_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - rx_lcids[i], - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - - } else if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1 )) { - - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frameP,rx_lcids[i], eNB_index,rx_lengths[i]); + + mac_rrc_data_ind_ue(module_idP, + CC_id, + frameP, subframeP, + UE_mac_inst[module_idP].crnti, + CCCH, + (uint8_t *) payload_ptr, + rx_lengths[i], eNB_index, 0); + + } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) { + LOG_D(MAC, + "[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", + module_idP, frameP, rx_lcids[i], eNB_index, + rx_lengths[i]); + mac_rlc_data_ind(module_idP, UE_mac_inst[module_idP].crnti, + eNB_index, frameP, ENB_FLAG_NO, + MBMS_FLAG_NO, rx_lcids[i], + (char *) payload_ptr, rx_lengths[i], 1, + NULL); + + } else if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1)) { + + LOG_D(MAC, + "[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", + module_idP, frameP, rx_lcids[i], eNB_index, + rx_lengths[i]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - int j; - for (j=0;j<rx_lengths[i];j++) - LOG_T(MAC,"%x.",(unsigned char)payload_ptr[j]); - LOG_T(MAC,"\n"); + int j; + for (j = 0; j < rx_lengths[i]; j++) + LOG_T(MAC, "%x.", (unsigned char) payload_ptr[j]); + LOG_T(MAC, "\n"); #endif - mac_rlc_data_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - rx_lcids[i], - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - } else { - LOG_E(MAC,"[UE %d] Frame %d : unknown LCID %d (eNB %d)\n", module_idP, frameP,rx_lcids[i], eNB_index); - } - payload_ptr+= rx_lengths[i]; - } - } // end if (payload_ptr != NULL) - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); + mac_rlc_data_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + rx_lcids[i], + (char *) payload_ptr, rx_lengths[i], 1, + NULL); + } else { + LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (eNB %d)\n", + module_idP, frameP, rx_lcids[i], eNB_index); + } + payload_ptr += rx_lengths[i]; + } + } // end if (payload_ptr != NULL) + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); + stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); #endif } -void ue_decode_si(module_id_t module_idP,int CC_id,frame_t frameP, uint8_t eNB_index, void *pdu,uint16_t len) +void +ue_decode_si(module_id_t module_idP, int CC_id, frame_t frameP, + uint8_t eNB_index, void *pdu, uint16_t len) { #if UE_TIMING_TRACE start_meas(&UE_mac_inst[module_idP].rx_si); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN); - - LOG_D(MAC,"[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",module_idP,frameP,BCCH,len); - - mac_rrc_data_ind(module_idP, - CC_id, - frameP,0, // unknown subframe - SI_RNTI, - BCCH, - (uint8_t *)pdu, - len, - ENB_FLAG_NO, - eNB_index, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN); + + LOG_D(MAC, "[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n", + module_idP, frameP, BCCH, len); + + mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe + SI_RNTI, + BCCH, (uint8_t *) pdu, len, eNB_index, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_si); + stop_meas(&UE_mac_inst[module_idP].rx_si); #endif - if (opt_enabled == 1) { - trace_pdu(0, - (uint8_t *)pdu, - len, - module_idP, - 4, - 0xffff, - UE_mac_inst[module_idP].rxFrame, - UE_mac_inst[module_idP].rxSubframe, - 0, - 0); - LOG_D(OPT,"[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, 0xffff, len); - } + if (opt_enabled == 1) { + trace_pdu(0, + (uint8_t *) pdu, + len, + module_idP, + 4, + 0xffff, + UE_mac_inst[module_idP].rxFrame, + UE_mac_inst[module_idP].rxSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, len); + } } -void ue_decode_p(module_id_t module_idP,int CC_id,frame_t frameP, uint8_t eNB_index, void *pdu,uint16_t len) +void +ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP, + uint8_t eNB_index, void *pdu, uint16_t len) { #if UE_TIMING_TRACE start_meas(&UE_mac_inst[module_idP].rx_p); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN); - - LOG_D(MAC,"[UE %d] Frame %d Sending Paging message to RRC (LCID Id %d,len %d)\n",module_idP,frameP,PCCH,len); - - mac_rrc_data_ind(module_idP, - CC_id, - frameP,0, // unknown subframe - P_RNTI, - PCCH, - (uint8_t *)pdu, - len, - ENB_FLAG_NO, - eNB_index, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN); + + LOG_D(MAC, + "[UE %d] Frame %d Sending Paging message to RRC (LCID Id %d,len %d)\n", + module_idP, frameP, PCCH, len); + + mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe + P_RNTI, + PCCH, (uint8_t *) pdu, len, eNB_index, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_p); + stop_meas(&UE_mac_inst[module_idP].rx_p); #endif - if (opt_enabled == 1) { - trace_pdu(0, - (uint8_t *)pdu, - len, - module_idP, - 4, - P_RNTI, - UE_mac_inst[module_idP].rxFrame, - UE_mac_inst[module_idP].rxSubframe, - 0, - 0); - LOG_D(OPT,"[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, P_RNTI, len); - } + if (opt_enabled == 1) { + trace_pdu(0, + (uint8_t *) pdu, + len, + module_idP, + 4, + P_RNTI, + UE_mac_inst[module_idP].rxFrame, + UE_mac_inst[module_idP].rxSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, P_RNTI, len); + } } #if defined(Rel10) || defined(Rel14) unsigned char *parse_mch_header(unsigned char *mac_header, - unsigned char *num_sdu, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) + unsigned char *num_sdu, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { - unsigned char not_done=1, num_sdus=0, lcid, i; - unsigned char *mac_header_ptr = mac_header; - unsigned short length; - - while (not_done == 1) { - if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) { - not_done = 0; - } - - lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; - - if (lcid < SHORT_PADDING) {// subheader for MSI, MCCH or MTCH - if (not_done == 0) { // last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length- (mac_header_ptr - mac_header); - - for (i=0; i<num_sdus; i++) { - length -= rx_lengths[i]; - } - } else { // not the last MAC SDU - if ( ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) {// subheader has length of 3octets - // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L; - length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); - mac_header_ptr += 3; - } else { // subheader has length of 2octets - length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; - mac_header_ptr += 2; - } - } - - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } else { // subheader for padding - // if (lcid == SHORT_PADDING) - mac_header_ptr++; + unsigned char not_done = 1, num_sdus = 0, lcid, i; + unsigned char *mac_header_ptr = mac_header; + unsigned short length; + + while (not_done == 1) { + if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { + not_done = 0; + } + + lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; + + if (lcid < SHORT_PADDING) { // subheader for MSI, MCCH or MTCH + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = tb_length - (mac_header_ptr - mac_header); + + for (i = 0; i < num_sdus; i++) { + length -= rx_lengths[i]; + } + } else { // not the last MAC SDU + if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { // subheader has length of 3octets + // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L; + length = + ((((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_MSB & 0x7f) + << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_LSB & 0xff); + mac_header_ptr += 3; + } else { // subheader has length of 2octets + length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; + mac_header_ptr += 2; + } + } + + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; + } else { // subheader for padding + // if (lcid == SHORT_PADDING) + mac_header_ptr++; + } } - } - *num_sdu = num_sdus; - return(mac_header_ptr); + *num_sdu = num_sdus; + return (mac_header_ptr); } // this function is for sending mch_sdu from phy to mac -void ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, uint8_t *sdu, uint16_t sdu_len, uint8_t eNB_index, uint8_t sync_area) +void +ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, + uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index, + uint8_t sync_area) { - unsigned char num_sdu, i, *payload_ptr; - unsigned char rx_lcids[NB_RB_MAX]; - unsigned short rx_lengths[NB_RB_MAX]; + unsigned char num_sdu, i, *payload_ptr; + unsigned char rx_lcids[NB_RB_MAX]; + unsigned short rx_lengths[NB_RB_MAX]; #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].rx_mch_sdu); + start_meas(&UE_mac_inst[module_idP].rx_mch_sdu); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN); - - LOG_D(MAC,"[UE %d] Frame %d : process the mch PDU for sync area %d \n",module_idP,frameP, sync_area); - LOG_D(MAC,"[UE %d] sdu: %x.%x\n", module_idP,sdu[0], sdu[1]); - LOG_D(MAC,"[UE %d] parse_mch_header, demultiplex\n",module_idP); - - payload_ptr = parse_mch_header(sdu, &num_sdu, rx_lcids, rx_lengths, sdu_len); - LOG_D(MAC,"[UE %d] parse_mch_header, found %d sdus\n",module_idP,num_sdu); - - for (i=0; i<num_sdu; i++) { - if (rx_lcids[i] == MCH_SCHDL_INFO) { - if (UE_mac_inst[module_idP].mcch_status==1) { - LOG_I(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, sync_area, eNB_index, rx_lengths[i]); - // ??store necessary scheduling info to ue_mac_inst in order to - // calculate exact position of interested service (for the complex case has >1 mtch) - // set msi_status to 1 - UE_mac_inst[module_idP].msi_status = 1; - } - } else if (rx_lcids[i] == MCCH_LCHANID) { - LOG_I(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, i, sync_area, eNB_index, rx_lengths[i]); - mac_rrc_data_ind(module_idP, - CC_id, - frameP,0, // unknown subframe - M_RNTI, - MCCH, - payload_ptr, rx_lengths[i], 0, eNB_index, sync_area); - } else if (rx_lcids[i] == MTCH) { - if (UE_mac_inst[module_idP].msi_status==1) { - LOG_I(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, sync_area, eNB_index, rx_lengths[i]); - - mac_rlc_data_ind( - module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_YES, - MTCH, /*+ (maxDRB + 3),*/ - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN); - } - } else { - LOG_W(MAC,"[UE %d] Frame %d : unknown sdu %d rx_lcids[%d]=%d mcch status %d eNB %d \n", - module_idP, - frameP, - rx_lengths[i], - i, - rx_lcids[i], - UE_mac_inst[module_idP].mcch_status, eNB_index); + LOG_D(MAC, + "[UE %d] Frame %d : process the mch PDU for sync area %d \n", + module_idP, frameP, sync_area); + LOG_D(MAC, "[UE %d] sdu: %x.%x\n", module_idP, sdu[0], sdu[1]); + LOG_D(MAC, "[UE %d] parse_mch_header, demultiplex\n", module_idP); + + payload_ptr = + parse_mch_header(sdu, &num_sdu, rx_lcids, rx_lengths, sdu_len); + LOG_D(MAC, "[UE %d] parse_mch_header, found %d sdus\n", module_idP, + num_sdu); + + for (i = 0; i < num_sdu; i++) { + if (rx_lcids[i] == MCH_SCHDL_INFO) { + if (UE_mac_inst[module_idP].mcch_status == 1) { + LOG_I(MAC, + "[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes)\n", + module_idP, frameP, sync_area, eNB_index, + rx_lengths[i]); + // ??store necessary scheduling info to ue_mac_inst in order to + // calculate exact position of interested service (for the complex case has >1 mtch) + // set msi_status to 1 + UE_mac_inst[module_idP].msi_status = 1; + } + } else if (rx_lcids[i] == MCCH_LCHANID) { + LOG_I(MAC, + "[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n", + module_idP, frameP, i, sync_area, eNB_index, + rx_lengths[i]); + mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe + M_RNTI, + MCCH, + payload_ptr, rx_lengths[i], eNB_index, + sync_area); + } else if (rx_lcids[i] == MTCH) { + if (UE_mac_inst[module_idP].msi_status == 1) { + LOG_I(MAC, + "[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes)\n", + module_idP, frameP, sync_area, eNB_index, + rx_lengths[i]); + + mac_rlc_data_ind(module_idP, UE_mac_inst[module_idP].crnti, eNB_index, frameP, ENB_FLAG_NO, MBMS_FLAG_YES, MTCH, /*+ (maxDRB + 3), */ + (char *) payload_ptr, rx_lengths[i], 1, + NULL); + + } + } else { + LOG_W(MAC, + "[UE %d] Frame %d : unknown sdu %d rx_lcids[%d]=%d mcch status %d eNB %d \n", + module_idP, frameP, rx_lengths[i], i, rx_lcids[i], + UE_mac_inst[module_idP].mcch_status, eNB_index); + } + + payload_ptr += rx_lengths[i]; } - payload_ptr += rx_lengths[i]; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_OUT); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_mch_sdu); + stop_meas(&UE_mac_inst[module_idP].rx_mch_sdu); #endif } - void ue_send_sl_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, @@ -798,7 +877,8 @@ void ue_send_sl_sdu(module_id_t module_idP, } else { //SL_DISCOVERY uint16_t len = sdu_len; LOG_I( MAC, "SL DISCOVERY \n"); - mac_rrc_data_ind(module_idP, + // Panos: Ask TTN if we should be calling mac_rrc_data_ind_ue() instead of mac_rrc_data_ind() now! + /*mac_rrc_data_ind(module_idP, CC_id, frameP,subframeP, UE_mac_inst[module_idP].crnti, @@ -807,1128 +887,1382 @@ void ue_send_sl_sdu(module_id_t module_idP, len, ENB_FLAG_NO, eNB_index, - 0); + 0);*/ + mac_rrc_data_ind_ue(module_idP, + CC_id, + frameP,subframeP, + UE_mac_inst[module_idP].crnti, + SL_DISCOVERY, + sdu, //(uint8_t*)&UE_mac_inst[Mod_id].SL_Discovery[0].Rx_buffer.Payload[0], + len, + eNB_index, + 0); } } int8_t ue_get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t mbsfn_sync_area, unsigned char eNB_index) + { - // currently there is one-to-one mapping between sf allocation pattern and sync area - if (mbsfn_sync_area >= MAX_MBSFN_AREA) { - LOG_W( MAC, "[UE %"PRIu8"] MBSFN synchronization area %"PRIu8" out of range for eNB %"PRIu8"\n", module_idP, mbsfn_sync_area, eNB_index ); - return -1; - } else if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) { - return mbsfn_sync_area; - } else { - LOG_W( MAC, "[UE %"PRIu8"] MBSFN Subframe Config pattern %"PRIu8" not found \n", module_idP, mbsfn_sync_area ); - return -1; - } + // currently there is one-to-one mapping between sf allocation pattern and sync area + if (mbsfn_sync_area >= MAX_MBSFN_AREA) { + LOG_W(MAC, + "[UE %" PRIu8 "] MBSFN synchronization area %" PRIu8 + " out of range for eNB %" PRIu8 "\n", module_idP, + mbsfn_sync_area, eNB_index); + return -1; + } else if (UE_mac_inst[module_idP]. + mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) { + return mbsfn_sync_area; + } else { + LOG_W(MAC, + "[UE %" PRIu8 "] MBSFN Subframe Config pattern %" PRIu8 + " not found \n", module_idP, mbsfn_sync_area); + return -1; + } } -int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) +int +ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, + uint32_t subframe, uint8_t eNB_index, uint8_t * sync_area, + uint8_t * mcch_active) { - int i=0, j=0, ii=0, msi_pos=0, mcch_mcs = - 1; - int mcch_flag=0, mtch_flag=0, msi_flag=0; - int mbsfn_period = 0;// 1<<(UE_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); - int mcch_period = 0;// 32<<(UE_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - int mch_scheduling_period = -1; + int i = 0, j = 0, ii = 0, msi_pos = 0, mcch_mcs = -1; + int mcch_flag = 0, mtch_flag = 0, msi_flag = 0; + int mbsfn_period = 0; // 1<<(UE_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); + int mcch_period = 0; // 32<<(UE_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + int mch_scheduling_period = -1; - int frame_FDD=1; + int frame_FDD = 1; #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].ue_query_mch); + start_meas(&UE_mac_inst[module_idP].ue_query_mch); #endif - if (UE_mac_inst[module_idP].pmch_Config[0]) { - mch_scheduling_period = 8<<(UE_mac_inst[module_idP].pmch_Config[0]->mch_SchedulingPeriod_r9); - } - - for (i=0; - i< UE_mac_inst[module_idP].num_active_mbsfn_area; - i++ ) { - // assume, that there is always a mapping - if ((j=ue_get_mbsfn_sf_alloction(module_idP,i,eNB_index)) == -1) { - return -1; // continue; + if (UE_mac_inst[module_idP].pmch_Config[0]) { + mch_scheduling_period = + 8 << (UE_mac_inst[module_idP]. + pmch_Config[0]->mch_SchedulingPeriod_r9); } - ii=0; - msi_pos=0; - mbsfn_period = 1<<(UE_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); - mcch_period = 32<<(UE_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - - LOG_D(MAC, - "[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d,mac sched period (%d,%ld))\n", - module_idP,frameP, subframe,i,UE_mac_inst[module_idP].num_active_mbsfn_area, - j,UE_mac_inst[module_idP].num_sf_allocation_pattern,mbsfn_period,mcch_period, - mch_scheduling_period,UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset); - - // get the real MCS value - switch (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { - case 0: - mcch_mcs = 2; - break; - - case 1: - mcch_mcs = 7; - break; - - case 2: - mcch_mcs = 13; - break; - - case 3: - mcch_mcs = 19; - break; - } - - if (frameP % mbsfn_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset) { // MBSFN frameP - if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format - - if (UE_mac_inst[module_idP].pmch_Config[0]) { - // Find the first subframe in this MCH to transmit MSI - if (frameP % mch_scheduling_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) { - while (ii == 0) { - ii = UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos); - msi_pos++; - } - } - } - - if (UE_mac_inst[module_idP].tdd_Config == NULL) frame_FDD=1; - else frame_FDD=0; - // Check if the subframe is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 - switch (subframe) { - case 1: - if (frame_FDD==1) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { - if (msi_pos == 1) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 2: - if (frame_FDD==1) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { - if (msi_pos == 2) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 3: - if (frame_FDD==0) { //TDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { - if (msi_pos == 1) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } else { // FDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { - if (msi_pos == 3) { - msi_flag = 1; - } - - if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 4: - if (frame_FDD==0) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { - if (msi_pos == 2) { - msi_flag = 1; - } - - if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 6: - if (frame_FDD==1) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { - if (msi_pos == 4) { - msi_flag = 1; - } - - if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 7: - if (frame_FDD==0) { // TDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { - if (msi_pos == 3) { - msi_flag = 1; - } - - if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } else { // FDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { - if (msi_pos == 5) { - msi_flag = 1; - } - - if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 8: - if (frame_FDD==0) { //TDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { - if (msi_pos == 4) { - msi_flag = 1; - } - - if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) { - mcch_flag = 1; - } + for (i = 0; i < UE_mac_inst[module_idP].num_active_mbsfn_area; i++) { + // assume, that there is always a mapping + if ((j = + ue_get_mbsfn_sf_alloction(module_idP, i, eNB_index)) == -1) { + return -1; // continue; + } + + ii = 0; + msi_pos = 0; + mbsfn_period = + 1 << (UE_mac_inst[module_idP]. + mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); + mcch_period = + 32 << (UE_mac_inst[module_idP]. + mbsfn_AreaInfo[0]->mcch_Config_r9. + mcch_RepetitionPeriod_r9); + + LOG_D(MAC, + "[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d,mac sched period (%d,%ld))\n", + module_idP, frameP, subframe, i, + UE_mac_inst[module_idP].num_active_mbsfn_area, j, + UE_mac_inst[module_idP].num_sf_allocation_pattern, + mbsfn_period, mcch_period, mch_scheduling_period, + UE_mac_inst[module_idP]. + mbsfn_SubframeConfig[j]->radioframeAllocationOffset); + + // get the real MCS value + switch (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]-> + mcch_Config_r9.signallingMCS_r9) { + case 0: + mcch_mcs = 2; + break; + + case 1: + mcch_mcs = 7; + break; + + case 2: + mcch_mcs = 13; + break; + + case 3: + mcch_mcs = 19; + break; + } + + if (frameP % mbsfn_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset) { // MBSFN frameP + if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format + + if (UE_mac_inst[module_idP].pmch_Config[0]) { + // Find the first subframe in this MCH to transmit MSI + if (frameP % mch_scheduling_period == + UE_mac_inst[module_idP]. + mbsfn_SubframeConfig + [j]->radioframeAllocationOffset) { + while (ii == 0) { + ii = UE_mac_inst[module_idP]. + mbsfn_SubframeConfig[j]-> + subframeAllocation.choice. + oneFrame.buf[0] & (0x80 >> msi_pos); + msi_pos++; + } + } + } + + if (UE_mac_inst[module_idP].tdd_Config == NULL) + frame_FDD = 1; + else + frame_FDD = 0; + // Check if the subframe is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 + switch (subframe) { + case 1: + if (frame_FDD == 1) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { + if (msi_pos == 1) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF1) == + MBSFN_FDD_SF1)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - mtch_flag = 1; - } - } else { // FDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { - if (msi_pos == 6) { - msi_flag = 1; - } - - if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } + break; + + case 2: + if (frame_FDD == 1) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { + if (msi_pos == 2) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF2) == + MBSFN_FDD_SF2)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - break; + break; + + case 3: + if (frame_FDD == 0) { //TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { + if (msi_pos == 1) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF3) == + MBSFN_TDD_SF3)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } else { // FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { + if (msi_pos == 3) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF3) == + MBSFN_FDD_SF3)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - case 9: - if (frame_FDD==0) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { - if (msi_pos == 5) { - msi_flag = 1; - } + break; + + case 4: + if (frame_FDD == 0) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { + if (msi_pos == 2) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF4) == + MBSFN_TDD_SF4)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) { - mcch_flag = 1; - } + break; + + case 6: + if (frame_FDD == 1) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { + if (msi_pos == 4) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF6) == + MBSFN_FDD_SF6)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - mtch_flag = 1; - } - } + break; + + case 7: + if (frame_FDD == 0) { // TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { + if (msi_pos == 3) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF7) == + MBSFN_TDD_SF7)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } else { // FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { + if (msi_pos == 5) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF7) == + MBSFN_FDD_SF7)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - break; - }// end switch + break; + + case 8: + if (frame_FDD == 0) { //TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { + if (msi_pos == 4) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF8) == + MBSFN_TDD_SF8)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } else { // FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { + if (msi_pos == 6) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_FDD_SF8) == + MBSFN_FDD_SF8)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - // sf allocation is non-overlapping - if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)) { - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", - module_idP, frameP, subframe,i,j,msi_flag,mcch_flag,mtch_flag); + break; + + case 9: + if (frame_FDD == 0) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig + [j]->subframeAllocation.choice.oneFrame. + buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { + if (msi_pos == 5) { + msi_flag = 1; + } + + if ((frameP % mcch_period == + UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.mcch_Offset_r9) + && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo + [i]->mcch_Config_r9.sf_AllocInfo_r9. + buf[0] & MBSFN_TDD_SF9) == + MBSFN_TDD_SF9)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } + } - *sync_area=i; - break; - } - } else { // four-frameP format - } - } - } // end of for + break; + } // end switch + + // sf allocation is non-overlapping + if ((msi_flag == 1) || (mcch_flag == 1) + || (mtch_flag == 1)) { + LOG_D(MAC, + "[UE %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", + module_idP, frameP, subframe, i, j, msi_flag, + mcch_flag, mtch_flag); + + *sync_area = i; + break; + } + } else { // four-frameP format + } + } + } // end of for #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_query_mch); + stop_meas(&UE_mac_inst[module_idP].ue_query_mch); #endif - if ( (mcch_flag==1)) { // || (msi_flag==1)) - *mcch_active=1; - } + if ((mcch_flag == 1)) { // || (msi_flag==1)) + *mcch_active = 1; + } - if ( (mcch_flag==1) || ((msi_flag==1) && (UE_mac_inst[module_idP].mcch_status==1)) ) { - return mcch_mcs; - } else if ((mtch_flag==1) && (UE_mac_inst[module_idP].msi_status==1)) { - return UE_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9; - } else { - return -1; - } + if ((mcch_flag == 1) + || ((msi_flag == 1) && (UE_mac_inst[module_idP].mcch_status == 1))) { + return mcch_mcs; + } else if ((mtch_flag == 1) + && (UE_mac_inst[module_idP].msi_status == 1)) { + return UE_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9; + } else { + return -1; + } } #endif -unsigned char generate_ulsch_header(uint8_t *mac_header, - uint8_t num_sdus, - uint8_t short_padding, - uint16_t *sdu_lengths, - uint8_t *sdu_lcids, - POWER_HEADROOM_CMD *power_headroom, - uint16_t *crnti, - BSR_SHORT *truncated_bsr, - BSR_SHORT *short_bsr, - BSR_LONG *long_bsr, - unsigned short post_padding) +unsigned char +generate_ulsch_header(uint8_t * mac_header, + uint8_t num_sdus, + uint8_t short_padding, + uint16_t * sdu_lengths, + uint8_t * sdu_lcids, + POWER_HEADROOM_CMD * power_headroom, + uint16_t * crnti, + BSR_SHORT * truncated_bsr, + BSR_SHORT * short_bsr, + BSR_LONG * long_bsr, unsigned short post_padding) { - SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *)mac_header; - unsigned char first_element=0,last_size=0,i; - unsigned char mac_header_control_elements[16],*ce_ptr; + SCH_SUBHEADER_FIXED *mac_header_ptr = + (SCH_SUBHEADER_FIXED *) mac_header; + unsigned char first_element = 0, last_size = 0, i; + unsigned char mac_header_control_elements[16], *ce_ptr; - LOG_D(MAC,"[UE] Generate ULSCH : num_sdus %d\n",num_sdus); + LOG_D(MAC, "[UE] Generate ULSCH : num_sdus %d\n", num_sdus); #ifdef DEBUG_HEADER_PARSING - for (i=0; i<num_sdus; i++) { - LOG_T(MAC,"[UE] sdu %d : lcid %d length %d",i,sdu_lcids[i],sdu_lengths[i]); - } + for (i = 0; i < num_sdus; i++) { + LOG_T(MAC, "[UE] sdu %d : lcid %d length %d", i, sdu_lcids[i], + sdu_lengths[i]); + } - LOG_T(MAC,"\n"); + LOG_T(MAC, "\n"); #endif - ce_ptr = &mac_header_control_elements[0]; - - if ((short_padding == 1) || (short_padding == 2)) { - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - first_element=1; - last_size=1; - } - - if (short_padding == 2) { - mac_header_ptr->E = 1; - mac_header_ptr++; - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - last_size=1; - } + ce_ptr = &mac_header_control_elements[0]; + + if ((short_padding == 1) || (short_padding == 2)) { + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + first_element = 1; + last_size = 1; + } - if (power_headroom) { - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } else { - first_element=1; + if (short_padding == 2) { + mac_header_ptr->E = 1; + mac_header_ptr++; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + last_size = 1; } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = POWER_HEADROOM; - last_size=1; - *((POWER_HEADROOM_CMD *)ce_ptr)=(*power_headroom); - ce_ptr+=sizeof(POWER_HEADROOM_CMD); - LOG_D(MAC, "phr header size %zu\n",sizeof(POWER_HEADROOM_CMD)); - } + if (power_headroom) { + if (first_element > 0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } else { + first_element = 1; + } + + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = POWER_HEADROOM; + last_size = 1; + *((POWER_HEADROOM_CMD *) ce_ptr) = (*power_headroom); + ce_ptr += sizeof(POWER_HEADROOM_CMD); + LOG_D(MAC, "phr header size %zu\n", sizeof(POWER_HEADROOM_CMD)); + } - if (crnti) { + if (crnti) { #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] CRNTI : %x (first_element %d)\n",*crnti,first_element); + LOG_D(MAC, "[UE] CRNTI : %x (first_element %d)\n", *crnti, + first_element); #endif - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } else { - first_element=1; + if (first_element > 0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } else { + first_element = 1; + } + + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = CRNTI; + last_size = 1; + *((uint16_t *) ce_ptr) = (*crnti); + ce_ptr += sizeof(uint16_t); + // printf("offset %d\n",ce_ptr-mac_header_control_elements); } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = CRNTI; - last_size=1; - *((uint16_t *)ce_ptr)=(*crnti); - ce_ptr+=sizeof(uint16_t); - // printf("offset %d\n",ce_ptr-mac_header_control_elements); - } + if (truncated_bsr) { + if (first_element > 0) { + mac_header_ptr->E = 1; + /* + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr++; + } else { + first_element = 1; + } - if (truncated_bsr) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* - printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } else { - first_element=1; - } +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, "[UE] Scheduler Truncated BSR Header\n"); +#endif + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = TRUNCATED_BSR; + last_size = 1; + *((BSR_TRUNCATED *) ce_ptr) = (*truncated_bsr); + ce_ptr += sizeof(BSR_TRUNCATED); + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + + } else if (short_bsr) { + if (first_element > 0) { + mac_header_ptr->E = 1; + /* + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr++; + } else { + first_element = 1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] Scheduler Truncated BSR Header\n"); + LOG_D(MAC, "[UE] Scheduler SHORT BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = TRUNCATED_BSR; - last_size=1; - *((BSR_TRUNCATED *)ce_ptr)=(*truncated_bsr); - ce_ptr+=sizeof(BSR_TRUNCATED); - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); - - } else if (short_bsr) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* - printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } else { - first_element=1; - } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_BSR; + last_size = 1; + *((BSR_SHORT *) ce_ptr) = (*short_bsr); + ce_ptr += sizeof(BSR_SHORT); + + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + } else if (long_bsr) { + if (first_element > 0) { + mac_header_ptr->E = 1; + /* + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr++; + } else { + first_element = 1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] Scheduler SHORT BSR Header\n"); + LOG_D(MAC, "[UE] Scheduler Long BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_BSR; - last_size=1; - *((BSR_SHORT *)ce_ptr)=(*short_bsr); - ce_ptr+=sizeof(BSR_SHORT); - - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); - } else if (long_bsr) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* - printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } else { - first_element=1; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = LONG_BSR; + last_size = 1; + + *(ce_ptr) = + (long_bsr-> + Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4); + *(ce_ptr + 1) = + ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr-> + Buffer_size2 & 0x3C) + >> 2); + *(ce_ptr + 2) = + ((long_bsr-> + Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F); + ce_ptr += BSR_LONG_SIZE; + + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } + // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + for (i = 0; i < num_sdus; i++) { #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] Scheduler Long BSR Header\n"); + LOG_T(MAC, "[UE] sdu subheader %d (lcid %d, %d bytes)\n", i, + sdu_lcids[i], sdu_lengths[i]); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = LONG_BSR; - last_size=1; - - *(ce_ptr) = (long_bsr->Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4); - *(ce_ptr + 1) = ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr->Buffer_size2 & 0x3C) >> 2); - *(ce_ptr + 2) = ((long_bsr->Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F); - ce_ptr += BSR_LONG_SIZE; - - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); - } - // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - - for (i=0; i<num_sdus; i++) { + if ((i == (num_sdus - 1)) + && ((short_padding) || (post_padding == 0))) { + if (first_element > 0) { + mac_header_ptr->E = 1; #ifdef DEBUG_HEADER_PARSING - LOG_T(MAC,"[UE] sdu subheader %d (lcid %d, %d bytes)\n",i,sdu_lcids[i],sdu_lengths[i]); + LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n", + *(unsigned char *) mac_header_ptr, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID); #endif - - if ((i == (num_sdus - 1)) && ((short_padding) || (post_padding == 0))) { - if (first_element>0) { - mac_header_ptr->E = 1; - #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - #endif - mac_header_ptr+=last_size; - } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = sdu_lcids[i]; - } - else { - if ((first_element>0)) { - mac_header_ptr->E = 1; - #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - #endif - mac_header_ptr+=last_size; - // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - } else { - first_element=1; - - } - - if (sdu_lengths[i] < 128) { - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; // 3 - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; - last_size=2; - #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] short sdu\n"); - LOG_T(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", - ((uint16_t*)mac_header_ptr)[0], - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L); - #endif - } else { - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; - last_size=3; - #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] long sdu\n"); - #endif - } + mac_header_ptr += last_size; + } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = sdu_lcids[i]; + } else { + if ((first_element > 0)) { + mac_header_ptr->E = 1; +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n", + *(unsigned char *) mac_header_ptr, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID); +#endif + mac_header_ptr += last_size; + // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + } else { + first_element = 1; + + } + + if (sdu_lengths[i] < 128) { + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R = 0; // 3 + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F = 0; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID = + sdu_lcids[i]; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L = + (unsigned char) sdu_lengths[i]; + last_size = 2; +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, "[UE] short sdu\n"); + LOG_T(MAC, + "[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", + ((uint16_t *) mac_header_ptr)[0], + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L); +#endif + } else { + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->F = 1; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->LCID = + sdu_lcids[i]; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB = + ((unsigned short) sdu_lengths[i] >> 8) & 0x7f; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB = + (unsigned short) sdu_lengths[i] & 0xff; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->padding = 0x00; + last_size = 3; +#ifdef DEBUG_HEADER_PARSING + LOG_D(MAC, "[UE] long sdu\n"); +#endif + } + } } - } - if (post_padding>0) {// we have lots of padding at the end of the packet - mac_header_ptr->E = 1; - mac_header_ptr+=last_size; - // add a padding element - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - mac_header_ptr++; - } else { // no end of packet padding - // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) - mac_header_ptr++; - //mac_header_ptr=last_size; // FIXME: should be ++ - } + if (post_padding > 0) { // we have lots of padding at the end of the packet + mac_header_ptr->E = 1; + mac_header_ptr += last_size; + // add a padding element + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + mac_header_ptr++; + } else { // no end of packet padding + // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) + mac_header_ptr++; + //mac_header_ptr=last_size; // FIXME: should be ++ + } - if ((ce_ptr-mac_header_control_elements) > 0) { - memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements); - mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements); - } - + if ((ce_ptr - mac_header_control_elements) > 0) { + memcpy((void *) mac_header_ptr, mac_header_control_elements, + ce_ptr - mac_header_control_elements); + mac_header_ptr += + (unsigned char) (ce_ptr - mac_header_control_elements); + } #ifdef DEBUG_HEADER_PARSING - LOG_T(MAC," [UE] header : "); + LOG_T(MAC, " [UE] header : "); - for (i=0; i<((unsigned char*)mac_header_ptr - mac_header); i++) { - LOG_T(MAC,"%2x.",mac_header[i]); - } + for (i = 0; i < ((unsigned char *) mac_header_ptr - mac_header); i++) { + LOG_T(MAC, "%2x.", mac_header[i]); + } - LOG_T(MAC,"\n"); + LOG_T(MAC, "\n"); #endif - return((unsigned char*)mac_header_ptr - mac_header); + return ((unsigned char *) mac_header_ptr - mac_header); } -void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint8_t *ulsch_buffer,uint16_t buflen, uint8_t *access_mode) +void +ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, + sub_frame_t subframe, uint8_t eNB_index, + uint8_t * ulsch_buffer, uint16_t buflen, uint8_t * access_mode) { - uint8_t total_rlc_pdu_header_len=0, rlc_pdu_header_len_last=0 ; - uint16_t buflen_remain = 0; - uint8_t bsr_len=0,bsr_ce_len=0,bsr_header_len=0; - uint8_t phr_header_len=0, phr_ce_len=0,phr_len=0; - uint8_t lcid=0,lcid_rlc_pdu_count=0; - boolean_t is_lcid_processed = FALSE; - boolean_t is_all_lcid_processed = FALSE; - uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - uint8_t payload_offset=0,num_sdus=0; - uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; - uint16_t sdu_length_total=0; - BSR_SHORT bsr_short,bsr_truncated; - BSR_LONG bsr_long; - BSR_SHORT *bsr_s=&bsr_short; - BSR_LONG *bsr_l=&bsr_long; - BSR_SHORT *bsr_t=&bsr_truncated; - POWER_HEADROOM_CMD phr; - POWER_HEADROOM_CMD *phr_p=&phr; - unsigned short short_padding=0, post_padding=0, padding_len=0; - int j; // used for padding - // Compute header length - int lcg_id = 0; - int lcg_id_bsr_trunc = 0; - int highest_priority = 16; - int num_lcg_id_with_data = 0; - rlc_buffer_occupancy_t lcid_buffer_occupancy_old=0, lcid_buffer_occupancy_new=0; - - LOG_D(MAC,"[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n", - module_idP, frameP, subframe, buflen); - - - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); + uint8_t total_rlc_pdu_header_len = 0, rlc_pdu_header_len_last = 0; + uint16_t buflen_remain = 0; + uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0; + uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0; + uint8_t lcid = 0, lcid_rlc_pdu_count = 0; + boolean_t is_lcid_processed = FALSE; + boolean_t is_all_lcid_processed = FALSE; + uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8_t payload_offset = 0, num_sdus = 0; + uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; + uint16_t sdu_length_total = 0; + BSR_SHORT bsr_short, bsr_truncated; + BSR_LONG bsr_long; + BSR_SHORT *bsr_s = &bsr_short; + BSR_LONG *bsr_l = &bsr_long; + BSR_SHORT *bsr_t = &bsr_truncated; + POWER_HEADROOM_CMD phr; + POWER_HEADROOM_CMD *phr_p = &phr; + unsigned short short_padding = 0, post_padding = 0, padding_len = 0; + int j; // used for padding + // Compute header length + int lcg_id = 0; + int lcg_id_bsr_trunc = 0; + int highest_priority = 16; + int num_lcg_id_with_data = 0; + rlc_buffer_occupancy_t lcid_buffer_occupancy_old = + 0, lcid_buffer_occupancy_new = 0; + + LOG_D(MAC, + "[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); + + + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); + start_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_IN); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_IN); #ifdef CBA - if (*access_mode==CBA_ACCESS) { - LOG_D(MAC,"[UE %d] frameP %d subframe %d try CBA transmission\n", - module_idP, frameP, subframe); - - //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY) - if (cba_access(module_idP,frameP,subframe,eNB_index,buflen)==0) { - *access_mode=POSTPONED_ACCESS; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); - return; + if (*access_mode == CBA_ACCESS) { + LOG_D(MAC, "[UE %d] frameP %d subframe %d try CBA transmission\n", + module_idP, frameP, subframe); + + //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY) + if (cba_access(module_idP, frameP, subframe, eNB_index, buflen) == + 0) { + *access_mode = POSTPONED_ACCESS; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); + return; + } + + LOG_I(MAC, + "[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n", + module_idP, frameP, subframe, buflen); } - - LOG_I(MAC,"[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n", - module_idP, frameP, subframe,buflen); - } - #endif - bsr_header_len = 0; - phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); - - while (lcg_id < MAX_NUM_LCGID) { - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]){ - num_lcg_id_with_data ++; - } - lcg_id ++; - } - - if (num_lcg_id_with_data){ - LOG_D(MAC,"[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", - module_idP, - frameP, - subframe, - num_lcg_id_with_data, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], - UE_mac_inst[module_idP].BSR_reporting_active, buflen); - - } - //Restart ReTxBSR Timer at new grant indication (36.321) - if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING){ - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); - } - - // periodicBSR-Timer expires, trigger BSR - if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != PeriodicBSR_Timer_r12_infinity) - && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)){ - // Trigger BSR Periodic - UE_mac_inst[module_idP].BSR_reporting_active |= BSR_TRIGGER_PERIODIC; - - LOG_D(MAC,"[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", - module_idP, frameP, subframe, buflen); - + bsr_header_len = 0; + phr_header_len = 1; //sizeof(SCH_SUBHEADER_FIXED); + + while (lcg_id < MAX_NUM_LCGID) { + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) { + num_lcg_id_with_data++; + } + lcg_id++; } - //Compute BSR Length if Regular or Periodic BSR is triggered - //WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx - if (UE_mac_inst[module_idP].BSR_reporting_active){ + if (num_lcg_id_with_data) { + LOG_D(MAC, + "[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", + module_idP, frameP, subframe, num_lcg_id_with_data, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], + UE_mac_inst[module_idP].BSR_reporting_active, buflen); - AssertFatal ((UE_mac_inst[module_idP].BSR_reporting_active & BSR_TRIGGER_PADDING) == 0 , "Inconsistent BSR Trigger=%d !\n", - UE_mac_inst[module_idP].BSR_reporting_active); - - if (buflen >= 4){ - //A Regular or Periodic BSR can only be sent if TBS >= 4 as transmitting only a BSR is not allowed if UE has data to transmit - bsr_header_len = 1; + } + //Restart ReTxBSR Timer at new grant indication (36.321) + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != + MAC_UE_BSR_TIMER_NOT_RUNNING) { + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = + get_sf_retxBSRTimer(UE_mac_inst[module_idP]. + scheduling_info.retxBSR_Timer); + } + // periodicBSR-Timer expires, trigger BSR + if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != + PeriodicBSR_Timer_r12_infinity) + && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)) { + // Trigger BSR Periodic + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_PERIODIC; + + LOG_D(MAC, + "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); - if (num_lcg_id_with_data <= 1){ - bsr_ce_len = sizeof(BSR_SHORT); //1 byte - } - else{ - bsr_ce_len = BSR_LONG_SIZE; //3 bytes - } - } - } + } + //Compute BSR Length if Regular or Periodic BSR is triggered + //WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx + if (UE_mac_inst[module_idP].BSR_reporting_active) { + + AssertFatal((UE_mac_inst[module_idP].BSR_reporting_active & + BSR_TRIGGER_PADDING) == 0, + "Inconsistent BSR Trigger=%d !\n", + UE_mac_inst[module_idP].BSR_reporting_active); + + if (buflen >= 4) { + //A Regular or Periodic BSR can only be sent if TBS >= 4 as transmitting only a BSR is not allowed if UE has data to transmit + bsr_header_len = 1; + + if (num_lcg_id_with_data <= 1) { + bsr_ce_len = sizeof(BSR_SHORT); //1 byte + } else { + bsr_ce_len = BSR_LONG_SIZE; //3 bytes + } + } + } - bsr_len = bsr_ce_len + bsr_header_len; - - phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; - if ((phr_ce_len > 0) && ((phr_ce_len + phr_header_len + bsr_len) <= buflen)){ - phr_len = phr_ce_len + phr_header_len; - LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", - module_idP, phr_len, phr_ce_len, phr_header_len, buflen); - } else { - phr_len=0; - phr_header_len = 0; - phr_ce_len = 0; - } + bsr_len = bsr_ce_len + bsr_header_len; + + phr_ce_len = + (UE_mac_inst[module_idP].PHR_reporting_active == + 1) ? 1 /* sizeof(POWER_HEADROOM_CMD) */ : 0; + if ((phr_ce_len > 0) + && ((phr_ce_len + phr_header_len + bsr_len) <= buflen)) { + phr_len = phr_ce_len + phr_header_len; + LOG_D(MAC, + "[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", + module_idP, phr_len, phr_ce_len, phr_header_len, buflen); + } else { + phr_len = 0; + phr_header_len = 0; + phr_ce_len = 0; + } - // check for UL bandwidth requests and add SR control element + // check for UL bandwidth requests and add SR control element - // check for UL bandwidth requests and add SR control element + // check for UL bandwidth requests and add SR control element - // Check for DCCH first + // Check for DCCH first // TO DO: Multiplex in the order defined by the logical channel prioritization -for (lcid=DCCH; (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE) ; lcid++) { - if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) { - - lcid_rlc_pdu_count = 0; - is_lcid_processed = FALSE; - lcid_buffer_occupancy_old = mac_rlc_get_buffer_occupancy_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - subframe, - ENB_FLAG_NO, - lcid); - - lcid_buffer_occupancy_new = lcid_buffer_occupancy_old; - - AssertFatal (lcid_buffer_occupancy_new == UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid], "LCID=%d RLC has BO %d bytes but MAC has stored %d bytes\n", - lcid,lcid_buffer_occupancy_new,UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]); - - AssertFatal (lcid_buffer_occupancy_new <= UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], "LCID=%d RLC has more BO %d bytes than BSR = %d bytes\n", - lcid,lcid_buffer_occupancy_new,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); - - - //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data - //Adjust at the end of the loop - while ((!is_lcid_processed) && (lcid_buffer_occupancy_new) && (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { - - // Workaround for issue in OAI eNB or EPC which are not able to process SRB2 message multiplexed with SRB1 on the same MAC PDU - if ((usim_test == 0) && (lcid == DCCH1) && (lcid_rlc_pdu_count == 0) && (num_sdus)) { - - // Skip SRB2 multiplex if at least one SRB1 SDU is already multiplexed - break; - } - - buflen_remain = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); - - - LOG_D(MAC, "[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to " - "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", - module_idP,frameP, lcid,lcid_buffer_occupancy_new,buflen,bsr_len,phr_len,sdu_length_total,total_rlc_pdu_header_len,UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); - - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - lcid, - buflen_remain, - (char *)&ulsch_buff[sdu_length_total] + for (lcid = DCCH; + (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE); lcid++) + { + if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == + LCID_NOT_EMPTY) { + + lcid_rlc_pdu_count = 0; + is_lcid_processed = FALSE; + lcid_buffer_occupancy_old = + mac_rlc_get_buffer_occupancy_ind(module_idP, + UE_mac_inst[module_idP]. + crnti, eNB_index, frameP, + subframe, ENB_FLAG_NO, + lcid); + + lcid_buffer_occupancy_new = lcid_buffer_occupancy_old; + + AssertFatal(lcid_buffer_occupancy_new == + UE_mac_inst[module_idP]. + scheduling_info.LCID_buffer_remain[lcid], + "LCID=%d RLC has BO %d bytes but MAC has stored %d bytes\n", + lcid, lcid_buffer_occupancy_new, + UE_mac_inst[module_idP]. + scheduling_info.LCID_buffer_remain[lcid]); + + AssertFatal(lcid_buffer_occupancy_new <= + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [lcid]], + "LCID=%d RLC has more BO %d bytes than BSR = %d bytes\n", + lcid, lcid_buffer_occupancy_new, + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [lcid]]); + + + //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data + //Adjust at the end of the loop + while ((!is_lcid_processed) && (lcid_buffer_occupancy_new) + && (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) + { + + // Workaround for issue in OAI eNB or EPC which are not able to process SRB2 message multiplexed with SRB1 on the same MAC PDU + if ((usim_test == 0) && (lcid == DCCH1) + && (lcid_rlc_pdu_count == 0) && (num_sdus)) { + + // Skip SRB2 multiplex if at least one SRB1 SDU is already multiplexed + break; + } + + buflen_remain = + buflen - (bsr_len + phr_len + + total_rlc_pdu_header_len + sdu_length_total + + 1); + + + LOG_D(MAC, + "[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to " + "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", + module_idP, frameP, lcid, lcid_buffer_occupancy_new, + buflen, bsr_len, phr_len, sdu_length_total, + total_rlc_pdu_header_len, + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [lcid]]); + + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + UE_mac_inst + [module_idP]. + crnti, eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + lcid, + buflen_remain, + (char *)&ulsch_buff[sdu_length_total] #ifdef Rel14 - ,0, - 0 + ,0, + 0 #endif - ); - - - AssertFatal (buflen_remain >= sdu_lengths[num_sdus], "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", - lcid,sdu_lengths[num_sdus],buflen_remain); - - - if (sdu_lengths[num_sdus]) - { - sdu_length_total += sdu_lengths[num_sdus]; - sdu_lcids[num_sdus] = lcid; - LOG_D(MAC,"[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LcId%d\n",module_idP,sdu_lengths[num_sdus],lcid); - - if (buflen == (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1)) { - //No more remaining TBS after this PDU - //exit the function - rlc_pdu_header_len_last = 1; - is_lcid_processed = TRUE; - is_all_lcid_processed = TRUE; - } - else { - rlc_pdu_header_len_last = (sdu_lengths[num_sdus] > 128 ) ? 3 : 2 ; - - //Change to 1 byte if it does not fit in the TBS, ie last PDU - if (buflen <= (bsr_len + phr_len + total_rlc_pdu_header_len + rlc_pdu_header_len_last + sdu_length_total)) { - rlc_pdu_header_len_last = 1; - is_lcid_processed = TRUE; - is_all_lcid_processed = TRUE; - } - } - - //Update number of SDU - num_sdus ++; - - //Update total MAC Header size for RLC PDUs and save last one - total_rlc_pdu_header_len += rlc_pdu_header_len_last; - - lcid_rlc_pdu_count ++; - } - else - { - /* avoid infinite loop ... */ - is_lcid_processed = TRUE; - } - - /* Get updated BO after multiplexing this PDU */ - lcid_buffer_occupancy_new = mac_rlc_get_buffer_occupancy_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - subframe, - ENB_FLAG_NO, - lcid); - - is_lcid_processed = (is_lcid_processed) || (lcid_buffer_occupancy_new <= 0); - } - - //Update Buffer remain and BSR bytes after transmission - - AssertFatal (lcid_buffer_occupancy_new <= lcid_buffer_occupancy_old, "MAC UE Tx error : Buffer Occupancy After Tx=%d greater than before=%d BO! for LCID=%d RLC PDU nb=%d Frame %d Subrame %d\n", - lcid_buffer_occupancy_new,lcid_buffer_occupancy_old,lcid,lcid_rlc_pdu_count,frameP,subframe); - - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = lcid_buffer_occupancy_new; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] += (lcid_buffer_occupancy_new - lcid_buffer_occupancy_old); + ); + + + + AssertFatal(buflen_remain >= sdu_lengths[num_sdus], + "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", + lcid, sdu_lengths[num_sdus], buflen_remain); + + + if (sdu_lengths[num_sdus]) { + sdu_length_total += sdu_lengths[num_sdus]; + sdu_lcids[num_sdus] = lcid; + LOG_D(MAC, + "[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LcId%d\n", + module_idP, sdu_lengths[num_sdus], lcid); + + if (buflen == + (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1)) { + //No more remaining TBS after this PDU + //exit the function + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + is_all_lcid_processed = TRUE; + } else { + rlc_pdu_header_len_last = + (sdu_lengths[num_sdus] > 128) ? 3 : 2; + + //Change to 1 byte if it does not fit in the TBS, ie last PDU + if (buflen <= + (bsr_len + phr_len + total_rlc_pdu_header_len + + rlc_pdu_header_len_last + sdu_length_total)) { + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + is_all_lcid_processed = TRUE; + } + } - //Update the number of LCGID with data as BSR shall reflect status after BSR transmission - if ((num_lcg_id_with_data > 1) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == 0)) - { - num_lcg_id_with_data --; - // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 - if ((bsr_len) && (num_lcg_id_with_data == 1)) - { - bsr_ce_len = sizeof(BSR_SHORT); - bsr_len = bsr_ce_len + bsr_header_len; - } + //Update number of SDU + num_sdus++; + + //Update total MAC Header size for RLC PDUs and save last one + total_rlc_pdu_header_len += rlc_pdu_header_len_last; + + lcid_rlc_pdu_count++; + } else { + /* avoid infinite loop ... */ + is_lcid_processed = TRUE; + } + + /* Get updated BO after multiplexing this PDU */ + lcid_buffer_occupancy_new = + mac_rlc_get_buffer_occupancy_ind(module_idP, + UE_mac_inst + [module_idP].crnti, + eNB_index, frameP, + subframe, ENB_FLAG_NO, + lcid); + + is_lcid_processed = (is_lcid_processed) + || (lcid_buffer_occupancy_new <= 0); + } + + //Update Buffer remain and BSR bytes after transmission + + AssertFatal(lcid_buffer_occupancy_new <= + lcid_buffer_occupancy_old, + "MAC UE Tx error : Buffer Occupancy After Tx=%d greater than before=%d BO! for LCID=%d RLC PDU nb=%d Frame %d Subrame %d\n", + lcid_buffer_occupancy_new, + lcid_buffer_occupancy_old, lcid, + lcid_rlc_pdu_count, frameP, subframe); + + UE_mac_inst[module_idP].scheduling_info. + LCID_buffer_remain[lcid] = lcid_buffer_occupancy_new; + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID[lcid]] += + (lcid_buffer_occupancy_new - lcid_buffer_occupancy_old); + + //Update the number of LCGID with data as BSR shall reflect status after BSR transmission + if ((num_lcg_id_with_data > 1) + && (UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID[lcid]] + == 0)) { + num_lcg_id_with_data--; + // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 + if ((bsr_len) && (num_lcg_id_with_data == 1)) { + bsr_ce_len = sizeof(BSR_SHORT); + bsr_len = bsr_ce_len + bsr_header_len; + } + } + + + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = + LCID_EMPTY; + } } - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY; - } - } - - - - // Compute BSR Values and update Nb LCGID with data after multiplexing - num_lcg_id_with_data = 0; - lcg_id_bsr_trunc = 0; - for (lcg_id=0;lcg_id<MAX_NUM_LCGID;lcg_id++){ - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); - - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]){ - num_lcg_id_with_data ++; - lcg_id_bsr_trunc = lcg_id; - } - } - - - if (bsr_ce_len) { - //Print updated BSR when sent - LOG_D(MAC,"[UE %d] Remaining Buffer after Tx frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", - module_idP, - frameP, - subframe, - num_lcg_id_with_data, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], - UE_mac_inst[module_idP].BSR_reporting_active, buflen); - - LOG_D(MAC,"[UE %d] Frame %d Subframe %d TX BSR Regular or Periodic size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n",module_idP,frameP,subframe,bsr_ce_len, - UE_mac_inst[module_idP].scheduling_info.BSR[0], - UE_mac_inst[module_idP].scheduling_info.BSR[1], - UE_mac_inst[module_idP].scheduling_info.BSR[2], - UE_mac_inst[module_idP].scheduling_info.BSR[3]); - } - - - // build PHR and update the timers - if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) { - if (nfapi_mode == 3){ //phy_stub mode - //Panos: Substitute with a static value for the MAC layer abstraction (phy_stub mode) - phr_p->PH = 40; - } - else { // Full stack mode - phr_p->PH = get_phr_mapping(module_idP,CC_id,eNB_index); - } - - phr_p->R = 0; - LOG_D(MAC,"[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", - module_idP,frameP, get_PHR(module_idP,CC_id,eNB_index), phr_p->PH,POWER_HEADROOM); - update_phr(module_idP,CC_id); - } else { - phr_p=NULL; - } - - LOG_T(MAC,"[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", module_idP,frameP,bsr_s, bsr_l, phr_p); + // Compute BSR Values and update Nb LCGID with data after multiplexing + num_lcg_id_with_data = 0; + lcg_id_bsr_trunc = 0; + for (lcg_id = 0; lcg_id < MAX_NUM_LCGID; lcg_id++) { + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = + locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, + UE_mac_inst + [module_idP].scheduling_info. + BSR_bytes[lcg_id]); + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) { + num_lcg_id_with_data++; + lcg_id_bsr_trunc = lcg_id; + } + } - // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order - // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 - /* For Padding BSR: - - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader: - - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission; - - else report Short BSR. - - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. - */ - if (sdu_length_total) { - padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - rlc_pdu_header_len_last + sdu_length_total + 1); - } - else { - padding_len = buflen - (bsr_len + phr_len); - } + if (bsr_ce_len) { + //Print updated BSR when sent + LOG_D(MAC, + "[UE %d] Remaining Buffer after Tx frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", + module_idP, frameP, subframe, num_lcg_id_with_data, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], + UE_mac_inst[module_idP].BSR_reporting_active, buflen); + + LOG_D(MAC, + "[UE %d] Frame %d Subframe %d TX BSR Regular or Periodic size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n", + module_idP, frameP, subframe, bsr_ce_len, + UE_mac_inst[module_idP].scheduling_info.BSR[0], + UE_mac_inst[module_idP].scheduling_info.BSR[1], + UE_mac_inst[module_idP].scheduling_info.BSR[2], + UE_mac_inst[module_idP].scheduling_info.BSR[3]); + } + // build PHR and update the timers + if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) { + phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index); + phr_p->R = 0; + LOG_D(MAC, + "[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", + module_idP, frameP, get_PHR(module_idP, CC_id, eNB_index), + phr_p->PH, POWER_HEADROOM); + update_phr(module_idP, CC_id); + } else { + phr_p = NULL; + } - if ((padding_len) && (bsr_len == 0)) - { - /* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR*/ - if (padding_len >= (1+BSR_LONG_SIZE)) - { - bsr_ce_len = BSR_LONG_SIZE; - bsr_header_len = 1; - // Trigger BSR Padding - UE_mac_inst[module_idP].BSR_reporting_active |= BSR_TRIGGER_PADDING; - - - } else if (padding_len >= (1+sizeof(BSR_SHORT))) { - bsr_ce_len = sizeof(BSR_SHORT); - bsr_header_len = 1; - - if (num_lcg_id_with_data > 1) - { - // REPORT TRUNCATED BSR - //Get LCGID of highest priority LCID with data - for (lcid=DCCH; lcid < MAX_NUM_LCID ; lcid++) { - if (UE_mac_inst[module_idP].logicalChannelConfig[lcid] != NULL) { - lcg_id = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]; - - if ((lcg_id < MAX_NUM_LCGID) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) - && (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->priority <= highest_priority)) { - highest_priority = UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->priority; - lcg_id_bsr_trunc = lcg_id; - } - } - } - } - else - { - //Report SHORT BSR, clear bsr_t - bsr_t = NULL; - } - - // Trigger BSR Padding - UE_mac_inst[module_idP].BSR_reporting_active |= BSR_TRIGGER_PADDING; - } - bsr_len = bsr_header_len + bsr_ce_len; - } + LOG_T(MAC, "[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", + module_idP, frameP, bsr_s, bsr_l, phr_p); + + // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order + // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 + /* For Padding BSR: + - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader: + - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission; + - else report Short BSR. + - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. + */ + if (sdu_length_total) { + padding_len = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - + rlc_pdu_header_len_last + sdu_length_total + 1); + } else { + padding_len = buflen - (bsr_len + phr_len); + } - //Fill BSR Infos - if (bsr_ce_len == 0 ) { - bsr_s = NULL; - bsr_l = NULL; - bsr_t = NULL; - } else if (bsr_ce_len == BSR_LONG_SIZE) { - bsr_s = NULL; - bsr_t = NULL; - bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; - bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; - bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; - bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - - LOG_D(MAC, "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP,subframe, - UE_mac_inst[module_idP].BSR_reporting_active, - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); - - } else if (bsr_ce_len == sizeof(BSR_SHORT)) { - bsr_l = NULL; - if ((bsr_t != NULL) && (UE_mac_inst[module_idP].BSR_reporting_active & BSR_TRIGGER_PADDING)) { - //Truncated BSR - bsr_s = NULL; - bsr_t->LCGID = lcg_id_bsr_trunc; - bsr_t->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - - LOG_D(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", - module_idP, frameP, subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); - - } - else - { - bsr_t = NULL; - bsr_s->LCGID = lcg_id_bsr_trunc; - bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc]; - - LOG_D(MAC,"[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", - module_idP, frameP, subframe, UE_mac_inst[module_idP].BSR_reporting_active, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id_bsr_trunc],lcg_id_bsr_trunc); - } - } + if ((padding_len) && (bsr_len == 0)) { + /* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR */ + if (padding_len >= (1 + BSR_LONG_SIZE)) { + bsr_ce_len = BSR_LONG_SIZE; + bsr_header_len = 1; + // Trigger BSR Padding + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_PADDING; + + + } else if (padding_len >= (1 + sizeof(BSR_SHORT))) { + bsr_ce_len = sizeof(BSR_SHORT); + bsr_header_len = 1; + + if (num_lcg_id_with_data > 1) { + // REPORT TRUNCATED BSR + //Get LCGID of highest priority LCID with data + for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { + if (UE_mac_inst[module_idP]. + logicalChannelConfig[lcid] != NULL) { + lcg_id = + UE_mac_inst[module_idP].scheduling_info. + LCGID[lcid]; + + if ((lcg_id < MAX_NUM_LCGID) + && (UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[lcg_id]) + && + (UE_mac_inst[module_idP].logicalChannelConfig + [lcid]->ul_SpecificParameters->priority <= + highest_priority)) { + highest_priority = + UE_mac_inst[module_idP]. + logicalChannelConfig[lcid]-> + ul_SpecificParameters->priority; + lcg_id_bsr_trunc = lcg_id; + } + } + } + } else { + //Report SHORT BSR, clear bsr_t + bsr_t = NULL; + } + + // Trigger BSR Padding + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_PADDING; + } + bsr_len = bsr_header_len + bsr_ce_len; + } + //Fill BSR Infos + if (bsr_ce_len == 0) { + bsr_s = NULL; + bsr_l = NULL; + bsr_t = NULL; + } else if (bsr_ce_len == BSR_LONG_SIZE) { + bsr_s = NULL; + bsr_t = NULL; + bsr_l->Buffer_size0 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; + bsr_l->Buffer_size1 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; + bsr_l->Buffer_size2 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; + bsr_l->Buffer_size3 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + + LOG_D(MAC, + "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].BSR_reporting_active, + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); + + } else if (bsr_ce_len == sizeof(BSR_SHORT)) { + bsr_l = NULL; + if ((bsr_t != NULL) + && (UE_mac_inst[module_idP].BSR_reporting_active & + BSR_TRIGGER_PADDING)) { + //Truncated BSR + bsr_s = NULL; + bsr_t->LCGID = lcg_id_bsr_trunc; + bsr_t->Buffer_size = + UE_mac_inst[module_idP].scheduling_info. + BSR[lcg_id_bsr_trunc]; + + LOG_D(MAC, + "[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].BSR_reporting_active, + UE_mac_inst[module_idP]. + scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); + + } else { + bsr_t = NULL; + bsr_s->LCGID = lcg_id_bsr_trunc; + bsr_s->Buffer_size = + UE_mac_inst[module_idP].scheduling_info. + BSR[lcg_id_bsr_trunc]; + + LOG_D(MAC, + "[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].BSR_reporting_active, + UE_mac_inst[module_idP]. + scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); + } + } // 1-bit padding or 2-bit padding special padding subheader // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 - if (sdu_length_total) { - padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - rlc_pdu_header_len_last + sdu_length_total + 1); - } - else { - padding_len = buflen - (bsr_len + phr_len); - } - - if (padding_len <= 2) { - short_padding = padding_len; - // only add padding header - post_padding = 0; - //update total MAC Hdr size for RLC data if (sdu_length_total) { - total_rlc_pdu_header_len = total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1; - rlc_pdu_header_len_last = 1; - } - } - else if (sdu_length_total) { - post_padding = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); - // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding - if (post_padding == 0) { - total_rlc_pdu_header_len -= rlc_pdu_header_len_last; - padding_len = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); - short_padding = padding_len; - total_rlc_pdu_header_len ++; - } - } - else { - if (padding_len == buflen) {// nona mac pdu - *access_mode=CANCELED_ACCESS; + padding_len = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - + rlc_pdu_header_len_last + sdu_length_total + 1); + } else { + padding_len = buflen - (bsr_len + phr_len); } - short_padding = 0; - - post_padding = buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + sdu_length_total + 1); - } - - // Generate header - // if (num_sdus>0) { - - payload_offset = generate_ulsch_header(ulsch_buffer, // mac header - num_sdus, // num sdus - short_padding, // short pading - sdu_lengths, // sdu length - sdu_lcids, // sdu lcid - phr_p, // power headroom - NULL, // crnti - bsr_t, // truncated bsr - bsr_s, // short bsr - bsr_l, - post_padding); // long_bsr - - LOG_D(MAC, - "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n", - module_idP,buflen, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],payload_offset, total_rlc_pdu_header_len, - short_padding,post_padding, bsr_len, phr_len,buflen-sdu_length_total-payload_offset); - // cycle through SDUs and place in ulsch_buffer - if (sdu_length_total) { - memcpy(&ulsch_buffer[payload_offset],ulsch_buff,sdu_length_total); - } - - // fill remainder of DLSCH with random data - if (post_padding) { - for (j=0; j<(buflen-sdu_length_total-payload_offset); j++) { - ulsch_buffer[payload_offset+sdu_length_total+j] = (char)(taus()&0xff); - } - } - LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", module_idP); - UE_mac_inst[module_idP].scheduling_info.SR_pending=0; - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; - - /* Actions when a BSR is sent */ - if (bsr_ce_len) - { - LOG_D(MAC,"[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n", - module_idP, bsr_ce_len, bsr_header_len, buflen); - - // Reset ReTx BSR Timer - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + if (padding_len <= 2) { + short_padding = padding_len; + // only add padding header + post_padding = 0; + //update total MAC Hdr size for RLC data + if (sdu_length_total) { + total_rlc_pdu_header_len = + total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1; + rlc_pdu_header_len_last = 1; + } + } else if (sdu_length_total) { + post_padding = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1); + // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding + if (post_padding == 0) { + total_rlc_pdu_header_len -= rlc_pdu_header_len_last; + padding_len = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1); + short_padding = padding_len; + total_rlc_pdu_header_len++; + } + } else { + if (padding_len == buflen) { // nona mac pdu + *access_mode = CANCELED_ACCESS; + } - LOG_D(MAC,"[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP, - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF); + short_padding = 0; - // Reset Periodic Timer except when BSR is truncated - if ((bsr_t == NULL) && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != PeriodicBSR_Timer_r12_infinity)) - { - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); + post_padding = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1); + } - LOG_D(MAC,"[UE %d] MAC Periodic BSR Timer Reset =%d\n", - module_idP, UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF); + // Generate header + // if (num_sdus>0) { - } + payload_offset = generate_ulsch_header(ulsch_buffer, // mac header + num_sdus, // num sdus + short_padding, // short pading + sdu_lengths, // sdu length + sdu_lcids, // sdu lcid + phr_p, // power headroom + NULL, // crnti + bsr_t, // truncated bsr + bsr_s, // short bsr + bsr_l, post_padding); // long_bsr - // Reset BSR Trigger flags - UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; - } + LOG_D(MAC, + "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n", + module_idP, buflen, sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], payload_offset, total_rlc_pdu_header_len, + short_padding, post_padding, bsr_len, phr_len, + buflen - sdu_length_total - payload_offset); + // cycle through SDUs and place in ulsch_buffer + if (sdu_length_total) { + memcpy(&ulsch_buffer[payload_offset], ulsch_buff, + sdu_length_total); + } + // fill remainder of DLSCH with random data + if (post_padding) { + for (j = 0; j < (buflen - sdu_length_total - payload_offset); j++) { + ulsch_buffer[payload_offset + sdu_length_total + j] = + (char) (taus() & 0xff); + } + } + LOG_D(MAC, + "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", + module_idP); + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; + + /* Actions when a BSR is sent */ + if (bsr_ce_len) { + LOG_D(MAC, + "[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n", + module_idP, bsr_ce_len, bsr_header_len, buflen); + + // Reset ReTx BSR Timer + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = + get_sf_retxBSRTimer(UE_mac_inst[module_idP]. + scheduling_info.retxBSR_Timer); + + LOG_D(MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP, + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF); + + // Reset Periodic Timer except when BSR is truncated + if ((bsr_t == NULL) + && (UE_mac_inst[module_idP].scheduling_info. + periodicBSR_Timer != PeriodicBSR_Timer_r12_infinity)) { + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = + get_sf_periodicBSRTimer(UE_mac_inst + [module_idP].scheduling_info. + periodicBSR_Timer); + + LOG_D(MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n", + module_idP, + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF); + + } + // Reset BSR Trigger flags + UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; + } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); + stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); #endif - - if (opt_enabled) { - trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].txFrame, UE_mac_inst[module_idP].txSubframe, 0, 0); - LOG_D(OPT,"[UE %d][ULSCH] Frame %d subframe %d trace pdu for rnti %x with size %d\n", - module_idP, frameP, subframe, UE_mac_inst[module_idP].crnti, buflen); - } + if (opt_enabled) { + trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, + UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].txFrame, + UE_mac_inst[module_idP].txSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][ULSCH] Frame %d subframe %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, subframe, UE_mac_inst[module_idP].crnti, + buflen); + } } @@ -1942,281 +2276,337 @@ for (lcid=DCCH; (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE) ; lcid // 4. Perform PHR procedures UE_L2_STATE_t -ue_scheduler( - const module_id_t module_idP, - const frame_t rxFrameP, - const sub_frame_t rxSubframeP, - const frame_t txFrameP, - const sub_frame_t txSubframeP, - const lte_subframe_t directionP, - const uint8_t eNB_indexP, - const int CC_id) +ue_scheduler(const module_id_t module_idP, + const frame_t rxFrameP, + const sub_frame_t rxSubframeP, + const frame_t txFrameP, + const sub_frame_t txSubframeP, + const lte_subframe_t directionP, + const uint8_t eNB_indexP, const int CC_id) //------------------------------------------------------------------------------ { - int lcid; // lcid index - int TTI= 1; - int bucketsizeduration = -1; - int bucketsizeduration_max = -1; - // mac_rlc_status_resp_t rlc_status[MAX_NUM_LCGID]; // 4 - // int8_t lcg_id; - struct RACH_ConfigCommon *rach_ConfigCommon = (struct RACH_ConfigCommon *)NULL; - protocol_ctxt_t ctxt; + int lcid; // lcid index + int TTI = 1; + int bucketsizeduration = -1; + int bucketsizeduration_max = -1; + // mac_rlc_status_resp_t rlc_status[MAX_NUM_LCGID]; // 4 + // int8_t lcg_id; + struct RACH_ConfigCommon *rach_ConfigCommon = + (struct RACH_ConfigCommon *) NULL; + protocol_ctxt_t ctxt; #if defined(ENABLE_ITTI) - MessageDef *msg_p; - const char *msg_name; - instance_t instance; - int result; + MessageDef *msg_p; + const char *msg_name; + instance_t instance; + int result; #endif #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].ue_scheduler); + start_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_IN); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_IN); - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO, UE_mac_inst[module_idP].crnti, txFrameP, txSubframeP,eNB_indexP); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO, + UE_mac_inst[module_idP].crnti, txFrameP, + txSubframeP, eNB_indexP); #if defined(ENABLE_ITTI) - do { - // Checks if a message has been sent to MAC sub-task - itti_poll_msg (TASK_MAC_UE, &msg_p); + do { + // Checks if a message has been sent to MAC sub-task + itti_poll_msg(TASK_MAC_UE, &msg_p); - if (msg_p != NULL) { - msg_name = ITTI_MSG_NAME (msg_p); - instance = ITTI_MSG_INSTANCE (msg_p); + if (msg_p != NULL) { + msg_name = ITTI_MSG_NAME(msg_p); + instance = ITTI_MSG_INSTANCE(msg_p); - switch (ITTI_MSG_ID(msg_p)) { - case RRC_MAC_CCCH_DATA_REQ: - LOG_I(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", - msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, - RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index); + switch (ITTI_MSG_ID(msg_p)) { + case RRC_MAC_CCCH_DATA_REQ: + LOG_I(MAC, + "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", + msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, + RRC_MAC_CCCH_DATA_REQ(msg_p).frame, + RRC_MAC_CCCH_DATA_REQ(msg_p).enb_index); - // TODO process CCCH data req. - break; + // TODO process CCCH data req. + break; - default: - LOG_E(MAC, "Received unexpected message %s\n", msg_name); - break; - } + default: + LOG_E(MAC, "Received unexpected message %s\n", msg_name); + break; + } - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + AssertFatal(result == EXIT_SUCCESS, + "Failed to free memory (%d)!\n", result); + } } - } while(msg_p != NULL); + while (msg_p != NULL); #endif - //Mac_rlc_xface->frameP=frameP; - //Rrc_xface->Frame_index=Mac_rlc_xface->frameP; - //if (subframe%5 == 0) - //LG#ifdef EXMIMO - pdcp_run(&ctxt); - //#endif - UE_mac_inst[module_idP].txFrame = txFrameP; - UE_mac_inst[module_idP].txSubframe = txSubframeP; - UE_mac_inst[module_idP].rxFrame = rxFrameP; - UE_mac_inst[module_idP].rxSubframe = rxSubframeP; + //Mac_rlc_xface->frameP=frameP; + //Rrc_xface->Frame_index=Mac_rlc_xface->frameP; + //if (subframe%5 == 0) + //LG#ifdef EXMIMO + pdcp_run(&ctxt); + //#endif + UE_mac_inst[module_idP].txFrame = txFrameP; + UE_mac_inst[module_idP].txSubframe = txSubframeP; + UE_mac_inst[module_idP].rxFrame = rxFrameP; + UE_mac_inst[module_idP].rxSubframe = rxSubframeP; #ifdef CELLULAR - rrc_rx_tx(module_idP, txFrameP, 0, eNB_indexP); + rrc_rx_tx_ue(module_idP, txFrameP, 0, eNB_indexP); #else - switch (rrc_rx_tx(&ctxt, - eNB_indexP, - CC_id)) { - case RRC_OK: - break; + switch (rrc_rx_tx_ue(&ctxt, eNB_indexP, CC_id)) { + case RRC_OK: + break; - case RRC_ConnSetup_failed: - LOG_E(MAC,"RRCConnectionSetup failed, returning to IDLE state\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + case RRC_ConnSetup_failed: + LOG_E(MAC, "RRCConnectionSetup failed, returning to IDLE state\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return(CONNECTION_LOST); - break; + return (CONNECTION_LOST); + break; - case RRC_PHY_RESYNCH: - LOG_E(MAC,"RRC Loss of synch, returning PHY_RESYNCH\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + case RRC_PHY_RESYNCH: + LOG_E(MAC, "RRC Loss of synch, returning PHY_RESYNCH\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return(PHY_RESYNCH); - - case RRC_Handover_failed: - LOG_N(MAC,"Handover failure for UE %d eNB_index %d\n",module_idP,eNB_indexP); - //Invalid...need to add another MAC UE state for re-connection procedure - phy_config_afterHO_ue(module_idP,0,eNB_indexP,(MobilityControlInfo_t *)NULL,1); - //return(3); - break; - - case RRC_HO_STARTED: - LOG_I(MAC,"RRC handover, Instruct PHY to start the contention-free PRACH and synchronization\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + return (PHY_RESYNCH); + + case RRC_Handover_failed: + LOG_N(MAC, "Handover failure for UE %d eNB_index %d\n", module_idP, + eNB_indexP); + //Invalid...need to add another MAC UE state for re-connection procedure + phy_config_afterHO_ue(module_idP, 0, eNB_indexP, + (MobilityControlInfo_t *) NULL, 1); + //return(3); + break; + + case RRC_HO_STARTED: + LOG_I(MAC, + "RRC handover, Instruct PHY to start the contention-free PRACH and synchronization\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return(PHY_HO_PRACH); + return (PHY_HO_PRACH); - default: - break; - } + default: + break; + } #endif - // Check Contention resolution timer (put in a function later) - if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) { + // Check Contention resolution timer (put in a function later) + if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) { - if (UE_mac_inst[module_idP].radioResourceConfigCommon) { - rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; - } else { - LOG_E(MAC,"FATAL: radioResourceConfigCommon is NULL!!!\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { + rach_ConfigCommon = + &UE_mac_inst[module_idP]. + radioResourceConfigCommon->rach_ConfigCommon; + } else { + LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, + VCD_FUNCTION_OUT); - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); - AssertFatal(1==0,""); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + AssertFatal(1 == 0, ""); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - //return(RRC_OK); - } - - LOG_I(MAC,"Frame %d: Contention resolution timer %d/%ld\n",txFrameP,UE_mac_inst[module_idP].RA_contention_resolution_cnt, - ((1+rach_ConfigCommon->ra_SupervisionInfo.mac_ContentionResolutionTimer)<<3)); - - UE_mac_inst[module_idP].RA_contention_resolution_cnt++; - if (UE_mac_inst[module_idP].RA_contention_resolution_cnt == - ((1+rach_ConfigCommon->ra_SupervisionInfo.mac_ContentionResolutionTimer)<<3)) { - UE_mac_inst[module_idP].RA_active = 0; - UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; - // Signal PHY to quit RA procedure - LOG_E(MAC,"Module id %u Contention resolution timer expired, RA failed\n", module_idP); - ra_failed(module_idP,0,eNB_indexP); + //return(RRC_OK); + } + + LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n", + txFrameP, + UE_mac_inst[module_idP].RA_contention_resolution_cnt, + ((1 + + rach_ConfigCommon-> + ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)); + + UE_mac_inst[module_idP].RA_contention_resolution_cnt++; + + if (UE_mac_inst[module_idP].RA_contention_resolution_cnt == + ((1 + + rach_ConfigCommon-> + ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)) { + UE_mac_inst[module_idP].RA_active = 0; + UE_mac_inst[module_idP].RA_contention_resolution_timer_active = + 0; + // Signal PHY to quit RA procedure + LOG_E(MAC, + "Module id %u Contention resolution timer expired, RA failed\n", + module_idP); + if(nfapi_mode == 3) { // Panos: phy_stub mode + // Panos: Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to + // PRACH state. + UE_mac_inst[module_idP].UE_mode[eNB_indexP] = PRACH; + //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + } + else{ + ra_failed(module_idP, CC_id, eNB_indexP); + } + //ra_failed(module_idP, 0, eNB_indexP); + } } - } - - - // Get RLC status info and update Bj for all lcids that are active - for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++ ) { - if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) { - // meausre the Bj - if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { - if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters) { - bucketsizeduration = UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->prioritisedBitRate * TTI; - bucketsizeduration_max = get_ms_bucketsizeduration(UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->bucketSizeDuration); - } else { - LOG_E(MAC,"[UE %d] lcid %d, NULL ul_SpecificParameters\n",module_idP,lcid); - AssertFatal(1==0,""); - } - - if ( UE_mac_inst[module_idP].scheduling_info.Bj[lcid] > bucketsizeduration_max ) { - UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = bucketsizeduration_max; - } else { - UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = bucketsizeduration; - } - } - - - /* - if (lcid == DCCH) { - LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n", - module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], -// UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); - } - */ + // Get RLC status info and update Bj for all lcids that are active + for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) { + // meausre the Bj + if ((directionP == SF_UL) + && (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { + if (UE_mac_inst[module_idP]. + logicalChannelConfig[lcid]->ul_SpecificParameters) { + bucketsizeduration = + UE_mac_inst[module_idP].logicalChannelConfig + [lcid]->ul_SpecificParameters->prioritisedBitRate * + TTI; + bucketsizeduration_max = + get_ms_bucketsizeduration(UE_mac_inst + [module_idP].logicalChannelConfig + [lcid]->ul_SpecificParameters->bucketSizeDuration); + } else { + LOG_E(MAC, + "[UE %d] lcid %d, NULL ul_SpecificParameters\n", + module_idP, lcid); + AssertFatal(1 == 0, ""); + } + + if (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] > + bucketsizeduration_max) { + UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = + bucketsizeduration_max; + } else { + UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = + bucketsizeduration; + } + } + + + /* + if (lcid == DCCH) { + LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n", + module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + // UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + } + */ + } } - } - - // Call BSR procedure as described in Section 5.4.5 in 36.321 - // First check ReTxBSR Timer because it is always configured - // Decrement ReTxBSR Timer if it is running and not null - if ((UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING) - && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != 0)){ - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF --; - } - - // Decrement Periodic Timer if it is running and not null - if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != MAC_UE_BSR_TIMER_NOT_RUNNING) - && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != 0)){ - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; - } - - //Check whether Regular BSR is triggered - if (update_bsr(module_idP,txFrameP, txSubframeP,eNB_indexP) == TRUE) { - // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures - // outlined in Sections 5.4.4 an 5.4.5 of 36.321 - UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; - // Regular BSR trigger - UE_mac_inst[module_idP].BSR_reporting_active |= BSR_TRIGGER_REGULAR; - LOG_D(MAC,"[UE %d][BSR] Regular BSR Triggered Frame %d subframe %d SR for PUSCH is pending\n", - module_idP, txFrameP,txSubframeP); - } + // Call BSR procedure as described in Section 5.4.5 in 36.321 - // UE has no valid phy config dedicated || no valid/released SR - if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) { - // cancel all pending SRs - UE_mac_inst[module_idP].scheduling_info.SR_pending=0; - UE_mac_inst[module_idP].ul_active=0; - LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + // First check ReTxBSR Timer because it is always configured + // Decrement ReTxBSR Timer if it is running and not null + if ((UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != + MAC_UE_BSR_TIMER_NOT_RUNNING) + && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != 0)) { + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; + } + // Decrement Periodic Timer if it is running and not null + if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != + MAC_UE_BSR_TIMER_NOT_RUNNING) + && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != 0)) { + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; + } + //Check whether Regular BSR is triggered + if (update_bsr(module_idP, txFrameP, txSubframeP, eNB_indexP) == TRUE) { + // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures + // outlined in Sections 5.4.4 an 5.4.5 of 36.321 + UE_mac_inst[module_idP].scheduling_info.SR_pending = 1; + // Regular BSR trigger + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_REGULAR; + LOG_D(MAC, + "[UE %d][BSR] Regular BSR Triggered Frame %d subframe %d SR for PUSCH is pending\n", + module_idP, txFrameP, txSubframeP); + } + // UE has no valid phy config dedicated || no valid/released SR + if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) { + // cancel all pending SRs + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].ul_active = 0; + LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return(CONNECTION_OK); - } - - if ((UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig == NULL) || - (UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->present == SchedulingRequestConfig_PR_release)) { - - // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5 - - // cancel all pending SRs - UE_mac_inst[module_idP].scheduling_info.SR_pending=0; - UE_mac_inst[module_idP].ul_active=0; - LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); - } + return (CONNECTION_OK); + } - // Put this in a function - // Call PHR procedure as described in Section 5.4.6 in 36.321 - if (UE_mac_inst[module_idP].PHR_state == MAC_MainConfig__phr_Config_PR_setup) { // normal operation + if ((UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig == NULL) + || (UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->present == + SchedulingRequestConfig_PR_release)) { - if (UE_mac_inst[module_idP].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers - UE_mac_inst[module_idP].PHR_reporting_active = 1; - UE_mac_inst[module_idP].PHR_reconfigured = 0; - } else { - //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].PHR_reporting_active); - if ((UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF <= 0) && - ((get_PL(module_idP,0,eNB_indexP) < UE_mac_inst[module_idP].scheduling_info.PathlossChange_db) || - (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] > UE_mac_inst[module_idP].scheduling_info.PathlossChange_db))) - // trigger PHR and reset the timer later when the PHR report is sent - { - UE_mac_inst[module_idP].PHR_reporting_active = 1; - } else if (UE_mac_inst[module_idP].PHR_reporting_active ==0 ) { - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--; - } + // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5 - if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <= 0 ) - // trigger PHR and reset the timer later when the PHR report is sent - { - UE_mac_inst[module_idP].PHR_reporting_active = 1; - } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0 ) { - UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--; - } + // cancel all pending SRs + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].ul_active = 0; + LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP); + } + // Put this in a function + // Call PHR procedure as described in Section 5.4.6 in 36.321 + if (UE_mac_inst[module_idP].PHR_state == MAC_MainConfig__phr_Config_PR_setup) { // normal operation + + if (UE_mac_inst[module_idP].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers + UE_mac_inst[module_idP].PHR_reporting_active = 1; + UE_mac_inst[module_idP].PHR_reconfigured = 0; + } else { + //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].PHR_reporting_active); + if ((UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF <= + 0) + && + ((get_PL(module_idP, 0, eNB_indexP) < + UE_mac_inst[module_idP].scheduling_info. + PathlossChange_db) + || (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] > + UE_mac_inst[module_idP]. + scheduling_info.PathlossChange_db))) + // trigger PHR and reset the timer later when the PHR report is sent + { + UE_mac_inst[module_idP].PHR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) { + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--; + } + + if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <= + 0) + // trigger PHR and reset the timer later when the PHR report is sent + { + UE_mac_inst[module_idP].PHR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) { + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--; + } + } + } else { // release / nothing + UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR } - } else { // release / nothing - UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR - } - //If the UE has UL resources allocated for new transmission for this TTI here: - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + //If the UE has UL resources allocated for new transmission for this TTI here: + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return(CONNECTION_OK); + return (CONNECTION_OK); } // to be improved @@ -2224,156 +2614,169 @@ ue_scheduler( extern int cba_backoff; double uniform_rngen(int min, int max) { - double random = (double)taus()/((double)0xffffffff); - return (max - min) * random + min; + double random = (double) taus() / ((double) 0xffffffff); + return (max - min) * random + min; } -int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen) +int +cba_access(module_id_t module_idP, frame_t frameP, + sub_frame_t subframe, uint8_t eNB_index, uint16_t buflen) { - mac_rlc_status_resp_t rlc_status; - int header_offset=4; - int rv =0; - - /* - if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff - // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe, - // UE_mac_inst[module_idP].cba_last_access[0] ); - - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,40)); - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - - rv=1; - } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ - - UE_mac_inst[module_idP].cba_last_access[0]-=1; - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - - } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 )) && - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 )) && - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] == 0 )) ) - && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ - UE_mac_inst[module_idP].cba_last_access[0]-=1; - }*/ - - if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]<64) ) { - return 0; - } - - if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0 ) && - (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0 ) && - (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0 ) ) { - return 0; - } - - if (cba_backoff == 0 ) { // apply probablisitc method - UE_mac_inst[module_idP].cba_last_access[0]= uniform_rngen(0,1); - - if (uniform_rngen(0,1) > 0.6 ) { - LOG_I(MAC,"[UE %d] Frame %d Subframe %d: CBA probability-based backoff (%d), UL active state %d \n", module_idP, frameP, subframe, - cba_backoff,UE_mac_inst[module_idP].ul_active); - - rv=1; + mac_rlc_status_resp_t rlc_status; + int header_offset = 4; + int rv = 0; + + /* + if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff + // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe, + // UE_mac_inst[module_idP].cba_last_access[0] ); + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,40)); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + + rv=1; + } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ + + UE_mac_inst[module_idP].cba_last_access[0]-=1; + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + + } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 )) && + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 )) && + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] == 0 )) ) + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ + UE_mac_inst[module_idP].cba_last_access[0]-=1; + } */ + + if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] > 0) + && (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] < 64)) { + return 0; } - } else { - if (UE_mac_inst[module_idP].cba_last_access[0] <= 0) { - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff)); - - LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active); + if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0) && + (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0) && + (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0)) { + return 0; + } - rv = 1; - /* - rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index - DTCH, - 0); + if (cba_backoff == 0) { // apply probablisitc method + UE_mac_inst[module_idP].cba_last_access[0] = uniform_rngen(0, 1); - if (( - // (rlc_status.pdus_in_buffer > 0 ) && - // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive - (rlc_status.head_sdu_is_segmented == 0 ) && - ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) - )){ - rv = 1; + if (uniform_rngen(0, 1) > 0.6) { + LOG_I(MAC, + "[UE %d] Frame %d Subframe %d: CBA probability-based backoff (%d), UL active state %d \n", + module_idP, frameP, subframe, cba_backoff, + UE_mac_inst[module_idP].ul_active); - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - */ + rv = 1; + } } else { - UE_mac_inst[module_idP].cba_last_access[0]-=1; - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - } - } - return rv; - /* - if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { - - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff)); - - LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active); - - rv = 1; - - rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index - DTCH, - 0); - - if (( - // (rlc_status.pdus_in_buffer > 0 ) && - // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive - (rlc_status.head_sdu_is_segmented == 0 ) && - ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) - )){ - rv = 1; - - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - } else - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,5)); - - - } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ) - { + if (UE_mac_inst[module_idP].cba_last_access[0] <= 0) { + UE_mac_inst[module_idP].cba_last_access[0] = + round(uniform_rngen(1, cba_backoff)); + + LOG_I(MAC, + "[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], cba_backoff, + UE_mac_inst[module_idP].ul_active); + + rv = 1; + /* + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + DTCH, + 0); + + if (( + // (rlc_status.pdus_in_buffer > 0 ) && + // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive + (rlc_status.head_sdu_is_segmented == 0 ) && + ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) + )){ + rv = 1; + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + */ + } else { + UE_mac_inst[module_idP].cba_last_access[0] -= 1; + LOG_D(MAC, + "[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], + UE_mac_inst[module_idP].ul_active); + } + } - UE_mac_inst[module_idP].cba_last_access[0]-=1; - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - } - } - */ + return rv; + /* + if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff)); + + LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active); + + rv = 1; + + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + DTCH, + 0); + + if (( + // (rlc_status.pdus_in_buffer > 0 ) && + // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive + (rlc_status.head_sdu_is_segmented == 0 ) && + ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) + )){ + rv = 1; + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + } else + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,5)); + + + } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ) + { + + UE_mac_inst[module_idP].cba_last_access[0]-=1; + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + } + } + */ } #endif -boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP,eNB_index_t eNB_index) +boolean_t +update_bsr(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP, eNB_index_t eNB_index) { mac_rlc_status_resp_t rlc_status; @@ -2462,290 +2865,315 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subfra } while ((array_index < num_lcid_with_data) && (array_index < MAX_NUM_LCID)); } - } - } + } + } - } - - // Check whether a regular BSR can be triggered according to the first cases in 36.321 - if (num_lcid_with_data) - { - LOG_D(MAC,"[UE %d] PDCCH Tick at frame %d subframe %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n", - module_idP, frameP, subframeP,num_lcid_with_data,lcid_reordered_array[0],lcid_reordered_array[1],lcid_reordered_array[2]); - - for (array_index=0; array_index < num_lcid_with_data; array_index++) - { - lcid = lcid_reordered_array[array_index]; - /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity - either the data belongs to a logical channel with higher priority than the priorities of the logical channels - which belong to any LCG and for which data is already available for transmission - */ - if ((UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] == 0) - /* or there is no data available for any of the logical channels which belong to a LCG */ - ||(lcgid_buffer_remain[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == 0) - ) - { - bsr_regular_triggered = TRUE; - - LOG_D(MAC,"[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d subframe %d\n", - module_idP, lcid,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid],frameP, subframeP); - - break; - } - } - - // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission - if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0) - { - bsr_regular_triggered = TRUE; - - if ((UE_mac_inst[module_idP].BSR_reporting_active & BSR_TRIGGER_REGULAR) == 0) { - LOG_I(MAC,"[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n", - module_idP, frameP, subframeP); - } - - } - } + } - //Store Buffer Occupancy in remain buffers for next TTI - for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) - { - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = lcid_bytes_in_buffer[lcid]; - } + // Check whether a regular BSR can be triggered according to the first cases in 36.321 + if (num_lcid_with_data) { + LOG_D(MAC, + "[UE %d] PDCCH Tick at frame %d subframe %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n", + module_idP, frameP, subframeP, num_lcid_with_data, + lcid_reordered_array[0], lcid_reordered_array[1], + lcid_reordered_array[2]); + + for (array_index = 0; array_index < num_lcid_with_data; + array_index++) { + lcid = lcid_reordered_array[array_index]; + /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity + either the data belongs to a logical channel with higher priority than the priorities of the logical channels + which belong to any LCG and for which data is already available for transmission + */ + if ((UE_mac_inst[module_idP]. + scheduling_info.LCID_buffer_remain[lcid] == 0) + /* or there is no data available for any of the logical channels which belong to a LCG */ + || + (lcgid_buffer_remain + [UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == + 0)) { + bsr_regular_triggered = TRUE; + + LOG_D(MAC, + "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d subframe %d\n", + module_idP, lcid, + UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], + frameP, subframeP); + + break; + } + } + + // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0) { + bsr_regular_triggered = TRUE; + + if ((UE_mac_inst[module_idP].BSR_reporting_active & + BSR_TRIGGER_REGULAR) == 0) { + LOG_I(MAC, + "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n", + module_idP, frameP, subframeP); + } + + } + } + //Store Buffer Occupancy in remain buffers for next TTI + for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = + lcid_bytes_in_buffer[lcid]; + } - return bsr_regular_triggered; + return bsr_regular_triggered; } -uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) +uint8_t +locate_BsrIndexByBufferSize(const uint32_t * table, int size, int value) { - uint8_t ju, jm, jl; - int ascend; + uint8_t ju, jm, jl; + int ascend; - DevAssert( size > 0 ); - DevAssert( size <= 256 ); + DevAssert(size > 0); + DevAssert(size <= 256); - if (value == 0) { - return 0; //elseif (value > 150000) return 63; - } + if (value == 0) { + return 0; //elseif (value > 150000) return 63; + } - jl = 0; // lower bound - ju = size - 1; // upper bound - ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise + jl = 0; // lower bound + ju = size - 1; // upper bound + ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise - while (ju-jl > 1) { //If we are not yet done, - jm = (ju+jl) >> 1; //compute a midpoint, + while (ju - jl > 1) { //If we are not yet done, + jm = (ju + jl) >> 1; //compute a midpoint, - if ((value >= table[jm]) == ascend) { - jl=jm; // replace the lower limit - } else { - ju=jm; //replace the upper limit - } + if ((value >= table[jm]) == ascend) { + jl = jm; // replace the lower limit + } else { + ju = jm; //replace the upper limit + } - LOG_T(MAC,"[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", jm, table[jm], value); - } + LOG_T(MAC, + "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", + jm, table[jm], value); + } - if (value == table[jl]) { - return jl; - } else { - return jl+1; //equally ju - } + if (value == table[jl]) { + return jl; + } else { + return jl + 1; //equally ju + } } int get_sf_periodicBSRTimer(uint8_t sf_offset) { - switch (sf_offset) { - case PeriodicBSR_Timer_r12_sf5: - return 5; - break; + switch (sf_offset) { + case PeriodicBSR_Timer_r12_sf5: + return 5; + break; - case PeriodicBSR_Timer_r12_sf10: - return 10; - break; + case PeriodicBSR_Timer_r12_sf10: + return 10; + break; - case PeriodicBSR_Timer_r12_sf16: - return 16; - break; + case PeriodicBSR_Timer_r12_sf16: + return 16; + break; - case PeriodicBSR_Timer_r12_sf20: - return 20; - break; + case PeriodicBSR_Timer_r12_sf20: + return 20; + break; - case PeriodicBSR_Timer_r12_sf32: - return 32; - break; + case PeriodicBSR_Timer_r12_sf32: + return 32; + break; - case PeriodicBSR_Timer_r12_sf40: - return 40; - break; + case PeriodicBSR_Timer_r12_sf40: + return 40; + break; - case PeriodicBSR_Timer_r12_sf64: - return 64; - break; + case PeriodicBSR_Timer_r12_sf64: + return 64; + break; - case PeriodicBSR_Timer_r12_sf80: - return 80; - break; + case PeriodicBSR_Timer_r12_sf80: + return 80; + break; - case PeriodicBSR_Timer_r12_sf128: - return 128; - break; + case PeriodicBSR_Timer_r12_sf128: + return 128; + break; - case PeriodicBSR_Timer_r12_sf160: - return 160; - break; + case PeriodicBSR_Timer_r12_sf160: + return 160; + break; - case PeriodicBSR_Timer_r12_sf320: - return 320; - break; + case PeriodicBSR_Timer_r12_sf320: + return 320; + break; - case PeriodicBSR_Timer_r12_sf640: - return 640; - break; + case PeriodicBSR_Timer_r12_sf640: + return 640; + break; - case PeriodicBSR_Timer_r12_sf1280: - return 1280; - break; + case PeriodicBSR_Timer_r12_sf1280: + return 1280; + break; - case PeriodicBSR_Timer_r12_sf2560: - return 2560; - break; + case PeriodicBSR_Timer_r12_sf2560: + return 2560; + break; - case PeriodicBSR_Timer_r12_infinity: - default: - return 0xFFFF; - break; - } + case PeriodicBSR_Timer_r12_infinity: + default: + return 0xFFFF; + break; + } } int get_sf_retxBSRTimer(uint8_t sf_offset) { - switch (sf_offset) { - case RetxBSR_Timer_r12_sf320: - return 320; - break; + switch (sf_offset) { + case RetxBSR_Timer_r12_sf320: + return 320; + break; - case RetxBSR_Timer_r12_sf640: - return 640; - break; + case RetxBSR_Timer_r12_sf640: + return 640; + break; - case RetxBSR_Timer_r12_sf1280: - return 1280; - break; + case RetxBSR_Timer_r12_sf1280: + return 1280; + break; - case RetxBSR_Timer_r12_sf2560: - return 2560; - break; + case RetxBSR_Timer_r12_sf2560: + return 2560; + break; - case RetxBSR_Timer_r12_sf5120: - return 5120; - break; + case RetxBSR_Timer_r12_sf5120: + return 5120; + break; - case RetxBSR_Timer_r12_sf10240: - return 10240; - break; + case RetxBSR_Timer_r12_sf10240: + return 10240; + break; - default: - return -1; - break; - } + default: + return -1; + break; + } } + int get_ms_bucketsizeduration(uint8_t bucketsizeduration) { - switch (bucketsizeduration) { - case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50: - return 50; - break; - - case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100: - return 100; - break; - - case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms150: - return 150; - break; - - case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms300: - return 300; - break; - - case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms500: - return 500; - break; - - case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000: - return 1000; - break; - - default: - return 0; - break; - } + switch (bucketsizeduration) { + case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50: + return + 50; + break; + + case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100: + return + 100; + break; + + case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms150: + return + 150; + break; + + case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms300: + return + 300; + break; + + case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms500: + return + 500; + break; + + case LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000: + return + 1000; + break; + + default: + return 0; + break; + } } -void update_phr(module_id_t module_idP,int CC_id) +void update_phr(module_id_t module_idP, int CC_id) { - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); - - UE_mac_inst[module_idP].PHR_reporting_active =0; - UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); - // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF); + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + + UE_mac_inst[module_idP].PHR_reporting_active = 0; + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = + get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.periodicPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = + get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.prohibitPHR_Timer); + // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF); } -uint8_t get_phr_mapping (module_id_t module_idP, int CC_id, uint8_t eNB_index) + +uint8_t +get_phr_mapping(module_id_t module_idP, int CC_id, uint8_t eNB_index) { - AssertFatal(CC_id==0, - "Transmission on secondary CCs is not supported yet\n"); + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); - //power headroom reporting range is from -23 ...+40 dB, as described in 36313 - //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float - if (get_PHR(module_idP,CC_id,eNB_index) < -23) { - return 0; - } else if (get_PHR(module_idP,CC_id,eNB_index) >= 40) { - return 63; - } else { // -23 to 40 - return (uint8_t) get_PHR(module_idP,CC_id,eNB_index) + PHR_MAPPING_OFFSET; + //power headroom reporting range is from -23 ...+40 dB, as described in 36313 + //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float + if (get_PHR(module_idP, CC_id, eNB_index) < -23) { + return 0; + } else if (get_PHR(module_idP, CC_id, eNB_index) >= 40) { + return 63; + } else { // -23 to 40 + return (uint8_t) get_PHR(module_idP, CC_id, + eNB_index) + PHR_MAPPING_OFFSET; - } + } } + int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer) { - return (perioidicPHR_Timer+1)*10; + return (perioidicPHR_Timer + 1) * 10; } int get_sf_prohibitPHR_Timer(uint8_t prohibitPHR_Timer) { - return (prohibitPHR_Timer)*10; + return (prohibitPHR_Timer) * 10; } int get_db_dl_PathlossChange(uint8_t dl_PathlossChange) { - switch (dl_PathlossChange) { - case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1: - return 1; - break; - - case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB3: - return 3; - break; - - case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB6: - return 6; - break; - - case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_infinity: - default: - return -1; - break; - } + switch (dl_PathlossChange) { + case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1: + return 1; + break; + + case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB3: + return 3; + break; + + case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB6: + return 6; + break; + + case MAC_MainConfig__phr_Config__setup__dl_PathlossChange_infinity: + default: + return -1; + break; + } } @@ -2758,8 +3186,8 @@ SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t UE_MAC_INST *ue = &UE_mac_inst[Mod_id]; SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch; - - sldch->payload_length = mac_rrc_data_req(Mod_id, + // Panos: Ask TTN if we should be calling mac_rrc_data_req_ue() instead of mac_rrc_data_req() now! + /*sldch->payload_length = mac_rrc_data_req(Mod_id, CC_id, frame_tx, SL_DISCOVERY, @@ -2767,7 +3195,17 @@ SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t (char*)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0], 0, 0, //eNB_indexP - 0); + 0);*/ + + sldch->payload_length = mac_rrc_data_req_ue(Mod_id, + CC_id, + frame_tx, + SL_DISCOVERY, + 1, + (char*)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0], + 0, //eNB_indexP + 0); + if (sldch->payload_length >0 ) { diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 4ff54752530fe9e892d8bf93f355effd03d12c89..d153c82aeeef2e2ed132cd7c790ffd10150d18d5 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -32,27 +32,31 @@ #ifndef __MAC_VARS_H__ #define __MAC_VARS_H__ -#ifdef USER_MODE -//#include "stdio.h" -#endif //USER_MODE #include "PHY/defs.h" #include "defs.h" #include "COMMON/mac_rrc_primitives.h" -const uint32_t BSR_TABLE[BSR_TABLE_SIZE]= {0,10,12,14,17,19,22,26,31,36,42,49,57,67,78,91, - 105,125,146,171,200,234,274,321,376,440,515,603,706,826,967,1132, - 1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099, - 16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000 - }; -// extended bsr table--currently not used -const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,53,65,80,98,120,147, - 181,223,274,337,414,509,625,769,945,1162,1429, - 1757,2161,2657,3267,4017,4940,6074,7469,9185, - 11294,13888,17077,20999,25822,31752,39045,48012, - 59039,72598,89272,109774,134986,165989,204111, - 250990,308634,379519,466683,573866,705666,867737, - 1067031,1312097,1613447,1984009,2439678,3000000, - 6000000}; +const uint32_t BSR_TABLE[BSR_TABLE_SIZE] = + { 0, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78, 91, + 105, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603, 706, 826, + 967, 1132, + 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995, 4677, 5467, 6411, 7505, + 8787, 10287, 12043, 14099, + 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759, 58255, 68201, + 79846, 93479, 109439, 128125, 150000, 300000 +}; + +// extended bsr table--currently not used +const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = + { 0, 10, 13, 16, 19, 23, 29, 35, 43, 53, 65, 80, 98, 120, 147, + 181, 223, 274, 337, 414, 509, 625, 769, 945, 1162, 1429, + 1757, 2161, 2657, 3267, 4017, 4940, 6074, 7469, 9185, + 11294, 13888, 17077, 20999, 25822, 31752, 39045, 48012, + 59039, 72598, 89272, 109774, 134986, 165989, 204111, + 250990, 308634, 379519, 466683, 573866, 705666, 867737, + 1067031, 1312097, 1613447, 1984009, 2439678, 3000000, + 6000000 +}; //#define MAX_SIZE_OF_AGG3 576 //#define MAX_SIZE_OF_AGG2 288 @@ -64,24 +68,26 @@ const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,5 * this is also dependent to transmission mode, where an offset could be defined */ // the follwoing three tables are calibrated for TXMODE 1 and 2 -const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]= { - {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size= 37 bits - //{3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 41 - {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 41 - {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE = 43 - {3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0} // 20_DCI0_CRC_SIZE = 44 +const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE] = { + {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size= 37 bits + //{3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 41 + {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 41 + {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE = 43 + {3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0} // 20_DCI0_CRC_SIZE = 44 }; -const uint8_t cqi2fmt1x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]= { - {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size < 38 bits - {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE < 43 - {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE < 47 - {3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0} // 20_DCI0_CRC_SIZE < 55 + +const uint8_t cqi2fmt1x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE] = { + {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size < 38 bits + {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE < 43 + {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE < 47 + {3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0} // 20_DCI0_CRC_SIZE < 55 }; -const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]= { - {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size= 47 bits - {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 55 - {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE = 59 - {3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0} // 20_DCI0_CRC_SIZE = 64 + +const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE] = { + {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size= 47 bits + {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 55 + {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE = 59 + {3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0} // 20_DCI0_CRC_SIZE = 64 }; //uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181}; @@ -89,7 +95,7 @@ const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]= { uint32_t RRC_CONNECTION_FLAG; -UE_MAC_INST *UE_mac_inst; //[NB_MODULE_MAX]; +UE_MAC_INST *UE_mac_inst; //[NB_MODULE_MAX]; MAC_RLC_XFACE *Mac_rlc_xface; /// Primary component carrier index of eNB @@ -97,39 +103,39 @@ int pCC_id[NUMBER_OF_eNB_MAX]; -eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 -eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 +eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 +eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 #ifdef OPENAIR2 -unsigned char NB_eNB_INST=0; -unsigned char NB_UE_INST=0; -unsigned char NB_RN_INST=0; -unsigned char NB_INST=0; +unsigned char NB_eNB_INST = 0; +unsigned char NB_UE_INST = 0; +unsigned char NB_RN_INST = 0; +unsigned char NB_INST = 0; #endif -DCI0_5MHz_TDD_1_6_t UL_alloc_pdu; +DCI0_5MHz_TDD_1_6_t UL_alloc_pdu; -DCI1A_5MHz_TDD_1_6_t DLSCH_alloc_pdu1A; -DCI1A_5MHz_TDD_1_6_t RA_alloc_pdu; -DCI1A_5MHz_TDD_1_6_t BCCH_alloc_pdu; +DCI1A_5MHz_TDD_1_6_t DLSCH_alloc_pdu1A; +DCI1A_5MHz_TDD_1_6_t RA_alloc_pdu; +DCI1A_5MHz_TDD_1_6_t BCCH_alloc_pdu; -DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; -DCI1_5MHz_TDD_t DLSCH_alloc_pdu; +DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; +DCI1_5MHz_TDD_t DLSCH_alloc_pdu; #if defined(Rel10) || defined(Rel14) -DCI1C_5MHz_t MCCH_alloc_pdu; +DCI1C_5MHz_t MCCH_alloc_pdu; #endif -DCI0_5MHz_FDD_t UL_alloc_pdu_fdd; +DCI0_5MHz_FDD_t UL_alloc_pdu_fdd; -DCI1A_5MHz_FDD_t DLSCH_alloc_pdu1A_fdd; -DCI1A_5MHz_FDD_t RA_alloc_pdu_fdd; -DCI1A_5MHz_FDD_t BCCH_alloc_pdu_fdd; +DCI1A_5MHz_FDD_t DLSCH_alloc_pdu1A_fdd; +DCI1A_5MHz_FDD_t RA_alloc_pdu_fdd; +DCI1A_5MHz_FDD_t BCCH_alloc_pdu_fdd; -DCI1A_5MHz_FDD_t CCCH_alloc_pdu_fdd; -DCI1_5MHz_FDD_t DLSCH_alloc_pdu_fdd; +DCI1A_5MHz_FDD_t CCCH_alloc_pdu_fdd; +DCI1_5MHz_FDD_t DLSCH_alloc_pdu_fdd; DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu1; DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2; @@ -137,5 +143,3 @@ DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2; DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu1E; #endif - - diff --git a/openair2/LAYER2/Makefile.inc b/openair2/LAYER2/Makefile.inc index c0e4df5617a7faf659f048bf4fe75305cae9ba92..2f5cea7555462e485dcf00b0d1ec9dc10a98feb5 100644 --- a/openair2/LAYER2/Makefile.inc +++ b/openair2/LAYER2/Makefile.inc @@ -54,10 +54,6 @@ SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_reassembly.c SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_receiver.c SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_dar.c -ifeq ($(OPENAIR_EMU),1) -SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_very_simple_test.c -endif - SOURCES_L2 += $(RLC_DIR)/rlc_mac.c SOURCES_L2 += $(RLC_DIR)/rlc.c SOURCES_L2 += $(RLC_DIR)/rlc_rrc.c diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index dbcb25856574e625011b28387d18ceec642c4a64..174db3bdfa7b954b1f06b9f35961e606ac5870d6 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -30,9 +30,6 @@ #define PDCP_C //#define DEBUG_PDCP_FIFO_FLUSH_SDU -#ifndef USER_MODE -#include <rtai_fifos.h> -#endif #include "assertions.h" #include "hashtable.h" #include "pdcp.h" @@ -64,10 +61,10 @@ # include "gtpv1u.h" #endif -#ifndef OAI_EMU extern int otg_enabled; -#endif +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; //----------------------------------------------------------------------------- /* @@ -452,11 +449,6 @@ pdcp_data_ind( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_IN); -#ifdef OAI_EMU - - CHECK_CTXT_ARGS(ctxt_pP); - -#endif #ifdef PDCP_MSG_PRINT int i=0; LOG_F(PDCP,"[MSG] PDCP UL %s PDU on rb_id %d\n", (srb_flagP)? "CONTROL" : "DATA", rb_idP); @@ -651,11 +643,11 @@ pdcp_data_ind( PROTOCOL_PDCP_CTXT_FMT" DATA-IND len %u", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len); - rrc_data_ind(ctxt_pP, + rrc_data_ind(ctxt_pP, rb_id, sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len, (uint8_t*)&sdu_buffer_pP->data[pdcp_header_len]); - free_mem_block(sdu_buffer_pP, __func__); + // free_mem_block(new_sdu, __func__); if (ctxt_pP->enb_flag) { @@ -704,49 +696,6 @@ pdcp_data_ind( payload_offset=0; } -#if defined(USER_MODE) && defined(OAI_EMU) - - if (oai_emulation.info.otg_enabled == 1) { - //unsigned int dst_instance; - int ctime; - - if ((pdcp_p->rlc_mode == RLC_MODE_AM)&&(MBMS_flagP==0) ) { - pdcp_p->last_submitted_pdcp_rx_sn = sequence_number; - } - -#if defined(DEBUG_PDCP_PAYLOAD) - rlc_util_print_hex_octets(PDCP, - (unsigned char*)&sdu_buffer_pP->data[payload_offset], - sdu_buffer_sizeP - payload_offset); -#endif - - ctime = oai_emulation.info.time_ms; // avg current simulation time in ms : we may get the exact time through OCG? - if (MBMS_flagP == 0){ - LOG_D(PDCP, - PROTOCOL_PDCP_CTXT_FMT"Check received buffer : (dst %d)\n", - PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p), - ctxt_pP->instance); - } - if (otg_rx_pkt( - ctxt_pP->instance, - ctime, - (const char*)(&sdu_buffer_pP->data[payload_offset]), - sdu_buffer_sizeP - payload_offset ) == 0 ) { - free_mem_block(sdu_buffer_pP, __func__); - - if (ctxt_pP->enb_flag) { - stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_ind); - } else { - stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_ind); - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND,VCD_FUNCTION_OUT); - return TRUE; - } - } - -#else - if (otg_enabled==1) { LOG_D(OTG,"Discarding received packed\n"); free_mem_block(sdu_buffer_pP, __func__); @@ -761,9 +710,6 @@ pdcp_data_ind( return TRUE; } -#endif - - // XXX Decompression would be done at this point /* @@ -822,6 +768,13 @@ 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 + */ + ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = 1; +#endif } else { ((pdcp_data_ind_header_t*) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * maxDRB); } @@ -953,6 +906,21 @@ pdcp_run ( AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); break; + case RRC_PCCH_DATA_REQ: + { + sdu_size_t sdu_buffer_sizeP; + sdu_buffer_sizeP = RRC_PCCH_DATA_REQ(msg_p).sdu_size; + uint8_t CC_id = RRC_PCCH_DATA_REQ(msg_p).CC_id; + uint8_t ue_index = RRC_PCCH_DATA_REQ(msg_p).ue_index; + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_paging[ue_index] = sdu_buffer_sizeP; + if (sdu_buffer_sizeP > 0) { + memcpy(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].paging[ue_index], RRC_PCCH_DATA_REQ(msg_p).sdu_p, sdu_buffer_sizeP); + } + //paging pdcp log + LOG_D(PDCP, "PDCP Received RRC_PCCH_DATA_REQ CC_id %d length %d \n", CC_id, sdu_buffer_sizeP); + } + break; + default: LOG_E(PDCP, "Received unexpected message %s\n", msg_name); break; @@ -986,11 +954,6 @@ pdcp_run ( itti_send_msg_to_task(TASK_MAC_ENB, 3, msg_resp_p); } # endif -#endif - -#if defined(USER_MODE) && defined(OAI_EMU) - pdcp_fifo_read_input_sdus_from_otg(ctxt_pP); - #endif // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer @@ -1042,6 +1005,13 @@ pdcp_remove_UE( // check and remove SRBs first + for(int i = 0;i<NUMBER_OF_UE_MAX;i++){ + if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti){ + pdcp_eNB_UE_instance_to_rnti[i] = NOT_A_RNTI; + break; + } + } + for (srb_id=0; srb_id<2; srb_id++) { key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_YES); h_rc = hashtable_remove(pdcp_coll_p, key); @@ -1349,7 +1319,7 @@ rrc_pdcp_config_asn1_req ( for (cnt=0; cnt<drb2release_list_pP->list.count; cnt++) { pdrb_id_p = drb2release_list_pP->list.array[cnt]; drb_id = *pdrb_id_p; - key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, srb_id, SRB_FLAG_NO); + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, drb_id, SRB_FLAG_NO); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); if (h_rc != HASH_TABLE_OK) { @@ -1477,7 +1447,17 @@ pdcp_config_req_asn1 ( if (ctxt_pP->enb_flag == ENB_FLAG_YES) { pdcp_pP->is_ue = FALSE; //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; - pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; +// pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; + if( srb_flagP == SRB_FLAG_NO ) { + for(int i = 0;i<NUMBER_OF_UE_MAX;i++){ + if(pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] == NOT_A_RNTI){ + break; + } + pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; + } + pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; + pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; + } //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; } else { pdcp_pP->is_ue = TRUE; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 39639a103a59f7269fc3f7824efae0ee754f84ca..abefd0b7c7e8bec56a0e2f6c080dbd62a1153d46 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -33,14 +33,11 @@ #define PDCP_DEBUG 1 //#define DEBUG_PDCP_FIFO_FLUSH_SDU -#ifndef OAI_EMU extern int otg_enabled; -#endif #include "pdcp.h" #include "pdcp_primitives.h" -#ifdef USER_MODE #include <pthread.h> #include <errno.h> #include <stdio.h> @@ -48,9 +45,6 @@ extern int otg_enabled; #include <unistd.h> #define rtf_put write #define rtf_get read -#else -#include <rtai_fifos.h> -#endif //USER_MODE #include "../MAC/extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" @@ -860,25 +854,24 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) #ifdef PDCP_DEBUG LOG_I(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 % maxDRB; - ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index]; - } else { - ctxt.module_id = 0; - rab_id = pdcp_read_header_g.rb_id % maxDRB; - ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - } - + if (ctxt_cpy.enb_flag) { + ctxt.module_id = 0; + rab_id = pdcp_read_header_g.rb_id % maxDRB; + ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_read_header_g.rb_id / maxDRB]; + } else { + ctxt.module_id = 0; + rab_id = pdcp_read_header_g.rb_id % maxDRB; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; + } #endif - if (ctxt.enb_flag) { - if (rab_id != 0) { - rab_id = rab_id % 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 (ctxt.enb_flag) { + if (rab_id != 0) { + rab_id = rab_id % 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 @@ -1104,165 +1097,44 @@ 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) { - unsigned char *otg_pkt=NULL; - module_id_t dst_id; // dst for otg - rb_id_t rb_id; - unsigned int pkt_size=0; -#if defined(USER_MODE) && defined(OAI_EMU) - module_id_t src_id; - static unsigned int pkt_cnt_enb=0, pkt_cnt_ue=0; - - Packet_otg_elt_t *otg_pkt_info=NULL; - int result; - uint8_t pdcp_mode, is_ue=0; -#endif - protocol_ctxt_t ctxt; - // we need to add conditions to avoid transmitting data when the UE is not RRC connected. -#if defined(USER_MODE) && defined(OAI_EMU) - - if (oai_emulation.info.otg_enabled ==1 ) { - // module_id is source id - while ((otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[ctxt_pP->instance]))) != NULL) { - LOG_I(OTG,"Mod_id %d Frame %d Got a packet (%p), HEAD of otg_pdcp_buffer[%d] is %p and Nb elements is %d\n", - ctxt_pP->module_id, - ctxt_pP->frame, - otg_pkt_info, - ctxt_pP->instance, - pkt_list_get_head(&(otg_pdcp_buffer[ctxt_pP->instance])), - otg_pdcp_buffer[ctxt_pP->instance].nb_elements); - //otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id])); - dst_id = (otg_pkt_info->otg_pkt).dst_id; // type is module_id_t - src_id = (otg_pkt_info->otg_pkt).module_id; // type is module_id_t - rb_id = (otg_pkt_info->otg_pkt).rb_id; - is_ue = (otg_pkt_info->otg_pkt).is_ue; - pdcp_mode = (otg_pkt_info->otg_pkt).mode; - // LOG_I(PDCP,"pdcp_fifo, pdcp mode is= %d\n",pdcp_mode); - - // generate traffic if the ue is rrc reconfigured state - // if (mac_get_rrc_status(module_id, ctxt_pP->enb_flag, dst_id ) > 2 /*RRC_CONNECTED*/) { // not needed: this test is already done in update_otg_enb - otg_pkt = (unsigned char*) (otg_pkt_info->otg_pkt).sdu_buffer; - pkt_size = (otg_pkt_info->otg_pkt).sdu_buffer_size; - - if (otg_pkt != NULL) { - if (is_ue == 0 ) { - PROTOCOL_CTXT_SET_BY_MODULE_ID( - &ctxt, - src_id, - ENB_FLAG_YES, - oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id], - ctxt_pP->frame, - ctxt_pP->subframe, - src_id); - - LOG_D(OTG,"[eNB %d] Frame %d sending packet %d from module %d on rab id %d (src %d, dst %d/%x) pkt size %d for pdcp mode %d\n", - ctxt.module_id, - ctxt.frame, - pkt_cnt_enb++, - src_id, - rb_id, - src_id, - dst_id, - oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id], - pkt_size, - pdcp_mode); - result = pdcp_data_req(&ctxt, - SRB_FLAG_NO, - rb_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pkt_size, - otg_pkt, - pdcp_mode -#ifdef Rel14 - , NULL, NULL -#endif - ); - if (result != TRUE) { - LOG_W(OTG,"PDCP data request failed!\n"); - } - } else { - //rb_id= eNB_index * MAX_NUM_RB + DTCH; - - - LOG_D(OTG,"[UE %d] Frame %d: sending packet %d from module %d on rab id %d (src %d/%x, dst %d) pkt size %d\n", - ctxt_pP->module_id, - ctxt_pP->frame, - pkt_cnt_ue++, - ctxt_pP->module_id, - rb_id, - src_id, - pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id], // [src_id] - dst_id, - pkt_size); - PROTOCOL_CTXT_SET_BY_MODULE_ID( - &ctxt, - ctxt_pP->module_id, //src_id, - ENB_FLAG_NO, - pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id],// [src_id] - ctxt_pP->frame, - ctxt_pP->subframe, - dst_id); - - result = pdcp_data_req( &ctxt, - SRB_FLAG_NO, - rb_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pkt_size, - otg_pkt, - PDCP_TRANSMISSION_MODE_DATA -#ifdef Rel14 - , NULL, NULL -#endif - ); - if (result != TRUE) { - LOG_W(OTG,"PDCP data request failed!\n"); - } - } - - free(otg_pkt); - otg_pkt = NULL; - } - - // } //else LOG_D(OTG,"ctxt_pP->frame %d enb %d-> ue %d link not yet established state %d \n", ctxt_pP->frame, eNB_index,dst_id - NB_eNB_INST, mac_get_rrc_status(module_id, ctxt_pP->enb_flag, dst_id - NB_eNB_INST)); - - } - } - -#else - - if ((otg_enabled==1) && (ctxt_pP->enb_flag == ENB_FLAG_YES)) { // generate DL traffic - unsigned int ctime=0; - ctime = ctxt_pP->frame * 100; + unsigned char *otg_pkt=NULL; + module_id_t dst_id; // dst for otg + rb_id_t rb_id; + unsigned int pkt_size=0; + 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 + unsigned int ctime=0; + ctime = ctxt_pP->frame * 100; /*if ((mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 0 ) > 2) && (mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 1 ) > 2)) { */ - PROTOCOL_CTXT_SET_BY_MODULE_ID( - &ctxt, - ctxt_pP->module_id, - ctxt_pP->enb_flag, - NOT_A_RNTI, - ctxt_pP->frame, - ctxt_pP->subframe, - ctxt_pP->module_id); - - for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { - ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id]; - - if (ctxt.rnti != NOT_A_RNTI) { - if (mac_eNB_get_rrc_status(ctxt.module_id, ctxt.rnti ) > 2 /*RRC_SI_RECEIVED*/) { - unsigned int temp = 0; - otg_pkt=packet_gen( - ENB_MODULE_ID_TO_INSTANCE(ctxt.module_id), - UE_MODULE_ID_TO_INSTANCE(dst_id), - 0, - ctime, - &temp); - pkt_size = temp; - - if (otg_pkt != NULL) { - rb_id = dst_id * maxDRB + DTCH; - pdcp_data_req(&ctxt, + PROTOCOL_CTXT_SET_BY_MODULE_ID( + &ctxt, + ctxt_pP->module_id, + ctxt_pP->enb_flag, + NOT_A_RNTI, + ctxt_pP->frame, + ctxt_pP->subframe, + ctxt_pP->module_id); + + for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id]; +/* + if (ctxt.rnti != NOT_A_RNTI) { + if (mac_eNB_get_rrc_status(ctxt.module_id, ctxt.rnti ) > 2 ) { + unsigned int temp = 0; + otg_pkt=packet_gen( + ENB_MODULE_ID_TO_INSTANCE(ctxt.module_id), + UE_MODULE_ID_TO_INSTANCE(dst_id), + 0, + ctime, + &temp); + pkt_size = temp; + + if (otg_pkt != NULL) { + rb_id = dst_id * maxDRB + DTCH; + pdcp_data_req(&ctxt, SRB_FLAG_NO, rb_id, RLC_MUI_UNDEFINED, @@ -1282,9 +1154,9 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) } } } - } - -#endif +*/ + } + } } //TTN for D2D (PC5S) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c index f0288f21a97d60bc8ada511f4804ebf51c88aa1a..8e2ada01edac615e7b5db2d298b4dbd8793256a8 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c @@ -99,13 +99,8 @@ pdcp_netlink_init( struct sched_param sched_param; reset_meas(&ip_pdcp_stats_tmp); -#if defined(USER_MODE) && defined(OAI_EMU) - nb_inst_enb = oai_emulation.info.nb_enb_local; - nb_inst_ue = oai_emulation.info.nb_ue_local; -#else nb_inst_enb = 1; nb_inst_ue = 1; -#endif #if defined(LINK_ENB_PDCP_TO_GTPV1U) nb_inst_enb = 0; @@ -261,24 +256,7 @@ void *pdcp_netlink_thread_fct(void *arg) } } else { pdcp_thread_read_state = 0; - -#ifdef OAI_EMU - - // LG: new_data_p->pdcp_read_header.inst will contain in fact a module id - if (new_data_p->pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) { - module_id = new_data_p->pdcp_read_header.inst - - oai_emulation.info.nb_enb_local + - + oai_emulation.info.first_ue_local; - eNB_flag = 0; - } else { - module_id = new_data_p->pdcp_read_header.inst - + oai_emulation.info.first_enb_local; - eNB_flag = 1; - } - -#else module_id = 0; -#endif new_data_p->data = malloc(sizeof(uint8_t) * new_data_p->pdcp_read_header.data_size); /* Copy the data */ memcpy(new_data_p->data, NLMSG_DATA(nas_nlh_rx), new_data_p->pdcp_read_header.data_size); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c index d395f959819098e9ff7e4db191afeddd1d823b6e..2554eb145ab9de975100795e207efe6276e39978 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c @@ -220,7 +220,7 @@ pdcp_validate_security( stream_decrypt(pdcp_pP->cipheringAlgorithm, &decrypt_params, &buffer_decrypted); - +#if !defined(USRP_REC_PLAY) if (srb_flagP) { /* Now check the integrity of the complete PDU */ decrypt_params.message = pdcp_pdu_buffer; @@ -241,7 +241,7 @@ pdcp_validate_security( return -1; } } - +#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_VALIDATE_SECURITY, VCD_FUNCTION_OUT); return 0; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c index 0200ffdbf8fc485d837b35ccc913d1abd017c94c..0b6be93d59a5f44448282293529f0c1ff337e95b 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_thread.c @@ -110,9 +110,7 @@ int init_pdcp_thread(void) p.sched_priority = OPENAIR_THREAD_PRIORITY; pthread_attr_setschedparam (&pdcp_thread_attr, &p); -#ifndef RTAI_ISNT_POSIX pthread_attr_setschedpolicy (&pdcp_thread_attr, SCHED_FIFO); -#endif pthread_mutex_init(&pdcp_mutex,NULL); pthread_cond_init(&pdcp_cond,NULL); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h index 131d56e1f89a6f677ec7750ac5c6c7d948dafe1d..5130bde38b9f32f6a8d3b18c6d4d8e139c388c84 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -73,10 +73,6 @@ # include "RLC-Config.h" //# include "rlc_am_test.h" -#ifdef USER_MODE -//# include "rlc_am_very_simple_test.h" -#endif - #define PROTOCOL_RLC_AM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u]" #define PROTOCOL_RLC_AM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c index f6dd0c58095c5a946b326582cee0edd104797d9a..01a635656e24ce819f112c399f70f99ccf7a3e1a 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c @@ -21,9 +21,7 @@ #define RLC_AM_MODULE 1 #define RLC_AM_INIT_C 1 -#ifdef USER_MODE #include <string.h> -#endif //----------------------------------------------------------------------------- #include "rlc_am.h" #include "LAYER2/MAC/extern.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c index addc949d356bd875eb03d6f0aac753256cee774a..d0b5b52395417f9e01e6581402111ec51d2c05de 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c @@ -268,11 +268,9 @@ rlc_am_reassemble_pdu( //} break; -#if USER_MODE default: assert(0 != 0); -#endif } } else { switch (pdu_info->fi) { @@ -382,19 +380,13 @@ rlc_am_reassemble_pdu( if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug // data is already ok, done by last loop above rlc_am_reassembly (ctxt_pP, rlc_pP, &pdu_info->payload[j], pdu_info->hidden_size); - } else { -#if USER_MODE - //assert (5!=5); -#endif } //rlc_pP->reassembly_missing_sn_detected = 0; break; -#if USER_MODE default: assert(1 != 1); -#endif } } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c index afce72b45571112aaaf459034beff3fd1a678246..c16e897bb6f67fdadddb2111694cb95e7ad11097 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -22,9 +22,7 @@ #define RLC_AM_MODULE 1 #define RLC_AM_SEGMENT_C 1 //----------------------------------------------------------------------------- -#if USER_MODE #include <assert.h> -#endif //----------------------------------------------------------------------------- #include "platform_types.h" //----------------------------------------------------------------------------- @@ -468,9 +466,7 @@ void rlc_am_segment_10 ( PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); -#if USER_MODE assert(1!=1); -#endif memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h index a6c340a165299bdc59ed1dc3e5e8363e774a05f1..147fd44d07e0cb0f55af32d92eca4b8011aeda2e 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h @@ -36,9 +36,7 @@ # include "list.h" # include "mem_block.h" # include "rlc_am_constants.h" -//#ifdef USER_MODE # include "mac_rlc_primitives.h" -//#endif //USER_MODE # include "mac_primitives.h" # include "rlc_primitives.h" /** diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c index f0cacc287486123a4c19a777d59e25eb47e68c30..7a3005334e8cdd7d8ef0d393230ecc3f459c85cc 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c @@ -22,9 +22,7 @@ #define RLC_AM_MODULE 1 #define RLC_AM_WINDOWS_C 1 //----------------------------------------------------------------------------- -#if USER_MODE #include <assert.h> -#endif //----------------------------------------------------------------------------- #include "platform_types.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c index faf7763e4fae992fa6e175ca2c4e69ea1d70c796..15dc90f175a183dab9d247afeb081aad21db975a 100644 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -125,6 +125,7 @@ rlc_tm_cleanup ( // RX SIDE if ((rlcP->output_sdu_in_construction)) { free_mem_block (rlcP->output_sdu_in_construction, __func__); + rlcP->output_sdu_in_construction = NULL; } memset(rlcP, 0, sizeof(rlc_tm_entity_t)); diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index 7a9c0d38b51e331e43ecaa77f0d71b50597bd649..0f3b643dd9d0f7efd05ad2dcb0f98e42f04add4b 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -688,10 +688,6 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t { rlc_um_entity_t *rlc_p = (rlc_um_entity_t *) rlc_pP; -#if ! USER_MODE - unsigned long int rlc_um_time_us; - int min, sec, usec; -#endif #if TRACE_RLC_UM_PDU #if ENABLE_ITTI MessageDef *msg_p; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h index c7754f587a09a3638c8f04cfec386ac4c2492e31..abf4f8ad6e991a59fd7e98c086b7d557f51f969f 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.h @@ -64,9 +64,6 @@ # include "rlc_um_receiver.h" # include "rlc_um_segment.h" # include "rlc_um_test.h" -#ifdef USER_MODE -//# include "rlc_um_very_simple_test.h" -#endif #define PROTOCOL_RLC_UM_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u] %s()" #define PROTOCOL_RLC_UM_CTXT_ARGS(CTXT_Pp, rLC_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c index 0f2ed70a9df02efec8f394336281e2b593b045dd..895015dc883778e9255638a71981c995602c39c3 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c @@ -351,6 +351,7 @@ rlc_um_cleanup ( if ((rlc_pP->output_sdu_in_construction)) { free_mem_block (rlc_pP->output_sdu_in_construction, __func__); + rlc_pP->output_sdu_in_construction = NULL; } if (rlc_pP->dar_buffer) { diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c index 468a7d062aded4e95a01741caaa962eafd11a70a..91e1ba66d1bfa662eb29f75cdd286260c48e5147 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c @@ -23,9 +23,7 @@ #define RLC_UM_REASSEMBLY_C 1 #include "platform_types.h" //----------------------------------------------------------------------------- -#if USER_MODE #include <string.h> -#endif #if ENABLE_ITTI # include "platform_types.h" # include "intertask_interface.h" diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c index 4d4362251eaf96847882391c09d9eb83bc8d6e43..f9af7c1cc2b167a3935615aca9b973784ef3cd40 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c @@ -25,9 +25,7 @@ #include "platform_types.h" #include "platform_constants.h" //----------------------------------------------------------------------------- -#if USER_MODE #include <assert.h> -#endif #include "assertions.h" #include "msc.h" #include "list.h" @@ -367,10 +365,8 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); #endif -#if USER_MODE #if !EXMIMO assert(1!=1); -#endif #endif memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); // reduce the size of the PDU @@ -754,9 +750,7 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); #endif -#if USER_MODE assert(1!=1); -#endif memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_structs.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_structs.h index a5425cb8a0f8a5e6a754ba4dfd364528495cf1fb..7ab9798a38d66a128079abe3142ddf3f960ffb04 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_structs.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_structs.h @@ -36,9 +36,7 @@ # include "rlc_um_constants.h" # include "mac_primitives.h" # include "rlc_primitives.h" -//#ifdef USER_MODE # include "mac_rlc_primitives.h" -//#endif //USER_MODE //----------------------- /** * @addtogroup _rlc_um_impl_ diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index ae7d49a3d377fbbc6da3d4c59ca773309aea7977..764378807873e5f731e805607fd4d7bfd7bdbf39 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -135,11 +135,6 @@ rlc_op_status_t rlc_stat_req ( hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; -#ifdef OAI_EMU - - CHECK_CTXT_ARGS(ctxt_pP) - -#endif AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -351,11 +346,6 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, #else AssertFatal(MBMS_flagP == 0, "MBMS_flagP %u", MBMS_flagP); #endif -#ifdef OAI_EMU - - CHECK_CTXT_ARGS(ctxt_pP) - -#endif #if T_TRACER if (ctxt_pP->enb_flag) diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index 72278976835dff0da16884bca92dd24c4655364c..a804278dc5b1c626ede9055ff67f1a76a3891a38 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -701,10 +701,6 @@ public_rlc(rlc_op_status_t rlc_stat_req ( public_rlc(int rlc_module_init(void);) /** @} */ -#ifndef USER_MODE -#define assert(x) ((x)?msg("rlc assertion fails\n"):0) -#endif - #define RLC_FG_COLOR_BLACK "\e[0;30m" #define RLC_FG_COLOR_RED "\e[0;31m" diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 708fbbfb9496002eef935bddadab6712b96f2c73..6bad322dc45571869f86ddea2449bf77642b24fd 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -162,13 +162,6 @@ tbs_size_t mac_rlc_data_req( AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); } -#ifdef OAI_EMU - CHECK_CTXT_ARGS(&ctxt); - //printf("MBMS_flagP %d, MBMS_FLAG_NO %d \n",MBMS_flagP, MBMS_FLAG_NO); - // AssertFatal (MBMS_flagP == MBMS_FLAG_NO ," MBMS FLAG SHOULD NOT BE SET IN mac_rlc_data_req in UE\n"); - -#endif - if (MBMS_flagP) { if (enb_flagP) { mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[module_idP][channel_idP]; @@ -265,18 +258,6 @@ void mac_rlc_data_ind ( } #endif // DEBUG_MAC_INTERFACE -#ifdef OAI_EMU - - if (MBMS_flagP) - AssertFatal (channel_idP < RLC_MAX_MBMS_LC, "channel id is too high (%u/%d)!\n", - channel_idP, RLC_MAX_MBMS_LC); - else - AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", - channel_idP, NB_RB_MAX); - - CHECK_CTXT_ARGS(&ctxt); - -#endif #if T_TRACER if (enb_flagP) @@ -361,31 +342,6 @@ mac_rlc_status_resp_t mac_rlc_status_ind( memset (&mac_rlc_status_resp, 0, sizeof(mac_rlc_status_resp_t)); memset (&tx_status , 0, sizeof(struct mac_status_ind)); -#ifdef OAI_EMU - - if (MBMS_flagP) - AssertFatal (channel_idP < RLC_MAX_MBMS_LC, - "%s channel id is too high (%u/%d) enb module id %u ue %u!\n", - (enb_flagP) ? "eNB" : "UE", - channel_idP, - RLC_MAX_MBMS_LC, - module_idP, - rntiP); - else - AssertFatal (channel_idP < NB_RB_MAX, - "%s channel id is too high (%u/%d) enb module id %u ue %u!\n", - (enb_flagP) ? "eNB" : "UE", - channel_idP, - NB_RB_MAX, - module_idP, - rntiP); - - CHECK_CTXT_ARGS(&ctxt); - -#endif - - - if (MBMS_flagP) { if (enb_flagP) { mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[module_idP][channel_idP]; @@ -401,17 +357,19 @@ mac_rlc_status_resp_t mac_rlc_status_ind( } else #endif { + //LOG_I(RLC, "Panos-D mac_rlc_status_ind 1 enb_flagP: %d, channel_idP: %d, srb_flag: %d \n", enb_flagP, channel_idP, srb_flag); key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); } } + //LOG_I(RLC, "Panos-D mac_rlc_status_ind 2 enb_flagP: %d, channel_idP: %d, srb_flag: %d \n", enb_flagP, channel_idP, srb_flag); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - LOG_W(RLC , "[%s] RLC not configured lcid %u module %u!\n", __FUNCTION__, channel_idP, module_idP); + //LOG_W(RLC , "[%s] RLC not configured lcid %u module %u!\n", __FUNCTION__, channel_idP, module_idP); //LOG_D(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); } diff --git a/openair2/LAYER2/RLC/rlc_primitives.h b/openair2/LAYER2/RLC/rlc_primitives.h index 8d679ab9aaf61f8f67d720ef68df79adcbb84e33..eb7b9ae0053b925a3d52132c99e3240b1658181d 100644 --- a/openair2/LAYER2/RLC/rlc_primitives.h +++ b/openair2/LAYER2/RLC/rlc_primitives.h @@ -31,10 +31,8 @@ #ifndef __RLC_PRIMITIVES_H__ # define __RLC_PRIMITIVES_H__ -# ifdef USER_MODE -# include <stdio.h> -# include <stdlib.h> -# endif +# include <stdio.h> +# include <stdlib.h> # include "platform_types.h" # include "platform_constants.h" # include "mem_block.h" diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index 7fb84f95b11b7a8ae1b6ac651e32fbd11273d500..bb2abb560f2929c12f664c2beb4992cdaef6c613 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -33,9 +33,6 @@ #include "rlc_um.h" #include "rlc_tm.h" #include "UTIL/LOG/log.h" -#ifdef OAI_EMU -#include "UTIL/OCG/OCG_vars.h" -#endif #include "RLC-Config.h" #include "DRB-ToAddMod.h" #include "DRB-ToAddModList.h" @@ -90,12 +87,6 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ ASN1 \n", PROTOCOL_CTXT_ARGS(ctxt_pP)); -#ifdef OAI_EMU - - CHECK_CTXT_ARGS(ctxt_pP) - -#endif - if (srb2add_listP != NULL) { for (cnt=0; cnt<srb2add_listP->list.count; cnt++) { rb_id = srb2add_listP->list.array[cnt]->srb_Identity; @@ -564,10 +555,6 @@ rlc_op_status_t rrc_rlc_remove_rlc ( rlc_union_t *rlc_union_p = NULL; #if defined(Rel10) || defined(Rel14) rlc_mbms_id_t *mbms_id_p = NULL; -#endif -#ifdef OAI_EMU - CHECK_CTXT_ARGS(ctxt_pP) - #endif /* for no gcc warnings */ @@ -678,12 +665,6 @@ rlc_union_t* rrc_rlc_add_rlc ( logical_chan_id_t lcid = 0; #endif -#ifdef OAI_EMU - - CHECK_CTXT_ARGS(ctxt_pP) - -#endif - if (MBMS_flagP == FALSE) { AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); @@ -791,11 +772,6 @@ rlc_op_status_t rrc_rlc_config_req ( PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); -#ifdef OAI_EMU - - CHECK_CTXT_ARGS(ctxt_pP) - -#endif AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); switch (actionP) { diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c index 7801279be2058fc2fc6f653084f70ef4b4c52d0d..34c06a9c538cd968d835210210353015920c0be2 100644 --- a/openair2/LAYER2/openair2_proc.c +++ b/openair2/LAYER2/openair2_proc.c @@ -29,21 +29,7 @@ # @ingroup _openair2 */ -#ifdef USER_MODE -# include <inttypes.h> -#else -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/proc_fs.h> - -# ifndef PRIu64 -# if __WORDSIZE == 64 -# define PRIu64 "lu" -# else -# define PRIu64 "llu" -# endif -# endif -#endif +#include <inttypes.h> #include "LAYER2/RLC/rlc.h" #include "LAYER2/MAC/defs.h" @@ -131,6 +117,12 @@ int dump_eNB_l2_stats(char *buffer, int length) eNB->eNB_stats[CC_id].bcch_buffer, eNB->eNB_stats[CC_id].total_bcch_buffer, eNB->eNB_stats[CC_id].bcch_mcs); + + len += sprintf(&buffer[len],"PCCH , NB_TX_MAC = %d, transmitted bytes (TTI %d, total %d) MCS (TTI %d)\n", + eNB->eNB_stats[CC_id].total_num_pcch_pdu, + eNB->eNB_stats[CC_id].pcch_buffer, + eNB->eNB_stats[CC_id].total_pcch_buffer, + eNB->eNB_stats[CC_id].pcch_mcs); eNB->eNB_stats[CC_id].dlsch_bitrate=((eNB->eNB_stats[CC_id].dlsch_bytes_tx*8)/((eNB->frame + 1)*10)); eNB->eNB_stats[CC_id].total_dlsch_pdus_tx+=eNB->eNB_stats[CC_id].dlsch_pdus_tx; @@ -236,7 +228,7 @@ int dump_eNB_l2_stats(char *buffer, int length) PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, eNB_id, ENB_FLAG_YES, - UE_list->eNB_UE_stats[UE_PCCID(eNB_id,UE_id)][UE_id].crnti, + UE_list->eNB_UE_stats[0][UE_id].crnti,//UE_PCCID(eNB_id,UE_id)][UE_id].crnti, eNB->frame, eNB->subframe, eNB_id); @@ -404,11 +396,7 @@ int dump_eNB_l2_stats(char *buffer, int length) } #ifdef PROC -#ifndef USER_MODE -static int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) -#else int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) -#endif { int len = 0,fg,Overhead, Sign; @@ -691,36 +679,4 @@ int openair2_stats_read(char *buffer, char **my_buffer, off_t off, int length) return len; } -#ifndef USER_MODE -static struct proc_dir_entry *proc_openair2_root; -/* - * Initialize the module and add the /proc file. - */ -int add_openair2_stats() -{ - struct proc_dir_entry *pde; - - proc_openair2_root = proc_mkdir("openair2",0); - // pde = proc_create_entry("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root); - pde = proc_create_data("lchan_stats", S_IFREG | S_IRUGO, proc_openair2_root, NULL,openair2_stats_read); - - if (!pde) { - printk("[OPENAIR][ERROR] can't create proc entry !\n"); - } - - return 0; -} -/* - * Unregister the file when the module is closed. - */ -void remove_openair_stats() -{ - - if (proc_openair2_root) { - printk("[OPENAIR][CLEANUP] Removing openair proc entry\n"); - remove_proc_entry("lchan_stats", proc_openair2_root); - - } -} -#endif #endif diff --git a/openair2/LAYER2/register.c b/openair2/LAYER2/register.c deleted file mode 100644 index 964666875a5a5d6a86a9bbb7276c567c3121c870..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/register.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*________________________rrc_register.c________________________ - - Authors : Hicham Anouar, Raymond Knopp - Company : EURECOM - Emails : anouar@eurecom.fr, knopp@eurecom.fr -________________________________________________________________*/ - - -#ifndef USER_MODE -#define __NO_VERSION__ -#else -#include <stdio.h> -#include <stdlib.h> - -#include <pthread.h> -#endif - -#include "COMMON/openair_types.h" -#include "MAC/extern.h" - -#include <linux/module.h> - -#ifndef USER_MODE - -//-----------------------------------------------------------------------------------------------------------// -MAC_RLC_XFACE* mac_rrc_register(RRC_XFACE* RRC_xface) -{ - //-----------------------------------------------------------------------------------------------------------// - if(Is_rrc_registered) { - msg("[OPENAIR][MAC][RRC_REGISTER] RRC interface already registered, aborting ...\n"); - return NULL; - } else { - msg("[OPENAIR][MAC][RRC_REGISTER] Registering RRC Interface, Mac_rlc_xface=%p\n",Mac_rlc_xface); - Rrc_xface=RRC_xface; - Is_rrc_registered=1; - return Mac_rlc_xface; - } -} - -//-----------------------------------------------------------------------------------------------------------// -int mac_rrc_unregister(RRC_XFACE *RRC_xface) -{ - //-----------------------------------------------------------------------------------------------------------// - if (Rrc_xface == RRC_xface) { - msg("[OPENAIR][MAC XFACE][RRC_UNREGISTER] Unregistering RRC interface\n"); - Rrc_xface=NULL; - Is_rrc_registered=0; - return(0); - } else { - msg("[OPENAIR][MAC XFACE][RRC_UNREGISTER] Not the right interface descriptor pointer!!!, aborting ...\n"); - return (-1); - } - -} - -EXPORT_SYMBOL(mac_rrc_register); -EXPORT_SYMBOL(mac_rrc_unregister); -#endif //USER_MODE - - diff --git a/openair2/Makefile b/openair2/Makefile deleted file mode 100755 index 2fbeb193a6e949e8a4ff9b5de1aa9837a01e57b9..0000000000000000000000000000000000000000 --- a/openair2/Makefile +++ /dev/null @@ -1,254 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ - -#################################################### -# USER SPACE CODE GENERATION -#################################################### - -#--------------------------------------------------- -# -#--------------------------------------------------- - - -#LM_LICENSE_FILE= -#export LM_LICENSE_FILE -include $(OPENAIR_DIR)/common/utils/Makefile.inc - -KERNEL_NAME:=$(shell uname -r) -NUM_CORES=$(shell getconf _NPROCESSORS_CONF) - -export SET_UM=$(shell if grep --silent User\ Mode\ Linux /proc/cpuinfo ; then echo "ARCH=um" ; else echo ""; fi) - -#SUBDIRS_openair_USERRF = $(MAIN_RT_DIR) $(CONFIG_DIR) - -#openair_USERRFDIR = openair_RFOBJS -#openair_USERRFLIBS = $(addsuffix /${openair_USERRFDIR}/Lib.a, ${SUBDIRS_openair_USERRF}) -#openair_USERRFOBJS = $(addsuffix /${openair_USERRFDIR}/*.o, ${SUBDIRS_openair_USERRF}) -#openair_USERRFDEPS = $(addsuffix /${openair_USERRFDIR}/*.d, ${SUBDIRS_openair_USERRF}) - -mac_sim_no_netlink: - ( cd SIMULATION/USER_TOOLS/LAYER2_SIM && make mac_sim MASTER=1) - -mac_sim: - ( cd SIMULATION/USER_TOOLS/LAYER2_SIM && make mac_sim MASTER=1 NETLINK=1 NO_RRM=1) - -mac_sim_rrm: - ( cd SIMULATION/USER_TOOLS/LAYER2_SIM && make mac_sim_rrm MASTER=1 NETLINK=1) - -mac_sim_mt_cellular: - ( cd SIMULATION/USER_TOOLS/LAYER2_SIM && make mac_sim_mt CELLULAR=1 NO_RRM=1) - -mac_sim_rg_cellular: - ( cd SIMULATION/USER_TOOLS/LAYER2_SIM && make mac_sim_rg MASTER=1 CELLULAR=1 NO_RRM=1) - -openair_layer2_emul.ko: - (cd LAYER2 && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` NO_RRM=1 PCTARGET=1 RTAI=1 MASTER=1 OPEN_AIR=1 PHYEMUL=1 && mv openair_l2.ko openair_layer2.ko) - -openair_layer2_emul_rrm.ko: - (cd LAYER2 && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 MASTER=1 OPEN_AIR=1 PHYEMUL=1 && mv openair_l2.ko openair_layer2.ko) - - -openair_layer2.ko: - (cd LAYER2 && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` NO_RRM=1 PCTARGET=1 RTAI=1 MASTER=1 OPEN_AIR=1 OPENAIR1=1 && mv openair_l2.ko openair_layer2.ko) - -openair_layer2_rrm.ko: - (cd LAYER2 && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 MASTER=1 OPEN_AIR=1 OPENAIR1=1 && mv openair_l2.ko openair_layer2.ko) - -openair_layer2_2615.ko: - (cd LAYER2 && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 MASTER=1 OPEN_AIR=1 OPENAIR1=1 && mv openair_l2.ko openair_layer2_2615.ko) - - -openair_rrc.ko: - (cd RRC/MESH && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 OPEN_AIR=1 MASTER=1 NO_RRM=1 && mv openair_rrc.ko openair_RRC.ko) - -openair_rrc_rrm.ko: - (cd RRC/MESH && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 OPEN_AIR=1 MASTER=1 && mv openair_rrc.ko openair_RRC.ko) - - -openair_rrc_2615.ko: - (cd RRC/MESH && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 OPEN_AIR=1 MASTER=1 && mv openair_rrc.ko openair_RRC_2615.ko) - -openair_rrc_emul.ko: - (cd RRC/MESH && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 OPEN_AIR=1 MASTER=1 PHYEMUL=1 NO_RRM=1) - -openair_rrc_emul_rrm.ko: - (cd RRC/MESH && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 OPEN_AIR=1 MASTER=1 PHYEMUL=1) - - -openair_emul.ko: - (cd SIMULATION/PHY_EMULATION/DEVICE_DRIVER/ && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 OPEN_AIR=1 MASTER=1 NO_RRM=1) - -openair_emul_rrm.ko: - (cd SIMULATION/PHY_EMULATION/DEVICE_DRIVER/ && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` PCTARGET=1 RTAI=1 OPEN_AIR=1 MASTER=1) - - - -create_device: - rm -f /dev/openair0 - mknod /dev/openair0 c 127 0 - chmod a+rw /dev/openair0 - - -install_emul: - make devs - make fifos - (insmod SIMULATION/PHY_EMULATION/DEVICE_DRIVER/openair_emul.ko) - (insmod LAYER2/openair_layer2.ko) - (insmod RRC/MESH/openair_rrc.ko) - (insmod NETWORK_DRIVER/MESH/nasmesh.ko) - -remove_emul: - rmmod nasmesh - sleep 1 - rmmod openair_rrc - sleep 1 - rmmod openair_l2 - sleep 1 - rmmod openair_emul - - -clean_nasmesh: - (cd NETWORK_DRIVER/MESH && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` clean) - -nasmesh_address_fix.ko: - (cd NETWORK_DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) V=1 ADDRESS_FIX=1 -C $(KERNEL_DIR)/build M=`pwd`) - -nasmesh.ko: - (cd NETWORK_DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) V=1 -C $(KERNEL_DIR)/build M=`pwd`) - -# automatically detect the linux header files for driver compilation -nasmesh_netlink.ko: - (cd NETWORK_DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - -naslite_netlink_ether.ko: - (cd NETWORK_DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - -oai_nw_ether.ko: - (cd NETWORK_DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - -oai_nw_drv.ko: - (cd NETWORK_DRIVER/LITE && $(MAKE) -j$(NUM_CORES) $(SET_UM) OAI_NW_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - -nasmesh_netlink_address_fix.ko: - (cd NETWORK_DRIVER/MESH && $(MAKE) -j$(NUM_CORES) $(SET_UM) PDCP_USE_NETLINK=1 ADDRESS_FIX=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - - -nasmesh_netlink_loopback.ko: - (cd NETWORK_DRIVER/MESH && $(MAKE) $(SET_UM) PDCP_USE_NETLINK=1 LOOPBACK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - -# drivers cellular version -nascellmt_netlink.ko: - (cd NAS/DRIVER/CELLULAR/NASMT && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - -nascellmt_clean.ko: - (cd NAS/DRIVER/CELLULAR/NASMT && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` clean) - -nascellrg_netlink.ko: - (cd NAS/DRIVER/CELLULAR/NASRG && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - -nascellrg_clean.ko: - (cd NAS/DRIVER/CELLULAR/NASRG && $(MAKE) -j$(NUM_CORES) $(SET_UM) NAS_DRIVER_TYPE_ETHERNET=1 PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` clean) - -# Driver for UE using LTE core network (MME, S+P-GW) -ue_ip.ko: - (cd NETWORK_DRIVER/UE_IP && $(MAKE) -j$(NUM_CORES) $(SET_UM) PDCP_USE_NETLINK=1 OAI_NW_DRIVER_USE_NETLINK=1 V=1 -C $(KERNEL_DIR)/build M=`pwd` modules) - - -rt_emul: - (cd SIMULATION/USER_TOOLS/RT_EMUL_LAUNCHER && $(MAKE)) - -bypass_phy: - (cd SIMULATION/PHY_EMULATION/TRANSPORT/KERNEL_INTERFACE && $(MAKE)) - -rb_tool: - (cd NETWORK_DRIVER/MESH/RB_TOOL && $(MAKE)) - - -fifos: - @for i in `seq 0 64`;\ - do \ - have_rtfX=`ls /dev/ |grep -c rtf$$i`;\ - if [ "$$have_rtfX" -eq 0 ] ;then \ - mknod -m 666 /dev/rtf$$i c 150 $$i; \ - fi;\ - done - -# cp arch/openair_CardBus_MIMO1/device_driver/openair_rf.ko $(KERNEL_DIR)/openair/ -# depmod -aq - -devs: - if ! test -a /dev/openair0;\ - then \ - mknod /dev/openair0 c 127 0;\ - chmod a+rw /dev/openair0;\ - fi; - -load_sounder_ue: install_cbmimo1_ublaze - insmod mac/chansounder/openair_chansounder_ue.ko - -load_sounder_nodeb: install_platon - (cd openair_rf && ./openair_rf_platon 1917600 0 ../arch/platon/rbt_files/DAQ_B.rbt 30p 15p 10p 25p && ./openair_rf_platon 1917600 0 ../arch/platon/rbt_files/daq_platon_11_2005.rbt 30p 15p 10p 25p) - - -stop_sounder: - rmmod openair_chansounder - rmmod openair_rf - -stop_sounder_nodeb: - (cd openair_rf && ./openair_rf_platon 1907600 4) - rmmod openair_chansounder - rmmod openair_rf - - -emul_rt: - (cd SIMULATION/USER_TOOLS/RT_EMUL_LAUNCHER && $(MAKE)) - -clean: - (cd NETWORK_DRIVER/MESH && $(MAKE) clean) - (cd NETWORK_DRIVER/LITE && $(MAKE) clean) - rm -rf NETWORK_DRIVER/MESH/RB_TOOL/rb_tool - rm -rf NETWORK_DRIVER/LITE/RB_TOOL/rb_tool - -cleanall: - find -name *.o -delete -print - find -name *.ko -delete -print - find -name *~ -delete -print - find -name *.bak -delete -print - rm -rf NETWORK_DRIVER/MESH/RB_TOOL/rb_tool - rm -rf NETWORK_DRIVER/LITE/RB_TOOL/rb_tool - - -cleansvn: - rm -rf `find -name *.svn* -print` ; \ - find -name *.svn* -delete -print - -tgz: - mkdir /tmp/openair2_tmp; \ - $(MAKE) cleanall; \ - cp -r . /tmp/openair2_tmp; \ - (cd /tmp/openair2_tmp && $(MAKE) cleansvn && cd .. && tar czfv openair2.tgz openair2_tmp) ; \ - cp /tmp/openair2.tgz . ;\ - rm -rf /tmp/openair2_tmp - -print: - @echo $(IS_KERNEL_OPENAIRINTERFACE) - @echo $(KERNEL_DIR) - @echo $(IS_LINUX) diff --git a/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/Makefile b/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/Makefile deleted file mode 100755 index 427a9fad518f07312b3564ee19bc83219b3e3b2f..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# Lines starting with the pound sign are comments. -# -# These things are options that you might need -# to tweak. - -# You can modify the below as well, but probably -# won't need to. - -#CC = egcs - -#UPDIR := $(shell /bin/pwd) -#GRAAL_DIR =$(UPDIR)/.. -#RRC_DIR =$(UPDIR)/../../../AS/L3/RRC - -CELL_UPDIR := $(shell /bin/pwd) -NAS_DIR := $(OPENAIR2_DIR)/NAS/DRIVER/CELLULAR/NASMT -RRC_DIR := $(OPENAIR2_DIR)/RRC/CELLULAR -EXTRA_CFLAGS += -I$(RRC_DIR) -DNODE_MT - -CFLAGS = -Wall -g -I$(NAS_DIR) -I$(RRC_DIR) - -COMPILE = $(CC) $(CFLAGS) -c - -OBJS = nascell_ioctl.o - -EXECUTABLE = gioctl - -# "all" is the default target. Simply make it point to myprogram. - -all: $(EXECUTABLE) - -# Define the components of the program, and how to link them together. -# These components are defined as dependencies; that is, they must be -# made up-to-date before the code is linked. - -$(EXECUTABLE): $(OBJS) - $(CC) $(CFLAGS) -o $(EXECUTABLE) $(OBJS) - -# Add any special rules here. - -# Specify that all .o files depend on .c files, and indicate how -# the .c files are converted (compiled) to the .o files. - -%.o: %.c - $(COMPILE) -o $@ $< - -clean: - -rm $(OBJS) $(EXECUTABLE) diff --git a/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/nascell_ioctl.c b/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/nascell_ioctl.c deleted file mode 100644 index 0b520ed151bc3e06672f58fe4ed2893cece59189..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/CTL_TOOL/nascell_ioctl.c +++ /dev/null @@ -1,859 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "nascell_ioctl.h" -#include "rrc_nas_primitives.h" -//#include "rrc_qos.h" -//#include "graal_local.h" -#include "nasmt_constant.h" -#include "nasmt_iocontrol.h" -#define USHRT_MAX 255 -//--------------------------------------------------------------------------- -void print_error(int status) -{ - //--------------------------------------------------------------------------- - switch(status) { - case -NAS_ERROR_NOMEMORY: - printf(" The memory is low\n"); - break; - - case -NAS_ERROR_NORB: - printf(" The radio bearer is not identified\n"); - break; - - case -NAS_ERROR_NOTMT: - printf(" The entity must be a mobile\n"); - break; - - case -NAS_ERROR_NOTRG: - printf(" The entity must be an access router\n"); - break; - - case -NAS_ERROR_NOTIDLE: - printf(" The selected connection or radio bearer must be IDLE\n"); - break; - - case -NAS_ERROR_NOTCONNECTED: - printf(" The selected connection or radio bearer must be CONNECTED\n"); - break; - - case -NAS_ERROR_NOTCORRECTLCR: - printf(" The LCR value is not correct\n"); - break; - - case -NAS_ERROR_NOTCORRECTDIR: - printf(" The DIR value is not correct\n"); - break; - - case -NAS_ERROR_NOTCORRECTDSCP: - printf(" The DSCP value is not correct\n"); - break; - - case -NAS_ERROR_NOTCORRECTVERSION: - printf(" The version value is not correct\n"); - break; - - case -NAS_ERROR_NOTCORRECTRABI: - printf(" The rab_id value is not correct\n"); - break; - - case -NAS_ERROR_ALREADYEXIST: - printf(" Some components must not be duplicated\n"); - break; - - default: - printf(" Unknown error cause %d\n", status); - } -} - -//--------------------------------------------------------------------------- -void print_state(uint8_t state) -{ - //--------------------------------------------------------------------------- - switch(state) { - case NAS_IDLE: - printf("NAS_IDLE\n"); - return; - - // case NAS_STATE_CONNECTED:printf("NAS_STATE_CONNECTED\n");return; - // case NAS_STATE_ESTABLISHMENT_REQUEST:printf("NAS_STATE_ESTABLISHMENT_REQUEST\n");return; - // case NAS_STATE_ESTABLISHMENT_FAILURE:printf("NAS_STATE_ESTABLISHMENT_FAILURE\n");return; - // case NAS_STATE_RELEASE_FAILURE:printf("NAS_STATE_RELEASE_FAILURE\n");return; - case NAS_CX_FACH: - printf("NAS_CX_FACH\n"); - return; - - case NAS_CX_DCH: - printf("NAS_CX_DCH\n"); - return; - - case NAS_CX_RECEIVED: - printf("NAS_CX_RECEIVED\n"); - return; - - case NAS_CX_CONNECTING: - printf("NAS_CX_CONNECTING\n"); - return; - - case NAS_CX_RELEASING: - printf("NAS_CX_RELEASING\n"); - return; - - case NAS_CX_CONNECTING_FAILURE: - printf("NAS_CX_CONNECTING_FAILURE\n"); - return; - - case NAS_CX_RELEASING_FAILURE: - printf("NAS_CX_RELEASING_FAILURE\n"); - return; - - case NAS_RB_ESTABLISHING: - printf("NAS_RB_ESTABLISHING\n"); - return; - - case NAS_RB_RELEASING: - printf("NAS_RB_RELEASING\n"); - return; - - default: - printf(" Unknown state\n"); - } -} - -//--------------------------------------------------------------------------- -void print_usage_class() -{ - //--------------------------------------------------------------------------- - printf("Usage: gioctl class add {send <lcr>|receive} -f {qos <rab_id>|del|ctl|dc} -cr <classref> [-dscp <dscp>] [-ip {6|4} <saddr> <splen> <daddr> <dplen>] [-p {tcp|udp|icmp4|icmp6} <sport> <dport>]\n"); - printf("Usage: gioctl class del {send <lcr>|receive} -cr <classref> [-dscp <dscp>] \n"); - printf("Usage: gioctl class list {send <lcr>|receive} [-dscp <dscp>]\n"); -} -//--------------------------------------------------------------------------- -void print_usage_cx() -{ - //--------------------------------------------------------------------------- - printf("Usage: gioctl cx add <lcr> <cellid>\n"); - printf("Usage: gioctl cx del <lcr>\n"); - printf("Usage: gioctl cx list\n"); -} -//--------------------------------------------------------------------------- -void print_usage_rb() -{ - //--------------------------------------------------------------------------- - printf("Usage: gioctl rb add <lcr> <rab_id> <qos>\n"); - printf("Usage: gioctl rb list <lcr>\n"); -} - -//--------------------------------------------------------------------------- -int main(int argc, char *argv[]) -{ - //--------------------------------------------------------------------------- - struct nas_ioctl gifr; - int err, fd; - - // Invalid number of arguments - if (argc<2) { - printf("Usage: gioctl statistic\n"); - print_usage_cx(); - print_usage_rb(); - print_usage_class(); - return -1; - } - - // Get an UDP IPv6 socket ?? - fd=socket(AF_INET6, SOCK_DGRAM, 0); - - if (fd<0) { - printf("Error opening socket\n"); - return 0; - } - - strcpy(gifr.name, "oai0"); - printf("Socket opened successfully\n"); - - /***************************/ - if (strcmp(argv[1], "statistic")==0) { - struct nas_msg_statistic_reply *msgrep; - gifr.type=NAS_MSG_STATISTIC_REQUEST; - gifr.msg=(char *)malloc(sizeof(msgrep)); - msgrep=(struct nas_msg_statistic_reply *)(gifr.msg); - printf(" Statistics requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - printf("tx_packets = %u, rx_packets = %u\n", msgrep->tx_packets, msgrep->rx_packets); - printf("tx_bytes = %u, rx_bytes = %u\n", msgrep->tx_bytes, msgrep->rx_bytes); - printf("tx_errors = %u, rx_errors = %u\n", msgrep->tx_errors, msgrep->rx_errors); - printf("tx_dropped = %u, rx_dropped = %u\n", msgrep->tx_dropped, msgrep->rx_dropped); - return 0; - } - - /***************************/ - if (strcmp(argv[1], "cx")==0) { - if (argc<3) { - print_usage_cx(); - return -1; - } - - /***/ - // printf("Usage: gioctl cx add <lcr> <cellid>\n"); - if (strcmp(argv[2], "add")==0) { - struct nas_msg_cx_establishment_request *msgreq; - struct nas_msg_cx_establishment_reply *msgrep; - - if (argc<5) { - print_usage_cx(); - return -1; - } - - gifr.type=NAS_MSG_CX_ESTABLISHMENT_REQUEST; - gifr.msg=(char *)malloc(sizeof(msgrep)<sizeof(msgreq)?sizeof(msgreq):sizeof(msgrep)); - msgreq=(struct nas_msg_cx_establishment_request *)(gifr.msg); - msgrep=(struct nas_msg_cx_establishment_reply *)(gifr.msg); - msgreq->lcr=strtoul(argv[3], NULL, 0); - msgreq->cellid=strtoul(argv[4], NULL, 0); - // - printf(" Connection establishment requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - perror("Connection establishment IOCTL error\n"); - return -1; - } - - if (msgrep->status<0) { - printf(" Connexion establishment failure: "); - print_error(msgrep->status); - return -1; - } - - return 0; - } - - /***/ - // printf("Usage: gioctl cx del <lcr>\n"); - if (strcmp(argv[2], "del")==0) { - struct nas_msg_cx_release_request *msgreq; - struct nas_msg_cx_release_reply *msgrep; - - if (argc<4) { - print_usage_cx(); - return -1; - } - - gifr.type=NAS_MSG_CX_RELEASE_REQUEST; - gifr.msg=(char *)malloc(sizeof(msgrep)<sizeof(msgreq)?sizeof(msgreq):sizeof(msgrep)); - msgreq=(struct nas_msg_cx_release_request *)(gifr.msg); - msgrep=(struct nas_msg_cx_release_reply *)(gifr.msg); - msgreq->lcr=strtoul(argv[3], NULL, 0); - // - printf(" Connexion release requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - if (msgrep->status<0) { - printf(" Connexion release failure: "); - print_error(msgrep->status); - return -1; - } - - return 0; - } - - /***/ - // printf("Usage: gioctl cx list\n"); - if (strcmp(argv[2], "list")==0) { - uint8_t *msgrep; - uint8_t i; - struct nas_msg_cx_list_reply *list; - uint8_t lcr; - gifr.type=NAS_MSG_CX_LIST_REQUEST; - gifr.msg=(char *)malloc(NAS_LIST_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1); - msgrep=(uint8_t *)(gifr.msg); - // - printf(" Connexion list requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - printf("Lcr\t\tCellId\tIID4\tIID6\t\t\tnrb\tnsclass\tState\n"); - list=(struct nas_msg_cx_list_reply *)(msgrep+1); - - for(lcr=0; lcr<msgrep[0]; ++lcr) { - printf("%u\t\t%u\t%u\t", list[lcr].lcr, list[lcr].cellid, list[lcr].iid4); - - for (i=0; i<8; ++i) - printf("%02x", *((uint8_t *)list[lcr].iid6+i)); - - printf("\t%u\t%u\t", list[lcr].num_rb, list[lcr].nsclassifier); - print_state(list[lcr].state); - } - - return 0; - } - - print_usage_cx(); - return -1; - } - - /***************************/ - if (strcmp(argv[1], "rb")==0) { - if (argc<3) { - print_usage_rb(); - return -1; - } - - /***/ - // printf("Usage: gioctl rb add <lcr> <rab_id> <qos>\n"); - if (strcmp(argv[2], "add")==0) { - struct nas_msg_rb_establishment_request *msgreq; - struct nas_msg_rb_establishment_reply *msgrep; - - if (argc<6) { - print_usage_rb(); - return -1; - } - - gifr.type=NAS_MSG_RB_ESTABLISHMENT_REQUEST; - gifr.msg=(char *)malloc(sizeof(msgrep)<sizeof(msgreq)?sizeof(msgreq):sizeof(msgrep)); - msgreq=(struct nas_msg_rb_establishment_request *)(gifr.msg); - msgrep=(struct nas_msg_rb_establishment_reply *)(gifr.msg); - msgreq->lcr=strtoul(argv[3], NULL, 0); - msgreq->rab_id=strtoul(argv[4], NULL, 0); - msgreq->qos=strtoul(argv[5], NULL, 0); - // - printf(" Radio bearer establishment requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - if (msgrep->status<0) { - printf(" Radio bearer establishment failure: "); - print_error(msgrep->status); - return -1; - } - - return 0; - } - - /***/ - if (strcmp(argv[2], "del")==0) { - struct nas_msg_rb_release_request *msgreq; - struct nas_msg_rb_release_reply *msgrep; - - if (argc<5) { - print_usage_rb(); - return -1; - } - - gifr.type=NAS_MSG_RB_RELEASE_REQUEST; - gifr.msg=(char *)malloc(sizeof(msgrep)<sizeof(msgreq)?sizeof(msgreq):sizeof(msgrep)); - msgreq=(struct nas_msg_rb_release_request *)(gifr.msg); - msgrep=(struct nas_msg_rb_release_reply *)(gifr.msg); - msgreq->lcr=strtoul(argv[3], NULL, 0); - msgreq->rab_id=strtoul(argv[4], NULL, 0); - // - printf(" Radio Bearer release requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - if (msgrep->status<0) { - printf(" Radio bearer release failure: "); - print_error(msgrep->status); - return -1; - } - - return 0; - } - - /***/ - // printf("Usage: gioctl rb list <lcr>\n"); - if (strcmp(argv[2], "list")==0) { - uint8_t *msgrep; - uint8_t rbi; - struct nas_msg_rb_list_reply *list; - struct nas_msg_rb_list_request *msgreq; - - if (argc<4) { - print_usage_rb(); - return -1; - } - - gifr.type=NAS_MSG_RB_LIST_REQUEST; - gifr.msg=(char *)malloc(NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1); - msgreq=(struct nas_msg_rb_list_request *)(gifr.msg); - msgrep=(uint8_t *)(gifr.msg); - msgreq->lcr=strtoul(argv[3], NULL, 0); - // - printf(" Radio bearer list requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - printf("rab_id\t\tSapi\t\tQoS\t\tState\n"); - list=(struct nas_msg_rb_list_reply *)(msgrep+1); - - for(rbi=0; rbi<msgrep[0]; ++rbi) { - printf("%u\t\t%u\t\t%u\t\t", list[rbi].rab_id, list[rbi].sapi, list[rbi].qos); - print_state(list[rbi].state); - } - - return 0; - } - - print_usage_rb(); - return -1; - } - - /***************************/ - if (strcmp(argv[1], "class")==0) { - if (argc<3) { - print_usage_class(); - return -1; - } - - /***/ - if (strcmp(argv[2], "add")==0) { - struct nas_msg_class_add_request *msgreq; - struct nas_msg_class_add_reply *msgrep; - uint8_t i,j; - gifr.type=NAS_MSG_CLASS_ADD_REQUEST; - gifr.msg=(char *)malloc(sizeof(msgrep)<sizeof(msgreq)?sizeof(msgreq):sizeof(msgrep)); - msgreq=(struct nas_msg_class_add_request *)(gifr.msg); - msgrep=(struct nas_msg_class_add_reply *)(gifr.msg); - i=3; - - if (strcmp(argv[i], "send")==0) { - msgreq->dir=NAS_DIRECTION_SEND; - msgreq->lcr=strtoul(argv[++i], NULL, 0); - ++i; - } else { - if (strcmp(argv[i], "receive")==0) { - msgreq->dir=NAS_DIRECTION_RECEIVE; - ++i; - } else { - print_usage_class(); - return -1; - } - } - - msgreq->classref=USHRT_MAX; - msgreq->dscp=NAS_DSCP_DEFAULT; - msgreq->version=NAS_VERSION_DEFAULT; - msgreq->protocol=NAS_PROTOCOL_DEFAULT; - msgreq->sport=NAS_PORT_DEFAULT; - msgreq->dport=NAS_PORT_DEFAULT; - msgreq->fct=0; - - while (i<argc) { - if (strcmp(argv[i], "-cr")==0) { - msgreq->classref=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "-dscp")==0) { - msgreq->dscp=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "-f")==0) { - ++i; - - if (strcmp(argv[i], "qos")==0) { - msgreq->fct=NAS_FCT_QOS_SEND; - msgreq->rab_id=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "del")==0) { - msgreq->fct=NAS_FCT_DEL_SEND; - msgreq->rab_id=0; - ++i; - continue; - } - - if (strcmp(argv[i], "ctl")==0) { - msgreq->fct=NAS_FCT_CTL_SEND; - msgreq->rab_id=0; - ++i; - continue; - } - - if (strcmp(argv[i], "dc")==0) { - msgreq->fct=NAS_FCT_DC_SEND; - msgreq->rab_id=0; - ++i; - continue; - } - - print_usage_class(); - return -1; - } - - if (strcmp(argv[i], "-ip")==0) { - ++i; - - if (strcmp(argv[i], "4")==0) { - if (msgreq->version!=NAS_VERSION_DEFAULT) { - print_usage_class(); - return -1; - } - - msgreq->version=NAS_VERSION_4; - inet_pton(AF_INET, argv[++i], (void *)(&msgreq->saddr)); - msgreq->splen=strtoul(argv[++i], NULL, 0); - inet_pton(AF_INET, argv[++i], (void *)(&msgreq->daddr)); - msgreq->dplen=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "6")==0) { - if (msgreq->version!=NAS_VERSION_DEFAULT) { - print_usage_class(); - return -1; - } - - msgreq->version=NAS_VERSION_6; - inet_pton(AF_INET6, argv[++i], (void *)(&msgreq->saddr)); - msgreq->splen=strtoul(argv[++i], NULL, 0); - inet_pton(AF_INET6, argv[++i], (void *)(&msgreq->daddr)); - msgreq->dplen=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - print_usage_class(); - return -1; - } - - if (strcmp(argv[i], "-p")==0) { - ++i; - - if (strcmp(argv[i], "tcp")==0) { - if (msgreq->protocol!=NAS_PROTOCOL_DEFAULT) { - print_usage_class(); - return -1; - } - - msgreq->protocol=NAS_PROTOCOL_TCP; - msgreq->sport=strtoul(argv[++i], NULL, 0); - msgreq->dport=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "udp")==0) { - if (msgreq->protocol!=NAS_PROTOCOL_DEFAULT) { - print_usage_class(); - return -1; - } - - msgreq->protocol=NAS_PROTOCOL_UDP; - msgreq->sport=strtoul(argv[++i], NULL, 0); - msgreq->dport=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "icmp4")==0) { - if (msgreq->protocol!=NAS_PROTOCOL_DEFAULT) { - print_usage_class(); - return -1; - } - - msgreq->protocol=NAS_PROTOCOL_ICMP4; - msgreq->sport=strtoul(argv[++i], NULL, 0); - msgreq->dport=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "icmp6")==0) { - if (msgreq->protocol!=NAS_PROTOCOL_DEFAULT) { - print_usage_class(); - return -1; - } - - msgreq->protocol=NAS_PROTOCOL_ICMP6; - msgreq->sport=strtoul(argv[++i], NULL, 0); - msgreq->dport=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - print_usage_class(); - return -1; - } - - print_usage_class(); - return -1; - } - - if ((msgreq->classref==USHRT_MAX)||(msgreq->fct==0)) { - print_usage_class(); - return -1; - } - - printf(" Class add requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - if (msgrep->status<0) { - printf(" Class add failure: "); - print_error(msgrep->status); - return -1; - } - - return 0; - } - - /***/ - if (strcmp(argv[2], "del")==0) { - uint8_t i; - struct nas_msg_class_del_request *msgreq; - struct nas_msg_class_del_reply *msgrep; - gifr.type=NAS_MSG_CLASS_DEL_REQUEST; - gifr.msg=(char *)malloc(sizeof(msgrep)<sizeof(msgreq)?sizeof(msgreq):sizeof(msgrep)); - msgreq=(struct nas_msg_class_del_request *)(gifr.msg); - msgrep=(struct nas_msg_class_del_reply *)(gifr.msg); - i=3; - - if (strcmp(argv[i], "send")==0) { - msgreq->dir=NAS_DIRECTION_SEND; - msgreq->lcr=strtoul(argv[++i], NULL, 0); - ++i; - } else { - if (strcmp(argv[i], "receive")==0) { - msgreq->dir=NAS_DIRECTION_RECEIVE; - ++i; - } else { - print_usage_class(); - return -1; - } - } - - msgreq->classref=USHRT_MAX; - msgreq->dscp=NAS_DSCP_DEFAULT; - - while (i<argc) { - if (strcmp(argv[i], "-cr")==0) { - msgreq->classref=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - if (strcmp(argv[i], "-dscp")==0) { - msgreq->dscp=strtoul(argv[++i], NULL, 0); - ++i; - continue; - } - - print_usage_class(); - return -1; - } - - if (msgreq->classref==USHRT_MAX) { - print_usage_class(); - return -1; - } - - printf(" Class del requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - if (msgrep->status<0) { - printf(" Class add failure: "); - print_error(msgrep->status); - return -1; - } - - return 0; - } - - /***/ - if (strcmp(argv[2], "list")==0) { - uint8_t *msgrep; - uint8_t cli, i; - struct nas_msg_class_list_reply *list; - struct nas_msg_class_list_request *msgreq; - char addr[45]; - - if (argc<4) { - print_usage_class(); - return -1; - } - - gifr.type=NAS_MSG_CLASS_LIST_REQUEST; - gifr.msg=(char *)malloc(NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1); - - if (gifr.msg==NULL) { - printf(" No memory\n"); - return -1; - } - - msgreq=(struct nas_msg_class_list_request *)(gifr.msg); - msgrep=(uint8_t *)(gifr.msg); - i=3; - - if (strcmp(argv[i], "send")==0) { - msgreq->dir=NAS_DIRECTION_SEND; - msgreq->lcr=strtoul(argv[++i], NULL, 0); - ++i; - } else { - if (strcmp(argv[i], "receive")==0) { - msgreq->dir=NAS_DIRECTION_RECEIVE; - msgreq->lcr=0; - ++i; - } else { - print_usage_class(); - return -1; - } - } - - msgreq->dscp=NAS_DSCP_DEFAULT; - - while (i<argc) { - if (strcmp(argv[i], "-dscp")==0) - msgreq->dscp=strtoul(argv[++i], NULL, 0); - } - - printf(" Classifier list requested\n"); - err=ioctl(fd, NASMT_IOCTL_RAL, &gifr); - - // - if (err<0) { - printf("IOCTL error, err=%d\n",err); - return -1; - } - - printf("Lcr\trab_id\tCref\tFct\t(Vers., saddr, daddr)\t\t\t\t(Proto., Sport, Dport)\n"); - list=(struct nas_msg_class_list_reply *)(msgrep+1); - - for(cli=0; cli<msgrep[0]; ++cli) { - printf("%u\t%u\t%u\t", list[cli].lcr, list[cli].rab_id, list[cli].classref); - - switch(list[cli].fct) { - case NAS_FCT_QOS_SEND: - printf("qos\t"); - break; - - case NAS_FCT_DEL_SEND: - printf("del\t"); - break; - - case NAS_FCT_CTL_SEND: - printf("ctl\t"); - break; - - case NAS_FCT_DC_SEND: - printf("dc\t"); - break; - - default: - printf("?\t"); - } - - switch(list[cli].version) { - case 4: - inet_ntop(AF_INET, (void *)&list[cli].saddr, addr, 45); - printf("(ip4, %s/%u,", addr, list[cli].splen); - inet_ntop(AF_INET, (void *)&list[cli].daddr, addr, 45); - printf("%s/%u\t", addr, list[cli].dplen); - break; - - case 6: - inet_ntop(AF_INET6, (void *)&list[cli].saddr, addr, 45); - printf("(ip6, %s/%u", addr, list[cli].splen); - inet_ntop(AF_INET6, (void *)&list[cli].daddr, addr, 45); - printf("%s/%u\t", addr, list[cli].dplen); - break; - - default: - printf("(--, --, --)\t\t\t"); - break; - } - - switch(list[cli].protocol) { - case IPPROTO_UDP: - printf("(udp, %u, %u)\t\n", list[cli].sport, list[cli].dport); - break; - - case IPPROTO_TCP: - printf("(tcp, %u, %u)\t\n", list[cli].sport, list[cli].dport); - break; - - case IPPROTO_ICMP: - printf("(icmp4, %u, %u)\t\n", list[cli].sport, list[cli].dport); - break; - - case IPPROTO_ICMPV6: - printf("(icmp6, %u, %u)\t\n", list[cli].sport, list[cli].dport); - break; - - default: - printf("(--, --, --)\t\n"); - } - } - - return 0; - } - - return 0; - } - - printf(" Unknown command %s\n",argv[1]); - return 0; -} - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile b/openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile deleted file mode 100755 index ec14990d6321e4c64a76bad8ca43ec005c85daa1..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# NAS CELLULAR Driver makefile -# -include $(OPENAIR_DIR)/common/utils/Makefile.inc -NAS_UPDIR := $(shell /bin/pwd) - -#################################################### -# D E B U G F L A G S -#################################################### - -#################################################### -# EXTRA COMPILER FLAGS -#################################################### -EXTRA_CFLAGS = -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) - -ifdef ADDRCONF -EXTRA_CFLAGS += -DADDRCONF -endif - -ifdef NAS_DRIVER_TYPE_ETHERNET -EXTRA_CFLAGS += -DNAS_DRIVER_TYPE_ETHERNET -endif - - -ifdef PDCP_USE_NETLINK -EXTRA_CFLAGS += -DPDCP_USE_NETLINK -else -EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall -endif - -ifdef LOOPBACK -EXTRA_CFLAGS += -DLOOPBACK_TEST -endif - -ifdef ADDRESS_FIX -EXTRA_CFLAGS += -DNAS_ADDRESS_FIX -endif - -#################################################### -# NASMTCELL extra compilation flags -#################################################### -#RTAI=1 -RRC_DIR := $(OPENAIR2_DIR)/RRC/CELLULAR -EXTRA_CFLAGS += -I$(RRC_DIR) -DNODE_MT - -#################################################### -# LOADABLE MODULE GOALS -#################################################### -obj-m += nascellmt.o -nascellmt-objs += nasmt_device.o -nascellmt-objs += nasmt_common.o -nascellmt-objs += nasmt_iocontrol.o -nascellmt-objs += nasmt_classifier.o -nascellmt-objs += nasmt_tool.o -nascellmt-objs += nasmt_ascontrol.o -ifdef PDCP_USE_NETLINK -nascellmt-objs += nasmt_netlink.o -endif - -#################################################### -# REVOIR LE CLEAN -#################################################### - -#netlink.ko: - #make $(x)$(y) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules - -#nasmesh.ko: -# make V=1 -C $(KERNEL_DIR) M=`pwd` modules -print: - @echo subversion : $(SUBVERSION) - @echo RRC_DIR $(RRC_DIR) -clean: - rm -f *.ko - rm -f .*.ko.cmd - rm -f .*.o.cmd - rm -f *.o - rm -f *.mod.c - find . -name *.ko -delete - find . -name *.o -delete - find . -name *.mod.c -delete diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c deleted file mode 100644 index 666cbb1a044c9b98c1f0b6d7d9bca26b6ad071f4..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_ascontrol.c +++ /dev/null @@ -1,1152 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_ascontrol.c -* \brief Access Stratum Control functions for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifdef NODE_MT -#include "nasmt_variables.h" -#include "nasmt_proto.h" - -//--------------------------------------------------------------------------- -void nasmt_ASCTL_init(void) -{ - //--------------------------------------------------------------------------- - // struct cx_entity *cx; - int i; - gpriv->next_sclassref = NASMT_DEFAULTRAB_CLASSREF; - - for (i = 0; i<NASMT_MBMS_SVCES_MAX; i++) { - gpriv->cx->joined_services[i]= -1; - } - - printk("nasmt_ASCTL_init Complete\n"); -} - -//--------------------------------------------------------------------------- -int nasmt_ASCTL_write(int sap, unsigned char *data_buffer, unsigned int data_length) -{ - //--------------------------------------------------------------------------- - int bytes_wrote = 0; -#ifdef PDCP_USE_NETLINK - unsigned char xmit_buffer [NAS_MESSAGE_MAXLEN]; - //MT xmit on DC-SAP only - xmit_buffer[0] = RRC_NAS_DC0_IN; - memcpy (&((char*)xmit_buffer)[1], data_buffer, data_length); - bytes_wrote = nasmt_netlink_send(xmit_buffer,data_length, NASNL_DEST_RRC); -#else - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version - bytes_wrote = rtf_put(sap, data_buffer, data_length); -#endif //PDCP_USE_NETLINK - return bytes_wrote; -} - -//--------------------------------------------------------------------------- -//For demo, add automatically a classifier -//Equivalent to class add send 0 -f qos <x> -cr 0 -void nasmt_ASCTL_start_default_sclassifier(struct cx_entity *cx,struct rb_entity *rb) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("\nnasmt_ASCTL_start_default_sclass - begin \n"); -#endif - - if (!cx || !rb) { - printk("nasmt_ASCTL_start_default_sclass - input parameter cx or rb is NULL \n"); - return; - } - - // End debug information - // - gc=nasmt_CLASS_add_sclassifier(cx, NAS_DSCP_DEFAULT, gpriv->next_sclassref); - - // gc=nasmt_CLASS_add_sclassifier(cx, 5, 0); - if (gc==NULL) { - printk("nasmt_ASCTL_start_default_sclass - Error - Classifier not added \n"); - return; - } - - gc->fct = nasmt_COMMON_QOS_send; - gc->rab_id =rb->rab_id; - gc->rb= rb; - gc->version = NASMT_DEFAULTRAB_IPVERSION; - gc->protocol= NAS_PROTOCOL_DEFAULT; - gc->dplen= NAS_DEFAULT_IPv6_PREFIX_LENGTH; - //gc->daddr.ipv6.s6_addr32[2] = cx->iid6[0]; - //gc->daddr.ipv6.s6_addr32[3] = cx->iid6[1]; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_ASCTL_start_default_sclass - end \n"); - nasmt_TOOL_print_classifier(gc); -#endif -} - -//--------------------------------------------------------------------------- -//For demo, add automatically a classifier -//Equivalent to class add send 0 -f qos <x> -cr 0 -void nasmt_ASCTL_start_sclassifier(struct cx_entity *cx,struct rb_entity *rb) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("\nnasmt_ASCTL_start_sclass - begin \n"); -#endif - - if (cx==NULL) { - printk("nasmt_ASCTL_start_sclass - input parameter cx is NULL \n"); - return; - } - - if (rb==NULL) { - printk("nasmt_ASCTL_start_sclass - input parameter rb is NULL \n"); - return; - } - - // End debug information - // - gc=nasmt_CLASS_add_sclassifier(cx, rb->dscp, gpriv->next_sclassref); - - // gc=nasmt_CLASS_add_sclassifier(cx, 5, 0); - if (gc==NULL) { - printk("nasmt_ASCTL_start_sclass - Error - Classifier not added \n"); - return; - } - - gc->fct = nasmt_COMMON_QOS_send; - gc->rab_id =rb->rab_id; - gc->rb= rb; - gc->version = NASMT_DEFAULTRAB_IPVERSION; - gc->protocol= NAS_PROTOCOL_DEFAULT; - gc->dplen= NAS_DEFAULT_IPv6_PREFIX_LENGTH; - gc->daddr.ipv6.s6_addr32[2] = cx->iid6[0]; - gc->daddr.ipv6.s6_addr32[3] = cx->iid6[1]; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_ASCTL_start_sclass - end \n"); - nasmt_TOOL_print_classifier(gc); -#endif -} - -//--------------------------------------------------------------------------- -void nasmt_ASCTL_timer(unsigned long data) -{ - //--------------------------------------------------------------------------- - uint8_t cxi; - struct cx_entity *cx; - struct rb_entity *rb; - spin_lock(&gpriv->lock); -#ifdef NAS_DEBUG_TIMER - printk("nasmt_ASCTL_timer - begin \n"); -#endif - (gpriv->timer).function=nasmt_ASCTL_timer; - (gpriv->timer).expires=jiffies+NAS_TIMER_TICK; - (gpriv->timer).data=0L; - - for (cxi=0; cxi<NAS_CX_MAX; ++cxi) { - cx=gpriv->cx+cxi; - - if (cx==NULL) { -#ifdef NAS_DEBUG_TIMER - printk("nasmt_ASCTL_timer - No pointer for connection %d \n", cxi); -#endif - continue; - } - - if (cx->countimer!=NAS_TIMER_IDLE) { -#ifdef NAS_DEBUG_TIMER - printk("nasmt_ASCTL_timer: lcr %u, countimer %u\n", cx->lcr, cx->countimer); -#endif - - if (cx->countimer==0) { - switch (cx->state) { - case NAS_CX_CONNECTING: - case NAS_CX_CONNECTING_FAILURE: - if (cx->retry<gpriv->retry_limit) - nasmt_ASCTL_DC_send_cx_establish_request(cx); - else { - printk("nasmt_ASCTL_timer: Establishment failure\n"); - cx->state=NAS_IDLE; - cx->retry=0; - cx->countimer=NAS_TIMER_IDLE; - } - - break; - - case NAS_CX_RELEASING_FAILURE: - nasmt_ASCTL_DC_send_cx_release_request(cx); - break; - - default: - printk("nasmt_ASCTL_timer: default value\n"); - cx->countimer=NAS_TIMER_IDLE; - } - } else - --cx->countimer; - } - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { - if (rb->countimer!=NAS_TIMER_IDLE) { -#ifdef NAS_DEBUG_TIMER - printk("nasmt_ASCTL_timer : rb countimer %d, rb state %d\n", rb->countimer, rb->state); -#endif - - if (rb->countimer==0) { - switch (rb->state) { - case NAS_RB_DCH: -#ifdef DEMO_3GSM - if (cx->num_rb == 1) { - nasmt_ASCTL_start_default_sclassifier(cx, rb); - } - -#endif - nasmt_ASCTL_start_sclassifier(cx, rb); - rb->countimer=NAS_TIMER_IDLE; - break; - - default: - rb->countimer=NAS_TIMER_IDLE; - } - } else { - --rb->countimer; - printk("nasmt_ASCTL_timer : rb countimer-- %d, rb state %d\n", rb->countimer, rb->state); - } - } - } - } - - add_timer(&gpriv->timer); - spin_unlock(&gpriv->lock); -} - -//--------------------------------------------------------------------------- -// Request the sleep of a connexion -int nasmt_ASCTL_enter_sleep_mode(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - uint8_t sig_category; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_enter_sleep_mode - begin \n"); -#endif - - if (!cx) { - printk("nasmt_ASCTL_enter_sleep_mode - input parameter cx is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - // send peer message to NASRG - sig_category = NAS_CMD_ENTER_SLEEP; - printk("nasmt_ASCTL_enter_sleep_mode - sig_category %u \n", sig_category); - nasmt_ASCTL_DC_send_peer_sig_data_request(cx, sig_category); - cx->state=NAS_CX_RELEASING; - return 0; -} - -//--------------------------------------------------------------------------- -// Request to reactivate a connexion -int nasmt_ASCTL_leave_sleep_mode(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - uint8_t sig_category; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_leave_sleep_mode - begin \n"); -#endif - - if (!cx) { - printk("nasmt_ASCTL_leave_sleep_mode - input parameter cx is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - cx->state=NAS_CX_DCH; - // send peer message to NASRG - sig_category = NAS_CMD_LEAVE_SLEEP; - printk("nasmt_ASCTL_leave_sleep_mode - sig_category %u \n", sig_category); - nasmt_ASCTL_DC_send_peer_sig_data_request(cx, sig_category); - return 0; -} - -/*********************************************** - * Transmit Functions * - ***********************************************/ - -//--------------------------------------------------------------------------- -// Request the establishment of a connexion (DC channel) -int nasmt_ASCTL_DC_send_cx_establish_request(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_cx_establish - begin \n"); -#endif - - if (!cx) { - printk("nasmt_ASCTL_DC_send_cx_establish - input parameter cx is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - - switch (cx->state) { - case NAS_CX_CONNECTING: - case NAS_CX_CONNECTING_FAILURE: - case NAS_IDLE: - p= (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = CONN_ESTABLISH_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASConnEstablishReq); - p->nasUEDCPrimitive.conn_establish_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.conn_establish_req.cellId = cx->cellid; -#ifdef NAS_DEBUG_DC - printk ("\nCONN_ESTABLISH_REQ Buffer to Xmit: "); - nasmt_TOOL_print_buffer((char *)p,p->length); -#endif - ++cx->retry; - - //bytes_wrote = rtf_put(cx->sap[GRAAL_DC_INPUT_SAPI], p, p->length); //original version - bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); - //printk("nasmt_ASCTL_DC_send_cx_establish_request - Wrote %d bytes to RRC NAS_DC_INPUT_SAPI\n", bytes_wrote); - - cx->countimer=gpriv->timer_establishment; - - if (bytes_wrote==p->length) { - cx->state=NAS_CX_CONNECTING; -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_cx_establish - Message sent successfully in DC-FIFO\n"); - printk(" Local Connection reference %u\n", p->nasUEDCPrimitive.conn_establish_req.localConnectionRef); - printk(" Cell Identification %u\n", p->nasUEDCPrimitive.conn_establish_req.cellId); - nasmt_TOOL_print_state(cx->state); -#endif - } else { - cx->state=NAS_CX_CONNECTING_FAILURE; - printk("nasmt_ASCTL_DC_send_cx_establish - Message sent failure in DC-FIFO\n"); - nasmt_TOOL_print_state(cx->state); - } - - return bytes_wrote; - - default: - return -NAS_ERROR_NOTIDLE; -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_cx_establish - NAS_ERROR_NOTIDLE \n"); -#endif - } -} - -//--------------------------------------------------------------------------- -// Request the release of a connexion (DC channel) -int nasmt_ASCTL_DC_send_cx_release_request(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_cx_release - begin \n"); -#endif - - if (cx==NULL) { - printk("nasmt_ASCTL_DC_send_cx_release - input parameter cx is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - switch (cx->state) { - case NAS_CX_RELEASING_FAILURE: - case NAS_CX_DCH: - p= (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = CONN_RELEASE_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASConnReleaseReq); - p->nasUEDCPrimitive.conn_release_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.conn_release_req.releaseCause = NAS_CX_RELEASE_UNDEF_CAUSE; - - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version - bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); - //printk("nasmt_ASCTL_DC_send_cx_release - Wrote %d bytes to RRC NAS_DC_INPUT_SAPI\n", bytes_wrote); - - if (bytes_wrote==p->length) { - cx->state=NAS_IDLE; - cx->iid4=0; - // nasmt_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); - nasmt_COMMON_flush_rb(cx); - nasmt_CLASS_flush_sclassifier(cx); - -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_cx_release - Message sent successfully in DC-FIFO\n"); - printk(" Local Connection Reference %u\n", p->nasUEDCPrimitive.conn_release_req.localConnectionRef); - printk(" Release Cause %u\n", p->nasUEDCPrimitive.conn_release_req.releaseCause); - nasmt_TOOL_print_state(cx->state); -#endif - } else { - ++cx->retry; - cx->countimer=gpriv->timer_release; - cx->state=NAS_CX_RELEASING_FAILURE; - printk("nasmt_ASCTL_DC_send_cx_release - Message sent failure in DC-FIFO\n"); - nasmt_TOOL_print_state(cx->state); - } - - return bytes_wrote; - - default: - return -NAS_ERROR_NOTCONNECTED; -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_cx_release - NAS_ERROR_NOTCONNECTED \n"); -#endif - } -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (DC SAP) -void nasmt_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - char data_type = 'A'; - int bytes_wrote = 0; -#ifdef PDCP_USE_NETLINK - unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; - int count=0; -#endif - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_sig_data - begin \n"); -#endif - - if (!skb || !gc || !cx) { - printk("nasmt_ASCTL_DC_send_sig_data - input parameter skb, gc or cx is NULL \n"); - return; - } - - // End debug information - if (cx->state!=NAS_CX_DCH) { - printk("nasmt_ASCTL_DC_send_sig_data - Not connected, so the message is dropped\n"); - ++gpriv->stats.tx_dropped; - return; - } - - p = (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = DATA_TRANSFER_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASDataReq); - p->nasUEDCPrimitive.data_transfer_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.data_transfer_req.priority = 3; // TBD - p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (skb->len)+1; //adds category character - - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version -#ifdef PDCP_USE_NETLINK - memcpy(xbuffer,(unsigned char *)p, p->length); - count = p->length; - bytes_wrote = count; -#else - bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); -#endif - //printk("nasmt_ASCTL_DC_send_sig_data - Wrote %d bytes to RRC NAS_DC_INPUT_SAPI\n", bytes_wrote); - - if (bytes_wrote!=p->length) { - printk("nasmt_ASCTL_DC_send_sig_data - Header sent failure in DC-FIFO\n"); - return; - } - -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),(unsigned char *)&data_type, 1); - count += 1; - bytes_wrote = count; -#else - bytes_wrote += nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)&data_type, 1); -#endif - -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),(unsigned char *)skb->data, skb->len); - count += skb->len; - bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], xbuffer, count); -#else - bytes_wrote += nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)skb->data, skb->len); -#endif - - if (bytes_wrote != p->length + skb->len + 1) { - printk("nasmt_ASCTL_DC_send_sig_data - Data sent failure in DC-FIFO\n"); - return; - } - - gpriv->stats.tx_bytes += skb->len; - gpriv->stats.tx_packets ++; -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_sig_data - end \n"); -#endif -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (DC SAP) -void nasmt_ASCTL_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig_category) -{ - //--------------------------------------------------------------------------- - struct nas_ue_dc_element *p; - uint8_t nasmt_data[10]; - unsigned int nasmt_length; - char data_type = 'Z'; - int bytes_wrote = 0; -#ifdef PDCP_USE_NETLINK - unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; - int count=0; -#endif - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_peer_sig_data - begin \n"); -#endif - - if (!cx) { - printk("nasmt_ASCTL_DC_send_peer_sig_data - input parameter cx is NULL \n"); - return; - } - - // End debug information - - if (cx->state!=NAS_CX_DCH) { - printk("nasmt_ASCTL_DC_send_peer_sig_data: Not connected, so the message is dropped\n"); - return; - } - - // Initialize peer message - nasmt_length = 10; - memset (nasmt_data, 0, nasmt_length); - nasmt_data[0]= sig_category; - // - p = (struct nas_ue_dc_element *)(gpriv->xbuffer); - p->type = DATA_TRANSFER_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASDataReq); - p->nasUEDCPrimitive.data_transfer_req.localConnectionRef = cx->lcr; - p->nasUEDCPrimitive.data_transfer_req.priority = 3; // TBD - p->nasUEDCPrimitive.data_transfer_req.nasDataLength = (nasmt_length)+1; //adds category character - - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version -#ifdef PDCP_USE_NETLINK - memcpy(xbuffer,(unsigned char *)p, p->length); - count = p->length; - bytes_wrote = count; -#else - bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); -#endif - //printk("nasmt_ASCTL_DC_send_sig_data - Wrote %d bytes to RRC NAS_DC_INPUT_SAPI\n", bytes_wrote); - - if (bytes_wrote!=p->length) { - printk("nasmt_ASCTL_DC_send_peer_sig_data - Header sent failure in DC-FIFO\n"); - return; - } - -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),(unsigned char *)&data_type, 1); - count += 1; -#else - bytes_wrote += nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)&data_type, 1); -#endif - -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),(unsigned char *)nasmt_data, nasmt_length); - count += nasmt_length; - bytes_wrote = nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], xbuffer, count); -#else - bytes_wrote += nasmt_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (char *)nasmt_data, nasmt_length); -#endif - - if (bytes_wrote != p->length + nasmt_length + 1) { - printk("nasmt_ASCTL_DC_send_peer_sig_data - Data sent failure in DC-FIFO\n"); - return; - } - -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_send_peer_sig_data - end \n"); -#endif -} - -/*************************************************************************** - Reception side - ***************************************************************************/ -//--------------------------------------------------------------------------- -// Decode CONN_ESTABLISH_RESP message from RRC -void nasmt_ASCTL_DC_decode_cx_establish_resp(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - - uint8_t sig_category; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_cx_establish - begin \n"); -#endif - - if (!cx || !p) { - printk("nasmt_ASCTL_DC_decode_cx_establish - input parameter cx or p is NULL \n"); - return; - } - - // End debug information - cx->retry=0; - - if (p->nasUEDCPrimitive.conn_establish_resp.status == TERMINATED) { - cx->state=NAS_CX_DCH; //to be changed to NAS_CX_FACH - cx->iid4=1; - nasmt_TOOL_imei2iid(NAS_RG_IMEI, (uint8_t *)cx->iid6); - sig_category = NAS_CMD_OPEN_RB; - //For demo, add automatically a radio bearer -#ifdef DEMO_3GSM - printk("nasmt_ASCTL_DC_decode_cx_establish - sig_category %u \n", sig_category); - nasmt_ASCTL_DC_send_peer_sig_data_request(cx, sig_category); -#endif - } else { - cx->state=NAS_IDLE; - } - -#ifdef NAS_DEBUG_DC - printk(" nasmt_ASCTL_DC_decode_cx_establish: CONN_ESTABLISH_RESP\n"); - printk(" Local Connection reference %u\n",p->nasUEDCPrimitive.conn_establish_resp.localConnectionRef); - printk(" Connection Establishment status %u\n",p->nasUEDCPrimitive.conn_establish_resp.status); - nasmt_TOOL_print_state(cx->state); -#endif -} - -//--------------------------------------------------------------------------- -// Decode CONN_LOSS_IND message from RRC -void nasmt_ASCTL_DC_decode_cx_loss_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_cx_loss - begin \n"); -#endif - - if (cx==NULL) { - printk("nasmt_ASCTL_DC_decode_cx_loss - input parameter cx is NULL \n"); - return; - } - - if (p==NULL) { - printk("nasmt_ASCTL_DC_decode_cx_loss - input parameter p is NULL \n"); - return; - } - - // End debug information - cx->state=NAS_IDLE; - cx->iid4=0; - //nasmt_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); - nasmt_COMMON_flush_rb(cx); -#ifdef NAS_DEBUG_DC - printk(" nasmt_ASCTL_DC_decode_cx_loss: CONN_LOSS_IND reception\n"); - printk(" Local Connection reference %u\n", p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef); - nasmt_TOOL_print_state(cx->state); -#endif -} - -//--------------------------------------------------------------------------- -// Decode CONN_RELEASE_IND message from RRC -//void nasmt_ASCTL_DC_decode_cx_release_ind(struct cx_entity *cx, struct nas_ue_dc_element *p){ -//--------------------------------------------------------------------------- -// printk("\t\tCONN_RELEASE_IND\n"); -// printk("\t\tLocal Connection reference %u\n", p->nasUEDCPrimitive.conn_release_ind.localConnectionRef); -// printk("\t\tRelease cause %u\n", p->nasRGDCPrimitive.conn_release_ind.releaseCause); -// if (gpriv->cx[cxi].state==NAS_CX_DCH) -// { -// gpriv->cx[cxi].state=NAS_IDLE; -// printk("\t\tMobile no more connected\n"); -// return bytes_read; -// } -// printk("\t\tIncoherent state %u\n", gpriv->cx[cxi].state); -// return bytes_read; -//} - -//--------------------------------------------------------------------------- -// Decode DATA_TRANSFER_IND message from RRC -void nasmt_ASCTL_DC_decode_sig_data_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - // struct pdcp_data_ind_header_t *pdcph; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_sig_data - begin \n"); -#endif - - if (!cx || !p) { - printk("nasmt_ASCTL_DC_decode_sig_data - input parameter cx or p is NULL \n"); - return; - } - - // End debug information - -#ifdef NAS_DEBUG_DC - printk(" nasmt_ASCTL_DC_decode_sig_data: DATA_TRANSFER_IND reception\n"); - printk(" Local Connection reference %u\n",p->nasUEDCPrimitive.data_transfer_ind.localConnectionRef); - printk(" Signaling Priority %u\n",p->nasUEDCPrimitive.data_transfer_ind.priority); - printk(" NAS Data length %u\n",p->nasUEDCPrimitive.data_transfer_ind.nasDataLength); - printk(" NAS Data string %s\n", (uint8_t *)p+p->length); -#endif - - //nasmt_COMMON_receive(p->length, p->nasUEDCPrimitive.data_transfer_ind.nasDataLength, cx->sap[GRAAL_DC_OUTPUT_SAPI]); // original -#ifndef PDCP_USE_NETLINK - //void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); - // data_buffer is NULL because FIFO should be read directly in the skbuff (LITE has an intermediary buffer) - nasmt_COMMON_receive(p->length, p->nasUEDCPrimitive.data_transfer_ind.nasDataLength, NULL, 2, cx->sap[NAS_DC_OUTPUT_SAPI]); -#else - nasmt_COMMON_receive(p->length, p->nasUEDCPrimitive.data_transfer_ind.nasDataLength, (unsigned char *)p+p->length, 2, 0); -#endif - -} -//--------------------------------------------------------------------------- -// Decode RB_ESTABLISH_IND message from RRC -void nasmt_ASCTL_DC_decode_rb_establish_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - int hard_coded_rbId = 3; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_rb_establish - begin \n"); -#endif - - if (cx==NULL) { - printk("nasmt_ASCTL_DC_decode_rb_establish - input parameter cx is NULL \n"); - return; - } - - if (p==NULL) { - printk("nasmt_ASCTL_DC_decode_rb_establish - input parameter p is NULL \n"); - return; - } - - // End debug information - // TEMP -MW - 26/9/13- Overwrite the rb_id sent by RRC - p->nasUEDCPrimitive.rb_establish_ind.rbId = hard_coded_rbId; - // TEMP -MW - 26/9/13- Rest should be kept unchanged - rb=nasmt_COMMON_search_rb(cx, p->nasUEDCPrimitive.rb_establish_ind.rbId); - - if (rb==NULL) { - rb=nasmt_COMMON_add_rb(cx, p->nasUEDCPrimitive.rb_establish_ind.rbId, p->nasUEDCPrimitive.rb_establish_ind.QoSclass); - rb->state=NAS_RB_DCH; - cx->state=NAS_CX_DCH; - rb->dscp = p->nasUEDCPrimitive.rb_establish_ind.dscp; - rb->sapi = p->nasUEDCPrimitive.rb_establish_ind.sapId; - rb->countimer=1; -#ifdef NAS_DEBUG_DC - printk(" nasmt_ASCTL_DC_decode_rb_establish: RB_ESTABLISH_IND reception\n"); - printk(" Local Connection reference %u\n",p->nasUEDCPrimitive.rb_establish_ind.localConnectionRef); - printk(" Radio Bearer Identity %u \n",p->nasUEDCPrimitive.rb_establish_ind.rbId); - printk(" QoS Traffic Class %u\n",p->nasUEDCPrimitive.rb_establish_ind.QoSclass); - printk(" DSCP Code %u\n",p->nasUEDCPrimitive.rb_establish_ind.dscp); - printk(" SAP Id %u\n",p->nasUEDCPrimitive.rb_establish_ind.sapId); - nasmt_TOOL_print_state(cx->state); - nasmt_TOOL_print_rb_entity(rb); -#endif - } else - printk("NAS_MT_DC_DECODE_RB_ESTABLISH_IND: RB_ESTABLISH_IND reception, Radio bearer already opened\n"); -} - -//--------------------------------------------------------------------------- -// Decode RB_RELEASE_IND message from RRC -void nasmt_ASCTL_DC_decode_rb_release_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - uint8_t dscp; - int hard_coded_rbId = 3; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_rb_release - begin \n"); -#endif - - if (!cx || !p) { - printk("nasmt_ASCTL_DC_decode_rb_release - input parameter is NULL \n"); - return; - } - - // End debug information - // TEMP -MW - 26/9/13- Overwrite the rb_id sent by RRC - p->nasUEDCPrimitive.rb_release_ind.rbId = hard_coded_rbId; - // TEMP -MW - 26/9/13- Rest should be kept unchanged - rb=nasmt_COMMON_search_rb(cx, p->nasUEDCPrimitive.rb_release_ind.rbId); - - if (rb!=NULL) { -#ifdef NAS_DEBUG_DC - printk(" nasmt_ASCTL_DC_decode_rb_release : RB_RELEASE_IND reception\n"); - printk(" Local Connection reference %u\n",p->nasUEDCPrimitive.rb_release_ind.localConnectionRef); - printk(" Radio Bearer Identity %u\n",p->nasUEDCPrimitive.rb_release_ind.rbId); - nasmt_TOOL_print_state(cx->state); -#endif - // rb->state=NAS_IDLE; - dscp = rb->dscp; - nasmt_COMMON_del_rb(cx, p->nasUEDCPrimitive.rb_release_ind.rbId, dscp); - } else - printk("nasmt_ASCTL_DC_decode_rb_release: RB_RELEASE_IND reception, No corresponding radio bearer\n"); - -} -//--------------------------------------------------------------------------- -// Decode MEASUREMENT_IND message from RRC -void nasmt_ASCTL_DC_decode_measurement_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - uint8_t i; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_measurement - begin \n"); -#endif - - if (cx==NULL) { - printk("nasmt_ASCTL_DC_decode_measurement - input parameter cx is NULL \n"); - return; - } - - if (p==NULL) { - printk("nasmt_ASCTL_DC_decode_measurement - input parameter p is NULL \n"); - return; - } - - // End debug information -#ifdef NAS_DEBUG_DC_MEASURE - printk(" nasmt_ASCTL_DC_decode_measurement : MEASUREMENT_IND reception\n"); - printk(" Local Connection reference: %u\n", p->nasUEDCPrimitive.measurement_ind.localConnectionRef); - printk(" Number of RGs: %u\n", p->nasUEDCPrimitive.measurement_ind.nb_rg); - nasmt_TOOL_print_state(cx->state); - - for (i=0; i<p->nasUEDCPrimitive.measurement_ind.nb_rg; ++i) { - printk(" RG[%u]: Cell_Id %u, Level: %u\n", i, - p->nasUEDCPrimitive.measurement_ind.measures[i].cell_id, - p->nasUEDCPrimitive.measurement_ind.measures[i].level); - } - -#endif -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_measurement - Local cell %d\n",p->nasUEDCPrimitive.measurement_ind.measures[0].cell_id); -#endif - cx->num_measures = p->nasUEDCPrimitive.measurement_ind.nb_rg; - - for (i=0; i<cx->num_measures; i++) { - cx->meas_cell_id[i]= (int)(p->nasUEDCPrimitive.measurement_ind.measures[i].cell_id); - cx->meas_level[i] = (int)(p->nasUEDCPrimitive.measurement_ind.measures[i].level); - //npriv->provider_id[i]=; - } - - cx->provider_id[0]=25; - cx->provider_id[1]=1; - cx->provider_id[2]=25; - -} - -//--------------------------------------------------------------------------- -// Decode MBMS_UE_NOTIFY_IND message from RRC -void nasmt_ASCTL_DC_decode_mbms_ue_notify_ind(struct cx_entity *cx, struct nas_ue_dc_element *p) -{ - //--------------------------------------------------------------------------- - uint8_t i, j, k; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasmt_ASCTL_DC_decode_mbms_ue_notify - begin \n"); -#endif - - if (!cx || !p) { - printk("nasmt_ASCTL_DC_decode_mbms_ue_notify - input parameter is NULL \n"); - return; - } - - for (i = 0; i<NASMT_MBMS_SVCES_MAX; i++) { - if (p->nasUEDCPrimitive.mbms_ue_notify_ind.joined_services[i].mbms_serviceId >=0) { - for (j = 0; j<NASMT_MBMS_SVCES_MAX; j++) { - if (cx->joined_services[j] ==-1) { - cx->joined_services[j]= p->nasUEDCPrimitive.mbms_ue_notify_ind.joined_services[i].mbms_serviceId; - break; - } - } - } - - if (p->nasUEDCPrimitive.mbms_ue_notify_ind.left_services[i].mbms_serviceId >=0) { - for (k = 0; k<NASMT_MBMS_SVCES_MAX; k++) { - if (cx->joined_services[k] == p->nasUEDCPrimitive.mbms_ue_notify_ind.left_services[i].mbms_serviceId) { - cx->joined_services[k]=-1; - break; - } - } - } - } - - // End debug information -#ifdef NAS_DEBUG_DC - printk(" nasmt_ASCTL_DC_decode_mbms_ue_notify : MBMS_UE_NOTIFY_IND reception\n"); - printk(" Local Connection reference: %u\n", p->nasUEDCPrimitive.mbms_ue_notify_ind.localConnectionRef); - nasmt_TOOL_print_state(cx->state); - printk("Joined services: "); - - for (i = 0; i<MAX_MBMS_SERVICES && (int) (p->nasUEDCPrimitive.mbms_ue_notify_ind.joined_services[i].mbms_serviceId) >= 0; i++) - printk("%d ", (p->nasUEDCPrimitive.mbms_ue_notify_ind.joined_services[i].mbms_serviceId)); - - printk("\n"); - printk("Left services: "); - - for (i = 0; i<MAX_MBMS_SERVICES && (int) (p->nasUEDCPrimitive.mbms_ue_notify_ind.left_services[i].mbms_serviceId) >= 0; i++) - printk("%d ", (p->nasUEDCPrimitive.mbms_ue_notify_ind.left_services[i].mbms_serviceId)); - - printk("\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Check if anything in DC FIFO and decode it (MT) -int nasmt_ASCTL_DC_receive(struct cx_entity *cx, char *buffer) -{ - //--------------------------------------------------------------------------- - int bytes_read=0; - - // Start debug information -#ifdef NAS_DEBUG_DC_DETAIL - printk("nasmt_ASCTL_DC_receive - begin \n"); -#endif - - if (!cx) { - printk("nasmt_ASCTL_DC_receive - input parameter cx is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - -#ifndef PDCP_USE_NETLINK - bytes_read = rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI] , gpriv->rbuffer, NAS_TL_SIZE); -#else - bytes_read = NAS_TL_SIZE; -#endif - - // - if (bytes_read>0) { - struct nas_ue_dc_element *p; - -#ifndef PDCP_USE_NETLINK - p= (struct nas_ue_dc_element *)(gpriv->rbuffer); - //get the rest of the primitive - bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); - - if (bytes_read!=p->length) { - printk("nasmt_ASCTL_DC_receive: Problem while reading primitive header\n"); - return bytes_read; - } - -#else - p= (struct nas_ue_dc_element *)(buffer); -#endif - - switch (p->type) { - case CONN_ESTABLISH_RESP : - if (p->nasUEDCPrimitive.conn_establish_resp.localConnectionRef!=cx->lcr) - printk("nasmt_ASCTL_DC_receive: CONN_ESTABLISH_RESP, Local connection reference not correct %u\n",p->nasUEDCPrimitive.conn_establish_resp.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_CONNECTING: - nasmt_ASCTL_DC_decode_cx_establish_resp(cx,p); // process message - break; - - default: - printk("nasmt_ASCTL_DC_receive: CONN_ESTABLISH_RESP reception, Invalid state %u\n", cx->state); - } - } - - break; - - case CONN_LOSS_IND : - if (p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef!=cx->lcr) - printk("nasmt_ASCTL_DC_receive: CONN_LOSS_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_RELEASING_FAILURE: - cx->retry=0; - - case NAS_CX_DCH: - nasmt_ASCTL_DC_decode_cx_loss_ind(cx,p); // process message - break; - - default: - printk("nasmt_ASCTL_DC_receive: CONN_LOSS_IND reception, Invalid state %u", cx->state); - } - } - - break; - - // case CONN_RELEASE_IND : - // break; - case DATA_TRANSFER_IND : - if (p->nasUEDCPrimitive.data_transfer_ind.localConnectionRef!=cx->lcr) - printk("nasmt_ASCTL_DC_receive: DATA_TRANSFER_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.conn_loss_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_FACH: - case NAS_CX_DCH: - nasmt_ASCTL_DC_decode_sig_data_ind(cx,p); // process message - break; - - default: - printk("nasmt_ASCTL_DC_receive: DATA_TRANSFER_IND reception, Invalid state %u", cx->state); - } - } - - break; - - case RB_ESTABLISH_IND : - if (p->nasUEDCPrimitive.rb_establish_ind.localConnectionRef!=cx->lcr) - printk("nasmt_ASCTL_DC_receive: RB_ESTABLISH_IND reception, Local connexion reference not correct %u\n", p->nasUEDCPrimitive.rb_establish_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_FACH: - case NAS_CX_DCH: - nasmt_ASCTL_DC_decode_rb_establish_ind(cx,p); // process message - break; - - default: - printk("nasmt_ASCTL_DC_receive: RB_ESTABLISH_IND reception, Invalid state %u", cx->state); - } - } - - break; - - case RB_RELEASE_IND : - if (p->nasUEDCPrimitive.rb_release_ind.localConnectionRef!=cx->lcr) - printk("nasmt_ASCTL_DC_receive: RB_RELEASE_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.rb_release_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_DCH: - nasmt_ASCTL_DC_decode_rb_release_ind(cx,p); // process message - break; - - default: - printk("nasmt_ASCTL_DC_receive: RB_RELEASE_IND reception, Invalid state %u", cx->state); - } - } - - break; - - case MEASUREMENT_IND : - if (p->nasUEDCPrimitive.measurement_ind.localConnectionRef!=cx->lcr) - printk("nasmt_ASCTL_DC_receive: MEASUREMENT_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.measurement_ind.localConnectionRef); - else { - nasmt_ASCTL_DC_decode_measurement_ind(cx,p); - } - - break; - - case MBMS_UE_NOTIFY_IND : - if (p->nasUEDCPrimitive.rb_release_ind.localConnectionRef!=cx->lcr) - printk("nasmt_ASCTL_DC_receive: MBMS_UE_NOTIFY_IND reception, Local connection reference not correct %u\n", p->nasUEDCPrimitive.rb_release_ind.localConnectionRef); - else { - switch (cx->state) { - case NAS_CX_DCH: - nasmt_ASCTL_DC_decode_mbms_ue_notify_ind(cx,p); // process message - break; - - default: - printk("nasmt_ASCTL_DC_receive: MBMS_UE_NOTIFY_IND reception, Invalid state %u", cx->state); - } - } - - break; - - default : - printk("nasmt_ASCTL_DC_receive: Invalid message received\n"); - } - } - -#ifdef NAS_DEBUG_DC_DETAIL - printk("nasmt_ASCTL_DC_receive - end \n"); -#endif - return bytes_read; -} - -//--------------------------------------------------------------------------- -// Check if anything in GC FIFO and decode it (MT) -int nasmt_ASCTL_GC_receive(char *buffer) -{ - //--------------------------------------------------------------------------- - int bytes_read = 0; - -#ifdef NAS_DEBUG_GC - printk("nasmt_ASCTL_GC_receive - begin \n"); -#endif - // End debug information - -#ifndef PDCP_USE_NETLINK - bytes_read = rtf_get(gpriv->sap[NAS_GC_SAPI], gpriv->rbuffer, NAS_TL_SIZE); -#else - bytes_read = NAS_TL_SIZE; -#endif - - // - if (bytes_read>0) { - struct nas_ue_gc_element *p; -#ifndef PDCP_USE_NETLINK - p= (struct nas_ue_gc_element *)(gpriv->rbuffer); - //get the rest of the primitive - bytes_read += rtf_get(gpriv->sap[NAS_GC_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); - - if (bytes_read!=p->length) { - printk("nasmt_ASCTL_GC_receive: Problem while reading primitive's header\n"); - return bytes_read; - } - -#else - p= (struct nas_ue_gc_element *)(buffer); - bytes_read = p->length; -#endif - - // start decoding message - switch (p->type) { - case INFO_BROADCAST_IND : -#ifndef PDCP_USE_NETLINK - bytes_read += rtf_get(gpriv->sap[NAS_GC_SAPI], (uint8_t *)p+p->length, p->nasUEGCPrimitive.broadcast_ind.nasDataLength); - - if (bytes_read!=p->length+p->nasUEGCPrimitive.broadcast_ind.nasDataLength) { - printk("nasmt_ASCTL_GC_receive: INFO_BROADCAST_IND reception, Problem while reading primitive's data\n"); - return bytes_read; - } - -#endif -#ifdef NAS_DEBUG_GC - printk(" nasmt_ASCTL_GC_receive : INFO_BROADCAST_IND reception\n"); - printk(" Primitive length %d \n", (int)(p->type)); - printk(" Data length %u\n", p->nasUEGCPrimitive.broadcast_ind.nasDataLength); - printk(" Data string %s\n", (uint8_t *)p+p->length); -#endif - return bytes_read; - - default : - printk("nasmt_ASCTL_GC_receive: Invalid message received, type %d\n", p->type); - nasmt_TOOL_print_buffer(buffer, 16); - return -1; - } - } else - return -1; -} - -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_classifier.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_classifier.c deleted file mode 100644 index 3cc1ac0879822d1ad85d169ac1cc665774386f67..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_classifier.c +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_classifier.c -* \brief Flow classification functions for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#include "nasmt_variables.h" -#include "nasmt_proto.h" - -#include <net/ip6_fib.h> -#include <net/route.h> - -#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) -#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) -#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000) -#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) - -/* Address to accept any incoming messages. */ -#define INADDR_ANY ((unsigned long int) 0x00000000) - -#define NIPADDR(addr) \ - (uint8_t)(addr & 0x000000FF), \ - (uint8_t)((addr & 0x0000FF00) >> 8), \ - (uint8_t)((addr & 0x00FF0000) >> 16), \ - (uint8_t)((addr & 0xFF000000) >> 24) - -#define NIP6ADDR(addr) \ - ntohs((addr)->s6_addr16[0]), \ - ntohs((addr)->s6_addr16[1]), \ - ntohs((addr)->s6_addr16[2]), \ - ntohs((addr)->s6_addr16[3]), \ - ntohs((addr)->s6_addr16[4]), \ - ntohs((addr)->s6_addr16[5]), \ - ntohs((addr)->s6_addr16[6]), \ - ntohs((addr)->s6_addr16[7]) - - -#define IN6_IS_ADDR_UNSPECIFIED(a) \ - (((__const uint32_t *) (a))[0] == 0 \ - && ((__const uint32_t *) (a))[1] == 0 \ - && ((__const uint32_t *) (a))[2] == 0 \ - && ((__const uint32_t *) (a))[3] == 0) - -#define IN6_ARE_ADDR_MASKED_EQUAL(a,b,m) \ - (((((__const uint32_t *) (a))[0] & (((__const uint32_t *) (m))[0])) == (((__const uint32_t *) (b))[0] & (((__const uint32_t *) (m))[0]))) \ - && ((((__const uint32_t *) (a))[1] & (((__const uint32_t *) (m))[1])) == (((__const uint32_t *) (b))[1] & (((__const uint32_t *) (m))[1]))) \ - && ((((__const uint32_t *) (a))[2] & (((__const uint32_t *) (m))[2])) == (((__const uint32_t *) (b))[2] & (((__const uint32_t *) (m))[2]))) \ - && ((((__const uint32_t *) (a))[3] & (((__const uint32_t *) (m))[3])) == (((__const uint32_t *) (b))[3] & (((__const uint32_t *) (m))[3])))) - -#define IN_ARE_ADDR_MASKED_EQUAL(a,b,m) \ - (((((__const uint8_t *) (a))[0] & (((__const uint8_t *) (m))[0])) == (((__const uint8_t *) (b))[0] & (((__const uint8_t *) (m))[0]))) \ - && ((((__const uint8_t *) (a))[1] & (((__const uint8_t *) (m))[1])) == (((__const uint8_t *) (b))[1] & (((__const uint8_t *) (m))[1]))) \ - && ((((__const uint8_t *) (a))[2] & (((__const uint8_t *) (m))[2])) == (((__const uint8_t *) (b))[2] & (((__const uint8_t *) (m))[2]))) \ - && ((((__const uint8_t *) (a))[3] & (((__const uint8_t *) (m))[3])) == (((__const uint8_t *) (b))[3] & (((__const uint8_t *) (m))[3])))) - -//--------------------------------------------------------------------------- -void nasmt_create_mask_ipv6_addr(struct in6_addr *masked_addrP, int prefix_len) -{ - //--------------------------------------------------------------------------- - int u6_addr8_index; - int u6_addr1_index; - int index; - - masked_addrP->s6_addr32[0] = 0xFFFFFFFF; - masked_addrP->s6_addr32[1] = 0xFFFFFFFF; - masked_addrP->s6_addr32[2] = 0xFFFFFFFF; - masked_addrP->s6_addr32[3] = 0xFFFFFFFF; - - u6_addr8_index = prefix_len >> 3; - u6_addr1_index = prefix_len & 0x07; - - for (index = u6_addr8_index + 1; index < 16; index++) { - masked_addrP->s6_addr[index] = 0; - } - - if (u6_addr1_index > 0) { - masked_addrP->s6_addr[u6_addr8_index] = 0xFF << (8-u6_addr1_index); - } -} -//--------------------------------------------------------------------------- -void nasmt_create_mask_ipv4_addr(struct in_addr *masked_addrP, int prefix_len) -{ - //--------------------------------------------------------------------------- - if (prefix_len > 32) { - prefix_len = 32; - } - - masked_addrP->s_addr = 0xFFFFFFFF << (32 - prefix_len); - return; -} - -//--------------------------------------------------------------------------- -// Add a new classifier rule (send direction) -struct classifier_entity *nasmt_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_add_sclassifier: begin for dscp %d, classref %d\n", dscp,classref); -#endif - - if (cx==NULL) { - printk("nasmt_CLASS_add_sclassifier - input parameter cx is NULL \n"); - return NULL; - } - - //*** - for (gc=cx->sclassifier[dscp]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_add_sclassifier: classifier already exist for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_ATOMIC); - - if (gc==NULL) - return NULL; - - memset(gc, 0, sizeof(struct classifier_entity)); - gc->next=cx->sclassifier[dscp]; - gc->classref=classref; - cx->sclassifier[dscp]=gc; - ++cx->nsclassifier; - ++gpriv->next_sclassref; //increment send classref index - MW 15/01/07 -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_add_sclassifier: classifier created for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; -} - -//--------------------------------------------------------------------------- -// Add a new classifier rule (receive direction) -struct classifier_entity *nasmt_CLASS_add_rclassifier(uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_add_rclassifier: begin\n"); -#endif - - //*** - for (gc=gpriv->rclassifier[dscp]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_add_rclassifier: classifier already exist for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL); - - if (gc==NULL) - return NULL; - - gc->next=gpriv->rclassifier[dscp]; - gc->classref=classref; - gpriv->rclassifier[dscp]=gc; - ++gpriv->nrclassifier; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_add_rclassifier: classifier created for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; -} - -//--------------------------------------------------------------------------- -void nasmt_CLASS_flush_sclassifier(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - uint8_t dscpi; - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_flush_sclassifier: begin\n"); -#endif - - if (cx==NULL) { - printk("nasmt_CLASS_flush_sclassifier - input parameter cx is NULL \n"); - return; - } - - //*** - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) { - for (gc=cx->sclassifier[dscpi]; gc!=NULL; gc=cx->sclassifier[dscpi]) { - cx->sclassifier[dscpi]=gc->next; - kfree(gc); - } - } - - cx->nsclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_flush_sclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -void nasmt_CLASS_flush_rclassifier() -{ - //--------------------------------------------------------------------------- - uint8_t dscpi; - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_flush_rclassifier: begin\n"); -#endif - - //*** - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) { - for (gc=gpriv->rclassifier[dscpi]; gc!=NULL; gc=gpriv->rclassifier[dscpi]) { - gpriv->rclassifier[dscpi]=gc->next; - kfree(gc); - } - } - - gpriv->nrclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_flush_rclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (send direction) -void nasmt_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_del_sclassifier: begin\n"); -#endif - - if (cx==NULL) { - printk("nasmt_CLASS_del_sclassifier - input parameter cx is NULL \n"); - return; - } - - //*** - p=cx->sclassifier[dscp]; - - if (p==NULL) - return; - - if (p->classref==classref) { - cx->sclassifier[dscp]=p->next; - kfree(p); - --cx->nsclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --cx->nsclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_del_sclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (receive direction) -void nasmt_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_del_rclassifier: begin\n"); -#endif - //*** - p=gpriv->rclassifier[dscp]; - - if (p==NULL) - return; - - if (p->classref==classref) { - gpriv->rclassifier[dscp]=p->next; - kfree(p); - --gpriv->nrclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --gpriv->nrclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_del_rclassifier: end\n"); -#endif -} - -/* ORIGINAL VERSION -//--------------------------------------------------------------------------- -// Search the entity with the IPv6 address 'addr' -struct cx_entity *nasmt_CLASS_cx6(struct sk_buff *skb){ -//--------------------------------------------------------------------------- - uint8_t cxi; - #ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx6: begin\n"); - #endif - cxi=0; - return gpriv->cx+cxi; -}*/ - -//--------------------------------------------------------------------------- -// Search the entity with the IPv6 address 'addr' -// Navid: the ipv6 classifier is not fully tested -struct cx_entity *nasmt_CLASS_cx6(struct sk_buff *skb, unsigned char dscp, int *paddr_type, unsigned char *cx_index) -{ - //--------------------------------------------------------------------------- - uint8_t cxi; - struct cx_entity *cx = NULL; - struct classifier_entity *sclassifier= NULL; - uint32_t mc_addr_hdr; - struct in6_addr masked_addr; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx6: begin\n"); -#endif - - if (skb) { -#ifdef NAS_DEBUG_CLASS - printk("SOURCE ADDR %X:%X:%X:%X:%X:%X:%X:%X",NIP6ADDR(&(ipv6_hdr(skb)->saddr))); - printk(" DEST ADDR %X:%X:%X:%X:%X:%X:%X:%X\n",NIP6ADDR(&(ipv6_hdr(skb)->daddr))); -#endif - mc_addr_hdr = ntohl(ipv6_hdr(skb)->daddr.in6_u.u6_addr32[0]); - - // First check if multicast [1st octet is FF] - if ((mc_addr_hdr & 0xFF000000) == 0xFF000000) { - // packet type according to the scope of the multicast packet - // we don't consider RPT bits in second octet [maybe done later if needed] - switch(mc_addr_hdr & 0x000F0000) { - case (0x00020000): - *paddr_type = NAS_IPV6_ADDR_MC_SIGNALLING; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx6: multicast packet - signalling \n"); -#endif - break; - - default: - printk("nasmt_CLASS_cx6: default multicast\n"); - *paddr_type = NAS_IPV6_ADDR_UNKNOWN; - } - } else { - // This is not multicast, so we should be able to identify the MT - *paddr_type = NAS_IPV6_ADDR_UNICAST; - cxi = 0; - (*cx_index)++; - sclassifier = gpriv->cx[cxi].sclassifier[dscp]; - - while (sclassifier!=NULL) { - // verify that this is an IPv6 classifier - if ((sclassifier->version == NAS_VERSION_6) || (sclassifier->version == NAS_VERSION_DEFAULT)) { - /*LGif (IN6_IS_ADDR_UNSPECIFIED(&(sclassifier->daddr.ipv6))) { - printk("nas_CLASS_cx6: addr is null \n"); - sclassifier = sclassifier->next; - continue; - }*/ -#ifdef NAS_DEBUG_CLASS - printk("cx %d : DSCP %d %X:%X:%X:%X:%X:%X:%X:%X\n",cxi, dscp, NIP6ADDR(&(sclassifier->daddr.ipv6))); -#endif //NAS_DEBUG_CLASS - - //if ((dst = (unsigned int*)&(((struct rt6_info *)skbdst)->rt6i_gateway)) == 0){ - // LG: STRANGE - if (IN6_IS_ADDR_UNSPECIFIED(&ipv6_hdr(skb)->daddr)) { - printk("nasmt_CLASS_cx6: dst addr is null \n"); - sclassifier = sclassifier->next; - continue; - } - - nasmt_create_mask_ipv6_addr(&masked_addr, sclassifier->dplen); - // Modified MW to check only the iid6 - masked_addr.s6_addr32[0] = 0x00000000; - masked_addr.s6_addr32[1] = 0x00000000; - - if (IN6_ARE_ADDR_MASKED_EQUAL(&ipv6_hdr(skb)->daddr, &(sclassifier->daddr.ipv6), &masked_addr)) { -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx6: found cx %d: %X:%X:%X:%X:%X:%X:%X:%X\n",cxi, NIP6ADDR(&(sclassifier->daddr.ipv6))); -#endif //NAS_DEBUG_CLASS - return &gpriv->cx[cxi]; - } - } - - // Go to next classifier entry for connection - sclassifier = sclassifier->next; - } - } - } - - //printk("nas_CLASS_cx6 NOT FOUND: %X:%X:%X:%X:%X:%X:%X:%X\n",NIP6ADDR(&ipv6_hdr(skb)->daddr)); - return cx; -} - -/* ORIGINAL VERSION -//--------------------------------------------------------------------------- -// Search the entity with the IPv4 address 'addr' -struct cx_entity *nasmt_CLASS_cx4(struct sk_buff *skb){ -//--------------------------------------------------------------------------- - uint8_t cxi; - #ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx4: begin\n"); - #endif - cxi=0; - return gpriv->cx+cxi; -}*/ - -//--------------------------------------------------------------------------- -// Search the entity with the IPv4 address 'addr' -struct cx_entity *nasmt_CLASS_cx4(struct sk_buff *skb, unsigned char dscp, int *paddr_type, unsigned char *cx_index) -{ - //--------------------------------------------------------------------------- - unsigned char cxi; - uint32_t daddr; - struct cx_entity *cx=NULL; - struct classifier_entity *pclassifier=NULL; - struct in_addr masked_addr; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx4: begin\n"); -#endif - - if (skb!=NULL) { - daddr = ((struct iphdr*)(skb_network_header(skb)))->daddr; - - if (daddr != INADDR_ANY) { -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx4: SOURCE ADDR %d.%d.%d.%d",NIPADDR(ip_hdr(skb)->saddr)); - printk(" DEST ADDR %d.%d.%d.%d\n",NIPADDR(ip_hdr(skb)->daddr)); -#endif - - if (ipv4_is_multicast(ip_hdr(skb)->daddr)) { - // TO BE CHECKED - *paddr_type = NAS_IPV4_ADDR_MC_SIGNALLING; - } else { - if (ipv4_is_lbcast(ip_hdr(skb)->daddr)) { - // TO BE CHECKED - *paddr_type = NAS_IPV4_ADDR_BROADCAST; - } else { - if (IN_CLASSA(ip_hdr(skb)->daddr) || IN_CLASSB(ip_hdr(skb)->daddr) || IN_CLASSC(ip_hdr(skb)->daddr)) { - *paddr_type = NAS_IPV4_ADDR_UNICAST; - cxi = 0; - (*cx_index)++; - pclassifier = gpriv->cx[cxi].sclassifier[dscp]; - - while (pclassifier!=NULL) { - // verify that this is an IPv4 classifier - if ((pclassifier->version == NAS_VERSION_4) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - nasmt_create_mask_ipv4_addr(&masked_addr, pclassifier->dplen); - - if (IN_ARE_ADDR_MASKED_EQUAL(&ip_hdr(skb)->daddr, &(pclassifier->daddr.ipv4), &masked_addr)) { -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_cx4: IP MASK MATCHED: found cx %d: %d.%d.%d.%d/%d\n",cxi, NIPADDR(pclassifier->daddr.ipv4), pclassifier->dplen); -#endif - return &gpriv->cx[cxi]; - } - } - - // goto to next classification rule for the connection - pclassifier = pclassifier->next; - } - } else { - *paddr_type = NAS_IPV4_ADDR_UNKNOWN; - } - } - } - } - } - - return cx; -} - -//--------------------------------------------------------------------------- -// Search the sending function for IP Packet -void nasmt_CLASS_send(struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *pclassifier, *sp; - uint8_t *protocolh = NULL; - uint8_t version; - uint8_t protocol, dscp; - uint16_t classref; - struct cx_entity *cx; -#ifdef NAS_DEBUG_CLASS - char sfct[10], sprotocol[10]; -#endif - struct net_device *dev = gdev; - unsigned char cx_index,no_connection; - int addr_type; - struct in6_addr masked6_addr; - struct in_addr masked_addr; - // RARP vars - struct arphdr *rarp; - unsigned char *rarp_ptr; - /* s for "source", t for "target" */ - __be32 sip, tip; - unsigned char *sha, *tha; - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: begin -\n"); -#endif - - if (skb==NULL) { - printk("nasmt_CLASS_send - input parameter skb is NULL \n"); - return; - } - - //*** -#ifdef NAS_DEBUG_SEND - printk("nasmt_CLASS_send - Received IP packet to transmit:"); - - if ((skb->data) != NULL) { - if (skb->len<100) - nasmt_TOOL_print_buffer(skb->data,skb->len); - else - nasmt_TOOL_print_buffer(skb->data,100); - } - -#endif - //*** - // find all connections related to socket - cx_index = 0; - no_connection = 1; - cx = NULL; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: [before switch on IP protocol version] \n"); -#endif - - - // Get mobile connexion entity, protocol and dscp from IP packet - switch (ntohs(skb->protocol)) { - case ETH_P_IPV6: -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send : skb->protocol : IPv6 \n"); -#endif - version = NAS_VERSION_6; - addr_type = NAS_IPV6_ADDR_UNKNOWN; - protocolh = nasmt_TOOL_get_protocol6(ipv6_hdr(skb), &protocol); - dscp = nasmt_TOOL_get_dscp6 (ipv6_hdr(skb)); - cx = nasmt_CLASS_cx6 (skb, dscp, &addr_type, &cx_index); -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send - ETH_P_IPV6 skb %p dscp %d gpriv %p cx_index %p \n",skb, dscp, gpriv, &cx_index); -#endif - - // find in default DSCP a valid classification - if (cx == NULL) { - switch (addr_type) { - case NAS_IPV6_ADDR_MC_SIGNALLING: - case NAS_IPV6_ADDR_UNICAST: - pclassifier=(&gpriv->cx[0])->sclassifier[NAS_DSCP_DEFAULT]; - - while (pclassifier!=NULL) { - if ((pclassifier->version == NAS_VERSION_6) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - // ok found default classifier for this packet - nasmt_create_mask_ipv6_addr(&masked6_addr, pclassifier->dplen); - - if (IN6_ARE_ADDR_MASKED_EQUAL(&pclassifier->daddr.ipv6, &ipv6_hdr(skb)->daddr, &masked6_addr)) { - // then force dscp - cx = &gpriv->cx[0]; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send - ETH_P_IPV6 FOUND NAS_DSCP_DEFAULT with IN6_ARE_ADDR_MASKED_EQUAL(%d bits)\n",pclassifier->dplen); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } else { - if(IN6_IS_ADDR_UNSPECIFIED(&pclassifier->daddr.ipv6)) { - cx = &gpriv->cx[0]; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send - ETH_P_IPV6 FOUND NAS_DSCP_DEFAULT with IN6_IS_ADDR_UNSPECIFIED\n"); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } - } - } - - pclassifier = pclassifier->next; - } - - break; - - // should have found a valid classification rule - case NAS_IPV6_ADDR_UNKNOWN: - default: - printk("nasmt_CLASS_send: No corresponding address type\n"); - } - } - - break; - - case ETH_P_ARP: -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send : skb->protocol : ARP \n"); -#endif - version = NAS_VERSION_4; - addr_type = NAS_IPV4_ADDR_BROADCAST; - dscp = 0; - cx = NULL; - // Basic sanity checks can be done without the lock - rarp = (struct arphdr *)skb_network_header(skb); - - if (rarp) { - if (rarp->ar_hln != dev->addr_len || dev->type != ntohs(rarp->ar_hrd)) { - printk("nasmt_CLASS_send: ARP PACKET WRONG ADDR LEN or WRONG ARP HEADER TYPE\n"); - break; - } - } else { - printk("nasmt_CLASS_send: ARP HEADER POINTER IS NULL\n"); - break; - } - - // If it's not Ethernet, delete it. - if (rarp->ar_pro != htons(ETH_P_IP)) { - printk("nasmt_CLASS_send: ARP PACKET PROTOCOL IS NOT ETHERNET\n"); - break; - } - - rarp_ptr = (unsigned char *) (rarp + 1); - sha = rarp_ptr; - rarp_ptr += dev->addr_len; - memcpy(&sip, rarp_ptr, 4); - rarp_ptr += 4; - tha = rarp_ptr; - rarp_ptr += dev->addr_len; - memcpy(&tip, rarp_ptr, 4); -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: ARP DEST IP transport IP = %d.%d.%d.%d\n",NIPADDR(tip)); -#endif - pclassifier=(&gpriv->cx[0])->sclassifier[NAS_DSCP_DEFAULT]; - - while (pclassifier!=NULL) { - if ((pclassifier->version == NAS_VERSION_4) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - // ok found default classifier for this packet - nasmt_create_mask_ipv4_addr(&masked_addr, pclassifier->dplen); -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: MASK = %d.%d.%d.%d\n",NIPADDR(masked_addr.s_addr)); -#endif - - // - if (IN_ARE_ADDR_MASKED_EQUAL(&pclassifier->daddr.ipv4, &tip, &masked_addr.s_addr)) { - // then force dscp - cx = &gpriv->cx[0]; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: ETH_P_ARP FOUND NAS_DSCP_DEFAULT with IN_ARE_ADDR_MASKED_EQUAL(%d bits)\n", pclassifier->dplen); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } else { - if (INADDR_ANY == pclassifier->daddr.ipv4) { - cx = &gpriv->cx[0]; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: ETH_P_ARP FOUND NAS_DSCP_DEFAULT with INADDR_ANY\n"); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } - } - } - - pclassifier = pclassifier->next; - } - - break; - - case ETH_P_IP: -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send : skb->protocol : IPv4 \n"); -#endif - version = NAS_VERSION_4; - addr_type = NAS_IPV4_ADDR_UNKNOWN; - dscp = nasmt_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb))); - cx = nasmt_CLASS_cx4(skb, dscp, &addr_type, &cx_index); - protocolh = nasmt_TOOL_get_protocol4((struct iphdr *)(skb_network_header(skb)), &protocol); - - // find in default DSCP a valid classification - if (cx == NULL) { - switch (addr_type) { - case NAS_IPV4_ADDR_MC_SIGNALLING: - case NAS_IPV4_ADDR_UNICAST: - case NAS_IPV4_ADDR_BROADCAST: - pclassifier=(&gpriv->cx[0])->sclassifier[NAS_DSCP_DEFAULT]; - - while (pclassifier != NULL) { - if ((pclassifier->version == NAS_VERSION_4) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - // ok found default classifier for this packet - nasmt_create_mask_ipv4_addr(&masked_addr, pclassifier->dplen); -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send : MASK = %d.%d.%d.%d\n", NIPADDR(masked_addr.s_addr)); -#endif - - if (IN_ARE_ADDR_MASKED_EQUAL(&pclassifier->daddr.ipv4, &ip_hdr(skb)->daddr, &masked_addr.s_addr)) { - // then force dscp - cx = &gpriv->cx[0]; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send : ETH_P_IP FOUND NAS_DSCP_DEFAULT with IN_ARE_ADDR_MASKED_EQUAL(%d bits)\n",pclassifier->dplen); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } else { - if(INADDR_ANY == pclassifier->daddr.ipv4) { - cx = &gpriv->cx[0]; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send : ETH_P_IP FOUND NAS_DSCP_DEFAULT with INADDR_ANY\n"); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } - } - } - - pclassifier = pclassifier->next; - } - - break; - - // should have found a valid classification rule - case NAS_IPV4_ADDR_UNKNOWN: - default: - printk("nasmt_CLASS_send: No corresponding address type\n"); - } - } - -#ifdef NAS_DEBUG_CLASS - - //printk("nasmt_CLASS_send: ETH_P_IP Received IPv4 packet (%02X), dscp = %d, cx = %08X\n",ntohs(skb->protocol),dscp,cx); - if (cx) - printk("nasmt_CLASS_send: ETH_P_IP Received IPv4 packet (%02X), dscp = %d, cx = %d\n",ntohs(skb->protocol),dscp,cx->lcr); - else - printk("nasmt_CLASS_send: ETH_P_IP Received IPv4 packet (%02X), dscp = %d, No valid connection\n",ntohs(skb->protocol),dscp); - -#endif - break; - - default: - printk("nasmt_CLASS_send: Unknown IP version protocol\n"); - version = 0; - return; - } - -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasmt_CLASS_send: [before if (cx != NULL)]\n"); -#endif - - // If a valid connection for the DSCP/EXP with destination address - // is found scan all protocol-based classification rules - if (cx != NULL) { - classref = 0; - sp = NULL; - - if (cx->state!=NAS_CX_DCH) { -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: UE not connected, in state %d. Packet is dropped\n",cx->state); -#endif - return; - } - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: DSCP %d version %d: looking for classifier entry\n",dscp, version); -#endif - - for (pclassifier=cx->sclassifier[dscp]; pclassifier!=NULL; pclassifier=pclassifier->next) { -#ifdef NAS_DEBUG_CLASS - printk("nasmt_CLASS_send: DSCP %d p->classref=%d,p->protocol=%d,p->version=%d\n",dscp,pclassifier->classref,pclassifier->protocol,pclassifier->version); -#endif - - // normal rule checks that network protocol version matches - if ((pclassifier->version == version) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - //printk("nasmt_CLASS_send: IP version are equals\n"); - sp=pclassifier; - classref=sp->classref; -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasmt_CLASS_send: classifier found for dscp %u \n", dscp); -#endif - break; - } - } - - if (sp!=NULL) { -#ifdef NAS_DEBUG_CLASS - - //char sfct[10], sprotocol[10]; - // classifier entity found. Print its parameters - if (sp->fct==nasmt_COMMON_QOS_send) - strcpy(sfct, "data xfer"); - - if (sp->fct==nasmt_CTL_send) - strcpy(sfct, "iocontrol"); - - if (sp->fct==nasmt_COMMON_del_send) - strcpy(sfct, "delete"); - - if (sp->fct==nasmt_ASCTL_DC_send_sig_data_request) - strcpy(sfct, "DC-SAP"); - - switch(protocol) { - case NAS_PROTOCOL_UDP: - strcpy(sprotocol, "udp"); - printk("udp packet\n"); - break; - - case NAS_PROTOCOL_TCP: - strcpy(sprotocol, "tcp"); - printk("tcp packet\n"); - break; - - case NAS_PROTOCOL_ICMP4: - strcpy(sprotocol, "icmp4"); - printk("icmp4 packet\n"); - break; - - case NAS_PROTOCOL_ICMP6: - strcpy(sprotocol, "icmp6"); - nasmt_TOOL_pk_icmp6((struct icmp6hdr*)protocolh); - break; - - default: - strcpy(sprotocol, "other L4"); - break; - } - - printk("nasmt_CLASS_send: (dscp %u, %s) received, (classref %u, fct %s, drb_id %u) classifier rule\n", - dscp, sprotocol, sp->classref, sfct, sp->rab_id); -#endif - - //forward packet to the correct entity - if (sp->fct!=NULL) { - sp->fct(skb, cx, sp); - } else { - printk("\n\nnasmt_CLASS_send: ERROR : CLASSIFIER FUNCTION IS NULL\n\n"); - } - - no_connection = 0; - // end : if classifier entry match found - } else { - printk("nasmt_CLASS_send: no corresponding item in the classifier list, so the message is dropped\n"); - printk("nasmt_CLASS_send: packet parameters: dscp %u, %s\n", dscp, sprotocol); - nasmt_COMMON_del_send(skb, cx, NULL); // Note MW: LG has commented this line. Why? - } - } // if connection found - -#ifdef NAS_DEBUG_CLASS - - if (no_connection == 1) { - printk("nasmt_CLASS_send: no corresponding connection, so the message is dropped\n"); - } - - printk("nasmt_CLASS_send: end\n"); -#endif -} diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c deleted file mode 100644 index bbafa86ad1c0fdb0b74301b78e8d3ace99802789..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_common.c +++ /dev/null @@ -1,542 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_common.c -* \brief Common functions for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#include "nasmt_variables.h" -#include "nasmt_proto.h" - -#include <linux/inetdevice.h> -#ifdef NAS_DRIVER_TYPE_ETHERNET -#include <linux/etherdevice.h> -#endif - -//--------------------------------------------------------------------------- -// Receive data from FIFO (QOS or DC) -//void nasmt_COMMON_receive(uint16_t hlen, uint16_t dlen, int sap){ -//void nasmt_COMMON_receive(uint16_t hlen, uint16_t dlen, void *pdcp_sdu, int sap){ -void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap) -{ - //--------------------------------------------------------------------------- - struct sk_buff *skb; - struct ipversion *ipv; - unsigned int hard_header_len; - uint16_t *p_ether_type; - uint16_t ether_type; - -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_receive: begin\n"); -#endif -#ifdef PDCP_USE_NETLINK - - // data_buffer is NULL if FIFOs - if (!data_buffer) { - printk("nasmt_COMMON_receive - input parameter data_buffer is NULL \n"); - return; - } - -#endif - - skb = dev_alloc_skb( payload_length + 2 ); - - if(!skb) { - printk("nasmt_COMMON_receive: low on memory\n"); - ++gpriv->stats.rx_dropped; - return; - } - - skb_reserve(skb,2); - -#ifndef PDCP_USE_NETLINK - bytes_read += rtf_get(sap, skb_put(skb, payload_length), payload_length); - - if (bytes_read != NAS_PDCPH_SIZE + payload_length) { - printk("nasmt_COMMON_receive: problem while reading DC sap\n"); - kfree(skb->data); - dev_kfree_skb(skb); - return; - } - -#else - memcpy(skb_put(skb, payload_length), data_buffer, payload_length); - bytes_read += payload_length; -#endif - -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_receive: received packet from PDCP, length %d\n", bytes_read); -#endif - - skb->dev = gdev; - hard_header_len = gdev->hard_header_len; - skb->mac_header = skb->data; - skb->pkt_type = PACKET_HOST; - skb->ip_summed = CHECKSUM_UNNECESSARY; - - ipv = (struct ipversion *)&(skb->data[hard_header_len]); - - switch (ipv->version) { - case 6: -#ifdef NAS_DEBUG_RECEIVE_BASIC - printk("nasmt_COMMON_receive: receive IPv6 message\n"); -#endif - skb->network_header = &skb->data[hard_header_len]; - // set protocol default value - skb->protocol = htons(ETH_P_IPV6); - // If type Ethernet, correct it -#ifdef NAS_DRIVER_TYPE_ETHERNET - skb->protocol = eth_type_trans(skb, gdev); -#endif - break; - - case 4: -#ifdef NAS_DEBUG_RECEIVE_BASIC - printk("nasmt_COMMON_receive: receive IPv4 message\n"); -#endif - -#ifdef NAS_DEBUG_RECEIVE - addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->saddr; - - if (addr) { - printk("nasmt_COMMON_receive: Source %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]); - } - - addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->daddr; - - if (addr) { - printk("[NAS][COMMON][RECEIVE] Dest %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]); - } - - printk("[NAS][COMMON][RECEIVE] protocol %d\n",((struct iphdr *)&skb->data[hard_header_len])->protocol); -#endif - - skb->network_header = &skb->data[hard_header_len]; - // set protocol default value - skb->protocol = htons(ETH_P_IP); - // If type Ethernet, correct it -#ifdef NAS_DRIVER_TYPE_ETHERNET - skb->protocol = eth_type_trans(skb, gdev); -#endif - break; - - default: - printk("nasmt_COMMON_receive: Packet is not IPv4 or IPv6 (version=%d)\n", ipv->version); - -#ifdef NAS_DRIVER_TYPE_ETHERNET -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_receive: ether_type=%04X\n", ether_type); -#endif - skb->protocol = eth_type_trans(skb, gdev); - // minus 1(short) instead of 2(bytes) because uint16_t* - p_ether_type = (uint16_t *)&(skb->mac_header[hard_header_len-2]); - ether_type = ntohs(*p_ether_type); -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_receive: ether_type=%04X\n", ether_type); -#endif - - switch (ether_type) { - case ETH_P_ARP: - printk("[NAS][COMMON] ether_type = ETH_P_ARP\n"); - skb->protocol = htons(ETH_P_ARP); - skb->network_header = &skb->mac_header[hard_header_len]; - break; - - default: - break; - } - -#endif - } - - ++gpriv->stats.rx_packets; - gpriv->stats.rx_bytes += bytes_read; -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_receive: forwarding packet of size %d to kernel\n",skb->len); -#endif - - netif_rx(skb); -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_receive: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete the data -void nasmt_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *sp) -{ - //--------------------------------------------------------------------------- -#ifdef NAS_DEBUG_SEND - printk("nasmt_COMMON_del_send - updating statistics \n"); -#endif - ++gpriv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (QoS SAP) -void nasmt_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - //struct pdcp_data_req pdcph; - struct pdcp_data_req_header_t pdcph; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_SEND - printk("nasmt_COMMON_QOS_send - begin \n"); -#endif - - // if (cx->state!=NAS_STATE_CONNECTED) // <--- A REVOIR - // { - // gpriv->stats.tx_dropped ++; - // printk("NAS_QOS_SEND: No connected, so message are dropped \n"); - // return; - // } - if (!skb || !gc || !cx) { - printk("nasmt_COMMON_QOS_send - input parameter skb|gc|cx is NULL \n"); - return; - } - - // End debug information - - if (gc->rb==NULL) { - gc->rb = nasmt_COMMON_search_rb(cx, gc->rab_id); - - if (gc->rb==NULL) { - ++gpriv->stats.tx_dropped; - printk("nasmt_COMMON_QOS_send: No corresponding Radio Bearer, so message is dropped, rab_id=%u \n", gc->rab_id); - return; - } - } - -#ifdef NAS_DEBUG_SEND - printk("nasmt_COMMON_QOS_send #1 :"); - printk("lcr %u, rab_id %u, rab_id %u\n", cx->lcr, (gc->rb)->rab_id, gc->rab_id); - nasmt_TOOL_print_classifier(gc); -#endif - - pdcph.data_size = skb->len; - pdcph.rb_id = ((gc->rb)->rab_id+(32*cx->lcr))-NAS_SIG_NUM_SRB; - pdcph.inst = 0; - -#ifdef PDCP_USE_NETLINK - bytes_wrote = nasmt_netlink_send((unsigned char *)&pdcph,NAS_PDCPH_SIZE, NASNL_DEST_PDCP); - //printk("nasmt_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", bytes_wrote,skb->len); -#else - //bytes_wrote = rtf_put(gpriv->sap[(gc->rb)->sapi], &pdcph, NAS_PDCPH_SIZE); - bytes_wrote = rtf_put(NAS2PDCP_FIFO, &pdcph, NAS_PDCPH_SIZE); - //printk("nasmt_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP fifo\n", bytes_wrote,skb->len); -#endif //PDCP_USE_NETLINK - - if (bytes_wrote != NAS_PDCPH_SIZE) { - printk("nasmt_COMMON_QOS_send: problem while writing PDCP's header\n"); - printk("rb_id %d, SAP index %d, Wrote %d to fifo %d, Header Size %d \n", pdcph.rb_id , (gc->rb)->sapi, bytes_wrote, NAS2PDCP_FIFO, NAS_PDCPH_SIZE); - gpriv->stats.tx_dropped ++; - return; - } - -#ifdef PDCP_USE_NETLINK - bytes_wrote += nasmt_netlink_send((unsigned char *)skb->data,skb->len, NASNL_DEST_PDCP); -#else - //bytes_wrote += rtf_put(gpriv->sap[(gc->rb)->sapi], skb->data, skb->len); - bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len); -#endif //PDCP_USE_NETLINK - - if (bytes_wrote != skb->len + NAS_PDCPH_SIZE) { - printk("nasmt_COMMON_QOS_send: problem while writing PDCP's data\n"); // congestion - printk("rb_id %d, SAP index %d, Wrote %d to fifo %d, Header Size %d \n", pdcph.rb_id , (gc->rb)->sapi, bytes_wrote, NAS2PDCP_FIFO, NAS_PDCPH_SIZE); - gpriv->stats.tx_dropped ++; - return; - } - -#ifdef NAS_DEBUG_SEND - printk("nasmt_COMMON_QOS_send - %d bytes wrote to rb_id %d, sap %d \n", bytes_wrote, pdcph.rb_id,NAS2PDCP_FIFO); -#endif - gpriv->stats.tx_bytes += skb->len; - gpriv->stats.tx_packets ++; -#ifdef NAS_DEBUG_SEND - printk("nasmt_COMMON_QOS_send - end \n"); -#endif -} - -#ifndef PDCP_USE_NETLINK -//--------------------------------------------------------------------------- -void nasmt_COMMON_QOS_receive(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - uint8_t sapi; - //struct pdcp_data_ind pdcph; - struct pdcp_data_ind_header_t pdcph; - int bytes_read = 0; - - // Start debug information -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_QOS_receive - begin \n"); -#endif - - if (!cx) { - printk("nasmt_COMMON_QOS_receive - input parameter cx is NULL \n"); - return; - } - - // End debug information - - // LG force the use of only 1 rt fifo - sapi = NAS_DRB_OUTPUT_SAPI; - - bytes_read = rtf_get(gpriv->sap[sapi], &pdcph, NAS_PDCPH_SIZE); - - while (bytes_read>0) { - if (bytes_read != NAS_PDCPH_SIZE) { - printk("nasmt_COMMON_QOS_receive: problem while reading PDCP header\n"); - return; - } - - //void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); - // data_buffer is NULL because FIFO should be read directly in the skbuff (LITE has an intermediary buffer) - nasmt_COMMON_receive(NAS_PDCPH_SIZE, pdcph.data_size, NULL, pdcph->rb_id, gpriv->sap[sapi]); - // check if another frame is in the FIFO, otherwise return - bytes_read = rtf_get(gpriv->sap[sapi], &pdcph, NAS_PDCPH_SIZE); - } - -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_QOS_receive - end \n"); -#endif -} - -#else -//--------------------------------------------------------------------------- -void nasmt_COMMON_QOS_receive(struct nlmsghdr *nlh) -{ - //--------------------------------------------------------------------------- - - struct pdcp_data_ind_header_t *pdcph; - - // Start debug information -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_QOS_receive - begin \n"); -#endif - - if (!nlh) { - printk("nasmt_COMMON_QOS_receive - input parameter nlh is NULL \n"); - return; - } - - // End debug information - pdcph = (struct pdcp_data_ind_header_t *)NLMSG_DATA(nlh); - -#ifdef NAS_DEBUG_RECEIVE - printk("nasmt_COMMON_QOS_receive - receive from PDCP, size %d, rab %d\\n", pdcph->data_size, pdcph->rb_id); -#endif //NAS_DEBUG_RECEIVE - - //void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); - nasmt_COMMON_receive(NAS_PDCPH_SIZE + pdcph->data_size, pdcph->data_size, (unsigned char *)NLMSG_DATA(nlh) + NAS_PDCPH_SIZE, pdcph->rb_id, 0); - -} -#endif //PDCP_USE_NETLINK - - -//--------------------------------------------------------------------------- -struct cx_entity *nasmt_COMMON_search_cx(nasLocalConnectionRef_t lcr) -{ - //--------------------------------------------------------------------------- -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_search_cx - lcr %d\n",lcr); -#endif - - if (lcr<NAS_CX_MAX) - return gpriv->cx+lcr; - else - return NULL; -} - -//--------------------------------------------------------------------------- -// Search a Radio Bearer -struct rb_entity *nasmt_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_search_rb - rab_id %d\n", rab_id); -#endif - - if (!cx) { - printk("nasmt_COMMON_search_rb - input parameter cx is NULL \n"); - return NULL; - } - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { - if (rb->rab_id==rab_id) - return rb; - } - - return NULL; -} - -//--------------------------------------------------------------------------- -struct rb_entity *nasmt_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasQoSTrafficClass_t qos) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_add_rb - begin for rab_id %d , qos %d\n", rab_id, qos ); -#endif - - if (cx==NULL) { - printk("nasmt_COMMON_add_rb - input parameter cx is NULL \n"); - return NULL; - } - - rb=nasmt_COMMON_search_rb(cx, rab_id); - - if (rb==NULL) { - rb=(struct rb_entity *)kmalloc(sizeof(struct rb_entity), GFP_KERNEL); - - if (rb!=NULL) { - rb->retry=0; - rb->countimer=NAS_TIMER_IDLE; - rb->rab_id=rab_id; - // rb->rab_id=rab_id+(32*cx->lcr); -#ifdef NAS_DEBUG_DC - printk("nasmt_COMMON_add_rb: rb rab_id=%u, rab_id=%u, mt_id=%u\n",rb->rab_id,rab_id, cx->lcr); -#endif - rb->qos=qos; - rb->sapi=NAS_DRB_INPUT_SAPI; - // LG force the use of only one rt-fifo rb->sapi=NAS_BA_INPUT_SAPI; - rb->state=NAS_IDLE; - rb->next=cx->rb; - cx->rb=rb; - ++cx->num_rb; - } else - printk("nasmt_COMMON_add_rb: no memory\n"); - } - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_add_rb - end \n" ); -#endif - return rb; -} - -//--------------------------------------------------------------------------- -// free the memory that has previously been allocated to rb and remove from linked list -void nasmt_COMMON_del_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasIPdscp_t dscp) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb, *curr_rb, *prev_rb; - struct classifier_entity *p; - uint16_t classref=0; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_del_rb - begin\n"); -#endif - - if (cx==NULL) { - printk("nasmt_COMMON_del_rb - input parameter cx is NULL \n"); - return; - } - - // End debug information - - // Clear the associated classifier - for (p=cx->sclassifier[dscp]; p!=NULL; p=p->next) { - if (p->classref>=classref) { - classref=p->classref; -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_del_rb: classifier found for dscp %u \n", dscp); -#endif - } - } - - nasmt_CLASS_del_sclassifier(cx, dscp, classref); - - // Now, delete the RB - curr_rb = NULL; - prev_rb = NULL; - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { - if (rb->rab_id == rab_id) { - curr_rb = rb; - - if (prev_rb!=NULL) { - prev_rb->next = rb->next; - } else { - cx->rb=rb->next; - } - - break; - } else { - prev_rb = rb; - } - } - - if (curr_rb!= NULL) { - printk("nasmt_COMMON_del_rb: del rab_id %u\n", rb->rab_id); - kfree(rb); - (cx->num_rb)--; - } else { - printk("\n\n--nasmt_COMMON_del_rb: ERROR, invalid rab_id %u\n", rb->rab_id); - } - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_del_rb - end\n"); -#endif -} - -//--------------------------------------------------------------------------- -void nasmt_COMMON_flush_rb(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - struct classifier_entity *gc; - uint8_t dscp; - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_flush_rb - begin\n"); -#endif - - if (cx==NULL) { - printk("nasmt_COMMON_flush_rb - input parameter cx is NULL \n"); - return; - } - - // End debug information - for (rb=cx->rb; rb!=NULL; rb=cx->rb) { - printk("nasmt_COMMON_flush_rb: del rab_id %u\n", rb->rab_id); - cx->rb=rb->next; - kfree(rb); - } - - cx->num_rb=0; - cx->rb=NULL; - - for(dscp=0; dscp<NAS_DSCP_MAX; ++dscp) { - for (gc=cx->sclassifier[dscp]; gc!=NULL; gc=gc->next) - gc->rb=NULL; - } - -#ifdef NAS_DEBUG_CLASS - printk("nasmt_COMMON_flush_rb - end\n"); -#endif -} diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_constant.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_constant.h deleted file mode 100644 index bdba11ff79bc77d4ca5d97f527ecae698205a537..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_constant.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_constant.h -* \brief Defines all constants for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASMTD_CST -#define _NASMTD_CST - -//Debug flags -#define NAS_DEBUG_DC -//#define NAS_DEBUG_DC_DETAIL // detail of DC-SAP operation -#define NAS_DEBUG_SEND -#define NAS_DEBUG_SEND_DETAIL // detail of packet transmission -//#define NAS_DEBUG_RECEIVE -#define NAS_DEBUG_RECEIVE_BASIC -#define NAS_DEBUG_CLASS -//#define NAS_DEBUG_GC -//#define NAS_DEBUG_DC_MEASURE -//#define NAS_DEBUG_TIMER -#define NAS_DEBUG_DEVICE -//#define NAS_DEBUG_INTERRUPT -//#define NAS_DEBUG_TOOL -#define NETLINK_DEBUG -//#define NAS_DEBUG_RRCNL // RRC netlink socket - -// Other flags -#define DEMO_3GSM -#define ENABLE_SLEEP_MODE - -// Parameters for the default RAB started after attachment (needs DEMO_3GSM defined) -#define NASMT_DEFAULTRAB_CLASSREF 1 //MW-01/01/07- -#define NASMT_DEFAULTRAB_DSCP 0 //MW-01/01/07- -#define NASMT_DEFAULTRAB_IPVERSION NAS_VERSION_DEFAULT //MW-01/01/07- - -#define NAS_DEFAULT_IPv6_PREFIX_LENGTH 128 // used to compare destination address - - -// General Constants -#define NAS_MTU 1500 -#define NAS_TX_QUEUE_LEN 100 -#define NAS_ADDR_LEN 8 -#define NAS_INET6_ADDRSTRLEN 46 -#define NAS_INET_ADDRSTRLEN 16 - -#define NAS_RESET_RX_FLAGS 0 - -#define NAS_CX_MAX 1 -//#define NAS_CX_MULTICAST_ALLNODE 2 -#define NASMT_MBMS_SVCES_MAX 4 // Identical to RRC constant - -#define NAS_RETRY_LIMIT_DEFAULT 5 - -#define NAS_MESSAGE_MAXLEN 1600 - -// UMTS -#define NAS_SIG_SRB3 3 -#define NAS_SIG_SRB4 3 // not used yet -//LTE -#define NAS_SIG_NUM_SRB 3 // number of srbs in LTE to send Rb_Id to PDCP - -//peer-to-peer messages between NAS entities -#define NAS_CMD_OPEN_RB 1 -#define NAS_CMD_ENTER_SLEEP 2 -#define NAS_CMD_LEAVE_SLEEP 3 - -//#define NAS_IID1_CONTROL 0x0 -//#define NAS_IID2_CONTROL __constant_htonl(0xffffffff) - -//#define NAS_STATE_IDLE 0 -//#define NAS_STATE_CONNECTED 1 -//#define NAS_STATE_ESTABLISHMENT_REQUEST 2 -//#define NAS_STATE_ESTABLISHMENT_FAILURE 3 -//#define NAS_STATE_RELEASE_FAILURE 4 -#define NAS_CX_RELEASE_UNDEF_CAUSE 1 - -// MT+RG NAS States -#define NAS_IDLE 0x01 -// Connection -#define NAS_CX_FACH 0x06 -#define NAS_CX_DCH 0x0A -#define NAS_CX_RECEIVED 0x10 -#define NAS_CX_CONNECTING 0x04 -#define NAS_CX_RELEASING 0x08 -#define NAS_CX_CONNECTING_FAILURE 0x14 -#define NAS_CX_RELEASING_FAILURE 0x18 -// Radio Bearers -#define NAS_RB_ESTABLISHING 0x24 -#define NAS_RB_RELEASING 0x28 -#define NAS_RB_DCH 0x2A - - -#define NAS_TIMER_ESTABLISHMENT_DEFAULT 12 -#define NAS_TIMER_RELEASE_DEFAULT 2 -#define NAS_TIMER_IDLE UINT_MAX -#define NAS_TIMER_TICK HZ - -#define NAS_PDCPH_SIZE sizeof(struct pdcp_data_req_header_t) -#define NAS_IPV4_SIZE 20 -#define NAS_IPV6_SIZE 40 - -#define NAS_DIRECTION_SEND 0 -#define NAS_DIRECTION_RECEIVE 1 - -// function number -#define NAS_FCT_DEL_SEND 1 -#define NAS_FCT_QOS_SEND 2 -#define NAS_FCT_DC_SEND 3 -#define NAS_FCT_CTL_SEND 4 - -// type of IOCTL command -#define NASMT_IOCTL_RAL 0x89F0 - -// Error cause -#define NAS_ERROR_ALREADYEXIST 1 -#define NAS_ERROR_NOMEMORY 3 -#define NAS_ERROR_NOTMT 9 -#define NAS_ERROR_NOTRG 10 -#define NAS_ERROR_NOTIDLE 11 -#define NAS_ERROR_NOTCONNECTED 12 -#define NAS_ERROR_NORB 14 -#define NAS_ERROR_NOTCORRECTVALUE 32 -#define NAS_ERROR_NOTCORRECTLCR 33 -#define NAS_ERROR_NOTCORRECTDIR 34 -#define NAS_ERROR_NOTCORRECTDSCP 35 -#define NAS_ERROR_NOTCORRECTVERSION 36 -#define NAS_ERROR_NOTCORRECTRABI 37 - - -/**********************************************************/ -/* Constants related with IP protocols */ -/**********************************************************/ -// Destination address types -#define NAS_IPV6_ADDR_UNICAST 1 -#define NAS_IPV6_ADDR_MC_SIGNALLING 2 -#define NAS_IPV6_ADDR_MC_MBMS 3 -#define NAS_IPV6_ADDR_UNKNOWN 4 - -#define NAS_IPV4_ADDR_UNICAST 5 -#define NAS_IPV4_ADDR_MC_SIGNALLING 6 -#define NAS_IPV4_ADDR_BROADCAST 7 -#define NAS_IPV4_ADDR_UNKNOWN 8 - - -//#define NAS_PORT_CONTROL __constant_htons(0xc45) -//#define NAS_PORT_AUTHENTICATION __constant_htons(1811) - -//#define NAS_TRAFFICCLASS_MASK __constant_htonl(0x0fc00000) //Yan -#define NAS_TRAFFICCLASS_MASK __constant_htonl(0x0ff00000) - -// Network control codepoint 111000 + IP version 6 -#define NAS_FLOWINFO_NCONTROL __constant_htonl(0x6e000000) -// network control codepoint 111000 -#define NAS_DSCP_NCONTROL 56 //0x38 -// default codepoint 1000000 -#define NAS_DSCP_DEFAULT 64 -#define NAS_DSCP_MAX 65 - -#define NAS_PROTOCOL_DEFAULT 0 -#define NAS_PROTOCOL_TCP IPPROTO_TCP -#define NAS_PROTOCOL_UDP IPPROTO_UDP -#define NAS_PROTOCOL_ICMP4 IPPROTO_ICMP -#define NAS_PROTOCOL_ICMP6 IPPROTO_ICMPV6 - -#define NAS_PORT_DEFAULT __constant_htons(65535) -#define NAS_PORT_HTTP __constant_htons(80) - -#define NAS_VERSION_DEFAULT 0 -#define NAS_VERSION_4 4 -#define NAS_VERSION_6 6 //?MW - -/**********************************************************/ -/* Constants related with Netlink sockets */ -/**********************************************************/ -#define OAI_IP_DRIVER_NETLINK_ID 31 -#define NL_DEST_PID 1 - -// defined in rrc_nas_sap.h -//#define NAS_RRCNL_ID 30 -//#define NL_DEST_RRC_PID 2 - -#define NASNL_DEST_PDCP 0 -#define NASNL_DEST_RRC 1 - -#endif - - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c deleted file mode 100644 index efc8562bf9fa5f6e7ec5dc8adb733d382ac7fd7f..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_device.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_device.c -* \brief Networking Device Driver for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef PDCP_USE_NETLINK -#ifdef RTAI -#include "rtai_posix.h" -#define RTAI_IRQ 30 //try to get this irq with RTAI -#endif // RTAI -#endif // PDCP_USE_NETLINK -//:::::::::::::::::::::::::::::::::::::::;; -#include "nasmt_variables.h" -#include "nasmt_proto.h" -//:::::::::::::::::::::::::::::::::::::::;; -//#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/version.h> -#include <linux/init.h> -#include <linux/spinlock.h> -#include <linux/moduleparam.h> - -#ifdef NAS_DRIVER_TYPE_ETHERNET -#include <linux/if_ether.h> -#endif - -#include <asm/io.h> -#include <asm/bitops.h> -#include <asm/uaccess.h> -#include <asm/segment.h> -#include <asm/page.h> -#include <asm/delay.h> -#include <asm/unistd.h> -#include <linux/netdevice.h> -#ifdef NAS_DRIVER_TYPE_ETHERNET -#include <linux/etherdevice.h> -#endif -//:::::::::::::::::::::::::::::::::::::::;; -struct net_device *gdev; -struct nas_priv *gpriv; -//int bytes_wrote; -//int bytes_read; -uint8_t NAS_NULL_IMEI[14]= {0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x00}; -uint8_t NAS_RG_IMEI[14]= {0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x01}; - -// TEMP -//uint8_t nas_IMEI[14]; -static unsigned char nas_IMEI[14]; -static int m_arg=0; - - -#ifdef PDCP_USE_NETLINK -extern void nasmt_netlink_release(void); -extern int nasmt_netlink_init(void); -#endif -extern void nasmt_ASCTL_timer(unsigned long data); - - -#ifndef PDCP_USE_NETLINK -//--------------------------------------------------------------------------- -//void nasmt_interrupt(void){ -void *nasmt_interrupt(void) -{ - //--------------------------------------------------------------------------- - uint8_t cxi; - char *buffer = NULL; -#ifdef NAS_DEBUG_INTERRUPT - printk("nasmt_interrupt - begin\n"); -#endif - //spin_lock(&gpriv->lock); - cxi=0; - nasmt_COMMON_QOS_receive(gpriv->cx+cxi); - nasmt_ASCTL_GC_receive(buffer); - nasmt_ASCTL_DC_receive(gpriv->cx+cxi, buffer); - //spin_unlock(&gpriv->lock); -#ifdef NAS_DEBUG_INTERRUPT - printk("nasmt_interrupt: end\n"); -#endif -} -#endif //NETLINK - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is activated by ifconfig -int nasmt_open(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - printk("nasmt_open: begin\n"); - - gpriv=netdev_priv(dev); - - // Address has already been set at init -#ifndef PDCP_USE_NETLINK - - if (gpriv->irq==-EBUSY) { - printk("nasmt_open: irq failure\n"); - return -EBUSY; - } - -#endif //NETLINK - - // next lines prevent compilation of the driver with kernel version under 2.6.29 - // ATTENTION !!!!!! NASMT is not usable with these versions - - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - // - init_timer(&gpriv->timer); - (gpriv->timer).expires=jiffies+NAS_TIMER_TICK; - (gpriv->timer).data=0L; - (gpriv->timer).function=nasmt_ASCTL_timer; - // ??LITE comments: add_timer(&gpriv->timer); - add_timer(&gpriv->timer); - // - printk("nasmt_open: name = %s, end\n", dev->name); - return 0; -} - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is desactivated by ifconfig -int nasmt_stop(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - struct nas_priv *priv = netdev_priv(dev); - printk("nasmt_stop: begin\n"); - del_timer(&priv->timer); - netif_stop_queue(dev); - - printk("nasmt_stop: name = %s, end\n", dev->name); - return 0; -} - -//--------------------------------------------------------------------------- -void nasmt_teardown(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - int cxi; -#ifndef PDCP_USE_NETLINK - struct nas_priv *priv = netdev_priv(dev); -#endif //PDCP_USE_NETLINK - - printk("nasmt_teardown: begin\n"); - // priv=(struct nas_priv *)(gdev.priv); - - if (dev) { -#ifndef PDCP_USE_NETLINK - - if (priv->irq!=-EBUSY) { - *pt_nas_ue_irq=-1; - rt_free_srq(priv->irq); - } - -#endif //PDCP_USE_NETLINK - -#ifdef PDCP_USE_NETLINK - nasmt_netlink_release(); -#endif //PDCP_USE_NETLINK - // for (sapi=0; sapi<NAS_SAPI_MAX; ++sapi) - // close(priv->sap[sapi]); - nasmt_CLASS_flush_rclassifier(); - cxi=0; - nasmt_COMMON_flush_rb(gpriv->cx+cxi); - nasmt_CLASS_flush_sclassifier(gpriv->cx+cxi); - // for (sapi=0; sapi<NAS_SAPI_CX_MAX; ++sapi) - // close(priv->cx[cxi].sap[sapi]); - } // check dev - else { - printk("nasmt_teardown: Device is null\n"); - } - - printk("nasmt_teardown: end\n"); -} - -//--------------------------------------------------------------------------- -int nasmt_set_config(struct net_device *dev, struct ifmap *map) -{ - //--------------------------------------------------------------------------- - printk("nasmt_set_config: begin\n"); - - if (dev->flags & IFF_UP) - return -EBUSY; - - if (map->base_addr != dev->base_addr) { - printk(KERN_WARNING "nasmt_set_config: Can't change I/O address\n"); - return -EOPNOTSUPP; - } - - if (map->irq != dev->irq) - dev->irq = map->irq; - - printk("nasmt_set_config: end\n"); - return 0; -} - -//--------------------------------------------------------------------------- -// -int nasmt_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_DEVICE - printk("nasmt_hard_start_xmit: begin\n"); -#endif - - if ((!skb)||(!dev)) { - printk("nasmt_hard_start_xmit - input parameter skb or dev is NULL \n"); - return -1; - } - - // End debug information - netif_stop_queue(dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasmt_hard_start_xmit: step 1\n"); -#endif - nasmt_CLASS_send(skb); -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasmt_hard_start_xmit: step 2\n"); -#endif - dev_kfree_skb(skb); -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasmt_hard_start_xmit: step 3\n"); -#endif - netif_wake_queue(dev); -#ifdef NAS_DEBUG_DEVICE - printk("nasmt_hard_start_xmit: end\n"); -#endif - return 0; -} - -//--------------------------------------------------------------------------- -struct net_device_stats *nasmt_get_stats(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - // return &((struct nas_priv *)dev->priv)->stats; - struct nas_priv *npriv = netdev_priv(dev); - return &npriv->stats; -} - -//--------------------------------------------------------------------------- -// New function from LITE DRIVER -int nasmt_set_mac_address(struct net_device *dev, void *mac) -{ - //--------------------------------------------------------------------------- - struct sockaddr *addr = mac; - printk("nasmt_set_mac_address: begin\n"); - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - return 0; -} - - -//--------------------------------------------------------------------------- -int nasmt_change_mtu(struct net_device *dev, int mtu) -{ - //--------------------------------------------------------------------------- - printk("nasmt_change_mtu: begin\n"); - - if ((mtu<50) || (mtu>1500)) - // if ((mtu<1280) || (mtu>1500)) - return -EINVAL; - - dev->mtu = mtu; - return 0; -} - -//--------------------------------------------------------------------------- -int nasmt_change_rx_flags(struct net_device *dev, int flags) -{ - //--------------------------------------------------------------------------- - //struct nas_priv *priv = netdev_priv(dev); - printk("nasmt_change_rx_flags %08X\n", flags); - gpriv->rx_flags ^= flags; - return 0; -} - -//--------------------------------------------------------------------------- -void nasmt_tx_timeout(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - /* Transmitter timeout, serious problems. */ - printk("nasmt_tx_timeout: begin\n"); - //((struct nas_priv *)(dev->priv))->stats.tx_errors++; - (gpriv->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif - netif_wake_queue(dev); - printk("nasmt_tx_timeout: transmit timed out %s\n",dev->name); -} - -//--------------------------------------------------------------------------- -// Define pointers for the module -static const struct net_device_ops nasmt_netdev_ops = { - // ?? nasmt_interrupt - // - .ndo_open = nasmt_open, - .ndo_stop = nasmt_stop, - .ndo_start_xmit = nasmt_hard_start_xmit, - .ndo_validate_addr = NULL, - .ndo_get_stats = nasmt_get_stats, - //#ifdef KERNEL_VERSION_GREATER_THAN_32 - // .ndo_set_multicast_list = NULL, - .ndo_set_mac_address = nasmt_set_mac_address, - .ndo_set_config = nasmt_set_config, - .ndo_do_ioctl = nasmt_CTL_ioctl, - .ndo_change_mtu = nasmt_change_mtu, - .ndo_tx_timeout = nasmt_tx_timeout, - .ndo_change_rx_flags = nasmt_change_rx_flags, - //#endif -}; -//--------------------------------------------------------------------------- - -//--------------------------------------------------------------------------- -// Initialisation of the network device -void nasmt_init(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - uint8_t cxi, dscpi; - - printk("nasmt_init: begin\n"); - - if (dev) { - gpriv=netdev_priv(dev); - memset(gpriv, 0, sizeof(struct nas_priv)); - // Initialize function pointers - dev->netdev_ops = &nasmt_netdev_ops; - -#ifndef NAS_DRIVER_TYPE_ETHERNET - // Update driver properties - dev->type = ARPHRD_EURUMTS; - dev->features = NETIF_F_NO_CSUM; - dev->hard_header_len = 0; - dev->addr_len = NAS_ADDR_LEN; - dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP; - dev->tx_queue_len = NAS_TX_QUEUE_LEN; - dev->mtu = NAS_MTU; -#endif - // Can be one of the following enum defined in include/linux/netdevice.h: - // enum netdev_state_t { - // __LINK_STATE_START, - // __LINK_STATE_PRESENT, - // __LINK_STATE_NOCARRIER, - // __LINK_STATE_LINKWATCH_PENDING, - // __LINK_STATE_DORMANT, - // }; - set_bit(__LINK_STATE_PRESENT, &dev->state); - -#ifdef NAS_DRIVER_TYPE_ETHERNET - // overwrite values written above ( header_ops,type,hard_header_len,mtu,addr_len,tx_queue_len,flags,broadcast) - printk("\nnasmt_init: WARNING Driver type ETHERNET\n"); - ether_setup(dev); -#endif - - // - // Initialize private structure - gpriv->rx_flags = NAS_RESET_RX_FLAGS; - - gpriv->sap[NAS_GC_SAPI] = RRC_DEVICE_GC; - gpriv->sap[NAS_NT_SAPI] = RRC_DEVICE_NT; - gpriv->cx[0].sap[NAS_DC_INPUT_SAPI] = RRC_DEVICE_DC_INPUT0; - gpriv->cx[0].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT0; - - //gpriv->sap[NAS_CO_INPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_INPUT; - //gpriv->sap[NAS_CO_OUTPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_OUTPUT; - gpriv->sap[NAS_DRB_INPUT_SAPI] = PDCP2PDCP_USE_RT_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; - gpriv->sap[NAS_DRB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; - - gpriv->retry_limit = NAS_RETRY_LIMIT_DEFAULT; - gpriv->timer_establishment = NAS_TIMER_ESTABLISHMENT_DEFAULT; - gpriv->timer_release = NAS_TIMER_RELEASE_DEFAULT; - - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) - gpriv->rclassifier[dscpi] = NULL; - - gpriv->nrclassifier = 0; - // - cxi=0; -#ifdef NAS_DEBUG_DEVICE - printk("nasmt_init: init classifiers, state and timer for MT %u\n", cxi); -#endif - gpriv->cx[cxi].state = NAS_IDLE; - gpriv->cx[cxi].countimer = NAS_TIMER_IDLE; - gpriv->cx[cxi].retry = 0; - gpriv->cx[cxi].lcr = cxi; - gpriv->cx[cxi].rb = NULL; - gpriv->cx[cxi].num_rb = 0; - - // initialisation of the classifiers - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) { - gpriv->cx[cxi].sclassifier[dscpi]=NULL; - } - - gpriv->cx[cxi].nsclassifier=0; - // initialisation of the IP address - nasmt_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)gpriv->cx[cxi].iid6); - gpriv->cx[cxi].iid4=0; - // - spin_lock_init(&gpriv->lock); - printk("nasmt_init: init IMEI to IID\n"); - -#ifdef NAS_DRIVER_TYPE_ETHERNET - nasmt_TOOL_eth_imei2iid(nas_IMEI, dev->dev_addr ,(uint8_t *)gpriv->cx[0].iid6, dev->addr_len); -#else - nasmt_TOOL_imei2iid(nas_IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address) - nasmt_TOOL_imei2iid(nas_IMEI, (uint8_t *)gpriv->cx[0].iid6); -#endif - - nasmt_ASCTL_init(); - } else { - printk("\n\nnasmt_init: ERROR, Device is NULL!!\n"); - } - - printk("nasmt_init: end\n"); - return; -} - -//--------------------------------------------------------------------------- -int init_module (void) -{ - //--------------------------------------------------------------------------- - int err; - int inst = 0; - int index; - struct nas_priv *priv; - char devicename[100]; - - printk("\n\n\ninit_module: begin \n"); - - // check IMEI parameter - printk("number of IMEI parameters %d, IMEI ", m_arg); - - for (index = 0; index < m_arg; index++) { - printk("%02X ", nas_IMEI[index]); - } - - printk("\n"); - - -#ifndef PDCP_USE_NETLINK - - // Initialize parameters shared with RRC (done first to avoid going further) - if (pt_nas_ue_irq==NULL) { - printk("init_module: shared irq parameter not initialised\n"); - err = -EBUSY; - printk("init_module: returning %d \n\n", err); - return err; - } - - printk("init_module: pt_nas_ue_irq valid \n"); -#endif - - // Allocate device structure - sprintf(devicename,"oai%d",inst); -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) - gdev = alloc_netdev(sizeof(struct nas_priv), devicename, nasmt_init); -#else - gdev = alloc_netdev(sizeof(struct nas_priv), devicename, NET_NAME_PREDICTABLE, nasmt_init); -#endif - priv = netdev_priv(gdev); - //// -#ifndef PDCP_USE_NETLINK - priv->irq=rt_request_srq(0, nasmt_interrupt, NULL); - - if (priv->irq == -EBUSY || priv->irq == -EINVAL) { - printk("\n init_module: No interrupt resource available\n"); - - if (gdev) { - free_netdev(gdev); - printk("init_module: free_netdev ..\n"); - } - - return -EBUSY; - } else - printk("init_module: Interrupt %d, ret = %d \n", priv->irq , ret); - - if (pt_nas_ue_irq==NULL) { - printk("init_module: shared irq parameter has been reset\n"); - } else { - *pt_nas_ue_irq=priv->irq; - } - -#endif - -#ifdef PDCP_USE_NETLINK - - if ((err=nasmt_netlink_init()) == -1) - printk("init_module: NETLINK failed\n"); - - printk("init_module: NETLINK INIT successful\n"); -#endif //NETLINK - // - err= register_netdev(gdev); - - if (err) { - printk("init_module: error %i registering device %s\n", err, gdev->name); - } else { - printk("init_module: registering device %s, ifindex = %d\n\n",gdev->name, gdev->ifindex); - } - - return err; -} - -//--------------------------------------------------------------------------- -void cleanup_module(void) -{ - //--------------------------------------------------------------------------- - printk("nasmt_cleanup_module: begin\n"); - unregister_netdev(gdev); - nasmt_teardown(gdev); - free_netdev(gdev); - printk("nasmt_cleanup_module: end\n\n\n\n"); -} - -//--------------------------------------------------------------------------- -// Replaced by init_module and cleanup_module -//module_init (nasmt_init_module); -//module_exit (nasmt_cleanup_module); -//--------------------------------------------------------------------------- - -#define DRV_NAME "oai_nasmt" -#define DRV_VERSION "3.0.1"DRV_NAME -#define DRV_DESCRIPTION "OPENAIR CELLULAR LTE NASMT Device Driver" -#define DRV_COPYRIGHT "-Copyright(c) GNU GPL Eurecom 2013" -#define DRV_AUTHOR "Michelle Wetterwald <michelle.wetterwald@eurecom.fr>"DRV_COPYRIGHT - -module_param_array_named(nas_IMEI,nas_IMEI,byte,&m_arg,0); -//module_param_array(oai_nw_drv_IMEI,byte,&m_arg,0444); -MODULE_PARM_DESC(nas_IMEI,"Terminal IMEI Identifier (14 digits, only first 10 significant if ETH option ON)"); - - -// MODULE_LICENSE("GPL"); -// MODULE_DESCRIPTION("LTE Driver for Mobile Terminal, playing as Non Access Stratum"); -// MODULE_AUTHOR("Michelle Wetterwald <michelle.wetterwald@eurecom.fr>"); - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_iocontrol.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_iocontrol.c deleted file mode 100644 index 296ae788666e83b4ce1b7fbe0bf4e057d2ea5acb..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_iocontrol.c +++ /dev/null @@ -1,764 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_iocontrol.c -* \brief I/O control functions for upper layers of driver for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#include "nasmt_variables.h" -#include "nasmt_iocontrol.h" -#include "nasmt_proto.h" - -//#include <linux/in.h> -#include <asm/uaccess.h> -#include <asm/checksum.h> -#include <asm/uaccess.h> - -extern int nasmt_ASCTL_DC_send_cx_establish_request(struct cx_entity *cx); - -// Statistic -//--------------------------------------------------------------------------- -void nasmt_set_msg_statistic_reply(struct nas_msg_statistic_reply *msgrep) -{ - //--------------------------------------------------------------------------- - msgrep->rx_packets=gpriv->stats.rx_packets; - msgrep->tx_packets=gpriv->stats.tx_packets; - msgrep->rx_bytes=gpriv->stats.rx_bytes; - msgrep->tx_bytes=gpriv->stats.tx_bytes; - msgrep->rx_errors=gpriv->stats.rx_errors; - msgrep->tx_errors=gpriv->stats.tx_errors; - msgrep->rx_dropped=gpriv->stats.rx_dropped; - msgrep->tx_dropped=gpriv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_statistic_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_statistic_reply msgrep; - printk("nasmt_ioCTL_statistic: stat requested\n"); - nasmt_set_msg_statistic_reply(&msgrep); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_statistic: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connections List -//--------------------------------------------------------------------------- -void nasmt_set_msg_cx_list_reply(uint8_t *msgrep) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - nasLocalConnectionRef_t lcr; - struct nas_msg_cx_list_reply *list; - msgrep[0]=NAS_CX_MAX; - list=(struct nas_msg_cx_list_reply *)(msgrep+1); - - for(lcr=0; lcr<NAS_CX_MAX; ++lcr) { - cx=nasmt_COMMON_search_cx(lcr); - list[lcr].lcr=lcr; - list[lcr].state=cx->state; - list[lcr].cellid=cx->cellid; - list[lcr].iid4=cx->iid4; - list[lcr].iid6[0]=cx->iid6[0]; - list[lcr].iid6[1]=cx->iid6[1]; - list[lcr].num_rb=cx->num_rb; - list[lcr].nsclassifier=cx->nsclassifier; - printk("nasmt_set_msg_cx_list_reply: nsc=%u\n",cx->nsclassifier); - } -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_cx_list_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1]; - printk("nasmt_ioCTL_cx_list: connection list requested\n"); - nasmt_set_msg_cx_list_reply(msgrep); - - if (copy_to_user(gifr->msg, msgrep, NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1)) { - printk("nasmt_ioCTL_cx_list: copy_to_user failure\n"); - return -EFAULT; - } - - printk("nasmt_ioCTL_cx_list: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connection Establishment -//--------------------------------------------------------------------------- -void nasmt_set_msg_cx_establishment_reply(struct nas_msg_cx_establishment_reply *msgrep, struct nas_msg_cx_establishment_request *msgreq) -{ - //--------------------------------------------------------------------------- -#ifdef NODE_RG - msgrep->status=-NAS_ERROR_NOTMT; -#else - struct cx_entity *cx; - cx=nasmt_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) { - if (cx->state == NAS_CX_RELEASING) { - msgrep->status=nasmt_ASCTL_leave_sleep_mode(cx); - } else { - cx->cellid=msgreq->cellid; - msgrep->status=nasmt_ASCTL_DC_send_cx_establish_request(cx); - } - } else - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - -#endif -} -//--------------------------------------------------------------------------- -int nasmt_ioCTL_cx_establishment_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_cx_establishment_request msgreq; - struct nas_msg_cx_establishment_reply msgrep; - printk("nasmt_ioCTL_cx_establishment: connection establishment requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_cx_establishment: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_cx_establishment_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_cx_establishment: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connection Release -//--------------------------------------------------------------------------- -void nasmt_set_msg_cx_release_reply(struct nas_msg_cx_release_reply *msgrep, struct nas_msg_cx_release_request *msgreq) -{ - //--------------------------------------------------------------------------- -#ifdef NODE_RG - msgrep->status=-NAS_ERROR_NOTMT; -#else - struct cx_entity *cx; - cx=nasmt_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) { -#ifdef ENABLE_SLEEP_MODE - msgrep->status=nasmt_ASCTL_enter_sleep_mode(cx); -#endif -#ifndef ENABLE_SLEEP_MODE - msgrep->status=nasmt_ASCTL_DC_send_cx_release_request(cx); -#endif - } else - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - -#endif -} - -//--------------------------------------------------------------------------- -// Request the release of a connection -int nasmt_ioCTL_cx_release_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_cx_release_request msgreq; - struct nas_msg_cx_release_reply msgrep; - - printk("nasmt_ioCTL_cx_release: connection release requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_cx_release: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_cx_release_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_cx_release: copy_to_user failure\n"); - return -EFAULT; - } - - printk("nasmt_ioCTL_cx_release: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer List -//--------------------------------------------------------------------------- -void nasmt_set_msg_rb_list_reply(uint8_t *msgrep, struct nas_msg_rb_list_request *msgreq) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - cx=nasmt_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) { - uint8_t rbi; - struct rb_entity *rb; - struct nas_msg_rb_list_reply *list; - - if (cx->num_rb > NAS_LIST_RB_MAX) - msgrep[0] = NAS_LIST_RB_MAX; - else - msgrep[0] = cx->num_rb; - - list=(struct nas_msg_rb_list_reply *)(msgrep+1); - - for (rb=cx->rb, rbi=0; (rb!=NULL)&&(rbi<msgrep[0]); rb=rb->next, ++rbi) { - list[rbi].state=rb->state; - list[rbi].rab_id=rb->rab_id; - list[rbi].sapi=rb->sapi; - list[rbi].qos=rb->qos; - } - } else - msgrep[0]=0; -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_rb_list_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1]; - struct nas_msg_rb_list_request msgreq; - printk("nasmt_ioCTL_rb_list: Radio Bearer list requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_rb_list: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_rb_list_reply(msgrep, &msgreq); - - if (copy_to_user(gifr->msg, msgrep, NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1)) { - printk("nasmt_ioCTL_rb_list: copy_to_user failure\n"); - return -EFAULT; - } - - printk("nasmt_ioCTL_rb_list: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer Establishment -//--------------------------------------------------------------------------- -void nasmt_set_msg_rb_establishment_reply(struct nas_msg_rb_establishment_reply *msgrep, struct nas_msg_rb_establishment_request *msgreq) -{ - //--------------------------------------------------------------------------- - msgrep->status=-NAS_ERROR_NOTRG; -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_rb_establishment_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_rb_establishment_request msgreq; - struct nas_msg_rb_establishment_reply msgrep; - printk("nasmt_ioCTL_rb_establishment: Radio bearer establishment requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_rb_establishment: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_rb_establishment_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_rb_establishment: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer Release -//--------------------------------------------------------------------------- -void nasmt_set_msg_rb_release_reply(struct nas_msg_rb_release_reply *msgrep, struct nas_msg_rb_release_request *msgreq) -{ - //--------------------------------------------------------------------------- - msgrep->status=-NAS_ERROR_NOTRG; -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_rb_release_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_rb_release_request msgreq; - struct nas_msg_rb_release_reply msgrep; - printk("nasmt_ioCTL_rb_release: Radio bearer release requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_rb_release: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_rb_release_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_rb_release: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Classifier List -//--------------------------------------------------------------------------- -void nasmt_set_msg_class_list_reply(uint8_t *msgrep, struct nas_msg_class_list_request *msgreq) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - struct classifier_entity *gc; - struct nas_msg_class_list_reply *list; - uint8_t cli; - list=(struct nas_msg_class_list_reply *)(msgrep+1); - - switch(msgreq->dir) { - case NAS_DIRECTION_SEND: - cx=nasmt_COMMON_search_cx(msgreq->lcr); - - if (cx==NULL) { - msgrep[0]=0; - return; - } - - gc=cx->sclassifier[msgreq->dscp]; - break; - - case NAS_DIRECTION_RECEIVE: - cx=NULL; - gc=gpriv->rclassifier[msgreq->dscp]; - break; - - default: - cx=NULL; - msgrep[0]=0; - return; - } - - for (cli=0; (gc!=NULL)&&(cli<NAS_LIST_CLASS_MAX); gc=gc->next, ++cli) { - list[cli].classref=gc->classref; - list[cli].lcr=msgreq->lcr; - list[cli].dir=msgreq->dir; - list[cli].dscp=msgreq->dscp; - list[cli].rab_id=gc->rab_id; - list[cli].version=gc->version; - - switch(gc->version) { - case 4: - list[cli].saddr.ipv4 = gc->saddr.ipv4; - list[cli].daddr.ipv4 = gc->daddr.ipv4; - break; - - case 6: - list[cli].saddr.ipv6 = gc->saddr.ipv6; - list[cli].daddr.ipv6 = gc->daddr.ipv6; - break; - } - - list[cli].protocol=gc->protocol; - list[cli].sport=ntohs(gc->sport); - list[cli].dport=ntohs(gc->dport); - list[cli].splen=gc->splen; - list[cli].dplen=gc->dplen; - list[cli].fct=nasmt_TOOL_invfct(gc); - } - - msgrep[0]=cli; -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_class_list_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1]; - struct nas_msg_class_list_request msgreq; - printk("nasmt_ioCTL_class_list: classifier list requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_class_list: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_class_list_reply(msgrep, &msgreq); - - if (copy_to_user(gifr->msg, msgrep, NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1)) { - printk("nasmt_ioCTL_class_list: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Request the addition of a classifier rule -//--------------------------------------------------------------------------- -void nasmt_set_msg_class_add_reply(struct nas_msg_class_add_reply *msgrep, struct nas_msg_class_add_request *msgreq) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - - if (msgreq->dscp>NAS_DSCP_DEFAULT) { - printk("nasmt_set_msg_class_add_reply: Incoherent parameter value\n"); - msgrep->status=-NAS_ERROR_NOTCORRECTDSCP; - return; - } - - if (msgreq->dir==NAS_DIRECTION_SEND) { - struct cx_entity *cx; - cx=nasmt_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) { - printk("nasmt_set_msg_class_add_reply: DSCP %d, Classref %d\n",msgreq->dscp, msgreq->classref ); - gc=nasmt_CLASS_add_sclassifier(cx, msgreq->dscp, msgreq->classref); - printk("nasmt_set_msg_class_add_reply: %p %p\n" , msgreq, gc); - - if (gc==NULL) { - msgrep->status=-NAS_ERROR_NOMEMORY; - return; - } - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - return; - } - - gc->rab_id=msgreq->rab_id; - gc->rb=nasmt_COMMON_search_rb(cx, gc->rab_id); - } else { - if (msgreq->dir==NAS_DIRECTION_RECEIVE) { - gc=nasmt_CLASS_add_rclassifier(msgreq->dscp, msgreq->classref); - - if (gc==NULL) { - msgrep->status=-NAS_ERROR_NOMEMORY; - return; - } - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTDIR; - return; - } - } - - nasmt_TOOL_fct(gc, msgreq->fct); - gc->version=msgreq->version; - - switch(gc->version) { - case 4: - gc->saddr.ipv4=msgreq->saddr.ipv4; - gc->daddr.ipv4=msgreq->daddr.ipv4; - gc->splen=msgreq->splen; - gc->dplen=msgreq->dplen; - break; - - case 6: - gc->saddr.ipv6=msgreq->saddr.ipv6; - gc->daddr.ipv6=msgreq->daddr.ipv6; - gc->splen=msgreq->splen; - gc->dplen=msgreq->dplen; - break; - - case 0: - gc->saddr.ipv6.s6_addr32[0]=0; - gc->daddr.ipv6.s6_addr32[1]=0; - gc->saddr.ipv6.s6_addr32[2]=0; - gc->daddr.ipv6.s6_addr32[3]=0; - gc->splen=0; - gc->dplen=0; - break; - - default: - msgrep->status=-NAS_ERROR_NOTCORRECTVERSION; - kfree(gc); - return; - } - - gc->protocol=msgreq->protocol; - gc->sport=htons(msgreq->sport); - gc->dport=htons(msgreq->dport); - msgrep->status=0; -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_class_add_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_class_add_request msgreq; - struct nas_msg_class_add_reply msgrep; - printk("nasmt_ioCTL_class_add: Add classifier components requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_class_add: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_class_add_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_class_add: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Request the deletion of a classifier rule -//--------------------------------------------------------------------------- -void nasmt_set_msg_class_del_reply(struct nas_msg_class_del_reply *msgrep, struct nas_msg_class_del_request *msgreq) -{ - //--------------------------------------------------------------------------- - if (msgreq->dscp>NAS_DSCP_DEFAULT) { - printk("nasmt_set_msg_class_del_reply: Incoherent parameter value\n"); - msgrep->status=-NAS_ERROR_NOTCORRECTDSCP; - return; - } - - if (msgreq->dir==NAS_DIRECTION_SEND) { - struct cx_entity *cx; - cx=nasmt_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) - nasmt_CLASS_del_sclassifier(cx, msgreq->dscp, msgreq->classref); - else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - return; - } - } else { - if (msgreq->dir==NAS_DIRECTION_RECEIVE) - nasmt_CLASS_del_rclassifier(msgreq->dscp, msgreq->classref); - else { - msgrep->status=-NAS_ERROR_NOTCORRECTDIR; - return; - } - } - - msgrep->status=0; -} - -//--------------------------------------------------------------------------- -int nasmt_ioCTL_class_del_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_class_del_request msgreq; - struct nas_msg_class_del_reply msgrep; - printk("nasmt_ioCTL_class_del: Del classifier components requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_class_del: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_class_del_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_class_del: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Measurement -// Messages for Measurement transfer - -//--------------------------------------------------------------------------- -void nasmt_set_msg_measure_reply(struct nas_msg_measure_reply *msgrep, struct nas_msg_measure_request *msgreq) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - int lcr=0; // Temp lcr->mt =0 - int i; - - cx = nasmt_COMMON_search_cx(lcr); - - if (cx!=NULL) { - msgrep->num_cells = cx->num_measures; - - for (i=0; i<cx->num_measures; i++) { - msgrep-> measures[i].cell_id = cx->meas_cell_id[i]; - msgrep-> measures[i].level = cx->meas_level[i]; - msgrep-> measures[i].provider_id = cx->provider_id[i]; - } - - msgrep->signal_lost_flag = 0; - } else { - // msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - // return; - } -} -//--------------------------------------------------------------------------- -int nasmt_ioCTL_measure_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_measure_request msgreq; - struct nas_msg_measure_reply msgrep; - printk("nasmt_ioCTL_measure: Measurement requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasmt_ioCTL_measure: copy_from_user failure\n"); - return -EFAULT; - } - - nasmt_set_msg_measure_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_measure: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// IMEI -// Messages for IMEI transfer -//--------------------------------------------------------------------------- -void nasmt_set_msg_imei_reply(struct nas_msg_l2id_reply *msgrep) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - int lcr=0; // Temp lcr->mt =0 - int i; - - cx=nasmt_COMMON_search_cx(lcr); - - if (cx!=NULL) { - msgrep->l2id[0] = cx->iid6[0]; - msgrep->l2id[1] = cx->iid6[1]; - } else { - // msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - // return; - } -} -//--------------------------------------------------------------------------- -int nasmt_ioCTL_imei_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_l2id_reply msgrep; - printk("nasmt_ioCTL_imei: IMEI requested\n"); - nasmt_set_msg_imei_reply(&msgrep); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasmt_ioCTL_imei: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IOCTL command -//--------------------------------------------------------------------------- -int nasmt_CTL_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - //--------------------------------------------------------------------------- - struct nas_ioctl *gifr; - int r; - printk("nasmt_CTL_ioctl: begin\n"); - - //spin_lock(&gpriv->lock); - switch(cmd) { - case NASMT_IOCTL_RAL: - gifr=(struct nas_ioctl *)ifr; - - switch(gifr->type) { - case NAS_MSG_STATISTIC_REQUEST: - r=nasmt_ioCTL_statistic_request(gifr); - break; - - case NAS_MSG_CX_ESTABLISHMENT_REQUEST: - r=nasmt_ioCTL_cx_establishment_request(gifr); - break; - - case NAS_MSG_CX_RELEASE_REQUEST: - r=nasmt_ioCTL_cx_release_request(gifr); - break; - - case NAS_MSG_CX_LIST_REQUEST: - r=nasmt_ioCTL_cx_list_request(gifr); - break; - - case NAS_MSG_RB_ESTABLISHMENT_REQUEST: - r=nasmt_ioCTL_rb_establishment_request(gifr); - break; - - case NAS_MSG_RB_RELEASE_REQUEST: - r= nasmt_ioCTL_rb_release_request(gifr); - break; - - case NAS_MSG_RB_LIST_REQUEST: - r=nasmt_ioCTL_rb_list_request(gifr); - break; - - case NAS_MSG_CLASS_ADD_REQUEST: - r=nasmt_ioCTL_class_add_request(gifr); - break; - - case NAS_MSG_CLASS_LIST_REQUEST: - r=nasmt_ioCTL_class_list_request(gifr); - break; - - case NAS_MSG_CLASS_DEL_REQUEST: - r=nasmt_ioCTL_class_del_request(gifr); - break; - - case NAS_MSG_MEAS_REQUEST: - r=nasmt_ioCTL_measure_request(gifr); - break; - - case NAS_MSG_IMEI_REQUEST: - r=nasmt_ioCTL_imei_request(gifr); - break; - - default: - printk("nasmt_CTL_ioctl: unkwon request type, type=%x\n", gifr->type); - r=-EFAULT; - } - - break; - - default: - printk("nasmt_CTL_ioctl: Unknown ioctl command, cmd=%x\n", cmd); - r=-EFAULT; - } - - //spin_unlock(&gpriv->lock); - printk("nasmt_CTL_ioctl: end\n"); - return r; -} - -//--------------------------------------------------------------------------- -void nasmt_CTL_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - printk("nasmt_CTL_send - void \n"); -} - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_iocontrol.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_iocontrol.h deleted file mode 100644 index 40118d8368257a4586b7f6b07db91ddaf7ea91ae..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_iocontrol.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_iocontrol.h -* \brief I/O control constnats and structures for upper layers of driver for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef NASMTD_CTL_H -#define NASMTD_CTL_H - -#include <asm/byteorder.h> -#include <asm/types.h> -#include <linux/udp.h> -#include <linux/tcp.h> - -#define NAS_MSG_MAXLEN 1100 - -// type of CTL message -#define NAS_MSG_STATISTIC_REQUEST 1 -#define NAS_MSG_STATISTIC_REPLY 2 -#define NAS_MSG_ECHO_REQUEST 3 -#define NAS_MSG_ECHO_REPLY 4 -#define NAS_MSG_CX_ESTABLISHMENT_REQUEST 5 -#define NAS_MSG_CX_ESTABLISHMENT_REPLY 6 -#define NAS_MSG_CX_RELEASE_REQUEST 7 -#define NAS_MSG_CX_RELEASE_REPLY 8 -#define NAS_MSG_CX_LIST_REQUEST 9 -#define NAS_MSG_CX_LIST_REPLY 10 -#define NAS_MSG_RB_ESTABLISHMENT_REQUEST 11 -#define NAS_MSG_RB_ESTABLISHMENT_REPLY 12 -#define NAS_MSG_RB_RELEASE_REQUEST 13 -#define NAS_MSG_RB_RELEASE_REPLY 14 -#define NAS_MSG_RB_LIST_REQUEST 15 -#define NAS_MSG_RB_LIST_REPLY 16 -#define NAS_MSG_CLASS_ADD_REQUEST 17 -#define NAS_MSG_CLASS_ADD_REPLY 18 -#define NAS_MSG_CLASS_DEL_REQUEST 19 -#define NAS_MSG_CLASS_DEL_REPLY 20 -#define NAS_MSG_CLASS_LIST_REQUEST 21 -#define NAS_MSG_CLASS_LIST_REPLY 22 -#define NAS_MSG_MEAS_REQUEST 23 -#define NAS_MSG_MEAS_REPLY 24 -#define NAS_MSG_IMEI_REQUEST 25 -#define NAS_MSG_IMEI_REPLY 26 - -// Max number of entry of a message list -#define NAS_LIST_CX_MAX 32 -#define NAS_LIST_RB_MAX 32 -#define NAS_LIST_CLASS_MAX 32 - -typedef uint16_t nasMsgType_t; - -struct nas_ioctl { - char name[IFNAMSIZ]; - nasMsgType_t type; - char *msg; -}; - -struct nas_msg_statistic_reply { - uint32_t rx_packets; - uint32_t tx_packets; - uint32_t rx_bytes; - uint32_t tx_bytes; - uint32_t rx_errors; - uint32_t tx_errors; - uint32_t rx_dropped; - uint32_t tx_dropped; -}; - -struct nas_msg_cx_list_reply { - nasLocalConnectionRef_t lcr; // Local Connection reference - uint8_t state; - nasCellID_t cellid; // cell identification - uint32_t iid6[2]; // IPv6 interface identification - uint8_t iid4; // IPv4 interface identification - uint16_t num_rb; - uint16_t nsclassifier; -}; -struct nas_msg_cx_establishment_reply { - int status; -}; -struct nas_msg_cx_establishment_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasCellID_t cellid; // Cell identification -}; -struct nas_msg_cx_release_reply { - int status; -}; -struct nas_msg_cx_release_request { - nasLocalConnectionRef_t lcr; // Local Connection reference -}; - -struct nas_msg_rb_list_reply { - nasRadioBearerId_t rab_id; - nasSapId_t sapi; - nasQoSTrafficClass_t qos; - uint8_t state; -}; -struct nas_msg_rb_list_request { - nasLocalConnectionRef_t lcr; // Local Connection reference -}; -struct nas_msg_rb_establishment_reply { - int status; -}; -struct nas_msg_rb_establishment_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; - nasQoSTrafficClass_t qos; -}; - -struct nas_msg_rb_release_reply { - int status; -}; -struct nas_msg_rb_release_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; -}; - -struct nas_msg_class_add_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; - uint8_t dir; // direction (send or receive) - uint8_t dscp; // codepoint - uint8_t fct; - uint16_t classref; - uint8_t version; - union { - struct in6_addr ipv6; - uint32_t ipv4; - } saddr; // IP source address - uint8_t splen; // prefix length - union { - struct in6_addr ipv6; - uint32_t ipv4; - } daddr; // IP destination address - uint8_t dplen; // prefix length - uint8_t protocol; // high layer protocol type - uint16_t sport; // source port - uint16_t dport; // destination port -}; -struct nas_msg_class_add_reply { - int status; -}; -struct nas_msg_class_del_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - uint8_t dir; // direction (send or receive) - uint8_t dscp; // codepoint - uint16_t classref; -}; -struct nas_msg_class_del_reply { - int status; -}; -#define nas_msg_class_list_reply nas_msg_class_add_request -struct nas_msg_class_list_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - uint8_t dir; - uint8_t dscp; -}; - - -// Messages for Measurement transfer - MW 01/04/2005 -typedef uint32_t nioctlProviderId_t; -typedef uint16_t nioctlSignalLoss_t; -typedef struct nioctlMeasures { - nasCellID_t cell_id; - nasSigLevel_t level; - nioctlProviderId_t provider_id; -} nioctlMeasures_t; - -struct nas_msg_measure_request { - nasNumRGsMeas_t num_cells; - nasCellID_t cellid[MAX_MEASURE_NB]; // Cell identification - uint16_t num_providers; - nioctlProviderId_t provider_id[MAX_MEASURE_NB]; // Provider identification -}; -struct nas_msg_measure_reply { - nasNumRGsMeas_t num_cells; - nioctlMeasures_t measures[MAX_MEASURE_NB]; - nioctlSignalLoss_t signal_lost_flag; -}; - -// Messages for L2Id transfer - MW -typedef uint32_t nioctlL2Id_t[2]; - -struct nas_msg_l2id_reply { - nioctlL2Id_t l2id; -}; - - -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c deleted file mode 100644 index 2f92b94717ea2eca2171298ee8fcaecd09258f27..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_netlink.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_netlink.c -* \brief Netlink socket functions for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -//#include <linux/config.h> -#include <linux/socket.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/netlink.h> -#include <net/sock.h> -#include <linux/kthread.h> - -#include <linux/mutex.h> - -#include "nasmt_variables.h" -#include "nasmt_proto.h" - -static struct sock *nas_nl_sk = NULL; -static struct sock *nas_rrcnl_sk = NULL; - -//static int exit_netlink_thread=0; -static DEFINE_MUTEX(nasmt_mutex); - -// This can also be implemented using thread to get the data from PDCP without blocking. -//--------------------------------------------------------------------------- -// Function for transfer with PDCP (from NASLITE) -static void nasmt_nl_data_ready (struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct nlmsghdr *nlh = NULL; - - // Start debug information -#ifdef NETLINK_DEBUG - printk("nasmt_nl_data_ready - begin \n"); -#endif - - if (!skb) { - printk("nasmt_nl_data_ready - input parameter skb is NULL \n"); - return; - } - - // End debug information - -#ifdef NETLINK_DEBUG - printk("nasmt_nl_data_ready - Received socket from PDCP\n"); -#endif //NETLINK_DEBUG - nlh = (struct nlmsghdr *)skb->data; - nasmt_COMMON_QOS_receive(nlh); -} - -//--------------------------------------------------------------------------- -// Function for transfer with RRC -static void nasmt_rrcnl_data_ready (struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct nlmsghdr *nlh = NULL; - char target_sap; - uint8_t cxi = 0; - - // Start debug information -#ifdef NAS_DEBUG_RRCNL - printk("nasmt_rrcnl_data_ready - begin \n"); -#endif - - if (!skb) { - printk("nasmt_rrcnl_data_ready - input parameter skb is NULL \n"); - return; - } - - // End debug information - - nlh = (struct nlmsghdr *)skb->data; - //pdcph = (struct pdcp_data_ind_header_t *)NLMSG_DATA(nlh); - //nasmt_TOOL_print_buffer((char *)NLMSG_DATA(nlh), 48); - - target_sap = ((char*)NLMSG_DATA(nlh))[0]; -#ifdef NAS_DEBUG_RRCNL - printk("nasmt_rrcnl_data_ready - Received on socket from RRC, SAP %d\n", target_sap); -#endif //NAS_DEBUG_RRCNL - - switch (target_sap) { - case RRC_NAS_GC_OUT: - //printk("nasmt_rrcnl_data_ready - Calling nasmt_ASCTL_GC_receive\n"); - nasmt_ASCTL_GC_receive(&((char*)NLMSG_DATA(nlh))[1]); - break; - - case RRC_NAS_DC0_OUT: - //printk("nasmt_rrcnl_data_ready - Calling nasmt_ASCTL_DC_receive\n"); - nasmt_ASCTL_DC_receive(gpriv->cx+cxi, &((char*)NLMSG_DATA(nlh))[1]); - break; - - default: - printk("nasmt_rrcnl_data_ready - Invalid SAP value received\n"); - } - -} - -//--------------------------------------------------------------------------- -int nasmt_netlink_init(void) -{ - //--------------------------------------------------------------------------- - printk("nasmt_netlink_init - begin \n"); - - nas_nl_sk = netlink_kernel_create(&init_net,OAI_IP_DRIVER_NETLINK_ID, 0, nasmt_nl_data_ready, - &nasmt_mutex, // NULL - THIS_MODULE); - - if (!nas_nl_sk) { - printk("nasmt_netlink_init - netlink_kernel_create failed for PDCP socket\n"); - return(-1); - } - - nas_rrcnl_sk = netlink_kernel_create(&init_net,NAS_RRCNL_ID, 0, nasmt_rrcnl_data_ready, - &nasmt_mutex, // NULL - THIS_MODULE); - - if (!nas_rrcnl_sk) { - printk("nasmt_rrcnl_init - netlink_kernel_create failed for RRC socket\n"); - return(-1); - } - - return(0); -} - -//--------------------------------------------------------------------------- -void nasmt_netlink_release(void) -{ - //--------------------------------------------------------------------------- - printk("nasmt_netlink_release - begin \n"); - - //exit_netlink_thread=1; - printk("nasmt_netlink_release - Releasing netlink sockets\n"); - - if(nas_nl_sk) { - netlink_kernel_release(nas_nl_sk); - } - - if(nas_rrcnl_sk) { - netlink_kernel_release(nas_rrcnl_sk); - } - -} - -//--------------------------------------------------------------------------- -int nasmt_netlink_send(unsigned char *data_buffer, unsigned int data_length, int destination) -{ - //--------------------------------------------------------------------------- - struct sk_buff *nl_skb; - struct nlmsghdr *nlh; - int status; - // Start debug information -#ifdef NETLINK_DEBUG - printk("nasmt_netlink_send - begin \n"); -#endif - - if (!data_buffer) { - printk("nasmt_netlink_send - ERROR - input parameter data is NULL \n"); - return(0); - } - - if (!nas_nl_sk || !nas_rrcnl_sk) { - printk("nasmt_netlink_send - ERROR - socket is NULL\n"); - return(0); - } - - // End debug information - - nl_skb = alloc_skb(NLMSG_SPACE(data_length),GFP_ATOMIC); - - if (!nl_skb) { - printk("nasmt_netlink_send - ERROR - could not allocate skbuffer\n"); - return(0); - } - - nlh = (struct nlmsghdr *)nl_skb->data; - - // printk("nasmt_netlink_send Sending %d bytes (%d)\n",data_length,NLMSG_SPACE(data_length)); - skb_put(nl_skb, NLMSG_SPACE(data_length)); - memcpy(NLMSG_DATA(nlh), data_buffer, data_length); - nlh->nlmsg_len = NLMSG_SPACE(data_length); - - nlh->nlmsg_pid = 0; /* from kernel */ - NETLINK_CB(nl_skb).pid = 0; - - // destination 0 = PDCP, 1 = RRC - if (!destination) { -#ifdef NETLINK_DEBUG - printk("nasmt_netlink_send - nl_skb %p, nl_sk %p, nlh %p, nlh->nlmsg_len %d\n", nl_skb, nas_nl_sk, nlh, nlh->nlmsg_len); -#endif //DEBUG_NETLINK - status = netlink_unicast(nas_nl_sk, nl_skb, NL_DEST_PID, MSG_DONTWAIT); - } else { -#ifdef NAS_DEBUG_RRCNL - printk("nasmt_rrcnl_send - nl_skb %p, nas_rrcnl_sk %p, nlh %p, nlh->nlmsg_len %d\n", nl_skb, nas_rrcnl_sk, nlh, nlh->nlmsg_len); -#endif //NAS_DEBUG_RRCNL - status = netlink_unicast(nas_rrcnl_sk, nl_skb, NL_DEST_RRC_PID, MSG_DONTWAIT); - } - - if (status < 0) { - printk("nasmt_netlink_send - SEND status is %d\n",status); - return(0); - } else { -#ifdef NETLINK_DEBUG - printk("nasmt_netlink_send - SEND status is %d, data_length %d\n",status, data_length); -#endif - return data_length; - } -} - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h deleted file mode 100644 index 3a6ffe4848a0deffb0b81c01263a1224748f317f..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_proto.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_proto.h -* \brief Function prototypes for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASMTD_PROTO_H -#define _NASMTD_PROTO_H - -#include <linux/if_arp.h> -#include <linux/types.h> -#include <linux/spinlock.h> -#include <linux/netdevice.h> -#include <linux/skbuff.h> -#include <linux/ipv6.h> -#include <linux/ip.h> -#include <linux/sysctl.h> -#include <linux/timer.h> -#include <asm/param.h> -//#include <sys/sysctl.h> -#include <linux/udp.h> -#include <linux/tcp.h> -#include <linux/icmp.h> -#include <linux/icmpv6.h> -#include <linux/in.h> -#include <net/ndisc.h> - -//#include "rrc_nas_primitives.h" -//#include "protocol_vars_extern.h" -//#include "as_sap.h" -//#include "rrc_qos.h" -//#include "rrc_sap.h" - -// nasmt_netlink.c -void nasmt_netlink_release(void); -int nasmt_netlink_init(void); -int nasmt_netlink_send(unsigned char *data_buffer, unsigned int data_length, int destination); - -// nasmt_common.c -//void nasmt_COMMON_receive(uint16_t hlen, uint16_t dlength, int sap); -void nasmt_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); - -void nasmt_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -void nasmt_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -#ifndef PDCP_USE_NETLINK -void nasmt_COMMON_QOS_receive(struct cx_entity *cx); -#else -void nasmt_COMMON_QOS_receive(struct nlmsghdr *nlh); -#endif -struct rb_entity *nasmt_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rabi, nasQoSTrafficClass_t qos); -struct rb_entity *nasmt_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rabi); -struct cx_entity *nasmt_COMMON_search_cx(nasLocalConnectionRef_t lcr); -void nasmt_COMMON_del_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasIPdscp_t dscp); -void nasmt_COMMON_flush_rb(struct cx_entity *cx); - - -//nasmt_ascontrol.c -void nasmt_ASCTL_init(void); -void nasmt_ASCTL_timer(unsigned long data); -int nasmt_ASCTL_DC_receive(struct cx_entity *cx, char *buffer); -int nasmt_ASCTL_GC_receive(char *buffer); -int nasmt_ASCTL_DC_send_cx_establish_request(struct cx_entity *cx); -int nasmt_ASCTL_DC_send_cx_release_request(struct cx_entity *cx); -void nasmt_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -void nasmt_ASCTL_DC_send_peer_sig_data_request(struct cx_entity *cx, uint8_t sig_category); -int nasmt_ASCTL_leave_sleep_mode(struct cx_entity *cx); -int nasmt_ASCTL_enter_sleep_mode(struct cx_entity *cx); - -// nasmt_iocontrol.c -void nasmt_CTL_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -int nasmt_CTL_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); - -// nasmt_classifier.c -void nasmt_CLASS_send(struct sk_buff *skb); -struct classifier_entity *nasmt_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref); -struct classifier_entity *nasmt_CLASS_add_rclassifier(uint8_t dscp, uint16_t classref); -void nasmt_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref); -void nasmt_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref); -void nasmt_CLASS_flush_sclassifier(struct cx_entity *cx); -void nasmt_CLASS_flush_rclassifier(void); - -// nasmt_tool.c -uint8_t nasmt_TOOL_invfct(struct classifier_entity *gc); -void nasmt_TOOL_fct(struct classifier_entity *gc, uint8_t fct); -void nasmt_TOOL_imei2iid(uint8_t *imei, uint8_t *iid); - -void nasmt_TOOL_eth_imei2iid(unsigned char *imei, unsigned char *addr ,unsigned char *iid, unsigned char len); -uint8_t nasmt_TOOL_get_dscp6(struct ipv6hdr *iph); -uint8_t nasmt_TOOL_get_dscp4(struct iphdr *iph); -uint8_t *nasmt_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol); -uint8_t *nasmt_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol); - -void nasmt_TOOL_pk_icmp6(struct icmp6hdr *icmph); - -void nasmt_TOOL_print_state(uint8_t state); -void nasmt_TOOL_print_buffer(unsigned char * buffer,int length); -void nasmt_TOOL_print_rb_entity(struct rb_entity *rb); -void nasmt_TOOL_print_classifier(struct classifier_entity *gc); - -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h deleted file mode 100644 index c0934f4622a2c519bbe6e5143e073b0041b1cec7..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_sap.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_sap.h -* \brief SAP constants for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASMTD_SAP_H -#define _NASMTD_SAP_H - -// RT-FIFO identifiers ** must be identical to Access Stratum as_sap.h and rrc_sap.h -#define RRC_DEVICE_GC RRC_SAPI_UE_GCSAP -#define RRC_DEVICE_NT RRC_SAPI_UE_NTSAP -#define RRC_DEVICE_DC_INPUT0 RRC_SAPI_UE_DCSAP_IN -#define RRC_DEVICE_DC_OUTPUT0 RRC_SAPI_UE_DCSAP_OUT - -//#define QOS_DEVICE_CONVERSATIONAL_INPUT QOS_SAPI_CONVERSATIONAL_INPUT_MT -//#define QOS_DEVICE_CONVERSATIONAL_OUTPUT QOS_SAPI_CONVERSATIONAL_OUTPUT_MT - -#define PDCP2PDCP_USE_RT_FIFO 21 -#define NAS2PDCP_FIFO 22 - -//FIFO indexes in control blocks -#define NAS_DC_INPUT_SAPI 0 -#define NAS_DC_OUTPUT_SAPI 1 -#define NAS_SAPI_CX_MAX 2 - -#define NAS_GC_SAPI 0 -#define NAS_NT_SAPI 1 -#define NAS_DRB_INPUT_SAPI 2 //NAS_CO_INPUT_SAPI -#define NAS_DRB_OUTPUT_SAPI 3 //NAS_CO_OUTPUT_SAPI -#define NAS_SAPI_MAX 4 - -//#define NAS_QOS_CONVERSATIONAL UMTS_TRAFFIC_CONVERSATIONAL -// - -/* Defined in RRC -#define RRC_NAS_GC_IN 0 -#define RRC_NAS_GC_OUT 1 -#define RRC_NAS_NT_IN 2 -#define RRC_NAS_NT_OUT 3 -#define RRC_NAS_DC0_IN 4 -#define RRC_NAS_DC0_OUT 5 -#define RRC_NAS_DC1_IN 6 -#define RRC_NAS_DC1_OUT 7 -#define RRC_NAS_DC2_IN 8 -#define RRC_NAS_DC2_OUT 9 -*/ -#endif - - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_tool.c b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_tool.c deleted file mode 100644 index 4c5d3fcf6e700742a13ba017caad1af567de051a..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_tool.c +++ /dev/null @@ -1,494 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*************************************************************************** - nasmt_tool.c - description - *************************************************************************** - - ***************************************************************************/ -/*! \file nasmt_tool.c -* \brief Tool functions for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ - -#include "nasmt_variables.h" -#include "nasmt_proto.h" - -//--------------------------------------------------------------------------- -// -void nasmt_TOOL_fct(struct classifier_entity *gc, uint8_t fct) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_fct - begin \n"); -#endif - - if (gc==NULL) { - printk("nasmt_TOOL_fct - input parameter gc is NULL \n"); - return; - } - - // End debug information - switch(fct) { - case NAS_FCT_QOS_SEND: - gc->fct=nasmt_COMMON_QOS_send; - break; - - case NAS_FCT_CTL_SEND: - gc->fct=nasmt_CTL_send; - break; - - case NAS_FCT_DC_SEND: - gc->fct=nasmt_ASCTL_DC_send_sig_data_request; - break; - - case NAS_FCT_DEL_SEND: - gc->fct=nasmt_COMMON_del_send; - break; - - default: - gc->fct=nasmt_COMMON_del_send; - } -} - -//--------------------------------------------------------------------------- -uint8_t nasmt_TOOL_invfct(struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_invfct - begin \n"); -#endif - - if (gc==NULL) { - printk("nasmt_TOOL_invfct - input parameter gc is NULL \n"); - return 0; - } - - // End debug information - if (gc->fct==nasmt_COMMON_QOS_send) - return NAS_FCT_QOS_SEND; - - if (gc->fct==nasmt_CTL_send) - return NAS_FCT_CTL_SEND; - - if (gc->fct==nasmt_COMMON_del_send) - return NAS_FCT_DEL_SEND; - - if (gc->fct==nasmt_ASCTL_DC_send_sig_data_request) - return NAS_FCT_DC_SEND; - - return 0; -} - -//--------------------------------------------------------------------------- -uint8_t nasmt_TOOL_get_dscp6(struct ipv6hdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_get_dscp6 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasmt_TOOL_get_dscp6 - input parameter ipv6hdr is NULL \n"); - return 0; - } - - // End debug information - // return (ntohl(((*(__u32 *)iph)&NAS_TRAFFICCLASS_MASK)))>>22; //Yan - return (ntohl(((*(__u32 *)iph)&NAS_TRAFFICCLASS_MASK)))>>20; -} - -//--------------------------------------------------------------------------- -uint8_t nasmt_TOOL_get_dscp4(struct iphdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_get_dscp4 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasmt_TOOL_get_dscp4 - input parameter ipv4hdr is NULL \n"); - return 0; - } - - // End debug information - return ((iph->tos)>>5)<<3; -} - - -//--------------------------------------------------------------------------- -uint8_t *nasmt_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - uint16_t size; - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_get_protocol6 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasmt_TOOL_get_protocol6 - input parameter ipv6hdr is NULL \n"); - return NULL; - } - - if (protocol==NULL) { - printk("nasmt_TOOL_get_protocol6 - input parameter protocol is NULL \n"); - return NULL; - } - - // End debug information - *protocol=iph->nexthdr; - size=NAS_IPV6_SIZE; - - while (1) { - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMPV6: - return (uint8_t *)((uint8_t *)iph+size); - - case IPPROTO_HOPOPTS: - case IPPROTO_ROUTING: - case IPPROTO_DSTOPTS: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]*8+8; - break; - - case IPPROTO_FRAGMENT: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]+8; - break; - - case IPPROTO_NONE: - case IPPROTO_AH: - case IPPROTO_ESP: - default: - return NULL; - } - } -} - -//--------------------------------------------------------------------------- -uint8_t *nasmt_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_get_protocol4 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasmt_TOOL_get_protocol4 - input parameter iph is NULL \n"); - return NULL; - } - - if (protocol==NULL) { - printk("nasmt_TOOL_get_protocol4 - input parameter protocol is NULL \n"); - return NULL; - } - - // End debug information - *protocol=iph->protocol; - - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMP: - return (uint8_t *)((uint8_t *)iph+iph->tot_len); - - default: - return NULL; - } -} - -//--------------------------------------------------------------------------- -// Convert the IMEI to iid -void nasmt_TOOL_imei2iid(uint8_t *imei, uint8_t *iid) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_imei2iid - begin \n"); -#endif - - if (imei==NULL) { - printk("nasmt_TOOL_imei2iid - input parameter imei is NULL \n"); - return; - } - - if (iid==NULL) { - printk("nasmt_TOOL_imei2iid - input parameter iid is NULL \n"); - return; - } - - // End debug information - memset(iid, 0, NAS_ADDR_LEN); - iid[0] = 0x03; - iid[1] = 16*imei[0]+imei[1]; - iid[2] = 16*imei[2]+imei[3]; - iid[3] = 16*imei[4]+imei[5]; - iid[4] = 16*imei[6]+imei[7]; - iid[5] = 16*imei[8]+imei[9]; - iid[6] = 16*imei[10]+imei[11]; - iid[7] = 16*imei[12]+imei[13]; -} - -//--------------------------------------------------------------------------- -// Convert the IMEI to iid -void nasmt_TOOL_eth_imei2iid(unsigned char *imei, unsigned char *addr ,unsigned char *iid, unsigned char len) -{ - //--------------------------------------------------------------------------- - unsigned int index; - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_eth_imei2iid - begin \n"); -#endif - - if (!imei || !addr || !iid) { - printk("OAI_NW_DRV_TOOL_eNB_IMEI2IID - input parameter imei, addr or iid is NULL \n"); - return; - } - - // End debug information - // set addr (should be device HW address) - memset(addr, 0, len); - addr[0] = 0x00; // to be compatible between link local and global - - // len -1 because of insertion of 0 above - for (index = 0; index < (len-1); index++) { - addr[index+1] = 16*imei[index*2]+imei[index*2+1]; - } - - // set iid6 - memset(iid, 0, NAS_ADDR_LEN); - iid[0] = 0x02; - iid[1] = 16*imei[0]+imei[1]; - iid[2] = 16*imei[2]+imei[3]; - iid[3] = 0xff; - iid[4] = 0xfe; - iid[5] = 16*imei[4]+imei[5]; - iid[6] = 16*imei[6]+imei[7]; - iid[7] = 16*imei[8]+imei[9]; - -} - -//--------------------------------------------------------------------------- -void nasmt_TOOL_pk_icmp6(struct icmp6hdr *icmph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef GRAAL_DEBUG_TOOL - printk("nasmt_TOOL_pk_icmp6 - begin \n"); -#endif - - if (!icmph) { - printk("nasmt_TOOL_pk_icmp6 - input parameter icmph is NULL \n"); - return; - } - - // End debug information - printk("ICMPv6:\t type= %d, code = %d\n", icmph->icmp6_type, icmph->icmp6_code); - - switch(icmph->icmp6_type) { - case ICMPV6_DEST_UNREACH: - printk("Destination unreachable\n"); - break; - - case ICMPV6_PKT_TOOBIG: - printk("Packet too big\n"); - break; - - case ICMPV6_TIME_EXCEED: - printk("Time exceeded\n"); - break; - - case ICMPV6_PARAMPROB: - printk("Parameter problem\n"); - break; - - case ICMPV6_ECHO_REQUEST: - printk("Echo request\n"); - break; - - case ICMPV6_ECHO_REPLY: - printk("Echo reply\n"); - break; - - case ICMPV6_MGM_QUERY: - printk("Multicast listener query\n"); - break; - - case ICMPV6_MGM_REPORT: - printk("Multicast listener report\n"); - break; - - case ICMPV6_MGM_REDUCTION: - printk("Multicast listener done\n"); - break; - - case NDISC_ROUTER_SOLICITATION: - printk("Router solicitation\n"); - break; - - case NDISC_ROUTER_ADVERTISEMENT: - printk("Router advertisment\n"); - break; - - case NDISC_NEIGHBOUR_SOLICITATION: - printk("Neighbour solicitation\n"); - break; - - case NDISC_NEIGHBOUR_ADVERTISEMENT: - printk("Neighbour advertisment\n"); - break; - - case NDISC_REDIRECT: - printk("redirect message\n"); - break; - } -} - -//--------------------------------------------------------------------------- -void nasmt_TOOL_print_state(uint8_t state) -{ - //--------------------------------------------------------------------------- - switch(state) { - case NAS_IDLE: - printk("NAS_IDLE\n"); - return; - - case NAS_CX_FACH: - printk("NAS_CX_FACH\n"); - return; - - case NAS_CX_DCH: - printk("NAS_CX_DCH\n"); - return; - - case NAS_CX_RECEIVED: - printk("NAS_CX_RECEIVED\n"); - return; - - case NAS_CX_CONNECTING: - printk("NAS_CX_CONNECTING\n"); - return; - - case NAS_CX_RELEASING: - printk("NAS_CX_RELEASING\n"); - return; - - case NAS_CX_CONNECTING_FAILURE: - printk("NAS_CX_CONNECTING_FAILURE\n"); - return; - - case NAS_CX_RELEASING_FAILURE: - printk("NAS_CX_RELEASING_FAILURE\n"); - return; - - case NAS_RB_ESTABLISHING: - printk("NAS_RB_ESTABLISHING\n"); - return; - - case NAS_RB_RELEASING: - printk("NAS_RB_RELEASING\n"); - return; - - case NAS_RB_DCH: - printk("NAS_RB_DCH\n"); - return; - - default: - printk("nasmt_TOOL_print_state - Unknown state\n"); - } -} - -//----------------------------------------------------------------------------- -// Print the content of a buffer in hexadecimal -void nasmt_TOOL_print_buffer(unsigned char * buffer,int length) -{ - //----------------------------------------------------------------------------- - int i; - - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_print_buffer - begin \n"); -#endif - - if (buffer==NULL) { - printk("nasmt_TOOL_print_buffer - input parameter buffer is NULL \n"); - return; - } - - // End debug information - printk("\nBuffer content: "); - - for (i=0; i<length; i++) - printk("-%hx-",buffer[i]); - - printk(",\t length %d\n", length); -} -//----------------------------------------------------------------------------- -void nasmt_TOOL_print_rb_entity(struct rb_entity *rb) -{ - //----------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_print_rb_entity - begin \n"); -#endif - - if (rb==NULL) { - printk("nasmt_TOOL_print_rb_entity - input parameter rb is NULL \n"); - return; - } - - // End debug information - printk("\nrb_entity content: rab_id %d, sapi %d, qos %d, dscp %d, \n", rb->rab_id, rb->sapi, rb->qos, rb->dscp); - printk("state %d, retry %d, countimer %d\n",rb->state, rb->retry, rb->countimer); -}; - -//----------------------------------------------------------------------------- -void nasmt_TOOL_print_classifier(struct classifier_entity *gc) -{ - //----------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasmt_TOOL_print_classifier - begin \n"); -#endif - - if (gc==NULL) { - printk("nasmt_TOOL_print_classifier - input parameter gc is NULL \n"); - return; - } - - // End debug information - printk("\nClassifier content: classref %d, version %d, splen %d, dplen %d,\n", gc->classref, gc->version, gc->splen, gc->dplen); - printk("protocol %d, sport %d, dport %d, rab_id %d\n", gc->protocol, gc->sport, gc->dport, gc->rab_id); - nasmt_TOOL_print_rb_entity(gc->rb); -}; - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_variables.h b/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_variables.h deleted file mode 100644 index c5754e948eb0ba1440bdc76a7b68ff1a499b18d0..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASMT/nasmt_variables.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_variables.h -* \brief Variable and structure definitions for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASMTD_VAR_H -#define _NASMTD_VAR_H - -#include <linux/if_arp.h> -#include <linux/types.h> -#include <linux/spinlock.h> -#include <linux/netdevice.h> -#include <linux/skbuff.h> -#include <linux/ipv6.h> -#include <linux/ip.h> -#include <linux/sysctl.h> -#include <linux/timer.h> -#include <linux/unistd.h> -#include <asm/param.h> -//#include <sys/sysctl.h> -#include <linux/udp.h> -#include <linux/tcp.h> -#include <linux/icmp.h> -#include <linux/icmpv6.h> -#include <linux/in.h> -#include <net/ndisc.h> - -#include "rrc_nas_primitives.h" -#include "rrc_qos_classes.h" -#include "rrc_nas_sap.h" - -#include "nasmt_constant.h" -#include "nasmt_sap.h" - -struct cx_entity; - -struct rb_entity { - uint32_t cnxid; - nasRadioBearerId_t rab_id; //ue_rbId - nasSapId_t sapi; - nasQoSTrafficClass_t qos; - nasQoSTrafficClass_t RadioQosClass; - nasIPdscp_t dscp; - uint8_t state; - uint8_t result; - uint8_t retry; - uint32_t countimer; - struct rb_entity *next; -}; - -struct classifier_entity { - uint32_t classref; // classifier identity - uint8_t version; // IP version 4 or 6 - union { - struct in6_addr ipv6; - uint32_t ipv4; - } saddr; // IP source address - uint8_t splen; // IP prefix size - union { - struct in6_addr ipv6; - uint32_t ipv4; - } daddr; // IP destination address - uint8_t dplen; // IP prefix size - uint8_t protocol; // layer 4 protocol type (tcp, udp, ...) - uint16_t sport; // source port - uint16_t dport; // destination port - struct rb_entity *rb; - nasRadioBearerId_t rab_id; // RAB identification - void (*fct)(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); - struct classifier_entity *next; -}; - - -struct cx_entity { - int sap[NAS_SAPI_CX_MAX]; - uint8_t state; // state of the connection - nasLocalConnectionRef_t lcr; // Local connection reference - nasCellID_t cellid; // cell identification - uint32_t countimer; // timeout's counter - uint8_t retry; // number of retransmissions - struct classifier_entity *sclassifier[NAS_DSCP_MAX]; // send classifiers table - uint16_t nsclassifier; - uint32_t iid6[2]; // IPv6 interface identification - uint8_t iid4; // IPv4 interface identification - struct rb_entity *rb; - uint16_t num_rb; - //measures - int req_prov_id[MAX_MEASURE_NB]; - int num_measures; - int meas_cell_id[MAX_MEASURE_NB]; - int meas_level[MAX_MEASURE_NB]; - int provider_id[MAX_MEASURE_NB]; - //MBMS - int joined_services[NASMT_MBMS_SVCES_MAX]; - -}; - -struct nas_priv { - int irq; - int rx_flags; - struct timer_list timer; - spinlock_t lock; - struct net_device_stats stats; - uint8_t retry_limit; - uint32_t timer_establishment; - uint32_t timer_release; - struct cx_entity cx[NAS_CX_MAX]; - struct classifier_entity *rclassifier[NAS_DSCP_MAX]; // receive classifier - uint16_t nrclassifier; - uint32_t next_sclassref; - int sap[NAS_SAPI_MAX]; - uint8_t xbuffer[NAS_MAX_LENGTH]; // transmission buffer - uint8_t rbuffer[NAS_MAX_LENGTH]; // reception buffer -}; - -struct ipversion { -#if defined(__LITTLE_ENDIAN_BITFIELD) - uint8_t reserved:4, - version:4; -#else - uint8_t version:4, - reserved:4; -#endif -}; - -typedef struct pdcp_data_req_header_t { - unsigned int rb_id; - unsigned int data_size; - int inst; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_t { - unsigned int rb_id; - unsigned int data_size; - int inst; -} pdcp_data_ind_header_t; -// - -extern struct nas_priv *gpriv; -extern struct net_device *gdev; -//extern int bytes_wrote; -//extern int bytes_read; - -extern uint8_t NAS_NULL_IMEI[14]; -extern uint8_t NAS_RG_IMEI[14]; - -//global variables shared with RRC -extern int *pt_nas_ue_irq; -//extern uint8_t nas_IMEI[14]; -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile b/openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile deleted file mode 100755 index 758fa0420b0220e949ebae6266e6a11e403e1926..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# NAS CELLULAR Driver makefile -# -include $(OPENAIR_DIR)/common/utils/Makefile.inc - -NAS_UPDIR := $(shell /bin/pwd) - -#################################################### -# D E B U G F L A G S -#################################################### - -#################################################### -# EXTRA COMPILER FLAGS -#################################################### -EXTRA_CFLAGS = -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) - -ifdef ADDRCONF -EXTRA_CFLAGS += -DADDRCONF -endif - -ifdef NAS_DRIVER_TYPE_ETHERNET -EXTRA_CFLAGS += -DNAS_DRIVER_TYPE_ETHERNET -endif - - -ifdef PDCP_USE_NETLINK -EXTRA_CFLAGS += -DPDCP_USE_NETLINK -else -EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall -endif - -ifdef LOOPBACK -EXTRA_CFLAGS += -DLOOPBACK_TEST -endif - -ifdef ADDRESS_FIX -EXTRA_CFLAGS += -DNAS_ADDRESS_FIX -endif - -#################################################### -# NASRGCELL extra compilation flags -#################################################### -#RTAI=1 -RRC_DIR := $(OPENAIR2_DIR)/RRC/CELLULAR -EXTRA_CFLAGS += -I$(RRC_DIR) -DNODE_RG - -#################################################### -# LOADABLE MODULE GOALS -#################################################### -obj-m += nascellrg.o -nascellrg-objs += nasrg_device.o -nascellrg-objs += nasrg_common.o -nascellrg-objs += nasrg_iocontrol.o -nascellrg-objs += nasrg_classifier.o -nascellrg-objs += nasrg_tool.o -nascellrg-objs += nasrg_ascontrol.o -ifdef PDCP_USE_NETLINK -nascellrg-objs += nasrg_netlink.o -endif - -#################################################### -# REVOIR LE CLEAN -#################################################### - -#netlink.ko: - #make $(x)$(y) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules - -#nasmesh.ko: -# make V=1 -C $(KERNEL_DIR) M=`pwd` modules -print: - @echo RRC_DIR $(RRC_DIR) -clean: - rm -f *.ko - rm -f .*.ko.cmd - rm -f .*.o.cmd - rm -f *.o - rm -f *.mod.c - find . -name *.ko -delete - find . -name *.o -delete - find . -name *.mod.c -delete diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c deleted file mode 100644 index 4a6ef0e27510e512703b35804237b107b2add8c3..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_ascontrol.c +++ /dev/null @@ -1,1494 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_ascontrol.c -* \brief Access Stratum Control functions for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifdef NODE_RG -#include "nasrg_variables.h" -#include "nasrg_proto.h" - -//--------------------------------------------------------------------------- -void nasrg_ASCTL_init(void) -{ - //--------------------------------------------------------------------------- - int cxi, i; - - gpriv->next_sclassref = NASRG_DEFAULTRAB_CLASSREF; - - // Initialize MBMS services list in MT - for (cxi=0; cxi<NAS_CX_MAX ; ++cxi) { - for (i = 0; i<NASRG_MBMS_SVCES_MAX; i++) { - gpriv->cx[cxi].requested_joined_services[i]= -1; - gpriv->cx[cxi].requested_left_services[i]= -1; - gpriv->cx[cxi].joined_services[i]= -1; - } - } - - printk("nasrg_ASCTL_init Complete\n"); -} - -//--------------------------------------------------------------------------- -int nasrg_ASCTL_write(int sap, unsigned char *data_buffer, unsigned int data_length) -{ - //--------------------------------------------------------------------------- - int bytes_wrote = 0; -#ifdef PDCP_USE_NETLINK - unsigned char xmit_buffer [NAS_MESSAGE_MAXLEN]; - - //write SAP_Id - switch (sap) { - case RRC_DEVICE_GC: - xmit_buffer[0] = RRC_NAS_GC_IN; - break; - - case RRC_DEVICE_NT: - xmit_buffer[0] = RRC_NAS_NT_IN; - break; - - case RRC_DEVICE_DC_INPUT0: - xmit_buffer[0] = RRC_NAS_DC0_IN; - break; - - case RRC_DEVICE_DC_INPUT1: - xmit_buffer[0] = RRC_NAS_DC1_IN; - //case RRC_DEVICE_DC_INPUT2: - //xmit_buffer[0] = RRC_NAS_DC2_IN; - break; - - default: - printk("nasrg_ASCTL_write - ERROR - Invalid SAP %d\n", sap); - return 0; - break; - } - - memcpy (&((char*)xmit_buffer)[1], data_buffer, data_length); -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_write - Sending data to RRC, sap %d, length %d (including NETLINK SAP value)\n", sap, data_length+1); - nasrg_TOOL_print_buffer(xmit_buffer,data_length+1); -#endif - bytes_wrote = nasrg_netlink_send(xmit_buffer,data_length+1, NASNL_DEST_RRC); -#else - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); //original version - bytes_wrote = rtf_put(sap, data_buffer, data_length+1); -#endif //PDCP_USE_NETLINK - return bytes_wrote-1; -} - -//--------------------------------------------------------------------------- -//For demo, add automatically a radio bearer -//Equivalent to rb add send 0 5 2 -void nasrg_ASCTL_start_default_rb(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- -#ifdef DEMO_3GSM - struct rb_entity *rb; - int status; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_start_default_rb - begin \n"); -#endif - - if (!cx) { - printk("nasrg_ASCTL_start_default_rb - input parameter cx is NULL \n"); - return; - } - - // End debug information - - rb = nasrg_COMMON_add_rb(cx, NASRG_DEFAULTRAB_RBID, NASRG_DEFAULTRAB_QoS); - - if (rb!=NULL) { - rb->cnxid = (NAS_RB_MAX_NUM * cx->lcr)+1; - //rb->default_rab =1; - rb->dscp = NASRG_DEFAULTRAB_DSCP; - rb->dscp_ul = NASRG_DEFAULTRAB_DSCP; - status=nasrg_ASCTL_DC_send_rb_establish_request(cx, rb); - } else - status=-NAS_ERROR_NOMEMORY; - -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_start_default_rb - end %d \n",status); -#endif -} -#endif - -//--------------------------------------------------------------------------- -//For demo, add automatically a classifier -//Equivalent to class add send 0 -f qos <x> -cr 0 -void nasrg_ASCTL_start_default_sclassifier(struct cx_entity *cx,struct rb_entity *rb) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("nasrg_ASCTL_start_default_sclassifier - begin \n"); -#endif - - if (!cx || !rb) { - printk("nasrg_ASCTL_start_default_sclassifier - input parameter is NULL \n"); - return; - } - - // End debug information - gc=nasrg_CLASS_add_sclassifier(cx, NAS_DSCP_DEFAULT, gpriv->next_sclassref); - - if (gc==NULL) { - printk("nasrg_ASCTL_start_default_sclassifier - Classifier pointer is null : not added \n"); - return; - } - - gc->fct = nasrg_COMMON_QOS_send; - gc->rab_id =rb->rab_id; - gc->rb= rb; - gc->version = NASRG_DEFAULTRAB_IPVERSION; - gc->protocol= NAS_PROTOCOL_DEFAULT; - gc->dplen= NAS_DEFAULT_IPv6_PREFIX_LENGTH; - // copy locator part of address into the gc structure - //gc->daddr.ipv6.s6_addr32[0] = 0; - //gc->daddr.ipv6.s6_addr32[1] = 0; - //gc->daddr.ipv6.s6_addr32[2] = 0; - //gc->daddr.ipv6.s6_addr32[3] = 0; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_ASCTL_start_default_sclassifier - end \n"); - nasrg_TOOL_print_classifier(gc); -#endif -} - -//--------------------------------------------------------------------------- -//Add automatically a classifier on DSCP -//Equivalent to class add send 0 -f qos <x> -cr 0 -void nasrg_ASCTL_start_sclassifier(struct cx_entity *cx,struct rb_entity *rb) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("nasrg_ASCTL_start_sclassifier - begin \n"); -#endif - - if (!cx || !rb) { - printk("nasrg_ASCTL_start_sclassifier - input parameter is NULL \n"); - return; - } - - // End debug information - gc=nasrg_CLASS_add_sclassifier(cx, rb->dscp, gpriv->next_sclassref); - - if (gc==NULL) { - printk("nasrg_ASCTL_start_sclassifier - Classifier pointer is null : not added \n"); - return; - } - - gc->fct = nasrg_COMMON_QOS_send; - gc->rab_id =rb->rab_id; - gc->rb= rb; - gc->version = NASRG_DEFAULTRAB_IPVERSION; - gc->protocol= NAS_PROTOCOL_DEFAULT; - gc->dplen= NAS_DEFAULT_IPv6_PREFIX_LENGTH; - // copy locator part of address into the gc structure - gc->daddr.ipv6.s6_addr32[2] = cx->iid6[0]; - gc->daddr.ipv6.s6_addr32[3] = cx->iid6[1]; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_ASCTL_start_sclassifier - end \n"); - nasrg_TOOL_print_classifier(gc); -#endif -} - -//--------------------------------------------------------------------------- -//Add automatically a classifier for mbms -void nasrg_ASCTL_start_mbmsclassifier(int mbms_ix,struct rb_entity *mbms_rb) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("nasrg_ASCTL_start_mbmsclassifier - begin \n"); -#endif - - if (!mbms_rb) { - printk("nasrg_ASCTL_start_mbmsclassifier - input parameter is NULL \n"); - return; - } - - // End debug information - // - // gc=nasrg_CLASS_add_mbmsclassifier(mbms_ix, gpriv->next_mbmsclassref); - gc=nasrg_CLASS_add_mbmsclassifier(mbms_ix, gpriv->next_sclassref++); - - if (gc==NULL) { - printk("nasrg_ASCTL_start_mbmsclassifier - Classifier pointer is null : not added \n"); - return; - } - - gc->fct = nasrg_COMMON_QOS_send; - gc->rab_id =mbms_rb->mbms_rbId; - gc->rb= mbms_rb; - gc->version = NASRG_DEFAULTRAB_IPVERSION; - gc->protocol= NAS_PROTOCOL_DEFAULT; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_ASCTL_start_mbmsclassifier - end \n"); - nasrg_TOOL_print_classifier(gc); -#endif -} - -//--------------------------------------------------------------------------- -//Notifies automatically UE on default MBMS service -void nasrg_ASCTL_start_default_ue_notification(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_start_default_ue_notification - begin \n"); -#endif - - if (!cx) { - printk("\nERROR nasrg_ASCTL_start_default_ue_notification - input parameter is NULL \n"); - return; - } - - // End debug information - // set value for default MBMS service - cx->requested_joined_services[0] = (NAS_CX_MAX*NAS_RB_MAX_NUM) +1; - nasrg_ASCTL_DC_send_mbms_ue_notify_req(cx); -} - -//--------------------------------------------------------------------------- -//Notifies automatically UE on default MBMS service -void nasrg_ASCTL_start_default_mbms_service(void) -{ - //--------------------------------------------------------------------------- - int mbms_ix=0; // should allocate index based on Service_id /cnxid / MC IP address -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_start_default_mbms_service - begin \n"); -#endif - - // Establish MBMS bearer if not already done - if ((gpriv->mbms_rb[mbms_ix].state != NAS_CX_DCH)&&(gpriv->mbms_rb[mbms_ix].state != NAS_RB_ESTABLISHING)) { - gpriv->mbms_rb[mbms_ix].cnxid = (NAS_CX_MAX*NAS_RB_MAX_NUM) +1; - gpriv->mbms_rb[mbms_ix].serviceId = (NAS_CX_MAX*NAS_RB_MAX_NUM) +1; - gpriv->mbms_rb[mbms_ix].sessionId = NASRG_TEMP_MBMS_SESSION_ID; //Temp hard coded - gpriv->mbms_rb[mbms_ix].mbms_rbId = NASRG_DEFAULTRAB_RBID; - gpriv->mbms_rb[mbms_ix].sapi = NAS_DC_INPUT_SAPI; -#ifdef NAS_DEBUG_MBMS_PROT - gpriv->mbms_rb[mbms_ix].sapi = NAS_DRB_INPUT_SAPI; //Only one RT-FIFO is used -#endif - gpriv->mbms_rb[mbms_ix].qos = 20; //from first version of MBMS traces - gpriv->mbms_rb[mbms_ix].dscp = 0; //maybe 7 - gpriv->mbms_rb[mbms_ix].duration = NASRG_TEMP_MBMS_DURATION; //Temp hard coded - //memcpy ((char *)&(gpriv->mbms_rb[mbms_ix].mcast_address),(char *)&(msgreq->mcast_group), 16); - gpriv->mbms_rb[mbms_ix].mcast_address[0] = 0xFF; - gpriv->mbms_rb[mbms_ix].mcast_address[1] = 0x0E; - nasrg_ASCTL_GC_send_mbms_bearer_establish_req(mbms_ix); - } else { -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_start_default_mbms_service - skipped, mbms_rb.state = %d \n", gpriv->mbms_rb[mbms_ix].state); -#endif - } -} -//--------------------------------------------------------------------------- -void nasrg_ASCTL_timer(unsigned long data) -{ - //--------------------------------------------------------------------------- - uint8_t cxi; - struct cx_entity *cx; - struct rb_entity *rb; - spin_lock(&gpriv->lock); -#ifdef NAS_DEBUG_TIMER - printk("nasrg_ASCTL_timer - begin \n"); -#endif - (gpriv->timer).function = nasrg_ASCTL_timer; - (gpriv->timer).expires=jiffies+NAS_TIMER_TICK; - (gpriv->timer).data=0L; - - for (cxi=0; cxi<NAS_CX_MAX ; ++cxi) { - cx=gpriv->cx+cxi; - - if (!cx) { - printk("nasrg_ASCTL_timer - No pointer for connection %d \n", cxi); - continue; - } - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { - if (rb->countimer!=NAS_TIMER_IDLE) { -#ifdef NAS_DEBUG_TIMER - printk("nasrg_ASCTL_timer : rb countimer %d, rb state %d\n", rb->countimer, rb->state); -#endif - - if (rb->countimer==0) { - switch (rb->state) { - case NAS_CX_CONNECTING: - case NAS_CX_CONNECTING_FAILURE: // MW - 15/01/07 Useless, currently no retry if failure - if (rb->retry<gpriv->retry_limit) { - printk("nasrg_ASCTL_timer: Retry RB establishment %d\n", rb->retry); - nasrg_ASCTL_DC_send_rb_establish_request(cx, rb); - } else { - printk("nasrg_ASCTL_timer: RB Establishment failure\n"); - rb->state=NAS_IDLE; - rb->countimer=NAS_TIMER_IDLE; - } - - break; - - case NAS_CX_DCH: -#ifdef DEMO_3GSM - if (cx->num_rb == 1) { - nasrg_ASCTL_start_default_sclassifier(cx, rb); - } - -#endif - nasrg_ASCTL_start_sclassifier(cx, rb); - rb->countimer=NAS_TIMER_IDLE; - break; - - case NAS_CX_RELEASING_FAILURE: - nasrg_ASCTL_DC_send_rb_release_request(cx, rb); - break; - - default: - rb->countimer=NAS_TIMER_IDLE; - } - } else { - --rb->countimer; - printk("nasrg_ASCTL_timer : rb countimer-- %d, rb state %d\n", rb->countimer, rb->state); - } - } - } - } - - add_timer(&gpriv->timer); -#ifdef NAS_DEBUG_TIMER - printk("nasrg_ASCTL_timer - end \n"); -#endif - spin_unlock(&gpriv->lock); -} - - -/*************************************************************************** - Transmission side - ***************************************************************************/ -//--------------------------------------------------------------------------- -// Encode INFO_BROADCAST_REQ message -int nasrg_ASCTL_GC_send_broadcast_request(uint8_t category) -{ - //--------------------------------------------------------------------------- - char *xmit_data = "TESTING BROADCASTING ROUTER ADVERTISEMENT. TESTING BROADCASTING ROUTER ADVERTISEMENT. BROADCASTING ROUTER.\0"; - int bytes_wrote = 0; -#ifdef PDCP_USE_NETLINK - unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; - int count=0; -#endif - - struct nas_rg_gc_element *p; - p= (struct nas_rg_gc_element *)(gpriv->xbuffer); - p->type = INFO_BROADCAST_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASInfoBroadcastReq); - // - p->nasRGGCPrimitive.broadcast_req.period = 0; - p->nasRGGCPrimitive.broadcast_req.category = category; - p->nasRGGCPrimitive.broadcast_req.nasDataLength = strlen(xmit_data)+1; // TBD - - //bytes_wrote = rtf_put(gpriv->sap[NAS_GC_SAPI], p, p->length); //original version -#ifdef PDCP_USE_NETLINK - memcpy(xbuffer,(unsigned char *)p, p->length); - count = p->length; - bytes_wrote = count; -#else - bytes_wrote = nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], (unsigned char *)p, p->length); -#endif - //printk("nasrg_ASCTL_GC_send_broadcast_request - Wrote %d bytes to RRC NAS_GC_SAPII\n", bytes_wrote); - - //bytes_wrote += rtf_put(gpriv->sap[NAS_GC_SAPI], xmit_data, p->nasRGGCPrimitive.broadcast_req.nasDataLength); -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),(unsigned char *)xmit_data, p->nasRGGCPrimitive.broadcast_req.nasDataLength); - count += p->nasRGGCPrimitive.broadcast_req.nasDataLength; - bytes_wrote += nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], xbuffer, count); -#else - bytes_wrote += nasrg_ASCTL_write((gpriv->sap[NAS_GC_SAPI], xmit_data, p->nasRGGCPrimitive.broadcast_req.nasDataLength); -#endif - - if (bytes_wrote==p->length+p->nasRGGCPrimitive.broadcast_req.nasDataLength) { -#ifdef NAS_DEBUG_GC - printk("nasrg_ASCTL_GC_send_broadcast: INFO_BROADCAST_REQ primitive sent successfully in GC-FIFO\n"); -#endif - } else { - printk("nasrg_ASCTL_GC_send_broadcast: Message sent failure in GC-FIFO\n"); - } - return bytes_wrote; -} - - -//--------------------------------------------------------------------------- -// Encode INFO_BROADCAST_REQ message for RRC SIB1 -int nasrg_ASCTL_GC_send_SIB1_broadcast_request(struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct nas_rg_gc_element *p; - char sib1_flag; // will be used for reception in nas_ue - int bytes_wrote = 0; -#ifdef PDCP_USE_NETLINK - unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; - int count=0; -#endif - - // Start debug information -#ifdef NAS_DEBUG_GC - printk("nasrg_ASCTL_GC_send_SIB1_broadcast_request - begin \n"); -#endif - - if (!skb) { - printk("nasrg_ASCTL_GC_send_SIB1_broadcast_request - input parameter is NULL \n"); - return 0; - } - - // End debug information - p= (struct nas_rg_gc_element *)(gpriv->xbuffer); - p->type = INFO_BROADCAST_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASInfoBroadcastReq); - // - p->nasRGGCPrimitive.broadcast_req.period = 10; // to be checked - p->nasRGGCPrimitive.broadcast_req.category = 1; - p->nasRGGCPrimitive.broadcast_req.nasDataLength = skb->len+1; // TBD - sib1_flag = 1; - // send header - //bytes_wrote = rtf_put(gpriv->sap[NAS_GC_SAPI], p, p->length); //original version -#ifdef PDCP_USE_NETLINK - memcpy(xbuffer,(unsigned char *)p, p->length); - count = p->length; - bytes_wrote = count; -#else - bytes_wrote = nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], (unsigned char *)p, p->length); -#endif - //printk("nasrg_ASCTL_GC_send_broadcast_request - Wrote %d bytes to RRC NAS_GC_SAPII\n", bytes_wrote); - - - if (bytes_wrote!=p->length) { - printk("nasrg_ASCTL_GC_send_SIB1_broadcast_request: Header send failure in GC-FIFO\n"); - return bytes_wrote; - } - - // send sib1_flag - //bytes_wrote += rtf_put(gpriv->sap[NAS_GC_SAPI], &sib1_flag, 1); -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),(unsigned char *)&sib1_flag, 1); - count += 1; - bytes_wrote = count; -#else - bytes_wrote += nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], (unsigned char *)&sib1_flag, 1); -#endif - - if (bytes_wrote!=p->length+1) { - printk("nasrg_ASCTL_GC_send_SIB1_broadcast_request: sib1_flag send failure in GC-FIFO\n"); - return bytes_wrote; - } - - // send data - //bytes_wrote += rtf_put(gpriv->sap[NAS_GC_SAPI], skb->data, skb->len); -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),skb->data, skb->len); - count += skb->len; - bytes_wrote = nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], xbuffer, count); -#else - bytes_wrote += nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], skb->data, skb->len); -#endif - - - if (bytes_wrote!=p->length+skb->len+1) { - printk("nasrg_ASCTL_GC_send_SIB1_broadcast_request: Data send failure in GC-FIFO\n"); - return bytes_wrote; - } - -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_GC_send_SIB1_broadcast_request - end \n"); -#endif - return bytes_wrote; -} - -//----------------------------------------------------------------------------- -// Encode MBMS_BEARER_ESTABLISH_REQ message -int nasrg_ASCTL_GC_send_mbms_bearer_establish_req(int mbms_ix ) -{ - //----------------------------------------------------------------------------- - struct nas_rg_gc_element *p; - int bytes_wrote = 0; - - p= (struct nas_rg_gc_element *)(gpriv->xbuffer); - p->type = MBMS_BEARER_ESTABLISH_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASMBMSBearerEstablishReq); - // - p->nasRGGCPrimitive.mbms_establish_req.mbms_serviceId = gpriv->mbms_rb[mbms_ix].serviceId; - p->nasRGGCPrimitive.mbms_establish_req.mbms_sessionId = gpriv->mbms_rb[mbms_ix].sessionId; - p->nasRGGCPrimitive.mbms_establish_req.mbms_rbId = gpriv->mbms_rb[mbms_ix].mbms_rbId; - p->nasRGGCPrimitive.mbms_establish_req.mbms_sapId = gpriv->mbms_rb[mbms_ix].sapi; - p->nasRGGCPrimitive.mbms_establish_req.mbms_QoSclass = gpriv->mbms_rb[mbms_ix].qos; - p->nasRGGCPrimitive.mbms_establish_req.mbms_duration = gpriv->mbms_rb[mbms_ix].duration; - gpriv->mbms_rb[mbms_ix].state = NAS_RB_ESTABLISHING; - // - //bytes_wrote = rtf_put(gpriv->sap[NAS_GC_SAPI], p, p->length); - bytes_wrote = nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], (unsigned char *)p, p->length); - - if (bytes_wrote==p->length) { -#ifdef NAS_DEBUG_GC - printk(" nasrg_ASCTL_GC_send_mbms_bearer_establish: MBMS_BEARER_ESTABLISH_REQ primitive sent successfully in GC-FIFO\n"); - printk(" ServiceId %d, RB_Id %d , qos class %d \n", - p->nasRGGCPrimitive.mbms_establish_req.mbms_serviceId, - p->nasRGGCPrimitive.mbms_establish_req.mbms_rbId, - p->nasRGGCPrimitive.mbms_establish_req.mbms_QoSclass); -#endif - } else { - printk("nasrg_ASCTL_GC_send_mbms_bearer_establish: Message sent failure in GC-FIFO\n"); - } - - return bytes_wrote; -} - -//----------------------------------------------------------------------------- -// HNN - Encode MBMS_BEARER_RELEASE_REQ message -int nasrg_ASCTL_GC_send_mbms_bearer_release_req(int mbms_ix) -{ - //----------------------------------------------------------------------------- - struct nas_rg_gc_element *p; - uint16_t classref=0; - int bytes_wrote = 0; - - p= (struct nas_rg_gc_element *)(gpriv->xbuffer); - - p->type = MBMS_BEARER_RELEASE_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASMBMSBearerReleaseReq); - // - p->nasRGGCPrimitive.mbms_release_req.mbms_serviceId = gpriv->mbms_rb[mbms_ix].serviceId; - p->nasRGGCPrimitive.mbms_release_req.mbms_sessionId = gpriv->mbms_rb[mbms_ix].sessionId; - p->nasRGGCPrimitive.mbms_release_req.mbms_rbId = gpriv->mbms_rb[mbms_ix].mbms_rbId; - //gpriv->mbms_rb[mbms_ix].state = NAS_RB_RELEASING; - // - //bytes_wrote = rtf_put(gpriv->sap[NAS_GC_SAPI], p, p->length); - bytes_wrote = nasrg_ASCTL_write(gpriv->sap[NAS_GC_SAPI], (unsigned char *)p, p->length); - - if (bytes_wrote==p->length) { -#ifdef NAS_DEBUG_GC - printk(" nasrg_ASCTL_GC_send_mbms_bearer_release: MBMS_BEARER_RELEASE_REQ primitive sent successfully in GC-FIFO\n"); - printk(" ServiceId %d, RB_Id %d \n", p->nasRGGCPrimitive.mbms_establish_req.mbms_serviceId, p->nasRGGCPrimitive.mbms_establish_req.mbms_rbId); -#endif - // clean NASRG private structures - classref = (gpriv->mbmsclassifier[mbms_ix])->classref; - nasrg_CLASS_del_mbmsclassifier(mbms_ix, classref); - //nasrg_CLASS_flush_mbmsclassifier(); - //gpriv->mbms_rb[mbms_ix].state = NAS_IDLE; - memset (&(gpriv->mbms_rb[mbms_ix]),0,sizeof (struct rb_entity)); - } else { - printk("nasrg_ASCTL_GC_send_mbms_bearer_release: Message sent failure in GC-FIFO\n"); - } - - return bytes_wrote; -} - -//--------------------------------------------------------------------------- -// Confirm the establishment of a connection (DC channel) -int nasrg_ASCTL_DC_send_cx_establish_confirm(struct cx_entity *cx, uint8_t response) -{ - //--------------------------------------------------------------------------- - struct nas_rg_dc_element *p; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_cx_establish - begin \n"); -#endif - - if (!cx) { - printk("nasrg_ASCTL_DC_send_cx_establish - input parameter cx is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - p= (struct nas_rg_dc_element *)(gpriv->xbuffer); - p->type = CONN_ESTABLISH_CNF; - p->length = NAS_TL_SIZE + sizeof(struct NASConnEstablishConf); - p->nasRGDCPrimitive.conn_establish_conf.localConnectionRef = cx->lcr; - p->nasRGDCPrimitive.conn_establish_conf.status = response; // can be ACCEPTED or FAILURE - p->nasRGDCPrimitive.conn_establish_conf.num_RBs = 0; // Hard coded in first step - // - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); - bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); - - if (bytes_wrote==p->length) { -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_cx_establish: CONN_ESTABLISH_CNF primitive sent successfully in DC-FIFO\n"); - printk(" lcr (Mobile_id) %u\n",p->nasRGDCPrimitive.conn_establish_conf.localConnectionRef); - printk(" Status %u\n",p->nasRGDCPrimitive.conn_establish_conf.status); -#endif - } else - printk("nasrg_ASCTL_DC_send_cx_establish: Message transmission failure to DC-FIFO\n"); - - return bytes_wrote; -} - -//--------------------------------------------------------------------------- -// Request the establishment of a radio bearer -int nasrg_ASCTL_DC_send_rb_establish_request(struct cx_entity *cx, struct rb_entity *rb) -{ - //--------------------------------------------------------------------------- - struct nas_rg_dc_element *p; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_rb_establish - begin \n"); -#endif - - if (!cx || !rb) { - printk("nasrg_ASCTL_DC_send_rb_establish - input parameter is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - switch(rb->state) { - case NAS_CX_CONNECTING: - case NAS_CX_CONNECTING_FAILURE: - case NAS_IDLE: - ++rb->retry; - rb->countimer=gpriv->timer_establishment; - - if (cx->state==NAS_CX_DCH) { - p= (struct nas_rg_dc_element *)(gpriv->xbuffer); - p->type = RB_ESTABLISH_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASrbEstablishReq); - p->nasRGDCPrimitive.rb_establish_req.localConnectionRef = cx->lcr; - p->nasRGDCPrimitive.rb_establish_req.rbId = rb->rab_id + (NAS_RB_MAX_NUM * cx->lcr); - p->nasRGDCPrimitive.rb_establish_req.QoSclass = rb->qos; - p->nasRGDCPrimitive.rb_establish_req.dscp = rb->dscp_ul; - // - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); - bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); - - if (bytes_wrote==p->length) { - rb->state=NAS_CX_CONNECTING; -#ifdef NAS_DEBUG_DC - printk(" nasrg_ASCTL_DC_send_rb_establish: RB_ESTABLISH_REQ primitive sent successfully in DC-FIFO\n"); - printk(" lcr (Mobile_id) %u\n",p->nasRGDCPrimitive.rb_establish_req.localConnectionRef); - printk(" Radio Bearer identification %u\n",p->nasRGDCPrimitive.rb_establish_req.rbId); - printk(" QoS %u\n",p->nasRGDCPrimitive.rb_establish_req.QoSclass); -#endif - } else { - rb->state=NAS_CX_CONNECTING_FAILURE; - printk("nasrg_ASCTL_DC_send_rb_establish: Message sent failure in DC-FIFO\n"); - } - - return bytes_wrote; - } else { - rb->state=NAS_CX_CONNECTING_FAILURE; - printk("nasrg_ASCTL_DC_send_rb_establish: Failure \n"); - return 0; - } - - default: - return -NAS_ERROR_NOTIDLE; - } -} - -//--------------------------------------------------------------------------- -// Request the release of a radio bearer -int nasrg_ASCTL_DC_send_rb_release_request(struct cx_entity *cx, struct rb_entity *rb) -{ - //--------------------------------------------------------------------------- - struct nas_rg_dc_element *p; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_rb_release - begin \n"); -#endif - - if (!cx || !rb) { - printk("nasrg_ASCTL_DC_send_rb_release - input parameter is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - switch (rb->state) { - case NAS_CX_RELEASING_FAILURE: - case NAS_CX_DCH: - p= (struct nas_rg_dc_element *)(gpriv->xbuffer); - p->type = RB_RELEASE_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASrbReleaseReq); - p->nasRGDCPrimitive.rb_release_req.localConnectionRef = cx->lcr; - p->nasRGDCPrimitive.rb_release_req.rbId = rb->rab_id + (NAS_RB_MAX_NUM * cx->lcr); - // - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); - bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); - - if (bytes_wrote) { - rb->state=NAS_IDLE; -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_rb_release: RB_RELEASE_REQ primitive sent successfully in DC-FIFO\n"); -#endif - } else { - ++rb->retry; - rb->countimer=gpriv->timer_release; - rb->state=NAS_CX_RELEASING_FAILURE; - printk("nasrg_ASCTL_DC_send_rb_release: Message sent failure in DC-FIFO\n"); - } - - return bytes_wrote; - - default: - return -NAS_ERROR_NOTCONNECTED; - } -} - -//----------------------------------------------------------------------------- -// Request the notification of a UE to joined or left services -int nasrg_ASCTL_DC_send_mbms_ue_notify_req(struct cx_entity *cx) -{ - //----------------------------------------------------------------------------- - struct nas_rg_dc_element *p; - int i; - int bytes_wrote = 0; - -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_mbms_ue_notify_req - begin \n"); -#endif - - if (!cx) { - printk("nasrg_ASCTL_DC_send_mbms_ue_notify_req - input parameter is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - p= (struct nas_rg_dc_element *)(gpriv->xbuffer); - p->type = MBMS_UE_NOTIFY_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASMBMSUENotifyReq); - // - p->nasRGDCPrimitive.mbms_ue_notify_req.localConnectionRef = cx->lcr; - - // joined/left services are lists of MAX_MBMS_SERVICES - // -1 means the end of the list - for (i = 0; i < MAX_MBMS_SERVICES; i++) { - p->nasRGDCPrimitive.mbms_ue_notify_req.joined_services[i].mbms_serviceId = (nasMBMSServiceId_t)cx->requested_joined_services[i]; - p->nasRGDCPrimitive.mbms_ue_notify_req.left_services[i].mbms_serviceId = (nasMBMSServiceId_t)cx->requested_left_services[i]; - } - - // - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); - bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); - - if (bytes_wrote==p->length) { -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_mbms_ue_notify_req: MBMS_UE_NOTIFY_REQ primitive sent successfully in DC-FIFO\n"); - printk(" lcr (Mobile_id) %u\n",p->nasRGDCPrimitive.mbms_ue_notify_req.localConnectionRef); - printk(" joined service %d, left service %d\n",cx->requested_joined_services[0], cx->requested_left_services[0] ); -#endif - } else - printk("nasrg_ASCTL_DC_send_mbms_ue_notify_req: Message transmission failure to DC-FIFO\n"); - - return bytes_wrote; -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (DC SAP) -void nasrg_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - struct nas_rg_dc_element *p; - int bytes_wrote = 0; -#ifdef PDCP_USE_NETLINK - unsigned char xbuffer[NAS_MESSAGE_MAXLEN]; - int count=0; -#endif - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_sig_data - begin \n"); -#endif - - if (!skb || !gc || !cx) { - printk("nasrg_ASCTL_DC_send_sig_data - input parameter is NULL \n"); - return; - } - - // End debug information - if (cx->state!=NAS_CX_DCH) { - printk("nasrg_ASCTL_DC_send_sig_data: Not connected, so the message is dropped\n"); - ++gpriv->stats.tx_dropped; - return; - } - - p = (struct nas_rg_dc_element *)(gpriv->xbuffer); - p->type = DATA_TRANSFER_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASDataReq); - p->nasRGDCPrimitive.data_transfer_req.localConnectionRef = cx->lcr; - p->nasRGDCPrimitive.data_transfer_req.priority = NAS_SIG_SRB3; - p->nasRGDCPrimitive.data_transfer_req.nasDataLength = skb->len; - // - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); -#ifdef PDCP_USE_NETLINK - memcpy(xbuffer,(unsigned char *)p, p->length); - count = p->length; - bytes_wrote = count; -#else - bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); -#endif - - if (bytes_wrote!=p->length) { - printk("nasrg_ASCTL_DC_send_sig_data: Header sent failure in DC-FIFO\n"); - return; - } - - //bytes_wrote += rtf_put(cx->sap[NAS_DC_INPUT_SAPI], skb->data, skb->len); -#ifdef PDCP_USE_NETLINK - memcpy(&(xbuffer[count]),(unsigned char *)skb->data, skb->len); - count += skb->len; - bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], xbuffer, count); -#else - bytes_wrote += nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)skb->data, skb->len); -#endif - - if (bytes_wrote!=p->length+skb->len) { - printk("nasrg_ASCTL_DC_send_sig_data: Data sent failure in DC-FIFO\n"); - return; - } - - gpriv->stats.tx_bytes += skb->len; - gpriv->stats.tx_packets ++; -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_sig_data - end \n"); -#endif -} - -//--------------------------------------------------------------------------- -// Confirm the establishment of a connection (DC channel) -int nasrg_ASCTL_DC_send_eNBmeasurement_req(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - struct nas_rg_dc_element *p; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_eNBmeasurement_req - begin \n"); -#endif - - if (!cx) { - printk("nasrg_ASCTL_DC_send_eNBmeasurement_req - input parameter cx is NULL \n"); - return NAS_ERROR_NOTCORRECTVALUE; - } - - // End debug information - p= (struct nas_rg_dc_element *)(gpriv->xbuffer); - p->type = ENB_MEASUREMENT_REQ; - p->length = NAS_TL_SIZE + sizeof(struct NASENbMeasureReq); - p->nasRGDCPrimitive.eNBmeasurement_req.cell_id = cx->cellid; - // - //bytes_wrote = rtf_put(cx->sap[NAS_DC_INPUT_SAPI], p, p->length); - bytes_wrote = nasrg_ASCTL_write(cx->sap[NAS_DC_INPUT_SAPI], (unsigned char *)p, p->length); - - if (bytes_wrote==p->length) { -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_send_eNBmeasurement_req: ENB_MEASUREMENT_REQ primitive sent successfully in DC-FIFO\n"); - printk(" cell_id %u\n",p->nasRGDCPrimitive.eNBmeasurement_req.cell_id); -#endif - } else - printk("nasrg_ASCTL_DC_send_eNBmeasurement_req: Message transmission failure to DC-FIFO\n"); - - return bytes_wrote; -} - -/*************************************************************************** - Reception side - ***************************************************************************/ - -//--------------------------------------------------------------------------- -// Decode CONN_ESTABLISH_IND message from RRC -void nasrg_ASCTL_DC_decode_cx_establish_ind(struct cx_entity *cx, struct nas_rg_dc_element *p) -{ - //--------------------------------------------------------------------------- - int i; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_cx_establish - begin \n"); -#endif - - if (!cx || !p) { - printk("nasrg_ASCTL_DC_decode_cx_establish - input parameter is NULL \n"); - return; - } - - // End debug information - if (nasrg_ASCTL_DC_send_cx_establish_confirm(cx, ACCEPTED)>0) { - nasrg_TOOL_imei2iid(p->nasRGDCPrimitive.conn_establish_ind.InterfaceIMEI, (uint8_t *)cx->iid6); - cx->iid4=97; // A AUTOMATISER - cx->lcr = p->nasRGDCPrimitive.conn_establish_ind.localConnectionRef; - cx->state=NAS_CX_DCH; -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_cx_establish: CONN_ESTABLISH_IND reception\n"); - printk(" primitive length %d\n",p->length); - printk(" Local Connection reference %d\n",p->nasRGDCPrimitive.conn_establish_ind.localConnectionRef); - printk(" IMEI "); - - for (i=0; i<14; ++i) - printk("%u",p->nasRGDCPrimitive.conn_establish_ind.InterfaceIMEI[i]); - - printk(" state "); - nasrg_TOOL_print_state(cx->state); -#endif - } -} - -//--------------------------------------------------------------------------- -// Decode CONN_RELEASE_IND message from RRC -void nasrg_ASCTL_DC_decode_cx_release_ind(struct cx_entity *cx, struct nas_rg_dc_element *p) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_cx_release - begin \n"); -#endif - - if (!cx || !p) { - printk("nasrg_ASCTL_DC_decode_cx_release - input parameter is NULL \n"); - return; - } - - // End debug information - cx->state=NAS_IDLE; - cx->iid4=0; - nasrg_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); - nasrg_COMMON_flush_rb(cx); - nasrg_CLASS_flush_sclassifier(cx); -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_cx_release: CONN_RELEASE_IND reception\n"); - printk(" Primitive length %u\n",p->length); - printk(" Local Connection reference %u\n",p->nasRGDCPrimitive.conn_release_ind.localConnectionRef); - printk(" Release cause %u\n",p->nasRGDCPrimitive.conn_release_ind.releaseCause); - nasrg_TOOL_print_state(cx->state); -#endif -} - -//--------------------------------------------------------------------------- -// Decode CONN_LOSS_IND message from RRC -void nasrg_ASCTL_DC_decode_cx_loss_ind(struct cx_entity *cx, struct nas_rg_dc_element *p) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_cx_loss - begin \n"); -#endif - - if (!cx || !p) { - printk("nasrg_ASCTL_DC_decode_cx_loss - input parameter is NULL \n"); - return; - } - - // End debug information - cx->state = NAS_IDLE; - cx->iid4=0; - nasrg_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)cx->iid6); - nasrg_COMMON_flush_rb(cx); -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_cx_loss: CONN_LOSS_IND reception\n"); - printk(" Primitive length %u\n",(int)(p->length)); - printk(" Local Connection reference %u\n",p->nasRGDCPrimitive.conn_loss_ind.localConnectionRef); - nasrg_TOOL_print_state(cx->state); -#endif -} -//--------------------------------------------------------------------------- -// Decode RB_ESTABLISH_CNF message from RRC -void nasrg_ASCTL_DC_decode_rb_establish_cnf(struct cx_entity *cx, struct nas_rg_dc_element *p) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - int rb_id; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_rb_establish - begin \n"); -#endif - - if (!cx || !p) { - printk("nasrg_ASCTL_DC_decode_rb_establish - input parameter is NULL \n"); - return; - } - - // End debug information - rb_id = p->nasRGDCPrimitive.rb_establish_conf.rbId; - rb=nasrg_COMMON_search_rb(cx, rb_id - (NAS_RB_MAX_NUM * cx->lcr)); - - // - if (rb!=NULL) { - if (rb->state==NAS_CX_CONNECTING) { -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_rb_establish: RB_ESTABLISH_CNF received\n"); - printk(" Primitive length %u\n", p->length); - printk(" Local Connection reference %u\n",p->nasRGDCPrimitive.rb_establish_conf.localConnectionRef); - printk(" RB Id %u\n",p->nasRGDCPrimitive.rb_establish_conf.rbId); - printk(" SAP Id %u\n",p->nasRGDCPrimitive.rb_establish_conf.sapId); - printk(" Status %u, Failure code %d, Cx state, RB state\n",p->nasRGDCPrimitive.rb_establish_conf.status, p->nasRGDCPrimitive.rb_establish_conf.fail_code); - nasrg_TOOL_print_state(cx->state); - nasrg_TOOL_print_state(rb->state); -#endif - - switch (p->nasRGDCPrimitive.rb_establish_conf.status) { - case ACCEPTED: - rb->state = NAS_CX_DCH; - rb->countimer=1; - break; - - case FAILURE: - printk("nasrg_ASCTL_DC_decode_rb_establish: RB_ESTABLISH_CNF rejected\n"); - rb->state = NAS_CX_CONNECTING_FAILURE; - //delete rb - break; - - default: - printk("nasrg_ASCTL_DC_decode_rb_establish: RB_ESTABLISH_CNF reception, invalid status\n"); - } - } else - printk("nasrg_ASCTL_DC_decode_rb_establish: invalid state %u\n", cx->state); - } else - printk("nasrg_ASCTL_DC_decode_rb_establish: RB_ESTABLISH_CNF, No corresponding radio bearer\n"); -} - -//--------------------------------------------------------------------------- -// Decode DATA_TRANSFER_IND message from RRC -void nasrg_ASCTL_DC_decode_data_transfer_ind(struct cx_entity *cx, struct nas_rg_dc_element *p, char *buffer) -{ - //--------------------------------------------------------------------------- - uint8_t nasrg_data[10]; - unsigned int nas_length; - char data_type; - int bytes_read=0; - unsigned int peer_command; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_data_transfer - begin \n"); -#endif - - if (!cx || !p) { - printk("nasrg_ASCTL_DC_decode_data_transfer - input parameter is NULL \n"); - return; - } - - // End debug information - - bytes_read=p->length; - // Get first character - nas_length = (p->nasRGDCPrimitive.data_transfer_ind.nasDataLength) -1; -#ifndef PDCP_USE_NETLINK - bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], &data_type, 1); -#else - memcpy (&data_type, (char *)(&buffer[bytes_read]), 1); - bytes_read ++; -#endif - - //check if peer message - if (data_type =='A') { - // receive in a skbuff - //nasrg_COMMON_receive((p->length) + 1, nas_length, cx->sap[NAS_DC_OUTPUT_SAPI]); // original -#ifndef PDCP_USE_NETLINK - //void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); - // data_buffer is NULL because FIFO should be read directly in the skbuff (LITE has an intermediary buffer) - nasrg_COMMON_receive((p->length) + 1, nas_length, NULL, 2, cx->sap[NAS_DC_OUTPUT_SAPI]); -#else - //nasrg_COMMON_receive((p->length) + 1, nas_length, (unsigned char *)p+p->length+1, 2, 0); - nasrg_COMMON_receive((p->length) + 1, nas_length, (unsigned char *)(&buffer[bytes_read]), 2, 0); -#endif - } else { - // if FIFO, empty remaining data -#ifndef PDCP_USE_NETLINK - bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], (gpriv->rbuffer)+ (p->length), nas_length); -#endif - - if (data_type=='Z') { -#ifndef PDCP_USE_NETLINK - memcpy (&nasrg_data, (char *)(gpriv->rbuffer)+ (p->length), 10); -#else - memcpy (&nasrg_data, (char *)(&buffer[bytes_read]), 10); -#endif - peer_command = (int)nasrg_data[0]; - printk("nasrg_ASCTL_DC_decode_data_transfer: Received peer message %d %d \n", nasrg_data[0], peer_command); - nasrg_TOOL_print_buffer(nasrg_data, 10); - - if (nasrg_data[0]== NAS_CMD_OPEN_RB) { - // open radio bearer - printk("nasrg_ASCTL_DC_decode_data_transfer: Opening Default Radio Bearer\n"); - nasrg_ASCTL_start_default_rb(cx); - } else if (nasrg_data[0]== NAS_CMD_ENTER_SLEEP) { - printk("nasrg_ASCTL_DC_decode_data_transfer: Entering Sleep Mode\n"); - cx->state = NAS_CX_RELEASING; - } else if (nasrg_data[0]== NAS_CMD_LEAVE_SLEEP) { - printk("nasrg_ASCTL_DC_decode_data_transfer: Leaving Sleep Mode\n"); - cx->state = NAS_CX_DCH; - } else { - printk("\n\nnasrg_ASCTL_DC_decode_data_transfer: Unknown peer command\n"); - } - } else - printk("nasrg_ASCTL_DC_decode_data_transfer: Error during reception of the message - Dropped\n"); - } - -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_data_transfer: DATA_TRANSFER_IND reception\n"); - printk(" Primitive length %u\n", p->length); - printk(" Local Connection reference %u\n",p->nasRGDCPrimitive.data_transfer_ind.localConnectionRef); - printk(" Data Length %u\n", p->nasRGDCPrimitive.data_transfer_ind.nasDataLength); - nasrg_TOOL_print_state(cx->state); -#endif -} - -//--------------------------------------------------------------------------- -// Decode MBMS_BEARER_ESTABLISH_CNF message from RRC -void nasrg_ASCTL_DC_decode_mbms_bearer_establish_cnf(struct nas_rg_dc_element *p) -{ - //--------------------------------------------------------------------------- - int mbms_ix; - int rb_id; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_mbms_bearer_establish - begin \n"); -#endif - - if (!p) { - printk("nasrg_ASCTL_DC_decode_mbms_bearer_establish - input parameter is NULL \n"); - return; - } - - // End debug information - rb_id = p->nasRGDCPrimitive.mbms_establish_cnf.rbId; - mbms_ix = 0; // A revoir - find using cnxid... - - if (rb_id == gpriv->mbms_rb[mbms_ix].mbms_rbId) { - switch (p->nasRGDCPrimitive.mbms_establish_cnf.status) { - case ACCEPTED: - gpriv->mbms_rb[mbms_ix].state = NAS_CX_DCH; - gpriv->mbms_rb[mbms_ix].rab_id = gpriv->mbms_rb[mbms_ix].mbms_rbId; - nasrg_ASCTL_start_mbmsclassifier(mbms_ix,&(gpriv->mbms_rb[mbms_ix])); - break; - - case FAILURE: - printk("nasrg_ASCTL_DC_decode_mbms_bearer_establish: MBMS_BEARER_ESTABLISH_CNF rejected\n"); - gpriv->mbms_rb[mbms_ix].state = NAS_CX_CONNECTING_FAILURE; //supprimer l'entree - break; - - default: - printk("nasrg_ASCTL_DC_decode_mbms_bearer_establish: MBMS_BEARER_ESTABLISH_CNF reception, invalid status\n"); - } - } else - printk(" nasrg_ASCTL_DC_decode_mbms_bearer_establish: invalid RB_Id %d\n", rb_id); - -#ifdef NAS_DEBUG_DC - printk(" nasrg_ASCTL_DC_decode_mbms_bearer_establish: MBMS_BEARER_ESTABLISH_CNF reception\n"); - printk(" Primitive length %u\n",p->length); - printk(" rb_id %d, status %d\n",p->nasRGDCPrimitive.mbms_establish_cnf.rbId, p->nasRGDCPrimitive.mbms_establish_cnf.status); - nasrg_TOOL_print_state(gpriv->mbms_rb[mbms_ix].state); -#endif -} - -//--------------------------------------------------------------------------- -// Decode MBMS_UE_NOTIFY_CNF message from RRC -void nasrg_ASCTL_DC_decode_mbms_ue_notify_cnf(struct cx_entity *cx, struct nas_rg_dc_element *p) -{ - //--------------------------------------------------------------------------- - int i, j, k; - - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_mbms_ue_notify - begin \n"); -#endif - - if (!cx || !p) { - printk("nasrg_ASCTL_DC_decode_mbms_ue_notify - input parameter is NULL \n"); - return; - } - - // End debug information - if (p->nasRGDCPrimitive.mbms_ue_notify_cnf.mbmsStatus == ACCEPTED) { - for (i = 0; i<NASRG_MBMS_SVCES_MAX; i++) { - if (cx->requested_joined_services[i] >=0) { - for (j = 0; j<NASRG_MBMS_SVCES_MAX; j++) { - if (cx->joined_services[j] ==-1) { - cx->joined_services[j]= cx->requested_joined_services[i]; - cx->requested_joined_services[i]=-1; - break; - } - } - } - - if (cx->requested_left_services[i] >=0) { - for (k = 0; k<NASRG_MBMS_SVCES_MAX; k++) { - if (cx->joined_services[k] == cx->requested_left_services[i]) { - cx->joined_services[k]=-1; - cx->requested_left_services[i]=-1; - break; - } - } - } - } - } - -#ifdef NAS_DEBUG_DC - printk(" nasrg_ASCTL_DC_decode_mbms_ue_notify: MBMS_UE_NOTIFY_CNF reception\n"); - printk(" Primitive length %u\n",p->length); - printk(" Local Connection reference %u\n",p->nasRGDCPrimitive.mbms_ue_notify_cnf.localConnectionRef); - printk(" MBMS Status: %d\n", p->nasRGDCPrimitive.mbms_ue_notify_cnf.mbmsStatus); - printk(" UE services currently joined \n"); - - for (i = 0; i<NASRG_MBMS_SVCES_MAX; i++) - printk ("%d * ", cx->joined_services[i]); - - nasrg_TOOL_print_state(cx->state); -#endif -} -/* - msgToBuild->nasRgPrimitive.dc_sap_prim.nasRGDCPrimitive.eNBmeasurement_ind.cell_id = protocol_bs->rrc.rg_cell_id; - // next values are temp hard coded, to be replaced by real values - msgToBuild->nasRgPrimitive.dc_sap_prim.nasRGDCPrimitive.eNBmeasurement_ind.num_UEs = num_connected_UEs; - for (ix=0; ix<ralpriv->num_connected_UEs; ix++){ - msgToBuild->nasRgPrimitive.dc_sap_prim.nasRGDCPrimitive.eNBmeasurement_ind.measures[ix].rlcBufferOccupancy = 100 - (30*ix); - msgToBuild->nasRgPrimitive.dc_sap_prim.nasRGDCPrimitive.eNBmeasurement_ind.measures[ix].scheduledPRB = 500 - (200*ix); - msgToBuild->nasRgPrimitive.dc_sap_prim.nasRGDCPrimitive.eNBmeasurement_ind.measures[ix].totalDataVolume = 640000 + (160000*ix); - } - msgToBuild->nasRgPrimitive.dc_sap_prim.nasRGDCPrimitive.eNBmeasurement_ind.totalNumPRBs = 1000; - -*/ -//--------------------------------------------------------------------------- -// Decode ENB_MEASUREMENT_IND message from RRC -void nasrg_ASCTL_DC_decode_eNBmeasurement_ind(struct nas_rg_dc_element *p) -{ - //--------------------------------------------------------------------------- - uint8_t i; - // Start debug information -#ifdef NAS_DEBUG_DC - printk("nasrg_ASCTL_DC_decode_eNBmeasurement_ind - begin \n"); -#endif - - if (!p) { - printk("nasrg_ASCTL_DC_decode_eNBmeasurement_ind - input parameter p is NULL \n"); - return; - } - - // End debug information -#ifdef NAS_DEBUG_DC_DETAIL - printk(" nasrg_ASCTL_DC_decode_eNBmeasurement_ind : ENB_MEASUREMENT_IND reception\n"); - printk(" Measured Cell: %u\n", p->nasRGDCPrimitive.eNBmeasurement_ind.cell_id); - printk(" Number of Connected Mobiles: %u\n", p->nasRGDCPrimitive.eNBmeasurement_ind.num_UEs); - - for (i=0; i<p->nasRGDCPrimitive.eNBmeasurement_ind.num_UEs; ++i) { - printk(" UE[%u]: rlcBufferOccupancy %u, scheduledPRB: %u, totalDataVolume: %u\n", i, - p->nasRGDCPrimitive.eNBmeasurement_ind.measures[i].rlcBufferOccupancy, - p->nasRGDCPrimitive.eNBmeasurement_ind.measures[i].scheduledPRB, - p->nasRGDCPrimitive.eNBmeasurement_ind.measures[i].totalDataVolume); - } - - printk(" Total number of PRBs: %u\n", p->nasRGDCPrimitive.eNBmeasurement_ind.totalNumPRBs); -#endif - // store Measures - gpriv->measured_cell_id = p->nasRGDCPrimitive.eNBmeasurement_ind.cell_id; - gpriv->num_UEs = p->nasRGDCPrimitive.eNBmeasurement_ind.num_UEs; - - for (i=0; i<gpriv-> num_UEs; ++i) { - gpriv->rlcBufferOccupancy[i] = p->nasRGDCPrimitive.eNBmeasurement_ind.measures[i].rlcBufferOccupancy; - gpriv->scheduledPRB[i] += p->nasRGDCPrimitive.eNBmeasurement_ind.measures[i].scheduledPRB; - gpriv->totalDataVolume[i] += p->nasRGDCPrimitive.eNBmeasurement_ind.measures[i].totalDataVolume; - } - - gpriv->totalNumPRBs += p->nasRGDCPrimitive.eNBmeasurement_ind.totalNumPRBs; -} - -//--------------------------------------------------------------------------- -// Check if anything in DC FIFO and process it (RG Finite State Machine) -int nasrg_ASCTL_DC_receive(struct cx_entity *cx, char *buffer) -{ - //--------------------------------------------------------------------------- - int bytes_read=0; - - // Start debug information -#ifdef NAS_DEBUG_DC_DETAIL - printk("nasrg_ASCTL_DC_receive - begin \n"); -#endif - - if (!cx) { - printk("nasrg_ASCTL_DC_receive - input parameter cx is NULL \n"); - return 0; - } - - // End debug information - -#ifndef PDCP_USE_NETLINK - bytes_read = rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI] , gpriv->rbuffer, NAS_TL_SIZE); -#else - bytes_read = NAS_TL_SIZE; -#endif - - if (bytes_read>0) { - struct nas_rg_dc_element *p; -#ifndef PDCP_USE_NETLINK - p= (struct nas_rg_dc_element *)(gpriv->rbuffer); - //get the rest of the primitive - bytes_read += rtf_get(cx->sap[NAS_DC_OUTPUT_SAPI], (uint8_t *)p+NAS_TL_SIZE, p->length-NAS_TL_SIZE); - - if (bytes_read!=p->length) { - printk("nasrg_ASCTL_DC_receive: Problem while reading primitive's header\n"); - return bytes_read; - } - -#else - p= (struct nas_rg_dc_element *)(buffer); - bytes_read=p->length; -#endif - - switch (p->type) { - case CONN_ESTABLISH_IND : - if (p->nasRGDCPrimitive.conn_establish_ind.localConnectionRef!=cx->lcr) - printk("nasrg_ASCTL_DC_receive: CONN_ESTABLISH_IND reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.conn_establish_ind.localConnectionRef); - else { - switch(cx->state) { - case NAS_IDLE: - nasrg_ASCTL_DC_decode_cx_establish_ind(cx,p); - break; - - default: - printk("nasrg_ASCTL_DC_receive: CONN_ESTABLISH_IND reception, invalid state %u\n", cx->state); - } - } - - break; - - case CONN_RELEASE_IND : - if (p->nasRGDCPrimitive.conn_release_ind.localConnectionRef!=cx->lcr) - printk("nasrg_ASCTL_DC_receive: CONN_RELEASE_IND reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.conn_release_ind.localConnectionRef); - else { - switch(cx->state) { - case NAS_CX_DCH: - nasrg_ASCTL_DC_decode_cx_release_ind(cx,p); - break; - - default: - printk("nasrg_ASCTL_DC_receive: CONN_RELEASE_IND reception, invalid state %u\n", cx->state); - } - } - - break; - - case CONN_LOSS_IND: - if (p->nasRGDCPrimitive.conn_loss_ind.localConnectionRef!=cx->lcr) - printk("nasrg_ASCTL_DC_receive: CONN_LOSS_IND reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.conn_loss_ind.localConnectionRef); - else { - switch(cx->state) { - case NAS_CX_DCH: - nasrg_ASCTL_DC_decode_cx_loss_ind(cx,p); - break; - - default: - printk("nasrg_ASCTL_DC_receive: CONN_LOSS_IND reception, invalid state %u\n", cx->state); - } - } - - break; - - case RB_ESTABLISH_CNF: - if (p->nasRGDCPrimitive.rb_establish_conf.localConnectionRef!=cx->lcr) - printk("nasrg_ASCTL_DC_receive: RB_ESTABLISH_CNF reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.rb_establish_conf.localConnectionRef); - else { - switch(cx->state) { - case NAS_CX_DCH: - nasrg_ASCTL_DC_decode_rb_establish_cnf(cx,p); -#ifdef NAS_AUTO_MBMS - nasrg_ASCTL_start_default_ue_notification(cx); -#endif - break; - - default: - printk("nasrg_ASCTL_DC_receive: RB_ESTABLISH_CNF reception, invalid state %u\n", cx->state); - } - } - - break; - - case DATA_TRANSFER_IND: - if (p->nasRGDCPrimitive.data_transfer_ind.localConnectionRef!=cx->lcr) - printk("nasrg_ASCTL_DC_receive: DATA_TRANSFER_IND reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.rb_establish_conf.localConnectionRef); - else { - switch(cx->state) { - case NAS_CX_DCH: - case NAS_CX_RELEASING: - nasrg_ASCTL_DC_decode_data_transfer_ind(cx,p,buffer); - break; - - default: - printk("nasrg_ASCTL_DC_receive: DATA_TRANSFER_IND reception, invalid state %u\n", cx->state); - } - } - - break; - - // Temp - Should be in uplink GC-SAP - case MBMS_BEARER_ESTABLISH_CNF: - // if (p->nasRGDCPrimitive.mbms_ue_notify_cnf.localConnectionRef!=cx->lcr) - // printk("nasrg_ASCTL_DC_receive: MBMS_BEARER_ESTABLISH_CNF reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.rb_establish_conf.localConnectionRef); - // else - nasrg_ASCTL_DC_decode_mbms_bearer_establish_cnf(p); - break; - - case MBMS_UE_NOTIFY_CNF: - if (p->nasRGDCPrimitive.mbms_ue_notify_cnf.localConnectionRef!=cx->lcr) - printk("nasrg_ASCTL_DC_receive: MBMS_UE_NOTIFY_CNF reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.rb_establish_conf.localConnectionRef); - else { - switch(cx->state) { - case NAS_CX_DCH: - nasrg_ASCTL_DC_decode_mbms_ue_notify_cnf(cx,p); - /* //Temp - nasrg_ASCTL_start_default_mbms_service();*/ - break; - - default: - printk("nasrg_ASCTL_DC_receive: MBMS_UE_NOTIFY_CNF reception, invalid state %u\n", cx->state); - } - } - - break; - - // Temp - Should be in uplink GC-SAP - case ENB_MEASUREMENT_IND : - // if (p->nasRGDCPrimitive.eNBmeasurement_ind.localConnectionRef!=cx->lcr) - // printk("nasrg_ASCTL_DC_receive: ENB_MEASUREMENT_IND reception, Local connection reference not correct %u\n", p->nasRGDCPrimitive.eNBmeasurement_ind.localConnectionRef); - // else - nasrg_ASCTL_DC_decode_eNBmeasurement_ind(p); - break; - - default : - printk("nasrg_ASCTL_DC_receive: Invalid message received\n"); - } - } - - return bytes_read; -} - -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_classifier.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_classifier.c deleted file mode 100644 index 4c0cf8aa1ed4e9da01083b0143ee05f13a9fe3fe..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_classifier.c +++ /dev/null @@ -1,1139 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_classifier.c -* \brief Flow classification functions for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#include "nasrg_variables.h" -#include "nasrg_proto.h" - -#include <net/ip6_fib.h> -#include <net/route.h> - -#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) -#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) -#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000) -#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) - -/* Address to accept any incoming messages. */ -#define INADDR_ANY ((unsigned long int) 0x00000000) - -#define NIPADDR(addr) \ - (uint8_t)(addr & 0x000000FF), \ - (uint8_t)((addr & 0x0000FF00) >> 8), \ - (uint8_t)((addr & 0x00FF0000) >> 16), \ - (uint8_t)((addr & 0xFF000000) >> 24) - -#define NIP6ADDR(addr) \ - ntohs((addr)->s6_addr16[0]), \ - ntohs((addr)->s6_addr16[1]), \ - ntohs((addr)->s6_addr16[2]), \ - ntohs((addr)->s6_addr16[3]), \ - ntohs((addr)->s6_addr16[4]), \ - ntohs((addr)->s6_addr16[5]), \ - ntohs((addr)->s6_addr16[6]), \ - ntohs((addr)->s6_addr16[7]) - - -#define IN6_IS_ADDR_UNSPECIFIED(a) \ - (((__const uint32_t *) (a))[0] == 0 \ - && ((__const uint32_t *) (a))[1] == 0 \ - && ((__const uint32_t *) (a))[2] == 0 \ - && ((__const uint32_t *) (a))[3] == 0) - -#define IN6_ARE_ADDR_MASKED_EQUAL(a,b,m) \ - (((((__const uint32_t *) (a))[0] & (((__const uint32_t *) (m))[0])) == (((__const uint32_t *) (b))[0] & (((__const uint32_t *) (m))[0]))) \ - && ((((__const uint32_t *) (a))[1] & (((__const uint32_t *) (m))[1])) == (((__const uint32_t *) (b))[1] & (((__const uint32_t *) (m))[1]))) \ - && ((((__const uint32_t *) (a))[2] & (((__const uint32_t *) (m))[2])) == (((__const uint32_t *) (b))[2] & (((__const uint32_t *) (m))[2]))) \ - && ((((__const uint32_t *) (a))[3] & (((__const uint32_t *) (m))[3])) == (((__const uint32_t *) (b))[3] & (((__const uint32_t *) (m))[3])))) - -#define IN_ARE_ADDR_MASKED_EQUAL(a,b,m) \ - (((((__const uint8_t *) (a))[0] & (((__const uint8_t *) (m))[0])) == (((__const uint8_t *) (b))[0] & (((__const uint8_t *) (m))[0]))) \ - && ((((__const uint8_t *) (a))[1] & (((__const uint8_t *) (m))[1])) == (((__const uint8_t *) (b))[1] & (((__const uint8_t *) (m))[1]))) \ - && ((((__const uint8_t *) (a))[2] & (((__const uint8_t *) (m))[2])) == (((__const uint8_t *) (b))[2] & (((__const uint8_t *) (m))[2]))) \ - && ((((__const uint8_t *) (a))[3] & (((__const uint8_t *) (m))[3])) == (((__const uint8_t *) (b))[3] & (((__const uint8_t *) (m))[3])))) - -//--------------------------------------------------------------------------- -void nasrg_create_mask_ipv6_addr(struct in6_addr *masked_addrP, int prefix_len) -{ - //--------------------------------------------------------------------------- - int u6_addr8_index; - int u6_addr1_index; - int index; - - masked_addrP->s6_addr32[0] = 0xFFFFFFFF; - masked_addrP->s6_addr32[1] = 0xFFFFFFFF; - masked_addrP->s6_addr32[2] = 0xFFFFFFFF; - masked_addrP->s6_addr32[3] = 0xFFFFFFFF; - - u6_addr8_index = prefix_len >> 3; - u6_addr1_index = prefix_len & 0x07; - - for (index = u6_addr8_index + 1; index < 16; index++) { - masked_addrP->s6_addr[index] = 0; - } - - if (u6_addr1_index > 0) { - masked_addrP->s6_addr[u6_addr8_index] = 0xFF << (8-u6_addr1_index); - } - -#ifdef NAS_DEBUG_CLASS - //printk("nasrg_create_mask_ipv6_addr: MASK = %X:%X:%X:%X:%X:%X:%X:%X\n",NIP6ADDR(masked_addrP)); -#endif -} -//--------------------------------------------------------------------------- -void nasrg_create_mask_ipv4_addr(struct in_addr *masked_addrP, int prefix_len) -{ - //--------------------------------------------------------------------------- - if (prefix_len > 32) { - prefix_len = 32; - } - - masked_addrP->s_addr = 0xFFFFFFFF << (32 - prefix_len); -#ifdef NAS_DEBUG_CLASS - //printk("nasrg_create_mask_ipv4_addr: MASK = %d.%d.%d.%d\n",NIPADDR(masked_addrP)); -#endif - return; -} - -//--------------------------------------------------------------------------- -// Add a new classifier rule (send direction) -struct classifier_entity *nasrg_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_sclassifier: begin for dscp %d, classref %d\n", dscp,classref); -#endif - - if (cx==NULL) { - printk("nasrg_CLASS_add_sclassifier - input parameter cx is NULL \n"); - return NULL; - } - - //*** - for (gc=cx->sclassifier[dscp]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_sclassifier: classifier already exist for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_ATOMIC); - - if (gc==NULL) - return NULL; - - memset(gc, 0, sizeof(struct classifier_entity)); - gc->next=cx->sclassifier[dscp]; - gc->classref=classref; - cx->sclassifier[dscp]=gc; - ++cx->nsclassifier; - ++gpriv->next_sclassref; //increment send classref index - MW 15/01/07 -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_sclassifier: classifier created for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; -} - -//--------------------------------------------------------------------------- -// Add a new classifier rule (receive direction) -struct classifier_entity *nasrg_CLASS_add_rclassifier(uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_rclassifier: begin\n"); -#endif - - //*** - for (gc=gpriv->rclassifier[dscp]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_rclassifier: classifier already exist for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL); - - if (gc==NULL) - return NULL; - - gc->next=gpriv->rclassifier[dscp]; - gc->classref=classref; - gpriv->rclassifier[dscp]=gc; - ++gpriv->nrclassifier; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_rclassifier: classifier created for dscp %d, classref %d\n",dscp,classref); -#endif - return gc; -} - -//--------------------------------------------------------------------------- -// Add a new classifier rule (mbms direction) -struct classifier_entity *nasrg_CLASS_add_mbmsclassifier(int mbms_ix, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_mbmsclassifier: begin\n"); -#endif - - //*** - for (gc=gpriv->mbmsclassifier[mbms_ix]; gc!=NULL; gc=gc->next) { - if (gc->classref==classref) { -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_mbmsclassifier: classifier already exist for service %d, classref %d\n",mbms_ix,classref); -#endif - return gc; - } - } - - gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_ATOMIC); - - if (gc==NULL) - return NULL; - - gc->next=gpriv->mbmsclassifier[mbms_ix]; - gc->classref=classref; - gpriv->mbmsclassifier[mbms_ix]=gc; - ++gpriv->nmbmsclassifier; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_add_mbmsclassifier: classifier created for service index %d, classref %d\n",mbms_ix,classref); -#endif - return gc; -} - -//--------------------------------------------------------------------------- -void nasrg_CLASS_flush_sclassifier(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - uint8_t dscpi; - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_flush_sclassifier: begin\n"); -#endif - - if (cx==NULL) { - printk("nasrg_CLASS_flush_sclassifier - input parameter cx is NULL \n"); - return; - } - - //*** - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) { - for (gc=cx->sclassifier[dscpi]; gc!=NULL; gc=cx->sclassifier[dscpi]) { - cx->sclassifier[dscpi]=gc->next; - kfree(gc); - } - } - - cx->nsclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_flush_sclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -void nasrg_CLASS_flush_rclassifier() -{ - //--------------------------------------------------------------------------- - uint8_t dscpi; - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_flush_rclassifier: begin\n"); -#endif - - //*** - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) { - for (gc=gpriv->rclassifier[dscpi]; gc!=NULL; gc=gpriv->rclassifier[dscpi]) { - gpriv->rclassifier[dscpi]=gc->next; - kfree(gc); - } - } - - gpriv->nrclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_flush_rclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -void nasrg_CLASS_flush_mbmsclassifier() -{ - //--------------------------------------------------------------------------- - int mbmsi; - struct classifier_entity *gc; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_flush_mbmsclassifier: begin\n"); -#endif - - //*** - for (mbmsi=0; mbmsi<NASRG_MBMS_SVCES_MAX; ++mbmsi) { - for (gc=gpriv->mbmsclassifier[mbmsi]; gc!=NULL; gc=gpriv->mbmsclassifier[mbmsi]) { - gpriv->mbmsclassifier[mbmsi]=gc->next; - kfree(gc); - } - } - - gpriv->nmbmsclassifier=0; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_flush_mbmsclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (send direction) -void nasrg_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_del_sclassifier: begin\n"); -#endif - - if (cx==NULL) { - printk("nasrg_CLASS_del_sclassifier - input parameter cx is NULL \n"); - return; - } - - //*** - p=cx->sclassifier[dscp]; - - if (p==NULL) - return; - - if (p->classref==classref) { - cx->sclassifier[dscp]=p->next; - kfree(p); - --cx->nsclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --cx->nsclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_del_sclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (receive direction) -void nasrg_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_del_rclassifier: begin\n"); -#endif - //*** - p=gpriv->rclassifier[dscp]; - - if (p==NULL) - return; - - if (p->classref==classref) { - gpriv->rclassifier[dscp]=p->next; - kfree(p); - --gpriv->nrclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --gpriv->nrclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_del_rclassifier: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete a classifier rule (mbms direction) -void nasrg_CLASS_del_mbmsclassifier(int mbms_ix, uint16_t classref) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *p,*np; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_del_mbmsclassifier: begin\n"); -#endif - //*** - p=gpriv->mbmsclassifier[mbms_ix]; - - if (p==NULL) - return; - - if (p->classref==classref) { - gpriv->mbmsclassifier[mbms_ix]=p->next; - kfree(p); - --gpriv->nmbmsclassifier; - return; - } - - for (np=p->next; np!=NULL; p=np) { - if (np->classref==classref) { - p->next=np->next; - kfree(np); - --gpriv->nmbmsclassifier; - return; - } - } - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_del_mbmsclassifier: end\n"); -#endif -} - -/* ORIGINAL VERSION -//--------------------------------------------------------------------------- -// Search the entity with the IPv4 address 'addr' -struct cx_entity *nasrg_CLASS_cx4(struct sk_buff *skb){ -//--------------------------------------------------------------------------- - uint8_t cxi; - #ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx4: begin\n"); - #endif - cxi=0; - return gpriv->cx+cxi; -//#endif -}*/ - -//--------------------------------------------------------------------------- -// Search the entity with the IPv4 address 'addr' -struct cx_entity *nasrg_CLASS_cx4(struct sk_buff *skb, unsigned char dscp, int *paddr_type, unsigned char *cx_index) -{ - //--------------------------------------------------------------------------- - unsigned char cxi; - uint32_t daddr; - struct cx_entity *cx=NULL; - struct classifier_entity *pclassifier=NULL; - struct in_addr masked_addr; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx4: begin\n"); -#endif - - if (skb!=NULL) { - daddr = ((struct iphdr*)(skb_network_header(skb)))->daddr; - - if (daddr != INADDR_ANY) { -#ifdef NAS_DEBUG_CLASS - printk("SOURCE ADDR %d.%d.%d.%d",NIPADDR(ip_hdr(skb)->saddr)); - printk(" DEST ADDR %d.%d.%d.%d\n",NIPADDR(ip_hdr(skb)->daddr)); -#endif - - if (ipv4_is_multicast(ip_hdr(skb)->daddr)) { - // TO BE CHECKED - *paddr_type = NAS_IPV4_ADDR_MC_SIGNALLING; - } else { - if (ipv4_is_lbcast(ip_hdr(skb)->daddr)) { - // TO BE CHECKED - *paddr_type = NAS_IPV4_ADDR_BROADCAST; - } else { - if (IN_CLASSA(ip_hdr(skb)->daddr) || IN_CLASSB(ip_hdr(skb)->daddr) || IN_CLASSC(ip_hdr(skb)->daddr)) { - *paddr_type = NAS_IPV4_ADDR_UNICAST; - - for (cxi=*cx_index; cxi<NAS_CX_MAX; ++cxi) { - (*cx_index)++; - pclassifier = gpriv->cx[cxi].sclassifier[dscp]; - - while (pclassifier!=NULL) { - // verify that this is an IPv4 classifier - if ((pclassifier->version == NAS_VERSION_4) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - nasrg_create_mask_ipv4_addr(&masked_addr, pclassifier->dplen); - - if (IN_ARE_ADDR_MASKED_EQUAL(&ip_hdr(skb)->daddr, &(pclassifier->daddr.ipv4), &masked_addr)) { -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx4: IP MASK MATCHED: found cx %d: %d.%d.%d.%d/%d\n",cxi, NIPADDR(pclassifier->daddr.ipv4), pclassifier->dplen); -#endif - return &gpriv->cx[cxi]; - } - } - - // goto to next classification rule for the connection - pclassifier = pclassifier->next; - } - } - } else { - *paddr_type = NAS_IPV4_ADDR_UNKNOWN; - } - } - } - } - } - - return cx; -} - -/* ORIGINAL VERSION -//--------------------------------------------------------------------------- -// Search the entity corresponding to destination address in IPv6 header -struct cx_entity *nasrg_CLASS_cx6(struct sk_buff *skb, int* paddr_type, int* pmbms_ix){ -//--------------------------------------------------------------------------- - struct cx_entity * cx=NULL; - uint8_t cxi; - uint32_t mc_addr_hdr, uni_ifid1, uni_ifid2; - //int addr_type = NASRG_ADDR_UNKNOWN; - - #ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: begin\n"); - #endif - if (!skb){ - printk("nasrg_CLASS_cx6 - input parameter skb is NULL \n"); - return cx; - } - *paddr_type = NASRG_ADDR_UNKNOWN; - //mc_addr_hdr = ntohl(skb->nh.ipv6h->daddr.in6_u.u6_addr32[0]); - mc_addr_hdr = ntohl(ipv6_hdr(skb)->daddr.in6_u.u6_addr32[0]); - // First check if multicast [1st octet is FF] - if ((mc_addr_hdr & 0xFF000000) == 0xFF000000) { - // packet type according to the scope of the multicast packet - // we don't consider RPT bits in second octet [maybe done later if needed] - switch(mc_addr_hdr & 0x000F0000) { - case (0x00020000): - *paddr_type = NASRG_ADDR_MC_SIGNALLING; - #ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: multicast packet - signalling \n"); - #endif - break; - case (0x000E0000): - *paddr_type = NASRG_ADDR_MC_MBMS; - *pmbms_ix = 0; - cx=gpriv->cx; // MBMS associate to Mobile 0 - #ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: multicast packet - MBMS data \n"); - #endif - break; - default: - *paddr_type = NASRG_ADDR_UNKNOWN; - *pmbms_ix = NASRG_MBMS_SVCES_MAX; - } - // This is not multicast, so we should be able to identify the MT - }else{ - #ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: unicast packet\n"); - #endif - *paddr_type = NASRG_ADDR_UNICAST; - uni_ifid1 = ntohl(ipv6_hdr(skb)->daddr.in6_u.u6_addr32[2]); - uni_ifid2 = ntohl(ipv6_hdr(skb)->daddr.in6_u.u6_addr32[3]); - for (cxi=0; cxi<NAS_CX_MAX; cxi++){ - cx=gpriv->cx+cxi; - #ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_CLASS_cx6: Compared addresses \n"); - printk(" Daddr[2] %ul, Daddr[3] %ul\n", - ipv6_hdr(skb)->daddr.in6_u.u6_addr32[2],ipv6_hdr(skb)->daddr.in6_u.u6_addr32[3]); - printk(" ntohl Daddr[2] %ul, Daddr[3] %ul\n",uni_ifid1,uni_ifid2); - printk(" IIF[0] %ul, IIF[1] %ul\n",cx->iid6[0],cx->iid6[1]); - printk(" htonl IIF[0] %ul, IIF[1] %ul\n",htonl(cx->iid6[0]),htonl(cx->iid6[1])); - #endif - if (((cx->iid6[0] == uni_ifid1)&&(cx->iid6[1] == uni_ifid2)) - || ((htonl(cx->iid6[0]) == uni_ifid1)&&(htonl(cx->iid6[1]) == uni_ifid2))){ - return cx; - } - } - } - return cx; -}*/ - -//--------------------------------------------------------------------------- -// Search the entity with the IPv6 address 'addr' -// Navid: the ipv6 classifier is not fully tested -struct cx_entity *nasrg_CLASS_cx6(struct sk_buff *skb, unsigned char dscp, int *paddr_type, unsigned char *cx_index, int* pmbms_ix) -{ - //--------------------------------------------------------------------------- - uint8_t cxi; - struct cx_entity *cx = NULL; - struct classifier_entity *sclassifier= NULL; - uint32_t mc_addr_hdr; - struct in6_addr masked_addr; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: begin\n"); -#endif - - if (skb) { -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: SOURCE ADDR %X:%X:%X:%X:%X:%X:%X:%X",NIP6ADDR(&(ipv6_hdr(skb)->saddr))); - printk(" DEST ADDR %X:%X:%X:%X:%X:%X:%X:%X\n",NIP6ADDR(&(ipv6_hdr(skb)->daddr))); -#endif - mc_addr_hdr = ntohl(ipv6_hdr(skb)->daddr.in6_u.u6_addr32[0]); - - // First check if multicast [1st octet is FF] - if ((mc_addr_hdr & 0xFF000000) == 0xFF000000) { - // packet type according to the scope of the multicast packet - // we don't consider RPT bits in second octet [maybe done later if needed] - switch(mc_addr_hdr & 0x000F0000) { - case (0x00020000): - *paddr_type = NAS_IPV6_ADDR_MC_SIGNALLING; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: multicast packet - signalling \n"); -#endif - break; - - case (0x000E0000): - *paddr_type = NAS_IPV6_ADDR_MC_MBMS; - *pmbms_ix = 0; - cx=gpriv->cx; // MBMS associate to Mobile 0 -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: multicast packet - MBMS data \n"); -#endif - break; - - default: - printk("nasrg_CLASS_cx6: default multicast\n"); - *paddr_type = NAS_IPV6_ADDR_UNKNOWN; - *pmbms_ix = NASRG_MBMS_SVCES_MAX; - } - } else { - // This is not multicast, so we should be able to identify the MT - *paddr_type = NAS_IPV6_ADDR_UNICAST; - - for (cxi=*cx_index; cxi<NAS_CX_MAX; cxi++) { - //cxi = 0; - (*cx_index)++; - sclassifier = gpriv->cx[cxi].sclassifier[dscp]; - - while (sclassifier!=NULL) { - // verify that this is an IPv6 classifier - if ((sclassifier->version == NAS_VERSION_6) || (sclassifier->version == NAS_VERSION_DEFAULT)) { - /*LGif (IN6_IS_ADDR_UNSPECIFIED(&(sclassifier->daddr.ipv6))) { - printk("nas_CLASS_cx6: addr is null \n"); - sclassifier = sclassifier->next; - continue; - }*/ -#ifdef NAS_DEBUG_CLASS - printk("cx %d : DSCP %d %X:%X:%X:%X:%X:%X:%X:%X\n",cxi, dscp, NIP6ADDR(&(sclassifier->daddr.ipv6))); -#endif //NAS_DEBUG_CLASS - - //if ((dst = (unsigned int*)&(((struct rt6_info *)skbdst)->rt6i_gateway)) == 0){ - // LG: STRANGE - if (IN6_IS_ADDR_UNSPECIFIED(&ipv6_hdr(skb)->daddr)) { - printk("nasrg_CLASS_cx6: dst addr is null \n"); - sclassifier = sclassifier->next; - continue; - } - - nasrg_create_mask_ipv6_addr(&masked_addr, sclassifier->dplen); - // Modified MW to check only the iid6 - masked_addr.s6_addr32[0] = 0x00000000; - masked_addr.s6_addr32[1] = 0x00000000; - - if (IN6_ARE_ADDR_MASKED_EQUAL(&ipv6_hdr(skb)->daddr, &(sclassifier->daddr.ipv6), &masked_addr)) { -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_cx6: found cx %d: %X:%X:%X:%X:%X:%X:%X:%X\n",cxi, NIP6ADDR(&(sclassifier->daddr.ipv6))); -#endif //NAS_DEBUG_CLASS - return &gpriv->cx[cxi]; - } - } - - // Go to next classifier entry for connection - sclassifier = sclassifier->next; - } - } - } - } - - //printk("nas_CLASS_cx6 NOT FOUND: %X:%X:%X:%X:%X:%X:%X:%X\n",NIP6ADDR(&ipv6_hdr(skb)->daddr)); - return cx; -} - -//--------------------------------------------------------------------------- -// Search the sending function for IP Packet -void nasrg_CLASS_send(struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *pclassifier, *sp; - uint8_t *protocolh = NULL; - uint8_t version; - uint8_t protocol, dscp; - uint16_t classref; - struct cx_entity *cx; - unsigned int i; -#ifdef NAS_DEBUG_CLASS - char sfct[10], sprotocol[10]; -#endif - struct net_device *dev = gdev; - unsigned char cx_index,no_connection; - int addr_type; - int mbms_ix; - struct in6_addr masked6_addr; - struct in_addr masked_addr; - // RARP vars - struct arphdr *rarp; - unsigned char *rarp_ptr; - /* s for "source", t for "target" */ - __be32 sip, tip; - unsigned char *sha, *tha; - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: begin -\n"); -#endif - - if (skb==NULL) { - printk("nasrg_CLASS_send - input parameter skb is NULL \n"); - return; - } - - //*** -#ifdef NAS_DEBUG_SEND - printk("nasrg_CLASS_send - Received IP packet to transmit, length %d\n", skb->len); -#endif -#ifdef NAS_DEBUG_SEND_DETAIL - - if ((skb->data) != NULL) { - if (skb->len<150) - nasrg_TOOL_print_buffer(skb->data,skb->len); - else - nasrg_TOOL_print_buffer(skb->data,150); - } - -#endif - //*** - // find all connections related to socket - cx_index = 0; - no_connection = 1; - cx = NULL; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: [before switch on IP protocol version] \n"); -#endif - - - // Get mobile connexion entity, protocol and dscp from IP packet - switch (ntohs(skb->protocol)) { - case ETH_P_IPV6: -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send : skb->protocol : IPv6 \n"); -#endif - version = NAS_VERSION_6; - addr_type = NAS_IPV6_ADDR_UNKNOWN; - protocolh = nasrg_TOOL_get_protocol6(ipv6_hdr(skb), &protocol); - dscp = nasrg_TOOL_get_dscp6 (ipv6_hdr(skb)); - cx = nasrg_CLASS_cx6 (skb, dscp, &addr_type, &cx_index, &mbms_ix); -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send - ETH_P_IPV6 skb %p dscp %d gpriv %p cx_index %p \n",skb, dscp, gpriv, &cx_index); -#endif - - // find in default DSCP a valid classification - if (cx == NULL) { - switch (addr_type) { - case NAS_IPV6_ADDR_MC_SIGNALLING: - case NAS_IPV6_ADDR_UNICAST: -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send - case NAS_IPV6_ADDR_MC_SIGNALLING | NAS_IPV6_ADDR_UNICAST\n"); -#endif //NAS_DEBUG_CLASS - - for (i=0; i<NAS_CX_MAX; i++) { - pclassifier=(&gpriv->cx[i])->sclassifier[NAS_DSCP_DEFAULT]; - - while (pclassifier!=NULL) { - if ((pclassifier->version == NAS_VERSION_6) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - // ok found default classifier for this packet - nasrg_create_mask_ipv6_addr(&masked6_addr, pclassifier->dplen); - // Modified MW to let everything go (pb with signalling) - masked6_addr.s6_addr32[0] = 0x00000000; - masked6_addr.s6_addr32[1] = 0x00000000; -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send - cx %d : DSCP NAS_DSCP_DEFAULT %X:%X:%X:%X:%X:%X:%X:%X\n",i, NIP6ADDR(&(pclassifier->daddr.ipv6))); -#endif //NAS_DEBUG_CLASS - - if (IN6_ARE_ADDR_MASKED_EQUAL(&pclassifier->daddr.ipv6, &ipv6_hdr(skb)->daddr, &masked6_addr)) { - // then force dscp - cx = &gpriv->cx[i]; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send - ETH_P_IPV6 FOUND NAS_DSCP_DEFAULT with IN6_ARE_ADDR_MASKED_EQUAL(%d bits)\n",pclassifier->dplen); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } else { - if(IN6_IS_ADDR_UNSPECIFIED(&pclassifier->daddr.ipv6)) { - cx = &gpriv->cx[i]; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send - ETH_P_IPV6 FOUND NAS_DSCP_DEFAULT with IN6_IS_ADDR_UNSPECIFIED\n"); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } - } - } - - pclassifier = pclassifier->next; - } - } - - break; - - // MBMS is broken!!!! To be updated (these values will be over-ridden afterwards - case NAS_IPV6_ADDR_MC_MBMS: -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send - case NAS_IPV6_ADDR_MC_MBMS\n"); -#endif //NAS_DEBUG_CLASS - pclassifier = gpriv->mbmsclassifier[mbms_ix]; - printk("nasrg_CLASS_send: MBMS is broken!!!!\n\n\n"); - sp = gpriv->mbmsclassifier[mbms_ix]; - - if (sp!= NULL) { - classref=sp->classref; -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send: classifier found for multicast service %d \n", mbms_ix); -#endif - } else { - printk("nasrg_CLASS_send: No corresponding multicast bearer, so the message is dropped\n"); - return; - } - - break; - - // should have found a valid classification rule - case NAS_IPV6_ADDR_UNKNOWN: - default: - printk("nasrg_CLASS_send: No corresponding address type\n"); - } - } - - break; - - case ETH_P_ARP: -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send : skb->protocol : ARP \n"); -#endif - version = NAS_VERSION_4; - addr_type = NAS_IPV4_ADDR_BROADCAST; - dscp = 0; - cx = NULL; - // Basic sanity checks can be done without the lock - rarp = (struct arphdr *)skb_network_header(skb); - - if (rarp) { - if (rarp->ar_hln != dev->addr_len || dev->type != ntohs(rarp->ar_hrd)) { - printk("nasrg_CLASS_send: ARP PACKET WRONG ADDR LEN or WRONG ARP HEADER TYPE\n"); - break; - } - } else { - printk("nasrg_CLASS_send: ARP HEADER POINTER IS NULL\n"); - break; - } - - // If it's not Ethernet, delete it. - if (rarp->ar_pro != htons(ETH_P_IP)) { - printk("nasrg_CLASS_send: ARP PACKET PROTOCOL IS NOT ETHERNET\n"); - break; - } - - rarp_ptr = (unsigned char *) (rarp + 1); - sha = rarp_ptr; - rarp_ptr += dev->addr_len; - memcpy(&sip, rarp_ptr, 4); - rarp_ptr += 4; - tha = rarp_ptr; - rarp_ptr += dev->addr_len; - memcpy(&tip, rarp_ptr, 4); -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: ARP DEST IP transport IP = %d.%d.%d.%d\n",NIPADDR(tip)); -#endif - - for (i=0; i<NAS_CX_MAX; i++) { - pclassifier=(&gpriv->cx[i])->sclassifier[NAS_DSCP_DEFAULT]; - - while (pclassifier!=NULL) { - if ((pclassifier->version == NAS_VERSION_4) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - // ok found default classifier for this packet - nasrg_create_mask_ipv4_addr(&masked_addr, pclassifier->dplen); -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: MASK = %d.%d.%d.%d\n",NIPADDR(masked_addr.s_addr)); -#endif - - // - if (IN_ARE_ADDR_MASKED_EQUAL(&pclassifier->daddr.ipv4, &tip, &masked_addr.s_addr)) { - // then force dscp - cx = &gpriv->cx[i]; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: ETH_P_ARP FOUND NAS_DSCP_DEFAULT with IN_ARE_ADDR_MASKED_EQUAL(%d bits)\n", pclassifier->dplen); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } else { - if (INADDR_ANY == pclassifier->daddr.ipv4) { - cx = &gpriv->cx[i]; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: ETH_P_ARP FOUND NAS_DSCP_DEFAULT with INADDR_ANY\n"); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } - } - } - - pclassifier = pclassifier->next; - } - } - - break; - - case ETH_P_IP: -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send : skb->protocol : IPv4 \n"); -#endif - version = NAS_VERSION_4; - addr_type = NAS_IPV4_ADDR_UNKNOWN; - dscp = nasrg_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb))); - cx = nasrg_CLASS_cx4(skb, dscp, &addr_type, &cx_index); - protocolh = nasrg_TOOL_get_protocol4((struct iphdr *)(skb_network_header(skb)), &protocol); - - // find in default DSCP a valid classification - if (cx == NULL) { - switch (addr_type) { - case NAS_IPV4_ADDR_MC_SIGNALLING: - case NAS_IPV4_ADDR_UNICAST: - case NAS_IPV4_ADDR_BROADCAST: - for (i=0; i<NAS_CX_MAX; i++) { - pclassifier=(&gpriv->cx[i])->sclassifier[NAS_DSCP_DEFAULT]; - - while (pclassifier != NULL) { - if ((pclassifier->version == NAS_VERSION_4) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - // ok found default classifier for this packet - nasrg_create_mask_ipv4_addr(&masked_addr, pclassifier->dplen); -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send : MASK = %d.%d.%d.%d\n", NIPADDR(masked_addr.s_addr)); -#endif - - if (IN_ARE_ADDR_MASKED_EQUAL(&pclassifier->daddr.ipv4, &ip_hdr(skb)->daddr, &masked_addr.s_addr)) { - // then force dscp - cx = &gpriv->cx[i]; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send : ETH_P_IP FOUND NAS_DSCP_DEFAULT with IN_ARE_ADDR_MASKED_EQUAL(%d bits)\n",pclassifier->dplen); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } else { - if(INADDR_ANY == pclassifier->daddr.ipv4) { - cx = &gpriv->cx[i]; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send : ETH_P_IP FOUND NAS_DSCP_DEFAULT with INADDR_ANY\n"); -#endif - dscp = NAS_DSCP_DEFAULT; - break; - } - } - } - - pclassifier = pclassifier->next; - } - } - - break; - - // should have found a valid classification rule - case NAS_IPV4_ADDR_UNKNOWN: - default: - printk("nasrg_CLASS_send: No corresponding address type\n"); - } - } - -#ifdef NAS_DEBUG_CLASS - - if (cx) - printk("nasrg_CLASS_send: ETH_P_IP Received IPv4 packet (%02X), dscp = %d, cx = %d\n",ntohs(skb->protocol),dscp,cx->lcr); - else - printk("nasrg_CLASS_send: ETH_P_IP Received IPv4 packet (%02X), dscp = %d, No valid connection\n",ntohs(skb->protocol),dscp); - -#endif - break; - - default: - printk("nasrg_CLASS_send: Unknown IP version protocol\n"); - version = 0; - return; - } - -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send: [before if (cx != NULL)]\n"); -#endif - - //Next lines bypass classifiers to test the netlink socket - //#define DEBUG_NETLINKRG_TEST -#ifdef DEBUG_NETLINKRG_TEST - nasrg_COMMON_QOS_send_test_netlink(skb); - return; -#endif - - // If a valid connection for the DSCP/EXP with destination address - // is found scan all protocol-based classification rules - if (cx != NULL) { - classref = 0; - sp = NULL; - - if (cx->state!=NAS_CX_DCH) { -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: UE not connected, in state %d. Packet is dropped\n",cx->state); -#endif - return; - } - - if (addr_type==NAS_IPV6_ADDR_MC_MBMS) { - sp = gpriv->mbmsclassifier[mbms_ix]; - - if (sp!= NULL) { - classref=sp->classref; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: classifier found for multicast index %d, service %d\n", mbms_ix, gpriv->mbms_rb[mbms_ix].cnxid); -#endif - } else { - // Temp MEDIEVAL : use default classifier - sp = cx->sclassifier[NAS_DSCP_DEFAULT]; - - if (sp!= NULL) { - classref=sp->classref; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_CLASS_send: classifier for multicast service %d replaced by default %d\n", mbms_ix, classref); -#endif -#ifdef NAS_AUTO_MBMS - nasrg_ASCTL_start_default_mbms_service(); -#endif - } else { - printk("nasrg_CLASS_send: No corresponding multicast bearer, so the message is dropped\n"); - return; - } - } - } else { -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send: DSCP %d version %d: looking for classifier entry\n",dscp, version); -#endif - - for (pclassifier=cx->sclassifier[dscp]; pclassifier!=NULL; pclassifier=pclassifier->next) { -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send: DSCP %d p->classref=%d,p->protocol=%d,p->version=%d\n",dscp,pclassifier->classref,pclassifier->protocol,pclassifier->version); -#endif - - // normal rule checks that network protocol version matches - if ((pclassifier->version == version) || (pclassifier->version == NAS_VERSION_DEFAULT)) { - //printk("nasrg_CLASS_send: IP version are equals\n"); - sp=pclassifier; - classref=sp->classref; -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send: classifier found for dscp %u \n", dscp); -#endif - break; - } - } - } - - if (sp!=NULL) { -#ifdef NAS_DEBUG_CLASS - - //char sfct[10], sprotocol[10]; - // classifier entity found. Print its parameters - if (sp->fct==nasrg_COMMON_QOS_send) - strcpy(sfct, "data xfer"); - - if (sp->fct==nasrg_CTL_send) - strcpy(sfct, "iocontrol"); - - if (sp->fct==nasrg_COMMON_del_send) - strcpy(sfct, "delete"); - - if (sp->fct==nasrg_ASCTL_DC_send_sig_data_request) - strcpy(sfct, "DC-SAP"); - - switch(protocol) { - case NAS_PROTOCOL_UDP: - strcpy(sprotocol, "udp"); - printk("udp packet\n"); - break; - - case NAS_PROTOCOL_TCP: - strcpy(sprotocol, "tcp"); - printk("tcp packet\n"); - break; - - case NAS_PROTOCOL_ICMP4: - strcpy(sprotocol, "icmp4"); - printk("icmp4 packet\n"); - break; - - case NAS_PROTOCOL_ICMP6: - strcpy(sprotocol, "icmp6"); - nasrg_TOOL_pk_icmp6((struct icmp6hdr*)protocolh); - break; - - default: - strcpy(sprotocol, "other L4"); - break; - } - - printk("nasrg_CLASS_send: (dscp %u, %s) received, (classref %u, fct %s, drb_id %u) classifier rule\n", - dscp, sprotocol, sp->classref, sfct, sp->rab_id); -#endif - - //forward packet to the correct entity - if (sp->fct!=NULL) { - sp->fct(skb, cx, sp); - } else { - printk("\n\nnasrg_CLASS_send: ERROR : CLASSIFIER FUNCTION IS NULL\n\n"); - } - - no_connection = 0; - // end : if classifier entry match found - } else { - printk("nasrg_CLASS_send: no corresponding item in the classifier list, so the message is dropped\n"); - printk("nasrg_CLASS_send: packet parameters: dscp %u, %s\n", dscp, sprotocol); - nasrg_COMMON_del_send(skb, cx, NULL); // Note MW: LG has commented this line. Why? - } - } // if connection found - -#ifdef NAS_DEBUG_CLASS - - if (no_connection == 1) { - printk("nasrg_CLASS_send: no corresponding connection, so the message is dropped\n"); - } - -#endif -#ifdef NAS_DEBUG_CLASS_DETAIL - printk("nasrg_CLASS_send: end\n"); -#endif -} diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c deleted file mode 100644 index 6bfd77a17d3aa636397ea777f7582ed2bb2e37f2..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_common.c +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_common.c -* \brief Common functions for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#include "nasrg_variables.h" -#include "nasrg_proto.h" - -#include <linux/inetdevice.h> -#ifdef NAS_DRIVER_TYPE_ETHERNET -#include <linux/etherdevice.h> -#endif - -//--------------------------------------------------------------------------- -// Receive data from FIFO (QOS or DC) -//void nasrg_COMMON_receive(uint16_t hlen, uint16_t dlen, int sap){ -void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap) -{ - //--------------------------------------------------------------------------- - struct sk_buff *skb; - struct ipversion *ipv; - unsigned int hard_header_len; - uint16_t *p_ether_type; - uint16_t ether_type; - -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_receive: begin\n"); -#endif -#ifdef PDCP_USE_NETLINK - - // data_buffer is NULL if FIFOs - if (!data_buffer) { - printk("nasrg_COMMON_receive - input parameter data_buffer is NULL \n"); - return; - } - -#endif - - skb = dev_alloc_skb( payload_length + 2 ); - - if(!skb) { - printk("nasrg_COMMON_receive: low on memory\n"); - ++gpriv->stats.rx_dropped; - return; - } - - skb_reserve(skb,2); - -#ifndef PDCP_USE_NETLINK - bytes_read += rtf_get(sap, skb_put(skb, payload_length), payload_length); - - if (bytes_read != NAS_PDCPH_SIZE + payload_length) { - printk("nasrg_COMMON_receive: problem while reading rtf sap\n"); - kfree(skb->data); - dev_kfree_skb(skb); - return; - } - -#else - memcpy(skb_put(skb, payload_length), data_buffer, payload_length); - bytes_read += payload_length; -#endif - -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_receive: received packet from PDCP, length %d\n", bytes_read); -#endif - - skb->dev = gdev; - hard_header_len = gdev->hard_header_len; - skb->mac_header = skb->data; - skb->pkt_type = PACKET_HOST; - skb->ip_summed = CHECKSUM_UNNECESSARY; - - ipv = (struct ipversion *)&(skb->data[hard_header_len]); - - switch (ipv->version) { - case 6: -#ifdef NAS_DEBUG_RECEIVE_BASIC - printk("nasrg_COMMON_receive: receive IPv6 message\n"); -#endif - skb->network_header = &skb->data[hard_header_len]; - // set protocol default value - skb->protocol = htons(ETH_P_IPV6); - // If type Ethernet, correct it -#ifdef NAS_DRIVER_TYPE_ETHERNET - skb->protocol = eth_type_trans(skb, gdev); -#endif - break; - - case 4: -#ifdef NAS_DEBUG_RECEIVE_BASIC - printk("nasrg_COMMON_receive: receive IPv4 message\n"); -#endif - -#ifdef NAS_DEBUG_RECEIVE - addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->saddr; - - if (addr) { - printk("nasrg_COMMON_receive: Source %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]); - } - - addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->daddr; - - if (addr) { - printk("nasrg_COMMON_receive Dest %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]); - } - - printk("nasrg_COMMON_receive protocol %d\n",((struct iphdr *)&skb->data[hard_header_len])->protocol); -#endif - - skb->network_header = &skb->data[hard_header_len]; - // set protocol default value - skb->protocol = htons(ETH_P_IP); - // If type Ethernet, correct it -#ifdef NAS_DRIVER_TYPE_ETHERNET - skb->protocol = eth_type_trans(skb, gdev); -#endif - break; - - default: - printk("nasrg_COMMON_receive: Packet is not IPv4 or IPv6 (version=%d)\n", ipv->version); - -#ifdef NAS_DRIVER_TYPE_ETHERNET -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_receive: ether_type=%04X\n", ether_type); -#endif - skb->protocol = eth_type_trans(skb, gdev); - // minus 1(short) instead of 2(bytes) because uint16_t* - p_ether_type = (uint16_t *)&(skb->mac_header[hard_header_len-2]); - ether_type = ntohs(*p_ether_type); -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_receive: ether_type=%04X\n", ether_type); -#endif - - switch (ether_type) { - case ETH_P_ARP: - printk("nasrg_COMMON_receive: ether_type = ETH_P_ARP\n"); - skb->protocol = htons(ETH_P_ARP); - skb->network_header = &skb->mac_header[hard_header_len]; - break; - - default: - break; - } - -#endif - } - - ++gpriv->stats.rx_packets; - gpriv->stats.rx_bytes += bytes_read; -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_receive: forwarding packet of size %d to kernel\n",skb->len); -#endif - - netif_rx(skb); -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_receive: end\n"); -#endif -} - -//--------------------------------------------------------------------------- -// Delete the data -void nasrg_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *sp) -{ - //--------------------------------------------------------------------------- - ++gpriv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (QoS SAP) -void nasrg_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - struct pdcp_data_req_header_t pdcph; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send - begin \n"); -#endif - - // if (cx->state!=NAS_STATE_CONNECTED) // <--- A REVOIR - // { - // gpriv->stats.tx_dropped ++; - // printk("NAS_QOS_SEND: No connected, so message are dropped \n"); - // return; - // } - if (!skb || !gc || !cx) { - printk("nasrg_COMMON_QOS_send - input parameter skb|gc|cx is NULL \n"); - return; - } - - // End debug information - - if (gc->rb==NULL) { - gc->rb=nasrg_COMMON_search_rb(cx, gc->rab_id); - - if (gc->rb==NULL) { - ++gpriv->stats.tx_dropped; - printk("nasrg_COMMON_QOS_send: No corresponding Radio Bearer, so message is dropped, rab_id=%u \n", gc->rab_id); - return; - } - } - -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send #1 :"); - printk("lcr %u, rab_id %u, rab_id %u\n", cx->lcr, (gc->rb)->rab_id, gc->rab_id); -#endif -#ifdef NAS_DEBUG_SEND_DETAIL - nasrg_TOOL_print_classifier(gc); -#endif - pdcph.data_size = skb->len; - //pdcph.rb_id = (gc->rb)->rab_id+(NAS_RB_MAX_NUM*cx->lcr); - pdcph.rb_id = ((gc->rb)->rab_id)-NAS_SIG_NUM_SRB; - pdcph.inst = 0; - -#ifdef PDCP_USE_NETLINK - bytes_wrote = nasrg_netlink_send((unsigned char *)&pdcph,NAS_PDCPH_SIZE, NASNL_DEST_PDCP); -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", bytes_wrote,skb->len); -#endif -#else - //bytes_wrote = rtf_put(gpriv->sap[(gc->rb)->sapi], &pdcph, NAS_PDCPH_SIZE); - bytes_wrote = rtf_put(NAS2PDCP_FIFO, &pdcph, NAS_PDCPH_SIZE); -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP fifo\n", bytes_wrote,skb->len); -#endif -#endif //PDCP_USE_NETLINK - - if (bytes_wrote != NAS_PDCPH_SIZE) { - printk("nasrg_COMMON_QOS_send: problem while writing PDCP's header\n"); - printk("PDCP rb_id %d, SAP index %d, Wrote %d to fifo %d, Header Size %d \n", pdcph.rb_id , (gc->rb)->sapi, bytes_wrote, NAS2PDCP_FIFO, NAS_PDCPH_SIZE); - gpriv->stats.tx_dropped ++; - return; - } - -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_COMMON_QOS_send #2 :"); - printk("Header bytes written : %d\n", bytes_wrote); -#endif - -#ifdef PDCP_USE_NETLINK - bytes_wrote += nasrg_netlink_send((unsigned char *)skb->data,skb->len, NASNL_DEST_PDCP); -#else - //bytes_wrote += rtf_put(gpriv->sap[(gc->rb)->sapi], skb->data, skb->len); - bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len); -#endif //PDCP_USE_NETLINK - - if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) { - printk("nasrg_COMMON_QOS_send: problem while writing PDCP's data\n"); // congestion - printk("rb_id %d, SAP index %d, Wrote %d to fifo %d, Header Size %d \n", pdcph.rb_id , (gc->rb)->sapi, bytes_wrote, NAS2PDCP_FIFO, NAS_PDCPH_SIZE); - gpriv->stats.tx_dropped ++; - return; - } - -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send #3 :"); - printk(" %d bytes written to rb_id %d, sap %d \n", bytes_wrote, pdcph.rb_id, NAS2PDCP_FIFO); -#endif - gpriv->stats.tx_bytes += skb->len; - gpriv->stats.tx_packets ++; -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_COMMON_QOS_send - end \n"); -#endif -} - -//--------------------------------------------------------------------------- -// Request the transfer of data (QoS SAP) -void nasrg_COMMON_QOS_send_test_netlink(struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct pdcp_data_req_header_t pdcph; - int bytes_wrote = 0; - - // Start debug information -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send - begin \n"); -#endif - - // if (cx->state!=NAS_STATE_CONNECTED) // <--- A REVOIR - // { - // gpriv->stats.tx_dropped ++; - // printk("NAS_QOS_SEND: No connected, so message are dropped \n"); - // return; - // } - if (!skb ) { - printk("nasrg_COMMON_QOS_send - input parameter skb|gc|cx is NULL \n"); - return; - } - - // End debug information - -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send #1 :"); - // printk("lcr %u, rab_id %u, rab_id %u\n", cx->lcr, (gc->rb)->rab_id, gc->rab_id); - // nasrg_TOOL_print_classifier(gc); -#endif - pdcph.data_size = skb->len; - //pdcph.rb_id = (gc->rb)->rab_id+(NAS_RB_MAX_NUM*cx->lcr); - pdcph.rb_id = 6; - pdcph.inst = 0; - -#ifdef PDCP_USE_NETLINK - bytes_wrote = nasrg_netlink_send((unsigned char *)&pdcph,NAS_PDCPH_SIZE, NASNL_DEST_PDCP); - //printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n", bytes_wrote,skb->len); -#else - //bytes_wrote = rtf_put(gpriv->sap[(gc->rb)->sapi], &pdcph, NAS_PDCPH_SIZE); - bytes_wrote = rtf_put(NAS2PDCP_FIFO, &pdcph, NAS_PDCPH_SIZE); - //printk("nasrg_COMMON_QOS_send - Wrote %d bytes (header for %d byte skb) to PDCP fifo\n", bytes_wrote,skb->len); -#endif //PDCP_USE_NETLINK - - if (bytes_wrote != NAS_PDCPH_SIZE) { - printk("nasrg_COMMON_QOS_send: problem while writing PDCP's header\n"); - // printk("PDCP rb_id %d, SAP index %d, Wrote %d to fifo %d, Header Size %d \n", pdcph.rb_id , (gc->rb)->sapi, bytes_wrote, NAS2PDCP_FIFO, NAS_PDCPH_SIZE); - gpriv->stats.tx_dropped ++; - return; - } - -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send #2 :"); - printk("Header bytes wrote : %d\n", bytes_wrote); -#endif - -#ifdef PDCP_USE_NETLINK - bytes_wrote += nasrg_netlink_send((unsigned char *)skb->data,skb->len, NASNL_DEST_PDCP); -#else - //bytes_wrote += rtf_put(gpriv->sap[(gc->rb)->sapi], skb->data, skb->len); - bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len); -#endif //PDCP_USE_NETLINK - - if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) { - printk("nasrg_COMMON_QOS_send: problem while writing PDCP's data\n"); // congestion - // printk("rb_id %d, SAP index %d, Wrote %d to fifo %d, Header Size %d \n", pdcph.rb_id , (gc->rb)->sapi, bytes_wrote, NAS2PDCP_FIFO, NAS_PDCPH_SIZE); - gpriv->stats.tx_dropped ++; - return; - } - -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send #3 :"); - printk(" %d bytes wrote to rb_id %d, sap %d \n", bytes_wrote, pdcph.rb_id, NAS2PDCP_FIFO); -#endif - gpriv->stats.tx_bytes += skb->len; - gpriv->stats.tx_packets ++; -#ifdef NAS_DEBUG_SEND - printk("nasrg_COMMON_QOS_send - end \n"); -#endif -} - -#ifndef PDCP_USE_NETLINK -//--------------------------------------------------------------------------- -void nasrg_COMMON_QOS_receive(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - uint8_t sapi; - struct pdcp_data_ind_header_t pdcph; - int bytes_read = 0; - // Start debug information -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_QOS_receive - begin \n"); -#endif - - if (!cx) { - printk("nasrg_COMMON_QOS_receive - input parameter cx is NULL \n"); - return; - } - - // End debug information - - // LG force the use of only 1 rt fifo - sapi = NAS_DRB_OUTPUT_SAPI; - - bytes_read = rtf_get(gpriv->sap[sapi], &pdcph, NAS_PDCPH_SIZE); - - while (bytes_read>0) { - if (bytes_read != NAS_PDCPH_SIZE) { - printk("nasrg_COMMON_QOS_receive: problem while reading PDCP header\n"); - return; - } - - // data_buffer is NULL because FIFO should be read directly in the skbuff (LITE has an intermediary buffer) - nasrg_COMMON_receive(NAS_PDCPH_SIZE, pdcph.data_size, NULL, pdcph->rb_id, gpriv->sap[sapi]); - // check if another frame is in the FIFO, otherwise return - bytes_read = rtf_get(gpriv->sap[sapi], &pdcph, NAS_PDCPH_SIZE); - } - -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_QOS_receive - end \n"); -#endif -} -#else -//--------------------------------------------------------------------------- -void nasrg_COMMON_QOS_receive(struct nlmsghdr *nlh) -{ - //--------------------------------------------------------------------------- - - struct pdcp_data_ind_header_t *pdcph; - - // Start debug information -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_QOS_receive - begin \n"); -#endif - - if (!nlh) { - printk("nasrg_COMMON_QOS_receive - input parameter nlh is NULL \n"); - return; - } - - // End debug information - pdcph = (struct pdcp_data_ind_header_t *)NLMSG_DATA(nlh); - -#ifdef NAS_DEBUG_RECEIVE - printk("nasrg_COMMON_QOS_receive - receive from PDCP, size %d, rab %d\\n", pdcph->data_size, pdcph->rb_id); -#endif //NAS_DEBUG_RECEIVE - - //void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); - nasrg_COMMON_receive(NAS_PDCPH_SIZE + pdcph->data_size, pdcph->data_size, (unsigned char *)NLMSG_DATA(nlh) + NAS_PDCPH_SIZE, pdcph->rb_id, 0); -} -#endif //PDCP_USE_NETLINK - -//--------------------------------------------------------------------------- -struct cx_entity *nasrg_COMMON_search_cx(nasLocalConnectionRef_t lcr) -{ - //--------------------------------------------------------------------------- -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_search_cx - lcr %d\n",lcr); -#endif - - if (lcr<NAS_CX_MAX) - return gpriv->cx+lcr; - else - return NULL; -} - -//--------------------------------------------------------------------------- -// Search a Radio Bearer -struct rb_entity *nasrg_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_search_rb - rab_id %d\n", rab_id); -#endif - - if (cx==NULL) { - printk("nasrg_COMMON_search_rb - input parameter cx is NULL \n"); - return NULL; - } - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { - if (rb->rab_id==rab_id) - return rb; - } - - return NULL; -} - -//--------------------------------------------------------------------------- -struct rb_entity *nasrg_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasQoSTrafficClass_t qos) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_add_rb - begin for rab_id %d , qos %d\n", rab_id, qos ); -#endif - - if (cx==NULL) { - printk("nasrg_COMMON_add_rb - input parameter cx is NULL \n"); - return NULL; - } - - rb=nasrg_COMMON_search_rb(cx, rab_id); - - if (rb==NULL) { - rb=(struct rb_entity *)kmalloc(sizeof(struct rb_entity), GFP_KERNEL); - - if (rb!=NULL) { - rb->retry=0; - rb->countimer=NAS_TIMER_IDLE; - rb->rab_id=rab_id; - // rb->rab_id=rab_id+(32*cx->lcr); -#ifdef NAS_DEBUG_DC - printk("nasrg_COMMON_add_rb: rb rab_id=%u, rab_id=%u, mt_id=%u\n",rb->rab_id,rab_id, cx->lcr); -#endif - // rb->dscp = NASRG_TEMP_2NDRAB_DSCP; //TEMP - rb->qos=qos; - rb->sapi=NAS_DRB_INPUT_SAPI; - // LG force the use of only one rt-fifo - // rb->sapi=NAS_BA_INPUT_SAPI; - rb->state=NAS_IDLE; - rb->next=cx->rb; - cx->rb=rb; - (cx->num_rb)++; - } else - printk("nasrg_COMMON_add_rb: no memory\n"); - } - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_add_rb - end \n" ); -#endif - return rb; -} - -//--------------------------------------------------------------------------- -// free the memory that has previously been allocated to rb and remove from linked list -void nasrg_COMMON_del_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasIPdscp_t dscp) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb, *curr_rb, *prev_rb; - struct classifier_entity *p; - uint16_t classref=0; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_del_rb - begin\n"); -#endif - - if (cx==NULL) { - printk("nasrg_COMMON_del_rb - input parameter cx is NULL \n"); - return; - } - - // End debug information - - // Clear the associated classifier - for (p=cx->sclassifier[dscp]; p!=NULL; p=p->next) { - if (p->classref>=classref) { - classref=p->classref; -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_del_rb: classifier found for dscp %u \n", dscp); -#endif - } - } - - nasrg_CLASS_del_sclassifier(cx, dscp, classref); - - // Now, delete the RB - curr_rb = NULL; - prev_rb = NULL; - - for (rb=cx->rb; rb!=NULL; rb=rb->next) { - if (rb->rab_id == rab_id) { - curr_rb = rb; - - if (prev_rb!=NULL) { - prev_rb->next = rb->next; - } else { - cx->rb=rb->next; - } - - break; - } else { - prev_rb = rb; - } - } - - if (curr_rb!= NULL) { - printk("nasrg_COMMON_del_rb: del rab_id %u\n", rb->rab_id); - kfree(rb); - (cx->num_rb)--; - } else { - printk("\n\n--nasrg_COMMON_del_rb: ERROR, invalid rab_id %u\n", rb->rab_id); - } - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_del_rb - end\n"); -#endif -} - -//--------------------------------------------------------------------------- -void nasrg_COMMON_flush_rb(struct cx_entity *cx) -{ - //--------------------------------------------------------------------------- - struct rb_entity *rb; - struct classifier_entity *gc; - uint8_t dscp; - - // Start debug information -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_flush_rb - begin\n"); -#endif - - if (cx==NULL) { - printk("nasrg_COMMON_flush_rb - input parameter cx is NULL \n"); - return; - } - - // End debug information - for (rb=cx->rb; rb!=NULL; rb=cx->rb) { - printk("nasrg_COMMON_flush_rb: del rab_id %u\n", rb->rab_id); - cx->rb=rb->next; - kfree(rb); - } - - cx->num_rb=0; - cx->rb=NULL; - - for(dscp=0; dscp<NAS_DSCP_MAX; ++dscp) { - for (gc=cx->sclassifier[dscp]; gc!=NULL; gc=gc->next) - gc->rb=NULL; - } - -#ifdef NAS_DEBUG_CLASS - printk("nasrg_COMMON_flush_rb - end\n"); -#endif -} diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_constant.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_constant.h deleted file mode 100644 index 7a0e69cc4847caa05129ce397efb81008a86c841..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_constant.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_constant.h -* \brief Defines all constants for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASRGD_CST -#define _NASRGD_CST - -//Debug flags -#define NAS_DEBUG_DC -//#define NAS_DEBUG_DC_DETAIL -#define NAS_DEBUG_SEND -//#define NAS_DEBUG_SEND_DETAIL // detail of packet transmission -//#define NAS_DEBUG_RECEIVE -#define NAS_DEBUG_RECEIVE_BASIC -#define NAS_DEBUG_CLASS -//#define NAS_DEBUG_CLASS_DETAIL -#define NAS_DEBUG_GC -//#define NAS_DEBUG_DC_MEASURE -//#define NAS_DEBUG_TIMER -#define NAS_DEBUG_DEVICE -//#define NAS_DEBUG_INTERRUPT -//#define NAS_DEBUG_TOOL -//#define NAS_DEBUG_MBMS_PROT //Only one RT-FIFO is used -#define NETLINK_DEBUG -#define NAS_DEBUG_RRCNL // RRC netlink socket - -// Other flags -#define DEMO_3GSM -//#define NODE_RG -//#define NAS_AUTO_MBMS - -// Begin default RAB -// Parameters for the default RAB started after network attachment (needs DEMO_3GSM defined) -// RBId value to be synchronized with RAL-RG -#define NASRG_DEFAULTRAB_RBID 6 //MW-01/01/07- RBID 5 => MBMS, 6 => DEFAULTRAB, 7+ => others -// Only one of next lines must be active - other values in l3/rrc/rrc_qos.h -#define NASRG_DEFAULTRAB_QoS 2 //MW-01/01/07- RRC_QOS_CONV_64_64 -//#define NASRG_DEFAULTRAB_QoS 3 //MW-01/01/07- RRC_QOS_CONV_128_128 -//#define NASRG_DEFAULTRAB_QoS 4 //MW-01/01/07- RRC_QOS_CONV_256_256 -//#define NASRG_DEFAULTRAB_QoS 5 //MW-01/01/07- RRC_QOS_CONV_320_320 -//#define NASRG_DEFAULTRAB_QoS 11 //LG RRC_QOS_INTER_128_64 -// -#define NASRG_DEFAULTRAB_CLASSREF 1 //MW-01/01/07 -#define NASRG_DEFAULTRAB_DSCP 0 //MW-01/01/07 -#define NASRG_DEFAULTRAB_IPVERSION NAS_VERSION_DEFAULT //MW-01/01/07 -// End default RAB - -//Temp - hard coded -#define NASRG_OWN_CELLID 5 -#define NASRG_TEMP_2NDRAB_DSCP 5 -#define NASRG_TEMP_MBMS_SESSION_ID 1 -#define NASRG_TEMP_MBMS_DURATION 999 -#define NAS_DEFAULT_IPv6_PREFIX_LENGTH 128 // used to compare destination address with MT's - -// General Constants -#define NAS_MTU 1500 -#define NAS_TX_QUEUE_LEN 100 -#define NAS_ADDR_LEN 8 -#define NAS_INET6_ADDRSTRLEN 46 -#define NAS_INET_ADDRSTRLEN 16 - -#define NAS_RESET_RX_FLAGS 0 - -#define NAS_CX_MAX 3 //Identical to RRC constant -//#define NAS_CX_MULTICAST_ALLNODE 2 - -#define NASRG_MBMS_SVCES_MAX 4 // Identical to RRC constant - -#define NAS_RB_MAX_NUM 32 // maximum number of RBs per MT - 25.331 -#define NAS_RETRY_LIMIT_DEFAULT 5 - -#define NAS_MESSAGE_MAXLEN 1600 - -// UMTS -#define NAS_SIG_SRB3 3 -#define NAS_SIG_SRB4 3 // not used yet -//LTE -#define NAS_SIG_NUM_SRB 3 // number of srbs in LTE to send Rb_Id to PDCP - - -//peer-to-peer messages between NAS entities -#define NAS_CMD_OPEN_RB 1 -#define NAS_CMD_ENTER_SLEEP 2 -#define NAS_CMD_LEAVE_SLEEP 3 - -#define NAS_CX_RELEASE_UNDEF_CAUSE 1 - -// MT+RG NAS States -#define NAS_IDLE 0x01 -// Connection -#define NAS_CX_FACH 0x06 -#define NAS_CX_DCH 0x0A -#define NAS_CX_RECEIVED 0x10 -#define NAS_CX_CONNECTING 0x04 -#define NAS_CX_RELEASING 0x08 -#define NAS_CX_CONNECTING_FAILURE 0x14 -#define NAS_CX_RELEASING_FAILURE 0x18 -// Radio Bearers -#define NAS_RB_ESTABLISHING 0x24 -#define NAS_RB_RELEASING 0x28 -#define NAS_RB_ESTABLISHED 0x2A - - -#define NAS_TIMER_ESTABLISHMENT_DEFAULT 12 -#define NAS_TIMER_RELEASE_DEFAULT 2 -#define NAS_TIMER_IDLE UINT_MAX -#define NAS_TIMER_TICK HZ - -#define NAS_PDCPH_SIZE sizeof(struct pdcp_data_req_header_t) -#define NAS_IPV4_SIZE 20 -#define NAS_IPV6_SIZE 40 - -#define NAS_DIRECTION_SEND 0 -#define NAS_DIRECTION_RECEIVE 1 - -// function number -#define NAS_FCT_DEL_SEND 1 -#define NAS_FCT_QOS_SEND 2 -#define NAS_FCT_DC_SEND 3 -#define NAS_FCT_CTL_SEND 4 - -// type of IOCTL command -#define NASRG_IOCTL_RAL 0x89F0 - -// Error cause -#define NAS_ERROR_ALREADYEXIST 1 -#define NAS_ERROR_NOMEMORY 3 -#define NAS_ERROR_NOTMT 9 -#define NAS_ERROR_NOTRG 10 -#define NAS_ERROR_NOTIDLE 11 -#define NAS_ERROR_NOTCONNECTED 12 -#define NAS_ERROR_NORB 14 -#define NAS_ERROR_NOTCORRECTVALUE 32 -#define NAS_ERROR_NOTCORRECTLCR 33 -#define NAS_ERROR_NOTCORRECTDIR 34 -#define NAS_ERROR_NOTCORRECTDSCP 35 -#define NAS_ERROR_NOTCORRECTVERSION 36 -#define NAS_ERROR_NOTCORRECTRABI 37 - - -/**********************************************************/ -/* Constants related with IP protocols */ -/**********************************************************/ - -// Destination address types -#define NAS_IPV6_ADDR_UNICAST 1 -#define NAS_IPV6_ADDR_MC_SIGNALLING 2 -#define NAS_IPV6_ADDR_MC_MBMS 3 -#define NAS_IPV6_ADDR_UNKNOWN 4 - -#define NAS_IPV4_ADDR_UNICAST 5 -#define NAS_IPV4_ADDR_MC_SIGNALLING 6 -#define NAS_IPV4_ADDR_BROADCAST 7 -#define NAS_IPV4_ADDR_UNKNOWN 8 - -//#define NAS_TRAFFICCLASS_MASK __constant_htonl(0x0fc00000) Yan -#define NAS_TRAFFICCLASS_MASK __constant_htonl(0x0ff00000) - -// Network control codepoint 111000 + IP version 6 -#define NAS_FLOWINFO_NCONTROL __constant_htonl(0x6e000000) -// network control codepoint 111000 -#define NAS_DSCP_NCONTROL 56 //0x38 -// default codepoint 1000000 -#define NAS_DSCP_DEFAULT 64 -#define NAS_DSCP_MAX 65 - -#define NAS_PROTOCOL_DEFAULT 0 -#define NAS_PROTOCOL_TCP IPPROTO_TCP -#define NAS_PROTOCOL_UDP IPPROTO_UDP -#define NAS_PROTOCOL_ICMP4 IPPROTO_ICMP -#define NAS_PROTOCOL_ICMP6 IPPROTO_ICMPV6 - -#define NAS_PORT_DEFAULT __constant_htons(65535) -#define NAS_PORT_HTTP __constant_htons(80) - -#define NAS_VERSION_DEFAULT 0 -#define NAS_VERSION_4 4 -#define NAS_VERSION_6 6 //?MW - -/**********************************************************/ -/* Constants related with Netlink sockets */ -/**********************************************************/ -#define OAI_IP_DRIVER_NETLINK_ID 31 -#define NL_DEST_PID 1 - -// defined in rrc_nas_sap.h -//#define NAS_RRCNL_ID 30 -//#define NL_DEST_RRC_PID 2 - -#define NASNL_DEST_PDCP 0 -#define NASNL_DEST_RRC 1 - -#endif - - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c deleted file mode 100644 index 8fe2d48e3fabaf29bf4d8acaf3490a76f3764b89..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_device.c +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_device.c -* \brief Networking Device Driver for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef PDCP_USE_NETLINK -#ifdef RTAI -#include "rtai_posix.h" -#define RTAI_IRQ 30 //try to get this irq with RTAI -#endif // RTAI -#endif // PDCP_USE_NETLINK -//:::::::::::::::::::::::::::::::::::::::;; -#include "nasrg_variables.h" -#include "nasrg_proto.h" -//:::::::::::::::::::::::::::::::::::::::;; -//#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/version.h> -#include <linux/init.h> -#include <linux/spinlock.h> -#ifdef NAS_DRIVER_TYPE_ETHERNET -#include <linux/if_ether.h> -#endif -#include <asm/io.h> -#include <asm/bitops.h> -#include <asm/uaccess.h> -#include <asm/segment.h> -#include <asm/page.h> -#include <asm/delay.h> -#include <asm/unistd.h> -#include <linux/netdevice.h> -#ifdef NAS_DRIVER_TYPE_ETHERNET -#include <linux/etherdevice.h> -#endif -//:::::::::::::::::::::::::::::::::::::::;; -/* Global variables */ -struct net_device *gdev; -struct nas_priv *gpriv; -//int bytes_wrote; -//int bytes_read; -uint8_t NAS_RG_IMEI[14]= {0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x01}; -uint8_t NAS_NULL_IMEI[14]= {0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00, 0x00}; - -uint16_t local_rg_cell_id; - -#ifdef PDCP_USE_NETLINK -extern void nasrg_netlink_release(void); -extern int nasrg_netlink_init(void); -#endif -extern void nasrg_ASCTL_timer(unsigned long data); - -#ifndef PDCP_USE_NETLINK -//--------------------------------------------------------------------------- -void *nasrg_interrupt(void) -{ - //--------------------------------------------------------------------------- - uint8_t cxi; -#ifdef NAS_DEBUG_INTERRUPT - printk("nasrg_interrupt - begin\n"); -#endif - - //spin_lock(&gpriv->lock); - for (cxi=0; cxi<NAS_CX_MAX; ++cxi) - nasrg_COMMON_QOS_receive(gpriv->cx+cxi); - - for (cxi=0; cxi<NAS_CX_MAX; ++cxi) - nasrg_ASCTL_DC_receive(gpriv->cx+cxi); - - //spin_unlock(&gpriv->lock); -#ifdef NAS_DEBUG_INTERRUPT - printk("nasrg_interrupt: end\n"); -#endif - // return 0; -} -#endif //NETLINK - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is activated by ifconfig -int nasrg_open(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - printk("nasrg_open: begin\n"); - - gpriv=netdev_priv(dev); - - // Address has already been set at init -#ifndef PDCP_USE_NETLINK - - if (gpriv->irq==-EBUSY) { - printk("nasrg_open: irq failure\n"); - return -EBUSY; - } - -#endif //NETLINK - - if(!netif_queue_stopped(dev)) - netif_start_queue(dev); - else - netif_wake_queue(dev); - - // - init_timer(&gpriv->timer); - (gpriv->timer).expires=jiffies+NAS_TIMER_TICK; - (gpriv->timer).data=0L; - (gpriv->timer).function=nasrg_ASCTL_timer; - add_timer(&gpriv->timer); - // - printk("nasrg_open: name = %s, end\n", dev->name); - return 0; -} - -//--------------------------------------------------------------------------- -// Called by ifconfig when the device is desactivated by ifconfig -int nasrg_stop(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - struct nas_priv *priv = netdev_priv(dev); - printk("nasrg_stop: begin\n"); - del_timer(&priv->timer); - netif_stop_queue(dev); - - printk("nasrg_stop: name = %s, end\n", dev->name); - return 0; -} - -//--------------------------------------------------------------------------- -void nasrg_teardown(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - int cxi; -#ifndef PDCP_USE_NETLINK - struct nas_priv *priv = netdev_priv(dev); -#endif //PDCP_USE_NETLINK - - printk("nasrg_teardown: begin\n"); - - if (dev) { -#ifndef PDCP_USE_NETLINK - - if (priv->irq!=-EBUSY) { - *pt_nas_rg_irq=-1; - rt_free_srq(priv->irq); - } - -#endif //PDCP_USE_NETLINK - -#ifdef PDCP_USE_NETLINK - nasrg_netlink_release(); -#endif //PDCP_USE_NETLINK - - // for (sapi=0; sapi<NAS_SAPI_MAX; ++sapi) - // close(priv->sap[sapi]); - nasrg_CLASS_flush_rclassifier(); - nasrg_CLASS_flush_mbmsclassifier(); - - for (cxi=0; cxi<NAS_CX_MAX; ++cxi) { - nasrg_COMMON_flush_rb(gpriv->cx+cxi); - nasrg_CLASS_flush_sclassifier(gpriv->cx+cxi); - //for (sapi=0; sapi<NAS_SAPI_CX_MAX; ++sapi) - // close(priv->cx[cxi].sap[sapi]); - } - } // check dev - else { - printk("nasmt_teardown: Device is null\n"); - } - - printk("nasrg_teardown: end\n"); -} - -//--------------------------------------------------------------------------- -int nasrg_set_config(struct net_device *dev, struct ifmap *map) -{ - //--------------------------------------------------------------------------- - printk("nasrg_set_config: begin\n"); - - if (dev->flags & IFF_UP) - return -EBUSY; - - if (map->base_addr != dev->base_addr) { - printk(KERN_WARNING "nasrg_set_config: Can't change I/O address\n"); - return -EOPNOTSUPP; - } - - if (map->irq != dev->irq) - dev->irq = map->irq; - - return 0; -} - -//--------------------------------------------------------------------------- -int nasrg_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_DEVICE - printk("nasrg_hard_start_xmit: begin\n"); -#endif - - if ((!skb )||(!dev)) { - printk("nasrg_hard_start_xmit - input parameter skb or dev is NULL \n"); - return -1; - } - - // End debug information - netif_stop_queue(dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_hard_start_xmit: step 1\n"); -#endif - nasrg_CLASS_send(skb); -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_hard_start_xmit: step 2\n"); -#endif - dev_kfree_skb(skb); -#ifdef NAS_DEBUG_SEND_DETAIL - printk("nasrg_hard_start_xmit: step 3\n"); -#endif - netif_wake_queue(dev); -#ifdef NAS_DEBUG_DEVICE - printk("nasrg_hard_start_xmit: end\n"); -#endif - return 0; -} - -//--------------------------------------------------------------------------- -struct net_device_stats *nasrg_get_stats(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - struct nas_priv *npriv = netdev_priv(dev); - return &npriv->stats; -} - -//--------------------------------------------------------------------------- -// New function from LITE DRIVER -int nasrg_set_mac_address(struct net_device *dev, void *mac) -{ - //--------------------------------------------------------------------------- - struct sockaddr *addr = mac; - printk("nasrg_set_mac_address: begin\n"); - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - return 0; -} - -//--------------------------------------------------------------------------- -int nasrg_change_mtu(struct net_device *dev, int mtu) -{ - //--------------------------------------------------------------------------- - printk("nasrg_change_mtu: begin\n"); - - if ((mtu<50) || (mtu>1500)) - // if ((mtu<1280) || (mtu>1500)) - return -EINVAL; - - dev->mtu = mtu; - return 0; -} - -//--------------------------------------------------------------------------- -int nasrg_change_rx_flags(struct net_device *dev, int flags) -{ - //--------------------------------------------------------------------------- - //struct nas_priv *priv = netdev_priv(dev); - printk("nasrg_change_rx_flags %08X\n", flags); - gpriv->rx_flags ^= flags; - return 0; -} - -//--------------------------------------------------------------------------- -void nasrg_tx_timeout(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - /* Transmitter timeout, serious problems. */ - printk("nasrg_tx_timeout: begin\n"); - // ((struct nas_priv *)(dev->priv))->stats.tx_errors++; - (gpriv->stats).tx_errors++; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif - netif_wake_queue(dev); - printk("nasrg_tx_timeout: transmit timed out %s\n",dev->name); -} - -//--------------------------------------------------------------------------- -// Define pointers for the module -static const struct net_device_ops nasrg_netdev_ops = { - // ?? nasrg_ interrupt - // - .ndo_open = nasrg_open, - .ndo_stop = nasrg_stop, - .ndo_start_xmit = nasrg_hard_start_xmit, - .ndo_validate_addr = NULL, - .ndo_get_stats = nasrg_get_stats, - //#ifdef KERNEL_VERSION_GREATER_THAN_32 - // .ndo_set_multicast_list = NULL, - .ndo_set_mac_address = nasrg_set_mac_address, - .ndo_set_config = nasrg_set_config, - .ndo_do_ioctl = nasrg_CTL_ioctl, - .ndo_change_mtu = nasrg_change_mtu, - .ndo_tx_timeout = nasrg_tx_timeout, - .ndo_change_rx_flags = nasrg_change_rx_flags, - //#endif -}; -//--------------------------------------------------------------------------- - - -//--------------------------------------------------------------------------- -// Initialisation of the network device -void nasrg_init(struct net_device *dev) -{ - //--------------------------------------------------------------------------- - uint8_t cxi, dscpi; - - printk("nasrg_init: begin\n"); - - if (dev) { - gpriv=netdev_priv(dev); - - memset(gpriv, 0, sizeof(struct nas_priv)); - // Initialize function pointers - dev->netdev_ops = &nasrg_netdev_ops; - -#ifndef NAS_DRIVER_TYPE_ETHERNET - dev->type = ARPHRD_EURUMTS; - dev->features = NETIF_F_NO_CSUM; - dev->hard_header_len = 0; - dev->addr_len = NAS_ADDR_LEN; - dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP; - dev->tx_queue_len = NAS_TX_QUEUE_LEN; - dev->mtu = NAS_MTU; -#endif - // Can be one of the following enum defined in include/linux/netdevice.h: - // enum netdev_state_t { - // __LINK_STATE_START, - // __LINK_STATE_PRESENT, - // __LINK_STATE_NOCARRIER, - // __LINK_STATE_LINKWATCH_PENDING, - // __LINK_STATE_DORMANT, - // }; - set_bit(__LINK_STATE_PRESENT, &dev->state); - -#ifdef NAS_DRIVER_TYPE_ETHERNET - // overwrite values written above ( header_ops,type,hard_header_len,mtu,addr_len,tx_queue_len,flags,broadcast) - printk("\nnasrg_init: WARNING Driver type ETHERNET\n"); - ether_setup(dev); -#endif - // - // Initialize private structure - gpriv->rx_flags = NAS_RESET_RX_FLAGS; - - gpriv->sap[NAS_GC_SAPI] = RRC_DEVICE_GC; - gpriv->sap[NAS_NT_SAPI] = RRC_DEVICE_NT; - gpriv->cx[0].sap[NAS_DC_INPUT_SAPI] = RRC_DEVICE_DC_INPUT0; - gpriv->cx[0].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT0; - gpriv->cx[1].sap[NAS_DC_INPUT_SAPI] = RRC_DEVICE_DC_INPUT1; - gpriv->cx[1].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT1; - // gpriv->sap[NAS_CO_INPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_INPUT; - // gpriv->sap[NAS_CO_OUTPUT_SAPI] = QOS_DEVICE_CONVERSATIONAL_OUTPUT; - gpriv->sap[NAS_DRB_INPUT_SAPI] = PDCP2PDCP_USE_RT_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; - gpriv->sap[NAS_DRB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; - // - gpriv->retry_limit=NAS_RETRY_LIMIT_DEFAULT; - gpriv->timer_establishment=NAS_TIMER_ESTABLISHMENT_DEFAULT; - gpriv->timer_release=NAS_TIMER_RELEASE_DEFAULT; - - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) - gpriv->rclassifier[dscpi]=NULL; - - gpriv->nrclassifier=0; - - // - for(cxi=0; cxi<NAS_CX_MAX; ++cxi) { -#ifdef NAS_DEBUG_DEVICE - printk("nasrg_init: init classifiers, state and timer for MTs %u\n", cxi); -#endif - gpriv->cx[cxi].state=NAS_IDLE; - gpriv->cx[cxi].countimer=NAS_TIMER_IDLE; - gpriv->cx[cxi].retry=0; - gpriv->cx[cxi].lcr=cxi; - gpriv->cx[cxi].rb=NULL; - gpriv->cx[cxi].num_rb=0; - - // initialisation of the classifier - for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) - gpriv->cx[cxi].sclassifier[dscpi]=NULL; - - gpriv->cx[cxi].nsclassifier=0; - // initialisation of the IP address - nasrg_TOOL_imei2iid(NAS_NULL_IMEI, (uint8_t *)gpriv->cx[cxi].iid6); - gpriv->cx[cxi].iid4=0; - } - - spin_lock_init(&gpriv->lock); - - nasrg_TOOL_RGimei2iid(NAS_RG_IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address) - printk("nasrg_init: init IMEI to IID\n"); - nasrg_ASCTL_init(); - } else { - printk("\n\nnasmt_init: ERROR, Device is NULL!!\n"); - } - - printk("nasrg_init: end\n"); - return ; -} - -//--------------------------------------------------------------------------- -int init_module (void) -{ - //--------------------------------------------------------------------------- - int err; - int inst = 0; - struct nas_priv *priv; - char devicename[100]; - - printk("\n\n\n\nnasrg_init_module: begin \n"); - - // Initialize parameters shared with RRC -#ifndef PDCP_USE_NETLINK - - if (pt_nas_rg_irq==NULL) { - printk("nasrg_init_module: shared irq parameter not initialised\n"); - err = -EBUSY; - printk("nasrg_init_module: returning %d \n\n", err); - return err; - } - - printk("nasrg_init_module: pt_nas_rg_irq valid \n"); -#endif - - /* - if (pt_rg_own_cell_id==NULL){ - printk("nasrg_init_module: shared cell_id parameter not initialised\n"); - err = -EBUSY; - printk("nasrg_init_module: returning %d \n\n\n", err); - return err; - } - printk("nasrg_init_module: pt_rg_own_cell_id valid \n"); - *pt_rg_own_cell_id = NASRG_OWN_CELLID; - */ - local_rg_cell_id = NASRG_OWN_CELLID; - - // Allocate device structure - sprintf(devicename,"oai%d",inst); -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) - gdev = alloc_netdev(sizeof(struct nas_priv), devicename, nasrg_init); -#else - gdev = alloc_netdev(sizeof(struct nas_priv), devicename, NET_NAME_PREDICTABLE, nasrg_init); -#endif - printk("nasrg_init_module: after alloc_netdev \n"); - priv = netdev_priv(gdev); - //// - // -#ifndef PDCP_USE_NETLINK - priv->irq=rt_request_srq(0, nasrg_interrupt, NULL); - - if (priv->irq == -EBUSY || priv->irq == -EINVAL) { - printk("nasrg_init_module: No interrupt resource available\n"); - - if (gdev) { - free_netdev(gdev); - printk("nasrg_init_module: free_netdev ..\n"); - } - - return -EBUSY; - } else - printk("nasrg_init_module: Interrupt %d, ret = %d \n", priv->irq , ret); - - if (pt_nas_rg_irq==NULL) { - printk("nasmt_init_module: shared irq parameter has been reset\n"); - } else { - *pt_nas_rg_irq=priv->irq; - } - -#endif - // - ////// -#ifdef PDCP_USE_NETLINK - - if ((err=nasrg_netlink_init()) < 0) - printk("nasrg_init_module: NETLINK failed\n"); - - printk("nasrg_init_module: NETLINK INIT successful\n"); -#endif //NETLINK - - err= register_netdev(gdev); - - if (err) { - printk("nasrg_init_module: error %i registering device %s\n", err, gdev->name); - } else { - printk("nasrg_init_module: registering device %s, ifindex = %d\n\n",gdev->name, gdev->ifindex); - } - - return err; -} - -//--------------------------------------------------------------------------- -void cleanup_module(void) -{ - //--------------------------------------------------------------------------- - printk("nasrg_cleanup_module: begin\n"); - unregister_netdev(gdev); - nasrg_teardown(gdev); - free_netdev(gdev); - printk("nasrg_cleanup_module: end\n\n\n\n"); -} - -//--------------------------------------------------------------------------- -// Replaced by init_module and cleanup_module -//module_init (nasrg_init_module); -//module_exit (nasrg_cleanup_module); -//--------------------------------------------------------------------------- - -#define DRV_NAME "oai_nasrg" -#define DRV_VERSION "3.0.1"DRV_NAME -#define DRV_DESCRIPTION "OPENAIR CELLULAR LTE NASRG (eNodeB) Device Driver" -#define DRV_COPYRIGHT "-Copyright(c) GNU GPL Eurecom 2013" -#define DRV_AUTHOR "Michelle Wetterwald <michelle.wetterwald@eurecom.fr>"DRV_COPYRIGHT - -// MODULE_LICENSE("GPL"); -// MODULE_DESCRIPTION("LTE Driver for eNodeB, playing as Non Access Stratum"); -// MODULE_AUTHOR("Michelle Wetterwald <michelle.wetterwald@eurecom.fr>"); diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_iocontrol.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_iocontrol.c deleted file mode 100644 index 3c8f5d3cc6e9f41ecb384168765ed3a47470f104..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_iocontrol.c +++ /dev/null @@ -1,906 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_iocontrol.c -* \brief I/O control functions for upper layers of driver for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#include "nasrg_variables.h" -#include "nasrg_iocontrol.h" -#include "nasrg_proto.h" - -//#include <linux/in.h> -#include <asm/uaccess.h> -#include <asm/checksum.h> -#include <asm/uaccess.h> - -// Statistic -/////////////////////////////////////////////////////////////////////////////// - -//--------------------------------------------------------------------------- -void nasrg_set_msg_statistic_reply(struct nas_msg_statistic_reply *msgrep) -{ - //--------------------------------------------------------------------------- - msgrep->rx_packets=gpriv->stats.rx_packets; - msgrep->tx_packets=gpriv->stats.tx_packets; - msgrep->rx_bytes=gpriv->stats.rx_bytes; - msgrep->tx_bytes=gpriv->stats.tx_bytes; - msgrep->rx_errors=gpriv->stats.rx_errors; - msgrep->tx_errors=gpriv->stats.tx_errors; - msgrep->rx_dropped=gpriv->stats.rx_dropped; - msgrep->tx_dropped=gpriv->stats.tx_dropped; -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_statistic_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_statistic_reply msgrep; - printk("nasrg_ioCTL_statistic: stat requested\n"); - nasrg_set_msg_statistic_reply(&msgrep); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_statistic: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - - -/////////////////////////////////////////////////////////////////////////////// -// Connections List -//--------------------------------------------------------------------------- -void nasrg_set_msg_cx_list_reply(uint8_t *msgrep) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - nasLocalConnectionRef_t lcr; - struct nas_msg_cx_list_reply *list; - msgrep[0]=NAS_CX_MAX; - list=(struct nas_msg_cx_list_reply *)(msgrep+1); - - for(lcr=0; lcr<NAS_CX_MAX; ++lcr) { - cx=nasrg_COMMON_search_cx(lcr); - list[lcr].lcr=lcr; - list[lcr].state=cx->state; - list[lcr].cellid=cx->cellid; - list[lcr].iid4=cx->iid4; - list[lcr].iid6[0]=cx->iid6[0]; - list[lcr].iid6[1]=cx->iid6[1]; - list[lcr].num_rb=cx->num_rb; - list[lcr].nsclassifier=cx->nsclassifier; - printk("nasrg_set_msg_cx_list: nsc=%u\n",cx->nsclassifier); - } -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_cx_list_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1]; - printk("nasrg_ioCTL_cx_list: connection list requested\n"); - nasrg_set_msg_cx_list_reply(msgrep); - - if (copy_to_user(gifr->msg, msgrep, NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1)) { - printk("nasrg_ioCTL_cx_list: copy_to_user failure\n"); - return -EFAULT; - } - - printk("nasrg_ioCTL_cx_list: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connection Establishment -//--------------------------------------------------------------------------- -void nasrg_set_msg_cx_establishment_reply(struct nas_msg_cx_establishment_reply *msgrep, struct nas_msg_cx_establishment_request *msgreq) -{ - //--------------------------------------------------------------------------- - msgrep->status=-NAS_ERROR_NOTMT; -} -//--------------------------------------------------------------------------- -int nasrg_ioCTL_cx_establishment_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_cx_establishment_request msgreq; - struct nas_msg_cx_establishment_reply msgrep; - printk("nasrg_ioCTL_cx_establishment: connection establishment requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_cx_establishment: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_cx_establishment_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_cx_establishment: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Connection Release -//--------------------------------------------------------------------------- -void nasrg_set_msg_cx_release_reply(struct nas_msg_cx_release_reply *msgrep, struct nas_msg_cx_release_request *msgreq) -{ - //--------------------------------------------------------------------------- - msgrep->status=-NAS_ERROR_NOTMT; -} - -//--------------------------------------------------------------------------- -// Request the release of a connection -int nasrg_ioCTL_cx_release_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_cx_release_request msgreq; - struct nas_msg_cx_release_reply msgrep; - - printk("nasrg_set_msg_cx_release: connection release requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_set_msg_cx_release: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_cx_release_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_set_msg_cx_release: copy_to_user failure\n"); - return -EFAULT; - } - - printk("nasrg_set_msg_cx_release: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer List -//--------------------------------------------------------------------------- -void nasrg_set_msg_rb_list_reply(uint8_t *msgrep, struct nas_msg_rb_list_request *msgreq) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - cx=nasrg_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) { - uint8_t rbi; - struct rb_entity *rb; - struct nas_msg_rb_list_reply *list; - - if (cx->num_rb > NAS_LIST_RB_MAX) - msgrep[0] = NAS_LIST_RB_MAX; - else - msgrep[0] = cx->num_rb; - - list=(struct nas_msg_rb_list_reply *)(msgrep+1); - - // list all radio bearers - for (rb=cx->rb, rbi=0; (rb!=NULL)&&(rbi<msgrep[0]); rb=rb->next, ++rbi) { - list[rbi].state=rb->state; - list[rbi].rab_id=rb->rab_id; - list[rbi].sapi=rb->sapi; - list[rbi].qos=rb->qos; - list[rbi].cnxid=rb->cnxid; - } - - // check if mt0 requested and multicast bearer started, then add it to the list - if ((msgreq->lcr==0)&&(gpriv->mbms_rb[0].mbms_rbId!=0)) { - printk("MT %d, MBMS bearer rb_id %d\n", msgreq->lcr, gpriv->mbms_rb[0].mbms_rbId); - //++rbi; - ++msgrep[0]; - list[rbi].state=gpriv->mbms_rb[0].state; - list[rbi].rab_id=gpriv->mbms_rb[0].mbms_rbId; - list[rbi].sapi=gpriv->mbms_rb[0].sapi; - list[rbi].qos=gpriv->mbms_rb[0].qos; - list[rbi].cnxid=gpriv->mbms_rb[0].cnxid; - printk("rab_id cnxid Sapi QoS State\n"); - printk("%u %u %u %u ", list[rbi].rab_id,list[rbi].cnxid, list[rbi].sapi, list[rbi].qos); - nasrg_TOOL_print_state(list[rbi].state); - printk("\n"); - } - } else - msgrep[0]=0; -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_rb_list_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1]; - struct nas_msg_rb_list_request msgreq; - printk("nasrg_ioCTL_rb_list: Radio Bearer list requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_rb_list: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_rb_list_reply(msgrep, &msgreq); - - if (copy_to_user(gifr->msg, msgrep, NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1)) { - printk("nasrg_ioCTL_rb_list: copy_to_user failure\n"); - return -EFAULT; - } - - printk("nasrg_ioCTL_rb_list: end\n"); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer Establishment -//--------------------------------------------------------------------------- -void nasrg_set_msg_rb_establishment_reply(struct nas_msg_rb_establishment_reply *msgrep, struct nas_msg_rb_establishment_request *msgreq) -{ - //--------------------------------------------------------------------------- - if ((msgreq->rab_id<5)||(msgreq->rab_id>(NAS_RB_MAX_NUM-1))) - msgrep->status=-NAS_ERROR_NOTCORRECTRABI; - else { - struct cx_entity *cx; - cx=nasrg_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) { //not multicast - struct rb_entity *rb; - rb=nasrg_COMMON_add_rb(cx, msgreq->rab_id, msgreq->qos); - - if (rb!=NULL) { - rb->cnxid = msgreq->cnxid; - rb->dscp = msgreq->dscp_dl; - rb->dscp_ul = msgreq->dscp_ul; - msgrep->status=nasrg_ASCTL_DC_send_rb_establish_request(cx, rb); - } else { - msgrep->status=-NAS_ERROR_NOMEMORY; - } - } else { //no MT found - if (msgreq->mcast_flag) { //multicast - int mbms_ix=0; // should allocate index based on Service_id /cnxid / MC IP address - // - gpriv->mbms_rb[mbms_ix].cnxid = msgreq->cnxid; - gpriv->mbms_rb[mbms_ix].serviceId = msgreq->cnxid; - gpriv->mbms_rb[mbms_ix].sessionId = NASRG_TEMP_MBMS_SESSION_ID; //Temp hard coded - gpriv->mbms_rb[mbms_ix].mbms_rbId = msgreq->rab_id; - gpriv->mbms_rb[mbms_ix].sapi = NAS_DC_INPUT_SAPI; -#ifdef NAS_DEBUG_MBMS_PROT - gpriv->mbms_rb[mbms_ix].sapi = NAS_DRB_INPUT_SAPI; //Only one RT-FIFO is used -#endif - gpriv->mbms_rb[mbms_ix].qos = msgreq->qos; - gpriv->mbms_rb[mbms_ix].dscp = msgreq->dscp_dl; - gpriv->mbms_rb[mbms_ix].duration = NASRG_TEMP_MBMS_DURATION; //Temp hard coded - memcpy ((char *)&(gpriv->mbms_rb[mbms_ix].mcast_address),(char *)&(msgreq->mcast_group), 16); - msgrep->status=nasrg_ASCTL_GC_send_mbms_bearer_establish_req(mbms_ix); - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - } - - msgrep->cnxid = msgreq->cnxid; - } - } -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_rb_establishment_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_rb_establishment_request msgreq; - struct nas_msg_rb_establishment_reply msgrep; - printk("nasrg_ioCTL_rb_establishment: Radio bearer establishment requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_rb_establishment: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_rb_establishment_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_rb_establishment: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Radio Bearer Release -//--------------------------------------------------------------------------- -void nasrg_set_msg_rb_release_reply(struct nas_msg_rb_release_reply *msgrep, struct nas_msg_rb_release_request *msgreq) -{ - //--------------------------------------------------------------------------- - if (msgreq->lcr<NAS_CX_MAX) { - if (msgreq->rab_id!=NASRG_DEFAULTRAB_RBID) { - struct rb_entity *rb; - struct cx_entity *cx; - cx=nasrg_COMMON_search_cx(msgreq->lcr); - rb=nasrg_COMMON_search_rb(cx, msgreq->rab_id); - - if ((rb!=NULL)&&(cx!=NULL)) { - uint8_t dscp; - msgrep->status=nasrg_ASCTL_DC_send_rb_release_request(cx, rb); - dscp=rb->dscp; - nasrg_COMMON_del_rb(cx, msgreq->rab_id, dscp); - } else - msgrep->status=-NAS_ERROR_NOTCONNECTED; - - msgrep->cnxid = msgreq->cnxid; - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTRABI; - } - } else { - if (msgreq->mcast_flag) { // multicast - int mbms_ix=0; // should search mbms_ix based on cnxid - msgrep->status=nasrg_ASCTL_GC_send_mbms_bearer_release_req(mbms_ix); - msgrep->cnxid = msgreq->cnxid; - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - } - } -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_rb_release_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_rb_release_request msgreq; - struct nas_msg_rb_release_reply msgrep; - printk("nasrg_ioCTL_rb_release: Radio bearer release requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_rb_release: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_rb_release_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_rb_release: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Classifier List -//--------------------------------------------------------------------------- -void nasrg_set_msg_class_list_reply(uint8_t *msgrep, struct nas_msg_class_list_request *msgreq) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - struct classifier_entity *gc; - struct nas_msg_class_list_reply *list; - uint8_t cli; - list=(struct nas_msg_class_list_reply *)(msgrep+1); - - switch(msgreq->dir) { - case NAS_DIRECTION_SEND: - cx=nasrg_COMMON_search_cx(msgreq->lcr); - - if (cx==NULL) { - msgrep[0]=0; - return; - } - - gc=cx->sclassifier[msgreq->dscp]; - break; - - case NAS_DIRECTION_RECEIVE: - cx=NULL; - gc=gpriv->rclassifier[msgreq->dscp]; - break; - - default: - cx=NULL; - msgrep[0]=0; - return; - } - - for (cli=0; (gc!=NULL)&&(cli<NAS_LIST_CLASS_MAX); gc=gc->next, ++cli) { - list[cli].classref=gc->classref; - list[cli].lcr=msgreq->lcr; - list[cli].dir=msgreq->dir; - list[cli].dscp=msgreq->dscp; - list[cli].rab_id=gc->rab_id; - list[cli].version=gc->version; - - switch(gc->version) { - case 4: - list[cli].saddr.ipv4 = gc->saddr.ipv4; - list[cli].daddr.ipv4 = gc->daddr.ipv4; - break; - - case 6: - list[cli].saddr.ipv6 = gc->saddr.ipv6; - list[cli].daddr.ipv6 = gc->daddr.ipv6; - break; - } - - list[cli].protocol=gc->protocol; - list[cli].sport=ntohs(gc->sport); - list[cli].dport=ntohs(gc->dport); - list[cli].splen=gc->splen; - list[cli].dplen=gc->dplen; - list[cli].fct=nasrg_TOOL_invfct(gc); - } - - msgrep[0]=cli; -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_class_list_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - uint8_t msgrep[NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1]; - struct nas_msg_class_list_request msgreq; - printk("nasrg_ioCTL_class_list: classifier list requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_class_list: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_class_list_reply(msgrep, &msgreq); - - if (copy_to_user(gifr->msg, msgrep, NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1)) { - printk("nasrg_ioCTL_class_list: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Request the addition of a classifier rule -//--------------------------------------------------------------------------- -void nasrg_set_msg_class_add_reply(struct nas_msg_class_add_reply *msgrep, struct nas_msg_class_add_request *msgreq) -{ - //--------------------------------------------------------------------------- - struct classifier_entity *gc; - - if (msgreq->dscp>NAS_DSCP_DEFAULT) { - printk("nasrg_set_msg_class_add: Incoherent parameter value\n"); - msgrep->status=-NAS_ERROR_NOTCORRECTDSCP; - return; - } - - if (msgreq->dir==NAS_DIRECTION_SEND) { - struct cx_entity *cx; - cx=nasrg_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) { - printk("nasrg_set_msg_class_add: DSCP %d, Classref %d\n",msgreq->dscp, msgreq->classref ); - gc=nasrg_CLASS_add_sclassifier(cx, msgreq->dscp, msgreq->classref); - printk("nasrg_set_msg_class_add: %p %p\n" , msgreq, gc); - - if (gc==NULL) { - msgrep->status=-NAS_ERROR_NOMEMORY; - return; - } - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - return; - } - - gc->rab_id=msgreq->rab_id; - gc->rb=nasrg_COMMON_search_rb(cx, gc->rab_id); - } else { - if (msgreq->dir==NAS_DIRECTION_RECEIVE) { - gc=nasrg_CLASS_add_rclassifier(msgreq->dscp, msgreq->classref); - - if (gc==NULL) { - msgrep->status=-NAS_ERROR_NOMEMORY; - return; - } - } else { - msgrep->status=-NAS_ERROR_NOTCORRECTDIR; - return; - } - } - - nasrg_TOOL_fct(gc, msgreq->fct); - gc->version=msgreq->version; - - switch(gc->version) { - case 4: - gc->saddr.ipv4=msgreq->saddr.ipv4; - gc->daddr.ipv4=msgreq->daddr.ipv4; - gc->splen=msgreq->splen; - gc->dplen=msgreq->dplen; - break; - - case 6: - gc->saddr.ipv6=msgreq->saddr.ipv6; - gc->daddr.ipv6=msgreq->daddr.ipv6; - gc->splen=msgreq->splen; - gc->dplen=msgreq->dplen; - break; - - case 0: - gc->saddr.ipv6.s6_addr32[0]=0; - gc->daddr.ipv6.s6_addr32[1]=0; - gc->saddr.ipv6.s6_addr32[2]=0; - gc->daddr.ipv6.s6_addr32[3]=0; - gc->splen=0; - gc->dplen=0; - break; - - default: - msgrep->status=-NAS_ERROR_NOTCORRECTVERSION; - kfree(gc); - return; - } - - gc->protocol=msgreq->protocol; - gc->sport=htons(msgreq->sport); - gc->dport=htons(msgreq->dport); - msgrep->status=0; -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_class_add_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_class_add_request msgreq; - struct nas_msg_class_add_reply msgrep; - printk("nasrg_ioCTL_class_add: Add classifier components requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_class_add: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_class_add_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_class_add: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// Request the deletion of a classifier rule -//--------------------------------------------------------------------------- -void nasrg_set_msg_class_del_reply(struct nas_msg_class_del_reply *msgrep, struct nas_msg_class_del_request *msgreq) -{ - //--------------------------------------------------------------------------- - if (msgreq->dscp>NAS_DSCP_DEFAULT) { - printk("nasrg_set_msg_class_del: Incoherent parameter value\n"); - msgrep->status=-NAS_ERROR_NOTCORRECTDSCP; - return; - } - - if (msgreq->dir==NAS_DIRECTION_SEND) { - struct cx_entity *cx; - cx=nasrg_COMMON_search_cx(msgreq->lcr); - - if (cx!=NULL) - nasrg_CLASS_del_sclassifier(cx, msgreq->dscp, msgreq->classref); - else { - msgrep->status=-NAS_ERROR_NOTCORRECTLCR; - return; - } - } else { - if (msgreq->dir==NAS_DIRECTION_RECEIVE) - nasrg_CLASS_del_rclassifier(msgreq->dscp, msgreq->classref); - else { - msgrep->status=-NAS_ERROR_NOTCORRECTDIR; - return; - } - } - - msgrep->status=0; -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_class_del_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_class_del_request msgreq; - struct nas_msg_class_del_reply msgrep; - printk("nasrg_ioCTL_class_del: Del classifier components requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_class_del: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_class_del_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_class_del: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// UE Multicast Join -//--------------------------------------------------------------------------- -void nasrg_set_ue_multicast_join_reply(struct nas_msg_mt_mcast_reply *msgrep, struct nas_msg_mt_mcast_join *msgreq) -{ - //--------------------------------------------------------------------------- - if (msgreq->ue_id<NAS_CX_MAX) { - struct cx_entity *cx; - cx=nasrg_COMMON_search_cx(msgreq->ue_id); - cx->requested_joined_services[0] = msgreq->cnxid; - msgrep->ue_id = msgreq->ue_id; - msgrep->result = nasrg_ASCTL_DC_send_mbms_ue_notify_req(cx); - msgrep->cnxid = msgreq->cnxid; - } else { - msgrep->result=-NAS_ERROR_NOTCORRECTLCR; - } -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_ue_multicast_join_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_mt_mcast_join msgreq; - struct nas_msg_mt_mcast_reply msgrep; - printk("nasrg_ioCTL_ue_multicast_join: UE multicast join requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_ue_multicast_join: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_ue_multicast_join_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_ue_multicast_join: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// UE Multicast Leave -//--------------------------------------------------------------------------- -void nasrg_set_ue_multicast_leave_reply(struct nas_msg_mt_mcast_reply *msgrep, struct nas_msg_mt_mcast_leave *msgreq) -{ - //--------------------------------------------------------------------------- - if (msgreq->ue_id<NAS_CX_MAX) { - struct cx_entity *cx; - cx=nasrg_COMMON_search_cx(msgreq->ue_id); - cx->requested_left_services[0] = msgreq->cnxid; - msgrep->ue_id = msgreq->ue_id; - msgrep->result = nasrg_ASCTL_DC_send_mbms_ue_notify_req(cx); - msgrep->cnxid = msgreq->cnxid; - } else { - msgrep->result=-NAS_ERROR_NOTCORRECTLCR; - } -} - -//--------------------------------------------------------------------------- -int nasrg_ioCTL_ue_multicast_leave_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_mt_mcast_leave msgreq; - struct nas_msg_mt_mcast_reply msgrep; - printk("nasrg_ioCTL_ue_multicast_leave: UE multicast leave requested\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_ue_multicast_leave: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_ue_multicast_leave_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_ue_multicast_leave: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// ENB Measures -// Messages for triggering measurement -//--------------------------------------------------------------------------- -void nasrg_set_msg_eNBmeasure_trigger_reply(struct nas_msg_enb_measure_trigger_reply *msgrep, struct nas_msg_enb_measure_trigger *msgreq) -{ - //--------------------------------------------------------------------------- - struct cx_entity *cx; - int lcr=0; // Temp lcr->mt =0 (should be GC uplink) - - cx=nasrg_COMMON_search_cx(lcr); - - if (msgreq->cell_id != cx->cellid) - printk("\nERROR : invalid cell_id received\n\n"); - - if (nasrg_ASCTL_DC_send_eNBmeasurement_req(cx)>0) - msgrep->status = 0; - else - msgrep->status = NAS_ERROR_NOTCORRECTVALUE ; -} -//--------------------------------------------------------------------------- -int nasrg_ioCTL_eNBmeasure_trigger_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_enb_measure_trigger msgreq; - struct nas_msg_enb_measure_trigger_reply msgrep; - printk("nasrg_ioCTL_eNBmeasure_trigger_request: Measures triggered\n"); - - if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) { - printk("nasrg_ioCTL_eNBmeasure_trigger_request: copy_from_user failure\n"); - return -EFAULT; - } - - nasrg_set_msg_eNBmeasure_trigger_reply(&msgrep, &msgreq); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_eNBmeasure_trigger_request: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// ENb Measurement -// Messages for Measurement retrieval -//--------------------------------------------------------------------------- -void nasrg_set_msg_eNBmeasure_retrieve_reply(struct nas_msg_enb_measure_retrieve *msgrep) -{ - //--------------------------------------------------------------------------- - int i; - - msgrep->cell_id = gpriv->measured_cell_id; - msgrep->num_UEs = gpriv->num_UEs; - - for (i=0; i<gpriv-> num_UEs; i++) { - msgrep->measures[i].rlcBufferOccupancy = gpriv->rlcBufferOccupancy[i]; - msgrep->measures[i].scheduledPRB = gpriv->scheduledPRB[i]; - msgrep->measures[i].totalDataVolume = gpriv->totalDataVolume[i]; - //clean variables - gpriv->rlcBufferOccupancy[i] = 0; - gpriv->scheduledPRB[i] = 0; - gpriv->totalDataVolume[i] = 0; - } - - msgrep->totalNumPRBs = gpriv->totalNumPRBs; - //clean variable - gpriv->totalNumPRBs = 0; -} -//--------------------------------------------------------------------------- -int nasrg_ioCTL_eNBmeasure_retrieve_request(struct nas_ioctl *gifr) -{ - //--------------------------------------------------------------------------- - struct nas_msg_enb_measure_retrieve msgrep; - printk("nasrg_ioCTL_eNBmeasure_retrieve_request: Measurement requested\n"); - - nasrg_set_msg_eNBmeasure_retrieve_reply(&msgrep); - - if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) { - printk("nasrg_ioCTL_eNBmeasure_retrieve_request: copy_to_user failure\n"); - return -EFAULT; - } - - return 0; -} - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IOCTL command -//--------------------------------------------------------------------------- -int nasrg_CTL_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - //--------------------------------------------------------------------------- - struct nas_ioctl *gifr; - int r; - printk("nasrg_CTL_ioctl: begin\n"); - spin_lock(&gpriv->lock); - - switch(cmd) { - case NASRG_IOCTL_RAL: - gifr=(struct nas_ioctl *)ifr; - - switch(gifr->type) { - case NAS_MSG_STATISTIC_REQUEST: - r=nasrg_ioCTL_statistic_request(gifr); - break; - - case NAS_MSG_CX_ESTABLISHMENT_REQUEST: - r=nasrg_ioCTL_cx_establishment_request(gifr); - break; - - case NAS_MSG_CX_RELEASE_REQUEST: - r=nasrg_ioCTL_cx_release_request(gifr); - break; - - case NAS_MSG_CX_LIST_REQUEST: - r=nasrg_ioCTL_cx_list_request(gifr); - break; - - case NAS_MSG_RB_ESTABLISHMENT_REQUEST: - r=nasrg_ioCTL_rb_establishment_request(gifr); - break; - - case NAS_MSG_RB_RELEASE_REQUEST: - r=nasrg_ioCTL_rb_release_request(gifr); - break; - - case NAS_MSG_RB_LIST_REQUEST: - r=nasrg_ioCTL_rb_list_request(gifr); - break; - - case NAS_MSG_CLASS_ADD_REQUEST: - r=nasrg_ioCTL_class_add_request(gifr); - break; - - case NAS_MSG_CLASS_LIST_REQUEST: - r=nasrg_ioCTL_class_list_request(gifr); - break; - - case NAS_MSG_CLASS_DEL_REQUEST: - r=nasrg_ioCTL_class_del_request(gifr); - break; - - case NAS_RG_MSG_MT_MCAST_JOIN: - r=nasrg_ioCTL_ue_multicast_join_request(gifr); - break; - - case NAS_RG_MSG_MT_MCAST_LEAVE: - r=nasrg_ioCTL_ue_multicast_leave_request(gifr); - break; - - case NAS_MSG_ENB_MEAS_TRIGGER: - r=nasrg_ioCTL_eNBmeasure_trigger_request(gifr); - break; - - case NAS_MSG_ENB_MEAS_RETRIEVE: - r=nasrg_ioCTL_eNBmeasure_retrieve_request(gifr); - break; - - default: - printk("nasrg_CTL_ioctl: unkwon request type, type=%x\n", gifr->type); - r=-EFAULT; - } - - break; - - default: - printk("nasrg_CTL_ioctl: Unknown ioctl command, cmd=%x\n", cmd); - r=-EFAULT; - } - - spin_unlock(&gpriv->lock); - printk("nasrg_CTL_ioctl: end\n"); - return r; -} - -//--------------------------------------------------------------------------- -void nasrg_CTL_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - printk("nasrg_CTL_send - void \n"); -} - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_iocontrol.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_iocontrol.h deleted file mode 100644 index bd7baac3b63bbb2d3e948d3bc40a99a9517f8f78..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_iocontrol.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_iocontrol.h -* \brief I/O control constnats and structures for upper layers of driver for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef NASRGD_CTL_H -#define NASRGD_CTL_H - -#include <asm/byteorder.h> -#include <asm/types.h> -#include <linux/udp.h> -#include <linux/tcp.h> - -#define NAS_MSG_MAXLEN 1100 - -// type of CTL message -#define NAS_MSG_STATISTIC_REQUEST 1 -#define NAS_MSG_STATISTIC_REPLY 2 -#define NAS_MSG_ECHO_REQUEST 3 -#define NAS_MSG_ECHO_REPLY 4 -#define NAS_MSG_CX_ESTABLISHMENT_REQUEST 5 -#define NAS_MSG_CX_ESTABLISHMENT_REPLY 6 -#define NAS_MSG_CX_RELEASE_REQUEST 7 -#define NAS_MSG_CX_RELEASE_REPLY 8 -#define NAS_MSG_CX_LIST_REQUEST 9 -#define NAS_MSG_CX_LIST_REPLY 10 -#define NAS_MSG_RB_ESTABLISHMENT_REQUEST 11 -#define NAS_MSG_RB_ESTABLISHMENT_REPLY 12 -#define NAS_MSG_RB_RELEASE_REQUEST 13 -#define NAS_MSG_RB_RELEASE_REPLY 14 -#define NAS_MSG_RB_LIST_REQUEST 15 -#define NAS_MSG_RB_LIST_REPLY 16 -#define NAS_MSG_CLASS_ADD_REQUEST 17 -#define NAS_MSG_CLASS_ADD_REPLY 18 -#define NAS_MSG_CLASS_DEL_REQUEST 19 -#define NAS_MSG_CLASS_DEL_REPLY 20 -#define NAS_MSG_CLASS_LIST_REQUEST 21 -#define NAS_MSG_CLASS_LIST_REPLY 22 -#define NAS_MSG_NEIGHBOUR_REQUEST 23 -#define NAS_MSG_NEIGHBOUR_REPLY 24 -//MBMS -#define NAS_RG_MSG_MT_MCAST_JOIN 30 -#define NAS_RG_MSG_MT_MCAST_LEAVE 31 -#define NAS_RG_MSG_MT_MCAST_REPLY 32 -// ENB MEASURES (MEDIEVAL DEMO 3) -#define NAS_MSG_ENB_MEAS_TRIGGER 33 -#define NAS_MSG_ENB_MEAS_RETRIEVE 34 - - -// Max number of entry of a message list -#define NAS_LIST_CX_MAX 32 -#define NAS_LIST_RB_MAX 32 -#define NAS_LIST_CLASS_MAX 32 - -typedef uint16_t nasMsgType_t; - -struct nas_ioctl { - char name[IFNAMSIZ]; - nasMsgType_t type; - char *msg; -}; - -//**** -struct nas_msg_statistic_reply { - uint32_t rx_packets; - uint32_t tx_packets; - uint32_t rx_bytes; - uint32_t tx_bytes; - uint32_t rx_errors; - uint32_t tx_errors; - uint32_t rx_dropped; - uint32_t tx_dropped; -}; - -//**** -struct nas_msg_cx_list_reply { - nasLocalConnectionRef_t lcr; // Local Connection reference - uint8_t state; - nasCellID_t cellid; // cell identification - uint32_t iid6[2]; // IPv6 interface identification - uint8_t iid4; // IPv4 interface identification - uint16_t num_rb; - uint16_t nsclassifier; -}; -//**** -struct nas_msg_cx_establishment_reply { - int status; -}; -struct nas_msg_cx_establishment_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasCellID_t cellid; // Cell identification -}; -//**** -struct nas_msg_cx_release_reply { - int status; -}; -struct nas_msg_cx_release_request { - nasLocalConnectionRef_t lcr; // Local Connection reference -}; - -//**** -struct nas_msg_rb_list_reply { - nasRadioBearerId_t rab_id; - nasSapId_t sapi; - nasQoSTrafficClass_t qos; - uint8_t state; - uint32_t cnxid; -}; -struct nas_msg_rb_list_request { - nasLocalConnectionRef_t lcr; // Local Connection reference -}; -//**** -struct nas_msg_rb_establishment_reply { - int status; - uint32_t cnxid; -}; -struct nas_msg_rb_establishment_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; - nasQoSTrafficClass_t qos; - uint16_t dscp_ul; - uint16_t dscp_dl; - uint16_t mcast_flag; - uint8_t mcast_group[16]; - uint32_t cnxid; -}; - -//**** -struct nas_msg_rb_release_reply { - int status; - uint32_t cnxid; -}; -struct nas_msg_rb_release_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; - uint16_t mcast_flag; - uint32_t cnxid; -}; - -//**** -struct nas_msg_class_add_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - nasRadioBearerId_t rab_id; - uint8_t dir; // direction (send or receive) - uint8_t dscp; // codepoint - uint8_t fct; - uint16_t classref; - uint8_t version; - union { - struct in6_addr ipv6; - uint32_t ipv4; - } saddr; // IP source address - uint8_t splen; // prefix length - union { - struct in6_addr ipv6; - uint32_t ipv4; - } daddr; // IP destination address - uint8_t dplen; // prefix length - uint8_t protocol; // high layer protocol type - uint16_t sport; // source port - uint16_t dport; // destination port -}; -struct nas_msg_class_add_reply { - int status; -}; -//**** -struct nas_msg_class_del_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - uint8_t dir; // direction (send or receive) - uint8_t dscp; // codepoint - uint16_t classref; -}; -struct nas_msg_class_del_reply { - int status; -}; -//**** -#define nas_msg_class_list_reply nas_msg_class_add_request -struct nas_msg_class_list_request { - nasLocalConnectionRef_t lcr; // Local Connection reference - uint8_t dir; - uint8_t dscp; -}; - -//**** -struct nas_msg_neighbour_cell_list_reply { - nasCellID_t cellid; // cell identification - uint32_t iid6[4]; // IPv6 address of access router -}; - -//MBMS -//**** -struct nas_msg_mt_mcast_join { - nasLocalConnectionRef_t ue_id; - uint32_t cnxid; - nasRadioBearerId_t rab_id; -}; - -struct nas_msg_mt_mcast_leave { - nasLocalConnectionRef_t ue_id; - uint32_t cnxid; - nasRadioBearerId_t rab_id; -}; - -struct nas_msg_mt_mcast_reply { - nasLocalConnectionRef_t ue_id; - uint32_t cnxid; - int result; -}; -//**** - -//MEDIEVAL DEMO 3 -//**** -struct nas_msg_enb_measure_trigger { - nasCellID_t cell_id; -}; -struct nas_msg_enb_measure_trigger_reply { - int status; -}; - -struct nas_msg_enb_measure_retrieve { - nasCellID_t cell_id; - nasNumConnUEs_t num_UEs; - nasENbMeasures_t measures[MAX_MEASURE_UE]; - nasENbMeasure_t totalNumPRBs; -}; - - -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c deleted file mode 100644 index d0a3516567f952089b11e17796d8cf5bdf98b577..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_netlink.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_netlink.c -* \brief Netlink socket functions for OpenAirInterface CELLULAR version - MT -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -//#include <linux/config.h> -#include <linux/socket.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/netlink.h> -#include <net/sock.h> -#include <linux/kthread.h> - -#include <linux/mutex.h> - -#include "nasrg_variables.h" -#include "nasrg_proto.h" - -static struct sock *nas_nl_sk = NULL; -static struct sock *nas_rrcnl_sk = NULL; - -//static int exit_netlink_thread=0; -static DEFINE_MUTEX(nasrg_mutex); - -// This can also be implemented using thread to get the data from PDCP without blocking. -//--------------------------------------------------------------------------- -// Function for transfer with PDCP (from NASLITE) -static void nasrg_nl_data_ready (struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct nlmsghdr *nlh = NULL; - - // Start debug information -#ifdef NETLINK_DEBUG - printk("nasrg_nl_data_ready - begin \n"); -#endif - - if (!skb) { - printk("nasrg_nl_data_ready - input parameter skb is NULL \n"); - return; - } - - // End debug information - -#ifdef NETLINK_DEBUG - printk("nasrg_nl_data_ready - Received socket from PDCP\n"); -#endif //NETLINK_DEBUG - nlh = (struct nlmsghdr *)skb->data; - nasrg_COMMON_QOS_receive(nlh); -} - -//--------------------------------------------------------------------------- -// Function for transfer with RRC -static void nasrg_rrcnl_data_ready (struct sk_buff *skb) -{ - //--------------------------------------------------------------------------- - struct nlmsghdr *nlh = NULL; - char target_sap; - uint8_t cxi; - - // Start debug information -#ifdef NAS_DEBUG_RRCNL - printk("nasrg_rrcnl_data_ready - begin \n"); -#endif - - if (!skb) { - printk("nasrg_rrcnl_data_ready - input parameter skb is NULL \n"); - return; - } - - // End debug information - - nlh = (struct nlmsghdr *)skb->data; - //pdcph = (struct pdcp_data_ind_header_t *)NLMSG_DATA(nlh); - //nasrg_TOOL_print_buffer((char *)NLMSG_DATA(nlh), 48); - - target_sap = ((char*)NLMSG_DATA(nlh))[0]; -#ifdef NAS_DEBUG_RRCNL - printk("nasrg_rrcnl_data_ready - Received on socket from RRC, SAP %d\n", target_sap); -#endif //NAS_DEBUG_RRCNL - - switch (target_sap) { - case RRC_NAS_DC0_OUT: - //printk("nasrg_rrcnl_data_ready - Calling nasrg_ASCTL_DC_receive\n"); - cxi = 0; - nasrg_ASCTL_DC_receive(gpriv->cx+cxi, &((char*)NLMSG_DATA(nlh))[1]); - break; - - case RRC_NAS_DC1_OUT: - //printk("nasrg_rrcnl_data_ready - Calling nasrg_ASCTL_DC_receive\n"); - cxi = 1; - nasrg_ASCTL_DC_receive(gpriv->cx+cxi, &((char*)NLMSG_DATA(nlh))[1]); - break; - - case RRC_NAS_DC2_OUT: - //printk("nasrg_rrcnl_data_ready - Calling nasrg_ASCTL_DC_receive\n"); - cxi = 2; - nasrg_ASCTL_DC_receive(gpriv->cx+cxi, &((char*)NLMSG_DATA(nlh))[1]); - break; - - default: - printk("nasrg_rrcnl_data_ready - Invalid SAP value received\n"); - } - -} - -//--------------------------------------------------------------------------- -int nasrg_netlink_init(void) -{ - //--------------------------------------------------------------------------- - printk("nasrg_netlink_init - begin \n"); - - nas_nl_sk = netlink_kernel_create(&init_net,OAI_IP_DRIVER_NETLINK_ID, 0, nasrg_nl_data_ready, - &nasrg_mutex, // NULL - THIS_MODULE); - - if (!nas_nl_sk) { - printk("nasrg_netlink_init - netlink_kernel_create failed for PDCP socket\n"); - // TEMP printk("nasrg_netlink_init - netlink_kernel_create failed for PDCP socket %d\n", errno); - return(-1); - } - - nas_rrcnl_sk = netlink_kernel_create(&init_net,NAS_RRCNL_ID, 0, nasrg_rrcnl_data_ready, - &nasrg_mutex, // NULL - THIS_MODULE); - - if (!nas_rrcnl_sk) { - printk("nasrg_rrcnl_init - netlink_kernel_create failed for RRC socket\n"); - return(-1); - } - - return(0); -} - -//--------------------------------------------------------------------------- -void nasrg_netlink_release(void) -{ - //--------------------------------------------------------------------------- - printk("nasrg_netlink_release - begin \n"); - - //exit_netlink_thread=1; - printk("nasrg_netlink_release - Releasing netlink sockets\n"); - - if(nas_nl_sk) { - netlink_kernel_release(nas_nl_sk); - } - - if(nas_rrcnl_sk) { - netlink_kernel_release(nas_rrcnl_sk); - } - -} - -//--------------------------------------------------------------------------- -int nasrg_netlink_send(unsigned char *data_buffer, unsigned int data_length, int destination) -{ - //--------------------------------------------------------------------------- - struct sk_buff *nl_skb; - struct nlmsghdr *nlh; - int status; - // Start debug information -#ifdef NETLINK_DEBUG - printk("nasrg_netlink_send - begin \n"); -#endif - - if (!data_buffer) { - printk("nasrg_netlink_send - ERROR - input parameter data is NULL \n"); - return(0); - } - - if (!nas_nl_sk || !nas_rrcnl_sk) { - printk("nasrg_netlink_send - ERROR - socket is NULL\n"); - return(0); - } - - // End debug information - - nl_skb = alloc_skb(NLMSG_SPACE(data_length),GFP_ATOMIC); - - if (!nl_skb) { - printk("nasrg_netlink_send - ERROR - could not allocate skbuffer\n"); - return(0); - } - - nlh = (struct nlmsghdr *)nl_skb->data; - - // printk("nasrg_netlink_send Sending %d bytes (%d)\n",data_length,NLMSG_SPACE(data_length)); - skb_put(nl_skb, NLMSG_SPACE(data_length)); - memcpy(NLMSG_DATA(nlh), data_buffer, data_length); - nlh->nlmsg_len = NLMSG_SPACE(data_length); - - nlh->nlmsg_pid = 0; /* from kernel */ - NETLINK_CB(nl_skb).pid = 0; - - // destination 0 = PDCP, 1 = RRC - if (destination== NASNL_DEST_PDCP) { -#ifdef NETLINK_DEBUG - printk("nasrg_netlink_send - Sending to PDCP - nl_skb %p, nl_sk %p, nlh %p, nlh->nlmsg_len %d\n", nl_skb, nas_nl_sk, nlh, nlh->nlmsg_len); -#ifdef NAS_DEBUG_SEND_DETAIL - nasrg_TOOL_print_buffer(NLMSG_DATA(nlh),48); -#endif -#endif //DEBUG_NETLINK - status = netlink_unicast(nas_nl_sk, nl_skb, NL_DEST_PID, MSG_DONTWAIT); - } else { -#ifdef NAS_DEBUG_RRCNL - printk("nasrg_netlink_send - Sending to RRC - nl_skb %p, nas_rrcnl_sk %p, nlh %p, nlh->nlmsg_len %d\n", nl_skb, nas_rrcnl_sk, nlh, nlh->nlmsg_len); - nasrg_TOOL_print_buffer(NLMSG_DATA(nlh),data_length); -#endif //NAS_DEBUG_RRCNL - status = netlink_unicast(nas_rrcnl_sk, nl_skb, NL_DEST_RRC_PID, MSG_DONTWAIT); - } - - if (status < 0) { - printk("nasrg_netlink_send - SEND status is %d\n",status); - return(0); - } else { -#ifdef NETLINK_DEBUG - printk("nasrg_netlink_send - SEND status is %d, data_length %d\n",status, data_length); -#endif - return data_length; - } -} - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h deleted file mode 100644 index 9053c88a56e24775213ee88a842fd04710779e56..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_proto.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_proto.h -* \brief Function prototypes for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASRGD_PROTO_H -#define _NASRGD_PROTO_H - -#include <linux/if_arp.h> -#include <linux/types.h> -#include <linux/spinlock.h> -#include <linux/netdevice.h> -#include <linux/skbuff.h> -#include <linux/ipv6.h> -#include <linux/ip.h> -#include <linux/sysctl.h> -#include <linux/timer.h> -#include <asm/param.h> -//#include <sys/sysctl.h> -#include <linux/udp.h> -#include <linux/tcp.h> -#include <linux/icmp.h> -#include <linux/icmpv6.h> -#include <linux/in.h> -#include <net/ndisc.h> - -// #include "rrc_nas_primitives.h" -// #include "protocol_vars_extern.h" -// #include "as_sap.h" -// #include "rrc_qos.h" -// #include "rrc_sap.h" - -// nasrg_netlink.c -void nasrg_netlink_release(void); -int nasrg_netlink_init(void); -int nasrg_netlink_send(unsigned char *data_buffer, unsigned int data_length, int destination); - -// nasrg_common.c -//void nasrg_COMMON_receive(uint16_t hlen, uint16_t dlength, int sap); -void nasrg_COMMON_receive(uint16_t bytes_read, uint16_t payload_length, void *data_buffer, int rb_id, int sap); - -void nasrg_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -void nasrg_COMMON_QOS_send_test_netlink(struct sk_buff *skb); -void nasrg_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -#ifndef PDCP_USE_NETLINK -void nasrg_COMMON_QOS_receive(struct cx_entity *cx); -#else -void nasrg_COMMON_QOS_receive(struct nlmsghdr *nlh); -#endif -struct rb_entity *nasrg_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rabi, nasQoSTrafficClass_t qos); -struct rb_entity *nasrg_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rabi); -struct cx_entity *nasrg_COMMON_search_cx(nasLocalConnectionRef_t lcr); -void nasrg_COMMON_del_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasIPdscp_t dscp); -void nasrg_COMMON_flush_rb(struct cx_entity *cx); - -//nasrg_ascontrol.c -void nasrg_ASCTL_init(void); -void nasrg_ASCTL_timer(unsigned long data); -void nasrg_ASCTL_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -//int nasrg_ASCTL_DC_receive(struct cx_entity *cx); -int nasrg_ASCTL_DC_receive(struct cx_entity *cx, char *buffer); -// -int nasrg_ASCTL_DC_send_cx_establish_confirm(struct cx_entity *cx, uint8_t response); -int nasrg_ASCTL_DC_send_rb_establish_request(struct cx_entity *cx, struct rb_entity *rb); -int nasrg_ASCTL_DC_send_rb_release_request(struct cx_entity *cx, struct rb_entity *rb); -int nasrg_ASCTL_GC_send_mbms_bearer_establish_req(int mbms_ix ); -int nasrg_ASCTL_GC_send_mbms_bearer_release_req(int mbms_ix); -int nasrg_ASCTL_DC_send_mbms_ue_notify_req(struct cx_entity *cx); -int nasrg_ASCTL_DC_send_eNBmeasurement_req(struct cx_entity *cx); - -void nasrg_ASCTL_start_default_mbms_service(void); - -// nasrg_iocontrol.c -void nasrg_CTL_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); -int nasrg_CTL_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); - -// nasrg_classifier.c -void nasrg_CLASS_send(struct sk_buff *skb); -struct classifier_entity *nasrg_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref); -struct classifier_entity *nasrg_CLASS_add_rclassifier(uint8_t dscp, uint16_t classref); -struct classifier_entity *nasrg_CLASS_add_mbmsclassifier(int mbms_ix, uint16_t classref); -void nasrg_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref); -void nasrg_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref); -void nasrg_CLASS_del_mbmsclassifier(int mbms_ix, uint16_t classref); -void nasrg_CLASS_flush_sclassifier(struct cx_entity *cx); -void nasrg_CLASS_flush_rclassifier(void); -void nasrg_CLASS_flush_mbmsclassifier(void); - -// nasrg_tool.c -uint8_t nasrg_TOOL_invfct(struct classifier_entity *gc); -void nasrg_TOOL_fct(struct classifier_entity *gc, uint8_t fct); -void nasrg_TOOL_imei2iid(uint8_t *imei, uint8_t *iid); -void nasrg_TOOL_RGimei2iid(uint8_t *imei, uint8_t *iid); -uint8_t nasrg_TOOL_get_dscp6(struct ipv6hdr *iph); -uint8_t nasrg_TOOL_get_dscp4(struct iphdr *iph); -uint8_t *nasrg_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol); -uint8_t *nasrg_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol); -char *nasrg_TOOL_get_udpmsg(struct udphdr *udph); -uint16_t nasrg_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, uint8_t proto, uint32_t udplen, void *data); -int nasrg_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, uint8_t plen); -int nasrg_TOOL_network4(uint32_t *addr, uint32_t *prefix, uint8_t plen); - -void nasrg_TOOL_pk_icmp6(struct icmp6hdr *icmph); - -void nasrg_TOOL_pk_all(struct sk_buff *skb); -void nasrg_TOOL_pk_ipv6(struct ipv6hdr *iph); -void nasrg_TOOL_print_state(uint8_t state); -void nasrg_TOOL_print_buffer(unsigned char * buffer,int length); -void nasrg_TOOL_print_rb_entity(struct rb_entity *rb); -void nasrg_TOOL_print_classifier(struct classifier_entity *gc); - -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h deleted file mode 100644 index e2835adf7d61773552bb9090993c5de106b0009b..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_sap.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasmt_sap.h -* \brief SAP constants for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASRGD_SAP_H -#define _NASRGD_SAP_H - - -// RT-FIFO identifiers ** must be identical to Access Stratum as_sap.h and rrc_sap.h - -#define RRC_DEVICE_GC RRC_SAPI_RG_GCSAP -#define RRC_DEVICE_NT RRC_SAPI_RG_NTSAP -#define RRC_DEVICE_DC_INPUT0 RRC_SAPI_RG_DCSAP0_IN -#define RRC_DEVICE_DC_INPUT1 RRC_SAPI_RG_DCSAP1_IN -#define RRC_DEVICE_DC_OUTPUT0 RRC_SAPI_RG_DCSAP0_OUT -#define RRC_DEVICE_DC_OUTPUT1 RRC_SAPI_RG_DCSAP1_OUT -// -//#define QOS_DEVICE_CONVERSATIONAL_INPUT QOS_SAPI_CONVERSATIONAL_INPUT_RG -//#define QOS_DEVICE_CONVERSATIONAL_OUTPUT QOS_SAPI_CONVERSATIONAL_OUTPUT_RG - -#define PDCP2PDCP_USE_RT_FIFO 21 -#define NAS2PDCP_FIFO 22 - -//FIFO indexes in control blocks -#define NAS_DC_INPUT_SAPI 0 -#define NAS_DC_OUTPUT_SAPI 1 -#define NAS_SAPI_CX_MAX 2 - -#define NAS_GC_SAPI 0 -#define NAS_NT_SAPI 1 -#define NAS_DRB_INPUT_SAPI 2 //NAS_CO_INPUT_SAPI -#define NAS_DRB_OUTPUT_SAPI 3 //NAS_CO_OUTPUT_SAPI -#define NAS_SAPI_MAX 4 - -//#define NAS_QOS_CONVERSATIONAL UMTS_TRAFFIC_CONVERSATIONAL -// - -/* Defined in RRC -#define RRC_NAS_GC_IN 0 -#define RRC_NAS_GC_OUT 1 -#define RRC_NAS_NT_IN 2 -#define RRC_NAS_NT_OUT 3 -#define RRC_NAS_DC0_IN 4 -#define RRC_NAS_DC0_OUT 5 -#define RRC_NAS_DC1_IN 6 -#define RRC_NAS_DC1_OUT 7 -#define RRC_NAS_DC2_IN 8 -#define RRC_NAS_DC2_OUT 9 -*/ -#endif - - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_tool.c b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_tool.c deleted file mode 100644 index 54324cf63fc322866bd4ecb33acee592e1ed8698..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_tool.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "nasrg_variables.h" -#include "nasrg_proto.h" - -//--------------------------------------------------------------------------- -// -void nasrg_TOOL_fct(struct classifier_entity *gc, uint8_t fct) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_fct - begin \n"); -#endif - - if (gc==NULL) { - printk("nasrg_TOOL_fct - input parameter gc is NULL \n"); - return; - } - - // End debug information - switch(fct) { - case NAS_FCT_QOS_SEND: - gc->fct=nasrg_COMMON_QOS_send; - break; - - case NAS_FCT_CTL_SEND: - gc->fct=nasrg_CTL_send; - break; - - case NAS_FCT_DC_SEND: - gc->fct=nasrg_ASCTL_DC_send_sig_data_request; - break; - - case NAS_FCT_DEL_SEND: - gc->fct=nasrg_COMMON_del_send; - break; - - default: - gc->fct=nasrg_COMMON_del_send; - } -} - -//--------------------------------------------------------------------------- -uint8_t nasrg_TOOL_invfct(struct classifier_entity *gc) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_invfct - begin \n"); -#endif - - if (gc==NULL) { - printk("nasrg_TOOL_invfct - input parameter gc is NULL \n"); - return 0; - } - - // End debug information - if (gc->fct==nasrg_COMMON_QOS_send) - return NAS_FCT_QOS_SEND; - - if (gc->fct==nasrg_CTL_send) - return NAS_FCT_CTL_SEND; - - if (gc->fct==nasrg_COMMON_del_send) - return NAS_FCT_DEL_SEND; - - if (gc->fct==nasrg_ASCTL_DC_send_sig_data_request) - return NAS_FCT_DC_SEND; - - return 0; -} - -//--------------------------------------------------------------------------- -uint8_t nasrg_TOOL_get_dscp6(struct ipv6hdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_get_dscp6 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasrg_TOOL_get_dscp6 - input parameter iph is NULL \n"); - return 0; - } - - // End debug information - // return (ntohl(((*(__u32 *)iph)&NAS_TRAFFICCLASS_MASK)))>>22; //Yan - return (ntohl(((*(__u32 *)iph)&NAS_TRAFFICCLASS_MASK)))>>20; -} - -//--------------------------------------------------------------------------- -uint8_t nasrg_TOOL_get_dscp4(struct iphdr *iph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_get_dscp4 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasrg_TOOL_get_dscp4 - input parameter iph is NULL \n"); - return 0; - } - - // End debug information - return ((iph->tos)>>5)<<3; -} - -//--------------------------------------------------------------------------- -uint8_t *nasrg_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - uint16_t size; - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_get_protocol6 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasrg_TOOL_get_protocol6 - input parameter iph is NULL \n"); - return NULL; - } - - if (protocol==NULL) { - printk("nasrg_TOOL_get_protocol6 - input parameter protocol is NULL \n"); - return NULL; - } - - // End debug information - - *protocol=iph->nexthdr; - size=NAS_IPV6_SIZE; - - while (1) { - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMPV6: - return (uint8_t *)((uint8_t *)iph+size); - - case IPPROTO_HOPOPTS: - case IPPROTO_ROUTING: - case IPPROTO_DSTOPTS: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]*8+8; - break; - - case IPPROTO_FRAGMENT: - *protocol=((uint8_t *)iph+size)[0]; - size+=((uint8_t *)iph+size)[1]+8; - break; - - case IPPROTO_NONE: - case IPPROTO_AH: - case IPPROTO_ESP: - default: - return NULL; - } - } -} - -//--------------------------------------------------------------------------- -uint8_t *nasrg_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_get_protocol4 - begin \n"); -#endif - - if (iph==NULL) { - printk("nasrg_TOOL_get_protocol4 - input parameter iph is NULL \n"); - return NULL; - } - - if (protocol==NULL) { - printk("nasrg_TOOL_get_protocol4 - input parameter protocol is NULL \n"); - return NULL; - } - - // End debug information - *protocol=iph->protocol; - - switch(*protocol) { - case IPPROTO_UDP: - case IPPROTO_TCP: - case IPPROTO_ICMP: - return (uint8_t *)((uint8_t *)iph+iph->tot_len); - - default: - return NULL; - } -} - -//--------------------------------------------------------------------------- -// Convert the IMEI to iid -void nasrg_TOOL_imei2iid(uint8_t *imei, uint8_t *iid) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_imei2iid - begin \n"); -#endif - - if (imei==NULL) { - printk("nasrg_TOOL_imei2iid - input parameter imei is NULL \n"); - return; - } - - if (iid==NULL) { - printk("nasrg_TOOL_imei2iid - input parameter iid is NULL \n"); - return; - } - - // End debug information - memset(iid, 0, NAS_ADDR_LEN); - iid[0] = 0x03; -#ifdef NAS_DRIVER_TYPE_ETHERNET - iid[0] = 0x02; -#endif - iid[1] = 16*imei[0]+imei[1]; - iid[2] = 16*imei[2]+imei[3]; - iid[3] = 16*imei[4]+imei[5]; - iid[4] = 16*imei[6]+imei[7]; -#ifdef NAS_DRIVER_TYPE_ETHERNET - iid[3] = 0xff; - iid[4] = 0xfe; -#endif - iid[5] = 16*imei[8]+imei[9]; - iid[6] = 16*imei[10]+imei[11]; - iid[7] = 16*imei[12]+imei[13]; -} - -//--------------------------------------------------------------------------- -// Convert the RG IMEI to iid -void nasrg_TOOL_RGimei2iid(uint8_t *imei, uint8_t *iid) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_RGimei2iid - begin \n"); -#endif - - if (!imei || !iid) { - printk("nasrg_TOOL_RGimei2iid - input parameter imei or iid is NULL \n"); - return; - } - - // End debug information - memset(iid, 0, NAS_ADDR_LEN); - iid[0] = 0x00; // to be compatible between link local and global - iid[1] = 16*imei[0]+imei[1]; - iid[2] = 16*imei[2]+imei[3]; - iid[3] = 16*imei[4]+imei[5]; - iid[4] = 16*imei[6]+imei[7]; - iid[5] = 16*imei[8]+imei[9]; - iid[6] = 16*imei[10]+imei[11]; - iid[7] = 16*imei[12]+imei[13]; -} - -//--------------------------------------------------------------------------- -void nasrg_TOOL_pk_icmp6(struct icmp6hdr *icmph) -{ - //--------------------------------------------------------------------------- - // Start debug information -#ifdef GRAAL_DEBUG_TOOL - printk("nasrg_TOOL_pk_icmp6 - begin \n"); -#endif - - if (!icmph) { - printk("nasrg_TOOL_pk_icmp6 - input parameter icmph is NULL \n"); - return; - } - - // End debug information - printk("ICMPv6:\t type= %d, code = %d\n", icmph->icmp6_type, icmph->icmp6_code); - - switch(icmph->icmp6_type) { - case ICMPV6_DEST_UNREACH: - printk("Destination unreachable\n"); - break; - - case ICMPV6_PKT_TOOBIG: - printk("Packet too big\n"); - break; - - case ICMPV6_TIME_EXCEED: - printk("Time exceeded\n"); - break; - - case ICMPV6_PARAMPROB: - printk("Parameter problem\n"); - break; - - case ICMPV6_ECHO_REQUEST: - printk("Echo request\n"); - break; - - case ICMPV6_ECHO_REPLY: - printk("Echo reply\n"); - break; - - case ICMPV6_MGM_QUERY: - printk("Multicast listener query\n"); - break; - - case ICMPV6_MGM_REPORT: - printk("Multicast listener report\n"); - break; - - case ICMPV6_MGM_REDUCTION: - printk("Multicast listener done\n"); - break; - - case NDISC_ROUTER_SOLICITATION: - printk("Router solicitation\n"); - break; - - case NDISC_ROUTER_ADVERTISEMENT: - printk("Router advertisment\n"); - break; - - case NDISC_NEIGHBOUR_SOLICITATION: - printk("Neighbour solicitation\n"); - break; - - case NDISC_NEIGHBOUR_ADVERTISEMENT: - printk("Neighbour advertisment\n"); - break; - - case NDISC_REDIRECT: - printk("redirect message\n"); - break; - } -} - - -//--------------------------------------------------------------------------- -void nasrg_TOOL_print_state(uint8_t state) -{ - //--------------------------------------------------------------------------- - switch(state) { - case NAS_IDLE: - printk("NAS_IDLE\n"); - return; - - case NAS_CX_FACH: - printk("NAS_CX_FACH\n"); - return; - - case NAS_CX_DCH: - printk("NAS_CX_DCH\n"); - return; - - case NAS_CX_RECEIVED: - printk("NAS_CX_RECEIVED\n"); - return; - - case NAS_CX_CONNECTING: - printk("NAS_CX_CONNECTING\n"); - return; - - case NAS_CX_RELEASING: - printk("NAS_CX_RELEASING\n"); - return; - - case NAS_CX_CONNECTING_FAILURE: - printk("NAS_CX_CONNECTING_FAILURE\n"); - return; - - case NAS_CX_RELEASING_FAILURE: - printk("NAS_CX_RELEASING_FAILURE\n"); - return; - - case NAS_RB_ESTABLISHING: - printk("NAS_RB_ESTABLISHING\n"); - return; - - case NAS_RB_RELEASING: - printk("NAS_RB_RELEASING\n"); - return; - - case NAS_RB_ESTABLISHED: - printk("NAS_RB_ESTABLISHED\n"); - return; - - default: - printk(" Unknown state\n"); - } -} - -//----------------------------------------------------------------------------- -// Print the content of a buffer in hexadecimal -void nasrg_TOOL_print_buffer(unsigned char * buffer,int length) -{ - //----------------------------------------------------------------------------- - int i; - - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_print_buffer - begin \n"); -#endif - - if (buffer==NULL) { - printk("\n nasrg_TOOL_print_buffer - input parameter buffer is NULL \n"); - return; - } - - // End debug information - printk("Buffer content: "); - - for (i=0; i<length; i++) - printk("-%hx-",buffer[i]); - - printk(",\t length %d\n", length); -} - -//----------------------------------------------------------------------------- -void nasrg_TOOL_print_rb_entity(struct rb_entity *rb) -{ - //----------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_print_rb_entity - begin \n"); -#endif - - if (rb==NULL) { - printk("\n nasrg_TOOL_print_rb_entity - input parameter rb is NULL \n"); - return; - } - - // End debug information - printk("\nrb_entity content: rab_id %d, sapi %d, qos %d, dscp %d, \n", rb->rab_id, rb->sapi, rb->qos, rb->dscp); - printk("state %d, retry %d, countimer %d\n",rb->state, rb->retry, rb->countimer); -}; - -//----------------------------------------------------------------------------- -void nasrg_TOOL_print_classifier(struct classifier_entity *gc) -{ - //----------------------------------------------------------------------------- - // Start debug information -#ifdef NAS_DEBUG_TOOL - printk("nasrg_TOOL_print_classifier - begin \n"); -#endif - - if (gc==NULL) { - printk("\n nasrg_TOOL_print_classifier - input parameter gc is NULL \n"); - return; - } - - // End debug information - printk("\nClassifier content: classref %d, version %d, splen %d, dplen %d,\n", gc->classref, gc->version, gc->splen, gc->dplen); - printk("protocol %d, sport %d, dport %d, rab_id %d\n", gc->protocol, gc->sport, gc->dport, gc->rab_id); - nasrg_TOOL_print_rb_entity(gc->rb); -}; - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_variables.h b/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_variables.h deleted file mode 100644 index 7c2b69459ca7ee733225665270f9f98c6645c18c..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NASRG/nasrg_variables.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nasrg_variables.h -* \brief Variable and structure definitions for OpenAirInterface CELLULAR version - RG -* \author michelle.wetterwald, navid.nikaein, raymond.knopp, Lionel Gauthier -* \company Eurecom -* \email: michelle.wetterwald@eurecom.fr, raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr -*/ -/*******************************************************************************/ -#ifndef _NASRGD_VAR_H -#define _NASRGD_VAR_H - -#include <linux/if_arp.h> -#include <linux/types.h> -#include <linux/spinlock.h> -#include <linux/netdevice.h> -#include <linux/skbuff.h> -#include <linux/ipv6.h> -#include <linux/ip.h> -#include <linux/sysctl.h> -#include <linux/timer.h> -#include <linux/unistd.h> -//#include <asm/unistd.h> -#include <asm/param.h> -//#include <sys/sysctl.h> -#include <linux/udp.h> -#include <linux/tcp.h> -#include <linux/icmp.h> -#include <linux/icmpv6.h> -#include <linux/in.h> -#include <net/ndisc.h> - -#include "rrc_nas_primitives.h" -#include "rrc_qos_classes.h" -#include "rrc_nas_sap.h" - -#include "nasrg_constant.h" -#include "nasrg_sap.h" - -struct cx_entity; - -struct rb_entity { - // uint16_t default_rab; - uint32_t cnxid; - nasRadioBearerId_t rab_id; //ue_rbId - nasRadioBearerId_t rg_rbId; - nasRadioBearerId_t mbms_rbId; - nasSapId_t sapi; - nasQoSTrafficClass_t qos; - nasQoSTrafficClass_t RadioQosClass; - nasIPdscp_t dscp; //this is DL dscp - nasIPdscp_t dscp_ul; - uint8_t state; - uint8_t result; - uint8_t retry; - uint32_t countimer; - //for MBMS - uint16_t serviceId; - uint16_t sessionId; - uint16_t duration; - uint8_t mcast_address[16]; - // - struct rb_entity *next; -}; - -struct classifier_entity { - uint32_t classref; // classifier identity - uint8_t version; // IP version 4 or 6 - union { - struct in6_addr ipv6; - uint32_t ipv4; - } saddr; // IP source address - uint8_t splen; // IP prefix size - union { - struct in6_addr ipv6; - uint32_t ipv4; - } daddr; // IP destination address - uint8_t dplen; // IP prefix size - uint8_t protocol; // layer 4 protocol type (tcp, udp, ...) - uint16_t sport; // source port - uint16_t dport; // destination port - struct rb_entity *rb; - nasRadioBearerId_t rab_id; // RAB identification - void (*fct)(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc); - struct classifier_entity *next; -}; - - -struct cx_entity { - int sap[NAS_SAPI_CX_MAX]; - uint8_t state; // state of the connection - nasLocalConnectionRef_t lcr; // Local connection reference - nasCellID_t cellid; // cell identification - uint32_t countimer; // timeout's counter - uint8_t retry; // number of retransmissions - struct classifier_entity *sclassifier[NAS_DSCP_MAX]; // send classifiers table - uint16_t nsclassifier; - uint32_t iid6[2]; // IPv6 interface identification - uint8_t iid4; // IPv4 interface identification - struct rb_entity *rb; // RB entities for RABs - uint16_t num_rb; - // MW - 17/5/05 - int ue_id; - int rrc_state; - // MBMS - int requested_joined_services[NASRG_MBMS_SVCES_MAX]; - int requested_left_services[NASRG_MBMS_SVCES_MAX]; - int joined_services[NASRG_MBMS_SVCES_MAX]; -}; - -//struct mbms_rb_entity{ -// uint32_t cnxid; -// nasRadioBearerId_t mbms_rbId; -// nasSapId_t sapi; -// nasQoSTrafficClass_t qos; -// nasQoSTrafficClass_t RadioQosClass; -// uint8_t state; -// uint8_t result; -// uint8_t retry; -// uint32_t countimer; -// -// uint16_t serviceId; -// uint16_t sessionId; -// uint16_t duration; -//}; -// - -struct nas_priv { - int irq; - int rx_flags; - struct timer_list timer; - spinlock_t lock; - struct net_device_stats stats; - uint8_t retry_limit; - uint32_t timer_establishment; - uint32_t timer_release; - struct cx_entity cx[NAS_CX_MAX]; - struct classifier_entity *rclassifier[NAS_DSCP_MAX]; // receive classifier - int nrclassifier; - uint32_t next_sclassref; - int sap[NAS_SAPI_MAX]; - uint8_t xbuffer[NAS_MAX_LENGTH]; // transmission buffer - uint8_t rbuffer[NAS_MAX_LENGTH]; // reception buffer - // MW - 17/5/05 - int broadcast_counter; - int SIB18_counter; - // MBMS - struct rb_entity mbms_rb[NASRG_MBMS_SVCES_MAX]; - struct classifier_entity *mbmsclassifier[NASRG_MBMS_SVCES_MAX]; // mbms classifier - int nmbmsclassifier; - uint32_t next_mbmsclassref; - //Added for demo 3 - MW - nasCellID_t measured_cell_id; - uint16_t num_UEs; - uint32_t rlcBufferOccupancy[NAS_CX_MAX]; - uint32_t scheduledPRB[NAS_CX_MAX]; - uint32_t totalDataVolume[NAS_CX_MAX]; - uint32_t totalNumPRBs; -}; - -struct ipversion { -#if defined(__LITTLE_ENDIAN_BITFIELD) - uint8_t reserved:4, - version:4; -#else - uint8_t version:4, - reserved:4; -#endif -}; - -typedef struct pdcp_data_req_header_t { - unsigned int rb_id; - unsigned int data_size; - int inst; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_t { - unsigned int rb_id; - unsigned int data_size; - int inst; -} pdcp_data_ind_header_t; -// -extern struct nas_priv *gpriv; -extern struct net_device *gdev; -//extern int bytes_wrote; -//extern int bytes_read; - -extern uint8_t NAS_RG_IMEI[14]; -extern uint8_t NAS_NULL_IMEI[14]; - -//global variables shared with RRC -extern int *pt_nas_rg_irq; -//extern uint16_t *pt_rg_own_cell_id; -extern uint16_t local_rg_cell_id; -#endif diff --git a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/Makefile b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/Makefile deleted file mode 100755 index eec82de367aaa0dd70afc5d94cf3a397a9dc3ed7..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# Lines starting with the pound sign are comments. -# -# These things are options that you might need -# to tweak. - -# You can modify the below as well, but probably -# won't need to. - -#CC = egcs - -#UPDIR := $(shell /bin/pwd) -#GRAAL_DIR =$(UPDIR)/.. -#RRC_DIR =$(UPDIR)/../../../AS/L3/RRC - -CELL_UPDIR := $(shell /bin/pwd) -NAS_DIR := $(OPENAIR2_DIR)/NAS/DRIVER/CELLULAR/NASMT -RRC_DIR := $(OPENAIR2_DIR)/RRC/CELLULAR -EXTRA_CFLAGS += -I$(RRC_DIR) -DNODE_MT - -CFLAGS = -Wall -g -I$(NAS_DIR) -I$(RRC_DIR) - -COMPILE = $(CC) $(CFLAGS) -c - -OBJS = netltest.o - -EXECUTABLE = netltest - -# "all" is the default target. Simply make it point to myprogram. - -all: $(EXECUTABLE) - -# Define the components of the program, and how to link them together. -# These components are defined as dependencies; that is, they must be -# made up-to-date before the code is linked. - -$(EXECUTABLE): $(OBJS) - $(CC) $(CFLAGS) -o $(EXECUTABLE) $(OBJS) - -# Add any special rules here. - -# Specify that all .o files depend on .c files, and indicate how -# the .c files are converted (compiled) to the .o files. - -%.o: %.c - $(COMPILE) -o $@ $< - -clean: - -rm $(OBJS) $(EXECUTABLE) diff --git a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest deleted file mode 100755 index f44ea64b09862efd61f5e17082141e4be4e9a500..0000000000000000000000000000000000000000 Binary files a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest and /dev/null differ diff --git a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest.c b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest.c deleted file mode 100644 index 84de51a68d5a6b9ad5581cb8323d144c74901075..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/netltest.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -//----------------------------------------------------------------------------- -// For FIFOS / NETLINK interface -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sys/socket.h> -#include <linux/netlink.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -/******************** -// RRC definitions - ********************/ -#include "nasmt_constant.h" -#include "rrc_nas_sap.h" -#include "rrc_constant.h" -//----------------------------------------------------------------------------- -//#define MAX_PAYLOAD 4096 /* this sould cover the max mtu size*/ -struct nlmsghdr *rrcnl_nlh; -int rrcnl_sock_fd; -struct sockaddr_nl rrcnl_src_addr, rrcnl_dest_addr; -struct iovec rrcnl_iov; -struct msghdr rrcnl_msg; - -//----------------------------------------------------------------------------- -typedef unsigned int sdu_size_t; -typedef unsigned int rb_id_t; - -typedef struct pdcp_data_req_header_t { - rb_id_t rb_id; - sdu_size_t data_size; - int inst; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_t { - rb_id_t rb_id; - sdu_size_t data_size; - int inst; -} pdcp_data_ind_header_t; - -#define MAX_PAYLOAD 1024 /* maximum payload size*/ -struct sockaddr_nl src_addr, dest_addr; -struct nlmsghdr *nlh = NULL; -struct iovec iov; -int sock_fd; -struct msghdr msg; -#define OAI_IP_DRIVER_NETLINK_ID 31 -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -void foo( int sig ) -{ - //----------------------------------------------------------------------------- - printf("I got cntl-C, closing socket\n"); - close(sock_fd); - close(rrcnl_sock_fd); - exit(-1); -} - -//----------------------------------------------------------------------------- -int main() -{ - //----------------------------------------------------------------------------- - struct sigaction newaction; - int i=0; - int ret; - int len, count; - - newaction.sa_handler = foo; - - // register cntl-C handler - if ( sigaction( SIGINT, &newaction, NULL ) == -1) - perror("Could not install the new signal handler"); - - // create both sockets - sock_fd = socket(PF_NETLINK, SOCK_RAW,OAI_IP_DRIVER_NETLINK_ID); - printf("Opened socket with fd %d\n",sock_fd); - ret = fcntl(sock_fd,F_SETFL,O_NONBLOCK); - printf("fcntl returns %d\n",ret); - - rrcnl_sock_fd = socket(PF_NETLINK, SOCK_RAW, NAS_RRCNL_ID); - printf("rrc_ue_netlink_init - Opened socket with fd %d\n", rrcnl_sock_fd); - ret = fcntl(rrcnl_sock_fd,F_SETFL,O_NONBLOCK); - printf("rrc_ue_netlink_init - fcntl returns %d\n",ret); - - // set src addresses blocks - memset(&src_addr, 0, sizeof(src_addr)); - src_addr.nl_family = AF_NETLINK; - src_addr.nl_pid = 1;//getpid(); /* self pid */ - src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(sock_fd, (struct sockaddr*)&src_addr, sizeof(src_addr)); - printf("bind returns %d\n",ret); - - memset(&rrcnl_src_addr, 0, sizeof(rrcnl_src_addr)); - rrcnl_src_addr.nl_family = AF_NETLINK; - rrcnl_src_addr.nl_pid = NL_DEST_RRC_PID;//getpid(); /* self pid */ - rrcnl_src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(rrcnl_sock_fd, (struct sockaddr*)&rrcnl_src_addr, sizeof(rrcnl_src_addr)); - printf("rrc_ue_netlink_init - bind returns %d\n",ret); - - // set dest addresses blocks - memset(&dest_addr, 0, sizeof(dest_addr)); - dest_addr.nl_family = AF_NETLINK; - dest_addr.nl_pid = 0; /* For Linux Kernel */ - dest_addr.nl_groups = 0; /* unicast */ - - memset(&rrcnl_dest_addr, 0, sizeof(rrcnl_dest_addr)); - rrcnl_dest_addr.nl_family = AF_NETLINK; - rrcnl_dest_addr.nl_pid = 0; /* For Linux Kernel */ - rrcnl_dest_addr.nl_groups = 0; /* unicast */ - - // set nlh - nlh=(struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD)); - /* Fill the netlink message header */ - nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD); - nlh->nlmsg_pid = 1;//getpid(); /* self pid */ - nlh->nlmsg_flags = 0; - - rrcnl_nlh=(struct nlmsghdr *)malloc(NLMSG_SPACE(RRC_NAS_MAX_SIZE)); - //memset(rrcnl_nlh, 0, NLMSG_SPACE(MAX_PAYLOAD)); - /* Fill the netlink message header */ - rrcnl_nlh->nlmsg_len = NLMSG_SPACE(RRC_NAS_MAX_SIZE); - rrcnl_nlh->nlmsg_pid = NL_DEST_RRC_PID;//getpid(); /* self pid */ - rrcnl_nlh->nlmsg_flags = 0; - - // set iov - iov.iov_base = (void *)nlh; - iov.iov_len = nlh->nlmsg_len; - memset(&msg,0,sizeof(msg)); - msg.msg_name = (void *)&dest_addr; - msg.msg_namelen = sizeof(dest_addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - rrcnl_iov.iov_base = (void *)rrcnl_nlh; - rrcnl_iov.iov_len = rrcnl_nlh->nlmsg_len; - memset(&rrcnl_msg,0,sizeof(rrcnl_msg)); - rrcnl_msg.msg_name = (void *)&rrcnl_dest_addr; - rrcnl_msg.msg_namelen = sizeof(rrcnl_dest_addr); - rrcnl_msg.msg_iov = &rrcnl_iov; - rrcnl_msg.msg_iovlen = 1; - - /* Read message from kernel */ - memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD)); - - /* Read message from kernel */ - memset(rrcnl_nlh, 0, NLMSG_SPACE(MAX_PAYLOAD)); - - while (1) { - len = recvmsg(sock_fd, &msg, 0); - count = recvmsg(rrcnl_sock_fd, &rrcnl_msg, 0); - - if (len<0) { - // exit(-1); - } else { - printf("Received PDCP socket with length %d (nlmsg_len = %d)\n",len,nlh->nlmsg_len); - } - - if (count<0) { - // exit(-1); - } else { - printf("Received RRC socket with length %d (nlmsg_len = %d)\n",count,rrcnl_nlh->nlmsg_len); - } - - /* usleep(1000); - i=i+1; - if ((i % 100) == 0) - printf("%d\n",i);*/ - usleep(50); - i=i+1; - - if ((i % 1000) == 0) - printf("%d\n",i); - - /* - for (i=0;i<nlh->nlmsg_len - sizeof(struct nlmsghdr);i++) { - printf("%x ", - ((unsigned char *)NLMSG_DATA(nlh))[i]); - } - */ - } - - /* Close Netlink Socket */ - return 0; -} - - - - diff --git a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/nettestPDCP.c b/openair2/NAS/DRIVER/CELLULAR/NETLTEST/nettestPDCP.c deleted file mode 100644 index 121d3bba8b9cb9ade5a35f79a82d7ab7d37d5f39..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/NETLTEST/nettestPDCP.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <sys/types.h> -#include <fcntl.h> -#include <sys/socket.h> -#include <linux/netlink.h> -#include <signal.h> -#include <stdio.h> -#include <unistd.h> - -typedef unsigned int sdu_size_t; -typedef unsigned int rb_id_t; - -typedef struct pdcp_data_req_header_t { - rb_id_t rb_id; - sdu_size_t data_size; - int inst; -} pdcp_data_req_header_t; - -typedef struct pdcp_data_ind_header_t { - rb_id_t rb_id; - sdu_size_t data_size; - int inst; -} pdcp_data_ind_header_t; - -#define MAX_PAYLOAD 1024 /* maximum payload size*/ -struct sockaddr_nl src_addr, dest_addr; -struct nlmsghdr *nlh = NULL; -struct iovec iov; -int sock_fd; -struct msghdr msg; - - -void foo( int sig ) -{ - - printf("I got cntl-C, closing socket\n"); - - - close(sock_fd); - exit(-1); -} - - -#define OAI_IP_DRIVER_NETLINK_ID 31 - -void main() -{ - - - struct sigaction newaction; - int i=0; - int ret; - int len; - - newaction.sa_handler = foo; - - if ( sigaction( SIGINT, &newaction, NULL ) == -1) - perror("Could not install the new signal handler"); - - sock_fd = socket(PF_NETLINK, SOCK_RAW,OAI_IP_DRIVER_NETLINK_ID); - - printf("Opened socket with fd %d\n",sock_fd); - - ret = fcntl(sock_fd,F_SETFL,O_NONBLOCK); - printf("fcntl returns %d\n",ret); - - memset(&src_addr, 0, sizeof(src_addr)); - src_addr.nl_family = AF_NETLINK; - src_addr.nl_pid = 1;//getpid(); /* self pid */ - src_addr.nl_groups = 0; /* not in mcast groups */ - ret = bind(sock_fd, (struct sockaddr*)&src_addr, - sizeof(src_addr)); - printf("bind returns %d\n",ret); - - memset(&dest_addr, 0, sizeof(dest_addr)); - dest_addr.nl_family = AF_NETLINK; - dest_addr.nl_pid = 0; /* For Linux Kernel */ - dest_addr.nl_groups = 0; /* unicast */ - - nlh=(struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD)); - /* Fill the netlink message header */ - nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD); - nlh->nlmsg_pid = 1;//getpid(); /* self pid */ - nlh->nlmsg_flags = 0; - - iov.iov_base = (void *)nlh; - iov.iov_len = nlh->nlmsg_len; - memset(&msg,0,sizeof(msg)); - msg.msg_name = (void *)&dest_addr; - msg.msg_namelen = sizeof(dest_addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - - /* Read message from kernel */ - memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD)); - - while (1) { - len = recvmsg(sock_fd, &msg, 0); - - - if (len<0) { - - // exit(-1); - } else { - printf("Received socket with length %d (nlmsg_len = %d)\n",len,nlh->nlmsg_len); - } - - usleep(1000); - i=i+1; - - if ((i % 100) == 0) - printf("%d\n",i); - - /* - for (i=0;i<nlh->nlmsg_len - sizeof(struct nlmsghdr);i++) { - printf("%x ", - ((unsigned char *)NLMSG_DATA(nlh))[i]); - } - */ - } - - /* Close Netlink Socket */ - -} - - - - diff --git a/openair2/NAS/DRIVER/CELLULAR/readme.txt b/openair2/NAS/DRIVER/CELLULAR/readme.txt deleted file mode 100755 index fd4411a25bf46168b66fed55a4c9aa442cba6d39..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/readme.txt +++ /dev/null @@ -1,157 +0,0 @@ - --------------------------------- - | UMTS-TDD (TD-CDMA) NAS driver | - --------------------------------- - - - -1 - COMPILATION ---------------- -Pre-Req : - - RTAI installed and running - - IPv6 patched as described below (see 4 - Patching IPv6) - -From RHODOS26 directory: - - - make nasrg : creates the NAS RG driver (nasrg.ko) and copies it to the RHODOS26/bin directory - - - make cleannasrg : deletes all object and temporary files from the nasrg directory - - - make nasmt : creates the NAS MT driver (nasmt.ko) and copies it to the RHODOS26/bin directory - - - make cleannasmt : deletes all object and temporary files from the nasmt directory - - -2 - OPERATION - RG side ------------------------ - -A1 - Compile the Access Stratum (for IF mode) - -Pre-Req : RTAI installed and running - ICC 8.0 installed and running - - > make rgif - > make asrguserif - > make rrmumts - -A2 - Compile the Access Stratum (for RF mode) - -Pre-Req : RTAI installed and running - ICC 8.0 installed and running - - > make guimakefiles - > make rgrf - > make asrguserrfa2 - > make rrmumts - - -B - Start the Access Stratum - - (as root ) > cd <..>RHODOS26/bin - - (first install) > create_rtfifos - (first install) > mknod -m 666 /dev/daq0 c 127 1 - (after cleanas) > cp -../src/rrm_umts/congestion_control/resources_manager/rrm_master.properties . - - (-- ) > ./start_rtos - (-- ) > ./runrgif [for IF] [or ./runrga2 for RF] - - ==> to check correct operation: - (as root ) cat /dev/rtf62 - (as root ) tail -f /var/log/messages - -C - Start the NAS Driver - - (as root ) > cd <..>RHODOS26/bin - (-- ) > insmod nasrg.ko - (-- ) > ./access_router.up - -D - Stop the NAS Driver and the Access Stratum - - (-- ) > ./access_router.down - (-- ) > rmmod nasrg - (-- ) > <CTRL+C> on Acccess stratum window - (-- ) > ./stop_rtos - -E - Clean Access Stratum compilation - - > make cleanas - -3 - OPERATION - MT side ------------------------ - -A1 - Compile the Access Stratum (for IF mode) - -Pre-Req : RTAI installed and running - ICC 8.0 installed and running - file RHODOS26/src/access_stratum/l1/low/control/mmx.h copied in /usr/include - - > make mtif - > make asmtuserif - > make fpgatest - -A2 - Compile the Access Stratum (for RF mode) - -Pre-Req : RTAI installed and running - ICC 8.0 installed and running - file RHODOS26/src/access_stratum/l1/low/control/mmx.h copied in /usr/include - - > make guimakefiles - > make mtrf - > make asmtuserrf - > make fpgatest - - -B - Start the Access Stratum - - (as root ) > cd <..>RHODOS26/bin - - (first install) > create_rtfifos - (first install) > mknod -m 666 /dev/daq0 c 127 1 - - (-- ) > ./start_rtos - (-- ) > ./runrgif [for IF] [or ./runrga2 for RF] - - ==> to check correct operation: - (as root ) cat /dev/rtf62 - (as root ) tail -f /var/log/messages - -C - Start the NAS Driver - - (as root ) > cd <..>RHODOS26/bin - (-- ) > insmod nasmt.ko - (-- ) > ./mobile_node.up - -D - Stop the NAS Driver and the Access Stratum - - (-- ) > ./mobile_node.down - (-- ) > rmmod nasmt - (-- ) > <CTRL+C> on Acccess stratum window - (-- ) > ./stop_rtos - -E - Clean Access Stratum compilation - - > make cleanas - - -4 - Patching IPv6 ------------------------ - -For Linux with 2.6.xx kernel version (xx = 10 or 81): - -- move RHODOS26/non_access_stratum/driver/src/addrconf.c.26.xx to /usr/src/linux/net/ipv6/addrconf.c -- move RHODOS26/non_access_stratum/driver/src/if_arp.h.26.xx to /usr/src/linux/include/linux/if_arp.h -- recompile IPv6 (inside the kernel or as a module, as usual) - -5 - Start the MT connection ------------------------ - -You can use either the RAL-UMTS (RAL-CDMA) -- see corresponding documentation -- - -* OR * - -the tool provided with the driver (directory RHODOS26/src/non_access_stratum/driver/mt_tools). -Install the tool, update the Cell_id field if needed and click on the "Attach" button. - - - \ No newline at end of file diff --git a/openair2/NAS/DRIVER/CELLULAR/start_mt_cellular b/openair2/NAS/DRIVER/CELLULAR/start_mt_cellular deleted file mode 100755 index c89f19e9c04e315fdce80edaff46645816c9efee..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/start_mt_cellular +++ /dev/null @@ -1,13 +0,0 @@ -#xterm -hold "tail -f /var/log/messages" & -insmod ./NASMT/nascellmt.ko nas_IMEI=3,5,6,0,1,4,9,1,5,0,0,0,0,0 -#insmod ./NASMT/nascellmt.ko -sleep 2 -ifconfig oai0 10.0.1.2 netmask 255.255.255.0 broadcast 10.0.1.255 -#ifconfig oai0 add 2001:660:382:14:335:600:8014:9150/64 -#./bin/mobile_node.up -#sleep 3 -#./CTL_TOOL/gioctl cx add 0 5 -#xterm -hold -e ./bin/IALdummy & -#sleep 1 -#xterm -hold -e ./bin/tdcdma_gui & -#lsmod diff --git a/openair2/NAS/DRIVER/CELLULAR/start_rg_cellular_noradvd b/openair2/NAS/DRIVER/CELLULAR/start_rg_cellular_noradvd deleted file mode 100755 index 3d51140dcde1916cec44af8f32674ca7e9e65f87..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/start_rg_cellular_noradvd +++ /dev/null @@ -1,17 +0,0 @@ - -#xterm -hold -e ant -buildfile rrm_umts.xml run & -#sleep 2 -insmod ./NASRG/nascellrg.ko -sleep 2 -#bin/access_router_noradvd.up -sysctl -w net.ipv6.conf.default.dad_transmits=0 -#sysctl -w net.ipv6.conf.all.forwarding=1 -#sysctl -w net.ipv4.conf.all.forwarding=1 - -#ifconfig oai0 192.168.14.100 -ifconfig oai0 10.0.1.3 netmask 255.255.255.0 broadcast 10.0.1.255 -ifconfig oai0 add 2001:660:382:14::1/64 -#ifconfig graal0 192.168.14.100 -#ifconfig graal0 add 2001:690:2380:7777::1/64 -#ifconfig graal0 add 2001:660:382:14::1/64 -#lsmod \ No newline at end of file diff --git a/openair2/NAS/DRIVER/CELLULAR/start_rg_cellular_radvd b/openair2/NAS/DRIVER/CELLULAR/start_rg_cellular_radvd deleted file mode 100755 index f57fb7712d6fb16a76d1041e1e31af8c082767fc..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/start_rg_cellular_radvd +++ /dev/null @@ -1,17 +0,0 @@ - -#xterm -hold -e ant -buildfile rrm_umts.xml run & -#sleep 2 -insmod ./NASRG/nascellrg.ko -sleep 2 -#bin/access_router_noradvd.up -sysctl -w net.ipv6.conf.default.dad_transmits=0 -sysctl -w net.ipv6.conf.all.forwarding=1 -#sysctl -w net.ipv4.conf.all.forwarding=1 - -#ifconfig oai0 192.168.14.100 -ifconfig oai0 10.0.1.3 netmask 255.255.255.0 broadcast 10.0.1.255 -ifconfig oai0 add 2001:660:382:14::1/64 - -#lsmod -sleep 4s -radvd diff --git a/openair2/NAS/DRIVER/CELLULAR/stop_mt_cellular b/openair2/NAS/DRIVER/CELLULAR/stop_mt_cellular deleted file mode 100755 index e7325cf40f586f45dc4bb2cf20ff12d6507a0e2f..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/stop_mt_cellular +++ /dev/null @@ -1,5 +0,0 @@ -#killall -qw tdcdma_gui -#killall -qw IALdummy -#./bin/mobile_node.down -rmmod -w nascellmt - diff --git a/openair2/NAS/DRIVER/CELLULAR/stop_rg_cellular b/openair2/NAS/DRIVER/CELLULAR/stop_rg_cellular deleted file mode 100755 index 88d17a7e6bffae19a5ff224c8157bf0aac45fe45..0000000000000000000000000000000000000000 --- a/openair2/NAS/DRIVER/CELLULAR/stop_rg_cellular +++ /dev/null @@ -1,2 +0,0 @@ -ifconfig oai0 down -rmmod -w nascellrg diff --git a/openair2/NAS/Makefile.inc b/openair2/NAS/Makefile.inc deleted file mode 100644 index a06e8f690aa3d9ae1aea78d27767f293eace592b..0000000000000000000000000000000000000000 --- a/openair2/NAS/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -NAS_UE_DIR = $(OPENAIR2_TOP)/NAS - -NAS_UE_OBJS = - -NAS_UE_incl = \ - -I$(NAS_UE_DIR) diff --git a/openair2/NAS/SIMU_CELLULAR/Makefile b/openair2/NAS/SIMU_CELLULAR/Makefile deleted file mode 100755 index 26af978a4ef741d386f7be4614948057b91af3e6..0000000000000000000000000000000000000000 --- a/openair2/NAS/SIMU_CELLULAR/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# lines starting with the pound sign are comments. -# -# These things are options that you might need -# to tweak. - - -# You can modify the below as well, but probably -# won't need to. - -include $(OPENAIR_DIR)/common/utils/Makefile.inc -#UPDIR := /homes/mwett/rh_mw/RHODOS -COMMON_DIR = $(OPENAIR2_DIR)/COMMON -RRC_CELL_DIR = $(OPENAIR2_DIR)/RRC/CELLULAR -NAS_SIMU_DIR = $(OPENAIR2_DIR)/NAS/SIMU_CELLULAR -#ASN1_DIR = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES -ASN1_DIR = $(OPENAIR2_DIR) - -#UPDIR := $(EURECOM_SRC_PATH) -#GRAAL_DIR =$(UPDIR)/non_access_stratum/driver/nasmt -#RRC_DIR =$(UPDIR)/access_stratum/l3/rrc - -#CFLAGS += -Wall -g -DDEBUG_RRC_STATE -DUSER_MODE -DNODE_RG -DNODE_MT -CFLAGS += -std=gnu99 -I$(KERNEL_DIR) -DUSER_MODE -DNB_ANTENNAS_RX=1 - -ifdef CELL_RRM -CFLAGS += -DNODE_RG -OBJ +=rrm_fifo_standalone.o nasrg_simu_meas.o -else -ifdef MASTER -CFLAGS += -DNODE_RG -OBJ +=nasrg_simu_main.o nasrg_simu_control.o nasrg_simu_rrm_fifo.o nasrg_simu_meas.o -else -CFLAGS += -DNODE_MT -OBJ +=nasmt_simu_main.o nasmt_simu_control.o -endif -endif - -ifdef CELLULAR -CFLAGS += -DCELLULAR -DNO_RRM -I$(COMMON_DIR) -I$(RRC_CELL_DIR) -I$(NAS_SIMU_DIR) -I$(ASN1_DIR) -endif - - -$(OBJ) : %.o : %.c - $(CC) $(CFLAGS) -c -o $@ $< -pthread - -all: nasmt_simu nasrg_simu - -nasmt_sim : $(OBJ) - $(CC) -o nasmt_simu $(OBJ) $(CFLAGS) -lm -lrt -pthread - mv nasmt_simu $(OPENAIR_TARGETS)/SIMU/USER - -nasrg_sim : $(OBJ) - $(CC) -o nasrg_simu $(OBJ) $(CFLAGS) -lm -lrt -pthread - mv nasrg_simu $(OPENAIR_TARGETS)/SIMU/USER - -cell_rrm : $(OBJ) - $(CC) -o cell_rrm $(OBJ) $(CFLAGS) -lm -lrt -pthread - mv cell_rrm $(OPENAIR_TARGETS)/SIMU/USER - -clean: - -rm $(OBJ) $(EXECUTABLE) - diff --git a/openair2/NAS/SIMU_CELLULAR/nas_simu_proto.h b/openair2/NAS/SIMU_CELLULAR/nas_simu_proto.h deleted file mode 100644 index 86ab7a1ec53173011bc0302f2089ca484f2d11b6..0000000000000000000000000000000000000000 --- a/openair2/NAS/SIMU_CELLULAR/nas_simu_proto.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef __NAS_CONTROL_H__ -#define __NAS_CONTROL_H__ - -#ifdef NODE_MT -//----------------------------------------------------------------------------- -void nas_ue_control_init (void); -//int nas_ue_DC_attach(void); -//int nas_ue_DC_attach_complete(void); -int nas_ue_GC_Rcve_FIFO (void); -int nas_ue_NT_Rcve_FIFO (void); -int nas_ue_DC_Rcve_FIFO (void); -#endif - -#ifdef NODE_RG -//----------------------------------------------------------------------------- -void nas_rg_control_init (void); -//int nas_rg_DC_ConnectMs(void) ; -int nas_rg_DC_Rcve_FIFO (int time); - -int nasrg_rrm_socket_init(void); -void nasrg_rrm_fifos_init (void); -void nasrg_rrm_to_rrc_write (void); -void nasrg_rrm_from_rrc_read (void); - -int nasrg_meas_loop (int time, int UE_Id); -void nas_rg_print_buffer (char *buffer, int length); -/*void nasrg_print_meas_report (char *rrc_rrm_meas_payload, uint16_t type); -void nasrg_print_bs_meas_report (char *rrc_rrm_meas_payload, uint16_t type);*/ -void nasrg_print_meas_report (char *rrc_rrm_meas_payload, unsigned short type); -void nasrg_print_bs_meas_report (char *rrc_rrm_meas_payload, unsigned short type); -#endif - -#endif diff --git a/openair2/NAS/SIMU_CELLULAR/nasrg_simu_meas.c b/openair2/NAS/SIMU_CELLULAR/nasrg_simu_meas.c deleted file mode 100644 index a192b82d7247eafc2f8ae8e94df2e88d65507fb0..0000000000000000000000000000000000000000 --- a/openair2/NAS/SIMU_CELLULAR/nasrg_simu_meas.c +++ /dev/null @@ -1,646 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <pthread.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> - - -#include "openair_types.h" -#include "rrc_constant.h" - -#include "rrc_msg_constant.h" -#include "rrc_rrm_primitives.h" -#include "rrc_msg_ies.h" - -#include "nas_simu_proto.h" - -extern int rrc_rg_rrm_in_fifo; - -int sim_counter=0; - -/* Mobile Station */ -//------------------------------------------------------------------- -void nasrg_meas_if_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Intra-Frequency - rrm_control->type = IX_ifM; - // measurementCommand SETUP - rrm_control->command = MC_setup; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; - rrm_control->amount = amount16; - rrm_control->period = int2000; -} - -//------------------------------------------------------------------- -void nasrg_meas_if_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Intra-Frequency - rrm_control->type = IX_ifM; - // measurementCommand RELEASE - rrm_control->command = MC_release; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; -} - -//------------------------------------------------------------------- -void nasrg_meas_tv_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Traffic Volume - rrm_control->type = IX_tvM; - // measurementCommand SETUP - rrm_control->command = MC_setup; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; - rrm_control->amount = amount_inf; - rrm_control->period = int2000; -} - -//------------------------------------------------------------------- -void nasrg_meas_tv_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Traffic Volume - rrm_control->type = IX_tvM; - // measurementCommand RELEASE - rrm_control->command = MC_release; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; -} - -//------------------------------------------------------------------- -void nasrg_meas_q_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Quality - rrm_control->type = IX_qM; - // measurementCommand SETUP - rrm_control->command = MC_setup; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; - rrm_control->amount = amount2; //for test - //rrm_control->amount = amount_inf; // for execution - rrm_control->period = int3000; -} - -//------------------------------------------------------------------- -void nasrg_meas_q_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Quality - rrm_control->type = IX_qM; - // measurementCommand RELEASE - rrm_control->command = MC_release; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; -} - -//------------------------------------------------------------------- -void nasrg_meas_int_ue_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Internal UE - rrm_control->type = IX_iueM; - // measurementCommand SETUP - rrm_control->command = MC_setup; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; - rrm_control->amount = amount8; - rrm_control->period = int1000; -} - -//------------------------------------------------------------------- -void nasrg_meas_int_ue_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Internal UE - rrm_control->type = IX_iueM; - // measurementCommand RELEASE - rrm_control->command = MC_release; - rrm_control->BaseStation = 0; - rrm_control->UE_Id = UE_Id; -} - - -/* Base Station */ -//------------------------------------------------------------------- -void nasrg_meas_bs_tv_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Traffic Volume - rrm_control->type = IX_tvbM; - // measurementCommand SETUP - rrm_control->command = MC_setup; - rrm_control->BaseStation = 1; - rrm_control->UE_Id = UE_Id; - rrm_control->amount = amount_inf; - rrm_control->period = int4000; -} - -//------------------------------------------------------------------- -void nasrg_meas_bs_tv_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Traffic Volume - rrm_control->type = IX_tvbM; - // measurementCommand RELEASE - rrm_control->command = MC_release; - rrm_control->BaseStation = 1; - rrm_control->UE_Id = UE_Id; -} - -//------------------------------------------------------------------- -void nasrg_meas_bs_q_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Quality - rrm_control->type = IX_qbM; - // measurementCommand SETUP - rrm_control->command = MC_setup; - rrm_control->BaseStation = 1; - rrm_control->UE_Id = UE_Id; - rrm_control->amount = amount2; - rrm_control->period = int3000; -} - -//------------------------------------------------------------------- -void nasrg_meas_bs_q_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Quality - rrm_control->type = IX_qbM; - // measurementCommand RELEASE - rrm_control->command = MC_release; - rrm_control->BaseStation = 1; - rrm_control->UE_Id = UE_Id; -} - -//------------------------------------------------------------------- -void nasrg_meas_int_bs_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Internal BS - rrm_control->type = IX_ibsM; - // measurementCommand SETUP - rrm_control->command = MC_setup; - rrm_control->BaseStation = 1; - rrm_control->UE_Id = maxUsers; //should not be set - rrm_control->amount = amount16; - rrm_control->period = int4000; -} - -//------------------------------------------------------------------- -void nasrg_meas_int_bs_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - // measurement identity Internal BS - rrm_control->type = IX_ibsM; - // measurementCommand RELEASE - rrm_control->command = MC_release; - rrm_control->BaseStation = 1; - rrm_control->UE_Id = maxUsers; //should not be set -} - -//------------------------------------------------------------------- -void nasrg_send_meas_request_to_rrc (int ue_id, struct rrc_rrm_measure_ctl *rrm_control) -{ - //------------------------------------------------------------------- - rpc_message rpc_mess; - measurement_request meas_request; - int count =0; - - printf ("[NASRG_MEAS_TEST] RPC_MEASUREMENT_REQUEST --> RRC\n "); - memset ((char*)& rpc_mess, 0, sizeof (rpc_message)); - memset ((char*)& meas_request, 0, sizeof (measurement_request)); - //build header - rpc_mess.type = RPC_MEASUREMENT_REQUEST; - rpc_mess.length = sizeof (measurement_request); - // build content - meas_request.measurement_type = rrm_control->type; - meas_request.measurement_command = rrm_control->command; - // different conding between RRM and RRC - // Mobile terminal RRC = 0, RRM = 1 - // Base Station RRC = 1, RRM = 2 - meas_request.equipment_type = rrm_control->BaseStation + 1; - meas_request.equipment_id = rrm_control->UE_Id; - meas_request.amount = rrm_control->amount; - meas_request.period = rrm_control->period; - - // send to RRC - count = write(rrc_rg_rrm_in_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) & meas_request, sizeof (measurement_request)); - - if (count > 0) { - printf ("RRM message sent successfully on RRM FIFO, length: %d\n", count); - } else { - printf ("RRM FIFO transmit failed"); - } - -#ifdef DEBUG_NAS_MEAS_SIMU - nas_rg_print_buffer ((char *) & rpc_mess, sizeof (rpc_message)); - nas_rg_print_buffer ((char *) & meas_request, sizeof (meas_request)); -#endif -} - -//------------------------------------------------------------------- -// in case not rrc_rg_meas_loop (time,UE_Id); -int nasrg_rrm_meas_stop (int time, int UE_Id) -{ - //------------------------------------------------------------------- - struct rrc_rrm_measure_ctl control; - - // Measurement Control - Stop Quality previously sent by RRM - nasrg_meas_q_release (UE_Id, &control); - //rrc_rrm_measure_request (control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - return 0; -} -//------------------------------------------------------------------- -// rrc_rg_meas_loop (time,UE_Id); -int nasrg_meas_loop (int time, int UE_Id) -{ - //------------------------------------------------------------------- - struct rrc_rrm_measure_ctl control; - - sim_counter++; - // if (time % 5 == 0) { -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n[NASRG_MEAS_TEST] Simu Measurement Time : %d, counter : %d\n", time, sim_counter); -#endif - - // } - if (sim_counter == 8) { - // Measurement Control - Stop Quality previously sent by RRM -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] NAS sends Measurement Control (Stop Quality) message at time : %d\n\n", sim_counter); -#endif - // setup if measurement for MT - nasrg_meas_q_release (UE_Id, &control); - //rrc_rrm_measure_request (control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // Intra-Frequency - // if (sim_counter == 140) { - if (sim_counter == 16) { - // Measurement Control - Start Intra-frequency -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Start Intra-freq) message at time : %d\n\n", sim_counter); -#endif - // setup if measurement for MT - nasrg_meas_if_setup (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // if (sim_counter == 700) { - if (sim_counter == 70) { - // Measurement Control - Stop Intra-frequency -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Stop Intra-freq) message at time : %d\n\n", sim_counter); -#endif - // setup if measurement for MT - nasrg_meas_if_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // Traffic Volume - // if (sim_counter == 100) { - if (sim_counter == 12) { - // Measurement Control - Start Traffic Volume -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Start Traffic Volume) message at time : %d\n\n", sim_counter); -#endif - // setup if measurement for MT - nasrg_meas_tv_setup (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // if (sim_counter == 990) { - if (sim_counter == 92) { - // Measurement Control - Stop Traffic Volume -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Stop Traffic Volume) message at time : %d\n\n", sim_counter); -#endif - // setup if measurement for MT - nasrg_meas_tv_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // Quality - // if (sim_counter == 503) { - if (sim_counter == 50) { - // Measurement Control - Start Quality -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Start Quality) message at time : %d\n\n", sim_counter); -#endif - // setup if measurement for MT - nasrg_meas_q_setup (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // if (sim_counter == 995) { - if (sim_counter == 96) { - // Measurement Control - Stop Quality -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Stop Quality) message at time : %d\n\n", sim_counter); -#endif - // setup if measurement for MT - nasrg_meas_q_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // Internal UE - // if (sim_counter == 210) { - if (sim_counter == 20) { - // Measurement Control - Start Internal UE -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Start Int UE) message at time : %d\n\n", sim_counter); -#endif - // setup int_ue measurement for MT - nasrg_meas_int_ue_setup (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // if (sim_counter == 999) { - if (sim_counter == 98) { - // Measurement Control - Stop Internal UE -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG sends Measurement Control (Stop Int UE) message at time : %d\n\n", sim_counter); -#endif - nasrg_meas_int_ue_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // Internal BS - // if (sim_counter == 105) { - if (sim_counter == 14) { - // Measurement Control - Start Internal BS -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG starts internal Measurement (Int BS) at time : %d\n\n", sim_counter); -#endif - nasrg_meas_int_bs_setup (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // if (sim_counter == 980) { - if (sim_counter == 86) { - // Measurement Control - Stop Internal BS -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG stops internal Measurement (Int BS) at time : %d\n\n", sim_counter); -#endif - nasrg_meas_int_bs_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // Traffic Volume BS - // if (sim_counter == 220) { - if (sim_counter == 22) { - // Measurement Control - Start Traffic Volume BS -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG starts internal Measurement (Traffic Volume BS) at time : %d\n\n", sim_counter); -#endif - nasrg_meas_bs_tv_setup (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // if (sim_counter == 900) { - if (sim_counter == 80) { - // Measurement Control - Stop Traffic Volume BS -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG stops internal Measurement (Traffic Volume BS) at time : %d\n\n", sim_counter); -#endif - nasrg_meas_bs_tv_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // Quality BS - // if (sim_counter == 625) { - if (sim_counter == 62) { - // Measurement Control - Start Quality BS -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG starts internal Measurement (Quality BS) at time : %d\n\n", sim_counter); -#endif - nasrg_meas_bs_q_setup (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - // if (sim_counter == 989) { - if (sim_counter == 90) { - // Measurement Control - Stop Quality BS -#ifdef DEBUG_NAS_MEAS_SIMU - printf ("\n\n[NASRG_MEAS_TEST] RG stops internal Measurement (Quality BS) at time : %d\n\n", sim_counter); -#endif - nasrg_meas_bs_q_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - } - - return sim_counter; -} - -//----------------------------------------------------------------------------- -//void rrc_rg_print_meas_report (struct rrc_rg_mt_meas_rep *p){ -void nasrg_print_meas_report (char *rrc_rrm_meas_payload, uint16_t type) -{ - //----------------------------------------------------------------------------- - int i, j; - char *payload[20] = - { "pl0", "pl4", "pl8", "pl16", "pl32", "pl64", "pl128", "pl256", "pl512", "pl1024", "pl2k", "pl4k", "pl8k", "pl16k", "pl32k", "pl64k", "pl128k", "pl256k", "pl512k", "pl1024k" }; - char *average[20] = { - "pla0", "pla4", "pla8", "pla16", "pla32", "pla64", "pla128", "pla256", "pla512", "pla1024", "pla2k", - "pla4k", "pla8k", "pla16k", "pla32k", "pla64k", "pla128k", "pla256k", "pla512k","pla1024k" - }; - char *variance[14] = { "plv0", "plv4", "plv8", "plv16", "plv32", "plv64", "plv128", "plv256", "plv512", "plv1024", "plv2k", "plv4k", "plv8k", "plv16k" }; - - printf ("\n[NASRG-MEAS] ************** MT Measurement Report Message *****************\n"); - - switch (type) { - case RPC_L1_MEASUREMENT_MT_INTRA_FREQUENCY_REPORT: { - struct rrc_rrm_meas_report_mt_if *p; - p = (struct rrc_rrm_meas_report_mt_if *)rrc_rrm_meas_payload; - printf ("Intra Frequency Measurement\t Number of cells: %d\n", p->if_num_cells); - - for (i = 0; i < p->if_num_cells; i++) { - printf ("[NASRG-MEAS] Cell number: %d\tCell Identity: %d\tCell Parameters Id: %d\tP-CCPCH RSCP: %d\tPathloss: %d\n", i, p->if_cell_id[i], p->if_cell_parms_id[i], p->if_BCH_RSCP[i], p->if_pathloss[i]); - printf ("\tTimeslot ISCP for each slot:\t"); - - for (j = 0; j < JRRM_SLOTS_PER_FRAME; j++) - printf ("%d: %d, ", j, p->if_slot_iscp[i][j]); - - printf ("\n"); - } - } - break; - - case RPC_L1_MEASUREMENT_MT_TRAFFIC_VOLUME_REPORT: { - struct rrc_rrm_meas_report_mt_tv *p; - p = (struct rrc_rrm_meas_report_mt_tv *)rrc_rrm_meas_payload; - printf ("Traffic Volume Measurement -\t Number of RBs: %d\n", p->tv_num_rbs); - - for (i = 0; i < p->tv_num_rbs; i++) - printf ("[NASRG-MEAS] RB_Id : %d\t, RLC_BufferPayload : %s\t, Average : %s\t, Variance : %s\n", - p->tv_rbid[i], payload[p->tv_rb_payload[i]], average[p->tv_rb_average[i]], variance[p->tv_rb_variance[i]]); - } - break; - - case RPC_L1_MEASUREMENT_MT_QUALITY_REPORT: { - struct rrc_rrm_meas_report_mt_q *p; - p = (struct rrc_rrm_meas_report_mt_q *)rrc_rrm_meas_payload; - printf ("Quality Measurement -\t Number of Transport Channels : %d, Number of TFCS : %d\n", p->q_num_TrCH, p->q_num_tfcs); - printf ("[NASRG-MEAS] BLER for each Transport Channel:\t"); - - for (i = 0; i < p->q_num_TrCH; i++) - printf ("%d: %d, ", p->q_dl_TrCH_id[i], p->q_dl_TrCH_BLER[i]); - - printf ("\n"); - printf ("[NASRG-MEAS] SIR for each TFCS for each slot:\n"); - - for (i = 0; i < p->q_num_tfcs; i++) { - printf ("%d: ", p->q_tfcs_id[i]); - - for (j = 0; j < JRRM_SLOTS_PER_FRAME; j++) - printf ("%d, ", p->q_sir[i][j]); - - printf ("\n"); - } - } - break; - - case RPC_L1_MEASUREMENT_MT_INTERNAL_REPORT: { - struct rrc_rrm_meas_report_mt_int *p; - p = (struct rrc_rrm_meas_report_mt_int *)rrc_rrm_meas_payload; - printf ("UE internal Measurement\t Timing Advance: %d\n", p->int_timing_advance); - printf ("[NASRG-MEAS] Transmitted Power for each slot:\t"); - - for (j = 0; j < JRRM_SLOTS_PER_FRAME; j++) - printf ("%d: %d, ", j, p->int_xmit_power[j]); - - printf ("\n"); - } - break; - } - - printf ("[NASRG-MEAS] *****END********* Measurement Report Message *******\n\n"); -} - -//----------------------------------------------------------------------------- -void nasrg_print_bs_meas_report (char *rrc_rrm_meas_payload, uint16_t type) -{ - //----------------------------------------------------------------------------- - int i, j; - char *payload[20] = - { "pl0", "pl4", "pl8", "pl16", "pl32", "pl64", "pl128", "pl256", "pl512", "pl1024", "pl2k", "pl4k", "pl8k", "pl16k", "pl32k", "pl64k", "pl128k", "pl256k", "pl512k", "pl1024k" }; - char *average[20] = { - "pla0", "pla4", "pla8", "pla16", "pla32", "pla64", "pla128", "pla256", "pla512", "pla1024", "pla2k", - "pla4k", "pla8k", "pla16k", "pla32k", "pla64k", "pla128k", "pla256k", "pla512k", "pla1024k" - }; - char *variance[14] = { "plv0", "plv4", "plv8", "plv16", "plv32", "plv64", "plv128", "plv256", "plv512", "plv1024", "plv2k", "plv4k", "plv8k", "plv16k" }; - - printf ("\n[NASRG-MEAS] ************** BS Measurement Report Message *****************\n"); - - switch (type) { - case RPC_L1_MEASUREMENT_RG_TRAFFIC_VOLUME_REPORT: { - struct rrc_rrm_meas_report_bs_tv *p; - p = (struct rrc_rrm_meas_report_bs_tv *)rrc_rrm_meas_payload; - printf ("Traffic Volume Measurement -\t Number of RBs: %d\n", p->tv_num_rbs); - - for (i = 0; i < p->tv_num_rbs; i++) - printf ("[NASRG-MEAS] RB_Id : %d\t, RLC_BufferPayload : %s\t, Average : %s\t, Variance : %s\n", - p->tv_rbid[i], payload[p->tv_rb_payload[i]], average[p->tv_rb_average[i]], variance[p->tv_rb_variance[i]]); - } - break; - - case RPC_L1_MEASUREMENT_RG_QUALITY_REPORT: { - struct rrc_rrm_meas_report_bs_q *p; - p = (struct rrc_rrm_meas_report_bs_q *)rrc_rrm_meas_payload; - printf ("Quality Measurement -\t Number of Transport Channels : %d, Number of TFCS : %d\n", p->q_num_TrCH, p->q_num_tfcs); - printf ("[NASRG-MEAS] BLER for each Transport Channel:\t"); - - for (i = 0; i < p->q_num_TrCH; i++) - printf ("%d: %d, ", p->q_dl_TrCH_id[i], p->q_dl_TrCH_BLER[i]); - - printf ("\n"); - printf ("[NASRG-MEAS] SIR for each TFCS for each slot:\n"); - - for (i = 0; i < p->q_num_tfcs; i++) { - printf ("%d: ", p->q_tfcs_id[i]); - - for (j = 0; j < JRRM_SLOTS_PER_FRAME; j++) - printf ("%d, ", p->q_sir[i][j]); - - printf ("\n"); - } - } - break; - - case RPC_L1_MEASUREMENT_RG_INTERNAL_REPORT: { - struct rrc_rrm_meas_report_bs_int *p; - p = (struct rrc_rrm_meas_report_bs_int *)rrc_rrm_meas_payload; - printf ("BS internal Measurement\n"); - - for (i = 0; i < numANTENNAS; i++) { - printf ("[NASRG-MEAS] Transmitted Power for each slot on antenna %d : ", i); - - for (j = 0; j < JRRM_SLOTS_PER_FRAME; j++) - printf ("%d: %d, ", j, p->int_xmit_power[i][j]); - - printf ("\n"); - } - - for (i = 0; i < JRRM_SLOTS_PER_FRAME; i++) { - printf ("[NASRG-MEAS] RSCP for each channel on slot %d : ", i); - - for (j = 0; j < MAXCH; j++) - printf ("%d: %d, ", j, p->int_rscp[i][j]); - - printf ("\n"); - } - - for (i = 0; i < numANTENNAS; i++) { - printf ("[NASRG-MEAS] RSSI RF for each slot on antenna %d : ", i); - - for (j = 0; j < JRRM_SLOTS_PER_FRAME; j++) - printf ("%d: %d, ", j, p->int_rssi_rf[i][j]); - - printf ("\n"); - } - - for (i = 0; i < NUMSPARE; i++) { - printf ("[NASRG-MEAS] Spare value : %d: %d\n", i, p->int_spare[i]); - } - } - break; - } - - printf ("[NASRG-MEAS] *****END********* Measurement Report Message *******\n\n"); -} - diff --git a/openair2/NAS/SIMU_CELLULAR/rrm_fifo_standalone.c b/openair2/NAS/SIMU_CELLULAR/rrm_fifo_standalone.c deleted file mode 100644 index e9cefdd926a169c48986c4627541a2d13079f08c..0000000000000000000000000000000000000000 --- a/openair2/NAS/SIMU_CELLULAR/rrm_fifo_standalone.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <errno.h> -#include <sys/time.h> -#include <ctype.h> - -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <pthread.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -// -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -//----------------------------------------------------------------------------- -#include "openair_types.h" -#include "rrc_constant.h" -#include "nas_simu_proto.h" - -#include "rrc_rrm_sap.h" -#include "rrc_msg_constant.h" -#include "rrc_rrm_primitives.h" - -void nasrg_meas_q_setup (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control); -void nasrg_meas_q_release (int UE_Id, struct rrc_rrm_measure_ctl *rrm_control); -void nasrg_send_meas_request_to_rrc (int ue_id, struct rrc_rrm_measure_ctl *rrm_control); -//----------------------------------------------------------------------------- -int rrc_rg_rrm_in_fifo; -int rrc_rg_rrm_out_fifo; -int tXmit_id; -#define RRM_MSG_MAX_LENGTH 1500 -struct rrc_rrm_measure_ctl control; - -//----------------------------------------------------------------------------- -// Open FIFOs for RG RRC SAPs -void nasrg_rrm_fifos_init (void) -{ - //----------------------------------------------------------------------------- - int write_flag = O_WRONLY | O_NONBLOCK | O_NDELAY; - int read_flag = O_RDONLY | O_NONBLOCK | O_NDELAY; - - // Open FIFOs - - while ((rrc_rg_rrm_in_fifo = open (RRM_INPUT_SAPI, write_flag)) < 0) { - printf ("%s returned value %d\n", RRM_INPUT_SAPI, rrc_rg_rrm_in_fifo); - fflush(stdout); - sleep (1); - } - - while ((rrc_rg_rrm_out_fifo = open (RRM_OUTPUT_SAPI, read_flag)) < 0) { - printf ("%s returned value %d\n", RRM_OUTPUT_SAPI, rrc_rg_rrm_out_fifo); - fflush(stdout); - sleep (1); - } - - printf ("FIFO RRM_INPUT_SAPI, %d\n", rrc_rg_rrm_in_fifo); - printf ("FIFO RRM_OUTPUT_SAPI, %d\n", rrc_rg_rrm_out_fifo); -} - -//------------------------------------------------------------------- -void rrm_connection_response (void) -{ - //------------------------------------------------------------------- - rpc_message rpc_mess; - connection_response response; - int count=0; - char *sim_data = "Void configuration\0"; - - printf ("[CELL-RRM] RPC_CONNECTION_RESPONSE --> RRC\n "); - rpc_mess.type = RPC_CONNECTION_RESPONSE; - rpc_mess.length = sizeof (connection_response)+ strlen (sim_data); - response.equipment_id = 0; - response.status = STATUS_CONNECTION_ACCEPTED; - - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & confirm, sizeof (add_user_confirm)); - count = write(rrc_rg_rrm_in_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) & response, sizeof (connection_response)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) sim_data, strlen (sim_data)); - - if (count > 0) { - printf ("RRM message sent successfully on RRM FIFO, length: %d\n", count); - } else { - printf ("RRM FIFO transmit failed"); - } -} - -//------------------------------------------------------------------- -void rrm_add_user_response (char *rcve_buffer) -{ - //------------------------------------------------------------------- - rpc_message rpc_mess; - add_user_response response; - add_user_request *request; - int count=0; - char *sim_data = "Void configuration\0"; - - request = (add_user_request *)rcve_buffer; - printf ("[CELL-RRM] RPC_ADD_USER_RESPONSE --> RRC\n "); - rpc_mess.type = RPC_ADD_USER_RESPONSE; - rpc_mess.length = sizeof (add_user_response)+ strlen (sim_data); - response.equipment_id = 0; - response.user_id = request->user_id; - response.tx_id = request->tx_id; - response.status = ADD_USER_SUCCESSFUL; - - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & confirm, sizeof (add_user_confirm)); - count = write(rrc_rg_rrm_in_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) & response, sizeof (add_user_response)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) sim_data, strlen (sim_data)); - - if (count > 0) { - printf ("RRM message sent successfully on RRM FIFO, length: %d\n", count); - } else { - printf ("RRM FIFO transmit failed"); - } -} - -//------------------------------------------------------------------- -void rrm_remove_user_response (char *rcve_buffer) -{ - //------------------------------------------------------------------- - rpc_message rpc_mess; - remove_user_response response; - remove_user_request *request; - int count=0; - char *sim_data = "Void configuration\0"; - - request = (remove_user_request *)rcve_buffer; - printf ("[CELL-RRM] RPC_REMOVE_USER_RESPONSE --> RRC\n "); - rpc_mess.type = RPC_REMOVE_USER_RESPONSE; - rpc_mess.length = sizeof (remove_user_response)+ strlen (sim_data); - response.equipment_id = 0; - response.user_id = request->user_id; - response.tx_id = request->tx_id; - response.status = REMOVE_USER_SUCCESSFUL; - - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & confirm, sizeof (add_user_confirm)); - count = write(rrc_rg_rrm_in_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) & response, sizeof (remove_user_response)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) sim_data, strlen (sim_data)); - - if (count > 0) { - printf ("RRM message sent successfully on RRM FIFO, length: %d\n", count); - } else { - printf ("RRM FIFO transmit failed"); - } - - /* Not sure it is really needed here - usleep (5000); //wait 5ms - // stop q measurement for MT - nasrg_meas_q_release (UE_Id, &control); - nasrg_send_meas_request_to_rrc (UE_Id, &control); - */ -} - -//------------------------------------------------------------------- -void rrm_add_radio_access_bearer_response (char *rcve_buffer) -{ - //------------------------------------------------------------------- - rpc_message rpc_mess; - add_radio_access_bearer_response response; - add_radio_access_bearer_request *request; - int count=0; - char *sim_data = "Void configuration\0"; - - request = (add_radio_access_bearer_request *)rcve_buffer; - printf ("[CELL-RRM] RPC_ADD_RADIO_ACCESS_BEARER_RESPONSE --> RRC\n "); - rpc_mess.type = RPC_ADD_RADIO_ACCESS_BEARER_RESPONSE; - rpc_mess.length = sizeof (add_radio_access_bearer_response)+ strlen (sim_data); - response.user_id = request->user_id; - response.rab_id = request->rab_id; - response.tx_id = request->tx_id; - response.status = ADD_RADIO_ACCESS_BEARER_SUCCESSFUL; - - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & confirm, sizeof (add_user_confirm)); - count = write(rrc_rg_rrm_in_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) & response, sizeof (add_radio_access_bearer_response)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) sim_data, strlen (sim_data)); - - if (count > 0) { - printf ("RRM message sent successfully on RRM FIFO, length: %d\n", count); - } else { - printf ("RRM FIFO transmit failed"); - } -} - -//------------------------------------------------------------------- -void rrm_add_measurement_request (char *rcve_buffer) -{ - //------------------------------------------------------------------- - add_radio_access_bearer_confirm *confirm; - - confirm = (add_radio_access_bearer_confirm *)rcve_buffer; - printf ("[CELL-RRM] RPC_L1_MEASUREMENT_MT_QUALITY_REPORT --> RRC\n "); - - // TEMP removed the Meas request (causes bothe messages to be received together by RRC RG - // usleep (20000); //wait 5ms - // setup q measurement for MT - nasrg_meas_q_setup (confirm->user_id, &control); - nasrg_send_meas_request_to_rrc (confirm->user_id, &control); - -} - - -//------------------------------------------------------------------- -void rrm_remove_radio_access_bearer_response (char *rcve_buffer) -{ - //------------------------------------------------------------------- - rpc_message rpc_mess; - remove_radio_access_bearer_response response; - remove_radio_access_bearer_request *request; - int count=0; - char *sim_data = "Void configuration\0"; - - request = (remove_radio_access_bearer_request *)rcve_buffer; - printf ("[CELL-RRM] RPC_REMOVE_RADIO_ACCESS_BEARER_RESPONSE --> RRC\n "); - rpc_mess.type = RPC_REMOVE_RADIO_ACCESS_BEARER_RESPONSE; - rpc_mess.length = sizeof (remove_radio_access_bearer_response)+ strlen (sim_data); - response.user_id = request->user_id; - response.rab_id = request->rab_id; - response.tx_id = request->tx_id; - response.status = REMOVE_RADIO_ACCESS_BEARER_SUCCESSFUL; - - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - //count = rtf_put (protocol_bs->rrc.rc_rrm.output_fifo, (uint8_t *) & confirm, sizeof (add_user_confirm)); - count = write(rrc_rg_rrm_in_fifo, (uint8_t *) & rpc_mess, sizeof (rpc_message)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) & response, sizeof (remove_radio_access_bearer_response)); - count += write(rrc_rg_rrm_in_fifo, (uint8_t *) sim_data, strlen (sim_data)); - - if (count > 0) { - printf ("RRM message sent successfully on RRM FIFO, length: %d\n", count); - } else { - printf ("RRM FIFO transmit failed"); - } - - usleep (20000); //wait 5ms - // stop q measurement for MT - nasrg_meas_q_release (request->user_id, &control); - nasrg_send_meas_request_to_rrc (request->user_id, &control); -} - - -//----------------------------------------------------------------------------- -// Check if anything in RRC FIFO and send it to RRM -void nasrg_rrm_from_rrc_read (void) -{ - //----------------------------------------------------------------------------- - char rcve_buffer[RRM_MSG_MAX_LENGTH]; - int rpc_header_size=0; - int count = 0; - rpc_message *rrc_rrm_mess; - char *rrc_rrm_meas_payload; - - memset (rcve_buffer, 0, RRM_MSG_MAX_LENGTH - 1); - rpc_header_size = sizeof (rpc_message); - rrc_rrm_mess = (rpc_message *) rcve_buffer; - - if ((count = read (rrc_rg_rrm_out_fifo, rcve_buffer, rpc_header_size)) > 0) { - //printf("\n RRM FIFO %d, bytes count %d", rrc_rg_rrm_out_fifo, count); -#ifdef DEBUG_RRC_RRM_INTF - printf ("\n [DEBUG]Message Received in RRM FIFO %d , length %d, type %d \n", rrc_rg_rrm_out_fifo, rrc_rrm_mess->length, rrc_rrm_mess->type); -#endif - //get the rest of the primitive - count += read (rrc_rg_rrm_out_fifo, &(rcve_buffer[rpc_header_size]), rrc_rrm_mess->length ); - - switch (rrc_rrm_mess->type) { - case RPC_CONNECTION_REQUEST: - printf ("\n[CELL-RRM]Received RPC_CONNECTION_REQUEST, length %d\n", rrc_rrm_mess->length); - rrm_connection_response(); - break; - - case RPC_ADD_USER_REQUEST: - printf ("\n[CELL-RRM]Received RPC_ADD_USER_REQUEST, length %d\n", rrc_rrm_mess->length); - rrm_add_user_response(&(rcve_buffer[rpc_header_size])); - break; - - case RPC_REMOVE_USER_REQUEST: - printf ("\n[CELL-RRM]Received RPC_REMOVE_USER_REQUEST, length %d\n", rrc_rrm_mess->length); - rrm_remove_user_response(&(rcve_buffer[rpc_header_size])); - break; - - case RPC_ADD_RADIO_ACCESS_BEARER_REQUEST: - printf ("\n[CELL-RRM]Received RPC_ADD_RADIO_ACCESS_BEARER_REQUEST, length %d\n", rrc_rrm_mess->length); - rrm_add_radio_access_bearer_response(&(rcve_buffer[rpc_header_size])); - break; - - case RPC_REMOVE_RADIO_ACCESS_BEARER_REQUEST: - printf ("\n[CELL-RRM]Received RPC_REMOVE_RADIO_ACCESS_BEARER_REQUEST, length %d\n", rrc_rrm_mess->length); - rrm_remove_radio_access_bearer_response(&(rcve_buffer[rpc_header_size])); - break; - - case RPC_ADD_USER_CONFIRM: - printf ("\n[CELL-RRM]Received RPC RPC_ADD_USER_CONFIRM , length %d\n", rrc_rrm_mess->length); - break; - - case RPC_ADD_RADIO_ACCESS_BEARER_CONFIRM: - printf ("\n[CELL-RRM]Received RPC RPC_ADD_RADIO_ACCESS_BEARER_CONFIRM , length %d\n", rrc_rrm_mess->length); - //rrm_add_measurement_request(&(rcve_buffer[rpc_header_size])); - break; - - case RPC_L1_MEASUREMENT_RG_INTERNAL_REPORT: - case RPC_L1_MEASUREMENT_RG_QUALITY_REPORT: - case RPC_L1_MEASUREMENT_RG_TRAFFIC_VOLUME_REPORT: - rrc_rrm_meas_payload = (char *)rcve_buffer +12; //12 = rpc_header + equipment_id - //nas_rg_print_buffer (rrc_rrm_meas_payload, rrc_rrm_mess->length); - nasrg_print_bs_meas_report (rrc_rrm_meas_payload,rrc_rrm_mess->type); - break; - - case RPC_L1_MEASUREMENT_MT_INTERNAL_REPORT: - case RPC_L1_MEASUREMENT_MT_QUALITY_REPORT: - case RPC_L1_MEASUREMENT_MT_TRAFFIC_VOLUME_REPORT: - case RPC_L1_MEASUREMENT_MT_INTRA_FREQUENCY_REPORT: - rrc_rrm_meas_payload = (char *)rcve_buffer +12; //12 = rpc_header + equipment_id - //nas_rg_print_buffer (rrc_rrm_meas_payload, rrc_rrm_mess->length); - nasrg_print_meas_report (rrc_rrm_meas_payload,rrc_rrm_mess->type); - break; - - default: - break; - } - - fflush(stdout); - } -} - - -//----------------------------------------------------------------------------- -int main (int argc, char **argv) -{ - //----------------------------------------------------------------------------- - int time = 0; - // int rc, sd_rrm; - // fd_set readfds; - // struct timeval tv; - tXmit_id =0; - nasrg_rrm_fifos_init (); - printf ("[RRM] RRM FIFOs ready\n"); - fflush(stdout); - - while (1) { - usleep (100000); - time ++; - //printf ("\n[RRM_TEST] Simu Measurement Time at Main: %d\n", time); - - // check RRM FIFO - nasrg_rrm_from_rrc_read(); - } -} diff --git a/openair2/NETWORK_DRIVER/LITE/Makefile b/openair2/NETWORK_DRIVER/LITE/Makefile deleted file mode 100755 index 76ba3b5bdb3baaed7780d38cb60ee40699fc6d5e..0000000000000000000000000000000000000000 --- a/openair2/NETWORK_DRIVER/LITE/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# NASMESH Driver makefile -# -include $(OPENAIR_DIR)/common/utils/Makefile.inc -NAS_UPDIR := $(shell /bin/pwd) - -KERNEL_ARCH:=$(shell echo `uname -m`) -SET_X64:=$(shell if [ $(KERNEL_ARCH) = 'x86_64' ]; then echo true ; fi) - -#################################################### -# EXTRA COMPILER FLAGS -#################################################### -EXTRA_CFLAGS = -I$(OPENAIR2_DIR)/COMMON -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) - -ifdef ADDRCONF -EXTRA_CFLAGS += -DADDRCONF -endif - -ifdef OAI_NW_DRIVER_TYPE_ETHERNET -EXTRA_CFLAGS += -DOAI_NW_DRIVER_TYPE_ETHERNET -endif - -ifdef OAI_NW_DRIVER_USE_NETLINK -EXTRA_CFLAGS += -DOAI_NW_DRIVER_USE_NETLINK -else -EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall -endif - -ccflags-y= $(CFLAGS) $(EXTRA_CFLAGS) -CFLAGS= - -ifdef LOOPBACK -EXTRA_CFLAGS += -DLOOPBACK_TEST -endif - -ifdef ADDRESS_FIX -EXTRA_CFLAGS += -DNAS_ADDRESS_FIX -endif - -#################################################### -# LOADABLE MODULE GOALS -#################################################### -obj-m += oai_nw_drv.o -oai_nw_drv-objs += device.o -oai_nw_drv-objs += common.o -oai_nw_drv-objs += ioctl.o -oai_nw_drv-objs += classifier.o -oai_nw_drv-objs += tool.o -ifdef OAI_NW_DRIVER_USE_NETLINK -oai_nw_drv-objs += netlink.o -endif - -#################################################### -# REVOIR LE CLEAN -#################################################### - -#netlink.ko: - #make $(x)$(y) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules - -#oai_nw_drv.ko: -# make V=1 -C $(KERNEL_DIR) M=`pwd` modules -print: - @echo subversion : $(SUBVERSION) -clean: - rm -f *.ko - rm -f .*.ko.cmd - rm -f .*.o.cmd - rm -f *.o - rm -f *.mod.c - find . -name *.ko -delete - find . -name .*.o -delete - find . -name *.o -delete - find . -name *.mod.c -delete diff --git a/openair2/NETWORK_DRIVER/LITE/device.c b/openair2/NETWORK_DRIVER/LITE/device.c index fe60d82c157881236a6c0955106af1beca2b6ffd..854c3bcc997b07b4231b088a2eabd9215d8e6f42 100644 --- a/openair2/NETWORK_DRIVER/LITE/device.c +++ b/openair2/NETWORK_DRIVER/LITE/device.c @@ -28,13 +28,6 @@ */ /*******************************************************************************/ -#ifndef OAI_NW_DRIVER_USE_NETLINK -#ifdef RTAI -#include "rtai_posix.h" -#define RTAI_IRQ 30 //try to get this irq with RTAI -#endif // RTAI -#endif // OAI_NW_DRIVER_USE_NETLINK - #include "constant.h" #include "local.h" #include "proto_extern.h" @@ -519,23 +512,12 @@ int init_module (void) #ifndef OAI_NW_DRIVER_USE_NETLINK -#ifdef RTAI //with RTAI you have to indicate which irq# you want - - pdcp_2_oai_nw_drv_irq=rt_request_srq(0, oai_nw_drv_interrupt, NULL); - -#endif - if (pdcp_2_oai_nw_drv_irq == -EBUSY || pdcp_2_oai_nw_drv_irq == -EINVAL) { printk("[OAI_IP_DRV][%s] No interrupt resource available\n", __FUNCTION__); return -EBUSY; } else printk("[OAI_IP_DRV][%s] Interrupt %d\n", __FUNCTION__, pdcp_2_oai_nw_drv_irq); - //rt_startup_irq(RTAI_IRQ); - - //rt_enable_irq(RTAI_IRQ); - - #endif //NETLINK for (inst=0; inst<OAI_NW_DRV_NB_INSTANCES_MAX; inst++) { @@ -601,12 +583,6 @@ void cleanup_module(void) if (pdcp_2_oai_nw_drv_irq!=-EBUSY) { pdcp_2_oai_nw_drv_irq=0; -#ifdef RTAI - // V1 - // rt_free_linux_irq(priv->irq, NULL); - // END V1 - rt_free_srq(pdcp_2_oai_nw_drv_irq); -#endif // Start IRQ linux //free_irq(priv->irq, NULL); // End IRQ linux diff --git a/openair2/NETWORK_DRIVER/MESH/Makefile b/openair2/NETWORK_DRIVER/MESH/Makefile deleted file mode 100755 index f4bf87f3185dab440d6bf00b5598c942f2a0597b..0000000000000000000000000000000000000000 --- a/openair2/NETWORK_DRIVER/MESH/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -# NASMESH Driver makefile -# -include $(OPENAIR_DIR)/common/utils/Makefile.inc -NAS_UPDIR := $(shell /bin/pwd) - -#################################################### -# NASMESH compilation flags -#################################################### -#RTAI=1 - -#################################################### -# D E B U G F L A G S -#################################################### - -#################################################### -# EXTRA COMPILER FLAGS -#################################################### -#EXTRA_CFLAGS = -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) -EXTRA_CFLAGS += -I$(OPENAIR2_DIR) -ifdef PDCP_USE_NETLINK -EXTRA_CFLAGS += -DPDCP_USE_NETLINK -else -EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall -endif - -ifdef LOOPBACK -EXTRA_CFLAGS += -DLOOPBACK_TEST -endif - -ifdef ADDRESS_FIX -EXTRA_CFLAGS += -DNAS_ADDRESS_FIX -endif -ifdef NAS_DEBUG_RECEIVE -EXTRA_CFLAGS += -DNAS_DEBUG_RECEIVE -endif - -ifdef NAS_DEBUG_SEND -EXTRA_CFLAGS += -DNAS_DEBUG_SEND -endif - -ccflags-y := $(CFLAGS) $(EXTRA_CFLAGS) -CFLAGS= - -#################################################### -# LOADABLE MODULE GOALS -#################################################### -obj-m += nasmesh.o -nasmesh-objs += device.o -nasmesh-objs += common.o -nasmesh-objs += ioctl.o -nasmesh-objs += classifier.o -nasmesh-objs += tool.o -nasmesh-objs += mesh.o -ifdef PDCP_USE_NETLINK -nasmesh-objs += netlink.o -endif - -#################################################### -# REVOIR LE CLEAN -#################################################### - -#netlink.ko: -# make PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules - -#nasmesh.ko: -# make V=1 -C $(KERNEL_DIR) M=`pwd` modules - -clean: - rm -f $(nasmesh-objs) $(obj-m) -# make -C $(KERNEL_DIR) modules diff --git a/openair2/NETWORK_DRIVER/MESH/common.c b/openair2/NETWORK_DRIVER/MESH/common.c index 0eb7530ee6fabbf8c130d5172d5e9e27339879d0..d380b8a4d829cf31bf1369996d05de279cab73a5 100644 --- a/openair2/NETWORK_DRIVER/MESH/common.c +++ b/openair2/NETWORK_DRIVER/MESH/common.c @@ -28,12 +28,8 @@ * \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr */ -//#include "nas_common.h" #include "local.h" #include "proto_extern.h" -#ifdef RTAI -#include "rtai_fifos.h" -#endif //#define NAS_DEBUG_RECEIVE 1 //#define NAS_DEBUG_SEND 1 diff --git a/openair2/NETWORK_DRIVER/MESH/device.c b/openair2/NETWORK_DRIVER/MESH/device.c index f9bc592bce4a3ddf335064842a377a1490fba732..086ec3909ca225376d36cf520dca88f44aaf55d4 100644 --- a/openair2/NETWORK_DRIVER/MESH/device.c +++ b/openair2/NETWORK_DRIVER/MESH/device.c @@ -28,13 +28,6 @@ */ /*******************************************************************************/ -#ifndef PDCP_USE_NETLINK -#ifdef RTAI -#include "rtai_posix.h" -#define RTAI_IRQ 30 //try to get this irq with RTAI -#endif // RTAI -#endif // PDCP_USE_NETLINK - #include "constant.h" #include "local.h" #include "proto_extern.h" @@ -116,6 +109,7 @@ void *nas_interrupt(void) printk("INTERRUPT: end\n"); #endif // return 0; + return NULL; } #endif //NETLINK @@ -449,23 +443,12 @@ int init_module (void) #ifndef PDCP_USE_NETLINK -#ifdef RTAI //with RTAI you have to indicate which irq# you want - - pdcp_2_nas_irq=rt_request_srq(0, nas_interrupt, NULL); - -#endif - if (pdcp_2_nas_irq == -EBUSY || pdcp_2_nas_irq == -EINVAL) { printk("[NAS][INIT] No interrupt resource available\n"); return -EBUSY; } else printk("[NAS][INIT]: Interrupt %d\n", pdcp_2_nas_irq); - //rt_startup_irq(RTAI_IRQ); - - //rt_enable_irq(RTAI_IRQ); - - #endif //NETLINK for (inst=0; inst<NB_INSTANCES_MAX; inst++) { @@ -529,12 +512,6 @@ void cleanup_module(void) if (pdcp_2_nas_irq!=-EBUSY) { pdcp_2_nas_irq=0; -#ifdef RTAI - // V1 - // rt_free_linux_irq(priv->irq, NULL); - // END V1 - rt_free_srq(pdcp_2_nas_irq); -#endif // Start IRQ linux // free_irq(priv->irq, NULL); // End IRQ linux diff --git a/openair2/NETWORK_DRIVER/UE_IP/Makefile b/openair2/NETWORK_DRIVER/UE_IP/Makefile deleted file mode 100755 index fbcf85fabb3527bed1233302289f75e1c4a899d2..0000000000000000000000000000000000000000 --- a/openair2/NETWORK_DRIVER/UE_IP/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# UE IP Driver makefile -# -NAS_UPDIR := $(shell /bin/pwd) - -KERNEL_ARCH=$(shell echo `uname -m`) -SET_X64=$(shell if [ $(KERNEL_ARCH) = 'x86_64' ]; then echo true ; fi) - -#################################################### -# EXTRA COMPILER FLAGS -#################################################### -EXTRA_CFLAGS = -I$(OPENAIR2_DIR)/COMMON -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) - - - -ifdef OAI_NW_DRIVER_USE_NETLINK -EXTRA_CFLAGS += -DOAI_NW_DRIVER_USE_NETLINK -else -EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall -endif - - -#################################################### -# LOADABLE MODULE GOALS -#################################################### -obj-m += ue_ip.o -ue_ip-objs += device.o -ue_ip-objs += common.o -ifdef OAI_NW_DRIVER_USE_NETLINK -ue_ip-objs += netlink.o -endif - -#################################################### -# REVOIR LE CLEAN -#################################################### - - -print: - @echo SET_X64 : $(SET_X64) - -clean: - rm -f *.ko - rm -f .*.ko.cmd - rm -f .*.o.cmd - rm -f *.o - rm -f *.mod.c - find . -name *.ko -delete - find . -name .*.o -delete - find . -name *.o -delete - find . -name *.mod.c -delete diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c index a4398e9d9ed62634afadfebe37e9566e90f67056..29db4ae07a172f26e49dd14811420084f88816a7 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/device.c +++ b/openair2/NETWORK_DRIVER/UE_IP/device.c @@ -28,13 +28,6 @@ */ /*******************************************************************************/ -#ifndef OAI_NW_DRIVER_USE_NETLINK -#ifdef RTAI -#include "rtai_posix.h" -#define RTAI_IRQ 30 //try to get this irq with RTAI -#endif // RTAI -#endif // OAI_NW_DRIVER_USE_NETLINK - #include "constant.h" #include "local.h" #include "proto_extern.h" diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index 282e77faeb6a8b4d69aeace0d95ce84b1f431627..a3e362a60322cceee9107d411294d57a86a71ef8 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -25,7 +25,8 @@ void handle_rach(UL_IND_t *UL_info) { AssertFatal(UL_info->rach_ind.rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n"); UL_info->rach_ind.rach_indication_body.number_of_preambles=0; - LOG_E(MAC,"UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->subframe, NFAPI_SFNSF2DEC(UL_info->rach_ind.sfn_sf)); + + LOG_D(MAC,"UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->subframe, NFAPI_SFNSF2DEC(UL_info->rach_ind.sfn_sf)); initiate_ra_proc(UL_info->module_id, UL_info->CC_id, NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf), @@ -75,7 +76,7 @@ void handle_sr(UL_IND_t *UL_info) { } else { - for (i=0;i<UL_info->sr_ind.sr_indication_body.number_of_srs;i++) + for (i=0;i<UL_info->sr_ind.sr_indication_body.number_of_srs;i++) SR_indication(UL_info->module_id, UL_info->CC_id, UL_info->frame, @@ -127,11 +128,9 @@ void handle_harq(UL_IND_t *UL_info) { int i; - //if (UL_info->harq_ind.number_of_harqs>0) - if (nfapi_mode == 1 && UL_info->harq_ind.harq_indication_body.number_of_harqs>0) // PNF { - LOG_E(PHY, "UL_info->harq_ind.harq_indication_body.number_of_harqs:%d Send to VNF\n", UL_info->harq_ind.harq_indication_body.number_of_harqs); + //LOG_D(PHY, "UL_info->harq_ind.harq_indication_body.number_of_harqs:%d Send to VNF\n", UL_info->harq_ind.harq_indication_body.number_of_harqs); int retval = oai_nfapi_harq_indication(&UL_info->harq_ind); @@ -144,7 +143,7 @@ void handle_harq(UL_IND_t *UL_info) { } else { - for (i=0;i<UL_info->harq_ind.harq_indication_body.number_of_harqs;i++) + for (i=0;i<UL_info->harq_ind.harq_indication_body.number_of_harqs;i++) harq_indication(UL_info->module_id, UL_info->CC_id, NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf), @@ -179,55 +178,53 @@ void handle_ulsch(UL_IND_t *UL_info) { } else { - for (i=0;i<UL_info->rx_ind.rx_indication_body.number_of_pdus;i++) { - for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) { - // find crc_indication j corresponding rx_indication i - LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti, i, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti); - if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti == - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti) { - LOG_D(PHY, "UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].crc_indication_rel8.crc_flag:%d\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag); - if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication - LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->subframe); - rx_sdu(UL_info->module_id, - UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, - NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, - (uint8_t *)NULL, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); - } - else { - LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->subframe); - rx_sdu(UL_info->module_id, - UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, - NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); - } - break; - } //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti == - // UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti) - } // for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) - AssertFatal(j<UL_info->crc_ind.crc_indication_body.number_of_crcs,"SFN/SF:%d Couldn't find matchin CRC indication RX_IND:PDUs:%d CRCs:%d\n", NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf),UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->crc_ind.crc_indication_body.number_of_crcs); - } // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++) - } - - if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0) - { - UL_info->rx_ind.rx_indication_body.number_of_pdus = 0; - //LOG_D(PHY, "UL_INFO:SFN/SF:%d%d ZEROING rx_ind[SFN/SF:%d number_of_pdus:%d]\n", UL_info->frame, UL_info->subframe, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf), UL_info->rx_ind.rx_indication_body.number_of_pdus); - } - if (UL_info->subframe && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) - { - //LOG_D(PHY, "UL_INFO:SFN/SF:%d%d ZEROING crc_ind[SFN/SF:%d crcs:%d]\n", UL_info->frame, UL_info->subframe, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf), UL_info->crc_ind.crc_indication_body.number_of_crcs); - UL_info->crc_ind.crc_indication_body.number_of_crcs=0; + if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) { + for (i=0;i<UL_info->rx_ind.rx_indication_body.number_of_pdus;i++) { + for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) { + // find crc_indication j corresponding rx_indication i + LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti, i, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti); + if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti == + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti) { + LOG_D(PHY, "UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].crc_indication_rel8.crc_flag:%d\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag); + if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication + LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->subframe); + rx_sdu(UL_info->module_id, + UL_info->CC_id, + NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, + NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, + (uint8_t *)NULL, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); + } + else { + LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->subframe); + rx_sdu(UL_info->module_id, + UL_info->CC_id, + NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, + NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); + } + break; + } //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti == + // UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti) + } // for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) + } // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++) + UL_info->crc_ind.crc_indication_body.number_of_crcs=0; + UL_info->rx_ind.rx_indication_body.number_of_pdus = 0; + } // UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->subframe && UL_info->crc_ind.crc_indication_body.number_of_crcs>0 + else if (UL_info->rx_ind.rx_indication_body.number_of_pdus!=0 || UL_info->crc_ind.crc_indication_body.number_of_crcs!=0) { + LOG_E(PHY,"hoping not to have mis-match between CRC ind and RX ind - hopefully the missing message is coming shortly rx_ind:%d(SFN/SF:%05d) crc_ind:%d(SFN/SF:%05d) UL_info(SFN/SF):%04d%d\n", + UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf), + UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf), + UL_info->frame, UL_info->subframe); + } } } @@ -306,7 +303,7 @@ static void dump_ul(UL_IND_t *u) A("XXXX crc_ind %d\n", u->crc_ind.crc_indication_body.number_of_crcs); - A("XXXX sr_ind %d\n", u->sr_ind.number_of_srs); + A("XXXX sr_ind %d\n", u->sr_ind.sr_indication_body.number_of_srs); A("XXXX cqi_ind %d\n", u->cqi_ind.number_of_cqis); for (i = 0; i < u->cqi_ind.number_of_cqis; i++) { @@ -547,10 +544,10 @@ void UL_indication(UL_IND_t *UL_info) IF_Module_t *ifi = if_inst[module_id]; eNB_MAC_INST *mac = RC.mac[module_id]; - LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rx_ind:%d harqs:%d crcs:%d cqis:%d preambles:%d sr_ind:%d]\n", - UL_info->frame,UL_info->subframe, - module_id,CC_id, - UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs); + LOG_D(MAC,"Panos-D! SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rx_ind:%d harqs:%d crcs:%d cqis:%d preambles:%d sr_ind:%d]\n", + UL_info->frame,UL_info->subframe, + module_id,CC_id, + UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs); if (nfapi_mode != 1) { @@ -566,12 +563,9 @@ void UL_indication(UL_IND_t *UL_info) } - //LOG_D(PHY,"%s() SFN_SF:%d%d About to call clear_nfapi_information()\n", __FUNCTION__, UL_info->frame, UL_info->subframe); - // clear DL/UL info for new scheduling round clear_nfapi_information(RC.mac[module_id],CC_id, UL_info->frame,UL_info->subframe); - //LOG_D(PHY,"%s() SFN_SF:%d%d Returned from call clear_nfapi_information()\n", __FUNCTION__, UL_info->frame, UL_info->subframe); handle_rach(UL_info); @@ -603,7 +597,7 @@ void UL_indication(UL_IND_t *UL_info) sched_info->DL_req = &mac->DL_req[CC_id]; sched_info->HI_DCI0_req = &mac->HI_DCI0_req[CC_id]; if ((mac->common_channels[CC_id].tdd_Config==NULL) || - (is_UL_sf(&mac->common_channels[CC_id],(sched_info->subframe+sf_ahead)%10)>0)) + (is_UL_sf(&mac->common_channels[CC_id],(sched_info->subframe+sf_ahead)%10)>0)) sched_info->UL_req = &mac->UL_req[CC_id]; else sched_info->UL_req = NULL; @@ -624,7 +618,7 @@ void UL_indication(UL_IND_t *UL_info) } LOG_D(PHY,"Schedule_response: SFN_SF:%d%d dl_pdus:%d\n",sched_info->frame,sched_info->subframe,sched_info->DL_req->dl_config_request_body.number_pdu); - } + } } } diff --git a/openair2/PHY_INTERFACE/mac_phy_primitives.c b/openair2/PHY_INTERFACE/mac_phy_primitives.c index 3d42393d1140800fa08cefb67652729689e68cd0..06e06d096dc53caf0066bbdd26f6546dd5f7f9ee 100644 --- a/openair2/PHY_INTERFACE/mac_phy_primitives.c +++ b/openair2/PHY_INTERFACE/mac_phy_primitives.c @@ -187,9 +187,6 @@ MACPHY_DATA_REQ *new_macphy_data_req(unsigned char Mod_id) return((MACPHY_DATA_REQ*)0); } -#ifndef USER_MODE -EXPORT_SYMBOL(new_macphy_data_req); -#endif #endif //PHY_CONTEXT @@ -262,13 +259,7 @@ void macphy_data_ind(unsigned char Mod_id,unsigned char Pdu_type,void *pdu,unsig } } msg("[OPENAIR][MAC][ERROR] No more PHY_RESOURCES !!!!\n"); -#ifdef USER_MODE exit(-1); -#else - print_active_indications(); - print_active_requests(); - mac_xface->macphy_exit(); -#endif } */ diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 019fb6c500f8bfe2237a92952def926113f79544..fdec6b5404bb991a2eb81a00b28ccc5e137216e6 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -7,7 +7,7 @@ #include "openair2/LAYER2/MAC/proto.h" //#include "openair2/LAYER2/MAC/vars.h" #include "openair1/SCHED/defs.h" -#include "nfapi/nfapi_interface.h" +#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h" //#include "common/ran_context.h" #include "openair2/PHY_INTERFACE/phy_stub_UE.h" diff --git a/openair2/PHY_INTERFACE/vars.h b/openair2/PHY_INTERFACE/vars.h index 736d6f89db2038bb3dd87cf71be8dc44d7063922..566f4347b6e5e264ff19a5a28193b1c96258ab97 100644 --- a/openair2/PHY_INTERFACE/vars.h +++ b/openair2/PHY_INTERFACE/vars.h @@ -42,7 +42,3 @@ unsigned int mac_registered; #endif -#ifndef USER_MODE -EXPORT_SYMBOL(mac_xface); -#endif //PHY_EMUL - diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c index 8d69b6e76ba8e22a217e53a1da33a6098eb0ec2a..0844593d93e787a710b2dafb8b00aeb88bfaf19f 100644 --- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c +++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c @@ -28,45 +28,10 @@ * \email: navid.nikaein@eurecom.fr */ -#ifdef USER_MODE #include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#else //USER_MODE - -#include <asm/io.h> -#include <asm/bitops.h> -#include <asm/uaccess.h> -#include <asm/segment.h> -#include <asm/page.h> -#include <asm/delay.h> - -#include <linux/init.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/mm.h> -#include <linux/mman.h> - -#include <linux/slab.h> -#include <linux/version.h> -#include <linux/kernel.h> -#include <linux/fs.h> - -#include <linux/errno.h> - - -#ifdef KERNEL2_6 - -#include <linux/slab.h> -#endif - -#ifdef KERNEL2_4 -#include <linux/malloc.h> -#include <linux/wrapper.h> -#endif -#endif //USER_MODE - #include "platform_types.h" #include "openair_defs.h" diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h index b13d72f980bcdc6eb21872bbe1fb1b5775adb96b..4b651761de57a7c1cf7438afe33956cef1a3cdec 100644 --- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h +++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h @@ -41,8 +41,6 @@ mac_rrc_data_req( const rb_id_t srb_idP, const uint8_t nb_tbP, uint8_t* const buffer_pP, - const eNB_flag_t eNB_flagP, - const mac_enb_index_t eNB_indexP, const uint8_t mbsfn_sync_areaP ); @@ -56,7 +54,31 @@ mac_rrc_data_ind( const rb_id_t srb_idP, const uint8_t *sduP, const sdu_size_t sdu_lenP, - const eNB_flag_t eNB_flagP, + const uint8_t mbsfn_sync_area +); + +int8_t +mac_rrc_data_req_ue( + const module_id_t module_idP, + const int CC_idP, + const frame_t frameP, + const rb_id_t srb_idP, + const uint8_t nb_tbP, + uint8_t* const buffer_pP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_areaP +); + +int8_t +mac_rrc_data_ind_ue( + const module_id_t module_idP, + const int CC_idP, + const frame_t frameP, + const sub_frame_t sub_frameP, + const rnti_t rntiP, + const rb_id_t srb_idP, + const uint8_t *sduP, + const sdu_size_t sdu_lenP, const mac_enb_index_t eNB_indexP, const uint8_t mbsfn_sync_area ); diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index 687badfa7b13a840b6e51a13bb964c595a7c1229..a9b05101fb9929fd33269519a00babd66531a846 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -56,7 +56,6 @@ extern UE_MAC_INST *UE_mac_inst; //#define RRC_DATA_REQ_DEBUG //#define DEBUG_RRC 1 -mui_t mui=0; extern RAN_CONTEXT_t RC; @@ -69,8 +68,6 @@ mac_rrc_data_req( const rb_id_t Srb_id, const uint8_t Nb_tb, uint8_t* const buffer_pP, - const eNB_flag_t enb_flagP, - const uint8_t eNB_index, const uint8_t mbsfn_sync_area ) //-------------------------------------------------------------------------- @@ -90,7 +87,6 @@ mac_rrc_data_req( rrc_eNB_carrier_data_t *carrier; BCCH_BCH_Message_t *mib; - if( enb_flagP == ENB_FLAG_YES) { rrc = RC.rrc[Mod_idP]; carrier = &rrc->carrier[0]; @@ -250,6 +246,44 @@ mac_rrc_data_req( return (Sdu_size); } + if( (Srb_id & RAB_OFFSET ) == PCCH) { + LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); + + // check if data is there for MAC + if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer + LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + +#if 0 //defined(ENABLE_ITTI) + { + MessageDef *message_p; + int pcch_size = RC.rrc[Mod_idP]->arrier[CC_id].sizeof_paging[mbsfn_sync_area]; + int sdu_size = sizeof(RRC_MAC_PCCH_DATA_REQ (message_p).sdu); + + if (pcch_size > sdu_size) { + LOG_E(RRC, "SDU larger than PCCH SDU buffer size (%d, %d)", pcch_size, sdu_size); + pcch_size = sdu_size; + } + + message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_PCCH_DATA_REQ); + RRC_MAC_PCCH_DATA_REQ (message_p).frame = frameP; + RRC_MAC_PCCH_DATA_REQ (message_p).sdu_size = pcch_size; + memset (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, 0, PCCH_SDU_SIZE); + memcpy (RRC_MAC_PCCH_DATA_REQ (message_p).sdu, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], pcch_size); + RRC_MAC_PCCH_DATA_REQ (message_p).enb_index = eNB_index; + + itti_send_msg_to_task (TASK_MAC_ENB, ENB_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); + } +#endif + + memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]; + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0; + } + + return (Sdu_size); + } + #if defined(Rel10) || defined(Rel14) if((Srb_id & RAB_OFFSET) == MCCH) { @@ -322,61 +356,6 @@ mac_rrc_data_req( #endif - } else { //This is an UE - -#ifdef Rel14 - LOG_D(RRC,"[UE %d] Frame %d Filling SL DISCOVERY SRB_ID %d\n",Mod_idP,frameP,Srb_id); - LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size); - - //TTN (for D2D) - if (Srb_id == SL_DISCOVERY && UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size > 0){ - memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size); - uint8_t Ret_size=UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size; - LOG_I(RRC,"[UE %d] Sending SL_Discovery, size %d bytes\n",Mod_idP,Ret_size); - UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size = 0; - return(Ret_size); - } -#endif - - LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id); - LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); - - - if( (UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size > 0) ) { - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - int ccch_size = UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size; - int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu); - - if (ccch_size > sdu_size) { - LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", ccch_size, sdu_size); - ccch_size = sdu_size; - } - - message_p = itti_alloc_new_message (TASK_RRC_UE, RRC_MAC_CCCH_DATA_REQ); - RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP; - RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size; - memset (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, 0, CCCH_SDU_SIZE); - memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload, ccch_size); - RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index; - - itti_send_msg_to_task (TASK_MAC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); - } -#endif - - memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); - uint8_t Ret_size=UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size; - // UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0; - UE_rrc_inst[Mod_idP].Info[eNB_index].T300_active = 1; - UE_rrc_inst[Mod_idP].Info[eNB_index].T300_cnt = 0; - // msg("[RRC][UE %d] Sending rach\n",Mod_id); - return(Ret_size); - } else { - return 0; - } - } return(0); } @@ -392,8 +371,6 @@ mac_rrc_data_ind( const rb_id_t srb_idP, const uint8_t* sduP, const sdu_size_t sdu_lenP, - const eNB_flag_t eNB_flagP, - const mac_enb_index_t eNB_indexP, const uint8_t mbsfn_sync_areaP ) //-------------------------------------------------------------------------- @@ -408,120 +385,8 @@ mac_rrc_data_ind( /* int si_window; */ - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, eNB_flagP, rntiP, frameP, sub_frameP,eNB_indexP); - - if(eNB_flagP == ENB_FLAG_NO) { - if(srb_idP == BCCH) { - LOG_D(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",module_idP,srb_idP,eNB_indexP); - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - int msg_sdu_size = sizeof(RRC_MAC_BCCH_DATA_IND (message_p).sdu); - - if (sdu_lenP > msg_sdu_size) { - LOG_E(RRC, "SDU larger than BCCH SDU buffer size (%d, %d)", sdu_lenP, msg_sdu_size); - sdu_size = msg_sdu_size; - } else { - sdu_size = sdu_lenP; - } - - message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_BCCH_DATA_IND); - memset (RRC_MAC_BCCH_DATA_IND (message_p).sdu, 0, BCCH_SDU_SIZE); - RRC_MAC_BCCH_DATA_IND (message_p).frame = frameP; - RRC_MAC_BCCH_DATA_IND (message_p).sub_frame = sub_frameP; - RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size; - memcpy (RRC_MAC_BCCH_DATA_IND (message_p).sdu, sduP, sdu_size); - RRC_MAC_BCCH_DATA_IND (message_p).enb_index = eNB_indexP; - RRC_MAC_BCCH_DATA_IND (message_p).rsrq = 30 /* TODO change phy to report rspq */; - RRC_MAC_BCCH_DATA_IND (message_p).rsrp = 45 /* TODO change phy to report rspp */; - - itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); - } -#else - decode_BCCH_DLSCH_Message(&ctxt,eNB_indexP,(uint8_t*)sduP,sdu_lenP, 0, 0); -#endif - } - - if(srb_idP == PCCH) { - LOG_D(RRC,"[UE %d] Received SDU for PCCH on SRB %d from eNB %d\n",module_idP,srb_idP,eNB_indexP); - decode_PCCH_DLSCH_Message(&ctxt,eNB_indexP,(uint8_t*)sduP,sdu_lenP); - } - if((srb_idP & RAB_OFFSET) == CCCH) { - if (sdu_lenP>0) { - LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",module_idP,srb_idP & RAB_OFFSET,eNB_indexP); - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - int msg_sdu_size = CCCH_SDU_SIZE; - - if (sdu_lenP > msg_sdu_size) { - LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); - sdu_size = msg_sdu_size; - } else { - sdu_size = sdu_lenP; - } - - message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_IND); - memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, sduP, sdu_size); - RRC_MAC_CCCH_DATA_IND (message_p).frame = frameP; - RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frameP; - RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size; - RRC_MAC_CCCH_DATA_IND (message_p).enb_index = eNB_indexP; - RRC_MAC_CCCH_DATA_IND (message_p).rnti = rntiP; - itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); - } -#else - Srb_info = &UE_rrc_inst[module_idP].Srb0[eNB_indexP]; - memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP); - Srb_info->Rx_buffer.payload_size = sdu_lenP; - rrc_ue_decode_ccch(&ctxt, Srb_info, eNB_indexP); -#endif - } - } - -#if defined(Rel10) || defined(Rel14) - - if ((srb_idP & RAB_OFFSET) == MCCH) { - LOG_T(RRC,"[UE %d] Frame %d: Received SDU on MBSFN sync area %d for MCCH on SRB %d from eNB %d\n", - module_idP,frameP, mbsfn_sync_areaP, srb_idP & RAB_OFFSET,eNB_indexP); - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - int msg_sdu_size = sizeof(RRC_MAC_MCCH_DATA_IND (message_p).sdu); - - if (sdu_size > msg_sdu_size) { - LOG_E(RRC, "SDU larger than MCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); - sdu_size = msg_sdu_size; - } - - message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_MCCH_DATA_IND); - RRC_MAC_MCCH_DATA_IND (message_p).frame = frameP; - RRC_MAC_MCCH_DATA_IND (message_p).sub_frame = sub_frameP; - RRC_MAC_MCCH_DATA_IND (message_p).sdu_size = sdu_lenP; - memset (RRC_MAC_MCCH_DATA_IND (message_p).sdu, 0, MCCH_SDU_SIZE); - memcpy (RRC_MAC_MCCH_DATA_IND (message_p).sdu, sduP, sdu_lenP); - RRC_MAC_MCCH_DATA_IND (message_p).enb_index = eNB_indexP; - RRC_MAC_MCCH_DATA_IND (message_p).mbsfn_sync_area = mbsfn_sync_areaP; - itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); - } -#else - decode_MCCH_Message(&ctxt, eNB_indexP, sduP, sdu_lenP, mbsfn_sync_areaP); -#endif - } - - //TTN (for D2D) - if(srb_idP == SL_DISCOVERY) { - LOG_I(RRC,"[UE %d] Received SDU (%d bytes) for SL_DISCOVERY on SRB %d from eNB %d\n",module_idP, sdu_lenP, srb_idP,eNB_indexP); - decode_SL_Discovery_Message(&ctxt, eNB_indexP, sduP, sdu_lenP); - } + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, rntiP, frameP, sub_frameP,0); -#endif // Rel10 || Rel14 - - } else { // This is an eNB Srb_info = &RC.rrc[module_idP]->carrier[CC_id].Srb0; LOG_D(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",module_idP,Srb_info->Srb_id); @@ -558,210 +423,11 @@ mac_rrc_data_ind( } #endif - } return(0); } - -//-------------------------------------------------------------------------------------------// -// this function is Not USED anymore -void mac_sync_ind(module_id_t Mod_idP,uint8_t Status) -{ - //-------------------------------------------------------------------------------------------// -} - -//------------------------------------------------------------------------------ -uint8_t -rrc_data_req( - 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, - const pdcp_transmission_mode_t modeP -) -//------------------------------------------------------------------------------ -{ - MSC_LOG_TX_MESSAGE( - ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE, - ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE, - buffer_pP, - sdu_sizeP, - MSC_AS_TIME_FMT"RRC_DCCH_DATA_REQ UE %x MUI %d size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ctxt_pP->rnti, - muiP, - sdu_sizeP); - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). - uint8_t *message_buffer; - - message_buffer = itti_malloc ( - ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, - ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, - sdu_sizeP); - - memcpy (message_buffer, buffer_pP, sdu_sizeP); - - message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); - RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame; - RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag; - RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP; - RRC_DCCH_DATA_REQ (message_p).muip = muiP; - RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP; - RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP; - RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer; - RRC_DCCH_DATA_REQ (message_p).mode = modeP; - RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id; - RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti; - RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index; - - itti_send_msg_to_task ( - ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, - ctxt_pP->instance, - message_p); - return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. - - } -#else - return pdcp_data_req ( - ctxt_pP, - SRB_FLAG_YES, - rb_idP, - muiP, - confirmP, - sdu_sizeP, - buffer_pP, - modeP -#ifdef Rel14 - ,NULL, NULL -#endif - ); -#endif -} - -//------------------------------------------------------------------------------ -void -rrc_data_ind( - 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 -) -//------------------------------------------------------------------------------ -{ - rb_id_t DCCH_index = Srb_id; - - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - LOG_N(RRC, "[UE %x] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB %d\n", - ctxt_pP->module_id, ctxt_pP->frame, DCCH_index,Srb_id,sdu_sizeP, ctxt_pP->eNB_index); - } else { - LOG_N(RRC, "[eNB %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from UE %x\n", - ctxt_pP->module_id, - ctxt_pP->frame, - DCCH_index, - Srb_id, - sdu_sizeP, - ctxt_pP->rnti); - } - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). - uint8_t *message_buffer; - - message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP); - memcpy (message_buffer, buffer_pP, sdu_sizeP); - - message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); - RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame; - RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index; - RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_sizeP; - RRC_DCCH_DATA_IND (message_p).sdu_p = message_buffer; - RRC_DCCH_DATA_IND (message_p).rnti = ctxt_pP->rnti; - RRC_DCCH_DATA_IND (message_p).module_id = ctxt_pP->module_id; - RRC_DCCH_DATA_IND (message_p).eNB_index = ctxt_pP->eNB_index; - - itti_send_msg_to_task (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, ctxt_pP->instance, message_p); - } -#else - - if (ctxt_pP->enb_flag == ENB_FLAG_YES) { - rrc_eNB_decode_dcch( - ctxt_pP, - DCCH_index, - buffer_pP, - sdu_sizeP); - } else { -//#warning "LG put 0 to arg4 that is eNB index" - rrc_ue_decode_dcch( - ctxt_pP, - DCCH_index, - buffer_pP, - 0); - } - -#endif -} - -//-------------------------------------------------------------------------------------------// -void rrc_in_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_index) -{ - //-------------------------------------------------------------------------------------------// -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - //LOG_I(RRC,"sending a message to task_mac_ue\n"); - message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_IN_SYNC_IND); - RRC_MAC_IN_SYNC_IND (message_p).frame = frameP; - RRC_MAC_IN_SYNC_IND (message_p).enb_index = eNB_index; - - itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); - } -#else - UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt=0; - - if (UE_rrc_inst[Mod_idP].Info[eNB_index].T310_active==1) { - UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt++; - } - -#endif -} - -//-------------------------------------------------------------------------------------------// -void rrc_out_of_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_index) -{ - //-------------------------------------------------------------------------------------------// - if (UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt>10) - LOG_I(RRC,"[UE %d] Frame %d: OUT OF SYNC FROM eNB %d (T310 active %d : T310 %d, N310 %d, N311 %d)\n ", - Mod_idP,frameP,eNB_index, - UE_rrc_inst[Mod_idP].Info[eNB_index].T300_active, - UE_rrc_inst[Mod_idP].Info[eNB_index].T310_cnt, - UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt, - UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt); - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - - message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_OUT_OF_SYNC_IND); - RRC_MAC_OUT_OF_SYNC_IND (message_p).frame = frameP; - RRC_MAC_OUT_OF_SYNC_IND (message_p).enb_index = eNB_index; - - itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); - } -#else - UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt++; -#endif -} - //------------------------------------------------------------------------------ int mac_eNB_get_rrc_status( @@ -795,12 +461,34 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, if (ue_context_p != NULL) { LOG_I(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP); - ue_context_p->ue_context.ul_failure_timer=1; + if(ue_context_p->ue_context.ul_failure_timer == 0) + ue_context_p->ue_context.ul_failure_timer=1; } else { LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); } - rrc_mac_remove_ue(Mod_instP,rntiP); +// rrc_mac_remove_ue(Mod_instP,rntiP); +} + +void mac_eNB_rrc_uplane_failure(const module_id_t Mod_instP, + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) +{ + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context( + RC.rrc[Mod_instP], + rntiP); + if (ue_context_p != NULL) { + LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP); + + if(ue_context_p->ue_context.ul_failure_timer == 0) + ue_context_p->ue_context.ul_failure_timer=19999; + } + else { + LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP); + } } void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, @@ -823,33 +511,3 @@ void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, frameP, subframeP, rntiP); } } -//------------------------------------------------------------------------------ -int -mac_UE_get_rrc_status( - const module_id_t Mod_idP, - const uint8_t indexP -) -//------------------------------------------------------------------------------ -{ - return(UE_rrc_inst[Mod_idP].Info[indexP].State); -} - -//-------------------------------------------------------------------------------------------// -int mac_ue_ccch_success_ind(module_id_t Mod_idP, uint8_t eNB_index) -{ - //-------------------------------------------------------------------------------------------// -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - - message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_CNF); - RRC_MAC_CCCH_DATA_CNF (message_p).enb_index = eNB_index; - - itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); - } -#else - // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds) - UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size=0; -#endif - return 0; -} diff --git a/openair2/RRC/LITE/L2_interface_common.c b/openair2/RRC/LITE/L2_interface_common.c new file mode 100644 index 0000000000000000000000000000000000000000..1b832521528ec231b8b8dc9d016e62584ff97191 --- /dev/null +++ b/openair2/RRC/LITE/L2_interface_common.c @@ -0,0 +1,183 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file l2_interface.c + * \brief layer 2 interface, used to support different RRC sublayer + * \author Raymond Knopp and Navid Nikaein + * \date 2010-2014 + * \version 1.0 + * \company Eurecom + * \email: raymond.knopp@eurecom.fr + */ + +#include "platform_types.h" +//#include "openair_defs.h" +//#include "openair_proto.h" +#include "defs.h" +#include "extern.h" +//#include "mac_lchan_interface.h" +//#include "openair_rrc_utils.h" +//#include "openair_rrc_main.h" +#include "UTIL/LOG/log.h" +#include "rrc_eNB_UE_context.h" +#include "pdcp.h" +#include "msc.h" +#include "common/ran_context.h" + +#ifdef PHY_EMUL +#include "SIMULATION/simulation_defs.h" +extern EMULATION_VARS *Emul_vars; +extern eNB_MAC_INST *eNB_mac_inst; +extern UE_MAC_INST *UE_mac_inst; +#endif + +#if defined(ENABLE_ITTI) +# include "intertask_interface.h" +#endif + +//#define RRC_DATA_REQ_DEBUG +//#define DEBUG_RRC 1 + +//------------------------------------------------------------------------------ +uint8_t +rrc_data_req( + 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, + const pdcp_transmission_mode_t modeP +) +//------------------------------------------------------------------------------ +{ + MSC_LOG_TX_MESSAGE( + ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE, + ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE, + buffer_pP, + sdu_sizeP, + MSC_AS_TIME_FMT"RRC_DCCH_DATA_REQ UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt_pP->rnti, + muiP, + sdu_sizeP); + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). + uint8_t *message_buffer; + + message_buffer = itti_malloc ( + ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, + ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, + sdu_sizeP); + + memcpy (message_buffer, buffer_pP, sdu_sizeP); + + message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); + RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame; + RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag; + RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP; + RRC_DCCH_DATA_REQ (message_p).muip = muiP; + RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP; + RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP; + RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer; + RRC_DCCH_DATA_REQ (message_p).mode = modeP; + RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id; + RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti; + RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index; + + itti_send_msg_to_task ( + ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, + ctxt_pP->instance, + message_p); + return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. + + } +#else + return pdcp_data_req ( + ctxt_pP, + SRB_FLAG_YES, + rb_idP, + muiP, + confirmP, + sdu_sizeP, + buffer_pP, + modeP); +#endif +} + +//------------------------------------------------------------------------------ +void +rrc_data_ind( + 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 +) +//------------------------------------------------------------------------------ +{ + rb_id_t DCCH_index = Srb_id; + + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + LOG_N(RRC, "[UE %x] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB %d\n", + ctxt_pP->module_id, ctxt_pP->frame, DCCH_index,Srb_id,sdu_sizeP, ctxt_pP->eNB_index); + } else { + LOG_N(RRC, "[eNB %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from UE %x\n", + ctxt_pP->module_id, + ctxt_pP->frame, + DCCH_index, + Srb_id, + sdu_sizeP, + ctxt_pP->rnti); + } + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). + uint8_t *message_buffer; + + message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP); + memcpy (message_buffer, buffer_pP, sdu_sizeP); + + message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); + RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame; + RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index; + RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_sizeP; + RRC_DCCH_DATA_IND (message_p).sdu_p = message_buffer; + RRC_DCCH_DATA_IND (message_p).rnti = ctxt_pP->rnti; + RRC_DCCH_DATA_IND (message_p).module_id = ctxt_pP->module_id; + RRC_DCCH_DATA_IND (message_p).eNB_index = ctxt_pP->eNB_index; + + itti_send_msg_to_task (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, ctxt_pP->instance, message_p); + } +#else + + rrc_eNB_decode_dcch( + ctxt_pP, + DCCH_index, + buffer_pP, + sdu_sizeP); + +#endif +} diff --git a/openair2/RRC/LITE/L2_interface_ue.c b/openair2/RRC/LITE/L2_interface_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..3c46f7ff71b9c60c3d30631028408c42c2d50ef7 --- /dev/null +++ b/openair2/RRC/LITE/L2_interface_ue.c @@ -0,0 +1,486 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file l2_interface.c + * \brief layer 2 interface, used to support different RRC sublayer + * \author Raymond Knopp and Navid Nikaein + * \date 2010-2014 + * \version 1.0 + * \company Eurecom + * \email: raymond.knopp@eurecom.fr + */ + +#include "platform_types.h" +//#include "openair_defs.h" +//#include "openair_proto.h" +#include "defs.h" +#include "extern.h" +//#include "mac_lchan_interface.h" +//#include "openair_rrc_utils.h" +//#include "openair_rrc_main.h" +#include "UTIL/LOG/log.h" +#include "rrc_eNB_UE_context.h" +#include "pdcp.h" +#include "msc.h" + + +#if defined(ENABLE_ITTI) +# include "intertask_interface.h" +#endif + +//#define RRC_DATA_REQ_DEBUG +//#define DEBUG_RRC 1 + + + +//------------------------------------------------------------------------------ +int8_t +mac_rrc_data_req_ue( + const module_id_t Mod_idP, + const int CC_id, + const frame_t frameP, + const rb_id_t Srb_id, + const uint8_t Nb_tb, + uint8_t* const buffer_pP, + const uint8_t eNB_index, + const uint8_t mbsfn_sync_area +) +//-------------------------------------------------------------------------- +{ + asn_enc_rval_t enc_rval; + SRB_INFO *Srb_info; + uint8_t Sdu_size = 0; + uint8_t sfn = (uint8_t)((frameP>>2)&0xff); + + +#ifdef DEBUG_RRC + int i; + LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); +#endif + + eNB_RRC_INST *rrc; + rrc_eNB_carrier_data_t *carrier; + BCCH_BCH_Message_t *mib; + +#ifdef Rel14 + LOG_D(RRC,"[UE %d] Frame %d Filling SL DISCOVERY SRB_ID %d\n",Mod_idP,frameP,Srb_id); + LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size); + + //TTN (for D2D) + if (Srb_id == SL_DISCOVERY && UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size > 0){ + memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size); + uint8_t Ret_size=UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size; + LOG_I(RRC,"[UE %d] Sending SL_Discovery, size %d bytes\n",Mod_idP,Ret_size); + UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size = 0; + return(Ret_size); + } +#endif + + + LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id); + LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); + + + if( (UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size > 0) ) { + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + int ccch_size = UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size; + int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu); + + if (ccch_size > sdu_size) { + LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", ccch_size, sdu_size); + ccch_size = sdu_size; + } + + message_p = itti_alloc_new_message (TASK_RRC_UE, RRC_MAC_CCCH_DATA_REQ); + RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP; + RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size; + memset (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, 0, CCCH_SDU_SIZE); + memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload, ccch_size); + RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index; + + itti_send_msg_to_task (TASK_MAC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); + } +#endif + + memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); + uint8_t Ret_size=UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size; + // UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0; + UE_rrc_inst[Mod_idP].Info[eNB_index].T300_active = 1; + UE_rrc_inst[Mod_idP].Info[eNB_index].T300_cnt = 0; + // msg("[RRC][UE %d] Sending rach\n",Mod_id); + return(Ret_size); + } else { + return 0; + } + + return(0); +} + +//------------------------------------------------------------------------------ +int8_t +mac_rrc_data_ind_ue( + const module_id_t module_idP, + const int CC_id, + const frame_t frameP, + const sub_frame_t sub_frameP, + const rnti_t rntiP, + const rb_id_t srb_idP, + const uint8_t* sduP, + const sdu_size_t sdu_lenP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_areaP +) +//-------------------------------------------------------------------------- +{ + SRB_INFO *Srb_info; + protocol_ctxt_t ctxt; + sdu_size_t sdu_size = 0; + + /* for no gcc warnings */ + (void)sdu_size; + + /* + int si_window; + */ + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, 0, rntiP, frameP, sub_frameP,eNB_indexP); + + if(srb_idP == BCCH) { + LOG_D(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",module_idP,srb_idP,eNB_indexP); + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + int msg_sdu_size = sizeof(RRC_MAC_BCCH_DATA_IND (message_p).sdu); + + if (sdu_lenP > msg_sdu_size) { + LOG_E(RRC, "SDU larger than BCCH SDU buffer size (%d, %d)", sdu_lenP, msg_sdu_size); + sdu_size = msg_sdu_size; + } else { + sdu_size = sdu_lenP; + } + + message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_BCCH_DATA_IND); + memset (RRC_MAC_BCCH_DATA_IND (message_p).sdu, 0, BCCH_SDU_SIZE); + RRC_MAC_BCCH_DATA_IND (message_p).frame = frameP; + RRC_MAC_BCCH_DATA_IND (message_p).sub_frame = sub_frameP; + RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size; + memcpy (RRC_MAC_BCCH_DATA_IND (message_p).sdu, sduP, sdu_size); + RRC_MAC_BCCH_DATA_IND (message_p).enb_index = eNB_indexP; + RRC_MAC_BCCH_DATA_IND (message_p).rsrq = 30 /* TODO change phy to report rspq */; + RRC_MAC_BCCH_DATA_IND (message_p).rsrp = 45 /* TODO change phy to report rspp */; + + itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); + } +#else + decode_BCCH_DLSCH_Message(&ctxt,eNB_indexP,(uint8_t*)sduP,sdu_lenP, 0, 0); +#endif + } + + if(srb_idP == PCCH) { + LOG_D(RRC,"[UE %d] Received SDU for PCCH on SRB %d from eNB %d\n",module_idP,srb_idP,eNB_indexP); + decode_PCCH_DLSCH_Message(&ctxt,eNB_indexP,(uint8_t*)sduP,sdu_lenP); + } + if((srb_idP & RAB_OFFSET) == CCCH) { + if (sdu_lenP>0) { + LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",module_idP,srb_idP & RAB_OFFSET,eNB_indexP); + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + int msg_sdu_size = CCCH_SDU_SIZE; + + if (sdu_lenP > msg_sdu_size) { + LOG_E(RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); + sdu_size = msg_sdu_size; + } else { + sdu_size = sdu_lenP; + } + + message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_IND); + memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); + memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, sduP, sdu_size); + RRC_MAC_CCCH_DATA_IND (message_p).frame = frameP; + RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frameP; + RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size; + RRC_MAC_CCCH_DATA_IND (message_p).enb_index = eNB_indexP; + RRC_MAC_CCCH_DATA_IND (message_p).rnti = rntiP; + itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); + } +#else + Srb_info = &UE_rrc_inst[module_idP].Srb0[eNB_indexP]; + memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP); + Srb_info->Rx_buffer.payload_size = sdu_lenP; + rrc_ue_decode_ccch(&ctxt, Srb_info, eNB_indexP); +#endif + } + } + +#if defined(Rel10) || defined(Rel14) + + if ((srb_idP & RAB_OFFSET) == MCCH) { + LOG_T(RRC,"[UE %d] Frame %d: Received SDU on MBSFN sync area %d for MCCH on SRB %d from eNB %d\n", + module_idP,frameP, mbsfn_sync_areaP, srb_idP & RAB_OFFSET,eNB_indexP); + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + int msg_sdu_size = sizeof(RRC_MAC_MCCH_DATA_IND (message_p).sdu); + + if (sdu_size > msg_sdu_size) { + LOG_E(RRC, "SDU larger than MCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); + sdu_size = msg_sdu_size; + } + + message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_MCCH_DATA_IND); + RRC_MAC_MCCH_DATA_IND (message_p).frame = frameP; + RRC_MAC_MCCH_DATA_IND (message_p).sub_frame = sub_frameP; + RRC_MAC_MCCH_DATA_IND (message_p).sdu_size = sdu_lenP; + memset (RRC_MAC_MCCH_DATA_IND (message_p).sdu, 0, MCCH_SDU_SIZE); + memcpy (RRC_MAC_MCCH_DATA_IND (message_p).sdu, sduP, sdu_lenP); + RRC_MAC_MCCH_DATA_IND (message_p).enb_index = eNB_indexP; + RRC_MAC_MCCH_DATA_IND (message_p).mbsfn_sync_area = mbsfn_sync_areaP; + itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); + } +#else + decode_MCCH_Message(&ctxt, eNB_indexP, sduP, sdu_lenP, mbsfn_sync_areaP); +#endif + } + //TTN (for D2D) + if(srb_idP == SL_DISCOVERY) { + LOG_I(RRC,"[UE %d] Received SDU (%d bytes) for SL_DISCOVERY on SRB %d from eNB %d\n",module_idP, sdu_lenP, srb_idP,eNB_indexP); + decode_SL_Discovery_Message(&ctxt, eNB_indexP, sduP, sdu_lenP); + } + +#endif // Rel10 || Rel14 + + return(0); + +} + + +//------------------------------------------------------------------------------ +uint8_t +rrc_data_req_ue( + 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, + const pdcp_transmission_mode_t modeP +) +//------------------------------------------------------------------------------ +{ + MSC_LOG_TX_MESSAGE( + ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE, + ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE, + buffer_pP, + sdu_sizeP, + MSC_AS_TIME_FMT"RRC_DCCH_DATA_REQ UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt_pP->rnti, + muiP, + sdu_sizeP); + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). + uint8_t *message_buffer; + + message_buffer = itti_malloc ( + ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, + ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, + sdu_sizeP); + + memcpy (message_buffer, buffer_pP, sdu_sizeP); + + message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); + RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame; + RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag; + RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP; + RRC_DCCH_DATA_REQ (message_p).muip = muiP; + RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP; + RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP; + RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer; + RRC_DCCH_DATA_REQ (message_p).mode = modeP; + RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id; + RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti; + RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index; + + itti_send_msg_to_task ( + TASK_PDCP_UE, + ctxt_pP->instance, + message_p); + return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. + + } +#else + return pdcp_data_req ( + ctxt_pP, + SRB_FLAG_YES, + rb_idP, + muiP, + confirmP, + sdu_sizeP, + buffer_pP, + modeP +#ifdef Rel14 + ,NULL, NULL +#endif + ); +#endif +} + +//------------------------------------------------------------------------------ +void +rrc_data_ind_ue( + 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 +) +//------------------------------------------------------------------------------ +{ + rb_id_t DCCH_index = Srb_id; + + LOG_N(RRC, "[UE %x] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB %d\n", + ctxt_pP->module_id, ctxt_pP->frame, DCCH_index,Srb_id,sdu_sizeP, ctxt_pP->eNB_index); + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). + uint8_t *message_buffer; + + message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP); + memcpy (message_buffer, buffer_pP, sdu_sizeP); + + message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); + RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame; + RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index; + RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_sizeP; + RRC_DCCH_DATA_IND (message_p).sdu_p = message_buffer; + RRC_DCCH_DATA_IND (message_p).rnti = ctxt_pP->rnti; + RRC_DCCH_DATA_IND (message_p).module_id = ctxt_pP->module_id; + RRC_DCCH_DATA_IND (message_p).eNB_index = ctxt_pP->eNB_index; + + itti_send_msg_to_task (TASK_RRC_UE, ctxt_pP->instance, message_p); + } +#else + +//#warning "LG put 0 to arg4 that is eNB index" + rrc_ue_decode_dcch( + ctxt_pP, + DCCH_index, + buffer_pP, + 0); + +#endif +} + +//-------------------------------------------------------------------------------------------// +void rrc_in_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_index) +{ + //-------------------------------------------------------------------------------------------// +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + //LOG_I(RRC,"sending a message to task_mac_ue\n"); + message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_IN_SYNC_IND); + RRC_MAC_IN_SYNC_IND (message_p).frame = frameP; + RRC_MAC_IN_SYNC_IND (message_p).enb_index = eNB_index; + + itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); + } +#else + UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt=0; + + if (UE_rrc_inst[Mod_idP].Info[eNB_index].T310_active==1) { + UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt++; + } + +#endif +} + +//-------------------------------------------------------------------------------------------// +void rrc_out_of_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_index) +{ + //-------------------------------------------------------------------------------------------// + if (UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt>10) + LOG_I(RRC,"[UE %d] Frame %d: OUT OF SYNC FROM eNB %d (T310 active %d : T310 %d, N310 %d, N311 %d)\n ", + Mod_idP,frameP,eNB_index, + UE_rrc_inst[Mod_idP].Info[eNB_index].T300_active, + UE_rrc_inst[Mod_idP].Info[eNB_index].T310_cnt, + UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt, + UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt); + +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + + message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_OUT_OF_SYNC_IND); + RRC_MAC_OUT_OF_SYNC_IND (message_p).frame = frameP; + RRC_MAC_OUT_OF_SYNC_IND (message_p).enb_index = eNB_index; + + itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); + } +#else + UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt++; +#endif +} + +//------------------------------------------------------------------------------ +int +mac_UE_get_rrc_status( + const module_id_t Mod_idP, + const uint8_t indexP +) +//------------------------------------------------------------------------------ +{ + if (UE_rrc_inst) + return(UE_rrc_inst[Mod_idP].Info[indexP].State); + else + return(-1); +} + +//-------------------------------------------------------------------------------------------// +int mac_ue_ccch_success_ind(module_id_t Mod_idP, uint8_t eNB_index) +{ + //-------------------------------------------------------------------------------------------// +#if defined(ENABLE_ITTI) + { + MessageDef *message_p; + + message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_CNF); + RRC_MAC_CCCH_DATA_CNF (message_p).enb_index = eNB_index; + + itti_send_msg_to_task (TASK_RRC_UE, UE_MODULE_ID_TO_INSTANCE(Mod_idP), message_p); + } +#else + // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds) + UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size=0; +#endif + return 0; +} diff --git a/openair2/RRC/LITE/MESSAGES/Makefile b/openair2/RRC/LITE/MESSAGES/Makefile deleted file mode 100644 index bd99081ad2e3d6768cf7bb16fa44fce5d51c4dbd..0000000000000000000000000000000000000000 --- a/openair2/RRC/LITE/MESSAGES/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -include $(OPENAIR_DIR)/common/utils/Makefile.inc -OPENAIR2_TOP = ../../.. -include $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc - - -EXTRA_CFLAGS += -I$(OPENAIR1_DIR) -I/usr/realtime/include -D__need_Emath -D__NO_ASSERT_H__ - -ifdef RTAI -# Get the RTAI variables -CCC = $(shell rtai-config --cc) -RTAI_SUBVERSION=$(shell rtai-config --version | sed -e 's/^..\(.\).*$$/\1/') -IS_RTAI_SUBVERSION_LESS_THAN_FIVE=$(shell if [ $(RTAI_SUBVERSION) -lt 5 ] ; then echo true ; fi) - -EXTRA_CFLAGS += -D__IN_RTAI__ $(shell rtai-config --module-cflags) -g -march=pentium4 -DNODE_RG -DBIGPHYSAREA -DRTAI -DRTAI_ENABLED -fno-stack-protector -DHW_PREFIX_REMOVAL -Wall -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DWIDENS_DLC -I$(KERNEL_DIR)/build/include -I$(KERNEL_DIR)/build/include/asm/mach-default -include $(KERNEL_DIR)/build/include/linux/autoconf.h $(if $(IS_RTAI_SUBVERSION_LESS_THAN_FIVE),-DRTAI_ISNT_POSIX,) -endif - - -obj-m = asn1_msg_kern.o -asn1_msg_kern-objs = $(ASN1_CONVERTER_OBJS) $(ASN1_MODULE_OBJS) bsearch.o rtai_mem.o - -clean: - rm -rf $(asn1_msg_kern-objs) $(obj-m) - -test: - echo $(asn1_msg_kern-objs) $(obj-m) - -regen: regenerate-from-asn1-source - -regenerate-from-asn1-source: - asn1c -gen-PER -fcompound-names -fnative-types -fskeletons-copy asn1c/ASN1_files/EUTRA-RRC-Definitions.asn - diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index db31a7743631886d6f22775102aa4e05830f572c..07d1cc92dc4126ab75b7c93eb10a2b3d85f0f15a 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -28,7 +28,6 @@ * \email: raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr */ -#ifdef USER_MODE #include <stdio.h> #include <sys/types.h> #include <stdlib.h> /* for atoi(3) */ @@ -36,14 +35,7 @@ #include <string.h> /* for strerror(3) */ #include <sysexits.h> /* for EX_* exit codes */ #include <errno.h> /* for errno */ -#else -#include <linux/module.h> /* Needed by all modules */ -#endif -#ifdef USER_MODE -//#include "RRC/LITE/defs.h" -//#include "COMMON/mac_rrc_primitives.h" #include "UTIL/LOG/log.h" -#endif #include <asn_application.h> #include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */ #include <per_encoder.h> @@ -54,6 +46,8 @@ #include "UL-DCCH-Message.h" #include "DL-CCCH-Message.h" #include "DL-DCCH-Message.h" +#include "PCCH-Message.h" +#include "openair3/UTILS/conversions.h" #include "EstablishmentCause.h" #include "RRCConnectionSetup.h" #include "SRB-ToAddModList.h" @@ -91,17 +85,10 @@ #endif #include "common/ran_context.h" +#include "secu_defs.h" -//#include "PHY/defs.h" -#ifndef USER_MODE -#define msg printk -#ifndef errno -int errno; -#endif -#else -# if !defined (msg) -# define msg printf -# endif +#if !defined (msg) +#define msg printf #endif //#define XER_PRINT @@ -232,7 +219,7 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich AssertFatal(phich_Resource <= PHICH_Config__phich_Resource_two,"Illegal phich_Resource\n"); mib->message.phich_Config.phich_Resource = phich_Resource; - AssertFatal(phich_Resource <= PHICH_Config__phich_Duration_extended,"Illegal phich_Duration\n"); + AssertFatal(phich_duration <= PHICH_Config__phich_Duration_extended,"Illegal phich_Duration\n"); mib->message.phich_Config.phich_Duration = phich_duration; LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x,sfn %x\n", (uint32_t)mib->message.dl_Bandwidth, @@ -556,9 +543,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, # endif #endif -#ifdef USER_MODE LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif if (enc_rval.encoded==-1) { return(-1); @@ -1340,7 +1325,11 @@ uint8_t do_SIB23(uint8_t Mod_id, (void*)systemInformation, sizeof(SystemInformation_t));*/ - bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = SystemInformation__criticalExtensions_PR_criticalExtensionsFuture;//SystemInformation__criticalExtensions_PR_systemInformation_r8 + // Panos: Careful here! You have uncommented the old assignment in the next line + //bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = SystemInformation__criticalExtensions_PR_criticalExtensionsFuture;//SystemInformation__criticalExtensions_PR_systemInformation_r8 + + bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = SystemInformation__criticalExtensions_PR_systemInformation_r8; + bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0; @@ -1358,9 +1347,10 @@ uint8_t do_SIB23(uint8_t Mod_id, #endif + //Panos: Careful here! You have commented TTN's next two lines //TTN - for D2D - ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib18_part); - ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib19_part); + //ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib18_part); + //ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib19_part); //ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib21_part); @@ -1395,9 +1385,7 @@ uint8_t do_SIB23(uint8_t Mod_id, # endif #endif -#ifdef USER_MODE LOG_D(RRC,"[eNB] SystemInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif if (enc_rval.encoded==-1) { msg("[RRC] ASN1 : SI encoding failed for SIB23\n"); @@ -1484,9 +1472,7 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) # endif #endif -#ifdef USER_MODE LOG_D(RRC,"[UE] RRCConnectionRequest Encoded %zd bits (%zd bytes), ecause %d\n",enc_rval.encoded,(enc_rval.encoded+7)/8,ecause); -#endif return((enc_rval.encoded+7)/8); @@ -1733,9 +1719,7 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin # endif #endif -#ifdef USER_MODE LOG_D(RRC,"RRCConnectionSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif return((enc_rval.encoded+7)/8); @@ -1795,9 +1779,7 @@ do_RRCConnectionReconfigurationComplete( # endif #endif -#ifdef USER_MODE LOG_D(RRC,"RRCConnectionReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif return((enc_rval.encoded+7)/8); } @@ -2184,10 +2166,8 @@ do_RRCConnectionSetup( # endif #endif -#ifdef USER_MODE LOG_D(RRC,"RRCConnectionSetup Encoded %zd bits (%zd bytes), ecause %d\n", enc_rval.encoded,(enc_rval.encoded+7)/8,ecause); -#endif // FREEMEM(SRB_list); // free(SRB1_config); @@ -2257,13 +2237,11 @@ do_SecurityModeCommand( # endif #endif -#ifdef USER_MODE LOG_D(RRC,"[eNB %d] securityModeCommand for UE %x Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rnti, enc_rval.encoded, (enc_rval.encoded+7)/8); -#endif if (enc_rval.encoded==-1) { LOG_E(RRC,"[eNB %d] ASN1 : securityModeCommand encoding failed for UE %x\n", @@ -2335,13 +2313,11 @@ do_UECapabilityEnquiry( # endif #endif -#ifdef USER_MODE LOG_D(RRC,"[eNB %d] UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rnti, enc_rval.encoded, (enc_rval.encoded+7)/8); -#endif if (enc_rval.encoded==-1) { LOG_E(RRC,"[eNB %d] ASN1 : UECapabilityRequest encoding failed for UE %x\n", @@ -2475,7 +2451,7 @@ do_RRCConnectionReconfiguration( //TTN for D2D //allocate dedicated resource pools for SL communication (sl_CommConfig_r12) - if (sl_CommConfig != NULL) { + /*if (sl_CommConfig != NULL) { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, @@ -2512,7 +2488,7 @@ do_RRCConnectionReconfiguration( sizeof(SL_DiscConfig_r12_t)); } else { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 = NULL; - } + }*/ enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message, (void*)&dl_dcch_msg, @@ -2544,13 +2520,219 @@ do_RRCConnectionReconfiguration( # endif #endif - //#ifdef USER_MODE LOG_I(RRC,"RRCConnectionReconfiguration Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); // for (i=0;i<30;i++) // msg("%x.",buffer[i]); // msg("\n"); - //#endif + + return((enc_rval.encoded+7)/8); +} + +//------------------------------------------------------------------------------ +uint8_t +do_RRCConnectionReestablishment( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + int CC_id, + uint8_t* const buffer, + const uint8_t transmission_mode, + const uint8_t Transaction_id, + SRB_ToAddModList_t **SRB_configList, + struct PhysicalConfigDedicated **physicalConfigDedicated) +{ + asn_enc_rval_t enc_rval; + + long* logicalchannelgroup = NULL; + struct SRB_ToAddMod* SRB1_config = NULL; + struct SRB_ToAddMod* SRB2_config = NULL; + struct SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL; + struct SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL; + struct LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL; + eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; + +#ifdef CBA + struct PUSCH_CBAConfigDedicated_vlola* pusch_CBAConfigDedicated_vlola = NULL; + long* betaOffset_CBA_Index = NULL; + long* cShift_CBA = NULL; +#endif + PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL; + + DL_CCCH_Message_t dl_ccch_msg; + + RRCConnectionReestablishment_t* rrcConnectionReestablishment = NULL; + + int i = 0; + SRB_ToAddModList_t **SRB_configList2 = NULL; + SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[Transaction_id]; + if (*SRB_configList2) { + free(*SRB_configList2); + } + *SRB_configList2 = CALLOC(1, sizeof(SRB_ToAddModList_t)); + + memset((void *)&dl_ccch_msg, 0, sizeof(DL_CCCH_Message_t)); + dl_ccch_msg.message.present = DL_CCCH_MessageType_PR_c1; + dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment; + rrcConnectionReestablishment = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReestablishment; + + // RRCConnectionReestablishment + // Configure SRB1 + + + // get old configuration of SRB2 + if (*SRB_configList != NULL) { + for (i = 0; (i < (*SRB_configList)->list.count) && (i < 3); i++) { + LOG_D(RRC, "(*SRB_configList)->list.array[%d]->srb_Identity=%ld\n", + i, (*SRB_configList)->list.array[i]->srb_Identity); + if ((*SRB_configList)->list.array[i]->srb_Identity == 2 ){ + SRB2_config = (*SRB_configList)->list.array[i]; + } else if ((*SRB_configList)->list.array[i]->srb_Identity == 1 ){ + SRB1_config = (*SRB_configList)->list.array[i]; + } + } + } + + if (SRB1_config == NULL) { + // default SRB1 configuration + LOG_W(RRC,"SRB1 configuration does not exist in SRB configuration list, use default\n"); + /// SRB1 + SRB1_config = CALLOC(1, sizeof(*SRB1_config)); + + SRB1_config->srb_Identity = 1; + SRB1_rlc_config = CALLOC(1, sizeof(*SRB1_rlc_config)); + SRB1_config->rlc_Config = SRB1_rlc_config; + + SRB1_rlc_config->present = SRB_ToAddMod__rlc_Config_PR_explicitValue; + SRB1_rlc_config->choice.explicitValue.present=RLC_Config_PR_am; + #if defined(ENABLE_ITTI) + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = rrc->srb1_timer_poll_retransmit; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = rrc->srb1_poll_pdu; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = rrc->srb1_poll_byte; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = rrc->srb1_max_retx_threshold; + SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = rrc->srb1_timer_reordering; + SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = rrc->srb1_timer_status_prohibit; + #else + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms20;; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = PollPDU_p4;; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity; + SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8; + SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35; + SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms0; + #endif + + SRB1_lchan_config = CALLOC(1, sizeof(*SRB1_lchan_config)); + SRB1_config->logicalChannelConfig = SRB1_lchan_config; + + SRB1_lchan_config->present = SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; + SRB1_ul_SpecificParameters = CALLOC(1, sizeof(*SRB1_ul_SpecificParameters)); + + SRB1_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB1_ul_SpecificParameters; + SRB1_ul_SpecificParameters->priority = 1; + + //assign_enum(&SRB1_ul_SpecificParameters->prioritisedBitRate,LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity); + SRB1_ul_SpecificParameters->prioritisedBitRate=LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + + //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50); + SRB1_ul_SpecificParameters->bucketSizeDuration=LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + logicalchannelgroup = CALLOC(1, sizeof(long)); + *logicalchannelgroup = 0; + SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; + } + + if (SRB2_config == NULL) { + LOG_W(RRC,"SRB2 configuration does not exist in SRB configuration list\n"); + } else { + ASN_SEQUENCE_ADD(&(*SRB_configList2)->list, SRB2_config); + } + + if (*SRB_configList) { + free(*SRB_configList); + } + + *SRB_configList = CALLOC(1, sizeof(SRB_ToAddModList_t)); + + ASN_SEQUENCE_ADD(&(*SRB_configList)->list,SRB1_config); + + physicalConfigDedicated2 = *physicalConfigDedicated; + + rrcConnectionReestablishment->rrc_TransactionIdentifier = Transaction_id; + rrcConnectionReestablishment->criticalExtensions.present = RRCConnectionReestablishment__criticalExtensions_PR_c1; + rrcConnectionReestablishment->criticalExtensions.choice.c1.present = RRCConnectionReestablishment__criticalExtensions__c1_PR_rrcConnectionReestablishment_r8; + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.srb_ToAddModList = *SRB_configList; + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.drb_ToAddModList = NULL; + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.drb_ToReleaseList = NULL; + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.sps_Config = NULL; + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.physicalConfigDedicated = physicalConfigDedicated2; + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.mac_MainConfig = NULL; + + uint8_t KeNB_star[32] = { 0 }; + uint16_t pci = rrc->carrier[CC_id].physCellId; + uint32_t earfcn_dl = (uint32_t)freq_to_arfcn10(RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, + rrc->carrier[CC_id].dl_CarrierFreq); + bool is_rel8_only = true; + if (earfcn_dl > 65535) { + is_rel8_only = false; + } + + LOG_D(RRC, "pci=%d, eutra_band=%d, downlink_frequency=%d, earfcn_dl=%u, is_rel8_only=%s\n", + pci, + RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, + 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); + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = ue_context_pP->ue_context.nh_ncc; + } else { // first HO + derive_keNB_star (ue_context_pP->ue_context.kenb, pci, earfcn_dl, is_rel8_only, KeNB_star); + // LG: really 1 + rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0; + } + + // 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; + +#ifdef XER_PRINT + xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg); +#endif + enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message, + (void*)&dl_ccch_msg, + buffer, + 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + +#if defined(ENABLE_ITTI) +# if !defined(DISABLE_XER_SPRINT) + { + char message_string[20000]; + size_t message_string_size; + + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_CCCH_Message, (void *) &dl_ccch_msg)) > 0) { + MessageDef *msg_p; + + msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); + + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); + } + } +# endif +#endif + +#ifdef USER_MODE + LOG_D(RRC,"RRCConnectionReestablishment Encoded %zd bits (%zd bytes)\n", + enc_rval.encoded,(enc_rval.encoded+7)/8); +#endif return((enc_rval.encoded+7)/8); } @@ -2605,10 +2787,8 @@ do_RRCConnectionReestablishmentReject( # endif #endif -#ifdef USER_MODE LOG_D(RRC,"RRCConnectionReestablishmentReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif return((enc_rval.encoded+7)/8); } @@ -2666,10 +2846,8 @@ do_RRCConnectionReject( # endif #endif -#ifdef USER_MODE LOG_D(RRC,"RRCConnectionReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif return((enc_rval.encoded+7)/8); } @@ -2857,9 +3035,7 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, # endif #endif -#ifdef USER_MODE LOG_D(RRC,"[eNB] MCCH Message Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif if (enc_rval.encoded==-1) { msg("[RRC] ASN1 : MCCH encoding failed for MBSFNAreaConfiguration\n"); @@ -2991,9 +3167,7 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ # endif #endif -#ifdef USER_MODE printf("Measurement Report Encoded %zu bits (%zu bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif return((enc_rval.encoded+7)/8); } @@ -3042,6 +3216,73 @@ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t trans return encoded; } +uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain) +{ + LOG_D(RRC, "[eNB %d] do_Paging start\n", Mod_id); + asn_enc_rval_t enc_rval; + + PCCH_Message_t pcch_msg; + PagingRecord_t *paging_record_p; + int j; + + pcch_msg.message.present = PCCH_MessageType_PR_c1; + pcch_msg.message.choice.c1.present = PCCH_MessageType__c1_PR_paging; + + pcch_msg.message.choice.c1.choice.paging.pagingRecordList = CALLOC(1,sizeof(*pcch_msg.message.choice.c1.choice.paging.pagingRecordList)); + + pcch_msg.message.choice.c1.choice.paging.systemInfoModification = NULL; + pcch_msg.message.choice.c1.choice.paging.etws_Indication = NULL; + pcch_msg.message.choice.c1.choice.paging.nonCriticalExtension = NULL; + + asn_set_empty(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list); + pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count = 0; + + if ((paging_record_p = calloc(1, sizeof(PagingRecord_t))) == NULL) { + /* Possible error on calloc */ + return (-1); + } + + memset(paging_record_p, 0, sizeof(PagingRecord_t)); + + /* convert ue_paging_identity_t to PagingUE_Identity_t */ + if (ue_paging_identity.presenceMask == UE_PAGING_IDENTITY_s_tmsi) { + paging_record_p->ue_Identity.present = PagingUE_Identity_PR_s_TMSI; + MME_CODE_TO_OCTET_STRING(ue_paging_identity.choice.s_tmsi.mme_code, + &paging_record_p->ue_Identity.choice.s_TMSI.mmec); + paging_record_p->ue_Identity.choice.s_TMSI.mmec.bits_unused = 0; + M_TMSI_TO_OCTET_STRING(ue_paging_identity.choice.s_tmsi.m_tmsi, + &paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI); + paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI.bits_unused = 0; + } else if (ue_paging_identity.presenceMask == UE_PAGING_IDENTITY_imsi) { + IMSI_Digit_t imsi_digit[21]; + for (j = 0; j< ue_paging_identity.choice.imsi.length; j++) { /* IMSI size */ + imsi_digit[j] = (IMSI_Digit_t)ue_paging_identity.choice.imsi.buffer[j]; + ASN_SEQUENCE_ADD(&paging_record_p->ue_Identity.choice.imsi.list, &imsi_digit[j]); + } + } + + /* set cn_domain */ + if (cn_domain == CN_DOMAIN_PS) { + paging_record_p->cn_Domain = PagingRecord__cn_Domain_ps; + } else { + paging_record_p->cn_Domain = PagingRecord__cn_Domain_cs; + } + /* add to list */ + ASN_SEQUENCE_ADD(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list, paging_record_p); + LOG_D(RRC, "[eNB %d] do_Paging paging_record: cn_Domain %ld, ue_paging_identity.presenceMask %d, PagingRecordList.count %d\n", + Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); + + enc_rval = uper_encode_to_buffer(&asn_DEF_PCCH_Message, (void*)&pcch_msg, buffer, RRC_BUF_SIZE); + + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); +#ifdef XER_PRINT + xer_fprint(stdout, &asn_DEF_PCCH_Message, (void*)&pcch_msg); +#endif + + return((enc_rval.encoded+7)/8); +} + uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer) { ssize_t encoded; diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.h b/openair2/RRC/LITE/MESSAGES/asn1_msg.h index 207cdb6d2b1d1be5d827532eb6f63f2f4591776b..efb1c85b48270e8ad612fb75e2c714035db6454c 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.h @@ -28,7 +28,6 @@ * \email: raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr */ -#ifdef USER_MODE #include <stdio.h> #include <sys/types.h> #include <stdlib.h> /* for atoi(3) */ @@ -36,9 +35,6 @@ #include <string.h> /* for strerror(3) */ #include <sysexits.h> /* for EX_* exit codes */ #include <errno.h> /* for errno */ -#else -#include <linux/module.h> /* Needed by all modules */ -#endif #include <asn_application.h> #include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */ @@ -206,6 +202,28 @@ do_RRCConnectionReconfiguration( , SCellToAddMod_r10_t *SCell_config #endif ); +/** +\brief Generate an RRCConnectionReestablishment DL-CCCH-Message (eNB). This routine configures SRB_ToAddMod (SRB1/SRB2) and +PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting (PUCCH format 2/2a/2b) or SRS. +@param ctxt_pP Running context +@param ue_context_pP UE context +@param CC_id Component Carrier ID +@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU +@param transmission_mode Transmission mode for UE (1-9) +@param Transaction_id Transaction_ID for this message +@param SRB_configList Pointer (returned) to SRB1_config/SRB2_config(later) IEs for this UE +@param physicalConfigDedicated Pointer (returned) to PhysicalConfigDedicated IE for this UE +@returns Size of encoded bit stream in bytes*/ +uint8_t +do_RRCConnectionReestablishment( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + int CC_id, + uint8_t* const buffer, + const uint8_t transmission_mode, + const uint8_t Transaction_id, + SRB_ToAddModList_t **SRB_configList, + struct PhysicalConfigDedicated **physicalConfigDedicated); /** \brief Generate an RRCConnectionReestablishmentReject DL-CCCH-Message (eNB). @@ -260,6 +278,8 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer); +uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain); + uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer); OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer); diff --git a/openair2/RRC/LITE/MESSAGES/rtai_mem.c b/openair2/RRC/LITE/MESSAGES/rtai_mem.c deleted file mode 100644 index c522a1f0bfdc566b008d38abaf876e8d5f8786af..0000000000000000000000000000000000000000 --- a/openair2/RRC/LITE/MESSAGES/rtai_mem.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rtai_mem.c -* \brief a wrapper for Unified RTAI real-time memory management. -* \author Florian Kaltenberger -* \date 2011-04-06 -* \version 0.1 -* \company Eurecom -* \email: florian.kaltenberger@eurecom.fr -* \note -* \bug -* \warning -*/ - -#include <asm/io.h> -#include <asm/bitops.h> -#include <asm/uaccess.h> -#include <asm/segment.h> -#include <asm/page.h> -#include <asm/delay.h> - -#include <linux/init.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/mm.h> -#include <linux/mman.h> - -#include <linux/slab.h> -//#include <linux/config.h> -#include <linux/version.h> -#include <linux/kernel.h> -#include <linux/fs.h> - -#include <linux/errno.h> - -#include <linux/slab.h> - -#include <asm/rtai.h> -#include <rtai.h> -#include <rtai_shm.h> -#include <rtai_malloc.h> - -/* -void* rt_alloc_wrapper(int size) { - - unsigned long* tmp_ptr; - static unsigned long name = 0; - - rt_shm_free(name); - tmp_ptr = (unsigned long*) rt_shm_alloc(name,size+sizeof(unsigned long),GFP_KERNEL); - - if (!tmp_ptr) { - printk("rt_mem.c: failed to allocate %d bytes for name %ld at %p\n",size,name,tmp_ptr); - return NULL; - } - - printk("rt_mem.c: allocated %d bytes for name %ld at %p\n",size,name,tmp_ptr+1); - - tmp_ptr[0] = name; - name++; - - return (void*) (tmp_ptr+1); - -} - -int rt_free_wrapper(void* ptr) { - - unsigned long name; - - printk("rt_mem.c: freeing memory at %p, ",ptr); - - name = *(((unsigned long*) ptr)-1); - - printk("name %ld\n",name); - - return rt_shm_free(name); - -} - -void* rt_realloc_wrapper(void* oldptr, int size) { - - void* newptr; - - printk("rt_mem.c: reallocating %p with %d bytes\n",oldptr,size); - - if (oldptr==NULL) - newptr = rt_alloc_wrapper(size); - else { - newptr = rt_alloc_wrapper(size); - memcpy(newptr,oldptr,size); - rt_free_wrapper(oldptr); - } - - return newptr; -} -*/ - -void* rt_realloc(void* oldptr, int size) -{ - - void* newptr; - - printk("rt_mem.c: reallocating %p with %d bytes\n",oldptr,size); - - if (oldptr==NULL) { - newptr = rt_malloc(size); - } else { - newptr = rt_malloc(size); - memcpy(newptr,oldptr,size); - rt_free(oldptr); - } - - return newptr; -} - -void* rt_calloc(int nmemb, int size) -{ - - void* newptr; - - printk("rt_mem.c: allocating %d elements with %d bytes\n",nmemb,size); - - newptr = rt_malloc(nmemb*size); - memset(newptr,0,nmemb*size); - - return newptr; -} diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index 42968bfa95e15a0548b9d49f06bcd4ee77eb366d..a222ed35e6e1b8da4c4c6bb483f7abcc8f7d40b1 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -31,11 +31,9 @@ #ifndef __OPENAIR_RRC_DEFS_H__ #define __OPENAIR_RRC_DEFS_H__ -#ifdef USER_MODE #include <stdio.h> #include <stdlib.h> #include <string.h> -#endif #include "collection/tree.h" #include "rrc_types.h" @@ -169,7 +167,7 @@ void *send_UE_status_notification(void *); //#include "COMMON/openair_defs.h" #ifndef USER_MODE -#include <rtai.h> +//#include <rtai.h> #endif #include "SystemInformationBlockType1.h" @@ -379,7 +377,11 @@ typedef enum SL_TRIGGER_e { // #define NUM_MAX_CBA_GROUP 4 // in the platform_constants /* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */ +#if defined(USRP_REC_PLAY) +#define RRC_TRANSACTION_IDENTIFIER_NUMBER 1 +#else #define RRC_TRANSACTION_IDENTIFIER_NUMBER 3 +#endif typedef struct { unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */ @@ -429,12 +431,15 @@ typedef enum e_rab_satus_e { E_RAB_STATUS_DONE, // from the eNB perspective E_RAB_STATUS_ESTABLISHED, // get the reconfigurationcomplete form UE E_RAB_STATUS_FAILED, + E_RAB_STATUS_TORELEASE // to release DRB between eNB and UE } e_rab_status_t; typedef struct e_rab_param_s { e_rab_t param; uint8_t status; uint8_t xid; // transaction_id + s1ap_Cause_t cause; + uint8_t cause_value; } __attribute__ ((__packed__)) e_rab_param_t; #endif @@ -512,6 +517,7 @@ typedef struct eNB_RRC_UE_s { SRB_ToAddModList_t* SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; DRB_ToAddModList_t* DRB_configList; DRB_ToAddModList_t* DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + DRB_ToReleaseList_t* DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; uint8_t DRB_active[8]; struct PhysicalConfigDedicated* physicalConfigDedicated; struct SPS_Config* sps_Config; @@ -531,6 +537,9 @@ typedef struct eNB_RRC_UE_s { #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 */ CipheringAlgorithm_r12_t ciphering_algorithm; @@ -560,9 +569,15 @@ typedef struct eNB_RRC_UE_s { uint8_t setup_e_rabs; /* Number of e_rab to be setup in the list */ uint8_t nb_of_e_rabs; + /* Number of e_rab to be modified in the list */ + uint8_t nb_of_modify_e_rabs; + uint8_t nb_of_failed_e_rabs; + e_rab_param_t modify_e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB]; /* list of e_rab to be setup by RRC layers */ e_rab_param_t e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB]; - + //release e_rabs + uint8_t nb_release_of_e_rabs; + e_rab_failed_t e_rabs_release_failed[S1AP_MAX_E_RAB]; // LG: For GTPV1 TUNNELS uint32_t enb_gtp_teid[S1AP_MAX_E_RAB]; transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; @@ -571,6 +586,13 @@ typedef struct eNB_RRC_UE_s { uint32_t ul_failure_timer; uint32_t ue_release_timer; uint32_t ue_release_timer_thres; + uint32_t ue_release_timer_s1; + uint32_t ue_release_timer_thres_s1; + uint32_t ue_release_timer_rrc; + uint32_t ue_release_timer_thres_rrc; + uint32_t ue_reestablishment_timer; + uint32_t ue_reestablishment_timer_thres; + uint8_t e_rab_release_command_flag; } eNB_RRC_UE_t; typedef uid_t ue_uid_t; @@ -639,6 +661,8 @@ typedef struct { // End - TTN SRB_INFO SI; SRB_INFO Srb0; + uint8_t *paging[NUMBER_OF_UE_MAX]; + uint32_t sizeof_paging[NUMBER_OF_UE_MAX]; } rrc_eNB_carrier_data_t; typedef struct eNB_RRC_INST_s { @@ -786,6 +810,8 @@ typedef struct UE_RRC_INST_s { #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 */ @@ -798,6 +824,14 @@ typedef struct UE_RRC_INST_s { #endif } UE_RRC_INST; +typedef struct UE_PF_PO_s { + boolean_t enable_flag; /* flag indicate whether current object is used */ + uint16_t ue_index_value; /* UE index value */ + uint8_t PF_min; /* minimal value of Paging Frame (PF) */ + uint8_t PO; /* Paging Occasion (PO) */ + uint32_t T; /* DRX cycle */ +} UE_PF_PO_t; + #include "proto.h" #endif diff --git a/openair2/RRC/LITE/extern.h b/openair2/RRC/LITE/extern.h index 77dcaac5e69492b9895d87434850adb42c923aec..71d8c9d0dcf8780dd91542ee1b5019ae12aa38d6 100644 --- a/openair2/RRC/LITE/extern.h +++ b/openair2/RRC/LITE/extern.h @@ -77,6 +77,11 @@ extern uint32_t timeToTrigger_ms[16]; extern float RSRP_meas_mapping[100]; extern float RSRQ_meas_mapping[33]; +extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +extern pthread_mutex_t ue_pf_po_mutex; + +extern uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2]; + #endif diff --git a/openair2/RRC/LITE/mesh_top.c b/openair2/RRC/LITE/mesh_top.c deleted file mode 100644 index 16395e99c64294ca1179e25a14071dfc359d1a45..0000000000000000000000000000000000000000 --- a/openair2/RRC/LITE/mesh_top.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*________________________openair_rrc_top.c________________________ - - Authors : Hicham Anouar - Company : EURECOM - Emails : anouar@eurecom.fr -________________________________________________________________*/ - - -#ifndef USER_MODE -#define __NO_VERSION__ - -#include <asm/io.h> -#include <asm/bitops.h> -#include <asm/uaccess.h> -#include <asm/segment.h> -#include <asm/page.h> -#include <asm/delay.h> - -#include <linux/init.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/mm.h> -#include <linux/mman.h> - -#include <linux/slab.h> -#include <linux/version.h> -#include <linux/kernel.h> -#include <linux/fs.h> - -#include <linux/errno.h> -#ifdef KERNEL2_6 -#include <linux/slab.h> -#endif - -#ifdef KERNEL2_4 -#include <linux/malloc.h> -#include <linux/wrapper.h> -#endif - -#endif - - - -#include "defs.h" -#include "vars.h" - -extern MAC_RLC_XFACE* mac_rrc_register(RRC_XFACE*); -extern int mac_rrc_unregister(RRC_XFACE *); - -extern void *bigphys_malloc(int); - - - - -#ifndef USER_MODE - -/*------------------------------------------------*/ -/* Prototypes */ -/*------------------------------------------------*/ -#ifdef KERNEL2_4 -static int init_module( void ); -static void cleanup_module(void); -#else -static int openair_rrc_init_module( void ); -static void openair_rrc_cleanup_module(void); -#endif - -#ifdef KERNEL2_6 -static int __init openair_rrc_init_module( void ) -#else -int init_module( void ) -#endif //KERNEL2_6 -{ - printk("[OPENAIR][RRC][INIT] inserting module\n"); - - - Rrc_xface = (RRC_XFACE*)malloc16(sizeof(RRC_XFACE)); - - if(Rrc_xface == NULL) { - printk("[RRC] FATAL EROOR: Could not allocate memory for Rrc_xface !!!\n"); - return (-1); - } - - Mac_rlc_xface=mac_rrc_register(Rrc_xface); - - if( Mac_rlc_xface == NULL ) { - printk("[OPENAIR][RRC][INIT] Could not get RRC descriptor\n"); - return -1; - } else { - printk("[OPENAIR][RRC][INIT] Got RRC descriptor , Rcc_xface %p,Mac_rlc_xface=%p \n",Rrc_xface,Mac_rlc_xface); - } - - if(rrc_init_global_param()==-1) { - printk("[OPENAIR][RRC][INIT] FATAL ERROR: INIT_GLOBAL_PARAM_NOK\n"); - return -1; - } - - return 0; -} - -#ifdef KERNEL2_6 -static void __exit openair_rrc_cleanup_module(void) -#else -void cleanup_module(void) -#endif //KERNEL2_6 -{ -#ifndef NO_RRM - rtf_destroy(RRC2RRM_FIFO); - rtf_destroy(RRM2RRC_FIFO); -#endif //NO_RRM - printk("[OPENAIR][RRC][CLEANUP] cleanup module\n"); - mac_rrc_unregister(Rrc_xface); - -} - -MODULE_AUTHOR -("Lionel GAUTHIER <lionel.gauthier@eurecom.fr>, Raymond KNOPP <raymond.knopp@eurecom.fr>, Aawatif MENOUNI <aawatif.menouni@eurecom.fr>,Dominique NUSSBAUM <dominique.nussbaum@eurecom.fr>, Michelle WETTERWALD <michelle.wetterwald@eurecom.fr>, Maxime GUILLAUD <maxime.guillaud@eurecom.fr, Hicham ANOUAR <hicham.anouar@eurecom.fr>"); -MODULE_DESCRIPTION ("openair RRC layer module"); -MODULE_LICENSE ("GPL"); -module_init (openair_rrc_init_module); -module_exit (openair_rrc_cleanup_module); - -#endif //USER_MODE - - diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h index 630b65fecd52b49446f8152bfe982582398f97af..902d8f1fc3bdbbd2b690b2293d6329fcdcc8596c 100644 --- a/openair2/RRC/LITE/proto.h +++ b/openair2/RRC/LITE/proto.h @@ -54,15 +54,30 @@ 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); +void +openair_rrc_on_ue( + const protocol_ctxt_t* const ctxt_pP); + void rrc_top_cleanup(void); -/** \brief Function to update timers every subframe. For UE it updates T300,T304 and T310. +/** \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, + const int CC_id +); + +/** \brief Function to update timers every subframe. For UE it updates T300,T304 and T310. +@param ctxt_pP running context +@param enb_index +@param CC_id +*/ +RRC_status_t +rrc_rx_tx_ue( protocol_ctxt_t* const ctxt_pP, const uint8_t enb_index, const int CC_id @@ -284,6 +299,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( const uint8_t ho_state ); +int freq_to_arfcn10(int band, unsigned long freq); + void rrc_eNB_generate_dedeicatedRRCConnectionReconfiguration( const protocol_ctxt_t* const ctxt_pP, @@ -291,7 +308,19 @@ rrc_eNB_generate_dedeicatedRRCConnectionReconfiguration( const uint8_t ho_state ); +/**\brief release Data Radio Bearer between ENB and UE + \param ctxt_pP Running context + \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, + uint8_t xid, + uint32_t nas_length, + uint8_t* nas_buffer +); + +void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* ue_context_pP); @@ -374,8 +403,6 @@ mac_rrc_data_req( const rb_id_t Srb_id, const uint8_t Nb_tb, uint8_t* const buffer_pP, - const eNB_flag_t enb_flagP, - const uint8_t eNB_index, const uint8_t mbsfn_sync_area ); @@ -389,7 +416,31 @@ mac_rrc_data_ind( const rb_id_t srb_idP, const uint8_t* sduP, const sdu_size_t sdu_lenP, - const eNB_flag_t eNB_flagP, + const uint8_t mbsfn_sync_areaP +); + +int8_t +mac_rrc_data_req_ue( + const module_id_t Mod_idP, + const int CC_id, + const frame_t frameP, + const rb_id_t Srb_id, + const uint8_t Nb_tb, + uint8_t* const buffer_pP, + const mac_enb_index_t eNB_indexP, + const uint8_t mbsfn_sync_area +); + +int8_t +mac_rrc_data_ind_ue( + const module_id_t module_idP, + const int CC_id, + const frame_t frameP, + const sub_frame_t sub_frameP, + const rnti_t rntiP, + const rb_id_t srb_idP, + const uint8_t* sduP, + const sdu_size_t sdu_lenP, const mac_enb_index_t eNB_indexP, const uint8_t mbsfn_sync_areaP ); @@ -402,8 +453,14 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, 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, +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); + +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); diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 2ec9bcd94dbd5a6342cbd0c917a41aa90718e9d6..f44c5aa4a5660977cdfa380007c8b7ea191e4722 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -62,14 +62,8 @@ #include "TDD-Config.h" #include "UECapabilityEnquiry.h" #include "UE-CapabilityRequest.h" -#ifdef PHY_ABSTRACTION -#include "OCG.h" -#include "OCG_extern.h" -#endif -#ifdef USER_MODE #include "RRC/NAS/nas_config.h" #include "RRC/NAS/rb_config.h" -#endif #if ENABLE_RAL #include "rrc_UE_ral.h" #endif @@ -250,7 +244,31 @@ static int rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_t subState ) } //----------------------------------------------------------------------------- -void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index ) +void +openair_rrc_on_ue( + const protocol_ctxt_t* const ctxt_pP +) +//----------------------------------------------------------------------------- +{ + unsigned short i; + int CC_id; + + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" UE?:OPENAIR RRC IN....\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + + for (i = 0; i < NB_eNB_INST; i++) { + LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" Activating CCCH (eNB %d)\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), i); + UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Srb_id = CCCH; + memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[0], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[1], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); + rrc_config_buffer (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i], CCCH, 1); + UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Active = 1; + } +} + +//----------------------------------------------------------------------------- +static void init_SI_UE( const 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; @@ -535,7 +553,7 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_ #endif #ifdef NO_RRM //init ch SRB0, SRB1 & BDTCH - openair_rrc_on(&ctxt); + openair_rrc_on_ue(&ctxt); #endif #ifdef CBA int j; @@ -627,7 +645,48 @@ static const char const nas_attach_req_guti[] = { #endif //----------------------------------------------------------------------------- -void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ) +void +rrc_t310_expiration( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index +) +//----------------------------------------------------------------------------- +{ + + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State != RRC_CONNECTED) { + LOG_D(RRC, "Timer 310 expired, going to RRC_IDLE\n"); + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_IDLE; + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].UE_index = 0xffff; + UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Rx_buffer.payload_size = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Rx_buffer.payload_size = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size = 0; + + if (UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active == 1) { + LOG_D (RRC,"[Inst %d] eNB_index %d, Remove RB %d\n ", ctxt_pP->module_id, eNB_index, + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id); + rrc_pdcp_config_req (ctxt_pP, + SRB_FLAG_YES, + CONFIG_ACTION_REMOVE, + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, + 0); + rrc_rlc_config_req (ctxt_pP, + SRB_FLAG_YES, + MBMS_FLAG_NO, + CONFIG_ACTION_REMOVE, + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, + Rlc_info_um); + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active = 0; + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Status = IDLE; + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Next_check_frame = 0; + } + } else { // Restablishment procedure + LOG_D(RRC, "Timer 310 expired, trying RRCRestablishment ...\n"); + } +} + +//----------------------------------------------------------------------------- +static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ) { uint8_t buffer[100]; @@ -650,7 +709,7 @@ void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* const ct LOG_D(RLC, "[FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", ctxt_pP->frame, ctxt_pP->module_id+NB_eNB_INST, size, eNB_index, rrc_mui, ctxt_pP->module_id+NB_eNB_INST, DCCH); - rrc_data_req ( + rrc_data_req_ue ( ctxt_pP, DCCH, rrc_mui++, @@ -677,7 +736,7 @@ void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t rrc_mui, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), DCCH); - rrc_data_req ( + rrc_data_req_ue ( ctxt_pP, DCCH, rrc_mui++, @@ -920,13 +979,8 @@ rrc_ue_establish_drb( */ #ifdef 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) -# ifdef OAI_EMU - ip_addr_offset3 = oai_emulation.info.nb_enb_local; - ip_addr_offset4 = NB_eNB_INST; -# else ip_addr_offset3 = 0; - ip_addr_offset4 = 8; -# endif + 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 @@ -934,9 +988,6 @@ rrc_ue_establish_drb( ip_addr_offset4+ue_mod_idP+1); // fourth_octet if (oip_ifup == 0 ) { // interface is up --> send a config the DRB -# ifdef OAI_EMU - oai_emulation.info.oai_ifup[ue_mod_idP]=1; -# endif 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, @@ -952,10 +1003,6 @@ rrc_ue_establish_drb( LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index); } -# else -# ifdef OAI_EMU - oai_emulation.info.oai_ifup[ue_mod_idP]=1; -# endif # endif #endif @@ -1756,17 +1803,6 @@ rrc_ue_process_radioResourceConfigDedicated( UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_CONNECTED; LOG_I(RRC,"[UE %d] State = RRC_CONNECTED (eNB %d)\n",ctxt_pP->module_id,eNB_index); -#if !defined(ENABLE_USE_MME) && defined(OAI_EMU) -# ifdef OAI_EMU - rrc_eNB_emulation_notify_ue_module_id( - ctxt_pP->module_id, - ctxt_pP->rnti, - UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[0], - UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[1], - UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[2], - UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[3]); -# endif /* OAI_EMU */ -#endif } @@ -1907,48 +1943,49 @@ rrc_ue_process_securityModeCommand( #endif //#if defined(ENABLE_SECURITY) if (securityModeCommand->criticalExtensions.present == SecurityModeCommand__criticalExtensions_PR_c1) { - if (securityModeCommand->criticalExtensions.choice.c1.present == SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) { - - ul_dcch_msg.message.choice.c1.choice.securityModeComplete.rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; - ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; - ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.choice.securityModeComplete_r8.nonCriticalExtension =NULL; - - LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d)\n", - ctxt_pP->module_id,ctxt_pP->frame,eNB_index); - - enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, - (void*)&ul_dcch_msg, - buffer, - 100); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - + if (securityModeCommand->criticalExtensions.choice.c1.present != SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) + LOG_W(RRC,"securityModeCommand->criticalExtensions.choice.c1.present (%d) != SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8\n", + securityModeCommand->criticalExtensions.choice.c1.present); + + + ul_dcch_msg.message.choice.c1.choice.securityModeComplete.rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; + ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; + ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.choice.securityModeComplete_r8.nonCriticalExtension =NULL; + + LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d)\n", + ctxt_pP->module_id,ctxt_pP->frame,eNB_index); + + enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, + (void*)&ul_dcch_msg, + buffer, + 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + #ifdef XER_PRINT - xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); + xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); #endif - + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) - { - char message_string[20000]; - size_t message_string_size; - - if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { - MessageDef *msg_p; - - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); - } + { + char message_string[20000]; + size_t message_string_size; + + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { + MessageDef *msg_p; + + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); + + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } + } # endif #endif -#ifdef USER_MODE LOG_D(RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); -#endif for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) { LOG_T(RRC, "%02x.", buffer[i]); @@ -1964,7 +2001,9 @@ rrc_ue_process_securityModeCommand( buffer, PDCP_TRANSMISSION_MODE_CONTROL); } - } + + else LOG_W(RRC,"securityModeCommand->criticalExtensions.present (%d) != SecurityModeCommand__criticalExtensions_PR_c1\n", + securityModeCommand->criticalExtensions.present); } //----------------------------------------------------------------------------- @@ -2008,68 +2047,71 @@ rrc_ue_process_ueCapabilityEnquiry( // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.size = UE_rrc_inst[ue_mod_idP].UECapability_size; - if (UECapabilityEnquiry->criticalExtensions.present == UECapabilityEnquiry__criticalExtensions_PR_c1) { - if (UECapabilityEnquiry->criticalExtensions.choice.c1.present == UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8) { - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.present = UECapabilityInformation__criticalExtensions_PR_c1; - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.present = - UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count - =0; - - for (i=0; i<UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count; i++) { - - if (*UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.array[i] - == RAT_Type_eutra) { - ASN_SEQUENCE_ADD( - &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, - &ue_CapabilityRAT_Container); - - enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, (void*) &ul_dcch_msg, buffer, 100); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - + AssertFatal(UECapabilityEnquiry->criticalExtensions.present == UECapabilityEnquiry__criticalExtensions_PR_c1, + "UECapabilityEnquiry->criticalExtensions.present (%d) != UECapabilityEnquiry__criticalExtensions_PR_c1 (%d)\n", + UECapabilityEnquiry->criticalExtensions.present,UECapabilityEnquiry__criticalExtensions_PR_c1); + + if (UECapabilityEnquiry->criticalExtensions.choice.c1.present != UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8) + LOG_W(RRC,"UECapabilityEnquiry->criticalExtensions.choice.c1.present (%d) != UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8)\n", + UECapabilityEnquiry->criticalExtensions.choice.c1.present); + + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.present = UECapabilityInformation__criticalExtensions_PR_c1; + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.present = + UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count + =0; + + for (i=0; i<UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count; i++) { + + if (*UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.array[i] + == RAT_Type_eutra) { + ASN_SEQUENCE_ADD( + &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, + &ue_CapabilityRAT_Container); + + enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, (void*) &ul_dcch_msg, buffer, 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + #ifdef XER_PRINT - xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); + xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); #endif - + #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) - { - char message_string[20000]; - size_t message_string_size; - - if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { - MessageDef *msg_p; - - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - - itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); - } - } + { + char message_string[20000]; + size_t message_string_size; + + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { + MessageDef *msg_p; + + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); + + itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); + } + } # endif #endif + -#ifdef USER_MODE LOG_D(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); -#endif for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) { LOG_T(RRC, "%02x.", buffer[i]); } - - LOG_T(RRC, "\n"); - rrc_data_req ( - ctxt_pP, - DCCH, - rrc_mui++, - SDU_CONFIRM_NO, - (enc_rval.encoded + 7) / 8, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - } - } + + LOG_T(RRC, "\n"); + rrc_data_req_ue ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + (enc_rval.encoded + 7) / 8, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } } } @@ -3828,7 +3870,8 @@ uint64_t arfcn_to_freq(long arfcn) { // instead of SystemInformation__criticalExtensions_PR_systemInformation_r8 // Panos: I brought this if condition back to previous form in order to prevent crashing. Pending to // modify for SystemInformation__criticalExtensions_PR_criticalExtensionsFuture - if ((*si)->criticalExtensions.present == SystemInformation__criticalExtensions_PR_systemInformation_r8) { + if ((*si)->criticalExtensions.present == SystemInformation__criticalExtensions_PR_systemInformation_r8 || + (*si)->criticalExtensions.present == SystemInformation__criticalExtensions_PR_criticalExtensionsFuture) { //if ((*si)->criticalExtensions.present == SystemInformation__criticalExtensions_PR_criticalExtensionsFuture) { LOG_D( RRC, "[UE] (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count %d\n", (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count ); @@ -4618,10 +4661,6 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB #endif // rel10 -#ifndef USER_MODE -EXPORT_SYMBOL(Rlc_info_am_config); -#endif - #if defined(ENABLE_ITTI) //----------------------------------------------------------------------------- void *rrc_ue_task( void *args_p ) @@ -4921,7 +4960,7 @@ void *rrc_ue_task( void *args_p ) // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) if(UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL) { - rrc_data_req (&ctxt, + rrc_data_req_ue (&ctxt, DCCH, rrc_mui++, SDU_CONFIRM_NO, @@ -4930,7 +4969,7 @@ void *rrc_ue_task( void *args_p ) } else { - rrc_data_req (&ctxt, + rrc_data_req_ue (&ctxt, DCCH1, rrc_mui++, SDU_CONFIRM_NO, @@ -5989,3 +6028,121 @@ int decode_SL_Discovery_Message( } #endif + +//----------------------------------------------------------------------------- +RRC_status_t +rrc_rx_tx_ue( + protocol_ctxt_t* const ctxt_pP, + const uint8_t enb_indexP, + const int CC_id +) +//----------------------------------------------------------------------------- +{ + //uint8_t UE_id; + int32_t current_timestamp_ms, ref_timestamp_ms; + struct timeval ts; + struct rrc_eNB_ue_context_s *ue_context_p = NULL,*ue_to_be_removed = NULL; + +#ifdef LOCALIZATION + double estimated_distance; + protocol_ctxt_t ctxt; +#endif + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN); + + // check timers + + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active == 1) { + if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt % 10) == 0) + LOG_D(RRC, + "[UE %d][RAPROC] Frame %d T300 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt); + + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt + == T300[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t300]) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active = 0; + // ALLOW CCCH to be used + UE_rrc_inst[ctxt_pP->module_id].Srb0[enb_indexP].Tx_buffer.payload_size = 0; + rrc_ue_generate_RRCConnectionRequest (ctxt_pP, enb_indexP); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); + return (RRC_ConnSetup_failed); + } + + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt++; + } + + if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].SIStatus&2)>0) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt + == N310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n310]) { + LOG_I(RRC,"Activating T310\n"); + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 1; + } + } else { // in case we have not received SIB2 yet + /* if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt == 100) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt = 0; + + }*/ + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); + return RRC_OK; + } + + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active == 1) { + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt + == N311[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n311]) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0; + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt = 0; + } + + if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt % 10) == 0) { + LOG_D(RRC, "[UE %d] Frame %d T310 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt); + } + + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt == T310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t310]) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0; + rrc_t310_expiration (ctxt_pP, enb_indexP); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); + LOG_I(RRC,"Returning RRC_PHY_RESYNCH: T310 expired\n"); + return RRC_PHY_RESYNCH; + } + + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt++; + } + + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active==1) { + if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt % 10) == 0) + LOG_D(RRC,"[UE %d][RAPROC] Frame %d T304 Count %d ms\n",ctxt_pP->module_id,ctxt_pP->frame, + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt); + + if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt == 0) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active = 0; + UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; + LOG_E(RRC,"[UE %d] Handover failure..initiating connection re-establishment procedure... \n", + ctxt_pP->module_id); + //Implement 36.331, section 5.3.5.6 here + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); + return(RRC_Handover_failed); + } + + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt--; + } + + // Layer 3 filtering of RRC measurements + if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0] != NULL) { + ue_meas_filtering(ctxt_pP,enb_indexP); + } + + ue_measurement_report_triggering(ctxt_pP,enb_indexP); + + if (UE_rrc_inst[ctxt_pP->module_id].Info[0].handoverTarget > 0) { + LOG_I(RRC,"[UE %d] Frame %d : RRC handover initiated\n", ctxt_pP->module_id, ctxt_pP->frame); + } + + if((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State == RRC_HO_EXECUTION) && + (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId != 0xFF)) { + UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State= RRC_IDLE; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); + return(RRC_HO_STARTED); + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); + return (RRC_OK); +} + diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index 65e1a25b1708e404cd07508c2754ffe3a2669085..707d57a168b4102215b1a0b8aef07be3188aef4e 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -53,41 +53,6 @@ extern UE_MAC_INST *UE_mac_inst; extern mui_t rrc_eNB_mui; -//configure BCCH & CCCH Logical Channels and associated rrc_buffers, configure associated SRBs -//----------------------------------------------------------------------------- -void -openair_rrc_on( - const protocol_ctxt_t* const ctxt_pP -) -//----------------------------------------------------------------------------- -{ - unsigned short i; - int CC_id; - - if (ctxt_pP->enb_flag == ENB_FLAG_YES) { - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB:OPENAIR RRC IN....\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1; - rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1; - } - } else { - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" UE?:OPENAIR RRC IN....\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - - for (i = 0; i < NB_eNB_INST; i++) { - LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" Activating CCCH (eNB %d)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), i); - UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Srb_id = CCCH; - memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[0], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[1], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - rrc_config_buffer (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i], CCCH, 1); - UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Active = 1; - } - } -} //----------------------------------------------------------------------------- int @@ -97,9 +62,7 @@ rrc_init_global_param( //----------------------------------------------------------------------------- { - //#ifdef USER_MODE // Rrc_xface = (RRC_XFACE*)malloc16(sizeof(RRC_XFACE)); - //#endif //USRE_MODE // Rrc_xface->openair_rrc_top_init = openair_rrc_top_init; // Rrc_xface->openair_rrc_eNB_init = openair_rrc_eNB_init; @@ -170,241 +133,6 @@ rrc_config_buffer( } -//----------------------------------------------------------------------------- -void -rrc_t310_expiration( - const protocol_ctxt_t* const ctxt_pP, - const uint8_t eNB_index -) -//----------------------------------------------------------------------------- -{ - - if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State != RRC_CONNECTED) { - LOG_D(RRC, "Timer 310 expired, going to RRC_IDLE\n"); - UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_IDLE; - UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].UE_index = 0xffff; - UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Rx_buffer.payload_size = 0; - UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size = 0; - UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Rx_buffer.payload_size = 0; - UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size = 0; - - if (UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active == 1) { - msg ("[RRC Inst %d] eNB_index %d, Remove RB %d\n ", ctxt_pP->module_id, eNB_index, - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id); - rrc_pdcp_config_req (ctxt_pP, - SRB_FLAG_YES, - CONFIG_ACTION_REMOVE, - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, - 0); - rrc_rlc_config_req (ctxt_pP, - SRB_FLAG_YES, - MBMS_FLAG_NO, - CONFIG_ACTION_REMOVE, - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, - Rlc_info_um); - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active = 0; - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Status = IDLE; - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Next_check_frame = 0; - } - } else { // Restablishment procedure - LOG_D(RRC, "Timer 310 expired, trying RRCRestablishment ...\n"); - } -} - -//----------------------------------------------------------------------------- -RRC_status_t -rrc_rx_tx( - protocol_ctxt_t* const ctxt_pP, - const uint8_t enb_indexP, - const int CC_id -) -//----------------------------------------------------------------------------- -{ - //uint8_t UE_id; - int32_t current_timestamp_ms, ref_timestamp_ms; - struct timeval ts; - struct rrc_eNB_ue_context_s *ue_context_p = NULL,*ue_to_be_removed = NULL; - -#ifdef LOCALIZATION - double estimated_distance; - protocol_ctxt_t ctxt; -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN); - - if(ctxt_pP->enb_flag == ENB_FLAG_NO) { - // check timers - - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active == 1) { - if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt % 10) == 0) - LOG_D(RRC, - "[UE %d][RAPROC] Frame %d T300 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt); - - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt - == T300[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t300]) { - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active = 0; - // ALLOW CCCH to be used - UE_rrc_inst[ctxt_pP->module_id].Srb0[enb_indexP].Tx_buffer.payload_size = 0; - rrc_ue_generate_RRCConnectionRequest (ctxt_pP, enb_indexP); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - return (RRC_ConnSetup_failed); - } - - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt++; - } - - if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].SIStatus&2)>0) { - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt - == N310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n310]) { - LOG_I(RRC,"Activating T310\n"); - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 1; - } - } else { // in case we have not received SIB2 yet - /* if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt == 100) { - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt = 0; - - }*/ - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - return RRC_OK; - } - - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active == 1) { - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt - == N311[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n311]) { - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0; - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt = 0; - } - - if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt % 10) == 0) { - LOG_D(RRC, "[UE %d] Frame %d T310 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt); - } - - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt == T310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t310]) { - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0; - rrc_t310_expiration (ctxt_pP, enb_indexP); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - LOG_I(RRC,"Returning RRC_PHY_RESYNCH: T310 expired\n"); - return RRC_PHY_RESYNCH; - } - - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt++; - } - - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active==1) { - if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt % 10) == 0) - LOG_D(RRC,"[UE %d][RAPROC] Frame %d T304 Count %d ms\n",ctxt_pP->module_id,ctxt_pP->frame, - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt); - - if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt == 0) { - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active = 0; - UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; - LOG_E(RRC,"[UE %d] Handover failure..initiating connection re-establishment procedure... \n", - ctxt_pP->module_id); - //Implement 36.331, section 5.3.5.6 here - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - return(RRC_Handover_failed); - } - - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt--; - } - - // Layer 3 filtering of RRC measurements - if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0] != NULL) { - ue_meas_filtering(ctxt_pP,enb_indexP); - } - - ue_measurement_report_triggering(ctxt_pP,enb_indexP); - - if (UE_rrc_inst[ctxt_pP->module_id].Info[0].handoverTarget > 0) { - LOG_I(RRC,"[UE %d] Frame %d : RRC handover initiated\n", ctxt_pP->module_id, ctxt_pP->frame); - } - - if((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State == RRC_HO_EXECUTION) && - (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId != 0xFF)) { - UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State= RRC_IDLE; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - return(RRC_HO_STARTED); - } - - } else { // eNB - check_handovers(ctxt_pP); - // counetr, and get the value and aggregate - - // check for UL failure - RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { - if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) { - if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { - LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/20000\n", - ue_context_p->ue_context.rnti, - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.ul_failure_timer); - } - else { - LOG_I(RRC,"UE rnti %x failure timer %d/20000\n", - ue_context_p->ue_context.rnti, - ue_context_p->ue_context.ul_failure_timer); - } - } - if (ue_context_p->ue_context.ul_failure_timer>0) { - ue_context_p->ue_context.ul_failure_timer++; - if (ue_context_p->ue_context.ul_failure_timer >= 20000) { - // remove UE after 20 seconds after MAC has indicated UL failure - LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); - ue_to_be_removed = ue_context_p; - break; - } - } - if (ue_context_p->ue_context.ue_release_timer>0) { - ue_context_p->ue_context.ue_release_timer++; - if (ue_context_p->ue_context.ue_release_timer >= - ue_context_p->ue_context.ue_release_timer_thres) { - LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); - ue_to_be_removed = ue_context_p; - break; - } - } - } - if (ue_to_be_removed) - rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed); - -#ifdef RRC_LOCALIZATION - - /* for the localization, only primary CC_id might be relevant*/ - gettimeofday(&ts, NULL); - current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; - ref_timestamp_ms = RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms; - RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { - ctxt = *ctxt_pP; - ctxt.rnti = ue_context_p->ue_context.rnti; - estimated_distance = rrc_get_estimated_ue_distance( - &ctxt, - CC_id, - RC.rrc[ctxt_pP->module_id]->loc_type); - - if ((current_timestamp_ms - ref_timestamp_ms > RC.rrc[ctxt_pP->module_id]->aggregation_period_ms) && - estimated_distance != -1) { - LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", - ctxt.rnti, - ctxt_pP->module_id, - current_timestamp_ms, - ctxt_pP->frame, - estimated_distance); - LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status); - push_front(&RC.rrc[ctxt_pP->module_id]->loc_list, - estimated_distance); - RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms; - } - } - -#endif - (void)ts; /* remove gcc warning "unused variable" */ - (void)ref_timestamp_ms; /* remove gcc warning "unused variable" */ - (void)current_timestamp_ms; /* remove gcc warning "unused variable" */ - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - return (RRC_OK); -} - //----------------------------------------------------------------------------- long binary_search_int( @@ -490,3 +218,110 @@ binary_search_float( return first; } +typedef enum { BAND_TYPE_FDD, BAND_TYPE_TDD } band_type; + +typedef struct { + band_type t; + int band; + unsigned long ul_minfreq, ul_maxfreq; + unsigned long dl_minfreq, dl_maxfreq; +} band_freq; + +static band_freq bands[] = { + { BAND_TYPE_FDD, 1, 1920000000UL, 1980000000UL, 2110000000UL, 2170000000UL }, + { BAND_TYPE_FDD, 2, 1850000000UL, 1910000000UL, 1930000000UL, 1990000000UL }, + { BAND_TYPE_FDD, 3, 1710000000UL, 1785000000UL, 1805000000UL, 1880000000UL }, + { BAND_TYPE_FDD, 4, 1710000000UL, 1755000000UL, 2110000000UL, 2155000000UL }, + { BAND_TYPE_FDD, 5, 824000000UL, 849000000UL, 869000000UL, 894000000UL }, + /* to remove? */{ BAND_TYPE_FDD, 6, 830000000UL, 840000000UL, 875000000UL, 885000000UL }, + { BAND_TYPE_FDD, 7, 2500000000UL, 2570000000UL, 2620000000UL, 2690000000UL }, + { BAND_TYPE_FDD, 8, 880000000UL, 915000000UL, 925000000UL, 960000000UL }, + { BAND_TYPE_FDD, 9, 1749900000UL, 1784900000UL, 1844900000UL, 1879900000UL }, + { BAND_TYPE_FDD, 10, 1710000000UL, 1770000000UL, 2110000000UL, 2170000000UL }, + { BAND_TYPE_FDD, 11, 1427900000UL, 1447900000UL, 1475900000UL, 1495900000UL }, + { BAND_TYPE_FDD, 12, 699000000UL, 716000000UL, 729000000UL, 746000000UL }, + { BAND_TYPE_FDD, 13, 777000000UL, 787000000UL, 746000000UL, 756000000UL }, + { BAND_TYPE_FDD, 14, 788000000UL, 798000000UL, 758000000UL, 768000000UL }, + { BAND_TYPE_FDD, 17, 704000000UL, 716000000UL, 734000000UL, 746000000UL }, + { BAND_TYPE_FDD, 18, 815000000UL, 830000000UL, 860000000UL, 875000000UL }, + { BAND_TYPE_FDD, 19, 830000000UL, 845000000UL, 875000000UL, 890000000UL }, + { BAND_TYPE_FDD, 20, 832000000UL, 862000000UL, 791000000UL, 821000000UL }, + { BAND_TYPE_FDD, 21, 1447900000UL, 1462900000UL, 1495900000UL, 1510900000UL }, + { BAND_TYPE_FDD, 22, 3410000000UL, 3490000000UL, 3510000000UL, 3590000000UL }, + { BAND_TYPE_FDD, 23, 2000000000UL, 2020000000UL, 2180000000UL, 2200000000UL }, + { BAND_TYPE_FDD, 24, 1626500000UL, 1660500000UL, 1525000000UL, 1559000000UL }, + { BAND_TYPE_FDD, 25, 1850000000UL, 1915000000UL, 1930000000UL, 1995000000UL }, + + { BAND_TYPE_TDD, 33, 1900000000UL, 1920000000UL, 1900000000UL, 1920000000UL }, + { BAND_TYPE_TDD, 34, 2010000000UL, 2025000000UL, 2010000000UL, 2025000000UL }, + { BAND_TYPE_TDD, 35, 1850000000UL, 1910000000UL, 1850000000UL, 1910000000UL }, + { BAND_TYPE_TDD, 36, 1930000000UL, 1990000000UL, 1930000000UL, 1990000000UL }, + { BAND_TYPE_TDD, 37, 1910000000UL, 1930000000UL, 1910000000UL, 1930000000UL }, + { BAND_TYPE_TDD, 38, 2570000000UL, 2620000000UL, 2570000000UL, 2620000000UL }, + { BAND_TYPE_TDD, 39, 1880000000UL, 1920000000UL, 1880000000UL, 1920000000UL }, + { BAND_TYPE_TDD, 40, 2300000000UL, 2400000000UL, 2300000000UL, 2400000000UL }, + { BAND_TYPE_TDD, 41, 2496000000UL, 2690000000UL, 2496000000UL, 2690000000UL }, + { BAND_TYPE_TDD, 42, 3400000000UL, 3600000000UL, 3400000000UL, 3600000000UL }, + { BAND_TYPE_TDD, 43, 3600000000UL, 3800000000UL, 3600000000UL, 3800000000UL }, +}; + +typedef struct { + int band; + unsigned long dl_flow; + int dl_off; + int dl_offmin, dl_offmax; + unsigned long ul_flow; + int ul_off; + int ul_offmin, ul_offmax; +} earfcn; + +static earfcn earfcn_table[] = { + { 1, 2110000000UL, 0, 0, 599, 1920000000UL, 18000, 18000, 18599 }, + { 2, 1930000000UL, 600, 600, 1199, 1850000000UL, 18600, 18600, 19199 }, + { 3, 1805000000UL, 1200, 1200, 1949, 1710000000UL, 19200, 19200, 19949 }, + { 4, 2110000000UL, 1950, 1950, 2399, 1710000000UL, 19950, 19950, 20399 }, + { 5, 869000000UL, 2400, 2400, 2649, 824000000UL, 20400, 20400, 20649 }, + { 6, 875000000UL, 2650, 2650, 2749, 830000000UL, 20650, 20650, 20749 }, + { 7, 2620000000UL, 2750, 2750, 3449, 2500000000UL, 20750, 20750, 21449 }, + { 8, 925000000UL, 3450, 3450, 3799, 880000000UL, 21450, 21450, 21799 }, + { 9, 1844900000UL, 3800, 3800, 4149, 1749900000UL, 21800, 21800, 22149 }, + { 10, 2110000000UL, 4150, 4150, 4749, 1710000000UL, 22150, 22150, 22749 }, + { 11, 1475900000UL, 4750, 4750, 4949, 1427900000UL, 22750, 22750, 22949 }, + { 12, 729000000UL, 5010, 5010, 5179, 699000000UL, 23010, 23010, 23179 }, + { 13, 746000000UL, 5180, 5180, 5279, 777000000UL, 23180, 23180, 23279 }, + { 14, 758000000UL, 5280, 5280, 5379, 788000000UL, 23280, 23280, 23379 }, + { 17, 734000000UL, 5730, 5730, 5849, 704000000UL, 23730, 23730, 23849 }, + { 18, 860000000UL, 5850, 5850, 5999, 815000000UL, 23850, 23850, 23999 }, + { 19, 875000000UL, 6000, 6000, 6149, 830000000UL, 24000, 24000, 24149 }, + { 20, 791000000UL, 6150, 6150, 6449, 832000000UL, 24150, 24150, 24449 }, + { 21, 1495900000UL, 6450, 6450, 6599, 1447900000UL, 24450, 24450, 24599 }, + { 22, 3510000000UL, 6600, 6600, 7399, 3410000000UL, 24600, 24600, 25399 }, + { 23, 2180000000UL, 7500, 7500, 7699, 2000000000UL, 25500, 25500, 25699 }, + { 24, 1525000000UL, 7700, 7700, 8039, 1626500000UL, 25700, 25700, 26039 }, + { 25, 1930000000UL, 8040, 8040, 8689, 1850000000UL, 26040, 26040, 26689 }, + { 33, 1900000000UL, 36000, 36000, 36199, 1900000000UL, 36000, 36000, 36199 }, + { 34, 2010000000UL, 36200, 36200, 36349, 2010000000UL, 36200, 36200, 36349 }, + { 35, 1850000000UL, 36350, 36350, 36949, 1850000000UL, 36350, 36350, 36949 }, + { 36, 1930000000UL, 36950, 36950, 37549, 1930000000UL, 36950, 36950, 37549 }, + { 37, 1910000000UL, 37550, 37550, 37749, 1910000000UL, 37550, 37550, 37749 }, + { 38, 2570000000UL, 37750, 37750, 38249, 2570000000UL, 37750, 37750, 38249 }, + { 39, 1880000000UL, 38250, 38250, 38649, 1880000000UL, 38250, 38250, 38649 }, + { 40, 2300000000UL, 38650, 38650, 39649, 2300000000UL, 38650, 38650, 39649 }, + { 41, 2496000000UL, 39650, 39650, 41589, 2496000000UL, 39650, 39650, 41589 }, + { 42, 3400000000UL, 41590, 41590, 43589, 3400000000UL, 41590, 41590, 43589 }, + { 43, 3600000000UL, 43590, 43590, 45589, 3600000000UL, 43590, 43590, 45589 }, +}; + +int freq_to_arfcn10(int band, unsigned long freq) +{ + int N = sizeof(earfcn_table) / sizeof(earfcn_table[0]); + int i; + + for (i = 0; i < N; i++) if (bands[i].band == band) break; + if (i == N) return -1; + + if (!(bands[i].dl_minfreq < freq && freq < bands[i].dl_maxfreq)) + return -1; + + return (freq - earfcn_table[i].dl_flow) / 100000UL + earfcn_table[i].dl_off; +} diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 9abe19d8d126eb1d4284b38ea5b7e99c809ed384..8f6288a5cd540a900908570a980ceff052bafd9d 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -59,6 +59,7 @@ #include "SL-CommConfig-r12.h" #include "PeriodicBSR-Timer-r12.h" #include "RetxBSR-Timer-r12.h" +#include "UTIL/LOG/vcd_signal_dumper.h" #include "T.h" @@ -66,12 +67,10 @@ #include "MeasResults.h" //#endif -#ifdef USER_MODE -# include "RRC/NAS/nas_config.h" -# include "RRC/NAS/rb_config.h" -# include "OCG.h" -# include "OCG_extern.h" -#endif +#include "RRC/NAS/nas_config.h" +#include "RRC/NAS/rb_config.h" +#include "OCG.h" +#include "OCG_extern.h" #if defined(ENABLE_SECURITY) # include "UTIL/OSA/osa_defs.h" @@ -87,6 +86,7 @@ #endif #include "pdcp.h" +#include "gtpv1u_eNB_task.h" #if defined(ENABLE_ITTI) # include "intertask_interface.h" @@ -118,6 +118,25 @@ extern uint16_t two_tier_hexagonal_cellIds[7]; mui_t rrc_eNB_mui = 0; +void +openair_rrc_on( + const protocol_ctxt_t* const ctxt_pP +) +//----------------------------------------------------------------------------- +{ + unsigned short i; + int CC_id; + + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB:OPENAIR RRC IN....\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1; + rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1; + } +} + //----------------------------------------------------------------------------- static void init_SI( @@ -140,6 +159,7 @@ init_SI( LOG_E(RRC,"%s()\n\n\n\n",__FUNCTION__); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4); // copy basic parameters RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId = configuration->Nid_cell[CC_id]; @@ -653,6 +673,7 @@ rrc_eNB_get_next_free_ue_context( ctxt_pP->rnti); if (ue_context_p == NULL) { +#if 0 RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { if (ue_context_p->ue_context.random_ue_identity == ue_identityP) { LOG_D(RRC, @@ -663,6 +684,7 @@ rrc_eNB_get_next_free_ue_context( return NULL; } } +#endif ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[ctxt_pP->module_id]); if (ue_context_p == NULL) { @@ -690,7 +712,7 @@ rrc_eNB_get_next_free_ue_context( } } -#if !defined(ENABLE_USE_MME) +#if 0 //!defined(ENABLE_USE_MME) void rrc_eNB_emulation_notify_ue_module_id( const module_id_t ue_module_idP, const rnti_t rntiP, @@ -709,12 +731,21 @@ void rrc_eNB_emulation_notify_ue_module_id( return; } for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { +//<<<<<<< HEAD if (RC.rrc[enb_module_id]->carrier[CC_id].sib1 != NULL) { if ( (RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[0] == cell_identity_byte0P) && (RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[1] == cell_identity_byte1P) && (RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[2] == cell_identity_byte2P) && (RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[3] == cell_identity_byte3P) +/*======= + if (&RC.rrc[enb_module_id]->carrier[CC_id].sib1 != NULL) { + if ( + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[0] == cell_identity_byte0P) && + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[1] == cell_identity_byte1P) && + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[2] == cell_identity_byte2P) && + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[3] == cell_identity_byte3P) +>>>>>>> main/develop*/ ) { ue_context_p = rrc_eNB_get_ue_context( RC.rrc[enb_module_id], @@ -761,11 +792,29 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.SRB_configList = NULL; } + for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){ + if (ue_context_pP->ue_context.SRB_configList2[i]) { + free(ue_context_pP->ue_context.SRB_configList2[i]); + ue_context_pP->ue_context.SRB_configList2[i] = NULL; + } + } + if (ue_context_pP->ue_context.DRB_configList) { ASN_STRUCT_FREE(asn_DEF_DRB_ToAddModList, ue_context_pP->ue_context.DRB_configList); ue_context_pP->ue_context.DRB_configList = NULL; } + for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){ + if (ue_context_pP->ue_context.DRB_configList2[i]) { + free(ue_context_pP->ue_context.DRB_configList2[i]); + ue_context_pP->ue_context.DRB_configList2[i] = NULL; + } + if (ue_context_pP->ue_context.DRB_Release_configList2[i]) { + free(ue_context_pP->ue_context.DRB_Release_configList2[i]); + ue_context_pP->ue_context.DRB_Release_configList2[i] = NULL; + } + } + memset(ue_context_pP->ue_context.DRB_active, 0, sizeof(ue_context_pP->ue_context.DRB_active)); if (ue_context_pP->ue_context.physicalConfigDedicated) { @@ -802,10 +851,14 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.mac_MainConfig = NULL; } - if (ue_context_pP->ue_context.measGapConfig) { +/* if (ue_context_pP->ue_context.measGapConfig) { ASN_STRUCT_FREE(asn_DEF_MeasGapConfig, ue_context_pP->ue_context.measGapConfig); ue_context_pP->ue_context.measGapConfig = NULL; - } + }*/ + if (ue_context_pP->ue_context.handover_info) { + ASN_STRUCT_FREE(asn_DEF_Handover, ue_context_pP->ue_context.handover_info); + ue_context_pP->ue_context.handover_info = NULL; + } //SRB_INFO SI; //SRB_INFO Srb0; @@ -860,7 +913,12 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* (void)ue_module_id; #endif rnti_t rnti = ue_context_pP->ue_context.rnti; - + int i, j , CC_id, pdu_number; + LTE_eNB_ULSCH_t *ulsch = NULL; + LTE_eNB_DLSCH_t *dlsch = NULL; + nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + PHY_VARS_eNB *eNB_PHY = NULL; + eNB_MAC_INST *eNB_MAC = RC.mac[enb_mod_idP]; AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rnti); /* ue_context_p = rrc_eNB_get_ue_context( @@ -873,6 +931,8 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rnti); #if defined(ENABLE_USE_MME) + if( ue_context_pP->ue_context.ul_failure_timer >= 8 ) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ RNTI %x\n", enb_mod_idP, rnti); rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before @@ -880,16 +940,42 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* * in order to allow the UE to perform the NAS recovery * procedure, see TS 23.401 [17]. */ -#else -#if defined(OAI_EMU) - AssertFatal(ue_context_pP->local_uid < NUMBER_OF_UE_MAX, "local_uid invalid (%d<%d) for UE %x!", ue_context_pP->local_uid, NUMBER_OF_UE_MAX, rnti); - ue_module_id = oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[enb_mod_idP][ue_context_pP->local_uid]; - AssertFatal(ue_module_id < NUMBER_OF_UE_MAX, "ue_module_id invalid (%d<%d) for UE %x!", ue_module_id, NUMBER_OF_UE_MAX, rnti); - oai_emulation.info.eNB_ue_local_uid_to_ue_module_id[enb_mod_idP][ue_context_pP->local_uid] = -1; - oai_emulation.info.eNB_ue_module_id_to_rnti[enb_mod_idP][ue_module_id] = NOT_A_RNTI; -#endif + return; + } #endif + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + eNB_PHY = RC.eNB[enb_mod_idP][CC_id]; + for (i=0; i<NUMBER_OF_UE_MAX; i++) { + ulsch = eNB_PHY->ulsch[i]; + if((ulsch != NULL) && (ulsch->rnti == rnti)){ + LOG_I(RRC, "clean_eNb_ulsch UE %x \n", rnti); + clean_eNb_ulsch(ulsch); + } + } + for (i=0; i<NUMBER_OF_UE_MAX; i++) { + dlsch = eNB_PHY->dlsch[i][0]; + if((dlsch != NULL) && (dlsch->rnti == rnti)){ + LOG_I(RRC, "clean_eNb_dlsch UE %x \n", rnti); + clean_eNb_dlsch(dlsch); + } + } + for(j = 0; j < 10; j++){ + ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; + if(ul_req_tmp){ + pdu_number = ul_req_tmp->number_of_pdus; + for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ + if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ + LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); + if(pdu_index < pdu_number -1){ + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + } + ul_req_tmp->number_of_pdus--; + } + } + } + } + } rrc_mac_remove_ue(enb_mod_idP,rnti); rrc_rlc_remove_ue(&ctxt); pdcp_remove_UE(&ctxt); @@ -1105,199 +1191,953 @@ rrc_eNB_generate_RRCConnectionReject( //----------------------------------------------------------------------------- void -rrc_eNB_generate_RRCConnectionReestablishmentReject( - const protocol_ctxt_t* const ctxt_pP, +rrc_eNB_generate_RRCConnectionReestablishment( + const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, - const int CC_id + const int CC_id ) //----------------------------------------------------------------------------- { -#ifdef RRC_MSG_PRINT + LogicalChannelConfig_t *SRB1_logicalChannelConfig; + SRB_ToAddModList_t **SRB_configList; + SRB_ToAddMod_t *SRB1_config; int cnt; -#endif - T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T(T_ENB_RRC_CONNECTION_REESTABLISHMENT, 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; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = - do_RRCConnectionReestablishmentReject(ctxt_pP->module_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); + do_RRCConnectionReestablishment(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); #ifdef RRC_MSG_PRINT - LOG_F(RRC,"[MSG] RRCConnectionReestablishmentReject\n"); + LOG_F(RRC,"[MSG] RRCConnectionReestablishment\n"); for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) { - LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->Srb0.Tx_buffer.Payload)[cnt]); + LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload)[cnt]); } LOG_F(RRC,"\n"); #endif - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, - MSC_AS_TIME_FMT" RRCConnectionReestablishmentReject UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); + // configure SRB1 for UE - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCConnectionReestablishmentReject (bytes %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); -} + 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]; -//----------------------------------------------------------------------------- -void -rrc_eNB_generate_RRCConnectionRelease( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP -) -//----------------------------------------------------------------------------- -{ + if (SRB1_config->logicalChannelConfig) { + if (SRB1_config->logicalChannelConfig->present == + SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { + SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue; + } else { + SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; + } + } else { + SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; + } - uint8_t buffer[RRC_BUF_SIZE]; - uint16_t size; + 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, +#ifdef Rel14 + 0, +#endif + ctxt_pP->rnti, + (BCCH_BCH_Message_t *) NULL, + (RadioResourceConfigCommonSIB_t *) NULL, + (RadioResourceConfigCommonSIB_t *) NULL, + (struct PhysicalConfigDedicated* ) ue_context_pP->ue_context.physicalConfigDedicated, +#if defined(Rel10) || defined(Rel14) + (SCellToAddMod_r10_t *)NULL, + //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (TDD_Config_t *) NULL, + NULL, + (SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL +#if defined(Rel10) || defined(Rel14) + , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL +#endif +#ifdef Rel14 + ,(SystemInformationBlockType1_v1310_IEs_t *)NULL +#endif + ); + break; + } + } + } - T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_RRC_UE, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, + MSC_AS_TIME_FMT" RRCConnectionReestablishment 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); - memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); - // set release timer - ue_context_pP->ue_context.ue_release_timer=1; - // remove UE after 10 frames after RRCConnectionRelease is triggered - ue_context_pP->ue_context.ue_release_timer_thres=100; LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - size); - - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", + PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCConnectionReestablishment (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - size, - rrc_eNB_mui, - DCCH); - - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - buffer, - size, - MSC_AS_TIME_FMT" rrcConnectionRelease UE %x MUI %d size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_pP->ue_context.rnti, - rrc_eNB_mui, - size); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + // activate release timer, if RRCComplete not received after 10 frames, remove UE + //ue_context_pP->ue_context.ue_release_timer = 1; + // remove UE after 10 frames after RRCConnectionReestablishmentRelease is triggered + //ue_context_pP->ue_context.ue_release_timer_thres = 100; + // activate release timer, if RRCComplete not received after 100 frames, remove UE + int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; + // remove UE after 100 frames after RRCConnectionReestablishmentRelease is triggered + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 1000; } -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, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state - ) +rrc_eNB_process_RRCConnectionReestablishmentComplete( + const protocol_ctxt_t* const ctxt_pP, + const rnti_t const reestablish_rnti, + rrc_eNB_ue_context_t* ue_context_pP, + const uint8_t xid, + RRCConnectionReestablishmentComplete_r8_IEs_t * rrcConnectionReestablishmentComplete +) //----------------------------------------------------------------------------- { - + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, processing RRCConnectionReestablishmentComplete from UE (SRB1 Active)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + + T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + + DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList; + SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; + SRB_ToAddModList_t** SRB_configList2 = NULL; + DRB_ToAddModList_t** DRB_configList2 = NULL; + struct SRB_ToAddMod *SRB2_config = NULL; + struct DRB_ToAddMod *DRB_config = NULL; + int i = 0; +# if defined(ENABLE_USE_MME) + int j = 0; + hashtable_rc_t h_rc; +#endif uint8_t buffer[RRC_BUF_SIZE]; uint16_t size; - int i; - - struct DRB_ToAddMod *DRB_config = NULL; - struct RLC_Config *DRB_rlc_config = NULL; - struct PDCP_Config *DRB_pdcp_config = NULL; - struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; - struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; - struct LogicalChannelConfig *DRB_lchan_config = NULL; - struct LogicalChannelConfig__ul_SpecificParameters - *DRB_ul_SpecificParameters = NULL; - // DRB_ToAddModList_t** DRB_configList=&ue_context_pP->ue_context.DRB_configList; - DRB_ToAddModList_t* DRB_configList=ue_context_pP->ue_context.DRB_configList; - DRB_ToAddModList_t** DRB_configList2=NULL; - //DRB_ToAddModList_t** RRC_DRB_configList=&ue_context_pP->ue_context.DRB_configList; - + MeasObjectToAddModList_t *MeasObj_list = NULL; + MeasObjectToAddMod_t *MeasObj = NULL; + ReportConfigToAddModList_t *ReportConfig_list = NULL; + ReportConfigToAddMod_t *ReportConfig_per, *ReportConfig_A1, + *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; + MeasIdToAddModList_t *MeasId_list = NULL; + MeasIdToAddMod_t *MeasId0, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5; + RSRP_Range_t *rsrp = NULL; + struct MeasConfig__speedStatePars *Sparams = NULL; + QuantityConfig_t *quantityConfig = NULL; + CellsToAddMod_t *CellToAdd = NULL; + CellsToAddModList_t *CellsToAddModList = NULL; struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; DedicatedInfoNAS_t *dedicatedInfoNas = NULL; /* for no gcc warnings */ (void)dedicatedInfoNas; + C_RNTI_t *cba_RNTI = NULL; + uint8_t next_xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); + + ue_context_pP->ue_context.Status = RRC_CONNECTED; + + SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[xid]; + // get old configuration of SRB2 + if (*SRB_configList2 != NULL) { + LOG_D(RRC, "SRB_configList2(%p) count is %d\n SRB_configList2->list.array[0] addr is %p", + SRB_configList2, (*SRB_configList2)->list.count, (*SRB_configList2)->list.array[0]); + for (i = 0; (i < (*SRB_configList2)->list.count) && (i < 3); i++) { + if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ){ + LOG_D(RRC, "get SRB2_config from (ue_context_pP->ue_context.SRB_configList2[%d])\n", xid); + SRB2_config = (*SRB_configList2)->list.array[i]; + break; + } + } + } + SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[next_xid]; + DRB_configList2 = &ue_context_pP->ue_context.DRB_configList2[next_xid]; + + if (*SRB_configList2) { + free(*SRB_configList2); + LOG_D(RRC, "free(ue_context_pP->ue_context.SRB_configList2[%d])\n", next_xid); + } + *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2)); + if (SRB2_config != NULL) { + // Add SRB2 to SRB configuration list + + ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); + ASN_SEQUENCE_ADD(&(*SRB_configList2)->list, SRB2_config); + + LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList\n", + SRB2_config->srb_Identity); + LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList2[%d]\n", + SRB2_config->srb_Identity, next_xid); + } else { + // SRB configuration list only contains SRB1. + LOG_W(RRC,"SRB2 configuration does not exist in SRB configuration list\n"); + } + - long *logicalchannelgroup_drb; - int drb_identity_index=0; - uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); //Transaction_id, - DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid]; if (*DRB_configList2) { free(*DRB_configList2); + LOG_D(RRC, "free(ue_context_pP->ue_context.DRB_configList2[%d])\n", next_xid); } - //*DRB_configList = CALLOC(1, sizeof(*DRB_configList)); - *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); - /* Initialize NAS list */ - dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); - int e_rab_done=0; - - for ( i = 0 ; - i < ue_context_pP->ue_context.setup_e_rabs ; - i++){ - - // bypass the new and already configured erabs - if (ue_context_pP->ue_context.e_rab[i].status >= E_RAB_STATUS_DONE) { - drb_identity_index++; - continue; + if (DRB_configList != NULL) { + LOG_D(RRC, "get DRB_config from (ue_context_pP->ue_context.DRB_configList)\n"); + for (i = 0; (i < DRB_configList->list.count) && (i < 3); i++) { + DRB_config = DRB_configList->list.array[i]; + + // Add DRB to DRB configuration list, for RRCConnectionReconfigurationComplete + ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); } - - DRB_config = CALLOC(1, sizeof(*DRB_config)); + } + ue_context_pP->ue_context.Srb1.Active = 1; + //ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2; + +# if defined(ENABLE_USE_MME) + 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 (h_rc == HASH_TABLE_OK) { + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; + } + } - DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); - // allowed value 5..15, value : x+4 - *(DRB_config->eps_BearerIdentity) = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation + gtpv1u_enb_create_tunnel_req_t create_tunnel_req; - DRB_config->drb_Identity = 1 + drb_identity_index + e_rab_done;// + i ;// (DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id; - // 1 + drb_identiy_index; + /* Save e RAB information for later */ + memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); - DRB_config->logicalChannelIdentity = CALLOC(1, sizeof(long)); - *(DRB_config->logicalChannelIdentity) = DRB_config->drb_Identity + 2; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 - - DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); - DRB_config->rlc_Config = DRB_rlc_config; + for (j = 0, i = 0; i < NB_RB_MAX; i++) { + if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED) { + 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; - DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); - DRB_config->pdcp_Config = DRB_pdcp_config; - DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); - *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; - DRB_pdcp_config->rlc_AM = NULL; - DRB_pdcp_config->rlc_UM = NULL; + 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; - switch (ue_context_pP->ue_context.e_rab[i].param.qos.qci){ - /* - * type: realtime data with medium packer error rate - * action: swtich to RLC UM - */ - case 1: // 100ms, 10^-2, p2, GBR - case 2: // 150ms, 10^-3, p4, GBR - case 3: // 50ms, 10^-3, p3, GBR - case 4: // 300ms, 10^-6, p5 - case 7: // 100ms, 10^-3, p7, GBR - case 9: // 300ms, 10^-6, p9 + gtpv1u_update_s1u_tunnel( + ctxt_pP->instance, + &create_tunnel_req, + reestablish_rnti); +#endif + /* 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 + // Measurement ID list + MeasId_list = CALLOC(1, sizeof(*MeasId_list)); + memset((void *)MeasId_list, 0, sizeof(*MeasId_list)); + + MeasId0 = CALLOC(1, sizeof(*MeasId0)); + MeasId0->measId = 1; + MeasId0->measObjectId = 1; + MeasId0->reportConfigId = 1; + ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0); + + MeasId1 = CALLOC(1, sizeof(*MeasId1)); + MeasId1->measId = 2; + MeasId1->measObjectId = 1; + MeasId1->reportConfigId = 2; + ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1); + + MeasId2 = CALLOC(1, sizeof(*MeasId2)); + MeasId2->measId = 3; + MeasId2->measObjectId = 1; + MeasId2->reportConfigId = 3; + ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2); + + MeasId3 = CALLOC(1, sizeof(*MeasId3)); + MeasId3->measId = 4; + MeasId3->measObjectId = 1; + MeasId3->reportConfigId = 4; + ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3); + + MeasId4 = CALLOC(1, sizeof(*MeasId4)); + MeasId4->measId = 5; + MeasId4->measObjectId = 1; + MeasId4->reportConfigId = 5; + ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4); + + MeasId5 = CALLOC(1, sizeof(*MeasId5)); + MeasId5->measId = 6; + MeasId5->measObjectId = 1; + MeasId5->reportConfigId = 6; + ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5); + + // rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list; + + // Add one EUTRA Measurement Object + MeasObj_list = CALLOC(1, sizeof(*MeasObj_list)); + memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list)); + + // Configure MeasObject + + MeasObj = CALLOC(1, sizeof(*MeasObj)); + memset((void *)MeasObj, 0, sizeof(*MeasObj)); + + MeasObj->measObjectId = 1; + MeasObj->measObject.present = MeasObjectToAddMod__measObject_PR_measObjectEUTRA; + MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz + //MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 36090; //band 33, 1.909GHz + MeasObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth = AllowedMeasBandwidth_mbw25; + MeasObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1 = 1; + MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf = CALLOC(1, sizeof(uint8_t)); + MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0] = 0; + 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 = + (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 = (CellsToAddMod_t *) CALLOC(1, sizeof(*CellToAdd)); + CellToAdd->cellIndex = i + 1; + CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); + CellToAdd->cellIndividualOffset = Q_OffsetRange_dB0; + + ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); + } + + ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj); + // rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; + + // Report Configurations for periodical, A1-A5 events + ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list)); + + ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per)); + + ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1)); + + ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2)); + + ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3)); + + ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4)); + + ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5)); + + ReportConfig_per->reportConfigId = 1; + ReportConfig_per->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = + ReportConfigEUTRA__triggerType_PR_periodical; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.periodical.purpose = + ReportConfigEUTRA__triggerType__periodical__purpose_reportStrongestCells; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity; + + ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per); + + ReportConfig_A1->reportConfigId = 2; + ReportConfig_A1->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present = + ReportConfigEUTRA__triggerType_PR_event; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = + ReportConfigEUTRA__triggerType__event__eventId_PR_eventA1; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1. + a1_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1. + a1_Threshold.choice.threshold_RSRP = 10; + + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120; + ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity; + + ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1); + + if (RC.rrc[ctxt_pP->module_id]->HO_flag == 1 /*HO_MEASURMENT */ ) { + LOG_I(RRC, "[eNB %d] frame %d: requesting A2, A3, A4, A5, and A6 event reporting\n", + ctxt_pP->module_id, ctxt_pP->frame); + ReportConfig_A2->reportConfigId = 3; + ReportConfig_A2->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.present = + ReportConfigEUTRA__triggerType_PR_event; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = + ReportConfigEUTRA__triggerType__event__eventId_PR_eventA2; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA2.a2_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA2.a2_Threshold.choice.threshold_RSRP = 10; + + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity = + ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120; + ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity; + + ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2); + + ReportConfig_A3->reportConfigId = 4; + ReportConfig_A3->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present = + ReportConfigEUTRA__triggerType_PR_event; + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = + ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3; + + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset = 1; //10; + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA3.reportOnLeave = 1; + + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity = + ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both; + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120; + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity; + + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis = 0.5; // FIXME ...hysteresis is of type long! + ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = + TimeToTrigger_ms40; + ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3); + + ReportConfig_A4->reportConfigId = 5; + ReportConfig_A4->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present = + ReportConfigEUTRA__triggerType_PR_event; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = + ReportConfigEUTRA__triggerType__event__eventId_PR_eventA4; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA4.a4_Threshold.present = ThresholdEUTRA_PR_threshold_RSRP; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA4.a4_Threshold.choice.threshold_RSRP = 10; + + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity = + ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120; + ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity; + + ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4); + + ReportConfig_A5->reportConfigId = 6; + ReportConfig_A5->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present = + ReportConfigEUTRA__triggerType_PR_event; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = + ReportConfigEUTRA__triggerType__event__eventId_PR_eventA5; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA5.a5_Threshold1.present = ThresholdEUTRA_PR_threshold_RSRP; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA5.a5_Threshold2.present = ThresholdEUTRA_PR_threshold_RSRP; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA5.a5_Threshold1.choice.threshold_RSRP = 10; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. + eventA5.a5_Threshold2.choice.threshold_RSRP = 10; + + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity = + ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = ReportConfigEUTRA__reportQuantity_both; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = ReportInterval_ms120; + ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = ReportConfigEUTRA__reportAmount_infinity; + + ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5); + // rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; + + rsrp = CALLOC(1, sizeof(RSRP_Range_t)); + *rsrp = 20; + + Sparams = CALLOC(1, sizeof(*Sparams)); + Sparams->present = MeasConfig__speedStatePars_PR_setup; + Sparams->choice.setup.timeToTrigger_SF.sf_High = SpeedStateScaleFactors__sf_Medium_oDot75; + Sparams->choice.setup.timeToTrigger_SF.sf_Medium = SpeedStateScaleFactors__sf_High_oDot5; + Sparams->choice.setup.mobilityStateParameters.n_CellChangeHigh = 10; + Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5; + Sparams->choice.setup.mobilityStateParameters.t_Evaluation = MobilityStateParameters__t_Evaluation_s60; + Sparams->choice.setup.mobilityStateParameters.t_HystNormal = MobilityStateParameters__t_HystNormal_s120; + + quantityConfig = CALLOC(1, sizeof(*quantityConfig)); + memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); + quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct QuantityConfigEUTRA)); + memset((void *)quantityConfig->quantityConfigEUTRA, 0, sizeof(*quantityConfig->quantityConfigEUTRA)); + quantityConfig->quantityConfigCDMA2000 = NULL; + quantityConfig->quantityConfigGERAN = NULL; + quantityConfig->quantityConfigUTRA = NULL; + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = + CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP))); + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = + CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); + *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4; + *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4; + + LOG_I(RRC, + "[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n", + ctxt_pP->module_id, ctxt_pP->frame); + // store the information in an intermediate structure for Hanodver management + //rrc_inst->handover_info.as_config.sourceRadioResourceConfig.srb_ToAddModList = CALLOC(1,sizeof()); + ue_context_pP->ue_context.handover_info = CALLOC(1, sizeof(*(ue_context_pP->ue_context.handover_info))); + //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.srb_ToAddModList,(void *)SRB_list,sizeof(SRB_ToAddModList_t)); + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.srb_ToAddModList = *SRB_configList2; + //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.drb_ToAddModList,(void *)DRB_list,sizeof(DRB_ToAddModList_t)); + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToAddModList = DRB_configList; + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig = + CALLOC(1, sizeof(*ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig)); + memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, + (void *)ue_context_pP->ue_context.mac_MainConfig, sizeof(MAC_MainConfig_t)); + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated = + CALLOC(1, sizeof(PhysicalConfigDedicated_t)); + memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, + (void*)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(PhysicalConfigDedicated_t)); + ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.sps_Config = NULL; + //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)); + + } + +#ifdef CBA + //struct PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola; + uint8_t *cba_RNTI_buf; + cba_RNTI = CALLOC(1, sizeof(C_RNTI_t)); + cba_RNTI_buf = CALLOC(1, 2 * sizeof(uint8_t)); + cba_RNTI->buf = cba_RNTI_buf; + cba_RNTI->size = 2; + cba_RNTI->bits_unused = 0; + + // associate UEs to the CBa groups as a function of their UE id + if (rrc_inst->num_active_cba_groups) { + cba_RNTI->buf[0] = rrc_inst->cba_rnti[ue_mod_idP % rrc_inst->num_active_cba_groups] & 0xff; + cba_RNTI->buf[1] = 0xff; + LOG_D(RRC, + "[eNB %d] Frame %d: cba_RNTI = %x in group %d is attribued to UE %d\n", + enb_mod_idP, frameP, + rrc_inst->cba_rnti[ue_mod_idP % rrc_inst->num_active_cba_groups], + ue_mod_idP % rrc_inst->num_active_cba_groups, ue_mod_idP); + } else { + cba_RNTI->buf[0] = 0x0; + cba_RNTI->buf[1] = 0x0; + LOG_D(RRC, "[eNB %d] Frame %d: no cba_RNTI is configured for UE %d\n", enb_mod_idP, frameP, ue_mod_idP); + } + +#endif + +#if defined(ENABLE_ITTI) + /* Initialize NAS list */ + dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); + + /* Add all NAS PDUs to the list */ + for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { + if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { + dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t)); + memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); + LOG_D(RRC, "Add dedicatedInfoNas(%d) to dedicatedInfoNASList\n", i); + ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); + } + + /* TODO parameters yet to process ... */ + { + // ue_context_pP->ue_context.e_rab[i].param.qos; + // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; + // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + } + + /* TODO should test if e RAB are Ok before! */ + ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; + LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", + i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); + } + + /* If list is empty free the list and reset the address */ + if (dedicatedInfoNASList->list.count == 0) { + free(dedicatedInfoNASList); + dedicatedInfoNASList = NULL; + } + +#endif + + // send RRCConnectionReconfiguration + memset(buffer, 0, RRC_BUF_SIZE); + + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + next_xid, //Transaction_id, + (SRB_ToAddModList_t*)*SRB_configList2, // SRB_configList + (DRB_ToAddModList_t*)DRB_configList, + (DRB_ToReleaseList_t*)NULL, // DRB2_list, + (struct SPS_Config*)NULL, // maybe ue_context_pP->ue_context.sps_Config, + (struct PhysicalConfigDedicated*)ue_context_pP->ue_context.physicalConfigDedicated, +#ifdef EXMIMO_IOT + NULL, NULL, NULL,NULL, +#else + (MeasObjectToAddModList_t*)MeasObj_list, // MeasObj_list, + (ReportConfigToAddModList_t*)ReportConfig_list, // ReportConfig_list, + (QuantityConfig_t*)quantityConfig, //quantityConfig, + (MeasIdToAddModList_t*)NULL, +#endif + (MAC_MainConfig_t*)ue_context_pP->ue_context.mac_MainConfig, + (MeasGapConfig_t*)NULL, + (MobilityControlInfo_t*)NULL, + (struct MeasConfig__speedStatePars*)Sparams, // Sparams, + (RSRP_Range_t*)rsrp, // rsrp, + (C_RNTI_t*)cba_RNTI, // cba_RNTI + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, //dedicatedInfoNASList + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if defined(Rel10) || defined(Rel14) + , (SCellToAddMod_r10_t*)NULL +#endif + ); + +#ifdef RRC_MSG_PRINT + LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n"); + for (i = 0; i < size; i++) { + LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]); + } + LOG_F(RRC,"\n"); + //////////////////////////////////////// +#endif + +#if defined(ENABLE_ITTI) + + /* Free all NAS PDUs */ + for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { + if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { + /* Free the NAS PDU buffer and invalidate it */ + free(ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer); + ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL; + } + } + +#endif + + LOG_I(RRC, + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + + LOG_D(RRC, + "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", + ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); + + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" rrcConnectionReconfiguration UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); + + rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + + // delete UE data of prior RNTI. UE use current RNTI. + protocol_ctxt_t ctxt_prior = *ctxt_pP; + ctxt_prior.rnti = reestablish_rnti; + + LTE_eNB_ULSCH_t *ulsch = NULL; + nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + PHY_VARS_eNB *eNB_PHY = NULL; + eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id]; + for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id]; + for (int i=0; i<NUMBER_OF_UE_MAX; i++) { + ulsch = eNB_PHY->ulsch[i]; + if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){ + LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti); + clean_eNb_ulsch(ulsch); + break; + } + } + + for(int j = 0; j < 10; j++){ + ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; + if(ul_req_tmp){ + int pdu_number = ul_req_tmp->number_of_pdus; + for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ + if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == ctxt_prior.rnti){ + LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", ctxt_prior.rnti, pdu_index, pdu_number); + if(pdu_index < pdu_number -1){ + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + } + ul_req_tmp->number_of_pdus--; + } + } + } + } + } + rrc_mac_remove_ue(ctxt_prior.module_id, ctxt_prior.rnti); + rrc_rlc_remove_ue(&ctxt_prior); + pdcp_remove_UE(&ctxt_prior); +} + +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_RRCConnectionReestablishmentReject( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + const int CC_id +) +//----------------------------------------------------------------------------- +{ +#ifdef RRC_MSG_PRINT + int cnt; +#endif + int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 20; + + T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = + do_RRCConnectionReestablishmentReject(ctxt_pP->module_id, + (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); + +#ifdef RRC_MSG_PRINT + LOG_F(RRC,"[MSG] RRCConnectionReestablishmentReject\n"); + + for (cnt = 0; cnt < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size; cnt++) { + LOG_F(RRC,"%02x ", ((uint8_t*)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload)[cnt]); + } + + LOG_F(RRC,"\n"); +#endif + + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, + MSC_AS_TIME_FMT" RRCConnectionReestablishmentReject UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP == NULL ? -1 : 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 RRCConnectionReestablishmentReject (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); +} + +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_RRCConnectionRelease( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP +) +//----------------------------------------------------------------------------- +{ + + uint8_t buffer[RRC_BUF_SIZE]; + uint16_t size; + + T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + + memset(buffer, 0, RRC_BUF_SIZE); + + size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); + // set release timer + //ue_context_pP->ue_context.ue_release_timer=1; + // remove UE after 10 frames after RRCConnectionRelease is triggered + //ue_context_pP->ue_context.ue_release_timer_thres=100; + // set release timer + ue_context_pP->ue_context.ue_release_timer_rrc = 1; + // remove UE after 10 frames after RRCConnectionRelease is triggered + ue_context_pP->ue_context.ue_release_timer_thres_rrc = 100; + ue_context_pP->ue_context.ue_reestablishment_timer = 0; + ue_context_pP->ue_context.ue_release_timer = 0; + ue_context_pP->ue_context.ue_release_timer_s1 = 0; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size); + + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size, + rrc_eNB_mui, + DCCH); + + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" rrcConnectionRelease UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); + + rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); +} + +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, + rrc_eNB_ue_context_t* const ue_context_pP, + const uint8_t ho_state + ) +//----------------------------------------------------------------------------- +{ + + uint8_t buffer[RRC_BUF_SIZE]; + uint16_t size; + int i; + + struct DRB_ToAddMod *DRB_config = NULL; + struct RLC_Config *DRB_rlc_config = NULL; + struct PDCP_Config *DRB_pdcp_config = NULL; + struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; + struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; + struct LogicalChannelConfig *DRB_lchan_config = NULL; + struct LogicalChannelConfig__ul_SpecificParameters + *DRB_ul_SpecificParameters = NULL; + // DRB_ToAddModList_t** DRB_configList=&ue_context_pP->ue_context.DRB_configList; + DRB_ToAddModList_t* DRB_configList=ue_context_pP->ue_context.DRB_configList; + DRB_ToAddModList_t** DRB_configList2=NULL; + //DRB_ToAddModList_t** RRC_DRB_configList=&ue_context_pP->ue_context.DRB_configList; + + struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; + DedicatedInfoNAS_t *dedicatedInfoNas = NULL; + /* for no gcc warnings */ + (void)dedicatedInfoNas; + + long *logicalchannelgroup_drb; +// int drb_identity_index=0; + + uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); //Transaction_id, + DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid]; + if (*DRB_configList2) { + free(*DRB_configList2); + } + //*DRB_configList = CALLOC(1, sizeof(*DRB_configList)); + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); + /* Initialize NAS list */ + dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); + + int e_rab_done=0; + + for ( i = 0 ; + i < ue_context_pP->ue_context.setup_e_rabs ; + i++){ + + if (e_rab_done >= ue_context_pP->ue_context.nb_of_e_rabs){ + break; + } + + // bypass the new and already configured erabs + if (ue_context_pP->ue_context.e_rab[i].status >= E_RAB_STATUS_DONE) { +// drb_identity_index++; + continue; + } + + DRB_config = CALLOC(1, sizeof(*DRB_config)); + + DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(DRB_config->eps_BearerIdentity) = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation + + // DRB_config->drb_Identity = 1 + drb_identity_index + e_rab_done;// + i ;// (DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + // 1 + drb_identiy_index; + DRB_config->drb_Identity = i+1; + + DRB_config->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(DRB_config->logicalChannelIdentity) = DRB_config->drb_Identity + 2; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); + DRB_config->rlc_Config = DRB_rlc_config; + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + DRB_config->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + + switch (ue_context_pP->ue_context.e_rab[i].param.qos.qci){ + /* + * type: realtime data with medium packer error rate + * action: swtich to RLC UM + */ + case 1: // 100ms, 10^-2, p2, GBR + case 2: // 150ms, 10^-3, p4, GBR + case 3: // 50ms, 10^-3, p3, GBR + case 4: // 300ms, 10^-6, p5 + case 7: // 100ms, 10^-3, p7, GBR + case 9: // 300ms, 10^-6, p9 case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR case 66: // 100ms, 10^-2, p2, non-mission critical voice , GBR // RLC @@ -1339,6 +2179,7 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co LOG_E(RRC,"not supported qci %d\n", ue_context_pP->ue_context.e_rab[i].param.qos.qci); ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_FAILED; ue_context_pP->ue_context.e_rab[i].xid = xid; + e_rab_done++; continue; } @@ -1377,31 +2218,301 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co *DRB_ul_SpecificParameters->logicalChannelGroup ); - e_rab_done++; - ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; - ue_context_pP->ue_context.e_rab[i].xid = xid; - + e_rab_done++; + ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; + ue_context_pP->ue_context.e_rab[i].xid = xid; + + { + if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { + dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t)); + memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); + ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); + LOG_I(RRC,"add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length, i); + } + else { + LOG_W(RRC,"Not received activate dedicated EPS bearer context request\n"); + } + /* TODO parameters yet to process ... */ + { + // ue_context_pP->ue_context.e_rab[i].param.qos; + // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; + // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + } + } + + } + + /* If list is empty free the list and reset the address */ + if (dedicatedInfoNASList != NULL) { + if (dedicatedInfoNASList->list.count == 0) { + free(dedicatedInfoNASList); + dedicatedInfoNASList = NULL; + LOG_W(RRC,"dedlicated NAS list is empty, free the list and reset the address\n"); + } + } else { + LOG_W(RRC,"dedlicated NAS list is empty\n"); + } + + memset(buffer, 0, RRC_BUF_SIZE); + + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + xid, + (SRB_ToAddModList_t*)NULL, + (DRB_ToAddModList_t*)*DRB_configList2, + (DRB_ToReleaseList_t*)NULL, // DRB2_list, + (struct SPS_Config*)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if defined(Rel10) || defined(Rel14) + , (SCellToAddMod_r10_t*)NULL +#endif + ); + + +#ifdef RRC_MSG_PRINT + LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n"); + for (i = 0; i < size; i++) { + LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]); + } + LOG_F(RRC,"\n"); + //////////////////////////////////////// +#endif + +#if defined(ENABLE_ITTI) + + /* Free all NAS PDUs */ + for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { + if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { + /* Free the NAS PDU buffer and invalidate it */ + free(ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer); + ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL; + } + } +#endif + + LOG_I(RRC, + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + + LOG_D(RRC, + "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", + ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); + + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" dedicated rrcConnectionReconfiguration UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); + + rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + + +} +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 + ) +//----------------------------------------------------------------------------- +{ + uint8_t buffer[RRC_BUF_SIZE]; + uint16_t size; + int i, j; + + struct DRB_ToAddMod *DRB_config = NULL; + struct RLC_Config *DRB_rlc_config = NULL; + struct PDCP_Config *DRB_pdcp_config = NULL; + struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; + struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; + struct LogicalChannelConfig *DRB_lchan_config = NULL; + struct LogicalChannelConfig__ul_SpecificParameters + *DRB_ul_SpecificParameters = NULL; + DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList; + DRB_ToAddModList_t* DRB_configList2 = NULL; + + struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; + DedicatedInfoNAS_t *dedicatedInfoNas = NULL; + /* for no gcc warnings */ + (void)dedicatedInfoNas; + + uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); // Transaction_id, + DRB_configList2 = CALLOC(1, sizeof(*DRB_configList2)); + /* Initialize NAS list */ + dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); + + for (i = 0; i < ue_context_pP->ue_context.nb_of_modify_e_rabs; i++) { + // bypass the new and already configured erabs + if (ue_context_pP->ue_context.modify_e_rab[i].status >= E_RAB_STATUS_DONE) { + ue_context_pP->ue_context.modify_e_rab[i].xid = xid; + continue; + } + + if (ue_context_pP->ue_context.modify_e_rab[i].cause != S1AP_CAUSE_NOTHING) { + // set xid of failure RAB + ue_context_pP->ue_context.modify_e_rab[i].xid = xid; + ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED; + continue; + } + + DRB_config = NULL; + // search exist DRB_config + for (j = 0; j < DRB_configList->list.count; j++) { + if((uint8_t)*(DRB_configList->list.array[j]->eps_BearerIdentity) == ue_context_pP->ue_context.modify_e_rab[i].param.e_rab_id) { + DRB_config = DRB_configList->list.array[j]; + break; + } + } + if (NULL == DRB_config) { + ue_context_pP->ue_context.modify_e_rab[i].xid = xid; + ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED; + // TODO use which cause + ue_context_pP->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_pP->ue_context.modify_e_rab[i].cause_value = 0;//S1ap_CauseRadioNetwork_unspecified; + ue_context_pP->ue_context.nb_of_failed_e_rabs++; + continue; + } + + DRB_rlc_config = DRB_config->rlc_Config; + + DRB_pdcp_config = DRB_config->pdcp_Config; + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + switch (ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci) { + /* + * type: realtime data with medium packer error rate + * action: swtich to RLC UM + */ + case 1: // 100ms, 10^-2, p2, GBR + case 2: // 150ms, 10^-3, p4, GBR + case 3: // 50ms, 10^-3, p3, GBR + case 4: // 300ms, 10^-6, p5 + case 7: // 100ms, 10^-3, p7, GBR + case 9: // 300ms, 10^-6, p9 + case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR + case 66: // 100ms, 10^-2, p2, non-mission critical voice , GBR + // RLC + DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; + // PDCP + if (DRB_pdcp_config->rlc_AM) { + free(DRB_pdcp_config->rlc_AM); + DRB_pdcp_config->rlc_AM = NULL; + } + if (DRB_pdcp_config->rlc_UM) { + free(DRB_pdcp_config->rlc_UM); + DRB_pdcp_config->rlc_UM = NULL; + } + PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + break; + + /* + * type: non-realtime data with low packer error rate + * action: swtich to RLC AM + */ + case 5: // 100ms, 10^-6, p1 , IMS signaling + case 6: // 300ms, 10^-6, p6 + case 8: // 300ms, 10^-6, p8 + case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority + case 70: // 200ms, 10^-6, p5.5, mision critical data + // RLC + DRB_rlc_config->present = RLC_Config_PR_am; + DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = T_PollRetransmit_ms50; + DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = PollPDU_p16; + DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = PollByte_kBinfinity; + DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t8; + DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = T_Reordering_ms35; + DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = T_StatusProhibit_ms25; + + // PDCP + if (DRB_pdcp_config->rlc_AM) { + free(DRB_pdcp_config->rlc_AM); + DRB_pdcp_config->rlc_AM = NULL; + } + if (DRB_pdcp_config->rlc_UM) { + free(DRB_pdcp_config->rlc_UM); + DRB_pdcp_config->rlc_UM = NULL; + } + PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); + DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; + PDCP_rlc_AM->statusReportRequired = FALSE; + + break; + default : + LOG_E(RRC, "not supported qci %d\n", ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci); + ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED; + ue_context_pP->ue_context.modify_e_rab[i].xid = xid; + ue_context_pP->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_pP->ue_context.modify_e_rab[i].cause_value = 37;//S1ap_CauseRadioNetwork_not_supported_QCI_value; + ue_context_pP->ue_context.nb_of_failed_e_rabs++; + continue; + } + + DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; + + DRB_lchan_config = DRB_config->logicalChannelConfig; + DRB_ul_SpecificParameters = DRB_lchan_config->ul_SpecificParameters; + + if (ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci < 9 ) + DRB_ul_SpecificParameters->priority = qci_to_priority[ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci-1] + 3; + else + DRB_ul_SpecificParameters->priority= 4; + + DRB_ul_SpecificParameters->prioritisedBitRate = LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + + DRB_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + ASN_SEQUENCE_ADD(&(DRB_configList2)->list, DRB_config); + + LOG_I(RRC, "EPS ID %ld, DRB ID %ld (index %d), QCI %d, priority %ld, LCID %ld LCGID %ld \n", + *DRB_config->eps_BearerIdentity, + DRB_config->drb_Identity, i, + ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci, + DRB_ul_SpecificParameters->priority, + *(DRB_config->logicalChannelIdentity), + *DRB_ul_SpecificParameters->logicalChannelGroup + ); + + //e_rab_done++; + ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_DONE; + ue_context_pP->ue_context.modify_e_rab[i].xid = xid; + { - if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { - dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t)); - memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf(dedicatedInfoNas, - (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, - ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); - ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); - LOG_I(RRC,"add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length, i); - } - else { - LOG_W(RRC,"Not received activate dedicated EPS bearer context request\n"); + if (ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer != NULL) { + dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t)); + memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char*)ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length); + ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); + LOG_I(RRC, "add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length, i); } - /* TODO parameters yet to process ... */ - { - // ue_context_pP->ue_context.e_rab[i].param.qos; - // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; - // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + else { + LOG_W(RRC, "Not received activate dedicated EPS bearer context request\n"); } } - } /* If list is empty free the list and reset the address */ @@ -1410,7 +2521,7 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co free(dedicatedInfoNASList); dedicatedInfoNASList = NULL; LOG_W(RRC,"dedlicated NAS list is empty, free the list and reset the address\n"); - } + } } else { LOG_W(RRC,"dedlicated NAS list is empty\n"); } @@ -1421,7 +2532,7 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co buffer, xid, (SRB_ToAddModList_t*)NULL, - (DRB_ToAddModList_t*)*DRB_configList2, + (DRB_ToAddModList_t*)DRB_configList2, (DRB_ToReleaseList_t*)NULL, // DRB2_list, (struct SPS_Config*)NULL, // *sps_Config, NULL, NULL, NULL, NULL,NULL, @@ -1430,10 +2541,10 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co (SL_CommConfig_r12_t*)NULL, (SL_DiscConfig_r12_t*)NULL #if defined(Rel10) || defined(Rel14) - , (SCellToAddMod_r10_t*)NULL + , (SCellToAddMod_r10_t*)NULL #endif - ); - + ); + #ifdef RRC_MSG_PRINT LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n"); @@ -1447,11 +2558,11 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co #if defined(ENABLE_ITTI) /* Free all NAS PDUs */ - for (i = 0; i < ue_context_pP->ue_context.nb_of_e_rabs; i++) { - if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { + for (i = 0; i < ue_context_pP->ue_context.nb_of_modify_e_rabs; i++) { + if (ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer != NULL) { /* Free the NAS PDU buffer and invalidate it */ - free(ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer); - ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL; + free(ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer); + ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer = NULL; } } #endif @@ -1483,7 +2594,127 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); + return 0; +} + +//----------------------------------------------------------------------------- +void +rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( 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 buffer[RRC_BUF_SIZE]; + int i; + uint16_t size = 0; + DRB_ToReleaseList_t** DRB_Release_configList2=NULL; + DRB_Identity_t* DRB_release; + struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; + + DRB_Release_configList2=&ue_context_pP->ue_context.DRB_Release_configList2[xid]; + if (*DRB_Release_configList2) { + free(*DRB_Release_configList2); + } + *DRB_Release_configList2 = CALLOC(1, sizeof(**DRB_Release_configList2)); + + for(i = 0; i < NB_RB_MAX; i++){ + if((ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_TORELEASE) && ue_context_pP->ue_context.e_rab[i].xid == xid){ + DRB_release = CALLOC(1, sizeof(DRB_Identity_t)); + *DRB_release = i+1; + ASN_SEQUENCE_ADD(&(*DRB_Release_configList2)->list, DRB_release); + //free(DRB_release); + } + } + + /* If list is empty free the list and reset the address */ + if (nas_length > 0) { + DedicatedInfoNAS_t *dedicatedInfoNas = NULL; + dedicatedInfoNASList = CALLOC(1, sizeof(struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); + dedicatedInfoNas = CALLOC(1, sizeof(DedicatedInfoNAS_t)); + memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char*)nas_buffer, + nas_length); + ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); + LOG_I(RRC,"add NAS info with size %d\n",nas_length); + } else { + LOG_W(RRC,"dedlicated NAS list is empty\n"); + } + + memset(buffer, 0, RRC_BUF_SIZE); + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + xid, + NULL, + NULL, + (DRB_ToReleaseList_t*)*DRB_Release_configList2, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if defined(Rel10) || defined(Rel14) + , (SCellToAddMod_r10_t*)NULL +#endif + ); + ue_context_pP->ue_context.e_rab_release_command_flag = 1; + +#ifdef RRC_MSG_PRINT + LOG_F(RRC,"[MSG] RRC Connection Reconfiguration\n"); + for (i = 0; i < size; i++) { + LOG_F(RRC,"%02x ", ((uint8_t*)buffer)[i]); + } + LOG_F(RRC,"\n"); + //////////////////////////////////////// +#endif + +#if defined(ENABLE_ITTI) + /* Free all NAS PDUs */ + if (nas_length > 0) { + /* Free the NAS PDU buffer and invalidate it */ + free(nas_buffer); + } +#endif + + LOG_I(RRC, + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + + LOG_D(RRC, + "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", + ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); + + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" dedicated rrcConnectionReconfiguration UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); + rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } #endif @@ -3527,9 +4758,12 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; + ue_context_pP->ue_context.ue_reestablishment_timer = 0; DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList2[xid]; SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid]; + DRB_ToReleaseList_t* DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; + 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)); @@ -3563,7 +4797,8 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP, SRB_configList, //NULL, //LG-RK 14/05/2014 SRB_configList, DRB_configList, - (DRB_ToReleaseList_t *) NULL, +// (DRB_ToReleaseList_t *) NULL, + DRB_Release_configList2, /*RC.rrc[ctxt_pP->module_id]->ciphering_algorithm[ue_mod_idP] | (RC.rrc[ctxt_pP->module_id]->integrity_algorithm[ue_mod_idP] << 4), */ @@ -3580,7 +4815,8 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP, SRB_configList, // NULL, //LG-RK 14/05/2014 SRB_configList, DRB_configList, - (DRB_ToReleaseList_t *) NULL +// (DRB_ToReleaseList_t *) NULL + DRB_Release_configList2 #if defined(Rel10) || defined(Rel14) , (PMCH_InfoList_r9_t *) NULL , 0, 0 @@ -3608,6 +4844,8 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( SRB_configList->list.array[i]->srb_Identity); } } + free(SRB_configList); + ue_context_pP->ue_context.SRB_configList2[xid] = NULL; } // Loop through DRBs and establish if necessary @@ -3657,12 +4895,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP->module_id + 1); // fourth octet if (oip_ifup == 0) { // interface is up --> send a config the DRB -# ifdef OAI_EMU - oai_emulation.info.oai_ifup[ctxt_pP->module_id] = 1; - dest_ip_offset = NB_eNB_INST; -# else dest_ip_offset = 8; -# endif 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, @@ -3679,10 +4912,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ue_module_id); } -# else -# ifdef OAI_EMU - oai_emulation.info.oai_ifup[ctxt_pP->module_id] = 1; -# endif # endif #endif @@ -3783,6 +5012,22 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( } } } + free(DRB_configList); + ue_context_pP->ue_context.DRB_configList2[xid] = NULL; + } + + if(DRB_Release_configList2 != NULL){ + for (i = 0; i < DRB_Release_configList2->list.count; i++) { + if (DRB_Release_configList2->list.array[i]) { + drb_id_p = DRB_Release_configList2->list.array[i]; + drb_id = *drb_id_p; + if (ue_context_pP->ue_context.DRB_active[drb_id] == 1) { + ue_context_pP->ue_context.DRB_active[drb_id] = 0; + } + } + } + free(DRB_Release_configList2); + ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL; } } @@ -3902,9 +5147,13 @@ rrc_eNB_generate_RRCConnectionSetup( RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); // activate release timer, if RRCSetupComplete not received after 10 frames, remove UE - ue_context_pP->ue_context.ue_release_timer=1; + //ue_context_pP->ue_context.ue_release_timer=1; // remove UE after 10 frames after RRCConnectionRelease is triggered - ue_context_pP->ue_context.ue_release_timer_thres=100; + //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; + // remove UE after 10 frames after RRCConnectionRelease is triggered + ue_context_pP->ue_context.ue_release_timer_thres=1000; } @@ -4027,6 +5276,10 @@ openair_rrc_eNB_init( , configuration #endif ); + for (int ue_id = 0; ue_id < NUMBER_OF_UE_MAX; ue_id++) { + RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0; + RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t*) malloc16(256); + } } rrc_init_global_param(); @@ -4166,7 +5419,7 @@ rrc_eNB_decode_ccch( T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); #ifdef RRC_MSG_PRINT - LOG_F(RRC,"[MSG] RRC Connection Reestablishement Request\n"); + LOG_F(RRC,"[MSG] RRC Connection Reestablishment Request\n"); for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) { LOG_F(RRC,"%02x ", ((uint8_t*)Srb_info->Rx_buffer.Payload)[i]); @@ -4201,9 +5454,158 @@ rrc_eNB_decode_ccch( } */ /* 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); +// 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; + + if (rrcConnectionReestablishmentRequest->ue_Identity.physCellId != RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + rrcConnectionReestablishmentRequest->ue_Identity.physCellId, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + } + LOG_D(RRC, "physCellId is %ld\n", rrcConnectionReestablishmentRequest->ue_Identity.physCellId); + + for (i = 0; i < rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.size; i++) { + LOG_D(RRC, "rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[%d] = %x\n", + i, rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[i]); + } + + if (rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size == 0 || + rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size > 2) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest c_RNTI range error, let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + + } + + c_rnti = BIT_STRING_to_uint16(&rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI); + LOG_D(RRC, "c_rnti is %x\n", c_rnti); + + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], c_rnti); + if (ue_context_p == NULL) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentRequest without UE context, let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + } + int UE_id = find_UE_id(ctxt_pP->module_id, c_rnti); + if(ue_context_p->ue_context.ue_reestablishment_timer > 0 || RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer > 0){ + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishment(Previous) don't complete, let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + } + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p); + ue_context_p->ue_context.ul_failure_timer = 0; + ue_context_p->ue_context.ue_release_timer = 0; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + ue_context_p->ue_context.ue_release_timer_s1 = 0; + ue_context_p->ue_context.ue_release_timer_rrc = 0; + + /* reset timers */ + ue_context_p->ue_context.ul_failure_timer = 0; + ue_context_p->ue_context.ue_release_timer = 0; + + // insert C-RNTI to map + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (reestablish_rnti_map[i][0] == 0) { + reestablish_rnti_map[i][0] = ctxt_pP->rnti; + reestablish_rnti_map[i][1] = c_rnti; + break; + } + } + 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 + + ue_context_p->ue_context.primaryCC_id = CC_id; + + //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; + Idx = DCCH; + // SRB1 + ue_context_p->ue_context.Srb1.Active = 1; + ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + + // SRB2: set it to go through SRB1 with id 1 (DCCH) + ue_context_p->ue_context.Srb2.Active = 1; + ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + + rrc_eNB_generate_RRCConnectionReestablishment(ctxt_pP, ue_context_p, CC_id); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + Idx); + + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_PDCP_ENB, + NULL, + 0, + MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti); + + rrc_pdcp_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, + (DRB_ToAddModList_t *) NULL, + (DRB_ToReleaseList_t*) NULL, + 0xff, + NULL, + NULL, + NULL +# if defined(Rel10) || defined(Rel14) + , (PMCH_InfoList_r9_t *) NULL +# endif + ,NULL); + + rrc_rlc_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, + (DRB_ToAddModList_t*) NULL, + (DRB_ToReleaseList_t*) NULL +# if defined(Rel10) || defined(Rel14) + , (PMCH_InfoList_r9_t *) NULL, + 0,0 +# endif + ); +#endif //NO_RRM + } break; case UL_CCCH_MessageType__c1_PR_rrcConnectionRequest: @@ -4252,6 +5654,7 @@ rrc_eNB_decode_ccch( /* if there is already a registered UE (with another RNTI) with this random_value, * the current one must be removed from MAC/PHY (zombie UE) */ +#if 0 if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", ctxt_pP->rnti, ue_context_p->ue_context.rnti, ctxt_pP->rnti); @@ -4261,6 +5664,13 @@ rrc_eNB_decode_ccch( } else { ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); } +#endif + if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { + LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", + ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti); + ue_context_p->ue_context.ul_failure_timer = 20000; + } + ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); } else if (InitialUE_Identity_PR_s_TMSI == rrcConnectionRequest->ue_Identity.present) { /* Save s-TMSI */ S_TMSI_t s_TMSI = rrcConnectionRequest->ue_Identity.choice.s_TMSI; @@ -4281,9 +5691,13 @@ rrc_eNB_decode_ccch( /* reset timers */ ue_context_p->ue_context.ul_failure_timer = 0; ue_context_p->ue_context.ue_release_timer = 0; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + ue_context_p->ue_context.ue_release_timer_s1 = 0; + ue_context_p->ue_context.ue_release_timer_rrc = 0; } else { LOG_I(RRC," S-TMSI doesn't exist, setting Initialue_identity_s_TMSI.m_tmsi to %p => %x\n",ue_context_p,m_tmsi); - ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY); +// ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY); + ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP,random_value); if (ue_context_p == NULL) LOG_E(RRC, "%s:%d:%s: rrc_eNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__); if (ue_context_p != NULL) { @@ -4329,6 +5743,7 @@ rrc_eNB_decode_ccch( #if defined(ENABLE_ITTI) ue_context_p->ue_context.establishment_cause = rrcConnectionRequest->establishmentCause; + ue_context_p->ue_context.reestablishment_cause = ReestablishmentCause_spare1; if (stmsi_received==0) LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE random UE identity (0x%" PRIx64 ") MME code %u TMSI %u cause %ld\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -4462,6 +5877,12 @@ rrc_eNB_decode_dcch( UE_EUTRA_Capability_t *UE_EUTRA_Capability = NULL; int i; struct rrc_eNB_ue_context_s* ue_context_p = NULL; +#if defined(ENABLE_ITTI) +# if defined(ENABLE_USE_MME) + MessageDef * msg_delete_tunnels_p = NULL; + uint8_t xid; +#endif +#endif int dedicated_DRB=0; @@ -4622,12 +6043,60 @@ rrc_eNB_decode_dcch( # if defined(ENABLE_USE_MME) if (EPC_MODE_ENABLED == 1) { 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); +// 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; + 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 { - rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, + if(ue_context_p->ue_context.reestablishment_cause == ReestablishmentCause_spare1){ + rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, ue_context_p); + } else { + ue_context_p->ue_context.reestablishment_cause = 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 // establish a dedicated bearer @@ -4670,6 +6139,53 @@ rrc_eNB_decode_dcch( PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), DCCH, sdu_sizeP); + { + int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0; + rnti_t reestablish_rnti = 0; + // select C-RNTI from map + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (reestablish_rnti_map[i][0] == ctxt_pP->rnti) { + reestablish_rnti = reestablish_rnti_map[i][1]; + ue_context_p = rrc_eNB_get_ue_context( + RC.rrc[ctxt_pP->module_id], + reestablish_rnti); + // clear currentC-RNTI from map + reestablish_rnti_map[i][0] = 0; + reestablish_rnti_map[i][1] = 0; + break; + } + } + LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n", + i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]); + + if (!ue_context_p) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReestablishmentComplete without UE context, falt\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + break; + } + + if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.present == + RRCConnectionReestablishmentComplete__criticalExtensions_PR_rrcConnectionReestablishmentComplete_r8) { + rrc_eNB_process_RRCConnectionReestablishmentComplete(ctxt_pP, reestablish_rnti, ue_context_p, + ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier, + &ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8); + +#if defined(FLEXRAN_AGENT_SB_IF) + //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future + if (mac_agent_registered[ctxt_pP->module_id]) { + agent_mac_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + ue_context_p->ue_id_rnti, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); + } +#endif + } + //ue_context_p->ue_context.ue_release_timer = 0; + ue_context_p->ue_context.ue_reestablishment_timer = 1; + // remove UE after 100 frames after RRCConnectionReestablishmentRelease is triggered + ue_context_p->ue_context.ue_reestablishment_timer_thres = 1000; + } break; case UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete: @@ -5166,13 +6682,22 @@ rrc_enb_task( break; case S1AP_PAGING_IND: - LOG_E(RRC, "[eNB %d] Received not yet implemented message %s\n", instance, msg_name_p); + LOG_D(RRC, "[eNB %d] Received Paging message from S1AP: %s\n", instance, msg_name_p); + rrc_eNB_process_PAGING_IND(msg_p, msg_name_p, instance); break; case S1AP_E_RAB_SETUP_REQ: rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(msg_p, msg_name_p, instance); LOG_D(RRC, "[eNB %d] Received the message %s\n", instance, msg_name_p); break; + + case S1AP_E_RAB_MODIFY_REQ: + rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(msg_p, msg_name_p, instance); + break; + + case S1AP_E_RAB_RELEASE_COMMAND: + rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(msg_p, msg_name_p, instance); + break; case S1AP_UE_CONTEXT_RELEASE_REQ: rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name_p, instance); @@ -5186,6 +6711,11 @@ rrc_enb_task( /* Nothing to do. Apparently everything is done in S1AP processing */ //LOG_I(RRC, "[eNB %d] Received message %s, not processed because procedure not synched\n", //instance, msg_name_p); + if (rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti) + && rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc > 0) { + rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc = + rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_thres_rrc; + } break; # endif @@ -5468,3 +6998,99 @@ SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( const protocol_ctxt_t* cons //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTxConfig_r12; return sl_DiscConfig; } +RRC_status_t +rrc_rx_tx( + protocol_ctxt_t* const ctxt_pP, + const int CC_id +) +//----------------------------------------------------------------------------- +{ + //uint8_t UE_id; + int32_t current_timestamp_ms, ref_timestamp_ms; + struct timeval ts; + struct rrc_eNB_ue_context_s *ue_context_p = NULL,*ue_to_be_removed = NULL; + +#ifdef LOCALIZATION + double estimated_distance; + protocol_ctxt_t ctxt; +#endif + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN); + + check_handovers(ctxt_pP); + // counetr, and get the value and aggregate + + // check for UL failure + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { + if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) { + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { + LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/20000\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.ul_failure_timer); + } + else { + LOG_I(RRC,"UE rnti %x failure timer %d/20000\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.ul_failure_timer); + } + } + if (ue_context_p->ue_context.ul_failure_timer>0) { + ue_context_p->ue_context.ul_failure_timer++; + if (ue_context_p->ue_context.ul_failure_timer >= 20000) { + // remove UE after 20 seconds after MAC has indicated UL failure + LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); + ue_to_be_removed = ue_context_p; + break; + } + } + if (ue_context_p->ue_context.ue_release_timer>0) { + ue_context_p->ue_context.ue_release_timer++; + if (ue_context_p->ue_context.ue_release_timer >= + ue_context_p->ue_context.ue_release_timer_thres) { + LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); + ue_to_be_removed = ue_context_p; + break; + } + } + } + if (ue_to_be_removed) + rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed); + +#ifdef RRC_LOCALIZATION + + /* for the localization, only primary CC_id might be relevant*/ + gettimeofday(&ts, NULL); + current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; + ref_timestamp_ms = RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms; + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { + ctxt = *ctxt_pP; + ctxt.rnti = ue_context_p->ue_context.rnti; + estimated_distance = rrc_get_estimated_ue_distance( + &ctxt, + CC_id, + RC.rrc[ctxt_pP->module_id]->loc_type); + + if ((current_timestamp_ms - ref_timestamp_ms > RC.rrc[ctxt_pP->module_id]->aggregation_period_ms) && + estimated_distance != -1) { + LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", + ctxt.rnti, + ctxt_pP->module_id, + current_timestamp_ms, + ctxt_pP->frame, + estimated_distance); + LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status); + push_front(&RC.rrc[ctxt_pP->module_id]->loc_list, + estimated_distance); + RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms; + } + } + +#endif + (void)ts; /* remove gcc warning "unused variable" */ + (void)ref_timestamp_ms; /* remove gcc warning "unused variable" */ + (void)current_timestamp_ms; /* remove gcc warning "unused variable" */ + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); + return (RRC_OK); +} + diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c index 9aca0491669e8b12899a738c6b8364ed4d853488..e5f2c5aaae1c469c4da1ffbcda1a41a0d7c264d4 100644 --- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c @@ -47,7 +47,8 @@ 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 gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP, + uint8_t *inde_list ) { rnti_t rnti; @@ -66,15 +67,18 @@ rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( 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[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[i+ue_context_p->ue_context.setup_e_rabs], - i+ue_context_p->ue_context.setup_e_rabs, + ue_context_p->ue_context.enb_gtp_teid[inde_list[i]], + inde_list[i], i, create_tunnel_resp_pP->eps_bearer_id[i], create_tunnel_resp_pP->enb_addr.length); diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.h b/openair2/RRC/LITE/rrc_eNB_GTPV1U.h index 981c3f8d3ba8b1379c0f997c5a89f09513036226..aedbdeac5e12bdd510ad5d286f3d82bf4cab83f2 100644 --- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.h +++ b/openair2/RRC/LITE/rrc_eNB_GTPV1U.h @@ -43,7 +43,8 @@ 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 gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP, + uint8_t *inde_list ); # endif diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 55adb217facd8ecaacde5e83e08fccd6bb5091ec..d2c0d0acbe8f7375370fdc3699af8f6d6be1ca86 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -342,6 +342,8 @@ static void process_eNB_security_key ( /* Saves the security key */ memcpy (ue_context_pP->ue_context.kenb, security_key_pP, SECURITY_KEY_LENGTH); + memset (ue_context_pP->ue_context.nh, 0, SECURITY_KEY_LENGTH); + ue_context_pP->ue_context.nh_ncc = -1; for (i = 0; i < 32; i++) { sprintf(&ascii_buffer[2 * i], "%02X", ue_context_pP->ue_context.kenb[i]); @@ -355,7 +357,7 @@ static void process_eNB_security_key ( //------------------------------------------------------------------------------ -static void +void rrc_pdcp_config_security( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, @@ -390,8 +392,10 @@ rrc_pdcp_config_security( ue_context_pP->ue_context.kenb, &kRRCint); +#if !defined(USRP_REC_PLAY) #define DEBUG_SECURITY 1 - +#endif + #if defined (DEBUG_SECURITY) #undef msg #define msg printf @@ -890,6 +894,7 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char //MessageDef *message_gtpv1u_p = NULL; gtpv1u_enb_create_tunnel_req_t create_tunnel_req; gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; + uint8_t inde_list[NB_RB_MAX - 3]={0}; struct rrc_eNB_ue_context_s* ue_context_p = NULL; protocol_ctxt_t ctxt; @@ -935,10 +940,12 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char memcpy(&create_tunnel_req.sgw_addr[i], &S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].sgw_addr, sizeof(transport_layer_addr_t)); + inde_list[create_tunnel_req.num_tunnels]= i; + create_tunnel_req.num_tunnels++; } create_tunnel_req.rnti = ue_context_p->ue_context.rnti; // warning put zero above - create_tunnel_req.num_tunnels = i; +// create_tunnel_req.num_tunnels = i; gtpv1u_create_s1u_tunnel( instance, @@ -947,7 +954,8 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( &ctxt, - &create_tunnel_resp); + &create_tunnel_resp, + &inde_list[0]); ue_context_p->ue_context.setup_e_rabs=ue_context_p->ue_context.nb_of_e_rabs; } @@ -1189,6 +1197,7 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch } return (-1); } else { + ue_context_p->ue_context.ue_release_timer_s1 = 0; PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); rrc_eNB_generate_RRCConnectionRelease(&ctxt, ue_context_p); /* @@ -1263,9 +1272,12 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name uint32_t eNB_ue_s1ap_id; gtpv1u_enb_create_tunnel_req_t create_tunnel_req; gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; + uint8_t inde_list[NB_RB_MAX - 3]={0}; struct rrc_eNB_ue_context_s* ue_context_p = NULL; protocol_ctxt_t ctxt; + uint8_t e_rab_done; + ue_initial_id = S1AP_E_RAB_SETUP_REQ (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_E_RAB_SETUP_REQ (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); @@ -1296,35 +1308,46 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); uint8_t nb_e_rabs_tosetup = S1AP_E_RAB_SETUP_REQ (msg_p).nb_e_rabs_tosetup; + e_rab_done = 0; // keep the previous bearer // the index for the rec for (i = 0; - i < nb_e_rabs_tosetup; + // i < nb_e_rabs_tosetup; + i < NB_RB_MAX - 3; // loop all e-rabs in e_rab[] i++) { - if (ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status == E_RAB_STATUS_DONE) - LOG_W(RRC,"E-RAB already configured, reconfiguring\n"); - ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status = E_RAB_STATUS_NEW; - ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].param = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[i]; - + //if (ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status == E_RAB_STATUS_DONE) + // LOG_W(RRC,"E-RAB already configured, reconfiguring\n"); + // check e-rab status, if e rab status is greater than E_RAB_STATUS_DONE, don't not config this one + if(ue_context_p->ue_context.e_rab[i].status >= E_RAB_STATUS_DONE) + continue; + //ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status = E_RAB_STATUS_NEW; + //ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].param = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[i]; + ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.e_rab[i].param = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done]; - create_tunnel_req.eps_bearer_id[i] = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[i].e_rab_id; - create_tunnel_req.sgw_S1u_teid[i] = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[i].gtp_teid; + create_tunnel_req.eps_bearer_id[e_rab_done] = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done].e_rab_id; + create_tunnel_req.sgw_S1u_teid[e_rab_done] = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done].gtp_teid; - memcpy(&create_tunnel_req.sgw_addr[i], - & S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[i].sgw_addr, + memcpy(&create_tunnel_req.sgw_addr[e_rab_done], + & S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done].sgw_addr, sizeof(transport_layer_addr_t)); LOG_I(RRC,"E_RAB setup REQ: local index %d teid %u, eps id %d \n", - i+ue_context_p->ue_context.setup_e_rabs, - create_tunnel_req.sgw_S1u_teid[i], + i, + create_tunnel_req.sgw_S1u_teid[e_rab_done], create_tunnel_req.eps_bearer_id[i] ); + inde_list[e_rab_done] = i; + e_rab_done++; + if(e_rab_done >= nb_e_rabs_tosetup){ + break; + } } ue_context_p->ue_context.nb_of_e_rabs=nb_e_rabs_tosetup; create_tunnel_req.rnti = ue_context_p->ue_context.rnti; // warning put zero above - create_tunnel_req.num_tunnels = i; + create_tunnel_req.num_tunnels = e_rab_done; // NN: not sure if we should create a new tunnel: need to check teid, etc. gtpv1u_create_s1u_tunnel( @@ -1334,7 +1357,8 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( &ctxt, - &create_tunnel_resp); + &create_tunnel_resp, + &inde_list[0]); ue_context_p->ue_context.setup_e_rabs+=nb_e_rabs_tosetup; @@ -1398,12 +1422,17 @@ int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t* const ctxt_pP, S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; e_rabs_failed++; // TODO add cause when it will be integrated - } - + } S1AP_E_RAB_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done; S1AP_E_RAB_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; // NN: add conditions for e_rabs_failed + } else { + /*debug info for the xid */ + LOG_D(RRC,"xid does not corresponds (context e_rab index %d, status %d, xid %d/%d) \n ", + e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, ue_context_pP->ue_context.e_rab[e_rab].xid); + } + } if ((e_rabs_done > 0) ){ LOG_I(RRC,"S1AP_E_RAB_SETUP_RESP: sending the message: nb_of_erabs %d, total e_rabs %d, index %d\n", @@ -1422,17 +1451,528 @@ int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t* const ctxt_pP, itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } + for(int i = 0; i < NB_RB_MAX; i++) { + ue_context_pP->ue_context.e_rab[i].xid = -1; + } + + return 0; +} +int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) +{ + int i; + uint16_t ue_initial_id; + uint32_t eNB_ue_s1ap_id; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + protocol_ctxt_t ctxt; + + ue_initial_id = S1AP_E_RAB_MODIFY_REQ (msg_p).ue_initial_id; + eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (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); + LOG_D(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d, nb_of_e_rabs %d\n", + instance, msg_name, ue_initial_id, eNB_ue_s1ap_id, S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify); + + if (ue_context_p == NULL) { + /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ + LOG_W(RRC, "[eNB %d] In S1AP_E_RAB_MODIFY_REQ: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id); + int nb_of_e_rabs_failed = 0; + MessageDef *msg_fail_p = NULL; + + msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP); + + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id; + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs = 0; + + for (nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; nb_of_e_rabs_failed++) { + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id = + S1AP_E_RAB_MODIFY_REQ (msg_p).e_rab_modify_params[nb_of_e_rabs_failed].e_rab_id; + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK; + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = 31;//S1ap_CauseRadioNetwork_multiple_E_RAB_ID_instances; + } + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; + + 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 = eNB_ue_s1ap_id; + + /* Save e RAB information for later */ + { + int j; + boolean_t is_treated[S1AP_MAX_E_RAB] = {FALSE}; + uint8_t nb_of_failed_e_rabs = 0; + + // keep the previous bearer + // the index for the rec + for (i = 0; i < S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; i++) { + if (is_treated[i] == TRUE) { + // already treated + continue; + } + for (j = i+1; j < S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; j++) { + if (is_treated[j] == FALSE && + S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) { + // handle multiple E-RAB ID + ue_context_p->ue_context.modify_e_rab[j].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.modify_e_rab[j].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id; + ue_context_p->ue_context.modify_e_rab[j].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_p->ue_context.modify_e_rab[j].cause_value = 31;//S1ap_CauseRadioNetwork_multiple_E_RAB_ID_instances; + nb_of_failed_e_rabs++; + is_treated[i] = TRUE; + is_treated[j] = TRUE; + } + } + if (is_treated[i] == TRUE) { + // handle multiple E-RAB ID + ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.modify_e_rab[i].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id; + ue_context_p->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_p->ue_context.modify_e_rab[i].cause_value = 31;//S1ap_CauseRadioNetwork_multiple_E_RAB_ID_instances; + nb_of_failed_e_rabs++; + continue; + } + + if (S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].nas_pdu.length == 0) { + // nas_pdu.length == 0 + ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.modify_e_rab[i].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id; + ue_context_p->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_NAS; + ue_context_p->ue_context.modify_e_rab[i].cause_value = 3;//S1ap_CauseNas_unspecified; + nb_of_failed_e_rabs++; + is_treated[i] = TRUE; + continue; + } + + for (j = 0; j < NB_RB_MAX-3; j++) { + if (ue_context_p->ue_context.e_rab[j].param.e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) { + if(ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_TORELEASE || ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_DONE){ + break; + } + ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_NOTHING; + ue_context_p->ue_context.modify_e_rab[i].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id; + ue_context_p->ue_context.modify_e_rab[i].param.qos = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].qos; + ue_context_p->ue_context.modify_e_rab[i].param.nas_pdu.length = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].nas_pdu.length; + ue_context_p->ue_context.modify_e_rab[i].param.nas_pdu.buffer = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].nas_pdu.buffer; + ue_context_p->ue_context.modify_e_rab[i].param.sgw_addr = ue_context_p->ue_context.e_rab[j].param.sgw_addr; + ue_context_p->ue_context.modify_e_rab[i].param.gtp_teid = ue_context_p->ue_context.e_rab[j].param.gtp_teid; + + is_treated[i] = TRUE; + break; + } + } + + if (is_treated[i] == FALSE) { + // handle Unknown E-RAB ID + ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.modify_e_rab[i].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id; + ue_context_p->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_p->ue_context.modify_e_rab[i].cause_value = 30;//S1ap_CauseRadioNetwork_unknown_E_RAB_ID; + nb_of_failed_e_rabs++; + is_treated[i] = TRUE; + } + } + + ue_context_p->ue_context.nb_of_modify_e_rabs = S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; + ue_context_p->ue_context.nb_of_failed_e_rabs = nb_of_failed_e_rabs; + } + + /* TODO parameters yet to process ... */ + { + // S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr; + } + + if (ue_context_p->ue_context.nb_of_failed_e_rabs < ue_context_p->ue_context.nb_of_modify_e_rabs) { + if (0 == rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(&ctxt, ue_context_p, 0)) { + return (0); + } + } + + { + int nb_of_e_rabs_failed = 0; + MessageDef *msg_fail_p = NULL; + + msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP); + + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id; +// S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs[S1AP_MAX_E_RAB]; + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs = 0; + + for(nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < ue_context_p->ue_context.nb_of_failed_e_rabs; nb_of_e_rabs_failed++) { + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id = + ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].param.e_rab_id; + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause = ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].cause; + } + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; + + itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); + + 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)); + + return (0); + } + } // end of ue_context_p != NULL +} + +/*NN: careful about the typcast of xid (long -> uint8_t*/ +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 ) { + + MessageDef *msg_p = NULL; + int i; + int e_rab; + int e_rabs_done = 0; + int e_rabs_failed = 0; + msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP); + S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; + + for (e_rab = 0; e_rab < ue_context_pP->ue_context.nb_of_modify_e_rabs; e_rab++) { + + /* only respond to the corresponding transaction */ + if (xid == ue_context_pP->ue_context.modify_e_rab[e_rab].xid) { + if (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_DONE) { + for (i = 0; i < ue_context_pP->ue_context.setup_e_rabs; i++) { + if (ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id == ue_context_pP->ue_context.e_rab[i].param.e_rab_id) { + // Update ue_context_pP->ue_context.e_rab + ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_ESTABLISHED; + ue_context_pP->ue_context.e_rab[i].param.qos = ue_context_pP->ue_context.modify_e_rab[e_rab].param.qos; + ue_context_pP->ue_context.e_rab[i].cause = S1AP_CAUSE_NOTHING; + break; + } + } + if (i < ue_context_pP->ue_context.setup_e_rabs) { + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id; + // TODO add other information from S1-U when it will be integrated + + LOG_D (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d, xid %d): nb_of_modify_e_rabs %d, e_rab_id %d \n ", + e_rabs_done, e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, + ue_context_pP->ue_context.nb_of_modify_e_rabs, + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id); + + e_rabs_done++; + } else { + // unexpected + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id; + + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK; + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause_value = 30;//S1ap_CauseRadioNetwork_unknown_E_RAB_ID; + + e_rabs_failed++; + } + } else if ((ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_NEW) || + (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)){ + LOG_D (RRC,"E-RAB is NEW or already ESTABLISHED\n"); + } else { /* status == E_RAB_STATUS_FAILED; */ + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id; + // add failure cause when defined + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause = ue_context_pP->ue_context.modify_e_rab[e_rab].cause; + + e_rabs_failed++; + } } else { - /*debug info for the xid */ + /*debug info for the xid */ LOG_D(RRC,"xid does not corresponds (context e_rab index %d, status %d, xid %d/%d) \n ", - e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, ue_context_pP->ue_context.e_rab[e_rab].xid); + e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, ue_context_pP->ue_context.modify_e_rab[e_rab].xid); } - } - + + + S1AP_E_RAB_MODIFY_RESP (msg_p).nb_of_e_rabs = e_rabs_done; + S1AP_E_RAB_MODIFY_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; + // NN: add conditions for e_rabs_failed + if (e_rabs_done > 0 || e_rabs_failed > 0) { + LOG_D(RRC,"S1AP_E_RAB_MODIFY_RESP: sending the message: nb_of_modify_e_rabs %d, total e_rabs %d, index %d\n", + ue_context_pP->ue_context.nb_of_modify_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_E_RAB_SETUP_RESP (msg_p), + sizeof(s1ap_e_rab_setup_resp_t), + MSC_AS_TIME_FMT" E_RAB_MODIFY_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_id_rnti, + S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id, + e_rabs_done, e_rabs_failed); + + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); + } + return 0; } +int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *msg_name, instance_t instance){ + uint16_t mme_ue_s1ap_id; + uint32_t eNB_ue_s1ap_id; + struct rrc_eNB_ue_context_s* ue_context_p = NULL; + protocol_ctxt_t ctxt; + e_rab_release_t e_rab_release_params[S1AP_MAX_E_RAB]; + uint8_t nb_e_rabs_torelease; + int erab; + int i; + uint8_t b_existed,is_existed; + uint8_t xid; + uint8_t e_rab_release_drb; + MessageDef * msg_delete_tunnels_p = NULL; + e_rab_release_drb = 0; + memcpy(&e_rab_release_params[0], &(S1AP_E_RAB_RELEASE_COMMAND (msg_p).e_rab_release_params[0]), sizeof(e_rab_release_t)*S1AP_MAX_E_RAB); + + mme_ue_s1ap_id = S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id; + eNB_ue_s1ap_id = S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id; + nb_e_rabs_torelease = S1AP_E_RAB_RELEASE_COMMAND (msg_p).nb_e_rabs_torelease; + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); + if(ue_context_p != NULL){ + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + + xid = rrc_eNB_get_next_transaction_identifier(ctxt.module_id); + + LOG_D(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d ENB_UE_S1AP_ID %d release_e_rabs %d \n", + mme_ue_s1ap_id, eNB_ue_s1ap_id,nb_e_rabs_torelease); + for(erab = 0; erab < nb_e_rabs_torelease; erab++){ + b_existed = 0; + is_existed = 0; + for ( i = erab-1; i>= 0; i--){ + if (e_rab_release_params[erab].e_rab_id == e_rab_release_params[i].e_rab_id){ + is_existed = 1; + break; + } + } + if(is_existed == 1){ + //e_rab_id is existed + continue; + } + for ( i = 0; i < NB_RB_MAX; i++){ + if (e_rab_release_params[erab].e_rab_id == ue_context_p->ue_context.e_rab[i].param.e_rab_id){ + b_existed = 1; + break; + } + } + if(b_existed == 0) { + //no e_rab_id + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 30; + ue_context_p->ue_context.nb_release_of_e_rabs++; + } else { + if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_FAILED){ + ue_context_p->ue_context.e_rab[i].xid = xid; + continue; + } else if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED){ + ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_TORELEASE; + ue_context_p->ue_context.e_rab[i].xid = xid; + e_rab_release_drb++; + }else{ + //e_rab_id status NG + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 0; + ue_context_p->ue_context.nb_release_of_e_rabs++; + } + } + } + if(e_rab_release_drb > 0) { + //RRCConnectionReconfiguration To UE + rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(&ctxt, ue_context_p, xid, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.length, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.buffer); + } else { + //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, instance, msg_delete_tunnels_p); + + //S1AP_E_RAB_RELEASE_RESPONSE + rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(&ctxt, ue_context_p, xid); + } + } else { + LOG_E(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d ENB_UE_S1AP_ID %d Error ue_context_p NULL \n", + S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id, S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id); + return -1; + } + + return 0; +} + + +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 e_rabs_released = 0; + MessageDef *msg_p; + + msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_RELEASE_RESPONSE); + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; + + for (int i = 0; i < NB_RB_MAX; i++){ + if (xid == ue_context_pP->ue_context.e_rab[i].xid){ + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rab_release[e_rabs_released].e_rab_id = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + e_rabs_released++; + //clear + memset(&ue_context_pP->ue_context.e_rab[i],0,sizeof(e_rab_param_t)); + } + } + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_released = e_rabs_released; + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_failed = ue_context_pP->ue_context.nb_release_of_e_rabs; + memcpy(&(S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rabs_failed[0]),&ue_context_pP->ue_context.e_rabs_release_failed[0],sizeof(e_rab_failed_t)*ue_context_pP->ue_context.nb_release_of_e_rabs); + + ue_context_pP->ue_context.setup_e_rabs -= e_rabs_released; + LOG_I(RRC,"S1AP-E-RAB RELEASE RESPONSE: ENB_UE_S1AP_ID %d release_e_rabs %d setup_e_rabs %d \n", + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id, + e_rabs_released, ue_context_pP->ue_context.setup_e_rabs); + + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); + //clear xid + for(int i = 0; i < NB_RB_MAX; i++) { + ue_context_pP->ue_context.e_rab[i].xid = -1; + } + //clear release e_rabs + ue_context_pP->ue_context.nb_release_of_e_rabs = 0; + memset(&ue_context_pP->ue_context.e_rabs_release_failed[0],0,sizeof(e_rab_failed_t)*S1AP_MAX_E_RAB); + return 0; +} + +/*------------------------------------------------------------------------------*/ +int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance_t instance) +{ + const unsigned int Ttab[4] = {32,64,128,256}; + uint8_t Tc,Tue; /* DRX cycle of UE */ + uint32_t pcch_nB; /* 4T, 2T, T, T/2, T/4, T/8, T/16, T/32 */ + uint32_t N; /* N: min(T,nB). total count of PF in one DRX cycle */ + uint32_t Ns = 0; /* Ns: max(1,nB/T) */ + uint8_t i_s; /* i_s = floor(UE_ID/N) mod Ns */ + 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]); + if (RC.rrc[instance]->configuration.mcc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc + && RC.rrc[instance]->configuration.mnc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc + && RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) { + for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type; + /* get nB from configuration */ + /* get default DRX cycle from configuration */ + Tc = (uint8_t)RC.rrc[instance]->configuration.pcch_defaultPagingCycle[CC_id]; + if (Tc < PCCH_Config__defaultPagingCycle_rf32 || Tc > PCCH_Config__defaultPagingCycle_rf256) { + continue; + } + Tue = (uint8_t)S1AP_PAGING_IND(msg_p).paging_drx; + /* 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.pcch_nB[CC_id]; + switch (pcch_nB) { + case PCCH_Config__nB_fourT: + Ns = 4; + break; + case PCCH_Config__nB_twoT: + Ns = 2; + break; + default: + Ns = 1; + break; + } + /* set N = min(T,nB) */ + if (pcch_nB > PCCH_Config__nB_oneT) { + switch (pcch_nB) { + case PCCH_Config__nB_halfT: + N = T/2; + break; + case PCCH_Config__nB_quarterT: + N = T/4; + break; + case PCCH_Config__nB_oneEighthT: + N = T/8; + break; + case PCCH_Config__nB_oneSixteenthT: + N = T/16; + break; + case PCCH_Config__nB_oneThirtySecondT: + N = T/32; + break; + default: + /* pcch_nB error */ + LOG_E(RRC, "[eNB %d] In S1AP_PAGING_IND: pcch_nB error (pcch_nB %d) \n", + instance, pcch_nB); + return (-1); + } + } else { + N = T; + } + + /* insert data to UE_PF_PO or update data in UE_PF_PO */ + pthread_mutex_lock(&ue_pf_po_mutex); + uint8_t i = 0; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value)) + || (UE_PF_PO[CC_id][i].enable_flag != TRUE)) { + /* set T = min(Tc,Tue) */ + UE_PF_PO[CC_id][i].T = T; + /* set UE_ID */ + UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)S1AP_PAGING_IND(msg_p).ue_index_value; + /* calculate PF and PO */ + /* set PF_min : SFN mod T = (T div N)*(UE_ID mod N) */ + UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N); + /* set PO */ + /* i_s = floor(UE_ID/N) mod Ns */ + i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns); + if (Ns == 1) { + UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? 9 : 0; + } else if (Ns==2) { + UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4+(5*i_s)) : (5*i_s); + } else if (Ns==4) { + UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1))); + } + if (UE_PF_PO[CC_id][i].enable_flag == TRUE) { + //paging exist UE log + LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Update exist UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO); + } else { + /* set enable_flag */ + UE_PF_PO[CC_id][i].enable_flag = TRUE; + //paging new UE log + LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Insert a new UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO); + } + break; + } + } + pthread_mutex_unlock(&ue_pf_po_mutex); + + uint32_t length; + uint8_t buffer[RRC_BUF_SIZE]; + uint8_t *message_buffer; + /* Transfer data to PDCP */ + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_PCCH_DATA_REQ); + /* Create message for PDCP (DLInformationTransfer_t) */ + length = do_Paging (instance, + buffer, + S1AP_PAGING_IND(msg_p).ue_paging_identity, + S1AP_PAGING_IND(msg_p).cn_domain); + message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length); + /* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */ + memcpy (message_buffer, buffer, length); + RRC_PCCH_DATA_REQ (message_p).sdu_size = length; + RRC_PCCH_DATA_REQ (message_p).sdu_p = message_buffer; + RRC_PCCH_DATA_REQ (message_p).mode = PDCP_TRANSMISSION_MODE_TRANSPARENT; /* not used */ + RRC_PCCH_DATA_REQ (message_p).rnti = P_RNTI; + RRC_PCCH_DATA_REQ (message_p).ue_index = i; + RRC_PCCH_DATA_REQ (message_p).CC_id = CC_id; + LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length); + itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p); + } + } + } + + return (0); +} # endif /* defined(ENABLE_ITTI) */ #endif /* defined(ENABLE_USE_MME) */ diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.h b/openair2/RRC/LITE/rrc_eNB_S1AP.h index 6b2de919bd44403e4e3ae99229c41e4d47668fed..a924caf254c664159089e1bcf27579bbbb687b67 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.h +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.h @@ -79,6 +79,11 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co 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 + ); /*! \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. @@ -186,6 +191,24 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name */ 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. + *\param msg_p Message received by RRC. + *\param msg_name Message name. + *\param instance Message instance. + *\return 0 when successful, -1 if the UE index can not be retrieved. + */ +int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance); + +/*! \fn 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 ) + *\brief send a S1AP dedicated E_RAB modify response + *\param ctxt_pP contxt infirmation + *\param e_contxt_pP ue specific context at the eNB + *\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 ); + /*! \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. *\param msg_p Message received by RRC. @@ -213,6 +236,39 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char * */ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const char *msg_name, instance_t instance); +/*! \fn rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance_t instance) + *\brief process a S1AP_PAGING_IND message received from S1AP. + *\param msg_p Message received by RRC. + *\param msg_name Message name. + *\param instance Message instance. + *\return 0 when successful, -1 if the UE index can not be retrieved. + */ +int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance_t instance); + +void +rrc_pdcp_config_security( + 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); + *\brief process a S1AP dedicated E_RAB release command message received from S1AP. + *\param msg_p Message received by RRC. + *\param msg_name Message name. + *\param instance Message instance. + *\return 0 when successful, -1 if the UE index can not be retrieved. + */ +int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *msg_name, instance_t instance); + +/*! \fn 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 ) + *\brief send a S1AP dedicated E_RAB release response + *\param ctxt_pP contxt infirmation + *\param e_contxt_pP ue specific context at the eNB + *\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 ); + # endif # endif /* defined(ENABLE_USE_MME) */ #endif /* RRC_ENB_S1AP_H_ */ diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.c b/openair2/RRC/LITE/rrc_eNB_UE_context.c index 78f85a6da2cffeac00853e13964abcf3ae6bff20..0ae3d7ca151fbed5b997f51ac09b5bde03f1e0c6 100644 --- a/openair2/RRC/LITE/rrc_eNB_UE_context.c +++ b/openair2/RRC/LITE/rrc_eNB_UE_context.c @@ -136,6 +136,10 @@ rrc_eNB_allocate_new_UE_context( memset(new_p, 0, sizeof(struct rrc_eNB_ue_context_s)); new_p->local_uid = uid_linear_allocator_new(rrc_instance_pP); + for(int i = 0; i < NB_RB_MAX; i++) { + new_p->ue_context.e_rab[i].xid = -1; + new_p->ue_context.modify_e_rab[i].xid = -1; + } return new_p; } @@ -151,7 +155,21 @@ rrc_eNB_get_ue_context( memset(&temp, 0, sizeof(struct rrc_eNB_ue_context_s)); /* eNB ue rrc id = 24 bits wide */ temp.ue_id_rnti = rntiP; +#if 0 return RB_FIND(rrc_ue_tree_s, &rrc_instance_pP->rrc_ue_head, &temp); +#endif + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + ue_context_p = RB_FIND(rrc_ue_tree_s, &rrc_instance_pP->rrc_ue_head, &temp); + if ( ue_context_p != NULL) { + return ue_context_p; + } else { + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(rrc_instance_pP->rrc_ue_head)) { + if (ue_context_p->ue_context.rnti == rntiP) { + return ue_context_p; + } + } + return NULL; + } } @@ -184,6 +202,7 @@ void rrc_eNB_remove_ue_context( rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_pP); uid_linear_allocator_free(rrc_instance_pP, ue_context_pP->local_uid); free(ue_context_pP); + rrc_instance_pP->Nb_ue --; LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Removed UE context\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); diff --git a/openair2/RRC/LITE/rrc_rrm_interface.c b/openair2/RRC/LITE/rrc_rrm_interface.c index 822ce554af389f51022e353738c7f5a4b40eaafb..9f4270be8941487cc8ffe55bd0f08f1a316a1865 100644 --- a/openair2/RRC/LITE/rrc_rrm_interface.c +++ b/openair2/RRC/LITE/rrc_rrm_interface.c @@ -292,10 +292,5 @@ int send_msg_fifo(int *s, msg_t *fmsg) int send_msg(void *s, msg_t *smsg) { -#ifdef USER_MODE send_msg_sock((sock_rrm_t *)s, smsg); -#else - send_msg_fifo((int *)s,smsg); -#endif - } diff --git a/openair2/RRC/LITE/rrc_rrm_interface.h b/openair2/RRC/LITE/rrc_rrm_interface.h index d204ab2db60b8749bfbf3d951a92d32380989edf..0880859a59d6cd2c91ab4e339b4039bb71322227 100644 --- a/openair2/RRC/LITE/rrc_rrm_interface.h +++ b/openair2/RRC/LITE/rrc_rrm_interface.h @@ -101,8 +101,6 @@ extern "C" { #define START_MSG_PUSU 0xCC -#ifdef USER_MODE - #include <sys/socket.h> #include <sys/un.h> @@ -128,16 +126,6 @@ char *recv_msg( sock_rrm_t *s ) ; } #endif -#else //USER_MODE -#include <rtai_fifos.h> - -#define RRC2RRM_FIFO 14 -#define RRM2RRC_FIFO 15 -int send_msg_fifo(int *s ,msg_t *msg ) ; -#endif //USER_MODE - int send_msg(void *, msg_t *); - - #endif diff --git a/openair2/RRC/LITE/rrm_2_rrc_msg.c b/openair2/RRC/LITE/rrm_2_rrc_msg.c index 3ef0bc2e0a7ecec6ce4692bbbfa52d08094d774f..3ed3a9d8594a3f4fbc6f583b0a08d7531cda551d 100644 --- a/openair2/RRC/LITE/rrm_2_rrc_msg.c +++ b/openair2/RRC/LITE/rrm_2_rrc_msg.c @@ -65,17 +65,12 @@ void fn_rrc (void) /******************************************************************************/ msg_head_t *Header ; -#ifdef USER_MODE char *Data; -#else - int bytes_read; -#endif L2_ID Mac_id; while(1) { -#ifdef USER_MODE Header = (msg_head_t *) recv_msg(&S_rrc) ; if(Header==NULL) { @@ -83,52 +78,9 @@ void fn_rrc (void) } Data_to_read=Header->size; -#else - - if(Header_read_idx < Header_size) { - bytes_read = rtf_get (RRM2RRC_FIFO,&Header_buf[Header_read_idx],Header_size-Header_read_idx); - - if(bytes_read >0) { - msg("RRC: GET FIFOS RETURNS %d bytes, header %d\n",bytes_read,Header_read_idx); - } - - Header_read_idx+=bytes_read; - - if(Header_read_idx == Header_size) { - Header = (msg_head_t *) Header_buf; - Data_to_read=Header->size; - msg("RRC: Header read completed, data size %d\n",Data_to_read); - } - //msg("[fn_rrc]TTI %d: rcv_msg return Null\n",Rrc_xface->Frame_index); - else { - break; - } - } - -#endif if (Data_to_read > 0 ) { -#ifdef USER_MODE Data = (char *) (Header +1) ; -#else - bytes_read = rtf_get (RRM2RRC_FIFO,&Data[Data_read_idx],Data_to_read); - - if(bytes_read >0) { - msg("RRC: GET FIFOS RETURNS %d bytes, Data_to_read %d\n",bytes_read,Data_to_read); - } - - Data_to_read-=bytes_read; - Data_read_idx+=bytes_read; - - if(Data_to_read > 0 ) { - break; - } - - msg("RRC: DATA read completed, data size %d\n",Data_to_read); - Header_read_idx=0; - Data_read_idx=0; - Data_to_read=0; -#endif } msg("Got MSG of Type %d on Inst %d\n",Header->msg_type,Header->inst); diff --git a/openair2/RRC/LITE/utils.c b/openair2/RRC/LITE/utils.c index fd37fdf65cfb0e9985022aeeaba4ed0c1f9c4518..bbf97046bf5a0baba7f8b1eda2f866076610863f 100644 --- a/openair2/RRC/LITE/utils.c +++ b/openair2/RRC/LITE/utils.c @@ -29,25 +29,8 @@ ________________________________________________________________*/ -//#include "openair_types.h" #include "defs.h" #include "extern.h" -//#include "openair_proto.h" - - -#ifndef USER_MODE -char bcmp(void *x, void *y,int Size ) -{ - unsigned char i; - - for(i=0; i<Size; i++) - if(*(char*)(x+i)!= *(char*)(y+i)) { - return 1; - } - - return 0; -} -#endif //------------------------------------------------------------------------------------------------------------------// @@ -63,7 +46,6 @@ uint16_t find_free_dtch_position(uint8_t Mod_id, uint16_t UE_CH_index) for(i=j; i<NB_RAB_MAX; i++) { //first RAB IS BROADCAST DTCH - //msg("i=%d\n",i); if(CH_rrc_inst[Mod_id].Rab[i][UE_CH_index].Active==0) { return( i); } @@ -130,11 +112,7 @@ uint8_t find_rrc_info_index(uint8_t Mod_id,uint8_t CH_id) if(Rrc_inst[Mod_id].Rrc_info[i].Info.UE_info.CH_id == CH_id) return i; } error_msg("[OPENAIR][RRC] RRC_INFO_INDEX: FATAL ERROR: Not yet Pre_Synchronized with CH ???%d\n",CH_id); - #ifndef USER_MODE - // mac_xface->macphy_exit(); - #else exit(-1); - #endif */ } /* diff --git a/openair2/RRC/LITE/vars.h b/openair2/RRC/LITE/vars.h index fbf3ae1dff944696e7e1ef745e23315aaec83971..e3bab5f5eb48aa577400a62d92d1397ab2ed25cf 100644 --- a/openair2/RRC/LITE/vars.h +++ b/openair2/RRC/LITE/vars.h @@ -36,6 +36,8 @@ #include "COMMON/mac_rrc_primitives.h" #include "LAYER2/MAC/defs.h" +UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +pthread_mutex_t ue_pf_po_mutex; UE_RRC_INST *UE_rrc_inst; #include "LAYER2/MAC/extern.h" #define MAX_U32 0xFFFFFFFF @@ -236,4 +238,10 @@ float RSRQ_meas_mapping[35] = { -2 }; +// only used for RRC connection re-establishment procedure TS36.331 5.3.7 +// [0]: current C-RNTI, [1]: prior C-RNTI +// insert one when eNB received RRCConnectionReestablishmentRequest message +// delete one when eNB received RRCConnectionReestablishmentComplete message +uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2] = {{0}}; + #endif diff --git a/openair2/UTIL/LISTS/list2.c b/openair2/UTIL/LISTS/list2.c index 875f5e2d2fcbf4a69c6876e11efc521d89845940..3f0a59df53be4ca3548207f22a2c015bb772f4bb 100644 --- a/openair2/UTIL/LISTS/list2.c +++ b/openair2/UTIL/LISTS/list2.c @@ -38,11 +38,7 @@ ***************************************************************************/ #define LIST2_C #include "list.h" -#ifdef USER_MODE #include "assertions.h" -#else -#define NULL 0 -#endif #include <string.h> @@ -336,9 +332,7 @@ list2_display (list2_t * listP) nb_elements++; } msg (" found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements); - #ifdef USER_MODE AssertFatal(nb_elements == listP->nb_elements, "Bad count of elements %d != %d", nb_elements, listP->nb_elements); - #endif } }*/ } diff --git a/openair2/UTIL/LOG/log.c b/openair2/UTIL/LOG/log.c index f94d530b0cfa6a326552d6f839e64bfad8b95a6d..d4794d642bf2f21876ee96b8ab894bc950de19a3 100644 --- a/openair2/UTIL/LOG/log.c +++ b/openair2/UTIL/LOG/log.c @@ -42,17 +42,8 @@ # include "intertask_interface.h" #endif -#ifdef USER_MODE # include <pthread.h> # include <string.h> -#endif -#ifdef RTAI -# include <rtai.h> -# include <rtai_fifos.h> -# define FIFO_PRINTF_MAX_STRING_SIZE 1000 -# define FIFO_PRINTF_NO 62 -# define FIFO_PRINTF_SIZE 65536 -#endif #include "common/config/config_userapi.h" // main log variables log_t *g_log; @@ -92,9 +83,7 @@ int log_list_head = 0; int log_shutdown; #endif -#ifndef RTAI static int gfd; -#endif static char *log_level_highlight_start[] = {LOG_RED, LOG_RED, LOG_RED, LOG_RED, LOG_ORANGE, LOG_BLUE, "", ""}; /*!< \brief Optional start-format strings for highlighting */ static char *log_level_highlight_end[] = {LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET,LOG_RESET, "",""}; /*!< \brief Optional end-format strings for highlighting */ @@ -164,24 +153,12 @@ void log_getconfig(log_t *g_log) { int logInit (void) { -#ifdef USER_MODE -#ifndef RTAI int i; -#endif g_log = calloc(1, sizeof(log_t)); -#else - g_log = kmalloc(sizeof(log_t), GFP_KERNEL); -#endif - if (g_log == NULL) { -#ifdef USER_MODE perror ("cannot allocated memory for log generation module \n"); exit(EXIT_FAILURE); -#else - printk("cannot allocated memory for log generation module \n"); - return(-1); -#endif } @@ -485,7 +462,6 @@ int logInit (void) g_log->level = LOG_TRACE; g_log->flag = LOG_LOW; -#ifndef RTAI g_log->config.remote_ip = 0; g_log->config.remote_level = LOG_EMERG; g_log->config.facility = LOG_LOCAL7; @@ -513,22 +489,344 @@ int logInit (void) } } + printf("log init done\n"); + + return 0; +} + +void nfapi_log(char *file, char *func, int line, int comp, int level, const char* format, va_list args) +{ + //logRecord_mt(file,func,line, pthread_self(), comp, level, format, ##args) + int len = 0; + log_component_t *c; + char *log_start; + char *log_end; + /* The main difference with the version above is the use of this local log_buffer. + * The other difference is the return value of snprintf which was not used + * correctly. It was not a big problem because in practice MAX_LOG_TOTAL is + * big enough so that the buffer is never full. + */ + char log_buffer[MAX_LOG_TOTAL]; + + /* for no gcc warnings */ + (void)log_start; + (void)log_end; + + c = &g_log->log_component[comp]; + + // do not apply filtering for LOG_F + // only log messages which are enabled and are below the global log level and component's level threshold + if ((level != LOG_FILE) && ((level > c->level) || (level > g_log->level))) { + /* if ((level != LOG_FILE) && + ((level > c->level) || + (level > g_log->level) || + ( c->level > g_log->level))) { + */ + return; + } + + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LOG_RECORD, VCD_FUNCTION_IN); + + // adjust syslog level for TRACE messages + if (g_log->syslog) { + if (g_log->level > LOG_DEBUG) { + g_log->level = LOG_DEBUG; + } + } + + // make sure that for log trace the extra info is only printed once, reset when the level changes + if ((level == LOG_FILE) || (c->flag == LOG_NONE) || (level == LOG_TRACE)) { + log_start = log_buffer; + len = vsnprintf(log_buffer, MAX_LOG_TOTAL, format, args); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + log_end = log_buffer + len; + } else { + if ( (g_log->flag & FLAG_COLOR) || (c->flag & FLAG_COLOR) ) { + len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "%s", + log_level_highlight_start[level]); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + + log_start = log_buffer + len; + + if ( (g_log->flag & FLAG_COMP) || (c->flag & FLAG_COMP) ) { + len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s]", + g_log->log_component[comp].name); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + + if ( (g_log->flag & FLAG_LEVEL) || (c->flag & FLAG_LEVEL) ) { + len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s]", + g_log->level2string[level]); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + + if ( (g_log->flag & FLAG_THREAD) || (c->flag & FLAG_THREAD) ) { +# define THREAD_NAME_LEN 128 + char threadname[THREAD_NAME_LEN]; + if (pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN) != 0) + { + perror("pthread_getname_np : "); + } else { + len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s]", threadname); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } +# undef THREAD_NAME_LEN + } + + if ( (g_log->flag & FLAG_FUNCT) || (c->flag & FLAG_FUNCT) ) { + len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s] ", + func); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + + if ( (g_log->flag & FLAG_FILE_LINE) || (c->flag & FLAG_FILE_LINE) ) { + len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s:%d]", + file, line); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + + //len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%08lx]", thread_id); + //if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + + len += vsnprintf(&log_buffer[len], MAX_LOG_TOTAL - len, format, args); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + log_end = log_buffer + len; + + if ( (g_log->flag & FLAG_COLOR) || (c->flag & FLAG_COLOR) ) { + len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "%s", + log_level_highlight_end[level]); + if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL; + } + } + + va_end(args); + + // OAI printf compatibility + if ((g_log->onlinelog == 1) && (level != LOG_FILE)) +#ifdef RTAI + if (len > MAX_LOG_TOTAL) { + rt_printk ("[OPENAIR] FIFO_PRINTF WROTE OUTSIDE ITS MEMORY BOUNDARY : ERRORS WILL OCCUR\n"); + } + + if (len > 0) { + rtf_put (FIFO_PRINTF_NO, log_buffer, len); + } + #else - g_log->syslog = 0; - g_log->filelog = 0; - rtf_create (FIFO_PRINTF_NO, FIFO_PRINTF_SIZE); + fwrite(log_buffer, len, 1, stdout); #endif -#ifdef USER_MODE - printf("log init done\n"); +#ifndef RTAI + + if (g_log->syslog) { + syslog(g_log->level, "%s", log_buffer); + } + + if (g_log->filelog) { + if (write(gfd, log_buffer, len) < len) { + // TODO assert ? + } + } + + if ((g_log->log_component[comp].filelog) && (level == LOG_FILE)) { + if (write(g_log->log_component[comp].fd, log_buffer, len) < len) { + // TODO assert ? + } + } + #else - printk("log init done\n"); + + // online print messges + if ((g_log->log_component[comp].filelog) && (level == LOG_FILE)) { + printf(log_buffer); + } + #endif - return 0; +#if defined(ENABLE_ITTI) + + if (level <= LOG_DEBUG) { + task_id_t origin_task_id = TASK_UNKNOWN; + MessagesIds messages_id; + MessageDef *message_p; + size_t message_string_size; + char *message_msg_p; + + message_string_size = log_end - log_start; + +#if !defined(DISABLE_ITTI_DETECT_SUB_TASK_ID) + + /* Try to identify sub task ID from log information (comp, log_instance_type) */ + switch (comp) { + case PHY: + switch (log_instance_type) { + case LOG_INSTANCE_ENB: + origin_task_id = TASK_PHY_ENB; + break; + + case LOG_INSTANCE_UE: + origin_task_id = TASK_PHY_UE; + break; + + default: + break; + } + + break; + + case MAC: + switch (log_instance_type) { + case LOG_INSTANCE_ENB: + origin_task_id = TASK_MAC_ENB; + break; + + case LOG_INSTANCE_UE: + origin_task_id = TASK_MAC_UE; + + default: + break; + } + + break; + + case RLC: + switch (log_instance_type) { + case LOG_INSTANCE_ENB: + origin_task_id = TASK_RLC_ENB; + break; + + case LOG_INSTANCE_UE: + origin_task_id = TASK_RLC_UE; + + default: + break; + } + + break; + + case PDCP: + switch (log_instance_type) { + case LOG_INSTANCE_ENB: + origin_task_id = TASK_PDCP_ENB; + break; + + case LOG_INSTANCE_UE: + origin_task_id = TASK_PDCP_UE; + + default: + break; + } + + break; + + default: + break; + } + +#endif + + switch (level) { + case LOG_EMERG: + case LOG_ALERT: + case LOG_CRIT: + case LOG_ERR: + messages_id = ERROR_LOG; + break; + + case LOG_WARNING: + messages_id = WARNING_LOG; + break; + + case LOG_NOTICE: + messages_id = NOTICE_LOG; + break; + + case LOG_INFO: + messages_id = INFO_LOG; + break; + + default: + messages_id = DEBUG_LOG; + break; + } + + message_p = itti_alloc_new_message_sized(origin_task_id, messages_id, message_string_size); + + switch (level) { + case LOG_EMERG: + case LOG_ALERT: + case LOG_CRIT: + case LOG_ERR: + message_msg_p = (char *) &message_p->ittiMsg.error_log; + break; + + case LOG_WARNING: + message_msg_p = (char *) &message_p->ittiMsg.warning_log; + break; + + case LOG_NOTICE: + message_msg_p = (char *) &message_p->ittiMsg.notice_log; + break; + + case LOG_INFO: + message_msg_p = (char *) &message_p->ittiMsg.info_log; + break; + + default: + message_msg_p = (char *) &message_p->ittiMsg.debug_log; + break; + } + + memcpy(message_msg_p, log_start, message_string_size); + + itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p); + } + +#endif +#if 0 + LOG_params log_params; + int len; + + len = vsnprintf(log_params.l_buff_info, MAX_LOG_INFO-1, format, args); + + //2 first parameters must be passed as 'const' to the thread function + log_params.file = strdup(file); + log_params.func = strdup(func); + log_params.line = line; + log_params.comp = PHY;//comp; + log_params.level = 6; // INFO - level; + log_params.format = format; + log_params.len = len; + + if (pthread_mutex_lock(&log_lock) != 0) { + return; + } + + log_list_tail++; + log_list[log_list_tail - 1] = log_params; + + if (log_list_tail >= 1000) { + log_list_tail = 0; + } + + if (log_list_nb_elements < 1000) { + log_list_nb_elements++; + } + + if(pthread_cond_signal(&log_notify) != 0) { + pthread_mutex_unlock(&log_lock); + return; + } + + if(pthread_mutex_unlock(&log_lock) != 0) { + return; + } + +#endif } -void nfapi_log(char *file, char *func, int line, int comp, int level, const char* format, va_list args) +/*void nfapi_log(char *file, char *func, int line, int comp, int level, const char* format, va_list args) { LOG_params log_params; int len; @@ -568,7 +866,7 @@ void nfapi_log(char *file, char *func, int line, int comp, int level, const char return; } -} +}*/ //log record: add to a list void logRecord(const char *file, const char *func, int line, pthread_t thread_id, int comp, @@ -695,23 +993,9 @@ void logRecord_thread_safe(const char *file, const char *func, // OAI printf compatibility if ((g_log->onlinelog == 1) && (level != LOG_FILE)) { -#ifdef RTAI - - if (len > MAX_LOG_TOTAL) { - rt_printk ("[OPENAIR] FIFO_PRINTF WROTE OUTSIDE ITS MEMORY BOUNDARY : ERRORS WILL OCCUR\n"); - } - - if (len > 0) { - rtf_put (FIFO_PRINTF_NO, log_buffer, len); - } - -#else fprintf(stdout, "%s", log_buffer); -#endif } -#ifndef RTAI - if (g_log->syslog) { syslog(g_log->level, "%s", log_buffer); } @@ -728,8 +1012,6 @@ void logRecord_thread_safe(const char *file, const char *func, } } -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LOG_RECORD, VCD_FUNCTION_OUT); } @@ -880,20 +1162,7 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, // OAI printf compatibility if ((g_log->onlinelog == 1) && (level != LOG_FILE)) -#ifdef RTAI - if (len > MAX_LOG_TOTAL) { - rt_printk ("[OPENAIR] FIFO_PRINTF WROTE OUTSIDE ITS MEMORY BOUNDARY : ERRORS WILL OCCUR\n"); - } - - if (len > 0) { - rtf_put (FIFO_PRINTF_NO, c->log_buffer, len); - } - -#else fwrite(c->log_buffer, len, 1, stdout); -#endif - -#ifndef RTAI if (g_log->syslog) { syslog(g_log->level, "%s", c->log_buffer); @@ -911,15 +1180,6 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, } } -#else - - // online print messges - if ((g_log->log_component[comp].filelog) && (level == LOG_FILE)) { - printf(c->log_buffer); - } - -#endif - #if defined(ENABLE_ITTI) if (level <= LOG_DEBUG) { @@ -1181,20 +1441,7 @@ void logRecord_mt(const char *file, const char *func, int line, // OAI printf compatibility if ((g_log->onlinelog == 1) && (level != LOG_FILE)) -#ifdef RTAI - if (len > MAX_LOG_TOTAL) { - rt_printk ("[OPENAIR] FIFO_PRINTF WROTE OUTSIDE ITS MEMORY BOUNDARY : ERRORS WILL OCCUR\n"); - } - - if (len > 0) { - rtf_put (FIFO_PRINTF_NO, log_buffer, len); - } - -#else - fwrite(log_buffer, len, 1, stdout); -#endif - -#ifndef RTAI + fwrite(log_buffer, len, 1, stdout); if (g_log->syslog) { syslog(g_log->level, "%s", log_buffer); @@ -1212,15 +1459,6 @@ void logRecord_mt(const char *file, const char *func, int line, } } -#else - - // online print messges - if ((g_log->log_component[comp].filelog) && (level == LOG_FILE)) { - printf(log_buffer); - } - -#endif - #if defined(ENABLE_ITTI) if (level <= LOG_DEBUG) { @@ -1447,16 +1685,11 @@ void set_component_filelog(int comp) { if (g_log->log_component[comp].filelog == 0) { g_log->log_component[comp].filelog = 1; -#ifndef RTAI if (g_log->log_component[comp].fd == 0) { g_log->log_component[comp].fd = open(g_log->log_component[comp].filelog_name, O_WRONLY | O_CREAT | O_TRUNC, 0666); } - -#else - -#endif } } @@ -1512,9 +1745,6 @@ int is_newline( char *str, int size) void logClean (void) { -#ifdef RTAI - rtf_destroy (FIFO_PRINTF_NO); -#else int i; if (g_log->syslog) { @@ -1530,9 +1760,6 @@ void logClean (void) close(g_log->log_component[i].fd); } } - -#endif - } #if defined(ENABLE_ITTI) diff --git a/openair2/UTIL/LOG/log.h b/openair2/UTIL/LOG/log.h index cea32ee7a6386e664eca78beb3ac263376178f86..71924507558dacc5de331389c12aa42a88339ccb 100644 --- a/openair2/UTIL/LOG/log.h +++ b/openair2/UTIL/LOG/log.h @@ -32,7 +32,6 @@ # define __LOG_H__ /*--- INCLUDES ---------------------------------------------------------------*/ -#ifdef USER_MODE #include <unistd.h> #include <stdio.h> #include <stdlib.h> @@ -53,9 +52,6 @@ #define _GNU_SOURCE #endif #include <pthread.h> -#else -#include "rtai_fifos.h" -#endif /*----------------------------------------------------------------------------*/ @@ -283,20 +279,12 @@ void *log_thread_function(void * list); * @ingroup _macro * @brief Macro used to call tr_log_full_ex with file, function and line information * @{*/ -#ifdef USER_MODE -//#define logIt(component, level, format, args...) do {logRecord(__FILE__, __FUNCTION__, __LINE__, component, level, format, ##args);} while(0); #ifdef LOG_NO_THREAD #define logIt(component, level, format, args...) logRecord_mt(__FILE__, __FUNCTION__, __LINE__, pthread_self(), component, level, format, ##args) #else //default #define logIt(component, level, format, args...) logRecord(__FILE__, __FUNCTION__, __LINE__, pthread_self(), component, level, format, ##args) #endif -#else -#ifdef LOG_NO_THREAD -#define logIt(component, level, format, args...) logRecord_mt(NULL, __FUNCTION__, __LINE__, pthread_self(), component, level, format, ##args) -#else // default -#define logIt(component, level, format, args...) logRecord(NULL, __FUNCTION__, __LINE__, pthread_self(), component, level, format, ##args) -#endif -#endif + /* @}*/ /*----------------macro definitions for reading log configuration from the config module */ @@ -315,8 +303,8 @@ void *log_thread_function(void * list); /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define LOG_GLOBALPARAMS_DESC { \ -{LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, NULL, 0, strptr:(char **)&gloglevel, defstrval:log_level_names[2].name, TYPE_STRING, sizeof(gloglevel)}, \ -{LOG_CONFIG_STRING_GLOBAL_LOG_VERBOSITY,NULL, 0, strptr:(char **)&glogverbo, defstrval:log_verbosity_names[2].name, TYPE_STRING, sizeof(glogverbo)}, \ +{LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, NULL, 0, strptr:(char **)&gloglevel, defstrval:log_level_names[2].name, TYPE_STRING, 0}, \ +{LOG_CONFIG_STRING_GLOBAL_LOG_VERBOSITY,NULL, 0, strptr:(char **)&glogverbo, defstrval:log_verbosity_names[2].name, TYPE_STRING, 0}, \ {LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, NULL, 0, iptr:&(g_log->onlinelog), defintval:1, TYPE_INT, 0, }, \ {LOG_CONFIG_STRING_GLOBAL_LOG_INFILE, NULL, 0, iptr:&(g_log->filelog), defintval:0, TYPE_INT, 0, }, \ } @@ -327,7 +315,6 @@ void *log_thread_function(void * list); * @{*/ // debugging macros -#ifdef USER_MODE # if T_TRACER # include "T.h" # define LOG_I(c, x...) T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) @@ -379,17 +366,6 @@ void *log_thread_function(void * list); # endif /* 0 */ # endif /*DISABLE_LOG_X*/ # endif /* T_TRACER */ -#else /* USER_MODE */ -# define LOG_G(c, x...) printk(x) -# define LOG_A(c, x...) printk(x) -# define LOG_C(c, x...) printk(x) -# define LOG_E(c, x...) printk(x) -# define LOG_W(c, x...) printk(x) -# define LOG_N(c, x...) printk(x) -# define LOG_I(c, x...) printk(x) -# define LOG_D(c, x...) printk(x) -# define LOG_T(c, x...) printk(x) -#endif /* @}*/ diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.c b/openair2/UTIL/LOG/vcd_signal_dumper.c index 08d4e61497618543ff0e6d1fbf680b3f3f4f43da..b18d2a25ffd714c778e16a96a971db1e081694d9 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.c +++ b/openair2/UTIL/LOG/vcd_signal_dumper.c @@ -48,10 +48,6 @@ #include "vcd_signal_dumper.h" -#if defined(ENABLE_RTAI_CLOCK) -#include "rtai_lxrt.h" -#endif - #define VCDSIGNALDUMPER_VERSION_MAJOR 0 #define VCDSIGNALDUMPER_VERSION_MINOR 1 @@ -423,8 +419,6 @@ static inline unsigned long long int vcd_get_time(void); #if defined(ENABLE_USE_CPU_EXECUTION_TIME) struct timespec g_time_start; -#elif defined(ENABLE_RTAI_CLOCK) -RTIME start; #endif @@ -620,8 +614,6 @@ void vcd_signal_dumper_init(char *filename) #if defined(ENABLE_USE_CPU_EXECUTION_TIME) clock_gettime(CLOCK_MONOTONIC, &g_time_start); -#elif defined(ENABLE_RTAI_CLOCK) - start=rt_get_time_ns(); #endif vcd_signal_dumper_create_header(); @@ -674,9 +666,6 @@ static inline void vcd_signal_dumper_print_time_since_start(void) secondsSinceStart = (long long unsigned int)time.tv_sec - (long long unsigned int)g_time_start.tv_sec; /* Write time in nanoseconds */ fprintf(vcd_fd, "#%llu\n", nanosecondsSinceStart + (secondsSinceStart * 1000000000UL)); -#elif defined(ENABLE_RTAI_CLOCK) - /* Write time in nanoseconds */ - fprintf(vcd_fd, "#%llu\n",rt_get_time_ns()-start); #endif } } @@ -690,8 +679,6 @@ static inline unsigned long long int vcd_get_time(void) return (long long unsigned int)((time.tv_nsec - g_time_start.tv_nsec)) + ((long long unsigned int)time.tv_sec - (long long unsigned int)g_time_start.tv_sec) * 1000000000UL; -#elif defined(ENABLE_RTAI_CLOCK) - return rt_get_time_ns() - start; #endif } diff --git a/openair2/UTIL/MATH/random.c b/openair2/UTIL/MATH/random.c index 06caa3bc3ce6fc9e93c60a80a30a23e4625c0daa..30a6e9b1abba957f3257b924c67bb789bbe8c35a 100644 --- a/openair2/UTIL/MATH/random.c +++ b/openair2/UTIL/MATH/random.c @@ -29,11 +29,7 @@ #include "rtos_header.h" #include "platform_types.h" -#ifdef USER_MODE -# include <sys/time.h> -#else -#include <rtai_sched.h> -#endif +#include <sys/time.h> /* Random generators */ @@ -47,7 +43,6 @@ static int seed; void init_uniform (void) { -#ifdef USER_MODE struct timeval tv; struct timezone tz; @@ -61,9 +56,6 @@ init_uniform (void) #warning TO DO seed = rgId //seed += rgId; #endif -#else - seed = rt_get_time_ns(); -#endif } diff --git a/openair2/UTIL/MATH/taus.c b/openair2/UTIL/MATH/taus.c index 6e0fd84e66c16e39b71b1ce11a272ca4a0c3fc5a..632b1544dd0970b484fbe0a2ef4d585cae550604 100644 --- a/openair2/UTIL/MATH/taus.c +++ b/openair2/UTIL/MATH/taus.c @@ -29,21 +29,12 @@ * @ingroup util */ -#ifndef RTAI_ENABLED #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <math.h> #include "oml.h" -#else -#include <asm/io.h> -#include <asm/rtai.h> -#include <rtai.h> -#include <rtai_sched.h> -#define time(x) (unsigned int)(rt_get_time_ns()) -#endif - unsigned int s0[MAX_NUM_COMPS], s1[MAX_NUM_COMPS], s2[MAX_NUM_COMPS], b[MAX_NUM_COMPS], r[MAX_NUM_COMPS]; diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c index 09f10547cb05df8334658b4cfb37a8291f618841..9c3a50467a785f4f218d3f2eef034e327d5dde78 100644 --- a/openair2/UTIL/MEM/mem_block.c +++ b/openair2/UTIL/MEM/mem_block.c @@ -54,7 +54,7 @@ static pthread_mutex_t mtex = PTHREAD_MUTEX_INITIALIZER; //#define DEBUG_MEM_MNGT_ALLOC_SIZE //#define DEBUG_MEM_MNGT_ALLOC //----------------------------------------------------------------------------- -#if defined(USER_MODE) && defined(DEBUG_MEM_MNGT_ALLOC) +#if defined(DEBUG_MEM_MNGT_ALLOC) uint32_t counters[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif //----------------------------------------------------------------------------- @@ -269,10 +269,8 @@ get_free_mem_block (uint32_t sizeP, const char* caller) #ifdef DEBUG_MEM_MNGT_ALLOC LOG_E (RLC,"[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]); -#ifdef USER_MODE // display_mem_load (); // check_mem_area ((void *)&mem_block_var); -#endif #endif } while (pool_selected++ < 12); diff --git a/openair2/UTIL/MEM/mem_block.h b/openair2/UTIL/MEM/mem_block.h index b7e36bf5b374fc73f6f88d5207c0f6dcabc441f3..e9673802698fac9094f450c0e858e341a67ab197 100644 --- a/openair2/UTIL/MEM/mem_block.h +++ b/openair2/UTIL/MEM/mem_block.h @@ -31,9 +31,7 @@ #ifndef __MEM_BLOCK_H__ # define __MEM_BLOCK_H__ -#ifdef USER_MODE #include <stdint.h> -#endif #ifdef MEM_BLOCK_C # define public_mem_block(x) x # define private_mem_block(x) x @@ -63,19 +61,8 @@ public_mem_block(mem_block_t *copy_mem_block (mem_block_t * leP, mem_block_t * d public_mem_block(void display_mem_load (void);) public_mem_block(void check_mem_area (void);) -# ifdef USER_MODE private_mem_block(void check_free_mem_block (mem_block_t * leP);) -# endif -#ifdef USER_MODE -//# define MEM_SCALE MAX_MOBILES_PER_ENB*NB_RB_MAX # define MEM_SCALE MAX_MOBILES_PER_ENB -#else -# ifdef NODE_RG -# define MEM_SCALE 2 -# else -# define MEM_SCALE 1 -# endif -#endif // definition of the size of the allocated memory area # define MEM_MNGT_MB0_BLOCK_SIZE 64 // 64 diff --git a/openair2/UTIL/MEM/mem_mngt.c b/openair2/UTIL/MEM/mem_mngt.c index 49cd310ac907fda38c1213ee411661f6ea0c1df2..57c90ea4f909268f0c6aadcbacb7305e51f5bf4f 100644 --- a/openair2/UTIL/MEM/mem_mngt.c +++ b/openair2/UTIL/MEM/mem_mngt.c @@ -49,9 +49,7 @@ // #endif //----------------------------------------------------------------------------- -#ifdef USER_MODE uint32_t counters[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -#endif //----------------------------------------------------------------------------- /* * initialize all ures @@ -227,10 +225,8 @@ get_free_mem_block (uint16_t sizeP, __func__) #ifdef DEBUG_MEM_MNGT_ALLOC msg ("[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]); -# ifdef USER_MODE display_mem_load (); check_mem_area (mem); -# endif #endif } while (pool_selected++ < 9); diff --git a/openair2/UTIL/OCG/makefile b/openair2/UTIL/OCG/makefile index 1e531f94941f71b8e680f5671012dc0b4ded936b..1ef4ec98dca850bf5ad3c5ab91f92a27f62d465b 100644 --- a/openair2/UTIL/OCG/makefile +++ b/openair2/UTIL/OCG/makefile @@ -7,7 +7,7 @@ OPENAIR2_TOP = ../../../openair2 OPENAIR3_TOP = ../../../openair3 OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -DPHYSIM -DNODE_RG -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 #-Wno-packed-bitfield-compat +CFLAGS += -DPHYSIM -DNODE_RG -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 #-Wno-packed-bitfield-compat CFLAGS += -m32 -DOPENAIR_LTE -DOPENAIR2 #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE @@ -22,8 +22,6 @@ ifdef PDCP_USE_NETLINK CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif -CFLAGS += -DPHY_ABSTRACTION - #ifdef OCG CFLAGS += -I/usr/include/libxml2 -lxml2 #endif diff --git a/openair2/UTIL/OMG/makefile b/openair2/UTIL/OMG/makefile index 319b8296cd6f39e7ae019cd5818c71d86b6ba533..80ab8c6394f701b75416d15b9d42ce35c0277115 100644 --- a/openair2/UTIL/OMG/makefile +++ b/openair2/UTIL/OMG/makefile @@ -60,7 +60,7 @@ OPENAIR2_TOP = ../../../openair2 OPENAIR3_TOP = ../../../openair3 OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -DPHYSIM -DNODE_RG -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 #-Wno-packed-bitfield-compat +CFLAGS += -DPHYSIM -DNODE_RG -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 #-Wno-packed-bitfield-compat CFLAGS += -DOPENAIR_LTE -DOPENAIR2 #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE @@ -75,8 +75,6 @@ ifdef PDCP_USE_NETLINK CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif -CFLAGS += -DPHY_ABSTRACTION - include $(OPENAIR1_DIR)/PHY/Makefile.inc include $(OPENAIR1_DIR)/SCHED/Makefile.inc include $(OPENAIR2_DIR)/LAYER2/Makefile.inc diff --git a/openair2/UTIL/OMG/makefile_old b/openair2/UTIL/OMG/makefile_old index acc89254fb12228c799e3acf36f2d80ef3a6ef96..7bc551cb03c968ea5f174446e8f802c943e07b22 100644 --- a/openair2/UTIL/OMG/makefile_old +++ b/openair2/UTIL/OMG/makefile_old @@ -62,7 +62,7 @@ OPENAIR2_TOP = ../../../openair2 OPENAIR3_TOP = ../../../openair3 OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -DPHYSIM -DNODE_RG -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 #-Wno-packed-bitfield-compat +CFLAGS += -DPHYSIM -DNODE_RG -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 #-Wno-packed-bitfield-compat CFLAGS += -DOPENAIR_LTE -DOPENAIR2 #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE @@ -77,8 +77,6 @@ ifdef PDCP_USE_NETLINK CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif -CFLAGS += -DPHY_ABSTRACTION - include $(OPENAIR1_DIR)/PHY/Makefile.inc include $(OPENAIR1_DIR)/SCHED/Makefile.inc include $(OPENAIR2_DIR)/LAYER2/Makefile.inc diff --git a/openair2/UTIL/OMG/makefile_standalone b/openair2/UTIL/OMG/makefile_standalone index 68170543eedc73012c487ae70a3a9912485c9507..d612c018370da3fb0bf5cf9a9ac4168c8236fa49 100644 --- a/openair2/UTIL/OMG/makefile_standalone +++ b/openair2/UTIL/OMG/makefile_standalone @@ -8,7 +8,7 @@ OBJsumo = omg.c common.c sumo.c client_traci_OMG.c socket_traci_OMG.c storage_tr OBJ = omg.c common.c static.c job.c rwp.c rwalk.c trace.c steadystaterwp.c sumo.c grid.c mobility_parser.c hashtable.c client_traci_OMG.c socket_traci_OMG.c storage_traci_OMG.c id_manager.c -CFLAGS += -DSTANDALONE -DUSER_MODE -g +CFLAGS += -DSTANDALONE -g .PHONY: help staticOMG rwpOMG clean diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index 711436d2cd1ca9d703ce01e6fb4008f61720a1ab..ebc52bb1e04450d356de56054b01508a99aee915 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -410,18 +410,8 @@ static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context, /* PCAP Header */ /* TODO: Timestamp might want to be relative to a more sensible base time... */ -#if defined(RTAI) - { - unsigned long long int current_ns; - - current_ns = rt_get_time_ns(); - packet_header.ts_sec = current_ns / 1000000000UL; - packet_header.ts_usec = current_ns % 1000; - } -#else packet_header.ts_sec = context->subframesSinceCaptureStart / 1000; packet_header.ts_usec = (context->subframesSinceCaptureStart % 1000) * 1000; -#endif packet_header.incl_len = offset + length; packet_header.orig_len = offset + length; diff --git a/openair2/UTIL/TRACE/print.h b/openair2/UTIL/TRACE/print.h index 5982d249fa8497c43c9a2af82fdebf3a50ea63cd..72c43f20d473d51b20a842aa38ec3b3a80d2ae2b 100644 --- a/openair2/UTIL/TRACE/print.h +++ b/openair2/UTIL/TRACE/print.h @@ -28,14 +28,5 @@ ***************************************************************************/ #ifndef __PRINT_H__ # define __PRINT_H__ -# ifdef USER_MODE -# define msg printf -# else -# ifdef FIFO_PRINTF -# include "fifo_printf_proto_extern.h" -# define msg fifo_printf -# else -# define msg fifo_printf_null -# endif -# endif +# define msg printf #endif diff --git a/openair2/X2AP/Makefile.inc b/openair2/X2AP/Makefile.inc index 7369cf8dfa1b92421099fade99949ca65d10bd4c..a301a9934e924736868412284605a76a4946b668 100755 --- a/openair2/X2AP/Makefile.inc +++ b/openair2/X2AP/Makefile.inc @@ -28,7 +28,6 @@ CFLAGS = \ -Wall \ -DENB_MODE \ -DENABLE_USE_MME \ - -DUSER_MODE \ -I. \ -I$(ASN1MESSAGESDIR)/ASN1/$(ASN1RELDIR) \ -I$(ASN1MESSAGESDIR) \ diff --git a/openair2/X2AP/x2ap.h b/openair2/X2AP/x2ap.h index 65529c7119c186d2d6ec802473b64e57999ca5ab..89e8540b97c75c3563cca8cbd899f4bf71db1701 100644 --- a/openair2/X2AP/x2ap.h +++ b/openair2/X2AP/x2ap.h @@ -33,10 +33,7 @@ typedef struct x2ap_config_s { } x2ap_config_t; -#if defined(OAI_EMU) -#else extern x2ap_config_t x2ap_config; -#endif void *x2ap_task(void *arg); diff --git a/openair3/COMMON/nas_messages_def.h b/openair3/COMMON/nas_messages_def.h index 5214a1517153f81023403ad37fd0c3ca970e96e7..9bdcde4fdf06293338e7ef8659776b2a0fffaec1 100644 --- a/openair3/COMMON/nas_messages_def.h +++ b/openair3/COMMON/nas_messages_def.h @@ -61,9 +61,3 @@ MESSAGE_DEF(NAS_PDN_CONNECTIVITY_FAIL, MESSAGE_PRIORITY_MED, nas_pdn_ MESSAGE_DEF(NAS_AUTHENTICATION_PARAM_RSP, MESSAGE_PRIORITY_MED, nas_auth_param_rsp_t, nas_auth_param_rsp) MESSAGE_DEF(NAS_AUTHENTICATION_PARAM_FAIL, MESSAGE_PRIORITY_MED, nas_auth_param_fail_t, nas_auth_param_fail) -#if defined(DISABLE_USE_NAS) -MESSAGE_DEF(NAS_ATTACH_REQ, MESSAGE_PRIORITY_MED, nas_attach_req_t, nas_attach_req) -MESSAGE_DEF(NAS_ATTACH_ACCEPT, MESSAGE_PRIORITY_MED, nas_attach_accept_t, nas_attach_accept) -MESSAGE_DEF(NAS_AUTHENTICATION_RESP, MESSAGE_PRIORITY_MED, nas_auth_resp_t, nas_auth_resp) -MESSAGE_DEF(NAS_AUTHENTICATION_REQ, MESSAGE_PRIORITY_MED, nas_auth_req_t, nas_auth_req) -#endif diff --git a/openair3/COMMON/nas_messages_types.h b/openair3/COMMON/nas_messages_types.h index 45de68840e804f63ec73b4767099d5e9a2a37833..81a44fa4f4c42fe476822ca3d1f879f5468c4f6c 100644 --- a/openair3/COMMON/nas_messages_types.h +++ b/openair3/COMMON/nas_messages_types.h @@ -233,17 +233,7 @@ typedef struct nas_conn_est_ind_s { typedef nas_establish_rsp_t nas_conn_est_rej_t; -#if defined(DISABLE_USE_NAS) -typedef struct nas_conn_est_cnf_s { - uint32_t ue_id; - - nas_establish_cnf_t nas_establish_cnf; - /* Transparent message from MME_APP to S1AP */ - s1ap_initial_ctxt_setup_req_t transparent; -} nas_conn_est_cnf_t; -#else typedef nas_establish_cnf_t nas_conn_est_cnf_t; -#endif typedef struct nas_conn_rel_ind_s { @@ -336,10 +326,4 @@ typedef struct nas_auth_param_fail_s { } nas_auth_param_fail_t; -#if defined(DISABLE_USE_NAS) -typedef struct nas_attach_accept_s { - s1ap_initial_ctxt_setup_req_t transparent; -} nas_attach_accept_t; -#endif - #endif /* NAS_MESSAGES_TYPES_H_ */ diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index 0e13a59c4d80f02d81ffc552baa78bb4346168a2..578e0f167cf0f984631f0cc8a5dac56c1bd96434 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -776,6 +776,7 @@ gtpv1u_create_s1u_tunnel( gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].teid_eNB = s1u_teid; gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].teid_eNB_stack_session = stack_req.apiInfo.createTunnelEndPointInfo.hStackSession; gtpv1u_ue_data_p->bearers[eps_bearer_id - GTPV1U_BEARER_OFFSET].teid_sgw = create_tunnel_req_pP->sgw_S1u_teid[i]; + gtpv1u_ue_data_p->num_bearers++; create_tunnel_resp_pP->enb_S1u_teid[i] = s1u_teid; } else { @@ -817,7 +818,88 @@ gtpv1u_create_s1u_tunnel( return 0; } +int gtpv1u_update_s1u_tunnel( + const instance_t instanceP, + const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP, + const rnti_t prior_rnti + ) +{ + /* Local tunnel end-point identifier */ + teid_t s1u_teid = 0; + gtpv1u_teid_data_t *gtpv1u_teid_data_p = NULL; + gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL; + gtpv1u_ue_data_t *gtpv1u_ue_data_new_p = NULL; + //MessageDef *message_p = NULL; + hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS; + int i,j; + uint8_t bearers_num = 0,bearers_total = 0; + + //----------------------- + // PDCP->GTPV1U mapping + //----------------------- + hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, prior_rnti, (void **)>pv1u_ue_data_p); + if(hash_rc != HASH_TABLE_OK){ + LOG_E(GTPU,"Error get ue_mapping(rnti=%x) from GTPV1U hashtable error\n", prior_rnti); + return -1; + } + + gtpv1u_ue_data_new_p = calloc (1, sizeof(gtpv1u_ue_data_t)); + memcpy(gtpv1u_ue_data_new_p,gtpv1u_ue_data_p,sizeof(gtpv1u_ue_data_t)); + gtpv1u_ue_data_new_p->ue_id = create_tunnel_req_pP->rnti; + + hash_rc = hashtable_insert(RC.gtpv1u_data_g->ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_new_p); + AssertFatal(hash_rc == HASH_TABLE_OK, "Error inserting ue_mapping in GTPV1U hashtable"); + LOG_I(GTPU, "inserting ue_mapping(rnti=%x) in GTPV1U hashtable\n", + create_tunnel_req_pP->rnti); + + hash_rc = hashtable_remove(RC.gtpv1u_data_g->ue_mapping, prior_rnti); + LOG_I(GTPU, "hashtable_remove ue_mapping(rnti=%x) in GTPV1U hashtable\n", + prior_rnti); + //----------------------- + // GTPV1U->PDCP mapping + //----------------------- + bearers_total =gtpv1u_ue_data_new_p->num_bearers; + for(j = 0;j<GTPV1U_MAX_BEARERS_ID;j++){ + + if(gtpv1u_ue_data_new_p->bearers[j].state != BEARER_IN_CONFIG) + continue; + + bearers_num++; + for (i = 0; i < create_tunnel_req_pP->num_tunnels; i++) { + if(j == (create_tunnel_req_pP->eps_bearer_id[i]-GTPV1U_BEARER_OFFSET)) + break; + } + if(i < create_tunnel_req_pP->num_tunnels){ + s1u_teid = gtpv1u_ue_data_new_p->bearers[j].teid_eNB; + hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, s1u_teid, (void**)>pv1u_teid_data_p); + if (hash_rc == HASH_TABLE_OK) { + gtpv1u_teid_data_p->ue_id = create_tunnel_req_pP->rnti; + gtpv1u_teid_data_p->eps_bearer_id = create_tunnel_req_pP->eps_bearer_id[i]; + + LOG_I(GTPU, "updata teid_mapping te_id %u (prior_rnti %x rnti %x) in GTPV1U hashtable\n", + s1u_teid,prior_rnti,create_tunnel_req_pP->rnti); + }else{ + LOG_W(GTPU, "Error get teid mapping(s1u_teid=%u) from GTPV1U hashtable", s1u_teid); + } + }else{ + s1u_teid = gtpv1u_ue_data_new_p->bearers[j].teid_eNB; + hash_rc = hashtable_remove(RC.gtpv1u_data_g->teid_mapping, s1u_teid); + + if (hash_rc != HASH_TABLE_OK) { + LOG_D(GTPU, "Removed user rnti %x , enb S1U teid %u not found\n", prior_rnti, s1u_teid); + } + gtpv1u_ue_data_new_p->bearers[j].state = BEARER_DOWN; + gtpv1u_ue_data_new_p->num_bearers--; + LOG_I(GTPU, "delete teid_mapping te_id %u (rnti%x) bearer_id %d in GTPV1U hashtable\n", + s1u_teid,prior_rnti,j+GTPV1U_BEARER_OFFSET);; + } + if(bearers_num > bearers_total) + break; + } + return 0; + +} //----------------------------------------------------------------------------- static int gtpv1u_delete_s1u_tunnel( diff --git a/openair3/GTPV1-U/gtpv1u_eNB_task.h b/openair3/GTPV1-U/gtpv1u_eNB_task.h index 6f74c73a2926d0074cfca368845f7a797e1d28b3..5a7822fe8c7322e12a6a32d231cec8c6af1d1df6 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB_task.h +++ b/openair3/GTPV1-U/gtpv1u_eNB_task.h @@ -49,5 +49,9 @@ gtpv1u_create_s1u_tunnel( const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP, gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP); - +int +gtpv1u_update_s1u_tunnel( + const instance_t instanceP, + const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP, + const rnti_t prior_rnti); #endif /* GTPV1U_ENB_TASK_H_ */ diff --git a/openair3/S1AP/s1ap_eNB.c b/openair3/S1AP/s1ap_eNB.c index 08a18b629e0f58ccd075247f83c8832885a78230..301df6e81600fdff0e6f3ffae37e69e2d8d13019 100644 --- a/openair3/S1AP/s1ap_eNB.c +++ b/openair3/S1AP/s1ap_eNB.c @@ -65,10 +65,7 @@ #include "oaisim_mme_test_s1c.h" #endif - -#if !defined(OAI_EMU) s1ap_eNB_config_t s1ap_config; -#endif static int s1ap_eNB_generate_s1_setup_request( s1ap_eNB_instance_t *instance_p, s1ap_eNB_mme_data_t *s1ap_mme_data_p); @@ -364,6 +361,12 @@ void *s1ap_eNB_task(void *arg) &S1AP_E_RAB_SETUP_RESP(received_msg)); } break; + + case S1AP_E_RAB_MODIFY_RESP: { + s1ap_eNB_e_rab_modify_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), + &S1AP_E_RAB_MODIFY_RESP(received_msg)); + } + break; case S1AP_NAS_NON_DELIVERY_IND: { s1ap_eNB_nas_non_delivery_ind(ITTI_MESSAGE_GET_INSTANCE(received_msg), @@ -397,6 +400,12 @@ void *s1ap_eNB_task(void *arg) } break; + case S1AP_E_RAB_RELEASE_RESPONSE: { + s1ap_eNB_e_rab_release_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), + &S1AP_E_RAB_RELEASE_RESPONSE(received_msg)); + } + break; + default: S1AP_ERROR("Received unhandled message: %d:%s\n", ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); diff --git a/openair3/S1AP/s1ap_eNB.h b/openair3/S1AP/s1ap_eNB.h index 85bf00a4faaa9a3b11139fb2e38f2aab7d5aa3a9..e122703d82f2dbda6d5cf42b1bcbf08446a270a4 100644 --- a/openair3/S1AP/s1ap_eNB.h +++ b/openair3/S1AP/s1ap_eNB.h @@ -35,13 +35,9 @@ typedef struct s1ap_eNB_config_s { unsigned char mme_enabled; ///< MME enabled ? } s1ap_eNB_config_t; -#if defined(OAI_EMU) -# define EPC_MODE_ENABLED oai_emulation.info.s1ap_config.mme_enabled -#else extern s1ap_eNB_config_t s1ap_config; -# define EPC_MODE_ENABLED s1ap_config.mme_enabled -#endif +#define EPC_MODE_ENABLED s1ap_config.mme_enabled void *s1ap_eNB_task(void *arg); diff --git a/openair3/S1AP/s1ap_eNB_decoder.c b/openair3/S1AP/s1ap_eNB_decoder.c index f8daf6c67a7582983e26505a3a63699c5e9ef000..eac52c53ba6fc52cf13340267630a41d1de68c8c 100644 --- a/openair3/S1AP/s1ap_eNB_decoder.c +++ b/openair3/S1AP/s1ap_eNB_decoder.c @@ -108,7 +108,15 @@ static int s1ap_eNB_decode_initiating_message(s1ap_message *message, ret = s1ap_decode_s1ap_pagingies( &message->msg.s1ap_PagingIEs, &initiating_p->value); s1ap_xer_print_s1ap_paging(s1ap_xer__print2sp, message_string, message); - S1AP_ERROR("TODO Paging initiating message\n"); + message_id = S1AP_PAGING_LOG; + message_string_size = strlen(message_string); + message_p = itti_alloc_new_message_sized(TASK_S1AP, + message_id, + message_string_size + sizeof (IttiMsgText)); + message_p->ittiMsg.s1ap_paging_log.size = message_string_size; + memcpy(&message_p->ittiMsg.s1ap_paging_log.text, message_string, message_string_size); + itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p); + S1AP_INFO("Paging initiating message\n"); free(message_string); break; @@ -128,12 +136,36 @@ static int s1ap_eNB_decode_initiating_message(s1ap_message *message, free(message_string); S1AP_INFO("E_RABSetup initiating message\n"); break; + + case S1ap_ProcedureCode_id_E_RABModify: + ret = s1ap_decode_s1ap_e_rabmodifyrequesties( + &message->msg.s1ap_E_RABModifyRequestIEs, &initiating_p->value); + message_id = S1AP_E_RAB_MODIFY_REQUEST_LOG; + message_string_size = strlen(message_string); + message_p = itti_alloc_new_message_sized(TASK_S1AP, + message_id, + message_string_size + sizeof (IttiMsgText)); + message_p->ittiMsg.s1ap_e_rab_modify_request_log.size = message_string_size; + memcpy(&message_p->ittiMsg.s1ap_e_rab_modify_request_log.text, message_string, message_string_size); + itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p); + free(message_string); + S1AP_INFO("E_RABModify initiating message\n"); + break; + case S1ap_ProcedureCode_id_E_RABRelease: - ret = s1ap_decode_s1ap_e_rabreleasecommandies(&message->msg.s1ap_E_RABReleaseCommandIEs, - &initiating_p->value); - //s1ap_xer_print_s1ap_e_rabsetuprequest(s1ap_xer__print2sp, message_string, message); - S1AP_INFO("TODO E_RABRelease nitiating message\n"); + ret = s1ap_decode_s1ap_e_rabreleasecommandies( + &message->msg.s1ap_E_RABReleaseCommandIEs, &initiating_p->value); + s1ap_xer_print_s1ap_e_rabreleasecommand(s1ap_xer__print2sp, message_string, message); + message_id = S1AP_E_RAB_RELEASE_REQUEST_LOG; + message_string_size = strlen(message_string); + message_p = itti_alloc_new_message_sized(TASK_S1AP, + message_id, + message_string_size + sizeof (IttiMsgText)); + message_p->ittiMsg.s1ap_e_rab_release_request_log.size = message_string_size; + memcpy(&message_p->ittiMsg.s1ap_e_rab_release_request_log.text, message_string, message_string_size); + itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p); free(message_string); + S1AP_INFO("TODO E_RABRelease nitiating message\n"); break; default: diff --git a/openair3/S1AP/s1ap_eNB_encoder.c b/openair3/S1AP/s1ap_eNB_encoder.c index 4ab2f1f317f2cbee3f55404c53ed705cce10f158..9a5f422158dc592d685935d01bdbff06c17095c0 100644 --- a/openair3/S1AP/s1ap_eNB_encoder.c +++ b/openair3/S1AP/s1ap_eNB_encoder.c @@ -100,6 +100,16 @@ int s1ap_eNB_encode_e_rab_setup_response(S1ap_E_RABSetupResponseIEs_t *E_RABSet uint8_t **buffer, uint32_t *length); +static inline +int s1ap_eNB_encode_e_rab_modify_response(S1ap_E_RABModifyResponseIEs_t *E_RABModifyResponseIEs, + uint8_t **buffer, + uint32_t *length); + +static inline +int s1ap_eNB_encode_e_rab_release_response(S1ap_E_RABReleaseResponseIEs_t *s1ap_E_RABReleaseResponseIEs, + uint8_t **buffer, + uint32_t *length); + int s1ap_eNB_encode_pdu(s1ap_message *message, uint8_t **buffer, uint32_t *len) { DevAssert(message != NULL); @@ -264,6 +274,32 @@ int s1ap_eNB_encode_successfull_outcome(s1ap_message *s1ap_message_p, free(message_string); S1AP_INFO("E_RABSetup successful message\n"); break; + + case S1ap_ProcedureCode_id_E_RABModify: + ret = s1ap_eNB_encode_e_rab_modify_response ( + &s1ap_message_p->msg.s1ap_E_RABModifyResponseIEs, buffer, len); + message_id = S1AP_E_RAB_MODIFY_RESPONSE_LOG ; + message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText)); + message_p->ittiMsg.s1ap_e_rab_modify_response_log.size = message_string_size; + memcpy(&message_p->ittiMsg.s1ap_e_rab_modify_response_log.text, message_string, message_string_size); + itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p); + free(message_string); + S1AP_INFO("E_RABModify successful message\n"); + break; + + case S1ap_ProcedureCode_id_E_RABRelease: + ret = s1ap_eNB_encode_e_rab_release_response ( + &s1ap_message_p->msg.s1ap_E_RABReleaseResponseIEs, buffer, len); + s1ap_xer_print_s1ap_e_rabreleaseresponse(s1ap_xer__print2sp, message_string, s1ap_message_p); + message_id = S1AP_E_RAB_RELEASE_RESPONSE_LOG ; + message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText)); + message_p->ittiMsg.s1ap_e_rab_release_response_log.size = message_string_size; + memcpy(&message_p->ittiMsg.s1ap_e_rab_release_response_log.text, message_string, message_string_size); + itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p); + free(message_string); + S1AP_INFO("E_RAB Release successful message\n"); + break; + default: S1AP_WARN("Unknown procedure ID (%d) for successfull outcome message\n", (int)s1ap_message_p->procedureCode); @@ -563,3 +599,48 @@ int s1ap_eNB_encode_e_rab_setup_response(S1ap_E_RABSetupResponseIEs_t *s1ap_E_R &asn_DEF_S1ap_E_RABSetupResponse, e_rab_setup_response_p); } + +static inline +int s1ap_eNB_encode_e_rab_modify_response(S1ap_E_RABModifyResponseIEs_t *s1ap_E_RABModifyResponseIEs, + uint8_t **buffer, + uint32_t *length) +{ + S1ap_E_RABModifyResponse_t e_rab_modify_response; + S1ap_E_RABModifyResponse_t *e_rab_modify_response_p = &e_rab_modify_response; + + memset((void *)e_rab_modify_response_p, 0, + sizeof(e_rab_modify_response)); + + if (s1ap_encode_s1ap_e_rabmodifyresponseies (e_rab_modify_response_p, s1ap_E_RABModifyResponseIEs) < 0) { + return -1; + } + + return s1ap_generate_successfull_outcome(buffer, + length, + S1ap_ProcedureCode_id_E_RABModify, + S1ap_Criticality_reject, + &asn_DEF_S1ap_E_RABModifyResponse, + e_rab_modify_response_p); +} +static inline +int s1ap_eNB_encode_e_rab_release_response(S1ap_E_RABReleaseResponseIEs_t *s1ap_E_RABReleaseResponseIEs, + uint8_t **buffer, + uint32_t *length) +{ + S1ap_E_RABReleaseResponse_t e_rab_release_response; + S1ap_E_RABReleaseResponse_t *e_rab_release_response_p = &e_rab_release_response; + + memset((void *)e_rab_release_response_p, 0, + sizeof(e_rab_release_response)); + + if (s1ap_encode_s1ap_e_rabreleaseresponseies (e_rab_release_response_p, s1ap_E_RABReleaseResponseIEs) < 0) { + return -1; + } + + return s1ap_generate_successfull_outcome(buffer, + length, + S1ap_ProcedureCode_id_E_RABRelease, + S1ap_Criticality_reject, + &asn_DEF_S1ap_E_RABReleaseResponse, + e_rab_release_response_p); +} diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 186f034644eda4802ee90aa58fc124827b444a0e..0b02fc6db9ee4c0580ec108bdeb50bd162372d52 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -81,6 +81,20 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, uint32_t stream, struct s1ap_message_s *s1ap_message_p); +static +int s1ap_eNB_handle_paging(uint32_t assoc_id, + uint32_t stream, + struct s1ap_message_s *message_p); + +static +int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, + uint32_t stream, + struct s1ap_message_s *s1ap_message_p); + +static +int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, + uint32_t stream, + struct s1ap_message_s *s1ap_message_p); /* Handlers matrix. Only eNB related procedure present here */ s1ap_message_decoded_callback messages_callback[][3] = { @@ -90,11 +104,11 @@ s1ap_message_decoded_callback messages_callback[][3] = { { 0, 0, 0 }, /* PathSwitchRequest */ { 0, 0, 0 }, /* HandoverCancel */ { s1ap_eNB_handle_e_rab_setup_request, 0, 0 }, /* E_RABSetup */ - { 0, 0, 0 }, /* E_RABModify */ - { 0, 0, 0 }, /* E_RABRelease */ + { s1ap_eNB_handle_e_rab_modify_request, 0, 0 }, /* E_RABModify */ + { s1ap_eNB_handle_e_rab_release_command, 0, 0 }, /* E_RABRelease */ { 0, 0, 0 }, /* E_RABReleaseIndication */ { s1ap_eNB_handle_initial_context_request, 0, 0 }, /* InitialContextSetup */ - { 0, 0, 0 }, /* Paging */ + { s1ap_eNB_handle_paging, 0, 0 }, /* Paging */ { s1ap_eNB_handle_nas_downlink, 0, 0 }, /* downlinkNASTransport */ { 0, 0, 0 }, /* initialUEMessage */ { 0, 0, 0 }, /* uplinkNASTransport */ @@ -950,7 +964,7 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer = NULL; S1AP_WARN("NAS PDU is not provided, generate a E_RAB_SETUP Failure (TBD) back to MME \n"); - return -1; + // return -1; } /* Set the transport layer address */ @@ -983,4 +997,382 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, return 0; } +static +int s1ap_eNB_handle_paging(uint32_t assoc_id, + uint32_t stream, + struct s1ap_message_s *s1ap_message_p) +{ + S1ap_PagingIEs_t *paging_p; + s1ap_eNB_mme_data_t *mme_desc_p = NULL; + s1ap_eNB_instance_t *s1ap_eNB_instance = NULL; + MessageDef *message_p = NULL; + + DevAssert(s1ap_message_p != NULL); + // received Paging Message from MME + S1AP_DEBUG("[SCTP %d] Received Paging Message From MME\n",assoc_id); + + paging_p = &s1ap_message_p->msg.s1ap_PagingIEs; + + /* Paging procedure -> stream != 0 */ + if (stream == 0) { + S1AP_ERROR("[SCTP %d] Received Paging procedure on stream (%d)\n", + assoc_id, stream); + return -1; + } + + if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { + S1AP_ERROR("[SCTP %d] Received Paging for non " + "existing MME context\n", assoc_id); + return -1; + } + + s1ap_eNB_instance = mme_desc_p->s1ap_eNB_instance; + if (s1ap_eNB_instance == NULL) { + S1AP_ERROR("[SCTP %d] Received Paging for non existing MME context : s1ap_eNB_instance is NULL\n", + assoc_id); + return -1; + } + + message_p = itti_alloc_new_message(TASK_S1AP, S1AP_PAGING_IND); + + /* convert S1ap_PagingIEs_t to s1ap_paging_ind_t */ + /* convert UE Identity Index value */ + S1AP_PAGING_IND(message_p).ue_index_value = BIT_STRING_to_uint32(&paging_p->ueIdentityIndexValue); + S1AP_DEBUG("[SCTP %d] Received Paging ue_index_value (%d)\n", + assoc_id,(uint32_t)S1AP_PAGING_IND(message_p).ue_index_value); + + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code = 0; + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi = 0; + + /* convert UE Paging Identity */ + if (paging_p->uePagingID.present == S1ap_UEPagingID_PR_s_TMSI) { + S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_s_tmsi; + OCTET_STRING_TO_INT8(&paging_p->uePagingID.choice.s_TMSI.mMEC, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code); + OCTET_STRING_TO_INT32(&paging_p->uePagingID.choice.s_TMSI.m_TMSI, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi); + } else if (paging_p->uePagingID.present == S1ap_UEPagingID_PR_iMSI) { + S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_imsi; + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length = 0; + for (int i = 0; i < paging_p->uePagingID.choice.iMSI.size; i++) { + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i] = (uint8_t)(paging_p->uePagingID.choice.iMSI.buf[i] & 0x0F ); + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++; + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1] = (uint8_t)((paging_p->uePagingID.choice.iMSI.buf[i]>>4) & 0x0F); + LOG_D(S1AP,"paging : i %d %d imsi %d %d \n",2*i,2*i+1,S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1]); + if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2*i+1] == 0x0F) { + if(i != paging_p->uePagingID.choice.iMSI.size - 1){ + /* invalid paging_p->uePagingID.choise.iMSI.buffer */ + S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI error(i %d 0x0F)\n", assoc_id,i); + return -1; + } + } else { + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length++; + } + } + if (S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length >= S1AP_IMSI_LENGTH) { + /* invalid paging_p->uePagingID.choise.iMSI.size */ + S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.choise.iMSI.size(%d) is over IMSI length(%d)\n", assoc_id, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length, S1AP_IMSI_LENGTH); + return -1; + } +} else { + /* invalid paging_p->uePagingID.present */ + S1AP_ERROR("[SCTP %d] Received Paging : uePagingID.present(%d) is unknown\n", assoc_id, paging_p->uePagingID.present); + return -1; + } + +#if 0 + /* convert Paging DRX(optional) */ + if (paging_p->presenceMask & S1AP_PAGINGIES_PAGINGDRX_PRESENT) { + switch(paging_p->pagingDRX) { + case S1ap_PagingDRX_v32: + S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_32; + break; + case S1ap_PagingDRX_v64: + S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_64; + break; + case S1ap_PagingDRX_v128: + S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_128; + break; + case S1ap_PagingDRX_v256: + S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256; + break; + default: + // when UE Paging DRX is no value + S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256; + break; + } + } +#endif + S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256; + + /* convert cnDomain */ + if (paging_p->cnDomain == S1ap_CNDomain_ps) { + S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_PS; + } else if (paging_p->cnDomain == S1ap_CNDomain_cs) { + S1AP_PAGING_IND(message_p).cn_domain = CN_DOMAIN_CS; + } else { + /* invalid paging_p->cnDomain */ + S1AP_ERROR("[SCTP %d] Received Paging : cnDomain(%ld) is unknown\n", assoc_id, paging_p->cnDomain); + return -1; + } + + memset (&S1AP_PAGING_IND(message_p).plmn_identity[0], 0, sizeof(plmn_identity_t)*256); + memset (&S1AP_PAGING_IND(message_p).tac[0], 0, sizeof(int16_t)*256); + S1AP_PAGING_IND(message_p).tai_size = 0; + + for (int i = 0; i < paging_p->taiList.s1ap_TAIItem.count; i++) { + S1AP_INFO("[SCTP %d] Received Paging taiList: i %d, count %d\n", assoc_id, i, paging_p->taiList.s1ap_TAIItem.count); + S1ap_TAIItem_t s1ap_TAIItem; + memset (&s1ap_TAIItem, 0, sizeof(S1ap_TAIItem_t)); + + memcpy(&s1ap_TAIItem, paging_p->taiList.s1ap_TAIItem.array[i], sizeof(S1ap_TAIItem_t)); + + TBCD_TO_MCC_MNC(&s1ap_TAIItem.tAI.pLMNidentity, S1AP_PAGING_IND(message_p).plmn_identity[i].mcc, + S1AP_PAGING_IND(message_p).plmn_identity[i].mnc, + S1AP_PAGING_IND(message_p).plmn_identity[i].mnc_digit_length); + OCTET_STRING_TO_INT16(&s1ap_TAIItem.tAI.tAC, S1AP_PAGING_IND(message_p).tac[i]); + S1AP_PAGING_IND(message_p).tai_size++; + S1AP_DEBUG("[SCTP %d] Received Paging: MCC %d, MNC %d, TAC %d\n", assoc_id, S1AP_PAGING_IND(message_p).plmn_identity[i].mcc, S1AP_PAGING_IND(message_p).plmn_identity[i].mnc, S1AP_PAGING_IND(message_p).tac[i]); + } + +#if 0 + // CSG Id(optional) List is not used + if (paging_p->presenceMask & S1AP_PAGINGIES_CSG_IDLIST_PRESENT) { + // TODO + } + + /* convert pagingPriority (optional) if has value */ + if (paging_p->presenceMask & S1AP_PAGINGIES_PAGINGPRIORITY_PRESENT) { + switch(paging_p->pagingPriority) { + case S1ap_PagingPriority_priolevel1: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL1; + break; + case S1ap_PagingPriority_priolevel2: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL2; + break; + case S1ap_PagingPriority_priolevel3: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL3; + break; + case S1ap_PagingPriority_priolevel4: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL4; + break; + case S1ap_PagingPriority_priolevel5: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL5; + break; + case S1ap_PagingPriority_priolevel6: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL6; + break; + case S1ap_PagingPriority_priolevel7: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL7; + break; + case S1ap_PagingPriority_priolevel8: + S1AP_PAGING_IND(message_p).paging_priority = PAGING_PRIO_LEVEL8; + break; + default: + /* invalid paging_p->pagingPriority */ + S1AP_ERROR("[SCTP %d] Received paging : pagingPriority(%ld) is invalid\n", assoc_id, paging_p->pagingPriority); + return -1; + } + } +#endif + //paging parameter values + S1AP_DEBUG("[SCTP %d] Received Paging parameters: ue_index_value %d cn_domain %d paging_drx %d paging_priority %d\n",assoc_id, + S1AP_PAGING_IND(message_p).ue_index_value, S1AP_PAGING_IND(message_p).cn_domain, + S1AP_PAGING_IND(message_p).paging_drx, S1AP_PAGING_IND(message_p).paging_priority); + S1AP_DEBUG("[SCTP %d] Received Paging parameters(ue): presenceMask %d s_tmsi.m_tmsi %d s_tmsi.mme_code %d IMSI length %d (0-5) %d%d%d%d%d%d\n",assoc_id, + S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi, + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.length, + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[0], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[1], + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[3], + S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[4], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[5]); + + /* send message to RRC */ + itti_send_msg_to_task(TASK_RRC_ENB, s1ap_eNB_instance->instance, message_p); + + return 0; +} + +static +int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, + uint32_t stream, + struct s1ap_message_s *s1ap_message_p) { + + int i; + + s1ap_eNB_mme_data_t *mme_desc_p = NULL; + s1ap_eNB_ue_context_t *ue_desc_p = NULL; + MessageDef *message_p = NULL; + int nb_of_e_rabs_failed = 0; + + S1ap_E_RABModifyRequestIEs_t *s1ap_E_RABModifyRequest; + DevAssert(s1ap_message_p != NULL); + + s1ap_E_RABModifyRequest = &s1ap_message_p->msg.s1ap_E_RABModifyRequestIEs; + + if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { + S1AP_ERROR("[SCTP %d] Received E-RAB modify request for non " + "existing MME context\n", assoc_id); + return -1; + } + + + if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, + s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID)) == NULL) { + S1AP_ERROR("[SCTP %d] Received E-RAB modify request for non " + "existing UE context 0x%06lx\n", assoc_id, + s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID); + return -1; + } + /* E-RAB modify request = UE-related procedure -> stream != 0 */ + if (stream == 0) { + S1AP_ERROR("[SCTP %d] Received UE-related procedure on stream (%d)\n", + assoc_id, stream); + return -1; + } + + ue_desc_p->rx_stream = stream; + + if ( ue_desc_p->mme_ue_s1ap_id != s1ap_E_RABModifyRequest->mme_ue_s1ap_id){ + S1AP_WARN("UE context mme_ue_s1ap_id is different form that of the message (%d != %ld)", + ue_desc_p->mme_ue_s1ap_id, s1ap_E_RABModifyRequest->mme_ue_s1ap_id); + message_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP); + + S1AP_E_RAB_MODIFY_RESP (message_p).eNB_ue_s1ap_id = s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID; +// S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs[S1AP_MAX_E_RAB]; + S1AP_E_RAB_MODIFY_RESP (message_p).nb_of_e_rabs = 0; + + for(nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.count; nb_of_e_rabs_failed++) { + S1AP_E_RAB_MODIFY_RESP (message_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id = + ((S1ap_E_RABToBeModifiedItemBearerModReq_t *)s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.array[nb_of_e_rabs_failed])->e_RAB_ID; + S1AP_E_RAB_MODIFY_RESP (message_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK; + S1AP_E_RAB_MODIFY_RESP (message_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = 13;//S1ap_CauseRadioNetwork_unknown_mme_ue_s1ap_id; + } + S1AP_E_RAB_MODIFY_RESP (message_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; + + s1ap_eNB_e_rab_modify_resp(mme_desc_p->s1ap_eNB_instance->instance, + &S1AP_E_RAB_MODIFY_RESP(message_p)); + + message_p = NULL; + return -1; + } + + message_p = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_MODIFY_REQ); + + S1AP_E_RAB_MODIFY_REQ(message_p).ue_initial_id = ue_desc_p->ue_initial_id; + + S1AP_E_RAB_MODIFY_REQ(message_p).mme_ue_s1ap_id = s1ap_E_RABModifyRequest->mme_ue_s1ap_id; + S1AP_E_RAB_MODIFY_REQ(message_p).eNB_ue_s1ap_id = s1ap_E_RABModifyRequest->eNB_UE_S1AP_ID; + + S1AP_E_RAB_MODIFY_REQ(message_p).nb_e_rabs_tomodify = + s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.count; + + for (i = 0; i < s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.count; i++) { + S1ap_E_RABToBeModifiedItemBearerModReq_t *item_p; + + item_p = (S1ap_E_RABToBeModifiedItemBearerModReq_t *)s1ap_E_RABModifyRequest->e_RABToBeModifiedListBearerModReq.s1ap_E_RABToBeModifiedItemBearerModReq.array[i]; + + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].e_rab_id = item_p->e_RAB_ID; + + // check for the NAS PDU + if (item_p->nAS_PDU.size > 0 ) { + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.length = item_p->nAS_PDU.size; + + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.buffer = malloc(sizeof(uint8_t) * item_p->nAS_PDU.size); + + memcpy(S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.buffer, + item_p->nAS_PDU.buf, item_p->nAS_PDU.size); + } else { + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.length = 0; + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.buffer = NULL; + continue; + } + + /* Set the QOS informations */ + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.qci = item_p->e_RABLevelQoSParameters.qCI; + + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.priority_level = + item_p->e_RABLevelQoSParameters.allocationRetentionPriority.priorityLevel; + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.pre_emp_capability = + item_p->e_RABLevelQoSParameters.allocationRetentionPriority.pre_emptionCapability; + S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.pre_emp_vulnerability = + item_p->e_RABLevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability; + + } + + itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); + + return 0; +} +// handle e-rab release command and send it to rrc_end +static +int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, + uint32_t stream, + struct s1ap_message_s *s1ap_message_p) { + + int i; + + s1ap_eNB_mme_data_t *mme_desc_p = NULL; + s1ap_eNB_ue_context_t *ue_desc_p = NULL; + MessageDef *message_p = NULL; + + S1ap_E_RABReleaseCommandIEs_t *s1ap_E_RABReleaseCommand; + DevAssert(s1ap_message_p != NULL); + s1ap_E_RABReleaseCommand = &s1ap_message_p->msg.s1ap_E_RABReleaseCommandIEs; + + if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { + S1AP_ERROR("[SCTP %d] Received E-RAB release command for non existing MME context\n", assoc_id); + return -1; + } + if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, + s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID)) == NULL) { + S1AP_ERROR("[SCTP %d] Received E-RAB release command for non existing UE context 0x%06lx\n", assoc_id, + s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID); + return -1; + } + + /* Initial context request = UE-related procedure -> stream != 0 */ + if (stream == 0) { + S1AP_ERROR("[SCTP %d] Received UE-related procedure on stream (%d)\n", + assoc_id, stream); + return -1; + } + + ue_desc_p->rx_stream = stream; + + if ( ue_desc_p->mme_ue_s1ap_id != s1ap_E_RABReleaseCommand->mme_ue_s1ap_id){ + S1AP_WARN("UE context mme_ue_s1ap_id is different form that of the message (%d != %ld)", + ue_desc_p->mme_ue_s1ap_id, s1ap_E_RABReleaseCommand->mme_ue_s1ap_id); + } + + S1AP_DEBUG("[SCTP %d] Received E-RAB release command for eNB_UE_S1AP_ID %ld mme_ue_s1ap_id %ld\n", + assoc_id, s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID, s1ap_E_RABReleaseCommand->mme_ue_s1ap_id); + + message_p = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_RELEASE_COMMAND); + + S1AP_E_RAB_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = s1ap_E_RABReleaseCommand->eNB_UE_S1AP_ID; + S1AP_E_RAB_RELEASE_COMMAND(message_p).mme_ue_s1ap_id = s1ap_E_RABReleaseCommand->mme_ue_s1ap_id; + if(s1ap_E_RABReleaseCommand->nas_pdu.size > 0 ){ + S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.length = s1ap_E_RABReleaseCommand->nas_pdu.size; + + S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer = + malloc(sizeof(uint8_t) * s1ap_E_RABReleaseCommand->nas_pdu.size); + + memcpy(S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer, + s1ap_E_RABReleaseCommand->nas_pdu.buf, + s1ap_E_RABReleaseCommand->nas_pdu.size); + } else { + S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.length = 0; + S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer = NULL; + } + + S1AP_E_RAB_RELEASE_COMMAND(message_p).nb_e_rabs_torelease = s1ap_E_RABReleaseCommand->e_RABToBeReleasedList.s1ap_E_RABItem.count; + for(i=0; i < s1ap_E_RABReleaseCommand->e_RABToBeReleasedList.s1ap_E_RABItem.count; i++){ + S1ap_E_RABItem_t *item_p; + item_p = (S1ap_E_RABItem_t*)s1ap_E_RABReleaseCommand->e_RABToBeReleasedList.s1ap_E_RABItem.array[i]; + S1AP_E_RAB_RELEASE_COMMAND(message_p).e_rab_release_params[i].e_rab_id = item_p->e_RAB_ID; + S1AP_DEBUG("[SCTP] Received E-RAB release command for e-rab id %ld\n", item_p->e_RAB_ID); + } + + itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); + + return 0; +} diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c index ea0dbcb70af653217564fec618977d56de8fb686..d6d9b52c07a2cd6719b9bc63fbcda72bf4d11c4a 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c @@ -837,3 +837,282 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, return ret; } + +//------------------------------------------------------------------------------ +int s1ap_eNB_e_rab_modify_resp(instance_t instance, + s1ap_e_rab_modify_resp_t *e_rab_modify_resp_p) +//------------------------------------------------------------------------------ +{ + s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL; + struct s1ap_eNB_ue_context_s *ue_context_p = NULL; + + S1ap_E_RABModifyResponseIEs_t *initial_ies_p = NULL; + + s1ap_message message; + + uint8_t *buffer = NULL; + uint32_t length; + int ret = -1; + int i; + + /* Retrieve the S1AP eNB instance associated with Mod_id */ + s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); + + DevAssert(e_rab_modify_resp_p != NULL); + DevAssert(s1ap_eNB_instance_p != NULL); + + if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, + e_rab_modify_resp_p->eNB_ue_s1ap_id)) == NULL) { + /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */ + S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: 0x%06x\n", + e_rab_modify_resp_p->eNB_ue_s1ap_id); + return -1; + } + + /* Uplink NAS transport can occur either during an s1ap connected state + * or during initial attach (for example: NAS authentication). + */ + if (!(ue_context_p->ue_state == S1AP_UE_CONNECTED || + ue_context_p->ue_state == S1AP_UE_WAITING_CSR)) { + S1AP_WARN("You are attempting to send NAS data over non-connected " + "eNB ue s1ap id: %06x, current state: %d\n", + e_rab_modify_resp_p->eNB_ue_s1ap_id, ue_context_p->ue_state); + return -1; + } + + /* Prepare the S1AP message to encode */ + memset(&message, 0, sizeof(s1ap_message)); + + message.direction = S1AP_PDU_PR_successfulOutcome; + message.procedureCode = S1ap_ProcedureCode_id_E_RABModify; + message.criticality = S1ap_Criticality_reject; + + initial_ies_p = &message.msg.s1ap_E_RABModifyResponseIEs; + + initial_ies_p->eNB_UE_S1AP_ID = e_rab_modify_resp_p->eNB_ue_s1ap_id; + initial_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id; + + if ( e_rab_modify_resp_p->nb_of_e_rabs >= 1 ) + initial_ies_p->presenceMask |= S1AP_E_RABMODIFYRESPONSEIES_E_RABMODIFYLISTBEARERMODRES_PRESENT; + + for (i = 0; i < e_rab_modify_resp_p->nb_of_e_rabs; i++) { + S1ap_E_RABModifyItemBearerModRes_t *modify_item; + + modify_item = calloc(1, sizeof(S1ap_E_RABModifyItemBearerModRes_t)); + + modify_item->e_RAB_ID = e_rab_modify_resp_p->e_rabs[i].e_rab_id; + + S1AP_DEBUG("e_rab_modify_resp: modified e_rab ID %ld\n", + modify_item->e_RAB_ID); + + S1ap_IE_t *ie = s1ap_new_ie(S1ap_ProtocolIE_ID_id_E_RABModifyItemBearerModRes, + S1ap_Criticality_ignore, + &asn_DEF_S1ap_E_RABModifyItemBearerModRes, + modify_item); + + ASN_SEQUENCE_ADD(&initial_ies_p->e_RABModifyListBearerModRes.s1ap_E_RABModifyItemBearerModRes, + ie); + } + + if ( e_rab_modify_resp_p->nb_of_e_rabs_failed >= 1 ) + initial_ies_p->presenceMask |= S1AP_E_RABMODIFYRESPONSEIES_E_RABFAILEDTOMODIFYLIST_PRESENT; + + for (i = 0; i < e_rab_modify_resp_p->nb_of_e_rabs_failed; i++) { + S1ap_E_RABItem_t *failed_item; + + failed_item = calloc(1, sizeof(S1ap_E_RABItem_t)); + + failed_item->e_RAB_ID = e_rab_modify_resp_p->e_rabs_failed[i].e_rab_id; + switch(e_rab_modify_resp_p->e_rabs_failed[i].cause) + { + case S1AP_CAUSE_RADIO_NETWORK: + failed_item->cause.present = S1ap_Cause_PR_radioNetwork; + failed_item->cause.choice.radioNetwork = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; + break; + case S1AP_CAUSE_TRANSPORT: + failed_item->cause.present = S1ap_Cause_PR_transport; + failed_item->cause.choice.transport = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; + break; + case S1AP_CAUSE_NAS: + failed_item->cause.present = S1ap_Cause_PR_nas; + failed_item->cause.choice.nas = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; + break; + case S1AP_CAUSE_PROTOCOL: + failed_item->cause.present = S1ap_Cause_PR_protocol; + failed_item->cause.choice.protocol = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; + break; + case S1AP_CAUSE_MISC: + failed_item->cause.present = S1ap_Cause_PR_misc; + failed_item->cause.choice.misc = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; + break; + default: + break; + } + S1AP_DEBUG("e_rab_modify_resp: failed e_rab ID %ld\n", + failed_item->e_RAB_ID); + + S1ap_IE_t *ie = s1ap_new_ie(S1ap_ProtocolIE_ID_id_E_RABItem, + S1ap_Criticality_ignore, + &asn_DEF_S1ap_E_RABItem, + failed_item); + + ASN_SEQUENCE_ADD(&initial_ies_p->e_RABFailedToModifyList.s1ap_E_RABItem, + ie); + } + + fprintf(stderr, "start encode\n"); + if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) { + S1AP_ERROR("Failed to encode uplink transport\n"); + /* Encode procedure has failed... */ + return -1; + } + + MSC_LOG_TX_MESSAGE( + MSC_S1AP_ENB, + MSC_S1AP_MME, + (const char *)buffer, + length, + MSC_AS_TIME_FMT" E_RAN Modify successful Outcome eNB_ue_s1ap_id %u mme_ue_s1ap_id %u", + 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), + initial_ies_p->eNB_UE_S1AP_ID, + initial_ies_p->mme_ue_s1ap_id); + + /* UE associated signalling -> use the allocated stream */ + s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, + ue_context_p->mme_ref->assoc_id, buffer, + length, ue_context_p->tx_stream); + + return ret; +} +//------------------------------------------------------------------------------ +int s1ap_eNB_e_rab_release_resp(instance_t instance, + s1ap_e_rab_release_resp_t *e_rab_release_resp_p) +//------------------------------------------------------------------------------ +{ + s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL; + struct s1ap_eNB_ue_context_s *ue_context_p = NULL; + + S1ap_E_RABReleaseResponseIEs_t *release_response_ies_p = NULL; + + s1ap_message message; + + uint8_t *buffer = NULL; + uint32_t length; + int ret = -1; + int i; + /* Retrieve the S1AP eNB instance associated with Mod_id */ + s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); + DevAssert(e_rab_release_resp_p != NULL); + DevAssert(s1ap_eNB_instance_p != NULL); + + /* Prepare the S1AP message to encode */ + memset(&message, 0, sizeof(s1ap_message)); + + message.direction = S1AP_PDU_PR_successfulOutcome; + message.procedureCode = S1ap_ProcedureCode_id_E_RABRelease; + message.criticality = S1ap_Criticality_ignore; + + if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, + e_rab_release_resp_p->eNB_ue_s1ap_id)) == NULL) { + /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */ + S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n", + e_rab_release_resp_p->eNB_ue_s1ap_id); + return -1; + } + + release_response_ies_p = &message.msg.s1ap_E_RABReleaseResponseIEs; + release_response_ies_p->eNB_UE_S1AP_ID = e_rab_release_resp_p->eNB_ue_s1ap_id; + release_response_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id; + + if ( e_rab_release_resp_p->nb_of_e_rabs_released > 0 ) + release_response_ies_p->presenceMask |= S1AP_E_RABRELEASERESPONSEIES_E_RABRELEASELISTBEARERRELCOMP_PRESENT; + + //release + for (i = 0; i < e_rab_release_resp_p->nb_of_e_rabs_released; i++) { + + S1ap_E_RABReleaseItemBearerRelComp_t *new_item; + + new_item = calloc(1, sizeof(S1ap_E_RABReleaseItemBearerRelComp_t)); + + new_item->e_RAB_ID = e_rab_release_resp_p->e_rab_release[i].e_rab_id; + + S1AP_DEBUG("e_rab_release_resp: e_rab ID %ld\n",new_item->e_RAB_ID); + + ASN_SEQUENCE_ADD(&release_response_ies_p->e_RABReleaseListBearerRelComp.s1ap_E_RABReleaseItemBearerRelComp, + new_item); + + } + + if ( e_rab_release_resp_p->nb_of_e_rabs_failed > 0 ) + release_response_ies_p->presenceMask |= S1AP_E_RABRELEASERESPONSEIES_E_RABFAILEDTORELEASELIST_PRESENT; + + //release failed + for (i = 0; i < e_rab_release_resp_p->nb_of_e_rabs_failed; i++) { + S1ap_E_RABItem_t *new_rabitem; + new_rabitem = calloc(1, sizeof(S1ap_E_RABItem_t)); + //e_rab_id + new_rabitem->e_RAB_ID = e_rab_release_resp_p->e_rabs_failed[i].e_rab_id; + //cause + switch(e_rab_release_resp_p->e_rabs_failed[i].cause) + { + case S1AP_CAUSE_NOTHING: + new_rabitem->cause.present = S1ap_Cause_PR_NOTHING; + break; + + case S1AP_CAUSE_RADIO_NETWORK: + new_rabitem->cause.present = S1ap_Cause_PR_radioNetwork; + new_rabitem->cause.choice.radioNetwork = e_rab_release_resp_p->e_rabs_failed[i].cause_value; + break; + + case S1AP_CAUSE_TRANSPORT: + new_rabitem->cause.present = S1ap_Cause_PR_transport; + new_rabitem->cause.choice.transport = e_rab_release_resp_p->e_rabs_failed[i].cause_value; + break; + + case S1AP_CAUSE_NAS: + new_rabitem->cause.present = S1ap_Cause_PR_nas; + new_rabitem->cause.choice.nas = e_rab_release_resp_p->e_rabs_failed[i].cause_value; + break; + + case S1AP_CAUSE_PROTOCOL: + new_rabitem->cause.present = S1ap_Cause_PR_protocol; + new_rabitem->cause.choice.protocol = e_rab_release_resp_p->e_rabs_failed[i].cause_value; + break; + + case S1AP_CAUSE_MISC: + default: + new_rabitem->cause.present = S1ap_Cause_PR_misc; + new_rabitem->cause.choice.misc = e_rab_release_resp_p->e_rabs_failed[i].cause_value; + break; + } + S1AP_DEBUG("e_rab_release_resp: failed e_rab ID %ld\n",new_rabitem->e_RAB_ID); + ASN_SEQUENCE_ADD(&release_response_ies_p->e_RABFailedToReleaseList.s1ap_E_RABItem, new_rabitem); + } + + fprintf(stderr, "start encode\n"); + if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) { + S1AP_ERROR("Failed to encode release response\n"); + /* Encode procedure has failed... */ + return -1; + } + + MSC_LOG_TX_MESSAGE( + MSC_S1AP_ENB, + MSC_S1AP_MME, + (const char *)buffer, + length, + MSC_AS_TIME_FMT" E_RAN Release successfulOutcome eNB_ue_s1ap_id %u mme_ue_s1ap_id %u", + 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), + e_rab_release_resp_p->eNB_ue_s1ap_id, + ue_context_p->mme_ue_s1ap_id); + + /* UE associated signalling -> use the allocated stream */ + s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, + ue_context_p->mme_ref->assoc_id, buffer, + length, ue_context_p->tx_stream); + + S1AP_INFO("e_rab_release_response sended eNB_UE_S1AP_ID %d mme_ue_s1ap_id %d nb_of_e_rabs_released %d nb_of_e_rabs_failed %d\n", + e_rab_release_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,e_rab_release_resp_p->nb_of_e_rabs_released,e_rab_release_resp_p->nb_of_e_rabs_failed); + + return ret; +} diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.h b/openair3/S1AP/s1ap_eNB_nas_procedures.h index 269387257653e30efef12d630f58fd9b48bcde44..bb2a0488bfd898fb5ec87a62e0d205767c19d467 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.h +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.h @@ -44,4 +44,9 @@ int s1ap_eNB_ue_capabilities(instance_t instance, int s1ap_eNB_e_rab_setup_resp(instance_t instance, s1ap_e_rab_setup_resp_t *e_rab_setup_resp_p); +int s1ap_eNB_e_rab_modify_resp(instance_t instance, + s1ap_e_rab_modify_resp_t *e_rab_modify_resp_p); + +int s1ap_eNB_e_rab_release_resp(instance_t instance, + s1ap_e_rab_release_resp_t *e_rab_release_resp_p); #endif /* S1AP_ENB_NAS_PROCEDURES_H_ */ diff --git a/openair3/SECU/kdf.c b/openair3/SECU/kdf.c index 0717d17c59dbcac17a4e553eaa1c50902998bbc1..1073df8ebedf7f0e6a647b183122e394ce141982 100644 --- a/openair3/SECU/kdf.c +++ b/openair3/SECU/kdf.c @@ -63,3 +63,43 @@ int derive_keNB(const uint8_t kasme[32], const uint32_t nas_count, uint8_t *keNB } #endif +int derive_keNB_star( + const uint8_t *kenb_32, + const uint16_t pci, + const uint32_t earfcn_dl, + const bool is_rel8_only, + uint8_t *kenb_star) +{ + // see 33.401 section A.5 KeNB* derivation function + uint8_t s[10] = {0}; + + // FC = 0x13 + s[0] = FC_KENB_STAR; + // P0 = PCI (target physical cell id) + s[1] = (pci & 0x0000ff00) >> 8; + s[2] = (pci & 0x000000ff); + // L0 = length of PCI (i.e. 0x00 0x02) + s[3] = 0x00; + s[4] = 0x02; + // P1 = EARFCN-DL (target physical cell downlink frequency) + if (is_rel8_only) { + s[5] = (earfcn_dl & 0x0000ff00) >> 8; + s[6] = (earfcn_dl & 0x000000ff); + s[7] = 0x00; + s[8] = 0x02; + kdf (kenb_32, 32, s, 9, kenb_star, 32); + } else { + s[5] = (earfcn_dl & 0x00ff0000) >> 16; + s[6] = (earfcn_dl & 0x0000ff00) >> 8; + s[7] = (earfcn_dl & 0x000000ff); + s[8] = 0x00; + s[9] = 0x03; + kdf (kenb_32, 32, s, 10, kenb_star, 32); + } + // L1 length of EARFCN-DL (i.e. L1 = 0x00 0x02 if EARFCN-DL is between 0 and 65535, and L1 = 0x00 0x03 if EARFCN-DL is between 65536 and 262143) + // NOTE: The length of EARFCN-DL cannot be generally set to 3 bytes for backward compatibility reasons: A Rel-8 + // entity (UE or eNB) would always assume an input parameter length of 2 bytes for the EARFCN-DL. This + // would lead to different derived keys if another entity assumed an input parameter length of 3 bytes for the + // EARFCN-DL. + return 0; +} diff --git a/openair3/SECU/secu_defs.h b/openair3/SECU/secu_defs.h index 4130098c991199bc2ef916bb4680ac9c54f62a11..8ec05f3dafe58afeb6ddb5cd9c542c3818487e6c 100644 --- a/openair3/SECU/secu_defs.h +++ b/openair3/SECU/secu_defs.h @@ -23,6 +23,7 @@ #define SECU_DEFS_H_ #include "security_types.h" +#include <stdbool.h> #define EIA0_ALG_ID 0x00 #define EIA1_128_ALG_ID 0x01 @@ -44,6 +45,9 @@ void kdf(const uint8_t *key, int derive_keNB(const uint8_t kasme[32], const uint32_t nas_count, uint8_t *keNB); +int derive_keNB_star(const uint8_t *kenb_32, const uint16_t pci, const uint32_t earfcn_dl, + const bool is_rel8_only, uint8_t * kenb_star); + int derive_key_nas(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id, const uint8_t kasme[32], uint8_t *knas); diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 6214c81cc693b86c3de7235d4681c11bb22f2be7..2dc1650bfd719208ef5e182b0b79f76e5f12ff55 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -207,6 +207,15 @@ typedef struct { int iq_rxrescale; //! Configuration file for LMS7002M char *configFilename; +#if defined(USRP_REC_PLAY) + unsigned short sf_mode; // 1=record, 2=replay + char sf_filename[1024]; // subframes file path + unsigned int sf_max; // max number of recorded subframes + unsigned int sf_loops; // number of loops in replay mode + unsigned int sf_read_delay; // read delay in replay mode + unsigned int sf_write_delay; // write delay in replay mode + unsigned int eth_mtu; // ethernet MTU +#endif } openair0_config_t; /*! \brief RF mapping */ diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index e323a9d5bca71f6c57fd7716b44d9233a7d8c484..ad5bbda3fe77e37982564880d265cd858d307a83 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -235,7 +235,8 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam packet_size = UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks); } else if (flags == IF4p5_PULTICK) { packet_size = UDP_IF4p5_PULTICK_SIZE_BYTES; - } else if (flags == IF4p5_PRACH) { + } else if ((flags >= IF4p5_PRACH)&& + (flags <= (IF4p5_PRACH+4))) { packet_size = UDP_IF4p5_PRACH_SIZE_BYTES; } else { printf("trx_eth_write_udp_IF4p5: unknown flags %d\n",flags); diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/Makefile b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/Makefile index c9c5f82819e1bce3acef7db958e2a19b37bca99a..77b3d41f25fb2f39d20e77cb94723ce7021a7805 100644 --- a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/Makefile +++ b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -DUSER_MODE -DEXMIMO -g +CFLAGS = -DEXMIMO -g XTRA_CFLAGS = -msse -msse2 -mssse3 -fPIC #ifndef OPENAIR0_DIR diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index a8c1c9b3f56e0bfe5c8683587f40cbc0abebeaec..9b1755954ae84655a75cbe25ba0570291d01097f 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -270,11 +270,52 @@ static int sync_to_gps(openair0_device *device) return EXIT_SUCCESS; } +#if defined(USRP_REC_PLAY) +#include "usrp_lib.h" +static FILE *pFile = NULL; +int mmapfd = 0; +struct stat sb; +iqrec_t *ms_sample = NULL; // memory for all subframes +unsigned int nb_samples = 0; +unsigned int cur_samples = 0; +int64_t wrap_count = 0; +int64_t wrap_ts = 0; +unsigned int u_sf_mode = 0; // 1=record, 2=replay +unsigned int u_sf_record = 0; // record mode +unsigned int u_sf_replay = 0; // replay mode +char u_sf_filename[1024] = ""; // subframes file path +unsigned int u_sf_max = DEF_NB_SF; // max number of recorded subframes +unsigned int u_sf_loops = DEF_SF_NB_LOOP; // number of loops in replay mode +unsigned int u_sf_read_delay = DEF_SF_DELAY_READ; // read delay in replay mode +unsigned int u_sf_write_delay = DEF_SF_DELAY_WRITE; // write delay in replay mode + +char config_opt_sf_file[] = CONFIG_OPT_SF_FILE; +char config_def_sf_file[] = DEF_SF_FILE; +char config_hlp_sf_file[] = CONFIG_HLP_SF_FILE; +char config_opt_sf_rec[] = CONFIG_OPT_SF_REC; +char config_hlp_sf_rec[] = CONFIG_HLP_SF_REC; +char config_opt_sf_rep[] = CONFIG_OPT_SF_REP; +char config_hlp_sf_rep[] = CONFIG_HLP_SF_REP; +char config_opt_sf_max[] = CONFIG_OPT_SF_MAX; +char config_hlp_sf_max[] = CONFIG_HLP_SF_MAX; +char config_opt_sf_loops[] = CONFIG_OPT_SF_LOOPS; +char config_hlp_sf_loops[] = CONFIG_HLP_SF_LOOPS; +char config_opt_sf_rdelay[] = CONFIG_OPT_SF_RDELAY; +char config_hlp_sf_rdelay[] = CONFIG_HLP_SF_RDELAY; +char config_opt_sf_wdelay[] = CONFIG_OPT_SF_WDELAY; +char config_hlp_sf_wdelay[] = CONFIG_HLP_SF_WDELAY; + +#endif + /*! \brief Called to start the USRP transceiver. Return 0 if OK, < 0 if error @param device pointer to the device structure specific to the RF hardware target */ static int trx_usrp_start(openair0_device *device) { +#if defined(USRP_REC_PLAY) + if (u_sf_mode != 2) { // not replay mode +#endif + usrp_state_t *s = (usrp_state_t*)device->priv; @@ -313,12 +354,21 @@ static int trx_usrp_start(openair0_device *device) { s->rx_count = 0; s->tx_count = 0; s->rx_timestamp = 0; +#if defined(USRP_REC_PLAY) + } +#endif return 0; } /*! \brief Terminate operation of the USRP transceiver -- free all associated resources * \param device the hardware to use */ static void trx_usrp_end(openair0_device *device) { +#if defined(USRP_REC_PLAY) // For some ugly reason, this can be called several times... + static int done = 0; + if (done == 1) return; + done = 1; + if (u_sf_mode != 2) { // not subframes replay +#endif usrp_state_t *s = (usrp_state_t*)device->priv; s->rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); @@ -326,7 +376,45 @@ static void trx_usrp_end(openair0_device *device) { s->tx_md.end_of_burst = true; s->tx_stream->send("", 0, s->tx_md); s->tx_md.end_of_burst = false; - +#if defined(USRP_REC_PLAY) + } +#endif +#if defined(USRP_REC_PLAY) + if (u_sf_mode == 1) { // subframes store + pFile = fopen (u_sf_filename,"wb+"); + if (pFile == NULL) { + std::cerr << "Cannot open " << u_sf_filename << std::endl; + } else { + unsigned int i = 0; + unsigned int modu = 0; + if ((modu = nb_samples % 10) != 0) { + nb_samples -= modu; // store entire number of frames + } + std::cerr << "Writing " << nb_samples << " subframes to " << u_sf_filename << " ..." << std::endl; + for (i = 0; i < nb_samples; i++) { + fwrite(ms_sample+i, sizeof(unsigned char), sizeof(iqrec_t), pFile); + } + fclose (pFile); + std::cerr << "File " << u_sf_filename << " closed." << std::endl; + } + } + if (u_sf_mode == 1) { // record + if (ms_sample != NULL) { + free((void*)ms_sample); + ms_sample = NULL; + } + } + if (u_sf_mode == 2) { // replay + if (ms_sample != MAP_FAILED) { + munmap(ms_sample, sb.st_size); + ms_sample = NULL; + } + if (mmapfd != 0) { + close(mmapfd); + mmapfd = 0; + } + } +#endif } /*! \brief Called to send samples to the USRP RF target @@ -339,6 +427,9 @@ static void trx_usrp_end(openair0_device *device) { */ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { int ret=0; +#if defined(USRP_REC_PLAY) + if (u_sf_mode != 2) { // not replay mode +#endif usrp_state_t *s = (usrp_state_t*)device->priv; int nsamps2; // aligned to upper 32 or 16 byte boundary @@ -405,6 +496,15 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, if (ret != nsamps) LOG_E(PHY,"[xmit] tx samples %d != %d\n",ret,nsamps); +#if defined(USRP_REC_PLAY) + } else { + struct timespec req; + req.tv_sec = 0; + req.tv_nsec = u_sf_write_delay * 1000; + nanosleep(&req, NULL); + ret = nsamps; + } +#endif return ret; } @@ -421,9 +521,12 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, * \returns the number of sample read */ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - usrp_state_t *s = (usrp_state_t*)device->priv; - int samples_received=0,i,j; - int nsamps2; // aligned to upper 32 or 16 byte boundary + usrp_state_t *s = (usrp_state_t*)device->priv; + int samples_received=0,i,j; + int nsamps2; // aligned to upper 32 or 16 byte boundary +#if defined(USRP_REC_PLAY) + if (u_sf_mode != 2) { // not replay mode +#endif #if defined(__x86_64) || defined(__i386__) #ifdef __AVX2__ nsamps2 = (nsamps+7)>>3; @@ -490,7 +593,45 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp s->rx_count += nsamps; s->rx_timestamp = s->rx_md.time_spec.to_ticks(s->sample_rate); *ptimestamp = s->rx_timestamp; - return samples_received; +#if defined (USRP_REC_PLAY) + } +#endif +#if defined(USRP_REC_PLAY) + if (u_sf_mode == 1) { // record mode + // Copy subframes to memory (later dump on a file) + if (nb_samples < u_sf_max) { + (ms_sample+nb_samples)->header = BELL_LABS_IQ_HEADER; + (ms_sample+nb_samples)->ts = *ptimestamp; + memcpy((ms_sample+nb_samples)->samples, buff[0], nsamps*4); + nb_samples++; + } + } else if (u_sf_mode == 2) { // replay mode + if (cur_samples == nb_samples) { + cur_samples = 0; + wrap_count++; + if (wrap_count == u_sf_loops) { + std::cerr << "USRP device terminating subframes replay mode after " << u_sf_loops << " loops." << std::endl; + return 0; // should make calling process exit + } + wrap_ts = wrap_count * (nb_samples * (((int)(device->openair0_cfg[0].sample_rate)) / 1000)); + } + if (cur_samples < nb_samples) { + *ptimestamp = (ms_sample[0].ts + (cur_samples * (((int)(device->openair0_cfg[0].sample_rate)) / 1000))) + wrap_ts; + if (cur_samples == 0) { + std::cerr << "starting subframes file with wrap_count=" << wrap_count << " wrap_ts=" << wrap_ts + << " ts=" << *ptimestamp << std::endl; + } + memcpy(buff[0], &ms_sample[cur_samples].samples[0], nsamps*4); + cur_samples++; + } + struct timespec req; + req.tv_sec = 0; + req.tv_nsec = u_sf_read_delay * 1000; + nanosleep(&req, NULL); + return nsamps; + } +#endif + return samples_received; } /*! \brief Compares two variables within precision @@ -684,12 +825,132 @@ int trx_usrp_reset_stats(openair0_device* device) { return(0); } +#if defined(USRP_REC_PLAY) +extern "C" { +/*! \brief Initializer for USRP record/playback config + * \param parameter array description + * \returns 0 on success + */ +int trx_usrp_recplay_config_init(paramdef_t *usrp_recplay_params) { + // --subframes-file + memcpy(usrp_recplay_params[0].optname, config_opt_sf_file, strlen(config_opt_sf_file)); + usrp_recplay_params[0].helpstr = config_hlp_sf_file; + usrp_recplay_params[0].paramflags=PARAMFLAG_NOFREE; + usrp_recplay_params[0].strptr=(char **)&u_sf_filename; + usrp_recplay_params[0].defstrval = NULL; + usrp_recplay_params[0].type=TYPE_STRING; + usrp_recplay_params[0].numelt=sizeof(u_sf_filename); + // --subframes-record + memcpy(usrp_recplay_params[1].optname, config_opt_sf_rec, strlen(config_opt_sf_rec)); + usrp_recplay_params[1].helpstr = config_hlp_sf_rec; + usrp_recplay_params[1].paramflags=PARAMFLAG_BOOL; + usrp_recplay_params[1].uptr=&u_sf_record; + usrp_recplay_params[1].defuintval=0; + usrp_recplay_params[1].type=TYPE_UINT; + usrp_recplay_params[1].numelt=0; + // --subframes-replay + memcpy(usrp_recplay_params[2].optname, config_opt_sf_rep, strlen(config_opt_sf_rep)); + usrp_recplay_params[2].helpstr = config_hlp_sf_rep; + usrp_recplay_params[2].paramflags=PARAMFLAG_BOOL; + usrp_recplay_params[2].uptr=&u_sf_replay; + usrp_recplay_params[2].defuintval=0; + usrp_recplay_params[2].type=TYPE_UINT; + usrp_recplay_params[2].numelt=0; + // --subframes-max + memcpy(usrp_recplay_params[3].optname, config_opt_sf_max, strlen(config_opt_sf_max)); + usrp_recplay_params[3].helpstr = config_hlp_sf_max; + usrp_recplay_params[3].paramflags=0; + usrp_recplay_params[3].uptr=&u_sf_max; + usrp_recplay_params[3].defuintval=DEF_NB_SF; + usrp_recplay_params[3].type=TYPE_UINT; + usrp_recplay_params[3].numelt=0; + // --subframes-loops + memcpy(usrp_recplay_params[4].optname, config_opt_sf_loops, strlen(config_opt_sf_loops)); + usrp_recplay_params[4].helpstr = config_hlp_sf_loops; + usrp_recplay_params[4].paramflags=0; + usrp_recplay_params[4].uptr=&u_sf_loops; + usrp_recplay_params[4].defuintval=DEF_SF_NB_LOOP; + usrp_recplay_params[4].type=TYPE_UINT; + usrp_recplay_params[4].numelt=0; + // --subframes-read-delay + memcpy(usrp_recplay_params[5].optname, config_opt_sf_rdelay, strlen(config_opt_sf_rdelay)); + usrp_recplay_params[5].helpstr = config_hlp_sf_rdelay; + usrp_recplay_params[5].paramflags=0; + usrp_recplay_params[5].uptr=&u_sf_read_delay; + usrp_recplay_params[5].defuintval=DEF_SF_DELAY_READ; + usrp_recplay_params[5].type=TYPE_UINT; + usrp_recplay_params[5].numelt=0; + // --subframes-write-delay + memcpy(usrp_recplay_params[6].optname, config_opt_sf_wdelay, strlen(config_opt_sf_wdelay)); + usrp_recplay_params[6].helpstr = config_hlp_sf_wdelay; + usrp_recplay_params[6].paramflags=0; + usrp_recplay_params[6].uptr=&u_sf_write_delay; + usrp_recplay_params[6].defuintval=DEF_SF_DELAY_WRITE; + usrp_recplay_params[6].type=TYPE_UINT; + usrp_recplay_params[6].numelt=0; + + return 0; // always ok +} +} +#endif + extern "C" { /*! \brief Initialize Openair USRP target. It returns 0 if OK * \param device the hardware to use * \param openair0_cfg RF frontend parameters set by application */ int device_init(openair0_device* device, openair0_config_t *openair0_cfg) { +#if defined(USRP_REC_PLAY) + paramdef_t usrp_recplay_params[7]; + // to check + static int done = 0; + if (done == 1) { + return 0; + } // prevent from multiple init + done = 1; + // end to check + memset(usrp_recplay_params, 0, 7*sizeof(paramdef_t)); + memset(&u_sf_filename[0], 0, 1024); + if (trx_usrp_recplay_config_init(usrp_recplay_params) != 0) { + std::cerr << "USRP device record/replay mode configuration error exiting" << std::endl; + return -1; + } + config_process_cmdline(usrp_recplay_params,sizeof(usrp_recplay_params)/sizeof(paramdef_t),NULL); + + if (strlen(u_sf_filename) == 0) { + (void) strcpy(u_sf_filename, DEF_SF_FILE); + } + + if (u_sf_replay == 1) u_sf_mode = 2; + if (u_sf_record == 1) u_sf_mode = 1; + + if (u_sf_mode == 2) { + // Replay subframes from from file + int bw_gain_adjust=0; + device->openair0_cfg = openair0_cfg; + device->type = USRP_B200_DEV; + openair0_cfg[0].rx_gain_calib_table = calib_table_b210_38; + bw_gain_adjust=1; + openair0_cfg[0].tx_sample_advance = 80; + openair0_cfg[0].tx_bw = 20e6; + openair0_cfg[0].rx_bw = 20e6; + openair0_cfg[0].iq_txshift = 4;//shift + openair0_cfg[0].iq_rxrescale = 15;//rescale iqs + set_rx_gain_offset(&openair0_cfg[0],0,bw_gain_adjust); + device->priv = NULL; + device->trx_start_func = trx_usrp_start; + device->trx_write_func = trx_usrp_write; + device->trx_read_func = trx_usrp_read; + device->trx_get_stats_func = trx_usrp_get_stats; + device->trx_reset_stats_func = trx_usrp_reset_stats; + device->trx_end_func = trx_usrp_end; + device->trx_stop_func = trx_usrp_stop; + device->trx_set_freq_func = trx_usrp_set_freq; + device->trx_set_gains_func = trx_usrp_set_gains; + device->openair0_cfg = openair0_cfg; + std::cerr << "USRP device initialized in subframes replay mode for " << u_sf_loops << " loops." << std::endl; + } else { +#endif uhd::set_thread_priority_safe(1.0); usrp_state_t *s = (usrp_state_t*)calloc(sizeof(usrp_state_t),1); @@ -705,6 +966,11 @@ extern "C" { int vers=0,subvers=0,subsubvers=0; int bw_gain_adjust=0; +#if defined(USRP_REC_PLAY) + if (u_sf_mode == 1) { + std::cerr << "USRP device initialized in subframes record mode" << std::endl; + } +#endif sscanf(uhd::get_version_string().c_str(),"%d.%d.%d",&vers,&subvers,&subsubvers); LOG_I(PHY,"Checking for USRPs : UHD %s (%d.%d.%d)\n", uhd::get_version_string().c_str(),vers,subvers,subsubvers); @@ -743,6 +1009,10 @@ extern "C" { openair0_cfg[0].rx_gain_calib_table = calib_table_x310; +#if defined(USRP_REC_PLAY) + std::cerr << "-- Using calibration table: calib_table_x310" << std::endl; // Bell Labs info +#endif + LOG_I(PHY,"%s() sample_rate:%u\n", __FUNCTION__, (int)openair0_cfg[0].sample_rate); switch ((int)openair0_cfg[0].sample_rate) { @@ -803,9 +1073,15 @@ extern "C" { if ((vers == 3) && (subvers == 9) && (subsubvers>=2)) { openair0_cfg[0].rx_gain_calib_table = calib_table_b210; bw_gain_adjust=0; +#if defined(USRP_REC_PLAY) + std::cerr << "-- Using calibration table: calib_table_b210" << std::endl; // Bell Labs info +#endif } else { openair0_cfg[0].rx_gain_calib_table = calib_table_b210_38; bw_gain_adjust=1; +#if defined(USRP_REC_PLAY) + std::cerr << "-- Using calibration table: calib_table_b210_38" << std::endl; // Bell Labs info +#endif } switch ((int)openair0_cfg[0].sample_rate) { @@ -969,6 +1245,45 @@ extern "C" { } } +#if defined(USRP_REC_PLAY) + } +#endif +#if defined(USRP_REC_PLAY) + if (u_sf_mode == 1) { // record mode + ms_sample = (iqrec_t*) malloc(u_sf_max * sizeof(iqrec_t)); + if (ms_sample == NULL) { + std::cerr<< "Memory allocation failed for subframe record or replay mode." << std::endl; + exit(-1); + } + memset(ms_sample, 0, u_sf_max * BELL_LABS_IQ_BYTES_PER_SF); + } + if (u_sf_mode == 2) { + // use mmap + mmapfd = open(u_sf_filename, O_RDONLY | O_LARGEFILE); + if (mmapfd != 0) { + fstat(mmapfd, &sb); + std::cerr << "Loading subframes using mmap() from " << u_sf_filename << " size=" << (uint64_t)sb.st_size << " bytes ..." << std::endl; + ms_sample = (iqrec_t*) mmap(NULL, sb.st_size, PROT_WRITE, MAP_PRIVATE, mmapfd, 0); + if (ms_sample != MAP_FAILED) { + nb_samples = (sb.st_size / sizeof(iqrec_t)); + int aligned = (((unsigned long)ms_sample & 31) == 0)? 1:0; + std::cerr<< "Loaded "<< nb_samples << " subframes." << std::endl; + if (aligned == 0) { + std::cerr<< "mmap address is not 32 bytes aligned, exiting." << std::endl; + close(mmapfd); + exit(-1); + } + } else { + std::cerr << "Cannot mmap file, exiting." << std::endl; + close(mmapfd); + exit(-1); + } + } else { + std::cerr << "Cannot open " << u_sf_filename << " , exiting." << std::endl; + exit(-1); + } + } +#endif return 0; } } diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.h b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.h new file mode 100644 index 0000000000000000000000000000000000000000..47ba171f1b9805973d2076629037bb9e920d22c9 --- /dev/null +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.h @@ -0,0 +1,89 @@ +#ifndef __USRP_LIB_H +#define __USRP_LIB_H +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/** usrp_lib.h + * + * \author: bruno.mongazon-cazavet@nokia-bell-labs.com + */ + +#if defined (USRP_REC_PLAY) + +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include "common/config/config_paramdesc.h" +#include "common/config/config_userapi.h" + +#define BELL_LABS_IQ_HEADER 0xabababababababab +#define BELL_LABS_IQ_PER_SF 7680 // Up to 5MHz bw for now +#define BELL_LABS_IQ_BYTES_PER_SF (BELL_LABS_IQ_PER_SF * 4) +typedef struct { + int64_t header; + int64_t ts; + int64_t rfu1; + int64_t rfu2; // pad for 256 bits alignement required by AVX2 + unsigned char samples[BELL_LABS_IQ_BYTES_PER_SF]; // iq's for one subframe +} iqrec_t; +#define DEF_NB_SF 120000 // default nb of sf or ms to capture (2 minutes at 5MHz) +#define DEF_SF_FILE "/home/nokia/iqfile" // default subframes file name +#define DEF_SF_DELAY_READ 400 // default read delay µs (860=real) +#define DEF_SF_DELAY_WRITE 15 // default write delay µs (15=real) +#define DEF_SF_NB_LOOP 5 // default nb loops + + +/* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ +#define CONFIG_HLP_SF_FILE "Path of the file used for subframes record or replay" +#define CONFIG_HLP_SF_REC "Record subframes from USRP driver into a file for later replay" +#define CONFIG_HLP_SF_REP "Replay subframes into USRP driver from a file" +#define CONFIG_HLP_SF_MAX "Maximum count of subframes to be recorded in subframe file" +#define CONFIG_HLP_SF_LOOPS "Number of loops to replay of the entire subframes file" +#define CONFIG_HLP_SF_RDELAY "Delay in microseconds to read a subframe in replay mode" +#define CONFIG_HLP_SF_WDELAY "Delay in microseconds to write a subframe in replay mode" + +/* keyword strings for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ +#define CONFIG_OPT_SF_FILE "subframes-file" +#define CONFIG_OPT_SF_REC "subframes-record" +#define CONFIG_OPT_SF_REP "subframes-replay" +#define CONFIG_OPT_SF_MAX "subframes-max" +#define CONFIG_OPT_SF_LOOPS "subframes-loops" +#define CONFIG_OPT_SF_RDELAY "subframes-read-delay" +#define CONFIG_OPT_SF_WDELAY "subframes-write-delay" + +/* For information only - the macro is not usable in C++ */ +/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* command line parameters for USRP record/playback */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +#define USRP_RECPLAY_PARAMS_DESC { \ +{"subframes-file", CONFIG_HLP_SF_FILE, 0, strptr:(char **)&u_sf_filename, defstrval:DEF_SF_FILE, TYPE_STRING, sizeof(u_sf_filename)}, \ +{"subframes-record", CONFIG_HLP_SF_REC, PARAMFLAG_BOOL, uptr:&u_sf_record, defuintval:0, TYPE_UINT, 0}, \ +{"subframes-replay", CONFIG_HLP_SF_REP, PARAMFLAG_BOOL, uptr:&u_sf_replay, defuintval:0, TYPE_UINT, 0}, \ +{"subframes-max", CONFIG_HLP_SF_MAX, 0, uptr:&u_sf_max, defintval:DEF_NB_SF, TYPE_UINT, 0}, \ +{"subframes-loops", CONFIG_HLP_SF_LOOPS, 0, uptr:&u_sf_loops, defintval:DEF_SF_NB_LOOP, TYPE_UINT, 0}, \ +{"subframes-read-delay", CONFIG_HLP_SF_RDELAY, 0, uptr:&u_sf_read_delay, defintval:DEF_SF_DELAY_READ, TYPE_UINT, 0}, \ +{"subframes-write-delay", CONFIG_HLP_SF_WDELAY, 0, uptr:&u_sf_write_delay, defintval:DEF_SF_DELAY_WRITE, TYPE_UINT, 0}, \ +} +#endif // BELL_LABS_MUST +#endif // __USRP_LIB_H + diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 35b29e31b44bcd08f30e686bf44f36d188204177..22c7402faed6d068d5eba982256240786b55c396 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -40,9 +40,10 @@ # endif # include "enb_app.h" -int create_tasks(uint32_t enb_nb, uint32_t ue_nb) +int create_tasks(uint32_t enb_nb) { - LOG_E(ENB_APP, "%s(enb_nb:%d ue_nb:%d)\n", __FUNCTION__, enb_nb, ue_nb); + + LOG_D(ENB_APP, "%s(enb_nb:%d\n", __FUNCTION__, enb_nb); itti_wait_ready(1); if (itti_create_task (TASK_L2L1, l2l1_task, NULL) < 0) { @@ -58,11 +59,7 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb) } } - -# ifdef OPENAIR2 - { # if defined(ENABLE_USE_MME) - { if (enb_nb > 0) { if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) { LOG_E(SCTP, "Create task for SCTP failed\n"); @@ -85,19 +82,7 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb) } } -# if defined(NAS_BUILT_IN_UE) - if (ue_nb > 0) { - nas_user_container_t *users = calloc(1, sizeof(*users)); - if (users == NULL) abort(); - 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; - } - } # endif - } -# endif if (enb_nb > 0) { LOG_I(RRC,"Creating RRC eNB Task\n"); @@ -106,27 +91,8 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb) LOG_E(RRC, "Create task for RRC eNB failed\n"); return -1; } - } - if (ue_nb > 0) { - if (itti_create_task (TASK_RRC_UE, rrc_ue_task, NULL) < 0) { - LOG_E(RRC, "Create task for RRC UE failed\n"); - return -1; - } - -# if ENABLE_RAL - - if (itti_create_task (TASK_RAL_UE, mRAL_task, NULL) < 0) { - LOG_E(RAL_UE, "Create task for RAL UE failed\n"); - return -1; - } - -# endif - } - } -# endif // openair2: NN: should be openair3 - itti_wait_ready(0); diff --git a/targets/COMMON/create_tasks.h b/targets/COMMON/create_tasks.h index 493c441f59adbd6bfe2d544e835abb066f58e8f6..ff1d9ace5199fbc0dbf3bf8b9cc7a52f1db983c5 100644 --- a/targets/COMMON/create_tasks.h +++ b/targets/COMMON/create_tasks.h @@ -26,7 +26,8 @@ /* External declaration of L2L1 task that depend on the target */ extern void *l2l1_task(void *arg); -int create_tasks(uint32_t enb_nb, uint32_t ue_nb); +int create_tasks(uint32_t enb_nb); +int create_tasks_ue(uint32_t ue_nb); #endif #endif /* CREATE_TASKS_H_ */ diff --git a/targets/COMMON/create_tasks_ue.c b/targets/COMMON/create_tasks_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..bd36511b524a093504730643748f55bea95254ff --- /dev/null +++ b/targets/COMMON/create_tasks_ue.c @@ -0,0 +1,80 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#if defined(ENABLE_ITTI) +# include "intertask_interface.h" +# include "create_tasks.h" +# include "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 +# if ENABLE_RAL +# include "lteRALue.h" +# include "lteRALenb.h" +# endif +# include "RRC/LITE/defs.h" +# endif +# include "enb_app.h" + +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 (itti_create_task (TASK_L2L1, l2l1_task, NULL) < 0) { + LOG_E(PDCP, "Create task for L2L1 failed\n"); + return -1; + } + +# if defined(ENABLE_USE_MME) +# if defined(NAS_BUILT_IN_UE) + if (ue_nb > 0) { + nas_user_container_t *users = calloc(1, sizeof(*users)); + if (users == NULL) abort(); + 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; + } + } +# endif +# endif + + if (ue_nb > 0) { + if (itti_create_task (TASK_RRC_UE, rrc_ue_task, NULL) < 0) { + LOG_E(RRC, "Create task for RRC UE failed\n"); + return -1; + } + + } + + + itti_wait_ready(0); + + return 0; +} +#endif diff --git a/targets/DOCS/oai_L1_L2_procedures.ipe b/targets/DOCS/oai_L1_L2_procedures.ipe new file mode 100755 index 0000000000000000000000000000000000000000..2062240c14ad8249bcfa0bf34f04ced87c2f8c61 --- /dev/null +++ b/targets/DOCS/oai_L1_L2_procedures.ipe @@ -0,0 +1,12461 @@ +<?xml version="1.0"?> +<!DOCTYPE ipe SYSTEM "ipe.dtd"> +<ipe version="70107" creator="Ipe 7.2.5"> +<info created="D:20160514115229" modified="D:20171018195314"/> +<preamble>\usepackage{setspace}\usepackage{amsmath}\usepackage{stackrel}</preamble> +<bitmap id="1" width="418" height="289" length="22283" ColorSpace="DeviceRGB" Filter="FlateDecode" BitsPerComponent="8" encoding="base64"> +eNrsnQV3G9m2rX/Uu+/dce49p0+fhnSHwbHDDN1Jh8GOmZllmZmZmRnFZmbLJFtmtvWmVIla +LSdpx3YcyV5z7KFRKpVKVUu1vz1Xwd4yGYlEIpFIJBKJRCKRSCQSiUQikUgkEolEIpFIJBKJ +RCKRSCQSiUQikUgkEolEIpFIpEOrra2toaEhDdwwzdwqEomkdRocHHr+/JVEMqVRWzU+PvHs +2QuxWEx/EIlE2qMCAwMfPvw9ISFRo7YqMjIKWxUeHkF/EIlE2otGR8du375z48atBw9+m52d +1ZCtgrG8d+8BturOnbsTE5P0N5FIpF0rKCj41q07ly9fxavm2LmoqGjlVpGdI5FIezRyV69e +B0+uXbvx4MHvmmDnpqZg5O5je7BV2DbYOYlEQn8WiUTai5FjCqbj4xM0x8gptyosLJz+LBKJ +tBcjxxTYp/v3H87MzHzDrWLOyDFGjilXr964c+cenZ0jkUh7NHJK4xQXF/8NtyoyMuqjW0V2 +jkQifamRAzpUjZwm2LntRk7Vzk1O0tk5Eom0I21tbbFYXqDZtWs31Xhy/fpNzP9WxikgIBC/ +jm346Fb5+vpjy+nvI5FIO6GcSNQoEAiSkpKVxunKlWtXrlzPzs7B/Obmlm+yVU1NTfj1tLR0 +VTuH6dTUNMxvamomypFIpC9Se3vHjRu3lJRDYjgy8u2fqOrt7VO1c5ju7e2hP4tEIu1CQqFI +jXLd3d+eJ62tbWqUa2lpoT+LRCIR5UgkEokoRyKRiHJEORKJRJQjypFIJKIcUY5EIhHliHIk +EokoR5QjkUhEORKJRCLKkUgkohxRjkQiEeWIciQSiShHlCORSEQ5ohyJRCLKEeVIJBJRDlpZ +WVEdynB2dnZpaYmZXltb6+rqRvlU95sjI2Ls8tzcPB0MJNJBqqKiMioqmplG9UxISJyampbJ +B2sYDQkJ9fBgeXh48PkC1a+sr6/HxycoR1Pt7OzMyso+IpTr7Oy6e/d+T8/7LQ8NDS8rK8NE +c3OLpaW1l5e3m5uHlZXt8PCw6rc2NzcjIiJdXd28vX1MTc0qKyvpwCORDkwpKal37z7g8XhM +ZbSwsJyYmJienjYyMsnPLxgcHBSJRM+fv+BwuMqvwLQwizFv6+vrAcMjQrmurq7ff39kZWW9 +vr6Gt8HBoUDWwsKCsbFxc3Mzs0xGRiab7a36rfT0TABwc3MD021t7TY2touLi3TskUgHo/T0 +DHd3TxMTc8abOTg4zc3NxcXFJyYmKZfp7+/v6OhUpZyDg8Pk5PtBS7lcro+P79/+kEjUqEa5 +np7eb777fX3923pE/9xWNTY2BgQEhYSExcTEKrxcWEMDp7a2zt8/UC2xVU7DIdvY2PX19akG +kAaVIJEOTKBZaWlZbm4ei+WFt05OLlNTU6AW40yAPoFAgDQN7k41YwXllKen4AN3QjlN8HLY +HX+F/PzeF1BddQhFTDs4OCo/ZUpgYBAM2AfKNfn6+gFib94YDAwMIHOHyy0oKExNTcWny8vL +YWERyPTT0tIRJZVGwUlpfUkk0sFTLjs7FxOWlpbl5RXe3r5SqRQVGQ4NM5Gxoo6DaajssD0w +fpmZWTB7Ci8nUXo5pGOq69zY2PD19XV2dnVwcFYWY2NTwE3JE0ybmZmrLuDq6l5WVv5VdxZ0 +EgiE4Daf/74gl1Qbwys9PV35KVOEQqES6aCcp6e8OeDz+XZ29gEBgdh9THt6spiUv7m5paGh +AQksnKqLXK6AuYeHZ0tLq3IzAMbR0VE69kikA6NcRkYmk5a+fPnq3TujpaWlysoq2A/Ailmm +urrazc1jaGgoP7+gsLAQjgWWj8fjM5/GxydGRkaqrhPp2MzMzNTU9JSKqqqqlbkh4+UAENUF +YBeV1ysPTECQWsba3d31+bwboWCmIyOjbt68DWTBrdnY2IL/mMD8yspKfX3D+fn5aYVg6jDH +0tJ6bGwMC1RX1zx//mJ8fJyOPRLpYBQTE5uamsZMw6rBzMDLYRqZF/xVXFw88i9LSyuATvVb +XC7P2NgEn4aHR5qamo+Ojv3tDzU1NatlrDCH33z3v/TqA1LXkJAwZhq0NzExQygwDUrDANvZ +OTo5OQOD7e3tal/Mz8+3t7dn/K3yEi2JRDoADQ8PK7MneLDGxsaVldUPPqe7pKQUWSRsyfYv +joyIi4tLsMBHP92uw3GNFSFSWlxGyFKV0wjFwsLCp767urr6mU9JJJK2i559IJFIRDminIZo +bm5OKBQq3/b3909MTK6vr1dX1xTKVVRf3/DRLyJ6cPjKuysnJiZUb6Hp6uqamZmh8JKIckS5 +b66ent5bt+5UVb0/GRsYGFRSUiqRSH777VFCQmJ8fIKHBysmJlb1rj9Mh4aGu7l5JCYm4VMn +J5eVlZWysjJfX3/lMpgpEAgovCSiHFHum6iqqgomraOjY3R0tL9/wMDA0MDgHXPvd3h4eEVF +5djYmJOTk3J5ff13yqf8oPLyCkBM+TY0NGx0dKymplZ5sQZisdiNjY1UF0hEOaLcwQv2zM7O +MTU1/cGD3woKCgcHBwMCgvPyClxc5OCKjIwG5UC8d++MuFweFBcXHxgYqHrlxd/fv7S0TG21 +ZWXlRDkSUY4o9801MzNrbGzMXP+NjIzMzc0bGBhknoWxsbGrq6tPTU2DVZNKpX/88QTZq79/ +oIuLK9za+vo60AfvNzc3HxAQCOemtmbkuaqU8/T0EolEVBdIRDmi3AFrclJiZmbOnGTLyMjM +y8sH5Tw8PPFWLBbjIxcXt9raWrWM1cHBicPhREZGeXl51dXV5eTkhodHqCSw5fX1DfjTVTsu +cHBwQEZMdYF0WNXY2KRGud7evm++Ve3tHWqUa2trO2p/DRJPcCw5OQXtztu3BkVFxf39/YAY +82lxccm9ew/h6MbGxt++fdsv10Bzc8vbt/qYUq5kelpqamqenZ2DT5HePn/+YmBgYHl52dDQ +uLKyCjNhES0sLFX7MSCRlNo4FGpo4KpRrqW57ZtvlVDYqEY5gUCoLSFVPS22R0kkkuDgECSh +LBYbXg55aHp6uvLT4OBQwH9paclNLg+Uj55hGx8fx0pYLJavrz/cIDNzcHAQbzEzMDAEbpCq +81HW9PR0W2tneVlVfFwSDjYfHx8vtqeLq7OTs72tvYWNnXYXO3vLd0b6ly5dVfLk8qWrxiaG +mP9tt8rQ2OCyylZhCzHn227VDguOClsHa2cXRzc3Z08vTzabHRoanpKS3lDP6+0ZUPaIssNm +1MfHt7q6Go7L3NwcnKf6SNpHkybgNyYlprq5uzu42LizbWKSfUrrE5p687tGS3smyodna0YX +6qbWeVPrXK0uy7KmSl7iubMXP8DkykWdS4LO7EVZ4zfcqiVZU31T+oXzutgeBnHnz+vWilIx +XwuiusGTrHFG5moGpdXdY2Wd4hJBR05+RXRYrKezh6WTq7wbmdycgt6ezz0srOweoaenF6Dz +9vbZfgWBRNqdOtq7o6PiHBxtWb52RdVxneJSHLeo8osy0YJMOCsTzGzxpFu86Q0czxzJWoO2 +lyWZqIKboEY5XkcmdvYbbhWiXdeUqka5GmEK5mtJYDk4QlBwqOCAmZMJFmQiHEV4HV+qF3Xn +peQEO7hYurq6ZmfljYrVe0EB1ohppK+hqqo6V1d3Z3fL0roE8XztovywFOEQxRE7sVJ/WAto +Vs6JV6Mcty0DFfMbbtW8TFgrSlGjXLUgGfO1O+Cr9WgcEdslWSNazK6xspTsYDtHC1/vgLbW +930+p6amuri4MV1FkUj7paLCUlt7W78Ql46RkgW5ZxOhFT7EZCPKaUKZXG2Y2eLD4Em3+PVN +GbaOJoGBgXl5BU5OLqurq1QrSfulluZ2JwfnoAj33olyOLdZGX9ytf6I8A0FvmJF1lTF335e +LmtJfl6O8622alnW1NCcpka5usbUZfl5ucNmrZHhgt6rsuackojbt+96e/tRN1CkfdHi4mJo +SIStg3lTXwFq9IyMf3TgxpSxpbreyfKJpfqCqig1ysE1jS3W9UnKx5frDnir8Iu9krLxxfqy +hng1ypXUxWF+32TZwW/V1y7STZ54vsbS1rC0Pq6sLsHcyhz5BVVS0l7U1tppZWWTXx4zKxN8 +29TsG/oHZEx2TqZ37t69/+AeAxNlefDw/q3bt929baUbvIM0t9ik6XWui6fV7Tu37z+8r7pV +mL7/4P7tu7ed3C2m1riTaw2H6b+Y2eTbu5hFJnjBrKLNHZmrYQc4env7kqkj7U452fkWViYd +wyU4nCSHqLLs4txXblnEyRPndHQuqSIOReeC3pnTF8q5CXMHfh4Mv1hcG3v65Hlsg/pW6eid +Onm+sDr6MJ2dm1itX5SJgqPcXFiWaHBxQI6v1M9s8RZkosLKWCsrq9aWdqqzpC9SaHCET6Cz +ZJVzNC3cXy0EZ2qN88741dkP6aqyAHFWdkazm/yDt0z4RRhIMyuDM2d01Lbq7BkdE/O30g3u +YWqb0NTmlIYbmb0ZX6pTveYFW4uP0BabWRhVVdJdJaQdaXNz09vLNzbFF62kdJN7xBH34QKr +qKgm5ty5i3/JDfWuXNTRqxGlfCvLhN+t4CZeuKCnlrGeP69b1hC/cFiM3LhiT3kdWa/fPusQ +F83KBOPLH7kCPrZQZ21vlpdbSFWY9LeIc3FyyywMX0SWus4hvqnbORXjxBi5mS3+tzr3Basm +3YSd0z9zWmWrFEZuWv5YwSExcojwwFTF23cvqvhJaG4+RUIsNrXGdXK3TEvNoopM+ozc3b1y +SqNWZM1IBAhuanausDrm3Nn3dk5PbuQufUMjp/QwFdyEC+f1PlxjVRo50SFpX9Y50+tcazuj +xEx/ZKafvegsP003uyVwcrMoyC+mukz6qAL8gxMzAnAsEeI+e3ZOhzFy1vZGs9/OyKmenTO1 +1GfOzsFqGsuN3CE5I4fjcFEm8g12YvnZged/e1gCdDC3klWOlb1xXS2HajRJTYnxKSHRnorn +HylR/czZuWjYOV3dy5pg5P58KENu53T1dC/DyJUeIiOHBjctL9jc2gDg2uFNzgDdrIw/Ol9n +am7c1UlDY5P+FI8rtHEwmZUJjs4TW7vKnhoYO3fsp1PvjZwGmF7lxVZslfzS6vphMHKAFVhd +35T6xuB570TZzNYX3Is+riB/50iJqbm5sscS0hGXRDJtbGI0MFU1u8UnlP2tnSuoijp18nyN +SIOeFZVfbOUkYKtK6uIOx6VV+LGe8VIgrqE5DXu0/aLqTnxgUXWcF8ubKjgJcnFyq21MR646 +ThzbgZ0bnq2KTfUZX67TnLOXsHOji7XYKvF8zSEwclOwoysNZlb66QUhn7/isINzes7FRWVU +x4+4Ksqr2QGOi/IrDhpxtlki74xOk0vD1AYHTmNqXWO3qkGzA/jXogij2jEA88bytfMPdQam +9nJYSjd5owt1pmbGs7NzVNOPrJaWlnAMDE5XzWzyNCHtglMalJYPaHbBFg7OVAzSVu1TGZmv +mpMJpje54x8yzfh0PxsHY+kGb+93bC7K7/+JDfAPpsp+ZBUVGZtVHLHrpGAfLRyO88LqKGs7 +Y3tHazcPR1cPBypHoDi6uNlb2Zp5+dv2TpbObPEX5B0yJxoYvRycrpTuR8sLZzu7JbBxMOno +6Kb6fgQllc5YWJpMrXG/eUdkyFDi0rzfvjUsLa3o6Ozu6e3v6emjcgRKf3dPX1Nza0hwhIHh +q6GZip7x0tf6z4Vd2fO7uuLwqRyB15bl5uZBVf4IKjYmIbvk2xs5JMu8jvS3b/U7u7onJicH +h4YGBgepHJ0yPDIinZmJi0t2dDezsjfKr4hc3NdjcnINmYLQzsn886PkkA6hkZueMTU3HF+q +1wQjFxzlGh0dL5ma6h8YoHIEC5q2oeHhP/54Hhbn/jWaXSTCtaJ0NtuPKv6RUk52flJm4Dc3 +cswR6BvkkJdXNDo2RvX9aBY4upERsaOTY4e4QLq1/xfCJIobpy2sjCcmJFT3j44cHR07xSUz +GnAbMCjnF+JIlDvilBseHgHlWgZzp79OZ19o0JOzgtC4U90/IurrG7BzMp3bEmjCfa07oRxq +gXh0VKvLiFi8dxogrROPHcI4HADl0KB3ikudnZ2p+h8RJcQn51fELGrGM91/SzlUgb7+/pra +2qLikuISrSxFxcUNHO7eT161trWXlJRqaRCYOHC43G9COeZuJTsnc7QVRICjIFdX157x8q9x +AuRrUA7zwbcXL16xWF5eXmxtLB4erJcvX4tEjcMjI7um3Nj4uKurm4WFpZYGQREHz5evXjc2 +NanF4QAoxyStKdlB1JnwUdDMzIyNvdmUxvRc8beUQ+1OTkmNiIjU6rC7uLjV1tbthXKIj62t +3fDwsFbHwdnZta6+4ZtQblYmaOzJ86ErrUdAnAZ+QJjrogZcXd055VLT0kNDw7S+dtfV75Fy +9vYO3d3afQ+/k5NLfQPnm1BuaoM7tlRn62C9srJCHDj0J+XKOUma09EiUY4odzCUYw42Z3eL +nu4+4sDhVmBAUGNvvuaMP0iUI8odJOXC41g11fXEgcMtFzfnwemqaY0ZgvCrUi42Ns7JydnZ +2cXBQT4C++joKGaKRCLMdHFxRY3D/OLiEtWvSCQSzE9NTVPOSU5O+bASJxbLC5VSSylXW1vr +6Ig9cWUCEhAQKJFMYT7WiWigYD4W8PDw7O7+sy/xvr5+hM7GxhZ/weTkpFZTblEmKqiMTU3J +JA4cYi0sLNo5WU2taVCn2V+Vck+fPj9x4tTdu/dRfv31xO+/P15cXMzPL/j++x9u3ryNmVeu +XPv++x8DAoKUX8nNzfvf//3X9es3Z2dnmTkGBoa//HKcWQnWdvv2XYaWWke5iIhI7Di2XxmQ +t2/1NzY2Ghoafvjh52vXbjDzz5w5j90HdvCVysqqM2fOXbhwkdl3zO/s7NJeys3JhPz27JCQ +MELBIdbgwLCLu/WMjK85/dx+bcrBhDDTmZlZP/74s0jUWFlZefr02b6+vs3NTaAM7uX48ZPt +7R1YZmtry9DQyNbWDgwsKytnvvjunRFAx0yXlpZiJXl5+dpIuejoGD29K8pz776+fseO/Qp7 +hpiAYF1d7/FVVFT03XffV1RUYUmg79mzF+PjE4gVl8vD24KCQu2lnFTG7xwp8fambtIPs7q7 +et1ZtnMywRGh3PPnL42MjEcU8vHx/fnnXzo7O8vLK0C5oaH3d4d2dHSCcmlp6Zju7e29fPlq +T0+PubmFmZk5swDW8OLFK2YlYWHhP/10rKKiQhsph/z93DmdoKDgmJhYTIPkDx8+Wltb4/MF +CIi7uycwGB+f8OrV63PnLojFYqT2iJiS9jJFt6tanbFKN3l9kxWentQLkwZpclLS1bWfZ5tb +WzrcvW3m99bRtBZRztDQ+NSpM4AYsjN4MNi2zc0tuBFUauXpNUygUqN2YzoyMhpgVHi2sosX +9SYm5KehrK1tlCv54YefLCwskfZqI+Wwj9gR7Bd2BMXZ2aW/X94ZUUMDBxHAfIQFO4igCQRC +JgjweEKh8NBcfZje4A7NVLu6uhBbNEc1NbXe3j77uEIBv9EnyElzbpb72pR79erN06fPcnPz +srKya2pqkJBiZk5OLqozjBmzTHt7O6o8ZjIZ7o0btzw9WZaW1phZVCQfot3ExOzBg9+wkuzs +7IqKyo2NDS29+gCrpqt7aWxsjMfjX7hwEZRjAlJf3wCaISEdHBy6e/c+OD8zM4P5HA4XXk41 +Rc3IyOzp6dVeyk2tc8YW6x0c7IgtmiM0soGB+9llfX0dLzTac0nWdEQo9+TJMzs7e7WZ4BUo +19bWNjc3D7dma2sHhzM6Otbb26ejo+vg4Ojm5s5ied26dcfc3JLJWGFv9hh5jaHc5fn5eUyn +p6f/7//+Kzw8QnGYySnX0tIqU1yA/umnX0xNzRXXqhbu3XuAgh/FtzIzM//nf/4ZFRWt3ZRb +qreztz3KVNG0m6L3nXJ1tdywGNbXptz4cp10i7fDs39flXJ37tx7985QbWZWVtZ33/0HQEOO +dvbs+WPHfmXSVScnZ8xRWrWgoODvvvu+r69PX//dH388PQSUCwkJ/eWXExKJvI+1zc1NeNTv +v/+hq6uLz+eDeHy+gFkMof5//+8fzIlKLpd76dJlZOsIF5LZd++M5ubmiHJaqpaWFhh4ZIhE +uX04+7HOLamLq+QnzcmEf8u6r0q51NS07dcEOzo6goNDwsLCQ0LCgDK4F6bWJyYmFhYWKRdD +5fP3D+js7ELempmZfQgoh0Q1PDxSeQVBLBb7+vohXR0dHUUcxOJR5SUGeDxQDjHB24mJidjY +OD8//+zs3NXVVa0+L3dkKdfY2Igk5dq1G/fuPeTxeBq1bUKhaH/v+edxRZHx7A1Z+8wW7+NF +xocNw5G2l7Iqa/YNdjp54pyjqzm3PXNeJlCwjp59oGcfiHIHLZGoEUkK+Hbz5u0rV65hwt/f +Hw134SdUWVkJc7X3gtYTamtr6+zsbG/v+FRBKoH21MXFpbu75zOLtbe3d3V1j46O7aTk5Rb5 +BDr1j1W0DOR/qnSMFPVMlPaM776IZ6p9ghxPnTx/+tQFPb0rcta1Zc59gnVEOaIcUe5rSCAQ +2NraK/l2+fJVply/fvPGjVufKLfxKb6yX+Xq1ev46b8t2KodLrbDcuXK51Z4+crVm7duPXh4 +7/6DPZSH9xDZS5eu4Of09C4rWceT+zqhGuuIcl9EuZ6eHqIcUe4zWlpaqqmptbGxVdDs9hfB +4QMirh1w2fcfBXxAns8UXd3LF3UuXby4h6JzCVhTjRvDukt6V1w8LYWd2bMygXLY9B32L6ft +lEPt3nv/cjh0+/r6tDoOjo7O36p/uSNCORwhr169vX//IbzZl/KNyt4LWIc09sxpHScPi0Fp +JTNI4k76Ci4pLX327IW9g6MjaoIWFjs7B3lfwY177SvY3d3D0NBYS4PwPg7yvoKbiXJfVWtr +a2VlZfr6hshV4ei2WzUkkp8pB2/k9j1j/XaIuwK+Xbiga2z2Nr8ianSxVqK49rqT0W36+vuF +IlEDh9PA4Wpn4TQ1N+99oKvOri4Ol6u1QfhkHIhyX0Orq6slJaXv3qmz7vr1W3fu3MXMjxZQ +br/yR6xn5+fu/nYx7MKtW3d2UrAXOhf0Tp2SXxf4TDlzek8Fa9DR0VOyV8G3Cxd19Cxs3lVw +E6SbvAWZUHl7yQ7H8ELrr+1lX0ZnPpRxIMp9TdatFRUVIYdlWIc0Ni8vTyKRjH9MExMT+Dc6 +0ZruWd3d3XgRiUQ8Hv8zEgiE8fEJDg5OmOB/dkEOh1teXrGTEhIcbutoWlgek1UU9tGSXRKW +lB0QleQdk7z7kpjhb2Khf+GCHuPfQDxLW8NqYfKMjC/n2187fdo55UbEYu0t+0U5rQ7Cp+JA +lPvaWllZhq/T1ze4d+9hTU2Npt3rwjyDs28rFLZEJ/nIZN2LMtEnSiNeF/ZWZLL20BjPH/9z +Qkfn0nu+bfHnVfzbLkad5vEF1fh7amu1sVRX14gaG1GX956x1tTWaWkQPhMHotxBsW4lKyur +ublFo7ZKS599mJcJgiLc9A1fMP7tU3zb+UiFpWVlL1++cnZ2dXV108bi5OT8+vXb7SP0fenV +B09PlomJqZYG4X0c3rxtam454lcfmE4SVN8yczY2NpaWliHmqZMjIi2lHJjWO1mG18/z7Yvu +JAkLC6c7SWxsbHfXHzvdSaJRlBsaGjYyMhofn2DepqVlNDQ0zM/PGxqaID5oCxwcHNva2ohy +mkw55nDaYafrdFcwPftwFCi3vr7OPEEMn4Y9vnbthouLG/NRaGh4SUnp2NiYmZnlikLt7R3G +xqZ777NUK1Rfz/H3D9RGytEYXkQ5opxSnZ2dlpaWHh6eDg4OtbW1g4NDXl5sUC43N08mH48j +qry8Ynx83M7OgVleLB61srJeWFg4CpTjcLh77M6LKEeUI8odMOU2N7emp6dbWlrz8vJBMB6P +B3xxOByYNLi1nJwcUM7Hx3dqaur16zdSqTQxMQmUm5mZefz4D2ZouZcvX2PmISabRCJRDkmw +sbHR3NyMaBDldkE5sVgcEBDo7x/g5+fPZnsXFRUxJ3UzMrJwjGGmt7cvkgVkCirH52ZlZSXa +WR8fP6FQxMzs6Ojw9fVj1uPt7QNYaRflUIOwp9h47BQC0tvbh5nY68DAIMxE8fLyRn1cX/+z +D2QccrGxcZ6erJiYWFRYZmZWVrYybmFh4RMTE0Q55eWD0dFRPl+Qk5MbGBjMYnlhNxEokKqm +pratrd3KyoZZMj+/ICcnb3Bw0N1dPvZEYWERFo6JiauoqEQ8LSwsmV41+vsHHBycAMPDSjlE +4OnTZ8zjivj/TUxMR0bERLldUK6xsfGnn37R0dG9cuXahQsXf/zx57i4OMxHA/rzz78wt2cf +O/br5ctXcRxi/vLyMg6tH388hjn41rFjxxkjXVBQ+P33P+jpXcbyZ86cU/aUri2UQ2b0n//8 +yOwvNv7q1es4orq7e3755TjCgpm6upewgw4Ojmtra1i+tbX12rUbx4+fQhyw/M2bt8F5zH/z +Rl8ZN0w8fvyEGc71CFJuaWlpeHi4vr4+KSkZjQV2Ci2Cv79/RkYmnBs+Uu02HxbOyMiYsS5o +UJClYofd3N6flGOzfX777VFDAwcZKw4/5bfMzMyRyh1iO1dWVmZsbDIxMWlu/n5Px8cnRkZG +EFUk+ES5Haq5ueXEiVNVVdU45ObnF5AF3Lv3ABXZwMDQyMhkaWkZRSgUyh86MzaRyTsJzwAN +EhIScQzDwJiamj958gzLwwudOnWms7ML68GheOPGLeXAhVpBOdiG+/cfoq4xQ68C7CkpqaDK +yZOni4tLEITZ2dmgoOAffvipoqIKtgR7ff36zY6OTmAf/gQMZLInff13hoZGG3Jtwteh1Sgp +KT0ilFtcXMQBgCMhPj4eVt/DwwOYioiIgHlrbGxC/vX50UB4PL65uSUwaGhoiCYSTkZJORxp +Dx/+Xltbh4z10aM/AD0UNEywgkyjc4gFF/HHH0+ZIVegsLCI589fhoZGoKruLmM6mpRDRS4s +LJZKpTiufv/9Mcr6+jpqKzOuwYfG1PvSpSsKrJnheFPORx1nxuoqLi4G5QQCEdYD13f58hUT +EzMtopyHh+fdu/cnJyex/ciYYMMyM7PgNxCc6ur3t8EDdDCr/v6BIM7x4ydhUZRfx7eYu7kM +DN7p6xtIFYqOjoHpBRUPK+WQs7e3d8DGh4dHwoBhs319fSMjo+BAMB8R+JLTdJtoauGHEXMk ++wUFBcAX0y+98iTVwsICgtzf39/a2oai7Wdfdyjk6bdv30POxbwNCQlLTk6RKUZmAeSJcjtR +S0vLxYt6587pMGkmKm9ubq4iY32riilUWCw2ODj09q2+iYnp9vXAsWAN585dwCsQcf68DhyR +FlEONQuUPnv2PLYfBgyoB9J7enpBucrKKmUKBqPLYnm1tLRiPkzL9vXAjZw6dRYrOX36HDOg +IRzy4aAcnNjkpEQgEOTl5eNIQ7sArwXPprguUNnb27eXmzqALxxj9vaOvr4Bbm4eexw449AI +SEd1A+hev37DnPoICwtnBv8tLCyE7yXK7dDLoWq7urrFxyfExMQ2NTUx80E5VS+HVgM2Bm03 +vNxvvz1SzsexjSZ4bW29tLTs9Omzfn4BcXHxKLsbqu8bUo7FYl++fDU2Ng4lLS1dKpWPQtjW +1qbq5RYW5rEM9hHIQXOAlFa1wWWGbTU2Nr1//wETTLQX8LpaevXB0cl+dXV1aGgYiWRqalpg +YAjggyQxMDAYJpbD4Q4NDe19hAs1YZ09PT1qTz0cWSE9f/NGn0lLk5KSzMzM0dCEhIQyA6/g +6PLx8SXK7ZByqLDMAMqqAuWMjExWFeru7rl69TozzhcOeFgUVHAmoXj58jVsG+oyqjkzlOFe +/tZvSDk3N3fVTJxRe3s7KAeAIwgrKysJCYmweeXl5UivHj9+cuvWHcB8dXUN2/yf//zEDAr8 +9q2BmZnZHg/vb0458XzNq9cvwDQPD4/g4BAkR2DdxMTE7obZJe1OGRkZkZHRqidV+Hx+fn4h +kyXV1NSonjMhyn1GIlHjP//5HRilNv/VqzfHjv3KdHQPfOnq6jHPLyMrsbCwQmW/fv2mjo7u +L78cZ4buQhbz3Xffd3R0ainl7Ozs4dPUTmUjM8UO6upeQhCuXbsBvFtb2zIGRigUyfs7PXUG +cUCgHjz4TSyWX+X/448nL1681HbKjS7WWVmb7+PdWaRdaHubsr6+vl8rP1KUQ8Vxd/fYjgV4 +Ng8PFovlhU+RpChH6JPJO1ldLygoREOPTxsb32e4ra2taGuUTx1qHeUKCgoQPbXjanR0FEmB +lxcbe4qkPicnVxWD4+PjISFhzs4uUVHRSC6YmfB7ycnJ2k45ZKwODnbEmUMsevbhW4mefdCu +a6wkohxRjihHlCMR5YhyRDmiHIkot/P+5fa3z+SDl4uL2977l7O1tVM+46zFtKeRCklEuW2U +KywqevbshZubh7u7VhZXV7fnz18KhaI99hXs7OxiZmaupUFQxkHU2ESUIxHl1KpAb19ffX1D +eUVlRaVWlvKKCi6P19ffv8dxH1rb2iorq7Q0CEwceDx+Xz+NbkMiyn2kFmj72FUoex/Da2h4 +WDw6evjiQJQjEeWoHO5ClCMR5agQ5YhyJO2mXLBjfn4xUY4oR5QjHVbK+YY45uTkj42PU30/ +spQbEY/a2tk2DxDlSIeQcvMyYVyatzc7YGp6mur70SwjYnFLS7upudGAtBwgIsqRDhnlpta5 +/VPlbw1eFRaWAnTjExNIXUfHqRyVMimRiEfHHOxdo1O80OR97WGCiXJEuYMv4yv1czIBty3d +2FTfm+2flpqVnZWflZX3kZIpL0VFJTk5BfLprF2WzMy8vLzCwsLizD2s5JAVhCI/v6igoGiP +McHXEViEd4fryc7Oj49PsbCw9g1x3PlI5UQ5knZRTgm6QWlFXLp3UKRLRAIrIv7jJSbZ28js +TUCYS1QS+1PL/G3BStzY1lZ2hnEpPrteySErsSk+jq7m9i5me4xJXKqPpa2hu7c1gryT5cPj +PAMjXco5cTgAvmquSpQjymlG6spZkImWZI14XdxWMHNN1jK6WHvvwd2imhiZrGNBJlz82JJ/ +W/DdwAhXA6OXK7KmZVnj7lZyyMqWrN3Z3cLO2XRT1ra025ggmMuyJn3DF0GRrgjyDr+Fn5uV +8Q/sGCPKEeU0uSzKGkNjPH768eQb/ed4K9lV0z+zxe8cLb558+apk+dBS8BTG0OxvwU+it+R +pXvxks4FvYaWNLzd9eXywuroUyfO37x1C0Ge2eJpYEtKlCPKaWyRbvJ6Jkrv3ruDmnj2jE5u +WcTirgCFb/mHOgNxZ8/qvDN+PbX21c8FaXiZXJVf5nZytzh96sKZ0xdg50C5ydUvjgnCiGAa +GL06e/bi6ZPnA8Nd0SoR5UhEuZ2XJZkIRg50unz56rmzF2HnJr/czsHIdYiL4TQu6ly6dOkK +1kN2Tm7kOjMRDT29yyi6upcbWtJ3ca1zUWHkEFKsCuG9dfu2ws7xiXIkotyXGTkdPVAO9Wh3 +du69kTslRyVDy3fGr460nVMxckxM5HbOibFzX2bkJKswci8RUmY9aI8Cwlw0zc4R5YhyGn5G +7vTJ9zVRxc417NzOKYxckdzIXbz0fj1H3s4pzsjJjRwsHBMTPT1MX2poSfsiO7fwwcghpMx6 +EGQNtHNEOaKc5hq5ScbIXVJS7rLCzuWURewcUAoj58LkvMpy9r2d4x5FOyc3cgJVI/ennXM2 +nd2xnZOscRRn5P40cn/auXDNsnNEOaKcJhs5NTrJ7dy592fndnKf1cwmr2O06JaqkVMU+dm5 +c0fUzsHI8TqymDNyqjFR2LkvODunekZOdT2MneuCndvkEeVIRLnPGLmusRLQCSxSo5ye7mWg +L6s4bCeAWpAJfYIdj/96Vq0mMpbj7bsX8uR3jXN0EDe52jC7xbd3MTshj8lfAnL50tUTx89Z +2xvNbPL/9mIrc8bgjcGL7c0QQo2A+4Y4aU4LQpQjymlggZ2IjGchV71586ZaTbx+/QbqkZHp +m7Glus8DSrrJ7RAXPfjt/tWr169eu35ZpVJfuXLthmLNxXWxu75PTBvLzBaf35F58+YthPHq +1WuqscXb6zduoDS0ps/+3Vm1OZkQThh/BMKIYKr+QVgNAv7w9wed4iLp1+xphChH0u6MdbW+ +Z7y0b6qc156J+qg8SX7m1IXYVJ9RaU2nuHh0sfbzlgOfDs9WAXRiaY2Lh+WZ0+9PQ124oPvs ++eOeidLusZL+qfJd3CSm1V5uUFqJmAxJq0wtDc5+OKWGxNPQ9PWQtLJztGhQWvG3McECCB0C +2D1e+vT5Y50Luso/yMXTSiytxU8g+BoSW6IcUU4zC/PkF1inSrnTJ89nFIasy1p32B0ZahmS +3zVZi5ef3ekPd5KcP6/78vXTmS3erIx/pNJV5e0fiMmyrMnKzvjMGZ33l2PO6JhZGSzJGhGW +HV6RQegQQLi1F6+eXjivq/yD2P72a7JW/ITmNB9EOaKc5p6d2+J1jBSpUS41L2jpC6/fLcpE +nj62qpR78eoJ6uBRfvwBebqlrZEq5Uwt9UGtL71fDq/PXz5RpRzL147ulyMR5YhyRDmiHIko +R5QjyhHlSEQ5ohxRjihHIsoR5YhyRDmiHFGOKEeUIxHliHJEOaIciShHlCPKEeVIRDmiHFGO +KEciyhHliHJEORJRjihHlCPKkYhyRDmiHFGOKEeUI8oR5UhEOaIcUY4oRzqylAMopja4Uxsc +ReF+qqcdyRpHWXcUbOFoEeXmZcLF94PON36mq3Ds4KxMsKRYZnLP8BxfrpuR8ZnB7vEq7+dz ++SPLID7STS4mxpflnfeCUePL2kE5ZuOX3gdWHltsP2Z+qjdU5i+Y3uAS5UgHTLmxpbo+SVnn +aHHXaEmnuPhTvSaOzFWPL9UpvzIyX60dlFuVM7m0Pi4u1Sc+zTcmxTurOAwY2b6P4PbMJq+c +kxCRwMopCccCqI87B85HauUal9OaEZfmixKdxC6oit4+Ztn0GlfYld3UlzctH6OH0ztRVt+U +uvMW5NtSDtvc2JOTkOHH7GNsqk/XaPH0Ovej29k6WIAFsBgOMzQl40Q50kFRbm5LgHr95Nkj +a3tjKzsjY7O35Q0Js5sCNbOH4sqyEvXkSjd50i1+Q0uap6/tDrtY/LaUYyyZvuFLVFugJjTG +IyU3CBBQIwnDNN9gJxtHk7gEXwdXM3OrdwNTFVPru++fE4bQxdMSUY1N9gmJcs8uCQd/1Mgp +H/0nyj02zXdRJoTxqxWm4KcxoRWUwz8YFOFmYPQSOxgRzwqL9UQrObPF276RxTWxhiavI+JY +geGu+NcqeUkzm3yiHOlgKIeamFkYyvKzW5CJlMgCl1SrCUM5S1tDfmcWPkIdrBEl2zmbKhb7 +ipTDNoBRyoLlWb7qlIM7QqKtupjaJmHO6GId2CVeqJXJumWyjmVZk3ihZnSxVhWPqIk5pRG2 +jibA/qqsBW8Dwly4bRl7GcEKK3H3tua0pstk/TJZ54qsubE3F7ZZNWVG2KMSvJKyAxYUlKtv +SnNnWx8A5VQjxgRQjXJefnY40v4S2G2tCdqdoEi37JIwxQ52rMta5d3Xz1WrBnZqg9s7WQbE +NffnrclasExuWQTs3y5GeiXKEeV2Tbns4jAvf3v4tzFFQjq+XFdSFydZb5j9MF4MQzkbB2NB +VzZDudrGFEc3849SDl9H1VuWNS59KDiwh2aqVCl36sS5nLJwMGdJZbH5bcPTYFVgkbLMbQg8 +vG3UKIdtVltsbLFWrTrDO5lbv4tP9yuujc2vjBqeqargJuSVR06tcuCsUJiTSwhCen4wJsYV +u4zd3IuRY2KLdeobvnD3snHxsOweK8ksDotJ9hZ15wDO+CHwdk3WGhnP2iHlwC7mFJ+ybMna +bRxNT38YC+PM6QsWNu82ZW2q8cevwF/95XTZcr1qxJgAqlEOtnluQ6i6GLOkGuXg35w9LMvr +E3LLIoXd2X2TZUhLATr5Od51DhPYsoZ4B1fzuQ9DxE5vcpEFUMZKOkjKFVXHPHh4HxAztdBH +AoJD0SfIEfWuoSUdaQXgg2WQ31nbGwm7cxjK1TV9knKARlZRmH+YS0i0B1PC4zyxwqtXrynH +GdS5oIc8LiqerVwGxgmW8i/malMAEBmZvsGSTLF1MPn98UNd3UvKgUdv3bplZW+EDVMuA5qh +0g1IK5WAUjiQBhMLfZhPdqADEu3OkSJk5V5+9nEpPqKeHCRZ/I4soI8dYJ9TGs4YLdRBQF6R +Xdbtxcvh50Jj3MGuSn7SxGI9KArKxaZ4l3MT4tJ8kSDz27Jik71TcgKZjJXTku7Ksvwo5bAj +4vkaJN2wT8q4IU988uyRckTvizqXHj/5DTORmCuX8Q91rhIkSTfem1JAplNchFjBnDNBYwKI +YCKkzHp0L1569Pg3WwdTZWBRcHhUC5JVM01QLiLe6/XbZ75BTm5e1vkVkUMzlZiIS/UpqIoa +nK5EYLvHSgurYzCTGQgb8URUZ2V8uvpAOkjK5ZSEu7NtxLM1PROlg9JKzPQLcaoVpaCyVHAS +kMS5sqzwkZ2TKbwcKiAqb40wxd7ZdEb2EcrhUIQVhHFKzg5kSlp+cGSC19Wr15WV6MI5XWcP +i6z8MOUyjNFSpdzkijz3we8i32HK2Gyti+dfx/B68bhPUt4/Va5cpneiDHNU0QQ4wO/ZOJj0 +TpYjY1Jc5mtEfSyui60RpWQUhoTFeBqbvSmsigZq2AEOcJ7Yx1VZc0ZhaGZR6Owmf28Zq00Z +Jx6/i3oNt4ZQCLqySuvj8ioikbjB9rT05WMm21/+u0j6gFm5ifrYqIvy1HuhBhucmOmvjFtG +foh8VJoLesrmAzFJzw/BviiXAU45bRmqFwXGlmr/jNhkGRPAp88fX1AZwwt/+thsnepi+C+A +WfwvahlrWl4QthyeDTvYOVocHs9CVg4ao5EyMX/rF+oMj2ds/nZ8qQ4HGxZrGyoICHfF2y8d +N4coR5TbNeWyikJRu3H44SiaWueiCkQksIZnq3CgNvfnwdFxWtOn1jhYJiTKHekPlvQOdAiM +cP3oLRlID1FJcfwvfCio44CnWsaaXYqMtUu5DJbfXrXlt7jIN+l9WZE1sXzt1DJWeb65yVVd +TC3NZCiH6tbYm8cMGYYfyquIKKmPreAlgmNMQgcKDUxVoDJi35u78gAK1HpeW+Yez8sB5gAa +s2t4TckJqm9Oyy2PKOfEA2vMbS3AsqmlPtyOf4gz/JKgM/tTPwovtCC/JebP2CI5BcDVMtYN +WeuSyjL4FalaxqoghrIwAdx2Xs5+RdasFlg1LuFI8A1xjkr0WlAcCVgALhEBBBJxqCg8Gw/J +KVwcjhYkC9zWjDpRqoHRS7R6s1sC8nKkg/NypeE+wU4MsnAYg3JRSWy07zHJ7MGZyjlkUvIb +unjI7HCgWtsZW9ka2TuboW5+9J4BjbvGutqACh6d5N01VsIAEPvS0JrO78xEulrXmKpECiZ6 +JsoAcGt7YzCnqS9vTsbfS2yR5gu7srvHS5jruXjtEBcNTFdgDjjAbDYaBWzP0GxVdnE4YgKf +80V3WXzba6wwujmlESV1sUwai/XgsCmqiUGjVlAZrTid+z4OaCWTswNsHE1snUxgYmfkW9hA +lCMdDOWYMZ37p/4yQjGOUpCBef3z/k/5fSP1gs4s1FzJOmd6c6f3kmnCXcHyiv9hMWw240wU +12f/3ItxxTkr0H5WcSpSfsZ+r3cF189syS9hMD+BV9gbeZVX/Lpq9BSj1grhu6a/cBR7Tbgr +WHEk1P15Q84mlxk/V81RI6TYWqZ80eYR5Yhyey84yNWyPObm1e23sOJYld+ov/VlIxHTE170 +hBc94UX6tpSj51iJckQ5ElGOKEeUI8qRiHJEOaIcUY5ElCPKEeWIciSiHFGOKEeUI8oR5Yhy +RDkSUY4oR5QjypGIckQ5ohxRjkSUI8oR5YhyJKIcUY4oR5QjEeWIckQ5ohyJKEeUI8oR5Yhy +RDmiHFGOUECU0zTELcua+iXlf+1F83xWceiWrH12Z/2MoRqiOm/K2tj+9qdO/km5l6+fzss7 +LBLKuy4/SnAbV1R5xGRN1mJtb3L69AfKndYxtzZYlTXPywTyzp12sB6EbkHRJ5K8z+EPlMMf +5B3gsClrx3zNaUSIckQ5DSwgGK8jq745raAq+tq1P3tEh+UICHcVduTUCFPUhnz6yLG9xumZ +KKvkJwk7sq0djM+dfV+jdXT0Hj/5va4prVqY3DyQP7XGOTqUm5J3yFmMmPA7sgyMXp0/p6sk +/xuDF7z2zCp+UvtI0d/GBAs09+cjgHVNqY/++B0hVf5BNg4m+IPwE72TZRoSW6IcUU4DC4xW +eKzniePn9PTeuzhluXTpyqnT59++ezG+VPf5QZalm7wOcdGt27fOndNVjo+jLBcvXjp79mJx +bexHx0o4rGV2i8/vyEQ0LlzQU4vJpUvy0R90dS81tKTP/t1ogMzYRmAawrj9Dzp37uLtO7c7 +xcXSPXQLT5QjHW7KIRtCrnr/wb3zH1IhZYGvQ+UqrIpakIl2ckYuOMrt5PFzaiuRn0E6dcHY +/M30OnfySJ2dW5UDys3L+uSJj8Tk5InzTm7ykQEnVv/+VMDUOtfI9A3C+JH1HD8XEu2+uIM/ +iChHOsrn5RZljVFJ7FPbKtHZszrvjF8hFZLsIBuSykdkKL17787FDymV0m+An+WchIWPjbNz +2O2coLE398rVa8qzne+bD93LCAu/M2uH5hatTFlDPMKo5gmRvd67fxfpqoYYOaIcUU5zrz5s +cAemKx78dl85mp4yGyqqiVnYsU8ALUOjPZSXHlQvKUo3eEfxMqtiPC/FMNwX1Myts4cFnN4O +L7MidPiPTMzfnv1woVZ5mTUs1kOjLrMS5YhyGluWYOcS2aqV8YuMnKqdu3P3jvIM+SW9Kxfk +Ri7+CBq593ZOxpfbuSt/2jndLzRyH+ycUG7nVE57Ish372mWkSPKEeU0287x+qcqHjy8r6Ow +c4yRK6z+AiOntHMh0e6nPtwvB+9hYgEjd8TOyG2zc+5sm9MnL/xp5Nwt5YNOfsn9cgjg9DrP +WMXOIcihMR50vxyJKPcldk4EO8fkm2fPXPxSI7fdzqmckRMdUcR9uNja2JvD2Dm9XRk5lbNz +cczZOcbI9UyWapSRI8odmGZmZvz9/aXSGeZtbW0dj8ff3Nz08fH19GR5enphQiwWq35lcHDI +w4OFwmJ5BQYGT05KMLO7uyc3N0+5TH5+YVtbu+ZTDlxCDVpQGbd9h2VV1jy52vDk2aPz5y5e +vHipRpS8JetgRiD9oiKTdcSn+Z45owPXYetkgtUiHd7F9nysCKVb36xST67Wz8j4uwjIoky0 +JWv3D3U+c1oHhR1gvylrX/zy3UcYEUwbB+OzitgmpPvJ5H/QvgRWNLtPtxbvC+Xm5uZ8ff0k +kinmbX19Awom/Pz8UUOZKjw0NKT6leHhYQ+5mCocND4+jpn9/f05ObnKZYqKiltaWg4H5bCD +N27cws4yb2Nj49LS0hcXF1+/ftPa2trT01NZWW1lZY05yq/U1NTa2Nj39PSiICwmJqZLS0tg +o5ubm3IZFotdVlau4ZQD38QLNQVVEdHJrOgkr+jkLyvJWX76hs9Pnjh38/aNqCRWbCr7S9eA +kpDu4x/mdPGi3pnT5+1djJMy/Xaxku0F25OQ6SPszlTc6n+gd8AyQ1EDcfUtKfHp3tiSL934 +xAxfTz+b8+d0zp3Tcfe2wtvdBQHBtHM2Pn36vK6uHoKMUO9DbBW7U9oQgwx6ZouvHJz6G1Ju +cnLy2rUbLi7va19iYhLKysrKy5dvmptbUIVhXSwsLAFD5VcaGjio1Ioq3JOfX2BsbLqwsNDU +1Ojk5KJcxtfXH6DTUqxhZ8F2Ly/v6OiYurp6iUSCXUMQyssr8GlSUnJ2ds78/LyNjZ3yK6am +pmNjY6qUCwoKUomGX2VlZXt7u7e3j3JmUFAo06BoLOXmZEJOa5qhyRtnJ7e4uMSMjOz09C8r +mZk5mVnZ9+49CAoKzssrTE/P+tI1KEpWYWGJvb3jixcvCwqLd7UG9YJ9SU3NDA4ONzI2Ru3e +RSq9t1sKeeL5aleWhZmZeVhYVFpa5pfHNquoqMTE1Azbj4m9hAIhff78pYOjE4K82z9IJbCK +15iYeHs7R3Prd+3DhfK7lJcPmnKonqh0MBIxMTGojNPT04oqbF1cXIJP4VJQlpeXbWz+XC3+ +C/g35VsOh+PvH6hSW4NLSkq7urq8vNjKmcHBoQwTtE5bW1vYkaioGDhYA4N3MTFxCBHmIAl9 +9UofPM9Evc3OWV1dff78FTLZwMBAKyurkJBQ1ZUgsPhI+bagoDAlJbWjowPwZOYAiYaGxrGx +sX19fQsLixpIOekmr3Uw7+WrF4WFpZMSyfjExNj4+C7KxORkUXFxT28vVrK7NaBIpqdFjY2V +VVVT09O7Xsn2gk0aGByytXGKSPA4sIu2yOKn17mObmbeXgFi8Sjis7uNRygaONz6hoY9xgRf +R2ARXsn+xRZHy8SkJDEhzdRS/2+fc9kXyk1NTcGVwXQNDg7iLSpaaGg4qAUPFh4eOTMzg7QU +NRr5F6bz8vJBuc3NzZcvUYUDUIXhWAICAlVXCMopaysExCUkJHZ3d7PZ3sqZISFhWko5JJ6g ++uLiEqZLS0vhbJHOOzg44W1GRibYlZWVgyQUDYGBgWFVVXV9fT1eYYYBLsAtNzevqamZw+Gq +Ui49PQMFXk4ZIvhDU1N5U45Iurl5oISFhaelpWFVvb29Uql0Y2ODWVLAb4qMZ6/L2ibXGr6o +04m9P6jF8rWJiU6YnpH2DwzspYyIxQNDg3tZQ19//9DwMNaDiT1uzPZt6+7pNTI2auzNPpgT +70iQS+tj4CuAAuzUXmIyPDKCsseY4OsIArZkf2M7MDgIfrI8vWPTvOf20ILI+x9YbnBw/Avl +1tbWwFGhUJiVlR0WFuGC6ufmASuC2jo6OgoHgprFpJ+oUHFx8ahQTBVGzfX29gXlUB/X19cN +DY0qK6uUVRiHGNIrVGGRqBErR0Kq/EUYm+TklO7uLuWZK4XBC9nJSScNFLJ1pJ+jo2OK5DQF +IUIzoUzGEYrXr/VBP5g6Ozt75bcQZGToiBXCjhAhqVd1d2gp2trax8bGkfYqZ9rZOfT19TMJ +MhodLpeH7yJHBgnxr6Hp8fX1TU5O9fcPdvey6R8rH12snd7kAj6LilO7mMYBsJPOPXZ3xWF4 +vsrazry5uRX1aH/BomlFMjUVEBCakOlzMI814R8MjHBJSkqDizvcgRWPjlZX19m7mEu3uF/U +QGNhHNvSLR5itSxrkqxxbW2tYNJQrVJT0/z8/D08PFBHAgODYckwUywWw3UoaxZDOeZqAmiG +OgX/5uTkxHzq4eH56tUbpFdLS0uqGSsgmZ+fX1tbh2ooEAhRADHlpw4Ojk1NTTAnqMKbmxvK +eg0DqaXn5cArS0tr5Jhv3xogqopds1Zmmjdu3M7NlXu5R4/+AAOTkpKjoqLNzc2x2J9pZl39 +q1ev8RH4D0LCDG9ubmE+vLGHBwtrZrN90KbAM390A9bW1pHLNDY2AadY/rX+czeWlY2DsZuX +dUC4S2Kmf1l9fHNf3sB0xfSGnHtMmdnivefe6j5c2OqZLLFzsO7rkzfKh7syTkxOxMQkRiV7 +HRjlvPztiorKxGOjhzuwwyPDAkGjg7PV1PrfpCE4aHHIzcr4TJ9aMNX9U+W8jszs4rDQaA83 +lvXDh7+xWOzg4FCACC4COfHW1tZnqjAslrm5JSoaEi5UQ3g5Cwsrprqhnl6/fhN4hJf7448n +sbHyKhwTE2tmZsFcSGXE4/FevHhfheFt4OuYr2MbYGmwZpgQbJKSeFqnnp4eGFeQKiIiEsn4 +yspqS0ur8tPW1lZYLwS5uroG5hYeGO3C/PzCX28+mS0tLcNHWIDH46t+hKYnP78AK9/hxggF +zRHx7IUNUddYSX1zalZxWES8l5efvZ2zKYqjmzk70CE2xSe/MorbltEnKWduj1+UNcq5J+MD +g7u4oI9DrneyxN7RRo1yTHYD8zMpkWhpwcaPjY+pZmcKyiXEpLIPjHLsAPvtlBscGtLeqCpj +q3pWAZTj80VOrtbbKSe/J3mDqzhQRYoH0xp6JkprRSlpecEBYS5O7hZ2TvJjOzDcNaMgpFaU +amVt+XmsbavCvchDUcti5IqFu2tpaVGuob29nTl9B+eG7FVRhQtmZ+fULkEqqzCHw1X9CGkX +qnBNTa1W3zoCXMO+wriiOejt7dWEu4JXZM0gz4fbq4Tym5HkdquM35FVVB0DynkHOLh4WsLv +2TubsvzsQmM8MotC65pSO0aKRhdqsDzTSs4pUl2J/BRfwy4oh+y1praW7Q0j6uPt46uNhcXy +wpGrmoZrAuWAuI7OztCwcDbbW0sDi+3GgVFbV6eMrZJy0xuwag048OYUxyFex5fq2oYKK3mJ +8em+PkGODi5mto4mSFWCo9xzSsPRXvdPV8DRMRnr9CZf7bzc3yo8PAJZraIKm3d1ddFNvx9V +Q0NDWVnZ5OSkxj77wJh86RZPecuu/GTabFVzfx7y2aSsgMAIV2cPS7nlczLFRFCkW3J2YDkn +vmUgf3iuGt9lvoWvS5Wp7t9RDu21q5u7r68fmjktLUhAjIxMUBOV+6UJlBsdG0NGYGhoXCqX +tsYW3sCT5QVHp6Qcjydy9bCdlwnQ1Db35aFFjk5ie/jY2isOS3dvm6hEdmFVdGNv7sh8NY7D +RcUByZx7YU687Pp+OS6Xi7xV9f4u0iF4wksxGgKHaTEXFGfqkBGIF2rahguRC2QUhoZEe3j6 +2No6mVjZGYF73kh1U32KamKFXdl9krKpDY7yiygD02XbKTcxOenm5t7U1KS98VxYWLC2toV3 +0jTKZefkBgeHaPWxilQOlENTqKRcU3OL/rs3Ht7WTJaBQy4uzbeCm9g6WDC2VMdYu3nFibhP +5Rf0hBdRbid97DC32SsuzjZiYny5rneirKElPbcsAi0p0lt7FzM0rKCfl799RIJXdkk4rz1D +1JNl72g7MDCkRjl3d4+GBo42P8kyoZmUy8nN8/cP0OpjtaqqmuXFVqWcSNRkam5YLUjqHith +7qJR3CHAR1u8w/4WiHJEuV08O8mkugz3mIK3/ZJyUU9OcW1sXKqPX4iTi6eVmZXB7Tt3EhKT +UAGJckS53VEOGauLu618KKLNXd71RJQjyu3X3fjyU3ybPKapZS7Odo0WmZgZcbl81TtX94Vy +Kysr8/PzCwphQnn/89raGmZ/6u4aLKz6mCFRbrsQyYUPQiSXlpaY+Qgp5qyurn70Wwj77Owc +Xr8G5T51jZUoRzpgyn107Ia+qVJHZ7uhoZF9z1jDwyMuXbqCoqd3WUdH948/nopEjTL5QzQl +V65cV+saApqenvb09MLC58/rGBmZdHZ2EuU+qqam5lu37ly5cg2x0tW9dPXq9cTExK0tmVQq +vX37bkpK6vavZGZm3717/9y5C/fuPcjPLyDKkY4O5T51jXVfKMdme4NXgYFBISGhwcEhqIwP +H/4OH1JYWPjrryf7+/v/auEWX716c+LEKRbLCwuj8l64cHFoaJgot10CgQCBsrd3QGBR3r0z ++vnnX5uammDqzp49HxMTq7Y85vznPz8aG5sisG/evP2f//lXZmYWUY5ElNs75cArOAflWxsb +W0APGVNJSenp0+cGBgZUF87Ly//hh5+Ki9/3byMUiry8vEEqotx2CYXC48dPtra2MW8rKiq+ +++77srLylZWVixf14uLiVReemJjQ0dFDKJi3ICECy+XyiHIkotzeKefn53/mzDn4t6dPn718 ++Qo2A3Nkip5btlMOxg/518zMDF192AHlRGgv7ty59+jRHzDAV69ee/z4yfS0dHZ2djvl+Hz+ +r7+eYHoi+npXH4hypKNJOV9fP1RGGxu7u3fvnzp1Njs7h5mfn5+/nXIsFhspLeopUW4nlDt3 +7oKhoZGhofHPP//i6OjEXK+ZnJzcTjkejwfjV15eTpQjEeX2nXJeXmzwTabo+uDatRtPnz6X +SqUKyuWBcmrPmyQlJaPCMpcnoJaWVn39d93dPUS5T2es8meu7e0dTp8+yzwuLZFIdHR01a4+ +DA4Ooonx8fFj3m5tbVlaWtN5ORJRbr/Oy92+fXdlZUWm6G70++9/dHPzYDJW1Lu0tPQqhUpL +y1ATJybkfVnfuHELn5aVld279+DUqTNqfo8op0o55tFyuF+krrDBsHPz83OXLl1xcnJmAgv/ +xucLgDVXV/effjoWHh4BOjk5ufzP//wLbQpRjkSU2zvlsAaAi6Ec5OnJ+uGHn5qbmysqKo8d +O/7rryeOHfsV5R//+N/w8EiFf2t58uQZ6iMWu3PnbkNDw15+/RBTjs/n//jjz8p/p76+AW+9 +vX1APDQTysD+61///u23RzJFt+EAHcCIwML4AXfKexeJciSi3F72SCwWd3V1Ke/+XV5ebmpq +QvYK19Ha2tbxQci8mLHPoPX19fb2dqSrCwsLdF7uU0JwEDTVTsCQ2iOSaFC6u7sRQCawbW1t +fX39ym6I+vsHmptbhodH6LwciShHT3jRE15EORJRjihHlCPKkQ4B5QQCofbGUyqd0diel4KC +grX7WK2rJ8qRDgHlPDxZ6ekZvVorDodraWk9NDysaZTLLyh0dnbt1WYlJaWwvX2IciStphwO +YDbbW1//HRydlhYrKxtTU3P54IkaRrnSsvI//nji5uahvbF980bfzz+AKEc6BBmrUCjS3njO +zMxSxvqV1NDAoYyVRFcf6OoDXX0gypGIckQ5ohxRjihHlCPKEeVIRDnNpFx+fr6bm3t8fAJz +7/3w8LC3t4+XF7urq5tZYG1tLSwsPDIySrVr9I2NjdLSMjc3DxbLa499oB1WynV2diKMCKZY +LJYpekGPi4tHqAsKCpXLlJdXuLq6qfVB2tnZ5efnj/lpaenKTtSJciSi3K53x9ra5l//+vel +S1eYvkcyM7O+++77H374qazsfRdAra1tP//8y/HjJ7u733NveXnZzs7+xx9/vnbthp7e5Z9/ +/hUY/NTwEEeWcsXFxQjj99//mJubJ1P096Kjo/vPf35na2uvbCmePn32X//135GR0cpv5ebm +njhx6sKFi4gtwv7y5WvlU3VEORJRbndydHS6fv3mo0eP6+vlD92zWOxHj/5ALUMFYRZgs33e +vjX4/fdHkZGRzJyUlFTU3+TklNXV1dnZWUtL66dPn++6x7nDSrny8nKE8fHjJz4+vnhbXV39 +22+PwC5nZ1dmAYFAcP/+QwsLy2fPnjNP5Q8ODp09e97ExGxiYhKxRYujq6u3F6tMlCMR5WSK +fs9QEx0cnMLDI5C0GhgYMp1qMpRbXFy8fftuRUVlaGgYquTa2jpmYhmmDw1GqI9wd5Sxqglm +GGH09vY1MjLB26CgYEdHZ4QazQqzgIeHJ3xda2vrmTPnmHuBgLVjx35taWlVrmSPo6QR5UhE +OQi554sXL2HPYMl6e/tev36TlyfvIpihXG1t3Y0btzAxMDBw5sz5pqZmTD979oKpuXT14fOU +gzHLzy949ep1X1+fubllamrakyfPGMqhXbh7935lZRWmYZ7ZbG9MxMXFnzt3YXh4iK4+kIhy ++0s5VD3g6+XL1yEhoQ4Ojo2NTSdPnkGGhU+RXiHtCggI9PJinzx5OiwsHDPfvTN6+PB35Rq6 +u7tLS0t3becOMeVOnTrD5wtsbOxg5N68Mejo6Hj69Jm9vSPTfPz660kYacT23r37v//+WHFS +Lg9errm5RWmSc3Nz1fpqJsqRiHJfKtRBeLOFhYW3b/V1dHRhJ7q6uk6cOFVf34BaduvWHeSn +ICHoB8vx6NHjjY2N7OycH374KTExCWSbmJiAFYQDkUimiHLbKHe2t7cXIUVg37zRn5+fRwwR +SXzq6uqO2Do5OSO25uYWCCAamqmpKUzAJ4+PjyO20dEx//jHP4uKiohyJKLcXiiHOsUM+mBr +a/9f//XfXC4PFfO77/7T0NBQVCS/Sjg4+D6Bwtv//u9/VFRUrq+vg40//njsypVr58/r/Prr +iZycXMpY1VRYWPTvf/+nt7evvr7+//yf/wugYebt23dtbGxBs+PHT0ZGRjFLgn5wfWAdphFJ +NDFgHWKL4CPOyj6ciXIkotzulJ2dDVcmUzzz6O3tMzMzOz097ePj29/fX1xcgpq4sfH+FhHM +xwIVFRUyxV0QJSWlnp4sLNnS0kLn5bYL+SmCI1UIcePx5JdK4+MTENW+vn4Wi616m1xaWnpY +WASaD5niRjv8roeHZ15ePjOHKEciytGzD/TsA1GORJQjyhHliHIkohxRjihHlCNpGuVmZmc9 +PDz5fIH2xnN2ds7KykbTKDc2Pl5QWBQQEKjVx2p9fYOHJ4soR9JeyolHR+MTEh4+/M3MzMLN +zV1Li7m5paWltUb1FQzk4tVWfifhU+0NrIuL6+vXb4OCQ4hyJK2mnImpGY/HHx4e7tdavX2r +X1NbOzwyopKGf2PKDQ0PC0UixFYsHtXewHp7+7DZ3kMqJpkoR9I6ysH/2NjajY2Na3U8HRwc +m5qbARZNo5y94vZd7VVyckp8fMLU9LQysEQ5kpZSTq13Mq2TnZ09kKKBlLOzd9DqwCYkJMbE +xE5MThLlSEQ5ohxRjihHIsoR5YhyRDmi3OGgXEBAoJ3dx2t3Xl6+qan5HvvoPrKUW1lZMTIy +Bnk++imb7b3v9+YR5UhEuY/KzMz8wYPf1Gaurq6mp2ecOnXm7t178/PzRLldCK2Dru4lLy+2 +2nypVOrl5f3vf/9gv9/WkShHIsp9VDY2tk+ePFObGRsbp6Oj9/Tps99/f7ywsECU2x3lbty4 +5efnrzbf1NTs1q07t2/fZTotIcqRNEE8jtA/1GVR1nh0KFdfX49fjYqKRmUkyu0j5ZiuXWDn +DAwMEXmiHElD1NLc7uFjOy8T7fo40TrKMQoMDCLK7buXY/TixStbWzutoNz0Bnd4tsbZxZFQ +cIjV3dXr4WU3JxNOrjYcSso9e/aCKPc1KHf9+s2goOCPfvry5WttoZx0k9c3WeHm4UYoOMQa +HBxxZdnNygSHknJgzoMHv3Up1NkpL8oBHYhye6Qcoufo6PQhtp19ff3KQWy1iHIzW/zOkRI2 +m00oOMSam5tzcrGe3uBJ1g6nl/v3v384duw4yk8/HUNRDrbCZntfvKhH11h3p8XFxVu37iCe +TGy///6H69dvYSbz6cOHj0xMTLWCcnMygbArJzgohFBwuOXkbD8yVzO9wT18lAPTiopKyhQq +LZWXmZn3w0nDflRVVe2xj+4jS7mNjY26urqSklImtsXFJbW1dcxg0zJFd/SNjY1aQTn8KSW1 +CUmJqcSBwy1fX9+WgYJZGZ+efSDKaay+EuUWZKLYFN/ysiriwOFWdHRctSB1QSYkyhHljh7l +Gl1ZVu1tncSBwy00ZFGJ3gd5y9xnKCcWj2p1MO3tHTSTctre81JSUvK+U06y3iBZ49o6Wu37 +6VmSpkksHrNxNJ3dOrjLrJ+inLmFZVtb+7z2am7e3MxCMylnZm6JzdNehYWFR0VF7y/lZrb4 +HSPFXl5eBIFDr62tLScXp6GZ6ulN3gFTrr9/ULWvYB8fX0NDY2trGy0toLSFhWVnVxfTCbkK +5RIPknJe/vbFxeWqPaJ3dXdbWVmbm1tqaWCtrGzevNEvKi4eGx/fR8rhH8kri0pNySAIHAWF +h0fWCA/u1Bwo1zdVamtv1dXdqwoETPf09nb3aG/pAbRVx+tBmZRMRkbGRiezlg7knAAo5x3o +kJdXNDo2ptwGZquwedob2L7+frXADo+M8PlCO0fzqQ3Obii3Kr/04M62aW1pJwIcBYmETR7e +tgsHYjZQkBrjsLSxN62padheGbW9qNZEBeUkzs5uueVh8wfSiOBXYlK8ggJDVTsPPxyx3R7Y +zMw8N7b17m4PQOaC/MXG1lp5Awzp0AuZwaC0SnpQSSt8Y3KOv7WVA3IQgO5w8E2twJpOS6X5 +eUUm5vqjCzWSdc4BBHZ6g9c+XPDm7RuBsHFySsKMmXj4yvjEBPydgYFhjShxdou/y3S1PDoh +Ppnq/tER/u68sugDu9I6udaAvNXT19bS0raultPXN4DSe1iKfHf6Bzu7euLikl++es5rT5+T +CSaWD+gSNuxcXkX46zdvMtJzurp7+/oPW2zxWl5ebaBvFJXE2p1DRjYxJxPaOZn29w1S3T86 +GhkZNbcynl7nStY4B3Z2Dq1wRlGwhY2RlY2Fq7uzq5vTISnuzk4uDhaWpm5sq/aRAjniDrBj +KwZ0gq5MJ/nwsKbYkkMWW2tbSys746LaqLndPn+NLzb3F7i50EP6R04BAcGK24NFB1YZcYjO +ywlQ1zdV2ic5VKVXUjI4UzEj40u3eAeMuPe3SSh+ekBafsgCKy9TpZK1+l23HZOK6w6ePnY8 +rpBq/VHTQP+QtZ2J/Ma5A3xyX5m9okgOUWF25yB77ftoIyI5jIGdkgd294forPw2uRI7O3uq +8kdTbJY37NziAdo5KlQOtKzKrzuw/R04DXyq70dT4pFRUzPDyZWG6XUu1Qgqh68syIS89ixn +Jxeq7EdZKSkZCekBywc7EgQVKgdzwWt6nWduZTjQP0Q1/ShrY2PDwsKqY6RkXiYYp6pB5RCV +JVljUmZQXEwCVXNSR3uXuZWRZJVzkF1rUqHylXNVkaAzx8rCZt+7TiVpqbIycwPD3dD2HeR4 +EFSofK37arZ4owt1JqZGI8OjVLtJSrFY3gWVMcsHOyA1FSr7/9TbOnd2S+Dgal5RXkP1mqSq +lZUVKyubWmH6El2JoKK1RbLGQa6KxCQuNokqNWm7pqdnzM3NhV25BDoqWoo4JCPx6f6BATRK +F+mTEo+MmZmbCDpyCHRUtO6+kUWZKDEziM32pYpM+rxGxWMWFlaV3GSATrJGFyOoaHoZX66X +bvHmZMLQaM8Af3JxpB1pfn7e0dEpuyRyQdYo3aTbS6hodJmXCSdXOO5smxi6NY70JVpfXw/w +D/bycxhfqj/IYQ2pUPmiE3HIOFr6CyysjAvyi6naknahgrxiS2uTpt58HEvTZOqoaFKZkwlm +ZcKckkgbG5uurl6qraRdq7u7z8HOMTSaNbZQtyhrPJiOvqlQ+UyRbvHQ7Lb2F9o5mYWFRq6s +rFA9Je1dWVl5VtZmJTXx0+vcRZloilhH5Rs91AC+DUmrw2O97OztG0UtVDdJ+6iJcQnaTRs7 +i/zy6PFl+aPQszI+PRFG5WDuEpmXCXHI9U1WRMR5WVlb5eUWUpUkfSWNjU5ER8Vb25r//y1f +N+PG4z3Agu4ruLgb7cmOIuoiYAX67s8ZYOH2FbS9+vSpq5unzurs6OrYs2v/r1+/RnPiKKA1 +ePcOdCVfX19fW1f9lj2Lrj3c8+YnaGcNMEECkyWw0AOmT9CJ1r9Ogy9jHUWjiAACJhXQcXB/ +zwATD6TZ9un/+aefjp2+thnYeGtta5g1a+6Z0+dHs94ooD948ODx5k3bpk6d1t7VMnFa68ad +849f3HDjyd7HH468+AaskU99+Hf2/SgaRYQQMKm8+Hbi4dvDVx7sOnBq9fJ107v6Gts72ubP +W3DwwJFPnz6N5rVRMODgz58/d27fO3L4+Lq1G+bOndvW0VpTV11VXV5YkldYnDuKRhEuVFSS +V1yWX1NXVddQ09fXs2DBoi2btwObbU+ePBvNVpgAADfb3Qk= +</bitmap> +<bitmap id="2" width="325" height="558" length="35723" ColorSpace="DeviceRGB" Filter="FlateDecode" BitsPerComponent="8" encoding="base64"> +eNrsnQVYHHf6x7metHe1VK5tHHdd3HaXZY31mRXcHQJBAsEhgjtrWLRpY40QJ+5pFFjYxUKa +5urX1NL04vOfBWp3aa/t/xJ26ft5vk+e2WFm9jfvbz47ml0MAwAAAAAAAAAAAAAAAAAAAAAA +AIDfL7dv3zp88OjubQd2b4dAdDvb9nfvPnzlyhXQ9qcYGRybafY0LdmQEguB6HToScaW/s+m +p6WDtj+FumeEHGz2+qeSFVfFEIguZ90/Q5JW2WdmZIG2P4Wmb9RXZNo6irT0CiAQXU7biCha +ZpuVmQ3ags4Q0Bl0hkBAZ9AZAgGdQWcIBHQGnSGgM+gMOkNAZ9B5uqUPkfUj8gFEqvp+pFSF +SL+fQDAxwURkql+xZHw5Pz+NtG88KugI0Bl0/h+4LO8X1B5nVRxhN/Yg8nFV5RpU1ito7pl0 +ufkir+poQOUJds0pdsURVu1ZPj7yFyxZ0HyeW/c2t/lnp2lRaZdfd5Lb1APmgs6g8/9vv6zi +Ztc5kdlz3Bjz6NnORafwjUdY/qabL8sm5xBPge+L1cL6vb6MkLn2Hi+bOL1CYBmHKOmKK+LO +dyQrxkQKXP9+tH10/OVVcceYeMUVkVIj7HhH3DkmrNrum9BOrFOJOi6LO65IOsdEMq2/aPsV +fGJJ27Cw+Rg1pdaz+ABjwRKf8gtI67AIH98+IsQPDGQaYftlcSf+chiVgs6gM+j83yIdEMqO +ED18TZJ2ctv6OJmdnvlH+XUHyNzQuXOtTDIO8ZTqifogrVfQguW2rDjnGg1uK1rXTQ5KtmAW +uJW9jTQf8w+vcuRFmzIS7UU51tQct7y3iMJkm4RNAbX7yGnrKFUHaUkNBFGyBbfQo/IS0nyC +Gp5tRY+zWbibXSy3NjR8SbDcK62OXNuPlK1y848wDaonNWrQ8s3eEcsduJEW4R3U5oHftdGg +M+j8i6JCFL3sxAJrd5F5SJ1HzpYAuRqtP80u3030Q2zT93IVP9C5sNKOk+RSNyxRnqXxuPO8 +g829ubMcEzzL1jsbEg1DqxxcjF7xW0RgBc52S3SML7F2iXVOb7Sj5ziXvOlGoM6WVLvSaSYh +DZTsNhdaqj0SOc8t0j6rw9WbbBhR48og26evdXMPMguuc+OGGolWU7NLjK2FlvHl9h4+ltkH +tMcJoDNoCzr/l+CHyiNo7VFmXrubJ32+aHUAflTcfsaPyLX+oc7KMbSgwo6T6FI3Gtiy28PC +6RWvKAtGtCk3z7dwnav9AreGgQAJzTrzID9vuRmtgqQ85UeUOCTU2nOKXIvecGem2lVfFi5M +sBEt9s1e7xVW5y6OmmsvssrdSAyKdMjfTkZ4DuF5puRCr5UfhRQq7ezzPDLKLTm15A4NU+Br +kdr1XUtAZwB0/smD7fp9RLTMOXsbs+4wDUk3pctoHVfEyuMkT6rlgt0/0PkKmrfEhhFFqB2W +yI6RqYhF4iZG0Vqv8DbakjcI5vHO1eeoPE+LtD2czCITdi1ZeojoKbCPq7Rl5DoXrHWlJdgs +VwuSI63FGW6cNENiiVd2rTWBb5a+zofNNY2TebD87ZNlDoQw66zt1NAkY3ozOavMjFlBlF+g +st3NQGfQGXT+JQfb0h52VrMTiTnXlW0U1ESqvoTIB1D5GZokyzXvME8+eYiLKIaRJR3uUeU+ +dQNCpQZZttbNnzXHKdgqdQendrdPQJVv3QVmXIpL/mFukZIQvYYmPUGVFHhmr/KIkvku7SJG +VLlX9wtyl7klKan5Kwje7Hm0NCvmYqeCg4yoDAt6qn1omlflJV5mtR2BOYeZ41bZixS3EqJW +UmUXmTHJzosPfNcS0BkAnX/2RpUaVWjGo0a1V557tCOVg+PD303Wg+/KtdNMvMRnwSdQ4rP0 +I1IV2qpBtMoPaWeR4ZPh6k0sAR9Wa2894zOOX6xG5WrtxwX+J4VG2IpPgP9pUIi/r2IQlfZp +J1OOt+T75UwsVgVXtkFn0PmXSy34RbeS/22W/8/bPYrFgs6gM2wwENAZdIZAQGfQGQIBnUFn +COgMgM4Q0Bl0hkBAZ9AZAgGdH6/ORIlZ51WhXI1CILqcFe9IYpV2oPPPoO4dtia/WHrYJ3+X +NwSiyyk7RGIXzkxOSgFtf4qPPvqYj3CFQVw0EPKrExiGioL5UIfHE3wr5aGsjo4O0BZ4FHz5 ++Q0oAgBMD8rLyy9cuAB1AAB956uvvpo3b15ubi6UAgD0ne7ubgMDAyKReOfOHagGAOg16enp +uM4vv/zy2bNnoRoAoL/885//dHBwMBhn2bJlUBAA0F+OHTtmaGj49NNPz507NyYmBo63AUB/ +uX79ukaj4XA4Fy9eHB0dvXv3LtQEAPSa0NDQb775BuoAAPrOvXv3goKCPvvsMygFAIDOAADo +DiEhITduwHOeAKDf4BZ/9NFHCIJcvnz5008/vX//PtQEAPSUPXv2GBkZPfPMM/i/ERERt27d +gpoAgJ7yzjvvzJ49e+IxksLCQigIAOg1UVFRuMszZsw4deoUVAMA9JpNmzbhOvv4+MCRNqA7 +3PrX7a8+/+YG5FdG0z/y4vMvL0heePPLW1CNxxB8K7154xZcdfwZrr37HsHdliIgkHmQXxku +YZbxC06+Zn58qMbjCEXg7OZnXVFRAdr+FAM9I67c2dIhVv3FAMivSsMlVsFWSvUZfACq8Tgi +G+SGNJqmLUgHbX8K7fdsi03bxrQ/Kwz5tZH1ayPtE0ApHkPaL4tj5PA92/9NZ/ja/EfxA80Q ++Np80BkCAZ1BZwjoDDqDzhDQGXSGQEBn0BkCAZ1BZwjoDDqDzo8mUtXkfWeZarJ6ky/H70RP +TvPdvekfv/zhNBDQGXSe8jRf4tWeYlcdY9ee48vHhW06z60+zq46wWnuQxT4mH5UpuLXHGdX +n+bJBlAZ7m8Pv+40pwofc4YnHZh0HAI6g85TGRXa3s8OjjU0953lwp7jHGaZ1s2XHyF6+L5q +z5jjQp/rn+dWdg5VngtIyLN0Zs5xYhsHtfnLxtDsPDMbj9ecWXMcWKaRK+gyDQrFBJ1B5ynX +uaOPwRJbhqxirfpAXCS1c070qNzt5cayKzqHtPUFBMaYccq8U8ut/dPca/rRuh3erCxCyQVu +aryZuILcdi2wepMHJcC66Dyq6Id6gs6g81TrrGLyAs0CyrxL9vpH5pj75PnW7vH2FDiUnkc7 +rogqV7swo0xoYWap+3gdQyh+ptx8ni8b5qckmjLSnAt205KX2voHOi7rQeUqqCfoDDpPsc6d +/QF84RwT3zneYkNShlPpObR5p5eHwHHJJeGKd8XL2wjMaHNWgnniLm7nqFAxKFT2CWQj/AVJ +881dZnqKDD3DbDP3cBRqKDvoDDrrwsE2PQC1DHudvfr9wPYRoXJIVL/dw4lilbEvoHovmRNp +Ftjil1lp4x3sWHSEVbzWnb3YZUkvLyXGTFLt1/GPoM5RkWIAag46g8668B+ptCfIkYudkzax +FIPay1nSAbTlCNmfO4cQMMeFMZ9X7VOjEiousJMLrVzxMUKzqLV0+aggZ6lTfJu/VI3CNW3Q +GXTWqcg1Pz7z7UNwteXae8qoQq29LSVVIQrN+JgBfIz2tpRMrX0JpQOdQWc9+M/O2u8xEPzb +8yH/OQYCOoPOENAZdAadIaAz6AyBgM6gMwQCOoPOEAjoDDpDQGcAdIaAztNMZ6LErOMdoXwA +hUB0OZ1XJLFKO9D5Z1D3DttSXl52glTcTdSdLD9CLTvop1NN+n2mpJu47Ai19ABZJ7aK4xRe +6eyU5FTQ9qf48MOPWBwGX8LkiXQmYqYniUDnkHSoSb/XcIV0Es2TJfDXhcbwxcwAHlWpVIK2 ++sWirMU7tu+COkw5d27dS05M7bnYB6UAfhuff/65jY1NREQElGLKOXPmzBNPPLFmzRooBfDb +6O7uxjchExOTzz77DKoxtTQ3NxsYGCAI8uDBA6gG8BvIz8/HN6Gnnnpq586dUI0p5NatW25u +bnhfzJgx49q1a1AQ4Nfy6aef4vtlg3Gio6NhpzCFXLhw4Q9/+MNEX7S0tEBBgF9LT09PQEDA +7Nmz8f1Camoqfh4NNZkqNm3axGAwDA0NbWxsSkpK7t27BzUBfhX/+te/bt68GRUVdfz48S+/ +/PLu3btQk6niq6++unHjRmZm5oYNG7755hv9P1L6Bhscwr66ox28cxO7/j52H479HgeJiYm9 +vb1QB10gPz9/9+7d+r8e97H2NOxZG+zYR9pX/ziDbSrG4HDjsRAfH3/+/Hmogy6Qm5vb1dWl +3+vw2WVseSz2/F8wA1vszD+1Yz7pxdbkYNdvQP+CzqCzXnEPk+Vi/igWz8eetMJOjet85zPs +6Gbsg0+hfx8DYampbw8OQh10Qufi4q4DB/R7Hd69ht14gHWVYH8wntRZN1GrsWPHpl9quNyh +9vZpuWp6l9zg4K6KCj1ehUuXJmVZv1jXdaZSMQMDCOTRJdfAoEuvV8HWVm90TknBTE2nXz5+ +7rlbc+dOy1XTpzg6Yh4epbNmHbGwwJyd9XIV8JafOPG9zgZGOq3zgwfTMglxcefPnZuua6cv +2bd3r1wmo9NoSYmJ27dtu3/3rl6uyHesXYgZvIwd+wSuhzxmYhMSzn13ygNMEfVNTQbfwubx +7uv7+rynxroOYNdvQ8/CjarfIdeuXZsxYwbu8l//+tdp8SQJADr/fnnw4AGKorjOM2fOvH79 +OhQEAJ31mrVr1+I6L1y4EEoBgM76zpUrV/BdM/zHcwB0/s189NHHo4NXRzTvTHkGeofTkrJ2 +b+/WhcaMqN+5MnLtyy+/BEFAZ705Y72PkSjeHjwjX6G5LzrVEZqTxJZEkcXUtwQ1J0ksbH1n +5ufngyCgs75w/w7mz/OouUhtG0OVI8iUp+0y2qoDzcCz6j1xbJv1wvQMEAR01iOd6QLvipNU +WT/80hD8qA3oDDqDzgDoDDqDzgDoDDqDzgDoDDqDzqAz6Aw6A6Az6Aw6A6CznujcJ5CO57f4 +8ptn/G+LBZ1BZ9D5V+vchygGUfkAIhtAFRpUrvq5ifFp5N8tvw+Rq7+dUY3K/jcCIvIBVKZC +pCoEdAadQedfpbO0H5WfprED5xEC5rqy5geUeS49K8DdVA4JZbi8GnwAlQ0IO96RrBgTtw4L +Fjc7Rq7wlw4g+N5TMSgoecODicxxYRqKa4m1vYi0D1EOi1a8I24dRPGFywdFbaPiDvylGmlR +oe0jovYxSeeoUIq/tQptG5OsuCJWDiDNPQLpAIq/RceoUNnLzniDlL/Rf0G5b2UPotBo37pj +RIivVNuwqP2yuHNM9PMfOKAz6Pz71XlAKD3k60oxT3yLUXuMKo41peYTW1Scws2U6kuCmp20 +wi3M6iPU2GLH4FpivVqQvtgkoNJXpkYVQ2jVOjdisFXSRkZFFxFNsojfHNAxipSt9RAXOGXv +ZCs0gmXbyelK97Bil7wjvJYzzPS1vrFVThFtfo39QnkPK6PWKWi5R+lJvnJQ2HyaHlfslLye +WbvD08b7777ZLplySr1G2HzMP7rQIaKD0niOvWgDMaGeENzgU3kekalAZ9AZdH6ozkRvvl3u +SaTzXXHNOldWvH1hF5EdaZp7DsnLs2eIHMMyrQPirNzY8+gyv6ylFrxaokwj6hjhxSda8QpI +iqtipQZtOM2uO8cvWePsIjThLLAghVhk7A+Ijp9lF2QpCDXyCXMvetNlvvdcVq61O8swfjNt +YaENCTXyD5pHiHWtvsiOijP34Ri6ITaxDS6O1FfdQsyoVMeyY3REaOwfb02JMWdl21rT55LS +bYjcOfxGP/zz5JefsIPOoPPvS2eebc4xQfs74vpN7qwE27ztJEGSReEltGiJEyeYkNTskdjs +6kp/xSbfK7PcclxnYfsoLyHZRlzqp3hHhJ87t46IWwc4kSnzac20jR+JIvItfGt8ExeZBL7O +bj1CYvjZp69ytY93rrssTF9sKql1Jfu/ahlgRA6c7yxwKN5F9KJbLDwswD8Wmo/4cYpso6Ve +QoSQ0elkIXFseD+4aaMn0XLm/HD7gl7x0npLWqF7U78QdAadQeeH6HzQ151pnXWY36piR2aY +M/OJzaf8aEGGSbtZKamWXkRjQoBVyiZK6AIj+xyPtDJzThV+sC1UjqBLZI6uEutFR/jSM4z4 +ckLWroDUIlO3XK+WC0wkzpjTSk7MMg56PaB5pzeD4rBwpYtdsnP1AD8py0TS5MENMQ9ewWg4 +4h8t86s9TvHzN4laQ82R+izq9KSmm4uWuXDZTjkb3B1plnmnePlNju4+80zj7PPOIQWVFvRi +D9AZdAadH3YpTCg/SSHTZtrS5jjT5pAynYtOIx2D3IRcE3vyXD+JpTjLRZBoQuCa+IeY+GV5 +LKizC5b74btjqQpV9nNSq+09SLMIlLnMbNdlF9GWk1RBtJG9/+yAxW6VFzipRZbRG1nN+0jC +YJecNz198z1q+vnpZVYR6+iVGzypAa850udxa8ktg0hhi5OHxysOXJv8/cy4RaY23rP9A12r +VPxFS23d8OVH26au8qQsJuSfRUqkdsJaH9AZdAadfypNF7g1J9hVJziNPYj2PlQfIuvl153i +NFzgS/sQaQ+v+gSn4SK/+RK/uQfPtzOqEEW/oP6kdsZmfBaV9o6V7KJ24qY+RK4SjE+vnbL5 +kqClRzA5PL4EuRppfJtdfYor7dfek5IPCOpPceovasdLL/HqznAbL/JbxsfXnWTXnucrBhB8 +ado3/WEDQGfQGXR+yD4akY3nu10ebrF2jEo7BtdtclilHf+j3WLff8yo+v7ldxPjM373tMn3 +I384Y59g4i2+X4LqB8tXae+LTd6J/rcGgM6gM+gMD3kCoDPoDDoDoDPoDDoDoDPoDDqDzqAz +BHQGnUFn0BkAnUFn0BkAnUFn0BkAnf9DZwbiXXue0T4qah0SQr7LqmuB8e32oDPorE8638Wc +fayilRZp65xT1xAg3yVzk6tf2otJiUkgCOisR5SVlcUnxOlIklNwgRJ0pDFx8XGbNm0CQUBn +4DfyAEoAgM7TgVu3blVXV2s0GigFADrrO2q1esaMGXB8C4DO04A1a9YYGBikpaVBKQDQWa+5 +f/8+n8/HdX7ttdc+/fRTKAgAOusvly9ffvLJJ3Gd//SnP23ZsgUKAoDO+suGDRsMDQ2fffZZ +/PQZP97Gd9ZQEwB01t+9c29vb3R0dENDAz4MOgOgs75TWFjY3d0NdQBA52lAbm5uV1cX1AEA +nUFnAACdQWcAdAZAZwB0BkBn4BGRkpIyMDAAddAF4Mo28Jv58ssv1Wq1SCTatGnT8PDw7du3 +oSZTxfvvv49/qMbGxspksrGxMSgI8Gs5c+aMwbf4+Ph88cUXUJOpQqFQ/OEPf5joi/DwcCgI +8Gu5ceOGh4fHxCaUlZUFBZlCRkZGXnjhBXhmG/j/UFlZiW9Czz///NGjR6EaUwuCIHhfGBoa +fvLJJ1AN4Ddw4sSJp556ytLS8tatW1CNqaWjowPXOSkJvm0P+I3gFru7u6empkIpppyhoaGX +X35548aNUArgN1NStOTwwWNQhynnzq175UsrR4evQCn0gg8/+JDGpHBEVLZQV8IRUn38Xehc +ou406fcb1J/M8GDwSDrSHq6YSqETz5+/AOY+FHXvsD317xVn/MoOknUn5cdpS49QdKpJv9Mc +Ipcfoy49rCubR+0FqrPohW2bdoK5D0XTN0oUm3W8g8oHEAhEx7P6PQk10WjHlr1g7k/p7Csy +bR2FXzeD6EFWXBX7xxuCzqAzBHQGnSEQ0Bl0hkBAZ9AZAgGdQWcI6Aw6g84Q0Bl0hmjTI5D2 +o51XJSvG03FZKMNHqtC2IaGsb3IaqQppvSzW/nVUKIWKgc6gs65G2o80HvaXpFsy4szpcRaS +SmJtv7DlODVxNaninECmEkgHUGkPO22ZLT3OPLjer16F4iOhbqAz6KyDkQ+iy1cSLDxM49eS +cl735PBNJI20xt3uhHirxSeQVg2qvBgQkWNJSXNMkrlywkxELeQWXPA+KB3oDDrrns4atGKd +i42noajcJa6eEICYRbQzGvd6eKXZ5p9E2keFy1e7kjm2pX3i1e+KG49Qc7fSG3sR0Bl0Bp11 +Vmdrt3mCPGtbm2edUz3l1wKbt7t5LtDq3DGKlipd6IGuDWMiea9AMSJq06D46TbUDXQGnXVT +56WrXDxC3GUfB9W+4eLFt8w5KZTudvfMcFiqCnzjk2DpLh9ygNmCo+jr70mqd5PTX6dq985Q +OtAZdNZJnZetcnYREio1ohUjvMg4I59F3rXd3k7Uv7sGmlKjLOLWUNKa7d3YhtQoY2+eadQ6 +mkyNQt1AZ9BZF69s9wkaz7CXdLOa+rRXuZtOMUv2MhsucEs2ERe0eqUovfP3c5RqwZINxBSl +V95ONu4ynDiDzqCz7hqtQpSa8ePnHoFsAFWqEWkfohwStY1ooxhAWvoQxfhL5SAKh9mgM+gM +gYDOoDMEdAadIRDQGXSGQEBn0BkCAZ1BZwjoDIDOENAZdIZAQGfdRN0zQgoyXftPSec7Ip2J +eDwiiI50x4qrEh3pkQ1fhNBTDbdv3gPmPpTR4bFZZs9TYoxI4YY6EkqkiV+Ese6053cev0hj +Wqw5OUInthBanPEs67/u3dUN5j6UO3funHv7wtEDp48d1JXs3Nrdveuw7rTnd57Nb25HuYHd +u47oQmOO7j/99qlzN76+AebqCxs3bhwZGYE66AjHjh2zsrJ67733oBTAr+Xjjz+eNWuWVCqF +UugI6enpBgYG7e3tUArg13L48GF845FIJPfv34dqTDlffPGFm5sb3iMCgQB6BPi1xMfH4xvP +iy++ePnyZajGlLNv3z6DcWbOnDk4OAgFAX7VvsDS0nJi+1m5ciUUZMopKip66qmn/vSnP+H/ +dnZ2QkGAX87GjRv/8Ic/TOhMpVLv3bsHNZlCHjx4cOLEiV27dpHJ5DfffLO/vx9qAvxyxsbG +Dh06lJWVlZKScvr0aThZ0xHCw8Nv374NdQB+A2vWrJHL5VAH3dlHBwcHX79+HUoB/AZaW1vr +6+uhDqAzADoD/3NCQkI+//xzqAMAOk8DQkNDb9yA5yoB0Fm/qaysdHZ2fvHFF+3s7FatWgUF +AUBn/aWjo2PivuETTzyxZw/8t0QAdNZjxsbGDA0NcZ19fX1v3boFBQFAZ70mJCQE1zk7OxtK +AYDO+o5MJnvmmWfOnj0LpQBAZ33niy++iIqKgjoAoPNvY9XKVcuXVOpIlpQsD5aE4f/qQmOW +lVVUVlRfu3YNNAGd9YL7dzEHNwt+8bzgKougiqlPcKVlVIN9UKVONCaqxXqu2x+3v7UTNAGd +9UPnOxgD9WnoZa64KukYE0N+mPWfhTBSjbvegi/mBZ31Rme6wLviJFXWD19+Dt+zDTqDzqAz +ADqDzqAzADqDzqAzADqDzqAz6Aw6g84A6Aw6g84A6Aw6g84A6KxDOjf3CORDQuUg2tKDv0SU +wyJFv0CmFrZpkPEx4+nRjmkdRKU/nlExLF4xJpJODA+J8GFZn3a4RYW0jgrlqsl5pQNo+zuS +FVclbfi7gM4A6PzIdJZrBMvWExdtoDcPoNKLnMWrvUuP85Z1kRI2MmUaVIFHjSqH0KqdpMyN +1JZBkWJgvAF9AkU/v3CFm6TBt64PVaqRsjc9A2u8qy4gcryF51k5MmLFeQFut2xQ2HiMGrXI +MiDJbsHmAKkaAZ0B0PnR6Iy0XhGkLzDn5/u0fxy6eogVFDM/ajOnaq9f8pYAhYa/bAdtyQFW +oxopqLUip9rn72BUnObJcKNVSOcQLyz4JYMnX8k4gqwc4SK+z/zJYl7BGWHHmKhqraMlYaaw +g9nxjqjlMJkVb87NI8SU2fuHmid1sZX/a6NBZ9AZdJ7UeQzJzjN3ZRiLywhBi61cGXOTd3EX +K5wodaT8Jgd34jxv7jxCjmeuws6FPYfEnevMt8s/zMf32h0abuQC09fMXuatZsiPEQluL1kL +zfNPCVeMchNz7JB0O3SRe+NVNCvXiprs3nQ1aOUYumwrOX8vS9oPOoPOoPOj0nlRnrmzvyGS +7yjMtHCmzk3Zzc1qsndNt6OEWGccFlS+TnBMc81qtPFNcWpQs8X+ZmFKhnxY2KFmh6fZ+IZa +UBe5L6yzp8SbBSRZLT4rVnR7kaJsst70ocdYpnWzF2TaiUspiqtCaR9+Qi1S9gua4WAbdAad +H5XOgoxsK1EZsQM/2B5mh6cYJ2znZDc7uC3AVbXJfVvUtN3NPcsts96WXewuHeKEsCyj2yZ1 +Dkm24RV7hkTNNnc3iaxw5i+wKjiP5tdbmTq+4s6fZ2H/KrOFkl/j4BvhWDkcuPoKUrKRuHhH +gHQA9s6gM+j8yHTOtOTleDYNi+Xn6OIYI1xnXF7XUq+s5XZk1NyfP9sk2SWr0Zax2LVZww6k +W0S2TuocFG8lrPeLSX7lzxaGmeu9+SmWi3bQAlOtEvfwO0ZFjft9qBGOxQeo4gxzT4EJLcSY +FGadeYCrBJ1BZ9D50VzZlvYLag8ylx9it6gQaQ+vvJtefZZfe5xZdoxbs58cuNCahM51zvWs +OslafpjV0sev2MmoPMmTqhAZPtzNLD/Oqz1Mz98d0Hies3w/s+Y0p7I7oFmFyvAJ+vlVO5h1 +PYj8PGuRwiNB6lN6hCeHK9sA6PzoHiPR3lNGFeqJu8yIXIObqL3L3KHm5cgJfpGmlAzH/EM8 +hUaoGDdRPojK+7VzNWtvcuHDiPYm9RCKC65Qay3GR357exrBJ5b24Z8YKH7W3D4qUqgRuO8M +gM5T8lSYXCPUft0HrqFuP4oGOoPOoDM85AmAzqAz6AyAzqAz6AyAzqAz6Aw6g86gMwA6g86g +MwA6g86gMwA6/xKdGYh3Yz9z1T8knVfFU54VVyUrdKAZE9nwZQhjgVHXZvjheNBZP3hwD3Px +tPcOmUWJMfSLmvrQ481ocaa60BJtY5KMZ1o/uWfnPtAEdNYXei71HthzbP/uo7qQRen5dZXN +OtKY7l1Hjh0++dVXX4ImoDPwG8jIyGhqaoI6AKCzvnP9+nW7cW7fvj1NVumbb7B7D8bPau5j +N29it+5qf4L365vY3fvQ3aDz9Ka7u9vAwODpp5/WaDTTYX3eKsVcKFj/V9rhr/sxL2csrQvT +rMdsXbDtw9DdoPP0Jj8/H9f5iSeeWLJkiZ6vyhfY2grs5Sew5y2wvhvaETdVmOGr2IIubGA1 +9twr2KYh6O5HQdO6dctbW6EOU84nDx48b2pqMI49hfK1Xq/MznKMGIDRXTAzAtY7vnd+8DGW +FoptU2OfXcIk8VjvdR1q7ddfY01N0yOnJJLDAsG0WR39zXs5OTlPPrnQwABP+SuvfFZaqrfr +Uo8FCbANO7C9xZihDdaj8xfGGQzMwAACgfxk/vInLJGAOXjqgc5xcRiKTo9ccXIasbObNquj +7+k3N//A03M6rAubjcXYY/b6oPM0onnt2gqFAuqgI6SVlLx18OA0WZn1C7H5NqDzY72y3dZW +39AAddARcnNzu3bsmCYr0x6BPTsLO/8FdOtjY+XKlS0tLVAHHaGgoGDfvunyjHTPTqxein1w +C7r1MTA6Orply5aEhISwsLADBw7cuXMHajKFfPzxx7t27eLxeDk5OXv37v3888+hJsAv5+jR +o88999zEjU6RSPTgwQOoydTqbGxsPNEdrq6uoDPwq7h58yaBQJjYfrZu3QoFmXJSU1MnumPh +woVQDeDXUlxcjG88L7300tWrV6EaU86OHTvw7njyySePHDkC1QB+LWfOnMG3H/z0GUqhC3zy +ySempqYmJiZff/01VAP4DZBJ5I0bN0IddIT09IXFRcVQB73gxo0bLc3SmoqGmkqdSNXyWj5H +uHBBto6053ee2soGHgsJEoXpSpMqGhrrm9977z0w96EM9o/MtH4yqMpMVKYTES8xi6hxCC63 +0pH2QMJr7MOq7HSkMWF1lrNdnti+ZReY+1DUvaN+weZrP5Z0XBFDIDqe9Z+HMhYYd70FX8z7 +cDR9o74i09ZR+EpnCHzPNugMgYDOoDMEAjqDzhDQGXQGnSGgM+gMgYDOoDMEAjqDzhAI6Aw6 +P8IoBkWtA0hzzy+dHp9SNihacUUk7xsf1gg78WGVdlg6IGwbQqXfTikdQDve0f7oaqsGegF0 +Bp0feWS9vKLNvou6OYpvf0Jd2o8o1KisH5H2ITIV0tInkA+gsj6BVIW/1E4g70fKt/gE13iV +n0eUGrRmDzms2rPsFF8xiNYf9M/YQmvs0xot16BNR6jhOdachQ4Ld7MVaugI0Bl0fpTpQ5S9 +nJDM+VQZrXMY1dqtRqVn2aW76NXnBNJLvPrzPGkvv+40t+GSoOUct/5tXrMKaR9Gs4vmGxg8 +G7qes+o9YVL0a3+Y8WL8HsHaK4LkEhMTV9OCE4K2YWFDNwmJM2XnEcILbYgim8xdHDkYDTqD +zo9Y54g8E1YrvWMI3yOjjcf9+bHGDsw5lBSnzHYXRqFr2V5fF6dXhEr/lDx7STVFOixqH0Ky +Km1nzX2BXEtW9ND9Wa8a+c5JPYi0n6BIcm146dbBK2krRgUJJZbei32U14JWjiGl60kFe9my +fugL0Bl0fkw6K4eRjFJT5wx3+ZAgNteMWOIiTrANzbezmvm092JHTqZ17FYufmrcNshPW+bo +I7EgpztntBBoiWb0OLP0g/zSVkdyilv+G27kEKdaFT+6xJLZylh5GcXfpe2ySNEvaOmBmoPO +oPOj1LmHE55vyl/HXv9x0NoPRAvzjTwLvVd/IEldYuG+nFhQa2njPY8RbmHLnOkRbld2Uajs +R7Q6l9r7Z3rEZRhZucwTFblKMs0X7GRGx8yd5zXLnTXTmDA/ZTsnp8HWI9mt5WrQKu3emZy3 +h6M9E4eag86g8yPTubWfG5k+x4hhzEm25Jd55m/28Qs2IkaYEAPN0/bzqlfZPT/zxdBVPj5m +Tzul+yguC6V9Wp1TC20oi3wXVRk98cLLkev8QtPNQmsIzCTnZecErUOCxTUOnMUeNSfpwfFG +HuHmjEgTr2D7vAM8+QD0BegMOj/KK9sqQeUeSlKze0ydW0I7ua4Prd/nF1fvvngPW65BW86y +CzdSq87xlndRyk7y5KrJWaoPMksPcBpOMnM20+ou8Cr20ZceYCw9xcXPjmUDqPQ8e9lBZlO/ +UPo2M7XZLabRq/gED65sg86g82OIXCPsuCzG0z4ilPVp7yPjw62a8dvHKrR1RChXIYohkRLf +t3578itTo7ie0n60bViIH0Lj4svxMRM73x6BVIX/VTs7PkG7dsnj80KpQWfQGQI6A6AzBHQG +nSEQ0Bl0hkBAZ9AZAgGdQWcI6Aw6QyCgM+gMgYDOU4S6d4QcbPb6p9r/Pq8bkax8V3caA9H2 +yHh0ojEbvwxlLDDq2rwHzH0oI4OXXzN7mp5i6B+nE6ElGLFSLXSkMRA8ASnmzGQzXWlMmvFM +m7/s3gF754dz6/atgwcO79zSvXOrTkTe2O7t5qcjjYHs2tadHJdekFOqI+3ZsWXf/r2Hvvji +czBXL/jHP/4RHx8PddAdkpOTc3NzoQ7Ab7k0p9FERkZCHXSEjz76yNTU1MjI6MaNG1ANAHTW +a7q6ugwMDP7yl78cPnwYqgGAznpNYmKiwTipqanTZZ1uY3tWYOnpWONG7Kv70MWg8++Ejz/+ +2MLC4oknnvjjH//o6en56aef6v0qPfgKq4jBXpqBzZiBPT0D4xdjn4PRjxD16GhodDTUQRf4 +8LPPdnR3sxAku6Bg94EDn339td6v0vv7MQMDLLQNe4BhqxZgBq9g3dd0tKmffTYNMvz228nB +wdNjXfQ+X36J3b5dvmjRka1b8QHsiy/0fo3+9TG24yB2bfxzaUsR9owhdvA9XXR57Vrs+een +Qe4/88w3f/7z9FiX6ZF/Pfnknb/9bZqsztLySV+GdmGWL2D+RZhuXrA3NNQeRUAgkJ/LE9iN +G9jIIczsBcwEwYZ09XGUsTFscHAaZGz37nyBABsamh6rMw1SFxt7SC6fJqszMoJpdmJO8zFS +DvYFXB155Fz5+OOwpCSog+6QUVi4tbt7mqzM/X9gfjO1++iQbKyqHFtaiQ18BF38KLh161Ze +Xp67u/trr71GIpF27twJNdEFcnNzu7q6psnKXHoDM34Vm/kq9sxfsT//GXvqBWyTCrr4kdwS +fPAgJibG4FtOnjwJNQGd/8fcuYV9fRO7+V2+we7BfedHxd69e2fMmIG7zGQyb9++DQUBnQH9 +5euvv7a1tcV1rqmpgWqAzoC+k5iYiO+gL168CKUAnQF95+23z4pEYqiD7lBaWnrk8BGog54c +395oa+1orpM31+tEivLKaH6slgaFjrRH2qjcu+dxf5XN5s1v6U4FiF6UmIgEHWlMU51cIWv9 +4IMPwNyHMjgw+prlk+JlpkihiS5EVGoRWmGvI40RlpqREl+mMsiPs0ce3MMc3CyY2bPRYp3o +FLw7ApdY6UiPBFVYzCI80bVlF5j7UNS9o37B5ms/Cey8Iob8W1a/F1R2hCgJFTzOHrl/B2Oi +Po19ASuvQaf8ezZ8HspcYNz1FnyT58OB79n+mSjUaN5OL3HI49aZLvCuOEmV9UOnwPdsg86g +M+gMOsPWAjqDzqAz6Aw6g86gM+gMOoPOoDPoDDoDoDPoDDqDzqAz6Aw6TyOdewSK4cnfBu28 +LJT1CVr60dYRoVyNKgaQ76aRDwqV6l+2EfYhylGhXKWdq7kXaR39duGj4wv/X3Q9vljFiFDb +vJ5pqfP3RWsfQaU9AqlaqNSgeI/Iv11lbWGHhMoBpPm/VgCfHe/QIaF0fBjvnbYrksmFD6PS +3v9ZjygHf1l7QOdHqbNMLShb6yHOteNn2ga1kOp60aaj9GwFZflhxrLjHGmfdnZZv2D5VlLe +ngCpCpENaLcrmQrBh7UbQ58AH8D/nRyPb6jnWYtb/cpP8/FhRR8vt91NmGOLLzxESqzrRfCR +2in7EXzJE9undNxxab/25YTv+AK1f5rY5r+dTDs8MX4AVfRz85Wkor0cmQaVDYzPqPp2xoHx +Zar0Vme8wj2cRUoX4SJbfpZ9wmpayxBavYu8aAut6mDA8qOcloHx0l3i5mwk5x/m4iv7fY/0 +T/YIPqzttfHxcjXScIS2aAOl9hIy0TvplQ5oFt4jdvGv01vGZ/z3Hun9vkcmekc20Tvji53o +nYlVmOypAUTRw8l+k7hoP1c5iE6877czavtL1j/Zy6DzI9YZ3xFwI9E5XlF2SS2ufhHGbAVN +diYgW+4bGm/KK/Np6McVQxTDgpQsw4BKonJEWHeUWdYd0IDvec/zcNekPfzGs7yWfqT2GHPJ +voDGAaH8FJnuYp62m6cYFHb00Cm0OW6RthGVTow4U04TRdovqD/BwjdLaT+/6gBj2TGu1kd8 +2zjHXnaQ1dSr3TxaLnCW7GVUnOLJcVt7eOX7GRUneNotpJdX3s0oP8VXanh5MmLhXk7zJX7d +SdZSvD0XtYbiMy7fz6w+zWu6yNdTnaX4h9UJClkyk7TYNbXBwZdqmbqNU7efsvgtUliiJSPf +t2lIiAvScZ5OjjXlrgpYOTbZI42XBI1v85rxJfQK6s/wpAOCifEtQ6KadQRytFXJOSF+0NWw +14fk+Hd6HiFqmR0ZtUp8g4n3SN1x1vIjHFkfv3I/Y/lRLt4GvFOaz3KWHWI14r2vRhpPscr2 +MmovTBZ56T5GzQU+3jst5zhLuxk155E2FTfrdWLWPg7eRzXHAvAZm/BPgAGk6TRryYGAunO8 +ph7Q+XHorBzhxoQaUlKdFrR5sMKNgt5kSff7Cdgm1nbPmZAsi99GWvEjvRFBWr4p0kKq2EJE +Qo2IQSbcMhdxvn36UUHDNh/JIteCLT78RBMiaiJaRqo75c8jW2Xs1ercfpHKkNimHRB13Y9Y +KrcnJLhl1Vu7UGZTsp1ji+x9/Gc5iEzD3gyQnaUL4owsvWfSa0hN5wKSllh7BhuRw50K9wek +19u6BMy1RyxTdgfkLLfxZM91Epln7qMlxDumb6IvSLfyohkS/GcTC7zrL7GiF5kQePPcyMaB +1RTpiPBn9gg6rfNJCj1yHmOJZ6bUyUNsnXWIX77WWVxo4+P4/Ewvq5KzSOuwqOMCg55qKX4z +oHaPLzPMhCg0EVc6ixPtFx/h1+/2Zhd4FLzpIww3IoqNec1+S95wDUi1LcV1HhbW7vARiG2r +rkXsvC1JijYTVvhmVTgQPOfQMpyjKuzxrnFhm8ZtYLacoQUmzLf0mMVbRqw+ThWnmBMDDVnF +7suOM8NSzV15s71DCWWH6OG5Zi7s2S4xhCXHA0KXOQavIkekzXcXGroS54qbqE2nqeyg+Q68 ++R6oUfx2TpsGAZ0fi85zHbkm/Cxrd7859GJy5TYfdoC1OMYiopnSMiCoxz/z+/lpheaSRg9U +ONuUNJ8imWPoNJ+WYitZ7rtQRhA3+4ZJXjWlzPcTzzF2MkzbQhZSrSd07uhlBHBmW9HnUyKM +XSSmMduYmUUmpEKfxgM+DjTzrONI1VpnL4FTapONQ4rzsoO0jK3UvCZbK+uXfSJN7O3/Ts91 +FcTNdYy2DVnukrDZP0QyxyPWPryEkLnLL5RrFb+aGhdhzlxEaj7m6xRnHbHckRnlWDXIj40w +4xaQpKN6q/Npf3rgTOdwK3ShuRN5TuR6ZrHUll9MCEq351X7y0eQhvN8+Wk6I90qaI1/cOxM +Q7/5FPHs+cS5zAwrtJm8qNYxXOmNisZ7KnDOPGfj6DoCZ6HdhM6NB4h+Ti86i00oQfPdxHZF +J9npqZbUZJ+6g94eEtOFx4W1bxAIKQ6JZbaUKIeS/Yy8NeSYXKNZrrMpYYZmLq8J6t3J5Dn0 +RU7BBR5F6719eDP9shzFy9wKu+m8bCuO1EcSPS94A6tc4eLPdoyttvYrIcouMASh88PWs9oH +QedHr/MwJybMPHkLvwuLrFQ4efGcS7t8eTwbNNw8tsO/WOrkzJwTUOiVWGoVVOPCCDSmlnkX +vkVKkJOL13pQBDOdmNZ5R+lBAXNZZd4Fm4mJLb7L9vvx/Sb3zvjBNkNgwihwz1zjm7MzQHkZ +ySgyQ1ooDV0eFlzr0sEgxU4vCt0+psLSOcddPiKqO8vOKrX2ZFpmbKNmyDyyNlPzVnpENriL +ki0YuR45K71im9yD0s1ZS10DUZuktf7x0bbB1XTlGbJ7ul1ovj07xk1+PTA7y1ZUTGrR272z +/AiZnmmV3RO2FwvJzDRmVZGKZPZIiZM42U7YSCtaS3AOmENf7ETJsAlcQZYkzKUu8yneTExo +I+at96H7zbSS2BXtpbKDjfxLvIu24D1FWtzuzPx271y/15fhNy9Y6pO50rfoMLfzGj810UZU +SKnZ5e4RbFGsDm3f7+mQZBeRbUWPc20eEzeeZoSnzXdLdync6pck9czdSUtvdotrcOWGmgY2 +EzOV7rHNbsxQ/JPfl5dnw5X6RCw0Sz3Ar+5wYyNOEUvMmY3UtVf4EQtNw9ezYO/8eM6do8Sz +bJnG3HRL/PM5sJ1Ru9WbSbMNyzRzRmwKj/Gb8fPQAX5qjgm/0XdxI8E/0JSTYEbK8azvYXH8 +Z8ziODWPovlN9qRIc3asOWuBe/lRCtvTIn3P+MH2Jao/zzJ6I3flNUnr4PhBe55JQBVR0csK +izbzlZj5hhgxaim1+4m+gUYenDmEZNfS3WRhoillgZW/2CZtnV90oYVnuDmZZyoq84jMMPcL +MfcNNeXXeUg4VvGrKLGhVqKlVPlJokOMbfoWP0mqCS3V0tVxNqvAT6a/e+dT/hT0FcdgS/4C +c1+uVdZ+bnGTDbvYOaHA2o5hU3CS19wjUJymURItRK8zCjucvAPNuDFmjEK3mktsPmXGbD6h +ZUyYV+foL9H2lF+hV94KZ3qiTcnkwbY3i2VReEm8ckyk1KDtY7zkWCvuQpJskB2YYeYmNqUI +jQTN5OrdvszAua6s2d6pTovWefqHmnFSzKnpDou2kflhpsQ4C3KYWbjMA0k2JSZY+LItUjuJ +rCwrVpN3SLJxwl5epdKFFkAo3OVLCTKlp5o5EWdFbGTD3vlxXNnuF5RvJ8XVuUZUuCSspTYN +oM2nWSVvMauPM9LaiUtPCxTaa6eCqn3UsiNcxQCvoMM9ssaz5DhfOYRU7fQv3s+W9qMKFS9v +lUdktWfpCb68l1u6kVZ9lq+9DN7DLdlGW36SJ528KCqo7qaWHmLL1ELpOWZanUvsSkpDL9qq +QSq7SNH4Yo/ytJvcfkpUpUvqG4yWQWHLaUZyvWuswq9+QCh9m7Gg1jW6g9LQxy/fSq84wanY +QV96kCu9yM7byajr4ZescUfSzFy9DQNrqbIRoVQfr2xrry7yitf7xFS7RFS4Zm4NkA2j9Ufo +pQdZDSfo6Uri0lN87cXkXl7xbtqS0/zWAV5ex3jlj/NbNYLyHbSi3WypGlX0f9tTJ/nStwNK +dtHrLyEyFdL0Nrt0C632ouDbK8/8yl30sj1s6aBQfpaZWusS306p70WVg3iPEKPrPIqO8tuH +kaUbfCKr3HL3shVDaG03JabKZcFGhmxQWLefEo0Pv8nAt5CyvfTSI+zle6iVZ/mNxwJKtgY0 +93Ky6h0ZMSbuPKPkXdxWNej8OO47ywdFHWNibYbHbw2rEOWQ9v5C+6hIrpqcBhdQe59Xe08Z +n1I0cYdRPijETZy4m9k6oh0/fqsaUQxP3jnS3o7EF9UvmLxB/N1yxm+GtuHvOKJ9x2bcL20b +Jhcr0wjxxrSN3xXFJ2vHJxu/Z/2DWRC5drGIfBBVqLWtasNHnqFHZlmSQ4xZRZ4VFwRyFaK/ +952Vw5M90jaEamuF77LV2htAkz0yfkNfqREq+scrPzpZ+ckeGZzske96qkWF4jviyfvOKkQx +9IMHAPBq4zXUTPYIXur2bx8PmNgqtD2Cl2u8PRN9Pdk7Q9oF4r35XU8pNNoHFeQaoXyipy4L +a/eSRLHG5CDT0Ba/BtV/uVcFOsNTYf+2X8MP71uHRa1Dkx8m8FTY1Eaq3S+I2kZEysH//rwK +6Aw6w0Oe8JAn6AwBnUFn0Bl0Bp1BZ9AZdAadQWfQGXQGnQHQGXQGnacT6t5RcpDZqvfFbSMi +yL9lxTuSkgO+4sf+tfkM1KfuIkN7rxZ64cdZ90kwPcWo6y3Q+Sd07huZT3g6eY19XKudLiSp +wynzDW9daUynA79sNpX5WH/U5v5dzMnTMqTBNKFdJzoleYVzYoejjvRI2hsEE9Jftm3eCeY+ +lM8++yw7e9HChRk6kvDwCCtLK91pD5729vbH3Cm1tbW6s/qhIWEJ8Qm60x6c0dFRMFcv+OD9 +D+PjEqAOuoNS0drdvR/qAPyWS3MaTWRkJNRBR3jw4AGbzY6IiIBSAKCzvtPf3//CCy/Mmzfv ++vXrUA0AdNZrVq1aZWBg8Je//GXXLvhJZQB01mPu3r3r7+9vMM406pS72MF12OI8bMVR6GLQ ++ffD2NjY/Pnzn3zyyb/97W9EIvHTTz/V/2sB/8JaUrGXn8X++lfs6dewrDXY7QfQ0Y8O9eho +aHQ01EEX+OzGDdXgYFBERFV9fa9G89WtW3q/SvevYF6mGL0cw25hIdbYn1jYh/d1tKk3bkyD +DF24kBAaOj3WRe9z8yZ+wL0kJ+fAtm3YnTval/q+Rtg9rFeF9WuwRSJsphHWdADTzZ1zZyf2 +979Pg9x74YWvnnpqeqzL9MjXf/vb7eeemyarU1gybsv7mJCEvTobW7gO+5dO+lxcjBkYQCCQ +n0tQMPbdKcP2Euyvf8d26OoDZr29+p2+Pqy//90dO0r4fHwAU6n0fo2mRRqjoo40N0+T1bm8 +B3MjYSv7tL5cbMOe/xO26hJcJHkkVykw7A7+mXT5siQmBj8A+hdURDdYWFS0Zf90ecjz+kVs +/jPYfApWXY1RzLA5DGzsBnTxo+DevXtFRUWOjo6vvPKKp6fnkSNHoCa6QG5ubldX1/RZn8uH +MKaN9sDbKQw7fw3699FRWlo68dDCH//4R41GAwUBnR/NnuNf2JdfYregbx8tKpUK3zXjOkdH +R9+/fx8KAjoDenz6fP++n58frnNHRwdUA3QG9J2Kior58+ePjY1BKUBnQN8ZHBxMTU2FOugO +paWlhw8fhjroBTdvfr1yxWp5c7uiRSdSW9EYH52ilHbqRHua21tlnQf2H3jMnbJ9W5eypUOh +G51C9qHiPaIjm4e8qb2jbeVHH30I5j6UoYHR1yyeRIqNubk6EX6eqajYSkcaI8g38Yl9icp4 +rF/99+Ae5uBqQUufxcvTiSIEltkKiyx0pEdEZWYzHZ7o2robzH0o6t5RvxDz1/8Z2PmOREey +Qmdasua9oCVHiZLH/sW8TNSnSRWw6lqgjnSH7vTIhi9CmQuMu97aA+Y+FPjafPjafPjafNAZ +dAadQWfQGXTWKZ1lA4i0D/8XVWi0kX/7pjL15BgFPoEKkWu+fan50c/ca2dUo/gSQGfQGXSe +Yp17+PWnuE2X+LXHA8p20Yp20CrP8JUaFB9fc5SJjyneQS09wKo7zS7bSS3dy1i2l168g151 +hjfhL/5RUHeMuaSb1dSHSEFn0Bl0njqdpf2o9BRFwLLP30GhMWdZ0+Z68uZ6xdimdfPkJ8h+ +zjNsmPO8kPnERS65b3pT0Xm27i/Mdn3VjWeasJ4pV6P4/rpuN5HDnm3lOT9QSVcMo1LQGXQG +nadQ55N+LF+bRZt9/RCbjIOCNf8QZiyxIca5Vx4kUv3mJe3mynv5zZfwKZGOK6KcegufSmLH +mFgxfrCtGBWWtztSwi34i2xoZWTFmFAGOoPOoPOU6szxs815i+gvtEnbw227LG7a481LsMre +RqLYPWtGnu0aMA8t92seFLYOIlk1Fj7LffD98sReGN87V+30cnZ73ohtu+S8QNbDbwadp6/O +eL8rBn5wXUX98LeQqhDFf2y3MjXyw+stE5Npz9dUiFyNgM7/e51FtpkHBavek9Rt8mBF2i3e +RmQyDFP28pQqQdOl8VJofqSzbABtOUrhR1hEdRDFkvmObPOUTQEyzSM/gwadp0RnaQ+/+khA +9Rk+7qBUJag7zqo4xm3+j+uf+F8bz3EqT3Fb+n44kl97jF13jv/9SHyyC7ymi/zGU+zl+9hN +qsd04WX663yCzHCzyt7k60M1lkjJJVuIgnhTdrlf40FfkteclP2CjsHJq9a4zhnlpq4lXt/p +3HSYzObPD1vjn5JnOOOl55BOhnwQBZ2nn87SAVR5nu7v++z8UOeGIUlbD41s+Zwl4tIwKm4f +EbWPilrHNxKZRrjiXUnpSoJjtkfziLhNu9tFlJfFHYMBQWzLmA6G8rKobVTUjo9RcxManRK3 +cpr2+CXX+DUOaxfSPiLU7v1VqPaHvIe1L+Uq0PnXdBP+qfg2PSHHc8khRvhCcw/E0Asx4lV4 +V/UJW475Ry12KjjO/+7AST6AlKxzC13tj7dK62wfgo+p2OpFCzYkpzmnd7hHtZHrepBHfccK +dJ4SnRVnaTTOs89YGBe+LWrc4TL3xb858d0aBnlJBVbufKOQFnLzIFq+zs1fYOzJm2eX51W8 +zj1+NVXaw0rK8Sg9Qgtm4TrTl3f5MIONiHG2aW1u9vbPmCYSijf6pdb4Ld3pyxPN84i3XXSI +jx/y8RbbM2ONfFKcSk/x5f9TBab/jao+RDkilKmQ1lFRx2Xth2TbkFA2flLTOiLCPx6bf3QG +JGzVID8+JxJOfK4qh4RKNQo3qqarzvIT/uxMIxeOUcR66qJia2+qESfMLaHBxjneMfcNL0aY +SaDcix9kHqEghqQY2S72zFhmzljiI+uhczwt0rdTwwTWCe2U+EoCusSZK5rtGW5JiTbkdlKX +ylz93Y3deGaSet8FlTaukW6lm92MSEZRa4iisHn8JopCg4LO8FQY6Py/1tmPlW0hWOZECzcn +JdpK0p2QcII43YjXRt/8sSiqzJoQZ+kRR6i6HFT5pot7kefC5RacGlKbOgDxt87cqdU5VkqK +b3GJaHTnS2Z7xVpzFltF7uHVr/YgW898TWRXog5aedqP4Wu3cLWbYzKhclCYVWzKqyfJ1aDz +5Hlx67BQm0FU9lPnID3aU2Dl0PgJb4+217QT9z18Jy7/j0e/pP3Id5c6J6NCtG3uQ/C6yfpA +52mk8zEyJdk06nUi6bU/vsS3SatyCRAQkqR2zlF2aa1utFCTsE5fNMRMUukpiplnke6Rr7R1 +ElkmtzgRbIzTd9GCmZZR5a6+IXOZ5Z4xGUYEkSkt3si/llQidaV6mnijZshSz9hSK7d499JN +buYRDkv7BAuyDVk1oPPESbGg4VRA3npSxkrf7M20RhX60KsK2kuUx5hle1mNfdrHOJtOs0p2 +M+suCf5dW/zlRW7VkYD6i9//CR+oP81edpz7w8uV+GR153gtF7glexmVZ/lSFeg8LXTGP6Xf +ZiS0ehQcYaUW2wY1Ucq3+SVV+TWpuWnLbH0kppHt/i2Dwpoub16wKSPVTrKC1nKeEZZsxkiz +jyjxXHqClV3ulbcrYLHUkRxqKix1CpF6Zylc2Iudc9aRU+v8Kg6QReFGxDTH/OOC5iOUwBZi +dZ+gZKVb6iaGDM6d+5C2IUFGqeVcx1nkaFNfkRG1xLvy0vjj1oNCJR71xH0BpPUKkr5gzgsv +vZp2BFk1hqQunP3nebMXHkPwk2jtZEPa57fxXXDbmFh2lMyPNcs4hKwYFeG7XXzX3zEmzGm2 +c8z1kg6LWscX2/6uaFm7S3CFT+NFdnybd8FxftvI+Ntpn/FG5Jrx4SGh4v93nxF0npr7zn1I +65AQ3x6Ul8Xtw6hMjbaO4Ad1iHJE1HlF3DZ+gKe9kHJF3DEmbh9EtRvhmLhDeylbe2VGMX7V +WjGknVh7MXwY3xJEHaNCuQZVjqDyARSfsfOySNGPH+Ch7eOPF8oHRcr/9S1pfdV5kJ+cb+u/ +2G/Vl6EdF/xpTJP4Lezmo/6hCcakCMu4jUxcUmmfVufMdMNXXnqOJmN2DgQgfs//2dU46yh/ +yVpnD/Yc7zhC6SlBywkqP9qYIJjrJjbL7mamVTvlHuPXrPeJKfBNUzgQ8r3rT1BDMs28xSYh +9d7C4Fdnm87N2EKNkHotPsjKXmbtxppDX+ZddY6TXmkTEGfmwzWJeZ0hU//2+4ygMzwV9jvU +OaXQlpzpKxsTtY4K0habSaReIaHzHQKMaUGzZ7mYLT4tXP1u4JqPhFmLLElMQ2qie+E2b3+2 +kW2qfVSjG51nmvAWNX6hZUCac1ixFbXYe3GroxfXNGs3VRJjmLSfXyEl0FmE5DYn12KfpW+5 +I6XO0Yst7ByNBbHmzHiXumP+3gmW9IU2nkK7vD1+gkgzzhJPYeRs6nKf7OV2PkzH8gGhQgU6 +g86g8y/eOxfie2dy5yfBK0c4EVHmMVIPP95cjwT70DLHwFKPTJkbNdiYXegem2ETtMiRl2nu +E24mKieQcuzQDDsqh9D8WVjLJhdajAktwTRqF/J6D1WYZpnR5R+UaJJ2HK1pc2GhLiltTm4l +XkWdbmHLXaMLrAgEU3GStaTAR3mJ7pdi5RJm4lpEfvNfQXm5dsxgB0m2eeJeXtMGDzrNYWk/ +6Aw6g86/VOf2IX5yroUlyzrtDWJskZV7lNOyM+zYhVacPLcMhQu3zKt0HyPndVLhPkZCvHnQ +Mq+wlJkGBi+lrPbxSLIOV3hyJUbCWnc0zIyf75lUY+eT6BBZZOlINcw5xApLmOubQQiONnbn +OifLHRwLPZJSjNwDbZMbHF1c53NjzYki25JdZM94S06BI4lrES11pYSaoQ0+wUmGkds4datd +yT52oDPoDDr/4iAKNbJ0vSc9ypQSbkpf6LT4EFcxJGw5TY9aaOoXY5OylSUfFLYOizquoKWd +3ou2MJa96SHIcy8/wYxv8y05I6ju8mZEmrIKvSovocpLrLhCa0qKTViDV8VFpHqrFzfSXFzq +mt7qX7yDHP0GvaabjB9j8/MJ0RXuuZtIoXmOaW9SEjuJxad4pe0E/3BTiZLSeImb2+aRf5TX +2O2fUkWqUf3221igM+j8e7tR1dwjkGuEK66Of2XfmEg5gGhvK/ejbVfwMeLWby8YaicbEio1 +iHxQ1HlFJFMhbUPaB2VlGqH2e/Yujz8ehh+6XxavGL8gKdM+lyvqvCppvyxqHUblamH7ICod +EOJjtE+UXRYpNcL2MbFSg+LLUfQjimER3oaOYVTap72qqb1uOYC2jgqlcGUbdAadIaAz6Aw6 +g86gMwR0Bp31TufeUVKg2cr3RJOP+EJ+kM4r4uL9PuLH/rX5DMS77gJj/BQVeuFHWfdxMD3Z +qOst0PnhqPuGjVyfSVvvlLTCUReyYLVzziZfXWnMGgK6fC4twO+x6nwXI3hbRUjNU1brRKcs +XOeettZVR3oka7OLGeXJbZt2grkP5fr162lpC5JTknUkwcFBlpYWutMePDKZ7DF3Snn5ct1Z +fQ6HIwmU6FCPJCcPDw+DuXrB++99EBcXD3XQHepq69e/uR7qAPyWc3mNJjIyEuqgI9y9e9ff +359MJj948ACqAYDOes2lS5eefvrpZ5999urVq1ANAHTWaxQKhYGBwRNPPNHa2grVAEBn/eXW +rVseHh4G49BoNPzAG2oCgM56yuXLly0sLJ555pkXX3yRRCK9//77UBMAdNZT8N3xzZs3s7Ky +Nm3ahA/cu3cPagKAznpNXl7e7t27oQ4A6DwNyM3N7erqgjoAoDPoDPyeuXr1amxsLNQBdAb0 +mjt37gwODm7evJnL5fb29l67dg1qAjoDesrdu3fT0tJefPHFv/71r3//+9937NgBNQGdAf1F +JpNNPLTw/PPPv/POO1AQ0BnQXz744ANTU1Nc5wULFkA1QGdA3+FwOH/84x/XrFkDpQCdAX1n +w4YNBALh+vXrUAodoaCgYO9e+DIf/eD+/fv/ePf90cF3L+tGtm7aSSUFjGqu6kh7rgxfu/7p +4/5s+efHH304qvlwRK0LSY0IXi1t1JHGfDg88OHVK7fv3AFzH8qVsasmNrNJEnNfVFfizjUi +Ci10oSVEkYULc744UPRYu+TBfQ8/2tP+wU8zI55mhE95/uwX+CQ1RBdaog075mkL52MH94O5 +D0XdM+IjMlrxPqIcFuhCWkcQ7e8p6EZjOq6ghfs90UDuY+2Su7dtAoQGmz4z6H5gsPfu1Gf/ +A4N993WiJXhOYQai/ENb4MuOHg58z7aufc82rrMDW2yw7j2DHTcMtn8B+VEO4TrnHt62CcwF +nUFn0Bl0Bp1BZ9B5euss7Uekff8/X/oQ+cC3C/nh8C+bV6b6pW2WDaC/buG6rvOXBjtvGuz6 +xmDHV9qXXV9NDvz2/HAJ3y5cm5sGXV/+aEr8Jf52eHb+knf8cnL6X968nf/X3nuAVZWlaaPv +nX/uzJ2emb/vzPx3pqu7q7urrLLUKktLy4yoKJLDIeeckZxzTpIElYyiIBmUHEUyCAKSJQoq +KjlIFjh373PAwtLqruqectBa77Oe8+yz99prr/Wt9a7vW9/69jmzb3koofPPT+fAu8KBDSJ/ +C52D7gn71goFNYuy/iFUxK9WKLDhR3JZ9EKdoE+l4IWmH8HlVlG/Cj73O4LUDPAh0DnjBXJm +EduFiDakTtLH6aNIGfkbuDyNm2N0CTdZx7cmkfAQUa2IaEXkA6SMv06uSdyaQNJTxA79OdK9 +SjcnkTKE+Me4+SMyZ71A0iCu9rGqQej8rujczAhpF1BT3aF2nZca8OwzoV0SUf1SEd1iF1sY +Yay/CQ5upf/n9xL12SsZxfpbYfovhvskI/vov/oN6RR3DfvqPz79L+VkwejHkq5hu3+/8z+V +UwTDH4iFdbOKYv0vcGivRGSfZBTrlkvt4hG9kpEPJSP7JfxyTmiHHfdtlYh8SGeIZP9rcItY +BJ1ZMryL/m/ioPuilzvEvNM5OAV+v4P7E5VU/ld/bfze0nkG2ZPwjgKPErhEwfDH9XEEXYf6 +JeQyUfySVoV5KyhmonCZplvuCu2Xpr7mvKDngaJVFFLZVpFJKc1ZFDDpS0VriMqGfCDiJpG7 +hMR74OMFhyzOyIPLFBcfIm+ZzkaXuYSLebDNxuV6mN1B3ip9bxETeYu067uIejpFyQX6TPEa +8ldwtQgOBQirhGsu0hdoRz1VSN4CzdbcZRSu0jlz51hTxBRtDMTdg6AivpGEWSXy5gmd3x2d +OwQUJLYpRPOEdND8Da7jN/D9+pTy59KBpwKqedRDjjpUi12q4FIO5/Qo49Ww2cWt9qVRlkBg +Gbea+W4e3T0m2UIRvRLOoV/98//9T5yuJyIfMVSVfve/f/P/KqUJRTbz67l/zaX8udTFUxca ++A1svhHU2X5cf69djYhX6lFpi13cMtsVw7nPF54yiOF0TDqparaHV327sCuHf7v4pSpuaYPt +J/S+Ugo+6lbLuNzKCOtiWJ/fwyG1W9ryc+GQM9Rc8X7TOXsBIengNUXkMArHYXQRro24EAN+ +BTDMoJ2I1BE4h0HEEHrpSBuBWxQ0XSBkieCHSO2GVgiUbCAZhBuTuDkIM0+IO8D/IaIzIOaO +2EmauddvQ8YAoc+ROYW0CdrwvtEEBRNIuOJKH9QU8Ud+mGfCvg7hRdD0gLgF3Eth7AWVq0if +QeQdSOtD3AdXHkFfG9s5YREP71Kas9a+4NeEcxWypuCdDC0vSJjAs5m2rimC5y0hKAF8+tD1 +gmIa8pcInd8lnZWkP1O6QtP5Uoe4z60jAqZfydnv3P3VJ/qpZxR0dqrG8zoH7eU5t0faavtu +oW28sh/vFP1cK/jA4a8/lgk75VMrEtYlZnt5/74THx8w+9Y568RZ9T99y/iT5i1B/0wObp2v +5ex2fHP6j/rJJ/j2/Y7H4ZC82fYjxofPuXy2W3S7TvCB00JfyFjt4jf/Ws9lz/5vtmmGHTgo ++ZlCEs85t53HDb/VdNnxDe+nZuVi4e2Myx0Mz8QD3+z69U6l/V6NjOBGkfeZztPIWYCDB7Ru +0YOfvYClzviH45QSHBNw/Bw0rkPBFQa+OCoBl3JIikAhFDqOOBmCmFJ8IgKzFEhpwbQAZtY4 +qQIxDezWgusNyJxfp3NCLU4dwwEGOCXA6Yi4MeiZ4ZAKZC1hdQsm7uC2gd5FcEXC3g3HzGDm +g6+UYZcCESV434WBPzQuQEgSsjFw9IaoFcy8oegBC6qStnCPBb8RXOugogWhAFi4gd8CCdRS +fYbWzrEV4DiEfQaIpSz8CZbxT+j8zuj8uWosH2XohvWKe6UcU3Lfr+a868s/fqyRJnw+8cBZ +k938el8pXDjOUP5ot9R2EcMdZy326Qcd4Bf4xrNLMrxNNLSTYX1h3wn1b6TO7RJU3iFssEfC +eLtaCr9PFoeU5wE1+517OH+vHsspJbXHoVEyvJiTl+srRYddchdPXR2WNLDdxqX6majdXj3X +bwXlDoc9FBEx2yl8kVPWdJtavnhsw2kxk52mdxgRXeKBhZw88rt0rhw+JfmHA4q7DHMEQzsY +77F2zlmE2wUo3qAtasowzmH5mrzDoOCPokVagUqEwiQWlgE4LASbImicw4UniMzHYX9EleOg +M1IX4ewPvevgkwKnDhTtoRAEjxuQ3qDz9RLImyJijLbPb71A7jyCbkHSCqqesMmEbQRUYuCa +DN5oOAdBrxAJVdhnh+QZmJnBOhfWcbCMgwgDYtEIiIZxHHxioeIKBWucq0UzE/JukI6HsRuc +OpFcDnFDXGM9Je0BpMxhnwVRbZw4B/cm5C4QOr8bOod2CsgJ/UHA5ZhjNrdbuYCRxeeHxXaZ +xB45uudj6TC+yHY+Pu7/85tT2x1qBDVsvuD14HRPP64SfNQ85OAZzt0uLWIhLTSdLc9/fUT9 +iJnvp3//j//C43lcyehT5SQ+c6/PdijuNos5eIz7dzIRHAyuP4kHHNdx23VU56C+x45Dyl+Z +x3Hwi2+XMNspYPG1tv0+HsaBiw8EeXW3C0ec1nXawWV31DT46yOMzy3KxSg6B2QdO3r8c8pg +UNf5/T//5/9RThEI6xR7j+mcNY9rZeBRgU0BQktoani2wS8MUu7ImYSIPb5VxTFr+OXgrAz0 +UqGsAd9eXEzHfh/aDN5tjYQpWLtCOwn6jtBJQkQl9FPhHw9RF1yfpMOuKGNbRAEutYhoREgD +kp/QFNa7CmN78DjAJBACdtC/DK5wOJ6HRiZiivG1I5LGYGAIk0gcV4dRBvTNcNYf5yMh6QCz +81Byh1EQuD1xKR+ChrApg541bO8jNg9COiw6LyClBWfl4VQJaxv879/BtIJekhM6vyPtLGxk +t+Og0B8Oi/7xtN4hp6yTQnKfcGl9KXbuK90EvuhHYho6H+/RPHypXzKo9LS46ieHBLcpXzvj +nXVK1eKoVzPjcrPo5XaGy41jcr5cntlHj8vvNCngM7+wzyRfKLCAU1D6jyd0vxSx3qMdd5zB +8cdDYp9w6O9xqBe19fniW/6POYQ/l4vk9sk6rnH5qFXUcXWXExfbhdQDD2hlCoXePStj/MUR +id9/I/qZVaVYWDvjUquo89UDXEJ/OGP7rZ7/Ie3IUwGtYj9+x2rrucKmkT2LsHzaSD4jRxM2 +bRbh+bBOQ9YkTJNgnQllIwjZQskXtsVwjED4Y1ypgdotxDZDOR7JU/BPhss9WhuqGeKUBqyr +cb0W5ilImKRN99QuKOuASx6nFejk0UBfFVMBnwn8HyC+AbIWUA6BYQmCMuByF/FNUE6kHeAe +UQhohMMFcOtAxRsaKYhtgaIFNM7DMZteyBvY45QMLAtxcxTO1xHQi8QGmEUhgbVqyHqBiEKI +qoBxHs43aDWdMkO77Aid38FGVZNoSJdERI9EeJcEpe8utYmF9UiEPRAP65GM7BY1d9+1+9Sn +RreFw9pob3ZYl0R4t0Qoy7Md2iV2caME+q5O+mRkr0RIK7XOpf3htPebVVREr1Ro7Wlhri/N +S0Sj+yUi+sTM3XYIeR8P7ZdmPzG0Q+xyu1joAzGqqNBO8fBOUZcbh4WUP+cQ/kTU/Zhvi9gl +Fm2pYsO66QJDH4iHtDHe/33nadohlv+STnkLtDM5c37dLqU+c9mXlpC/jJw55CzRjMicRf48 +7dnOX6TzU7fnzNIn81iF5M7Rx7msom5NsrKtoODl+iMolmXO0Weo42zWXfRzF5E3R5sKVDl0 +ftbTsxfpDNQSgLqXMtqpurEz04sC1hY5dZIqh7KrqQUCtWqgKJzByp+xydHHrjx9yxxxhW2F +qLBLLaLeedwO+QIXW/+2MikyNgn7lAgENIhS+pRKAdUCPtVCwT+gW6kMfmU81vEnLVPP+jcy +qGqQqDASFUbo/N/A6HZadV6kI8co7SlOa0ZKn/41/GJQNjnN5VbqdsZlqpx2RnDTnwlUox/3 +1z7rw6UzpUApfZfHSjnzPyG8hNK2GazPzB+O62AHfVGPyJoldP4g6fxKXQZW89unnDKLO2GR +wu3X9FdqTKoc/yoB37tCXrm8XhXCF1tIzPZP4vI0UodwuQq+JfArwaX7SJv+EQFdVJ5xXBuk +N7KjuhD7/AcCNdkRZeNIHkB0H7219GNCxQid30M6U6taC5/tfzjyEafsp4f5PxH3OO7XJk6t +tcO7xCmahHSKh7HW3WzlSy2u6VCuFlqzh7GOWetcRkinRPSAmJH9dsnLnNYXjlveFAhnBX2F +d4tfbhW92EItzKkyaQPgUjOh89sStXz2i8Z2bgjpQlALaqFIekGvrNkpd5YOFGGHYFHr2ew5 ++pNewDKR04MTdvBqgnMegh7SAV30mnqZrhWl6+kVNLXIXUTAVdiWI7YBziW4Obe+6M6ZW1+b +57GeQi2TbxI6v990DulgGHlt57rMnbKgHFN14qTS5+eyeI2cd55Q+EIp6pS579cnFbYJ+5/w +bxUPKDzJI/fHA9rfON8VPZ9+jI/x8SGNr0wKhMI7RU29dx+U/vQg328lQk9Y+XIYhXEou3zJ +p7iNU2G3dano5WpuMfVPDyhsF3f51qGSEdrKIHR+g84L8IoEdxCSh5HwmNakWZPwDAevKiQ9 +YFuJy2XQzEHWGJxi4VMDq0DwakArHund4LSBVyPsMqEfCj4VnJEFjxkiHtD72nSeOKQ8hsBJ +fCUFr3y4lOBGBxR0waUCzybE36f3wkR1IOyOK8PIfkHo/H7TuZNh6v35Lukdav4HpfW3nzHd +71LMdVbwI5FLXGbeX+0+8DtuzW3b9n0kHnhC3vIzDssDSh57VcIPcwttkwo6Yejz5UGlb20T +D3IofnkukVOI8XvxyxzK4rskjb8+Jvp7uaiTiorbBQ2PaHjuOmV1xCJkz0G+PxkWM8LbCZ3f +SJQm9YvCn47glCxOSkMzARF3cEYVPmUQ0YJgHLxu4EgwckegbgntaOiEwDwA3/DB8zZOu8Cv +Frw20MpHXDNUzCERhegqqF2AeSD2nqF3vc3N6cCSgDhIuUHKEpJRCEoCjw1sYnBaDG4lEDGG +XBYrhpzQ+f2ms5nX559y/1FQf6eg6X77MtFLladENLdbVoqaOH3+p9PbpJ32ipnsNY45zq/9 +J5l0kcQRmcCbBz8X2+XQLhNdcZLv5FcqbjtOOxyJeCpj4bFDOvyYqtxX0mZ7hQ13ObaK29rt +FVbeJ2b5mVKG6I3Ws5LGXxgWihI6v107e0ZBJB5lTJoLpUyabpwe9IFjNKQS4JWAU5EonoaO +AzQuwSoGlsE4JACPQprOvnch4gqbJoQXwyALeUxcKYRhOCwv4iA3PDvh6gbLUkRmQsIKvPrw +GELjAs7aQdEfSk7IWIK2H8RTCZ0/AGPbwHXb0fOnrj+VvfJQklrkBt0+wSf3iUGJqFvkfi6F +3abJnJL235pm8ihbf35Qd4+IwS5R70OCEp8JOR1Ssf3ikPYhl1tHOeW/kA86dIbnNyJBx5TF +donp7+bR3G7TwDA3/lJA5aB2wG4OvX3aXl8eFPjUuIRo57dq50V4XsY3hvAugEc2vGsRUQFR +LZjHQ0ATkqkIz8K3irC6Dl45CCjRMdUuCeDkg2UijtnAuwaCtjipj5MarHepKNvbBVw6cEnC +8dOwqoGbG0R94RENaU8oOkDQG04Xwe8I+2sQN0bqDJRdIZy0/r4VofN7S+dLrQynxCPqCWep +A3rTqoURVM1jcPEQtcgNbxc29919QvZTEWrt3CIeXH5GXO8zTt39TncZgYUnxZU/PWnyjW2Z +SPgDhmPUt1yqXwhb7zXNPmsdyGESxakfftSjkeF6heNc2Nng+/yqtrs4ZP6wT3ibWRmh81tf +Ip7HlTKI6UFQh07CXrgyiuhCKJjiqAoEE1E4BVMPOsjTMhkBFVA3g7w7TMIRUA3zLET2wuEm +5O0hogsRPch6IayRziPnBuPLCOhA3F0oecI1C+6VSBmArg2EjHGhC/EtcExF+jQ88+BQz4oe +IXR+j+kc3ERHZIVvfuWB9Vr05RbRoPuM0G7JqIdSkV3r29ORfVLRffSli23iEf1SUXScGP3C +csgDiah+ycheydA2RkiXOHsX+xI1VzwQj+gTc4s/LCDz6THBTyV8jvtthIEROn//BwSyFmgW +sN9ZLl5F1jSyl1DJhN1ViCXRvuhC9hvKy7RlXsh6A7pgld6hLliio8LylugXk9klFK3S3u+i +V3lm6Zg06piyAXIX6AoXsrLR5+dotzbbPMibo6tBXGHvNZ1/7tQsGlgr4J7P41rEf6GZcamF +bFT9xJQ2ipQxEhVG6LxF0sVmxuV2MXbkGAkj+ekRJn/7j4wROhM6k1/y3Bp0JjHbHx6d7/ec +kP78ymOJUNY7RyRtTlF9kvaFHJLy75zOglJIHkMB6zcKSNqcqCW/tG1JehJh7lvR3ty17dC/ +mqbuPxe7bysko/iDNjdPbJHKGCd8K+Xzx7P8p94tnZf/eOgk7LPhXQavO//zKbCG9nJvhZpQ +KfgeDkoUpJI/tXk7xsbGtLQ0NTTVt0iSkBL/Ysf2rVMfdU21wMDAd9wpjk5OqhpaqppbInGc +OMV1lmeLVIZO6uqdHR2Eue8Fnjwe0lDXJHLYOrCztvLz8SZyIPhr1vIdHcrKykQOWwTT09N7 +9uz5+uuvl8lfKhMQOr/nKCkp+bu/+7t/+qd/qq+vJ9IgIHR+r2Fvbw8WXFxciDQICJ3fX0xO +Tm7bto1N5yNHjszPz38oS4h+5pUrzLZh0sWEzr8cPHny5MKFCxwcHHJycuHh4ePj4x9Es1aY +bgwmwIxoIF38c6P12TNxLS0ih62ANdanoavrzYqKV1/fezzIZP4GTPyaGd+6dSvZ1cXU1PwA +0qSkZOn27R9GWz6EpKVVt3fvIx4e6uBDaE55GlNNlLnzG+Z//Yl57f7WpbOiIm0/kEQSSX8m +/fP/xTx2jplzlfnZp8wrjVuXzk+fMu3t3+/k4EClMT29jD17mI6O9Nf3vUUfRCo+erRLSur9 +b4gDU+oE85+3MUvGmEOZzN//gRnbRtZTPzf6Zmak9PWJHLYO9J2dk0tLP4SWBCgx8b+YX+xm +fvIR8+//nvmbr5mJ90n//kxYWlpKSUkxNTXdv3+/v79/XV0dkclWgKWlZUZGxofg0E69xFSU +Z4oxmCe/oem8V5BZ0EX69+cS98qKrKwsNpCfn09kQuj8s2Agg/nFTmZaH+ncnxXp6en/8A// +QHH58OHDMzMzRCCEzj8LXs4zh4eZ8yQK/efFyMjIzp07KTrb29sTaRA6E7zvUFFRoRT07du3 +iSgInQned6SmpnJwcCwuLhJRbBHY2Njk5uYSObwXWFtbffpsrLt/q6TCknoDU6e+wYktUp/e +gbGpqel33Cnj45M9D7dKj8irGASHxG2VEdI39nhobOUlWfa+HX39j/d/9f8pi/xaWWBLJFWh +f1MS2CqVURb6tSTXr+XlJN9lj6yuMXm5OeR5f60suCWEIH36H+V4/nmr9Ijorw999eui2+WE +uW/FvfsDmoJg3gezesuk2i1Tk3o8S4Cc5Nl32SOLL5kS/LtWCraMHO5upR7pgIsC4lOKCXPf +isaWQU3hf2DWgVlK0hupCg9joSjL/47pLC2050U2mOWkC95ITXBSQFJ6CWEuoTOhM6EzoTOh +M6EzofOHQ+cKMCtZqeKddFnFppFc8RNHNZW57EfnrPxLmX8hdC7b6N/KDQFu/lq+6WvFGwIs +J3R+z+i8kI/hdDxNxWg2qwd/1v66g8VCrNxhDaoyrBRh8fZPuHcqFwu3fwSjK7BWjNEMrBA6 +l2KtBDNZeJaGp2kYz1//+pT1dTIfczl4mo6JLIzexPAtvLyzweU7tAAXb//o+ZPQ+X+czhR5 +s6DLAdHTUOSD/BlkhmC5ih7nzEYw77G6tZZ1XLs+/unj+o0ZvobudLrwKtZxA+uzjHXjPdZB +Oetk48YsUYm1TKh/AhNz1vksSOyGoimrwHpWthrWLXWsq+yn1LKOG1gH+UjwQnMm6+s91mc5 +yx3KrlI1qzIsLi/nI04eQofgaovl6l82nevR4wqhXZDlgSIP/IPR7giBryDP+hoegCJbyHPh +6G6cOQ4DJTwuXO+stHMQOAwDI0yXvUNGEzr/jXROheoZ3L1Fs6POFIZimK3DdALOq8DdACNF +aPOHjTyu+mCtBhPX4SQJD2OM3sFMPPKDsVKBRle0XUH5JXio4KofPfmnGMBWB48KwMzDdV3Y +q6ExhfWsaqzchPq/Yzsfxmsxdh5/+HfwG9O3pFvAWgGZ4TRnrzrAk3q6KaZL0Xse4ZowUUTW +NTBLkBGIlgSUeuGSJpy1MViI8Wg4SyLQHDfDNyaNaizGwV4YwRbQUMZ8zS+bzvfQZAotcYyV +YrWU7uVqXejKYaYcq3c2pug8uo/iYzcmbcrkLoAtN8KNYaSB3sJ3tQojdP7b6ZwJuT3g4wTv +PpzmQPkNrGbBXQCastDmgNZZCH0LO23YSqEpEoaSOG+HaBVYOaDdGyaaWKpBNBeSHGHCgKwy +7mej1ATnFOEnjxvuiNSFhABshcAngvZ8eotzPgmBXBDjwt1YpGiAcRJqThgIg5MuwlTBOITm +SHAdha8DguTg6YEEUcjzIdUZkqJovgY1JcT6wZAbXva4IAI7aTiKIcoRzgwI6LC2UFmNWsiF +PS927kNlGq1Z1sftL5XOHXY4/geIn4bMadTcQpsVjnwCyTOQOYOaRJbQcuGkgcRYlnXEsrTX +7uCaJHbsREo0Lc8VYmy/L3ROg+ZZ3E3DXRvICuJ5NeYjIbMNRipwUIS/GS6rwVUDF41x0wza +SphtAjMBvGq44wZnI9qWSxTCLWdYaOEqpUBbcIUPUf5gtoGZDZMzkBKDkwqMddGTR0/+s/EI +YiDKGE5acNCCmxG07fAwAglOuKIK/u2oCoWeASbvYjYaIpqIUEBqAJidCDmBbA8Y6CDeD76q +6CpHnzW0vwK/Cv3QvgvQMt4w9cuQpIEAF1yRgSwvbvhipeoXTef75tARx+N8zOTjZR3uGkBf +Fs8LMZOHlyUszZsDRw0kXGctWMrozzxjnDdHtCnEeeDrhuXKd2VvEzr/zca2wkk05NBcCGXA +0BAzqfBgID8Ozb6IN4bPORQG0crO8Rx0JJEYgkITaJmg5zIURFAWCeN9iHOGkRouR9DhZzlq +sNBDlgOiHeGriQs+eHwFsR4YKabp/CIO7tyoCsfuf4W4ONJdoWCFdDmYaKHOF9J7UHABUnxI +CsFNPVjbI1kWpkpoioCqAGojoaGCGG94KqClGPcNYMoBPQaKwhGpBikDlqIpo1fQ4cII8Ea3 +P7b/K7TMsVT7C6ZzAxqMoM7ANNsl0oBKLWjJYqFmY21SQU+8Fkq4FvMdna9Jw0oXT2Jw8r/A +LYcFQuf3gs4VtD/qsgF6c2kuTFyFtx6eFONxKLR5oMZAww0UWUNJAO4WGC1B3yVonYGRIh5k +06y5pgIdCfip03Z4jCsK4+lClm7hojykhFCaiIUUuIhAgRcpIViuoIfTQjrSjfA4EwEiuOiL +zkgEBeJpJM7xwE4DflqoCYYIP/1Eax1MVCBHCnKHoSCJpCjaDR7qhLIo3HLC4G30e+OmE/rC +4SAGuZNgGG8Y2xV4kQRPGaiII9MbMW54XPAD3Pkl0LkW/b4It8Js2bprscsTkfZYrNhgaDnt +r7jhjPKU7wi+nImrClAWoefhNBt0Zb+r5TOh89+4UVW2YaPe2XBWl214qmvX/Vf0cTWr39nn +aza2L2s3srGoyt7doI9fnazYyFO5aTfzlfu6atOWd+26j3otASKK6Cpad3enUJa5AyvmvGpd +cdC3sJ3VrKoWOcBMFsoSSIna9JTKjXrWsG78JbvC7rAkUP0DX1+NgerX61OxSYDVxLNNosI2 +DZVX6c0zb6S1YgxlYGljY/rFLXqv+e0jv4z2dT+OQ/VltCX/Vepjq9H5TVm94675M9nePCZ0 +/kXRuWKT8n01DCo2vpZvnHyl2cs2hTBtYtxf4GkVS7NXfRBBnuy4rLINKf38Ma7rj/vzAYGV +m7R59Yb3+8fPGITOHwCdK1AfAN8AlBtBlAOyZyDLj5wE9AdA4Cjr62lcdUagCqRPgPcIJLno +LbClyncbg7R16FxOWxrXtCBykhaOlBCSw/GSPR82bMTzsGN46jZoUr8Rn1O+cbJqw5C+t+FG +qGPlYU+V7OMqlr3NWhaFyNMbhdTjzHTQnrWx5HkVMrQxtWbrQ0Yeo6wnluhDkR9Dr0quZZV2 +dyOqh13huo3AntvI8MGdRNYxOzSoaiPKqH6jhoTO7wWdK5FnCzkr3BCDvSXm7mC2APMVyDbG +aVXMlWIuD3P5mCxAjx+EpVCdgIkCrJW920puHTpX0Ju/NooICaPjXuhJjx8DJWAWocAGoQ4Y +vo35ZHrnKCWQte9WjrseCDZCVwYdBHI/CPOleJKAuiSMxyPXCUn+WK1EVwDCTFmewArc80Oo +Ke6nbCjlQhicQlQgnhXQAWAaCli5h6FIhJqg6JUXgkXnGEng31GUSB9r7MTHv8NgCTou45Ix +bl+lZ4+BEGQ74aIVevOwlo3aQFwzRMZFupJVoWhJw2ACsn1od1x9Csvd4YgrLrh3GS9K3pi9 +CZ23Kp2pXtN0QJoUjn0LHQasVDFWgWorfPYldMRgoIjWTHoaX4iBmjYGiv5ag/mDoXMRXMVw +mguaQvR2uZcL5sqRroZzwjBmQF0WxjJQEIOyGHJuoNID0iLwVYKJKiouwPYQrTFvmkPFDjla +4DmDpDCaywbHocMLB0vUnYcuA9YSUD6DlmyWBi+EBT+yr9NuxtVknJdGdjAdC2QuB2Ve3Ihm +aViWPk0wA+d+XPHFcDi0T0DtOGrD6FgCDxVIHkVnFqJOQuIsXJWgrINGP4gehbM6dE4gPwDW +mogIxVUNHBeArwr0lZBshXOy8FaA0B50FL6x4iB03sJ01rBHijSMddB8He2xWKpCkQVOS6M5 +Fi3XMV1EW2sz0VDRRG/+O4wk3Jp0zoOLMny9UWgErgNoKaLPSO4FQwCGotAWgqsqTYdLFrgd +AT8ZRF+jB7+9GuyMcP4sxiuRbw89R+QaIvgCmO24pQUdHfpgrgShp3GSA8aSkOOjNxDp9S+L +zpkxLNqmIVAB5zXoiddYCircCAxERyiSXXD/Oq5Zw8YITnoI0IKnEjz4UR2JW65IMgTXb1B6 +A3GSyI6mjWfP47hiAn9TMB+g2xGe+rDURkwYrhjDPoBujrsEFA6g6iZ97H2WFShI6Pye0Dnf +DgrWiJegFc362xnVyDKBgB5rCFWv75FNR0FWFT2EzjmwU8WNeHpIxylBwxBLBbAUQNoVTKch +3hnXnHE7DH6isNREoAZs3TB7i1bZEa5wPIF7qQhVgbod8gwQ7E8LvMQI6pLojUOmKyJk6TA5 +anVDzbGDuSxDqBBG3EiOpF9RKbKEuTrK3KGlQ8+xtQGoScIda9gpIjcYESa0D+TyIfxuP274 +IJAXl5XoIIHOaGjtQcFVXBfBBWeMJ0KbFzcdYCKPvgLcVEaQKR0rGHUZEcawDaAnDVcZ6J/F +9UsYiYTeMXQUEDq/N66wKm/YeiBXG+HeGz6QKpQ7Qc/qNU/p7HVYmWKwgGhnXDTBzTjaU7SU +CBM+NNzCUDCMTkKMB+E+yLaBxEloi6IhCSMpsBSExFFcdqP9Eslq4OeAgTwC/FBhj7jLtK5c +uIVgYfDsRZArRtPgJgnJ43A1wCQ7wKAEPiLgPQZpLugo414GVovp4DqxE9BXRUcWzSz2T8yl +WONqNEq1wHsWPTcQKYNKf2hxwlAGRnzIj0GiAB1sLyqImCg8D4XyCchSlaHWVhm4aIG0KKQ6 +IigEzFsIM0ZNFHzkoc8H4a9Z0QWEzu/PvvMaK25h7c2Tf+nML/PXSNZeiaKcdgu/ZPFuOR8z +Bev+q7lczBVt7P0VYzpvw5lchtm8jVeVXxXC4uxs/nr+NSp/LtY2/f7DWgntkJzOwVLJRjl3 +MJOL5Tuv1W29Vq8CA1iRQpTl8KKA9bUKIZyIdsMMK6D0iR/MVNCfzQoCrKQzr21qF/X05zHw +Vcc5AVipYayMuMLeHzq/NUrhrXEIZYTOb8ihfNNB+cbVitfPV2zarK/YtJVf9rY8m483X91c +ZtkbeTb3Y/mmH4Qp/y4NRuJp5vrm9XwGHsTj5eY6b06VGIlDgg3iXDD01shbQuctHhVGfivs +x9P5PU21GxtbdzaF4P6Z2BX2TnoF2XcmdCZ0Jj/994unc/1fiJT+haZqDMT9z9B5NmfDrCVp +c7oPZ0LnH8a9+wOqfKyYui0y/Zb9T4SL/LB2HrwOGYkz75jOYrw75raOdi7fSnbCfdjLkH/B ++EE8HHhy6Js/ygr+VpZ/SyRJ7v/kO/KrLVIZWYHfMrh+q6qi8C57ZHWNKSxwRopnq/SIDN9H +cgK/2yo9IvTbI9/89k5ZFWHuD2Btanr+6fDc05Etke6UNwqKym+RylDp+djcwsK7/nfaubmF +Z6NbRALzgcFXElPzqIMtUZ/huYmpubXVVcLb9wLd3d2qqqpEDlsHKioqxsbGRA4EfwU6OjqU +lZWJHLYIhoeHd+7c+dvf/vbFixdEGgSEzu81MjMzAfzqV7+qqiLLVQJC5/cblJkNFnR1dT+U +Nq0wnz9m9vSwUi/zxSLpZULnXwKePXv2L//yL2w6f/nllxMTEx9Cq5YHmEI7mMB6im0iHU3o +/AtZOCclJZ3l4dHT00tNTZ2cnPwQWjV0m/nlHqZbPPN2ETM7h/l4inT0z4fWZ8/EtLWJHLaQ +ve3hkVVT8+G0J8+b+ZvjzFsVzPq2rVvJvj6mgcEHkCbk5Yt27Pgw2vJhpKr9+/sFBT+Q5jTU +MkP0mH/3K+a/Upb2/2Ke0Wf2TG9FOispfbccIIkkkt6aOA8yr3oyDfyYLW3M4nDm//PPTNmI +rUjnR4+YFhbvfbKymtDQyPvqK+qAaWn5IbTo/U+lBw/2MBgfSHMaKpjpUczc+yzOvGDu3cbc +acRcIyuq/36w4/Y6RkclWHsiJIxvi0Df2TmltPRDac1LpsZu5q/2MxseMVtvMv/j35k6caSL +fw4sLS1dvXpVVVX1yy+/tLKyqqurIzLZCrC0tMzIyPhw2tNdzDz1Bcv2/kcmlzFzcJ508c8E +IyMjbIDQmdD558JkP/NaNDMpmzlNbMCfEWVlZf/2b/9GcZnBYCwvLxOBEDoTvL9YXFzcv38/ +RWc/Pz8iDUJngvcdFhYWH330UWNjIxEFoTPB+47CwsKTJ08uLCwQUWwRmJmZ3bx5k8iB4K/A +s2fPrl+/TuSwdeDo6JiTk0PkQEDwAWB2dnZpaYnIgYCAgICAgIBgi+NxQ5ars7O7l5eHu6uz +5/XW528x4Z62Fp2nrlJw8c1ofEKdmemuCvN0p884e6RW9K0tjd3Orx+apQMAxjpbq4q6iCFI +QPDuMdpbn5QQY3DqlLKRT0JKyeNZJnNxvKuj8+nMq4iRtYJw3bMWgQUU0kLktZyLH892XXNT +l7HOoM7kxFqamcXn39KR9Sx9Qt/ScuWyqXzsNJEsAcH/EIrs7BJKaLW7OtITbqIrpyAja+Nf +Osj+oci1O9fM+I3cExKTbyVcUjX0rng615fsqyljEpOQdCvtip2NXXpJrplWYNVTms7tN6Id +tJNniEx/PF5OVeenRIWHUohJLBn5yZbNUkdVbnRkGHV7+JWcAarTloYLUq+zygtNzm+h9xfn +nze0t4+xfoJr4ml3VfdzIvUPF3O3zM2jszupo+o4TyGT5DUms9jH2dSpmD2ySmNMudSt/B10 +9n58JKDsKXWmI9ZTSUTL18ti7659Vqm9zIUWHSX/2ucr1KWuxBgnjUSinX+KhVQjtpdP3zUk +Ojo6LvH284XVlZXF6cnpl9TsujgzNj7Dflnw5crSzNTkHCXjlYWp6U0vKawNWkkrqVgFUrf7 +WVvbOqT0tGQLcir6RFEnwq2VTSIyOl4+u61mb1M+TGe/e/P8We9s8gLiB0znm2ZmUSw637nq +ImifRx3UBXmbWeayf1Gx8Lq1ZX4fdVByyVnLPW2OUsHRfoFBt6kzbbd81a2vjM70uMhZ5va8 +pG8M89XXo/MQ/FiM3VU6oex7o7CioqLl2ezi4G01TXklPZfk7HQ3C2VJhoZvTMPMk2pVXU1F +RRlFQ6/4K0EKEiqR5X3r7yqsDjppmDiEZVXV3iu6GmRpENXWnK8oYZNaXlnXUBdqbO4Xc295 +uMLAw7V6hM5+LztI7EIBofMHTOd0Y+OIjHbqaLqnzl1VU89YT87YMaV5dH3tfNVcN+EufTjd +ZCipHFnzuDM2wMMthebsy8fe6op2yfUtmSHGJsZWVoYyOlZx94aITH8CJu4pHOGW1DS1srK6 +VNQ10Z56UsWr88XwNQ2t88mtC1MdburmSbeuC2s61zzpC2KoeCW29Rb5qfnFravttSEXZQWG +mrEm4/C2/SqVoyurD/MEOEQNLA25937KaxBLL3wG83Xd3WrH6OyNeRdFA/MJnT9crE4MDo5M +rttvC8Od+dk59wa/+8XXqdFHA+Oz65qkp/fh0OTc2POnQxNs7TD5/GHLAJV5paexNCsr+97D +MSLQn4bhalVu+8rhDWnfTxJwT5xYGQoU0ouvocS+EG1nEBoXregT+2RlNEbB5WbN9FhDuNKF +uEl2B6z2Oeiez+mhDvq9dfWiyoeWe/LV9RKohdJ4bayulnvTONVt1drmtkXPWMZ2ipuwP6Ez +AcHPROcK6cPnMtrX/6FmsjHuhEX40NpKU6KPtr6pm62NkWFM691UfuvQ/sWn4QybpIqJ5zUX +pHyubtC511LJ/iprOhgsChWTdiq+k6qkHDJIM3Y21kpT2fnmC+Zs7sXzpob2fn4uelrn4uoH +idQJCH4WLI7fq2h9PvOS/W156klV+0OWqbR0vyQ5Mupm98QKc3G4pv3h3OriQH3n0Pjy4kT/ +vZ5Hy+vG9mxH04NH4yw/x8pkS13Ng4cDzc2D86yri8MPqutaaNNqbepuxvWIiKg7TWQpREBA +QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA +QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA +QEBAQEBA8K6xOPWsvrI0P+cV8hu7R8af9d69P7j0Mzzu2YN66hl1D8f+TJ6x4aHnL5Z/4OLK +8EBHxZ0idl0LbtePLq5fmH7aU9PYv/DmDTND9xrujyysvXHhRefdxocj8z+1CQsTQ02VZRsS +y73bMcw6vfysd+D5xMJ/i5RWXwxVFuRWdQ6t/rj8a2sLkzMLtHAGex6OvPjxD5oZ6qstK8nd +6Pvi+s7XO325/34FLefy1tnvVeXl6N07BdSlu22P31Lu0lR7Q3Vx/kbBeWUD4+wOXR1/0l1R +WvxqtFU09G8qeLm7sZJ+XFn98ze65eWL4Y6Ovsmltbe3ZHluZm5+5Uc0ebS/MS+ndGB04YOk +c3uy88cf7VExNNuATWzBg4H2spi0urn/5kcttRVEmhubmpmZ6hk4xKY1L76Vy00pDEW5S3fH +f6CQcR9Frm0HRdbramZuaH3hTtckdeFp653opKo3h/LqcEt8QlrX1BvMWB7Jj0ms6Zn8qc1o +izH97Pe7lY3W5aWjdC74ZsMqczxQQi8w+cF/xwz7LNxAU1rFODSv6eWPY3NNrI9H3D1qprmk +K6gaWf2jn7SWbSP6h52cBht9r6iseM4vZ5TFvJXR9qBAH1sne+q8uZGFkUtgSe80+7ah+qIg +S2dre1vqkpWZpa1X6uPXx8rig5tHtm3nV1ov2ERTVVHXNr97ihoDkQZCH+/hNV5/oKm6rLzd +1WK63KXnWYHuFlZ0mdZOzg6Wnrn3Hm0uc6Q8eP8BqVsDb53nl0tCfX3jG/5igyc7cxWlZPWt +Aqp7pj5IOt+PdTjEY/P0exRYXlpYXGbPg2MDDxqbHoy/mB0fn1p4uTo/OTo8/oJ1aW1ucmxk +YnZ5cW5qYmL0SW9TW9cUPT+uPepubWxsH3+drmtjTTbatllddMfPlF3i5lErG3ltpl1ZmLqX +k3rjqqeAkGhYA4tlL+cGunqeTW8uaMRDTljBp+xVP+YHmpyS9+x6wVxbWV5cWlmam3o2PbdR +7urU6OT07MLS0hJr3l4b6W1vbGx8+GyWfZVu5Aq7KbN9bY2NzRvKfXludPLFwsJMX3vT/Y7H +37NSmiPPHRQyH9r4+qIu4tA3UrltnWFKJsEpbDqvPOunH/TgKWvMrC2NT07PLc4/6W5pbO59 +8arRi+OdTY2NLT0vNpN2Zf5heRT3jjOBOd1sRTTe39nYeP/xNFvzrM5OTExNjvZ2NHc+mVhb +t6/6PYU4hY3CB54Ph5pKaEcUDXa2NN7vnNo08Cee9lL1eTT+PZ23estS5JR+xCbjqVT2GG9Y +PTWXjlw0VBCxS3y+3viZNF89EfPQ52vM1aFKLW5Jr7j77KevTXbaySuaRNzd3JfzrSlch6Wy +v6Pj6g1rJX7dhFXmaqSehKhVxnfN7UnlOSKX0fviwS3X45Kur6RaHmonbXJtbFOho5WXDh2V +y368vDhDWSILM88GmhqbBlnm0OJUpzEPj4he5MNRVs/OjVHSb+p9xp7B56enJ8Ynh1hdH+ui +svO0Zd0Ye9Zf7Gu/T8t2k6ZeHn1M3Tow+d2Z2ee99Jnn8+8FnZvjnA6ftRp8/WR1jONZ9chZ +5mp3SbSWmpa6tq2jscLOvRoVoy/yHaW4DcJY4lhKslMTMYvrr0sU38+lb2WuZu1Z2/+8Lu6C +lo62urqOiVN4ff/MpoG6PL+4riK7MvxFlOyaJ16j88xAY/qN3MHBqnMyEiH1Eyyq9Ed7+me3 +jGy2lbwUhKWds7+7c67ZgEssun68N8uXVz2ipTFNXsW/myX7tdEqfQOnhMQoZRX9kifTLaVx +5tr6Ghrqmqqm1+sGmC/7bAXkQ0uGVib7IjycdLXV1OX1zM9fbR1dYQ7fkeLn0Xa/6GenI83Q +8Awpmd5kxrVEGx7kN+p6xcHnxZz7BaIqGyJUzS6m9zFXJ0uuhVubn9PU1JTXtk8q7FtZ6jaW +4ZGw8r/sbawsrmzlnjayyFwa6brm4Wygp6GhqqrlcqXl1Zph/kmUs+IXv/nstIRDaefju4UR +RqqUMNW1TFyyG6hemr+qIcojom1moW15pZQ94Y40ZUjv+nTHIYmrOfVRpoxTjHMu9ibqchKq +nnG9tE2y8iA3zsJQV11dw8DCM61is228mmHNOKl98buRutimefiAfd6jpfYkAU654s2z/Nzz ++82d88y16hDdw8r+m42n2ac9jZ1PNs9J822ppw+Lp3R8R4piX70Dwn5LzLUrBlLCponfdd9k +jdB+vtDakdYY40+PK+d1DL26tLS4vNmiGq28fIRDqWTqZV2QwVkejYv+ATrqcuKGbsV9kyPN +t7i+2L7zgHDYnf6ZRw1BzhZUZyrqmwfGFFPjr/KS6d7jso5WJupqyvwn93+07Yi6f/zTkcHi +q7765/Q1NbUMDFxy2p5Rjxi4f8tcS0tVXVnJ1CO3gVpDrXXcSbU2oOSvZWToFE+NmS2PznT3 +P330JUNRlQ1T9zSKSLVXbU+pRQ/2lypL6KT30COtKc78008lSoZf5NiIHNe6yKbzDUt53nPX ++qujD39+LKadlS3RlVfei02/lgRPWYfop99btE53+9kqf7vrrFd65/etYuYau9s0JMTW6fy2 +pc/36bz20EGQ0zS5tTvLm1M6eHh+0Eda8XIZPRB70wM0rUI6G9NkZLWy6+6YKMteZT1z/lFD +Zdsj5kKX+RnpiLKuMl9TOdNrLDtyMspCQcE1feJ5pcieffrRtPG22nVL+qhM9sPvVHTrFaNv +udRK+5+yMJh7wURQxX9oYSREwTg05/FUZ4qqcQB7PulKdJNWch+c6DHk2i/qmEUP+Ll7useF +r90f70hzO6USwaLAWl1l7YOxTRbIeJ3OKdX8J8zZ5gRBMeM7w/RU8jDL9+xZq7aRsQiFo0fV +QpfWl8zrKiXZRMEghLKxV8O1ePlMb7Ae/tiaoeqf83imL0tMRLuIReKF5hR5HbuKoVdtWc20 +ETsq79pFN+T5xOR4TazD4ePa1WPLLTFW+7gdHr5lLToVJMPNcLz5F9wLbalc3wqE3u6myh0e +nRjuKtXh4dQOuUs9MfKcxBnNywPUhWfDE1NjxRd0DvMY0rbYi0eXLWQOfnVQiCGmbehd0PLo ++x3PovOdqdWa83Lbv1GpZ5lv8TaagsZUZdYi9bSML7VQsvNVUTS72sieZ320jS7ndpWF6H5+ +wrCHZau03jzPpRhOib3r1iVdsxi2sim4qHfGKnHuRZ8ln4BFUht1piHcTlrv8oPmQk0RtfR+ +lp3Ym6krb1E9tNVX3K0JznsPKWbUtbLR2fecanf1VXs+3St5CU5cWqHra4ynxSL8evmPp3Lt +xE7qXmbTOcFaScAotr8i8vQpiULaIbQYqXp8t4R5WlpyUlJKUrDxtq9lc7/nUXs597C7425O +mIKSaU7bSGfD7SQaaTWtz9bH5vOKn0jnAUdBDsPE5u4c35MyF+i5KMJBxTjp5dpMmL2BV9bA +Sl+6hJRmUW9/jIejpesFn4sRxY0sY2Sx05JfOSL1pgGfbED+us4aLjx/Rsqqvr1Y+oR4eA2r +DpP39CUEA6q+sxA64qx3/PYLQRl5FlTMfGI7hykCjV6QMbiY3ru2OlVflBIaGJGSmeKuwXtA +2qpjqN1IQMguqYd192MPVUHrrO6J5iwLPetA36DQazd7Xl/Xrz0pUz+hlNU9luetdtYybUM5 +tmgdE4uqao3R5hb3zHxdJrOx+tLaAcUUjUKNxPTi6tnzZriSqtOV6sYrRjsOMEJT0igp30wM +OLb7hFPmKy2zluco+YfP9ktT7ZAR3r1zB5eGd+MT2l6tCjXdd9Zp8C2euIkAKW5x54w3LwzU +s7sy6Xbz04W+nBPbP+cQpAvm59jz2V6hkMymWXpyWLhqxvjdjmNy1AVJgT1fbBfRv/xg9JUJ +t/bofmXqtWB9BeGD3xw3Cr6zsPamdl6p9lXkVPVluzwawpzEpS/MUw3XUjMMvrcydof/64O6 +XtdSkpKS01KtRM5I6EWmBVlyKwSyzYnGBFdO6cDntIP06Z206xcjYm6lxGpKnNyjea33fsKJ +/QoF7Cns5fzkxGR1tOWOPcIhybTo0pMvCe7fa57Zt9WN7RtOh7gt+l7vuKorFJ2js2JtT+mF +r9P5SZGwgH7B48lsa2q1FcryfKyk2KvSdK6M4jrOyKWXPXPhiqePiGq5uThRcPfy9g/NfjS7 +9sr9unkJbCMsahBUVJEdTWd18ki93bP619F5sk7lpEDY3dHeTO8T0gHUpLLck6evZZlVkmsu +a9FAWYcdCaJiyvm0McXsrc5wcbBUlpXSdsscmem2F1YLT0hUOyMdWPh0w3D2PSluVt1SJM0p +Glz6fJ3OksL+lcPfM7YffN/v/zRQxjAsd2C4JVmOV8QpOK25/3F3fpCAsHppT7OJoIBFbDt7 +wHqoC5umtLGthKzwQFsDZV5xveslPa/TWTmre/imoyy3TfoGZVt0OERCSpsoOou6pH+Pztf1 +pNbpbMjQjKpi8+6SopLD1cq7YWaHDwvZs7rExd3T53zMvYEXrxnbWsF0b65O5kTZcYqbVz6h +7YThykieE0rlo697KQcfTS2vlgaqHdUInnltApp79LivMo3dlU5RRV0vum5xHxZP7qDNhJH2 +vHPivDbXatmehjA9SSHTBLqvl0ay/LUFFKzv08ycK46OKWj+zoR/VHBx3w6xrIcLb6XzMXkP +dn80hDtJyAbOMRdCNFUNLza8fF7Ey3FYwczZmaqHs5u3j19mRXu2nxGntM96forOskHU2GrL +DOQVUApKLOgceF513eGUTODdyphj+xQLHn63aKiJsNr5pZC9O0t0bp7nL4RVPJze+nQ+wGXS +Mfc9Ottxa13taEqTkrJvZkl0uCTw4Ncyhc+X7oXpHNMMYpmGL4I1BHiM4x5WRp3iEM15QhO8 +LNxczi5hfay059n4Jj7c8EvND9zR03Jap8VS6zlx5YC8wbdUiKYz48/Q2VNeWPF8+auRVB5i +dkTStXdxrSPVnVM6gKbl2nCwtT7naWFplxxq2Cy0xDMkVLJ7xgd7B9Z9R/Vhe/fr3etvdRRU +jC5tSbPS0fHMZRdX6KMtZhb17Em5+DGhdTpP1OtLCgVUvU5nPoOOhTfpbBxd3FsTrH1aK4R9 +qilSZ9th2er+FhMB/u/orCZsntY2O/aoa2TdwL6iyC9ulbS8ic5qnAq3uuYfl1w6K+3SyRpf +8003+Dj0qh49jVLnEvk+neeu60mci6D4shpqIKrxis4KCtYRdc/qrsmoO/avG8Fd3h4XSwbn +NtFZ9ITmhQ1uTl01ZXwj4T5IKaiXg16q4tIemRuXliri3RXMg/sWmcsDRXInxQNzejcM68eh +liYWQcWr33OFHRRLbF2fN56WhZ3YfTq4lJpSX4bpSQga31hv7OqzQIXTJ1XCKJWR46x4Rj1w +eEMKIxVXZM5a1I283Eznw8fW6Xx0g873wig6X5hjLoaoqpmFdFDGj4WyVlDF+rRQEnYpPqOl +INiYU+o7Oh+XDZ5mLkcZi/G6VbCzJVqKfXXGY/BZk94pMf9S2gybq7+houaSnhKjLWPftt6w +h8E+vqUDs1uczo0x1rsO67a9Xs3yMLODUpdmmEt1ib7GFk6e3qGB5grbPpHIebSy8KhcQ05B +3dozNi5C68QBvnPXespCDu3jyXi0yprjuyOtTI0d3D09HQzULaLSml++Us4r44Xh3nZuPp6e +ni5urv6RGc/fuufwrFSen/dCLatH5oeyrsVX9m7eSxrzkOH8jEPOw5OGv4eXuYVPZiPNu4Y4 ++2+FvNhG86Nc74/+Y5dXOa2SXzTG8AnJZ7Z13fSzMrR1o+5ytbVyvHF3fv6BMYdQYNGTuf5K +W30zOzd3T0cXXROX7I4p5nAB99en/YpZGn28Vk3gjFf581c1aArV2nVCs/X723hDPsKaF249 +nO6/raEqr27j6X/lioeB4J/4NSq7GnS5ThlcaV1fGsidMUnreNKcqWNo4UHJycfRxPh8ceOz +73Tdo9ty+8Xim2eZy0NxQbZ6xk6enl7mhiaBydTac+6C5MGztknf229qTnIW4ddIzCn11hVS +CWXPdeMB4gw9X+p4ruCCq6GZA9VwMwMTt/M5YyuvTJvVVGOebxXOf7dnM9Gsc/yIhGs2xeIX +PaVWFiaWjlQVPd3tHXTM7RLqn7DvbM+OMVY3t/P2pi652VrpmoY2P39tG2OuJeHwl7yxTa90 +2WpJgN5ODt2mobEIbREunZhXps3Ks0rJg0e0wqpezvXdcLezd/TwovvV28neIaGi57WNqrLA +r7+RLJxcqXCX2CvmyO6Pu8HW/EKeVP2bIjz5ebWii7sf1SabGJtRytTJysrY9nzj09lib/V9 +gq7s/HXX7fYLnx+jlgbl12V5FS09PcMjo40luHZwulKKoLkgQlXLjBpa+poGPmEVL5nz+VG+ +eka2VI3szIyNLuaMvFzb4nSeGequrO148brTY+JxV+39gcXFuZnpiY768sys8rbbMVJGHndZ +bpnpwab46zF5Ne1DfX3tHU9mJx7VVt8bfrXOeTlWmpMUExNX/fDNveOVB7WFMTExaRWdyz+4 +6zre0tAwwN5lWRytzC1sfrLZsns50FaTnhwfw0JiWvnwwtvCSBZH6+91snfKWGEkzWNUeS/H +y7KoisXklLezhtPsqzCStamB/OSYmNjCx9OsuXh+pL6q/iH7/uWptob6/onvbOuZR+2VdW0v +vu8mWuxvbHv4jCb5xEDjjesx8fnVz8dGuvp6RmemOurrO5+wVdVCT3N9B2unbKq7PoWqTVxK +49Dru+UL4y01TU+n2RJaaCm4SdWsrIsdePPy4f2ae93P3tjSHytPTi2q6uh90Nz2mG3YLA/c +b+roZ9+13FaTRze8off1RdXa8wf3aloebnZKj/U2FZS1rZtULyfrC1KpG+NvVX4v7OLlRE9G +cix1qaC6c+ktoTvPaqsans5sKnhppKq0rHt0+knn/fr218JjnnXWFtc9YGVd6qgouE4VmpLV +8fz7UQlLEwNV1ffHXq5N9N2vbuphP3RqsLuhsY8+XhouyEjOrKPtvRcPm1OvxVzbGBsjva3V +7DxU/iF6kLCLHmospZ5183brxOTz5uYB9vT8vKmMen7GvVdr5JW+u7To8qu7VpnvN+b6yy30 +bC5fTUlPTwxwdAlPurvEJCAgeE+xNtJZdeW8j4+Pf3pdPxEHAQEBAQEBAQEBAQEBAQEBAQEB +AQEBAQEBAQEBAQEBAQEBAQEBAQEBARv/PyjEf5A= +</bitmap> +<bitmap id="3" width="723" height="430" length="111248" ColorSpace="DeviceRGB" Filter="FlateDecode" BitsPerComponent="8" encoding="base64"> +eNrsnQdcU1f7x+m2fdu+o7u1rXa4ESegKCKIAoIs2Xs4WLL3DiRh7703yN4j7L33FBDFASoq +Khsy/ie5ev9pEiBabdXen+eD4eaMe0/Ifb73Oec8h0RChAgRIkSIECFChAgRIkSIECFChAgR +IkSIECFChAgRIkSIECFChAgRIkSIECFChAgRIkSIECFChAgRIkSIECFChAgRIkSIECFChAgR +IkSIECFChAgRIkSIECFChAgRIkSIECFChAgRIkSI3jBNT097e3urMNLg4CB1zvHxcRUmVFtb +S9MEqGfdUuHh4fTntm4pLBZLX8rY2HjdgiAPTSlwAsxc3dTUFE3BrKysdUvR9CQQ6KV1S4Ga +aUqB1l9RTzLsTHCEmYL0zTHTmS/Wk/R/XYgQIUKECAEPBDwQ8EDAAxEiRGvLngkB80RfEBxc +tyB9KXCHWbcUMIg0pSorK9ct1dnZSVPq2rVrzFwdqJzGHDNTit40MNMnDHsyOjr6BXryzwtc +OAsLi4WFRSWdaD6CmZmZSiY0OTlJzzbrlqI3zdC5rS36jxuosbFx3YIgDz0dMXN1CwsL9H9g +65ai/2MGvbRuKVAzTSnQ+ivqSYadCY4wU5C+OWY688V6kv6vCxEiRG+QgKWD74csTGjTpk30 +lYCD6xakL6WqqrpuKfq7LrC865YCF8XQsK4rGrMOWmemFLiQF+gThj3Jw8PzAj35ssCDvt/+ +Lu3cuZPlperbb78FfLhhwwaWV6CLFy++oprBabO8SomJiTk4OLyUqj777DOGBIgIESJENDp2 +7Bhs3Jl5rqF/SGTy6fLvfSBi5nGb/umSmUfL1Z4u1+0Thj3JzNPlPwE8vv/+e2BztbW1US9P +iYmJQ0NDGAwG9bIF1ezs7PzSay4vL6+urka9SlVT9OfrsbKy2rVr11/MHgYGBrKysshtHBGi +Nxc8EP1j9RqCB6COzZs3v0HskZWV9TqDwVvJHjw8PAw9h4gQIULAAxECHs8LHkZGRsCQvUHs +UVFR8SqqRdgDAQ9EiBDwQISAx18DHpAhe1PYw9/f/xUhDcIeCHggQoSAB6K3Hjxm5pZcoipp +UvvgrfuP5mjKVreN0WQLTm0EOSennqzWXM/wJMh2/FwoSFD+4fEphuDxZrHHq3OnIOyBgAci +RAh4IPq7CIHhKuOXDh6AHD48aEWfvuVzApxAXRaQA8OcOyQ8AVcALKFpCxQHldBkBjlXAw+E +PRD2QMADESIEPBD9XYJWE7/0j4x58IASNXusBh4wflB7M0BB6rdAYgY8Xil7vPTVKAh7ULPH +K425gYAHIkQIeCB6K8EjsbAT/AoSzBgAGOjBAxyEsoF0wSkTLg5ew5kh0viWzymvegA6ArAE +0Ah1Hobg8erY41WsRkHYA/7IbG1tEfBAhAgRU+BBBP/ICejR7Mzde/du3br9+PGTleWVheXl +2YWFhbn5pbmFhfmF2YX52fm5+fnZuYXZWXKaA0fA70Agz8LcwuLcIsgGXsyTM8/Nzc8sgjQ3 +B96ZWVxYWllaXl66/+jB7cmJmbl5IvKRvH7gAV7Dx9kVA9YAD+o66b0ZcJ1Spglrnw9D8Hhe +9oiNVWMmdXZmJCScZzIz86mszOvGjfZXUTNIXV3ZIL2KmqmbKC52eYGCbm5W1J+CpKTkqxtw +QcADEaK3CjwIBDyRiKcQSGJaujvG1c7O3sEdnZCaVFJf09Lc2lnV2FpRX1ldU9JQU15XU11T +Xl5XXlpfgWuoLK2vqqyrrquuaaysbaxsaqxsralpqq2pr6ypqq6vrK8pq68uaaitqW1qq29u +wdWURySFWaNtUSiH1MKiBQL+n/xxDIzdpbbyryF4nNKKYBI8AG/QgMfw+BR0BNDLi4EH8+xx +8+ZPJBILc+k3EimY6czPlQRIpCwSacOrqdyBklheZTJ4gVIrK+9TfxB2dnavbrIHAh6IEL1V +4AGwg0DxehBIsYHh9koXPSytrdxsdC0vWdtYZYbFNOQWVVZV5lWX5+KKC0tw5B8lBYW4wgJc +YX5pYSGuCFdcXFpUUlZUWlJSllVRmlNeWlxUVJVfWFdQXF6Gy6uuzC8syfQLt7I01bHR8ra3 +Q13QjUq9vEhc+Sd/HKm4Hhrz/deABxTZlXo4fjXwYJXyppmSwRA8ZuaWYI+HuW8RvRvkglPm +Gste1gAPiD2++eabr9bU8jLL/Pw7bm6frJv8/X/MzVVhJid9Ak3g8SxrZGhu9goJ2cZ8hbW1 +H/T2vs9k5uvXKyIi9jCZubDwQ0AFKSkbmD+Z5ORTz9UbCQkbHjx4Jzf3I5rP4osvvvj888/L +ysoQ8HguwQOXq31ToHfXrQRad7baWjO4FZrE8F2a1WfUkjJNAN9uOYuk17Y/oTMECfQG86VA +j6Xiutddqbdurz5vKYYZJqYer/1BPFdzr6XHg0QgkFYooy0JEVHmR09b7eN201SNtLP2sLMx +MdJDYxwSEqLLS0saqmvqSqsqi8urSsqrissqi0srSkrLS3GlpaUlZbiysoLSivzCqsL8qhJw +56nFVdVXNuYVV/okJJi7ONgaXPI0MPA00goQV7ThPJWZmYnHI+DxN4AHwz9gmjke4PYFz9yg +XqtCP8cD5IfdHeAggBA4M3iLenIpuBXQL3tZFzyANm7ceP78+fjVRSC8t7T0STwTys/PHx0d +jX8hgSZAQ2tkuHPnDg6HY77C7m7x0dGjTGYGHcV8zQ0N5wF44HBWz3My3c/VG7dv74acHunp +ATRvHTly5FVEiXmLwYP6C0gz9Zo6w7d8TgyLgy8d+LbCnE+z1ow6J30e+HGDfoY5wzOh9nCe +0op4bbsUvikxCR7QfYy6f6BbFjNlV+t5eG4bvcCdkDozQ8gJSGlgOGmfvt3XnD06Ozvp90Mh +D7AQSbMk0iMSmT1i46NsJaRstu1z+npzzAG+RAtrR0tDQws9UytDF1entKTEzuLK6vLa0pLK +yqKKmqKK2qKKyhLAHaXFZQBB8svKc6tKCxrKS1vKyXwSlZRi6u6hY2drY2qAOq/pJyiB3cJm +uJXNhlcoJzON8M8Gj+sT02v/Yf8t4EGznJbmu7PGqhbwRaP/doCvM81yWmqXCPPggcVir6wu +IvE9PP7zK0zo+vXrjx8/vvJCAk2AhtbIMDc3d/PmTeYrvH9f9/FjCSYzg45ivubJSSxAgps3 +45/nZO4/V2/MzbFD4DE2VkHz1tmzZxHw+DNfQPrvyBrgAb6hq+HEGnOxEPCgcY+sdk97MfCA +02qtU0/IXy0bDB6rncmbAh6riUggzVHYgwieqqJDnc+p2vPyeG/fFbTjgL+4NPrISX959QBX +lAnGwtDOJCogoKi6GtfQWFpeVVFcUVNIdn2UA/Iow5WUlVRVlHdV1jUX4VKiIp3Q9oZm+hbm +Rv4ox+gzCuhNbKY/b/XeuUf/xDFLeenL2ZeXCcvI+NfrDB5hGc00OVcDD5qFKtRKLuqi+WLS +4BYCHgh4/MNF/wWk8Q2uBh7UD86QeYIj+0E+kNXA46CCPxTTD0rgkQGKIghnAF9Smhg+byt4 +UFMHuHxNx3RQBBqpeV7wAKWgzoem5dODH00ROMgAw2zU4MHwQt508CAtURJ5yIUUFxfmJHwG +tZ/dQuSIrapooIGWJzuv+zdswUdE/PQvufmgzNDmdj6ukZmXy+pqauvqKkvLyotx5cUl1RWV +1XXNtWUN2dGXXdDOWmgTXXcjrMm5+BOn/dmOOv6y22cnh50Iv6eiCPq0kCPvqaS81BXSCnLP +eQ2HWuDRk19FXFcDD2ioBdyaqCdyrNEE9T2N5r4Kg0dISIibmxsCHgh4IOBBY/JWAw/q7xT4 +2jKsmWH+2o5ra9vQte31WwMe1E9SoAjNkAfDoWFmOg10L8NZc7AfGL5nwmXp3cU04EE/4PIW +gAdh6Sl9hMWHWQoKm21nvcCx3UZBOMTFGqOpjGLndv1xD+pHVg9hsUBrY0cbM1sbcy9P18ys +tJq6qqqqysaa2prK6oTkTFcXb2MrC0t7cwc3S5Shqiv7/tj//ei/ebuhCK+7knSEgqwP/zHM +zgNO7MdS89MIBAQ8XjvwgP6G4fmiNN4J+sml1M9ca3/HV8sJg0dNTc3du3cjIyMR8Hgx8Ojr +66+pbc4vrBq96oCAx5sIHtBTNv13hCF4UBvNNbwTrxo84A0RQKKHH/CtN/ctgjMwnOh1/fZD +cBzOA8wx9VQxqBJwEM7A8GLdY6rh4oAfmASP1aIaPpfoO21i6vEa4AH7WEB3wa/pH9xg8ICv +heZu/BYMtTwhkh6TV7eQ4mMitOXPavNzO+7YHbjrsLeGurmSlL6MiMkpXgzrQf8fdgayHYrX +vhRlbo7V17M1NfDwds3Kz8nOzsO6eRiaGJvoa7t6oUJNjJy5eDw2bY/5lTWY86Aj/xEzBRGH +U3yhv+6N+H6r7UFOwzOnU/LS8Ah4/B3gweSqFhjLGUYupfYNwuOV1EwObh00d4/VbmvU4AHO +7cGDB8XFxeuCR2xCltI5Z+5TJifFUQ+nP792/Ttzm5DM7NKXCB4tbR2uXrGiUlZc/MZC0q6j +136afvSpoXlQUkrR0NDQi4FHVXWjT0DSxUteatq+RWXig1eOl1XWDw4O/nnw6O3tS7pcoKHl +clLUOiNHAyDBtWvRCHi8ceAB8zn1t4kheNCvYf+LwYNbIwQ+B4YTVFYbmaWZxAIPTDA01tRz +1FfzCNHkgQhk3QuhfhRi6C96YfDoGZ5cbeIo+JV6eAU+c/rRFhg8wHnCTVDfjd94jweRtPh0 +sIWUFhFlLSiOOiHod+aMB/dJH0l5Jy4+i90HUDw8QVLi/ieOu/66xXvbAW8uviAVtVCUnaOj +lbaRrpaRkaOrq6uzlYe0RIKSSuJ+Xovvf7HZuzdCRMRHVND5IKcrKzv2V1abbTv9ThxzlZE0 +FBK6nJOOJ+L/5Gk/C3v2F/XSy1V91/W1V2z97XE8oOW01GtV1l1OCzM5qAdayzYzt0jDJzRf +cxg88vPzi4qK4uPjAXsAW+zl5UUNHgMDZOtcXd2ore+5j+sC2yFtPjE3SfUYRd20kWtbWrsO +SGlECElhxOWdUNjopqbWFwOP9vZu8PNyWrGkvC0r+7mDPKYC0r4y5xOV9TLautmv3/xZRjNS +WMZFXduzoqqBGfCATruruzcyJktO1XHfET0eEayEaqSiTmpSpjKuiue0NFbHKDA6Lq+jo/vF +wAPAjLNrlKC4xQEeEwEpH5lzcVqmAUVlh/TNXQNDMxoaWxHweIPAA/wK7DLDcHw04MEQEgCr +rLEqFi4Sl9++dgZmwAOaNw5ZeYYDqdAAKzzzgfoJBb71wZYXXDWUDdQG34XyqgeocQV6l8ZF +QI1q1Mix7oWsFpXoz4PHJdec1fwYcKPwrRIuTuMLgsED9AbcD9Rd96aAB7gbMNxxjEgiEwBk +V1PDojwPi/j8wo7iOmwhKuBnauhyRsLt591hP+/xPcrteOqoleBR5927g77/JeCX7Z6ikv56 +xgbKyvrnNPxMreyFBdx37owVEA89KmjBL3BehA/Fzx25lS12I6vt7gMu3DxW/EdQpw/7HeZx +38+blJe5QoKClv1/wlMSEfqF8CxBR1coP6EjREomIuHZ0ZfEBOQ6nyUSTSKQm6PO8KfbXHc5 +LUAOAAkMFyL9NeCBCi2j+fqs9lWl3pYFYnLqeyn1Ri1r7NWCRqPd3d2zs7MbGxu7urqAKUxO +TobBw9E97riQIYABTj6r03KBcheTAQwo6aYraKeq6ieo6icqaF+Wu5gkez5OTNFPWAZtbBn8 +vODRemVsz6ELHDw6rJxa3EJO4ioRAA9AK4BtQOXaFqHaFmFQK1LqEaelndV1PNcFj/ikAj0j +71Oi5oBhBGX8ZS+QGUZJLx3UDE4b1CZPOWcJ5UDFc95Yz8TauhbmwQPAD9Y9huO4/lEhlKgS ++dyUL2WCPlHUSZPXSpY9Hy+pGnxW2c3WKTI3v3JtvwoCHq8PeJDopijQgwccoI/GttK7IKi/ +bgzXXzDMwAx4gASveoMeNOiRgObZCh5ZgJ/coVvKak4buCE4P/yYA/cVVCfoHPj5iPp2tMaF +wCfzssCD5l7HcNEi/C788LXaaAs1eFA/uNETy2sOHutGLiWvaomLcVZWs+M6avn7b45cRzwN +dD1EJTHcxzHHjjrs2un/+27sYS4sP1+AkCB6336jzb867Oey1VCzVpT23n3AYdNWJ77jISb6 +3hKilrzHTI9w2LPt9N9zIJJfyFZI0OUIj+fufUG//O60Y5eLuGRsbvoStKqFYschUU6DzBME +Ijm0yNOEp0rQEfAuEWTDE0nLIP1F4EGiAQ/in2wXgAfzy8z/FvAobRqBj0N3mDWeEaijeYC7 +zWorZehX3dKsagHIUVFRAV4UFhY+efKkvr5+06ZNADwsUCmHT5hJqEapGxWqG+WrGmQrX8og +G26tFPDzadJJBTYXJLmLCfIX454XPLJy605JuB0TtJHWjNcwLqK0kqUCWtGhtPL/DZFbAcCg +oJW0PniklIvKOokoBFNOuwCctop+BqAO+T/Ulqqomy53MVHufNwl8wjmweOUqOVRQZT0uQQV +/SxwquDyFbQuw9WCJK9NPm3ZczGnZVwu6vvX1La8ueBhYGAgKyv7DwEP6qd4+NtEDR7U36+/ +CzxYpbypD8KWkZ4i4MhmsJGF64chARSnuTPQdwvNNUI3K+icz+jHPO+YEfUta+0PCDp56sRw +yGONQAQ0uEjd4mqjLTTgQe1YhqDlTQcPIgGIbO5J5MmlUSbnVe0UJVHHDzkdOhQkpxpygN+K +i8tURdhF5ETEtv0hm/e4H+SykxHDqkjbcXFYHuS4pKloJHvGj3WP19ET1hqKLuY6kUeOuP76 +i92e7Rh+Ljc1eQcZCVtObt/N+zx+2+G/bZvVGV79c7KXs57N8SCukBOBkiivAVEsU35fpk1E +QLTLFDcHxe0BUGWF9DTy2UseVKFhDjzsaKHCtZcCHn9mUtPLAg9oJR2UaCZmwMehP3XqLyD9 +dwp+C/IZQkdO60VB/k9z3yJmAogB23316lV3d3fwOiws7NatW83NzeHh4QmXK83t400dMi3R +Rcq6aaoGeRomherGuSoGmYq6qTAYACRQNchVM8zXMMx6gaEWY5skU9t4R7c8e1fQSqqKfjZo +RcM4V9UgU4ni94BaUbmUDZKaQea64FFR3R4WXeQfVhKZUKtvnaOinwNXSMEDUFsK+Zz1c9SM +Cs6ZZEUlVjMPHt4BOUa2GcqXMgHSqBnmgDqV9dL/CGNkRlLSywR9As4/K7caiePxRoAH9YAL +MNZrD7VQT5kABhH6DjKcNgkfvOSas7YNfYFVLfRPJQCZoHWpawS4AHmoQ/1Qx92i396axncK +jRNBr7UwWQyh4qUMtdBPVmHYq+BiwWcB/Qoy0E9yox5sgvsfLkIzBk0DHtQDT9Dw95sOHgQS +YY5EhGJqJERF2fAKe+zidDvE6S18+rKOMeb4KbPtrA4HD9gdP+R67Igb33Fr1q1hmzam79yB +5uRyEJGz1dG20lJ3FJMy5OE25zuEVpYPPCbgv48XzceH5uUMO3TIZfsurT1sqENc7sInzQUO +Wp04an2UNzMzlYiHmGH5D4lIToAoiCRAIDSJvLkLAXI2QDRAzkV8aQ4PqoEdwh+HelaeJapx +nbcHPP5e8fPzw+Dh6uo6NTV148aNycnJuLg4aPwlKirq0aNHBbg2db3Q5IwaYNoamnrdA8s1 +jTKV9NI1TAqAHVczzAaWV8OoUEk3XcMoA+OLq2vqegHwsMNknNMPzytspsz36PUPrzhvQm5F +3ShfwzhP3SiH8qJQ0ygrNLaqu7d/XfBobulxcrucV9REmf85mJnX7OBeoqqfoQmoyShHzQBU +WKh8KcvEIT86qaa5tfe55ngApCkoaSzEtbn6l2kYZpBPzJRcrcqlDABjgDpAzYBn1A0ysL5l ++SXtjKbEIuDxmoIHtfWEDNZq4MHQbjKcevpKl9PC1hlukRp+oBkasOWlrj8qu5UGTiD7S23u +qcEDTtRxz14APKinpK59vQCBqMOeQGtn1ui0X0VcGd7b1wg1Rj86Qw8eNAMub4HH4+kmcQA8 +YmIc5VWsD3E5bt0eeJA7TF7d5aSwi4CAw/Ej1my7Qrbuw+xjxwgJ+PGddNm1z3YXK4qT21hN +SV9NxuUQuy3rdrvjXFHGRkESMmZ7OB33c3jsZfNk2x1+jActImR2iMN534HAbaxYVnbsKZHo +gtRlsu0GphwaXqGaPPHs5VOR4J9PDxPIXEJGkyVKIkDvk56WgF9Ar5kbY6GIQB7Aofh/yD+p +E/kI5VTJ7VJOmEh6CUMt4E4Sk9v2DwcPaWnppqYmX19fgBnBwcEPHz6MoKiurq6npycrK2vH +jh2xsbHV9YPn9cOiEyv/6E/o1DVP1LdOs8KUuAWUJaY3lld1/plVLbbOqVrGkZez6qgP1tR3 +XTSKs3TKdvTABURWpuU0d3X1M7mqpbG5G+OZlpVX/4fJJO19/qHFKI+igIiqnKK2xuaewcGh +F1jV4h+aV1jSCL3u7OovKW8Pi63SMkszsCsydCh28a+MTq4rLmvr6OxHIpe+ieBx/fZD6hUf +NOCRVdEH+wrO6MfQsMRfAB47Jb2Wlp8uEJiYenxMIwQqq4vNBke8E2qfOmR8CuGCYoZxNPVD +NczMLbb23bQOKKbuh76RO9AFgp9Xrt9be4qFgHYkfARUBffMGhcCGoXPB+QHrfcM//9aP/B6 +jZjna3eae0w1dETOIgmeXQ8fBG0BqKBOoCB8pZUto2uAB+guVbvUNRYBvVlzPJaJTzdsi0iM +0RMTNz10yFb0uKWmpIuBju8RAevfWU0597mJ8AdKi9qfPO60bQd23+/owzvR4sLWCkrntFT0 +Lii6Scu7HDtjyXPC+oKCDxeH6342C5njtgonHY9yO7AdtN+9z2svJ0r4ZNBZkRAeQXse/tSi +jBcx3BRrT8ATVvAryyTiPIE4hycQqOCBAEEC8TlqfpoZ/MQT5qemhuobussr+qpreiur+8qr ++surBksruoqKr3d1EBbnKGuOCYQ/7+8gkQrrhtb+w/7LJpf+vfr++++tra3v3LkD6AKwx+XL +lx88eNDa2uro6Ojk5AReXL16tbi4+OrV8aqq1vZOWp+AqV1yaVkrk+ZyXfBobe1uaurq7e2n +H4JpaOpezxYzXtXS1tbT3UNbYVR8aVt7L/OGniF45OTV1jV0/HG6aUtodPELRClBwOM1BA+a +kX36AGI0y0ghPwDNGhMmwYN6dui6O5VQz44w9y2iHiyAL4F6ICM4tZFmMxTYRoMXZt4FkO+C +fpYI9dgEeA2FN6RZ+ULtaaF2qjAZuZRmVgz1gM7zRi6F2wKwQT/FlOHQ2BqgyBA8INHEeH9T +PR7k+GFPwSMhJsZCQMxqK5vdjm2+EqJRTg7u6ipoLm7nbayoXbuCuI56q8jYn+L22fJ78M+/ +OLDt8xWTd9LVcdC/4C8qid6xG7trl7e6moeKElpJCS0vjWHfG/nzlvBfd9gIHPdSPBusIo86 +eUyPnV37OLdFgmdJT015R01xa2VBa0V+W0VRd01Jf335leamka7u0f4rN0bHbl+/de/2vYf3 +pmemZ+dnF5bm8fglZgz+87k7SORJrWT+mpntSEvH+QW2xCU0R0Q3hkQ0BITW+wQ2enhVOqNy +nRyvtTRSspNJh0DmlFf7ef1ly2n/dvAwMjJKSEhYXFwsLS0F7OHj4zM6Onr79u3Q0FDwq5aW +FsAScIShBTSxTaLxJ7yKAGKGVgml5S0vAB6rCYBHU0v3nwQPRutcWsNjSxHweGvAg3pk/wX2 +aqHx3q8NHs+7Vws0oECT4FkKcMAKaptOP9RCP30CCmayGhgwtLY0eZiM47GaHX/hvVqo26IJ +70aNiAx3fIMntMALZtcAD5q+fXM9HrCdjo+KNhE/a8lzzHvn7rCt7OEKGg6SkjbCpxx4ubF7 +9yZ/yxq497CNlIj90RO+e7ldtu7y3HnAQUnJQk4yhJXVY882Rz7OmIs6UQoaVpz8rr9xhO/Y +G8i5z4trn70Evz0/j/3ufZcO72PX5N1/jn+PuSS7o+QBp7P70TJ7XWV3e8jt8VPaHai8J0SF +I0iTO+jCiVBtwXA9iSgT5QRrnTRn02wPh/xAv4r4uMac/J7K2istfdcGb92ZePT48fLcAnnE +5cUEDa5Qrn68vt5PSqbM2YXU3Ueqb8KXVi0Wls5mFS6lpC0mxjdhUAWemNl7E7CXhEB8tWFE +/lHgAQCjoaFhYWGhv7/f1dUV/FpVVTU9PV1UVLRx40Y/P7/h4WGGFtDMLjEn/5WDh7FtQnnl +ywSP6ITS5tZXAh5hMTgEPN4sAUsEB/ZkmAEK/nlaL2rtSQjU8x+geQg007nhAKGtfTdXOweG +0xhoBMUR1cVmA+yB26WPSgoMIvW7oAl4sgQ8oxUUOajgD582FHeUpjnIxUF9afROAwHtSLgG ++AxXC3NKL3Aa0KyJNXpvDW5h2BZ8HLyAz2e1jxiKtkodADYV1w3vpEOfH/IgrZHhDQAPPAH/ +bFVLVGyMsYiYAy8vVvKUuRC/u4I6mpPHZNd2Gz52P+nTvny8Tjv3ObCyubFuiz7O5S4ppntS +UFdN3kheHHWC3/2MmKPQSTcVlbBD/JhNu4059nnKCAUInUAd2GPDts/l1z3ae/ecVOP52U/2 +fzb8G/WOf2p9+APnwx9hjnzkfuwTL75PfQU+9T/9WZDIhgixDyPFN0SKfRIp/km42EdhZz4I +EX4n8PT7fmc+8zv7tZ/ML36KbL4ax3y1FSNsTJI8XNNDo4rTshpx1X3N3WMD1yfHHz56sLQ4 +TyISGI7VEJ69eDpVFU/Gh4Xbd1NNLMwPsseqq91Lz5zPzH8QkXQvOPaOf9h9L68pF/SIEypP +X683NweKIkIkvPLoZf808IDW0t6+fXtqaio+Ph78Ghsbe/fu3by8PG9v7zUseF1D16sGj8i4 +0pa27pcIHqUVLd3d/S8dPF5YCHggQoToLwYPytxJsmJiYiwFxaxY91pyHzSVPO1qYYaVlLTd +uR2z5VdPzgOYU8etBflRe/eHbNocsWWL1Qnei6Ji+ueVzdVlrIWFbA9xY3YfdFdUcxeUwB4R +NDhzwlGQM/z3X31/2WK2j9v7iLDz8VNKJziOKB/ZbM73H8dT7zue+BDL9y+34x+7HvnIifMD +a46PLY5+bsH3sc3xD1DHPnHh/bcn3+e+/J+EnH4vRoIlUfadFPmPUqQ/TD77cZL0x/FSG6Il +PokQ2wBAJVDwP0Ei3wdIbPOR4fJVPRtqoBfvhM4OjC5NLGkpar3SNnr76sMnDwj4P2yGC6hj +gURaWSESlwmkpaUuv2iLfUeTTI0HU6N6wgJuBMVccwi6buF23cJ6xNJozNjg3iXzHiWdYl3T +h8PkyT8EyvTW55pMgoDHuuCBwWAAGzQ0NDx69Ki2thZa55KVlTU5ObnaUMtz6c/s1cKELX6+ +vVqeSwh4IOCBCNHbBB4rRMIC5B0gkuLiYi3OaZgf53H7eWv0rr0x51XQ4lKWfKI2J0Wsd7LG +fLcl4AC7w0kuV9HTzuwcmJ9/89/OYSmnYqAgF7CL3fOn3SghEXdzA3dxIRQXpyP7Hocdm124 +9rlJCpoLCvqy84btPBT+/U7DfWxyWlJnMFoiAfp7MbI/Yk5/7iPwXtAplhCBd8NE3g8W+8RL +6GMXvndduN/FHnrH+eC7KPYP7Dk+tjn0L+tDn9gc/MSR8zOXI5/68mwIP/leovC7WRLvZIm/ +my76TsqZdxNEP4gT/zBS4oNgsY+Cxb8KktrkL8MapMoXaaBx2RlbEHG5Iq+lvenqteGpmQcr +sMOCSLpRXe3NJeQicHa4DHenp77Qz63DxWfYGDNy3mhE62LvOdV+ecUhQekGTsHAHexl7p74 +xQXyyhrCGwkeoEJQc2dn52vyZ0kTx8PPz+/WrVtxcXHAiINTBb9u3LgRvADMgIAHAh7IbRwR +orcDPPAEwhLxKXgkR0TbKyhhxUXdjx724jyceFYhfPcxxwNHLJWkbUSFI7ZwBP663Yl9L1ry +tLuMKPbQQTc2TmMlZR0lOa/9hzx5jmPUpL0Mz4VzHfHevAW1Z4fbcQ4/BQlHqVPmRw5id2xH +bd0cuPlXh1NHtBRkYlNSrtwey+koccoPUkm04w7V3hKk9E2g5GeBov8KPv1RmND7ceLvpsq8 +myL1cZzoV6FCP3kf/9aNe4M7z3uuR95z5ngfdfA91IF3UfvfQ3N8gOL8yJnrYzeej334Pg0W ++iT8zIZo8Y/iz76TLMWSIsOSJMMSK8kSJPLvAMmffWT3eCuJBGhfirT1ywutqC++Mtb76MFE +goK6ww6OxvDYoY6O8orStLCQSpTzoJ5hm7hE9WmBvMOHM3ewpXy/OfGbn/z/920IF/ft2moS +ZXebVzq99C/bnfa1Ag9ohAUQAgaDaWpqmp6elpWV7e7uRsADAQ8EPBAheuMEHnIZr80kh+Z6 +GpQrISrankcYw8Zhxr3fQlYqwtghgJPPcdsma66t1tz7PA/zuPEJWO3e77Htt/ADbFZHuc3F +ZUyMNK30FVxFhE2OHXA9xOorL+V7XMBnH7+N4Gn0ce7EnRxBm7fr791txXcwTFs0R0siWPmU +qaRARHjA/ds3CUtzS/jlqUcPRm5eq+xpjSnPdEz3V4414w5SZfVU2OSu8I2n3H/9JP8TLPxl +5KlPE0+zZJxlyZR+P036kySp/8ZIfBkk/G/Pkx+487G48ryDOfIOiuN9+4Pv2+7/0O7ABruD +H9lxfozi/i+G70sXvnfN9nyAPvJ5nARLgsh7EYL/9Tv1X8+T29zFhIPOu7mYOO3cn2tuPjN+ +E1fb4p2UmZNXXOnh0aymlLZja+jGH3y/+i7gq+/Cvvs66fuvs775LvbLH+q0DJYm7r7qWR7/ +WPAAKikpAdQBXqSnp5uZmQ0ODoJ+QMADAQ/kNo4I0dshApEcxwOKyRmWEG0pJWvDesB2028e +R3g8L160k5J2FhG24thtveWHkF+3Yo7wOQsLBxw+GPDzZuefd6K5hMy11c01pd0PHTP+bbvV +of1+Fno+ClI2HEdMOLns2A56/cLhv43H6oS4ydGjMQrCA7YXGoylUnSFw21Vct2t6iMD23Oz +r3f1zk3PQCczv7Bw79HdkTtDTQNtWRW4wOwU88sBUnFWHBFqvwVLbfQX/9r7zJc+ol8GiH8Z +LPlFmNR/omXfS5FnSVV457LsBynSHyVKfhAj8mGU0AchJz725vsPmvcHa+6Nuvs+OPPFR1q/ +fRUj8lG+JEuxOEuRKEuhCEuW8MdhgmKn9oSdEb3XUb+4spJR3e4Un1vfPTKUk1d3QT1hy+/e +n34Z8uWm0O9+iti0MXXz9xXfbyz736aU39mvJGW96s/lnwweQBMTE+3t7dAmcaATxsbGEPD4 +J4MHIkSI3ibhifh5EmXfFDwpISrG9rymueAJl/37A/bu95M448jN53xS1FFA1PbwsaCdB7Db +fvfjPRJ05gyKkxO1fxd6z0EzORU9OVn0QU67fbzGEnJujibeIoet9/5sfGSnFud+PUllVx2U +haSRJtsJw127fQUOZJkK1WLEceZ8efonCs0ly1HncViTAh9UWVJoW23BrVv9K/jH/++MWcI/ +mZu/9niq8e6VstGGws6ChOpEj7xA48sYpXgrnlCt3X6qv3nJ/+gh+63n2f95iX3uL/6vELFP +wsU3RIu9Eyf5XpzUF9Gy3/qK/svu8GdefJ8kibHknGHJP/NOhsiHGWLv5kl+HS0ufGR7uqkx +aerm0vJyx9jtvJae6/emF66NN9o5ZPKcDPtmS8r/tmZ9tz1x068pv26u2crauutIAht3ZUDo +ysoyAh4vETySk5PDw8Nh8ADGi0Ag9Pb2srOz37t37+rVqwh4IOCBCBGit0PEFcIKgRJAjEhK +i4yxFpY04GB3EjnuqSgdpHvJ7dhxu61bMGwHvAXE/GTlMfxcLjt2hmzf57lvv7Ukv42CpJmG +uqmGkpvCWT+es/57hf2UlGxOsWqd2GzlIa9lLq4ozOds4mDjkyCiZcB/+qSc0gl92f1JmpyD +aLFmFG+ZJXudMWeXKV+PtXijgyzOVSXXVzsvBt1Qln11uGN67i6BhKejpMWlpbmZ+UdTs1N9 +94ZrhlvKW6sLqgri8hM80wJtk931EhyVIs3FgvV4QrX3h2mxBWuyBqntCFDeEqS4yf/sj/7i +P4RI/uh9ZpuLyK/eYnvdJc+cPRYR7PF46ub1sf72rpqR0eZ7d4ZWHt3tT83IVbh4eRdXxqe/ +4b7anc/KmXeUr5hXKOeEGM7MZryvd46IR+Z4vETwqK+vX1pays/PB699fX1xOFxiYuLy8vLs +7CwgkJGREQQ8EPBAhAjR2+LxIO8LC23S5pcQaSQobL91j9OOHZ6iYt5YZzNdTXPeI27bf/Pc +sjH08H43RWUrYaGwrdtSvtmE3sHhKK5ge0kTq6MQLizpsZkj5Jf9UXJSIRYyFqqc5p7iXjl6 +phe51E8e1HHEnAsKVjKzltXV1uA7aXhsf7CZWL27Qpu3ZKvbqXp7jipztmor9ib0yQ4PmVbX +89XOukUuWqXhVp24sImRuoXHE4SlldXJiTJctLKyDIhkaf7BwqNbM3evPhgfvHu169ZQ9WhH +/mB9Tn9NZld5RkNBdlXu5eqsqIrkaFxibHliauXlovJcXHX5nRvj1aXxEV7K+eHqxckWwwPV +90av5lui8o7xle9kr+IUyhaUipdWSTynn27tNFJfDxqcJa3gSW/eqpbp6enKysrJycnXDTzq +6uoAXUxMTPT29gLwACYM/MzIyBgbG2ttbX0p5hUBDwQ8EP29mplbggKkv+ZhrxD9BeCxSAEP +8PweGh+lIyyC5uF12r3bjZPLX1nN7bSko4CA2UkuuyN7Qn7f6cLGbi8qgOLlDDjMgWU94Lj3 +mJmqopmcmB/rITQHr6H4CbS2cEmQco4j70WNrx0iTzkFiBno8CkKCeoZWTp5RRvbBF/SRGtI +aoVHhA+3lpfHY3M8lOu8xfv8zvS7CTRaHqsx4Wm2Oj2AOXvVW27QW6YOK4ZzU66IcGzHpY+P +DM7MzBAIVG4Gyg5zS0RKRI61fDrUiUi+YALxCYG4SMCTCCtLy8s9fcMjY2Plxd6xThwFzjuT +XY6UV0eOTtwq9gkqOH2i7MzJyyoqKWaWWQFh+Sk5GYmZ3e2dROIK/tlioDcLPF7bOB4FBQW5 +ublYLLavrw/gB4CQkpISaH4p8iV9/cQDgQeJxODvMycnB+kgRAxFv4ktordbq65qebrjKlk3 +RkYvBwVjDfT0RIUuHjsaLqMSx3rcZROr1XEeN0VZb15+7M7tqF2sjnv3eAsdw0rzm/Dxaqtq +aijLWQjw2MqJnVM8bnH+dIwTb5HPTrPzX1yw3GoXJeYYpGh88dTpY4cuatmiXdKN0clqRn72 +nkm13UMTU5MDbeVVUU6lWLU2d5VRP41Bd9l2J94aC7Zqs31tKN4hX6nBIOUWX8UaL0Wcl2ZF +FKqvPG1ybGBudvaprwFPDuW1SHHXkFfmrDzb2B5PgravJRKfbWxP2duNMnZDDr/xmESap1z7 +0tJyd9+VgasjFUXeqVhOnNPmdNSenHRsZWtndmxmkp5OvqM5LjG6pqigoryypKImPTuvo6OL +SCA+3VP3lQkQAmCP6enpfwh4ODs7e3l5RUVFgdf5+fnz8/Pg8dnJyWnjxo2ARhCPB+LxQPTn +vQ1vN3jQh1v/K/X3tv7aatXIpTQYQiD09HT7+vlqqqlaaWo6CIk6srE7b9nluf+A5/EjjieP +YfZyRfy0JXbTD9ijbEYCQlrndHTUVR2FT5pzH9JiP4CWUfQw4Uny3Rzlskvz4s/W/sKOkVJO +UWIXTQTExaUNDLwdvC/ruMQqWfgbOHrHZhRcuXF35smTq511FXEuxW6aDa6yI/7iNwPPDHgI +1tlyl5ly1tpw97mdvu4vcTNQfNhTpBYlUuyuUZHo1dtU8eDhNOGp54OMGQQ8xZdBCeuFJ5KW +yeABSINAIQTyaBI4RiCnFYhHIGhYWlpq7+ju7u4oTnULt9qfYPJ1ovk2XCKmoaEvt7Adl1fa +3ljX0trS2NzU0NjU2tZaUFjY3t4Bx3p94/Q6Ry4FGhsba29vB7wREBAAOAH8evToUQQ8ngs8 +rl6tB+ktAw9Qp7e3N3IbfwHlVQ9AG5Ews2PaGwoepU0j0H4uf/0VDY9PXXDKhHZ4Qf7YXhg8 +IC0uLXe3tof6+ly4pKGmJm7Iz43eust/8y63g1xevIJhQrz+B393++Unjx1HzeU1baTl4ndw +Wmzm4t0iZSB4zk32YJHHdlz4r1iL39X1D9snKZrHcWESxS2w6rGp+dEZdWYeUfro+HNWvuet +PK09YzJKmybvPyKtzNzuq2lK8ShxO1eDURj0U5oMUbjjLzHofKLG7GiBEU+No8iAz9lroYpX +AhUa3WSKXNQKYzwGupqm7txaXl6i8t8QyeMgADPwc6TlJyT8PInMIGTyWKR4ORb/GH8DgEdL +S3trc31BkkOQ6bYY4/8mWG+tyXTp7R0sreqsr6/v7+vs7evv6yerqakpLy9vcHDwzf0zeM3B +w9fXF3TvxMREWFgY+LW5uXl8fDwnJ2cNI/jkidAzt/+6aQ+wYExnft5USTUA8dIT6ZXVDCX7 +FyuIxPF4/fVcW7W+oeChhclabXvfN9qH8w8BD2Cz8Xg8Af90Lcns7GxlW517mLuhrrIOD5fd +bnavbZzovYfR0ifQasft+fa77ztmK6dioiqF5jqktEP2l58M+Lees2DbU+3wY0P4F7k+2y5q +bdP2E7PN5jeMYnPLkooriewdf+AXk+DgnmHhnaPuEK5qG6ztHOESnlHZ1PtoljzT5P74cAcu +FxfoXI7W6ERLT/grTAUp3vaVbnQ4nWEumGUhWI0W6/OXvxaqNOQl2oQSLPfVb8mNvN7b+GT6 +/rPrIJAIM6SVh6SVRyTCIpFIWKbszLJIDjdKJhBa8GjrGOjtqMlxibDamWD1baL9roZCj7Gx +KzVNba0d9deuDYyP37h27TowggUFBb09PYuLi6SnW9Qi4PFywAOLxaampsL4UVpaOj09XVxc +DF6rq6uD12s4ExYXdwAL+Pix5P37umun6Wns4mLTutkYJiLxIxLpnTUyLC8PP37sy3yFCwts +8/PsTGYGHcV8zcvLP4D0XFc3N1fwXPlB/Qh4IOCBgAcCHi/L40GgiEggRxWDjkw/fFDbUIn2 +tD+nIIHlE7Hafwi9bXvgATbLEwetxYUdLmk5XFKylzjNt/3819+bsn1pob1FLNvgfz3R39SF +fhPquvUSStQ5V9k4ldUwabd9gmZcQdTg1QEHTJKZR7pVcN5FTLyafeQFx2gT19igRFzH4E2o +1Yd37vXVV1XG+JRiL7SgRG97CD8OkbodItfnKlxvdbTMaH+DBfu4+4npoDNj3hLNGPEqV+Xq +cLtO3OXbI31z8/BUFvKCnXlAUBTqIBDxJMI8OVEFOwfg0djc2tHaWJXpFmnLGe+wIw59uKU0 +8M7kzdbu3r4rnfcf3gIP3bW1teXl5eAFxBtEIhEBj5cIHhgMBvxxDgwMeHl5QewRGRl548aN +7u7ubdu2hYeHT01NrQYewHwDC3jjRtIrHWrB4z8nEt97iUMtDx+qAAv+KoZa5ubYQUIil76h +ot7SfXh8Ct6uXc4iaTXDB+/nDm1AD082gLahBwchywgNB5BrTnu6PX1e9QB9u9SbzsMHqReh +0GwiD17T7CAPtQttLk+ibBAPZWNopuH930GGNWahgIuCRjSoN6+H3gIFfxVxhauF2yVR7U0P +zj+xsBMqCK2pYbit/FmTePoN7sFZ0TQNEigFVULfva19N+F+g88EGpSBr5Thxw1ODKoQRkTw +AUFH4Eum6eq3xuMBvyAQyetsSc+iZN15ch9XW4oyN7IQFQ3YfzTuu12ojb9bHefVM1CzPS8T +cvCk5DcaP3xlseM/Hkqc5t4aO/rifq0J3VATtSXKS8kxUheN49VJZLVOPYNOkOwdqh0YuuXk +n2TqFu0UmmvqdVnTNlzLKUbfJcnKMyW3oPzR1NPFnnOzczcGOtuyQ0t9dWucz4xgeB77n1oO +FXzozT3syF5serQAJdPmrTQeqnInRHbUVbDJ8VSFh2Z5SlBnW/PU3TtQJeAK5oikRXA9+GXS +8jQJPwOBBwQPeDy+f2CopDA/I9wpEiUe7sgT5izcXXd5ZXFxZGxi/Pb1G7fGSkpKMjIygBF8 +8uTJ8vLym0sdr/NQi4eHR1dX17179xITEyH2CAsLe/DgwcjISHBwMDiOgAcCHv8oBwVk7KDX +UAKmEyQaSqHOAFtAyJjCVp4m+SbVwU3AVVEbUJqD1EcAljCsk/rEqOkCGFlq0qAHj1NaEdAR +agqiEbgcmq6gPiv6t+DK4beAWYffhdbzUv8KNwQBDLVrCLxLXz99JdSptuMa/CFSu0Hg/NT9 +CecEHQs3BJ0A6NJ1u/qt8Xj8P4SQV9qSF4asEJ8tFSGRmgc6/TDOtmLSKK6Tdgd5rA/x6SlL +m8qKeLHyyX9zYctnNj994KYoE5Psg+1MYK+JYWkN+aI+UCQoxAqbLm9XIKQbv8cjlzci1ZpA +ItyanApLSLdA+2GCLjsFZWg7Rpy3jzRySbHBBgeFRjS1dy2vPB3xWcYv35q80VqbXxtlW4aW +bXU+dctHcCZcYjxIrsRBPMtcqMj8ZJsD34T36ekgsRt+ki0uUqVY5ZJAy+b8+MnhDsL8NGX0 +hbwjzcrK0goeT3wmAoEAwGP8xo2aykpcWkJBnFtyiGGohzYuN/Hm9cmBgfH6xqac3OzkpOSy +srKGhoa2tjbwGL609FdMDgcfFoAExguR3kbwgJSfnz89PV1VVQVdO8C8W7duhYeHT0xMIOCB +gMc/CjygJ1xgg2BbDz0a09t3kBNYbWDXYA6BnqlX83hUtl6lMYvAslMbdMhnAn5CZeFsoBU4 +2yXXHHAC1GcLuw6oTwxul6HHAxT5ls9p3WEganqBLD548Kd2a6zm8aC+dug0II8H8+BBXQOo +FrwFXTXsNmHo8XgB8KDuK9DE9dsP4TOEnCEwO/0tI0p/GXgsk0hPKIlsZVdIpDnyIYACdyYm +Y+29TMVV9TXOG4lJ2yor259XMhGXF/jFnHWD49csaHnl3P7WsaYk6ba0fzX6fTAQxlYQpR+R +jHXIkrXJ5zKP5HRPlMttTAO1PpmZKSitsHPxdfSOcovKM3ZLVLMO18Cma3tlmnnFxqdm37w+ +Bk0FxVNO48njR+MjvQ0FifmBlsVYxWFv8YVwselA/muYo40WHMWm3CVWAs0uZ8cCFW4HyQz5 +yda4ypa6KjfG2I/WZj6aHINoauVpPI+nAqatr6+3uqK6DldViysoxSXlZEelpSRmXi5KScqN +jo9PTb9cXFRcXl5eXFwM8GNgYGB+fv4v+Lz+aXE8YAUHB4OrBkAIuhogBxsbGxaLHR4eRsAD +AY9/GnjAQw8Qe0DWk94mUrvfYfsFD7jQz/GYmVukcWVAPABXCD1Tg2phw0dTFfVgAbWLhgY8 +aJwq9OABlaXJs0afUA8DMTPHg5oKqAGDSfCgtvXU2dad4/EC4EHjykjFddPPzIEB7A1yejwv +eKyQiHNE8hpUImVB6jKeuIgn4okE/CKp0Smp3jaxvKgamAkJYQFNZUkXezfRfZFb3nf/9j1X +vkPB/S23mjIsutJ+rQ/4tCvsq9a44+UFUa7pVo5FYtaJvC7pohbxMvUdZeRW8Cst3X0uQbGm +rpHOUUUWAQXydulKzjnGPrnW7tFuXiGVFdWL83PQhI2n4y/LK7fu3uluqysNsWhyEhrHHJ4P +FpyJkr/qL9eElSix4C8xPdZof3LAS+xGmOy1IOluN7FatEyFn1FTTsyNoV7YX4Enz2QhCzxT +93T3tzT2Vdc2ldbjcDVFOFxpSUFFblZBbmF2WRWupqa6tqamsbGxt6/37t27hFcbK/2fDh5A +GAwGmLDp6emUlBSGcTyaWzuzcsrCIrNCwnOujx8EFnBwMOo1B4/BwcH2ju6Kqsb8wuoiXP3N +W7L37um8LPDo7unNzi3DuMVoGfhdG98+eYe1pq4ZAY83GjyojSxks6jBg9qKQY/wUIKLw4aS +4eRS2CJD2aA8sLcfIgHY0wK7MhiiDrV/Y7UjDM009BrYembmvcDWGRhferO7LnjQEAuT4EHP +VK8OPGjmpgakNFD7sqAEfyKvwzzhVwQe5JEJPJEScIu0TCTOEslTNJdIhOGrk+XnQx97tRKX +iEO3rtt6oiNjQga7b8rzFH3L4vvDBo/9Xzs3FAwPNsQ3xR3sSfi5LvDj/sSv6rNNipuqbZK0 +fcoFzRMF0aXCrhGaQ8NdUFNjd+4HJhVfwkQ7hBa7hpeaouLOW4aZuqVZeWdaYCIj4zKGh8dI +lDChBNLTaKHg5/17E3VleVlhrhku2jVu8uN+EnNhYjNBwjc9TrXZcpeacFRYcHY5Hb/ue2Yi +WP6Kn1I1Wr7U5XxVrEdvS82T6Sl4lgZ+ZXH2yczk5MzQ9cm2a0PNo70dQ4N9fcN9Pf1Dg91D +Az0jo1fHbtyauvdg/snsMn4ZT56BiyfPgqGcBiV+Kjl+CAEaj4Jmn5IT8emQ1bOwqQh4MAke +QDU1NUNDQ5OTk8nJyV5eXvS2r7e3V+2i036uC00te1+dx6O/v9/YwnvvoQvXxr9aWXn/z3s8 +mpradPQ9pJUcrl0/+1I8HiWlNTaOoadEzTl4zQVl/GXOJ3b37+nsZRWRddUxDoiOy2tp7UDA +400ED5qZBjTgsdr8DXp7yrBCGhMGGWh4PgPUClSQHnVojPUa4EG/0IM6M9QWtfOE+Tke4Fdq +/FgXPGjmZDIJHjSTLl4peNCgEXRFq6W3GTwgs0ogvyBQInQtEwnAyLY3dtdeSpv2GwIUskLC +17U1jIxcuTH+RJg745t3XH7/0HPLO4EpYaO3x4dL4gWv5Xzb4L2hK+FfDbH7r3R0pOBSXVKP +m2SIeFaIumcfd0+4NDb59JQezyzmlTXbuITZeyZ4RBVb+maq2Uadd0qy8s+zcItHecbklzXe +n366cS0Rv0LAk6OkL+KJdx7PdPd1lmVG5PnolTqf7fGQvBUscz9U+m6w5LCrQKMlV7kRe7X5 +0R4Xkeu+Zyf9RPtcRYqxikUBZl1lqfcnrlFisIO0BIBidolwb3np9vLi7cXFezOLM48Wlx7O +L0/PzyziH5EniJAjgiyQFmZJMwTwP4WA8OQBKALoCTxxBVq0S3YKkaex4leIK+R1NHhyDLNn +c2QQ8FgHPNBodEhICLRnXG5uLkCOkpKSiYkJ6t1pQyMzhCXN2TgvAlN7Ws5X18y6sWW7pq5n +bGLuSwSP4LC00xLmu9nPc/JZnpb1D4tXzC06LKmIcXKJ7ujofl7w6O7ujUvMO6fjeviE0VEh +R3HlIHc/9bTMwMamthcDj4HhYQd0hIVt0EEeA15RFwnVKEWdVOVLmUq6aTqWYdoWYfJayXLn +4yRUAhXOeaPd4nGldQh4vJXgAU8toEmwm4JhhfAwCrQmBbaGkG8BGuWh9n7QzAP58+ABzztl +xuNBolpaQm1/4fmo64IHzUDJawgeNE3A4MHww6VZd/NWgQeN/4Mi8Lxfi6sZ9mh5EDRGmiMt +Ls83NdSNXLkyMjZ1ijvxWxbMro+CN7HEWehVPnq80FRs2xO/cTDs+xrfz3rS/11/+dLE2NXU +qhDHQkmjGC5Ulrh7iSQ2Sb2xpxZYfUoTxDv37hdWN2NC0619ku2Dc638c3TRCbrOcRaeqTbe +yejAxMTs0r6ha7Nz5Ogc5IAjoMwKkWzeV/Bzs4/u3xoZ78ANFIW0xNu0BJzv81Ec8ZW77it5 +zVO4H3Oq2eFUlYNwA0qw15m331Wo3f1snbdGXYrvYE/rvak7i0uLRMjNs7JMwC9SArEvEojz +gDGIhBU8nhyGjNwifn6JtPh4+tHdkZt3RsfuXr16Z+zq3aujU6OjU1evLT56Ai0IWiARFiiD +OeQw7URotIr4OoDH5OQksAsjIyOvIXgEBgaGh4fX1dX19/ffvXs3Ly8PHNy4cWNcXFxza6+Z +TbCEIobntD2/hJuYSjh4tFfQSVXUSVPQvgyMrOz5OEnVYCnVgIuGoWj3xMjY3O6evucCj7b2 +rksmfqZWgZJKWB5hB34Jd3GVCFnQijbUSqqCdor8xUQpjUhZjUBzu8jA0Mx1waOgqNrKPlxV +y++MnIegtI+kerTcxWRQG0jgnKU1o+U0Q3XNYuwxCVGxecW42h66c14NPLq7+9V1grRNovVt +C1QuZaoZ5qoaZCvrpQP8AB2ioHVZHvwkp1RlvQzwQsskEQGPtwk8JqYeQ9Mywc/SppE/2ujF +pWU8fYWajn/Y9uiYRghUp6J1Cnhh5l0ADl6//RCqFvwKVQ6O0BQBydgzf2l5BToNAe1I+OBz +gQc4T1W7VPCaXTGgZ3itbSupz+HK9XtyFkk09UNmGpwteJcZ8IB7D6SwjGa45i+PO1L3vC42 +G8rDKuVd23GNYQ/DV3RQwR8+CLoaPgjagg66x1QzDx7ROa3wEiSa3rj/aO4N+nsGd4M/s/EH +tAZk+vF0dUXNnYSRqaBR0jwZPBrqa4eHhq6O3RM8GvsDi//uDbE/siSLHo+euPVg+npnWSD3 +3fxNrYGftcR90Ry7ubvYa55I9M+y868XvRB11CLrVEijgn20ZG5tDEAaineF/Mc8t7CMq223 +dY80dYlxjSlzisBdQMWq2UZY+OegQgtMsdFeoZmt3aMreIoxX6QkUBoPuWeeumqezC8Mj16t +K8nBhTsXu6g1YyXHvETvB5y57ycwgj7abMFeYcJRbnuq2FkuWIc/0/VCSQx2sLF05v4UNJZD +INe6PEeaWSI9JkPEMnkfvUXy6eGfDI9V+MdUBSe2xya2hIS2+Qe2+/o3uXvirB2aAsNW7pG/ +IwtEaDYuNMTyzHP0GoDH6yZq8EhLS2tpaYHil9bX1wcEBEDggcViQyLyRRW8lfTSNIwL1Y0K +VA2yVPUzgZGV10oBCbKwFEJIV9RNU9bLVNJJjU8ufS7waGrpAtwipeqjqJ0MTLm6caGaYY6q +QSaw5hS2gVohJ4ANKpfACWSvCx5Jl3GqujFqBtmaJsVqRnngtFUuZTytDapQJ1VJN11JNw3U +JqUeHh1fyPxQS1hMSUp6JXhRWdMZEFGlY5GtbpivYZKvbpSjop8JOAR0lJJepqFtTmRiXWNz +LwIebxN40Iy2QGsuoKAQNDMhabKBDJAppF5hynAyKj05UA95AJNKvaaD4XKbtcEDOgKog2ZR +DMM+gReV0C87hWdE0KygWQM8aC4TKsVwIIM+GxwMhN55AmUAiAI7lGhKMQ8e1KtaoCgo4MJp +onz8EwSBx/jNG/VV9dNpNx6EXKWAx9wz8Lh7+mjMTyzhrBvifmRJPbIzuLfzOmlpqSpBezj7 +s6HEDyv9/nst43+V4WL3Jm5UNpa4FJ52qRfUDOPC4sT8qgXtIkRru3DkSREEInH56dTNwdGb +3pEZ+k7hdkE5rok1ht5Z8pYROthU5/AyG49UK0xUc+fQs5EXAtn9AYqSiEuU8Y6lp2NF5FCo +8zOPrvV3NOfHV4RY4dDybegz1z2EbviJD3ifbXSTDlLnvHDkm2gDoVpX+UKUXF6QU1tdzd2p ++4AcyKRBDrS+vEgiezyIENgsPGp384kWUx7LKyb29OLLKoh5hcSsnIW01Lsh4bWmVleyiiih +ygB7kJ0mlIghBGibOgQ86BUXF+fi4oJGo4uLi0tKSurq6mgme0DgASysgXV8Vn6jW0CZhiGZ +LjRNizRNARtkQWAAEuANNcN8Jb0MNYMMBw9cR1ff8w61GFnG65hGpWbVJ2U06NvmKumlgwrP +mRVTTHkGaBRqReVStpp+JsqjbF3wyCusi04sr6rtDI6uvmSVo2KQc860WNMEEAiZmkAiV2WY +r2aQ6eRVml3Q2tMzwDx4hEQVJ1z+f7vf2TWQmtV4yQqcXpamSZGWZZ5HUEUhrq2/f/AtmOPR +2dnZ2NiIgAfNaALDOB40dhZeFQsnCDyoj68WqYPepc8wrgUNYDwXeHjF164b+ZPa+jNcL1Pa +NLJ2HA968ABsQHMhoEL65bTQmtm1e5gmA+QbgVegwD3McD3sGnFloYhnb/QEj5cCHkB9A30p +MSkjHs0Pgq8CW7qMX2ysr7kyNHRt/J4od8KPLNG7Pon8mSV159dBZQV9oFRHRVht3GcTxR9U ++34ykfqfhpA9jWWJd+/ds49V8qoXRBWKnA/f710r5FF0xjlabWC8jdwQeQ+3Zcg/8PDJXGph +nalLlKlHkmtCtV14mYZ9rLpVlF1AATa0EOUT19jVP7dEXtxKIC6tEObxxCUKH1HmfeLnifiH +FBIhCxj+R9MPR/o7qosycqI8sz10a11lR/2k0i7u0Tj2M0aDf9RXdjZKrtVDLN1JKjPYvK06 +5/G9u5C3YhYgDWVAB2isvDCMl9/70LFqL/cHpcVTCUkzoRFP/AImvDzuenr1GJmXWzg8GR4n +kWeNrCw8pQ0iAh6riYOD49atW+7u7g0NDcB2Nzc3A9hIpQiKKgaBR1JqhalDMmzdUjIajOzz +VfTSwXP9ObMikDRNi1X1M/WscyMTa1czteuCh7FNkrZJVE3d0ykcldUdGJ9SNYM0gBwAP86b +lQDaAa1gfHC9vYPMzPHIyq1Oy6p7tvBkICu/2dGj6JxJloZxAahQzShP3yYnPK62tqH7BSaX +hsfikikeD2r5BeemZdenZTc1Nncju9O+iQLmCQoWQT0fcmZuCTpIb3RANuhZGI47Sh/cEgr7 +Cce4oB4mgBI1YABTCx9fLZQoyH9aLwqqjb45cIS+2tXeAo/2cHOrOT2YuUZgpumnQKx9IdD+ +blARaKqqd0ItTc/DlcNBUMEL+uuCgntA78IDQ9QRXMFHwPBDZPhxU39wcM1QPW9W9LCXQh3g +RXdfT0td05Bbfb9Fzc3e249mHnS0NY+Ojg4MjgtzxGxiidvxr6BN7yVu+iA8NaKb3G83Wwuj +WW/j3u8I/fdg8Bcjmd/lx8vOzz3KqomzTjgZ3CRhknJUN4Y7pE3BKZPfI8F44j5lhI6wQiBv +d09ucYlAbOi6gg1OMcKEO4cVesRVG7qmqltHGLunOgSkm7sGxuZnXr8HwecSkRwRfZFEntqJ +XyAQnhApO7WQsWSFQBnEIVL2iZt6Mjc81N9Ukl4ag0m2k0uyEC1Dy13zlFgKF8PHn34SxTvg +eaQMJVzu7zRa3TLz+DGBEnsd6Mm1a3EqamgOjvZA/4746L7YqDEfv5u2TrcsbUaszEdNzcZ0 +jUtlVLuCI0mLSwQC/hmtkChzSxHwYDzUEhUVNTQ0BDCjpaVlaWmpuLjY29u7q6sLUEdHR8eu +XbsAeCSklOtbJ9CY+5yCeoULEar6qeoG6WgvXEVN95+cXHrJIv6cQTiu/A8TPnv7B9V1Is8Z +pWoaZWB8Sytru5hf1ZKRXZWUVkNzMC65wtA61calKL+kra9v8MUmlwK1d/R0dvXSrNgNCCti +xsWBgAciRIjeiHEWsp+tsx3cYOdz7/abVNVm1lfUFudkpZfiSjPSi06whv3GkrDtM89NH8b8 +9E6yj00HfnllGf8Ql2bYn/HNePI39a6fXC/6sDR2050bQ4/n7odn26LTBIIalS9EHjfN4Q5s +k7SOlQzN8pyZf0TxM5DHNijb1ZHx48ad+zFpBWbOQbZeSd7xVfbBxWq2UQYeyaiwLEMXf0xo +VH1H78IiJbw7cYmAnycQlmYJxMeU2R+UMZI5EiARytgHZSrJ03Cgj+fmezsaq1IDSgLMSp0U +mlDCA1iee37cs2GnHoTLdLgqljhpVyf6373aS0aHpcUyjJfttgMZ5pZTw1c6i0sqXVxGnbBj +2sbXzuv1XLzQIiPXeko8i+1QIr/QFOQWpoAHZW4HMsdjVfAwMjKqpghgxsjICHjh5+dXUVGR +np4OLOmBAwcAeBQVN/iF5g8O0voTLBySIIPLjLlcFzxCowqDwguaW/9gzds7e40sE5mwxQzA +o6qmFVfeQnMw8XJ5XuHzbVtPYi6AGOgH/9DCjs4+BDwQIUL0drAH+NnU0rSwuDCbNXHff/jR +xOPm9lpvT7f42LiK8mZJrtRfWKK3fY7ZvCH8e5ZMC42m+dn7JNJ8R1VNXTDno6J/1fu915f6 +WUf6f/vaCygsMegWY+hZrObaIK4QudWuVCy4+YJFlFBOTcISZYM68qayK4uExUXiCpl5FpZW +qhs7HNzCzLAx2JgKp7haNaeYS57JmIhyO+9MK3RESgbu1gQ0pZm8KcsKIBDykA2BSCLgyR4P +st8CT6BgycrcCmEZ2ogGgMEsMBnXrgw0FDZlhZaGoIpdLpWhVBoxUn3eon1e/DhrgRSMzmhP +5XBhAXo/b5iI0lhZfU37QHZOcQnK+aqVw4iCVofA2TzuY0nbWVO+3pzw7++8vvq2yMJsaQYi +KMjZ8bqAx2u7nPbq1auzs7Pgep2dnVtaWtrb28PDw/v7+3ft2hUcHMwwcmlaVrWZfTLz5vLF +Aoi1tHYbWCZ2d/W+AHgwVHxKRU5+w6sBj6GAsAL6yS0IeCBChOgNFYFAAOABLPjD1Ot3/YaA +2V5amSspzu/s6JiYfCzHn/UjS+L2z923fBzyA0vuefGyR/dvk0hLk+MPccGyDwrf74nbUBP0 +35sFn9XhrCEb3NDahgrVDWgSti49qBp2zLtaO7BGxD5KvKaznMI6BNLKEhFQCHlbtiVoxujw +2M3g2Ex9p0DbkEzbqBJlu+iLtknOAZWYIJypUxTWP6m+Y2AJDwXtmietPCERlikrbqEwGkTy ++hTC0gp5VOZpwlNt97ayvPRw6uG1wdGemprG9PCqSNPqQOUKV7Vk24vpzqah4uJoTp4r2UW3 +r08FZ9VHZlfWxsR2mDvWnzqb+NMmn+82hnyxOe0/P5Z++UPyf76M2Ml2NS2LvP6Wct6E548g +Bu7ePDw8k5OT/xDwSE1NxePxT548yczM9PHx6erq6u7uHh0dFRERAbQwPj7OEDzMHVL+GvDo +Ws+aMw8eCSkV2XmvxOMxNDRUhGvqQ4ZaECFC9Hroz8TxgNwd4Kbd2UWe2XI/dWzSq5/0hAwe +bW2NV0dHb03clxa4/D1L7q5Pg1g/Cf6JpfAsd+rt6zfJnoqFxepMq+G4z+8UfIfz+vRW9ke1 +GQKzi2SKWF4gpucmOSWcCO0UMLp8WitUOLpd2rP4GCpedWC8m+K6IK9zIayAf3N44ixkux8+ +epxbVm7jFWQTnO0UXaeHSlI3CzP1zHWKqLLwTjfHhqdkl9y9e59SfIm4soJfXsGv4Cmh36FA +XkQibShRBliwvLQ4ff/OjetXbg333a6vildXN9u2vdDRDj8zPXTvkc/l6rCMiuGurmb3kGIh +qYAvPwn49ofEb9mKvv2l6tvvKr798fKXvxTLnH8ydoNIGdd5GqXsNdDrCR7Ozs4DAwM3btyY +nZ3t7OwEHAKOAGu4srLi5+cHDcFc+dP6MyHTX2yo5WWJ9Dx7tbyAkFUtiBAhej3BAzx15ubn +riyvPM68dc//CmmGtLg809BYfWVocOLOA7nTqd+x5O78VwgAj80sxXw7I/u7RqCyo11ZdUG/ +3C/7b0Pwpz0Rnzenbr95cxSq+cGj+4GpJi7ZIkFNarrRXJap7FFd0qh0Eb8Uuzv371DcHotE +4hPyEMkKgfRswgQgiY7hEWvvOFRIkU9clbVPppp1xDmn/2PvPACbqPcHHudDfK73ngtRcYAs +feoT11+f8sSBOFEEZO9N2bultIVSuujee680TZNmp2lGm902aZs23XvvkX33/91dG0NboIgo +4n35Ga+Xu9+Npvf95DsTHMOYLsHkE+eDvANjlYVlZtRHg1QZs2CwAf06/d+uKj383ieH/vN+ +BYUMQyPNw72CInWBvHB4cLiaKmKs353871din5iZ+fQCysyZ2S89z37zHdLr/41ftrpZroLR +cFYcPK4NHm5uboAKmEwm0FxarVYgELS2toI1AwMDABWEQuFvol5x8MDreOCCCy5/LvBQqVTE +rEwBO6/KS9LlXwm+yRtMOgAemrLSjq7+jd+nzyBkzHsgaMEDQS8RmItmBAk5Kmz3vo56buT3 +dZR7KpIfzL30WGnav2R5UUhlDPRdTZ3aNWq/H3uNj2jZ9sh55+hfhso2nIn5Mp7qNzA8iBYT +HbKYzEiRDhNWAHTUcSFRaY86hZx2j/WOYzuH5Wx3jl1/JuyED+liGN3BM+GUS2BqNrujD8wA +j6l9zO9huq7bAyvTil014mBi5LltO5rq5FMlkvb2NBWX5VWo6J11sv6erv7Kdu6Zi5QvPk15 +/FnKrPk5b80nfvph4ufLUr5fowiOM/QMYHVFkPxeC3Q7fAxuW4sHOKX09PT8/HyxWNzZ2alW +q729vZFSGNnZRUVFgENw8MDBA3+M44LLXwc8MPbg8/n1DfXlypLCs0zVUW57RYfOOCxXFFSU +a9o6ejcsT3mGkDJ3WvD8aYGzCcxXHw6hpCgwFa/XmYRUb3n8g13M6Vz3x2pTH2ImrOzpakdR +AAnI4MvynCPXBYt/cmD/b1P4W5d434RKl56NXsoQkUxmNEIC6XiCxIdCyKLJZDEivVPMFlmx +9kJA3EFnf5cw0sW43COXSetOhe88l+AcynYKIh06H3QpNFlZUWsaA4qx6mLQdS8WGov90JRr +N6/ddXKXPTGSolaUV9eo4yJOpfmuYUbv41Bj+5rayzKpmWtXMl5/j/PxstQfPovY8nPc/oN5 +l4MGapEk32E0swayWHDwuAZ4YLXCAHgIBIL4+Pje3t6IiAiwpry8/MKFC8nJyYAZcPDAwQN/ +jOOCy18KPMBzlclkAo1gMVu6k2vUR7g8Ip8npJOz0jlsDovDX/5p8POEpLl/C5k/LWgOgT77 +3ojIy/loPiyi5itKFezAN7o598giHq6Pf5QbOatUyYAR64MBoQGdIZ0aey5hZUDxisOkD3dG +vxZU9Ikvf4lT1BZ5mRpFBhMEDWPAgDbNNUJjfpfGju4YEv3ohaDTl5MvRueeC8/d6hC/6XTM +Cf9sl2jGUc+EE+7hREZe92iDOaQ0KtpN5Re0uLYUlZQt+eyHhQv/t3nrGX5BSW1tcVLw7hSX +t1OdFyUE7q4uV1TKxNF7NlO//ilrk12Ky+ms6KCc+Hh2GrGrFSErHXKN0KixBgeP64GHSCTy +8fGprq4Gn7fS0lK5XA40TlFREe5qwcEDBw9ccPmrgUdzczODwRgaGgLLvWl1HT4VvY39EjnP +x/tSXGysXKnatjplJiFq7t9CFzwQNO+unBcJCU6H6AY0iBQo+N7uIUHM4Uri3XU5D2pCHytL +fTA3/cjQYB9a1hypv9HZ0eObcP4CbZlv4bJdcf+2S/pPuGqlK+U7t9hTtW3NKG8MjlkqsChR +k9VpojOZ8+Ql53xiDl+Icg1nukULjniQ1p0K230x2TmS6RiUceR8gF9EcmlFrdmCRX0gMkX2 +GBgeSclibN53dtXWk/RcWWNdUWbIVqLzgizn2Ule3/PZCYI8VqSrfc5JJ0kijc1hM/PY2ZTs +bAq1ua0NHq1YakFqiUC4xeP64FFQUAAWXF1dOzuRGoYUCmXmzJmAeBsaGnDwwMEDf4zjgstf +CjxUKlV+fr7JhBQU7U6tafPRwHp4RD+Yy2UoFYoRveXYHtoMQujc+8MBeMy/O+cFAmnjt/E9 +3V2Y8jWY4FIOWRI1o1swTR78WDftQWbIO01VQjTpA6lTCgiivLrcKW6tB2+Jd8GPW4I/PE1e +GqZa5ZCyLDz7Uu9gO+pxgcaKcY2yB4T0ox8tDlrb0hmVzjziHHLGM9kzlnsujL3JIW7T6QiH +wOxLkbQzntH2bmHUXHnv4Gj1sKkbPXQWqKS2NT6bx+AWlClYSZ4ro47OjDn6j5RLn4lZiXyh +kELOUHMEEr6aJVEKi4u4+aJMOq2+tQWGb7smcX8K8AgMDOzt7a2srASccP78eQ8Pj/b2dhw8 +cPDAH+O44PLXAQ+goAUCgVKphNE4ydE6HsOwwTwklghK1SUGM2x/iPUsIfSVe8MWTg+efzf1 +BQLt0ze81cVFaMdZJJCjvbJWGPh5G40giPz7UM4j0sjHZQwvk8msRwCiH7YYLBYoV045HvWV +r3itE+PnDcFvXuB/EVq4wj56WVZuFGAeVI1b80MgCK2oajYbjAYDVlh12GDOE6tcvCKPXwi/ +EMa+EC09cDFzw/FQO9dEtyimS3D2ofPRQTFZNdU1SC9bNHD0euyBlRBBNq5q7RCI8ot5GfHn +fww+9FzY4cfTPb4uE7FkMi2FJyhUqYoKq4rUFYUlZQwej8JhdvSgKb1IMg4OHlMCj8zMTKw7 +rYuLS2FhIThJjUZTXFyMMQMOHjh44I9xXHD564CHTqfLyMggEokDA0jr5P7Mxg4fDZJOaxgW +iXglKrUFgl1Ocp4jhMy+N/LV6aHz7ia/SGC+Pcs1i5iFeDbQMAf9oF6Z4qJJuFeS8mBLymNN +mY/kRK1u72pHOs1beiBzC1DSI3p9AivyePw3wYU/HyW/uyVqga9kuT9vpWP4Wqmah54LIAyg +yyELlh5rMZiNIyaD3mjQW8yjQRQ19S3hCaTDTuEnvLI8Y0Rn/ZlbT8dss4+xD6Q7R+aeuBR9 +0dMvTyAaHtFfYfeYQCDQ6IsOgkcAeVQ3txTKZbVyRqrHz6En5kTZv5TuvapWJq4o7WLkK4uq +yxprW2tKK/M4PAaLXdtYj7SoBSdrxM73hv0sf0HwCAsLo1AoERERgYGBly5dAuwBFgYHB80A +Lg2G4ZsW8DEG+Dp8awScpF6vv0WTw2iQ1a0To9F4gxf7IQYeIyNl494Cv7W0tDQcPHDBBZdf +AR5YfxZMKbe2toJvo0Ap8AX87q6uwezmbr9KeAgGD1qxgF+iLgXbeDgzn7079MW7U+f/LXLe +PakvEaiLnvUIC4w1W/SIaQLto6JRslnh86qID8n8H9HRnqCHzc5XphkhoKIBmQxYIMQJ0t7T +E5By7gLpv0FFS3Ynvron/v1g5WY35ncXY7bXNVQh5UXhQQOMJLtAiNViAGnAYsGCTiGrUUGn +N3BFckevkOPnwy6FcC9FSvefJ687Eb3HM905nnfCL+PwhdCYNFoLEv8JLtNotpiQxBMIDT4d +YxHMnQMhWSkIotQ0tIkE+aUF1GS/jWGO86Oc56X5rW8tlbbWd4lkRfXdNeDrOZcuEotkvX19 +o0iDJbP8quiOvyB4YAL4FhBCaWlpfX09WOjt7aXT6W1tbY03LWCSoaGhxlsjgDo6Ojpu0eTg +RjXeSunv77/Bi30PA4/W1oJxb4HPbWxsLA4euOCCy68AD0AdWAQmWC4pKcnLywNaoFhVxKXm +qN15HZ4a2AibTHqJQFBchNTrCL7Mfe6+8BfvIs+7P3r+/cmzCZR3n/P3uRTRO4DEWKIBpHB7 +Zz0t5uemzEeZl/7WQ3yykPivjMxdw8NoSVIEI8xojTC4uqH8QsyGS/TPfOXfbI7497HMpSGq +DeczVoQmufYMNlhggwHJrUVrqkMjmB9kUqmqqw2Lzzx2LtLei+oRKz8ZwNxwNnydU/SJiDzn +KO6hC6FuvuH1Dc2oP8SMGEwsEFZwA7KJIzEjiSkIEXX2DItE8hxiQqzv/ojzn4Wcez8tZOdA +o2qkZ7BUo9U2qDIyM5i0/MbGdr1eZ711v1puEXiAL6TgGU6j0W5b8HBxcUlJSQEfOYC7gDrI +ZLKrqyue1YK7WnDwwAWXv4jFAyOQ/Px8qVQK1gD1XFteUXSJo7Jj1Srrewd6iqQSTVn50PCg +27m0F++PePku6vxpUQvuT5xDoL0zM/iSU2hVTQliNjAhyR0mk0HODKxJf0Lgf1955KMtnH9m +hX3SrNXAWPAGwhJGCCl9YRYo80+F77wsXHkh77PN4W84M38IEW87F706jRtqsGD9VSxI8IgF +uqL0+Ziuh8bMHwPDekae0tEz/tD56AsRdNdo5q7zsetPhx+5TLwQRT/tFXc5LKm9uw9zqiDF +UaHR4BH4lyXE1QLIpKtvpFhdyaQyqMlRpLAL0e674gMPlyv4LXUdMrmKTE/PyszMz1VIChTq +ElV3d/dNssdfqjut02Ti7Ozs5uaWkZGRnp6OgwcOHjh44ILLn07s7OxutOMYpjcHBgY4HI5W +q4VhrOkZ3JfdUH44j58lYfLpmUmJZDJFJBPZHwuf/0j0SwTagumR8/8WO4fA+s8T4e7nYpUK +EdogBR6B9WDnpooideJLpUn3sb3v62U/qgh7RUYJQ9NakJRT2GyEoF6AH0YTnM7NOR61LkD2 +46nsRdsjF/nkr/cVrTkVvk5UjAV7mFDwuOrJm80Wg3G0clhFTWNIUuYhlwB770SfeO4ZP9Km +M6E7XOIdI9gnvJI8Q5JVmprR7vUWK8iMGTxQV4vJbGxoa8+XFbFYAi6dJ6RyeaT07NQgUmoC +KYOeEE9MzUjkMhm51DwWjSMUCZuamrAMIBw8fjV4YAI0Tn19Pd6rBQcPHDxwweWOF6vFo6Wl +hclkglcMPCDY0kuq7/aq6G8dVKglwZcvR0TE1DfXJ8XkvfpExPME6oLpYQsfiH6ZwHnt0Rhv +50xhLtukG7TA5n5ID1S4cXBIkbSklT2N4nt3a9qjPUlPcSLWd/V3IoiAZMdaYIsBRjAE7hsa +CckKdkz7OlDx+eGUd/cmfeBbvMKVuto1yq62QYVCAnSNXBGASCaDGQADhLp5+oeGWUKps2f0 +6QuRnhFUl3D6NqeEn8/EnQ5mHr8YY38xjMbJHxhGXCrW6uYQhJYKAZeMBLtYeof7y6orCxRK +gUAq5Mryc0XCXDqTRs8isUgkJptFL8jLk/LEComiQqvFonBvRnDwwGTmzJnZ2dng44eDxxRF +q1W1tHiB1zsJPMCc3t7e+GMZF1zuePDAvrBrNBo2mz00NISiCFLBvIdU1+lRhhTgMOuEHE5B +vhRsxqYpX3sq9DkCbeGDIfOmhbxI4M5/MNHXhSnk5HU1N5jhwX7YqEdnlmTYtedN58feo/J5 +yEh5LC/8jeIiDpL4YUFriZnRlFmsKmlng0fyXrecrwMkq7bFvHaI+nZo0drzKd+Hp5/p6W8z +WyCjxQRdDT1GvSUAPIYs0BA2YVVdW3R8zgmnAEfflPPR3IM+OVucEi+EM84HEo87BwTHZtY0 +dWC7IvVBzCYI6W+LmGvAPwOkHzD0tQ+0NbY3VtbUlJZpSktKSksq1CXVanUl0ly1qrq1rqm7 +s2tEp4Nt/D44eNwkeLi6ujY1NU2qAaurRRB0H6YEpzBeBxpsyhvf6MgF38tv2eTwLZsZG2d/ +3Y6/G3jgggsufx0B3/UlqIzRCGJjAODRcakU7keCSwslYlVRCXgrly1f9HzYswTmgr8Hzp8e +OIcgevm+ZE8HTgFPWq4uhuCBEchsMqHN5nhx5VmPVFD/JnT622DWQ0XJT9HS7Q2mbqSLigke +DdtA2ANQiK6oin8uatdl9lo3/tJ14S86534UJl3hErcikxNjsphNFv212r4iRzMh+bDQMATr +MRAYGBzJFSnO+0Yfd4s6H8E47JW+xT78tG+mawj5xMUIZ584vqzUYMbaw4EzNiJBp+gZmZFU +Gp0ZHjZA/SPm3kFd/8DgMJitf0A30D8yPKQz6Y1IMzubOBMcPH4r8LjGt3sYvguC7gXfwa87 +dLq1JlP2VLacOMAhwIGusYHZrNDrd059QqPxGZPp8SluDCPptFOd2WB4ESCBXj/vRk4m9Ibu +htn8MA4euOCCy62weIBXg8FAIpHi4+NbWlrMZqw9yi/gYTTqpEJBoaIYbCkVl/x3XvRMAnvh +3/0XTvefSxDPuYe8d01cbFg8l8O2wAakzAai0c0NlUpR1As9vEcK3B+oinywmf54dvji5kYZ +lkkDYYdGAMcAHrdA+TML6PYR64Ly19pTPtoW8cJl8dc+eevORG1uaK8yW4zXugQYa2VrtqDZ +skiHFhRSwP/rmttiUyknz/s7BxEPehHXngzbcz72YkTOWd/Uo+eDk8jczr4hbBKzxZoQC6He +ICMWbop5cGxu1xXL0E0XSMfBYyrgAQSC7gF68Fa7WsAhwIF+Q1dLV9fe/v7lt8LV0trqCpCg +sTHuTnK14IILLn8d8GhoaGAwGFgBST6frynX6PX6vqyGDvcyqB82GEekAn6hoghsWaqqXroo +aQaBteBBXzBeIUhmEbI3fRullMpZXFZ7fx+ijw0jJrNhcKg/L2p1Y8oD9RkPcdwfbqH8XZXy +Ty7pwpBxxALrLRDaggVsbIIgA5JIY7LoxGU8jxQ7T+aPTtSlO2PfO8f93lOwMobhpDfoYSsW +YM1rRxU+EqkxVmcM3cCMpcgCAEGa24J5jUZjY2NzbAb9lG/aySDaER/KTueE/a7xZy6nOXjH +X/CNTaGwtPVNRjMCSxBW4MMyNrAaJ2jSD2qZMWGsZEYKu1qsSTFXjisWryve3t6zZs3Cajj8 +hlJQUACmvRUlnnDwuLPBQ5BfHJ8qSiWJpXI1Dh644ILLVORXVC4FylWhUABVNfrd32xWFik5 +1JwSj7wOjxJ4GAYUIRMKiguRUM/62pafPk1/ipA9/8GghdN95iHgwVzzaWRbc6swn68uKUU1 +r8WCVuAokVEFIa/00p4sCJyhjLxrKOcuZuCHheX5yDa2URtA5ZuMEBprWtOidYk56Ere6M5d +vzVy0TnWR+6U5bSCFAum/k1oFTIzmmA7CgPm67IVdlFypdI3KOLoxdizQSyHAOaOs7E7HKLs +A7LOBKcf8AiLSqe2dXShYGMyIYk5BqzDPXRFC5axemNIPCpKKRPGKBRB1orvf8zH4PYvIIaD +x+0GHnJlySV/9rp9xPX7MzfYZW0+QEwm2RmM9/+e4FFYWGh9EOGCCy53MHgMDQ3xeLySkhKr +AQRo+XptVaErp+QAp1pe29PXVSyVqIpKB4cG8vJE338c9wwhe860wAXT/RYQ8mcR6N+8G1Bf +3VhaquIL+GOWCMRa0NfbxI7+rjH1yeqMp+ju9w5lPSqLeS6LdgF1xVxhIQA8YUH8KYiGl5Tl +O4Tv9mT/6MT8cHvoW76cTc6xq1VVCK5YgM43YvEhWONa81RUu9Un0tnVnUTlnvSKPuOd6BJC +OeKWuvVU+CGP1LMhOcddo7yCE4o11SYkyQcyg38wNLrveIy5Zk+WK40fOHjcJHhoNBoevyA8 +imQ03mcw3ELwEAqloZHEwaFHLJZ7fxPwUCqLGSxBVfXmvr7vfxPwKC5WJ6XknLAPWr/t0p4j +4ckZWwASCEVeKlXJzYMHiSrde4q06UD22j1pa3angLFub8bGA2RnL6eq2pfxdFpccMHltwUP +8DhisVjgcQ2PFjId9S6M0NurjovYaXwqm5yVkkwkZvPyOaSsrJVfxM0gpM++P3jh9MD5d+W9 +SGAsWehXUdLQ0trEYDAMBgNsk6Ur5fjJw2Z1cR5he/+9PurJJspDqbFfNbU02yplaNS9geSv +wLABLDEljDNR3/oKlp5M/cKZvMo1+yuflAMtXbWo0QMzchiRMWWPBhq4gogBMivKK3yiEk5f +Cj3vT3L0oew8HbPPMdUpgH7KPeGUW2ROnmwQbe+COl3MKOFgHWOuwIprmFdsieMP4o47BzxI +FM7G7S5v/t+uzq6H2jv+yWLzbwV4+AYkLf3uyJsf7tNUPDM49ACRxLpJ8JBIFAHBKd+vdkjL +XNLe/tVNgodYrDjhEPi/ZUfe/eTkstX+q3Ykrtubfsn/JACPg6ePrdvu5eGTlMvL/3XgUVhU +6h3CXbsnfcN+EoYcNiMVsMe2w7ExydSyMg0OHrjggstvBR5geyyRFmMAAB4mMxJ/0ZPV0Oul +HWrXKYol/h6XgkPCq+uqensHjuygPUmIeeX+iFenhyy4m/0igf7eLB9lQfVA/2i7DdimIWxT +g4Ye8kkTdXpp9FNiz4d6Wffyo+cVCqlXWiQgFAzQuAo0jlRvMmVwYuwjvwkQ/Hgo4b/BijUO +scuSmf7DZiPaNA5G630Zfulhex2LB2QyIZYMk9lgsSCtuHqHBnO4IhevmDNuiU4+1EPnUref +iT3mmXXmcubR8xHRaYymtu5RcIBMY63qfrF3mK2xJFcfWFEzyx/0Mfizg0dhYbHzhfD/+2Tv +q+/s+PBLp2/Xh/qF773kt+vLFS6rN7n6BaWq1eqbBw8mW7h936XX39/++vt7l3zv/uPmaP+I +/dFJK79ccX7F+gupGfQbBY/y8vJ0ImPvIa//W3Lw/z4/+/WaoJPnHc+5bT52JiSNyCwpKf0V +4HHCIejz704s/tr1h02Ra/ekrd9PHDNKpK7Zk/rzrqRVO+JWbA77fo3b0TOhqRnMMo1miuBR +rCrNpkkP2JNtDR0Tx7p9GRvtss5czMkTFOLggQsuuNw8eAB1rFKppFIptoxoZ0RHIy6M3qyG +TnckxsNsNgg5bKlEjpgOTJDjEfoMQtic+2JeezBy/j05LxJobzzpy2eW6w26vLy8srIy2KY8 +iN5somW6FMc915X5LN1jWiP5nvr4J7jJp4aNVzSN/aV7rAkN/4ChvoGhCKKnc8rnJ9L+72zO +5yGidY6R64UqoRHCXCcjkMWAQIF5Spc51hMOXJnBuk95VWN4EtXBPcrBI/6YR/p2x0S780kO +PhnHz4f6hiaVlVeP7ov0gEO8L1hpdTMa3mFGDC7gNgFOAsxkQS0jyEA2RJJ2kIBZHDxuFDyS +0mmZWax1W5xff2/Hmx8e/HS514qtsev3ZYABvpIDJbh6Z8JPWyO/Wun27arzJxxCBQLJjYKH +urRy/xHvwPD0L789+uq7O95dcnrZ6oBVOxOBQl+3Nx3Tvz/vTFi5LerrlRcPHAugMfKuCx55 +fLFQJPULSv5xjcPr7+/75DuEYcBs4LQBHoBzXrk16uvVHtv2+QaFEQvE8hsCj3XbvJZvCNty +OGfTQfLGA+Ak09bsSvl5V7LVKAHwA9wchEC2x/6wITCDxJ0KeOSLVceccsAZTmbomDD2IKaP +rQczeIIiHDxwwQWXXwEev2h5NMCDRqPx+Xxb44MF1bI95Pr2iyq4DzYa9UqxuLhQjW3j7cJ+ +7t6Al++JX/hA9Ny7iS8RaK//I4SSruof6M3ISOfxeDZ+B+QoRWWFHP9PBklPcSOmKaIeGEp9 +jBn2v4o6JYwWPEe1tI1HwoS4Q2DTCFhq7mj2STzpQl62PeJN77wVntQNF6IOV7dVoiygt5iM +QOtDN6rasdiQsb0G9YY8qcIjJPKIW8Rx78z9LnH7HMMcPOKOOHifcfQSiOQjeiN6njDSksUC +YSeLmHPQVnfoqwn6JdAUMcdACLghmb0wVkQeB48pg8f+I0EL39754ZdO362PAPpu04Gs9fvS +gZ611YDI667kn3cmLl/v/+3PF28UPOKSaO/878Rr7+5eglBNPJh/08EsAAk2qtx6lKQfNgYt +W3H+uuARHkNd9N9973/m8M3aMDDPpoMkFDmumA2s/xmdcMUG98BQ4tTBIyqOGRLFtr9IA6cK +8GPL4Wx0/nRszjGjBHHTQSo46MnzOaKCwqmAx+Ug2urdpJ93p1+fOn4xfRC3HspkcZU4eOCC +Cy43Ax7gEZ2QkBAZGSmVStvb20eVM9pTZRQ8kHRanUwoVKJ1PICE++W+ON33BULCwr/FLrg3 +bTaBuvChKI9zWfkiQXJyEoVCwcI8RmcC8+hNrPBj9QlPlVEfo3tMG8p4QhL9nIgfMGZjGQMP +LDwCNSJAJh0MI84ObW31xdSNpzKW7o5+NzB/k1PiqmjqhSF9O7KrCTKbLDfWjB5CqcM4FrUx +Vou9sa01ico+5RF1/FLkiYtRhx2DV2899f3Pe4/Ye6RmcTq6kO5yFow3ENBAKORKp4plfOiH +0WxBo0qua48BT2/wsL3R9jp3Knh4+GVt3hP48864DXakzYeomw5mbzxI2rA/Y80eVMn+QiCp +6/ZmrN+fufUw9UbBo6BAtn5X5M6DYev3JG6wI246QAFHAap8g13GWsRzkWzV5mv3pG20Q9wQ +1wWPLGqBq2fq7qPJu09kbz5EwU57ox0Rm9DmnNOB7t58kHLEPmnq4OEfRqGzxGCBnVvoHczd +djgD3JktRyibD5E3HsjcdJCM/Hgw3TOQw+Aopx7jUSApOeWStXJr1A9bEhCzydTYY/0+4kGH +nMg4Lg4euOCCyw2Bh600NzczGIyysjIej5eZmVlQUNDb24sp6auBR1K0aO5jfrMISa9NS351 +WjIAj9n3R57an1hTU11XV2MN88DAA1PSaj45P+SlZvqjTI8HqpOfrMl8mJW6rW9gBKWgK8AD +6HaDGa3mZdYj2ALDcTSvi5QN++IXH0//MES0yj78S444FQu2MJtGLJD+hi0eKDWg9guDyaI3 +YyEjZrOsRBMUm+boHrbvpPe7n659a/GqrYfdTrqGBEWmVtY0oKcKoAjpvguZTK0lajWVWkKn +q2k5qpwcNY2uptOLaDlFzNy+pk7E0oGevOV6XHSLCoj9ScEjncTffTg8NIrJylXau+Zs3A9U +f9a2Y/QtR7IRL8O+NJQH0jceyN5gl7VhX/o5D+aviPGwd0ndfSQ8NUPAFxY7e9E32aUDfbrt +KDgKZdOBzPX70gEwrEeySklbDhHd/NjXBY98cZGnHzGdJFAUlsYmC484ZiPGgaO0rUeyATWt +RVwhaRsPAE4g7z5O8gvnAaU/dfDwC6XkMMTWH6VydVQif+vBFHAHAHUcd6FFJwnFUtWNZrU0 +NbX29w8LCzQHTqV+uz5q9c6pgcd+4tKfLn/2nQMGHtr6zvnLPbGx4mi89dcNlsGahJxC64/W +dy9G5oK3cPDABZe/LHgAjV9SUiIUChHNq9eXl5ezWCwqlVpTU4MYQ6iN7W6IqwUBD5GoUKnC +9qJkKF5/OngWIXnh3+Ln3x83m0B76d4Yr3Mc8NbwyDCbzdZoNGN2FazDGzzQ3cqM+Lw+bbo6 +9lFe8CMdOQ8wwj4qRaNBLBBa0WMsXcQM6wxwH0APWAfOCemdUl6ncojaco66bk/c6xfo7/rT +l7uF76+qqUQOYRm0wEOwlVpsrA7jk0rG0GZsG6w8KVq5bDSJB1nb3duXm690uBj25coDX685 +duR8lFsY+bRbuMvlaGlROYwZPmC4raws19dPGRFTEpekiohRBEfKAkPFfkH5l/0ozu6syCTj +wPDoEa9nj8HBwxY8iGTR1v1hMck8TDkWFZUFRPB2HAMwkLHlMHXr0Zztx5kb7Ig7jpJ8Q3Nl +CvWvCy4945K+42B4amYB9mOppiIygb/nZNb6/RlbjuQAzgFjo12muz9risGlADzOe6aRKAVj +KcDlVIb8gg8TnOfWw9TtxxibDpDsL9KTifmFRaU3GlwaHJFDZ10RylIgVrpfzszKkZJpsnHJ +JlMHD21lXV1DT1//yPCwLjSGt2Jz1I/XNH2gMJYBqGPef7Z++JkdBh4KTdP9i04BwMjOKwM4 +AaAC+3WPQ5HF20LAwMEDF1z+4uCB5brqdDqBQFBYWGhdD56r4KGUQ6OWFhe3p1X2eJQD8Bgx +DueLBEVjFg8hV/v+S5HPEVIXTAuaf1/sHILohXtj3E6zYaTnmlEkEmE9X8aiOS1YGQ05w08a +/VQT9WGG+zRt5gMFCbNk7FAINulgNI/FjCSpQGazER6wwMNoRVMkiBOC9CazKZUWczZ229nM +pfsi5vtyVl9M/zmU6Dg40oXktkAj0KghQ49koIw6T5AgT5PV04EGhZqQEiAWm5CQsZQYjFkg +zAeD/FTf1JFBETi6RZ1yCb0Yku2aINrvm37IPYLDl5qB9A4w7c8HrljZQCZbxMV6al4fLa8t +m9WWRu6PT28NjCaeOK0WcscOgls8bgA8UjMFm/YEh8XljtOYB08lrN8bv9Eu49BZchpZcpPp +tMcdU7bsC0lME45bv/tw5LaDyVsPER3dc9i8wqmn04oKihxdk9JJ4yeMiGUdPpvpEchh5ip/ +dTqtXFGsUl2BK5xcWUQc+1eUR7MFj+qahu6egcqqxura1r7+YUVRjd3J1B82xf68axL2wMJu +v1jh9crrG+e+uemjLw7Zggd4HRw2AJwISkVqfwEOwcwdVsDAwQMXXG4rAX+w1q8Jvxt4WGM8 +BgYGGAwGVsHDVlpamwUstuActd5eam4z6Uw6oVhUrFSjrDKQmsh5+/mAWQTiwum+C6fFvEJQ +zLo71sGOYkGdC2VlZRwOx2AwoAcBelpvRrV9V30VM/SjKvKj4sAHJNGPlpGe4idsHuzpHE2L +NUMw4loB4KG7wlCBSm9fXwTJ+1z8ijNJSw5EfeCXu8Y1YSMnP3uUKhDYQMFjLJYTGgMPCwzb +2FIQ9rg6B6B7jL1vMlk0lU2RCZQjziGHLhPPxnOPBaQfvRiiKamqzCB7fviJ62efSny8TVRO +b0x6Q2RiVURMXWBYp4d/v7OX4uDR7LNnRlrRKujXC379i4DHxo0bly9ffl3wYHGlFzzTs8ZM +B1Y5fCaORBFoNFP6dn9d8IiKZ/kGZXFypePWHzgZyxfKr9e+ZBLwUBaWJKVyuHnyCeDBEEuL +pg4G8NQql3J5stBo5s2CR22jQlWfkSXMovB7+4Y1FQ2NTZ0XPLN/3BS5ckeyjekDMXSs2Brz +/menX3lj09w3N8/7z5Zx4DHOvgEWjvvQMLsH5m3BwQOXP5G0dg7scCZafYhg+TecXFvfCf4W +sD8QTACu/7aHmIqAv9xr/BneavBobm6m0+ngKQ2PlfyyjJkERoaGm5IrynbSJclCiUaRJ+JJ +82XKIgWbl5MSz/j8jZhZhLT5030WTIuZS5A9T0g4so2o1yExpS0tLTk5Oa2tregRTBA0YIKM +iNI3mPIzLoljXtJmPsK//FgVcSYn7MOqQhlqrTAgVdBNEFqXFBp3qtgptXTXBxPPnov7/kTM +h+dSv3GM3OzofbquuWXUdIHQh8U0ZuX4xZ1iAx4TI0DH3RR4rAuMtVppd/8IX1rsHRh3/FyA +fUDG8WBS8MXwgG+Xu3/5P2lMWHFcfJ1/SJunb6W9g9bhTPXpU/WHj7XuO9K64yDv+zWa6DjY +Wv7jdweP21BWrlz5008//bqS6UfsEyfSyG9eMv3gqfiJNHIzJdMj41gSafFvDh7gJMOiGTcJ +HmASYYGmtLxJo22pa+ikMaVt7b2FqprwWN6GXTHfb4xdsyd13d40ML5c6fPae3vmvL5+Hkod +E8ED0AX2oMYe2mABIw1sAQcPXP5Egmlk8HkGC9j4bS0D2J8MGHnyGutfhPWv42oCzuc3P43f +Hzys3ha1Wp2XlzdaJh0VazotYo1htXWeK6oVVGXxsj183EP8Q3PzuI2tNbWVHWs+S3+WkIiU +TJ8WNY8gBuCxa3Xi4MAwZkXBwjyg0cqfw2ZIh2W5NJdo6UGfaSkPiDynlUc/Lk14sSA7FAnx +QEwRBhjSm2GjaQIjoeCBnGFtc3lw+lGn6GXr7N/+eO2Cdce/jaPF6UxGjBqQHrcwYi4xWqlj +zJEyWlfdfO0K65C1zQqEVuowYaYUCOpt68xlCM9djjvmlXBxs4P9m29nu59qrSwTZ1AKnFxb +nJxrdu2o2rahetumivUbin5cUfjJUsYrbyd9/q2hue66v4W/Dnhcmz2uDR5HHRIzs0W3Hjzi +OLny2x885AoVkyO9SfCQyYvjEhkZWcKi0qbK6jaeoLhUU5fDEKZnckkUqU8w66ctMT9tjf3g +C4e5b2565Y2NGHKAMf+t7Yu/PDbO1YLxBiAQ8PUNC/YAA3ytA8vW749gYXDYAJ6xtmGoOHjg +cluJbajS1VQ2+CRPaiexNWtMuo0t2Nii+DjwAPuCGWzXgA1uFDzAgX5P8Ji6GAwGoVCIBXjY +xGMgr0gVChjqptZ3XiyFe6GOga7k9GQ6hWk0Ilq+u2Nw+4/pzxCi500D4BE5/+785wnJG7+N +6+lB0k7BNvn5+XK5HMuURdwn0LAORoweugEDJ+GsLPmx0qjpRf5/1xAf4SSs7B4tnw6U/IgZ +1pkn+FnQcupI81qwprpZdiFky6dr31r4+XPfH3vtTMxaoSoHs3kA5BiydbdYfvGgmNEOtqOZ +r9ctdw6hPe6Q+u1Iwi5SGwypC2ZpbO1ikXlOn6yJ3rGnXMbjSBTZ6Qymq2fJsePatWuKPv9U +9OF/yf/+T8zc2THPzEh+dIb/ky8q/XwtI/04eEyFPa7bJG7qcjNN4qbQKf7GmsTdkMA30iTu +JsEDqaWmLuMLC5PSuDxBkaCgRKWuotKFuXnyUk2NtrLp25Xu//ng4Ox/r587ZuhAqGPR9s+/ +OxkYmm4FD/D4wh5xACcwqLC1G1sDP7A8F8wGMu6haitgTm9vb1z94fKHiG1g0kTBjHWYKc8K +z9ZwJmxH8LdgtfVNCtjYnwxG4BhLjAMP7C8FMxJifyngR6tDE9t9Yr6YQFlrPRzG+dhpWH06 +2I7Y9wKwpS14YCuv8Vf5Wwlm4hgaGmIymfX19ePAA6vvCUHmHmpDp2sJ3AUPW3QSuaSkuBTb +fWhw5OCmjJmE8PnTAhdOi5xL4D1PSF/5WWx72+iZY8m5iOUE0AISNzGih/V6lAiq5PmM0De0 +6dMLPO8vSbmLnfB8dWHumNrXW+ARywRXC/o/M+KLQW0bhaVC+0uOW06t3On3uiP5PZ+07a1t +WvCG3gIZLVbbxWRIYUENMNeI9vylEYsZjTU1IRGpYC8j1hUGHiqQXP7oKy03r7yh6XIaI5Gc +lxefLjx+kvHpZ3Eznov8x9NBj80IfurpmKcfJz/1PPGRF5iLvwXfIXHwmAp74ODx+4PHWOpQ +SXIaOzGV19k1wBcqKqsa2bnSQlXN8tXuCxftGEcdb3+0j0zJvXUFxHDB5Q+Ua3g9MLqwmhGA +7k5lFmNUAJat9g3b+A2wfqKZwqrx8+Q1KIHobQ8KmME28dw2L8w6FdjGyvZW4IkmyzEawWwp +AGzgMb8ntiN2XOzcwLvW0xh3XbcaPIA0NzfHxcVZVZ6txQPJL4Us3dSGDgAe3UCnG/IlojK1 +BjMhmEy6c4ezZ90VPvd+AB4R8wic5wnE5YtjWpo7YDRTRigUJiYmjoyMQFhfEwjwh9EAD0Gw +ebh3iJNgJ45/RBHykDLmbmHaw1JaoEWPFfk0g82gyaMxUbsFCgJAlCrNpfCzHuTvQhRLziYt +SWH6mSwG7FhDHW0t5eq2Um1rWXVLpba1sqy1srStUt3f3oxWHL32fbGNDhlryWKBzGZYD1uG +OmpIOzfEr15l1huKW3u8kukJOQJtYSnf63L8p0t9/jEz8O9PRj39ctJTz2c9/SxjxsvCf87P +e/Zd/gkXHDymwh44ePxR4IEJj6+QyKtyhRUKZQWXJy1W1y5f7fHqO7vGwGPrgrd3vf3xXiZb +eEtLpuOCy+0JHuMiQoGm9k/OH+easRoAsQG2nzibrakBbADoxfagmDUD231cXpj1KBixYMyA +YQZ2Mhj8gLes0SO2V2T1itqeBjbV70MdVikqKgoMDGQwGGq1uqenx5ZJMEXfQ23sdtfAPXBL +V0tyRjKdwhgaHsIUc6Abb/bfImbfG7DwgbB5dzGfIxC/+b8Yrba6paVJIBCkpqbGxMT09fWZ +xpJpYaScx5Ae7geqXyNm0UPfKk6YURD8sDRtLjPxcCdat9MIm9EQE2gyIoBQWwwSe4o6PmC+ +POd87Hp/3nJv/o9nEzYU1YjAZsMNrbLEWE7gZV5wBDswihEcwvbzzfXyyL10URAVCY/Zc64P +HhAWa4qmAY/CDqyik+xem5PjfNpgMdb2D/OLyqVlFXqDrig7K2Xj5vD5b0T869nEp1/IeuoF ++tMvMV5cKFjwnuidpbknnXDwmAp74ODxx4IHFjoSl5zrG8LQaJs0FY3fr/JY+PZOAB7z39q+ +YNHOZSvsWWzRrW4Shwsufyx4XM3VMi7KwhY8bLU5UO6YlwQbE9NVxgVXbHRIHQcetrtPavHA +NsNCpwB7AHoBwzWSa33LFiRswcP2uNiP1w64uhWCRWJIJEhJBDqdTqVSAYdY8QOjiyFOe/t5 +VVV+dSaX7OnrFRIQyhfyK6pLjaah1AjFgodjXrzLZ8G00Hn3MGYRsha/GhQfn8Rm06VSWXd3 +t0gkam5uNpqHjVA/aslALCUAPIywaaCjnxt7PD/6aYHfzDSXRWGXlmrKEGwwwCbED2Ka1N4B +G5F3jJAFeUEqkkP9LEm2ffiWi/yf7Sk/xFG9DP39otCY5P272xiUAb60I0fQSmF0p2UOxCYM +RcUUXHBrKdGMXdkUwGOsIDridIFMsMnULFNS/HxUXFpHa52kUKwultfWaHoH29vKi5hn7dMX +f5owY1bWjJncl+cL/v0e98P/pX71OeXQrrIc8h8CHmBCMLNthZbbnD1w8PjDwQMTOkuiLK6r +b+pdvtrz1bd3zV+04613Nrz5/trYtCt69eLggcudJ9r6TkAO2XllN2TxGGdGuPYhxm2z3y3L +NtD0avaHceCBOXFso0rOBrGsM1zN4jERPKyBH7/bHR4ZGWGxWFiAh16vLysry8nJAfgBVBWG +HyODQ3UJ6pIdNFlygbyiMFeQKxFJ1aUlZGqWVJ4bcpnyxuPxLxDCFjwQNv9e1guEnPde9k5N +JnV1dYyZU4q12ioI1pngXsRXgdbUMFp0BmgEMsPlEk6cz8uuux7b/tErTvveUEjiLUgFD7MZ +KWOOmDTG0ktGX8H/EfCA9Ei8BRL1OQg4BcAHRUw7mrDOgfxzaMpJXoRfyIo15z9aUh4dB4mK ++4j0juSU3oSE/vCI4cDQckdXnre/eXAQwsqYm0ZbrFizbK/GHuCf2TICjejgYQBN5prqhlq1 +JCbgULLPTmLECSYnor+zrCI9nrLqZ/Ki95n/WcT+9EvSNyszNmyJOmHHpcb39bb+IeBxu9Xx +uC574OBxm4AHUpZEqSZTxT+s8f73e3vfendtzrrn3vtoRXwGEwcPXO54wSIzrdGbrZ0DGIdM +jPHA1o9DBdt4TiyN69rggZX8tYKHbXMBDIQmxR5rjKj1oJ5xfOv5j4vxwK5lUvCwLliv91eL +nZ3dVDqOgUcQk8kca8uCCHiilpSUsNlsLpdbUqIu4AvEl9g1x4X6mhGg7KVySVkRElza0dFV +Wqb2v5zw5ozI5wnx8x8Mn38P5wUC68M5vkWFWtRZg1xyTU19cXHJaFe2seoZgC7MFiRRt6+v +LShy/fKlj69+e37QiTfzsk7193abkJwUowHJTzFbMIeKxYJ1VcFYxPqfBTJjNUgBxGTLsy5E +7fd333D+q0UeH31MPX1RHJrYHJvR6uVXc8Gp/IKjxsmx+tTZ2kP27O27m3ORUE8TmEMPIWkw +JqxgKlZYDLqqGQQcCsmpMYNtSss661X56T7LspznxTm9FRW5o7omryaPkbh5e9JXK7J+WJu2 +93Cyqzc1Mo6UkCiRFPT29/0hfz5/FvCwsgcOHrcPeGCSTszdauez4tMvKnY+hIMHLn81h8vE +AmJYejiWLWIb3mkLHrZZLZOmiowDAPD9edI+R9juVlsExifWY2FEYX0X7IKZXybOMC7+ZNLT +sJYavpmbNsU6HhqNBgAGlh5rNv/SmF6v1+fk5Li6uWakpVRHq/q8tHA/+K6vE4r4RdIi6+5c +tviDOWEzCeFzHwxacA/jRQLzvRe9RMIilC6QQho9PX0yuRK+0reB2DMso+mxUjn5wtGvvHa+ +zAp8jBn1WXMVuGrzCGwcQUufW8Yar5gxA4XZYqUXzGSBVViHkGQWY5EsO3DDV8defSH52KGu +snJZGkl5yaPV4Wzjnv3aPfuqDhyu3XlQu2or8YPFbLu9hu42pEyHyWgxow1nx1k8JgcPLDnX +BM5Do+mqLeZn+3/Bcn4u/dzC6NAtPCFRymIlObimHnHI8wqUpGTm07kiNo9BpUsksq7ubhw8 +psIejz32GA4etxV4AHELTP2dwQOv44HL7eN2mdTrMZVQTLDvzWSnAq6Y9ChXqw1yNZ/O73m7 +pgIeFotFKBQqFArbYEuAH+CJzefzGQyGVCYp4Asklzj1ZySWFpMeMkkk+WoFUjK9u7dLXSJN +Skpf8kbws3f5v/Kgz4L7yC8S6G8/58Fly1BFjVQPNZksYrF04nGtlVH7OjoY4afzAp9rzSXw +Ip8qz4+DLEakiBjW3gQ9KTDRCBLdAWF1OKwkAGFlNsaMFB25NN+3Pwj65gdZHltcpmQmxfPP +2TeePNGwZlvFj+uU36woWLyUMveNoCdm+M6bp06Igy0mA2zoh00jowaUa5EH5u/BcmwtkKlQ +WV2aT0u++FHGgb/H2j0b6bOJy6cK8qSsNIaUkVcslqqk8kKRpFAq4/PzCqSS9jHfEw4e15Y3 +3niD8BvJ3LlzHR0dCbdGwC19/fXXb9HkhYWFhFspO3bsuKHt737kpWX/918AHgvf/OKu6U+O +ezczMxMHD1xwwWWK4KHX69lstu1m9fX1YE12dnZ+fn57ezvieRkcqk1Qq7dTZWkFBRoFj58r +4YsLC5WZ5HSxLFet1mz8LnXmXR5zpnsvuJ/0MoH72uMegT4pWA0xTCRimcFwRc/6X0qFIJU5 +IDWHKAieNyQhFKfdLyM7GkZ04yqam9BipEbUxnEleEAwWiEEyEhtTfLPG90XflgWRypsqAtg +UkgZGXlel4uPnhR+8W3qwjcjZr0U9tSMiH8+Hjdzpu+/nkj76ofBkhIzbO6EDQMwmrxrulZl +c6znC/auwaDLIjHUfEqs0wfJ++6LO/BknM9mqUIgVpSzuHJ5iVaiLZeVqUvLylRqVQ6DrlAV +9Q0O/CEfg98KPIJSCxZvC/k9o49wuX0khshf+fmXADw++N8qnqTsdzgiDh644HKnggcW4DEw +gOjE1tZWoKRIJJJIJGppaTGZTKPaHYaHuO1tjsoaUSVZkON52TPCPyxfwK+sqdDpR8wm+NgO +2sy7Ls2ednnB/ZmzCcJ/Px7g5hLN4QjE4vyeXsTKpJAru7o6x4EHZmAxowq/v70tL2pjWcrf +y9Ifp/tv7ahsgnR680iPqX/YNKC3DCNuIPCfEQmxMNu2eUXAA62xYRoc4bt6np3zesbxc/qe +EUljq2tKRiqZUcaS5J6+mLR4iesTT7j/4x8hjz+e9NTTpOdnZTzzYvTT82VObsZ+QEiWQTTL +F6nVYe1jO0HMSDH30YMbjCM0OrtayY91/SLpxKMJZ55NDt5eqhaXlNfl5iuLtNUlTbXlzXXF +FWU0DitXyB8eGbFA0G0CHphTDxtTr74Ltrx/0anftk3AX1wmDTnDwQMHD1xwubPBo7Kyks/n +A8wQCoUAOcBrW1sbFu8xRgiI+6GX3tx9SQP3wu29HWkZKdwctl6ns27jepI76/5LL93vveBv +6S8RRK/9IzQ9id/e3pGby6FQMxRKeWFhUUND3VW0OTyIujjqpBSy8ztZZxdGHvqO4u1fEB+f +HxOVFxIDBi80tqkYedYZTSakuAd0BcFgP5bxJadfe8/l/Y+kBQKAOOUd3SQ2nylSdrcZJRHE +jJ9W+bzwUui/ZmQ8+Rzlqedpz8wWzF5EfvE94vLNXdpyExLFil6oZTTH5SqnakECWbHgWMgo +lshLxPw4zzXRTi9HOC9IDd/XWF1YX18vlyubGhu6u9uUpUVkDlNSrBwcGf4DPwYTwQMouxVH +47HSu7b5Vjh4/J5ibWWCgwcOHrjgMonGMZkNI4aRId21h25IZxwxDvUP3yanPRXw4PF4Xl5e +TCazqqpqcHDQbEa+7tsGYGAJpQA8Oi8ilUtHTDqRSKBWqGCs8jiq9RPDRfP/5fLC/Y4LHgx5 +icBY8HBAclwejDSUN/X0dmu15dHRMUqlctITwCqBWXQ6SUJi8Ko1mqigASGzk5LdlZbelZDS +FhvXER5T5R7IP+texRLoh0dMltH28tBoOVHEZwN+bFCVH136w8ZPvhCVKip76/P5xCJOQrmc +0dRc3a4p5zucJf5vacqMubQZrzD+/S71k68zl/5E2Xm4msI2DgxCFgirhGqtFjapIAktkBEh +H+SopvKqWnIGOTHUMSZgTcDFFUmhTk3Vpa2tDSqVXKMq5NMY5AwSV8gvKStraWpGfUvXsXh4 +e3uDJ21jY+OtBg8rRVhTt07708G4EMH9fFc4eGtweNQvlsos3uKYDlYecCdvPZduCx7RZPmu +C5ngrW/sosFKlXY0f4ojqcR2weKrWzr7bQ8BJgTrs3JLx50kWA8Ogc2GpYNNOo9PohAcVFYy +eoucQtjgxxY0zio7rwzMsPpE4g4XIti+qw/5M/RLEsVTlWD9RodU8CNYD84BbIPNOellhmZI +wJwcSZX1MsFb68+kgIWJ95YlrsQmB3OCmbHLRE+p33qG2Hqw5U4XonUzcI3/3RIM7id4xdZY +jwW2Aa/Ww1nvG1gJbk5iTiF2o8CPAmUtDh644HKHCVC+I4O67paeJm1LtbJWI64ok1xtlJdJ +y6sVNSKiOCuW+icCj+HhYXVJCTUnh8Xm1NXV6fQ667VD1pKdMNxDb+64pAbgMWAcFgr5ankx +qvoNaCdYWMAt/mCu0/P3H1rwsOvLhOR5D3slRSO6Y2RkuLq6gsViiAukev0VJuWx8hzYD4Oq +1BSXj74K/PoHyaWTbRlpdcGMJu/wVs+L9RedWs65dDq4lRxw9Fu2OsDRdUhvHOUV1PliQDq3 +jRo9SiqqAsLiSsTKejUvxmtNkstHyeeWEGMPt7XLy1nkuLXryJ9/w1z6XcrWjUm+l+JjQ4ls +StcQoiCQumAQ1lQOdaVclRCMCCWhjAJZjMWlWg4rP49FyWOlMEnJ2YkpGYnJKenJYQnhMYlx +NDK47twcGo1FZ8hE+UhnvOuBx+9Zx2MceGC9h8i8UrDGShcJOYXYNgpNE5bDZX1rhzMRLGMN +o61vYcHbL33tBr7Lg/XgFTOq2B4Cq34zzsxy3IdmPRA24dXmsZ4SPFbhB1vG1mN5bWBysIxl +pQEFDZbB/NYeTFZrA7Z+KpcJNgYqHlsYd28xdxXmLsFCx7FrsZ0ZOyuwmVecwLoZOHnrltga +67Gsvx1sGTsf7FaAZXBbJt5bHDxwweUOEJPB1NnYVS7TasXVxZxSGV0hYcildIWMrrQOqXWB +plAw5SpOkfeRwC2L90Wcj/2zgIdVEfYMD+bLFZnZFI6QW9dUbzAhD1IT0owNDCRftZvd2OAn +M/VbOo16kVBULlGgKtpktiBblhRrvljk8dxdXvOnRcwmEOf+3SfMn97c3Mhm00mkLIWiyIT5 +bsbiMSALrEdKcUFG1LjQp1IGf7/C/pOvNdmk0pwYaZCn9mJg49FzzfsPNRw6VGlnV7Fvv2aX +XeqS7wK22OkNJit4jJYUhUZNL2BujbahpLCiRsUj+/1Ac5mbff7NlPBd+VKqnMXyP3TUf/ue +ZPuzjIRYBpeWTMnIYNPae5EKaRYzYjUZzWixXN3kMVZHDM2ohZpb2+WyIqEgT5DH4efy+Bwe +i8EkU8kkahaLy8nLE/EF4FYJ5XJ5Q139KGzdxuCBaTFbfwrmjrFqW0xRYm/ZkoZVaYK3wJqn +PnG21cvWpgDYISbNAhs3G6aXrz2PFR6sDU8xFY81YbduA8DDtlIxODp4F6urY738a18mVgXo +bBDLCjO2gs0D1ttWGbIeHbst2HWBLV9d4W2bID/OdWU9FtZE3no462zYuYErGvcrw8EDF1zu +AOnvGiiVlGmkWkVuEcIb2GDKkMFQWIeYoZAwZRKGTMkqLmaW+Z0IXvPfbbuXHQ93i79NLuSq +4KGzwMMW5FWPDgNqutDD3U09Mr6YnUpWsgW9da3QsBn5ig82G4SHMmua3HnmHlOv0SgWFmjF +SLasCUI0NvKwbWpctSRsJiF27t3kOQT6Kw8GHDsQzOWylYXi/r5B9JB6tMntWL81CBwcGkHD +Jcy9/bSTjsdfW0R0v1yrLefRMyke58qcz9Ru29u8elvNqk3yn1YyvviU/M67Ec/PY51whK9Z +aqO2tkVcXF4oZxDdPycdeyzx6DPRfpu5uVQxm0+KTQZziwX5IqRAvJjF5rDZnO7uHtja9/YG +xWgwdnd3NzY2VlVXV1RUlJaVlZSUlJaWlpWWaTQarVZbV1fX2tra19en1+unMuHtBh6YVrVa +J2zfGqf1rG8BNgBfycfp5XHAMCl4jHvrGvNg2hycFVYVx3aDia0NMM8Rtg3WBQkLq7DaWK57 +mbbTTuy2AKACK9FjezMxkrF2QLBu+RHqW7GumQgekzZ3sL05YGMcPHDB5Q4T/bChra5dI9Yq +uSoZSyljK2VMhYwhl4PBBEMhZyjkTKUCDPAuMuQKlkKao3A/5Ltu8c6tX9jt/upYmNvtbfEo +N/Qm1Hcl1PUgo74ntqYvvnYQjNhaXVKLPqmjxbNYuCNNvI/UHlA+ENM4Et/Um1zTdZzZ48CE +OyC90SgR5pfJEPDQIxmxZlQFGw6sy3iWEP7KXdQ5BO6cBwLdnFMHBwfH6nwBwNCZzViPlVGz +h8GC1uMwQ5oU0slFH4Rs212vKOHmidPSSCQfX5m9o+KntYJ3P6YteCvhpTkRM56JeeLpiH/M +jPn2B+PQ1et/QlBVZT2vQCHITY9z+jjJ7pEou6fi/TbK5ZxCiZzHYJcVq9XFqqKiYsAHbA6H +yWIBKvjV4DFqHDOZAFfodLqhoaEBVMCFg2Wwxmg0Wq7TBPf3AI/e3l7AHuNq2E4FPKz+FFvl +bssk1u/vtj9azRqDwwZbK8c1FCW2+zhHxtXmsXpSbKv8WU0u42a2BQ/s0qxFj62Xf43LxGDg +uvG3mJXDikbY5OMMKeiF6G03mxQ8Jh4LBw9ccLmDpbO1ixrPIgZnx3mnxHglxXqlgIW0QBI5 +PIcSwaBGMqmRLGzQorlgUKM5OXEcdiLP61jgWoQ6Dm1benD314fDLkXf1uBRMNzpUd3kU9Xq +U93uXdXiqW33qOjxrOjyLu/21vZ61gxcru/2qG5xKW27oCk/KFTuYDSHKPv9C/SZVfAAPGw0 +5Ofnq+VI5JtuNB4TaWFyZk/WC3cHzSEwZhOErzwYEoH2qYEgo9lktiAFvnQWC4RFhBjQ2AwL +Yv6A+pUloct+Orv4M21uXntLd2RKTnQKXUjiChwuUj/5IvAfj/s8+s/Axx+PeeKJrMdn0p58 +OfjlhRpy5tVa2kOQpaq6Ll9RLM3PjnX5IvnoM/HHX04P2VaqzgPEweMjcZ4VWm1VVRWPx6PR +aFqtFmDDddrUXlNuiCv+KPCYKNiXcaDmJlowbLUhpuKtX8Ntgx+A+sZiDLC3bBnmv1uCrUV6 +rdEO11aU2GzWA2E4cbV5rDraVk1r6zuxlZi3BQvYGAcemGsG63Rga6O4xmVaQykm7WoNj/VN +sDp3rI4ka7ay7ZZng1i2m1knx67X9li2h8PBAxdc7mBprm0BsOF93N/rZKDXKTACwGuKd5bX +oSDnnR4uu7yuGDu9nHd7Oe/y9DoY7LzNe8sn+3d8cWj7Fwf3fHU0zC3mtr5OpGoGBPfDcA+M +vA6gy30WU7/ePGCE+0yWHgN4hYcgeMDSV9XBz2Tmcws7q3phNOy016DPKygoViqs2r65uUUh +UZ7YHTfvIf85BM5sgmz29OBQfwYGHmj4BAIe0Gi6KmLuwPJV9f09qQeP7HlyVpajs2VouKNn +IJnGS8wWNmu7C4PjKN8s958xw/upx0OffSZt5nOMx5/n/evl9OcX0Pbs13d2XA08Kqoq8+VK +lZKT4LEq8fSr8WfezA7fV1MlKa2pFCqklQ11LR1tykIlAI+W5maMN341eNju+Es9tDG5ncED +qGmrPd8aI2FVf7ZVwrDS/Zg2HPcWoAVMTdt2KwAiUNZaOxSM66J4jbbLtrNhjHG1eeCxNovj +ZgP8gJlBMFWOBXzudSXZ2hysdhJwXbauE9vLtI3xwN4a15HBVmyPaGussA3SGHdo282snRTG +Hcv2cLb3DVwLuKKp3M87ADwOHDiwatUqXDHhcmdLe1NHgm+a7+kgX/tQX4cQMPwcQtL9sgNO +RXoeCpxkHAn0OBQYeCrm0p6ArUsAeBwEY++yY+G3jatlcukzW7rMg/ltvTl1Q0Xdln7LQGWX +oW1ID5sHYYsJHWakRKfZhMZQdgx1ZUukmfRcsaKora9vwGwWSqVlaqRkent7i1AoIpNyChXF +CWG5i2Z4v4yAh2LOg0HhAUz0YFhXOCB6a/orPFbyvL1O6/zTDxc++VRJJA/pdT2Dnepqjbqq +xqSDO/gy5s7dye+8Hf70M3Ezns+cOZvz/ELR3Ldz3lksOHlmuK3tahfX1NzM4uZRsxIi3DZF +OyyOPLuEEn2mt7umvrtNXl7aPtCjqdbS6fSW5hbEDmO5qYpe4+jiJqnj9wQPXK4hEyNdf4Vg +fpap10i5/eX3Bw9ccPkrSFdbT6Jfhu/pQAw8fOyDwUj1y6JGsHMi2dQIzriRHcmmRHIY0fyL ++303Ldn7ZwEPSDEwmNTY4arq8ahodS4cYndpQ2UD7HqghEfGckmRMAx0YCp0wGjQamvYjFwK +nVkgkbAYTD6XK1dKydSMXC6vtqYRfNVXybWL57vPItBfIsjmPBgQFczCwAMaTRLRI5MaRvu/ +IhVAYGiwv0Mj4FRxmFpFcW1zQ4EwXZAbUVxIbaopMdTXF3h6U5Z9R5zxCvmZ+blvfMT54POs +Jcsytm7rKVYgTHQVi0d/X79criITU1NCnZK8t4c4r0kLO9/SWN3W31NYUSYtUqaRMhlMRqm6 +pL6mdmho+CZR4bcVHDz+KMGMKpghZdLslanLDmciFjQyqWsGBw9ccMHlCktAV39SIPHymQDM +3IGBR5xnSrIPMdknY+JI8slM9CGm+Wef3+29Zcm+Pw14FPT1B1cNnNPoHKv7T5XpaL3V7pLh +7AbYiBo4LGN2CevASmtZ4JGB4dqKaiE7N9TXPzw0RFDAr6rT6nWj+RotjfUrFns/S8h6kVAw +/2HfuAgeutpoBQ9EuWPNUNDZAJGYkFgPeLi3s0SlrdJWZEYcibrwaczlHzLizg40ldeycjPX +bOe+/wXz/z4nL/0hdd3m5BPHMyOCDPqr1mezWEzNDU3igkIeh8ejpXOzQykpfikxoSQSicpi +phAz4pOTMkiZLBaTxWRKC8Tt7R2T2i5w8PgLgoc1KsM2mOTXGUzG9bbGwQMXXHC5Knh090d5 +J/icDfJBwQMbkRfjY92TY8C4lBTjjo5LSdhynFsqWIj3Sju/03Pbn8jV0mTqz+3qPFfatbdo +4HyVWaGv9ZLoqA2QGTVF/FIdY2yY0UiNsTBK/cBQtaa8uqpSb9CNRpaiJTqM+s4DG6KfJ2S9 +QOC9+g+f5FgRotBtwMOCdJtF6nRh3haTBUnVBUtdnR2FxbU1mlJOxLZMlzlJbguj/VeWyCha +oTRq79GYH5Zn7NhGdnSkRIVmUzIzciiDQ8NWWhjv7LCYuzq6lXKNgC8T8nh8HpXLzWHQOZkk +ekpqWkpKMjk7m8Vhs9kcoVBYqlb39fbeVr+ZWwQeYEIwc2FhIf43jgsOHrjgcnuBRw8Aj0Rf +x1/AA3W1kMjh9KxQ2sRBDmGAV0oky2O/39Yl+3d+cXDnnwI8LHCbuk1zWT6Y1tFwuaiT1VgW +JBzg1gAdboRHq4mODQgarUxuGYbNQ5AJi/oY1fJYT3ozBBACqR0K67wcs+fcF/sigfHvfwam +peSjW6F1PhA+MOpheAC26MEMZgQ7TJAFrRQK9XT1KJRVlcWFvPDtWQ7PJjo8E+f1PY+WmM/J +Sw4Kzgz05GcmFuTSckVculhAYeUO9A5cDTyQOuZGc1/vSEN9e3l5lbpErShUSuRqqbxEIpbI +JBKlXFFUVKQp0zQ3Nw8MDGC5wHc8eGB1PE6cOJF7dRmXbItl4F5XJp6qTqe77l6TIlBBQcG1 +9wIbTNwLTHXdw01KYlO5ut4ruRRroXhdGXcnp3gzNRrNpL+4W3EnJ72Z172TJ518Fi96R7Xt +CvCY4uekdwLhT+Vm4qY/XP4S4NE7EOWd5OsY7OMQPGrxsA9OukwkBuZkBFCR4Y+OsWViALI+ +K4Thbue36ZM92z4/AMaeZcdvnzoeUVFRvZN9qR9o7G4VVBsbDN359V2ShhZR1XBtN2S+WpYq +xh6QeVyZc9R1ArjCAJtG0IwXYqL0jX96vEQgvf1kNIUqGd0TrQcK5h5B+tqbAafARiNsMBgh +0xDqdent6JUWqIok+UTv7eH7ZoQfeDrhwhopi5kvllKZVLm0QKGQyeQysUwqLyxkc7j9ff3X +ASsLICTziE4H0KKnp7e9s6utraO9vb2zs7Orq6u3p2d4eBhrSXO7CaYQdTbd934TAVqGcD0Z +V14MY5XrCiCliZdw3b0+/vjjiSc5a9asa+81aWYlmOq6h7sa4F1XxkELuEVT2WvcnZzizdy4 +cePE87xFd3LSmzmVOwmEu+ZBW/CY4udkIv5N5WZO/HThgsudJ+CrdPTlZF/HECt4BJ4L9zgQ +sHvZkb3fHN/79SRj15dHzm508zoQvH7xrs2f7gNj59LDIa63dx0PoJoNSNlQwAHQsAUaNEM6 +pPWZyQiZb7AoBTTap9VkQdrFw0px20fzA58kxH7wXFQBXzUpwEAWM2wC9GE0QRYd1gWms0+U +r1KIxRm+O0IO/Sv8+CPJHivU+fxCVTkzj6cqUaPFQMu0Wq1MKsvLyzOZTNc8JWiydbdRBOkf +Ijf6PR23eOAWjz+vxSMzM/PsBJkIhBj/nL2eTHH+cUKj0Sb+Nm03mPQ3jstfUAb7B2N9U3zP +/mLx8HcMC7SPctru6bzTa9JxbrvH5aNh7nYBaz/evvHTXWBs/3x/8IWI2x08MI+JYaymBpLA +AhnAuJFyWBAyAYS4UowWWIfo9K5208qv4v5JcP/kBc/8TF53Q3N7dX17TXVHtbajurqnttEy +ZECOZbGY0GAPrMF8S2e3SKYpLVJnBu2OPPtklNP0RN+lFUWCisrGPJEE8EZjY0N9fb1MJmMy +mROf6lfDj0kxA1tvLbiBf+ZxwWWK4h7MXLPWSbjzlds8xgMQ1Ouvvz5F69Cvs5ht3LjxunvZ +2dld2842d+7cO+BTAZ6hNU19/IIGfkEdt6CGK6rniGrZwkqWoJL5/+y9d1gcSZboe/943333 +ze7szO7M9ExPt9S923dm2o3pVsuilvfegaAstnxRhZEA4YT33pvyFu+99x6EFUhCICFhJCSE +9/AiK6Xs6sIIkGkEdb7z5ZeVGelORkX8MuLEicK7Gfl30/PupOa2pea0JWW3JmW1JmbeTki/ +HZvaFJPcHJ3cEJXQGJHQII2vk8TckkTXiqNrhJHVgohqLlBxNVtYzRJWhAnKwviVoeyKQHZx +ECcvIr7q6bORjfTPGh0eFQVE+1r9BB4+lsERfvFJ7JxEVhbQJJkqrKdwcxwNPTUOauKPEIDq +HqcGOYStc/CYnJ+ahLtOZHO1z80D5JgZhyJ4rEJm5+fG52emwGnGoU4U2HfDzjz+y/9Noak4 +5/nxCkJZmYHBGUH+mQE+We5eGfZe7amFAHEA7IzB88DKuju6XwxkV9SUFBRGBRmF234Z7viJ +OOhKV3tdd8+zmrr6vr5eABvgAy0pKenevXvzK4j3BaPFwpiibx5nQylK2YRS0/DYxiMXR48F +iqVKLmI8YjNq1+3dwp04Xl5eK2kdWluL2e3bt1971N27d5dpZwNotDGCsrZ2DMRm3hXGAW3h +xjZzottYEbdDJY0h4sYgYWMgt96f2+DDvuUZXuMeWuUaVOkcWOHgV27rXWrtUWLplmfhkn/D +sdDEPvu6TbaxVbaBRQb9RjrVNJ10PZVolKbLTNFiJGrSEjCkWBQ5FqefQLiepH8j3ie05N7D +0XVlh+mZWbxlxK92WcAxkFel/7zizvON8LN82dXiZx0KwEPsFRsXmBYbmLqIBiUDTQxLdzb0 +VN+PwxzWBap9nBK47sFjam56AjADIIU5SKFGiPmZGWi5ihYPGXjMTs5B0TnmJmEv0vni5FKd +v2oIMc6DhVUjxaX9mRlPUhKexMc+EUTccw/OMXN6VN04OzMzBjWVvGxsGZgcK2+pS4iPFAfY +8lzVgh0O8wKZjzrbh4aG2+40d3Z2ZGfnRERElJaWgmcZGRlZPkq5fChRhfVF430pq5X1L7UN +j209cs0cMgvKOiYnZ5QGeW9yr/OZd2gphhqtyUjAUCPRlAgMLVqTmaTJiBbF3Op/ProO7xkG +j0WBYf3IBogGf7ezLyq1PkhYHigqCxaVBvMr/Xnlfpxi3/BS75Byr+Ayz8BSj4BiN79CR98i +e59cG6+cmx6ZVm4ZFq5pZo5p123TrtmkGFmlMs2TGWZxDJNY2rVYilEM0TBKVz9Skx6hSYvE +kCVogviqjkCdyNMxiqLeSKTfSKKZxpOM4hk3YuubH60fa1S3PPqPvdb/vtviV7stVwse36l5 +CgOjFcBD4h2XEJwRH5S+iIakAE1mZTobeKruRaEOagLFHyX42wevc/CYk00CPwcPl517pa+m +e18F5slGyU7Pzk/OAggBpdBoR36a776Tvipnm7jimbLKgeiYoQjJMI8/HMQa8Qkrp93gEhjt +dbdmX43bnYMiow5UtZXm5CbkxsRnSzhR4c7cYL+sjMJbt6rz8pPj4+Ok0oi0tLT8/Hy421dJ +C5tHbt994hZYhKXF4PXjcfQ4PCPB0iWrorZLaZk3l+X/Rb1PhjnSGk1mDMAMDDUKIIe8Yukx +WgZJoBZobutTgsdmA4/B4aniik5ebEVYVHVYZENYRG2otCpYXBskqArgl/lxyn1ZVd6hVV4h +Ze7BJe5B+S4BgD0K7LzzbT1zrd2zLV2zzJzSr9unXbdON7ROZlgkMUxTaGZxVJM4snEswTBK +hxkFwANPjcCQJBiymHgt2sgm1cQh3cQx7Zp9qrFdynW7NBO7rBv20unpqXVik/zqdoAQv9pl +8WsVq48O2a1KD2gHS0Pi/SyC5cGD5SgSuEXzXSMXUTcpULFXjB3N5bKKuvo+jPp+DPawtq9d +wDoHDwg6kPGySKzSuVeBSldeds1B4DEyD3RmZn5s4llzhImu5487c03MC/1DOoURD/yCuhxc +e63sesyse0ysHhhaso6eLQvnzs2+jFUGrvfseX91c15uQUpRallZallBek5yfFaEJE0iEgh4 +AZGRkoyMjKysLLDMycm5f//+BgYP2P1sYJ1FF/mlpKCsQ4vx84qPGgnYA3AIoJHbd54oTfQu +ZHhkIi6tmWKSoGWQDEytgBzyitOPo5mnllY9XFf/SCV4vDsBtURR2V3PwNyb7lk2npk23pk2 +ntnW7rk3PbKs3LPMnTKu2Sabu6Sb2CZdv5lk6pB6Dah9krFdwjXrFCPrZEPrJAOrJAPzZLp5 +AsU0Vo8pJVyP1DOM0KVJdA0jtQ0jdQwitJkR2vpSbaoER5NgqRKmVZKdb4G9V66NWxZ0UY8s +G58sU48MFEN44Ny1gtyIkZHn6wc8gB4mhhVU31+VVjU/ihek+ZkD6vgJPLguUql3/BIaJ/VO +iPZPdqC7nN9z+co+1JX9KI3DeG87v/UOHj8P1YHo/KoKEKjJYnZqbm5Y5mU6PzlaHe5rtvM7 +PpXyora+KiqhyMW7w8X3Ht20h2zURaK16ui2aGASDh5PoxqOP4Y+lMagTp/56dHx3iftbe13 +Gyu7aosai4sKCkoq8gvr87MLivIzi4sLi4qKysvLa2tr29rahoeHN3CZr4xcCsvQ8ERMSpOe +cSKWFr2wvgMcArX260eHCqu6eweVqPC2ZGZmFsDedbt0TWYijh67DHL81PRBi8HR45z9Cpta +e5XgseHBIyu/BU9laRA4KKoQTRFjyDwsmYMl87FkEYYo1DeLtPFM06QKLOwTLB3iwF40RYSi +iHAUHo7Cx1EEQPEUAZYixFD4ukyBo3c6xUxCNZU6eabqMkQYighPFeFoYCnGUURYmhionpHE +1C7Fxb/INajYNajENbTc2DHpEMr1v/cw9pw1SIrwevSwbV2Bh7qpeA2HJ4jSAq3CfF85l3pb +BIk9Y+OD0+OC0hbT1Lig9OTwHCeG29mdFy79qAb06kG0p63vOgePOVlADjiEuXxw9NV1tEAn +mZ6em56U8UpfbqHn3mMuxy5XpxXW1TYXRCem3HRus3K5q6V/X1Wr4uTZuJ07Iv/6l7BPPvf4 +2z8b+FLo2wqwx5zM42RybHR8crh/9llP/6PeljuPWtvaHz+429vV/hDc/6NHj/r7+4eGhsbH +xze2Y4YSPKanZ3OK2g2tU0Hdt7CF/+dVXrQWM4lkkhCV1DQ4NKHEhjeU+uYeB+98vH4cnhG/ +EuSQ48BIGahEB/EqHj5+8UGCR1vbfHX1T/r4sWICsNHBAdK2tkVbKqFd/v7z3d0bFTwmp2er +6x9o0/loqhhDFeAAIVClWKpYhgp8LE2IJvD50or7vaNUY15hRWdFQweOyMHQRFi6AE8X4ugi +PA1SHE2AowmxFP4Nu+jegSmPoCyv4PzH/eNmVpEYsgBPE4K9eJoATxVqyg7BUMRgC8082tG/ +wCW0VNNY8PcjZp/u0P9sN13lvFF6tM/jB60bADzihSnBN1kwePhYBQPwEHnGAMZY3Lk0MCU2 +MC0pLMuJ6XZmx7kLey8DVT2g7mHjtd7BQ4YKC4Ojrwo85qBxMdNTsqEwM/fuJOAwZn/fkctO +aLk3wE3JjYpNzPUNrjO8UXL6SuRX21if/c3/oz8GfPxf7E8+CfrT55LTV4Zabs9AfTRzE7LZ +6JAmlJm5kYnZ0cmpmenJuanx6ampKXlvUiV4bGCpaXh80z0HVHx4/ZXWfVh6rCYzycA6Navg +7uTk9LxSVtNgOS/zxs8rafdnlWFpUZqMRNiDdA0KO53qGsWJYut/WafTtYDH3r3z/+t/zf/l +Lz9pQsLP9iLbQTIdnZ8BCbwdSSMQbEjwiE6pI5pEaZABckjwFCkebpegivAUEZYqwNJ5OBI7 +v7S9tfMZgc5Ky2m53ztAMhCiyRIMxBIiWAFOQEqWoCl8j+DMwYkZK6cEG7fMwck5d78UdQIX +gApOn4+j8/FUgewSAsA2WCrAD4GWgeg4xuOzXbRPduhv3WO0ZTdT5bxhWoz344cbATwSRanB +1qxXE7VA4CH0iI4PTl8KPOIC0pLDsh0M3I5vP3N2z8WzKhcv7VNzs/Zc5+Dxlgqu2fG5ySmA +AYNjNU6ODn/7LOqa6cDTkVsdTzzEkfyUjNvZ+eVmFrH7Djn/5g9+v/sT/5NPRJ/9Of6Trcl/ +/IL1yZflNx1mh15MQSeZUw5U2MzgMTU90w6NniiBKq811X04/XhNRoKFc2Z5zUNlLlq5ZOW1 +2nrkoKnxeGB2WtTakGOh06m+eXJK1i9WHawRPIAi4uPz00+YKJCGDn9/iD1guujuhnZdvDiP +9P8CJgFbVtDuwWQy1dXVP6CsEsAu1jGMx9LEAAY0qWJNGsQGOJoYQ5OggZK4ZrbRvc8nRfEV +GrosF5/0p6PTPqF5Gjo8LA2AhAgD9ZtArIKlSvFUCZbKL6npar7bR2IIyYYRzfeellR34Mkc +wDB4Ol+TLsTSpODkOKoQWtIEeIpEg8L95/Ebn+7S/3Sv/hYVxpbdDJXzRqmxADw2QldLkkQR +PATuUa8Bj9Ase6bbkR9Ont59FuiFHy+5WrltBvCYl7V4gO+m1qJKo23bTf7+1b2UzLnZ+Yf9 +vbE5qelVNc8edzfweVEXLoT/z1/FH/0p/pM/Jv/hT8V/+qLi8+8SvtwpvKA6eLsZasOYnJI5 +uyplM4JHRe1DS5dsbWbsoqMnVqHyfqd3lX6nK5K84ns8abWBVQqOHqWqJ0GRI96cPWCnUzwz +MVRY/bhn6IMEj4wMiB/mZX0oADPkWz9gugD4AcTYGEqm4HUGOGR9u5esTUJ5xQSjOBk2iHBQ +I4YMJ+gSdYpETYdLM+LXND1u63xONRGiAGDocwsq2+93D12ziFTXY6OpEohP6AIMUKoUTRTe +dE5+OjjtFZQO+YGQeZ5BmS9GZkSRFRhCGIbIw5PFeBpILMTSAdhIMTQhgBw0lf/dKatP9+hv ++ZGxRYW5ZZcMPGI2CHgkS9PkwCMEBo9lulpkLR5ZDgbuh7cdP7nzJNBzKudcLF02BXjMzc7J +JqatySt1xesG6RLuFVU+fzHS1VX3oKP0QW/n+OxIR21xvD41ftePcb//Y/yWjzP/+k35dz8W +7jqScOJCvpPjeO9DqHtnanrVsdqV4LEhhCcp1zGI1aDEaZCj3kqVB/ud4mhST2Pre3b7Ou1V +Npfa7bpD/c820q9Xos3E3xQUt9g5i2wcxZ4BaRbOGQA81AiSt/Ii0JRIbcNUIkOy6KXv6P+h +h607NzX+LjLV2sED8fHQ1YX4AYiDw0sCWQmubGgJFhRrG8epE4VXSXw1El+dKACqpsfWILIs +7GNqm7ta7j83tYlS1w5RJwmvEsPoJpz61t6G2z3QRr0wNJEL0l/V46nrscjGvMr6R0G8QnVi +uDpBCJ2TEBrKL+l+NhGdUksx4qN0w9F6HBSRhyZwUUSuBpGPIXHRFPF3p20/2a3/+R7GVhXm +VlmLR9pGBA8fy+DlwSMmCCyTk8Iy7Q1dD2w7dHTn8WM7T5xWOetk6bxOcktPT8/yM5u8IXnM +zUzOzk5PTUxODI7cLq9rrLnTdLdVwjZI8VNPDzPIzAl90N9YmyCNv6yRuv1g3JmLAryWhMGM +srRKZoU+e9Y3Pjc3Oj839V7cNib72p9E3+jhEt+i9grp/UmOb1GjjY7Rfvjf9wTX3+5p1602 +s2+k2+lFmWrzGLggAsqRbIQlct78uxtDjcTRY2n6XCeycQPhv1ZYEW9sbV2wpZj4l3r9/8k3 +2M0y1PQwNjYx9bFylHoF5xhaJWozo68SJBpk6dqQA+CfBkl8QtVzzzGLRW6G8ts28n+0Uf/z +WabPOgKPrVvnCQRIv/tu/uDBl9sXBY+hoeXAY2hoQ4JHILvoul1aRHx1ZFJNRFJNVGJNdGJl +dmHLnXt9I2OTdzv7EtLrJHEVUUlVUUk10qRacWJVfHpNR1f/4OhUbf2D+JSayISaxMyW2qbH +TwZGm1sfSuMqpYnV0Qk1MQk1YEUSX15Q2tg3MPx0YLS26VFSRhO4UFQSuFx1dFK1JK6KZhb9 +3QmrLbvpW/bob93D2GAtHulRWStv8YgOAuyRBMDDztBl/7aDR3aeAHp8zxl7S6fNQcFz87PT +M7LZ7YG0t3XWNTy81XIrIgib4fB1+s3vpSE6pQ2pJdnpArpJjO61zABBelxKZmZOXFJKTHp2 +78jo9LxsPtzp1Q6nWYs8jbNW1j7rX+PM9bC0SDU9CerN2j1w9JgzqIAdB4yLtD9WWhXo8K0k +hX9E+/2fBX4cGZ3MK2wI46QyrgW6eMd5BedhqdJL2sKVc6CM92I0SJKjl9z+uYf21Ta9ExfN +F/4TkVsC5PmOvrYWnZZuFV0tKiov/TQW7WpBEsNYIt/VAtbBFmPjjVfW+4QVOvjnT/6saRqa +BnxqZnJyZqlvW6h0n5qamvlpLo65mdmpqenJpb40Z+fmpkHquWlZrfCqlgGfjXPzNq6p3x22 +3LqbsUVF/zO4xePCxgGPvKQCZFQLHMfjteCRHJZlb+gmA49jQI/vOWlv6bBpwANkkrkx2cDc +jvbO6rqOiqoysdflhBt/jL72schHI6cgLi87P4MtqotJqyqoKSmoLC6uysorScvIHxiQTfQz +JZur7t2Dx+zYiz4xs8vz1HrWIv2vBed+ddfx0ArTb7DKsZ7ySRKX6+6fZmqfdkVHpE6UrKmt +I0adKD560eWrH/S+3Kbb0/t8XimL1wqL/OuePB2URuXTDH3b7nY3tfa4+OWq6gov64heix/A +7BhK5KmrPtv2GQCzf7lNJzAs+cXgyPsHj7WIAngAooC7WuZfOZci7SewcymMIrBzKUiAeJOu +2Ln0gxPf8EJ7n7wXozMjkzMjE3OjE3NjEzOzMn6YnJkbHBofGh0fmZwcnp4dm5ydGJ8dm5ga +HZseHB6dgIKLQuEpx6dmx2dm5mRhsodHpsfAGcZnhydmgI5OzID1F8MTI2NT8LSlIOXwxNzI ++Nzo5CzY9nxo1to59btjN7eokLf+SPtMxXDrHuaeCwapMb5ZuUXj62A42xuCR1F6SfDNcF/L +tYHHUaDH95zYNOAhc9CYmx+FhsNO3r97p7i0uSA/l2t3Ssj4Fdvw9yIfrcryotLShuLsguZb +1RW3Gm7VNTXeasrJy09PyxgeGIRG5EKzxczOKqOgy2QzD6cFWaC9ozeYlaxD8XT3jY1KrMPT +I9SJK2/th5ADrJxU8/5+L/Orbbp7DjOCwpNmZ5XuQ6uWx93PK6ruJKZUPBsYzcxtMbNPvaQt +VNUTLxVQBegFbMjOwyZfQcihdwl1MzWjcqmTfwDgUVj4M7pQGGwr36ABgER+EO7GHU4bxC2i +WyQ4emY4eac5+QBNd/VN40hKqhofDU3O1DV3ePtn2rpn2PumO3lnO/pm2PoluXqmZhc1Dk7O +3LnfHx1f6+GX6xuan1V8u/fFWFF5m51LipNnpqNPqqNPupNPhq1riiCioKd/pO/FREZ+q29o +gZN3hrNPqrNPmotPuoNXuq6x+PuT1lt36X++h7lFxWiLiv7eM/qpMd5HNe1/tcvi4yMOR0nh +rtz88sZfZlzbG4JHeXZlCAQeQYibB8814rVdLQ5Gbge2Hdic4DE9Nz8OIerU/Tvt1RVt1SUF +IuczPNPfhpl/EhlIvFNf13DrfmFhRfOdhub7rW2tbUWFBalpqU1NDdNTUEvH9Pz02DxgYuWA +2s0OHrCMjU0VljR5+kU/6h7IKWzD0qQXtYQaJOnr4meCui/qHCZ4x6FroO4DehXv0PVIObZl ++fbK5WR6erqu/n59Y4esAXw+ObOJZhp7UUug/vN3ASx/RZuz94TVN9sJX23TO3TmOl+SNTa2 +XDy39QgebW2KkcGqq3+2Bfz094egYtHWDDi82Gq8Sj448AgWlOkYJ6jr8q7qsq4QwlUJHDVd +PvipzeT6hBa0dbwoLu8gMAWXtMNV9fiXdTkahODIuMoHvcOShEradQmKEK4ONmpzNMlsS4eo +6qYuW7eky/ggNT3WVQLromagrVvyna7nRdXtN+2TNIk8DT32VbBLj6NO4GjostT1wtSp7O9P +W23Zxdi6x/DjXdQtO/WoBpZpErfdqubIbGuAQD46aPubvVYAQkJiKlo73l8J8IbgUV/aGGbP +8Vk7eBw/sfvUzeu26yS3cDic9zbxx/P+yY6WJz23q2ND1SI8/hLj+XW+hDH1pGOwb6y1pWt4 +dPjJ067GxnogY2NjymJ/UYEnzh4fH9/kdhgbmywpu11b3952r887pFCDKF7K2QBDg9w5Lmux +VI5bfL2dAD63j50zEUfljU9MKbPTW3gR45Ndj5/1PYHi0g8OTQqjqnSYkTL30Ui4V+sMyv/v +O8kAObbvp7n7RvU9eX1psx7B473LhwcevHI9oxQ8NIWKEIroRRPjKGIsRaJBFqJ0uFY2sfe7 +n5c1PtRm8DFUIY7MlsbXPBuZ8Q/Jw+mwsCQ+li6EophSpViyFKUX7hGU1fNs/KZLAgbsIvGt +XZJ6Xkyk57fo0AFmQIHW0bLhtGiqFC0LdqpFE6Gp4u9O3/x4D/XPO8nfHCDr6FsKuS4JEndV +fS9Q3QPeUJiS/rd7rX93wObzU84054T3QCBvCB63a++EOwtWBx7hmfZGrgdkPh6Hdxw5qXJG +yBKvk9zyjuN4IF9NUGv2i4HRrs7evq77zXWpTVWi21WSjua8sYEno4OjfX3PAWx0d3e1t98b +HFROrqGUFcmDrqcTst7bW02PbNwyVHWEGuQIJLwYXPGp6QkOnrX/difpq226O/bTvAJin/a/ +UJru7cqzZ8OdD54+lzllhbDzjl/2BiiIIkuOX/b4dgfpmx90r1uGt95ZaRO3Ejw+SPDgluoZ +x2OhkBpSKHIpRaxFEeBpAhRdDEXn0GU7uscODE2HCIvVCGxrp/j+4SleXLUqgYOmCjRpUHx1 +CFqoEixNiqVLcXRew90nFQ2P8PpCLQNxZUN3Q1uvNp2tQQS8AahGAgUco4sA2KAp0LomTYii +SP95zPazHXqn1A3cPJxiJV6xQpfOjtrZWai1vLzxoSs3/ygp/Dd7rf5w0PbXKlZyEGIGCOSv +591CYioGht7VN90bgsed+naWiyJ4LBVADIBHLACPULjF49Dh7cdO/HjS3sp+YmK9zBzxzsFD +KUp5l9Ld/fxBVz+8nld0R4su1iBJ4VYODZL4mGz0xJfbdL/doWdhy2nv6FZa7N1Jb99Ab++A +q1fSwVOOJy667pT1ah09Z1JS1rSq87xr8Kirq7O2tn5b5V5371BP39sfIfvBgUcgu1CLEYmm +C7CyEOhYSAU4mgBQAUpfpEGX4CmcipqOW629WlRWXHJjd98QzVSsTpFgqZF4iBwEcMhTHE2C +o0lRFH4QK+fFyLSJfYylS+Kz4Wn/0HQNIgtHh86MowvhqeI0qXw8jYeFAplKNIj845fN6cYW +ApZ7gsApgnWzqbZw0Vu91dbtKy7eqx38axXL3x+wkW8D+c99NwEYgATrDTzam++Huwm8X00S +B8CD7xaRGJoZH5wGNCE4HSi8Ds0cF5IWH5KSEp7taOx+4LtDx3aedLR2mpxcR/NVKcFjoahe +EyYVtLyLM9958LTm9iOgYEVp57clAOMfdvV3PXoG1g3NhMcuuKvpcE+r+23bZwC5c3yvQ9T3 +rqptUxrq/Uh13f1r5qIjZ+z+voN4Ts2qpfXBas/wrsHjbc1OOz4xnZF/x9gm7ZptWnbhvYm3 +OnTigwOPxrYez8A8DQIHR42QRUoXo+gSDDRviwQn6xZBEQXSuNre55PU6/zyuq7mtm4tcrgm +RaJFlUKdLDSxbEY5KR6ABzT3itDCKX5wYt4nOD0wNO/ZyKypXTSKIsRDaSCeAXiDoUlkhwhA +YiyVf90iMMjXM1boEcmxiRa61VZlTU+9pqodGBqPyKg/z+QBAgHUgRDIHw7abkf7F1TfXz/g +0dnygOMs9rEM87UKBepjFRLuwBd7RoHHBSqSqRBRzwihhzTCO+4m3enQjqM3DCwmJ9dXz/La +wMOZnff1JQ9YQTW6wUpO8FDcxOpFgQR5aliDIsuQvcAOCntB+uHRlzkf5OGDeiEg18G7wAqw +obKSeovy4sXog65+qgH72DnXQ6dsZe4cupfRtmmZVUrjrE3eZCBZOC/H3IY/s6aAwx8EeFTX +P7Z0ycIzEnD0WBw9DqzcdMupbXy8OcFjfHK6pb1vcmrO0T0BpctGk7kYsgBDEqPIQixJgCVz +MJRwdRLL0DrOn12iSeM6+Wc7+2VgiCywCwsFRedrkAUokgAFlhQeisxBk3gEQ3Egv9TwRqSh +eYwfq1iPKUJR+GAvmsJBkbkaZD5IDJZ4MkvfMMjVPUjC847l2UtZjplJwp6ezlXdPyCQkJiK +z085f3TQFsGPjw7ZAfx4W60fbwgeD1ofRvnGhznyw51gFYQ78sPseeFAHXhhMg1/paHQksNx +ETsYud00tRkeHllvGWZt4DE8OmnikwZsKEqte21iol0sqGrf50MBHngTIloKPAA5wKcFioAE +YgGwEfwEZoETAK4AP+Hz9DwdAgeC9DBCg5/gqJWYTimrla5Hz4LCsxkYxhlVS6Eke3R0QmmT +D07WP3hk5t/F0KIBbKApyHyFkZqMBAw1yp9T/uDRW3DX/4DAIyG/ecsJJ2nGLbD+pH/IwzfG +0Mz3+o1AM/NgE4sgU5mamQeYWgQam/kbGvuYmgcZmfgZmvqbWQTDe8EWsEQSv1w3CzI08jU1 +C7x2I8Dwmp/JjQBTK1l6SyRx4HWLIDv7AE6of5TQRcK6GSvxrKvOGRtde89XeePD80zef+2z +kW/9CIoq+8XBY2hgqKm2ub6ysaGyCWijbLmMQgkqmhqrmybG1mMZuOauFrhiXUnlDtfX7/Oh +Vn5vawAPefqCcUIePOTbMQCEkB3j3vx+5EU5quU1H+lT4x03t0EBwA3+e3qwV2kQJXi8XfAY +HJqQxtdrGyQsOl8hPBOQrlFcRELDi8E3+pN+EODR2vFkr3bwH2StBI6s3OK6jpb7fWB7d09H +TXlmRUFCRWFiRVFyRVFSZWFiZVFCRVHiyy2FMi1KroT2ylYKk2QboSW0EayAZUGy7EBovVx2 +CLwuSw+dtqIgsao4qaootro07kF77fzc26lkO7uf61hH/e6A7b/JBsL8h4qVbUj2LwseG0ze +CnhEZtYT7WLvPHiqek0IKmKwhH0YwBKurEFKeDtyOPjeB1vkE8OSVNCCnAScHCzBmeFd8DrY +CPYiG4Miy+DzAIUdM8DNIFcEipy8oPo+fGYk5VIXXSF4wIiyDHiAdRg8wE2CXW/Fb0QZx2N5 +GSgIR6qtp3HWSoMoweNtgcf0zGx+yX1DqxSt182SjKXFgDSG1im5xe3T02sMT7f+wSM8rupP +h+1eumXuu/nxEQdeUs1Gyoe9/UOgAP+dzPv0P/fZ/OOK15uMulWCx1sHD39pKVwFg42I+8cy +4AGwAe6VAIlhxwkYDwCNgO1gC9gO9iIHytfyQMEuGDxAMuSi8DkBXSwKHvCZQRokJdLTsehF +VwIe4FrypLEQPMA5gWXmX3W1AH3z7hUleCwvoKpCqq1eHklpECV4vBXwaG7rc/TJx+nH4/Xj +VxgpFy9LbO+d33h7LS1v6xk8BobGz+hz/vDKHeJPR+w9BYUbNTcC2PjyosfLJz1sB3BLCR7r +CjxA9SpflSM9C4vW1/JumWAvDBLICtIQoQAeCp4bCmNDwF5ADvOLdW0onFne7URhF3x7y4AH +zDkwosi34cDgAQMMAlQNd3qQvbBPyML2FiV4KMFDKesWPPqeDrPE1Th6tCYzEQkRs/KJgTQZ +ieDYUEFVd+/qHA/WLXiAivhv593+bbcl3A6wHe3f2z+0sTMkeORPjjnAjwxwC3NDsobJX5Tg +8S7AA8ED5AMf+fZXAA+4yoY9MGGFE3Q+fg43WSiwhEKLx8I7AZcDJ4EdSuEECuABswTAIeSK +8D2AA+FdCy+6FHjID0uBIUcBPORHtSAkhgi4B/hYedRRgocSPJSyDsFjfGJGGF1Pvh6vyUzC +0KLXPhUyDUBLMvFafFxq88jI5AcNHqCo3HLcEa5APz5i/+aeDx+KDAyNg2/Jjw5BjTy/+dF6 +n3bwatlDCR7vGjzgunsp8JCvvuW1qLZjYWW9PHgkFbTAJ4d3LQUe8M+FV4THnix0fF2Jjwfc +XyPfdiHf1QI7iiyKSfNyPU1K8FCCh1LWLXikZrfoGKXj9OPWjBw/n5w3FgCMiV16SeWDD3TK +y6TClo+POsC15+ennN9FlK11Lt6iYtgC/77bYrXsoQSPXxY84D6IhScE4AFOuLD3ZBnwUOgl +gZ06FoIH7Nu56KASOOXCi67Ex0PhQRR8POC2FPBQi1pvzSN9lOChBA8leLwf8BBIiy9ig9UJ +QqiHZZWdLEs6fjDiAYG4BRa13fvAQggC6vhU1tYB6tzv1H3eXWjxdS6gYN96wmkN7KEED4X/ +4NomiVszeMB9Igu7IbqfDir4fsB191LgAVf0CE7ID25VAA/AFUuFHIFPIr/rtT4eyE9wWsSr +ZH4x51LYlxW+NyV4KMFDKSsHj3tGW3958JAUnlT1PKPhfxEbCk17R4t6K+wBOX4wEzUZMfXN +H0yLASgV4S/9f9ttuYZehg0mt9q618AeSvB4c1EIILY8eMAOFSDrIrChEE0LpITbHODqGD4n +EqFrKfCAPUngFg+wDrc/wAkW+q/Ce+VHsiDri150hcNpYSPAD7IQPMBd7dcJhkEI3CdIJh9b +bG2RS5XgoQSPzQAedyj/edfgk9G2dzJWYuXgcfqq72kN/7NovwNn7K9oc9BkKeYtNX1gadH6 +FhmJ6fXNbX1v67meDIwVVz9Ky+1IzbuXnHM3Kft+Qta9+MzW2PTWmLS26OTWqORWaWKLJKFZ +FNcojG3kRzfwoho4EXUsUV24uC5EUBXErw7gVASwKvzDynxDS72DSjyCiu288y/qiU/h+Kfw +HDWiyNYlz8Y1z8Yjx8knK5BdWF3fNbf5siioAcWpDda++ebuee7skqScdpm178ZlAGu3xaQC +U9+OTL4tTWgRJzQDUwtiG294ZP2/281Byb8LFRAqrAzhVwfyqiBrh1f4hZX5hJR4AWsHFrsF +FLv6Fjv5FDl65zl45Nu55tu45tp6Zjv7ZfEjK5+/2NQRnBRCpgPwkB/foQAeMCHAXhZI44C8 +pwdYh5kEHn6LbIddMZEmBYVRJAjSIInBXiQBch6k3UMh4DninrHoRSMz6xc+9aKdRAjtwH4d +CjihYSoGFwKKuKTCF1pzvHQleCjBY6PK2PhUfHqzuXN2fmz8s3SPyZ53Nb1OT08PoI7XtvRC +LR5qPsfV/LjS4qs4sx9P255WD7iqJ3wb7AHNm3wOHfQvFWZq5psOsX8+OAY0r+weS1oRKCwL +EVaECCr8eRX+3FJfVrlPaJlXSJlnUKkHqNH8ih39ihx88my9cm56ZFu5Z1q4ZNxwTje1zzCx +SzW+mWJgkcK8EccwjaVdiyMbxxAMo3X0o7XokXhqJJYsRRMlV3WEqjpcLF2qdy2eYppAMooi +GEZ5Bufdud+3eTLqg+6BxKymYGFZkLA8RFgeDFubU+obXu4dWuYJrB0IWdsFWNu3wN4Hwoab +HlmmTqn7cSH7sSFaxlHGNsmGVqlM8ySGWaz+9VjqtTiSUbSeAbB2lCYtEkeNwJAkaIJEVZuv +psfDMyKJJglU0ziCQaSzT5ayoFiVgHpZoXsFnjFtYUr57Supo5eKCArOo+C8AY9/WdjLs8zN +vM3iTnb1N5weTgkeSvDYeDI1PZtb3G5sm/5y6hP9ODvPvLqmX7gnAoDHqau+J9R8jaxi9S2k +Ry57aupzVI5dP4cKQIF6Ya34gaVFY2hRZ1ABX/+g+7fvtGISit7kJp8+G4lKqwEaKq0KldaF +SitDxBXBwppAPqgNS/zZ5T5hVd6hFV7BZR5B4Gu6wAmAh2++nXeejWe2lVuWpasMPBzTTezS +jK3TmObJDNMkumkc7Xoc2SiGYBClw4jSpEvxlEhQFWroCXE0Mdk03tAmxcg2xRCAinWKoWWq +wY1kM7u4pIyKDZ9RR8enK+s6+fEVoZKa0IjaUElFsLgyWFgdwC/355b4sSq8Q6u8Qsq9goC1 +i1wDCp18C+198229cm+6ZwNTmzmlmzikmdimXbNON7BKZtxIYZgmAGsD8CAbxugxI7X1I4G1 +cSCfEMUoglCLEUG3SDSyTTWySTG4mWJolWJgnhzCz3wxOKIsNN6dwPFA3u4UgR+6KMFDCR4b +TGobHtt65uHlYnPB4S8w1Cjv0JJ7Hc9+QfA4rQ51tZxUDzyHZx9T9ZHEVRL0XX48aXtaIwgO +kL7KcbVROHrMZS32nmPmX36v/eX3Wl9t04lNLF706kwmU11dffk77Op+wY+q8eEUQcor82ZX +eoeXe7FKPMLKXIOKnQLyXYIKwEe3o1e+vW+urXeOrXfGTY9MK9ccS+dsC+dMM8dMU7uM67Zp +RnYpBlZJ9BvxFJM4qmEcySSGYBytZxSlaxipox+pTZPiqBIcVQoqQQu37Jtu2VYuGaAatXBL +N3dPu+GRRbFI+vG800lVZmVF1sTE8EbNqI2t3cLoOl9WiQ+3yJcL7FzpzSrzDC/xCC11BowR +mO8cWODgDTTfzgdYO9vWK93aHdgKmDrb3CkDmPqabaqhXTLTPBGYmmYRRzGOoxjFEa5D1tY1 +itIxANaO0KJJsVSxJj0SoJ2VR85NVwgOLV0yLNzTzN3TaVZJ3x+kiETc4aHHc3OzytLjrQjR +LjYosgxxhFjYt6IUJXgowWPDyN2OfoAWUJgLxiKxuUA1rWWQpMWI4Uhrep/+AtUZAh7nsCEX +tNgnr/piqQJtpvikmi+W6HHiipeqNhdLjVpJzwtIA5BDnSA8dM7h2x3Ev/4LD8ADUMcy4LF8 +HI/Z2fmcwmaDGxIthljXIEKmIl2mWJcp1TOI0GFEkI2lZBOpHlNKvyYmG4m0GRJNRoQmU6LN +EOroi4Fqv1xKtekSPFhnCPUMhbpMAdVIpCmbpB5Ph1QTmndejKVJcHQJ0yre3ivPxb/I0TfP +0bfQObDYyjtLlR72zZEbn/xAPqlmGMF3v9tWvfEy6vjEND+imGjA19IX6RgCU0t1DYR6TIku +M0KPCawtpV6XEo2lRKZU30RMMBBrMaXA2lpMkQ5D9MrOYmBnLWBSfTGBKSJdE+EZfJKhkMQU +4WgiHLAz2EWDTI2TWRucwcQ+GRjZxa/Q0Tffya/QOajomkvSD+ds/nGQ4uflkJMa9OzZBzyc +ua6ubv3MOCbvsyHv3aEURPLy8gB7rG0gkhI8lLJOBIAEW1KtyYhe0bwnBklUs6T65p5fFjxO +afidRgefxbGOq/rYucccOONw7Irn0Use0HhbSuQy+AGQAyxPqnr9S4UuQw4tGDnWDB5jE9PB +7DwtGl8DmlBegCFLgWLJAhyFj6XyMWQJmiDgSivSS+7p6nOyS9p5kSUoPQ4a4ARVgKcKcFQh +jiKEllQBFloKUSS2tVMCL7oqkFtcVH6fzBRiyUI8DdoFlniqCNSJoH7EUkQE4wgrt0zP8HIv +dpWRY8p+VafPdutv3UX9dDf5NMYsXuzdWl+8wfLq7Px8GK8QTeKiKMDakHmBYsl8HIWHpQjQ +ZIkOXZRTci9EVMY0ldS19lk5xWkQ+WiqCEfl42nAwiKZwcEKpGhSeLiwtKDqAclIkJrXFhFb +jSNxobdAg1Rmc8AhIpzsKNqNaHuffC92pVt4ua6p9PuTFlt2Uf953CA4wC0z2r3v8QfcF7Dm +OB5KUYoSPJSycpmbm+vsGkjJbnP2L9Y1gsJZrLyrAqTUNUzwCi3NK7nf0/emAbqHh4dBoffa +Dy6BGBrVclLd92WLh7rveVwoWDmh5n0BzwLU4RWShdFzPXLR7RI+8NRVH0AgKDLkOAq7j4J7 +1iCKz6IDfzxh9Y/dFMAbCsixNvDoeTJ0zT5Fg8jDgLqJIoaoQKZQVUURYWhCDJVLNhTdbu/P +Kb2jTQ4vrLjf2N4DvrLRZBGWJoC+r2lQYjyEHGI8BXxfC9AUblRSbUR8rVdwQf/IlINHogaB +iwWVIJ2Po/GhxDSQHtSbYqwMRbSNxIfUXb7Yy/x0l/6WPQZbdjM+3UU5jTaJk3i2NZZssHwb +KixFk4C1ga0k+Jd2gwwIiAJDE6DIbBvn5P7BKX9Orr6x8EHfcGx6HYbAB29HztpC6CiKGE3l +6xoKbt3uKavtxJP4qXl32h89pxgBehHIrM3D0QQyzIMOAVfEUoRa+iIck7/9jBUAvE93MYCp +/3WMERTokhXr2df9AVfcHxB4vPkMa0pRgodSfhGpb+mx987D6cfJHDki1xwBA89IxNCivUKK +73Wu3fdjhcNp+aICBDwuQl0tPgh4nMeHH7/ieVIj6CyOfVkzOCa59NRlU0Ag59CBqjpcCDlI +kqOXXP+xiyzfq7KorhY8OrueE40TcFRQCYo1IQzgQ1RAA5WgVIMq0SAJdajs7KK2h30jTEvw +U3DdNubx8/GEjEYckQN9sNMlGJoYow9qOjGGGgFqQ3Vdtk9IXv/QrLl9vDaNn1N8p6tn2Ngi +Aq3HAtWlJtTyL8bSQTUKDpRioZpRqE5mf3PUdMse/U9/pH+qwtgCVYi0M+jrEHg0vTXwCIos +W4mD3wqTLQeio5PLDGFw9cuXWVukCSEBXxMyuBgNW5vANzQT3+16UVx1H0/noEn8AE7e87E5 +d/9MlC4bQCCWJsWAVwNZW4IBjEfipmTefvx0zNw2CkMUMM0i7j8aLKm4r03jYEkc2SWAtUUy +awNTi2VtJsKzWgH/s5e5RYX+6V79T3czvjvGCA50zorzfNLduXnAA55Sdv7VKFRkJKyCwLPM +v+EIDnlZGCXjTYRoFwvPcrvo3qSClivGAvkHAQoHDFn+qRd9cMBLSFx32GtFfi84rbJHSQke +G1si4mrVSZFYesJbCYIBqnUtZpImI5otqel9shbfj1WCh985XOhFba4MPMJegocmBB4whxxX +9SZdBzfGP3bF8wwq8MhZh5NXPH7YbwiQ42/faS2DHGsFj2e61+IwVCmaIkFTRWiqEE0TAdUg +81V1OXr6vNScxt4X056BGSgCC02XaJBDw4R5/cMzPHExmhgON5VoUIUoCk+dwEURw3xCs3ue +TSVlN2JpfA0SX/+GuOluf9O9pzdsIzV0wtEELpYCUEoIdSuAb3zo412gTuZ/fdTi0z2Mz1UM +tgLdLQMPzHWFFg+4mJUvP1cl8MzjbyvZ8pXLMuEcnf1zMFQJmiJGwdaWLa+SeGo67GtW0vrW +ntsdL4wsAOPx0HSRJj00t7St68morWu8mm44hgwZTYMKdYphyKzY1PonA9O+rGwUiYOigEPY +jj6pfQNTGQWtZEOuug4LS+RiqdALwlAFaAq0BEh5Viv08x+NX1obgMdx/aBA5+zYTQQecIwL +OA4nTAKLwgAcv2upKOVvAsBvi2SQwB1L7f3irMvLXPcqYgkcjmyZp170weEJdgFswE6z4Cj5 +eGXzr4KcKEfuKMFjA0tJZaebfy7ROE5VDxS20rcUgCtGk5lENUtOSG8ZHZt6d+BxSt3vuLrP +cUzwCTWfC4uBB/h5ChV8XpN9QtULAo8z9nuP3vjbd5qvRY41t3gQriWhqVwsmYuicNEkLo4M +KclQ6B2UVd/yuK2z39EzGaUThCWGY0lQfYchBnKEBY+fjKRkNxmZizVJoILja9MkVs6JqXmN +j56ORMRW4knhGBIXQ+Kr6YXRTUQlVe33Hg0KYyqMzaO0SSI8iYcnsXFkNo7ExlPC1UnCbyHw +oG3dQ9+qor91F2PLLqjFI/bn4AF/3IFyDw7MuNqRAusEPFz98zFUHqAvDWBtChdL5OEpXAMz +KV9a2vHoeUlNB9NUBFmbxMaSeShiqB4jLKegpatniCUsAjgB7IYhCoiGEZHJNfcfDXj4panr +hGAoHByJD96dqm6IvXti6/2nt1r7fMOyaUZSTaIQB94piYUjc7AkliaVe1Yr/H9+NNyyh/bZ +Hn0EPKAWj57NAh7yNSYyC/zCVwZvfOvg8RYFhnAEJxbCw3a0n/xTIxFTl3nqRR/8ODl84SXg +SyNtJuC/udR0ckpRgscGkKi4In3jADefBEfvbC1GjKquWOYL8TZmXtOP0zVON2QEZVqhuzxP +rVA9Nf4BwCOSsnP5ZP50IhS5FBW4+zD9i2+OHbrsdg7PuqDNO6nmowAe5/EyIIHB46zDvuOW +K6QOoLaekVevsRfqR1u+/Lff/H6RXUZs45sp4Ns5p6g1q7Als6A5p6gJaGt778TUzOzsfNWt +9uTs+oyC5uyipqzC5rSi1rSilrS8+s6u/rn5+Y6ugdzi25kFLZX1j/uHJ2cByTzsycypTs9v +ySpoATVmelFLam5dQcmt/sGR6fn5h31DRZX3MgtvZ4JrFbZkF99OyGjUM5R8e9hs6x79LXsY +W1SYW3Yv3tUijwRwEEX5XLEwzhJSxsJl42rBA5xNoSG6/8XoSr5VlwcPN/+cqMTanFcWyMpv +KihvfdgDufcPDY3nlTQn59RnFrVkFTUBK6UVt6YWNOcWNw0MjU/NzTe0PAavILuotfFu//js +bH3D3bSs6gzoVM15BS3ZBS1phS1pOdVVt1rHZ2bHZucBgeSWtGUV3s4AFypqyS5p4Ugrz2sG +/d+9hlsA4O2BTP1TV8vmAA+4uUOh7wMOtdFw5yeHc/gTXmG2FLhCBxuBLqyIwRawXZhSu0xi +uBsObEdWFDpHkCwKbgY+dplmBBg84G6RRXth5LcvBA/4qRV8ThZ9cDhkuoLIB3tfbaOHcjjt +xgMPpP8OaFb53aX2LvXBCPIP+JsgLA30irFAIXMiPYYLFS7/FTauoWF8Genre8ERZOiQ3Y1u +hHoGplq5ZGCokWoEyZtHHcfSo89jg3cfMbe/uA95769Vp4P/B/yJBOd+tXwyL9QJGXgEHD5v +89dvjx+84HTggu3+K67HVL0uaLIWAQ81rzPoVYPHD+csPzu+iP6f//rs//n/frtw+1dn7G44 +pz8ZGJMz8KxM52ZmJydnphYN7gA2gh1TUzM/3zg9OTM5Mwv4YpGo54BipqFpdMEu6ChZCmjx +fGSWcSPim/1mW3czt+yR6S7Gp7teAx7g8wrJwDCEyM8nLl/FIJOVyx++TM84vAvO4fLlKrgK ++H5UKL3lqzBwcviWlgcPF/+crt4XCuacm5+ZnpmYmp1eNFz8jCwm3vT0zM/tCTBvZn7xtzM3 +NQNeH7A2/Crn5169kbqWJ5fwAV/sNgZ23irz4/0Oci7dROAhH5B8Xm6ONrBRfmYTuOJWmMEN +mUhFIbPBdS6yC8mi8BQtcGL4JPI+HgpgMP/zaOogs8EJlpoYDjkD3LghX+PD9wN7ZSwDHvBT +K9zDwgeHky11A/JZfZm/lRI8Njx4IP13QHVuRi+1d9GyEe4KRA5HVCHxommQbkH5G4D1XTTB +3bvf4+4dRTHwi00s9Q3Jum6bekVXvDb8wMKRuDRZKsfMv/pB78vvdezP73h34HFI1XP/JfdT +GgH/2on67C97D15yOytr34DB4+RV3/P4cGhFzfsMOujoasDjn7tJZLPwVYKHvZlLVs/AwiE5 +c9Pzc5PTc7Oz8wtAYg7CkrnZqempubmfMAPUnmALAiNzcoeBmhWqOmdnZxYwyYvhWaZZ1DcH +b2zZQ9myl/aZiuHWPYwtu6mnMddipZ5tjaUKpRxCs8hcmci8XfDMnnApDdMIUhpPTs0g4LE8 +CctXE3CRDrdyyL5SJ+QvsRA85Ge7WBI8AnI7ewcXWntybm5qanbuJdYpWBtg3szM9OTcPDJ/ +HECL6ZnZn78SBFQAAgJrQ1afU3h5dc1PLuODv4BaPChb9+p/tofxr+P0oCDn7BivJz0PNgN4 +KEQvR2pY8E7lS0v4LSuAh3wrB9xcAO+Ci004Q06++gMsGsFDHjzgae6RNjT5yWdB/jT3T5cv +k5cBD3hFng3gQCLw9uXBY2FU1YUPDm6A7Bi3EvBYeW+LEjw2NnggzkUrAQ+YruVhA9Y/HbZb +LXjIJ3h3gftAndjY/EAozQX4YesiYYlKyddjL2oJ1Ffs+IGhQsihpsc/cNb+2x2kL7fp7Tqo +HxiW+Oz54MpvYxU+Hup+Z1CBKuedVM45ntEIOHrJZfsB8hFVz13HjY9c9riAZ13U4rwJeOw4 +QI9PXnwYyFI+Hh0P+w1uJkck1Kfm3E7Jbk7NbsnMg7Th9uPBMfBRPVddfy8hrT4puyUptyUt +uy0ltzkprzEltbG2sX1qdn54eKqxpTsj905R9f3uZ8OgzO189Dw141Zyegs4W3JOc1p2a0Ja +Y25R0/OhCQA3dx4+yym6m5x9OzWnCZwqLbc5JrlJz0j87RHzrXuon+9lbFW5tkVF/887CCeu +GsUsAA+QkeD254Vfi3ApilQrIKVCsQ+DB9guTx1IYzhQuOJQKMPl5+fqfjoof4m1gYerf44o +tjYlpyU1uxle5hW33n3QPzE7/2JkLLe4GZgrKfd2cm5Les6d5LzGpKzG9IzG9ke9gDKePh0p +r36QnttW09w1MjVT3/QgMfVWSmYreGvJwJ45zalZrfFpdVV17RMz8y8mZ2619qTntcqs3ZgK +rJ13O1xUeVEr+IsfDbeqUD9XMdiyh/H3g5QAf+esOO9N4lyq0B0gX8MiY0CQul4BPOQFnATJ +CXB6hV4G+eayRcFDAU4QWoC3I43V8CGLdmEg/wI4W8pPm4sw9vLgocDhiz74ysFjGUZSgsem +Ag+gCsXvUuAB8p58A4V8Pi+91blw0kbk5DBpILowzdsaO7aUDA2P5+TfMrEMu932qOPhM5ao +HEORXNISvtbvFCCHbJiq2z/30L78Xu+b7brmNpz2+6uO37gq8DglCyB2UZtzWsN/xxm7A5c9 +T6MCv/7XuUOX3I5q+J7ChwPwuADAQxMCj7OY1YHH9v201YJHZ9dz3evxaAIXpcfR0AtXJ4aj +iVygegZCJ7/UkpqHdzqeefllXdUKUyOwrxL4akS2ml6Ad0DGna7+klsdzt5pJKYAo8fVovDM +7aLi0mrvdw/EJFVpkdlXdcM0SKzL2sFMM0nZrfttD57xRGVMk0gckYsigKuwMAQ2UBQpTJUS +/u1Rs627DD7fbfCJiv4nO4h/30e4dt02WeLe2lC0aFeLfMsDXNzBzbzyRa5CxlNo9F4GPOQP +RNKDjdvRfvKXWBt4OAfkA2tr6LE1COFXieEaBBaGxKOaiIMFhU33ntXc6rpuHn1FK/QqkXuV +wLtCDMOTg6MSqu/3vUjKbrxhF6tD5WF0uUSmQBhTdvdhv29Ihrp2KGRqIkudFH5ZK9jZJ7X1 +wdOqhkfgrZGYYiyR88raLLQeC0UJP6Md8MVew627DD/bw/xkFwmlZSpmuaVHuPR1b4oAYgoZ +QL6G1bSKhOtuhAcUwAPkFvnJYeULN/irDexFHEWQnj5wKgQJFMBD3r1T4aLysU+XKkXl8Rvh +nKDIMuScKwEPOP0yDw4eRAkeSvBYLXgo0PKi4IGMn1pht8hKoOK9gcfLFvvBsbr6Dp4oa+DF +WG3DA7eAvKsE0WUd0VJ+pxha1Cl13237DL7cpvvl9zoEmldl9Rqnr10DeFzQYoP1g5c9jmv4 +nwIrF52OqXp/+/2lb/donrjqe16TfVGL+3bBYykB4KF3LVWTIoVia1P5KJoIQ5ECRZHEV/XY +enRRQkrD05FJX3auBpGDpYlRRE4AK//Z0FRc8i0ijaehx0FBAzaFWLIEpcfHEoKcfVMe9U9k +FbVp0vgYMs/AIqLtwfO61scmN6UobS6KJEBT+WgaWEqgIB5QFAuBOpn77THTT1Tof95J37pD +75iaoZO7S5TII5bnfLthcR8P+c86+Y9N+f6URVs84C7sZQyyFHiAlc7Hz+UTKAAGcubXDact +wkPWFsmsLcRQJcDaGkSBuh7byCymtuFRe8+gsU20BpEPxZmncNLzbvc9n/QLzsYDMiRxgPWw +4FgiIIowYWzV06HpUEEhhsTBUYRg6RaY8WRoKjGrnsjgobT5KDIfQwPWFsqszcNT+Xi68KxW +0H/vY366h/HnHZT9F5kSoVcU1ylF4vq0b7N0tSwFHv7SUvBm5VsP5PcivpRLzTkLz2i/A+OP +bAGHIOHT4S4VBfBA+vLg9hP5i0Zm1st/0CEdi0uBB9LdI9+CsRLwQB5kqQcHt7dvMefS+Z87 +pSjBQwkeCFqADKPAEouCB8g8yMalQsqsc/B42XHQ2dfQ1Dkp84isrO20dEq7rCO4SpDIR/yA +nEhp0YcvOH+1TQ/oFYxdWmblm1x0beABeAPqW9HmAv7Zdc4B7Nq5n/jXf50/ftV33wX7oxp+ +J6/6vB/wIBgn46DoUmI8VYKjSDQpQqA4mghFF2NIAh0COzW7rvvZhKF1lDqJY24b3ftiMiGn +GRotS+RpQrE0oUnfZCGqIrAU0VXdcGe/tP6RaXOnJG2GqKjqwd2uF7TrInU9LhT8CoozJsLQ +RWjANjLa0aJJ1IniL49YfvwD4fsTZMZ1Kz7fJ1rkHMm2ys8SDL54shAJkPIcrMj70sM1PpwG +LkWRorX/xShy+PLssSh4wFcB4CF/CcSFD7n0inw8/ApwsllUAH4Ag+PJYk0qFH4NDYyjx2Ma +8Vvv91be6sbp89AkTigvf2By3iMkR12HjaPwNaFQ8xKgWKoUmFqDGBadUtc3OGXhFK9O5Bta +xjzsG8ssvI0lslBEAYYuRlPFwNTA5iDbo+CoZTTpGTx76x7DLTt1D16hBwS6RbAtEyK9H3bc +mp6e+nALavAfXOHEH0v5eMy/8guS9z5V6HGQf62wS8bCwu04OVxh6BPcOoc4HiscBTcygDyp +0MG3cFzA8uAB50bYoxW5gRWCB7j6Mg8+LxvVsrC/CR75Iv9VizT6KcFjk4NHaEyFQu2/KHgg +kLDC4SfrFjxg6e55/qj7ObyemddKMYnRIEkx1Ch4Otcr2pwfT1h9/YPe4TPX+eLssbGJNy/0 +VgQe4iIF8IADiJ286nsGG3JM1VPlvPORqz6nNAL+8vWRv31/CWx/D+DR8aBfxzBWFgxTgJNN +oSJrheDjaAI0XYzSF2qQBQZmwu6+keiUejSRlZDe1NU7TDGLUCODb3YpqAo14SCcVKhOBPgB +fV9TONmFrayIipueqc+Gp/1DM9UJLCwd4g2whCcv0wRf7jRQOUKEo6bH33bU+BLWyMfbJUHk +HsWxiRV6NFTlTk3Jj7WZl2/llu8NhItNZFyh/MgXJH1VUxfsH4IUyEv5Hcknk/9ABlfZjvZb +9BJw+Y8MtFkePBy9c8BTv7I2MAXU7IMFRqOLgLXViRyvwLTBkRk771Q9fWHLvf6iqnZ1Ck+D +CtGdbIo9OOQpNPWbBpVPuS7q6BpIzW1RI7GF8TV9z8YMbghRZB5ibdklwNvhQxelg2tJTmOC +vj9MJdDMOaEeMTz7kuyYgWePN0+RruBaLF/DDo9OwKUWkrUUuiTkd8Efa8jIa+SESH8NUlPD +4AFfdCF4ILlUfugKSHzNKwX5CYjoteAx/6q7XD5jrxA8YGhZ6sGB2IZkK4QLgwlHob5Y+QBG +JXhsbPAA32jIunxb31LgIf+PkA8UqZCjkPTyowyWSvP+wQPIyMjYw67+vieQj6goovTweber +uoKrBOHBc45/30X+apueJtGt98nbmRtxheAhjig+jw0/hQo4qR54UZsnBx4+FzVZRy97bDth +dUzW87L/jMX3+0lQHA80FEDsnYJH39Ph69ZJV/VY4AMZC5GDCEWHFCub2BRUXiiaFEfml9d0 +Nt19SjJgt91/XlF9F0dk4SmRmtSIl/ORQbHQwQc13PQhUSeyA1g5ablNoqiKZ0PTBuZCDEUI +8QY0cxn/1dwuUIULxfAki4jMQOubTiKuRyzfLoJlm53Ke7LKeUPgpo+l/g5vK1MtdYlVBaIM +F5aqE9gYugQHwYMITROjYWuDdWBtqkTfJOLJ87HIxJrrltLRyXkWPwetx9OiRkLmhQwokGGb +RNY1JsGQw/NL7tx/PEA2YNc2ddc1PcZRwmSNVwBOBD+3NtS9haPyaYberq7OUUL3aO7NzEQW +NNJoM4m8C8TCGlZheOnCLglk4DZ8HnnnUrgMvGDAX5gYCT++EDzglpOFpPrFWRfEK2mZ0azy +dwufSr4JQt4DBC6N5Rte5P8ayz9499NBJEoqogsLdgV8UoLHpgWP+VfDyZEOl4XgIe8TIp+X +FAa5KMDzokNaFk3zi4AHLM8Hhnt6Bzw9Ig+fdj5+3vmHfYZffq/75ffa18xDn/a/eFtXqaur +A/+j1/6JevtemNnGAszQYQp/PGV5DArcAcCDc0LNCwogdtkD/LyozTmm6nEKE3JJh/9+wAPI +495BG+cYtC4LSxJjKCI0VQopBfCGBEfhYWhsDRI3mFeRnHdPh8lLKbgXLizBEFg4igAPJRah +KBI05BYClkI0hYemiFAk4Q3HlHBxhV9ocWr+PV0DCYoqwlAEGCofTRGAdVC9oihiHJmrTQ0z +swllh/nEC1wj2Y6xYt+mxrKpqfENXKSAz2oHt3iULhdLFmOoQjRZiqJC0wHjoRYkDprKwdOF +KTl3g/hldDNpWUOPhUMshsjFUwRYYFiq+JW1xWgKH1qS+AG88oyie2SmMDbtNltSjYZj0b+0 +thAFxWYHh4hwZDaBEebgEiTmeMXzXaQsx9QE9gu5nqzNIwr1o3z9Ozw6qYCXCuAKDgQFGkIR +8mO64UBh4P0iGACHFFMYkLLQYQNsWciu4JsRPuEyWLswaJ7C3SJ7EV8R+S0K/UHLP/gyT4T0 +s6zQwUMJHpsBPOQRAo60r7AXaWdTgASkZXsZqJAHYAUyXw/gAUuR6XFrdfUz56x+2EvTJruX +lDX/UncyMzNTVnm3+lY7ge62/5zLSY3gs3jWqas+rwKIhV3UYh9T9Tx0xesiHDJ9leDx/V5K +XNJaZlV7MTjGFeYTGSF69GCiPgsogRlKYIQSmSEERpAe2M4IIYOf+qEkg1ACM4QIaSiRAake +M1SPATbKlrKf0Hb9EBIDHAuWYGMI0SAMOiF0thA4mS4zxNg00M87QML3iuTYSzl22emivu6H +m6FUefZ82MUrXpsaoKcfSKKzAA8QZDaRWSwYmBoYkAQZMJRkCIwZTIRMB1kVNq8uvCKzOUn2 +UsCrIejL3oh+qMzOoT9ZG3ovIQSDEEurwLAg/yiBWwTbJkrgWlacOjo8uDlL9ZW7IihlxTg9 +ufLmDiV4bBLwQAatgC3wdD9LdbUs2qb3xVmXNbRmrB/w6LRXAa9PqHso0H29lDaFpa0YYqil +S8qBU9cPX3S9qMU5/rIBBBpFe1GT9TJkugw8fjxmsRLq+Ho7YfdhRuwS4MHhcLy8vBbb81N8 +qc6HfZERQgk3BFJemJgXLuGFSrihEl6ImBsi4gSLueFCTpiIGy7bBRKEvVoBW8IkYJ0PbwyT +gDQccGCoiBsm4oRCybhhr5ZAofPHSkLTYvxSYzwKsvjdj1o2W9lSV98ijRSIOcHASi+NxoNM +DRmNEwIZjRsu4AADvrIwV2bhl9YOf3UIsHOYmA2ZWswNFQJr/5QsTLYEJw+R8sMSIoJTY3zS +Yr0qS+KHh7o3ecH+5jPyKEVeiHaxqwpPrQSPzQAe83IdLvKNFfKNG8uMatkY4HHPcMtoW+H6 +eU3Pnw/3Pn1hYOJ/+KLHcXV/WeTSl+BxQRZAbFXg8c12ohrO4c69R/eWiEOyVBwPRVvdqy5I +FwAtyhAWZgiLM0XFmYLiLGERpCLZT3FRpghal2khWM8QylS2IvtZnA1tL5YdDlKCXdCBsvTR +0mA3d2cHF3s3N8fkWHZOKq+6LGV4qH9zFi89j2+X5kQUAmtnCovShWEhXi6udk6u9h5eTnnp +AsjUWeLCV6aDrA1bOB1aFsJmzxZBx2YCU0PWlr0OcfFPh0DrcMqCDCGwdltjydTk+LxSlPKL +CvgOAiVST0+P0hQbGzzmFzhmyO+FA+ciXSoKXZBK8Hh30vGg39Ej2cAs9OB5lzOYsEs6vNWC +x9c/EL7ZQTqnZtn1eDkXxxWCx3sQQLn/ttsSZIzPTzl3vhp8pBRvUfFHh2yBWT46ZKecXny1 +sn///l27dh1YVhZWc3D1t7zU1Sl2H6Slpb32KJBGETJ7eg6sQJycnBb+c18rTCZzoU3U1dVf +e+DCo8ANvPaotVly4aMpZTOAB9LJsuhepNED3mXikwZH7AfY8KfDdqsCD3jiRfnum4UzOSrB +Q15yixqPXfZWJ7D2nbGHXD5eRS6FJ4lbCjy+/kHvmx3kPYeZgWFJg0Ojy19i/YDH+OT0F2dd +4bzxt/NuA0PKD/D5pMKWT487AoP87oCtCydfaZDVip2d3TuqLpXgoQQPJXi8CXjM/zwu+mvn +alnziJX3M0ncRgKPqanZ+OSa5MzqqzjbgxfcT2gEX5BFLl0aPHS/2UH6dgeBynS737Gi5sr1 +Ax7QG+l+/tfzbnDe+LuqV2//0GYuZIKiyv942B6Y4jc/WmNuSJSlrlKUogSPjQQesO/xamen +/dNhO0AO8kFslOChQPsrieOxEhFFlahpBzMthLuPmpxUgyKXLgSPr7cTv9lOxOm5Fpc1Xbhw +YdGPnXUOHjB7bDnh+HIqwzMut9o2qbujVWAG3KL42x+tLxkJlEWuUpSilA8RPOblRm0v3NXz +dGiZvcjhyMxZQJvu9i51/kVnEJBPoDB4XAker5WOzidlVbcvaDicuup/Fht85OxPPh5w38qR +syaSqLypqZczpHt5ea3ETWu9gYdCu8fHR+yFKbWbqmwZn5w+o8/5/UFbuK1DSR1KUYpSPmjw +UMqHCx5Aimo7/u9xp9MaPhc12cfOO0Pg8YMuQI4f9tFcvSP7nymGXwCX/te//tXV1fVhgQfM +Hn9X9fr33RawU6XqNeEmcfkob3z4xVlX2Mn2dwdslT0sSlGKUpTgoQSPXxA8wLewKze/7Fan +KLLsKt5333Hrr7fr0Y0Dmlo6lzqkp6dHR0fngwMPIIA0DhPCfrPXClTBoCL+5JhDREb9xs6Q +/KSaj2QNHUD/fNRB6U2qFKUoRQkeSvD4ZcHjZ/XywKhfUGpBUcNrU6alpamrqy81R+e6BQ9Y +mG5JHx2yg+vi3x+w2Y7236heHwCrfrffBqasz085lzc+VP5DlaIUpSjBQwkevzh4+IqL1xDj +QiKR7Nq16/bt2x8ceMzL4uv+8bA93PQB9A8HbfGWEcjMFxtAEvKb/3reDWCV7Ok2Ub/Se5CK +igprmSwMhglPpfRaURg2C86zkqMW/uvBltceBUqMhY/g5eW1/FGLRh4Gp3rt5RZ+jKzkJhca +c22WlH09Dbz2qLi4uIVP944sueiLAzewkqdTMObaLKkEDyV4rEPwgEPcq5uK13Ds06dP/fz8 +QFZPS0ubnp7+gMADyPTMbFpJ2zWvlP8+7fIfKlb/Z6f5F2dczP0zJGm3uvpefHAZDzxOdcsj +d14hziLio0O2v1ax+tUuC7CkOsXfe9iv/GO+Rdm/fz+TyVSCxyYHj7a2xxevOFtZuSrBQylK +8Hif4CFfjsmPdgGlQVlZ2Qf01oAR/nHFC+AH3ADy0UHbz085r60h6P3LrbZuHeuo/9pv89u9 +1vD9/8deqz8ctLvhn65s5XhH4KGc+EMpYWEZO3cageV6vkk4RNu6Ao+gyDI4yCdYsuIq5Qvh +pSYjXpv0PB0ClzioFwJU9ZpQPkbHexNwA19f8ngPAdU3J3gAAaTx5ZdfviPnk/cjdqE5/7XP +BgkI82sVK/BTlFr3oGdgYnJ6YfqR8anyukep2fdSc9oSs9sSM+8mZLXGZTTFpjVFJzdGJTdG +JDZIExrEcbdEsbeEMbcEUXW8yBquuIYtqWaJK8IEVSGCiiBeWTC7PIhVEhBe7Bda6BNS6BVc +5BlQ5Oaf7+qb6+KV7+iRa+eZ7uSdHJlQMzj8E0gMjkw4hOd+fMThD698R6EAHf8/e2cBHsXx +BfAKhbb8WygtlBYpVShWvLhTnAaJO8Tvklw8uYu768Xd3d2Iu7s7cU8IIcH+cxm63V6EEEJy +gX3f+/bbzM7OSm53fvvmzXsnlQGBYMiBgQcmGHgA4eLiAv0F7YAH7G5gZmHAA+vPqSH52kDv +PIekJ6BBEZ3gyeXgEDACGJLOfsECfMmYRCLHArQDs+Vi4EElHT1Dp+5Zz0tci/7+/qUerLix +rQ8w2JfHAXIogx/tikOkB9MMuww8fJ6Q1egeXOHiD7TE3q/Mwbvc1rPEyr3QwqWI7FBgal9o +ZJunb5Ota5WpbZ6hQU5XN05TMU5V0ktR0E8i6cQRtRJkNBKkVKMllWLE5aNFiZE42QhBqXA+ +yVBesTBukSAOoQAWPl9WIf+74iGCsiGixCBLp6zmjn+J4oKALYIcayesNIauyaNTMRImGHhg +goHHooMHvZQb0inD6OVIkvrJ4DE5h+xkAfUvCtpNtnVA6kDnT6GypUwZ72vKI84mMhh6R8g5 +M1SersHZXO87Ax7zLrKysnR0dNNNeFkSAvpu59C8g6zkVSeUKxu6qLYOP3ycmlvr6JNr4ZZl +5ZFh5ZZh5ZJt5pRJdkg1tcswts40tEzXN0/VMUvWME1WN7mvYhSnpB+joBtN0omU1YqUUY+U +Vo2UUooQVwwnEENF5QJFZAJwUoGCEn68BN97wj5cwt6cOG8WPg9GHhd2vLugbKCwfJgwKVRY +LlhQIlhKMTAkqvDpM8qZnOW1Abzx9WnVe0q+7204Vgw8MFlE8DCziHRwcDh7/iL05RgdpS1L +I02BB+QBBC0AeFwSskfwAA0eoGsGW2EPDskkr+IBYrWA7YB1GPx8/Tk1qo5exiQSNMWvFjDl +aUArBJInDjZ+kNUMHAgeERpkXqCCqyOFsAS0DE8MnCdiUQEK2iF7pSPR2mFMVOSSQWV4CHSD +yHVNPjpNgQdMGjXZpepNBPRZ8/uZHBgYuGfPnvk9yUWRjp6hvsFH6JK6pv7gqFI733Q73wIb +7yIbrzwrzxwrt3wLl2yyc4aZQ6aJXa6hVYaeZYqeRaI2GbBHkppRoopBvKJenLxOrJxWtIxW +lAwFPCLFlEJFiWGisqE42UAh6UB+CX9eMd97or5ceC8OIS8OnKeIfIisRrSsZpSsZoSMZoSU +ejj4U0o1lpHH0tEt8NmzcWWr2ODEMqwLwMADk8UCj11/0IGe/Zdtuz6YEB4BYQw8phOYmB4J +Yw5623vKfhAwAEugwQMWAkKAkAARAmZ/A43Afh/040m59aC/3kVvRDVAA20p8ECImwdQsAsC +LWAr2AQbhIlXoPMJkuEFJroFxwJb4RGRk4SnBNZBg2AJKsDzBM2m5DdAfoD+KlQXBddBOVwH +K0jOF6qj0xp4TJbZZHicHOccyXp54NDRj7744fufds4y8SXAiVcey9HREbyZDx8+PKVH/VKF +kO4hF690Re1wolYkSSeColrRRIpGAjaQVAoVUw6WUQsXk/eXUA4RUwZ/BhIUgsTkQ0RJwaKk +IFFisIhsMF42UFAugF/C966oO4+U911h93t4j7ti3twE77sEL25RL268Jxfekx3ngScFaZql +qBvGq+jHqhjEqRrHqZjFCauHXGAj//SnMI4gl58d/OjRIPb+x8ADk0UEj40bj0LkWPnFKrC8 +wy6Igcd0AnthNHgIagZCrw/Yj8N+GfTmVBYDaOiA2d+Qbh1pc/JQCxo80CnhENgAuALKoWEE +ksPP13XgvshACagDtoI6oAJch+ldqGwpkC4gmcAd0UMtyEVBwECGmeBVg8apyl85TEM74AF/ +Wq8UqlclHLJ5pUwmh4SEhFfupaSkBGqOjo6CcxMQEKA18+McJCaxnKTuz8RryyzgxCzoxirg +zibgyC7gyCboyibgzsrvqqofoaQfyY1zMba6zy/uwSLkzirkyiHkzC7kwiHkyk5Zf7lkFXQW +l/c1tku8J+airBemYxTJiXNlx7lz4P9RIbD0uEvwIGpG6lqk6Vql6ttkalikcUo4/3GZuPFP +3MY/BSXkVOOCTbs6mrD3PwYemCyKmJkFA/C4fEMcwAZ46XlGF4GlsJQyBh6vBR4v/hkZQQwC +sC+GvAEV6eghAEBbwQzgAW0jcBiFCkXgOSAtAwUoggYPaGxBdkHXhPYNtCMKwiEQb2YPHvBP +cDlU5cjRaR883lDma1bLdGJpaXn48OGl+6Ju7xly8U4HjMEi4MaG92THu3IBMMB5c+A8OCm0 +4MKGc7+Lc80rbk3ObRSWdG7vH1PUDmEXBptcOSlLD068OyfebUIpXMHCb+/gnto5+IRA9IpO +qi2r7uLFO02AhxtlF9A+zh3syA6OIuxGUAzQtkwhGcRcZDP88Shh45+iW44JbzwiKEFUTwox +68bAAwMPTBZJtLTcAXiw8+hzCsms/N8qCB46xtY0dZI0BR7Q2jAZPJBeHvbRyGgI1e5w7AP6 +QiBbpwQP2KmhnUsR8IDDPWgmgRgwGTwgvVBNSKECD6QyYo2ZDjzgRQGFuW5hOWQeDDzekhQU +FOzZs2fyqM2SEHWTSDa8G6ugOxsgDSEvLiFPCkgANsC5cQi5s+FdWXGOItKeD7pG/CMK+PAO +lfU9hlbxbDhPNgpITFgwJipz4jw4hCjcwiLkFJ1UXveg/x7exT2gsHNwVFTWjUXQlVJfxHmC +PdwpiALax7mz41zZhJ33XSZtOITbdERs8zHxTUdENx3GSRBVEsMAeGAh0N8j8Jg5zTcmCywy +MuYAPPhELC/cYNm45Vcjx1DQxfuFxGDgMZ3AMRR0r42AB4IKcCvs9CFgQKdNdM8Oe20ID2DH +9efUJlMK1XRaZKiFypQBG5wSPBDHUSQSyGTwgBYYuAvingELkaEipD407MAGEdh4b8GjsKoN +XDheO/itHqW/v//SpUtwCGZpibRyyF2CHwfOk2KywLlx4YG6cFKgwoMV58GG92Tlt3Pyyuge +GidpBbDyOboHZAdGl7LwOrPjXTiEQQVoyvBkx3lx4j2Y+Z1k1QLbe8d8g3PZeJ1J6sHt/Y+9 +g3JZeO0mkMOFS9iDHe8JcIWdgiuuXDiPm7zWv56U2HRUZONxkY1HRSngcQQvQVJKDDfr7sTA +gybAA7qmUyl8WaEn9E1XebqayEcT+uUJ16fz2MdkwQSH0wHgISrrsnv/sZ37jyno2YMuvqSi +FgOPGQR24ogBJD6rFm0PQQcQg06kyHMBXSkQ+wPs0+G6gnk0lQUDCvQFBS1Ajw70JFbQJigE +7cMpJIBqjNxS0KeBbgGcMGgfntjkKGdgE2gHlsMdwV6gELQPCqnqU10UPDSogPyJPvq7DR4L +KQA8Tp8+vbRm2sqpBd8l+LLjfNhxHhz/DIhwCHuy4j0ZBdwZ79rpm0Z0Dj4Jiixkwzmy4N2F +ZF2LqzsFCS6M/M6sOE82YQ9WERc2YTdWIU8mHgeclEdReWdZXbeorDurkBuboINnYPbA8FMj +y1hWHms2gYlxHGEXduGXwzqAcG7z2v16WmrTMZHNxwmbjhJeggdROQGzeNASeCABVSYreHGh +Z+jPUJmqJlhHTNCTa2L/iMUVJmY5AB4kzeCNW369cIMFJ6MJuvjhkUcYeMwg6ABimMyjYOAx +syQkJOzZs2cJBVSX1QjhFPVh5Hdl5HOh53dm4Hdm5AXrzgw8dryiLvZuyc2dw8HRZVyCNkw8 +9kwCLgz3LP1Cc1OyaglyHsx8dix8Toy8Lgw8juxCdir6gUVVncUVXWIKXvQ8Dky87gy8zsz8 +tn5hxc3dI87eGQJizqw89iw8Tiy8zkx8jkx8TuyCTrd5nX87I7vxqMiWo4TNx0Q3U4ZaKOCR +GIqBx+KIo6MjFTyjWQJxRUNsFOgoSejKr6yJuNLByoiD/UKGYcRkOrlyDQ/B45PlKziFZJjv +EVZ+sYrWTpLWwOMFKmQ6Ju8zeDS29R3hsCB7L9wvAXwtnj592tLScmlYPFTDREjB8lrBilrB +RO0gea1ABfVAFe1gB/e00oq2kdFn0feL5dV9iGq+Cpr+ChrBclrB2sYhnT0PG1sH7FwSlScK +jayS49Nrex6OVda06psEyyj7yWsHKmkGyWsES2sEyKt7Rcbm9Y08Ka3rcvbMUtWOUtQMVtAM +VNQKkFX1o+dz2npaatNR/KZjwpuQoRZo8cCGWmhD0OCBuGEMj4wh9gr0uC1SeeaaSPTFKUMh +zWNKC0zmJsdPcQHwEJf3AD27mKLhhRssv/2+CwMPTDDwmI0sgHPpZBkdHRUQEPD09KT9+yOh +6Gflkt4/+Lh/cLR38FE3WA6M9A0PP33x/MWLZ6OPH7f1DHb2P+oeGO0ZetQ9NNI5ONo+8HBg +IqnK+NMXPUOPewYfjTyhRBodf/Gkt6+vq7ePUnNwpK9/tH/gURdoc2Cos6d35PHYc0qdF32P +HnYPgfLhvoePCyu7OfAOW09KUwZZjoqhh1oSMfCgbfB48Y8r2ivBY8qa6DYx0zQNyt79dwB4 +CIrbUiazWPnt3n/s6KkLS/FCMPDAwOM9AQ8ooqKiFRNCy/eHoBhg75Mzqfjp02dPxp6Ojz97 +NtVOz549fzE+Pvbs+VOk5OnTsfEnYzMc6Omz50+ePn3y4glYRQqbO0a4cE5bTwDwENl0THTz +McLmI6KbD2M+HksDPKAf+2zAY8qaaIdSbD7LAkhCQsLRk+fNnV/al9raeo2Mgsemieq89ffL +ADxus6oC8LD1S1733eY7TOyTq4FGMjIq0SVPnj2nvCDeRfCAE68Qfaunza8WAGNrzG13GJUd +bUsEJfC059zmdAKHR9GjqHO4sTNncsHAY/bS3t5+eEICAwNp9v6IKwZYumb1Dj/pHx7rHRrr +HRzvGxwfHB4Dbw/w7hh9/KSzd6i7/2Hv8GjPw8cDQ+MDQ6O9/Y96BoaeTjDJ46eUHUfGx0Hl +J89f9PaPdveO9g+O9Q2OTRhDRvsHxnr6R7t6hh89piRgGX3xrP/hWPfgeO/Q44GHYyWVfVx4 +l62npTcdE9x8XGTzMYkfjopsPCJIIColhJl3d7RgnQXNggecvQIL0V73k8FjuppoHw84k2Xe +X4mYQOnv79/35wkY/3DVmnVlNRSkDwvLBmiRlzfFRBXw+G/ceBRsPf0XHuziHlX4yfIVciTF +yTVVVb2kpBz+/e/n5fOJyAFVUFSikaQS8wgeaG8lKrSegwyPjFn6ZEyX2hUdnnTOzyzaVwoZ +7pzZgQr0mFNOopmBOuBo6Zt4toAjIjFA3iXwYCV6LtbzDoSOjo5AINDm/ZFRCxYmBZDUQ0ka +wST1QKJmIEkjUEUnxM49Nb+8tW9kLC6pRFk9RFo1WFYrhKQeIasdqKIbVFTd3DM0nphaTbZO +UNSIMLKKi0+r6Bp8XF7bZmAWJqMUSFIPImoEkjSDZdVAs/6R9wv7Hj4pqe5w9MhU0QknaQTJ +awYqaAZLqQTS89sC8Nh8RHTLUbGNxyU2HRHaeOAuSV41IdQUCyBGg+Ax2WWU6j02g3Pp5Dfe +5Fkt4D32JlksMZks4CtCgCD35Vfrfvpt5y879m/+ZefJv249e/Z8BvAIiYiD4HH4xN2Pl30i +reMM8MPBwWFm8ACfWuu+20SJr/6/VfsOHV++fIWv3+JPi55f8IDWuXmxeEzOV/tWwQOZ5z5z +m68b1XzOUdAntzPDJPqlOKsFsEdHzyK/yoyMjCYnlKEJ8NAM5xLxZeFxZaLMNLG/w+8wMbHF +jZHXkUfMxcY5s6ntYXhcObuQPT2PEwOf6+27dk5eacU1nVrG4RxCjmAXZl4n1ntOXIJ2Krr+ +OaUPiqs6JBV97nDbMPE5MvDaM/FZ+0cUNXYPufik40U9WXgdmfkcmPgcmPmcWHgdmAXsb/HZ +bD0jufkIYdMRsfWH+Lce5+fgJ7rZG8Z463e1N2K9Bq2BB1rBu2LKOB6zrAkFpoGgqox5fcyj +POgaWrVm3ef/oyRbYeAm2Polf7J8hbGV03TgkZOTwyssvX79PrB1284rADxWfLZy1Zq12dnZ +M4MHgI3te4+JyhugE0wsemTFeQcPql8v6NzBzxUGJ4fdDTIzKyW/AV0HlkN7AqiMROWacpAC +ggfY69Q9K8QEAVPCwcaRZwSG8kCfDxxVmYz6yPkjAzFIshhII4gREn058IgwWW1OaQvcBOOE +UNUfHhmDJ0B1UaFJ5chpg0YaW/vQbaLfA+8SeNCI0OZMW1m1iHuEQE6cF8dEHA92vAc7zpOT +ElPUk0XQje2ek4FRROfQo8CYElZBR3YhV5ykW2ltt7isN+s9Bw6cG7sw3MWbXdCTmddGUNIl +r6ytsrGHQPRiF3TlEHT2Cs7vHn6iT45k4bFj4Xdjw7uzCruxCbuz4jw48W7cwp63eZx+PSP9 +3WGhTUf4z9ARlLR0vD0MfBxV74fbDvZ3YT+bhZeZ43igLRjobFZTWjxmrokIDGSExo95+YbC +BEpgYCAAgN/3Hr3FJgiQwzk0m5VfGqCIu0f8ZPAAryklJSUZGZnftu347vvtYMcVn35++jK9 +jIaFlpZWTU3NdODBxYv/Zv2m0IxGQSmNz//3JQy0/t3mXwaHR94x8IChtNApWZEs9tDADukC +9Kon71m9QIUShQMKECdmCR5gK52YC5K9BdSEs87hVthro3EIsZPMDB5IvhjQ3cMwqrAmFUjA +6Kbw0uDjDFAKifIHgQddHzSLzk8HrwtGcUfuCaijah2HbhOeG1Vu36UOHv1Do6o2cTQyOw96 +fRgZGaFLwOO8mBYP1VBuMR9KPHNKKFEvLkAdQm7cOBd2vBsLJcyXKyuPnaN7Qv/QU3ndEGZ+ +B8+A7KC4Mno+Z1CBUhnnRQmWjvNgF/Zix3sxCjhIKvu29o76hhUw8DvLaYV29o+7+WUy8tiy +4dzZRDzYhD05AKjgPdiEPDjw7lx4j1v3XH8+LrH7NL8AQd7Z3iDQU8/LXvV+hNPwQ0Adz7Fe +g9bAA74Z4FtiyjkpVD4eM9SkEvi5hFTGgiHMl4yOjq7fsPnCDeaE0v7te4/9umN/dF7H5l92 +MjBLUoEHpA60HCdYyFgFIn+qqalRectD8LB1dANIY+4eCyOra1r48klS8CO3uPptM9Ur40W/ +JR8PdKo1qhjjiNsGug4shPlcYH2qoRYY1RMJBIrsBft6pBq0ZsAnBT4jcwaPKZPGotfhUcBj +C+pDlvCJKaKKxjPZCgRTxlDldkETxSE2MrpNuAme0nSfJ5hz6ZsLgUBgYmKCMZpOnz4NnlPw +vC8aeKgEsb+0QriBlQl1Yxd2ncii4s4s4s6M8xCWdm/tGPaPKOQVcaqq7zOyjGPD+XAK+Uwk +hnPlwgEC8eDEA/DwZAVNCdpH3y9taB24K+rgEZTb2ftIVNaZDefKQcko5w5ansgFA+o7g/bZ +cZ4Mdy1vs8vo6GoFuOn5O6r5uWjmpUWNj41i/QUtgwfyUoJv4Ckjl76y5szv9rmFVsZkOnMr +nBXrGV0ECIFLWMHWL/mXrX+iwQNNHcrKynBli2SQUmQDgA2AHMhWtNcoAA8+fkPQppQqGTQO +YIOVXxriB9ne621f1wLH8Zjs40HliUH158/XdcA6uhDdvU5OjIJYVNBNocEDSZ6CBp43Bw+0 +5WFya+j0BxA80M8muj7AJCRLwpRJ5ZDbgm4TA48FE09Pz8OHD/Py8sJh0C1btoCvkkU5k+yC +RjW9UGYeOzYBD06cNzvegxXwg7Anu5AXp5AnB56S3I1LyDW3uC01txkn7dI5MK6iHcIt5MmF +82LDU1LLUbK0ICM1OE9mfkd7j8zOwSeSRPe45NqSqh5uEWdKfhacG4zHTjF3UHK7uLEKuvGK +OWhqm3rYGwW46ng6qESFOLQ0lWPdxJIAD3QEsCkjl85cE6bwpjo0ev4LBh7zKxzcvKvWrAvN +aBSVN4ADLnsPn9u3TwCCR2RkJMIV+vr6L9dUVJcR7gPweDERF1FLSwupg3wrAfD46Zdzl29z +Red1/Lpj/8GTlwF+fPnVOjY+sQW4qEUBD3QJFWnMYPF4JXhQyWTwgPsiLiILAB7wctDGCirz +y+SjI5NTqMAD/cWxi95o8pAKPKXpjKIYeMyXkMlktAuWgMCiRbYBvxNr+1h+EQcWXns2IUd2 +ATdWoIIu7ALO7IL2rIK2zIL2JM0wRe0wLpyjjkUcn5gLu6Aju6ATq6Azi6ALi4ALZUXIkUXA +kVXQiU3ASUTOV9c8jgfvJKceoqQdzo5zZhUC6sgq5MAq6MgysRenkB1R3sLaytzfVdfXQdXX +xSAv6/7jsRGsg1gq4PECFRYM/bKdOYAYUhM9ygwtzMgIOFRsau38Cvi02fTjr8iAy8/b998V +VVm3YS8ADzhgAUVXV9fc3PzlH9qGFItH+EuTSHt7u56eHlITeo0C8Ph+yx+AOs5dY/76203+ +iVU//b5/575jCxPKg9bAYwYfj8nggXZ+mD14QO8I+KSgbSOIt8Z04IFsBSszgAfSGnhOgSJH +BAoKXwkeEI2Q9LvIs4/28WAjeaHbRL8ipnvqMfCYFwEv9tWrV3/wX1mkARfK++Hp0+cFxQ16 +Jl6yiiaKShZKKpaKqpaKKpZKKhZQifJmRJKZkrKlDMlUQZlS4aW+rPbPUpWylJe3IMqZKilb +EBXIRHmygoq5kqrVy/rKFooqQM21tM29nE19XdQ9HdViI5xbmiuxroGWwWP9OTWoVJ8qKlax +sBy8WPzjStCVZ67Z2NYHPnzAn+j5LODPn6/rgPdSbGYN9o+Yd2lubj7w59Fr9Nw+cWVHzlw5 +e0Pgmw079x84LicnpzSjqKmpGRkZWVtb29raamhoIOUqGto//LyHjp3454m/Tl28qWcT+NvO +/QJ4sf6BBZpFuMDg4RNTBBRdArpmp5DcnoF/v5iqGrtACdkrHSyb2vqp6oAlWM8pbUF2hzUn +HwvZq7VzENkFPBegPjgHsIIUtnUPwiOCQmQveCB0kBC4CRZSbQUryHU1tvbB1mDj6MsB1IE+ +mcn3BH0m6HKwI9LI8Mjjnv6H6DbhQcGDL2EQNt2dX3LgMfr4SWJuHbgu2jmlJ0+egAf58OHD +VOwB/lz0UGP9/Z0PmqoeNJQ/aKx40FA5sZxYh9pQ2dJI0Qf/KiisoKz8u0SvVFDqN6DrU7QF +bmoobX9QPfKwH+sRaBw83qogARWx4KULY/fYsOXXE3/dTCjt3/jTrmtcVh8vW37x0lWEJQBX +GBoaqqioUJw6/vH0mFJEJGRXfLbyHB3nnmO3bzALmLvHLlu+Qk3HdCEvB8vV8m4Iv1rAzFHL +luJ02syS5v4hGnVWTEhIEBAQQBPIIjqaYoLJwoMHJvMuGRkZWlpaFy9enPJlkpaV98nyFUQd +u9vsQt9MTJgVVTBQek0hkeS/Wrth255jUrpu6zb97p9Y9fW3m67fZl3gK8XA4z2RJQcegDqW +HyTeU/Kl8fMMDAwED9Gnn366iI6mmGCCgcd00t7eXjAh7u7ujo6OKSkpyKasrCzCVAJqTq5j +YGDg+I+gG3lDgc6fADbAO+TAwT9FCJLCBElOTq4pKwsQiKvWrCMoUxLAbdl2UF7T9HXBQ1RU +9Ot132/6ecfv+y8cPse0fe+xH37dufAvLgw8MPCgTaFZ59IpBbydENMH1fx08GL5YBYCnsTJ +zb5yr9OnT0/eCyDQK3ec7lXwSoGziREBFzubvSZ/wXFycr5yr8kz/dE3k4mJCXuuMfCA0tTU +BNDC19cXQQJ7pTCSgA54QK5d+pvpJgfzLQ48p5QYj7yGONldJ8ZDN9ZTL9ZeI8iQaG9EdDAi +ORjLOxgrOJooOJoqOtlr+QeYJwVaJAdZJnsYR5qruZiruapK6RNF1IiiaiRRNRNV+0jnzCiX +rGjXLD1Fi9MTcu3KdYgo2traAE7Kyspmc+aysrLgx0xSVGtq7+/oGwWaU1j5ww9bpqw8ODyy +5ded33y78au1m4VFJcAD4oiSyMhI8KB5hkSflnXaI+3FYn5/i2QQnVEcVeBl8Aifv3QdPkSf +/29VXd0ixErCwAMDDww83lzAa2f16tVUE9aQx3zmbxB+MUWgBpZuk1MQvvL7BbxtXkz4FSMu +yu3dQ1uvKv18kSQpO9OOU5puQDnY6zqXwgVWeaBgBTby7SkiUFAC1qk+jiZHLppSJneIm/9S +gQ3OIJNxBbmZWyYEe67fW/AAnamhoSHo5a9evAGePrBk/JuNl0lUjlfbTiEUUAdQB5VwR9Vw +J7UIZ41IF80oV60oV+1oN50YBDw89eO8DOK8DeN9jO77Gt/3NUnwM03wN0sMICch4BFslRJs +nRJikxpqmxZmnx7ukB7hmBHhlImAR7Rbdox7dqxHTpRbpr2ht4ORj56SmZKUlpGadaJ/QVJA +YVJgIcAhSCNT5l/LyMj4448/1DT1IHgA3fzDD9P9KxMyixhZuWa4M5EVvR8QEj8QS7zjWAZW +tqhmTlnt/v37Nh4R1bV1i/Lvw8ADAw8MPOYFPObWD06ZION18xQj855eoAJOzsHlj2peJDJv +Cz0FbL5k/Tm1N2lwzjf8HRZRUVEaTCr05lJWVga+5clkMui7zcT9yBL+5pL+uiJOBA5FFQEz +XREHK9kga7lgG2KwDSnEVj50scAjzjM3zis33jvvvk/efd/8BL8CBDxCXBJMNW1U5XR4uQXB +T1dISAhcCxpC+PkFdA1NEfBgYmGH3xRzEMesdgp4EBK5PCrBcr1i+nQ1nz5btAjDGHhg4EGb +UtnQtfKIPJEc9Z6AB4zkj4TQnyHf38zg8WIiRs0cwlYjh4YTt2FAfgw8MFkUGRsbc3d3l5OT +A//oW1cYOW8J4JjllPnICHiYSwVYSAdYSgdayQTRPngkBxWlBBelhhSnhpakh5d624Uaa1r5 +OIRnRZdnxVS4WQX+/vsOiBw3bzMcOPgnJzfvdG4erxSlyAYEPFbLpYIVGvz/YuCBgQcmtAAe +VMF70QFkSmrbpzRfwPmMk8FjugOBdmZGl8nAg8SyowKPyaNCs79euBcGHphQCZLITF/AQ1/Q +k+eOmAyHjrGwt7GIj4mojynB11TM790Aj/SI0ozIssyocggeu3fuDY9JAtQBluu/+46RkXHr +tm0bNmyY220U8K2G4HHVpmSLaiZYaR8ao7X/dUVFxSunAWLggYEHJosCHjDJ4JQ5x2E1JEki +Ah4weDU6uQ86fyg6nTFaYAWqOL1UWyEnpOQ3oIdj0A1SHRemMECGjWD6IWQvDDwweTHhFBoc +HKyqqnrh7F+XL1xX4bbS4/eA4GEg5GWI83rnwUNRSouBkRWaO7Zv3+VhG+xhF6CmoHPzxm3w +I3/dsTOjxBZIHUDXkNJWSCWDlc0qGQ29S2/CHQYeGHgsvLxvQy0w6x9ieUDCUwMYCEksQ0ey +ffHPsAgcE0Fn8ppMMmhTBo+K33R0MfNgCnrrRUE72BqS4hmdKnE6goIeOxA5kB0x8Hhvpays +zNDQ8PL5a0BZr/MKMygqcVrq8Lrr8rm/V+CRElqw4ftNxZWNgDpUNXRZ6bnzEqrzE6sLkmoK +k2oyYoqLUuqKU+tK0upL0+u1tbXj4+OHh4enu6v9j568pA4xynKFZDJQuC4bVr/kfiQYeGDg +sfDy3jqXgk4ZHS8XqYZ069VN3VRZNtBYQgUecC8YXG545DH8c7p86LMBj/Xn1JBQdUgSMdjg +DOCBJGdEdsQsHu+tqLE7892U5rspQ2Q10+R21brrqn3PTZvH7T0ED5bbnIA3AHUA9vh9285o +vzQ0eBQm1yLgUZBcZUd2FcWJXzh/wcLCore3d/KNRdxKP5FIAstl4kmfSibDkj16uRh4YIKB +BwYeVJ0+TMQD+QHt0QGgAj20ATYhKYqQOmgfDzR4IIiCNDidZWOWFg/YIPr00DvOAB6T28fA +4z0R0EVGRkbKy8uzXxNSYXVSZXMC4KHO4azO6aLB5fI+g4eLecDePQdg+A52zntyYsq596um +A4/S9PrSjIayzIaitBpDLbMrl6/w8PDAdG+IMLmUQ8z4TikdrqyUTtmgnPHhhNFjyY22YOCB +gQcGHm8bPGB/TWUZgH+SPdPRFg+YWHk24IFYJGYJHq/08YCWCgw8aFNoLY5HWVmZtrb2+TN/ +MVziFqJTVGK2w8ADDR5H/zzp4RsMqCMuKWvbb9tz4ytnAx7lWY0V2U2Vuc2hPtEBHuHVBf+m +/Vo1MYflM6kUaPH4TjF9DTFtmUTSFzIp4E/LtFYMPDDBwGNmWSoh0+cXPBBUgMMZcL2texAN +HsguyFALlXPpdEMtja19cBOAOqrTQFxBQFPgHGAhWIGHmG6oBfHcgA1S0QUaZqi8QeCObwIe +jo6ORkZG2HNNm+ABkOPyuRvXzt/kvS5DZLBUYnJQZnZUYXHEwAMBDx1F04uXrkGf0r17DziY +eb8ueFTlNVfntwDwqCl8UFv0gEfeEtDF/2SSP5dOXqdAsXgA6viKmPqLRtbKCfCgsy+lnd8q +DFeIgQcGHrTJHjSbJO4tgQeaAUDvDPtuHhU/ZLQFVoP9OCiEoTbg1pmdS0G1g6xmM0QnQ0+T +QXSyvQI6l6KPizSIPivkhGELSFgz9I7zGxgEE9oBD/x1NYmbhgr0dooM9oqM9hh4UIFHYlDe +hu83Qp9SY7L1jcu3c+Iq3xA8uC0zAF18RIj/VcRlh8p96FO6SjaVzr7kD71csL5cMmn0yTMa ++a1icTww8MBkccGDahYq7MFh9w2noK4/p2bpk4GuBme7IF05jDj6yum0oJ2Z45KhJ94is2Ze +/DNPdvJ0WrCCbhAxy8Byqum0SFhUsISXg4HHOwMeY2NjkZGRIte15eisiTdtSLds5O/YYeAx +HXjwsOPEJYmAOpra+zds2BTpnfLm4LFdjQIe64ipy8QSV4jFgfWNMlFXLfNWSqeskEoGS1AS +WdGLgQcmGHjMIB09Q6fuWbuF5y+Js32rlv+27sEpy6ubumcfwgvUnK6dyTVfGRwMiV02JUoh +gzVTbsUexncJPIaHh93d3S+cuXTrPBvhuh4tg4eZvDsaPCR4FST4FCX5FFnucLLe4ZISUAIq +LaiEBg+yirO/ecL8goe/Q/RPP/0KfUp5+XBignLZsRVvCB6JaS+jle7VynKIrDmgnTVh/UhY +LhpjmdYaXNrztXwaKGF1rcDAAxMMPGaQpeVcigkm7xt49Pb22tjYAOS4c4GbcNVA9oYVoA6a +Ag99KUcVYWMBNnH6v1lOnz7Nys5VWNNZVNtVXNdVUt+la2Sua2ShZ2zhFxoXHJ1sbGGnb2Jp +YGJZ86C/9kF/XWt/fduAgBAe7Pg33U12Rm4FgpalpluwbfIbgsfp4+cdXX2gT+kfu/amhBW+ +OXjo+FHms2xVy1hHTP1EImm1LGUW7Ta1jAvGuZ9JJX8qmbxVM3uGhHEYeGCCgQcGHphgQuPg +oa2tDZCD8QKf2BVD6WuWMtetaA08rt+g4+DmJUgSyXbuIXGZ+dUdBdWdaPAore8ua+gpb+yp +aOoFWtncV9XcV93ShwaPhvaBxvbBvJKa6IQ0LV1DQZwwCyvbm4CHl034qdPnoU/p6dPnjTVs +smIq3hw8jutRuOIL6WQBp2LH6JqjE3+umJjbQvIpV/GvOG2U++GEScQtgibe/xh4YOCBgQcm +S04KCgoyMjKw+7Ao4CFxkXz3gqzYJWOpKxbSVy0WHTyMJdxl7mly3uEPjM1OK3mQXtqaUdqW +WdaWVd6WXdGeU9GeV9XxJuDR1DHY3DnY0jXU2j3c1jPc3jvc0fuws28kLSuPjxOnLmvgaR42 +S/CQECSlZhUC6nB09Tlz4gLM1fKG4FGa1wKQgxIaXTHtO/nUTYppa4mUebXr5VPprQr+J528 +TS1zHTH1q4nJtnu41AkEQlNTEwYemGDggYEHJq8lWByPhQeP9vZ2sQtm4n+ZAfCQvGQuedl8 +YcBDmkVv/ZqNU4KHIr8xMx3XpctXhMVlTW08olLLDCzdzvx1TV7daAHAo+FBV3h0vKa2LgMD +I+NtFgNlyyj3zJnBQ4hfHPEpDfdMnhfwcIuqAUTxlWwK4I3LpnkXTXLXyFFcSb+USflZJf0n +lYyrZnn7tLNg4SHdbCtz26tXrpLJ5LGxRUseh4EHBh60KaNjT3SdEgur2rD/HSYYeCwueJSV +lQkJCd0+y7ko4PHl56u3b9mnI+ikzmcHwcNU3EecU+XqxRt3GJiNrd3jc+qSi1pSilrcgxOj +08vXffvdZ5+vDIzJetvg0dU/0j3wqGfgUe/gaHxiipiEJN3NmyRx1RCnxCnBI8T5vqKKJgAP +cUkiLwceyU77huDBbFUAB1aumeUZBVWq+5Xv1aI4l34mmQzY44Z5vmlYjWFoNSAQGE29qLyj +srhOQ1VLX18fAw9MMPDABBMMPGgKPHp7e1VVVc+fvsR5VlrsvOnCg8efv59e/smn+nj3H9b/ +unXzbggeDt5RAngJW/fQxPzmxILmpMJmCB5fr133w0+/GNt4fP3N2h279y4kePQNjfYNj1bV +NWnr6hWWlE8JHn+duZqQmptTWPnjlp+TgvPnBTxK8pq/nBhnIXqW7tLIXCaeBHjjjEEOZTqt +Qpp9TO1hvewVkpSkLX+Z5h3Wo5SrBlZ2NPV2NPdlpeY/e7Y4kT0w8MDAg2bF1CO1sa0P6wcX +RpJy6+ml3KYLL4bd8PcQPCIjIwFyMJ4WEDlrSDhnuijg8cmy5Yzn+BnO8n780cfK9yxE5TRs +PKOCE4rPXLz+zdpv165br6JvBcBDTtVQl+xEVDNctfordh78yXOX1n77nbGN+wKDR//DxwMP +Hw+OjA2NjA0/GovzyYn2zIDgYaphf/jw8Y6+0YsXr2krmMAkcW8OHkaBFZSZs+KJezUzrcKq +6kvbsnOb6czz4ezaL2VSZL3Kais7C4rbtIOrPpeiIMpPKhkQPDpb+rpb+7vbBl5MRGLBwGOp +SH1Tn7ZZkqldelvHEAYe894Pvg+5WmhHYIzT6dK1YDec9gVwwgw5019LfMxjeFjwzKfwgqe1 +Rc6YiJ41WRTw0OR1BLwhw6n7v8+/PHr87F0hqU8//dzY3v+7DZv2HjhCUjfRJbvKqOjfE5IU +kpBftuwTnLjC9l17v/hylYiU0m/bdrByCwDwsHbx57gnICwugyPI8OPEbzGwBsekLQx4VFTX +6eroK0irKkvrXLhwpbii0cMniMAvi2SnfUPwyM1s2iCfulwiic++cJd65gaF1MM6Wd/Jp+7W +oIyqfEtMFXMr3aiYtl0985Bu9jfE1L8tC/brUCa8KAVUocGjpKBSV1vP1NSsqKgIAw/alNHR +8dLKTjf/Qnmd++x4X3a8Hzven1PEX9kg0Te0tLK2e2z8KQYeGHgsjFQ1dgFgOHnP6iCrGdBd +9EbQRhSaVE4v5XbqnhUACVB4T9mvsbUvPKXioqAdl6KPqnUc2PTzdZ1DbGSYjYVZ1gNUg9FN +QR238HzQDlgBSvZKA0tQH1Qrrm6/LuIEo6+D9lPyG963G/4+iNAJQ9wJQ/xJI+FTRiKnjRcR +PKSYdD9d8SkvTvyjjz4ydQw6dPT05i0/+0TnfLxsmaGNd0JeU2J+Mwu30KrVX+mQnZYtW7b3 +4JHzl//+8edfceKk33f8se/QUQAeylomASHRHX2jVQ0dh4+esHDwXjCLx8PR8ZHR8aqa+h9+ +2AKODs4BLyiBJIl7c/C4Z1dIiYUukXTbPN8xsrqupLW+tK2yuPWcUS60eACV9Sprqel6UNtV +Ud6hHVy1e8L94xOJpKqabgQ8etoHezsG66uaxAjigoKC7e3tb/s3RpWrpadvRNc8RUEnNjmj +4ck/cd1BV4WAx0C623v7PI6NPY1NqhVXjuAihLILB7AKeVMph3AAFyFEViMmKaP+6dNnNHXy +GHi8k/0gkogNBgsFN214ZAzeOiRqOsxmC+o4heTCcpjTjV8tAJ3hRcYkElYD66ARJOcLqOAe +UQAUHu6GqNMLVGB2DDzeJWlqajKQdqQd8BCiJ3744YeRmfVfr13PyiNCkNP8+OOPgxKL13+/ +8ceft4YmluiSXb5c9dWqr9ZwC4iBJR0D+w8//rJq9RpevBTAjluMHGjwAMrAxKaua7rA4MHD +y6draAqOXlzZiL83n+CxdmKiyjpi6h7NTDWfcrvw6jsWBWuJqRA8NiikGQRXXTTJW0tKZbcv +so+t43UuWUdK/WZisq1qUBUVePR1DvV3Dbk4ud2ku5mSkrIwP7mRR2Mh0RU4uRAOkUBOkSCg +aoYJBSUv5xR0ByrVSf/S6UF4Pj76fj6Sre2DSnrxnKLB4P5MRg6U+kzcvUAN48TCsnbaOX8s +ZPq71w9CNgC9P1WIcmTQBKayhQnaQDUIHlQpYhF4oBpqQcADIgdSQiJHwWaRbLkYeLwbUlBQ +cO70Ba7j8jQCHnqC7tyceAAeFm4RR09dWLf++5jshk0//MR6F+8RmvbVmm8++OCD5ctXfPbZ +54raZHo2ns9X/k9Z1/ybtd9+/c26mwwcu/YckFHShuDh6OrDK4CHUcoheywYeGRk5eza/QfE +nus3bsoSFOcLPMyDKN4dv6tmRCfV3yTnrZRO/lg8CRCITmBFalYzdC5trupIz3sg7FYK2GOF +JCWiqYBLqV5oNdi6UzNrSvDo7x4uyC0C7JGenv5Wf2/Pnj1PyWqU04jmEg1BelU2nA/4kw3n +a2qXUdfY+54/ktV13VIqUYA6wG2ZkTq8/717BHj30uuaaOLuYbNa3r1+EKLCZLPDlHlmJ4MH +wi0zgwdV2tz159TQbWLg8W5IfHz82dMXWI9LCh7TpxHw0OZ3tnQPX/vtd/sPn/SLL/xk+Qoe +vGx4WpVPdE58bqOhjfdHH30E2MPCJQjOagmOz9+85eeNm7fgJRTWfL0WkIlrQCwEj42bNksS +1S5evo6wh4ae6cKAB6COuKQscNCAkOgTJ09lpRVkRM4PeJyfmLryLTH1J+V0SbeSpPTGupJW +k5Cq6+Q8SjwxscRPJZOO6GYD/MC5libmtLTWdWcWtkl4lm9STF82EdS0sKJzSvAY6BlurGvp +6ewfHX1bdoaSig5N00QOkQBO0SDwtT6pA/XlIoTeFQtw8s7v6n74Hj6PbR1D9h65nCJ+HMKB +s0GO/9w9vC+3WOhdgr+zd35n9/DiXshSBI/CqrbRsScYeEwniMmCyuKBDJpQ1X9D8ICHI3ul +v7c3/F0VSpa3U5e5jioIHNWnHfAITasNS6/Vs/ICgKFqaC+nYXby3JXYnMa43EYAHpx8hE8+ +WQ42yaoYINNpOflEz1/+e9/BI/sPHbtKxwin05raengExeVXd5jbef2XPczeNnhYWdsxsbBD +cwcgkOycvPEnz7ISitIjSt4QPFJTG5ZLJH0kRgmTLulakpjWUFfcCn08TEOqTk0wCSW4h2SS +kGtpQk7Lg9ouAB6t9d1ZRW1EvwoYTd3ufsN04DHY+3Cob2S4f2R8fHx+f2zNrQOWTlkcwn4T +3+Yzfciz4/0BfgjJBAdFlj8cGXvnH8PnE8vunoeufoWCMsHchFB2vN/rUsd/7p5YGJ4YGhJd +sYh3b8mBB6AO0M0JagZi4DGDID4egArgqEp1UzckBKCWPhkIMwyPjM0GPKARA+3jgbZpgK2H +2MgvzYATB8LAg3ZEVFR0Dm6BhoaGF0/euHtEnf+IHu2AR0haDQSPiMy6M5foVq/5Jjq7ISa7 +AQGPrdt3f73222/WrT9x9hICHqnFD1R0zbfv2vv1N+tiMysnx/Ewt/+XPf6+Sa9navv2wONB +e+evv20trmwEx1LT1MMLi4yNPwXg8fTZ8ze3eIg7FwNyuGqSG5VUx+9QtFE+bYd6xmHdbMAh +18l5ZqFVEDzSc1tkvcp+UcnYppZx0zJ/l1bWJsV0YfeykAzKWIyUT8UrwWN44JGNjc28uJv2 +DTzyCCjikQgEOME26y51wnMyVFIlIiGt/gmNeU7OuwSGFYrKh7IJA+QImDNyTOF3qh7d2NKP +gcfsP+cx59JXfKtGFED2QBRyAnQcRUZbYPnM4BGaVI40AiBkSvBA3EVgm6DaYt1wR0dHIyMj +DDbQMoc4HuA2Xj1Bz/unNt9hPdoBDxyDnG98EQIewckV56/cRoNHcELx55+vvHSd/iYj5xdf +rkKDR0hCgYS8prmj33Qh0y0cvCF7AAUrNs4+bwk8hPDCgDegT+lvv23t6OyB4PFo9LGosHhK +aOGbgMdPSpQ093ZhVQA8hJ2KAXj8opK+VzOTCjxqytvJETU3LApWSif/ppb5lVzKJbN8y5i6 +pvqey+SCC6b5swIPK1smJqY3YY+2jqGo+9UipFBusVB2Yf85dKAv/U6NEvKLW2GbA+luPaGa +75jmFDxw8syUVo0Al8zA5zkv7AH9TqVUo6vqejDwwMBjvqS9e0jGJBLgBL2UG2LigJAA8AOU +gyUszyltAaiA1BkeGQN/ouEBTsKF9hNk6/B/zXR2AdnwWGAT1RAPJksOPO4eUuc5pM33py7t +gIc0m87Va38HJJUj4BGZWR+VVY8GD2kl/dVfrdExc7ZwDvpk+XJLlyAEPGaTJE5d15SBiQ3m +TJlgD995B4/UjOwDBw9B0wonN6+pmfnjsaeIxYNEkjfQMZkzeITHUZKz/E86+XfVjJ+U0gF4 +UA21XCe/DCC2lph6wzzfPKIGGWpxiKunsyxYR0o9bpALlrMBj4eDj2ysbRkYGAYGBl7fyjHq +GVTMLxXC9ep5GbPwnJzwOzWxTa8qKqvGf41Mtn03NIdvfWx0hoy8nYKai5FljLRaJCOfF7OA +17zgB6doELdoQGdhAgCAhdR6xT2VGHhgln9MMPD4R+4d0OY5qMN7SJemwIP7prCsqgF6qGUy +ePyx788PUELHwP5a4FFc16Wh9y97XLpCYY/5BY/jJ07CObxxSVm7d/8xOvYEDR75+fkszKzZ +CSVzAw9F9xLIFdo+5dUFLTWFD2qLHkDwiE1rvGtfBLPTAt2nnbVRIU3MvSwjvxWCR1tDT3tj +T1V1F50VJQaIc2LjbMBjZGjUgmzJxcX16NGj1/pNOntlCchEMfL7MgvMy8f7P36non4mwsKl +AmveJfCIEz+dL/JLCIldnKDNJ2ysrOVhaBl3l+DH9MbsAZiNRdDr7A3NdPxWwAALqRQ+xK+p +IXy3tHw88NrBS+JsCQQCExPTgh1ufPxpb/dwdVl7YWYDbWpBRkNJXnN/78PnzzEioDnwqKmp +ubtfmzbB49pfdHa+92cAD2uPiC++XLVu/Xe//LZ9284967/f+Olnn8Vl174WeJTUA/YwQ7OH +rYvffIGHu5fvlas3XvqU7vojMyuXCjyePXt+7dq1pJjMrLjSOYDHHbO8NbIp8h4lv6tmbJBP +FXYq9oqpkfcs/Vk5HaiCV1lOXgsEDzidFoDHJsW0HRqZ2sFV3smNHA7F60ipZ00oKWt3ambN +EjweDT/WUNcAL7rXmuqSX9JiSA5X1IkWkAqi5/VgFpyf73d2vB/ADzlhvSixy7USmxe4M31L +6sB1Fq6UKx4NUBYUENDQM/a1ckzglQi4dddtjqYPnA/HxNjW8YsK2/bdS+X+doFpqlp4bRXu +a2w67dKVJ0+e9nQP15S1ZyXVxAcWRbhlhztnhjum06yGOWZEuOckR5ZVFD3o7RkGL1vsn0gL +4EHJwHLyMtcBNRoED21el/PnLwSn1swAHheu3oKGDoAcn32+Eqx8+OGH94QkXhc8Suu7NfX/ +ZY8jx054B8W8OXh09Axs3vwD9Ck1MbdhZeN49PjJZPAAPbins392YskcwONHxTS8QxEMmS7j +VgLYY5l40lpiqohLcVZOc0NZW2N5OwIezdWdLTVdGfmt7HZFq2RTQE1AILqh1U0NvbphlCEb +56SmWYLHo4ePlZSUSSTS81l/TkTH5fPiDIkqTnqmwZpGsZwifnd4PFgE58X04cMjGXmb28HX +wWOBhw/eksb7/OdCWguSEiITJInWlvYx+uYJTPwed+65v9ato4RVx/neYLU4eEZq234e1gt0 +5YQfFoWpGpT2vrch4JaogEe8q2OwMLMxMawk0jMXwEaEc2aMW1ace1acRzYtazxYumdFuWSC +cwZnnhpdXlbQ0tU++PRdd02nZfAoKysD1MFxQJE2LR4q3FY36G7PAB5W7hErV36+fMVHO3Zv +3Xfw2KXr9EdPXQD4seLTz+Kza18XPMoaeuQU1XkF8DCgOmCP4KikNwQPgrgUSVENNvjrb1vr +G5unBA95eXlHa9eclOLXBY+AqOqPxRKVvUqvmuSulUu5Rc5zi6qpLXrgF1/HYk0JW/qXcS7i +XJpX+EAzsHKHeuYmxTRxj7KkvAdtDT2O8fV0VoXrSKkCrmUwktjswWOwf9jTw6ujo2OW7AE+ +l4pLGhTUnLgF9CTkbCzsY9UM4thw3gy8nm82WcMPgMfZG5q7D+PMbcLe4Yf6fmKhqWVQb99I +Vl4jSTPiNrcrPa/HLJDDl13Y7xaX3dG/SNsP8P2+n1dBRncRmWoJUUdjW98RDguyd8b7at94 +3t0+XFnUlp1QE+dTEO2WE++Rm+idBzTJJz/ROz/RZymo9z9Lr7w4j5xot9xY74L06MqqkvbH +j55gqLDA4DE2NsbBwcFwSOTuPi3aBA9FLvOZwWP/4RMfffTh6tUfbN68fNv2P77+Zt3HHy/7 +dv2GDz74gImTfw7gUd7YgxeTkZAmIewREp08Z/DIzi/auWs39CnlE8Rr6+qPjI5PCR7a2toW +JjY5KUVZsa8HHuf0swF4nNDLNvQvL8ltpvLxqC9tsw6vBuyBxPFgsyuKymhGnEuhj0dHU29V +TTefS+knEwE99CPrZgkeoyNjjx+NjY2O9/e/xvTMJ0+f1da1a+l7kq2DbRwi9clRkspht+66 +Mb7+xA3wFQ+og47D5vB5uW37eLYfuBcQkvpuP9etbX3hUTmpGRW9/SPhMaWipOCb3K7T3To2 +nC+HsD8Dj8upa6o7Dwls28977BwB3PZHjx5jb8jZyNJyLn1zefToUWFhUUlJWVZ6YbBvkqtt +tINZmL1RsJNxiKtZqLt5GFC3payUSyCHuZHDnE1CHIyC3W2jk+/nVlZUl5SU5uUVFBQUjjwa +mf3wMebNOwfwIJPJ146ycO/VolnwULtre/HSlenAg6huCgdZVq368OLFD46fOnSVjukOy71v +1n0LCj9etizkfsEcwKOiqZeKPUKjk2cPHuVVDfXNHRA8rl677ujqA31KDxw81NM/NB14wKEW +CnjElc0ePPwjKaaMHWoZX0onXzXJNQqooAIPq7Dq6+S8LyfCp4OaJw1y1pJSeRxLYORSNHh4 +JDft18k+bkhBlHXyaW2t/a8FHm1tbXMw3tbUtWvqe9wTMnTxuB8QViwoTfFemKXzJOxS79x1 +OnFZacdBfvAVz8Gnl5ZZ9u4Yt6ff9HDkcVFJQ1NLN1gffjjuFZjPI+Z7k9sNHfSVDefDIeLP +LOBx4ZbuH0fx2/bx7vqTV0HNub6xHXs3YuAxndTU1OBvy8vQ60jd0ZK4qUVk0acoqwFKDRdW +DV6pJDYjeXZjebB8fZVjNhCj05Rj0pWh15Zj0rt7RTSvIK+mugYDj7cEHoDtKIMse1VpGTyg +c6lHVO5k8PCKzP5y1Vcff7xs05afAWbs3fvB/gOrvtuwaeX/vti99xA96z1QuO/Q0bmBB1Bh +8f+yR0zyLMFDQBC/7ttvDYxMXT19Lv/jU3rs+MmIqFiYJG5K8AC9cHZyEQCP7Pjy2YPHOX1K +Unvb4MrK3GZD/3I42sJsVaAfUI6Ms5iGVFWVtG1USIMBxPIKW5X8Kn5RzQAq51vuk9zI61wK +nUtjclu7W/t3alLy1WqE1rwWePT29Lm4uMzhV/r48Xjc/QIHl8iW1v6a+i6yfTKbkOctbjeW +6f1O2SY8JJn43M7+rbX7sBD4it9/Aqdj5PO+Ddr2Dzxsbunp7KJMam7rGLJwSGER8AA8Bu4P +u7AfgJArjCb7TxK27efZtu8ev6hJXkE19lbEwGNmqa6ukWLQ0uG2NxJyNhR0MhRwUrxjqkRv +hqj8bRM5OoOFUdItI/Shp1RlBrLU39qiV5QlrqpJXVadrOJX1cSn2QR2kbyhqcpsAS5Ti8vG +FOcucFEmJze7umq2TwoGHq8FHsPDw+dOXmTaL8m1R5PGwYPtbz5NU+fJ4LFr76HPPl+5dccf +n3++8rsN31+8+JGh4TJVXc0bd9hA+YZNW+4wcwP2UNG1mBt4VDb38eMIRAVVGPJr3/6DyVnF +swEPb7/gnbt2c3Lzrlq1OqewEuzu6Opz9foNJDvtlOABqAOCx+yHWvwmzB0rJJLy0htgdtqo +xDp2m4LVMimfSSWvJaYIORUlZzRB51IEPKBzaUFxG96t9Cu51E/Ek35UTlcLqqqq6YZJ4pyT +mqDRo71tYPbgMTz0kJGRcc5JbEUJkgzM+MiYXMAOVTVduuT79DxTeU5OIAdgkkv0hnuPi/y+ +j+f3/fckiDbllU3v7WPe1T3Y1NwDIASss9y1uMFiwSLg+Te71Z9nZX7fz/v7fh4GDvWY+3nY ++/BNwIOV6LkkzvbN+0HwsS/LqqMv4KjNY6vDa2eEc1ZkMFViNIOqQG8sw6yhI2y5AKorYiXH +qUW8Y6DESEZOYLKqMJkLXSZJ3NAg0OsIMOsJUimTrsRtHYnbumCFapMAsy6BXpdwTUXrrq2J +qKsGlzVZ3BN/g5ibl1tThVk83gp4jI2NMewX4/pDg/bBQ5RJmYsXTwUefnGFq9d8veLTz7b8 +vPXzlSullfTbe+irm9a0dN4z9cr0iy1Y/dXX3363YfXX3/7viy/9ozPv5zbhtEMQ8Lgj6T4b +8Khq7rvNwGJCtgHwABDiyLETKdnFrwSP1o6+VatWwVCocILM5s0/1NQ3zwY8XiuOxzk9irmD +wzIfgIecawmMHibhWpyY2lBb9CAmpUHAsRjwxmGdbP3Ayg0T4BGd3mgQUnXaKHctKZXXqQQ6 +l/qnNjHaFq2SSZH8J2T6S6NHWO3swWPs8XhRYTEdHd3rRvaAwsXFBSixta23sbkbTndz9c0F +7MGKyt4y4UHqe53F/OBpSdCfAmXn0UlKK8aedCDtHf15IW4M7KZ/3dA5c0VlxyHK2NNfN2Td +vONHH49h9+cN2aOjZ2nExpwn8NDV43NUZiGrslsaCDmhwYN020AdZxxikxhslfC2Ncw22UjO +Vva27ivBQ/iKAvG65nFlu9WFFWtyy/7VvLLV2UW3+Axu4UxXZxWCP9FbV+WVnlCyk7ympsVt +q8tnR7pjYoRzFf6blJefW1Ndi4HH2wAPjl3qnLs1lgR46PC5Xjx/xc7vPpXF48CRU3/sPwxU +Skk/PrfxloSppc9+c69jApp+tsF5V4Ss9x4+8/1PO/cePEJ29MsobTsvYBeRXgPB44Kg/SzB +o7ql7w7jf9gjNbvklc6lx46/DBcG9/r1t63KqmrTgcej0ceB3uGvCx6J9ylTX5dLJMm6FP+q +nMZpXRAUW1Od3zLZudQzrvaOZcGHYokT0U1T6K0KXePrJzuXdjT3SflUAPzgci6V86+CRo+O +9oHZg8f42BMSkZSTkzNn8HhBcfx43lRbX5WZBNaDI4vp7zpSPEiF/djx/jc5bY9eIG4/AL7i +ea/eIvkHpTx58hR7zBGpEvjCg/MwP5PkmSuKJ/8SNyL7d3X3Y7flvZJ5AQ8ZForFQ1+Qoob/ +tXjI3zGSYVc3lXM0kXV422pGdJLn0Za7rf9K8MBfUZC9qXOPXf9vgjmdKEoJ5n+LkPGMujhm +vb9FzOj+u/VvUXOwi8QNdU0uG2NRFw1uazMxT/wNDDzeoiwh8IC5Wti5+WeIXEoyj2Umeifm +XdB2OCptLA/A4yyfraRRJJ24m5BWsIVfjlN4oaptgrV/jmtkEQCPg2xkEb1QUb0woK8Ej5oH +/VTskZZTMjN4SMuSJGVIEDyAAgjZtPmHXbv/mBI8HBwccYLCrwsejOQ8wAafSSbfNM2NS6iD +Qy2TwSMsqYHVpnAtMRXUBPUP62ZP51wKwKOzpa+2vkcvovaYYe7yiektmmG1rwUelRVV1tbW +z18/SuC/4DE+2qxztoBndWWo/cORp9fpDa4xmNzmsjt1VRV+xR+/QLC0CxscHMGe4sngAbRU +dq+5bWRmTgV2Q+ZF+odGVW3iFjH/6SKAB7OOgaCTmbi7KcHNCO+iSG+K7ugV6I2Jtw0XRkm3 +jZRnpA7E4iF3XfMU0XJtSu66hKx/NTF7bXz6bR69O/xGa2PTwJ/orWsTM0+SrCSvqQHwsJDy +MBRyspTyxl0nToAHNtQyz9Lb28u6S3lpgYe+gMftqyzKupbTgcdpXhu/+xUKFvpneNlP8fDs +YzHdP6EOofn7Wc0AeOC0Q4DidSg6B/ConcQe6bklM4BHSHj0/oOHQH26W/Trvv0WIIcQXnhK +59K29o6bdLfiwpMBdWRGzzZXS0hUFQCDj8UT18ilHNfN8o2qpgKPxLQGKbeSn5XTt6tlqPuV +5+S1THYuhZFLC8s6pgQPGGV9nXxaVWPf7MHjyfhTfT39hw8fvu7PMjAwUElJCax0ehBgB/rA +U7awuJGezfjyTf2j52S37efZc0RATce9+UHXm/z+HR0dT89CCgoK/vM2rqmZzV6RkZHUIyDt +7a/cS0tLa8oX2sxCIBAmg8fVX5Yd/mHlK/el2hGcwGyubnJaQFFR0de9ky8mIha+ci/wb5rh +TiYkJCzkOMt7lasFAQ9TMTcTUVcq8FBkMJW5oy3HpEtk0lsAlWXQId42eCV44K8oyNBpc3Ab +XJew+lvcEq03COaiDLp8rPrXxSyoNoESfraXFg9zSQ8DQUcMPN6eyMvL0x3kW3Lgocpjc+mv +Kx7hWVOCR3xu4w2Ci4ln5sjozy9efFDaYKvjnPLjVZ3U4gfn+G3TS1vP8dtllrVZ++dA8Hit +oRYIHuX1HX9dvubhGwzYIzWrcN+Bg7XNXRW1DxxcPCeDR1tn/5Vr15lZ2e2dXKrqmmB22imH +WmxsbB2sXLOSCinmjvjSWYLH2QnvDnaL/LLMBpugij/UM26a5dmFVuZmNmn7lv+pnbVRPk3A +sTgmtaG+tG1K59IHtV0xmS3sE8HSL5nlW8XUNTX0IkMtwVmtvR2DB/RywC4sDiWvBR5kM3JL +S8vzOaVG6E+yQ2Jrj7VXgZLGpm5z65gbjJrS8ral5Q1z/tlzcXHB9wMGHksdPD744APIqBh4 +LDx4kG4bKvLquRuEuOkFv2111w+xVnYXvaGsPAsfD4nratvJnqvySr7KLER0dXbRmsTMe7dU +TijarMoq+Cqr6N+tWUWr0vP+FjSUuo6Bx1sX8P48d/Ivtl2qSw489AU9Fe+SfbzTpwQPq4Cc +fcymCXlNV/AkeqnbN8XvSRpFAnUIzUeDB6AO64Bc79jSg2xkj+hiz+ji9JIHswSPutb+ioaO +i/+wR1xSlrK69o6du48eOzGbJHFTgkd5RZWYiCSgDgp4JBbPMjutsU8p4IEvpJITE2phyPTS +rEYmi7y1xNQPxRJ/UU7X9a9A+3hMBx7IUIuMT/mPKhlg32sWBejstEnFHSsmBmjC8tpmDx7Z +Wdm5ublzMHo8qs+mJPKYoI6eUE2kvLNrMDQip7au9U1++Qh4vPNDLfWkHe/2ZWLgsdjgoeum +H+KqF/y2FRzFStlN9O9XgwfuirzsLT1JNlNRLrIoJ5WayTOYSDObgJXJm+SYTcX/Y/HwEbom +l4uBx3wL+I64cYiLfaf6UgQPAyEvB/XgKcFjL7MpBA+P6NzMkt/zKtZXNRt6xpSwKfiyK/gC +8MBph1j555wXsMuuaL8p4SqiGyqiF8qt7D/7oRYYQKyy8V/2wItKqmrozRk8ysqrLl+6HOgV +TgGPxMKM6NLZgEd2Uu2PihSEkHEqhJFLPSOq9mtkXjXONfQvT0tvJLqX/DSRG07eszQzu2kG +8EjKfYB3K9ukmH5UP0cntDqntIPDsXiTUrqUb2V+ZTeMXCoz4WX6m3pmZ9fQLMHj6fjTtra2 +2QdRh/JksKNO+hfYdbZaMc/7Lx8DDww8MPCYl6EW6dtacow6coy6C6AyDNoT02lfMdQiek0Z +f0VB8pqa1BXVySp+XU1imk0S19VFr6lg4PG2RUhIiGGP+NIFD2MRb2Nhb3uf2MkWj9O8NgA8 +AH5IGqqf4WUffPhFdGbUj1d1LHyzAXhY+uXImEYdYDUD4KHtlAzjeHhGF78ueDS0D1Q1diLs +ERASPSV4/CWT8ErwuEl3y9zIOjOxMCuhMD2qJCOybDbgIWpXAEhgm3J6dGy1kG3BBlLqH+oZ +buFVVD4e0cn13LZFa4mppwxy9AIrqAKIaQZV7VDPhAHEsora0D4e+eWdADw2K6Uf0MsxiKqr +auj7VT0T7CjmVzV78Hj29Blgj2fPZhvOCzqUwn6zQXn/s0cDGHhg4EEj4PG+OZdWV9VI0Wvr +8ToaC7sa4VwMBJzlb5oq3DZDVPE2WeGW2WRVnG+daJOseIescPs/J0ClimB5y1SOznBuKn/L +RJ3Vmizmoc/naCHuI3hJNicvpxqL4/Fm9g10Bo3e3t6zp86z7VRZuuBhiPPSE3K5dYXxLr+w +T3QO2scDgscZXtvEgubj3KL0Urcj084fYDXRc0kB4OETVw7A46drOucF7JRt4t8EPBrbB++n +5uzYtftB1zAVeADegArejcj6lOCRcb8gITI9M6EgE1BHZEl6ROlswCMutgpONtmikAaQA4BH +THxNeVZjRXbTdLNaHKNq7lgUfCmdDJ1F92hlrSWlstsVRWc2TzmrBRlqic5v43YpWyefdsKY +Mn3mU8nk1PLu1wKP2f9Qu3xlYKdZI74RunYsUfDIq3hQ3dSNgce7BB5LS968H2yobyDyaagL +mmjgTIGq40xV+Axno8po5V0YNZhQyhFVeF/qHBpRFTDSFiWr40y0RMjS3MplFWVNjbMNSEgg +EJiYmLAfHlqo4nhYW1tfO8TBvkNtSYOHsbC3sYiPsoCZJE5BVJykZWznF5MLwcMxJF/GNBqA +h7ZzQkiSoLz5mcKqgwQDsortfQ37JOuA3PCJOB53Vfx1nJN1XZIljCLnAB6+QVG79+zl5cdJ +SJM4uHh4+YUAeFiGVAHG0PUqk5IlDT583Ds42t0/AvPIgHLbiNr2zt7QsAhjE7O02NyM+/kA +PAB1pEcVpkUUp4eXzgY8oqMqf5kYZFknlzLBHqkX9LNF7AvJAeU5aQ3TgQccaqktbdulQTFc +mIRVTfbxoAKP2vresJxW9dAaHteyvTrZH4snfSpJoZ3vFdOTyrpmAx6tD1olJCQGBl5tuBjv +e9BqzQZ7TI+/P39L1DF78DByS/n5ug5Y/vsQ3bMCOsujbL9lcIbXerqtBZWtZK90DDyWFni0 +dA7wqwd4RxW9J+Dx9OnTgYF+RDo6uhvrW8uL6wuzq7MSSzJiizJiChHNBBo7sXyVZqBWMlAr +GVPVnFxnPrQgI7ogPWZCY4syE0ry0ysqShra27v6B/r7gEwswLU/nRCMH+YLPG7/Icq8U+Hd +AA8TUR9Tgq+jRqihiuWNa3RMLBwxWbUJeU2J+c0APJIKm5OLWupawdvpg/Ena3MqC+YWMn06 +iwdVADHEygGkuLavZ+DR6Nh439AoAh5AL126rKWqlxydnREPqCM/OagoJbgoNaQ4NbRkluCx +VYlCHfRmucWpdQnxNTJOhd+RUmHO2c8kk/AORfeT6qcDj8by9sO6lIkw3gn1M4BHSGbLHu1s +2CbQTySSGO2L3VJbBnqGxfwozh6rZFNqHwzOxuIhJCSUlJQ0NDRTvMcngx2gl4TdZSTfLzCO +x+KCh7ZDwvKDRLBEswTQsfGneRUPhkfG2ruHLH0yqMwaSbn17hEFYCsaPEBNWI5UJpGjQAXY +DmIhmdwaBh40BR7vm4/H4MBgTET8/ZjkUL84O9NAM20fUw0vcw0vSy1vGx0fG913R620vcF1 +mev4+rlFp9zPjI9JigqNiwyLAQQyNDj0ApN5Ag/W31XZtqu9S+BhKuZnIRPgZRplZ+ge7BwP +FA0eKUUtfUOnwYtq8OGRtwcekCvSSzs6+0aQFyOQ9p5hNHgkRWWlx+WnA+qIz0+LLnhd8CA5 +FYJ+/xvZlPi4anSSuLDYalaLfDj+AnSrSrqKd2ledvNrgUdjXbdVTN1fZvkIcpwzzSfH1qNz +tXR2De2eYJI79iWzAQ9tLW1/f/+Ojo7pfpzPx0dbDK8gfaUANystg0dKfgMop5dyg3+CdRmT +lzNnAWmAP2E5Ah6AKJASsBXgByhcf04NrCPtg9bgjmDJrxbwJlc3/PBxcFQ5HmdFFFKNkqbD +wOO9BY83l8rKasFrJKkbOtI3dWRu6iowG8kx6MsxGCBKZDRcSJVjNEAffUr9p7LBXJTeQPy6 +FrhYyRtaxNsGHGfx2TnZVZVVLzDBwGN68DAT9yNL+NurhPjZxALwCHG+r6VgKCatYO7oG5tZ +lV1eMP5kLXhXtXRJvFXw6Oh9OXu0eYCCyr2DL80dRmQnWCEtLg+AR1psfkpoQVJg4WuBR2x0 +xdeylOEVVdciquy0cDpt9P3aK8a5y8T/z957gLVxpYvf+z33frv3+d8t3/9uNutNdu/du8lu +yu5m0+zEiZM4jh3b4IILLtg0m14MxnSwqab33nvvvYMQvYvee5FAQkL0KvwdcfDJWBIgMAiw +531e9Ixmzsw5M4zm/OY973lfIiKHUw7VzsntW4JHXFH/JQ8SDGoK9L/0Smwzulu6aHA6LUd2 +2pJW2n+slYysGNkSPAIDAv39/clk8tLSEs+bE/l1dKr+bpHSgSKXHmTwAFBBoU0hqIDWD4QN +cBmCx/TsInRHxJpBsBYPWBh8gvWAYcDyzuweLNYqsaxP0yRDSj1VXDVeUi1ZXCXWxa+8b5Dx +qj7WeEb5wMFjt4Q9q+WWtZ1ckLNqqJNqiKPy2qyWG65IDa456F6xFYSK2OpdtV+r1A3bAA41 +uemucdFc9fwTzfMm2meecKuGkKmGEO9NYJeHF83M73q5PAizkfH3UI9SFNKt2Y5zKS6vM3i4 +a8a7ayX4GCZ5aie6aEab6dsq3FM5++M5cSmZsJiHADzYUcV6U3cdPCBUUOjT4PIGBoeX1K+/ +4BdnV4NutDCpAhYoya4tyaojJpMK40nEhPrtgoeYa82/ifi8+yCVI0kcBI+QsHJPP2J7zWBj +9YBVTOvnlhX/fs4JDcGIepISCD0c4EGoHpIOaPy1TjECld8blGhGt3V107BxPDjAY4oxq5fY +yS78uJTOmN0cPGJiYhwcHAB4LCwscN+ZzLIwFChsuj71GSZk+gEED4ANEDzQemjlAAiBFrCF +0aHAMjRogE+wxi2qDC6gI4BPVAYdhH9p6RizcimSeJAo+SAJpdK7qxwLIERGIzEioWFich5/ +DL6sBaCP+p/HDfXdsl4f8GBnp5UPfCrlZXHPhztXi664hYtuoLPOnqurXvBjGRu961vnalE+ +b6B92VJBwvHWQ9/b6i+qmo/aLbsHtx3AAsemW+o+YBeNi6aW0r6OKsGmdz1d1CO2m6sFl83B +o7Ky8tLn919t8PDQTgDg4aWT5KWbFO2SkxpK8HEI1VEzjI/9iO3ssfTLlr7UXQQPm4haABVa +JmbQuKGuqulk4cOmjqQq8LUkuwZSR1F6LSG+tiC2jhC3DfBIiKoKCykNCy0LDyv7T8XUn1/x +/UrcMzKiIiqyMjqqMia6Kj2JhCwemmZJWOfSvwhZG0Q0v2VYirjit3rFcDrtbZ/6P2DW/0a3 +WCKgMa96mHtWC0/woI1PwwGXpDrK5uCRkZFhZGQEwGN2ljOpysJQAwoURks0QmBwcMADDaN0 +DtAgHmwXPOTNEqBBA5bhCR5gGVQEjgkVOX7wI2O0Gf/IWim1eCn1lLuYBL5IxVXAplQ1w9Rc +YtfSMgt/GOKyHfBgZ6c1uetuJsEjO60ZOzstIcmrYK81zZfoqOvDZ3Zadq6Wx75vVDa+WUr6 +Scvq3yiuuS5jd03R+Y2iavAVu/W3ZaSThj4oO62hqLOjcth2s9Pis1o2B4/k5OQLx8RfH/Dw +0U8OsUqPcc9NDipICy8kD3wF2IO18nNS6RMbE+fLF0Vk5JXMrJ2s7N2sHNzjMwgJGQRSBxkL +HqV17anZRak5RWm5xem5xXHJWY6uXi09IxA8AFFck3eCyDHGmCNGVMDl4qxqIomMXDvyomry +o2sLYrYNHkdFndh6g61/FXF4/4rjsRvOx26u6xdAbzkj8IiPq8GCx1+FrZNT6lJSSR5RVWIe +tb/WKUKkAfXfHxGvedX75/ZsMp2WJ3hMT8x2D0+apHdvafGoq6tTUlIC4MHhX8qaYyKH0iEH +ISwY7Cl4WFpa8vN8gKQBkCA8g4S4AlABGmqBYyhwqAUBBvdQC+QKUBiNyyDwoNCmwHo4vAKH +WmC9fJ7I0vJKSnabsm4Ke2xFJY4bObAKjSEmdvmkZjL+PMSF36EWMWt7hSAHlWAH5WBHFQ6L +h5O2mJm1mqcA1EbdS0/y6VoAMT6y04pYS0nYXdD0vPDoRdVwV75lo3Tb9sJDd85NjzykJdZz +tbg8DLWS8XXXiFLGs9PuKngEBgZe/Fz6IICH4Q0ftasWcpd1FUQMEHjo3HK8KyHFka9BSEhY ++ooKNmS68k09w3uO9qqRW4KHt14yYA8fgxRfw9Qg8/Qo55y+totwzKUs1zPMK8HbMdhQywSq +xB1poAkhWTlxJTnxJbnxpZcvXRG5dEXy7j2k96XkjHTNMmLXo3PQmPOFMaWFyZWFyevIUZhR +TXy+DC74S4LHaSmvsJBSONQirRnhH1CMzdUSE1119r4PAI9zMj5Qz8v65mQ0IvA4LubK1juu +5s5ZfS3k4JzuX2mz8eNPT0rtUzq628c2mU67OXjwGcdjanKqvLwcgMfk5CT2nsQ6lGIDhe01 +ePAvAAng2AdUUa0wthXrOXigoRPoLwooAq2BWyF4QK5AzqUQPFKJrXAZWk6wXqmwFn4kKLpO +Sj1FQjVhc+TAjLzESKmliKvEegRWDo0w8aciPtSyNXhsmp32iair/hUHwajhNWfjW/xmpz2l +43Ekv+IP2aVI38opO5JZdP2+7Q1Zhz9kEP+QU4bdeiSn9KQenp12zy0eF49K7hd4qFwyEzuv +ePnMzfNCQueFhO/LKT0xt/EOjkYjHVXN/VnEamRwaB+gdwwy6juGCkpq2cMcwxO9I8zm7pGn +gMSVVMD/+rLIFdELd+RvPtK7Z7MlePg9TvU3SgNamS0HwING/mvw08zMqCKgWTHFWbHF2Wwt +YVPHc/DITSjNA5pYBjQ/CWh5fnJ5QXI5xImpuSXvkMLxyYWkpMr5xZXUkIqZuSWIHEkhFZTx +OVgMXPYdgwfy8SjOan3nvFVeaiMWPJCPRzWxq6aoq61qwM49D2vx4J7V8jfTcgAeQi61W8bx +2BXwWGWtkteEwfjJyxHrULow1MAxFHJAwAPiBOAK7ERXNNQC1oD1oAC2PCgMXUmxAcTgXFq4 +Eo3FgJVgd+x0WnBMfqJirrBYPf3jjt6lEqqJd5Ri+KQODscPOc2k2JSmqekF/NnIvxwu59KX +t/xvFTLdWUvU4omk/RNJBwGowV0bnas2xnxYPLRFrG4pOJ8zCBDS939BdbzVr1tJSzuc0/Pj +2HROz1f+ji2enXZPwaO4uFjoi9uCBA/Niy4QPMqbRwKj0529QyOT88ubBmvaR9ddLLqwLha0 +5j4aB3iw/SuGGAg8oIvFmn/FFKmlO7ew1MXdOyUjl0KfgeDh8DDMTTNuE/AIMEkvjNdhsf5t +uOfzcJuUMOusaOe8OI/8RJ+CRB9Cki8hI7w4yj4v2iE/xrEg1qkgK6o0O7o0B2hMGVAUryPJ +iQg+xS5IhTkXpnsVRbgSkaEjObiCNrmwbu6IrAFrdgYefzln+Q7Q80CtuPVdIbbGxlSFhJad +k/Epym398rbL5uDxoRkbPH50qhEweKBZLVPVscihFCxz+2AcHPDgFg4fDwHLwDDTwqVIRiMR +wMMOqOMnxw9VtuPHI6MMQmkv/nh8JcFDAEniTBQc4t1z4lyz91rj3XICLWP5zE6recn8I+eI +Nyrqf1dS95OW1r2ZVyZzzeykoc8bJbUvbCqpe4NYdUXREc9Ou6fg0dLScvarKwIAD6XzZrfO +yAmdunLuvBCxtq+saQSARzl7KiuF7djZTtkV8BiiTg3T1uN3AfAYZbAjlgeGhIPb4LaI1ENJ +I2fNCJ7gEWia3l5z/tmzn9FH34lziQy1yg6zzgm3zomwyY20zY20y8OCR6wzIc6FEO9amOBG +THAnQpwItiqCmHFLSIoyvh6eNCOoYmpuCYVJf7b6LDei+uUtHkWZLQAz/PyLSMSugIBinrNa +3hWyDo+o0DRLCo+s0DJP0nqaBMBD2yJZ2zLZzCkLgcdfTMoAeFzzrBMweMDbD+tQSo3V4b5X +cfDYRFy880Xl4m7Kx/D0I92uSj5IknyQWFk7dEgfa/h02n0ED8PrjgbSVr6mUT4me66+ptFO +uv7ql022zk573lDnqs3j646GV2y51O7JDZcNNtk+ueH88JIZZ5K4Whw8XkpIJNL8/Pp8OgqF +cvqE0J6Cx70fdS+cunbh4uXH5nYRyYSSxqHSxmFBggd1YpZMZeYSii2tbIWFhe/dULZW9+MG +j0j7qGnm7wF7gM+0AA/+wSPRowhyxdzCcpBNiaaOAegr0wPK0jyK4fqskMrs0MrssKqc8CoA +HnmRNS8JHlKPIq4rBdUVdualNgICyU9r5AaPL265GNulJyTUaponnZf1BeCh9TQZgsfxO64I +PP5sxAaPW14kwYBHRkZGfHw8BI+NHEoPEXigyKX7UntlTYenf8E91eCLd/3FFKNfnj0AwCjo +pOcX95JHpw/dY03AAcQqmgYBeNw3in29wENp3cfDSTWUw8dD95qNzjVrgamhqOOWPh4AHlSE +HmtcMOWp6hdMH26w6eFFU/WLpmzw0GKDh5d2LJ6ddteFnSFub8BD6rSmyNXrdyXvu/nHEEmD +RfWDxQ1D+wIe7OSwk+ys9EOU8ZCwyBs3b16/eNvbIBELHkFmGTFOEfTRd8AzbHHhl8Up+vyD +R5JnETJrYDUjqAJcYQAe4HO3wMPXl/jOecvirFYAHj9Ke6s9iasv6r6nHVWQ0YQFDxnd6Jtq +Ie01gwA8tMyTsCHTheT9sOChmyqnEJInGPCAkUsheAy7XuHpUIoVS0tL8BM+yD+ffUwARyaP +sy/jyLi7b+5VyQAxpZg7L236EFeJP3PV7todKxw8+GGPianDERHl5fvBjvbOh1fMLSR9beUD +bGT9re756V100L/siNRAxMngsuBUX8QJWztvFXHSu+yge8leb5sKdtEXcTS+6eaoEmwp7eus +Eib3o3Z1TVVnRycOHrslt4D802DXwSOvpj84viAkoYBQx06VckDAgzE1PzE9z5xZKC2vmppd +5ACP4KeZ4TYpIz2fw3kutJEPcsJc+ASPZK/iZO/iFJ+SVN/SNP+y9ICyjMByAB6ZwRW7aPEg +pje/c87SyS2vltBp4ZB57IYzdC41tEw9dtOZI3KphlmisV2GnH7MJuAhEeIOznRk4n+HugYF +AB4wVwsAj9E4Q+RQOtdbtV83P5/TaTcSA7csNFVW8NI3QFlZWR1nTNPGJ+OSqi7f9bl2L2zH +7HFXOVZCNf5bIZP3PpY6JazFUVcqsRXGFYGesUjAGjT5F7rIQkOQ4Ief8Oy0e9oPDg8P2z12 +c33i72q0psb+zo99D6ga+rB1fXldnbatPs5PfN1NA8CZupkEWOs79/T2kEfIArvgr7xYWVld ++VRpt8BD9pRxTjXKSj9g5RocmVbKD3gYWToLEjwmZxbWU9LPLVo/8nXVj4DgEWKRFWqZVZn9 +YG7mvyB+DLR9n+gZc0DA46iok6phbE1BR3hY2TvnrZLjatCslrP3vG+oBEPwOCfj88Utl4+u +2GuaJW0OHmbxpG7a/7Az19A19xo8aFSakJAQoI5BQghyKGWWhe3jzc9nALGN5J2L1ruYzW3b +1u/ekbn55frmwa7esWfPVovL2tR0Ii6I+YjKRm7L6wMUBshxSz781GWLv30s+cFn909f5PS3 +QZOCsVFYAYSgScEQQuAymTa5s5irhwg8RsenvrvvHZZe95qAx9TkZDGhpIRYVpBdnJqQnxSd +mxyTmxKTlxqblxYHNP8AKWhSbN4Ly7HsdvKj7JIxucnROUkxubkZRWXFFSWFZYX5RYWE4snJ +SX4ya+PgwadkZmaePy768uCh9L21yPd3r924nVBQD8EjNrvmyFt/5BM8vvrmlLGl876AR0xc +grDwBetHPgg8Qq2yY5wSWspvrSz/HDzSwGdDsUycS+a+g4fko3DkXIr02E3nH+95g893haye +WKcB8PDwLSzKaW2rGoBDLX8VtsYq1sejv40yOpAOznF19ReUgdJdAY/mFkpuYSd9fIoDPDLS +M/T09IYbSzpU3tjEofQQgQfqczeSTZgEbRpnzu6s9p4+yvzCytLScl8/ZXB4fII5Mzs7n5xW +I6UUePGu/23FaH7wQ0I17o5SzPkbTp+ceACo4/1P720EHpA3EF08W8tnJ2+WgKKXvFbg8bo5 +l7a3dygIG2hdZM9j1b1q++S2o76ovZ4oJiPbDQdB6pYZ4kDb1ouJ7lA1LljqiNhoXrQyuOYg +/r1KVXUl/0nicPDYUqanp7//7tTdf5i8DHhInNQUvnjZyMotvawTWTy+//GSrKpOdkXnpet3 +NwEPZQ19r5D4lPzq377xZm5po+DBY2Z+aZg8Ki0l424YhcADOpcme4cNdX0NTR8zk0dKU0z3 +FzxQHI/E2Jq6wk4SsQsbxyM9iYQNmQ7Bw8Q+w9QhE2vxENMIw4LHQPvoNFOS7dky/9lLgkdz +K8UrsEJBO0laPV7/aXZ6dts4fQaBh4mJSWxYQJfu+8ihdHVpn4fIXwY8UBAwOAYBFmAvDKN+ +wTWwAIoDBvPYolhkoCv3jCk/8oPZzgZrRscYcwusxpahnLzqsKgsyhhzemZuhEwjU+huPjm3 +7vtduxe6Ns02ZgN3jjhx1TgRce8vTmm/94n0e59IAeSAupHFAyaaQacD1gB8Al+xp4yDxysJ +HtC51E4+yPkBO0mcE1eSOP1r9gJKEnfFVu+qHT9J4h5eNFNZSxKn88Nj7dMvqM7pxzBJnM5p +HpvWksSZmot7uaqH28r6ezyMUhLS21aSOBw8uCUwMHBiYoJjtOXWR7o7Bo+73z28fOV6WGpp +VmVvdlUfBA9776h3//ZhQe0AoA4xaSUseNh7hpnaeKQVkiB4BESlAeQgVHU80je9dPXmvoDH +7PxSQ2PLJWERjyfRWPCAzqWFcZaT9D9B/KAOfZwb4bvv4FFL6OQGDw4fDwgeKI4HAg9sHA8I +HsNdHSsrb4Kzm2Jo7Qw8SPVDjl7FkqqxUupp4irx4F1b8kGSlHrKwyfp8enNY7QpAB5CQkKd +1meRQ+ny5Oi+/xZeBjxgPwsjfcFkLpA9oCME5Aq0CXbNKAdcKrEVYYm+6wth0vmXxpbe/sHR +GlJfflF7HaljaXmls2vYNyhjZmZ+dm7B3TdbRSv0xr1AUdkIDscP6M4hej/4GyHjDz+XYQ+v +rBk6tgQP+AmJAjQYLsPrQKFN4eDxaoOH7h1rW/lAc0mvp9I+Di/majG87qgnYelmEOKmH7zX +6mEY+kTOVu8aP0niDHUuW8lKO13TCxLVeUGvaweoitmr3nEECxybrukEyko7wyRxDspBpnc8 +XNS2nSQOBw9u4chOC2XHQy131qgjMrMys7IXCx4yKjpAg+ILjrz1x5yKLrkHupdF7+ZXdf/9 +o0//53/fFb58w9DcMTm/5h//+qyqjXJbUlZKTjWntPHPf3l3v8BjbmE5NS1d+PwF1ychPON4 +kAqVlhZ+CfGjv/UcIdbjlQGPwY5R6nAkPLUJquu2wKOqesDWvUhcJYZXlpAYiQfs8Faq+qmZ +OfWBcscPgkPpXgy1QLqAyVmeYbLFYXttjvUo421jJ2VnwUDq6nt8A1Nj4nJJDV2tnZSmlsG+ +gbHw6PyhEfrc3FJeYV1pZaeTR5a0csDFu3635KMADUJ3jtsKkaevWH/0pRIaW+HQTYZakMUD +nhQK/w44BIFHRz8VoggOHq8WeMAkcR5mEl48ksQpOSZ7FyR55u+1pvoQHbaTJO6koc+bpaQj +xNqftKj294RKURm764pOvy+oBF+xW98sqvnewPt5kjh/Q1EXJ5VtJ4nDZU/BQ/xbLUAdERmV +GRU9HODx9ckfTe18DC1cT529VFg3+Mtf/Topr1ZeTff0uUtoqMXC0ecPb//J1i3QxTfiq29O +1XaM/urXvymq7dwv8FhYWiktrRC7cTfCLodnHI9Ej5TOumuwgwY6O3WkuVwuOzTmFQCPwc4x +xpgLPC/GmA8/4FFW3mfpRAB0AdDi7maJyUBnlyirkeiqeL9U4a8APCZKQ/m8V/d6Ou3uggd3 +mlrs184BGk/wgPaBHYDHyspKQ/NgcnpFSERODam/sWVwmDweGUsgj9IJRbVRsdl+gQmxiSUl +FR0xiRXi8v43ZcPA/0L4lutn36gD5HjvE2lu5AD696MKP1423Ag8oKEDJqNJJbaiISSwFa4E +y7d1I/jPMnNIwWN+cdkmqLC+g/z6gAdMEueoys4Qx50kTuu2uaWqu6XKnquVqoeuxDaSxElK +2p3X8RbSflE1PZVu2SiK2YIFjk3ntb3ALs+TxIVZy/i6P9p2kjhc+AQPNntsHzwSiW3R2bXp +5T3c4PGnP78TGFcgKacuKa+ekFt75K0/FtUPfnPqrLGNOwKP+0qPrt6UUNbQT8mveuvtPwHw ++OfHn4XEZuwjeCwusZaWWZnRxVGOuRvF8cgIjGyvEZuf/S9EILSRT+oI+ql++YcaPIa6qJPj +htDRlD4avRF4gE9icZe5fYG4ShwbOZRj+ZytKf0wVUY5yMXYsX9ogn8w2NMAYnsEHjA7LRw9 +mZ5dRIlodxc8kLR3jsYllpaWN/T2kaPiCFQaMyevPD6xoJbUER2XPUabWFxaNDAOPXPJ6ptz +T97/RPq9j6V4IgekDkk5G+/AdI4qwLmgwSCYmwbbYDii9GwtnQ1YcAwrFvxjDZ9OKwAfD5gk +zlk9lCtJnBs7SZyIgwBUT2R7SeJ+0HJ/O7v0jxnFGC15O61Q9L7tTRmHt1MIf8wswW59O7Po +lK7nSyaJw4VP8FhcXBQ+Lib+kSn/4JFS2pVa2p1W1s0TPKDFQ9vY7twl0cK6wf/67e8yipsf +GVoIXRaF4OEeGPfI4Omf//KurVugV0j8Z8e+OggWDwgeyyuslMDCLQOIlabYDrSdX1n5OcQP +1srPBzuECqKjDy94DHdTpxhakD0mqCEc4DE6zMjN7zCyzlvL7pHCJ3JwpAWRfpgmrR7vFVzV +1Tv+qoIHyk6LEtfCeR97BB5AenpHXTzio+MIWXk1ADxS0ojEkjrKKD0mnj0QA9aYWcecPGf6 +8VcqGxk6PvhM5u/HFDT0vBYXlw/jY03w4OESUdJPZrwmvQYfSeKeGkk7GEk77rUaSzsaitvq +XLXmL0mcpaiS6xmjoLNPAl9QfV/1a1aS9xzPPA7g2HTG0F/ujq3myyWJw4V/i4ehoeGVo3K7 +BR4ScuoyKjo+EZn//ed3ciq67kgrid65n1nS8snR43//6FPhyzd++8abgD0AeJTU90vJqYpJ +yuWUNr719p/20ccDCx4rrNUQywx+Ipem+WfUFejRRj6B+LG0+MvuBvGCmPhDCh4jPbTZ6VvP +J/KoQ/AY7hvPyGw1sMhh+2yo7QQ5OMJjSqunST6Ic/Etbe2kHl7wQLQAX/mx+WThuz8gDR3n +TLQeOkLAEOtoFxhui59ctJvLBHMut6DRO4CdqL2zezA7t5Q6zswrqMwrqKKNT9q5JJ88b/bp +iQc8nTo+PCr/96Py9xTtZ2bmD+ljDffx2EfwMLhmb6rokOCZF++Wu9ea4J4XZBXHf5K4jx3D +f19Sd6Sw5icl1v4hu1T2mtkpfe/fE6vZrh2YTb8vqLyq4IiDh8DAo6ur64dvf5T4lxk/4CEl +orU5eFi6BP/rsy8LagdOnb0kJf8wt7IrLJEAZ7UA9gBPiYTsCmJdX0ZRQ1hiHoCQ7JJGY0vn +s8IiBwQ8mpqab16/zX/I9GSv4tyI2I7ae8gBdYb5P8Ndws3l2qVpoYcLPEZ6acxxu9XVX6xF +jz/R3typZZItqZYMdFfykaHpnGsjNTH2XiUNrZTDCB4HUAYGx2vr+9NymhJSa9o6BuMScgqL +ahmM6ac2cTzB48PPZf9+TPHcFf345OKVlRX88YiDxw7Aw/C6o76UpZdxhJdR+N5rhIO278PL +pnwkiTPQvmJtdNXhySXrJ5dsOFXU+ck13puMRDdIEteBg8fugwcQU1PTS19K8AMe8jL6m4NH +Xk0/AA9tY7tUYtPHnx/HTqf9w1t/+p//fdc9MA5Op716S8LWLRCAx1tv/ykhq+TgWDxkZGQ8 +7QNjHPO2FTI9PypuqFN4afGXyAMEjsLQRz/raZStI7gUxhMOPniQ+8bHKVmstTm27e03bslF +ikiFiPEXk2p7kbqfO4pYuxJJzRQcPHZFSA0Dnv75Du5ZWXkNzS3dE8wZK/t4AB6ffK2KwOPD +z2UAchz7TtXJPYHBmMIfjDh4bAkeDkrBGyeJYw9/CChJ3FVrQ1GnLX08NC6Zqwg9eXiRnQyO +W9Uv8F7/cC1JHAQPj50miVNXV3+ZXAyvG3gsLi46OTkB9pD82HwT8JD56uljS9ctwSMhj3T6 +vAhH5FJHn4jzl0VNbTzOXriKjVx64849j8CYfYlcuhF4lJSU3pOQzYoujnbK30HI9PyotNLU +wNoC69ZKzd5mCXLvOcbop3Mzf1hl/dvy4q+mme/QKcdHekX6WuTbqk1aq6zqi/0aSvyq81Kr +czPLMmr2HTzYzqWDI0y6+9Li+6Nj9TmEJnv3HIVHUTdkgq/fD7utuKv4oRwr8SARgI3swwht +o7Dw2HLBgEdiYqKjo+Mr+TNfWloZGPqgqNRuhDIxRp20cUyG4PHBZzIffi77vbCOloFPdl7N +OH0SfyTuQJq7R/9ywfqJR85rcr6gyzBWsndQ93PSCnDSDHB8FGCp4GGliFVPnmq5B7p2WI8N +VWFN2cue68sKHhbbVLC7jaq3q26wo4a/m26I/v2nLa3N/X39fF4uPI7HtsADiqur64WvxDYB +D7ETGnZeUVuCR37NQEHtAEeSuE+OHnfzjy1rGmHHKS1v268kcfyAx/z8wukfTufElaQEEHcx +V8uPOgRFZ18FhZ95ev6MRPoZ1jDygpGE9YtJ+lGglH6J4W7lvlajtprg9tqQ3QWPoa6GscGE +sSGgidThRCbNbIqhNTWhNT2hPcNUW5z/enHhxNzsqaXlkf6h8a4eyvLKckNTv51Lxo17vhfv ++N+Sj3q5jKgx4qpx4ipx16T9vxUy/vsxub/+SwK8kus+8RMMeOzuKzDy3wjPIPEMCAYdP3Yl +twu3VwkvAZdO6hnb5YPi6pX94yXLT0+ofy+kGRaVN7+wiD8JXx8JDAx8ScBeWloiAxn5SSlk +ysgwubdroL66vTS/vji7tjizpiSrpiy7tiznJy3dB61ZU+zyZlqSXV2UWV2UU1NGqCdVt3W2 +9w4Pj5DXZGR4ZGSE/QmWwRVYXubX7xoHjx2Ax+LiYl1d3SbgcfuEmr1PzA7AIzm/DvQj4veV +7ytq/M//vusVmnSQwYPFWgX3DwCPzIji3QIPQB1AwUXIj66lMWYLYuv+4z9+dvLkz/T9rfvb +FAbaFRhjXzPHjy4v/WojINlIFxf+OMP8cmZyXWeBTgE9DnRuGqMzx6HzxrZ0ebmlp4/a0DIE +75CVlZX2jmFnz6zbMn4X7vjf3Al+xEisIccVSd8T543+cUz+bx8D5FifcKFvHCBI8ECBsLC6 +3YPAWSpwxgo8AoQQCAnYMjrOmS/fZo55NJuDB5Syik6/4Jy5uQX8GbgrUt9Bnj8kM4B2tx+c +nJzr66bWlvcWpDRmRddkhlXmRVblR1UXRFfnH05ltzwKvBVWgXPJjKgipDX1do6xVlefn/Hq +/l7w1wQ8oOwFeMir6X7x9cl7ihoAPCRkVLSfWAkSPECPv0PwiNod8EDUweHjAdbATVgfj6qc +8uaKwJbKoMGOh8PdyuMUoSnGsdmpD7bLDJsra+XX87NfLQCdA/r1NFMeWTymJh5PT+gvL/2T +HSptrmhxcXloeJRQVEdnzOQQmufm2L3q0DDNO6Dgrrw/OzamAn/4sRY8U1wlVkTC5+uzj/9+ +VHYtfuYLczwFDB4w2YqoVhiMbQ6/vgx4ANJAwbU4MGYHodF3CzxebTEyMiIQCAKrDlAHuP6K +FomvCXhQx6j+bmGhnrFeNuGW2r7mmj6W2n62ev52+gH2BgdWA7erDuBTPwCcl4WWn4t5aJRf +UqhXTIBLhJdTwPDIMJVKxcHjZcxuHLlaeAqLxdoIPMRPaFu5hW4XPPIqu/7rjd8B8Pjk6PFP +jx4/c/7y2QtXBQAesE+HPT5a5hM8JO5IA/AA+vLgAeutaBl7tjb1D8jU7AIAD7gMqoYFduxc +2lGb09sc0Qe0JbK/NbK/LWqgLXqwI3qoE2jMUFfMcHfsSE8suSeut7l3cx8Pct/wBM11Zfm/ +IZzMz30P2lxS0ZVX2OgXmOjmGU1q7AH4wZiYLiptnJ2bGyHTPXxzb9/3uSYVeFMuciP8gPG6 +7yrHXhb3+upHfZglhOfsTgGDx0ZdOSQQmI5kenYRRs2CZIKGS8IzSGANwAkd50xsjA54HBhF +HKV04RgfAQtgL23HdI4aKbQpsF7eLAHVAneEVePgwftU8em0e9kPtrd3KAk91r3k8FjU8ckN +Z9M7rvrXHPSvr6vBdQfD604G1xwFo+y6rjui2jfUaw46V211rtiyP7n1Cu9Numub9K7aaV+0 +1b9ir3PR1kjUVeK7BxVVFe1t7Th4CECmp6d//PaS5FEjTufSr58aWrhsFzxUtYz+/tGn9xQf +uvnHRiXZaRoYfnni+2JS/56CB0IONNQCO3qwkh/wyI5lUwf43C3wAFc1LbICfOZH1/7suZDH +Z7ktHvviXEru7ZpiaMHJLEABe0wy7Lva+2tJ7VW1nQUlnZSxqbr6zt5+yvz80gh53CcwvaG5 +l7W6Sh2fDAovNLKIl30QfFUqQFQmnCMpqrhKLACSi3c8vjytC9BiI+Q4UOCBHXkBRAHDhqMc +JQAPciu6YKI3lLIEO9Ty7HkGW2wSW1QFBBWw/p2L1ig7LdwR1gK3ovVoJUpPj4MHDh4C6wfZ +uVrErO0Vg9nZaR+EOKm+GLn0hqvuNRvd6wJSnWvWawHbt5hOqyZszI4hds5Y96S+7vcYXfv6 +SMj0kZCJ7vcG3Fu1zhmrXTC2kPR214iwlQ/w1IxWEsaz0wpUwsPDz3576d4xc47ptGoPTbcF +Hrlr5g4RUfFPjh7/+OO1NK+0fxe5+uFDXdO9Aw/Ym1MnZqem5wF4zMwuYsEDKJ/gkehT+JLg +AavLCa8qbx7Li6yB4FHROAotHnDr/k6nJffVzDAlkfvH0sLnEzRfGLm0p4Pi45/hF5iam19J +pU329NPikqtrST1kCt0vMKOhqZc+MUMbZ8YnF1bWdsWn1jw2j5N9EHTpjs8thai7KrHQ0HHt +XsAXp7QBbGyOHGz9XAaBx16LpaUlmvXGEzyweWNR1jPIDOEZJLeoMuTLAUdqOMCDYxlVAUOb +wn2L6/pQLQhynr0Y5hRVDWpBqWBx8MDBQ6DgwU4SF2B618Nc0suBM0mcg+E9a/+nsf7mMXut +gRbxZiqOetdst87Vct5Q77L1bRWP7zzSTrqlYvU7l2Q5SUdZaZfvXJI4Nn3rliKm4vHoIjtJ +nJ1igNEtN2fV8LUkcbV4dlpBiqurK2CP+188xYKH+LUH2wIP0Tv3wZPh/GVRYxv3xBwilf4p +eFQMDf8/Z8/938zihr0AD2TrAEJjzjX3MuiT86P0af7BIzu2GILHtuJ4cIMHtiWpEetZWaOi +S0BFYM384sr+gsfoQPrc9Hnk9TE/I0QbyeRIEtfZSiEQWoLDcpLS6+ubB6vrOodGGBPM2ZDI +3K6ekZa23tCIjMiYLG+/2OCwjJyCeiqNGZ1QdkPK/bp0wG2FCKFbLh8dV94SOWBkiQ8/lzUw +CRbMvY2N47GRxQNrEsEaN8BXRYtEZKzgdi7dBDxAMWS7gCHTYVY17sLwgPJmCRx2FRw89hc8 +oI+HilXy6wUe8oFmkl5Ppb25wcNEwT7OPSfWNWuvNcEjz1bLg9/stJcsz2t6/jWJ+Ld4wk+a +UPjX2DwxKVsxWUewAL5it76bQBB65KG5Bh62Cv5Pbro6qYapbDM7LQ4euyJmZmbnvhWR+fIp +Ao8b3yj4xRXwCR4ewUngsaCqZWTh6PfF1yd//otf/PaNNxWV/3t2lv1+XVz65/ruht0FD9iV +jzJmqtqp6LkEhH+LR3RMTIBrxMuDB6KO5LCq2fll6M5BrBpOj6oEywWxdevUsR8BxGjDngtz +n0HeWF39xQxTktJf+0IcjxdztfR2jRUVtccllnv4JmbmlLe29YVHF3R0DQ8OjyWnEbNyykco +4/GJeQ2NnSzWKpXGkFNxP33B4puzj9/7RPq9T6Q2RQ52/EywoKzhlkeoIxTVHzTw6BygocT3 +4RkkbvDA+nhsCzz6RxhoqgtP8PCMKUcmEZh+7nUDDwptCpwyMvscBPA4XLJrSeIUgpzV2EMt +HNlpH4s6a998aiLjZHJ/z9VUxlnn9lNDUQf+stNa3ZRzPGEdfsIy7Ce1Cj9hESJzx/q+uN2J +p8Hsr9itlmFgl0cX2SHTXR+F28r7e2hGbzc7LQ4euyX29vZnvjsvfdwUgof0CcPb4vf4AY9U +YtORt/6oa2Iv/0AXLFg6+cEkcSFxOY90jq2w2BnWVlb+X/K4JqlzYNfBAzZ+kMl+ZNEn16mj +f2Zhc/Do7e07d/ZchE8CAA/+Q6ZzgAesgjm9OLuwHB1UCatOiqiOC65A3h2wjIAjl/Y2A7Cw +Wl7603NHjjcnxzWHuzt5BBDjlZ12sIdWXt7pG5DhF5QRm1g6QmG0d/SHhKcWldTRGVMJSQUx +8Xl9A6O9/RTlhz4/CJsf++7RxonJ1pHjH8fkVB+5Vda0C/iu5h88ICqAfh86e8CSblFlEAkA +ivD08UDLoAD0TUVVoIOYeOWCBehxyhM84AKoJZXYejAtHnAACKscSWo4LilHSaBw+ImjMEAy +dGTkSwMK8wyEgoOHIMBDMchFg0fIdHaeuOsuepft9UT2Xi/bG1x12jxeOtbiIfzA+f2IrA9C +MzCa+X5Impi07V0pu/eDUj8Iy8RufT8sXUjDXfPiWsh0dnbaneRqwcGDW0gk0vz8TlJBRURE +APZASeIufH/9sYXLluBx7pLoz3/+iw//+SmgjtjM8pLGIQge5c0j1i4BR7/436Sk/7PuV7D8 +Zg858OXBY316SAM7/nZZM3V0kAnbD5bB0wl8wgIbOZfOzM4rKipZGtnDoZY4t4Ltggc8fpIb +sZc8FRZUmBRUCcAjOagiJawKIQdoDyxGiGPnLRUMePS1kBhjGqyVXz/PZ/fuONlpsGNgw8il +vMCDMTY1QZ0aHWZUV/f4BeXWNw2A9pdXtZaWkWZm5onFtRnZJQNDoyMUupZByCkh8y9OavJO +TLaGHP86rqCp711L6tyX3wIHeEAX0I2GWpDDJ/QvBSUbOykoCy0cDeEGD3hYCAnYKiDAgK9H +fjCDuWt57giKgX4Wm+sWruRu7T6CB7wyPJUjaAnytuVWsAnNQYby7X0vniXhRd5f8OgnM45L +eLhFl7924MErV8tjUSftW08tlN0tlPZcLZXdTWQdNUUs+MlOq3XZ4ryO9xduCV+6xP2krvHH +7SNVr1pcV3Y9xl4Tj9ka/4VTjLSE3UsmicPBg1v4jOPBLaurq+w4bmQyBA+5byyvnLuZVNS2 +OXhEppU6+UQ7+0ZnFDfDXC0IPMpbyJ5B8Z7B8dlE15nnNv/pua86BvN3DB6wNx8eXvflGB2f +GSSzwaOoYRQOtWw+nXZ6Zl5LS0tV4WEWmzqKM6OKox22l6vF0LoIHD/cqSzJvWjdyhFUER1S +kRRUlRRWgagjLLoUgYcALB79bYRJ+g3kOzo/89XYYMDWIdM3Bo8J2jRzfJpBnTQxc4yKLXD2 +yg6LrSyrbM/KKQ0OSxkYHB0apqk88vtBmAd4QOT49ISSgUlQY0vfPv4Wtpurhee7Nj+RSDcq +A17zx5mzO656S8cHAYMHdvYNUmzLsdN80BQhLHugktB7E66E84gBw8DyBwE8XkPn0k3AQ/+q +vbmyU4pPYbIXYa81xbsw1C5J7ZIRP9lpAXh88zTk/eTi9xOIP2li0QdRuYrXLS5oer2XWAi+ +Yje9H1cgJueEZ6c9OOABZWZmBrAHAA+lbxxUvnN00Y7cVsh0DvDAxvEYGLVeej6Rc3xSsrW/ +eVvgsY4co1Owcx9jzI0ymHCZSCKPT86hoY2NAohNzcxpQuqIKYbgwTZ3bHOoBYIHqCvClTg9 +t8S2eIRUUhlzsCUpQdVTc0sonAi4nntq8eio6yL3uk0zzyLf0SnGjaGuHH5ztWwFHuTnUlHV +GhRe+MQiNiS6srNneHJqdnhkXOWRLxxqwSQmkwPI8cVJVRPL0PaOwS1vNktLS/DMPDjgcdhE +0OCBPF6gXwpU7olCHCuh4wqHNQOu5MYMgGooJCwOHgcEPAyvO+nefeqo5e+g6bfXCmqxVHXT +EDHnJzut5mVLk0u2pmefmp7jUIvH1x2NLttyrWer0TUH9YumnNlpcfDYV/B4thZbzMXGS/4b +a+VvHDTPu7npRW0XPJQskwF4OEWWQ/CQNIqDzqUN3R2X1LXhi/kK6zejDEMNh+TY/JbNwcMl +sQ104jTm/CB1CoDH8NAkeXQdOfrJk6MDTI7RDZ7gMT278Jw6iiB4JPoURNjk7sDHAzuNBUl2 +WFXS8+ClgslOSxvWXGX9AkUonaDK9LeVby9J3MbgQSXTyRhhMpmASHv7aVHxFRXVPc/YQWDm +NfSCTgk9B4/PZf5xTPHr0+rWDtG9fRT+wQDPTnsYwWMjxuC5EvrPcIAHRySTrU8VB489Bw+b +jbPTuhlcd9S9Yqt7xU4AqnfV7nkcjw0VgIe2iJWasLHGRTOe+nBNN9qkedliLTttpINSEDs7 +rTAOHvsPHkAqKytPnzwr+a2uyreOqt85Sp7U0TS0SCps5gc8xB/HmvgU/CDv9zSAeFrBD4DH +aUU/NKvFIpBo7B0+NXsK9phP/c5nlPpsDh5sh425pcJ+5uDYzPziSn//JPgcGmbOzC2t4wdz +ijI+Bzv9iWm2fws3eIxQxjQf6GVGF0HwSPApCLfO2Rl4pPmve5amBFXMzS8vLrGQiSM3ohrU +DsADfO4ReAx0eE9Qr688d+SYnTo+NmjR3diyk+y0vMCjqa5VTlY+JCQEUQfnM6pnrLKmp6is +7YF26JmLVgA8Pvhc7th3ao7uCYPD1G3dZjh4vALggY0SzxM80KgKdlwGzhJCM4kOJnjc0Y88 +FPcBiUQqL38pd5T29g7li4+NbrmYSbibirsb33HTFLLSFLZGqnXB5icVfv65h2qtuZVqX7DR +vmD7QsP4VrCv3lV7SxlvYzFXKxnfez88rK6p6mzvfIbLvoIHkPr6ejExMdHvZFW+s1c+aXvt +e2nhi5c9Q1M2Bw8j73wRjbCyphEEHg7hpUfvuh6963ZdM/yBbaq0SbyabZq6XVpLb8TC0l+t +Ar76Xlb8pIzMCWn9/OoibvAAvfk7X0sC2ICMMTw6NTLAHB6dpmAMHUPMmdFJJgIPnhaPjCgi +oA4IHvHeBWHWOS8DHnA6LeINbHbavMiavbB49Ld5Mcauryz/Go2qTFBvdjfUbity6ZbgERed +ICIisgl1IOntpwaFEm9Kupw4o3v+ij6hqGFnYICDx2EEDzR6AsOdbQIe07OLPLkFSyNgPfK/ +PSDgAVs4Oj71mvQa4+PjUYFxsYHJbA1iaxx/Git4DUxiK3Y5MClm25oYG5S03v7A5MiAWMoo +hU6n4/yw7+CxurpKoVDAj/3syQuyJ00efO/88LrlZeEr9+VVEwsaNgIPRcukvKq+KxphADy+ +lvb8ywWbq4/CQ7MaVG1Sw7Mb/ZJqI3MagVoFFUHnUkN3g5C0r2rbjgAFT5eZ+R8odL/uYQoW +PFwT29CIRv/AFGV8dn15lNlPZqLen85k2zo4wINYXGpt7JQRSYTgEW6bHeeRH2qVvSvgwZ2d +dtfBo7shbJwstrz4O0wEsA8p/Y+76kt2EDJ9E/Do7x55qKYhKytbU1MDkYNKpc7NzW1+kwwO +0zNyaumMHT6fDx14iGqFocjqYBlN0wCdFHbO6Y48RQ8BeECX0aN3XNFXDmDYxLmU+7LAYLBY +19NNUuwRCIRdeazhwlOWl5cnGBMTdIwymAdVJ9YUu7xTXTtTxpqCK7CysoLfCfsOHlAWFxez +s7NFRUXFv9fQ+NHF/kG4hpzB+bPC+qa2yYRGnkMtSpbJJj4FMXktQen1IRkNR++6mvsXAvBI +JLadUfTPq+7Nr+79UckfgoeGfXpsfsvgWPTk7NWfcqqyfjM5Iz00VoSGWuYWlgFmjDHmn2c/ +mR4ZZqKQ6TA7LczVgsCjurb+iZHxVZHrbjb+EDyCn2aGWGSFWmYdfPDoJIXSRm4vvcgb5F7D +jtqil8nVshF4xEbGi4iIODg4IEPH6OjoltSxK2BwuMADpYRDnSboTGGAdDhqADaB3pbnvIxX +ADywik1yxw0eHESh45zJ7TLa0U/lPjIM8brvMjE1b+qTxx2oBBdcnq1lYnV0dMSvw96Bx7M1 +X9ORkZGGhgbQH6n/4GJwzcteO0DmrpLqfS1u8IjKbfqLsHVZ04i2c5ayVYquS3ZmebeqTQpA +jtqOUQP3HItAYkBynbpdWmBq3UP79LPKATKmCY8c0o298zuHekcZ9ovLf0W97dLy32hMB9ek +emTWwCpo2xiDPVeRAzxSM7LkFRSEhS480TZPDs1LB9QRSQy3zT744NFSmTg2KLm0+Aa6Aguz +fxkdeNBek7MrSeJ4gkdNeb2SklJ5eTmiDjqdDv7pArhXDyl4YLtjFHoUO46wd7L2f1mFBkl2 +QNpnUivg6+qzdWWtKXvbytpasLyyylp/jwNLu2LxOPKDGTxf7phgHBYP9HUTRw5oLMKyx1bR +SwQ0znKInEtxEbDgcTwEAB5Q5ufnwVsw6JUennaR/9HUUi7I1yw+yCY5yDYZgEd8diUEDxGN +UAgennHVADzAJuhcCsEjIrvxulb4PZN4wCcP7dKsg4ti85tj81viClrOKQcg59LBUeLkjDSL +9RvY+S4ufzDGiOeZnRaAB9biEZeYcumCyO0bd+1M3NLCC9Mj1jSSmBxECLHMPJjgUUso6iS5 +UgYkFube/sm+MfsXSr9qW3X27man5Qke2Nkr4F88MzMjsHtVkNlpdxE8AGzAKKMQNmC4dUH1 +mGycYEzPsVjL0OLBerbyDJEHIIvn1uK5+YWpGbbNamVpcWCENr+y9PIWD3i+PvGV3D4bHOCB +oqjxwx5AUNTWbU11wcEDFxw8Xm3wgG9bQMDrsAiQU2KPLts7qkfYKIUG2ybfE5P/8cxZVQ1d +W4+wb+95AvBQtkpWs0v3jq9xCC+9phlu7l+IZrUcE3dr6KYC8IjJb0ZxPLDgAZ1Le0dGxxj+ +cwun10N/s34/NatBYTRvBB4pIQUulr4+9qGpYYS0sEIAHinBhOTAggjH7EDT9CCzjIMDHtW5 +eX2tOjTyeSxssO0b82+PDUo2V2TuenZaDvAY6KR4uftirRxzc3MMBgMaOrAhrzlCU0JPBmwn +AjsXMm0SLfM/0HAYwQPrEol8EtAcjc0dFV5e5haWYhLyOtkTlllsn6iZmytrRMFiLUEmAZ/z +i4uMybnlpaXwTGJ5M3uGYHVbj71fDH1yes1O8rLgMc6cRddho8iliMGwET84IpdyCPYa4uCx +LXn5WS244OBxYMEDyeLioqurq5CQ0M3TsqrnbLSEPLSFPbyeRj5Wt7x3R/6tr5Ru35U8dt3U +1DPj8zuuADyQxcMioFDaJP6dizaAPW5oR2wOHmg67RgjennlvzHjLx9NzdxsblMMCla5dEFE +Q1knJbgAUAfQ1FACW8PAZ2GcZ16IZYa/UVqASfpBAI/yzLyWSsehznvM8aNY2GCxfjFJPzbc +o9xckbgX2Wk5wKO/nRwZEisqKqqpqQmHz7inrkDeAPwAJy9gE8cjIMGCByiDwGOjkNevmMUD +dEywO0YXB6xBcz22nKOxEzMHe0iFZeQQ7R+ZvzaCsgJunlHapWE6s6yiDRDj/OxyTzc7gsr8 +0nJiZkV9W/8glSqu69g9wp7j7BqZq2IRBIrtgDy4p6UgSEBpaDYCj2cvjtSgleBa9Y8wsLVg +Z8rg4IH3g/gFx8GDW5aXl5ubm62trQF+XD8tpXreSvuCp6tOTJBN8pdX7Iy1Pd87rasgaxKS +0XD1Ubh1YIGQvMuPsu4PbFMjcxphrpaHdmlfiLudVQ44t6ZfSrhvHrm0uz+gueXLpaV/w/ba +QBnUD3tar5FKtQuSgwB1+OgnB1tkBBin+z1OBdSxv+BRV+jT0/RgbOjs/Oxb2DYvLrwxOnCj +q8G8sTR+77LTcoBHR0Ofp4uPiIiInp4e1tbB7cuNTTjC8fYK3+ixfetrCB7YE+cYbtgjfw/o +xtHU1XtCzGx0YhYs51Y2s6l1VcLaN7G5a3B2flHXJvaEmHlSXiMoP0Cm6tqGrjxb1naMdo/J +AWtG6NOf3DKg0CdXnm3b6rF5HI8to4phZ84iCwnY652L1jDBDdZZdyP/UiMjIwKBILB/9OFy +LsX7QfyC77sEBgZOTEwIoKLV1dXp6emenh4vLy/wBv1I2EXnopf+Ve8vz9q46cRYGUaHOaaG +OaVpaYUE2iVIicmeEroH/l9C54Rl5JVk5JW/vfpQQdsSWTxE1APsnDzsnD3tnT3NrezlFVWA +KiiqWFjbx/vlJPjnBjnHGWiYuFr4Z8Q41pep9bVfZNLf5YCQleWfk3v/QSJezwk3iLL3Fzx4 +lCSnNJVaDHaITY7/k6Nty0u/Yox9PdCu0FTqX5pG2rvstNzg0dM8ZGluAxARPL2RlQN6dExN +TXGb36HFA73Co8cvnEMKC6De4fW0eKAktuBCwby0cCW8YnwGxdqOsOEwsaj+W0nb+QX29BAz +32T2TbUirmjss7Sy0DtAfe+czr+umYupezxbXWZMTalZBM6xWFqOMd5JRFB+cnbx6G3DPgqD +9WzbLqY8wQOQJ7c7KE/wePZi1HR4O22UeI4jMAgSPDst3g/iFxwXJCwWC3Re0O8UiO4lLz0R +b6D6V3ys5EI9DeMei/o9ueEf7pIeAdQ1w9821t7IC6iDsbfb0+Aoj8xooJ5Z/nbRWiqGUPXU +jJ3NfNlq7utlEwrBA2hiANC8xMC8JKBB+XHeOTFuKZlhFhVZ4n3NX0wx3uTo6+em/+9Q12ek +QrGccNOsEKuMIMeXB4/CuNDyDLfWSrUu0v2uehk65VP66KdTjL9xVL2eEW/ivZGe6+01JtW5 +iQLITrsReID/C4DD1tZWLHJMTk5uNHUF6+OBLBtwnAV+hZ4eryd4YLtISF/YkOCwd971OB5r +bqOsHvL417fNugdG2f1+egl0LrUNTKtt7e0ZHv/qrpWyUcxNJRfW6kpOcX1WcX3fCFXJyHOY +Ng7KF9d3nVe0np9f2AF4oBAlHLYIbOgSSAvoKwd4TM8uok2QXlBWX+z1BHzCM1HLvoBHRdPg +xNT8obgt8X4Qv+Cvp4C35sXFxZmZGQAhTU1N5iYWajI694Q1H11xhODx5Ka/yZ1AW6UIR7Uo +V+0YN91YD704H+NEH5NEH+MET8N4L8N478cJviaJIXZpQINtUoMsU4KsUoOtUwPMk51Uo50e +xDirxbg9ivPQTXDXjnd7FO+uGe+uleChneCpneilk+SlmxRgFBVl75Xq97QwXr0m725L5YX+ +ti/Hht6bnnhzeuL3gEM4zCMzzN8jZdL+TB3617oOA/2YtqbTzLdnp47MTa+H1Fic/83s1B8m +x/9Kp3wCqIPce3q4W3ikW7i7Qba7UbazTq25zKy2wLs0LZUQW7WnuVp4gkd9WXtCZJqznbu1 +hW0JoRw7YwX8a+h0+vT09MLCwuZOhrDjWFxaeWSfduQHs8ZOtufAbd0IsAw+oYLlx+7ZYH1T +NwX0GqWkfrDsFlkG1gsqfNbWYmlpefPmzV08IOArpNOzC2j9OHMWXKXiuj4IYLv/+2L/xFjg +r661Lzg2d2iEtrjEntUyNn5lena2b5g6t7QcnVpu5pqYklfHYq1OTM4sLS11dQ6NMyZXV5dG +RqgxWWXdI7Rnz3bkXbpngi7mljl8BQweJaR+cFeLG0Th/SAu+AU/RDI7O0sgEMTExM79cEH6 +wkP9G55GtwKMbweaiAWa3AkyvRtkJh5sLhFsLhnyVCrEQjrU8l6o1f0wK5kwa9lwG7lwW/kI +O4UIO8VIe6UoB+UoBB4u6rEuD+NcNeJ4goe3XrKPfrKPQYqvYeqWPh7xblF5kXb5UXb50fYF +MfaV2dot5ZItFWxtrQQq1VbF1orMpyXJzqUpLvsSuZRP8Gip7g32ibgnJQPjgGHHUzYJe745 +eKBl+ArPkZUDvu3C91zwogp4g+csmP2VVzVk+sLSyjI7Ogfb4rHIWoY2jEZSTyaxMbOg6nkp +OM12mbW6zFqfb3uIAzPiSeI27wePHDlCeC7cM1xIJBKBD5mf57Tw9PX1bbkX98g+hULZci9Q +hmMvUPuWe1VXV3OfPj+nBq4Ax17gKvGzI3d1bW1tH3/8MQ4eB1bm5uZGR0eJRKK5ufnAwMBB +A49DETKdH/CoL+0QEhJSU1OLj4/H8gb4aTOZzOXl5e3+42rbhpHFGyAHHDrhGEABBbBrCNU9 +4RkknqPzOHjsgf0DcgUAD8nVVdby8sIUczExpcInvNDdP4dJn2OtLK/Nt11mF1tlsW0lzwQS +Eg4Hj/2Qc+fOYTNlc9/zgEx+xodwz0oA13zLvbh758DAwC33AmW4IWfLvUCPz/Pe2FLAFeDY +C1wlfnbk+VQB699//328iz+4j8jV1dnZWTr9pxzr4GX8wpmrsiLaurdccPDYMXhU5DVkxOWj +q4r13xgbG6NSqTMzM6zD3dXg4LF1bwxDpg+P0k2cMz4XsfjoivHn1y31rOJaWwdftVMVLHj0 +kxnHJTzcog9HcAwOuwRu8dhriwdYDz7x/h0rgplOu11ZWVmBEyhAz5iXl2dtbS0qKip85rLU +5Qe6Yk44ePAJHsT0Klc7b9l7CmfOnMHmkMWaOBYXF/FfwWsFHo1dw//f58rvn3/8nbj1vy5b +//xjFe8YIg4euOCCy2sOHhyyvLwMOkrAnK6urmJiYiIiIgrXdHDw2Ag8ogKSdTQMAKqBCwUe +vykpKQMDAzt24Tg4kpiYuKe9yWsCHu395N+dUA7LqFxeXCqp7H3vwuPkwgYcPHDBBRccPDgE +vJhPTk6OjY3BkQKsP6TWHSu1W8am971fW/AoyazPSyqH4AEuSHx8vL+/P0pYj4ZUNpkSe1gs +EocrSdzBBI8BMvPICQ0RBU+XgIIb6sG//Ey5rY+Kg8fLSHsf9T+PG+q7ZeEdCi64vErggbV+ +zMzMjI+PUygU2KVmZmaCh4zomkhdUda4a2arFPLKg0dcUIanfeATHTOxW+JCQkKANMi8ZHR0 +lEajTU1NcUccxcHj9QSPxYUFFdOIhxaxNgG5mvYpKmbR3T0jOHi8jOBJ4nDB5dUGDySrq6vY +93foiQpe9g0NDc+cOUMkEhF4OKiFvzLgkRCcI3bz7smTJ2VlZcGjFfAGNp45djBlcXFxfn7+ +VXIZxcFjV8BjaXHR3Dmyu3e8vW+otXswKrksv4j0qp0qDh644IKDx94LHIsBb/fIEoIE9NFC +QkKiF+/cv6GqfEfHUNbOVNHNXTvuIINHtE96sFv8U0N7Uz1rJQUVdC4DAwOAqbgtG2NrIsgk +9Th4HFLwoDIYobGFbR1DJbWtpKae7KIGYkXr/NIcQBL2nNrVV+FUBZyrBQcPXHB5PcEDydLS +Eoy6CTpiQCOov87Ly4uPj3d1ddXT01NSUjpz5kx3dzcCj0f3jC3UPNn60Etg4BHnneNvH+3v +EI3AIzO8TERE5OTJk5KSkqCRoLX+/v5lZWU8x1CAgNMEJzs3N/cKjKTg4CEY8Cis6jR3imdM +z66wfyyr8ZnlviGZlLFxdhCPVwU8BCwVTYMAPO4bxeKXAhdcXk/w2Eiw4UG4xdzcXGlNZGVl +T67J1Ys3sOChIfP4keyayj3RlHvy9JGLo0GAk2EAFjxcjINdjYPdTIKdjQJ0VUz0VE2BYsFD +4tY9idv3IFoAAQuwUmxLOOKIIqHRfgotzmKxXgfSwMFjL8AjOavawjmuf4ganUisKO9MyKpJ +yqqqqGxZu7EOWpT0w8QehyVXCy644OAhYFlck6mpqcnJSWgVAZ04z46eY0TD9UXR1NTkZgYl +jKCS2AJ5a4KN37WJQIMGk8mcmZnBo20IADza2tq4gym9KrK6HjJ9eSmTUFta1TZKpg8O08gj +o40dvcSalqq67gVwj8FA6WuhS3H+wAUXXHDwEIAAIJmYmADdPY1GI++lwHnBiC6AcAf0w0XA +4PFKCwuCB405ZWAXVVjaMjU5s8JiMZmT/f1Uv/CcyIRCCo2+VpAdLh0Hj23J6PjUd/e9w9Lr +8EuBCy44eOwFmfAUbBkIEpsUWFxc3EFKFFxw8Hh58OjqHdU2DconNrW3DYbF5iVmVFRUdccl +l+cSG8vrOmZXWAsrK7ifx3YFdy7FBRccPHDBweP1kdXnummh9aGWtIzqtKyKwWFaTUtfcRu5 +tofa1jtGLG/s6h+NS6+o66XWdjD7yfOz8zBt3GElEAKBIMjHGg4euOCyLVFTU+POv4MLLjh4 +HCLwYP0EIAgzuLHhZ4sr4n6xRUGxxKbO0bYBZsvIfNPQRM/YRE5RfVZeXWJmVVUnjdjMKGgg +13bR24en5pfmDyl64HE8cMEFF1xwwcFjr4S1CkljgbVCZi629dNbeqkdg4zukckeymQPebKf +OkOmz4PeeIR2TVTdzco9k9QyVtM6lFnUQizv7uqj5+S1ZOc02brFh6XWtQxOF7SMOsS2n5NL +JDUNrK4uHEa7Bw4euOBySGV6drG2bRjoHh0fHPnDq/ZAN6+CQpsCv2ugGxXoHKDBdkIFXw/s +JYXnaxVAAMuiWmFgGXxuucttwT7QdJwzQaXg86BdPZhgek+Pf3hntZCZC1W9E3lN1JyGsdwG +Wk4DfU3BwlhO41h+0yjojXsGLpk5J7kFFpRWD1fUU9KLerLKuuvaKKRWakY2KTGr1iU4I7di +SFQz/79PBR8TdkpJLWCx5nDw2FLmF5dtggrrOw5xBkZccDkgAvpHgPGgD9o78ADHB8oTPAD2 +wK4ZKCgDO2ue8r2sNzwO1CM/mIEdDyZ+YM8FNht8brnLWUW/PW0VQLvwDBLH9dyyYa+kReWQ +xfFYi7lRUj/sk9pa2EkvaqcXNo4Rm6jEJvA5SmweBctFQJtpZR1U0Bt39pxNzq9PzKyOz6jJ +Lh+JJZJjigdKGsiFFe1eoVnVLRRCRYtjUMl15ZibClb6RkapaRkrK6y1MZxVTsXBAxdccHnl +wANuhT01P+ABSoIFoAA84NcDyB4HEDyQ3QmtAdcNtPAgG45w8MBKXnXvSemoO0aFEYTBktbJ +4mZmcQujuIVW1EIrbmYUsb9OlrQyQG88RL7iH1NeWtU+MDxRVt1d2TTcSV6oaeyvaujxicpu +H2J2DowVlDbllzX5B/qG+Pr39fSsIcYyO5o6VlcP+pwswYOHS0RJP5mB9xq44LLX4LHdgRiO +8ltaPOB62EFvCR6oB69uHoKH5RjFgLWDt3vu9/2NTgRu2rILRkfgODhY09RN4R880JgRT/DY +qJE89+JoHjwFniUR4PHzv9uolj0dksPBY3Nhzo5HJeZckbH9VsLbKJDknNzvmNjlmNTulNLp +nNLjmjpgGtqg71UCemPy2BUn/9SY5NLWdmpDbV9kNMHEKr6Q2NzaRrF2j0/NI1XV9xaUtQQl +EpoHGVWkMSpjDhpWYHSP57rCjjK2eqDnvOA+Hrjg8uqBB3QDgP07WGjspGC9F7Dv0bAv5igP +DfubgwcHV/APHkDkzRKwLQfVYWvHei/A0Ry4CRwBdtCgLnguaBM4IM+qQXnsEVCN2H2x4z4b +gQcogMpjLxHc5dhdNzScBL6mEltR7dhhJuz1hw1AZwGKmXrncR+fo/EQ1TicT0B12Lbpu2ai +hsGLiW0bN9fh4LF3wloL87WwONvb1Z6YnOISnBGU1R1ZOBSe3xde0BtZ2B9BGAonDEUV9lv5 +FoDeeHDkQkx2TX0PndTa3949VlI/6BKQWVTe1NI2QuoaT8qprGzoLq/qik6rKCANWgW2+MdV +jDNmO4cn2gd/0o4hZufQRNcQvY8ySZ9ZZq0+T38MFlhrM2sOwEAMDh644HKQZZM4HhuBB1oP +Oi+4DD5hX496f9Afoa/c5WEPtXfgAZ8D8MhoGRwBEQjsu0HfCncEX7HtR41E5wXUM6Z8o6ph +/wsKY3eHuCJjEodt20bgAdoJFkAVYIGDmsDCkR/MwEoEM9hN8AjYdkKiQG2ABcCZWgYUcB8f +LCNsAAuQr7ANQ1cPHAEcE3yCxkC6QI0Be6HaD6BL6qsKHmsWB9jFs8hjcxXN42Xt4xUdzLI2 +emnruha3TpR3TFV3UBIzy0Bv3Ddy2SKgWtOhJKu8r7Gd0k9eItPnqxo7a5oG+8fmalr76zuH +0gtqajroFn5ZEoZZLhHVBc30/HpqAUbz68egFjRQi1vojT2MUcYc2xWE3RDWAfEAwcEDF1xe +MfCAPQ56JQc91CW1IPjT4+gTYRnu8rAf5wCPpm4Kz2kpOwAP7JEhXSCTBTwpaIXgeEmH7YQe +DqB7RTiE+ISjXnAK8AjcgyOoC56eXeC+FJv7eEBjEbos0OKBjA/ovFDt07OLWDsPB/xw8xLH +8bmHWrAN4z53SEHoXNCF3egq7aLs9ayWw2fxYK20DVJJfcyKFlpRI5XYTCU2ja8p7bmONfTP +RaeV1TT2gN54YORSeHrHI+tiK/+K4prh0GhiQnZjSf1IXtlgSnZ9am59clZdbkVnUEJtYGJ1 +YFJtVdckoZX+4gE5dDy/YaysY6S2a5zURWODEOtAXBkcPHDB5VUCD9BNoxdtqMgJAfWwsAzc +kWd52PlygMc7F63Rq/dLggfqlFHtyPUUNQa0E1UHFTUGgseWAMZh5IECeQZrxsHCxibgAY6G +pvBgj8DhXAoLgBPk7uix7eRuMxwx4T7+5uDBPaUI/Jt4boI17il44NlpOWRx+Znc0wxh9axI +wlhFD72slVbcQgVaxPYsHQefFe3jFc0jsSmlLZ0joDdu7rhg6llGbCAXNQ2T2odTsyvTipur +O0Zr2unVzdS0/IbweGJLH7WsdrC7fyIgutAnqb0QHKFzoqRlvKSFBrS4ZXxN1ysqbR2v7pqO +KBg+K5csrhVBHR99tsQ6CJ4fAgaPw5urBfxsgW4SrGC7B6luHuLnaKAM3EsATIitiJ/zBa9y +sBh6pxOAgP4IO7UQBw+ODnecOQunjVj6E4rr+qA2dLInsEdlN4D139330nZMBwtukWUblQfa +P8LgAI/yhgG4Cdy6LwMeZQ39kGGgNwJoD1iWMIzG1g6qyCrtgGcXk9OA3bS4tALBg0ybhAcU +eRgCSl7XDOWoF57m0TuuqCTWxBGSVgu+TkzNwdOHD6WNwAM20ie+El4WDovHt/e84MFBs8HR +gDZ3jRp55MDaQYPh1gfWyfD68/zf/eWCNc/jbw4esGEyJnHrPd3Syp/OWcCvOHjss7nj2coq +a6W2uV/FNOrEnYArDzPtozu907o9kzvdUzrd0zr8MjsyKsmAH3KLW/KIHaA3bh+4ElsyVNVF +q2oj17YNkbro1R2Mug5qQ8dYXRe9rnuisLY3Lbe2trG/e5Da2Dnw1Kv0gka2nE2xW3q3Z1q7 +V2oXUO+1T68UoJ320S0/Kib/U9jz/G1r/cdWRCJhfv5ApIYX/KwWyvjU8spumnuauingOQaU +w0F9d2XzYAUmXrngCQBfWMBj59v7XsjBbKODXNUIAQ8lflhlE5928JyJzm7YLbLiNsVvDjx8 ++gC8jIDnMOh3gK73WfX98MH++swl3BI84H8NKfhfQP8NaGaH3gXoAiLzAvaO4i4PHRe3nE6L +fUNHDdgIPFAZrKvDM8zwBPRSgM6Q2B2RhwYsgL1XkYUEKE9I5janYK8bWAN+g9j5NRuBB9Zb +A9WIwAOZZThm63DUjm0n9+8a3NU8j4/+C5v7eKCrgWxBOHjsr7B9KVZZy0tLw/29GbklYVnN +KZXDaTXk9GpyWvVIRnV/Vee4TyQxjUhq7aUTitpAb1xUdyazrK+ufaR5cLK4jVbQwh5GKW2h +1nczqtqGajuHG3tp1Y3DecSGqrru+lZqVGplQTPNO707tZaaWTeaCT5raRm1tPSasbRqcmbt +aFrNWFB6m7tHiKeLc3ZW1tjYGIt1IMZaAHXs6agch9R3kMHNr2iRuIvHFED3t2VHDB6MaCQa +PsZ5PoH56c23BR7glLE251cPPATwtDzU4IFFDmyUUY5ZKgiD0S4cToYc5WEHt3nkUrSVQ7lL +ojhjUM8p+XNAAsesFuy/m2NaB/SIgBYPOPbBMceEQ7CzWrBHRv078ohAtz3PyKWohbAN2MsC +zwhtxc4R5q6d+x+BCsubJ/A8/rPnozwIabhntSAAY+8eW859LqjGLQOx4uCxm+jxbHVyfr6l +b6KsjV7WzgAIUdy8NhTSPF7VOVVY3e/ik9DRx2juoBWWNTf2PA1O8X3qVfrIoSowdyCrnpxb +T8utp+aSxgoaxso7R0uaB0id1MYeRnZJa3Jue2hcXXouKY5Q1zC8sDbOQl37hOMstLWK6MWt +tJJuakkjrbC8u6uHApPGrLBeu+S2e+HjsXn3B37F8HUjMrMeO4iA9eniGFZAu4DfO4djGz/M +sMm8e+xBwtLrsEeDLvfw0QQagFqIeAA8xKCLO2oVKAD6C/Dk5DgdnqcPFJ0gOhT2aJuAByiA +mgcH37mvPCzwyD5to9qxXQO64GAlnCOJrQIdBL7kovkLoDz34A7PcwGSX9kNi2Ev7CsGHvzc +ii8Tx0PAAqNYbNQwrI0L+XjAqTdbW1nXinHPJAXHxI7C8HN9Nt+60WTVTTbxefwtz5TPS7Gn +goMHVpYWl5p7qNW944QmOofPZ2ETraydWVhHLmkYaO6drG6hkDr6usgzhEaqkV/tRzdjP7+T +qOVVo+9L0vOtBarrU2MYUOOS1BaQ3eGd0PHYqdjErSwgtbWqYySrvKW6e3oj59LCZmpB82hh +83hJG72mm15cP0Slz7122CFw8ECmWmiBBN0QUA6LBHJvg0827C5Yp3T+wWOTl3TsQc4q+qE2 +oMluqFLumYNYMzXchA0RwF0dOi+0O6wX++6GFjr6qZuAB9ayjQ1TiTUCo6MhBMIa2DkaiU4Q +yy3YKrCefki53R15ngsEDEWLRNSwQx3E4GXA41UVDudSXA6I7DV4JCYmOjo6HparwZyZE5GP +e+zXUNL5/7d37sFVVHke9z+namfArXJ2tGpntBQc1NHCUSlhZyQlpeyMCzgIjkhE16AriouE +AIpCCPIGuQl5EFDCU4KARh6KPBRCEsIjiIDkKYFCzOURcjFjDI5A9pf8an/183Tfvp2b5HIf +30/9Cm5u9zl9um+f098+53d+x7enwrfryLlm+6rZdrb8u7/su72VdYVl3gPV9flHLiQvLOk+ +ZPXY7N0fFHybtbY6b/fpvN3ej3Z/S5ZX7M3bc3bT3pqtJac27D3zzqbS9ftPzv2w7Nlpnxce +rd9fdaHwaC3nbFqz9vDuqvLuOnZ+Wm75XY8uX5u3/4cf62Ptzgyl8BABwMqhR3wGSQ4ycWtn +pcEO9vopL0lYD3CntEvhIY5hAX08RHjIKC0/smXI23banQzHU+HJ6MnL8wqtPg/SV8AdHbyS +V5Nlkh2f49INJQ7Cg4ok+ct8BEN4sKi7td8sw2mfD0r/Wictcv7cj6EP0X/UUslfwk3QZw6V +aR1eN86FrxsLD94kR/fXLwThAeEBwl94RBaXr/z05tydtz7yzhOvfbqu6BTJj91ldUVlpDTq +dpXWFZTWFR09X1B2fnvpubm5Zb2Hbbqu18IHnlmbs6V6f0XdvvILtLXw6PmiFmseQCk9U3j0 +bNGRM7tKawsqzxZUnsnN/6bH0x/GPb9pxorSLV/W7T7qKyqtK2RrPpCPrbD8/LqS00MnFdz4 +5+z7B76dmpn+9fGKWPst2Mdj5Mz1IRAe/O5Mjx7uQH4wIZu73JvUlLcmFbXAmkQHWdIP4kFJ +K6Rv31Z1+IvSYys8rF4c2nnM2GqcrIOPhxGcQQs//e7PGdJj2tnHg4MnSBREQ3joiAq8Sa6k +7UkZgsE4hKgXa/eRPqK/c+GtLDykYAFnXkB4RBBUWx99JQfXAcIjvLl0oqr8zbdX3N4v84H4 +D0dnfJGUdWBM5qExGYcSM75ssUNjsw48Nj7/170Xd/lrzpjskh1H64rKfTsPO8TlOLfjyLnP +v2q2wvKzuTuqew1deUv/Vf1f256Y+cWYjIPNmac3Zz4mg/899Gr6oZ7xa7o+OO+J/5k5MSUl +Z/GC6uPV+G06TnjoTng2eiyyb5V+nOnA0dYk4o6lH8QygUV7agVUHf6EhzXKQduFh3MvkBY5 +boSHhFIU53x/woMf9xJfWj/onYMP6EO4FB7+zgXCAwAIj3Dghwvnv9i/J2vB8ldGZ418fcGI +N1JHvJbx4vj0F8bOfz4p7fmk1OFjZg9I8AyIf3vk2Kyhb3y2dNuJomMXCsvOBxQeBeV1uytr +J8zfmzgx7dlXZgwZ4Rk+Pmv4uFTONiHRwzY80fPcqHlPPj8lcdzkebNSVue+d+jw0Ybvf8BP +09E9HrYyQAIo8biG6AeHJM5DLaI6nENM2AoP6yyYjuvxEMdX6SXgfoNX52zwJzwkgCQPP2nX +WeuVl1ESfz0eVhXX9P8xneQQpBncCA9/58LKB8IjDKFfKmg3G4e00bECGoRHFHKl6WJD4/GK +0o0f5mame9JS56Slzk1Pm5c+f17G/HmZ8z2ZmanZizKzsuanZ+T0GvxulwErR3j2flxyZm/V +d82xxcrOF5c3255mq2Urpn+/9m0+cOal6Ttvemhx8ox5Oe+kL3lnceb8tOac097OoGzTU9kW +pKflZGYtzlm4fNXizz/fdvJszY+XLzZdufozakMcx+NETV3PYVkZ77fnULs8jHiyv8yYkAc6 +uxkcrvRaZQk7QsjT2UjS1OK+GFB4yAs+T8MXcyk8JEIjB6lmJwr3woPL7+DjQVt5YILdTmSY +g5trvg5rth7yJzzk+c5eFrY9HuyDQfmTCtJ9SnJ0OSntZ6IXLNOHsPZ4yCZ/Ph76XLgAUSM8 +ogb2tCGrvdAQdFrrfR7cnG5dT8m0pOE5ZdqMyb+0M485stFnCREG4QHh8TPd0bIqyqVLl8+e +O1tRUVlaWlrWQnl5eWVlBVlV1dfHqo/Rn+UV5Ws3bhnwYvZNjyzqlbB+2tryZTuOL992cun2 +U8s+O7Vs+6nlW0+t3P7te5/VrMg/NW3N0fue+uD6Bxb87YVZ6Z75u4uKqqurKyuIcvq32RTV +x74+efJkjdf7fcP3LWvHhMWkligImS4tjzEDoskSuUinkkeh8b2RxE1cC73ek15f0qXwaPr5 +/BSZoOFGeFAbyHEXrbNajPU05bg6ZoIckZ4FDkMtegTKVnhIhjq0lz4pYwlR68XUh9DCQ1xt +nWe16HPhAkB4hKHw4N8oOOGhHcLbLjyst42xVI2/W1cclbW1ak5uFJOXl9ehTxN6ZBcXR5J/ ++JUW3Ox56fLlGu/JjRvyJkzOenBIZu9nMp5MWvb3xPcGjVn9eOLqQYm5jyfm0ufBSasfH5/b +66n53f8y/amXp06bPfXjT9afPn26NUUKiysTBcJDYjvYvqTwognUmMxbUWD71mOd6SBJ6F1G +miOHEOISbNwwf+9ZnIkRx4NDXlD7Jktp84iPEcncGshi6YYS7mmxvTgSSUO/1knQDDpNOX2H +kOkSK4N2lgLowtAO/A6Y9/lX+uh09TghbdWXznox9SE4BIdsIu3BP4dtHA/bc2lScTz0a2wb +I96DNsJTsdo3bVuEB92WW3ZXGEvKykAn9xOKDjGm29MmcUGH8AhZj0pkrdXSKv55qen0uQt7 +9hQsW54zbcbsSSnTJ6dMeytlSou9NXnK1GZLmTppyqzJKSkzp05PfXvWp1s+Plt35tLlyOtw +wyJx4YZLdxEAIvHeZnnAscJkPjtpQuNupz9ZYepodVpaHK708lZb4SHJ/bmF2IapMYSHrbAJ +6EAOIDyC6RtpCSpK1tDY8M03J0pKSgoKiwqI/HyyXWS7drIV5BcU7NpRWLDrwIED5+vqmsJk +udlIEB5DJ+SiEhnNIDuoSOTqWA4SDqJVdcjAhDzc9biGhMk1JpfZdmvopXINrycdhU+Hi/cn +PGRGla3wEBcs3eMRoTFhIDzCWntcuSIDIVcuX7586dJP9vyT/7t0KYI9i0K/SBxpj9O19ahE +1mZQhps7dD0FAMJEeEgEOe04JA7ePI2FezwM4UFS4YY+b9EmPRTCm/R0Kh3szrbGUUUbn/qJ +sWidFEa/CIiPBy9eL1UVXkMQHiAihAfw1yxjViCwMmrUKK/XGx13uLXHQ/cqGMJDD75Yxzv6 +j1oqLzLWGdbi26PXl/cn9fUyRk0W51JZmU7gpd8cVisAEB4grISHr75xyqLt8PEDwCVRE8fD +QXjo4DB6NpZ0KWjhwVFfZIVrvUlPVdNrG/kTHiRyeE1Y2xC70p1iKy1oq8iP/V99gxu1qWXW +SYeudQ7hAeERHHAuDR/Ywc+2p4UjZmizXdlT5u/Qy6m8YwIIj7YID4ZnY8kgiFYX7ASSMHmd +VXhIz4lx91oLIz4eFSfOcnJxBdFlE4cT50UQlm4owY3ahNVpAYQHCIS1S1nPHbaGJdFtryyn +a3gGAgiPNgoP66iHNX4L7dkjPsO4FUWTGDPCbCWxdi6VUHu8p1E2qQtcMNpZSigxPbbtqcKN +CuEBIDyAS+HBvdmPjV6uw4/LBEPu0NDvnroppjafd6DWGMIDwqNdhAd9aawKRPekITzk/rSO +p4gO4Rz8+X9q4SFyhQdcnNdO0jNuRJP/o+EiblQIDwDhET6Nre2a9S0vYhf1EAa3rtY9+Xvb +wQ7GNrCSGz9V3ZxKh7PRsMs7o26obQe+dUQv5wKD2BQeHBmPrPZCAweLE88K3iTB9lkw8PQu +CWHHaeVWH/LaKt6BQ+XrTToHw3FU4JB04jXKScjopjXKxq0Wb92YX6ozJ6PdcJ9DeIDWEhcX +t2TJkpAdLnacS6lF0p7zMkOWGi5usp6dtEYGOHTob2NEQ79YSWMomVDLySHTdSod9Z1zsJ1R +qPXDiW/rHIRHk13XtG2IszVbD+kCo35BeAAIDwgPAEIDPZ3poU8SS0QFv17JOMXwlHW621ZG +NGS8Q4aeSVQY8QQkE0oS/8Zq/ZTXqaTb2Vl4kNhIyd5mHdcWJz2JsMQFkwmMnETLD16dlqWU +fmcEEB4AwqOD8ufvA+Lz+XSq5ORkN6mMF3OqjG5SWccR3CSkE7GeHWkt51S2YiwuLs5NOYO7 +kta5S3SVWnslQ8yeIyd99Y1RXwf10AM/uI1F3/7RcFGCIrJHPc8T1HMGtbO9eOzz6iTyufZC +g0MqIyqjVXjI4m5aJ1idS0nP6AEdHbhJ9+f0iM/Q69QDCA8A4dFe0PPO1jGAF6cLSGNjozW3 +gBw8+LN+XVIvblJZH81uEtKJWM/O4/E4p6IdrKnoKe+mnMFdSWuLRFeptVcyxKqDnlMJyWuj +vg7So1/Ggv0tc2+dRSjxjqxBF7V/ne1Ksno6oSEhHIQH943YCg/e5BDKgA4n8oOTS/eLdv4H +EB4AwgOAq0WMOJfyabIPBq9f2VrhYZUQboSHVa4EFB5cqoTJ6/TyEzqVeJb6GzrR8a5PfFtH +kkO0FrQHhAeA8AAAwiMEeFYW0Gne2m/Wtj1VG/NL//Olxa0VHrUXGu4a7KHP/ztr/dINJWR9 +R7xLfw5puXT+hEfNue948SxJ1Tsh243wKD125oY+b5HlfLTfmv/hSq8Uhv4cnrKOduD8M1bv +5k1csFWbDxZ8cfzjgnJ2eV358Re459tdeLjp1bR2bFImblLZdvYGTGU7ehuwizj03eZWCZeb +mxvKbvPgrmSHdpsbng8uL6a125yubffu3SE8QBhyoqau57CsjPejf2FHGYOgD+waKrMF9Zqb +xpQT/lNmwhqzWiQigc7ESMWzC/Wh/QkP7poQ94wFa4o5H54zaBSMA1kbnq7WgrHEwvpZHYob +Py6rKxc9TdyksnVvC5gqLi7OmiqgU1zoHQWtEmLAgAGhdBQM7kp2qKOgVYy5uZhWgcQ3WLdu +3VBDAbiK2EbYCAJ/kUDcHFr7tbb72dkWLIjSAgAAACBCmZmzQyaVyJpZ1oAbAAAAQCxQfvzs +v/R8c0LGp7gUHYQOq6jnmwAAAAAxCNZq6Wg25pdyOGgO+4x5JQAAACA8IDwAAAAAAOEBAAAA +gGgidiKXAgAAACBMtEcsrNUCAAAAAAAAAACA2OF0bX3vhIWIpA0AAACAEADnUgAAAABAeAAA +AAAAwgMAEN34fL6HH+lzTeu57fddjTVqAQAAwgOUlZVd+4trg3isjBuXhKsX9WzevLlL11vS +3n19X+X77m1OVtJ//OkB68rsAABgpfHHn2Yv3fllRQ0uReyQl5d319139unba+X6We4fLq8k +xd/f417SLbiA0dkUNDaStvxT3P2bixa2SnLcfmfXfv0f9Xq9uIYAAADaV37krJl6z7135eQs +xtWLMkhP3nf/PaQtg5Ac6OgAAKDHA3Sc/PisJGfAoIcHPzHQ5/Ph6kUH+/btveMPt7nXn5Ac +AIC2AB8PEIT8mO4Z3aXrLcXFxbh0kQ4JyH6P9S08shKSAwAA4QHCWX5sLlrY/Y93wOM0omFX +0g+2pUFyAAAgPEBEyA94nEYo7l1J0959nSTHb37zbx6PZwcAICZp37H1UAoP/HYRxKuvvnrt +L64l+bF+RwY8TqOMVrmS9h/Up0fP7jAYLGbtli6/e+GF59uxCQrZWi30LOvU+Vf4BSPOpntG +w+M0msjMymiVKykMBotxmzRzxNPD4iOxuSPhQU8x/IJRbPA4DWeqqqpmzZ758uhhqYsmFJeu +wu0K82fTPKMmTn9xybpp7Zjntn3vUp7tni0sQoWHt7b+5RkffbTjKIRHe1nuprmtql+0J+1P +lb19izF3wVjKlgoTynPfeXDZxOkjRo99cdGihefOncPjPrLcOWBXxeIe7vHbm280rAMr6ZfL +nHego19zzTUjEp9sx4Mu/3AGB0Bu32xhESo8QubjEc7Cw6jy1A6s25oadG5jJv53q+oX7Un7 +t3tT0/3ebpQtFeaqXFI4fkSiOwfsqhhXVW4EOlp43P3H3wdsmiA8YBAeoREezUtc3X4zf2ij +DIDwgOMH3Dlgra2q9G8IjtXpul9CeMAgPMJHeCxcNbnZh3/wQ1xBqKZAeMDxI0LhFWafGPqo +y8hgsPAUHnEP96DvxyY/918D4+hf/jJlzkj6ko3aK909S3/Kl5xW+m8pOR+ImhrOM6DwkANR +hnqkZuCQh+X7T4qy+XvOnw5nLQyEB4SHwZcVNSQ8Rs5cD+HBwoNlACHVmWofV2GuVgtWJBuu +FHor1UpDeEj19ze0KsKDjshVlWztpx7eSoeTL8moMNZGif+k5LwPlzxMhIeEGtu6dQv0QGgI +boVZWBgKD26aeAduUuTNSHfPUiuks5LxGt6Bc5aWLaAA0AeVTER7UMJO1/1S8pdiW1+g9HlB +eEB4YFaLbUVLnvkS1V/+LLWM64uuyKwQRNJLReattL8WHvEJ/XirIVdshYduK6R66mFf3iRK +w+gRlarNfTXhIzzY/ja4L+KMwY8U5sbHQ/oNpNY/99JAakPovYP/pIZF3jX0416y4lZC99/S +iw/9S5qB0vKfzu0h/UtH/KQo2zgEleG9DbO5weE9uXGD8IDwgPAIQngIXKmlG0FqClVV3pN3 +kEZAejvpG/ogwoNkjJu6Jm8irHaoxaDP9/X8g2gb6czkZkReMSJLeGzalQV3U/iRwhyEh2DU +cXkPMjQA94haa70kN9oEq48HfRaTlyOjYbEqik8Ks6mto+/1nhAeEB7uOVFT13NYVsb7xRAe +t91+M9URa7cGyw+qlVLRuCrRW4mtbwYLDxInRqPB0kXXdH7psFZY+izCo7maF2VTtaXdjCNG +lvCAu2lHO3V07tyJ2gc0kpE71EI1l00aH6OOWwdljAd6a4WHfufSvawOwoMkhx5qgfCA8IBz +adt9PKT/kAWD7sw0xkz9jcyy8BABI/0Vuvbp1sBZePAcf12AyBUebP0efyhCe+3Q4wG7Kj4e +boRHcD0eInX04Iuz8KAPvXrfY90TwgPCA8IjaOGhfaukW0PGO3RVchYe0uOh3byNmu6vJ1OE +B28Sf1FrC4AeDwAfj9gRHuwzRl9K68HDr4aPh7Pw0H2wbqbT6maHM+RN8o7Gf/IYMcGertRg +6oYUwgPCA8LDQXhozw3ZJHNJdFUSxy3ZSq8MelZLq3w8bIUHNyPSUBiNjOFVbkwEho8HZrWg +wYwy4SFPc54Sa/VFDyg8brjxet4h4KwWW+HBBaBMqLUxjk4vR+Iiy2WD8IDwcBYeQyfkQnjo +wRTx8ZBxFl3RuCpJI8DfcF0zZrWIGHAzq8UqPCQ5z6g1hlq4N0YfHbNagLh8II5HpBgPpxpd +o3pSm35Yc4AO3VLprUZW3Cmhe0gGDe3rZjqtzpZ926TZiU/oxz4eY5OfM/aUbl7+UhdGSgLh +AeEh2uN0bX2MCw9teiKJTLDl7416bW0EeFaL1C+eCOMcA9mo11yePn95gLWNeLzTB67Xsqex +lYsqjQwXDHE8YhlELo1WY4fz4FZ2CDqhntXinD9+IAgPTKdtu1FV0j6i7dgIuDHK2SFz561X +3RC5FB6nMBgMwuNnXbL1jVMWbc8vqYbwgMGVFB6nMBgMBudSWCQaVqeFxykMBoPwgPCAhcZe +SYq/v8e9cCWFxykMBoPwsLLnyEkSHgnJayE8YO3lRzpuXBKe8vA4hcFgEB4O2sNX3wjhAYMf +KTxOrRb/3ACquTAYLGbtli6/Gzbs6Qid1dKp86/wC0acTZ41En6ksexxOicr6d9/e+NNN920 +ZMmSHQCAmMTr9UZoW4ffLoJITk7u3LkzCY+AffLwI410j9MPtqW56Wsl+fH0sPjjx4/jugEA +AGhfffjnB3uR5HCItgo/0qjB5/P1e6yvS3dTyA8AAABXS3LAjzRq2Ldvb6vcTVl+DH7i8YMH +D+LqAQAACIK8vLy77r7TpeSAH2n0EUSA06meUbff2bVf/0chPwAAALRWcvTp28vlCy/8SKMb +9vogUUES1L0Nefavd9zRDQoEAACAg9i4/tf/OnrCM+4fLnDngPCA8AAAAADhAQAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +wJn/A5vjFyA= +</bitmap> +<ipestyle name="basic"> +<symbol name="arrow/arc(spx)"> +<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/farc(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/ptarc(spx)"> +<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/fptarc(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="mark/circle(sx)" transformations="translations"> +<path fill="sym-stroke"> +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e +</path> +</symbol> +<symbol name="mark/disk(sx)" transformations="translations"> +<path fill="sym-stroke"> +0.6 0 0 0.6 0 0 e +</path> +</symbol> +<symbol name="mark/fdisk(sfx)" transformations="translations"> +<group> +<path fill="sym-fill"> +0.5 0 0 0.5 0 0 e +</path> +<path fill="sym-stroke" fillrule="eofill"> +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e +</path> +</group> +</symbol> +<symbol name="mark/box(sx)" transformations="translations"> +<path fill="sym-stroke" fillrule="eofill"> +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h +</path> +</symbol> +<symbol name="mark/square(sx)" transformations="translations"> +<path fill="sym-stroke"> +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +</path> +</symbol> +<symbol name="mark/fsquare(sfx)" transformations="translations"> +<group> +<path fill="sym-fill"> +-0.5 -0.5 m +0.5 -0.5 l +0.5 0.5 l +-0.5 0.5 l +h +</path> +<path fill="sym-stroke" fillrule="eofill"> +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h +</path> +</group> +</symbol> +<symbol name="mark/cross(sx)" transformations="translations"> +<group> +<path fill="sym-stroke"> +-0.43 -0.57 m +0.57 0.43 l +0.43 0.57 l +-0.57 -0.43 l +h +</path> +<path fill="sym-stroke"> +-0.43 0.57 m +0.57 -0.43 l +0.43 -0.57 l +-0.57 0.43 l +h +</path> +</group> +</symbol> +<symbol name="arrow/fnormal(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/pointed(spx)"> +<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/fpointed(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/linear(spx)"> +<path stroke="sym-stroke" pen="sym-pen"> +-1 0.333 m +0 0 l +-1 -0.333 l +</path> +</symbol> +<symbol name="arrow/fdouble(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/double(spx)"> +<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h +</path> +</symbol> +<pen name="heavier" value="0.8"/> +<pen name="fat" value="1.2"/> +<pen name="ultrafat" value="2"/> +<symbolsize name="large" value="5"/> +<symbolsize name="small" value="2"/> +<symbolsize name="tiny" value="1.1"/> +<arrowsize name="large" value="10"/> +<arrowsize name="small" value="5"/> +<arrowsize name="tiny" value="3"/> +<color name="red" value="1 0 0"/> +<color name="green" value="0 1 0"/> +<color name="blue" value="0 0 1"/> +<color name="yellow" value="1 1 0"/> +<color name="orange" value="1 0.647 0"/> +<color name="gold" value="1 0.843 0"/> +<color name="purple" value="0.627 0.125 0.941"/> +<color name="gray" value="0.745"/> +<color name="brown" value="0.647 0.165 0.165"/> +<color name="navy" value="0 0 0.502"/> +<color name="pink" value="1 0.753 0.796"/> +<color name="seagreen" value="0.18 0.545 0.341"/> +<color name="turquoise" value="0.251 0.878 0.816"/> +<color name="violet" value="0.933 0.51 0.933"/> +<color name="darkblue" value="0 0 0.545"/> +<color name="darkcyan" value="0 0.545 0.545"/> +<color name="darkgray" value="0.663"/> +<color name="darkgreen" value="0 0.392 0"/> +<color name="darkmagenta" value="0.545 0 0.545"/> +<color name="darkorange" value="1 0.549 0"/> +<color name="darkred" value="0.545 0 0"/> +<color name="lightblue" value="0.678 0.847 0.902"/> +<color name="lightcyan" value="0.878 1 1"/> +<color name="lightgray" value="0.827"/> +<color name="lightgreen" value="0.565 0.933 0.565"/> +<color name="lightyellow" value="1 1 0.878"/> +<dashstyle name="dashed" value="[4] 0"/> +<dashstyle name="dotted" value="[1 3] 0"/> +<dashstyle name="dash dotted" value="[4 2 1 2] 0"/> +<dashstyle name="dash dot dotted" value="[4 2 1 2 1 2] 0"/> +<textsize name="large" value="\large"/> +<textsize name="Large" value="\Large"/> +<textsize name="LARGE" value="\LARGE"/> +<textsize name="huge" value="\huge"/> +<textsize name="Huge" value="\Huge"/> +<textsize name="small" value="\small"/> +<textsize name="footnote" value="\footnotesize"/> +<textsize name="tiny" value="\tiny"/> +<textstyle name="center" begin="\begin{center}" end="\end{center}"/> +<textstyle name="itemize" begin="\begin{itemize}" end="\end{itemize}"/> +<textstyle name="item" begin="\begin{itemize}\item{}" end="\end{itemize}"/> +<gridsize name="4 pts" value="4"/> +<gridsize name="8 pts (~3 mm)" value="8"/> +<gridsize name="16 pts (~6 mm)" value="16"/> +<gridsize name="32 pts (~12 mm)" value="32"/> +<gridsize name="10 pts (~3.5 mm)" value="10"/> +<gridsize name="20 pts (~7 mm)" value="20"/> +<gridsize name="14 pts (~5 mm)" value="14"/> +<gridsize name="28 pts (~10 mm)" value="28"/> +<gridsize name="56 pts (~20 mm)" value="56"/> +<anglesize name="90 deg" value="90"/> +<anglesize name="60 deg" value="60"/> +<anglesize name="45 deg" value="45"/> +<anglesize name="30 deg" value="30"/> +<anglesize name="22.5 deg" value="22.5"/> +<tiling name="falling" angle="-60" step="4" width="1"/> +<tiling name="rising" angle="30" step="4" width="1"/> +</ipestyle> +<ipestyle name="presentation"> +<symbol name="arrow/arc(spx)"> +<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/farc(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="mark/circle(sx)" transformations="translations"> +<path fill="sym-stroke"> +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e +</path> +</symbol> +<symbol name="mark/disk(sx)" transformations="translations"> +<path fill="sym-stroke"> +0.6 0 0 0.6 0 0 e +</path> +</symbol> +<symbol name="mark/fdisk(sfx)" transformations="translations"> +<group> +<path fill="sym-fill"> +0.5 0 0 0.5 0 0 e +</path> +<path fill="sym-stroke" fillrule="eofill"> +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e +</path> +</group> +</symbol> +<symbol name="mark/box(sx)" transformations="translations"> +<path fill="sym-stroke" fillrule="eofill"> +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h +</path> +</symbol> +<symbol name="mark/square(sx)" transformations="translations"> +<path fill="sym-stroke"> +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +</path> +</symbol> +<symbol name="mark/fsquare(sfx)" transformations="translations"> +<group> +<path fill="sym-fill"> +-0.5 -0.5 m +0.5 -0.5 l +0.5 0.5 l +-0.5 0.5 l +h +</path> +<path fill="sym-stroke" fillrule="eofill"> +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h +</path> +</group> +</symbol> +<symbol name="mark/cross(sx)" transformations="translations"> +<group> +<path fill="sym-stroke"> +-0.43 -0.57 m +0.57 0.43 l +0.43 0.57 l +-0.57 -0.43 l +h +</path> +<path fill="sym-stroke"> +-0.43 0.57 m +0.57 -0.43 l +0.43 -0.57 l +-0.57 0.43 l +h +</path> +</group> +</symbol> +<symbol name="arrow/fnormal(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/pointed(spx)"> +<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/fpointed(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/linear(spx)"> +<path stroke="sym-stroke" pen="sym-pen"> +-1 0.333 m +0 0 l +-1 -0.333 l +</path> +</symbol> +<symbol name="arrow/fdouble(spx)"> +<path stroke="sym-stroke" fill="white" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h +</path> +</symbol> +<symbol name="arrow/double(spx)"> +<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h +</path> +</symbol> +<pen name="normal" value="1.2"/> +<pen name="heavier" value="2.4"/> +<pen name="fat" value="3.6"/> +<pen name="ultrafat" value="6"/> +<symbolsize name="normal" value="9"/> +<symbolsize name="large" value="15"/> +<symbolsize name="small" value="6"/> +<symbolsize name="tiny" value="3.3"/> +<arrowsize name="normal" value="15"/> +<arrowsize name="large" value="20"/> +<arrowsize name="small" value="10"/> +<arrowsize name="tiny" value="6"/> +<color name="red" value="1 0 0"/> +<color name="green" value="0 1 0"/> +<color name="blue" value="0 0 1"/> +<color name="yellow" value="1 1 0"/> +<color name="orange" value="1 0.647 0"/> +<color name="gold" value="1 0.843 0"/> +<color name="purple" value="0.627 0.125 0.941"/> +<color name="gray" value="0.745"/> +<color name="brown" value="0.647 0.165 0.165"/> +<color name="navy" value="0 0 0.502"/> +<color name="pink" value="1 0.753 0.796"/> +<color name="seagreen" value="0.18 0.545 0.341"/> +<color name="turquoise" value="0.251 0.878 0.816"/> +<color name="violet" value="0.933 0.51 0.933"/> +<color name="darkblue" value="0 0 0.545"/> +<color name="darkcyan" value="0 0.545 0.545"/> +<color name="darkgray" value="0.663"/> +<color name="darkgreen" value="0 0.392 0"/> +<color name="darkmagenta" value="0.545 0 0.545"/> +<color name="darkorange" value="1 0.549 0"/> +<color name="darkred" value="0.545 0 0"/> +<color name="lightblue" value="0.678 0.847 0.902"/> +<color name="lightcyan" value="0.878 1 1"/> +<color name="lightgray" value="0.827"/> +<color name="lightgreen" value="0.565 0.933 0.565"/> +<color name="lightyellow" value="1 1 0.878"/> +<color name="title" value="0.4 0 0.4"/> +<dashstyle name="dashed" value="[4] 0"/> +<dashstyle name="dotted" value="[1 3] 0"/> +<dashstyle name="dash dotted" value="[4 2 1 2] 0"/> +<dashstyle name="dash dot dotted" value="[4 2 1 2 1 2] 0"/> +<textsize name="normal" value="\normalsize"/> +<textsize name="large" value="\large"/> +<textsize name="huge" value="\LARGE"/> +<textsize name="small" value="\normalsize"/> +<textstretch name="normal" value="2.8"/> +<textstretch name="large" value="2.8"/> +<textstretch name="huge" value="2.8"/> +<textstretch name="small" value="2.4"/> +<textstyle name="normal" begin="\begin{flushleft}" end="\end{flushleft}"/> +<textstyle name="center" begin="\begin{center}" end="\end{center}"/> +<textstyle name="itemize" begin="\begin{flushleft}\begin{itemize}" end="\end{itemize}\end{flushleft}"/> +<textstyle name="item" begin="\begin{flushleft}\begin{itemize}\item{}" end="\end{itemize}\end{flushleft}"/> +<gridsize name="16 pts (~6 mm)" value="16"/> +<gridsize name="32 pts (~12 mm)" value="32"/> +<gridsize name="10 pts (~3.5 mm)" value="10"/> +<gridsize name="20 pts (~7 mm)" value="20"/> +<gridsize name="14 pts (~5 mm)" value="14"/> +<gridsize name="28 pts (~10 mm)" value="28"/> +<gridsize name="56 pts (~20 mm)" value="56"/> +<anglesize name="90 deg" value="90"/> +<anglesize name="60 deg" value="60"/> +<anglesize name="45 deg" value="45"/> +<anglesize name="30 deg" value="30"/> +<anglesize name="22.5 deg" value="22.5"/> +<preamble> +\renewcommand\rmdefault{cmss} +\makeatletter +\leftmargini 1.5em +\leftmargin \leftmargini +\leftmarginii 1.2em +\leftmarginiii 1em +\def\@listI{\leftmargin\leftmargini + \parsep \z@ + \partopsep 3pt + \topsep \z@ + \itemsep \z@} +\@listI +\def\@listii {\leftmargin\leftmarginii + \labelwidth\leftmarginii + \advance\labelwidth-\labelsep + \topsep \z@ + \parsep \z@ + \itemsep \parsep} +\def\@listiii{\leftmargin\leftmarginiii + \labelwidth\leftmarginiii + \advance\labelwidth-\labelsep + \topsep \z@ + \parsep \z@ + \partopsep \z@ + \itemsep \topsep} +\makeatother +</preamble> +<layout paper="800 600" origin="32 0" frame="736 528" skip="32" crop="no"/> +<titlestyle pos="368 554" size="large" color="title" halign="center" valign="baseline"/> +<tiling name="falling" angle="-60" step="12" width="3"/> +<tiling name="rising" angle="30" step="12" width="3"/> +</ipestyle> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="221.536" height="19.3704" depth="0" halign="center" valign="baseline">Some Preliminaries</text> +<text transformations="translations" pos="16 512" stroke="black" type="minipage" width="704" height="116.909" depth="105.192" valign="top" size="small">\begin{itemize} +\item This description corresponds to the {\tt RU-RAU-split} branch for RAN infrastructure components (located in {\tt targets/DOCS/oai\_L1\_L2\_procedures.pdf}, editable with {\tt ipe}) +\item we describe +\begin{enumerate} +\item node functions +\item current functional splits and packet formats +\item RAN procedures +\item process scheduling +\end{enumerate} +\end{itemize}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<image layer="alpha" matrix="0.910864 0 0 0.743119 40 12" rect="0 0 723 430" bitmap="3"/> +<text matrix="1 0 0 1 185 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="326.802" height="19.3704" depth="0" halign="center" valign="baseline">NGFI Harmonization in OAI</text> +<text transformations="translations" pos="0 528" stroke="black" type="minipage" width="736" height="100.324" depth="86.576" valign="top">\small +\begin{itemize} +\item New descriptions for OAI RAN infrastructure Node Functions +\begin{itemize} +\item{\tt NGFI\_RCC} : Radio Cloud Center +\item{\tt NGFI\_RAU} : Radio Aggregation Unit +\item{\tt NGFI\_RRU} : Remote Radio Unit +\item{\tt 3GPP\_BBU} : Baseband Unit +\item{\tt 3GPP\_eNodeB} : Complete eNodeB +\end{itemize} +\end{itemize} </text> +<text transformations="translations" pos="320 16" stroke="black" type="label" width="420.913" height="6.229" depth="1.99" valign="baseline" size="tiny">\small Source: China Mobile - {\tt http://www.windriver.com.cn/windforum/download/wf2015\_networking03.pdf}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<image layer="alpha" matrix="0.852308 0 0 0.885714 64 16" rect="0 0 325 558" bitmap="2"/> +<text matrix="0.809524 0 0 1.02381 36.1429 4.19048" transformations="translations" pos="384 496" stroke="black" type="minipage" width="384" height="139.135" depth="127.464" valign="top" size="small">\small\begin{itemize} +\item Current OAI implementation (RRU/RCC) supports either +\begin{itemize} +\item IF5 time-domain fronthaul ($>$ 1 GbE required) +\item IF4.5 split (FFTs) (280 Mbit/s/antenna port fronthaul – 20 MHz carrier) per carrier/sector +\item Soon IF2 (NFAPI) +\item IF1’ for “PDCP/RRC†soon (3GPP Fh-C/Fh-U) +\end{itemize} +\end{itemize}</text> +<text matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="209.37" height="19.3928" depth="5.404" halign="center" valign="baseline">NGFI split points +</text> +<image matrix="0.866029 0 0 0.805556 358 8" rect="0 0 418 289" bitmap="1"/> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 188.731 -293.27" transformations="translations" pos="176 556" stroke="black" type="label" width="373.372" height="19.3704" depth="0" halign="center" valign="baseline">OAI RAN Software Architecture</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 90 -216" stroke="black"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 86 -212" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 82 -208" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 78 -204" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 10 -136" stroke="black"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 6 -132" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 2 -128" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -2 -124" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 86 -48" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 83 -44" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 80 -40" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 77 -36" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 10 45" stroke="black"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 6 49" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 2 53" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -2 57" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 64 18" transformations="translations" stroke="black" fill="1"> +528 64 m +528 32 l +640 32 l +640 64 l +h +</path> +<path matrix="1 0 0 1 56 26" transformations="translations" stroke="black" fill="1"> +528 64 m +528 32 l +640 32 l +640 64 l +h +</path> +<path transformations="translations" stroke="blue" dash="dashed" pen="heavier"> +528 101 m +528 48 l +736 48 l +736 101 l +h +</path> +<path matrix="1 0 0 1 0 -101" stroke="black" fill="white"> +392 376 m +392 296 l +512 296 l +512 376 l +h +</path> +<path matrix="1 0 0 1 -160 -135" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -168 -127" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -168 -127" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -168 -127" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -168 -127" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -168 -127" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1.25 0 0 1 -455.019 -129" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 0 74" stroke="black" fill="white"> +392 376 m +392 296 l +512 296 l +512 376 l +h +</path> +<path stroke="black"> +136 312 m +136 272 l +200 272 l +200 312 l +h +</path> +<path matrix="1.25 0 0 1 -456.019 50" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -161 42" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -168 48" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -6 61" stroke="black" fill="white"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -6 54" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -6 54" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<text matrix="1 0 0 1 -6 50" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf LTE\\ +MODEM</text> +<path matrix="1 0 0 1 -176 58" stroke="black"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -176 58" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -176 58" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -176 58" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -176 58" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -304 58" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -304 58" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path stroke="black"> +96 408 m +96 360 l +208 360 l +208 408 l +h +</path> +<path matrix="1 0 0 1 -460 21" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -460 21" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<text matrix="1 0 0 1 -472 15" transformations="translations" pos="576 384" stroke="black" type="minipage" width="96" height="20.5912" depth="6.608" valign="top" style="center">\tiny\bf LTE/NR/NB\\ +PDCP</text> +<path stroke="black" fill="1"> +128 320 m +128 280 l +192 280 l +192 320 l +h +</path> +<path matrix="1 0 0 1 -314 -86" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -314 -86" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<text matrix="1 0 0 1 -449 -71" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf LTE\\ +RRC</text> +<path matrix="1 0 0 1 0 53" stroke="black"> +112 464 m +112 440 l +648 440 l +648 464 l +h +</path> +<path matrix="1 0 0 1 -122 42" stroke="black"> +432 224 m +432 224 l +432 224 l +432 224 l +h +</path> +<text matrix="1 0 0 1 -35 37" transformations="translations" pos="192 480" stroke="black" type="minipage" width="448" height="17.9352" depth="5.976" valign="top" size="small" style="center">\bf OSS/BSS/MEC</text> +<path stroke="green" arrow="normal/small"> +192 296 m +232 296 l +232 404 l +256 404 l +</path> +<path matrix="1 0 0 1 15 37" stroke="green" arrow="normal/small"> +144 288 m +144 320 l +</path> +<path matrix="1 0 0 1 -48 58" stroke="red" arrow="normal/small" rarrow="normal/small"> +384 368 m +448 368 l +</path> +<path matrix="1 0 0 1 -48 58" stroke="green" arrow="normal/small" rarrow="normal/small"> +384 352 m +448 352 l +</path> +<path matrix="1 0 0 1 0 37" stroke="blue" arrow="normal/small" rarrow="normal/small"> +152 456 m +152 368 l +</path> +<path matrix="1 0 0 1 0 37" stroke="blue" arrow="normal/small" rarrow="normal/small"> +304 456 m +304 408 l +</path> +<path matrix="1 0 0 1 0 37" stroke="blue" arrow="normal/small" rarrow="normal/small"> +456 456 m +456 416 l +</path> +<path matrix="1 0 0 1 0 37" stroke="blue" arrow="normal/small" rarrow="normal/small"> +600 456 m +600 409 l +</path> +<path matrix="1 0 0 1 -6 54" stroke="red" arrow="normal/small" rarrow="normal/small"> +512 368 m +576 368 l +</path> +<path matrix="1 0 0 1 -6 54" stroke="green" arrow="normal/small" rarrow="normal/small"> +512 352 m +576 352 l +</path> +<path stroke="red" arrow="normal/small" rarrow="normal/small"> +88 384 m +8 384 l +</path> +<path matrix="1 0 0 1 0 37" stroke="red" arrow="normal/small" rarrow="normal/small"> +128 264 m +8 264 l +</path> +<text matrix="1 0 0 1 140.731 -13.2696" transformations="translations" pos="176 556" stroke="black" type="label" width="250.205" height="19.3928" depth="5.404" halign="center" valign="baseline">OAI Functional Splits</text> +<path matrix="1 0 0 1 -176 58" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 1 -176 42" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="11.816" depth="0" valign="top" style="center">\bf\tiny LTE-L1</text> +<path matrix="1 0 0 1 426 194" stroke="blue" arrow="normal/small" rarrow="normal/small"> +192 368 m +96 368 l +</path> +<path matrix="1 0 0 1 426 178" stroke="red" arrow="normal/small" rarrow="normal/small"> +192 368 m +96 368 l +</path> +<path matrix="1 0 0 1 426 162" stroke="green" arrow="normal/small" rarrow="normal/small"> +192 368 m +96 368 l +</path> +<text matrix="1 0 0 1 9 392" transformations="translations" pos="608 176" stroke="black" type="minipage" width="112" height="11.292" depth="0" valign="top" size="small">\bf\tiny Management</text> +<text matrix="1 0 0 1 11 375.418" transformations="translations" pos="608 176" stroke="black" type="minipage" width="144" height="11.9544" depth="0" valign="top" size="small">\bf\tiny data (user/control plane)</text> +<text matrix="1 0 0 1 9 360" transformations="translations" pos="608 176" stroke="black" type="minipage" width="112" height="11.292" depth="0" valign="top" size="small">\bf\tiny configuration</text> +<path matrix="1.25 0 0 1 -463 58" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 0.705114 -319 161.518" transformations="translations" pos="576 384" stroke="black" type="minipage" width="80" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf LTE\\ +MAC-RLC</text> +<path matrix="1 0 0 1 -76 21" stroke="black"> +288 432 m +288 432 l +288 432 l +288 432 l +h +</path> +<path stroke="blue" dash="dashed" pen="heavier"> +240 460 m +240 40 l +520 40 l +520 460 l +h +</path> +<path matrix="1 0 0 1 -48 21" stroke="black"> +384 416 m +384 416 l +384 416 l +384 416 l +h +</path> +<path matrix="1 0 0 1 0 37" stroke="blue" dash="dashed" pen="heavier"> +560 416 m +560 336 l +656 336 l +656 416 l +h +</path> +<path stroke="blue" dash="dashed" pen="heavier"> +88 456 m +88 40 l +216 40 l +216 221 l +216 261 l +216 456 l +100.8 456 l +88 456 l +</path> +<text matrix="1 0 0 1 -79 -148" transformations="translations" pos="160 176" stroke="blue" type="minipage" width="192" height="13.9468" depth="0" valign="top">\bf\tiny Radio-Cloud Center (RCC)</text> +<text matrix="1 0 0 1 -113 -258" transformations="translations" pos="480 288" stroke="blue" type="minipage" width="192" height="13.9468" depth="0" valign="top">\tiny\bf Radio-Access Unit (RAU)</text> +<path stroke="black"> +136 248 m +136 208 l +200 208 l +200 248 l +h +</path> +<path stroke="black" fill="1"> +128 256 m +128 216 l +192 216 l +192 256 l +h +</path> +<text matrix="1 0 0 1 -448 -134" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf NR\\ +RRC</text> +<path stroke="green" arrow="normal/small"> +128 229 m +112 229 l +112 261 l +112 360 l +</path> +<path matrix="1 0 0 1 0 74" stroke="black" fill="white"> +488 368 m +488 304 l +504 304 l +504 368 l +h +</path> +<path matrix="1.25 0 0 1 -463.019 -121" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -176 -117" stroke="black"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -176 -117" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -176 -117" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -176 -117" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -176 -117" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -304 -117" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -304 -117" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -48 -117" stroke="red" arrow="normal/small" rarrow="normal/small"> +384 368 m +448 368 l +</path> +<path matrix="1 0 0 1 -48 -117" stroke="green" arrow="normal/small" rarrow="normal/small"> +384 352 m +448 352 l +</path> +<path matrix="1 0 0 1 -176 -117" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 1 -176 -136" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="11.816" depth="0" valign="top" style="center">\bf\tiny NR-L1</text> +<text matrix="1 0 0 0.705114 -318 -17.482" transformations="translations" pos="576 384" stroke="black" type="minipage" width="80" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf NR\\ +MAC-RLC</text> +<path matrix="1 0 0 1 0 -101" stroke="black" fill="white"> +488 368 m +488 304 l +504 304 l +504 368 l +h +</path> +<text matrix="0 1 -1 0 724 -196" pos="576 224" stroke="black" type="label" width="58.2408" height="8.3016" depth="0" valign="baseline" size="small">\tiny PRECODE</text> +<text matrix="0 1 -1 0 724 -371" pos="576 224" stroke="black" type="label" width="58.2408" height="8.3016" depth="0" valign="baseline" size="small">\tiny PRECODE</text> +<path matrix="1 0 0 1 -6 -120" stroke="black" fill="white"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -6 -120" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -6 -120" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<text matrix="1 0 0 1 -6 -131" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf NR\\ +MODEM</text> +<path matrix="1 0 0 1 -6 -124" stroke="red" arrow="normal/small" rarrow="normal/small"> +512 368 m +576 368 l +</path> +<path matrix="1 0 0 1 -6 -123" stroke="green" arrow="normal/small" rarrow="normal/small"> +512 352 m +576 352 l +</path> +<path matrix="1 0 0 1 0 38" stroke="blue" dash="dashed" pen="heavier"> +560 231 m +560 160 l +656 160 l +656 231 l +h +</path> +<path matrix="1.25 0 0 1 -456.019 -44" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -22 -50" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -29 -44" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -37 -34" stroke="black"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -37 -34" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -37 -34" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -37 -34" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -37 -34" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -304 -36" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -304 -36" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 0 53" stroke="red" arrow="normal/small" rarrow="normal/small"> +336 264 m +536 264 l +</path> +<path matrix="1 0 0 1 0 83" stroke="green" arrow="normal/small" rarrow="normal/small"> +336 248 m +536 248 l +</path> +<path matrix="1 0 0 1 -37 -34" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 1 -37 -50" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="11.816" depth="0" valign="top" style="center">\bf\tiny LTE-L1</text> +<path matrix="1.25 0 0 1 -463 -36" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 0.705114 -319 67.518" transformations="translations" pos="576 384" stroke="black" type="minipage" width="80" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf LTE\\ +MAC-RLC</text> +<path matrix="1 0 0 1 139 -18" stroke="black" fill="white"> +488 368 m +488 304 l +504 304 l +504 368 l +h +</path> +<text matrix="0 1 -1 0 863 -288" pos="576 224" stroke="black" type="label" width="58.2408" height="8.3016" depth="0" valign="baseline" size="small">\tiny PRECODE</text> +<path matrix="1 0 0 1 74 -34" stroke="black" fill="white"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 74 -34" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 74 -34" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<text matrix="1 0 0 1 74 -45" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf LTE\\ +MODEM</text> +<path matrix="1 0 0 1 0 68" transformations="translations" stroke="green" fill="white" arrow="normal/small"> +232 264 m +256 264 l +</path> +<path transformations="translations" stroke="red" arrow="normal/small" rarrow="normal/small"> +256 424 m +224 424 l +224 316 l +256 316 l +</path> +<path matrix="1 0 0 1 0 37" transformations="translations" stroke="red" cap="1"> +64 264 m +64 264 l +</path> +<path matrix="1 0 0 1 0 70" stroke="blue" dash="dashed" pen="heavier"> +528 288 m +528 208 l +736 208 l +736 288 l +h +</path> +<path matrix="1.25 0 0 1 -456.019 -204" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1.25 0 0 1 -463 -196" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 0.705114 -319 -92.482" transformations="translations" pos="576 384" stroke="black" type="minipage" width="80" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf NR\\ +MAC-RLC</text> +<path matrix="1.25 0 0 1 -463 -283" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 0.705114 -319 -179.482" transformations="translations" pos="576 384" stroke="black" type="minipage" width="80" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf NB-IoT\\ +MAC-RLC</text> +<path matrix="1 0 0 1 0 -22" stroke="red" arrow="normal/small" rarrow="normal/small"> +128 264 m +8 264 l +</path> +<path matrix="1 0 0 1 -22 -217" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -29 -211" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -37 -201" stroke="black"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 -37 -201" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -37 -201" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 -37 -201" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 -37 -201" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<path matrix="1 0 0 1 0 -115" stroke="red" arrow="normal/small" rarrow="normal/small"> +336 264 m +536 264 l +</path> +<path matrix="1 0 0 1 0 -83" stroke="green" arrow="normal/small" rarrow="normal/small"> +336 248 m +536 248 l +</path> +<path matrix="1 0 0 1 -37 -201" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 1 -37 -217" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="11.816" depth="0" valign="top" style="center">\bf\tiny NR-L1</text> +<path matrix="1 0 0 1 139 -185" stroke="black" fill="white"> +488 368 m +488 304 l +504 304 l +504 368 l +h +</path> +<text matrix="0 1 -1 0 863 -455" pos="576 224" stroke="black" type="label" width="58.2408" height="8.3016" depth="0" valign="baseline" size="small">\tiny PRECODE</text> +<path matrix="1 0 0 1 74 -201" stroke="black" fill="white"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<path matrix="1 0 0 1 74 -201" stroke="black"> +624 336 m +624 336 l +624 336 l +624 336 l +h +</path> +<path matrix="1 0 0 1 74 -201" stroke="black"> +608 336 m +608 336 l +608 336 l +608 336 l +h +</path> +<text matrix="1 0 0 1 74 -212" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf NR\\ +MODEM</text> +<path matrix="1 0 0 1 0 -97" stroke="blue" dash="dashed" pen="heavier"> +528 288 m +528 208 l +736 208 l +736 288 l +h +</path> +<text matrix="1 0 0 1 71 -258" transformations="translations" pos="480 288" stroke="blue" type="minipage" width="192" height="13.9468" depth="0" valign="top">\tiny\bf Remote Radio-Unit (RRU)</text> +<path stroke="red" arrow="normal/small" rarrow="normal/small"> +336 72 m +576 72 l +</path> +<path stroke="green" arrow="normal/small" rarrow="normal/small"> +336 86 m +576 88 l +</path> +<path matrix="1 0 0 1 -452 -282" stroke="black" fill="1"> +576 384 m +576 336 l +640 336 l +640 384 l +h +</path> +<text matrix="1 0 0 1 -452 -293" transformations="translations" pos="576 384" stroke="black" type="minipage" width="64" height="20.1796" depth="6.244" valign="top" style="center">\tiny\bf NB-IoT\\ +RRC</text> +<path matrix="1 0 0 1 -8 -193" stroke="red" arrow="normal/small" rarrow="normal/small"> +128 264 m +8 264 l +</path> +<path transformations="translations" stroke="green" rarrow="normal/small"> +104 360 m +104 88 l +120 88 l +</path> +<path transformations="translations" stroke="green" arrow="normal/small"> +192 88 m +256 88 l +</path> +<path matrix="1 0 0 1 48 34" transformations="translations" stroke="black" fill="white"> +528 64 m +528 32 l +640 32 l +640 64 l +h +</path> +<text matrix="1 0 0 1 2 -288" transformations="translations" pos="576 384" stroke="black" type="minipage" width="104" height="21.9296" depth="7.98" valign="top" style="center">\tiny\bf NB-IoT\\ +L1/MODEM</text> +<path transformations="translations" stroke="red" fill="white" arrow="normal/small"> +224 384 m +208 384 l +</path> +<path transformations="translations" stroke="green" fill="white" arrow="normal/small"> +192 240 m +256 240 l +</path> +<path transformations="translations" stroke="green" arrow="normal/small"> +232 240 m +232 168 l +256 168 l +</path> +<path transformations="translations" stroke="green" cap="1"> +224 192 m +224 192 l +</path> +<path transformations="translations" stroke="green" cap="1"> +224 192 m +224 192 l +</path> +<path transformations="translations" stroke="green" arrow="normal/small"> +224 312 m +224 72 l +256 72 l +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 188.731 2.73037" transformations="translations" pos="176 556" stroke="black" type="label" width="250.205" height="19.3928" depth="5.404" halign="center" valign="baseline">OAI Functional Splits</text> +<text transformations="translations" pos="14.7471 512.821" stroke="black" type="minipage" width="707.342" height="140.266" depth="128.592" valign="top" size="small">\tiny\begin{itemize} +\item OAI currently implements the following entities in openairinterface5g +\begin{itemize} +\item LTE-MODEM (eNB 36.211 OFDM modulation/demodulation) +\item LTE-L1 (eNB 36.211/212/213) +\item LTE-MACRLC (eNB 36.321/322) +\item LTE-PDCP (eNB PDCP/GTPU 36.323) +\item LTE-RRC (eNB RRC/SCTP 36.331) +\end{itemize} +\item Each entity comprises +\begin{itemize} +\item a northbound interface (backhaul/midhaul/fronthaul and configuration) +\item a southbound interface (midaul/fronthaul and configuration) +\item one or two management interfaces +\item Three computing nodes +\begin{itemize} +\item {\bf Radio Cloud Center (RCC)} : multiple RRC/PDCP entities +\item {\bf Radio-Access Unit (RAU)}: multiple MACRLC entities with medium-latency midhaul and L1 entities with low-latency fronthaul. +\item {\bf Remote Radio-Unit (RRU)}: Equipment at radio site. Varying degrees of processing elements depending on fronthaul/midhaul interface. +\end{itemize} +\end{itemize} +\item Each entity has a configuration which is a local file or received via the management interface +\item default interface between all entities is implemented using a UDP socket. Transport is configurable via a dynamically-loadable networking device +\end{itemize}</text> +<path stroke="black"> +288 192 m +288 64 l +432 64 l +432 192 l +h +</path> +<text transformations="translations" pos="288 144" stroke="black" type="minipage" width="144" height="19.3928" depth="5.404" valign="top" style="center">OAI entity</text> +<path matrix="1 0 0 1 0 23" stroke="red" arrow="normal/small" rarrow="normal/small"> +336 171 m +336 208 l +</path> +<path matrix="1 0 0 1 0 23" stroke="green" arrow="normal/small" rarrow="normal/small"> +384 171 m +384 208 l +</path> +<path matrix="1 0 0 1 0 -144" stroke="red" arrow="normal/small" rarrow="normal/small"> +336 171 m +336 208 l +</path> +<path matrix="1 0 0 1 0 -144" stroke="green" arrow="normal/small" rarrow="normal/small"> +384 171 m +384 208 l +</path> +<path matrix="1 0 0 1 0 47" stroke="blue" arrow="normal/small" rarrow="normal/small"> +240 80 m +288 80 l +</path> +<path matrix="1 0 0 1 0 71" stroke="blue" arrow="normal/small" rarrow="normal/small"> +240 80 m +288 80 l +</path> +<path matrix="5.5 0 0 0.5 -1224 100" stroke="blue"> +16 0 0 16 288 224 e +</path> +<path matrix="5.5 0 0 0.5 -1224 -60" stroke="blue"> +16 0 0 16 288 224 e +</path> +<text transformations="translations" pos="464 224" stroke="blue" type="minipage" width="144" height="10.128" depth="0" valign="top" size="small">\tiny\bf Northbound interface</text> +<text matrix="1 0 0 1 0 -160" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="144" height="10.128" depth="0" valign="top" size="small">\tiny\bf Southbound interface</text> +<text matrix="1 0 0 1 -144 -199" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="32" height="10.128" depth="0" valign="top" size="small">\tiny\bf data</text> +<text matrix="1 0 0 1 -144 16" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="32" height="10.128" depth="0" valign="top" size="small">\tiny\bf data</text> +<text matrix="1 0 0 1 -96 -199" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="112" height="18.468" depth="6.504" valign="top" size="small">\tiny\bf in-band configuration</text> +<text matrix="1 0 0 1 -96 34" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="112" height="18.468" depth="6.504" valign="top" size="small">\tiny\bf in-band configuration</text> +<text matrix="1 0 0 1 -288 -55" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="64" height="11.9544" depth="0" valign="top" size="small">\tiny\bf OSS/BSS</text> +<text matrix="1 0 0 1 -288 -79" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="64" height="10.128" depth="0" valign="top" size="small">\tiny\bf FlexRAN</text> +<path matrix="1 0 0 1 0 -1" stroke="blue" arrow="normal/small" rarrow="normal/small"> +240 80 m +288 80 l +</path> +<text matrix="1 0 0 1 -248 -127" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="64" height="9.6312" depth="0" valign="top" size="small">\tiny\tt .conf</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="0.92926 0 0 1.00204 -473.9 3.55763" stroke="black" fill="lightgray"> +511.895 513.539 m +511.895 14.2386 l +734.284 14.2386 l +734.284 513.539 l +h +</path> +<path matrix="0.880259 0 0 1.00521 -236.182 1.22986" stroke="black" fill="lightgray"> +511.895 513.539 m +511.895 14.2386 l +734.284 14.2386 l +734.284 513.539 l +h +</path> +<path matrix="1 0 0 1.00204 -98.2818 2.84025" stroke="black" fill="lightgray"> +511.895 513.539 m +511.895 14.2386 l +734.284 14.2386 l +734.284 513.539 l +h +</path> +<path matrix="1 0 0 1.1 208 -43.2" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="1 0 0 1.1 0 -43.2" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<text matrix="1 0 0 1 185 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="313.978" height="20.9244" depth="6.972" halign="center" valign="baseline">Functional Splits (Current)</text> +<path matrix="0.791667 0 0 1 -126.042 -156.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 139 -128.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -126.25 -109" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 -126.25 -64" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 133.792 -35.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 138.792 -80.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -174.042 -156.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 91 -128.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -174.25 -109" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 -174.25 -64" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 85.792 -35.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 90.792 -80.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -222.25 -64" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 37.792 -35.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RRC +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -222.25 -16" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 37.792 7.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-C +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 -469.028 -12.3492" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 108.792 6.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-U +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -126.042 -204.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 139 -176.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -174.042 -204.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 91 -176.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX +\end{tiny} +</text> +<path matrix="1 0 0 1 -255 31" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<path matrix="1 0 0 1 -326 31" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<path matrix="1.68745 0 0 0.646102 -469.028 -103.883" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 101.792 -228.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt rf\_device} +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 81.958 -157.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 347 -129.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 81.75 -110" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 81.75 -65" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 341.792 -36.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 346.792 -81.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 33.958 -157.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 299 -129.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 33.75 -110" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 33.75 -65" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 293.792 -36.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 298.792 -81.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -14.25 -65" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 245.792 -36.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RRC +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -14.25 -17" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 245.792 6.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-C +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 -261.028 -13.3492" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 316.792 5.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-U +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 81.958 -205.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 347 -177.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 33.958 -205.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 299 -177.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -261.028 -101.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 309.792 -229.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 -70 -65" transformations="translations" pos="176 556" stroke="black" type="label" width="170.52" height="19.3704" depth="0" halign="center" valign="baseline">3GPP\_eNodeB</text> +<text matrix="1 0 0 1 138 -65" transformations="translations" pos="176 556" stroke="black" type="label" width="134.604" height="19.3704" depth="0" halign="center" valign="baseline">3GPP\_BBU</text> +<text matrix="1 0 0 1 -13 0" transformations="translations" pos="48 480" stroke="black" type="minipage" width="48" height="10.128" depth="0" valign="top" size="small">\tiny to MME</text> +<text matrix="1 0 0 1 51 0" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to S-PGw</text> +<path matrix="1 0 0 1 -47 31" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<path matrix="1 0 0 1 -118 31" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="1 0 0 1 195 0" transformations="translations" pos="48 480" stroke="black" type="minipage" width="48" height="10.128" depth="0" valign="top" size="small">\tiny to MME</text> +<text matrix="1 0 0 1 259 0" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to S-PGw</text> +<path stroke="black" fill="lightblue"> +160 112 m +160 112 l +160 112 l +160 112 l +h +</path> +<path stroke="black" fill="lightblue"> +144 112 m +144 112 l +144 112 l +144 112 l +h +</path> +<path matrix="1.68745 0 0 0.991372 -469.028 -289.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 101.792 -264.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="16.8048" depth="4.848" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt USB3 or PCIe} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 -261.028 -289.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 300.792 -264.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF5 / ethernet} +\end{tiny} +</text> +<path matrix="1 0 0 1.1 416 -43.2" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="0.791667 0 0 1 289.958 -157.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 555 -129.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 289.75 -110" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 289.75 -65" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 549.792 -36.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 554.792 -81.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 241.958 -157.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 507 -129.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 241.75 -110" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 241.75 -65" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 501.792 -36.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 506.792 -81.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 193.75 -65" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 453.792 -36.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RRC +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 193.75 -17" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 453.792 6.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-C +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 -53.028 -13.3492" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 524.792 5.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-U +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 289.958 -205.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 241.958 -205.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 507 -163.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="27.4872" depth="15.552" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY RX +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -53.028 -101.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 517.792 -229.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 346 -65" transformations="translations" pos="176 556" stroke="black" type="label" width="215.964" height="20.9244" depth="6.972" halign="center" valign="baseline">NGFI\_RCC (IF4.5)</text> +<path matrix="1 0 0 1 161 31" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<path matrix="1 0 0 1 90 31" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="1 0 0 1 403 0" transformations="translations" pos="48 480" stroke="black" type="minipage" width="48" height="10.128" depth="0" valign="top" size="small">\tiny to MME</text> +<text matrix="1 0 0 1 467 0" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to S-PGw</text> +<path matrix="1.68745 0 0 0.991372 -53.028 -289.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 508.792 -264.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF4p5 / ethernet} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 555 -163.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="27.4872" depth="15.552" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY TX +\end{tiny} +</text> +<path matrix="1 0 0 1 163 -334" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 406.604 -432" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to NGFI\_RRU</text> +<path matrix="1 0 0 1 -45 -334" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 198.604 -432" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="18.468" depth="6.504" valign="top" size="small">\tiny to NGFI\_RRU or RRH\_gw</text> +<path matrix="1 0 0 1 -253.457 -333.956" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 -11.8528 -430.956" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to RF Device</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1.01725 0 0 0.848434 249.573 104.961" stroke="black" fill="lightgray"> +1.83417 462.604 m +1.83417 50.8252 l +207.006 50.8252 l +207.006 462.604 l +h +</path> +<path matrix="1.00369 0 0 1.08732 29.991 -6.98372" stroke="black" fill="lightgray"> +1.83417 462.604 m +1.83417 50.8252 l +207.006 50.8252 l +207.006 462.604 l +h +</path> +<path matrix="1 0 0 0.900567 29 11.9552" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="0.791667 0 0 1 -97.042 -189.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 168 -161.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -97.25 -142" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 -97.25 -97" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 162.792 -68.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 167.792 -113.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -145.042 -189.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 120 -161.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -145.25 -142" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 -145.25 -97" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 114.792 -68.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 119.792 -113.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -193.25 -97" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 66.792 -68.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RRC +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 -193.25 -49" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 66.792 -25.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-C +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 -440.028 -45.3492" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 137.792 -26.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-U +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -440.028 -78.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 130.792 -206.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 -41 -97" transformations="translations" pos="176 556" stroke="black" type="label" width="208.216" height="20.9244" depth="6.972" halign="center" valign="baseline">NGFI\_RCC (IF1'')</text> +<path matrix="1 0 0 1 -226 -1" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<path matrix="1 0 0 1 -297 -1" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="1 0 0 1 16 -32" transformations="translations" pos="48 480" stroke="black" type="minipage" width="48" height="10.128" depth="0" valign="top" size="small">\tiny to MME</text> +<text matrix="1 0 0 1 80 -32" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to S-PGw</text> +<path matrix="1.68745 0 0 0.991372 -440.028 -266.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 113.792 -241.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="90" height="17.6496" depth="5.664" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF1pp} / ethernet +\end{tiny} +</text> +<path matrix="1 0 0 0.651275 253 119.649" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="0.791667 0 0 1 126.75 -97" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 386.792 -68.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 78.75 -97" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 338.792 -68.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 30.75 -97" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 290.792 -68.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RRC +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 30.75 -49" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 290.792 -25.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-C +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 -216.028 -45.3492" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 361.792 -26.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +GTP-U +\end{tiny} +</text> +<path matrix="2.69329 0 0 0.638421 -595.954 13.42" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 334.792 -114.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 183 -97" transformations="translations" pos="176 556" stroke="black" type="label" width="202.017" height="20.9244" depth="6.972" halign="center" valign="baseline">NGFI\_RCC (IF1')</text> +<path matrix="1 0 0 1 -2 -1" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<path matrix="1 0 0 1 -73 -1" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="1 0 0 1 240 -32" transformations="translations" pos="48 480" stroke="black" type="minipage" width="48" height="10.128" depth="0" valign="top" size="small">\tiny to MME</text> +<text matrix="1 0 0 1 304 -32" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to S-PGw</text> +<path matrix="1.68745 0 0 0.991372 -216.028 -174.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 337.792 -149.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="90" height="17.6496" depth="5.664" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF1p} / ethernet +\end{tiny} +</text> +<text matrix="2.11243 0 0 1 36.6036 -461" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to NGFI\_RRU</text> +<path matrix="1 0 0 1 -226 -313" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 15.604 -408" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to NGFI\_RAU</text> +<path matrix="1 0 0 1 -1 -222" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 240.604 -317" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to NGFI\_RAU</text> +<text matrix="1 0 0 1 185 -0.999538" transformations="translations" pos="176 556" stroke="black" type="label" width="313.978" height="20.9244" depth="6.972" halign="center" valign="baseline">Functional Splits (Current)</text> +<path matrix="1.00369 0 0 1.08732 500.993 -5.7664" stroke="black" fill="lightgray"> +1.83417 462.604 m +1.83417 50.8252 l +207.006 50.8252 l +207.006 462.604 l +h +</path> +<path matrix="0.727273 0 0 0.742424 530.364 32.2727" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="0.791667 0 0 1 351.958 -178.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 303.958 -178.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 569 -136.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="27.4872" depth="15.552" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY RX +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 8.972 -74.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 579.792 -202.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 433 -92" transformations="translations" pos="176 556" stroke="black" type="label" width="200.276" height="20.9244" depth="6.972" halign="center" valign="baseline">NGFI\_RAU(IF1'')</text> +<path matrix="1.68745 0 0 0.991372 8.972 -262.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 570.792 -237.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF4p5 / ethernet} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 617 -136.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="27.4872" depth="15.552" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY TX +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 7.934 21.42" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 581.792 -106.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 8.972 -82.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.769443 0 0 0.141445 570.792 268.279" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF1pp / ethernet} +\end{tiny} +</text> +<path matrix="1 0 0 1 223 -40" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 464.604 -71" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to NGFI\_RCC</text> +<path matrix="1 0 0 1 223 -312" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 464.604 -407" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to NGFI\_RRU</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1.0663 0 0 1.11251 444.141 -16.4274" stroke="black" fill="lightgray"> +1.83417 462.604 m +1.83417 50.8252 l +207.006 50.8252 l +207.006 462.604 l +h +</path> +<path matrix="1.06788 0 0 1.10769 212.939 -13.7478" stroke="black" fill="lightgray"> +1.83417 462.604 m +1.83417 50.8252 l +207.006 50.8252 l +207.006 462.604 l +h +</path> +<path matrix="1 0 0 1 0 37" stroke="black" fill="lightgray"> +1.83417 462.604 m +1.83417 50.8252 l +207.006 50.8252 l +207.006 462.604 l +h +</path> +<path matrix="0.727273 0 0 0.546841 27.364 94.7646" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -494.028 5.42" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 76.792 -122.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 -72 -92" transformations="translations" pos="176 556" stroke="black" type="label" width="195.818" height="20.9244" depth="6.972" halign="center" valign="baseline">NGFI\_RRU (IF5)</text> +<path matrix="1.68745 0 0 0.991372 -494.028 -100.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 67.792 -75.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF5/ ethernet} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -494.028 -27.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 76.792 -155.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt rf\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 147 -92" transformations="translations" pos="176 556" stroke="black" type="label" width="217.515" height="20.9244" depth="6.972" halign="center" valign="baseline">NGFI\_RRU (IF4.5)</text> +<path matrix="1 0 0 1 -279.958 -59.1734" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 -59.355 -78.1734" transformations="translations" pos="48 480" stroke="black" type="minipage" width="128" height="18.0648" depth="6.12" valign="top" size="small" style="center">\tiny to NGFI\_RCC, NGFI\_RAU,3GPP\_BBU</text> +<path matrix="1 0 0 1 -280 -274" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 -38.396 -369" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to RF Device</text> +<path matrix="1.67303 0 0 1.24455 -489.268 -322.215" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 76.792 -188.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="23.9736" depth="12.024" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt USB3, PCIe, CPRI} +\end{tiny} +</text> +<path matrix="0.7308 0 0 0.711699 250.308 23.5462" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -271.028 5.42" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 299.792 -122.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.991372 -271.028 -100.349" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 290.792 -75.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF4p5/ ethernet} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -271.028 -77.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 299.792 -205.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt rf\_device} +\end{tiny} +</text> +<path matrix="1 0 0 1 -56.958 -59.1734" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 163.645 -78.1734" transformations="translations" pos="48 480" stroke="black" type="minipage" width="128" height="17.2968" depth="5.352" valign="top" size="small" style="center">\tiny to NGFI\_RCC, NGFI\_RAU</text> +<path matrix="1 0 0 1 -57 -320" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 184.604 -424" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to RF Device</text> +<path matrix="1.67303 0 0 1.24455 -266.268 -372.215" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 299.792 -238.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="23.9736" depth="12.024" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt USB3, PCIe, CPRI} +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 71.958 -189.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 23.958 -189.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 289 -154.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +lower-PHY RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 337 -154.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +lower-PHY TX +\end{tiny} +</text> +<path matrix="0.754883 0 0 0.844765 480.935 6.70954" stroke="black" fill="lightyellow"> +16 432 m +16 112 l +192 112 l +192 432 l +h +</path> +<path matrix="0.791667 0 0 1 303.97 -144.528" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.74239 0 0 0.607628 -58.1448 -70.7751" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 530.804 -210.953" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 569.012 -102.277" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="27.4872" depth="15.552" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY TX +\end{tiny} +</text> +<path matrix="1.7325 0 0 0.638421 -53.9193 44.2159" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 534.804 -83.9531" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.79658 0 0 0.968027 -76.0285 -53.4485" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.769443 0 0 0.141445 521.804 288.075" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="20.832" depth="8.856" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF1pp\_4P5 / ethernet} +\end{tiny} +</text> +<path matrix="1 0 0 1 174.012 -21.2041" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<text matrix="2.11243 0 0 1 385.616 -56.2041" transformations="translations" pos="48 480" stroke="black" type="minipage" width="143.13" height="10.896" depth="0" valign="top" size="small">\tiny to NGFI\_RCC, NGFI\_RAU</text> +<path matrix="0.924035 0 0 1 204.183 -321.204" stroke="black" fill="lightblue" arrow="normal/normal" rarrow="normal/normal"> +384 432 m +384 384 l +</path> +<path matrix="1.67303 0 0 1.24455 -34.3906 -373.77" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 531.669 -240.304" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="23.9736" depth="12.024" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt USB3, PCIe, CPRI} +\end{tiny} +</text> +<text matrix="2.11243 0 0 1 420.344 -422.726" transformations="translations" pos="48 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny to RF Device</text> +<text matrix="1 0 0 1 185 -0.999076" transformations="translations" pos="176 556" stroke="black" type="label" width="313.978" height="20.9244" depth="6.972" halign="center" valign="baseline">Functional Splits (Current)</text> +<text matrix="1 0 0 1 0 33" transformations="translations" pos="453.069 456.148" stroke="black" type="minipage" width="204.455" height="36.8592" depth="22.96" valign="top" style="center">NGFI\_RRU\par +(IF1'')</text> +<path matrix="0.791667 0 0 1 303.674 -194.932" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 255.674 -194.932" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 520.716 -159.681" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +lower-PHY RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 568.716 -159.681" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +lower-PHY TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 255.97 -144.528" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 521.012 -102.277" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="27.4872" depth="15.552" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY RX +\end{tiny} +</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 188.731 2.73037" transformations="translations" pos="176 556" stroke="black" type="label" width="352.257" height="19.3928" depth="5.404" halign="center" valign="baseline">Some Notes on usage of splits</text> +<text transformations="translations" pos="14.7471 512.821" stroke="black" type="minipage" width="707.342" height="239.641" depth="226.212" valign="top">\tiny\begin{itemize} +\item IF4p5 corresponds to the split-point at the input (TX) and output (RX) of the OFDM symbol generator (i.e. frequency-domain signals). According to NGFI, IF4 is "Resource mapping and IFFT" and "FFT and Resource demapping". We currently do not try to exploit multiplexing gains for unused spectral components. So, IF4p5 is simply compressed transmitted or received resource elements in the usable channel band. +\item The simplest deployment for DAS (indoor) is one NGFI\_RCC (IF4p5) and many NGFI\_RRU (IF4p5). Spatio-temportal filtering (Precoding, later) is done in RCC and RRU perform IFFT/FFT and signal generation/acquisition. Fronthaul rates in this case are feasible with 1GbE copper links. This allows for PoE in addition to fronthaul data. +\item More complex indoor, for instance with RCC in a common data center with outdoor RRS, could be +\begin{enumerate} + \item RCC-RAU with IF1'', RAU-RRU with IF4p5. Spatio-temporal filtering is done in frequency-domain in RAU along with full TX and RX processing (L1/L2) for the indoor RRS. Note that IF1' fronthaul on TX to RRU would be difficult because spatio-temporal filtering should be used. RRU does only IFFT/FFT and signal generation/acquisition +\item RCC-RAU with IF1', RAU-RRU with IF4p5. Here RCC does L2, RAU does L1 and precoding for RRS. +\end{enumerate} +\item A massive-MIMO solution would consist either of +\begin{enumerate} +\item an embedded RAU with processing (Spatio-temporal in frequency-domain, lower/upper PHY TX/RX) like the IF1' DAS solution above +\item or more simply a high-speed fronthaul (IF4p5) with an RAU for multiple sites +\item directly connected to RCC via high-speed IF4p5 (several virtual cells, precoder and IFFT/FFT in array). +\end{enumerate} +\item RCC solution with IF1'' would cater to evolved-PDCP for heterogenity (4G,5G,WIFI,IoT) +\item Currently supported node functionalities +\begin{enumerate} +\item {\tt 3GPP\_eNodeB} +\item {\tt 3GPP\_eNodeB\_BBU} [NGFI\_IF5] +\item {\tt NGFI\_RCC} [NGFI\_IF4p5] +\item {\tt NGFI\_RRU} [NGFI\_IF5] +\item {\tt NGFI\_RRU} [NGFI\_IF4p5] +\end{enumerate} +\end{itemize}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 188.731 2.73037" transformations="translations" pos="176 556" stroke="black" type="label" width="233.391" height="19.3928" depth="5.404" halign="center" valign="baseline">RU - L1 negotiation</text> +<path matrix="1 0 0 1 -16 64" stroke="black" fill="lightblue"> +64 448 m +64 256 l +256 256 l +256 448 l +h +</path> +<path matrix="1 0 0 1 368 64" stroke="black" fill="lightblue"> +64 448 m +64 256 l +256 256 l +256 448 l +h +</path> +<text matrix="1 0 0 1 -16 16" transformations="translations" pos="64 416" stroke="black" type="minipage" width="192" height="19.3928" depth="5.404" valign="top" style="center">RRU Entity</text> +<text matrix="1 0 0 1 368 32" transformations="translations" pos="64 416" stroke="black" type="minipage" width="192" height="36.8592" depth="22.96" valign="top" style="center">RAU/RCC Entity</text> +<path matrix="1 0 0 1 -16 64" stroke="black" fill="lightblue" arrow="normal/normal"> +544 192 m +544 256 l +</path> +<path matrix="1 0 0 1 -16 64" stroke="red" fill="lightblue" arrow="normal/normal"> +256 320 m +448 320 l +</path> +<path matrix="1 0 0 1 -16 64" stroke="red" fill="lightblue" arrow="normal/normal"> +448 288 m +256 288 l +</path> +<path matrix="1 0 0 1 -400 64" stroke="black" fill="lightblue" arrow="normal/normal"> +544 192 m +544 256 l +</path> +<text matrix="1 0 0 1 -312 33" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="64" height="11.2364" depth="0" valign="top">\tiny\tt .conf</text> +<text matrix="1 0 0 1 72 33" transformations="translations" pos="464 224" stroke="blue" type="minipage" width="64" height="11.2364" depth="0" valign="top">\tiny\tt .conf</text> +<text matrix="1 0 0 1 -199 158" transformations="translations" pos="464 224" stroke="black" type="minipage" width="160" height="21.1652" depth="7.196" valign="top">\tiny\tt fronthaul data (IF5,IF4p5)</text> +<path matrix="1 0 0 1 -16 160" stroke="green" fill="lightblue" arrow="normal/normal"> +256 320 m +448 320 l +</path> +<path matrix="1 0 0 1 -16 160" stroke="green" fill="lightblue" arrow="normal/normal"> +448 288 m +256 288 l +</path> +<text matrix="1 0 0 1 -215 235" transformations="translations" pos="464 224" stroke="black" type="minipage" width="176" height="13.3672" depth="0" valign="top">\tiny\tt RRU control/config</text> +<text matrix="1 0 0 1 0 80" transformations="translations" pos="32 160" stroke="black" type="minipage" width="672" height="116.743" depth="105.024" valign="top" size="small">\begin{small} +Control and Configuration protocol +\begin{enumerate} +\item RAU$\rightarrow$ RRU : heartbeat (capabilities request) +\item RRU$\rightarrow$ RAU: capabilities indication +\item RAU$\rightarrow$ RRU: configuration (band, dl\_Carrier,ul\_Carrier, dl\_RS\_EPRE, rx/tx attenuation) +\end{enumerate} +\end{small} +During steady state, the control port manages the link quality and status (packet losses, synchronization state, start/stop, etc.)</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" transformations="translations" pos="16 512" stroke="black" type="minipage" width="704" height="186.004" depth="172.452" valign="top">\begin{small} +\begin{itemize} +\item IF5 interface +\begin{itemize} +\item DL subframes with timestamp (16-bit samples) +\item UL subframes with timestamp (16-bit samples) +\item optional A-law compression (13$\rightarrow$8bit) +\end{itemize} +\item IF4p5 interface +\begin{itemize} +\item DL packets, ofdm symbols with frame/subframe/symbol count +\item UL packets, ofdm symbols with frame/subframe/symbol count (16-bit) +\item UL PRACH packets with frame/subframe count (16-bit) +\item optional A-law compression (13$\rightarrow$8bit) +\end{itemize} +\end{itemize} +\end{small}</text> +<text matrix="1 0 0 1 188.731 2.73037" transformations="translations" pos="176 556" stroke="black" type="label" width="225.333" height="19.3928" depth="5.404" halign="center" valign="baseline">RU - L1 data plane</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="3.99386 0 0 1 -2166.33 147.732" stroke="black" fill="darkgray"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<text matrix="1 0 0 1 185 -0.999076" transformations="translations" pos="176 556" stroke="black" type="label" width="317.156" height="20.9244" depth="6.972" halign="center" valign="baseline">IF5 Packet Format (16-bit)</text> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 102.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 262.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 422.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<text matrix="1 0 0 1 -53.6718 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">0</text> +<text matrix="1 0 0 1 106.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">16</text> +<text matrix="1 0 0 1 266.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">32</text> +<text matrix="1 0 0 1 426.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">48</text> +<text matrix="1 0 0 1 73.3282 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">15</text> +<text matrix="1 0 0 1 233.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">31</text> +<text matrix="1 0 0 1 393.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">47</text> +<text matrix="1 0 0 1 553.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">63</text> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="violet"> +64 320 m +64 288 l +544 288 l +544 320 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="orange"> +544 320 m +544 288 l +704 288 l +704 320 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="orange"> +64 288 m +64 256 l +384 256 l +384 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="lightyellow"> +384 288 m +384 256 l +544 256 l +544 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="lightgreen"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<text matrix="1 0 0 1 45.3282 250.732" transformations="translations" pos="96 224" stroke="black" type="label" width="184.702" height="14.9448" depth="0" valign="baseline" size="small">\small Destination Address</text> +<text matrix="1 0 0 1 435.328 250.732" transformations="translations" pos="96 224" stroke="black" type="label" width="61.9848" height="14.9448" depth="0" valign="baseline" size="small">\small Source</text> +<text matrix="1 0 0 1 237.328 221.732" transformations="translations" pos="96 224" stroke="black" type="label" width="135.391" height="16.1424" depth="5.376" valign="baseline" size="small">\small Type (0x1234)</text> +<text matrix="1 0 0 1 421.328 221.732" transformations="translations" pos="96 224" stroke="black" type="label" width="93.8976" height="14.952" depth="4.176" valign="baseline" size="small">\small RF Config</text> +<text matrix="1 0 0 1 30.3282 218.732" transformations="translations" pos="96 224" stroke="black" type="label" width="71.9664" height="14.9448" depth="0" valign="baseline" size="small">\small Address</text> +<path matrix="1 0 0 1 -57.6718 162.732" stroke="black" fill="red"> +64 160 m +64 128 l +384 128 l +384 160 l +h +</path> +<text matrix="1 0 0 1 -52.6718 75.7323" transformations="translations" pos="96 224" stroke="black" type="label" width="214.279" height="14.952" depth="4.176" valign="baseline" size="small">\small Frame Check Sequence</text> +<path matrix="1 0 0 1 0.328186 99.7323" stroke="black"> +256 240 m +256 240 l +256 240 l +</path> +<text matrix="1 0 0 1 176.328 189.732" transformations="translations" pos="96 224" stroke="black" type="label" width="103.87" height="14.952" depth="4.176" valign="baseline" size="small">\small Timestamp</text> +<path matrix="1 0 0 1 1.3282 309" stroke="black" fill="lightblue" tiling="falling"> +5 63.5079 m +5 46.9999 l +645 46.9999 l +645 63.5079 l +h +</path> +<path matrix="1 0 0 1 -57.6718 148" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 148" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 100" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -57.6718 100" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 0 100" stroke="black"> +256 240 m +256 240 l +256 240 l +</path> +<path matrix="1 0 0 1 0 100" stroke="black"> +166 304 m +165.917 272.508 l +166.247 272.508 l +</path> +<path matrix="1 0 0 1 0 100" stroke="black"> +486 304 m +486.316 272.508 l +485.986 272.508 l +</path> +<path matrix="1 0 0 1 0 100" stroke="black"> +486.316 256 m +486.646 224 l +485.657 224 l +</path> +<path matrix="1 0 0 1 -320.398 99.9995" stroke="black"> +486.316 256 m +486.646 224 l +485.657 224 l +</path> +<text matrix="1 0 0 1 17 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_0$</text> +<text matrix="1 0 0 1 166 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_0$</text> +<text matrix="1 0 0 1 335 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_1$</text> +<text matrix="1 0 0 1 492 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_1$</text> +<text matrix="1 0 0 1 -3 89" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="13.0848" depth="1.128" valign="top" size="small">\tiny $Q_{N-2}$</text> +<text matrix="1 0 0 1 150 89" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="13.0848" depth="1.128" valign="top" size="small">\tiny $Q_{N-2}$</text> +<text matrix="1 0 0 1 320 89" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="13.0848" depth="1.128" valign="top" size="small">\tiny $I_{N-1}$</text> +<text matrix="1 0 0 1 477 89" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="13.0848" depth="1.128" valign="top" size="small">\tiny $Q_{N-1}$</text> +<text matrix="1 0 0 1 0 43" transformations="translations" pos="0 240" stroke="black" type="minipage" width="736" height="43.8816" depth="31.968" valign="top" size="small">\tiny +\begin{itemize} +\item {\bf Type:} 2 byte (16 bit) field that specifies the RoE protocol +\item {\bf RX Config:} 16-bit. Currently just antenna index (0-7). Can later be used for gain/timing adjustments. +\item {\bf Timstamp:} Timestamp in samples of the first sample of the received packet. +\end{itemize} +\begin{itemize} +\item {\bf data block :} Uncompressed IQ samples, 16-bit resolution for each real and imaginary component. $N$ complex samples per packet. $N$ can be configured at initialization. +\end{itemize}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 185 -0.999076" transformations="translations" pos="176 556" stroke="black" type="label" width="303.209" height="20.9244" depth="6.972" halign="center" valign="baseline">IF5 Packet Format (8-bit)</text> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 102.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 262.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 422.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<text matrix="1 0 0 1 -53.6718 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">0</text> +<text matrix="1 0 0 1 106.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">16</text> +<text matrix="1 0 0 1 266.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">32</text> +<text matrix="1 0 0 1 426.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">48</text> +<text matrix="1 0 0 1 73.3282 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">15</text> +<text matrix="1 0 0 1 233.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">31</text> +<text matrix="1 0 0 1 393.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">47</text> +<text matrix="1 0 0 1 553.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">63</text> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="violet"> +64 320 m +64 288 l +544 288 l +544 320 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="orange"> +544 320 m +544 288 l +704 288 l +704 320 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="orange"> +64 288 m +64 256 l +384 256 l +384 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="lightyellow"> +384 288 m +384 256 l +544 256 l +544 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="darkgray"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="lightblue"> +384 256 m +384 224 l +704 224 l +704 256 l +h +</path> +<text matrix="1 0 0 1 45.3282 250.732" transformations="translations" pos="96 224" stroke="black" type="label" width="184.702" height="14.9448" depth="0" valign="baseline" size="small">\small Destination Address</text> +<text matrix="1 0 0 1 430.328 250.732" transformations="translations" pos="96 224" stroke="black" type="label" width="61.9848" height="14.9448" depth="0" valign="baseline" size="small">\small Source</text> +<text matrix="1 0 0 1 237.328 221.732" transformations="translations" pos="96 224" stroke="black" type="label" width="145.154" height="16.1424" depth="5.376" valign="baseline" size="small">\small Type (0xBEEF)</text> +<text matrix="1 0 0 1 427.328 221.732" transformations="translations" pos="96 224" stroke="black" type="label" width="84.5928" height="14.952" depth="4.176" valign="baseline" size="small">\small RX Flags</text> +<text matrix="1 0 0 1 30.3282 218.732" transformations="translations" pos="96 224" stroke="black" type="label" width="71.9664" height="14.9448" depth="0" valign="baseline" size="small">\small Address</text> +<path matrix="1 0 0 1 -537.672 147.732" stroke="black" fill="darkgray"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<text matrix="1 0 0 1 -62.672 189.732" transformations="translations" pos="96 224" stroke="black" type="label" width="110.182" height="14.9448" depth="0" valign="baseline" size="small">\small FIFO\_status</text> +<path matrix="1 0 0 1 -377.672 147.732" stroke="black" fill="darkgray"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<text matrix="1 0 0 1 81.328 192.732" transformations="translations" pos="96 224" stroke="black" type="label" width="52.3516" height="9.7104" depth="2.688" valign="baseline" size="large">\tiny SeqNum</text> +<text matrix="1 0 0 1 175.328 192.732" transformations="translations" pos="96 224" stroke="black" type="label" width="25.2224" height="9.6852" depth="0" valign="baseline" size="large">\tiny rsvd</text> +<path matrix="1 0 0 1 -5 0" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<text matrix="1 0 0 1 358.328 189.732" transformations="translations" pos="96 224" stroke="black" type="label" width="60.7872" height="14.9448" depth="0" valign="baseline" size="small">\small Word0</text> +<path matrix="1 0 0 1 1 242" stroke="black" fill="lightblue" tiling="falling"> +5 63.5079 m +5 46.9999 l +645 46.9999 l +645 63.5079 l +h +</path> +<path matrix="1 0 0 1 262 148" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -58 81" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -58 33" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 320 100" stroke="black"> +166 304 m +165.917 272.508 l +166.247 272.508 l +</path> +<path matrix="1 0 0 1 -320 33" stroke="black"> +486 304 m +486.316 272.508 l +485.986 272.508 l +</path> +<path matrix="1 0 0 1 -320 33" stroke="black"> +486.316 256 m +486.646 224 l +485.657 224 l +</path> +<text matrix="1 0 0 1 288 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_0$</text> +<path matrix="1 0 0 1 154 -32" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 315 -32" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -167 -99" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -7 -99" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -167 -147" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -7 -147" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<text matrix="1 0 0 1 371 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_0$</text> +<text matrix="1 0 0 1 446 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_1$</text> +<text matrix="1 0 0 1 529 137" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_1$</text> +<text matrix="1 0 0 1 -32 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_2$</text> +<text matrix="1 0 0 1 51 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_2$</text> +<text matrix="1 0 0 1 128 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_3$</text> +<text matrix="1 0 0 1 211 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_3$</text> +<text matrix="1 0 0 1 -32 22" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_{638}$</text> +<text matrix="1 0 0 1 51 22" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_{638}$</text> +<text matrix="1 0 0 1 128 22" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_{639}$</text> +<text matrix="1 0 0 1 211 22" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_{639}$</text> +<text matrix="1 0 0 1 0 -24" transformations="translations" pos="0 240" stroke="black" type="minipage" width="736" height="65.3664" depth="53.52" valign="top" size="small">\tiny +\begin{itemize} +\item {\bf Type:} 2 byte (16 bit) field that specifies the RoE protocol +\item {\bf RX Flags:} overrun indicator. should be '0'. +\item {\bf FIFO status:} 2 bytes. should be '0'. +\item {\bf SeqNum:} 1 byte. Sequence number of the ethernet packet. +\item {\bf rsvd:} 1 byte. shoult be '0'. \item {\bf Word0:} 4 byte (32-bit). should be '0'. +\item {\bf Timstamp:} Timestamp in samples of the first sample of the received packet. \end{itemize} +\begin{itemize} +\item {\bf data block :} Uncompressed IQ samples, 8-bit resolution for each real and imaginary component. 640 complex samples per packet. +\end{itemize}</text> +<path matrix="1 0 0 1 -377.672 147.732" stroke="black" fill="lightblue"> +384 256 m +384 224 l +704 224 l +704 256 l +h +</path> +<text matrix="1 0 0 1 17.328 157.732" transformations="translations" pos="96 224" stroke="black" type="label" width="103.87" height="14.952" depth="4.176" valign="baseline" size="small">\small Timestamp</text> +<path matrix="1 0 0 1 262 81" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 0 33" stroke="black"> +486 304 m +486.316 272.508 l +485.986 272.508 l +</path> +<path matrix="1 0 0 1 153 -99" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 313 -99" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<text matrix="1 0 0 1 288 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_4$</text> +<text matrix="1 0 0 1 371 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_4$</text> +<text matrix="1 0 0 1 448 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $I_5$</text> +<text matrix="1 0 0 1 531 70" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="11.856" depth="0" valign="top" size="small">\tiny $Q_5$</text> +<path matrix="1 0 0 1 262.328 128.732" stroke="black" fill="red"> +64 160 m +64 128 l +384 128 l +384 160 l +h +</path> +<text matrix="1 0 0 1 283.328 40.7323" transformations="translations" pos="96 224" stroke="black" type="label" width="214.279" height="14.952" depth="4.176" valign="baseline" size="small">\small Frame Check Sequence</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 185 -0.999076" transformations="translations" pos="176 556" stroke="black" type="label" width="347.724" height="20.9244" depth="6.972" halign="center" valign="baseline">IF4p5 Packet Formats (RAW)</text> +<path stroke="black"> +272 512 m +272 512 l +272 512 l +272 512 l +h +</path> +<path matrix="1 0 0 1 -58 144" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 102 144" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 262 144" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 422 144" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<text matrix="1 0 0 1 -54 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">0</text> +<text matrix="1 0 0 1 106 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">16</text> +<text matrix="1 0 0 1 266 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">32</text> +<text matrix="1 0 0 1 426 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">48</text> +<text matrix="1 0 0 1 73 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">15</text> +<text matrix="1 0 0 1 233 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">31</text> +<text matrix="1 0 0 1 393 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">47</text> +<text matrix="1 0 0 1 553 150" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">63</text> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="violet"> +64 320 m +64 288 l +544 288 l +544 320 l +h +</path> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="orange"> +544 320 m +544 288 l +704 288 l +704 320 l +h +</path> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="orange"> +64 288 m +64 256 l +384 256 l +384 288 l +h +</path> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="lightyellow"> +384 288 m +384 256 l +544 256 l +544 288 l +h +</path> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="darkgray"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="lightblue"> +384 256 m +384 224 l +704 224 l +704 256 l +h +</path> +<path matrix="1 0 0 1 -58 207" stroke="black" fill="lightblue"> +64 160 m +64 96 l +704 96 l +704 160 l +h +</path> +<text matrix="1 0 0 1 45 215" transformations="translations" pos="96 224" stroke="black" type="label" width="184.702" height="14.9448" depth="0" valign="baseline" size="small">\small Destination Address</text> +<text matrix="1 0 0 1 430 215" transformations="translations" pos="96 224" stroke="black" type="label" width="61.9848" height="14.9448" depth="0" valign="baseline" size="small">\small Source</text> +<text matrix="1 0 0 1 237 186" transformations="translations" pos="96 224" stroke="black" type="label" width="139.111" height="16.1424" depth="5.376" valign="baseline" size="small">\small Type (0x080A)</text> +<text matrix="1 0 0 1 391 186" transformations="translations" pos="96 224" stroke="black" type="label" width="164.63" height="16.1424" depth="5.376" valign="baseline" size="small">\small Subtype (0x0021)</text> +<text matrix="1 0 0 1 30 183" transformations="translations" pos="96 224" stroke="black" type="label" width="71.9664" height="14.9448" depth="0" valign="baseline" size="small">\small Address</text> +<text matrix="1 0 0 1 239 151" transformations="translations" pos="96 224" stroke="black" type="label" width="250.642" height="14.952" depth="4.176" valign="baseline" size="small">\small LTE PRACH Configuration</text> +<text matrix="1 0 0 1 30 151" transformations="translations" pos="96 224" stroke="black" type="label" width="81.4704" height="14.9448" depth="0" valign="baseline" size="small">\small Reserved</text> +<text matrix="1 0 0 1 47 105" transformations="translations" pos="96 224" stroke="black" type="label" width="314.436" height="16.1424" depth="5.376" valign="baseline" size="small">\small PRACH data block (one antenna)</text> +<path matrix="1 0 0 1 -58 144" stroke="black" fill="red"> +64 160 m +64 128 l +384 128 l +384 160 l +h +</path> +<text matrix="1 0 0 1 -53 57" transformations="translations" pos="96 224" stroke="black" type="label" width="214.279" height="14.952" depth="4.176" valign="baseline" size="small">\small Frame Check Sequence</text> +<path matrix="1 0 0 1 -58 144" stroke="black"> +384 160 m +384 128 l +704 128 l +704 160 l +h +</path> +<text matrix="1 0 0 1 -58 118" transformations="translations" pos="64 384" stroke="black" type="label" width="423.247" height="17.9352" depth="5.976" valign="baseline" size="small">IF4p5 PRACH Packet (RRU$\rightarrow$ RAU,RCC)</text> +<text matrix="1 0 0 1 0 27" transformations="translations" pos="0 240" stroke="black" type="minipage" width="736" height="98.2224" depth="86.472" valign="top" size="small">\tiny +\begin{itemize} +\item {\bf Type:} 2 byte (16 bit) field that specifies the RoE protocol +\item {\bf Subtype:} 2 byte (16 bit) field that specifies the packet subtype +\item {\bf Reserved:} 4 byte (32 bit) field reserved +\item {\bf LTE PRACH conf:} 4 byte (32-bit) field that details the configuration of the LTE PRACH packet +\end{itemize} +\vskip 3pt +\begin{tabular}{|c|c|} +\hline +{\bf field (0 is LSB, 31 is MSB)} & {\bf description}\\ \hline +rsvd (0:2) & Reserved.\\ \hline +ant (3:5) & 3-bit Antenna index of LTE PRACH packet\\ \hline +RF Num (6:21) & 16-bit field indicating the Radio Frame number of this received PRACH packet\\ \hline +SF Num (22:25) & 4-bit field indicating the sub-frame number in the radio frame for the LTE PRACH packet\\ + & Valid range of 0 to 9.\\ \hline +Exponent (26:31) & FFT exponent output (0 if unscaled) \\ +\hline +\end{tabular} +\begin{itemize} +\item {\bf PRACH data block:} Uncompressed IQ samples +\end{itemize}</text> +<path matrix="1 0 0 1 -58 -176.508" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 -176.508" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<text matrix="1 0 0 1 -63 -167.508" transformations="translations" pos="96 224" stroke="black" type="label" width="63.5328" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 0 (Real)</text> +<text matrix="1 0 0 1 93 -167.508" transformations="translations" pos="96 224" stroke="black" type="label" width="66.6048" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 0 (Imag)</text> +<text matrix="1 0 0 1 257 -167.508" transformations="translations" pos="96 224" stroke="black" type="label" width="63.5328" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 1 (Real)</text> +<text matrix="1 0 0 1 417 -167.508" transformations="translations" pos="96 224" stroke="black" type="label" width="66.6048" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 1 (Imag)</text> +<path matrix="1 0 0 1 -0.000004 -224.508" stroke="black"> +166 304 m +165.917 272.508 l +166.247 272.508 l +</path> +<path matrix="1 0 0 1 -0.000004 -224.508" stroke="black"> +486 304 m +486.316 272.508 l +485.986 272.508 l +</path> +<path matrix="1 0 0 1 -58 -224" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 -224" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<text matrix="1 0 0 1 -63 -215" transformations="translations" pos="96 224" stroke="black" type="label" width="76.236" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 837 (Real)</text> +<text matrix="1 0 0 1 93 -215" transformations="translations" pos="96 224" stroke="black" type="label" width="79.308" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 837 (Imag)</text> +<text matrix="1 0 0 1 257 -215" transformations="translations" pos="96 224" stroke="black" type="label" width="76.236" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 838 (Real)</text> +<text matrix="1 0 0 1 417 -215" transformations="translations" pos="96 224" stroke="black" type="label" width="79.308" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny RE 838 (Imag)</text> +<path matrix="1 0 0 1 -0.000014 -272" stroke="black"> +166 304 m +165.917 272.508 l +166.247 272.508 l +</path> +<path matrix="1 0 0 1 -0.000014 -272" stroke="black"> +486 304 m +486.316 272.508 l +485.986 272.508 l +</path> +<path stroke="black" fill="lightblue" tiling="falling"> +6.00001 47.492 m +6.00001 32 l +646 32 l +646 47.492 l +h +</path> +<path stroke="black"> +528 16 m +528 16 l +528 16 l +528 16 l +h +</path> +<path stroke="black"> +560 16 m +560 16 l +560 16 l +560 16 l +h +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +64 224 m +64 192 l +224 192 l +224 224 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +224 224 m +224 192 l +384 192 l +384 224 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +384 224 m +384 192 l +544 192 l +544 224 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +544 224 m +544 192 l +704 192 l +704 224 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +64 192 m +64 160 l +224 160 l +224 192 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +224 192 m +224 160 l +384 160 l +384 192 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +384 192 m +384 160 l +544 160 l +544 192 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +544 192 m +544 160 l +704 160 l +704 192 l +h +</path> +<text matrix="1 0 0 1 -42 155" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 0</text> +<text matrix="1 0 0 1 118 155" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 1</text> +<text matrix="1 0 0 1 -42 123" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 4</text> +<text matrix="1 0 0 1 118 123" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 5</text> +<text matrix="1 0 0 1 278 155" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 2</text> +<text matrix="1 0 0 1 438 155" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 3</text> +<text matrix="1 0 0 1 278 123" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 6</text> +<text matrix="1 0 0 1 438 123" transformations="translations" pos="96 224" stroke="black" type="label" width="60.5064" height="14.9448" depth="0" valign="baseline" size="small">\small Gain 7</text> +<path matrix="1 0 0 1 0 36" stroke="black"> +272 512 m +272 512 l +272 512 l +272 512 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 102 180" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 262 180" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 422 180" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<text matrix="1 0 0 1 -54 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">0</text> +<text matrix="1 0 0 1 106 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">16</text> +<text matrix="1 0 0 1 266 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">32</text> +<text matrix="1 0 0 1 426 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">48</text> +<text matrix="1 0 0 1 73 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">15</text> +<text matrix="1 0 0 1 233 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">31</text> +<text matrix="1 0 0 1 393 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">47</text> +<text matrix="1 0 0 1 553 186" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">63</text> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="violet"> +64 320 m +64 288 l +544 288 l +544 320 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="orange"> +544 320 m +544 288 l +704 288 l +704 320 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="orange"> +64 288 m +64 256 l +384 256 l +384 288 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightyellow"> +384 288 m +384 256 l +544 256 l +544 288 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="darkgray"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -58 180" stroke="black" fill="lightblue"> +384 256 m +384 224 l +704 224 l +704 256 l +h +</path> +<text matrix="1 0 0 1 45 251" transformations="translations" pos="96 224" stroke="black" type="label" width="184.702" height="14.9448" depth="0" valign="baseline" size="small">\small Destination Address</text> +<text matrix="1 0 0 1 430 251" transformations="translations" pos="96 224" stroke="black" type="label" width="61.9848" height="14.9448" depth="0" valign="baseline" size="small">\small Source</text> +<text matrix="1 0 0 1 237 222" transformations="translations" pos="96 224" stroke="black" type="label" width="139.111" height="16.1424" depth="5.376" valign="baseline" size="small">\small Type (0x080A)</text> +<text matrix="1 0 0 1 391 222" transformations="translations" pos="96 224" stroke="black" type="label" width="164.63" height="16.1424" depth="5.376" valign="baseline" size="small">\small Subtype (0x0019)</text> +<text matrix="1 0 0 1 30 219" transformations="translations" pos="96 224" stroke="black" type="label" width="71.9664" height="14.9448" depth="0" valign="baseline" size="small">\small Address</text> +<text matrix="1 0 0 1 239 187" transformations="translations" pos="96 224" stroke="black" type="label" width="119.986" height="14.9448" depth="0" valign="baseline" size="small">\small Frame status</text> +<text matrix="1 0 0 1 30 187" transformations="translations" pos="96 224" stroke="black" type="label" width="81.4704" height="14.9448" depth="0" valign="baseline" size="small">\small Reserved</text> +<path matrix="1 0 0 1 -58 99" stroke="black" fill="red"> +64 160 m +64 128 l +384 128 l +384 160 l +h +</path> +<text matrix="1 0 0 1 -53 12" transformations="translations" pos="96 224" stroke="black" type="label" width="214.279" height="14.952" depth="4.176" valign="baseline" size="small">\small Frame Check Sequence</text> +<text matrix="1 0 0 1 0 -12" transformations="translations" pos="0 240" stroke="black" type="minipage" width="736" height="116.527" depth="104.808" valign="top" size="small">\tiny +\begin{itemize} +\item {\bf Type:} 2 byte (16 bit) field that specifies the RoE protocol +\item {\bf Subtype:} 2 byte (16 bit) field that specifies the packet subtype +\item {\bf Reserved:} 4 byte (32 bit) field reserved +\item {\bf Frame Status:} 4 byte (32 bit) field +\end{itemize} +\vskip 3pt +\begin{tabular}{|c|c|} +\hline +{\bf field (0 is LSB, 31 is MSB)} & {\bf description}\\ \hline +{\bf ant} (0:2) & The number of Antenna Carriers represented in the packet. Antenna numbers \\ +& range from 0 to 7 with valid inputs being 0,1, 3 and 7 (1,2,4,8 antennas)\\ \hline +{\bf ant start} (3:5) & starting antenna number\\ \hline +{\bf RF Num} (6:21) & 16-bit field indicating the Radio Frame number of the UL\_RE samples\\ \hline +{\bf SF Num} (22:25) & 4-bit field indicating the sub-frame number in the radio frame for the UL\_RE samples\\ + & Valid range of 0 to 9.\\ \hline +{\bf Sym Num:} (26:29) & Symbol number. Valid range of 0 to 13. \\ +{\bf rsvd:} (30:31) & reserved\\ +\hline +\end{tabular} +\begin{itemize} +\item {\bf ULRE data block:} compressed IQ samples (8-bit A-law). $N$ is the number of resource elements $N_{\mathrm{RB}}^{\mathrm{UL}}$. +\end{itemize}</text> +<path matrix="1 0 0 1 1 245" stroke="black" fill="lightblue" tiling="falling"> +5 63.5079 m +5 46.9999 l +645 46.9999 l +645 63.5079 l +h +</path> +<path matrix="1 0 0 1 -58 84" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 84" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 36" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -58 36" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<text matrix="1 0 0 1 38 166" transformations="translations" pos="64 384" stroke="black" type="label" width="589.005" height="25.102" depth="8.372" valign="baseline" size="large">IF4p5 Packets : ULRE (RRU$\rightarrow$ RAU,RCC)</text> +<path matrix="1 0 0 1 0 36" stroke="black"> +256 240 m +256 240 l +256 240 l +</path> +<path matrix="1 0 0 1 0 36" stroke="black"> +166 304 m +165.917 272.508 l +166.247 272.508 l +</path> +<path matrix="1 0 0 1 0 36" stroke="black"> +486 304 m +486.316 272.508 l +485.986 272.508 l +</path> +<path matrix="1 0 0 1 0 36" stroke="black"> +486.316 256 m +486.646 224 l +485.657 224 l +</path> +<path matrix="1 0 0 1 -320.398 35.9995" stroke="black"> +486.316 256 m +486.646 224 l +485.657 224 l +</path> +<path matrix="1 0 0 1 0 36" stroke="black" cap="1"> +258.16 141.771 m +258.16 141.771 l +</path> +<path matrix="1 0 0 1 0 36" stroke="black" cap="1"> +418.597 191.907 m +418.597 191.907 l +</path> +<path matrix="1 0 0 1 0 36" stroke="black" cap="1"> +429.181 79.9357 m +429.181 79.9357 l +</path> +<text matrix="1 0 0 1 -56 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 0\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 24 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 0\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 104 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 1\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 184 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 1\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 264 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 2\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 344 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 2\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 424 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 3\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 504 84" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 3\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 -56 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-4$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 24 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-4$\\Ant $R$ (Im)</text> +<text matrix="1 0 0 1 104 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-3$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 184 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-3$\\Ant $R$ (Im)</text> +<text matrix="1 0 0 1 264 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-2$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 344 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-2$\\Ant $R$ (Im)</text> +<text matrix="1 0 0 1 424 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-1$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 504 36" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-1$\\Ant $R$ (Im)</text> +<path matrix="1 0 0 1 -166 -96" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -6 -96" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 153 -96" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 313 -96" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -166 -144" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -6 -144" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 153 -144" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 313 -144" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 0.328186 35.7323" stroke="black"> +272 512 m +272 512 l +272 512 l +272 512 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 102.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 262.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<path matrix="1 0 0 1 422.328 179.732" stroke="black"> +64 352 m +64 320 l +224 320 l +224 352 l +h +</path> +<text matrix="1 0 0 1 -53.6718 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">0</text> +<text matrix="1 0 0 1 106.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">16</text> +<text matrix="1 0 0 1 266.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">32</text> +<text matrix="1 0 0 1 426.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">48</text> +<text matrix="1 0 0 1 73.3282 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">15</text> +<text matrix="1 0 0 1 233.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">31</text> +<text matrix="1 0 0 1 393.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">47</text> +<text matrix="1 0 0 1 553.328 185.732" transformations="translations" pos="64 336" stroke="black" type="minipage" width="32" height="13.8264" depth="1.848" valign="top" size="small">63</text> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="violet"> +64 320 m +64 288 l +544 288 l +544 320 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="orange"> +544 320 m +544 288 l +704 288 l +704 320 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="orange"> +64 288 m +64 256 l +384 256 l +384 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="lightyellow"> +384 288 m +384 256 l +544 256 l +544 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="darkgray"> +544 288 m +544 256 l +704 256 l +704 288 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -57.6718 179.732" stroke="black" fill="lightblue"> +384 256 m +384 224 l +704 224 l +704 256 l +h +</path> +<text matrix="1 0 0 1 45.3282 250.732" transformations="translations" pos="96 224" stroke="black" type="label" width="184.702" height="14.9448" depth="0" valign="baseline" size="small">\small Destination Address</text> +<text matrix="1 0 0 1 430.328 250.732" transformations="translations" pos="96 224" stroke="black" type="label" width="61.9848" height="14.9448" depth="0" valign="baseline" size="small">\small Source</text> +<text matrix="1 0 0 1 237.328 221.732" transformations="translations" pos="96 224" stroke="black" type="label" width="139.111" height="16.1424" depth="5.376" valign="baseline" size="small">\small Type (0x080A)</text> +<text matrix="1 0 0 1 391.328 221.732" transformations="translations" pos="96 224" stroke="black" type="label" width="164.63" height="16.1424" depth="5.376" valign="baseline" size="small">\small Subtype (0x0020)</text> +<text matrix="1 0 0 1 30.3282 218.732" transformations="translations" pos="96 224" stroke="black" type="label" width="71.9664" height="14.9448" depth="0" valign="baseline" size="small">\small Address</text> +<text matrix="1 0 0 1 239.328 186.732" transformations="translations" pos="96 224" stroke="black" type="label" width="119.986" height="14.9448" depth="0" valign="baseline" size="small">\small Frame status</text> +<text matrix="1 0 0 1 30.3282 186.732" transformations="translations" pos="96 224" stroke="black" type="label" width="81.4704" height="14.9448" depth="0" valign="baseline" size="small">\small Reserved</text> +<path matrix="1 0 0 1 -57.6718 162.732" stroke="black" fill="red"> +64 160 m +64 128 l +384 128 l +384 160 l +h +</path> +<text matrix="1 0 0 1 -52.6718 75.7323" transformations="translations" pos="96 224" stroke="black" type="label" width="214.279" height="14.952" depth="4.176" valign="baseline" size="small">\small Frame Check Sequence</text> +<text matrix="1 0 0 1 0.328186 51.7323" transformations="translations" pos="0 240" stroke="black" type="minipage" width="736" height="116.527" depth="104.808" valign="top" size="small">\tiny +\begin{itemize} +\item {\bf Type:} 2 byte (16 bit) field that specifies the RoE protocol +\item {\bf Subtype:} 2 byte (16 bit) field that specifies the packet subtype +\item {\bf Reserved:} 4 byte (32 bit) field reserved +\item {\bf Frame Status:} 4 byte (32 bit) field +\end{itemize} +\vskip 3pt +\begin{tabular}{|c|c|} +\hline +{\bf field (0 is LSB, 31 is MSB)} & {\bf description}\\ \hline +{\bf ant} (0:2) & The number of Antenna Carriers represented in the packet. Antenna numbers \\ +& range from 0 to 7 with valid inputs being 0,1, 3 and 7 (1,2,4,8 antennas)\\ \hline +{\bf ant start} (3:5) & starting antenna number\\ \hline +{\bf RF Num} (6:21) & 16-bit field indicating the Radio Frame number of this DLRE packet\\ \hline +{\bf SF Num} (22:25) & 4-bit field indicating the sub-frame number in the radio frame for the DLRE packet\\ + & Valid range of 0 to 9.\\ \hline +{\bf Sym Num:} (26:29) & Symbol number. Valid range of 0 to 13. \\ +{\bf rsvd:} (30:31) & reserved\\ +\hline +\end{tabular} +\begin{itemize} +\item DLRE data block : compressed IQ samples (8-bit A-law). $N$ is the number of resource elements $N_{\mathrm{RB}}^{\mathrm{DL}}$. +\end{itemize}</text> +<text matrix="1 0 0 1 38.3282 165.732" transformations="translations" pos="64 384" stroke="black" type="label" width="590.262" height="25.102" depth="8.372" valign="baseline" size="large">IF4p5 Packets : DLRE (RAU,RCC $\rightarrow$RRU)</text> +<path matrix="1 0 0 1 0.328186 99.7323" stroke="black" cap="1"> +258.16 141.771 m +258.16 141.771 l +</path> +<path matrix="1 0 0 1 0.328186 99.7323" stroke="black" cap="1"> +418.597 191.907 m +418.597 191.907 l +</path> +<path matrix="1 0 0 1 0.328186 99.7323" stroke="black" cap="1"> +429.181 79.9357 m +429.181 79.9357 l +</path> +<path matrix="1 0 0 1 1 309" stroke="black" fill="lightblue" tiling="falling"> +5 63.5079 m +5 46.9999 l +645 46.9999 l +645 63.5079 l +h +</path> +<path matrix="1 0 0 1 -58 148" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 148" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 262 100" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 -58 100" stroke="black" fill="lightblue"> +64 256 m +64 224 l +384 224 l +384 256 l +h +</path> +<path matrix="1 0 0 1 0 100" stroke="black"> +166 304 m +165.917 272.508 l +166.247 272.508 l +</path> +<path matrix="1 0 0 1 0 100" stroke="black"> +486 304 m +486.316 272.508 l +485.986 272.508 l +</path> +<path matrix="1 0 0 1 0 100" stroke="black"> +486.316 256 m +486.646 224 l +485.657 224 l +</path> +<path matrix="1 0 0 1 -320.398 99.9995" stroke="black"> +486.316 256 m +486.646 224 l +485.657 224 l +</path> +<text matrix="1 0 0 1 -56 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 0\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 24 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 0\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 104 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 1\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 184 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 1\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 264 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 2\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 344 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 2\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 424 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 3\\Ant 1 (Re)</text> +<text matrix="1 0 0 1 504 148" transformations="translations" pos="64 256" stroke="black" type="minipage" width="80" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE 3\\Ant 1 (Im)</text> +<text matrix="1 0 0 1 -56 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-4$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 24 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-4$\\Ant $R$ (Im)</text> +<text matrix="1 0 0 1 104 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-3$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 184 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-3$\\Ant $R$ (Im)</text> +<text matrix="1 0 0 1 264 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-2$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 344 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-2$\\Ant $R$ (Im)</text> +<text matrix="1 0 0 1 424 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-1$\\Ant $R$ (Re)</text> +<text matrix="1 0 0 1 504 100" transformations="translations" pos="64 256" stroke="black" type="minipage" width="96" height="18.7968" depth="6.84" valign="top" size="small">\tiny RE $N-1$\\Ant $R$ (Im)</text> +<path matrix="1 0 0 1 -166 -32" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -6 -32" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 153 -32" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 313 -32" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -166 -80" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 -6 -80" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 153 -80" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +<path matrix="1 0 0 1 313 -80" stroke="black"> +248.997 435.732 m +248.997 403.732 l +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" stroke="black" fill="violet"> +640 128 m +640 32 l +704 32 l +704 128 l +h +</path> +<path stroke="black" fill="violet"> +640 480 m +640 176 l +720 176 l +720 480 l +h +</path> +<path matrix="0.782649 0 0 1 194.326 12" fill="lightgray"> +328.159 119.72 m +328.159 15.3556 l +554.022 15.3556 l +554.022 119.72 l +h +</path> +<path matrix="0.898058 0 0 0.385515 103.608 -169.189" fill="lightyellow" fillrule="eofill"> +96 784 m +96 496 l +224 496 l +224 784 l +h +</path> +<path matrix="1 0 0 1 -69 -4" stroke="black"> +-192 928 m +-192 944 l +-192 944 l +-192 928 l +h +</path> +<path matrix="0.956412 0 0 1.08596 98.2256 -362.832" fill="lightyellow"> +96 784 m +96 496 l +224 496 l +224 784 l +h +</path> +<text matrix="1 0 0 1 147 -22" transformations="translations" pos="48 512" stroke="black" type="label" width="124.692" height="14.9448" depth="0" valign="baseline" size="small">\begin{small}L1 Instance 0\end{small}</text> +<text matrix="1 0 0 1 144 -377" transformations="translations" pos="48 512" stroke="black" type="label" width="128.453" height="16.6032" depth="0" valign="baseline" size="small">LI instance 1</text> +<text matrix="1 0 0 1 406 -26" transformations="translations" pos="48 512" stroke="black" type="label" width="270.245" height="16.1424" depth="5.376" valign="baseline" size="small">\begin{small}MAC/RLC/PDCP Instance 0\end{small}</text> +<path matrix="1 0 0 1 -46 -4" stroke="black"> +364 518 m +364 518 l +364 518 l +364 518 l +h +</path> +<path matrix="1.39392 0 0 1.07237 321.184 -356.09" fill="lightgray"> +96 784 m +96 496 l +224 496 l +224 784 l +h +</path> +<path matrix="0.835391 0 0 0.672703 360.137 -36.0947" fill="lightblue"> +128 768 m +128 704 l +192 704 l +192 768 l +h +</path> +<text matrix="1.36111 0 0 0.829268 467.799 77.5985" transformations="translations" pos="0 474" stroke="black" type="minipage" width="52" height="17.6496" depth="5.664" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +DL/UL Scheduler +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 200.75 -1" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 465.792 27.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 250.75 -1" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 393.75 -1" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 653.792 27.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 270.958 48.6756" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 536 76.927" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 320.75 49" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 392.75 49" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 652.792 77.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<path matrix="1 0 0 1 127 14" stroke="blue" arrow="normal/normal"> +180 460 m +340 460 l +</path> +<path matrix="1 0 0 1 127 -13" stroke="red" rarrow="normal/normal"> +180 460 m +340 460 l +</path> +<text matrix="1 0 0 1 152 4" transformations="translations" pos="200 480" stroke="blue" type="minipage" width="128" height="10.128" depth="0" valign="top" size="small">\begin{tiny}1ms TICK\end{tiny}</text> +<path matrix="1 0 0 1 75 -1" stroke="red" arrow="normal/normal"> +392.067 448.35 m +232.502 360 l +</path> +<text matrix="1 0 0 1 87 -9" transformations="translations" pos="230 460" stroke="red" type="label" width="144.917" height="8.3136" depth="3.576" valign="baseline" size="small">\begin{tiny}$\mathrm{DCI}_0$, Transport Blocks\end{tiny} +</text> +<text matrix="0.883494 0.468443 -0.468443 0.883494 345.823 -153.876" pos="230 460" stroke="red" type="label" width="46.6752" height="8.1384" depth="3.576" valign="baseline" size="small">\begin{tiny}$\mathrm{DCI}_1$\end{tiny} +</text> +<text matrix="0.660422 0.750895 -0.750895 0.660422 585.762 -107.641" pos="230 460" stroke="red" type="label" width="46.6752" height="8.1384" depth="3.576" valign="baseline" size="small">\begin{tiny}$\mathrm{DCI}_2$\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 515.792 27.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 585.792 77.2514" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -547.5 -1" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 200.252 29.0442" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_0$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -547.502 -101" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 200.252 -70.9558" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_1$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -547.502 -203.29" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 200.252 -173.245" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_2$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -547.502 49" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 200.252 79.0442" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_0$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -547.502 -51" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 200.252 -20.9558" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_1$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -547.502 -149" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 200.252 -118.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_2$ +\end{tiny} +</text> +<path matrix="1 0 0 1 75 -1" stroke="blue" arrow="normal/normal"> +234.502 211.006 m +387 210 l +</path> +<path matrix="1 0 0 1 130 -4" stroke="black" cap="1"> +243.386 213.48 m +243.386 213.48 l +</path> +<path matrix="1 0 0 1 75 9" stroke="red" rarrow="normal/normal"> +232.502 250.102 m +387.004 250.371 l +</path> +<path matrix="1 0 0 1 75 -1" stroke="blue" arrow="normal/normal"> +232.502 310 m +387 310 l +</path> +<path matrix="1 0 0 1 75 8" stroke="red" rarrow="normal/normal"> +232.502 346.88 m +387 347 l +</path> +<path matrix="1.06124 0 0 1.05601 109.366 -29.2854" stroke="red" arrow="normal/normal"> +336.917 451.424 m +185.872 274.589 l +</path> +<path matrix="1 0 0 1 75 -1" stroke="blue" arrow="normal/normal"> +232.5 410 m +386.079 409.083 l +</path> +<text matrix="1 0 0 1 132.165 -102.466" transformations="translations" pos="230 460" stroke="red" type="label" width="98.448" height="8.3232" depth="2.304" valign="baseline" size="small">\begin{tiny}Transport Blocks\end{tiny} +</text> +<text matrix="1 0 0 1 131.548 -196.94" transformations="translations" pos="230 460" stroke="red" type="label" width="98.448" height="8.3232" depth="2.304" valign="baseline" size="small">\begin{tiny}Transport Blocks\end{tiny} +</text> +<text matrix="1 0 0 1 117 0" transformations="translations" pos="191.31 225.577" stroke="blue" type="minipage" width="124.891" height="19.9872" depth="8.04" valign="top" size="small">\setstretch{.5}\begin{tiny}CQI/SR/ACK/NAK/PHR\\Transport Blocks\end{tiny}</text> +<text matrix="1 0 0 1 115.548 97.0652" transformations="translations" pos="191.31 225.577" stroke="blue" type="minipage" width="124.891" height="19.9872" depth="8.04" valign="top" size="small">\setstretch{.5}\begin{tiny}CQI/SR/ACK/NAK/PHR\\Transport Blocks\end{tiny}</text> +<text matrix="1 0 0 1 116.852 197.782" transformations="translations" pos="191.31 225.577" stroke="blue" type="minipage" width="124.891" height="19.9872" depth="8.04" valign="top" size="small">\setstretch{.5}\begin{tiny}CQI/SR/ACK/NAK/PHR\\Transport Blocks\end{tiny}</text> +<path matrix="1 0 0 1 123.894 -343.063" stroke="blue" arrow="normal/normal"> +180 460 m +340 460 l +</path> +<path matrix="1 0 0 1 123.894 -370.063" stroke="red" rarrow="normal/normal"> +180 460 m +340 460 l +</path> +<text matrix="1 0 0 1 148.894 -353.063" transformations="translations" pos="200 480" stroke="blue" type="minipage" width="128" height="10.128" depth="0" valign="top" size="small">\begin{tiny}1ms TICK\end{tiny}</text> +<text matrix="1 0 0 1 88.894 -366.063" transformations="translations" pos="230 460" stroke="red" type="label" width="144.917" height="8.3136" depth="3.576" valign="baseline" size="small">\begin{tiny}$\mathrm{DCI}_0$, Transport Blocks\end{tiny} +</text> +<path matrix="1.05698 0 0 1.52948 107.055 -427.707" stroke="blue" arrow="normal/normal"> +184.502 313 m +332 313 l +</path> +<text matrix="1 0 0 1 405.673 -373.496" transformations="translations" pos="48 512" stroke="black" type="label" width="270.245" height="16.1424" depth="5.376" valign="baseline" size="small">\begin{small}MAC/RLC/PDCP Instance 1\end{small}</text> +<path matrix="0.791667 0 0 1 202.166 -54.3244" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 467.208 -26.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 251.958 -54" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 394.958 -54" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 655 -25.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 517 -25.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 202.166 -149.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 467.208 -121.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 251.958 -149" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 394.958 -149" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 655 -120.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 517 -120.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 201.958 -101" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 467 -72.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 251.958 -101" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 394.958 -101" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 655 -72.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 517 -72.7486" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 201.75 -199" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 466.792 -170.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 251.75 -199" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 394.75 -199" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 654.792 -170.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 516.792 -170.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -549.88 -359" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 197.872 -328.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX \\ +$\mathrm{eNB}_0$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -549.882 -309" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 197.872 -278.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX \\ +$\mathrm{eNB}_0$ +\end{tiny} +</text> +<text matrix="1 0 0 1 114 -159" transformations="translations" pos="191.31 225.577" stroke="blue" type="minipage" width="124.891" height="19.9872" depth="8.04" valign="top" size="small">\setstretch{.5}\begin{tiny}CQI/SR/ACK/NAK/PHR\\Transport Blocks\end{tiny}</text> +<path matrix="0.835391 0 0 0.672703 356.345 -392.095" fill="lightblue"> +128 768 m +128 704 l +192 704 l +192 768 l +h +</path> +<text matrix="1.36111 0 0 0.829268 464.007 -278.401" transformations="translations" pos="0 474" stroke="black" type="minipage" width="52" height="17.6496" depth="5.664" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +DL/UL Scheduler +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 196.958 -357" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 462 -328.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 246.958 -357" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 390.958 -357" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 651 -328.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP RX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 267.166 -307.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 532.208 -279.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC TX +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 316.958 -307" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 389.958 -307" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 650 -278.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="42" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PDCP TX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 512 -328.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC RX +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 582 -278.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC TX +\end{tiny} +</text> +<text matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="489.023" height="20.9244" depth="6.972" halign="center" valign="baseline">RU/L1 Instances and Component Carriers</text> +<path matrix="0.972035 0 0 0.364588 -79.4938 -158.809" fill="lightyellow" fillrule="eofill"> +96 784 m +96 496 l +224 496 l +224 784 l +h +</path> +<path matrix="0.956412 0 0 1.08596 -77.7744 -362.832" fill="lightyellow"> +96 784 m +96 496 l +224 496 l +224 784 l +h +</path> +<path matrix="1 0 0 1 -222 -4" stroke="black"> +364 518 m +364 518 l +364 518 l +364 518 l +h +</path> +<path matrix="2.25001 0 0 1.17344 -723.502 -213.245" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 24.252 -119.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_3$ +\end{tiny} +</text> +<path matrix="1 0 0 1 0 -1" stroke="black"> +144 480 m +144 32 l +176 32 l +176 480 l +h +</path> +<path stroke="black" cap="1"> +176 432 m +176 432 l +</path> +<path matrix="1 0 0 1 0 -7" stroke="0 0 1"> +192 464 m +176 464 l +</path> +<path stroke="blue" cap="1"> +190.041 464 m +190.041 464 l +</path> +<path stroke="blue" cap="1"> +190.041 464 m +190.041 464 l +</path> +<path matrix="1 0 0 1 0 -105" stroke="0 0 1"> +192 464 m +176 464 l +</path> +<path matrix="1 0 0 1 0 -203" stroke="0 0 1"> +192 464 m +176 464 l +</path> +<path matrix="1 0 0 1 0 -363" stroke="0 0 1"> +192 464 m +176 464 l +</path> +<path matrix="1 0 0 1 -0.041 -55" stroke="red"> +192 464 m +176 464 l +</path> +<path matrix="1 0 0 1 0.918 -156" stroke="red"> +192 464 m +176 464 l +</path> +<path matrix="1 0 0 1 -0.041848 -260.196" stroke="red"> +192 464 m +176 464 l +</path> +<path matrix="1 0 0 1 -0.083 -414" stroke="red"> +192 464 m +176 464 l +</path> +<path matrix="2.25001 0 0 1.17344 -723.502 -21.245" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 24.252 72.544" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_0$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1.17344 -723.502 -85.245" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 24.252 8.544" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_1$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1.17344 -723.502 -149.245" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 24.252 -55.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_2$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1.17344 -723.502 -277.245" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 24.252 -183.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_4$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1.17344 -723.502 -382.245" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 24.252 -288.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_5$ +\end{tiny} +</text> +<path matrix="2.25001 0 0 1.17344 -723.502 -432.245" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 24.252 -337.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_6$ +\end{tiny} +</text> +<path matrix="1 0 0 1 0 3" stroke="0 0 1"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -13" stroke="1 0 0"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -61" stroke="0 0 1"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -77" stroke="1 0 0"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -125" stroke="0 0 1"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -141" stroke="1 0 0"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -189" stroke="0 0 1"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -205" stroke="1 0 0"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -253" stroke="0 0 1"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -269" stroke="1 0 0"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -359" stroke="0 0 1"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -375" stroke="1 0 0"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -406" stroke="0 0 1"> +144 464 m +129.959 464 l +</path> +<path matrix="1 0 0 1 0 -424" stroke="1 0 0"> +144 464 m +129.959 464 l +</path> +<path stroke="black" fill="violet"> +640 400 m +640 400 l +640 400 l +640 400 l +h +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 -512 70" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="267.199" depth="255.84" valign="top" size="small">\small\begin{itemize} +\item {\em Radio Unit} (RU) is +\begin{itemize} +\item an entity managing a set of {\bf physical} antennas. It can have a {\em local RF unit} or {\em remote RF unit} +\item performs precoding of multiple eNB TX streams and OFDM modulation (TX) and demodulation (RX) (part of 36.211) +\end{itemize} +\item {\em L1 Instance} (indexed by {\tt Mod\_id}, or {\tt enb\_mod\_id}) is a separate set of threads and contexts for the eNB/gNB procedures. There is one MAC/RLC entity associated to all :1 component carriers. +\item {\em L1 Component Carrier} (indexed by {\tt CC\_id}) is +\begin{itemize} +\item a software entity managing the L1 procedures (36.213,36.212,36.211) and can act on +\begin{itemize} +\item sectored antenna component +\item Rel10+ component carrier +\item virtual cell for DAS or Massive-MIMO array +\end{itemize} +\item each L1 instance is managed by one or two threads which operate on a subframe (TX and RX) and can have a {\em local RU} or {\em remote RU} +\item if a remote radio unit the eNB performs the 36.213 specifications only (HARQ, etc.) and connects to the remainder via the IF2 midhaul interface. +\end{itemize} +\end{itemize} </text> +<text matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="489.023" height="20.9244" depth="6.972" halign="center" valign="baseline">RU/L1 Instances and Component Carriers</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="489.023" height="20.9244" depth="6.972" halign="center" valign="baseline">RU/L1 Instances and Component Carriers</text> +<text matrix="1 0 0 1 -512 62" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="252.574" depth="241.176" valign="top" size="small">\small\begin{itemize} +\item RU may have both an {\tt if\_device} for fronthaul and an {\tt rf\_device} for interconnection with a local RF unit +\item if the {\tt rf\_device} is absent, it must have a southbound fronthaul interface (either IF5 or IF4p5) depending on the local processing of the remote RU +\item if the {\tt if\_device} is absent, it must have a southbound RF interface and {\tt rf\_device}. +\item three types of L1 processing are performed by the RU \begin{itemize} +\item subset of common L1 procedures from 36.211 specifications +\item fronthaul compression/decompression +\item framing +\end{itemize} +\item on TX +\begin{itemize} +\item A-law compression for (NGFI\_RAU\_IF4p5, NGFI\_RAU\_IF5) +\item A-law decompression (for NGFI\_RRU\_IF4p5 and NGFI\_RRU\_IF5) +\item OFDM modulation and cyclic prefix insertion (for NGFI\_RRU\_IF4p5,NGFI\_RAU\_IF5,3GPP\_eNodeB\_BBU,3GPP\_eNodeB) +\item Precoding (for NGFI\_RAU\_IF5, NGFI\_RAU\_IF4p5,3GPP\_eNodeB\_BBU,3GPP\_eNodeB) +\end{itemize} +\end{itemize}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="489.023" height="20.9244" depth="6.972" halign="center" valign="baseline">RU/L1 Instances and Component Carriers</text> +<text matrix="1 0 0 1 -512 62" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="183.014" depth="171.456" valign="top" size="small">\small\begin{itemize} +\item on RX +\begin{itemize} +\item A-law compression for (NGFI\_RRU\_IF4p5, NGFI\_RRU\_IF5) +\item A-law decompression (for NGFI\_RAU\_IF4p5 and 3GPP\_eNodeB\_BBU) +\item cyclic prefix removal, frequency-shifting, OFDM demodulation, PRACH DFT (for NGFI\_RRU\_IF4p5, NGFI\_RAU\_IF5, 3GPP\_eNodeB\_BBU, 3GPP\_eNodeB) +\end{itemize} +\item On TX path +\begin{itemize} +\item L1 instances/component carriers operate on a set of logical antenna ports (0-3 for TM1-6, 4 for eMBMS, 5 for TM7, 6 for positioning, 7-8 for TM8, etc.) +\item each L1 instance has a list of RUs and the logical antenna ports are mapped to the physical antennas attached to the RUs via the precoding function +\end{itemize} +\end{itemize}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 -512 87" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="165.41" depth="153.792" valign="top" size="small">\small\begin{itemize} +\item Example configurations +\begin{itemize} +\item {\em itsolated eNB:} one instance and one or several component carriers (multiple-frequencies or antenna sectors). Potentially multiple radio-units (for CoMP). Here there is a common MACRLC instnance driving multiple L1 procedures +\item {\em indoor DAS system (RCC split with L1/L2 RAU) Multiple layer 2 instances each driving one or more component carriers} here the RAU implements multiple L1/L2 instances and precoding function. Usually with IF2/IF1'' xhaul to RCC or potentially also MAC/RLC in RAU with IF1' xhaul to RCC. +\item {\em massive-MIMO array} same as 2nd indoor DAS system (i.e. integrated L1/L2 RAU with array) +\end{itemize} +\end{itemize} </text> +<text matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="489.023" height="20.9244" depth="6.972" halign="center" valign="baseline">RU/L1 Instances and Component Carriers</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 -117 31" stroke="black" fill="lightyellow"> +288 384 m +288 96 l +672 96 l +672 384 l +h +</path> +<path matrix="1 0 0 1 -117 119" fill="lightblue"> +301.83 142.941 m +301.83 103.286 l +648 104 l +648 144 l +h +</path> +<path matrix="1.19584 0 0 1.2081 -102.418 -199.483" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -372.028 -59.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 198.792 -187.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1 0 0 1 -117 31" fill="lightblue"> +301.83 142.941 m +301.83 103.286 l +648 104 l +648 144 l +h +</path> +<text matrix="1.12743 0 0 0.829268 277.792 -244.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="162" height="11.4576" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF4p5 / ethernet} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 299 -81.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="48" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY TX (212,213) +\end{tiny} +</text> +<path matrix="1.84415 0 0 0.573526 -364.777 112.325" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 260.792 -43.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.23792 0 0 0.982021 -258.579 37.7599" fill="lightblue"> +389.83 375.941 m +389.83 336.286 l +616 336 l +616 376 l +h +</path> +<text matrix="0.769443 0 0 0.141445 327.792 331.279" transformations="translations" pos="0 474" stroke="black" type="minipage" width="74" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NFGI\_IF1pp / ethernet} +\end{tiny} +</text> +<path matrix="1.88415 0 0 0.573526 -235.977 112.325" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 402.792 -43.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="0.769443 0 0 0.141445 300.792 187.279" transformations="translations" pos="0 474" stroke="black" type="minipage" width="122" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +TX PRECODING\\RX COMBINING +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -284.028 -59.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 286.792 -187.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -196.028 -59.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 374.792 -187.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -108.028 -59.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 462.792 -187.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<text matrix="1 0 0 1 -512 63" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="45.4008" depth="33.504" valign="top" size="small">\small\begin{itemize} +\item Example: RAU with {\tt NGFI\_IF1pp} xhaul (MAC/PHY split) northbound, {\tt NGFI\_IF4p5} fronthaul southbound, 2 vCell logical interfaces (2 L1/L2 instances, or 1 L2 instance and 2 CCs), 4 RRUs with {\tt NGFI\_IF4p5} + +\end{itemize} </text> +<path matrix="1.19584 0 0 1.2081 -166.418 -199.483" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 235 -81.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="48" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY RX (212,213) +\end{tiny} +</text> +<path matrix="1.19584 0 0 1.2081 -22.418 -199.483" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 379 -81.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="48" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY RX (212,213) +\end{tiny} +</text> +<path matrix="1.19584 0 0 1.2081 41.582 -199.483" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 443 -81.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="48" height="24.4656" depth="12.528" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +upper-PHY TX (212,213) +\end{tiny} +</text> +<path matrix="0.734203 0 0 0.68606 60.2968 67.2928" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<path matrix="0.734203 0 0 0.68606 147.297 67.2928" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<path matrix="0.734203 0 0 0.68606 235.297 67.2928" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<path matrix="0.734203 0 0 0.68606 323.297 67.2928" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 197.792 -224.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_0$ +\end{tiny} +</text> +<text matrix="1.12743 0 0 0.829268 283.792 -224.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_1$ +\end{tiny} +</text> +<text matrix="1.12743 0 0 0.829268 373.792 -224.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_2$ +\end{tiny} +</text> +<text matrix="1.12743 0 0 0.829268 460.792 -223.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_3$ +\end{tiny} +</text> +<path matrix="1.16776 0 0 0.634205 24.369 185.93" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 241.792 -63.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{eNB}_0$ +\end{tiny} +</text> +<path matrix="1.16776 0 0 0.634205 166.576 185.93" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 383.999 -63.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{eNB}_1$ +\end{tiny} +</text> +<text matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="247.341" height="20.9244" depth="6.972" halign="center" valign="baseline">RAU Example (DAS)</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" stroke="black" fill="lightyellow"> +168 416 m +168 32 l +576 32 l +576 416 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -375.028 -139.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -380.028 -144.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 -28.042 -200.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 -76.042 -200.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 189 -172.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX0 +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -384.028 -149.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 186.792 -277.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1 0 0 1 0 -82" fill="lightblue"> +176 176 m +176 136 l +552 136 l +552 176 l +h +</path> +<text matrix="1.12743 0 0 0.829268 277.792 -317.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="162" height="11.4576" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NGFI\_IF4p5 / ethernet} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 237 -173.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX0 +\end{tiny}</text> +<path fill="lightblue"> +184 360 m +184 336 l +552 336 l +552 360 l +h +</path> +<text matrix="1.12743 0 0 0.829268 329.792 -42.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path fill="lightblue"> +184 408 m +184 368 l +552 368 l +552 408 l +h +</path> +<text matrix="0.769443 0 0 0.141445 295.792 324.279" transformations="translations" pos="0 474" stroke="black" type="minipage" width="130" height="11.4576" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt NGFI\_IF1p / ethernet} +\end{tiny} +</text> +<path matrix="1 0 0 1 0 -82" fill="lightblue"> +184 264 m +184 224 l +552 224 l +552 264 l +h +</path> +<text matrix="0.769443 0 0 0.141445 300.792 105.279" transformations="translations" pos="0 474" stroke="black" type="minipage" width="122" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +TX PRECODING\\RX COMBINING +\end{tiny} +</text> +<text matrix="1 0 0 1 -512 63" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="42.1128" depth="30.216" valign="top" size="small">\small\begin{itemize} +\item Example: massive-MIMO RAU with {\tt NGFI\_IF1p} fronthaul northbound, 8 L1 component carriers,1 L2 instances, many local RRUs with {\tt NGFI\_IF4p5} southbound + +\end{itemize} </text> +<path matrix="1.68745 0 0 0.638421 -279.028 -139.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -284.028 -144.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -288.028 -149.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 282.792 -277.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -183.028 -139.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -188.028 -144.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -192.028 -149.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 378.792 -277.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="1.68745 0 0 0.638421 -87.028 -139.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -92.028 -144.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.68745 0 0 0.638421 -96.028 -149.58" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="1.12743 0 0 0.829268 474.792 -277.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="9.6312" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +{\tt if\_device} +\end{tiny} +</text> +<path matrix="0.791667 0 0 1 67.958 -200.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 19.958 -200.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 285 -172.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX1 +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 333 -173.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX1 +\end{tiny}</text> +<path matrix="0.791667 0 0 1 251.958 -200.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.791667 0 0 1 203.958 -200.324" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 469 -172.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX7 +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 517 -173.073" transformations="translations" pos="0 474" stroke="black" type="minipage" width="32" height="17.2968" depth="5.352" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX7 +\end{tiny}</text> +<path fill="lightblue"> +184 320 m +184 288 l +552 288 l +552 320 l +h +</path> +<text matrix="1.12743 0 0 0.829268 329.792 -84.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +RLC +\end{tiny} +</text> +<path fill="lightblue"> +184 280 m +184 248 l +552 248 l +552 280 l +h +</path> +<text matrix="1.12743 0 0 0.829268 331.792 -123.749" transformations="translations" pos="0 474" stroke="black" type="minipage" width="58" height="10.128" depth="0" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +MAC +\end{tiny} +</text> +<path matrix="1 0 0 1 6 0" stroke="black" dash="dashed"> +376 208 m +448 208 l +</path> +<path matrix="0.993512 0 0 0.664471 1.76482 65.9478" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 188.792 -228.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{eNB}_0$ +\end{tiny} +</text> +<path matrix="0.993512 0 0 0.664471 97.7648 65.9478" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 284.792 -205.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{eNB}_1$ +\end{tiny} +</text> +<path matrix="0.993512 0 0 0.664471 281.765 65.9478" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 468.792 -228.749" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{eNB}_7$ +\end{tiny} +</text> +<path matrix="0.917752 0 0 0.481451 6.3714 0.0229267" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 177.792 -296.724" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="14.9568" depth="2.976" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_{0\cdots 15}$ +\end{tiny} +</text> +<path matrix="0.917752 0 0 0.481451 102.371 0.0229267" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 273.792 -296.724" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="14.9568" depth="2.976" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_{16\cdots 31}$ +\end{tiny} +</text> +<path matrix="0.917752 0 0 0.481451 198.371 0.0229267" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 369.792 -296.724" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="14.9568" depth="2.976" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_{32\cdots 47}$ +\end{tiny} +</text> +<path matrix="0.917752 0 0 0.481451 294.371 0.0229267" stroke="red" dash="dashed"> +184.83 261.941 m +184.83 128 l +272 128 l +272 261.941 l +h +</path> +<text matrix="1.12743 0 0 0.829268 465.792 -296.724" transformations="translations" pos="0 474" stroke="red" type="minipage" width="58" height="14.9568" depth="2.976" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_{48\cdots 63}$ +\end{tiny} +</text> +<text matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="371.398" height="20.9244" depth="6.972" halign="center" valign="baseline">RAU Example (Massive-MIMO)</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="9.32238 0 0 7.538 -3010.38 -2934.28" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1.42158 0 0 1.03726 -243.165 -111.108" stroke="black" fill="violet"> +232 384 m +232 256 l +543.99 256 l +543.99 384 l +h +</path> +<path matrix="0.99836 0 0 1.3492 -9.1566 -33.1014" stroke="black" fill="gold"> +96 136 m +96 48 l +540 48 l +540 136 l +h +</path> +<path matrix="1 0 0 0.95491 6.23114 90.842" fill="lightgray"> +88 192 m +88 80 l +248 80 l +248 192 l +h +</path> +<path matrix="0.967606 0 0 0.857143 10.0338 -17.5714" fill="lightgray"> +88 192 m +88 80 l +248 80 l +248 192 l +h +</path> +<path matrix="0.459459 0 0 1.28571 41.514 -49.285" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 -512 63" transformations="translations" pos="512 464" stroke="black" type="minipage" width="740" height="114.648" depth="102.936" valign="top" size="small">\small\begin{itemize} +\item IF5 transports packets of size equal to a subframe and corresponding to a 1ms chunk of signal in the time-domain. This is done via the functions send\_if5 and recv\_if5, in the layer1 transport procedures ({\tt openair1/PHY/LTE\_TRANSPORT/if5\_tools.c}). A timestamp is given along with the samples, corresponding to the time (in samples) of the first sample of the packet. +\item each block can be compressed with A-law compression, yielding a compression rate of .5. +\end{itemize} </text> +<text matrix="1 0 0 1 169 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="315.42" height="20.9244" depth="6.972" halign="center" valign="baseline">RU Procedures (NGFI\_IF5)</text> +<path matrix="2.25001 0 0 1 -120.88 -377" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 627.252 -346.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_2$ (211,212) +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -120.502 -228" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 627.252 -197.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_2$ (211,212) +\end{tiny} +</text> +<path matrix="0.876018 0 0 0.636058 450.853 -13.2664" stroke="black"> +144 480 m +144 32 l +176 32 l +176 480 l +h +</path> +<text matrix="0.781914 0 0 0.829268 66.928 -374.838" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_0$ +\end{tiny} +</text> +<path matrix="-0.360709 0 0 -1 738.691 287.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="0.360709 0 0 1 486.749 -75.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -120.88 -329" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 627.252 -298.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_1$ (211,212) +\end{tiny} +</text> +<path matrix="0.360709 0 0 1 486.749 -27.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -120.88 -281" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 627.252 -250.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_0$ (211,212) +\end{tiny} +</text> +<path matrix="0.360709 0 0 1 486.749 20.663" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -119.035 -179" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 628.719 -148.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_1$ (211,212) +\end{tiny} +</text> +<path matrix="-0.360709 0 0 -1 740.158 336.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -119.035 -131" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 628.719 -100.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_0$ (211,212) +\end{tiny} +</text> +<path matrix="-0.360709 0 0 -1 740.158 384.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="1 0 0 1 143.432 -152.618" fill="turquoise"> +132 294 m +132 208 l +384 208 l +384 294 l +h +</path> +<path matrix="1 0 0 1 2 -29" stroke="black" arrow="normal/small"> +144.991 145.396 m +289.432 145.382 l +</path> +<path matrix="1 0 0 1 2 -29" stroke="black" arrow="normal/small"> +144.991 120.982 m +289.432 121.382 l +</path> +<text matrix="1 0 0 1 -447.936 88.75" pos="596 32" stroke="black" type="label" width="131.599" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.rxdata[0]}</text> +<text matrix="1 0 0 1 -446.936 64.75" pos="596 32" stroke="black" type="label" width="144.3" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.rxdata[R-1]}</text> +<path matrix="1 0 0 1 188.432 -100.618" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 213.433 -336.618" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny slot\_fep\_ul\par36.211</text> +<path matrix="0.459459 0 0 1.28571 223.135 -158.904" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<path matrix="1 0 0 1 143.432 -152.618" stroke="black" arrow="normal/tiny"> +184 268 m +196 268 l +</path> +<path matrix="1 0 0 1 143.432 -152.618" stroke="black" arrow="normal/tiny"> +184 244 m +196 244 l +</path> +<text matrix="1 0 0 1 -177.839 90.285" pos="596 32" stroke="black" type="label" width="169.706" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt eNB->common\_vars.rxdataF[0]}</text> +<text matrix="1 0 0 1 -176.839 66.285" pos="596 32" stroke="black" type="label" width="182.407" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt eNB->common\_vars.rxdataF[R-1]}</text> +<path matrix="1.14711 0 0 0.643127 105.368 -57.0842" stroke="black" arrow="normal/small"> +273 269 m +412 268 l +</path> +<path matrix="1 0 0 1 2 -29" stroke="black" arrow="normal/small"> +415.263 120.984 m +575 120.608 l +</path> +<path matrix="0.459459 0 0 1.28571 42.234 -159.285" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="0 1 -1 0 166.559 -528.915" pos="596 32" stroke="black" type="label" width="71.16" height="12.8064" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{Alaw}^{-1}()$</text> +<path matrix="1 0 0 1 2 -29" stroke="black" arrow="normal/tiny"> +56 128 m +110.531 128.542 l +</path> +<text matrix="1 0 0 1 -591.936 75.75" pos="596 32" stroke="black" type="label" width="105.653" height="8.3016" depth="0" valign="baseline" size="small">\tiny from IF5 {\tt if\_device}</text> +<path matrix="1 0 0 1 248 -71.02" stroke="black"> +680 104 m +680 104 l +680 104 l +680 104 l +h +</path> +<path matrix="0.632607 0 0 0.581545 154.85 73.761" stroke="black" fill="lightgreen"> +544 324 m +544 144 l +576 144 l +576 324 l +h +</path> +<text matrix="0.923166 0 0 0.436636 -9.1365 120.386" transformations="translations" pos="548 304" stroke="black" type="minipage" width="24" height="48.3768" depth="36.504" valign="top" size="small" style="center">\setstretch{.5}\tt\tiny P\\R\\E\\C\\O\\D\\I\\N\\G\\</text> +<path matrix="-1.00596 0 0 0.723429 1093.07 21.2483" stroke="black" fill="white"> +632 360 m +632 188 l +660 188 l +660 360 l +h +</path> +<text matrix="1 0 0 1 -325.616 204.83" pos="596 32" stroke="black" type="label" width="131.599" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.txdata[0]}</text> +<path matrix="-7.98213 0 0 0.926402 6014.38 -11.5901" stroke="black" arrow="normal/tiny"> +700 264 m +735.133 264 l +</path> +<path matrix="-1 0 0 1 1129.13 -52.02" stroke="black" arrow="normal/tiny"> +632 264.556 m +671.833 265 l +</path> +<text matrix="0 1 -1 0 712.677 -464.953" pos="636 280" stroke="black" type="minipage" width="84" height="16.6824" depth="4.704" valign="top" size="small" style="center">\setstretch{.5}\tt\tiny do\_ofdm\_mod\_rt()\par 36.211</text> +<text matrix="0.781914 0 0 0.829268 337.809 -371.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="200.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt openair1/SCHED/ru-procedures.c} +\end{tiny} +</text> +<path matrix="1 0 0 1 2 11" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<path matrix="1 0 0 1 1.635 2.903" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<path matrix="1 0 0 1 1.635 -5.097" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<path matrix="1 0 0 1 1.635 -69.097" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<text matrix="0 1 -1 0 164.559 -406.915" pos="596 32" stroke="black" type="label" width="48.876" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{Alaw}()$</text> +<text matrix="1 0 0 1 -592.594 184.743" pos="596 32" stroke="black" type="label" width="91.9344" height="8.3016" depth="0" valign="baseline" size="small">\tiny to IF5 {\tt if\_device}</text> +<path matrix="0.179243 0 0 -1.07565 47.9624 469.155" stroke="black" rarrow="normal/tiny"> +56 240 m +356.214 240.281 l +</path> +<path matrix="-8.02443 0 0 0.926402 6046.55 -49.554" stroke="black" arrow="normal/tiny"> +700 264 m +735.133 264 l +</path> +<text matrix="1 0 0 1 -325.616 167.83" pos="596 32" stroke="black" type="label" width="144.3" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.txdata[T-1]}</text> +<text matrix="0.781914 0 0 0.829268 187.809 -330.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="10.6272" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt recv\_IF5()} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 192.04 -214.271" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="10.6272" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt send\_IF5()} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 445.373 -326.074" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_fep\_full()} +\end{tiny} +</text> +<text matrix="1 0 0 1 212 -261" transformations="translations" pos="176 556" stroke="red" type="label" width="203.946" height="19.3704" depth="0" halign="center" valign="baseline">IF5 RU eNB end </text> +<text matrix="0 1 -1 0 344.559 -523.915" pos="596 32" stroke="black" type="label" width="62.2848" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{7.5kHz}()$</text> +<text matrix="0.781914 0 0 0.829268 86.9372 -348.796" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="10.6272" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_thread()} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 90.7769 -227.271" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_thread\_asynch\_rxtx()} +\end{tiny} +</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="9.40249 0 0 8.45522 -3042.82 -3293.1" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="0.99836 0 0 3.12886 -15.8426 -122.662" stroke="black" fill="gold"> +96 136 m +96 48 l +540 48 l +540 136 l +h +</path> +<path matrix="1 0 0 1 153.231 103.185" fill="lightgray"> +88 192 m +88 80 l +248 80 l +248 192 l +h +</path> +<path matrix="0.975001 0 0 1.09355 6.19995 -41.9606" fill="lightgray"> +88 192 m +88 80 l +248 80 l +248 192 l +h +</path> +<path matrix="0.459459 0 0 1.28571 286.514 -28.285" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 -512 55" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="86.8968" depth="75.096" valign="top" size="small">\small\begin{itemize} +\item IF4p5 transports packets of size equal to an OFDM symbol (for DLRE and ULRE) indexed by the symbol, subframe and frame number. This is done via the functions send\_if4p5 and recv\_if4p5, in the layer1 transport procedures ({\tt openair1/PHY/LTE\_TRANSPORT/if4\_tools.c}). +\item each block are compressed with A-law compression, yielding a compression rate of .5. +\end{itemize} </text> +<text matrix="1 0 0 1 169 -9" transformations="translations" pos="176 556" stroke="black" type="label" width="343.781" height="20.9244" depth="6.972" halign="center" valign="baseline">RU Procedures (NGFI\_IF4p5)</text> +<path matrix="2.25001 0 0 1 -122.88 -356" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 625.252 -325.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_2$ (211,212) +\end{tiny} +</text> +<path matrix="2.25001 0 0 1 -122.502 -207" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 625.252 -176.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_2$ (211,212) +\end{tiny} +</text> +<path matrix="0.876018 0 0 0.636058 448.853 7.7336" stroke="black"> +144 480 m +144 32 l +176 32 l +176 480 l +h +</path> +<text matrix="0.781914 0 0 0.829268 64.928 -375.838" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_0$ +\end{tiny} +</text> +<path matrix="-0.360709 0 0 -1 736.691 308.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="0.360709 0 0 1 484.749 -54.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -122.88 -308" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 625.252 -277.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_1$ (211,212) +\end{tiny} +</text> +<path matrix="0.360709 0 0 1 484.749 -6.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -122.88 -260" fill="lightgreen"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 625.252 -229.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY RX $n$\\ +$\mathrm{eNB}_0$ (211,212) +\end{tiny} +</text> +<path matrix="0.360709 0 0 1 484.749 41.663" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -121.035 -158" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 626.719 -127.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_1$ (211,212) +\end{tiny} +</text> +<path matrix="-0.360709 0 0 -1 738.158 357.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path matrix="2.25001 0 0 1 -121.035 -110" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 626.719 -79.956" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="19.1064" depth="7.128" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +PHY TX $n+4$\\ +$\mathrm{eNB}_0$ (211,212) +\end{tiny} +</text> +<path matrix="-0.360709 0 0 -1 738.158 405.337" stroke="red" rarrow="normal/small"> +371.001 106.337 m +323.502 106.337 l +323.502 106.337 l +</path> +<path stroke="black" arrow="normal/small"> +175.991 137.396 m +575 138.93 l +</path> +<path stroke="black" arrow="normal/small"> +175.991 112.982 m +575 114.329 l +</path> +<path matrix="0.459459 0 0 1.28571 71.234 -138.285" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="0 1 -1 0 195.559 -507.915" pos="596 32" stroke="black" type="label" width="71.16" height="12.8064" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{Alaw}^{-1}()$</text> +<path stroke="black" arrow="normal/tiny"> +56 120 m +141.531 120.07 l +</path> +<text matrix="1 0 0 1 -593.936 96.75" pos="596 32" stroke="black" type="label" width="118.562" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny from IF4p5 {\tt if\_device}</text> +<path matrix="1 0 0 1 248 -79.02" stroke="black"> +680 104 m +680 104 l +680 104 l +680 104 l +h +</path> +<path matrix="0.632607 0 0 0.581545 152.85 94.761" stroke="black" fill="lightgreen"> +544 324 m +544 144 l +576 144 l +576 324 l +h +</path> +<text matrix="0.923166 0 0 0.436636 -11.1365 141.386" transformations="translations" pos="548 304" stroke="black" type="minipage" width="24" height="48.3768" depth="36.504" valign="top" size="small" style="center">\setstretch{.5}\tt\tiny P\\R\\E\\C\\O\\D\\I\\N\\G\\</text> +<path matrix="-2.98839 0 0 1.00696 2588.86 -11.5723" stroke="black" arrow="normal/tiny"> +700 264 m +735.133 264 l +</path> +<text matrix="0.781914 0 0 0.829268 335.809 -372.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="208.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt openair1/SCHED/ru-procedures.c} +\end{tiny} +</text> +<path matrix="1 0 0 1 0 32" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<path matrix="1 0 0 1 -0.365 23.903" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<path matrix="1 0 0 1 -0.365 15.903" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<path matrix="1 0 0 1 -0.365 -48.097" stroke="red" rarrow="normal/small"> +517.232 240.387 m +576.078 240 l +576.078 240 l +</path> +<text matrix="0 1 -1 0 409.559 -385.915" pos="596 32" stroke="black" type="label" width="48.876" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{Alaw}()$</text> +<text matrix="1 0 0 1 -594.594 205.743" pos="596 32" stroke="black" type="label" width="104.844" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny to IF4p5 {\tt if\_device}</text> +<path matrix="1 0 0 1 0 -8" stroke="black" rarrow="normal/tiny"> +56 240 m +356.214 240.281 l +</path> +<path matrix="-2.98839 0 0 1.00696 2589.82 -52.8376" stroke="black" arrow="normal/tiny"> +700 264 m +735.133 264 l +</path> +<text matrix="0.786462 0 0 0.829268 173.831 -335.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt recv\_IF4p5()} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 326.04 -198.271" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt send\_IF4p5()} +\end{tiny} +</text> +<text matrix="1 0 0 1 56 -237" transformations="translations" pos="176 556" stroke="red" type="label" width="232.308" height="19.3928" depth="5.404" halign="center" valign="baseline">IF4p5 RU eNB end </text> +<path matrix="0.459459 0 0 0.399205 71.703 -11.0389" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<path stroke="black" arrow="normal/tiny"> +111.191 120.045 m +112 70 l +142 69.9344 l +</path> +<path stroke="black" cap="1"> +-36 68 m +-36 68 l +</path> +<path matrix="1 0 0 1 -0.527 -43.483" stroke="black" arrow="normal/small"> +175.991 112.982 m +575 114.329 l +</path> +<text matrix="1 0 0 1 -343.839 111.285" pos="596 32" stroke="black" type="label" width="169.706" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt eNB->common\_vars.rxdataF[0]}</text> +<text matrix="1 0 0 1 -343.839 87.285" pos="596 32" stroke="black" type="label" width="182.407" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt eNB->common\_vars.rxdataF[R-1]}</text> +<text matrix="1 0 0 1 -343.839 43.285" pos="596 32" stroke="black" type="label" width="207.648" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt eNB->prach\_vars.prachF[0$\cdots$ R-1]}</text> +<text matrix="0.781914 0 0 0.829268 81.3732 -352.933" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="10.6272" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_thread()} +\end{tiny} +</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="12.8399 0 0 9.34249 -4172.16 -3617.58" fill="lightcyan"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<path matrix="1 0 0 1.01102 0 0.424041" stroke="black" fill="violet"> +232 384 m +232 256 l +543.99 256 l +543.99 384 l +h +</path> +<path matrix="1 0 0 1.04447 0 -2.13433" stroke="black" fill="gold"> +96 136 m +96 48 l +540 48 l +540 136 l +h +</path> +<path matrix="1.1248 0 0 1 74.4712 -158" fill="turquoise"> +132 294 m +132 208 l +384 208 l +384 294 l +h +</path> +<path fill="lightyellow"> +96 384 m +96 148 l +544 148 l +544 256 l +224 256 l +224 384 l +h +</path> +<path matrix="1 0 0 1.17279 1 166.419" fill="lightgray"> +444 164 m +444 84.382 l +522.222 84.382 l +522.222 164 l +h +</path> +<path matrix="1 0 0 1 143.432 -48.618" fill="turquoise"> +132 294 m +132 208 l +384 208 l +384 294 l +h +</path> +<path matrix="1 0 0 1 2 77" fill="lightgray"> +444 164 m +444 84.382 l +522.222 84.382 l +522.222 164 l +h +</path> +<path matrix="0.459459 0 0 1.28571 379.514 54.715" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 161 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="343.781" height="20.9244" depth="6.972" halign="center" valign="baseline">RU Procedures (NGFI\_IF4p5)</text> +<text matrix="0.781914 0 0 0.829268 67.928 -354.838" transformations="translations" pos="0 474" stroke="black" type="minipage" width="102" height="11.8344" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +$\mathrm{RU}_0$ +\end{tiny} +</text> +<path matrix="1 0 0 1 2 75" stroke="black" arrow="normal/tiny"> +144.991 145.396 m +289.432 145.382 l +</path> +<path matrix="1 0 0 1 2 75" stroke="black" arrow="normal/tiny"> +144.991 120.982 m +289.432 121.382 l +</path> +<text matrix="1 0 0 1 -447.936 192.75" pos="596 32" stroke="black" type="label" width="131.599" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.rxdata[0]}</text> +<text matrix="1 0 0 1 -446.936 168.75" pos="596 32" stroke="black" type="label" width="144.3" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.rxdata[R-1]}</text> +<path matrix="1 0 0 1 188.432 3.382" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 213.433 -232.618" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny slot\_fep\_ul\par36.211</text> +<path matrix="0.459459 0 0 1.28571 223.135 -54.904" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<path matrix="1 0 0 1 143.432 -48.618" stroke="black" arrow="normal/tiny"> +184 268 m +196 268 l +</path> +<path matrix="1 0 0 1 143.432 -48.618" stroke="black" arrow="normal/tiny"> +184 244 m +196 244 l +</path> +<path matrix="0.248499 0 0 0.662073 349.697 42.5354" stroke="black" arrow="normal/small"> +273 269 m +412 268 l +</path> +<path matrix="0.21663 0 0 1.02946 327.304 71.447" stroke="black" arrow="normal/small"> +415.263 120.984 m +575 120.608 l +</path> +<path matrix="1 0 0 1 2 75" stroke="black" arrow="normal/tiny"> +56 128 m +110.531 128.542 l +</path> +<text matrix="1 0 0 1 -591.936 179.75" pos="596 32" stroke="black" type="label" width="84.276" height="8.3016" depth="0" valign="baseline" size="small">\tiny from {\tt rf\_device}</text> +<path matrix="1 0 0 1 240 -71.02" stroke="black"> +680 104 m +680 104 l +680 104 l +680 104 l +h +</path> +<path matrix="-1.00596 0 0 0.723429 1044.07 125.248" stroke="black" fill="white"> +632 360 m +632 188 l +660 188 l +660 360 l +h +</path> +<text matrix="1 0 0 1 -352.616 267.83" pos="596 32" stroke="black" type="label" width="131.599" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.txdata[0]}</text> +<path stroke="black" arrow="normal/tiny"> +380.13 336.98 m +149.46 336.349 l +</path> +<path matrix="-1 0 0 1 1080.13 51.98" stroke="black" arrow="normal/tiny"> +632 264.556 m +671.833 265 l +</path> +<text matrix="0 1 -1 0 663.677 -360.953" pos="636 280" stroke="black" type="minipage" width="84" height="16.6824" depth="4.704" valign="top" size="small" style="center">\setstretch{.5}\tt\tiny do\_ofdm\_mod\_rt()\par 36.211</text> +<text matrix="0.781914 0 0 0.829268 510.809 -351.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="200.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt openair1/SCHED/ru-procedures.c} +\end{tiny} +</text> +<text matrix="1 0 0 1 -592.594 288.743" pos="596 32" stroke="black" type="label" width="70.5552" height="7.3056" depth="0" valign="baseline" size="small">\tiny to {\tt rf\_device}</text> +<path matrix="1 0 0 1 0 75" stroke="black" rarrow="normal/tiny"> +58 240 m +114.121 240.053 l +</path> +<path stroke="black" arrow="normal/tiny"> +380.45 296 m +149.46 295.058 l +</path> +<text matrix="1 0 0 1 -362.967 310.18" pos="596 32" stroke="black" type="label" width="144.3" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt RU->ru\_time.txdata[T-1]}</text> +<text matrix="0.781914 0 0 0.829268 278.373 -223.074" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_fep\_full()} +\end{tiny} +</text> +<text matrix="1 0 0 1 -5 -65" transformations="translations" pos="176 556" stroke="red" type="label" width="262.063" height="19.3928" depth="5.404" halign="center" valign="baseline">IF4p5 RU remote-end </text> +<path matrix="0.459459 0 0 1.28571 44.014 -55.285" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="0 1 -1 0 502.559 -313.915" pos="596 32" stroke="black" type="label" width="71.16" height="12.8064" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{Alaw}^{-1}()$</text> +<path matrix="0.45771 0 0 1.1354 381.353 -25.8312" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="0 1 -1 0 504.559 -414.915" pos="596 32" stroke="black" type="label" width="48.876" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{Alaw}()$</text> +<text matrix="0 1 -1 0 345.559 -418.915" pos="596 32" stroke="black" type="label" width="62.2848" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny $\mathrm{7.5kHz}()$</text> +<path matrix="0.459459 0 0 1.28571 44.703 54.165" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="0.781914 0 0 0.829268 449.809 -118.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt recv\_IF4p5()} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 450.012 -220.947" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt send\_IF4p5()} +\end{tiny} +</text> +<path matrix="1 0 0 1 0 75" stroke="black" arrow="normal/tiny"> +485.71 128.939 m +581.963 129.331 l +</path> +<text matrix="1 0 0 1 -46.936 178.75" pos="596 32" stroke="black" type="label" width="70.5552" height="7.3056" depth="0" valign="baseline" size="small">\tiny to {\tt if\_device}</text> +<text matrix="1 0 0 1 -46.372 286.887" pos="596 32" stroke="black" type="label" width="84.276" height="8.3016" depth="0" valign="baseline" size="small">\tiny from {\tt if\_device}</text> +<path matrix="1 0 0 1 465.222 73.1439" stroke="black" rarrow="normal/tiny"> +58 240 m +114.121 240.053 l +</path> +<path matrix="1 0 0 1 105.674 -234" stroke="black" fill="1"> +131 344 m +131 316 l +276 316 l +276 344 l +h +</path> +<text matrix="1 0 0 1 123.675 -345" transformations="translations" pos="128 440" stroke="black" type="minipage" width="126.578" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ru\_prach\_procedures\par36.211</text> +<path matrix="1 0 0 1 -58.326 -234" stroke="black" arrow="normal/tiny"> +440.514 328 m +477 327.572 l +</path> +<text matrix="0.762991 0 0 1 1.41573 -218" transformations="translations" pos="300 280" stroke="black" type="minipage" width="268" height="11.4576" depth="0" valign="top" size="small">\tt\tiny ru\_prach\_procedures()</text> +<path matrix="1 0 0 1 267.865 -110" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 292.866 -346" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny rx\_prachl\par36.211</text> +<path stroke="black" arrow="normal/tiny"> +199.412 220.391 m +200 104 l +236.674 103.978 l +</path> +<path stroke="black" arrow="normal/tiny"> +178.262 196.069 m +179.06 92 l +236.674 91.6468 l +</path> +<path stroke="black" fill="gold"> +65.0054 121.159 m +65.0054 121.159 l +65.0054 121.159 l +65.0054 121.159 l +h +</path> +<text matrix="0.781914 0 0 0.829268 98.1012 -330.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_thread\_prach()} +\end{tiny} +</text> +<text matrix="0.781914 0 0 0.829268 99.672 -232.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="10.6272" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_thread()} +\end{tiny} +</text> +<path stroke="black" fill="violet"> +65.0054 357.66 m +65.0054 357.66 l +65.0054 357.66 l +65.0054 357.66 l +h +</path> +<text matrix="0.781914 0 0 0.829268 234.605 -119.456" transformations="translations" pos="0 474" stroke="black" type="minipage" width="168.119" height="11.4576" depth="0" valign="top" size="small">\setstretch{.5}\begin{tiny} +{\tt ru\_thread\_asynch\_rxtx()} +\end{tiny} +</text> +<text matrix="1 0 0 1 -39.936 67.75" pos="596 32" stroke="black" type="label" width="70.5552" height="7.3056" depth="0" valign="baseline" size="small">\tiny to {\tt if\_device}</text> +<path matrix="1 0 0 1 9.642 -35.284" stroke="black" arrow="normal/tiny"> +485.71 128.939 m +581.963 129.331 l +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 9.83755 0" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="1 0 0 1 161 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="231.997" height="19.3928" depth="5.404" halign="center" valign="baseline">OAI IF1pp Interface</text> +<text matrix="1 0 0 1 -512 55" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="30.296" depth="16.352" valign="top">\tiny\begin{itemize} +\item OAI IF1pp is the interface between the 36.213 Physical Layer Procedures (HARQ, SR, CSI, etc.) and the transport/physical channel processing +\item it can be networked, although this is not used as an xhaul interface at the moment. +\end{itemize} </text> +<path matrix="1 0 0 1 32 60" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<path matrix="1 0 0 1 32 60" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<path matrix="1 0 0 1 288 60" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<text matrix="1 0 0 1 -399.345 376.743" pos="596 32" stroke="black" type="label" width="151.668" height="7.3224" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_procedures\_lte\_eNB\_TX}</text> +<text matrix="1 0 0 1 -140.021 376.743" pos="596 32" stroke="black" type="label" width="151.668" height="7.3224" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_procedures\_lte\_eNB\_RX}</text> +<path matrix="1 0 0 1 33 -256" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<text matrix="1 0 0 1 -414.345 60.743" pos="596 32" stroke="black" type="label" width="439.776" height="14.952" depth="4.176" valign="baseline" size="small">\small PHY transport and physical channel procedures</text> +<text matrix="0 1 -1 0 208.848 -455.114" pos="596 32" stroke="black" type="label" width="161.575" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt common\_signal\_procedures()}</text> +<text matrix="0 1 -1 0 232.621 -455.114" pos="596 32" stroke="black" type="label" width="106.193" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt pmch\_procedures()}</text> +<text matrix="0 1 -1 0 256.394 -455.114" pos="596 32" stroke="black" type="label" width="221.532" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt generate\_dlsch\_parameters\_from\_dci()}</text> +<text matrix="0 1 -1 0 280.167 -455.114" pos="596 32" stroke="black" type="label" width="221.532" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt generate\_ulsch\_parameters\_from\_dci()}</text> +<text matrix="0 1 -1 0 303.94 -455.114" pos="596 32" stroke="black" type="label" width="172.5" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_config\_dedicated\_step2()}</text> +<text matrix="0 1 -1 0 327.713 -455.114" pos="596 32" stroke="black" type="label" width="110.765" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt generate\_dci\_top()}</text> +<text matrix="0 1 -1 0 351.486 -455.114" pos="596 32" stroke="black" type="label" width="123.468" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt generate\_phich\_top()}</text> +<text matrix="0 1 -1 0 375.259 -455.114" pos="596 32" stroke="black" type="label" width="112.543" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt pdsch\_procedures()}</text> +<path matrix="1 0 0 1 33.6108 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 1 57.3839 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 1 81.1569 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 1 104.93 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 1 128.703 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 1 152.476 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 1 176.249 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 1 265.346 -0.419" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 464.848 -455.114" pos="596 32" stroke="black" type="label" width="112.543" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt pucch\_procedures()}</text> +<text matrix="0 1 -1 0 487.637 -455.114" pos="596 32" stroke="black" type="label" width="87.1392" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt process\_Msg3()}</text> +<path matrix="1 0 0 1 288.134 0.491" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 511.251 -455.114" pos="596 32" stroke="black" type="label" width="61.7352" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt rx\_ulsch()}</text> +<path matrix="1 0 0 1 310.923 0.509" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 533.214 -455.114" pos="596 32" stroke="black" type="label" width="99.8424" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt ulsch\_decoding()}</text> +<path matrix="1 0 0 1 333.711 0.608" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 556.002 -455.114" pos="596 32" stroke="black" type="label" width="80.7888" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt extract\_cqi()}</text> +<path matrix="1 0 0 1 356.5 0.411" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 578.791 -455.114" pos="596 32" stroke="black" type="label" width="121.69" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt get\_Msg3\_alloc\_ret()}</text> +<path matrix="1 0 0 1 379.288 0.924" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 601.579 -455.114" pos="596 32" stroke="black" type="label" width="183.425" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt lte\_est\_timing\_advance\_pusch()}</text> +<path matrix="1 0 0 1 402.077 1.339" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 625.193 -455.114" pos="596 32" stroke="black" type="label" width="153.446" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt lte\_eNB\_I0\_measurements()}</text> +<path matrix="1 0 0 1 424.865 1.187" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 647.156 -455.114" pos="596 32" stroke="black" type="label" width="117.118" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt process\_HARQ\_info()}</text> +<path matrix="1 0 0 1 447.654 1.187" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="1 0 0 1 16 -48" transformations="translations" pos="0 448" stroke="black" type="minipage" width="128" height="28.0824" depth="16.152" valign="top" size="small">\small {\tt 36.213}\par +{\tt openair1/SCHED}</text> +<text matrix="1 0 0 1 1 -368" transformations="translations" pos="0 448" stroke="black" type="minipage" width="128" height="28.9872" depth="17.04" valign="top" size="small">\small {\tt 36.211/212}\par +{\tt openair1/PHY}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 0 -1" fill="lightgray"> +120 528 m +120 0 l +592 0 l +592 528 l +h +</path> +<path fill="turquoise"> +180 524 m +180 476 l +588 476 l +588 524 l +h +</path> +<path matrix="1 0 0 1 0 5" stroke="black" fill="white"> +248 520 m +248 483.903 l +400 484 l +400 520 l +h +</path> +<path matrix="1 0 0 1 0 -19" fill="lightcyan"> +180 493.216 m +180 452 l +536 452 l +536 493.216 l +h +</path> +<path matrix="1 0 0 1 0 -19" stroke="black"> +404 480 m +404 472 l +404 472 l +404 480 l +h +</path> +<path matrix="1 0 0 1 0 -19" fill="white"> +340 488 m +340 464 l +444 464 l +444 488 l +h +</path> +<path matrix="1 0 0 1 20.9996 13.2948" stroke="black" fill="1"> +312 456 m +312 432 l +424 432 l +424.001 456 l +h +</path> +<path matrix="1 0 0 1 1 -19" fill="lightgreen"> +144 448 m +144 360 l +536 360 l +536 448 l +h +</path> +<path matrix="1 0 0 1 1 -15" fill="lightblue"> +144 260 m +144 116 l +536 116 l +536 260 l +h +</path> +<path matrix="1 0 0 1 1 -16" fill="lightblue"> +144 344 m +144 264 l +536 264 l +536 344 l +h +</path> +<path matrix="1.16667 0 0 1 7.66667 -19" stroke="black" fill="white"> +128 440 m +128 384 l +224 384 l +224 440 l +h +</path> +<text matrix="1 0 0 1 30 -41.7052" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="14.484" depth="2.52" valign="center" size="small">\tt\tiny generate\_dci\_top()</text> +<text matrix="1 0 0 1 -15 -15" transformations="translations" pos="240 144" stroke="black" type="minipage" width="8" height="5.9784" depth="0" valign="top" size="small"></text> +<path fill="gold" tiling="rising"> +0 424 m +0 32 l +48 32 l +48 424 l +h +</path> +<text matrix="1 0 0 1 -17 -127" transformations="translations" pos="32 416" stroke="black" type="minipage" width="32" height="50.1172" depth="36.204" valign="top" style="center">M\\ +A\\ +C</text> +<path matrix="1 0 0 1 -16 -21" stroke="black" arrow="normal/small"> +64 416 m +172 416 l +</path> +<text matrix="1 0 0 1 -16 -21" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="15.3664" depth="1.372" valign="top">\tt\tiny DCI\_PDU</text> +<path matrix="1.16667 0 0 1 7.6667 -120" stroke="black" fill="1"> +128 440 m +128 384 l +224 384 l +224 440 l +h +</path> +<text matrix="1 0 0 1 37.0006 -148" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_coding()\par36.212</text> +<path matrix="1 0 0 1 -16 -123" stroke="black" arrow="normal/small"> +64 416 m +172 416 l +</path> +<text matrix="1 0 0 1 -16 -123" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="15.3664" depth="1.372" valign="top">\tt\tiny DLSCH\_PDU\_0</text> +<path matrix="1.16667 0 0 1 7.6667 -199" stroke="black" fill="1"> +128 440 m +128 384 l +224 384 l +224 440 l +h +</path> +<path matrix="1 0 0 1 -16 -203" stroke="black" arrow="normal/small"> +64 416 m +172 416 l +</path> +<text matrix="1 0 0 1 -16 -203" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="15.3664" depth="1.372" valign="top">\tt\tiny DLSCH\_PDU\_1\_0</text> +<path matrix="1.16667 0 0 1 7.6667 -263" stroke="black" fill="1"> +128 440 m +128 384 l +224 384 l +224 440 l +h +</path> +<path matrix="1 0 0 1 -16 -266" stroke="black" arrow="normal/small"> +64 416 m +172 416 l +</path> +<text matrix="1 0 0 1 -16 -266" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="15.3664" depth="1.372" valign="top">\tt\tiny DLSCH\_PDU\_1\_1</text> +<path matrix="1 0 0 1 -18.0004 -34.7052" stroke="black" fill="1"> +312 456 m +312 432 l +424 432 l +424.001 456 l +h +</path> +<text matrix="1 0 0 1 166 -30.7052" transformations="translations" pos="128 440" stroke="black" type="minipage" width="112" height="17.1312" depth="5.184" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny generate\_pcfich()\par36.212,36.211</text> +<path matrix="1 0 0 1 -9 -19" stroke="black" fill="1"> +304 408 m +304 384 l +400 384 l +400 408 l +h +</path> +<text matrix="1 0 0 1 167 -63.2264" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny generate\_dci0()\par36.212</text> +<path matrix="1 0 0 1 1 2.77362" stroke="black" fill="1"> +408 400 m +408 352 l +520 352 l +520 400 l +h +</path> +<text matrix="1 0 0 1 281 -61.2264" transformations="translations" pos="128 440" stroke="black" type="minipage" width="112" height="29.8512" depth="17.904" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny pdcch\_scrambling()\par pdcch\_modulation\par pdcch\_interleaving\par36.211</text> +<text matrix="1 0 0 1 37.0006 -227" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_coding()\par36.212</text> +<text matrix="1 0 0 1 37.0006 -291" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_coding()\par36.212</text> +<path matrix="1 0 0 1 1 -19" stroke="black" fill="white" arrow="normal/tiny"> +268 426.729 m +293 426.729 l +</path> +<path matrix="1 0 0 1 1 -21.3964" stroke="black" fill="white" arrow="normal/tiny"> +268 399.17 m +293 399.17 l +</path> +<path matrix="1 0 0 1 -14 -18.5991" stroke="black" fill="white" arrow="normal/tiny"> +405 397.373 m +421 397.373 l +</path> +<path matrix="1 0 0 1 1 -17" stroke="black" fill="1"> +294 320 m +294 296 l +392 296 l +392 320 l +h +</path> +<text matrix="1.16993 0 0 1 145.249 -149.226" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="17.5032" depth="5.544" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_encoding()\par36.212</text> +<path matrix="1 0 0 1 1 -107.396" stroke="black" arrow="normal/tiny"> +268 399.17 m +293 399.17 l +</path> +<path matrix="1 0 0 1 1 -14" stroke="black" fill="1"> +408 322.774 m +408 288 l +520 288 l +520 322.774 l +h +</path> +<text matrix="1 0 0 1 281 -147.226" transformations="translations" pos="128 440" stroke="black" type="minipage" width="112" height="23.3352" depth="11.4" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_scrambling()\par dlsch\_modulation()\par36.211</text> +<path matrix="1 0 0 1 -12 -105.599" stroke="black" arrow="normal/tiny"> +405 397.373 m +421 397.373 l +</path> +<path matrix="1 0 0 1 1 -95" stroke="black" fill="1"> +294 320 m +294 296 l +392 296 l +392 320 l +h +</path> +<text matrix="1.16993 0 0 1 145.249 -227.226" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="17.5032" depth="5.544" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_encoding()\par36.212</text> +<path matrix="1 0 0 1 1 -14.726" stroke="black" fill="1"> +408 251 m +408 144 l +520 144 l +520 251 l +h +</path> +<text matrix="1 0 0 1 281 -257.226" transformations="translations" pos="128 440" stroke="black" type="minipage" width="112" height="30.0144" depth="18.072" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_scrambling()\par dlsch\_modulation()\par[2-4 layers]\par 36.211</text> +<path matrix="1 0 0 1 -12 -183.599" stroke="black" arrow="normal/tiny"> +405 397.373 m +421 397.373 l +</path> +<path matrix="1 0 0 1 1 -159" stroke="black" fill="1"> +294 320 m +294 296 l +392 296 l +392 320 l +h +</path> +<text matrix="1.16993 0 0 1 145.249 -291.226" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="17.5032" depth="5.544" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_encoding()\par36.212</text> +<path matrix="1 0 0 1 -12 -247.599" stroke="black" arrow="normal/tiny"> +405 397.373 m +421 397.373 l +</path> +<path matrix="1 0 0 1 1 -187.396" stroke="black" arrow="normal/tiny"> +268 399.17 m +293 399.17 l +</path> +<path matrix="1 0 0 1 1 -251.396" stroke="black" arrow="normal/tiny"> +268 399.17 m +293 399.17 l +</path> +<path matrix="1 0 0 1 1 -19" stroke="black" cap="1"> +552 428 m +552 428 l +</path> +<path stroke="black" arrow="normal/tiny"> +405 409 m +600 408.924 l +</path> +<path stroke="black" arrow="normal/tiny"> +520 381 m +600 380.885 l +</path> +<path stroke="black" arrow="normal/tiny"> +521 292.923 m +600 293.648 l +</path> +<text matrix="1 0 0 1 -124 -14" transformations="translations" pos="300 280" stroke="black" type="minipage" width="360.737" height="14.484" depth="2.52" valign="top" size="small">\tt\tiny openair1/SCHED/phy\_procedures\_lte\_eNb.c:pdsch\_procedures()</text> +<text matrix="1 0 0 1 -124 -162" transformations="translations" pos="300 280" stroke="black" type="minipage" width="359.972" height="14.484" depth="2.52" valign="top" size="small">\tt\tiny openair1/SCHED/phy\_procedures\_lte\_eNb.c:pdsch\_procedures()</text> +<text matrix="1 0 0 1 1 -19" transformations="translations" pos="168 372" stroke="black" type="minipage" width="364" height="11.4576" depth="0" valign="top" size="small">\tt\tiny openair1/PHY/LTE\_TRANSPORT/dci.c</text> +<path matrix="1 0 0 1 0 -9" stroke="black"> +360 104 m +360 104 l +360 104 l +360 104 l +h +</path> +<path matrix="1 0 0 1 1 -249" fill="pink"> +144 344 m +144 264 l +536 264 l +536 344 l +h +</path> +<path matrix="1.16667 0 0 1 7.6667 -354" stroke="black" fill="1"> +128 440 m +128 384 l +224 384 l +224 440 l +h +</path> +<text matrix="1 0 0 1 37.0006 -382" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_coding()\par36.212</text> +<text matrix="1 0 0 1 -16 -353" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="15.3664" depth="1.372" valign="top">\tt\tiny MCH\_PDU</text> +<path matrix="1 0 0 1 1 -251" stroke="black" fill="1"> +294 320 m +294 296 l +392 296 l +392 320 l +h +</path> +<text matrix="1.16993 0 0 1 145.249 -383.226" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="17.5032" depth="5.544" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_encoding()\par36.212</text> +<path matrix="1 0 0 1 1 -341.396" stroke="black" arrow="normal/tiny"> +268 399.17 m +293 399.17 l +</path> +<path matrix="1 0 0 1 1 -248" stroke="black" fill="1"> +408 322.774 m +408 288 l +520 288 l +520 322.774 l +h +</path> +<text matrix="1 0 0 1 281 -381.226" transformations="translations" pos="128 440" stroke="black" type="minipage" width="112" height="23.3352" depth="11.4" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny dlsch\_scrambling()\par mch\_modulation()\par36.211</text> +<path matrix="1 0 0 1 -12 -339.599" stroke="black" arrow="normal/tiny"> +405 397.373 m +421 397.373 l +</path> +<text matrix="1 0 0 1 -124 -251" transformations="translations" pos="300 280" stroke="black" type="minipage" width="360.737" height="11.4576" depth="0" valign="top" size="small">\tt\tiny openair1/SCHED/phy\_procedures\_lte\_eNb.c:pmch\_procedures()</text> +<path matrix="1 0 0 1 -16 -358" stroke="black" arrow="normal/small"> +64 416 m +172 416 l +</path> +<path matrix="1 0 0 1 0 -10" stroke="black" fill="white"> +128 488 m +128 452 l +172 452 l +172 488 l +h +</path> +<path matrix="1 0 0 1 0 -10" stroke="black"> +140 472 m +140 472 l +140 472 l +140 472 l +h +</path> +<text matrix="1 0 0 1 0 -3" transformations="translations" pos="128 476" stroke="black" type="minipage" width="44" height="19.332" depth="7.368" valign="top" size="small" style="center">\setstretch{.5}\tt\tiny UL CNTL\\36.213</text> +<path matrix="1 0 0 1 0 -10" stroke="black" fill="white"> +188 476 m +188 460 l +316 460 l +316 476 l +h +</path> +<text matrix="1 0 0 1 63 18.2948" transformations="translations" pos="128 440" stroke="black" type="minipage" width="128" height="11.4576" depth="0" valign="center" size="small">\tt\tiny generate\_phich\_top()</text> +<path matrix="1 0 0 1 0 -10" stroke="black" arrow="normal/tiny"> +172 468 m +188 468 l +</path> +<text matrix="1 0 0 1 206 17.2948" transformations="translations" pos="128 440" stroke="black" type="minipage" width="112" height="17.1312" depth="5.184" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny generate\_phich()\par36.212,36.211</text> +<path matrix="1 0 0 1 -88 60.401" stroke="black" arrow="normal/tiny"> +405 397.373 m +421 397.373 l +</path> +<path stroke="black" arrow="normal/tiny"> +445 457 m +600 456.672 l +</path> +<path stroke="black" arrow="normal/tiny"> +520.262 58 m +600 58.7558 l +</path> +<text matrix="1 0 0 1 40 70" transformations="translations" pos="168 372" stroke="black" type="minipage" width="364" height="11.4576" depth="0" valign="top" size="small">\tt\tiny openair1/PHY/LTE\_TRANSPORT/phich.c</text> +<text matrix="1 0 0 1 51 -27" transformations="translations" pos="468 488" stroke="black" type="label" width="62.6328" height="8.3016" depth="0" valign="baseline" size="small">\tiny PHICH REs</text> +<text matrix="1 0 0 1 51 -75" transformations="translations" pos="468 488" stroke="black" type="label" width="69.0456" height="8.3016" depth="0" valign="baseline" size="small">\tiny PCFICH REs</text> +<text matrix="1 0 0 1 55 -105" transformations="translations" pos="468 488" stroke="black" type="label" width="67.428" height="8.3016" depth="0" valign="baseline" size="small">\tiny PDCCH REs</text> +<text matrix="1 0 0 1 38 -160" transformations="translations" pos="468 488" stroke="black" type="label" width="66.3696" height="8.3016" depth="0" valign="baseline" size="small">\tiny PDSCH REs</text> +<path matrix="0.0772642 0 0 0.976417 547.24 -8.88888" stroke="black"> +104.077 0 0 104.077 528 236 e +</path> +<text matrix="1 0 0 1 55 -426" transformations="translations" pos="468 488" stroke="black" type="label" width="61.2216" height="8.3016" depth="0" valign="baseline" size="small">\tiny PMCH REs</text> +<text matrix="1 0 0 1 126.793 67.9996" transformations="translations" pos="128 440" stroke="black" type="minipage" width="112" height="24.18" depth="12.216" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny generate\_pilots\_slot()\par generate\_pss/sss/pbch()\par36.211</text> +<path stroke="black"> +248 488.695 m +248 488.695 l +248 488.695 l +248 488.695 l +h +</path> +<text matrix="1 0 0 1 -120 208" transformations="translations" pos="300 280" stroke="black" type="minipage" width="428" height="11.4576" depth="0" valign="top" size="small">\tt\tiny openair1/SCHED/phy\_procedures\_lte\_eNb.c:common\_signal\_procedures()</text> +<path stroke="black" arrow="normal/tiny"> +401 507 m +600.424 507.963 l +</path> +<text matrix="1 0 0 1 -41 21" transformations="translations" pos="468 488" stroke="black" type="label" width="155.743" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny CS-RS/PSS/SSS/PBCH REs</text> +<path matrix="1 0 0 1 -8 -7" stroke="black" arrow="normal/tiny"> +576 332 m +592 324 l +</path> +<text matrix="1 0 0 1 -97 -262" transformations="translations" pos="300 280" stroke="black" type="minipage" width="387.452" height="14.484" depth="2.52" valign="top" size="small">\tt\tiny openair1/SCHED/phy\_procedures\_lte\_eNb.c:phy\_procedures\_eNB\_TX()</text> +<text matrix="1 0 0 1 191 4" transformations="translations" pos="176 556" stroke="black" type="label" width="235.25" height="19.3704" depth="0" halign="center" valign="baseline">eNB TX Procedures</text> +<text matrix="1 0 0 1 -484 12" transformations="translations" pos="608 516" stroke="black" type="minipage" width="96" height="18.468" depth="6.504" valign="top" size="small">\tiny eNodeB\_3GPP or NGFI\_RCC\_IF4p5</text> +<path matrix="1 0 0 1 -101 288" fill="red"> +232 276 m +232 240 l +240 240 l +240 276 l +h +</path> +<text matrix="1.34783 0 0 1 -218.435 173" transformations="translations" pos="168 372" stroke="black" type="minipage" width="124" height="10.9584" depth="0" valign="top" size="small">\tt\tiny IF2 split points</text> +<path matrix="1 0 0 10.3333 -185 -2439" fill="red"> +232 276 m +232 240 l +240 240 l +240 276 l +h +</path> +<path matrix="1 0 0 1 -0.061 -69.254" stroke="black" arrow="normal/tiny"> +521 292.923 m +600 293.648 l +</path> +<path matrix="1 0 0 1 -0.061 -149.254" stroke="black" arrow="normal/tiny"> +521 292.923 m +600 293.648 l +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 4 0" stroke="black" arrow="normal/small"> +539.766 93 m +539.306 79.0026 l +340 79.7439 l +</path> +<path matrix="1 0 0 1 4 0" fill="lightblue"> +447.064 116 m +447.064 92 l +632 92 l +632 116 l +h +</path> +<path matrix="1.21414 0.582107 -1.21414 0.582107 363.61 -219.929" fill="lightgray"> +304 384 m +304 320 l +368 320 l +368 384 l +h +</path> +<path matrix="1 0 0 1 4 -3" fill="lightblue"> +225.588 267.631 m +225.588 257.004 l +451.999 257.004 l +451.999 267.631 l +h +</path> +<path matrix="1 0 0 1 -5.33315 0" fill="lightblue"> +286.577 417.212 m +286.577 407.581 l +412.989 407.581 l +412.989 417.212 l +h +</path> +<path matrix="1 0 0 1 4 0" stroke="black"> +-66.4757 363.53 m +-66.4757 358.467 l +-65.4632 358.467 l +-65.4632 363.53 l +h +</path> +<path matrix="8.74693 0 0 0.672878 -2760.71 189.213" fill="lightblue"> +330 430 m +330 390 l +380 390 l +380 430 l +h +</path> +<text matrix="0.781914 0 0 0.829268 129.776 77.4777" transformations="translations" pos="0 474" stroke="black" type="minipage" width="429.348" height="11.4576" depth="0" halign="center" valign="top" size="small" style="center">\begin{tiny} +\tt {\bf phy\_procedures\_eNB\_TX}(sched\_subframe,eNB,abstraction\_flag,r\_type,rn) +\end{tiny} +</text> +<text matrix="1 0 0 1 -143 3" transformations="translations" pos="362.664 511.871" stroke="red" type="label" width="207.355" height="8.3232" depth="2.304" valign="baseline" size="small">\begin{tiny} eNB instance and component carriers \end{tiny}</text> +<text matrix="1 0 0 1 -351.27 2.39657" transformations="translations" pos="362.664 511.871" stroke="red" type="label" width="191.82" height="8.3016" depth="0" valign="baseline" size="small">\begin{tiny} subframe where TX was scheduled \end{tiny}</text> +<path matrix="1 0 0 1 4 0" stroke="red" arrow="normal/small"> +293.168 472.33 m +189.522 511.272 l +</path> +<path matrix="1 0 0 1 4 0" stroke="red" arrow="normal/small"> +372.849 474.127 m +310.542 512.47 l +</path> +<text matrix="1.00926 0 0 0.961538 41.9142 43.5872" transformations="translations" pos="385.43 499.889" stroke="red" type="minipage" width="222.269" height="19.1256" depth="7.176" valign="top" size="small">\setstretch{.5}\begin{tiny} Flag to indicate 212/213 Split\\(transport channels, no 211 procedures) \end{tiny}</text> +<path matrix="1 0 0 1 4 0" stroke="red" arrow="normal/small"> +432.16 473.528 m +526.22 499.29 l +</path> +<path matrix="1.28305 0 0 0.427959 -151.6 291.984" stroke="red"> +27.6629 0 0 27.6629 531.612 404.032 e +</path> +<path matrix="1 0 0 1 4 0" stroke="red" arrow="normal/small"> +526.819 478.92 m +598.712 484.312 l +</path> +<text matrix="1 0 0 1 -6.1848 4.19374" transformations="translations" pos="606.5 493.299" stroke="red" type="minipage" width="138.992" height="11.9544" depth="0" valign="top" size="small">\begin{tiny} Experimental (for relays)\end{tiny}</text> +<text matrix="1 0 0 1 -5.33315 0" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="126.411" height="9.6312" depth="0" halign="center" valign="top" size="small">\begin{tiny} +\bf\tt Check for dead UEs +\end{tiny}</text> +<path matrix="1.21414 0.582107 -1.21414 0.582107 363.876 -64.4895" fill="lightgray"> +304 384 m +304 320 l +368 320 l +368 384 l +h +</path> +<path matrix="1 0 0 1 4 0" stroke="black" arrow="normal/small"> +340.45 451.636 m +340.45 417.212 l +</path> +<text matrix="1 0 0 1 -16 -23" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="11.2364" depth="0" halign="center" valign="top" style="center">\begin{tiny}\tt eNB$\rightarrow$CC\_id==0?\end{tiny}</text> +<text matrix="1 0 0 1 -56.9892 -152.581" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="10.6272" depth="0" halign="center" valign="top" size="small">\begin{tiny} +\bf\tt Call eNB\_dlsch\_ulsch\_scheduler [MAC] +\end{tiny}</text> +<path matrix="1 0 0 1 3.55 -44.424" stroke="black" arrow="normal/small"> +340.45 451.636 m +340.45 417.212 l +</path> +<path matrix="1 0 0 1 3.55 -152.424" stroke="black" arrow="normal/small"> +340.45 451.636 m +340.45 417.212 l +</path> +<path matrix="1 0 0 1 3.55 -197.424" stroke="black" arrow="normal/small"> +340.45 451.636 m +340.45 417.212 l +</path> +<path matrix="1 0 0 1 4 0" stroke="black" arrow="normal/small"> +418.155 336 m +528 336 l +528 248 l +340 247.665 l +</path> +<text matrix="1 0 0 1 4 0" transformations="translations" pos="420 344" stroke="black" type="label" width="12.9096" height="5.3136" depth="0" valign="baseline" size="small">\tiny no</text> +<path matrix="0.573318 0 0 1.1292 147.381 -192.209" fill="lightblue"> +225.588 267.631 m +225.588 257.004 l +451.999 257.004 l +451.999 267.631 l +h +</path> +<text matrix="1 0 0 1 -22 -177.724" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="129.761" height="9.6312" depth="0" halign="center" valign="top" size="small" style="center">\begin{tiny}\tt is PMCH subframe?\end{tiny}</text> +<text matrix="1 0 0 1 -56.9892 -308.305" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="10.9584" depth="0" halign="center" valign="top" size="small" style="center">\begin{tiny} +\bf\tt Call pmch\_procedures +\end{tiny}</text> +<path matrix="1 0 0 1 3.55 -308.424" stroke="black" arrow="normal/small"> +340.45 451.636 m +340.45 417.212 l +</path> +<path matrix="1 0 0 1 4 1" stroke="black" arrow="normal/small"> +340 97.4877 m +340 52 l +</path> +<text matrix="1 0 0 1 4 -155.724" transformations="translations" pos="420 344" stroke="black" type="label" width="12.9096" height="5.3136" depth="0" valign="baseline" size="small">\tiny no</text> +<text matrix="1 0 0 1 164.487 -301.212" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="17.2968" depth="5.352" valign="top" size="small">\setstretch{.5} +\begin{tiny} +\bf\tt Call common\_signal\_procedures\\ +(CS-RS/PSS/SSS/PBCH) +\end{tiny}</text> +<path matrix="1 0 0 1 4 0" stroke="black" arrow="normal/small"> +417.889 180.561 m +540 180 l +539.532 116 l +</path> +<path matrix="1 0 0 1 -24.1093 40" fill="lightgreen"> +352 0 m +352 12 l +384 12 l +384 12 l +384 0 l +368 -12 l +368 -12 l +h +</path> +<text matrix="1 0 0 1 199 0" transformations="translations" pos="176 556" stroke="black" type="label" width="219.988" height="19.3704" depth="0" halign="center" valign="baseline">eNB TX Flowchart</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="0.611694 0 0 2.48525 137.723 -162.718" fill="lightblue"> +225.588 267.631 m +225.588 257.004 l +451.999 257.004 l +451.999 267.631 l +h +</path> +<text matrix="1 0 0 1 -54.8216 84.695" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="17.2968" depth="5.352" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call get\_dci\_sdu [MAC]\\ dci=first\_dci +\end{tiny}</text> +<path matrix="1 0 0 1 -23.3752 0" stroke="black" rarrow="normal/small"> +368.672 502.411 m +368 524 l +</path> +<path matrix="1.21414 0.582107 -1.21414 0.582107 364.387 16.9945" fill="lightgray"> +304 384 m +304 320 l +368 320 l +368 384 l +h +</path> +<text matrix="1 0 0 1 -14.4181 67.484" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="19.6056" depth="5.656" halign="center" valign="top" style="center">\setstretch{.5}\begin{tiny}\tt dci not empty and DL dci?\end{tiny}</text> +<path matrix="1 0 0 1 -23.3751 -48.205" stroke="black" rarrow="normal/small"> +368.672 502.411 m +368 524 l +</path> +<path matrix="1 0 0 1 -23 0" stroke="black" rarrow="normal/small"> +368.297 357.206 m +368 380 l +</path> +<path matrix="1 0 0 1 -23 0" fill="lightblue"> +260 356 m +260 328 l +476 328 l +476 356 l +h +</path> +<text matrix="1 0 0 1 -54.7825 -63.7328" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="17.2968" depth="5.352" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call generate\_dlsch\_params\_from\_dci\\ +dci=next(dci) +\end{tiny}</text> +<text matrix="1 0 0 1 -43 0" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="8.5512" depth="0" valign="top" size="small" style="center">\tt\tiny no</text> +<path matrix="1 0 0 1 -23 0" stroke="black" arrow="normal/small"> +260 342 m +240.242 342 l +240 472 l +368 472 l +</path> +<path matrix="1 0 0 1 -23 0" stroke="black" arrow="normal/small"> +445.666 417.484 m +512.662 417.484 l +512.662 303.725 l +367.862 303.725 l +367.862 288.454 l +</path> +<path matrix="1 0 0 1 -23 -68" fill="lightblue"> +260 356 m +260 328 l +476 328 l +476 356 l +h +</path> +<text matrix="1 0 0 1 -54.7825 -131.733" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="16.8048" depth="4.848" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call phy\_config\_dedicated\_step2\\ +dci=first\_dci +\end{tiny}</text> +<path fill="lightgray"> +272 200 m +344.961 161.229 l +416 200 l +344.961 235.739 l +h +</path> +<text matrix="1 0 0 1 -14.4181 -151.516" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="19.6056" depth="5.656" halign="center" valign="top" style="center">\setstretch{.5}\begin{tiny}\tt dci not empty and UL dci?\end{tiny}</text> +<path matrix="1 0 0 1 -23 -219" stroke="black" rarrow="normal/small"> +368.297 357.206 m +368 380 l +</path> +<path matrix="1 0 0 1 -23 -219" fill="lightblue"> +260 356 m +260 328 l +476 328 l +476 356 l +h +</path> +<text matrix="1 0 0 1 -54.7825 -282.733" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="17.2968" depth="5.352" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call generate\_ulsch\_params\_from\_dci\\ +dci=next(dci) +\end{tiny}</text> +<text matrix="1 0 0 1 -43 -219" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="8.5512" depth="0" valign="top" size="small" style="center">\tt\tiny no</text> +<path matrix="1 0 0 1 -23 0" stroke="black" arrow="normal/small"> +260 123 m +240.242 123 l +240 252 l +368 252 l +</path> +<path stroke="black" arrow="normal/small"> +416 200 m +488 200 l +489 96 l +345 96 l +344.862 77.0895 l +</path> +<path fill="lightblue"> +272 80 m +272 48 l +416 48 l +416 80 l +h +</path> +<text matrix="1 0 0 1 -54.7825 -343.733" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="18.1416" depth="6.168" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call generate\_dci\_top\\ +Call generate\_phich\_top +\end{tiny}</text> +<path matrix="1 0 0 1 -23.297 -121.206" stroke="black" rarrow="normal/small"> +368.297 357.206 m +368 380 l +</path> +<path matrix="1 0 0 1 -23 12" fill="lightgreen"> +352 0 m +352 12 l +384 12 l +384 12 l +384 0 l +368 -12 l +368 -12 l +h +</path> +<path stroke="black" rarrow="normal/small"> +344 24 m +344 48 l +</path> +<text matrix="1 0 0 1 40 56" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="9.8808" depth="0" valign="top" size="small" style="center">\tt\tiny yes</text> +<text matrix="1 0 0 1 41 -164" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="9.8808" depth="0" valign="top" size="small" style="center">\tt\tiny yes</text> +<text matrix="1 0 0 1 179 0" transformations="translations" pos="176 556" stroke="black" type="label" width="219.988" height="19.3704" depth="0" halign="center" valign="baseline">eNB TX Flowchart</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 0 15" fill="lightblue"> +240 96 m +240 56 l +496 56 l +496 96 l +h +</path> +<text matrix="1 0 0 1 -47.7825 -306.39" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="258.411" height="23.6472" depth="11.688" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt dlsch\_eNB[UE].subframe\_active=false\par [no PUCCH ACK to be checked in TTI n+k]\par +UE=next(UE) +\end{tiny}</text> +<path matrix="1 0 0 1 0 -161" fill="lightgray"> +288 464 m +368 432 l +448 464 l +368 496 l +h +</path> +<path matrix="1 0 0 1 0 -73" fill="lightgray"> +288 464 m +368 432 l +448 464 l +368 496 l +h +</path> +<path stroke="black" arrow="normal/small"> +368 528 m +368 512 l +</path> +<path matrix="1 0 0 1 0 15" fill="lightgray"> +288 464 m +368 432 l +448 464 l +368 496 l +h +</path> +<text matrix="1 0 0 1 9.5819 128.484" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="19.6056" depth="5.656" halign="center" valign="top" style="center">\setstretch{.5}\begin{tiny}\tt is dlsch\_SI active?\end{tiny}</text> +<path matrix="1 0 0 1 0 -81" stroke="black" arrow="normal/small"> +368 528 m +368 504 l +</path> +<text matrix="1 0 0 1 9.5819 26.484" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="19.6056" depth="5.656" halign="center" valign="center" style="center">\setstretch{.5}\begin{tiny}\tt is dlsch\_P active?\end{tiny}</text> +<path matrix="1 0 0 1 0 -169" stroke="black" arrow="normal/small"> +368 528 m +368 504 l +</path> +<text matrix="1 0 0 1 9.5819 -48.516" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="19.6056" depth="5.656" halign="center" valign="top" style="center">\setstretch{.5}\begin{tiny}\tt is dlsch\_RA active?\end{tiny}</text> +<text matrix="1 0 0 1 -57 63" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="8.5512" depth="0" valign="top" size="small" style="center">\tt\tiny no</text> +<text matrix="1 0 0 1 -57 -33" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="8.5512" depth="0" valign="top" size="small" style="center">\tt\tiny no</text> +<text matrix="1 0 0 1 -54 -107" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="8.5512" depth="0" valign="top" size="small" style="center">\tt\tiny no</text> +<path matrix="1 0 0 1 0 -257" stroke="black" arrow="normal/small"> +368 528 m +368 504 l +</path> +<path matrix="1 0 0 1 -16 -17" fill="lightblue"> +456 480 m +456 464 l +648 464 l +648 480 l +h +</path> +<text matrix="1 0 0 1 137.178 43.695" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="11.4576" depth="0" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call pdsch\_procedures(dlsch\_SI) +\end{tiny}</text> +<path matrix="1 0 0 1 0 15" stroke="black" arrow="normal/small"> +448 464 m +536 464 l +536 448 l +</path> +<path matrix="1 0 0 1 0 15" stroke="black" arrow="normal/small"> +536 432 m +536 424 l +368 424 l +</path> +<text matrix="1 0 0 1 64 119" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="9.8808" depth="0" valign="top" size="small" style="center">\tt\tiny yes</text> +<path matrix="1 0 0 1 -16 -105" fill="lightblue"> +456 480 m +456 464 l +648 464 l +648 480 l +h +</path> +<text matrix="1 0 0 1 137.178 -44.305" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="11.4576" depth="0" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call pdsch\_procedures(dlsch\_P) +\end{tiny}</text> +<path matrix="1 0 0 1 0 -73" stroke="black" arrow="normal/small"> +448 464 m +536 464 l +536 448 l +</path> +<path matrix="1 0 0 1 0 -73" stroke="black" arrow="normal/small"> +536 432 m +536 424 l +368 424 l +</path> +<text matrix="1 0 0 1 64 31" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="9.8808" depth="0" valign="top" size="small" style="center">\tt\tiny yes</text> +<path matrix="1 0 0 1 -16 -193" fill="lightblue"> +456 480 m +456 464 l +648 464 l +648 480 l +h +</path> +<text matrix="1 0 0 1 137.178 -132.305" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="11.4576" depth="0" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call pdsch\_procedures(dlsch\_RA) +\end{tiny}</text> +<path matrix="1 0 0 1 0 -161" stroke="black" arrow="normal/small"> +448 464 m +536 464 l +536 448 l +</path> +<path matrix="1 0 0 1 0 -161" stroke="black" arrow="normal/small"> +536 432 m +536 424 l +368 424 l +</path> +<text matrix="1 0 0 1 64 -57" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="9.8808" depth="0" valign="top" size="small" style="center">\tt\tiny yes</text> +<path matrix="1 0 0 1 0 15" fill="lightblue"> +256 232 m +256 208 l +480 208 l +480 232 l +h +</path> +<text matrix="1 0 0 1 -30.822 -172.305" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="17.2968" depth="5.352" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt UE=first\_UE from UE\_list \par [list of UE with t-CRNTI or CRNTI] +\end{tiny}</text> +<path matrix="1 0 0 1 0 -297" fill="lightgray"> +288 464 m +368 432 l +448 464 l +368 496 l +h +</path> +<text matrix="1 0 0 1 9.5819 -185.516" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="19.6056" depth="5.656" halign="center" valign="top" style="center">\setstretch{.5}\begin{tiny}\tt is dlsch\_UE active?\end{tiny}</text> +<path matrix="1 0 0 1 0 -305" stroke="black" arrow="normal/small"> +368 528 m +368 504 l +</path> +<path matrix="1 0 0 1 0 -392" stroke="black" arrow="normal/small"> +368 528 m +368 504 l +</path> +<path matrix="1 0 0 1 -16 -327" fill="lightblue"> +456 480 m +456 464 l +648 464 l +648 480 l +h +</path> +<text matrix="1 0 0 1 137.178 -267.305" transformations="translations" pos="286.577 417.212" stroke="black" type="minipage" width="226.411" height="11.4576" depth="0" halign="center" valign="top" size="small" style="center">\setstretch{.5}\begin{tiny} +\bf\tt Call pdsch\_procedures(dlsch\_UE) +\end{tiny}</text> +<text matrix="1 0 0 1 64 -192" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="9.8808" depth="0" valign="top" size="small" style="center">\tt\tiny yes</text> +<path matrix="1 0 0 1 0 -297" stroke="black" arrow="normal/small"> +448 464 m +536 464 l +536 448 l +</path> +<path matrix="1 0 0 1 0 -297" stroke="black" arrow="normal/small"> +536 432 m +536 424 l +368 424 l +</path> +<text matrix="1 0 0 1 -54 -243" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="8.5512" depth="0" valign="top" size="small" style="center">\tt\tiny no</text> +<path matrix="1 0 0 1 0 15" stroke="black"> +416 88 m +416 88 l +416 88 l +416 88 l +h +</path> +<path matrix="1 0 0 1 0 8" fill="lightgray"> +320 32 m +368 16 l +416 32 l +368 48 l +h +</path> +<text matrix="1 0 0 1 9.5819 -318.516" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="11.2364" depth="0" halign="center" valign="top" style="center">\setstretch{.5}\begin{tiny}\tt UE=NULL?\end{tiny}</text> +<path stroke="black" arrow="normal/small"> +368 72 m +368 56 l +</path> +<path stroke="black" arrow="normal/small"> +320 40 m +224 40 l +224 168 l +288 168 l +</path> +<text matrix="1 0 0 1 -94 -323" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="8.5512" depth="0" valign="top" size="small" style="center">\tt\tiny no</text> +<path matrix="1 0 0 1 273 15" fill="lightgreen"> +352 0 m +352 12 l +384 12 l +384 12 l +384 0 l +368 -12 l +368 -12 l +h +</path> +<path stroke="black" arrow="normal/small"> +416 40 m +640 40 l +640 24 l +</path> +<text matrix="1 0 0 1 32 -320" transformations="translations" pos="384 376" stroke="black" type="minipage" width="32" height="9.8808" depth="0" valign="top" size="small" style="center">\tt\tiny yes</text> +<path fill="blue"> +512 48 m +512 32 l +544 32 l +544 48 l +h +</path> +<path stroke="red" pen="fat" arrow="normal/small"> +528 80 m +528 48 l +</path> +<text matrix="1 0 0 1 -27 0" transformations="translations" pos="528 112" stroke="red" type="minipage" width="256" height="18.468" depth="6.504" valign="top" size="small">\bf\setstretch{.5}\tiny IF4p5 \par [All Frequency-domain Signals are created]</text> +<text matrix="1 0 0 1 183 0" transformations="translations" pos="176 556" stroke="black" type="label" width="219.988" height="19.3704" depth="0" halign="center" valign="baseline">eNB TX Flowchart</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 0 16" fill="lightgray"> +130 527 m +130 -1 l +608 0 l +608 528 l +h +</path> +<path matrix="1 0 0 1 21 16" fill="gold"> +388 288 m +388 208 l +584 208 l +584 288 l +h +</path> +<path matrix="1 0 0 1 0 16" fill="lightgreen"> +141 449 m +141 361 l +580.427 361 l +580 448 l +h +</path> +<path matrix="1 0 0 1 0 16" stroke="black" fill="white"> +464 428 m +464 396 l +576 396 l +576 428 l +h +</path> +<path matrix="1 0 0 1 -148 100" fill="lightyellow"> +462.358 361 m +462.358 287.368 l +602 287.368 l +602 361 l +h +</path> +<path matrix="1 0 0 1 0 16" fill="lightcyan"> +462.358 361 m +462.358 287.368 l +602 287.368 l +602 361 l +h +</path> +<path matrix="1 0 0 1 0 16" fill="pink"> +492 200 m +492 16 l +596 16 l +596 200 l +h +</path> +<path matrix="1 0 0 1 0 19" fill="lightblue"> +130 202.157 m +130 16 l +484 16 l +484 204 l +h +</path> +<text matrix="1 0 0 1 -168 -251" transformations="translations" pos="300 280" stroke="black" type="minipage" width="397.2" height="11.4576" depth="0" valign="top" size="small">\tt\tiny openair1/SCHED/phy\_procedures\_lte\_eNb.c:phy\_procedures\_eNB\_RX()</text> +<path matrix="1 0 0 1 687 40" fill="gold" tiling="rising"> +0 424 m +0 32 l +48 32 l +48 424 l +h +</path> +<text matrix="1 0 0 1 670 -91" transformations="translations" pos="32 416" stroke="black" type="minipage" width="32" height="50.1172" depth="36.204" valign="top" style="center">M\\ +A\\ +C</text> +<path matrix="1 0 0 1 515 12" stroke="black" arrow="normal/small"> +64 416 m +172 416 l +</path> +<text matrix="1 0 0 1 515 12" transformations="translations" pos="72 440" stroke="black" type="minipage" width="96" height="16.898" depth="2.94" valign="top">\setstretch{.5}\tt\tiny RACH Preamble</text> +<path matrix="1 0 0 1 0 9" stroke="black" arrow="normal/small"> +534 125.858 m +688 126 l +</path> +<text matrix="1 0 0 1 491 -280" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="15.9404" depth="1.96" valign="top">\tt\tiny ULSCH\_SDU(UE\_id)</text> +<text matrix="1 0 0 1 -523.368 259.368" pos="596 32" stroke="black" type="label" width="156.192" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny eNB\_common\_vars.rxdataF[0]</text> +<text matrix="1 0 0 1 -530.368 235.368" pos="596 32" stroke="black" type="label" width="168.646" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny eNB\_common\_vars.rxdataF[R-1]</text> +<path matrix="2.16129 0 0 1 -478.452 16" stroke="black" arrow="normal/small"> +273 269 m +412 268 l +</path> +<path matrix="2.14286 0 0 1 -469.857 12" stroke="black" arrow="normal/small"> +273 245 m +412 244 l +</path> +<path matrix="1 0 0 1 -53 16" stroke="black" fill="1"> +184 128 m +184 100 l +276 100 l +276 128 l +h +</path> +<text matrix="1 0 0 1 3.0006 -311" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny rx\_ulsch(UE\_id)\par36.211</text> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/tiny"> +208 240 m +208 128 l +</path> +<text matrix="1 0 0 1 147 25" transformations="translations" pos="168 372" stroke="black" type="minipage" width="364" height="11.4576" depth="0" valign="top" size="small">\tt\tiny LTE\_TRANSPORT/prach.c</text> +<text matrix="1 0 0 1 -27 -327" transformations="translations" pos="168 372" stroke="black" type="minipage" width="364" height="11.4576" depth="0" valign="top" size="small">\tt\tiny openair1/PHY/LTE\_TRANSPORT/ulsch\_demodulation.c</text> +<path matrix="1 0 0 1 21 16" stroke="black" fill="white"> +393 285 m +393 229 l +552 228 l +552 284 l +h +</path> +<text matrix="1 0 0 1 287 -161.705" transformations="translations" pos="128 440" stroke="black" type="minipage" width="161" height="10.6272" depth="0" valign="center" size="small">\tt\tiny lte\_eNB\_I0\_measurements()</text> +<group matrix="1 0 0 1 -49 16"> +<group> +<path stroke="black" fill="white"> +280 32 m +280 199 l +308 199 l +308 32 l +h +</path> +<text matrix="0 1 -1 0 734.001 -92" pos="128 440" stroke="black" type="minipage" width="164" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_extract\_rbs\_single()\par36.211</text> +</group> +</group> +<group matrix="1 0 0 1 -65 16"> +<path stroke="black" fill="white"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 786.001 -95" pos="128 440" stroke="black" type="minipage" width="164" height="16.6824" depth="4.704" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny lte\_ul\_channel\_estimation()\par36.211</text> +</group> +<group matrix="1 0 0 1 -93 16"> +<path matrix="1 0 0 1 100 0" stroke="black" fill="white"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 886.001 -95" pos="128 440" stroke="black" type="minipage" width="164" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_detection\_mrc()\par36.211</text> +</group> +<group matrix="1 0 0 1 -101 16"> +<path matrix="1 0 0 1 144 0" stroke="black" fill="white"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 930.001 -95" pos="128 440" stroke="black" type="minipage" width="164" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny frequency\_equalization()\par36.211</text> +</group> +<group matrix="1 0 0 1 -46 16"> +<path matrix="1 0 0 1 125 0" stroke="black" fill="white"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 911.001 -95" pos="128 440" stroke="black" type="minipage" width="164" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny lte\_idft()\par36.211</text> +</group> +<group matrix="1 0 0 1 -54 16"> +<path matrix="1 0 0 1 169 0" stroke="black" fill="white"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 955.001 -95" pos="128 440" stroke="black" type="minipage" width="164" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_XXX\_llr()\par36.211</text> +</group> +<group matrix="1 0 0 1 -39 16"> +<path matrix="1 0 0 1 213 0" stroke="black" fill="white"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 1001 -95" pos="128 440" stroke="black" type="minipage" width="164" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_decoding()\par36.212</text> +</group> +<group matrix="1 0 0 1 -20 16"> +<path matrix="1 0 0 1 -9 0" stroke="black" fill="white"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<group> +<text matrix="0 1 -1 0 777.001 -96" pos="128 440" stroke="black" type="minipage" width="164" height="17.5032" depth="5.544" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_channel\_compensation()\par36.211</text> +</group> +</group> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/small"> +476 118 m +504.475 118 l +</path> +<path matrix="1 0 0 1 0 16" stroke="black"> +564 220 m +564 220 l +564 220 l +564 220 l +h +</path> +<text matrix="1 0 0 1 326 -327" transformations="translations" pos="168 372" stroke="black" type="minipage" width="112.095" height="10.9584" depth="0" valign="top" size="small">\tt\tiny ulsch\_decoding.c</text> +<path matrix="1 0 0 1 60.209 86" stroke="black" arrow="normal/small"> +476 118 m +504.475 118 l +</path> +<text matrix="1 0 0 1 472.783 -208" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="16.3212" depth="2.352" valign="top">\tt\tiny ACK/NAK,RI,CQI</text> +<path matrix="1 0 0 1 164 16" stroke="black" fill="1"> +131 344 m +131 316 l +276 316 l +276 344 l +h +</path> +<text matrix="1 0 0 1 167.001 -95" transformations="translations" pos="128 440" stroke="black" type="minipage" width="146.013" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny pucch\_procedures(UE\_id)\par36.211</text> +<path matrix="1 0 0 1 324 140" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 349.001 -96" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny rx\_pucchl\par36.211</text> +<path matrix="1 0 0 1 77.275 242" stroke="black" arrow="normal/small"> +476 118 m +504.475 118 l +</path> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/small"> +551.76 312.126 m +687 312.231 l +</path> +<text matrix="1 0 0 1 510.907 -68" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="15.9404" depth="1.96" valign="top">\tt\tiny ACK/NAK</text> +<text matrix="1 0 0 1 510.907 -100" transformations="translations" pos="72 440" stroke="black" type="minipage" width="48" height="11.2364" depth="0" valign="top">\tt\tiny SR</text> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/small"> +440.514 328 m +477 327.572 l +</path> +<text matrix="1 0 0 1 295.239 -57.6321" transformations="translations" pos="168 372" stroke="black" type="minipage" width="112.095" height="11.4576" depth="0" valign="top" size="small">\tt\tiny TRANSPORT/pucch.c</text> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/tiny"> +373.112 244.28 m +373.112 316 l +</path> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/tiny"> +344.968 268.786 m +345.381 316 l +</path> +<path matrix="1 0 0 1 16 100" stroke="black" fill="1"> +131 344 m +131 316 l +276 316 l +276 344 l +h +</path> +<text matrix="1 0 0 1 43.001 -11" transformations="translations" pos="128 440" stroke="black" type="minipage" width="111.289" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny prach\_procedures\par36.211</text> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/small"> +405.275 413 m +464 412.625 l +</path> +<path matrix="1 0 0 1 -148 100" stroke="black" arrow="normal/small"> +440.514 328 m +477 327.572 l +</path> +<text matrix="1 0 0 1 -159.361 103" transformations="translations" pos="300 280" stroke="black" type="minipage" width="370.438" height="11.4576" depth="0" valign="top" size="small">\tt\tiny openair1/SCHED/phy\_procedures\_lte\_eNb.c:prach\_procedures()</text> +<path matrix="1 0 0 1 178.191 224" stroke="black" fill="1"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 203.192 -12" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny rx\_prachl\par36.211</text> +<text matrix="1 0 0 1 354 -12" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="14.484" depth="2.52" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny E\_PRACH>Lmin\par36.211</text> +<text matrix="1 0 0 1 240.239 -135.632" transformations="translations" pos="168 372" stroke="black" type="minipage" width="250.621" height="10.6272" depth="0" valign="top" size="small">\tt\tiny LTE\_ESTIMATION/lte\_eNB\_I0\_measurements.c</text> +<text matrix="1 0 0 1 203 20" transformations="translations" pos="176 556" stroke="black" type="label" width="299.76" height="19.3704" depth="0" halign="center" valign="baseline">eNB PHY RX Procedures</text> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/small"> +0 416 m +144 416 l +</path> +<text matrix="1 0 0 1 -592.839 419.285" pos="596 32" stroke="black" type="label" width="207.648" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt eNB->prach\_vars.prachF[0$\cdots$ R-1]}</text> +<path matrix="1 0 0 1 0 16" stroke="black" arrow="normal/tiny"> +160 268 m +160 128 l +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="0.999446 0 0 2 -0.592063 -512" fill="turquoise"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path matrix="0.999446 0 0 0.875 -0.592063 -151" fill="gold"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path matrix="0.999446 0 0 1 0.407937 -156" fill="pink"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path matrix="0.999446 0 0 1 0.407937 -124" fill="lightyellow"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path matrix="0.999446 0 0 1.125 0.407937 -125" fill="lightgreen"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path matrix="0.999446 0 0 0.75 0.407937 10" fill="lightgray"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path matrix="1 0 0 1 0 -32" fill="lightcyan"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path fill="lightblue"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<path matrix="1 0 0 1 -5 324" stroke="black" fill="1"> +184 128 m +184 100 l +276 100 l +276 128 l +h +</path> +<text matrix="1 0 0 1 51.0006 -3" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny rx\_ulsch(UE\_id)\par36.211</text> +<text matrix="1 0 0 1 -69 -7" transformations="translations" pos="68 284" stroke="black" type="label" width="742.558" height="8.9712" depth="8.232" valign="baseline" size="small">\tiny$\mathbf{R}_{r,l}=\mathrm{DFT}_{N_{\mathrm{fft}}}(\mathbf{r}_{r,l}\odot\mathbf{F}_{7.5}),r=0,1,\cdots,R-1,l=0,1,\cdots,N_{\mathrm{symb}}-1$ (\tt\bf eNB\_common\_vars$\rightarrow$rxdataF[][])%,N_{\mathrm{fft}}=2^{1+\left\lceil\log_2 12N^{\mathrm{RB}}_{\mathrm{DL}}\right\rceil$</text> +<path matrix="1 0 0 1 -84 232" stroke="black" fill="lightblue"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 -58.9994 -4" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny slot\_fep\_ul\par36.211</text> +<path stroke="black" arrow="normal/tiny"> +144 440 m +176 440 l +</path> +<path stroke="black" cap="1"> +272 328 m +272 328 l +</path> +<path matrix="1 0 0 1 -108 -4" stroke="black" arrow="normal/tiny"> +144 440 m +176 440 l +</path> +<text transformations="translations" pos="28 468" stroke="black" type="label" width="32.0432" height="6.2048" depth="7.588" valign="baseline">\tiny $\mathbf{r}_{r,l}$</text> +<text matrix="1 0 0 1 128 4" transformations="translations" pos="28 468" stroke="black" type="label" width="38.7464" height="9.576" depth="7.588" valign="baseline">\tiny $\mathbf{R}_{r,l}$</text> +<text matrix="1 0 0 1 276 -132" transformations="translations" pos="28 468" stroke="black" type="label" width="71.1956" height="9.576" depth="7.588" valign="baseline">\tiny $\mathbf{R}_{\mathrm{ext},r,l}$</text> +<text matrix="1 0 0 1 -24 -224" transformations="translations" pos="28 468" stroke="black" type="label" width="693.216" height="8.9712" depth="6.504" valign="baseline" size="small">\tiny $R_{\mathrm{ext},r,l}(n)={R}_{r,l}(12\mathrm{firstPRB}+n),n=0,1,\cdots,12N_{\mathrm{PRB}}-1$ (\tt\bf eNB\_pusch\_vars$\rightarrow$ulsch\_rxdataF\_ext[][])</text> +<text matrix="1 0 0 1 340 -156" transformations="translations" pos="28 468" stroke="black" type="label" width="39.4436" height="13.062" depth="7.588" valign="baseline">\tiny $\mathbf{\hat{H}}_{r,l}$</text> +<text matrix="1 0 0 1 -28 -246" transformations="translations" pos="28 468" stroke="black" type="label" width="631.046" height="11.196" depth="9.12" valign="baseline" size="small">\tiny $\mathbf{\hat{H}}_{r,l} = \mathbf{R}_{\mathrm{ext},r,l}\odot\mathbf{DRS}^*_{l}(\mathrm{cyclicShift},n_{\mathrm{DMRS}^{(2)}},n_{\mathrm{PRS}})$, (\tt\bf eNB\_pusch\_vars$\rightarrow$drs\_ch\_estimates[])</text> +<text matrix="1 0 0 1 392 -128" transformations="translations" pos="28 468" stroke="black" type="label" width="88.9196" height="9.576" depth="7.588" valign="baseline">\tiny $\mathbf{R}_{\mathrm{comp},r,l}$</text> +<text matrix="1 0 0 1 452 -156" transformations="translations" pos="28 468" stroke="black" type="label" width="89.5328" height="9.576" depth="7.588" valign="baseline">\tiny $\mathbf{R}_{\mathrm{comp},0,l}$</text> +<text matrix="1 0 0 1 -28 -320" transformations="translations" pos="28 468" stroke="black" type="label" width="247.932" height="14.2848" depth="6.504" valign="baseline" size="small">\tiny $\mathbf{R}_{\mathrm{comp},0,l}=\frac{1}{R}\sum_{r=0}^{R-1}\mathbf{R}_{\mathrm{comp},r,l}$</text> +<text matrix="1 0 0 1 512 -128" transformations="translations" pos="28 468" stroke="black" type="label" width="89.5328" height="9.576" depth="7.588" valign="baseline">\tiny $\mathbf{R}_{\mathrm{comp},0,l}$</text> +<text matrix="1 0 0 1 572 -156" transformations="translations" pos="28 468" stroke="black" type="label" width="82.8324" height="6.2048" depth="7.588" valign="baseline">\tiny $\mathbf{r}_{\mathrm{comp},0,l}$</text> +<text matrix="1 0 0 1 -28 -345" transformations="translations" pos="28 468" stroke="black" type="label" width="528.362" height="17.3352" depth="12.792" valign="baseline" size="small">\tiny $R_{\mathrm{comp},0,l}(n)=R_{\mathrm{comp},0,l}(n)\dot Q_8\left(\frac{1}{|\hat{H}(n)|^2+I_0}\right), \hat{H}(n)=\sum_{r=0}^{R-1}\hat{H}_{r}(n)$</text> +<text matrix="1 0 0 1 -3 15" transformations="translations" pos="4 192" stroke="black" type="minipage" width="728" height="23.3184" depth="11.376" valign="top" size="small">\tiny $\mathbf{R}_{\mathrm{comp},r,l}=\mathbf{\hat{H}}_r\odot\mathbf{R}_{\mathrm{ext},r,l}2^{-\log_2|H_\mathrm{max}|}, \mathbf{\hat{H}}_r = \frac{1}{2}(\mathbf{\hat{H}}_{r,3}+\mathbf{\hat{H}}_{r,10})$\par (\tt\bf eNB\_pusch\_vars$\rightarrow$ulsch\_rxdataF\_comp)</text> +<text matrix="1 0 0 1 624 -124" transformations="translations" pos="28 468" stroke="black" type="label" width="19.8156" height="9.6964" depth="4.872" valign="baseline">\tiny $\mathbf{\lambda}_{l}$</text> +<text matrix="1 0 0 1 -28 -402" transformations="translations" pos="28 468" stroke="black" type="label" width="636.775" height="8.9712" depth="6.504" valign="baseline" size="small">\tiny QPSK : $\lambda_l(2n)=\mathrm{Re}(r_{\mathrm{comp},0,l}(n)), \lambda_l(2n+1)=\mathrm{Im}(r_{\mathrm{comp},0,l}(n))$ (\tt\bf eNB\_pusch\_vars$\rightarrow$ulsch\_llr)</text> +<text matrix="1 0 0 1 -28 -374" transformations="translations" pos="28 468" stroke="black" type="label" width="287.525" height="8.9616" depth="8.064" valign="baseline" size="small">\tiny ${\mathbf r}_{\mathrm{comp},0,l} = \mathrm{IDFT}_{12N_{\mathrm{PRB}}}({\mathbf R}_{\mathrm{comp},0,l})$</text> +<text matrix="1 0 0 1 0 23" transformations="translations" pos="4 28" stroke="black" type="minipage" width="720" height="24.1008" depth="12.144" valign="top" size="small">\tiny 16QAM : $\lambda_l(4n)=\mathrm{Re}(r_{\mathrm{comp},0,l}(n)), \lambda_l(4n+2)=\mathrm{Im}(r_{\mathrm{comp},0,l}(n))$\par$\lambda_l(4n+1)=|\mathrm{Re}(r_{\mathrm{comp},0,l}(n))|-2\overline{|h(n)|},\lambda_l(4n+3)=|\mathrm{Im}(r_{\mathrm{comp},0,l}(n))|-2\overline{|h(n)|}$</text> +<path matrix="1 0 0 1 -1 324" stroke="black" fill="lightcyan"> +280 32 m +280 199 l +308 199 l +308 32 l +h +</path> +<text matrix="0 1 -1 0 733.001 232" pos="128 440" stroke="black" type="minipage" width="164" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_extract\_rbs\_single()\par36.211</text> +<path matrix="1 0 0 1 5 324" stroke="black" fill="lightgray"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 791.001 229" pos="128 440" stroke="black" type="minipage" width="164" height="16.6824" depth="4.704" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny lte\_ul\_channel\_estimation()\par36.211</text> +<path matrix="1 0 0 1 63 324" stroke="black" fill="lightgreen"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<group matrix="1 0 0 1 72 324"> +<text matrix="0 1 -1 0 777.001 -96" pos="128 440" stroke="black" type="minipage" width="164" height="17.5032" depth="5.544" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_channel\_compensation()\par36.211</text> +</group> +<path matrix="1 0 0 1 121 324" stroke="black" fill="lightyellow"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 907.001 229" pos="128 440" stroke="black" type="minipage" width="164" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_detection\_mrc()\par36.211</text> +<path matrix="1 0 0 1 179 324" stroke="black" fill="pink"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 965.001 229" pos="128 440" stroke="black" type="minipage" width="164" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny frequency\_equalization()\par36.211</text> +<path matrix="1 0 0 1 237 324" stroke="black" fill="gold"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 1023 229" pos="128 440" stroke="black" type="minipage" width="164" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny lte\_idft()\par36.211</text> +<path matrix="1 0 0 1 295 324" stroke="black" fill="turquoise"> +332 32 m +332 199 l +360 199 l +360 32 l +h +</path> +<text matrix="0 1 -1 0 1081 229" pos="128 440" stroke="black" type="minipage" width="164" height="15.492" depth="3.504" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny ulsch\_XXX\_llr()\par36.211</text> +<path stroke="black"> +304 236 m +304 236 l +304 236 l +304 236 l +h +</path> +<text matrix="1 0 0 1 199 0" transformations="translations" pos="176 556" stroke="black" type="label" width="320.138" height="19.3704" depth="0" halign="center" valign="baseline">eNB ULSCH Demodulation</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 199 0" transformations="translations" pos="176 556" stroke="black" type="label" width="273.104" height="19.3704" depth="0" halign="center" valign="baseline">eNB PRACH Detection</text> +<path matrix="1 0 0 1 0.643 45" fill="lightblue"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<text matrix="1 0 0 1 -68.357 38" transformations="translations" pos="68 284" stroke="black" type="label" width="505.402" height="8.9616" depth="8.064" valign="baseline" size="small">\tiny$\mathbf{R}_{r}=\mathrm{DFT}_{N_{\mathrm{PRACH}}}(\mathbf{r}_{r}),r=0,1,\cdots,R-1$ (\tt\bf lte\_eNB\_prach\_vars$\rightarrow$rxsigF[])%,N_{\mathrm{fft}}=2^{1+\left\lceil\log_2 12N^{\mathrm{RB}}_{\mathrm{DL}}\right\rceil$</text> +<path matrix="1 0 0 1 -0.879076 13" fill="lightcyan"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<text matrix="1 0 0 1 -69.8791 6" transformations="translations" pos="68 284" stroke="black" type="label" width="501.238" height="10.392" depth="4.776" valign="baseline" size="small">\tiny$\mathbf{R}_{\mathrm{comp},r}=\mathbf{R}_{r}\odot \mathbf{X}^*_u[i],r=0,1,\cdots,R-1$ (\tt\bf lte\_eNB\_prach\_vars$\rightarrow$prachF[])%,N_{\mathrm{fft}}=2^{1+\left\lceil\log_2 12N^{\mathrm{RB}}_{\mathrm{DL}}\right\rceil$</text> +<path matrix="1 0 0 1 -1.80008 -19" fill="lightgray"> +0 296 m +0 264 l +736 264 l +736 296 l +h +</path> +<text matrix="1 0 0 1 -70.8001 -26" transformations="translations" pos="68 284" stroke="black" type="label" width="569.174" height="10.1688" depth="5.904" valign="baseline" size="small">\tiny$\mathbf{r}_{839,r}=\mathrm{IDFT}_{1024}\left(\mathbf{R}_{\mathrm{comp},r}\right), r=0,1,\cdots,R-1$ (\tt\bf lte\_eNB\_prach\_vars$\rightarrow$prach\_ifft[])</text> +<path matrix="1 0 0 1 -61 -2" fill="lightblue"> +112 460 m +112 400 l +176 400 l +176 460 l +h +</path> +<text matrix="1 0 0 1 -25 -8" transformations="translations" pos="28 468" stroke="black" type="label" width="19.922" height="6.216" depth="2.772" valign="baseline">\tiny $\mathbf{r}_{r}$</text> +<path matrix="1 0 0 1 -127.121 -8" stroke="black" arrow="normal/tiny"> +144 440 m +176 440 l +</path> +<text matrix="1 0 0 1 -54 -2" transformations="translations" pos="112 439.386" stroke="black" type="minipage" width="64" height="14.2992" depth="2.304" valign="top" size="small">DFT</text> +<text matrix="1 0 0 1 95 -8" transformations="translations" pos="28 468" stroke="black" type="label" width="26.6224" height="9.5872" depth="2.772" valign="baseline">\tiny $\mathbf{R}_{r}$</text> +<path matrix="1 0 0 1 -61 -66" fill="lightcyan"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<text matrix="1 0 0 1 -55 -64" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="32" height="13.9488" depth="1.992" valign="top" size="small">$\odot$</text> +<path matrix="1 0 0 1 -61 -1" stroke="black" arrow="normal/tiny"> +176 428 m +208 428 l +208 456 l +268 456 l +</path> +<path matrix="1 0 0 1 -61 0" stroke="black" arrow="normal/tiny"> +208 428 m +208 400 l +268 400 l +</path> +<text matrix="1 0 0 1 187 16" transformations="translations" pos="28 468" stroke="black" type="label" width="53.3344" height="12.124" depth="5.572" valign="baseline">\tiny $\mathbf{X}^*_{u}(0)$</text> +<text matrix="1 0 0 1 187 -112" transformations="translations" pos="28 468" stroke="black" type="label" width="53.3344" height="12.124" depth="5.572" valign="baseline">\tiny $\mathbf{X}^*_{u}(1)$</text> +<path matrix="1 0 0 1 -61 0" stroke="black" arrow="normal/tiny"> +284 480 m +284 468 l +</path> +<path matrix="1 0 0 1 -61 0" stroke="black" arrow="normal/tiny"> +284 372 m +284 384 l +</path> +<path matrix="2.375 0 0 1.25 -361.5 -125" fill="lightgray"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<text matrix="1 0 0 1 11 -1" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="32" height="19.0224" depth="7.08" valign="top" size="small">\tiny$R\times\mathrm{IDFT}_{1024}$</text> +<path matrix="1 0 0 1 -61 0" stroke="black" arrow="normal/tiny"> +300 456 m +336 456 l +</path> +<path matrix="1 0 0 1 -61 -56" stroke="black" arrow="normal/tiny"> +300 456 m +336 456 l +</path> +<path matrix="2.375 0 0 1.25 -361.5 -181" fill="lightgray"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<text matrix="1 0 0 1 11 -57" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="32" height="19.0224" depth="7.08" valign="top" size="small">\tiny$R\times\mathrm{IDFT}_{1024}$</text> +<group matrix="1 0 0 1 -73 -1"> +<path matrix="1.88154 0 0 1 -53.5314 -8" stroke="black"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<group> +<group> +<text matrix="1 0 0 1 183 -6" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="64" height="14.3376" depth="2.376" valign="top" size="small">\tiny$\sum_{r}|\cdot|^2$</text> +</group> +</group> +</group> +<group matrix="1 0 0 1 -73 -57"> +<path matrix="1.88154 0 0 1 -53.5314 -8" stroke="black"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<group> +<group> +<text matrix="1 0 0 1 183 -6" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="64" height="14.3376" depth="2.376" valign="top" size="small">\tiny$\sum_{r}|\cdot|^2$</text> +</group> +</group> +</group> +<group matrix="1 0 0 1 -61 10"> +<path matrix="2.84167 0 0 1.68966 -230.567 -338.034" stroke="black"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<text matrix="1 0 0 1 263 -6" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="92" height="25.6392" depth="13.68" valign="top" size="small">\tiny max peak in size $\mathrm{NCS}_2$ window, keep delay</text> +</group> +<path matrix="1 0 0 1 -61 0" stroke="black" arrow="normal/tiny"> +412 456 m +440 456 l +</path> +<path matrix="1 0 0 1 -61 0" stroke="black" arrow="normal/tiny"> +412 400 m +440 400 l +</path> +<path matrix="1 0 0 1 -61 -3" stroke="black" arrow="normal/tiny"> +500 460 m +532 460 l +</path> +<path matrix="1 0 0 1 -61 -3" stroke="black" arrow="normal/tiny"> +500 460 m +532 460 l +</path> +<path matrix="1 0 0 1 -61 -59" stroke="black" arrow="normal/tiny"> +500 460 m +532 460 l +</path> +<path matrix="1 0 0 1 -61 1" stroke="black" arrow="normal/tiny"> +624 456 m +672 456 l +</path> +<path matrix="1 0 0 1 -61 -55" stroke="black" arrow="normal/tiny"> +624 456 m +672 456 l +</path> +<path matrix="2.84167 0 0 1.68966 -291.567 -384.034" stroke="black"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<text matrix="1 0 0 1 202 -52" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="92" height="25.6392" depth="13.68" valign="top" size="small">\tiny max peak in size $\mathrm{NCS}_2$ window, keep delay</text> +<text matrix="1 0 0 1 322 -20" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="92" height="21.6528" depth="9.696" valign="top" size="small">\tiny\tt preamble\_energy\_list[]\par preamble\_delay\_list[]</text> +<text matrix="1 0 0 1 311 -104" transformations="translations" pos="28 468" stroke="black" type="label" width="54.7904" height="6.2076" depth="6.888" valign="baseline">\tiny $\mathbf{r}_{839,r}$</text> +<text transformations="translations" pos="16 224" stroke="black" type="minipage" width="700" height="104.215" depth="92.448" valign="top" size="small">\small\begin{itemize} +\item PRACH detection is a quasi-optimal non-coherent receiver for vector observations (multiple antennas) +\item correlation is done in the frequency-domain, number of correlations (in the example above 2) depends on {\em zeroCorrelationConfig} configuration parameter +\item peak-detection (for delay estimation) is performed in each NCS time-window +\end{itemize}</text> +<group> +<path matrix="1 0 0 1 -61 -12" fill="lightcyan"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<text matrix="1 0 0 1 -55 -10" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="32" height="13.9488" depth="1.992" valign="top" size="small">$\odot$</text> +</group> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" fill="lightgreen"> +340 416 m +340 340 l +564 340 l +564 416 l +h +</path> +<path matrix="6.93939 0 0 1 -1513.76 -18" fill="lightcyan"> +268 480 m +268 452 l +300 452 l +300 480 l +h +</path> +<text matrix="1 0 0 1 145 -13" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="92" height="15.5088" depth="3.528" valign="top" size="small">\tiny$\sum_{r,l,i}|\cdot|^2$</text> +<text matrix="1 0 0 1 171 101" transformations="translations" pos="301.598 362.627" stroke="black" type="minipage" width="115.562" height="19.572" depth="5.628" halign="center" valign="top" style="center">\begin{tiny}$\stackbin{<}{>}\sigma^2[\mathrm{dB}]$\end{tiny}</text> +<text matrix="1 0 0 1 199 0" transformations="translations" pos="176 556" stroke="black" type="label" width="288.215" height="19.3704" depth="0" halign="center" valign="baseline">eNB PUCCH1 Detection</text> +<path matrix="1 0 0 1 31 336" stroke="black" fill="1"> +184 128 m +184 100 l +276 100 l +276 128 l +h +</path> +<text matrix="1 0 0 1 87.0006 9" transformations="translations" pos="128 440" stroke="black" type="minipage" width="96" height="16.3128" depth="4.344" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny rx\_pucch()\par36.211</text> +<path matrix="1 0 0 1 -48 244" stroke="black" fill="lightblue"> +153 232 m +153 176 l +228 176 l +228 232 l +h +</path> +<text matrix="1 0 0 1 -22.9994 8" transformations="translations" pos="128 440" stroke="black" type="minipage" width="76" height="15.8184" depth="3.84" valign="center" size="small" style="center">\setstretch{.5}\tt\tiny slot\_fep\_ul\par36.211</text> +<path matrix="1 0 0 1 36 12" stroke="black" arrow="normal/tiny"> +144 440 m +176 440 l +</path> +<path matrix="1 0 0 1 -72 8" stroke="black" arrow="normal/tiny"> +144 440 m +176 440 l +</path> +<text matrix="1 0 0 1 36 12" transformations="translations" pos="28 468" stroke="black" type="label" width="32.0432" height="6.2048" depth="7.588" valign="baseline">\tiny $\mathbf{r}_{r,l}$</text> +<text matrix="1 0 0 1 164 16" transformations="translations" pos="28 468" stroke="black" type="label" width="38.7464" height="9.576" depth="7.588" valign="baseline">\tiny $\mathbf{R}_{r,l}$</text> +<text matrix="1 0 0 1 252 22" transformations="translations" pos="28 468" stroke="black" type="label" width="229.617" height="16.1084" depth="6.748" valign="baseline">\tiny $\mathbf{Z}^*_{l}e^{-j2\pi f/16},-3\leq f\leq 2$</text> +<path stroke="black" arrow="normal/tiny"> +308 448 m +352 448 l +</path> +<text matrix="1 0 0 1 84 -16" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="32" height="13.9488" depth="1.992" valign="top" size="small">$\odot$</text> +<path matrix="1 0 0 1 63 2" stroke="black" arrow="normal/tiny"> +308 448 m +352 448 l +</path> +<path matrix="1 0 0 1 -31 0" stroke="black" arrow="normal/tiny"> +392 484 m +392 456 l +</path> +<path stroke="black" arrow="normal/tiny"> +328 448 m +328 400 l +352 400 l +</path> +<text matrix="1 0 0 1 83 -64" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="32" height="13.9488" depth="1.992" valign="top" size="small">$\odot$</text> +<path matrix="1 0 0 1 -31 -93" stroke="black" rarrow="normal/tiny"> +392 484 m +392 456 l +</path> +<text matrix="1 0 0 1 321 -116" transformations="translations" pos="28 468" stroke="black" type="label" width="24.486" height="12.138" depth="6.748" valign="baseline">\tiny $\mathbf{Z}^*_{l}$</text> +<path stroke="black"> +288 496 m +288 496 l +288 496 l +288 496 l +h +</path> +<path matrix="1 0 0 1 60 -48" stroke="black" arrow="normal/tiny"> +308 448 m +352 448 l +</path> +<path matrix="0.307692 0 0 1 285.231 0" stroke="black"> +412 408 m +412 392 l +464 392 l +464 408 l +h +</path> +<text transformations="translations" pos="412 408" stroke="black" type="minipage" width="52" height="11.5728" depth="0" valign="top" size="small">\tiny$\mathbf{\hat{H}}$</text> +<text matrix="1 0 0 1 143 -96" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="32" height="13.9488" depth="1.992" valign="top" size="small">$\odot$</text> +<path stroke="black" arrow="normal/tiny"> +420 392 m +420 376 l +</path> +<path stroke="black" arrow="normal/tiny"> +384 400 m +384 368 l +412 368 l +</path> +<path stroke="black" arrow="normal/tiny"> +428 368 m +464 368 l +</path> +<text matrix="1 0 0 1 201 -93" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="92" height="11.9544" depth="0" valign="top" size="small">\tiny$\mathrm{sgn}(\mathrm{Re}(\cdot))$</text> +<path stroke="black" arrow="normal/tiny"> +444 368 m +444 352 l +464 352 l +</path> +<text matrix="1 0 0 1 201 -109" transformations="translations" pos="268 471.863" stroke="black" type="minipage" width="92" height="11.9544" depth="0" valign="top" size="small">\tiny$\mathrm{sgn}(\mathrm{Im}(\cdot))$</text> +<path stroke="black"> +532 408 m +532 408 l +532 408 l +532 408 l +h +</path> +<text matrix="1 0 0 1 0 -6" transformations="translations" pos="432 472" stroke="black" type="label" width="165.809" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny PUCCH1 (Scheduling Request)</text> +<text matrix="1 0 0 1 0 -54" transformations="translations" pos="432 472" stroke="black" type="label" width="145.519" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny PUCCH1a/1b (ACK/NAK)</text> +<text matrix="1 0 0 1 24 92" transformations="translations" pos="16 224" stroke="black" type="minipage" width="700" height="93.756" depth="81.984" valign="top" size="small">\small\begin{itemize} +\item PUCCH1 detection is a quasi-optimal non-coherent receiver (energy detector) for vector observations (multiple antennas) for scheduling request. Care is taken to handle residual frequency-offset. +\item PUCCH1A/1B detection is quasi-coherent based on a rough channel estimate obtained on the 3 symbols without data modulation. \item In both cases, correlation is done in the frequency-domain +\end{itemize}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 -512 62" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="265.102" depth="253.752" valign="top" size="small">\small\begin{itemize} +\item Threads (all in {\tt targets/RT/USER/lte-ru.c}) +\begin{itemize} +\item {\tt ru\_thread}: Thread per RU which sequentially +performs +\begin{itemize} +\item read from south interface (RF or IF fronthaul) +\item RX processing for subframe $n$ (if necessary). +\item wakeup eNBs that are waiting for signal (if necessary) +\item wait for eNB task completion (if necessary) +\item do TX processing for subframe $n+4$ (if necessary). Note that this can spawn multiple worker threads for very high order spatial processing (e.g. massive-MIMO or DAS for UDN) +\item do outgoing fronthaul (RF or IF fronthaul) +\end{itemize} +\item {\tt ru\_thread\_prach}: Thread for PRACH processing in remote RU (DFT on RX, IF4p5 RRU) +\item {\tt ru\_thread\_asynch}: Thread for asynchronous reception from fronthaul interface (TX direction in RRU). %Allows for some jitter so as not to block the RRU real-time processing. +\end{itemize} +\item Synchronization on fronthaul interface +\begin{itemize} +\item {\em synch\_to\_ext\_device} : synchronizes to incoming samples from RF or Fronthaul interface using blocking read +\item {\em synch\_to\_other} : synchronizes via POSIX mechanism to other source (other CC, timer) which maintains real-time. +\end{itemize} +\end{itemize} </text> +<text matrix="1 0 0 1 201 -17" transformations="translations" pos="176 556" stroke="black" type="label" width="140.33" height="19.3704" depth="0" halign="center" valign="baseline">RU Threads</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 -512 78" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="166.006" depth="154.392" valign="top" size="small">\small\begin{itemize} +\item Threads (all in {\tt targets/RT/USER/lte-enb.c}) +\begin{itemize} +\item multi RX/TX thread mode (optional) +\begin{itemize} +\item {\tt eNB\_thread\_rxtx}: 2 threads per CC/Instance which do both RX procedures for subframe $n$ and TX procedures for subframe $n+4$. One operates on even subframes, one on odd. This allows 1ms subframe processing to use multiple-cores. +\end{itemize} +\item common RU-eNB RX/TX thread (default if single RU/eNB) +\begin{itemize} +\item calls {\tt eNB\_top}: procedure per CC/Instance which sequentially +\begin{itemize} +\item blocks on signal from RU +\item RX/TX processing for subframe $n$ and $n+4$ +\item signals completion to RU +\end{itemize} +\end{itemize} +\item {\tt eNB\_prach}: Thread per CC\_id/Instance for PRACH processing +\end{itemize} +\end{itemize} </text> +<text matrix="1 0 0 1 201 -1" transformations="translations" pos="176 556" stroke="black" type="label" width="153.891" height="19.3704" depth="0" halign="center" valign="baseline">eNB Threads</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 64 0" stroke="white" fill="lightblue"> +400 400 m +400 388 l +520 388 l +520 400 l +h +</path> +<path matrix="1 0 0 1 64 0" fill="lightgreen"> +400 432 m +400 420 l +520 420 l +520 432 l +h +</path> +<path matrix="0.46875 0 0 1 336.5 0" fill="pink"> +400 448 m +400 436 l +528 436 l +528 448 l +h +</path> +<path matrix="0.46875 0 0 1 276.5 0" fill="lightyellow"> +400 448 m +400 436 l +528 436 l +528 448 l +h +</path> +<path matrix="0.7 0 0 0.5 -7.4 198" fill="lightblue"> +192 388 m +192 364 l +272 364 l +272 388 l +h +</path> +<path matrix="0.15 0 0 1 107.2 -28" stroke="black" fill="lightgreen"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 183 0" transformations="translations" pos="176 556" stroke="black" type="label" width="390.382" height="20.9244" depth="6.972" halign="center" valign="baseline">eNB Timing (multi-thread mode)</text> +<path matrix="1 0 0 1 80 0" stroke="black"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 80 0" transformations="translations" pos="32 480" stroke="black" type="minipage" width="80" height="11.124" depth="0" valign="top" size="small">\tiny SF $n+1$</text> +<path matrix="1 0 0 1 160 0" stroke="black"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 160 0" transformations="translations" pos="32 480" stroke="black" type="minipage" width="80" height="11.124" depth="0" valign="top" size="small">\tiny SF $n+2$</text> +<path matrix="1 0 0 1 240 0" stroke="black"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 240 0" transformations="translations" pos="32 480" stroke="black" type="minipage" width="80" height="11.124" depth="0" valign="top" size="small">\tiny SF $n+3$</text> +<text matrix="0.15 0 0 0.5 107.2 207" transformations="translations" pos="32 480" stroke="black" type="minipage" width="12" height="8.5512" depth="0" valign="top" size="small">\tiny $n$</text> +<path matrix="0.493671 0 0 1 167.203 -28" stroke="black" fill="pink"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 151 -30" transformations="translations" pos="32 480" stroke="black" type="minipage" width="40" height="10.9584" depth="0" valign="top" size="small">\tiny$n+4$</text> +<path matrix="1 0 0 1 320 0" stroke="black"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 320 0" transformations="translations" pos="32 480" stroke="black" type="minipage" width="80" height="11.124" depth="0" valign="top" size="small">\tiny SF $n+4$</text> +<path stroke="red" arrow="normal/tiny"> +32 480 m +212 572 +352 480 c +</path> +<path stroke="black" cap="1"> +384 464 m +384 464 l +</path> +<path stroke="black" cap="1"> +380 472 m +380 472 l +</path> +<text matrix="1 0 0 1 -16 0" transformations="translations" pos="32 364" stroke="black" type="minipage" width="704" height="72.0944" depth="58.24" valign="top">\tiny\begin{itemize} +\item The current processing requires approximately 1ms peak in each direction (basically 1 core RX, 1core TX). The current architecture will work on a single core if the sum of RX and TX procedures is limited to 1ms. It can fit on 2 cores if the sum of RX,TX and PRACH is less than 2ms. +\item three threads, RX-TX even, RX-TX odd and PRACH. RX-TX blocks until woken by the RU thread with a new RX subframe $n$ that is linked to this eNB process. The RX-TX thread performs ue-specific processing for subframe $n$ and then TX common and ue-specific processing for subframe $n+4$ (frequency-domain generation only). This insures the data dependency between TX $n+4$ and RX $n$ is respected. The duration of this thread should be less than 2ms which can compensate some jitter on the RX processing. +\end{itemize}</text> +<path stroke="black"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text transformations="translations" pos="32 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny SF $n$</text> +<text transformations="translations" pos="328 512" stroke="red" type="label" width="270.986" height="8.9784" depth="2.976" valign="baseline" size="small">\tiny LTE HARQ periodicity (FDD, TDD can be longer)</text> +<text matrix="1 0 0 1 96 -88" transformations="translations" pos="32 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny PRACH $n$</text> +<path matrix="0.7 0 0 1 103.6 -28" stroke="black" fill="lightyellow"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<path matrix="0.15 0 0 1 187.2 -64" stroke="black" fill="lightgreen"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="0.15 0 0 0.5 191.2 153" transformations="translations" pos="32 480" stroke="black" type="minipage" width="68" height="10.9584" depth="0" valign="top" size="small">\tiny $n+1$</text> +<text matrix="0.15 0 0 0.5 121.2 207" transformations="translations" pos="32 480" stroke="black" type="minipage" width="12" height="8.5512" depth="0" valign="top" size="small">\tiny $n$</text> +<path matrix="0.493671 0 0 1 249.203 -64" stroke="black" fill="pink"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 233 -66" transformations="translations" pos="32 480" stroke="black" type="minipage" width="40" height="10.9584" depth="0" valign="top" size="small">\tiny$n+5$</text> +<path matrix="0.7 0 0 1 185.6 -64" stroke="black" fill="lightyellow"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="0.15 0 0 0.5 203.2 173" transformations="translations" pos="32 480" stroke="black" type="minipage" width="32" height="10.9584" depth="0" valign="top" size="small">\tiny $n+1$</text> +<path stroke="black" arrow="normal/tiny"> +124 424 m +172 416 +152 392 c +</path> +<path stroke="black" arrow="normal/tiny"> +204 424 m +228 424 +236 416 c +</path> +<path matrix="1 0 0 1 0 -12" stroke="black" arrow="normal/tiny"> +192 396 m +196 416 l +</path> +<path matrix="0.15 0 0 1 27.2 -64" stroke="black" fill="lightgreen"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="0.15 0 0 0.5 31.2 153" transformations="translations" pos="32 480" stroke="black" type="minipage" width="68" height="10.9584" depth="0" valign="top" size="small">\tiny $n-1$</text> +<path matrix="0.493671 0 0 1 89.203 -64" stroke="black" fill="pink"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 73 -66" transformations="translations" pos="32 480" stroke="black" type="minipage" width="40" height="10.9584" depth="0" valign="top" size="small">\tiny$n+3$</text> +<path matrix="0.7 0 0 1 25.6 -64" stroke="black" fill="lightyellow"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="0.15 0 0 0.5 43.2 173" transformations="translations" pos="32 480" stroke="black" type="minipage" width="32" height="10.9584" depth="0" valign="top" size="small">\tiny $n-1$</text> +<path matrix="0.7 0 0 1 267.6 -28" stroke="black" fill="lightyellow"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="0.15 0 0 0.5 285.2 209" transformations="translations" pos="32 480" stroke="black" type="minipage" width="56" height="10.9584" depth="0" valign="top" size="small">\tiny $n+2$</text> +<path matrix="0.493671 0 0 1 329.203 -28" stroke="black" fill="pink"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<text matrix="1 0 0 1 313 -30" transformations="translations" pos="32 480" stroke="black" type="minipage" width="40" height="10.9584" depth="0" valign="top" size="small">\tiny$n+6$</text> +<path matrix="0.15 0 0 1 271.2 -28" stroke="black" fill="lightgreen"> +32 480 m +32 464 l +112 464 l +112 480 l +h +</path> +<path stroke="black" arrow="normal/tiny"> +284 424 m +308 424 +316 436 c +</path> +<text matrix="0.15 0 0 0.5 229.2 221" transformations="translations" pos="32 480" stroke="black" type="minipage" width="68" height="10.9584" depth="0" valign="top" size="small">\tiny $n+2$</text> +<path matrix="1 0 0 1 7 6" stroke="black" arrow="normal/tiny"> +268 452 m +276 436 l +</path> +<text matrix="1 0 0 1 63 0" transformations="translations" pos="400 432" stroke="black" type="minipage" width="144" height="10.128" depth="0" valign="top" size="small">\tiny RU thread</text> +<text matrix="1 0 0 1 63 16" transformations="translations" pos="400 432" stroke="black" type="minipage" width="144" height="11.9544" depth="0" valign="top" size="small">\tiny RX-TX thread (even)</text> +<path matrix="0.46875 0 0 1 336.5 -32" fill="pink"> +400 448 m +400 436 l +528 436 l +528 448 l +h +</path> +<path matrix="0.46875 0 0 1 276.5 -32" fill="lightyellow"> +400 448 m +400 436 l +528 436 l +528 448 l +h +</path> +<text matrix="1 0 0 1 63 -16" transformations="translations" pos="400 432" stroke="black" type="minipage" width="144" height="11.9544" depth="0" valign="top" size="small">\tiny RX-TX thread (odd)</text> +<text matrix="1 0 0 1 432 -80" transformations="translations" pos="32 480" stroke="black" type="minipage" width="80" height="10.128" depth="0" valign="top" size="small">\tiny PRACH</text> +<path matrix="1 0 0 1 -160 -12" stroke="black" arrow="normal/tiny"> +192 396 m +196 416 l +</path> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 111 -311" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<path matrix="1 0 0 1 95 -303" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<path matrix="1 0 0 1 87 -295" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<path matrix="1 0 0 1 86 68" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<path matrix="0.232141 0 0 0.927995 612.286 93.6201" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<path matrix="0.573927 0 0 0.908562 397.291 100.149" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<path matrix="1 0 0 0.673921 67.8375 132.347" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="1 0 0 1 161 7" transformations="translations" pos="176 556" stroke="black" type="label" width="412" height="20.9244" depth="6.972" halign="center" valign="baseline">OAI IF1'' Interface (can be NFAPI)</text> +<text matrix="1 0 0 1 -512 63" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="37.2932" depth="23.38" valign="top">\tiny\begin{itemize} +\item OAI IF1'' is the interface between the 36.321 Medium-Access (MAC) Layer Procedures and the 36.213 Physical Layer Procedures. It links several PHY instances to one MAC instance. +\item It is a configurable (dynamically loadable) module which can implement an (N)FAPI P5/P7 or a simpler interface. +\end{itemize} </text> +<path matrix="0.441741 0 0 0.919575 158.74 96.2351" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<text matrix="1 0 0 1 -372.87 383.775" pos="596 32" stroke="black" type="label" width="83.256" height="8.3016" depth="0" valign="baseline" size="small">\tiny Random-Access</text> +<text matrix="1 0 0 1 54.4342 383.743" pos="596 32" stroke="black" type="label" width="35.1312" height="8.3016" depth="0" valign="baseline" size="small">\tiny Events</text> +<text matrix="1 0 0 1 -216.173 19.612" pos="596 32" stroke="black" type="label" width="150.346" height="14.952" depth="4.176" valign="baseline" size="small">\small PHY procedures</text> +<text matrix="0 1 -1 0 266.848 -324.389" pos="596 32" stroke="black" type="label" width="110.765" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt initiate\_ra\_proc()}</text> +<text matrix="0 1 -1 0 290.621 -330.742" pos="596 32" stroke="black" type="label" width="117.118" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt terminate\_ra\_proc()}</text> +<text matrix="0 1 -1 0 314.394 -311.688" pos="596 32" stroke="black" type="label" width="98.064" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt cancel\_ra\_proc()}</text> +<text matrix="0 1 -1 0 367.94 -349.796" pos="596 32" stroke="black" type="label" width="136.171" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_config\_dedicated()}</text> +<text matrix="0 1 -1 0 412.713 -318.039" pos="596 32" stroke="black" type="label" width="104.414" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_config\_sib1()}</text> +<text matrix="0 1 -1 0 436.486 -318.039" pos="596 32" stroke="black" type="label" width="104.414" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_config\_sib2()}</text> +<text matrix="0 1 -1 0 460.259 -324.389" pos="596 32" stroke="black" type="label" width="110.765" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_config\_sib13()}</text> +<path matrix="1 0 0 0.673921 91.6108 132.064" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.673921 115.384 132.064" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.673921 168.93 132.064" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.673921 213.703 132.064" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.673921 237.476 132.064" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.673921 261.249 132.064" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.673921 302.346 132.064" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 501.848 -379.774" pos="596 32" stroke="black" type="label" width="166.15" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt eNB\_dlsch\_ulsch\_scheduler()}</text> +<text matrix="0 1 -1 0 524.637 -298.985" pos="596 32" stroke="black" type="label" width="85.3608" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt get\_dcii\_sdu()}</text> +<path matrix="1 0 0 0.673921 325.134 132.678" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 548.251 -305.336" pos="596 32" stroke="black" type="label" width="91.7112" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt get\_dlsch\_sdu()}</text> +<path matrix="1 0 0 0.673921 347.923 132.69" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 570.214 -262.656" pos="596 32" stroke="black" type="label" width="49.032" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt rx\_sdu()}</text> +<path matrix="1 0 0 0.673921 370.711 132.757" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 593.002 -292.635" pos="596 32" stroke="black" type="label" width="79.0104" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt get\_mch\_sdu()}</text> +<path matrix="1 0 0 0.673921 393.5 132.624" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="0 1 -1 0 701.156 -307.114" pos="596 32" stroke="black" type="label" width="93.4896" height="8.3136" depth="0.984" valign="baseline" size="small">\tiny {\tt SR\_indication()}</text> +<path matrix="1 0 0 0.673921 501.654 133.147" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="0.494718 0 0 0.92251 268.305 95.0367" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<text matrix="1 0 0 1 -248.565 384.751" pos="596 32" stroke="black" type="label" width="63.9696" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny PHY Config</text> +<text matrix="1 0 0 1 -92.464 384.743" pos="596 32" stroke="black" type="label" width="56.9952" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny Scheduling</text> +<text matrix="1 0 0 1 0 -16" transformations="translations" pos="0 416" stroke="black" type="minipage" width="224" height="28.9872" depth="17.04" valign="top" size="small">\small {\tt 36.213/36.321}\\ +{\tt openair2/LAYER2/MAC}</text> +<text matrix="1 0 0 1 23 -384" transformations="translations" pos="0 448" stroke="black" type="minipage" width="152" height="28.9872" depth="17.04" valign="top" size="small">\small {\tt 36.211/212}\par +{\tt openair1/PHY}</text> +<path matrix="1 0 0 1 87 -167" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<text matrix="1 0 0 1 -216.173 147.612" pos="596 32" stroke="black" type="label" width="178.164" height="14.9448" depth="0" valign="baseline" size="small">\small OAI MAC interface</text> +<text matrix="0 1 -1 0 391.713 -312.039" pos="596 32" stroke="black" type="label" width="98.064" height="8.3184" depth="2.64" valign="baseline" size="small">\tiny {\tt phy\_config\_mib()}</text> +<path matrix="1 0 0 0.673921 192.703 132.064" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.250151 84.8376 58.5896" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.250151 221.838 58.5896" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.250151 756.838 -125.41" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="1 0 0 0.250151 348.838 58.5896" stroke="black" fill="lightgray" arrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<text matrix="1 0 0 1 -333.87 87.775" pos="596 32" stroke="black" type="label" width="125.146" height="14.9448" depth="0" valign="baseline" size="small">\small UL-Indication</text> +<text matrix="1 0 0 1 -194.87 87.775" pos="596 32" stroke="black" type="label" width="102.482" height="14.952" depth="4.176" valign="baseline" size="small">\small Config-Req</text> +<text matrix="1 0 0 1 -69.87 87.775" pos="596 32" stroke="black" type="label" width="132.761" height="14.952" depth="4.176" valign="baseline" size="small">\small Schedule-Resp</text> +<text matrix="1 0 0 1 -53 0" transformations="translations" pos="104 232" stroke="black" type="minipage" width="216" height="11.816" depth="0" valign="top">\tiny Northbound interface</text> +<text matrix="1 0 0 1 -53 -80" transformations="translations" pos="104 232" stroke="black" type="minipage" width="216" height="11.816" depth="0" valign="top">\tiny Southbound interface</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 161 7" transformations="translations" pos="176 556" stroke="black" type="label" width="217.12" height="19.3704" depth="0" halign="center" valign="baseline">OAI IF1'' Interface</text> +<text matrix="1 0 0 2.62963 -511 -694.148" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="229.141" depth="215.712" valign="top">\tiny\begin{itemize} +\item The PHY end uses three basic messages +\begin{itemize} +\item {\tt CONFIG\_REQ}: this provides the cell configuration and UE-specific configuration to the PHY instances. This comprises the following FAPI P5/P7 messages +\begin{enumerate} +\item CONFIG.request +\item UE\_CONFIG.request (**not used in OAI PHY) +\end{enumerate} +\item {\tt UL\_INDICATION} This is an uplink indication that sends all UL information received in one TTI, including PRACH, if available. It also provides the subframe indication for the DL scheduler. It maps to the following FAPI P7 messages +\begin{enumerate} +\item {\tt SUBFRAME.indication} +\item {\tt HARQ.indication} +\item {\tt CRC.indication } +\item {\tt RX\_ULSCH.indication} +\item {\tt RX\_SR.indication} +\item {\tt RX\_CQI.indication} +\item {\tt RACH.indication} +\item {\tt SRS.indication} +\end{enumerate} +\item {\tt SCHEDULE\_REQUEST} This message contains the scheduling response information and comprises the following FAPI P7 messages +\begin{enumerate} +\item {\tt DL\_CONFIG.request} +\item {\tt UL\_CONFIG.request} +\item {\tt TX.request} +\item {\tt HI\_DCI0.request} +\end{enumerate} +\end{itemize} +\item The module is registered both by PHY and MAC and can implement different types of transport (NFAPI, function call, FAPI over UDP, etc.). During registration, fuction pointers for the different messages are provided for the module to interact with either PHY or MAC or both if they are executing in the same machine. Note that for a networked implementation (e.g. NFAPI), there are north and south components running in different machines. +\end{itemize} </text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 161 7" transformations="translations" pos="176 556" stroke="black" type="label" width="217.12" height="19.3704" depth="0" halign="center" valign="baseline">OAI IF1'' Interface</text> +<text matrix="1 0 0 2.62963 -511 -694.148" transformations="translations" pos="512 464" stroke="black" type="minipage" width="732" height="261.064" depth="247.716" valign="top">\small\begin{itemize} +\item The PHY-layer timing is assumed to be +\begin{enumerate} +\item wait for subframe indication $n$ from HW +\item trigger PRACH if $n$ has PRACH (parallel thread) +\item trigger UE specific RX procedures for $n$ if $n$ is UL +\item assemble {\tt UL\_INDICATION} and send to MAC +\item wait for {\tt SCHEDULE\_REQUEST} +\item do TX procedures if $n+4$ is TX and RX programming if $n+4+k$ is UL +\end{enumerate} +\item The MAC-layer timing is assumed to be +\begin{enumerate} +\item do all UL processing for subframe $n$ if $n$ is UL after unraveling of UL\_INDICATION in MAC module +\item wait for call to {\tt eNB\_dlsch\_ulsch\_scheduler} +\item do DL scheduling for $n+4$ if it is DL +\item do UL scheduling for $n+8$ if it is UL +\item return from eNB\_dlsch\_ulsch\_scheduler +\item let MAC module form SCHEDULE\_REQUEST +\end{enumerate} +\end{itemize} </text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1 0 0 1 86 -220" stroke="black" fill="lightgray"> +96 384 m +96 320 l +640 320 l +640 384 l +h +</path> +<path matrix="0.232141 0 0 0.927995 612.286 -194.38" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<path matrix="0.573927 0 0 0.908562 397.291 -187.851" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<text matrix="1 0 0 1 161 7" transformations="translations" pos="176 556" stroke="black" type="label" width="115.455" height="19.3704" depth="0" halign="center" valign="baseline">OAI MAC</text> +<path matrix="0.441741 0 0 0.919575 158.74 -191.765" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<text matrix="1 0 0 1 -372.87 95.775" pos="596 32" stroke="black" type="label" width="83.256" height="8.3016" depth="0" valign="baseline" size="small">\tiny Random-Access</text> +<text matrix="1 0 0 1 54.4342 95.743" pos="596 32" stroke="black" type="label" width="35.1312" height="8.3016" depth="0" valign="baseline" size="small">\tiny Events</text> +<path matrix="0.494718 0 0 0.92251 268.305 -192.963" stroke="black" fill="1"> +128 368 m +128 336 l +352 336 l +352 368 l +h +</path> +<text matrix="1 0 0 1 -248.565 96.751" pos="596 32" stroke="black" type="label" width="63.9696" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny PHY Config</text> +<text matrix="1 0 0 1 -92.464 96.743" pos="596 32" stroke="black" type="label" width="56.9952" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny Scheduling</text> +<text matrix="1 0 0 1 16 -368" transformations="translations" pos="0 416" stroke="black" type="minipage" width="224" height="28.0824" depth="16.152" valign="top" size="small">\small {\tt 36.321}\\ +{\tt openair2/LAYER2/MAC}</text> +<path matrix="1 0 0 0.250151 756.838 -125.41" stroke="black" fill="lightgray" rarrow="normal/small"> +175.695 380 m +176.42 128 l +</path> +<path matrix="0.5 0 0 1 241 0" stroke="black"> +176 496 m +176 384 l +400 384 l +400 496 l +h +</path> +<path matrix="1 0 0 1 320 0" stroke="black"> +176 496 m +176 384 l +400 384 l +400 496 l +h +</path> +<text matrix="1 0 0 1 -228.87 399.775" pos="596 32" stroke="black" type="label" width="42.7896" height="14.9448" depth="0" valign="baseline" size="small">\small RRC</text> +<path stroke="black" arrow="normal/normal" rarrow="normal/normal"> +384 384 m +272 144 l +</path> +<path stroke="black" arrow="normal/normal" rarrow="normal/normal"> +384 384 m +384 144 l +</path> +<path stroke="black" arrow="normal/normal" rarrow="normal/normal"> +384 384 m +528 144 l +</path> +<path stroke="black" arrow="normal/normal" rarrow="normal/normal"> +608 384 m +528 144 l +</path> +<text matrix="1 0 0 1 -4.87 399.775" pos="596 32" stroke="black" type="label" width="40.5144" height="14.9448" depth="0" valign="baseline" size="small">\small RLC</text> +<path matrix="1 0 0 1 -128 -128" stroke="black"> +176 496 m +176 384 l +400 384 l +400 496 l +h +</path> +<text matrix="1 0 0 1 -495.87 271.775" pos="596 32" stroke="black" type="label" width="116.184" height="14.952" depth="4.176" valign="baseline" size="small">\small Preprocessor</text> +<path stroke="black" arrow="normal/normal" rarrow="normal/normal"> +160 256 m +528 144 l +</path> +<path stroke="black" arrow="normal/normal" rarrow="normal/normal"> +272 312 m +608 384 l +</path> +<path stroke="black" pen="heavier"> +472 504 m +472 232 l +152 232 l +152 40 l +728 40 l +736 40 l +736 504 l +h +</path> +<text matrix="1 0 0 1 504 72" transformations="translations" pos="0 416" stroke="black" type="minipage" width="224" height="28.0824" depth="16.152" valign="top" size="small">\small {\tt 36.322}\\ +{\tt openair2/LAYER2/RLC}</text> +<text matrix="1 0 0 1 32 0" transformations="translations" pos="0 416" stroke="black" type="minipage" width="224" height="28.0824" depth="16.152" valign="top" size="small">\small {\tt user customizable scheduling module}</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 199 -16" transformations="translations" pos="176 556" stroke="black" type="label" width="163.19" height="19.3928" depth="5.404" halign="center" valign="baseline">TX Precoding</text> +<text matrix="1 0 0 1 0 12" transformations="translations" pos="16 512" stroke="black" type="minipage" width="704" height="162.125" depth="150.504" valign="top" size="small">\small\begin{itemize} +\item Spatio-temporal filtering for muli-cell (vCell) and multi-user transmission. Input and output are frequency-domain signals. +\item can be applied to Rel-10/11/12/13 physical channels and Rel-8 common channels +\begin{itemize} +\item UE-specific precoding (TM7-10) +\item vCell-specific precoding (PDCCH + TM1-6) for groups of UEs +\item PMCH vCells +\end{itemize} +\item Precoding applicable to +\begin{enumerate} +\item indoor DAS +\item outdoor co-localized arrays (e,g, Massive-MIMO) +\item outdoor CoMP +\end{enumerate} +\end{itemize}</text> +<path matrix="0.470395 0 0 0.4 159.158 0" stroke="black" fill="lightgray"> +208 480 m +208 80 l +512 80 l +512 480 l +h +</path> +<path matrix="1 0 0 1 49 -275" stroke="pink" pen="fat" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 49 -323" stroke="darkgray" pen="fat" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 49 -387" stroke="gold" pen="fat" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 0 -37" stroke="lightcyan" fill="gold"> +400 160 +480 192 +528 160 +400 160 +400 160 u +</path> +<path matrix="0.866025 -0.5 0.5 0.866025 9.3796 241.005" stroke="lightyellow" fill="darkgray"> +400 96 +448 128 +512 144 +576 96 +496 80 +400 96 +400 96 u +</path> +<path stroke="black"> +480 160 m +480 160 l +</path> +<path stroke="black"> +496 160 m +496 160 l +</path> +<path matrix="0.866025 0.5 -0.5 0.866025 102.38 -159.995" stroke="lightyellow" fill="pink"> +400 96 +448 128 +512 144 +576 96 +496 80 +400 96 +400 96 u +</path> +<text transformations="translations" pos="512 144" stroke="black" type="label" width="28.4928" height="14.9448" depth="0" valign="baseline" size="small">\small UE</text> +<text matrix="1 0 0 1 16 64" transformations="translations" pos="512 144" stroke="black" type="label" width="44.7144" height="14.9448" depth="0" valign="baseline" size="small">\small vCell</text> +<text matrix="1 0 0 1 32 -96" transformations="translations" pos="512 144" stroke="black" type="label" width="44.7144" height="14.9448" depth="0" valign="baseline" size="small">\small vCell</text> +<text matrix="1 0 0 1 0 -22" transformations="translations" pos="256 144" stroke="black" type="minipage" width="144" height="16.6224" depth="4.632" valign="top" size="small">TX Precoding</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<path layer="alpha" matrix="1.18986 0 0 0.837002 -253.249 49.0308" stroke="0" fill="lightyellow"> +608 516 m +607 37 l +679 37 l +680 516 l +h +</path> +<path matrix="1 0 0 1 -133 -21" stroke="black" fill="white"> +632 360 m +632 188 l +660 188 l +660 360 l +h +</path> +<text matrix="1 0 0 1 199 -16" transformations="translations" pos="176 556" stroke="black" type="label" width="341.835" height="20.9244" depth="6.972" halign="center" valign="baseline">TX Precoding (to RF device)</text> +<path matrix="1 0 0 1 -63 0" stroke="black" fill="lightgray"> +208 480 m +208 80 l +512 80 l +512 480 l +h +</path> +<path matrix="1 0 0 1 -63 -35" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 -63 -99" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 -63 -291" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<text matrix="1 0 0 1 -63 -15" transformations="translations" pos="96 464" stroke="black" type="minipage" width="81.789" height="15.2856" depth="3.312" valign="top" size="small">\tt eNB[0]</text> +<text matrix="1 0 0 1 -63 -79" transformations="translations" pos="96 464" stroke="black" type="minipage" width="81.789" height="15.2856" depth="3.312" valign="top" size="small">\tt eNB[1]</text> +<text matrix="1 0 0 1 -89.2484 -270.814" transformations="translations" pos="96 464" stroke="black" type="minipage" width="129.789" height="21.324" depth="9.36" valign="top" size="small">\tt eNB[CC\_max]</text> +<path matrix="1 0 0 1 424.037 -0.368" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 424.714 -64.365" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 424.714 -320.365" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 424.815 -16.205" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 424.816 -16.2378" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 424.816 -80.2378" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 423.542 -304.438" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1.5 0 0 1.06426 -160 -29.8163" stroke="black"> +528 464 m +528 416 l +592 416 l +592 464 l +h +</path> +<text matrix="1 0 0 1 110 -15" transformations="translations" pos="528 464" stroke="black" type="minipage" width="64" height="13.6632" depth="1.68" valign="top" size="small">\tiny\tt rf\_device[0]</text> +<path matrix="1.49204 0 0 1 -156.224 -64" stroke="black"> +528 464 m +528 416 l +592 416 l +592 464 l +h +</path> +<text matrix="1 0 0 1 109.571 -78" transformations="translations" pos="528 464" stroke="black" type="minipage" width="64" height="13.6632" depth="1.68" valign="top" size="small">\tiny\tt rf\_device[1]</text> +<path matrix="1.53737 0 0 1 -180.161 -304" stroke="black"> +528 464 m +528 416 l +592 416 l +592 464 l +h +</path> +<text matrix="1 0 0 1 107.571 -317" transformations="translations" pos="528 464" stroke="black" type="minipage" width="64" height="13.6632" depth="1.68" valign="top" size="small">\tiny\tt rf\_device[N-1]</text> +<path matrix="2.60074 0 0 1 -307.342 -22" stroke="black" fill="lightblue"> +192 432 m +192 368 l +272 368 l +272 432 l +h +</path> +<path matrix="2.60024 0 0 1 -307.263 -118" stroke="black" fill="lightblue"> +192 432 m +192 368 l +272 368 l +272 432 l +h +</path> +<path matrix="2.60024 0 0 1 -307.263 -214" stroke="black" fill="lightblue"> +192 432 m +192 368 l +272 368 l +272 432 l +h +</path> +<text matrix="1 0 0 1 0 -33" transformations="translations" pos="192 432" stroke="black" type="minipage" width="208" height="24.4656" depth="12.528" valign="top" size="small" style="center">\tiny\tt common signal precoding(vCell)\\ PBCH,PSS/SSS,PCFICH/PHICH/PDCCH\\ +PDSCH - TM1-6</text> +<text matrix="1 0 0 1 0 -129" transformations="translations" pos="192 432" stroke="black" type="minipage" width="208" height="24.7944" depth="12.864" valign="top" size="small" style="center">\tiny\tt UE-specific signal precoding(vCell)\\ +UE-RS,PDSCH - TM7-10</text> +<text matrix="1 0 0 1 0 -243" transformations="translations" pos="192 432" stroke="black" type="minipage" width="208" height="10.9584" depth="0" valign="top" size="small" style="center">\tiny\tt PMCH precoding</text> +<path stroke="black" arrow="normal/normal"> +145 413.44 m +192 384 l +</path> +<path stroke="black" arrow="normal/normal"> +145 413.44 m +192 288 l +</path> +<path stroke="black" arrow="normal/normal"> +145 413.44 m +192 192 l +</path> +<path stroke="black" arrow="normal/normal"> +145 349.44 m +192 384 l +</path> +<path stroke="black" arrow="normal/normal"> +145 349.44 m +191.982 288.048 l +</path> +<path stroke="black" arrow="normal/normal"> +145 349.44 m +191.982 192.084 l +</path> +<path stroke="black"> +145 157.44 m +192 384 l +192 384 l +</path> +<path stroke="black" arrow="normal/normal"> +145 157.44 m +191.982 288.048 l +</path> +<path stroke="black" arrow="normal/normal"> +145 157.44 m +191.982 192.084 l +</path> +<path stroke="black" arrow="normal/normal"> +400 384 m +449 447.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 431.796 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 383.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 367.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 143.57 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 127.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400 288 m +449 383.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 367.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 143.57 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 127.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400 192 m +449 447.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 447.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +448.966 431.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 192.005 m +449 367.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 192.005 m +449 143.57 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 192.005 m +449 127.637 l +</path> +<text matrix="0 1 -1 0 517.304 -343.285" pos="596 32" stroke="black" type="label" width="116.59" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny phy\_vars\_eNB.txdataF</text> +<text matrix="0 1 -1 0 569.304 -343.285" pos="596 32" stroke="black" type="label" width="109.325" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny phy\_vars\_eNB.txdata</text> +<path matrix="1 0 0 1 -176 -16" stroke="black" arrow="normal/tiny"> +632 264.556 m +671.833 265 l +</path> +<text matrix="0 1 -1 0 779.067 -428.933" pos="636 280" stroke="black" type="minipage" width="84" height="16.6824" depth="4.704" valign="top" size="small" style="center">\setstretch{.5}\tt\tiny do\_ofdm\_mod\_rt()\par 36.211</text> +</page> +<page> +<layer name="alpha"/> +<view layers="alpha" active="alpha"/> +<text layer="alpha" matrix="1 0 0 1 199 -16" transformations="translations" pos="176 556" stroke="black" type="label" width="499.453" height="20.9244" depth="6.972" halign="center" valign="baseline">TX Precoding (to IF device, NGFI\_IFv4p5)</text> +<path matrix="1 0 0 1 -63 0" stroke="black" fill="lightgray"> +208 480 m +208 80 l +512 80 l +512 480 l +h +</path> +<path matrix="1 0 0 1 -63 -35" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 -63 -99" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 -63 -291" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<text matrix="1 0 0 1 -63 -15" transformations="translations" pos="96 464" stroke="black" type="minipage" width="89.789" height="15.2856" depth="3.312" valign="top" size="small">\tt eNB[0]</text> +<text matrix="1 0 0 1 -63 -79" transformations="translations" pos="96 464" stroke="black" type="minipage" width="97.789" height="15.2856" depth="3.312" valign="top" size="small">\tt eNB[1]</text> +<text matrix="1 0 0 1 -89.2484 -270.814" transformations="translations" pos="96 464" stroke="black" type="minipage" width="137.789" height="15.2856" depth="3.312" valign="top" size="small">\tt eNB[CC\_max]</text> +<path matrix="1 0 0 1 320.037 -0.368" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 320.714 -64.365" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 320.714 -320.365" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 320.815 -16.205" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 320.816 -16.2378" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 320.816 -80.2378" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1 0 0 1 319.542 -304.438" stroke="black" arrow="normal/normal"> +128 448 m +208 448.44 l +</path> +<path matrix="1.5 0 0 1.06426 -264 -29.8163" stroke="black"> +528 464 m +528 416 l +592 416 l +592 464 l +h +</path> +<text matrix="1 0 0 1 6 -15" transformations="translations" pos="528 464" stroke="black" type="minipage" width="88" height="10.6272" depth="0" valign="top" size="small">\tiny\tt if\_device[0]</text> +<path matrix="1.49204 0 0 1 -260.224 -64" stroke="black"> +528 464 m +528 416 l +592 416 l +592 464 l +h +</path> +<text matrix="1 0 0 1 5.571 -78" transformations="translations" pos="528 464" stroke="black" type="minipage" width="88" height="10.6272" depth="0" valign="top" size="small">\tiny\tt if\_device[1]</text> +<path matrix="1.53737 0 0 1 -284.161 -304" stroke="black"> +528 464 m +528 416 l +592 416 l +592 464 l +h +</path> +<text matrix="1 0 0 1 3.571 -317" transformations="translations" pos="528 464" stroke="black" type="minipage" width="96" height="10.6272" depth="0" valign="top" size="small">\tiny\tt if\_device[N-1]</text> +<path matrix="2.60074 0 0 1 -307.342 -22" stroke="black" fill="lightblue"> +192 432 m +192 368 l +272 368 l +272 432 l +h +</path> +<path matrix="2.60024 0 0 1 -307.263 -118" stroke="black" fill="lightblue"> +192 432 m +192 368 l +272 368 l +272 432 l +h +</path> +<path matrix="2.60024 0 0 1 -307.263 -214" stroke="black" fill="lightblue"> +192 432 m +192 368 l +272 368 l +272 432 l +h +</path> +<text matrix="1 0 0 1 0 -33" transformations="translations" pos="192 432" stroke="black" type="minipage" width="208" height="24.4656" depth="12.528" valign="top" size="small" style="center">\tiny\tt common signal precoding(vCell)\\ PBCH,PSS/SSS,PCFICH/PHICH/PDCCH\\ +PDSCH - TM1-6</text> +<text matrix="1 0 0 1 0 -129" transformations="translations" pos="192 432" stroke="black" type="minipage" width="208" height="24.7944" depth="12.864" valign="top" size="small" style="center">\tiny\tt UE-specific signal precoding(vCell)\\ +UE-RS,PDSCH - TM7-10</text> +<text matrix="1 0 0 1 0 -243" transformations="translations" pos="192 432" stroke="black" type="minipage" width="208" height="10.9584" depth="0" valign="top" size="small" style="center">\tiny\tt PMCH precoding</text> +<path stroke="black" arrow="normal/normal"> +145 413.44 m +192 384 l +</path> +<path stroke="black" arrow="normal/normal"> +145 413.44 m +192 288 l +</path> +<path stroke="black" arrow="normal/normal"> +145 413.44 m +192 192 l +</path> +<path stroke="black" arrow="normal/normal"> +145 349.44 m +192 384 l +</path> +<path stroke="black" arrow="normal/normal"> +145 349.44 m +191.982 288.048 l +</path> +<path stroke="black" arrow="normal/normal"> +145 349.44 m +191.982 192.084 l +</path> +<path stroke="black"> +145 157.44 m +192 384 l +192 384 l +</path> +<path stroke="black" arrow="normal/normal"> +145 157.44 m +191.982 288.048 l +</path> +<path stroke="black" arrow="normal/normal"> +145 157.44 m +191.982 192.084 l +</path> +<path stroke="black" arrow="normal/normal"> +400 384 m +449 447.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 431.796 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 383.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 367.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 143.57 l +</path> +<path stroke="black" arrow="normal/normal"> +400.059 384.077 m +449 127.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400 288 m +449 383.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 367.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 143.57 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 127.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400 192 m +449 447.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +449 447.637 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 288.002 m +448.966 431.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 192.005 m +449 367.763 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 192.005 m +449 143.57 l +</path> +<path stroke="black" arrow="normal/normal"> +400.001 192.005 m +449 127.637 l +</path> +<path stroke="black" cap="1"> +448 544 m +448 544 l +</path> +<path stroke="black" cap="1"> +432 544 m +432 544 l +</path> +<path matrix="1 0 0 1 0 8" stroke="black" arrow="normal/normal"> +624 432 m +672 432 l +</path> +<path matrix="1 0 0 1 0 -56" stroke="black" arrow="normal/normal"> +624 432 m +672 432 l +</path> +<path matrix="1 0 0 1 1 -296" stroke="black" arrow="normal/normal"> +624 432 m +672 432 l +</path> +<text matrix="1 0 0 1 -6 -14" transformations="translations" pos="672 464" stroke="black" type="label" width="68.7072" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny NGFI\_IFv4p5</text> +<text matrix="1 0 0 1 -6 -78" transformations="translations" pos="672 464" stroke="black" type="label" width="68.7072" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny NGFI\_IFv4p5</text> +<text matrix="1 0 0 1 -6 -318" transformations="translations" pos="672 464" stroke="black" type="label" width="68.7072" height="8.3232" depth="2.304" valign="baseline" size="small">\tiny NGFI\_IFv4p5</text> +</page> +</ipe> diff --git a/targets/DOCS/oai_L1_L2_procedures.pdf b/targets/DOCS/oai_L1_L2_procedures.pdf old mode 100755 new mode 100644 index 369efc3b479b960c74e89b7e73e427a15cea8de9..4e8059f503d8a4fedd634dc014c4f572275a5be8 Binary files a/targets/DOCS/oai_L1_L2_procedures.pdf and b/targets/DOCS/oai_L1_L2_procedures.pdf differ diff --git a/targets/Makefile b/targets/Makefile deleted file mode 100644 index b604898d2aef8230ad3a23c4d669a6a9303079eb..0000000000000000000000000000000000000000 --- a/targets/Makefile +++ /dev/null @@ -1,35 +0,0 @@ - - -build: - ./build_oai.bash -c -m - -build_rtai: - ./build_oai.bash -c -b -eRTAI -tSOFTMODEM -m - -build_usrp_rtai: - ./build_oai.bash -c -b -eRTAI -tSOFTMODEM -wUSRP -m - - -help: - @echo make check1 performs a simple sanity check - @echo make check2 performs another simple sanity check - @echo make check does both the above checks - -all: help - -check1: - @echo Doing 1 eNB 1 UE test - (cd SIMU/EXAMPLES/VIRT_EMUL_1eNB && make one_eNB_one_UE ) - -check2: - @echo Doing 1 eNB 4 UE test - (cd SIMU/EXAMPLES/VIRT_EMUL_1eNB && make one_eNB_four_UE ) - -install: - @echo Generating ASN1 files - @sh SCRIPTS/install_asn1.sh - -check: check1 check2 - -clean: - (cd SIMU/USER && make clean) diff --git a/targets/Makefile.common b/targets/Makefile.common index 042a36bf4562946b77087d306e123838fd28c714..ac0771770ba8c4737370a8f7670a71be2dc1b01e 100644 --- a/targets/Makefile.common +++ b/targets/Makefile.common @@ -86,7 +86,6 @@ endif ifeq ($(ENABLE_ITTI),1) COMMON_CFLAGS += -DENABLE_ITTI -COMMON_CFLAGS += -DUSER_MODE COMMON_CFLAGS += -I$(OPENAIR1_DIR) COMMON_CFLAGS += -I$(OPENAIR2_DIR)/NAS COMMON_CFLAGS += $(L2_incl) diff --git a/targets/PROJECTS/E-MBMS/build_all.bash b/targets/PROJECTS/E-MBMS/build_all.bash index 0cbece916eae4351990afb2dbc8e40468586cc16..bac9b33736853980953114bfb326de1d72a79131 100755 --- a/targets/PROJECTS/E-MBMS/build_all.bash +++ b/targets/PROJECTS/E-MBMS/build_all.bash @@ -61,8 +61,8 @@ echo_success "\n###############################" echo_success "# COMPILE oaisim" echo_success "###############################" cd $OPENAIR_TARGETS/SIMU/USER -echo_success "Executing: make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo `" -make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo ` +echo_success "Executing: make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo `" +make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo ` if [[ $? -eq 2 ]] ; then exit 1 fi diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf index 5818933c48f0aa4fe2f9072f0b1c81697168c212..b441b894568b629158a294b9dd255c7198ab5322 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf @@ -44,7 +44,7 @@ eNBs = nb_antennas_tx = 1; nb_antennas_rx = 1; tx_gain = 90; - rx_gain = 115; + rx_gain = 125; pbch_repetition = "FALSE"; prach_root = 0; prach_config_index = 0; @@ -55,8 +55,7 @@ eNBs = pucch_nRB_CQI = 0; pucch_nCS_AN = 0; pucch_n1_AN = 32; - #pdsch_referenceSignalPower = -27; - pdsch_referenceSignalPower = -30; + pdsch_referenceSignalPower = -27; pdsch_p_b = 0; pusch_n_SB = 1; pusch_enable64QAM = "DISABLE"; @@ -74,9 +73,9 @@ eNBs = srs_ackNackST =; srs_MaxUpPts =;*/ - pusch_p0_Nominal = -96; + pusch_p0_Nominal = -86; pusch_alpha = "AL1"; - pucch_p0_Nominal = -104; + pucch_p0_Nominal = -96; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; @@ -164,13 +163,30 @@ eNBs = } ); +#MACRLCs = ( +# { +# num_cc = 1; +# local_s_if_name = "eno1"; +# remote_s_address = "192.168.1.74"; +# #local_s_address = "192.168.1.78"; +# local_s_address = "192.168.1.28"; +# local_s_portc = 50001; +# remote_s_portc = 50000; +# local_s_portd = 50011; +# remote_s_portd = 50010; +# tr_s_preference = "nfapi"; +# tr_n_preference = "local_RRC"; +# } +#); + + MACRLCs = ( { num_cc = 1; - local_s_if_name = "eno1"; - remote_s_address = "192.168.1.74"; + local_s_if_name = "lo:"; + remote_s_address = "127.0.0.1"; #local_s_address = "192.168.1.78"; - local_s_address = "192.168.1.28"; + local_s_address = "127.0.0.2"; local_s_portc = 50001; remote_s_portc = 50000; local_s_portd = 50011; @@ -180,17 +196,21 @@ MACRLCs = ( } ); + + + + log_config : { - global_log_level ="debug"; + global_log_level ="info"; global_log_verbosity ="medium"; hw_log_level ="info"; hw_log_verbosity ="medium"; phy_log_level ="info"; phy_log_verbosity ="medium"; - mac_log_level ="debug"; - mac_log_verbosity ="high"; - rlc_log_level ="debug"; + mac_log_level ="info"; + mac_log_verbosity ="medium"; + rlc_log_level ="info"; rlc_log_verbosity ="high"; pdcp_log_level ="info"; pdcp_log_verbosity ="medium"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf index 048f2fcc358fa6de5fc02e48d7223b8b5a202514..e60e7934386b9b8296a5b1b1ebc4845a984f1a7a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf @@ -197,13 +197,13 @@ RUs = ( ); log_config = { - global_log_level ="debug"; + global_log_level ="info"; global_log_verbosity ="medium"; hw_log_level ="info"; hw_log_verbosity ="medium"; - phy_log_level ="debug"; + phy_log_level ="info"; phy_log_verbosity ="medium"; - mac_log_level ="debug"; + mac_log_level ="info"; mac_log_verbosity ="high"; rlc_log_level ="info"; rlc_log_verbosity ="medium"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf index af262223f01f574c3890062c85192e7fce2156d9..24ae36a0a4c7c671f0cc4ad4754f1d6b233397a6 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf @@ -17,3 +17,20 @@ RUs = ( } ); +log_config = { + global_log_level ="debug"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="debug"; + phy_log_verbosity ="medium"; + mac_log_level ="debug"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; +}; + diff --git a/targets/RT/Makefile b/targets/RT/Makefile deleted file mode 100644 index 1be49d2db80ce4595fd0263eebb15f35c2aa2163..0000000000000000000000000000000000000000 --- a/targets/RT/Makefile +++ /dev/null @@ -1,124 +0,0 @@ -# command line flags are automatically exported and thus passed down to any sub-make. -# here we set the default flags in case on command line flags are provided -# these flags have to be explicitely exported so that the sub-make is aware of them - - -include $(OPENAIR_DIR)/common/utils/Makefile.inc -ifndef OPENAIR_LTE -export OPENAIR_LTE=1 -export OPENAIR_EMU=0 -endif - -ifndef OPENAIR1 -export OPENAIR1=0 -endif - -ifndef OPENAIR2 -export OPENAIR2=0 -endif - -ifndef OPENAIR3 -export OPENAIR3=0 -endif - -ifndef EMOS -export EMOS=0 -endif - -ifndef rrc_cellular -export rrc_cellular = 0 -export rrc_cellular_eNB = 0 -export rrc_cellular_UE = 0 -else - export rrc_cellular = 1 - ifeq ($(eNB_flag),1) - export rrc_cellular_eNB=1 - endif - ifeq ($(UE_flag),1) - export rrc_cellular_UE=1 - endif -endif - -all: openair_rf_cbmimo1_softmodem.ko asn1_msg_kern.ko nasmesh.ko rb_tool openair_rf scope - -openair_rf_cbmimo1_softmodem.ko: - (cd $(OPENAIR1_DIR)/ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) -C $(KERNEL_DIR)/build V=1 M=`pwd` RTAI=1 CBMIMO1=1 && mv openair_rf.ko $(CURDIR)/openair_rf_softmodem.ko) - -oai_user_cbmimo1.ko: - (cd $(OPENAIR1_DIR)/ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) -C $(KERNEL_DIR)/build V=1 M=`pwd` RTAI=1 CBMIMO1=1 BIT8_TX=1 OPENAIR1=0 OPENAIR2=0 && mv openair_rf.ko $(CURDIR)/openair_rf_softmodem.ko) - -oai_user_exmimo.ko: - (cd $(OPENAIR1_DIR)/ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) -C $(KERNEL_DIR)/build V=1 M=`pwd` RTAI=1 CBMIMO1=1 OPENAIR1=0 OPENAIR2=0 && mv openair_rf.ko $(CURDIR)/openair_rf_softmodem.ko) - -asn1_msg_kern.ko: - (cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES && $(MAKE) -C $(KERNEL_DIR)/build V=0 M=`pwd` RTAI=1 -j2 && mv asn1_msg_kern.ko $(CURDIR)/asn1_msg_kern.ko) - -nasmesh.ko: - (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH && $(MAKE) V=1 -C $(KERNEL_DIR)/build M=`pwd` && mv nasmesh.ko $(CURDIR)/nasmesh.ko) - -rb_tool: - (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && $(MAKE)) - -openair_rf: - (cd $(OPENAIR1_DIR)/USERSPACE_TOOLS/OPENAIR_RF && $(MAKE) clean CBMIMO1=1 && $(MAKE) all CBMIMO1=1 && $(MAKE) clean CBMIMO1=1) - -scope: - (cd $(OPENAIR1_DIR)/USERSPACE_TOOLS/SCOPE && $(MAKE) clean && $(MAKE) all && $(MAKE) clean ) - -#Remove all but source files -cleanall: - (cd $(OPENAIR1_DIR) && $(MAKE) cleanall) - (cd $(OPENAIR2_DIR) && $(MAKE) cleanall) - -fifos: - @for i in `seq 0 64`;\ - do \ - have_rtfX=`ls /dev/ |grep -c rtf$$i`;\ - if [ "$$have_rtfX" -eq 0 ] ;then \ - mknod -m 666 /dev/rtf$$i c 150 $$i; \ - fi;\ - done - -openair0: - mknod /dev/openair0 c 127 0 - chmod a+rw /dev/openair0 - -install_oai_user: - make fifos - insmod openair_rf_softmodem.ko - -updatefw: - $(OPENAIR1_DIR)/USERSPACE_TOOLS/OAI_FW_INIT/updatefw -f $$OPENAIR0_DIR/express-mimo/software/sdr/main -s 0x43fffff0 - -boot_exmimo: - sudo make install_oai_user - $(OPENAIR1_DIR)/USERSPACE_TOOLS/OAI_FW_INIT/updatefw -f $$OPENAIR0_DIR/express-mimo/software/sdr/main -s 0x43fffff0 - sleep 1 - sudo rmmod openair_rf - sudo make install_oai_user - -reboot_exmimo: - $(OPENAIR1_DIR)/USERSPACE_TOOLS/OAI_FW_INIT/updatefw -f $$OPENAIR0_DIR/express-mimo/software/sdr/main -s 0x43fffff0 -b - sudo rmmod openair_rf - sudo make install_oai_user - -install_softmodem: - make fifos -ifeq ($(OPENAIR2),1) - insmod asn1_msg_kern.ko -endif - insmod openair_rf_softmodem.ko - -remove: - rmmod openair_rf -ifeq ($(OPENAIR2),1) - rmmod asn1_msg_kern -endif - -test: - (cd $(OPENAIR1_DIR)/ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) test RTAI=1 CBMIMO1=1) - (cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES && $(MAKE) test) - -clean: - (cd $(OPENAIR1_DIR)/ARCH/CBMIMO1/DEVICE_DRIVER && $(MAKE) clean RTAI=1 CBMIMO1=1) - (cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES && $(MAKE) clean) diff --git a/targets/RT/USER/Makefile b/targets/RT/USER/Makefile deleted file mode 100644 index 8c413d4e2e254048621c62d66f5d05634dcca154..0000000000000000000000000000000000000000 --- a/targets/RT/USER/Makefile +++ /dev/null @@ -1,447 +0,0 @@ -# Include some shared directives -include $(OPENAIR_TARGETS)/Makerules - -default: lte-softmodem -all: lte-softmodem rrh - -include $(OPENAIR_TARGETS)/Makefile.common - -KERNEL_VERSION:=$(shell echo `uname -r | cut -d. -f-2`) -KERNEL_TYPE:=$(shell echo `uname -r | cut -d. -f-3 | cut -d- -f3`) -DEADLINE_SCHEDULER_KERNEL:=$(shell if [ $(KERNEL_TYPE) = "lowlatency" ]; then echo "1" ; else echo "0" ; fi) - -include $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc - -ifdef EXMIMO -#ifdef DEADLINE_SCHEDULER # this ifdef is to be removed after the debugging -ifeq ($(DEADLINE_SCHEDULER_KERNEL),1) -CFLAGS+=-DDEADLINE_SCHEDULER -endif -#endif -endif - -ifndef USRP -USRP=0 -endif - -CFLAGS += -DDRIVER2013 -I$(OPENAIR_TARGETS)/ARCH/COMMON -I. - -ifndef OPENAIR2 -OPENAIR2=1 -endif - -ifdef DEBUG -DISABLE_XER_PRINT=0 -MSG_PRINT=1 -endif - -ifdef Rel10 -CFLAGS += -DRel10 -endif - -ifeq ($(EXMIMO),1) - CFLAGS += -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/DEFS -DENABLE_VCD_FIFO -endif - -ifeq ($(ETHERNET),1) - CFLAGS += -I$(OPENAIR_TARGETS)/ARCH/ETHERNET/USERSPACE/LIB/ -DETHERNET -endif - -ifeq ($(DEBUG),1) -CFLAGS += -g -ggdb -#CFLAGS += -DRRC_MSG_PRINT -#CFLAGS += -DPDCP_MSG_PRINT -else -CFLAGS += -O2 -endif - -ifdef ($(MSG_PRINT),1) -CFLAGS += -DRRC_MSG_PRINT -CFLAGS += -DPDCP_MSG_PRINT -endif - -SRC = synctest.c condtest.c - -ifndef RTAI -RTAI=1 -endif - -ifeq ($(LOCALIZATION), 1) -CFLAGS += -DLOCALIZATION -endif - -ifeq ($(LINUX_LIST), 1) -CFLAGS += -DLINUX_LIST -endif - -ifeq ($(RTAI),1) -CFLAGS += -DENABLE_RTAI_CLOCK -CFLAGS += -DCONFIG_RTAI_LXRT_INLINE #remend the RTAI warning -RTAI_OBJ = sched_dlsch.o sched_rx_pdsch.o rt_wrapper.o -else #RTAI -CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME -OBJ += sched_dlsch.o sched_rx_pdsch.o rt_wrapper.o -endif - -OBJ += $(OPENAIR1_DIR)/SIMULATION/TOOLS/taus.o $(OPENAIR_TARGETS)/SIMU/USER/init_lte.o - -ifeq ($(EXMIMO),1) -OBJ += $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/gain_control.o -CFLAGS += -DDRIVER2013 -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/DEFS -endif - -CFLAGS += -DENABLE_VCD_FIFO - - -TOP_DIR = $(OPENAIR1_DIR) -include $(OPENAIR1_DIR)/PHY/Makefile.inc -include $(OPENAIR1_DIR)/SCHED/Makefile.inc - -OBJ += $(PHY_OBJS) -ifeq ($(RTAI),1) -RTAI_OBJ += $(SCHED_OBJS) -else -OBJ += $(SCHED_OBJS) -endif - -OPENAIR2_TOP = $(OPENAIR2_DIR) -include $(OPENAIR2_DIR)/LAYER2/Makefile.inc -include $(OPENAIR2_DIR)/UTIL/Makefile.inc -include $(OPENAIR2_DIR)/RRC/NAS/Makefile.inc -include $(OPENAIR2_DIR)/ENB_APP/Makefile.inc - -ifeq ($(USRP),1) - -include $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/Makefile.inc -#CFLAGS += -I/opt/include/uhd -L/opt/lib -luhd -lpthread -lstdc++ -CFLAGS += -I/usr/include/uhd -L/usr/lib -luhd -lpthread -lstdc++ -CFLAGS += -DOAI_USRP -#LDFLAGS += -L/opt/lib -luhd -lpthread -lstdc++ -LDFLAGS += -L/usr/lib/ -luhd -lpthread -lstdc++ -endif - -ifeq ($(ETHERNET),1) -include $(OPENAIR_TARGETS)/ARCH/ETHERNET/USERSPACE/LIB/Makefile.inc -LDFLAGS += -lpthread -endif - -OBJ += $(ENB_APP_OBJS) - -ifeq ($(RTAI),1) -CFLAGS += -I/usr/realtime/include -I/usr/realtime/include/asm -LOG_OBJS= -RTAI_OBJ+=$(LOG_DIR)/vcd_signal_dumper.o -RTAI_OBJ+=$(LOG_DIR)/log.o -endif - - -OBJ += $(LOG_OBJS) - -ifeq ($(OPENAIR2),1) -ASN1_MSG_OBJS1=$(addprefix $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/, $(ASN1_MSG_OBJS)) -OBJ += $(L2_OBJS) $(LIST_OBJ) $(TIMER_OBJ) $(MEM_OBJ) $(OTG_OBJS) $(MATH_OBJS) $(OSA_OBJS) $(OPT_OBJS) -OBJ += $(OPENAIR1_DIR)/SIMULATION/ETH_TRANSPORT/netlink_init.o -#OBJ += $(PDCP_DIR)/pdcp_thread.o -CFLAGS += -DOPENAIR2 -DNO_RRM -DPUCCH -DMAC_CONTEXT=1 -endif - -#ifdef ENABLE_ITTI -RTAI_OBJ += $(UTILS_OBJS) -#else -#OBJ += $(UTILS_OBJS) -#endif - -ifdef SPECTRA -CFLAGS += -DSPECTRA -endif - -#ifdef ENABLE_ITTI -CFLAGS += -DEXMIMO_IOT -#endif - -CFLAGS += $(L2_incl) $(ENB_APP_incl) $(UTIL_incl) $(UTILS_incl) - -CFLAGS += -I$(OPENAIR1_DIR) -I$(OPENAIR2_DIR)/RRC/LITE/MESSAGES #-I$(OPENAIR3_DIR)/MESH -I$(OPENAIR3_DIR)/MESH/RRM - -CFLAGS += -DNEW_FFT -DLOG_NO_THREAD - -ifeq ($(XFORMS),1) -CFLAGS += -DXFORMS -I/usr/include/X11 -LDFLAGS += -lforms -OBJ += $(OPENAIR1_DIR)/PHY/TOOLS/lte_phy_scope.o -OBJ += stats.o -endif - -OBJ_SYNC = $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o rt_wrapper.o $(OPENAIR2_DIR)/UTIL/LOG/log.o $(OPENAIR2_DIR)/UTIL/LOG/vcd_signal_dumper.o - -ifdef SMBV -CFLAGS += -DSMBV -endif - -CFLAGS += -DPHYSIM -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DPHY_CONTEXT=1 -CFLAGS += -DOPENAIR_LTE -DENABLE_FXP -DOPENAIR1 #-DDLSCH_THREAD #-DULSCH_THREAD - - -ifeq ($(EXMIMO),1) -CFLAGS += -DEXMIMO -#CFLAGS += -DEXMIMO -DTIMING_ADVANCE_HW=138 #this is for ExpressMIMO 1 -#CFLAGS += -DEXMIMO -DTIMING_ADVANCE_HW=45 #this is for ExpressMIMO 2 -endif - -ifeq ($(HARD_RT),1) -CFLAGS += -DHARD_RT -endif - -ifeq ($(EMOS),1) -CFLAGS += -D_FILE_OFFSET_BITS=64 #-DEMOS -DEMOS_CHANNEL -LDFLAGS += -lgps -endif - - -ifeq ($(LINK_ENB_PDCP_TO_GTPV1U), 1) -CFLAGS += -DLINK_ENB_PDCP_TO_GTPV1U -endif - -ifeq ($(LINK_ENB_PDCP_TO_IP_DRIVER), 1) -CFLAGS += -DPDCP_USE_NETLINK -DLINUX -OBJ += $(NAS_OBJS) -NAS_FLAG=1 -endif - -LDFLAGS += -lpthread -lm -lforms -lconfig -lrt -ifeq ($(RTAI),1) -RTAI_CFLAGS += $(shell rtai-config --lxrt-cflags) -DRTAI -LDFLAGS += $(shell rtai-config --lxrt-ldflags) -endif - -#ifeq ($(USRP),1) -#CFLAGS += -I/opt/uhd/include -L/opt/uhd/lib -luhd -lpthread -lstdc++ -#CFLAGS += -DOAI_USRP -#endif -#CFLAGS += -I/usr/include/c++/4.6 -I/usr/include/c++/4.6/x86_64-linux-gnu -I/usr/include/rtai/ - -LFDS_OBJ_DIR = $(subst $(OPENAIR_DIR),$(OBJS_DIR),$(LFDS_DIR)) -LFDS_LIB = $(LFDS_OBJ_DIR)/bin/liblfds611.a -LIBS += $(LFDS_LIB) -SHARED_DEPENDENCIES += $(LFDS_LIB) - --include $(OBJ:.o=.d) --include $(ASN1_MSG_OBJS1:.o=.d) --include $(RTAI_OBJ:.o=.d) --include lte-softmodem.d --include lte-ue.d --include rrh.d - -$(LFDS_LIB): - @if [ ! -d $(LFDS_OBJ_DIR)/bin ]; then mkdir -p $(LFDS_OBJ_DIR)/bin; fi; - @if [ ! -d $(LFDS_OBJ_DIR)/obj ]; then mkdir -p $(LFDS_OBJ_DIR)/obj; fi; - $(MAKE) -C $(LFDS_DIR) -f makefile.linux OUTDIR=$(LFDS_OBJ_DIR) - -ifeq ($(USRP),1) -$(USRP_OBJ):$(USRP_FILE_OBJ) - @echo Compiling $< - @$(CXX) -c -g -ggdb $(USRP_CFLAGS) $(USRP_FILE_OBJ) -o $(USRP_OBJ) -endif - -ifeq ($(ETHERNET),1) -$(ETHERNET_OBJ):$(ETHERNET_FILE_OBJ) - @echo Compiling $< - @$(CC) -c -g -ggdb $(ETHERNET_CFLAGS) $(ETHERNET_FILE_OBJ) -o $(ETHERNET_OBJ) -endif - -ifeq ($(RTAI),1) -$(RTAI_OBJ) lte-softmodem.o lte-ue.o: %.o : %.c -else -$(RTAI_OBJ): %.o : %.c -endif - @echo Compiling $< ... - @$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) -o $@ $< - @$(CC) -MM $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) $< > $*.d - @mv -f $*.d $*.d.tmp - @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d - @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \ - sed -e 's/^ *//' -e 's/$$/:/' >> $*.d - @rm -f $*.d.tmp - -ifdef ENABLE_ITTI -$(OBJ) $(RTAI_OBJ): $(ITTI_MESSAGES_H) -endif - -ifeq ($(RTAI),1) -$(OBJ) $(ASN1_MSG_OBJS1): %.o : %.c -else -$(OBJ) $(ASN1_MSG_OBJS1) lte-softmodem.o lte-ue.o: %.o : %.c -endif - -rrh.o: %.o : %.c - - @echo Compiling $< ... - @$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $< - @$(CC) -MM $(CFLAGS) $(EXTRA_CFLAGS) $< > $*.d - @mv -f $*.d $*.d.tmp - @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d - @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \ - sed -e 's/^ *//' -e 's/$$/:/' >> $*.d - @rm -f $*.d.tmp - -OBJ_EMOS = $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/gain_control.o rt_wrapper.o $(OPENAIR2_DIR)/UTIL/LOG/log.o $(OPENAIR2_DIR)/UTIL/LOG/vcd_signal_dumper.o $(OPENAIR1_DIR)/PHY/TOOLS/signal_energy.o $(OPENAIR1_DIR)/PHY/TOOLS/dB_routines.o -ifeq ($(XFORMS),1) -OBJ_EMOS+=lte_scope.o -endif - -condtest: condtest.c - $(CC) $(CFLAGS) $(LDFLAGS) condtest.c -o condtest - -synctest: $(OBJ_SYNC) $(SHARED_DEPENDENCIES) synctest.c - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) $(OBJ_SYNC) -o synctest synctest.c $(LDFLAGS) $(LIBS) - -sleeptest: rt_wrapper.o sleeptest.c - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) rt_wrapper.o -o sleeptest sleeptest.c $(LDFLAGS) - -lte-softmodem: $(OBJ) $(USRP_OBJ) $(ETHERNET_OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) lte-ue.o lte-softmodem.o $(SHARED_DEPENDENCIES) - @echo Linking $@ - @$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(USRP_OBJ) $(ETHERNET_OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) lte-ue.o lte-softmodem.o -o lte-softmodem $(LDFLAGS) $(LIBS) - -rrh: rrh.o - @$(CC) $(CFLAGS) $(EXTRA_CFLAGS) rrh.o -o rrh -lpthread -lrt - -emos-raw: $(SHARED_DEPENDENCIES) $(OBJ_EMOS) emos-raw.c - @$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) $(OBJ_EMOS) -o emos-raw emos-raw.c $(LDFLAGS) $(LIBS) - - -synctest_eNB: synctest - cp synctest synctest_eNB - -synctest_UE: synctest - cp synctest synctest_UE - -drivers: -# cd $(OPENAIR2_DIR) && make clean && make nasmesh_netlink.ko -# cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && make clean && make - cd $(OPENAIR_TARGETS)/ARCH/EXMIMO/DRIVER/eurecom && make clean && make - cd $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT && make clean && make - cp $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/updatefw $(OPENAIR_TARGETS)/bin/. - -run: condtest - rtai-load condtest --verbose - -run_eNB_test: - rtai-load eNB_test --verbose - -run_eNB: - rtai-load eNB --verbose - -run_UE: - rtai-load UE --verbose - -run_UE0: - rtai-load UE0 --verbose - -run_UE0_smbv: - rtai-load UE0_smbv --verbose - -run_UE850: - rtai-load UE850 --verbose - -run_eNB850: - rtai-load eNB850 --verbose - -run_UE0prach: - rtai-load UE0prach --verbose - -run_UE1prach: - rtai-load UE1prach --verbose - -run_UE2prach: - rtai-load UE2prach --verbose - -run_UE0noL2: - rtai-load UE0noL2 -- verbose - -run_UE1noL2: - rtai-load UE1noL2 --verbose - -run_UE2noL2: - rtai-load UE2noL2 --verbose - -run_UE0calib: - rtai-load UE0calib --verbose - -run_UE0calibmed: - rtai-load UE0calibmed --verbose - -run_UE0calibbyp: - rtai-load UE0calibbyp --verbose - -run_UE1: - rtai-load UE1 --verbose - -run_UE2: - rtai-load UE2 --verbose - -run_eNB0: - rtai-load eNB0 --verbose - -run_eNB1: - rtai-load eNB1 --verbose - -run_eNB2: - rtai-load eNB2 --verbose - -clean: cleanmodem common-clean - -cleanmodem: - @$(RM_F_V) $(OBJ) $(RTAI_OBJ) $(OBJ_EMOS) $(OBJ_SYNC) $(USRP_OBJ) $(ETHERNET_OBJ) - @$(RM_F_V) $(OBJ:.o=.d) $(RTAI_OBJ:.o=.d) $(OBJ_EMOS:.o=.d) $(OBJ_SYNC:.o=.d) - @$(RM_F_V) $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1_msg.o $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1_msg.d - @$(RM_F_V) lte-ue.o lte-ue.d rrh.o rrh.d lte-softmodem.o lte-softmodem.d - @$(RM_F_V) rrh.o lte-ue.o lte-softmodem.o - -cleanasn1: - rm -f $(ASN1_MSG_OBJS1) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES ; rm -f $(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS) *.o *.d ) - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.am.sample - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/.lock-rel* - -cleancell: - rm -f $(OPENAIR2_DIR)/RRC/CELLULAR/*.o - rm -f $(OPENAIR2_DIR)/RRC/CELLULAR/*.d - rm -f $(OPENAIR2_DIR)/RRC/L2_INTERFACE/*.o - rm -f $(OPENAIR2_DIR)/RRC/L2_INTERFACE/*.d - rm -f $(OPENAIR2_DIR)/NAS/SIMU_CELLULAR/*.o - rm -f $(OPENAIR2_DIR)/NAS/SIMU_CELLULAR/*.d - -cleanalmostall: cleanmodem - rm -f $(ASN1_MSG_OBJS1) - rm -rf condtest synctest lte-softmodem rrh - rm -rf synctest_eNB synctest_UE - -cleanall: common-cleanall clean cleanasn1 - rm -rf condtest synctest lte-softmodem rrh - rm -rf synctest_eNB synctest_UE - -show: - @echo $(CFLAGS) - @echo $(EXTRA_CFLAGS) - @echo $(OBJ) $(RTAI_OBJ) - @echo $(USRP_OBJ) - @echo $(ETHERNET_OBJ) - @echo $(ETHERNET_FILE_OBJ) - @echo IS_REL8 is $(IS_REL8) - @echo IS_REL10 is $(IS_REL10) - @echo openssl $(OPENSSL_FOUND) - @echo nettle $(NETTLE_FOUND) - @echo lowlatency kernel: $(DEADLINE_SCHEDULER_KERNEL) - -beautiful: - astyle --style=gnu -s2 $(SRC) - -fifos: - @for i in `seq 0 64`;\ - do \ - have_rtfX=`ls /dev/ |grep -c rtf$$i`;\ - if [ "$$have_rtfX" -eq 0 ] ;then \ - mknod -m 666 /dev/rtf$$i c 150 $$i; \ - fi;\ - done diff --git a/targets/RT/USER/Makefile.agilent b/targets/RT/USER/Makefile.agilent deleted file mode 100644 index 061c15a31cc4067ed7897916429781b6da6a19f6..0000000000000000000000000000000000000000 --- a/targets/RT/USER/Makefile.agilent +++ /dev/null @@ -1,243 +0,0 @@ -include $(OPENAIR_TARGETS)/Makerules - -include $(OPENAIR_TARGETS)/Makefile.common - -CFLAGS += -DDRIVER2013 -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/DEFS -DENABLE_VCD_FIFO -DEXMIMO_IOT - -SRC = lte-enb.c - -ifndef RTAI -RTAI=1 -endif - -ifeq ($(RTAI),1) -CFLAGS += -DENABLE_RTAI_CLOCK -DRTAI -RTAI_OBJ = sched_dlsch.o sched_ulsch.o sched_rx_pdsch.o lte-enb.o rt_wrapper.o -else -OBJ = sched_dlsch.o sched_ulsch.o sched_rx_pdsch.o lte-enb.o rt_wrapper.o -CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME -endif - -OBJ += $(OPENAIR1_DIR)/SIMULATION/TOOLS/taus.o $(OPENAIR_TARGETS)/SIMU/USER/init_lte.o $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o - -TOP_DIR = $(OPENAIR1_DIR) -include $(OPENAIR1_DIR)/PHY/Makefile.inc -include $(OPENAIR1_DIR)/SCHED/Makefile.inc - -OBJ += $(PHY_OBJS) -ifeq ($(RTAI),1) -RTAI_OBJ += $(SCHED_OBJS) -else -OBJ += $(SCHED_OBJS) -endif - -#ifndef rrc_cellular -ifeq ($(rrc_cellular),0) -rrc_cellular = 0 -rrc_cellular_eNB = 0 -rrc_cellular_UE = 0 -else - ifeq ($(eNB_flag),1) - rrc_cellular_eNB=1 - endif - ifeq ($(UE_flag),1) - rrc_cellular_UE=1 - endif -endif - -export rrc_cellular - -OPENAIR2_TOP = $(OPENAIR2_DIR) -include $(OPENAIR2_DIR)/LAYER2/Makefile.inc -include $(OPENAIR2_DIR)/UTIL/Makefile.inc -include $(OPENAIR2_DIR)/RRC/NAS/Makefile.inc - -ifeq ($(RTAI),1) -LOG_OBJS= -RTAI_OBJ+=$(LOG_DIR)/vcd_signal_dumper.o -RTAI_OBJ+=$(LOG_DIR)/log.o -endif - -include $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc - -OBJ += $(LOG_OBJS) - -ifndef OPENAIR2 -OPENAIR2=1 -endif -ifeq ($(OPENAIR2),1) -ASN1_MSG_OBJS1=$(addprefix $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/, $(ASN1_MSG_OBJS)) -OBJ += $(L2_OBJS) $(LIST_OBJ) $(TIMER_OBJ) $(MEM_OBJ) $(OTG_OBJS) $(MATH_OBJS) -OBJ += $(OPENAIR1_DIR)/SIMULATION/ETH_TRANSPORT/netlink_init.o -OBJ += $(PDCP_DIR)/pdcp_thread.o -CFLAGS += -DOPENAIR2 -DNO_RRM -DPUCCH -DMAC_CONTEXT=1 -endif - -CFLAGS += $(L2_incl) $(UTIL_incl) $(UTILS_incl) - -CFLAGS += -I$(OPENAIR1_DIR) -I$(OPENAIR2_DIR)/RRC/LITE/MESSAGES #-I$(OPENAIR3_DIR)/MESH -I$(OPENAIR3_DIR)/MESH/RRM - -CFLAGS += -DNEW_FFT -DLOG_NO_THREAD - -ifeq ($(XFORMS),1) -CFLAGS += -DXFORMS -I/usr/include/X11 -LDFLAGS += -lforms -OBJ += $(OPENAIR1_DIR)/PHY/TOOLS/lte_phy_scope.o -OBJ += stats.o -endif - -ifdef SMBV -CFLAGS += -DSMBV -endif - -CFLAGS += -DPHYSIM -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DPHY_CONTEXT=1 -CFLAGS += -DOPENAIR_LTE -DENABLE_FXP -DOPENAIR1 -DDLSCH_THREAD #-DULSCH_THREAD - -#only for CBMIMO1 -ifdef CBMIMO1 -CFLAGS += -DFW2011 -DBIT8_TX -DCBMIMO1 -else -#only for EXPRESS MIMO -CFLAGS += -DEXMIMO -#CFLAGS += -DEXMIMO -DTIMING_ADVANCE_HW=138 #this is for ExpressMIMO 1 -#CFLAGS += -DEXMIMO -DTIMING_ADVANCE_HW=45 #this is for ExpressMIMO 2 -endif - -ifndef HARD_RT -HARD_RT=1 -endif - -ifeq ($(HARD_RT),1) -CFLAGS += -DHARD_RT -endif - -ifeq ($(EMOS),1) -CFLAGS += -DEMOS -DEMOS_CHANNEL -LDFLAGS += -lgps -endif - -ifndef NAS -NAS=1 -endif - -ifeq ($(NAS),1) -CFLAGS += -DPDCP_USE_NETLINK -DLINUX -OBJ += $(NAS_OBJS) -endif - -RTAI_CFLAGS += $(shell rtai-config --lxrt-cflags) -CFLAGS += -I/usr/realtime/include -DRTAI -LDFLAGS += -lpthread -lm -lforms -ifeq ($(RTAI),1) -LDFLAGS += $(shell rtai-config --lxrt-ldflags) -else -LDFLAGS += -lrt -endif - -#ifndef USE_MME -# USE_MME=R8 -#endif - -ifdef USE_MME - include $(OPENAIR2_DIR)/S1AP/Makefile.inc - include $(OPENAIR2_DIR)/S1AP/MESSAGES/Makefile.inc - CFLAGS += -DENABLE_USE_MME -DENB_MODE - LDFLAGS += -lsctp - CFLAGS_S1AP += -DENB_MODE -DENABLE_USE_MME -DEMIT_ASN_DEBUG=1 -DUSER_MODE - S1AP_BUILT_OBJS += $(S1AP_OBJS) $(addprefix $(OPENAIR2_DIR)/S1AP/MESSAGES/, $(S1AP_ASN_MODULE_SOURCES)) - S1AP_BUILT_OBJS += $(OPENAIR3_DIR)/OPENAIRMME/SCTP/sctp_primitives_client.o -endif - - -ASN1RELDIR=R9.8 -ifeq ($(USE_MME), R8) - ASN1RELDIR=R8.10 -else - CFLAGS_S1AP += -DUPDATE_RELEASE_9 -endif -S1AP_DIR=$(OPENAIR2_DIR)/S1AP -ASN1MESSAGESDIR=$(S1AP_DIR)/MESSAGES -ASN1DIR=$(ASN1MESSAGESDIR)/ASN1 - -all: lte-enb - -$(LFDS_DIR)/bin/liblfds611.a: - $(MAKE) -C $(LFDS_DIR) -f makefile.linux - - -$(RTAI_OBJ): %.o : %.c - @echo Compiling $< ... - @$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) -o $@ $< - -$(OBJ) $(ASN1_MSG_OBJS1): %.o : %.c - @echo Compiling $< ... - @$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $< - -$(S1AP_BUILT_OBJS): %.o : %.c - @echo Compiling $< - @$(CC) -Wall -c $(CFLAGS_S1AP) $(S1AP_Incl) $(UTIL_incl) -o $@ $< - -$(ASN1MESSAGESDIR)/s1ap_ieregen.stamp: $(ASN1DIR)/$(ASN1RELDIR)/S1AP-PDU-Contents.asn $(ASN1DIR)/asn1tostruct.py - echo Timestamp > $@ - (cd $(ASN1DIR) && python $(ASN1DIR)/asn1tostruct.py -f$<) - -$(ASN1MESSAGESDIR)/s1ap_asn1regen.stamp: $(ASN1DIR)/$(ASN1RELDIR)/S1AP-CommonDataTypes.asn $(ASN1DIR)/$(ASN1RELDIR)/S1AP-Constants.asn $(ASN1DIR)/$(ASN1RELDIR)/S1AP-IEs.asn $(ASN1DIR)/$(ASN1RELDIR)/S1AP-PDU.asn - echo Timestamp > $@ - (cd $(ASN1MESSAGESDIR) && asn1c -gen-PER -fnative-types -fskeletons-copy $^) - -$(S1AP_DIR)/libs1ap.a: $(ASN1MESSAGESDIR)/s1ap_ieregen.stamp $(ASN1MESSAGESDIR)/s1ap_asn1regen.stamp $(S1AP_BUILT_OBJS) - @echo Creating $@ - $(AR) rcs $@ $^ - -$(LFDS_DIR)/bin/liblfds611.a: - $(MAKE) -C $(LFDS_DIR) -f makefile.linux - -ifdef USE_MME - lte-enb: $(OBJ) $(S1AP_DIR)/libs1ap.a $(ASN1_MSG_OBJS1) $(RTAI_OBJ) $(LFDS_DIR)/bin/liblfds611.a -else - lte-enb: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) $(LFDS_DIR)/bin/liblfds611.a -endif - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) -o lte-enb $(LDFLAGS) $(LFDS_DIR)/bin/liblfds611.a - - - -nasmesh: - (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && $(MAKE)) - (cd $(OPENAIR2_DIR) && $(MAKE) nasmesh_netlink.ko) - (sudo insmod $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko) -rb_tool: - (cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && $(MAKE)) - -nasmesh_install: - (sudo rmmod nasmesh) - (sudo insmod $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko) - -clean: - rm -rf $(OBJ) $(RTAI_OBJ) - rm -f $(S1AP_BUILT_OBJS) - rm -f $(ASN1MESSAGESDIR)/libs1ap.a - -cleanasn1: - rm -f $(ASN1_MSG_OBJS1) - $(shell cd $(OPENAIR2_DIR)/RRC/LITE/MESSAGES ; rm -f $(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS) *.o *.d ) - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.am.sample - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/Makefile.inc.generated - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/.lock-rel8 - rm -f $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/asn1c/ASN1_files/.lock-rel10 - -cleanall: clean cleanasn1 - rm -rf condtest synctest lte-softmodem - rm -rf synctest_eNB synctest_UE - -show: - @echo $(CFLAGS) - @echo $(EXTRA_CFLAGS) - @echo $(OBJ) $(RTAI_OBJ) - @echo rrc_cellular variable is $(rrc_cellular) - @echo eNB_flag is $(eNB_flag) - @echo UE_flag is $(UE_flag) - @echo IS_REL8 is $(IS_REL8) - @echo IS_REL10 is $(IS_REL10) - -beautiful: - astyle --style=gnu -s2 $(SRC) diff --git a/targets/RT/USER/Makefile.msg_many b/targets/RT/USER/Makefile.msg_many deleted file mode 100644 index bc7840c1e574c63a7fb8344e9dea882db9883a4c..0000000000000000000000000000000000000000 --- a/targets/RT/USER/Makefile.msg_many +++ /dev/null @@ -1,21 +0,0 @@ -CFLAGS = $(shell rtai-config --lxrt-cflags) -LDFLAGS = $(shell rtai-config --lxrt-ldflags) -lpthread -llxrt -lm - -CFLAGS += -D__IN_RTAI__ -Wall -O2 -I. - -OBJS = msg_many.o msg_helper.o - -all: msg_many - -msg_many: $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) - -$(OBJS): msg_many.h - -run: msg_many - rtai-load msg_many --verbose - -.PHONY: clean -clean: - rm -f msg_many $(OBJS) - diff --git a/targets/RT/USER/UE_transport_IQ.c b/targets/RT/USER/UE_transport_IQ.c deleted file mode 100644 index 16f491263d6ea604955cb63651f04bb76c518c39..0000000000000000000000000000000000000000 --- a/targets/RT/USER/UE_transport_IQ.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file UE_transport_IQ.c - * \brief UE transport IQ sampels - * \author Katerina Trilyraki, Navid Nikaein, Raymond Knopp - * \date 2015 - * \version 0.1 - * \company Eurecom - * \maintainer: navid.nikaein@eurecom.fr - * \note - * \warning very experimental - */ - -#include <unistd.h> -#include <time.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <signal.h> - -#include "common_lib.h" -#include "PHY/defs.h" -#include "rrh_gw.h" -#include "rrh_gw_externs.h" - -#define START_CMD 1 -#define RRH_UE_PORT 51000 -#define RRH_UE_DEST_IP "127.0.0.1" -#define PRINTF_PERIOD 3750 - -/****************************************************************************** - ** FUNCTION PROTOTYPES ** - ******************************************************************************/ -void *rrh_proc_UE_thread(void *); -void *rrh_UE_thread(void *); -void *rrh_UE_rx_thread(void *); -void *rrh_UE_tx_thread(void *); - - - -openair0_timestamp timestamp_UE_tx[4]= {0,0,0,0},timestamp_UE_rx[4]= {0,0,0,0}; -openair0_timestamp nrt_UE_counter[4]= {0,0,0,0}; - -pthread_t main_rrh_UE_thread,main_rrh_proc_UE_thread; -pthread_attr_t attr, attr_proc; -struct sched_param sched_param_rrh, sched_param_rrh_proc; -pthread_cond_t sync_UE_cond[4]; -pthread_mutex_t sync_UE_mutex[4]; - -int32_t overflow_rx_buffer_UE[4]= {0,0,0,0}; -int32_t nsamps_UE[4]= {0,0,0,0}; -int32_t UE_tx_started=0,UE_rx_started=0; -int32_t RT_flag_UE=0, NRT_flag_UE=1; -int32_t counter_UE_rx[4]= {0,0,0,0}; -int32_t counter_UE_tx[4]= {0,0,0,0}; -int32_t **tx_buffer_UE, **rx_buffer_UE; - -int sync_UE_rx[4]= {-1,-1,-1,-1}; -void *rrh_UE_thread_status; - - -void *rx_ue[2]; // FIXME hard coded array size; indexed by lte_frame_parms.nb_antennas_rx -void *tx_ue[2]; // FIXME hard coded array size; indexed by lte_frame_parms.nb_antennas_tx - - -void config_UE_mod( rrh_module_t *dev_ue, uint8_t RT_flag,uint8_t NRT_flag) { - - int i; - int error_code_UE, error_code_proc_UE; - - RT_flag_UE=RT_flag; - NRT_flag_UE=NRT_flag; - - pthread_attr_init(&attr); - sched_param_rrh.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_attr_init(&attr_proc); - sched_param_rrh_proc.sched_priority = sched_get_priority_max(SCHED_FIFO-1); - - pthread_attr_setschedparam(&attr,&sched_param_rrh); - pthread_attr_setschedpolicy(&attr,SCHED_FIFO); - pthread_attr_setschedparam(&attr_proc,&sched_param_rrh_proc); - pthread_attr_setschedpolicy(&attr_proc,SCHED_FIFO-1); - - - for (i=0; i<4; i++) { - pthread_mutex_init(&sync_UE_mutex[i],NULL); - pthread_cond_init(&sync_UE_cond[i],NULL); - } - - error_code_UE = pthread_create(&main_rrh_UE_thread, &attr, rrh_UE_thread, (void *)dev_ue); - error_code_proc_UE = pthread_create(&main_rrh_proc_UE_thread, &attr_proc, rrh_proc_UE_thread, (void *)dev_ue); - - if (error_code_UE) { - printf("Error while creating UE thread\n"); - exit(-1); - } - - if (error_code_proc_UE) { - printf("Error while creating UE proc thread\n"); - exit(-1); - } - -} - - -/*! \fn void *rrh_proc_UE_thread((void *)dev_ue) -* \brief this function -* \param[in] -* \param[out] -* \return -* \note -* @ingroup _oai -*/ -void *rrh_proc_UE_thread(void * arg) { - - int antenna_index,i; - openair0_timestamp truncated_timestamp, truncated_timestamp_final, last_hw_counter=0; - struct timespec time_req, time_rem; - int16_t *txp,*rxp; - unsigned int samples_per_frame=0; - rrh_module_t *dev=(rrh_module_t *)arg; - - samples_per_frame= dev->eth_dev.openair0_cfg->samples_per_frame; - AssertFatal(samples_per_frame <=0, "invalide samples_per_frame !%u\n",samples_per_frame); - - time_req.tv_sec = 0; - time_req.tv_nsec = 1000; - - while (rrh_exit==0) { - //wait until some data has been copied - for (antenna_index=0; antenna_index<4; antenna_index++) { - if (sync_UE_rx[antenna_index]==0) { - if (!UE_tx_started) { - UE_tx_started=1; //Set this flag to 1 to indicate that a UE started retrieving data - if (RT_flag_UE==1) { - last_hw_counter=hw_counter; - } - } else { - if (RT_flag_UE==1) { - if (hw_counter > last_hw_counter+1) { - printf("L1"); - // goto end_copy_UE; - } else { - while (hw_counter < last_hw_counter+1) - nanosleep(&time_req,&time_rem); - } - } - } - - truncated_timestamp = timestamp_UE_tx[antenna_index]%(samples_per_frame); - truncated_timestamp_final = (timestamp_UE_tx[antenna_index]+nsamps_UE[antenna_index])%samples_per_frame; - - if ((truncated_timestamp + nsamps_UE[antenna_index]) > samples_per_frame) { - if ((timestamp_eNB_rx[antenna_index]%samples_per_frame < nsamps_UE[antenna_index]) && (eNB_rx_started==1)) { - overflow_rx_buffer_eNB[antenna_index]++; - printf("eNB Overflow[%d] : %d, timestamp : %d\n",antenna_index,overflow_rx_buffer_eNB[antenna_index],(int)truncated_timestamp); - - if (NRT_flag_UE==1) { - while ((timestamp_eNB_rx[antenna_index]%samples_per_frame) < nsamps_UE[antenna_index]) - nanosleep(&time_req,&time_rem); - } - } - - rxp = (int16_t*)&rx_buffer_eNB[antenna_index][truncated_timestamp]; - txp = (int16_t*)&tx_buffer_UE[antenna_index][truncated_timestamp]; - - for (i=0; i<(samples_per_frame<<1)-(truncated_timestamp<<1); i++) { - rxp[i] = txp[i]>>6; - } - - rxp = (int16_t*)&rx_buffer_eNB[antenna_index][0]; - txp = (int16_t*)&tx_buffer_UE[antenna_index][0]; - - for (i=0; i<nsamps_eNB[antenna_index]-(samples_per_frame)+(truncated_timestamp); i++) { - rxp[i] = txp[i]>>6; - } - - } else { - if (((truncated_timestamp < (timestamp_eNB_rx[antenna_index]%samples_per_frame)) && - (truncated_timestamp_final > (timestamp_eNB_rx[antenna_index]%samples_per_frame))) && - (eNB_rx_started==1)) { - overflow_rx_buffer_eNB[antenna_index]++; - printf("eNB Overflow[%d] : %d, timestamp : %d\n",antenna_index,overflow_rx_buffer_eNB[antenna_index],(int)truncated_timestamp); - - if (NRT_flag_UE==1) { - while (truncated_timestamp_final > timestamp_eNB_rx[antenna_index]%samples_per_frame) - nanosleep(&time_req,&time_rem); - } - } - - rxp = (int16_t*)&rx_buffer_eNB[antenna_index][truncated_timestamp]; - txp = (int16_t*)&tx_buffer_UE[antenna_index][truncated_timestamp]; - - for (i=0; i<(nsamps_eNB[antenna_index]); i++) { - rxp[i] =txp[i]>>6; - } - - } - //end_copy_UE : - last_hw_counter=hw_counter; - pthread_mutex_lock(&sync_UE_mutex[antenna_index]); - sync_UE_rx[antenna_index]--; - pthread_mutex_unlock(&sync_UE_mutex[antenna_index]); - - } - } - - } - - return(0); -} - -/*! \fn void *rrh_UE_thread(void *arg) -* \brief this function -* \param[in] -* \param[out] -* \return -* \note -* @ingroup _oai -*/ -void *rrh_UE_thread(void *arg) { - - rrh_module_t *dev=(rrh_module_t *)arg; - - struct sched_param sched_param_UE_rx, sched_param_UE_tx; - int16_t i,cmd; //,nsamps,antenna_index; - //struct timespec time_req_1us; - pthread_t UE_rx_thread, UE_tx_thread; - pthread_attr_t attr_UE_rx, attr_UE_tx; - int error_code_UE_rx, error_code_UE_tx; - void *tmp; - unsigned int samples_per_frame=0; - - samples_per_frame= dev->eth_dev.openair0_cfg->samples_per_frame; - //time_req_1us.tv_sec = 0; - //time_req_1us.tv_nsec = 1000; - - while (rrh_exit==0) { - - cmd=dev->eth_dev.trx_start_func(&dev->eth_dev); - - /* allocate memory for TX/RX buffers */ - rx_buffer_UE = (int32_t**)malloc16(dev->eth_dev.openair0_cfg->rx_num_channels*sizeof(int32_t*)); - tx_buffer_UE = (int32_t**)malloc16(dev->eth_dev.openair0_cfg->tx_num_channels*sizeof(int32_t*)); - - for (i=0; i<dev->eth_dev.openair0_cfg->rx_num_channels; i++) { - tmp=(void *)malloc(sizeof(int32_t)*(samples_per_frame+4)); - memset(tmp,0,sizeof(int32_t)*(samples_per_frame+4)); - rx_buffer_UE[i]=(tmp+4*sizeof(int32_t)); - } - - for (i=0; i<dev->eth_dev.openair0_cfg->tx_num_channels; i++) { - tmp=(void *)malloc(sizeof(int32_t)*(samples_per_frame+4)); - memset(tmp,0,sizeof(int32_t)*(samples_per_frame+4)); - tx_buffer_UE[i]=(tmp+4*sizeof(int32_t)); - } - - printf("Client %s:%d is connected (DL_RB=%d) rt=%d|%d. \n" , dev->eth_dev.openair0_cfg->remote_addr, - dev->eth_dev.openair0_cfg->remote_port, - dev->eth_dev.openair0_cfg->num_rb_dl, - dev->eth_dev.openair0_cfg->rx_num_channels, - dev->eth_dev.openair0_cfg->tx_num_channels); - - if (cmd==START_CMD) { - - pthread_attr_init(&attr_UE_rx); - pthread_attr_init(&attr_UE_tx); - sched_param_UE_rx.sched_priority = sched_get_priority_max(SCHED_FIFO); - sched_param_UE_tx.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_attr_setschedparam(&attr_UE_rx,&sched_param_UE_rx); - pthread_attr_setschedparam(&attr_UE_tx,&sched_param_UE_tx); - pthread_attr_setschedpolicy(&attr_UE_rx,SCHED_FIFO); - pthread_attr_setschedpolicy(&attr_UE_tx,SCHED_FIFO); - - error_code_UE_rx = pthread_create(&UE_rx_thread, &attr_UE_rx, rrh_UE_rx_thread, (void *)&dev); - error_code_UE_tx = pthread_create(&UE_tx_thread, &attr_UE_tx, rrh_UE_tx_thread, (void *)&dev); - - if (error_code_UE_rx) { - printf("Error while creating UE RX thread\n"); - exit(-1); - } - - if (error_code_UE_tx) { - printf("Error while creating UE TX thread\n"); - exit(-1); - } - - while (rrh_exit==0) - sleep(1); - } - } - - - rrh_UE_thread_status = 0; - pthread_exit(&rrh_UE_thread_status); - - return(0); -} - - -/*! \fn void *rrh_UE_rx_thread(void *arg) -* \brief this function -* \param[in] -* \param[out] -* \return -* \note -* @ingroup _oai -*/ -void *rrh_UE_rx_thread(void *arg) { - - rrh_module_t *dev = (rrh_module_t *)arg; - struct timespec time0,time1,time2; - struct timespec time_req_1us, time_rem_1us; - ssize_t bytes_sent; - int antenna_index, nsamps; - int trace_cnt=0; - unsigned long long max_rx_time=0, min_rx_time=133333, total_rx_time=0, average_rx_time=133333, s_period=0, trial=0; - unsigned int samples_per_frame=0; - openair0_timestamp last_hw_counter=0; - - antenna_index = 0; - nsamps = dev->eth_dev.openair0_cfg->samples_per_packet; - samples_per_frame = dev->eth_dev.openair0_cfg->samples_per_frame; - - /* TODO: check if setting time0 has to be done here */ - clock_gettime(CLOCK_MONOTONIC,&time0); - - while (rrh_exit == 0) { - if (!UE_rx_started) { - UE_rx_started=1; //Set this flag to 1 to indicate that a UE started retrieving data - - if (RT_flag_UE==1) { - last_hw_counter=hw_counter; - } - } else { - if (RT_flag_UE==1) { - if (hw_counter > last_hw_counter+1) { - printf("L1"); - //goto end_copy_UE; - } else { - while (hw_counter < last_hw_counter+1) - nanosleep(&time_req_1us,&time_rem_1us); - } - } - } - - clock_gettime(CLOCK_MONOTONIC,&time1); - - // send return - - if ((timestamp_UE_rx[antenna_index]%(samples_per_frame)+nsamps) > samples_per_frame) { // Wrap around if nsamps exceeds the buffer limit - if (((timestamp_eNB_tx[antenna_index]%(samples_per_frame)) < ((timestamp_UE_rx[antenna_index]+nsamps)%(samples_per_frame))) && (eNB_tx_started==1)) { - printf("UE underflow wraparound timestamp_UE_rx : %d, timestamp_eNB_tx : %d\n", - (int)(timestamp_UE_rx[antenna_index]%(samples_per_frame)), - (int)(timestamp_eNB_tx[antenna_index]%samples_per_frame)); - - if (NRT_flag_UE==1) { - while ((timestamp_eNB_tx[antenna_index]%samples_per_frame) < ((timestamp_UE_rx[antenna_index]+nsamps)%(samples_per_frame))) - nanosleep(&time_req_1us,&time_rem_1us); - } - } - - rx_ue[antenna_index]=(void*)&rx_buffer_UE[antenna_index][timestamp_UE_rx[antenna_index]%(samples_per_frame)]; - if ((bytes_sent =dev->eth_dev.trx_write_func (dev, - timestamp_UE_rx[antenna_index], - rx_ue, - ( samples_per_frame- (timestamp_eNB_rx[antenna_index]%(samples_per_frame)) ), - antenna_index, - 0))<0) - perror("RRH UE : sendto for RX"); - - rx_ue[antenna_index]=(void*)&rx_buffer_UE[antenna_index][3]; - if ((bytes_sent =dev->eth_dev.trx_write_func (dev, - timestamp_UE_rx[antenna_index], - rx_ue, - (nsamps - samples_per_frame + (timestamp_eNB_rx[antenna_index]%(samples_per_frame))), - antenna_index, - 0))<0) - perror("RRH UE : sendto for RX"); - - } else { - if (((timestamp_UE_rx[antenna_index]%samples_per_frame)< timestamp_eNB_tx[antenna_index]%samples_per_frame) && - (((timestamp_UE_rx[antenna_index]+nsamps)%samples_per_frame) > (timestamp_eNB_tx[antenna_index]%samples_per_frame)) && - (eNB_tx_started==1) ) { - printf("UE underflow timestamp_UE_rx : %d, timestamp_eNB_tx : %d\n", - (int)(timestamp_UE_rx[antenna_index]%samples_per_frame), - (int)(timestamp_eNB_tx[antenna_index]%samples_per_frame)); - - if (NRT_flag_UE==1) { - while (((timestamp_UE_rx[antenna_index]+nsamps)%samples_per_frame) > (timestamp_eNB_tx[antenna_index]%samples_per_frame)) { - nanosleep(&time_req_1us,&time_rem_1us); - } - } - } - - rx_ue[antenna_index]=(void*)&rx_buffer_UE[antenna_index][timestamp_UE_rx[antenna_index]%(samples_per_frame)]; - if ((bytes_sent = dev->eth_dev.trx_write_func (dev, - timestamp_UE_rx[antenna_index], - rx_ue, - nsamps, - antenna_index, - 0))<0) - perror("RRH UE thread: sendto for RX"); - } - - timestamp_UE_rx[antenna_index]+=nsamps; - last_hw_counter=hw_counter; - - clock_gettime(CLOCK_MONOTONIC,&time2); - - if (trace_cnt++ > 10) { - total_rx_time = (unsigned int)(time2.tv_nsec - time0.tv_nsec); - - if (total_rx_time < 0) total_rx_time=1000000000-total_rx_time; - - if ((total_rx_time > 0) && (total_rx_time < 1000000000)) { - trial++; - - if (total_rx_time < min_rx_time) - min_rx_time = total_rx_time; - - if (total_rx_time > max_rx_time) - max_rx_time = total_rx_time; - - average_rx_time = (long long unsigned int)((average_rx_time*trial)+total_rx_time)/(trial+1); - } - - if (s_period++ == PRINTF_PERIOD) { - s_period=0; - printf("Average UE RX time : %llu\tMax RX time : %llu\tMin RX time : %llu\n",average_rx_time,max_rx_time,min_rx_time); - - } - - //printf("RX: t1 %llu (time from last send), t2 %llu (sendto of %lu bytes) total time : %llu\n",(long long unsigned int)(time1.tv_nsec - time0.tv_nsec), (long long unsigned int)(time2.tv_nsec - time1.tv_nsec), - // (nsamps<<2)+sizeof(openair0_timestamp),(long long unsigned int)(time2.tv_nsec - time0.tv_nsec)); - - } - - memcpy(&time0,&time2,sizeof(struct timespec)); - - } //while (UE_exit==0) - - return(0); - -} - - -/*! \fn void *rrh_UE_tx_thread(void *arg) -* \brief this function -* \param[in] -* \param[out] -* \return -* \note -* @ingroup _oai -*/ -void *rrh_UE_tx_thread(void *arg) { - - struct timespec time0a,time0,time1,time2; - struct timespec time_req_1us, time_rem_1us; - - - rrh_module_t *dev = (rrh_module_t *)arg; - ssize_t bytes_received; - int antenna_index, nsamps; - unsigned int samples_per_frame=0; - - antenna_index = 0; - nsamps = dev->eth_dev.openair0_cfg->samples_per_packet; - samples_per_frame = dev->eth_dev.openair0_cfg->samples_per_frame; - - - while (rrh_exit == 0) { - - clock_gettime(CLOCK_MONOTONIC,&time0a); - - bytes_received = dev->eth_dev.trx_read_func(dev, - ×tamp_UE_tx[antenna_index], - tx_ue, - nsamps, - antenna_index); - - clock_gettime(CLOCK_MONOTONIC,&time1); - - if (NRT_flag_UE==1) { - nrt_UE_counter[antenna_index]++; - } - printf(" first part size: %d second part size: %"PRId64" idx=%"PRId64"\n", - (int32_t)(((samples_per_frame)<<2)-((timestamp_UE_tx[antenna_index]%(samples_per_frame))<<2)), - (nsamps<<2)-((samples_per_frame)<<2)+((timestamp_UE_tx[antenna_index]%(samples_per_frame))<<2), - timestamp_UE_tx[antenna_index]%(samples_per_frame)); - if ((timestamp_UE_tx[antenna_index]%(samples_per_frame)+nsamps) > samples_per_frame) { // Wrap around if nsamps exceeds the buffer limit - memcpy(&tx_buffer_UE[antenna_index][timestamp_UE_tx[antenna_index]%(samples_per_frame)],(void*)(tx_ue[antenna_index]), - (samples_per_frame<<2)-((timestamp_UE_tx[antenna_index]%(samples_per_frame))<<2)); - - memcpy(&tx_buffer_UE[antenna_index][0], (void*)(tx_ue[antenna_index]+(samples_per_frame*4)-((timestamp_UE_tx[antenna_index]%(samples_per_frame))<<2)), - (nsamps<<2)-((samples_per_frame-(timestamp_UE_tx[antenna_index]%(samples_per_frame)))<<2)); - //printf("Received UE TX samples for antenna %d, nsamps %d (%d)\n",antenna_index,nsamps,(int)(bytes_received>>2)); - } else { - memcpy(&tx_buffer_UE[antenna_index][timestamp_UE_tx[antenna_index]%(samples_per_frame)], (void*)(tx_ue[antenna_index]),(nsamps<<2)); - } - - while (sync_UE_rx[antenna_index]==0) - nanosleep(&time_req_1us,&time_rem_1us); - - pthread_mutex_lock(&sync_UE_mutex[antenna_index]); - sync_UE_rx[antenna_index]++; - - if (!sync_UE_rx[antenna_index]) { - counter_UE_tx[antenna_index]=(counter_UE_tx[antenna_index]+nsamps)%samples_per_frame; - nsamps_UE[antenna_index]=nsamps; - } else { - printf("rrh_eNB_proc thread is busy, will exit\n"); - exit(-1); - } - - pthread_mutex_unlock(&sync_UE_mutex[antenna_index]); - - clock_gettime(CLOCK_MONOTONIC,&time2); - - memcpy(&time0,&time2,sizeof(struct timespec)); - - } - - return(0); - -} - - diff --git a/targets/RT/USER/condtest.c b/targets/RT/USER/condtest.c deleted file mode 100644 index b6f00e80b3ac9a68e2ddc2ad32cb90e10fe7b246..0000000000000000000000000000000000000000 --- a/targets/RT/USER/condtest.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sched.h> - - -#include <rtai_lxrt.h> -#include <rtai_sem.h> -#include <rtai_msg.h> - -#define PERIOD 100000000 -#define THRESHOLD 1 - -static SEM *mutex; -static CND *cond; - -static int thread0; -static int thread1; - -static int instance_cnt=-1; //0 means worker is busy, -1 means its free - -static void *fun0(void *arg) -{ - RT_TASK *task; - int done1=0, cnt1=0; - RTIME right_now; - int ret; - - task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF); - mlockall(MCL_CURRENT | MCL_FUTURE); - - rt_make_hard_real_time(); - - while (cnt1 < THRESHOLD) { - rt_sem_wait(mutex); - rt_printk("fun0: Hello World %d, instance_cnt %d!\n",cnt1,instance_cnt); - - while (instance_cnt<0) { - ret = rt_cond_wait(cond, mutex); - - if (ret != 0) { - rt_printk("error in rt_cond_wait, code %d\n",ret); - - switch (ret) { - case RTE_PERM: - rt_printk("error RTE_PERM %d\n",ret); - break; - - case RTE_UNBLKD: - rt_printk("error RTE_UNBLKD %d\n",ret); - break; - - case RTE_OBJREM: - rt_printk("error RTE_OBJREM %d\n",ret); - break; - - default: - rt_printk("unknown error code %d\n",ret); - break; - } - - break; - } - } - - rt_sem_signal(mutex); - - // do some work here - cnt1++; - - rt_sem_wait(mutex); - instance_cnt--; - rt_sem_signal(mutex); - - } - - // makes task soft real time - rt_make_soft_real_time(); - - printf("Back to soft RT\n"); - // clean task - rt_task_delete(task); - printf("Task deleted. returning\n"); - return 0; -} - - -int main(void) -{ - RT_TASK *task; - RTIME now; - int cnt=0; - - // make main thread LXRT soft realtime - task = rt_task_init_schmod(nam2num("MYTASK"), 9, 0, 0, SCHED_FIFO, 0xF); - mlockall(MCL_CURRENT | MCL_FUTURE); - - // start realtime timer and scheduler - //rt_set_oneshot_mode(); - rt_set_periodic_mode(); - start_rt_timer(0); - - now = rt_get_time() + 10*PERIOD; - rt_task_make_periodic(task, now, PERIOD); - - printf("Init mutex and cond.\n"); - mutex = rt_sem_init(nam2num("MUTEX"), 1); - - if (mutex==0) - printf("Error init mutex\n"); - - cond = rt_cond_init(nam2num("CONDITION")); - - if (cond==0) - printf("Error init cond\n"); - - thread0 = rt_thread_create(fun0, NULL, 10000); - //thread1 = rt_thread_create(fun1, NULL, 20000); - - //rt_sleep(PERIOD); - - while (cnt < THRESHOLD) { - rt_task_wait_period(); - rt_printk("main: Hello World %d!\n",cnt); - rt_sem_wait(mutex); //now the mutex should have value 0 - - if (instance_cnt==0) { - rt_sem_signal(mutex); //now the mutex should have vaule 1 - rt_printk("worker thread busy!\n"); - } else { - instance_cnt++; - rt_cond_signal(cond); - rt_sem_signal(mutex); //now the mutex should have vaule 1 - rt_printk("signaling worker thread to start!\n"); - } - - cnt++; - } - - // wait for end of program - printf("TYPE <ENTER> TO TERMINATE\n"); - getchar(); - - // cleanup - stop_rt_timer(); - return 0; -} diff --git a/targets/RT/USER/eNB_transport_IQ.c b/targets/RT/USER/eNB_transport_IQ.c deleted file mode 100644 index b822a5ea75bd81faed46b3097b380adeeeaad9d8..0000000000000000000000000000000000000000 --- a/targets/RT/USER/eNB_transport_IQ.c +++ /dev/null @@ -1,744 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file eNB_transport_IQ.c - * \brief eNB transport IQ samples - * \author Katerina Trilyraki, Navid Nikaein, Raymond Knopp - * \date 2015 - * \version 0.1 - * \company Eurecom - * \maintainer: navid.nikaein@eurecom.fr - * \note - * \warning very experimental - */ -#include <unistd.h> -#include <time.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <signal.h> - -#include "common_lib.h" -#include "PHY/defs.h" -#include "rrh_gw.h" -#include "rrh_gw_externs.h" -#include "rt_wrapper.h" - -#define PRINTF_PERIOD 3750 -#define HEADER_SIZE ((sizeof(int32_t) + sizeof(openair0_timestamp))>>2) - -pthread_cond_t sync_eNB_cond[4]; -pthread_mutex_t sync_eNB_mutex[4]; -pthread_mutex_t sync_trx_mutex=PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t sync_trx_cond=PTHREAD_COND_INITIALIZER; - -openair0_timestamp nrt_eNB_counter[4]= {0,0,0,0}; -int32_t overflow_rx_buffer_eNB[4]= {0,0,0,0}; -int32_t nsamps_eNB[4]= {0,0,0,0}; -int32_t eNB_tx_started=0,eNB_rx_started=0; -int32_t counter_eNB_rx[4]= {0,0,0,0}; -int32_t counter_eNB_tx[4]= {0,0,0,0}; -uint8_t RT_flag_eNB,NRT_flag_eNB; -void *rrh_eNB_thread_status; -int sync_eNB_rx[4]= {-1,-1,-1,-1}; -unsigned int sync_trx=0; - -int32_t **tx_buffer_eNB; -int32_t **rx_buffer_eNB; -void **rx_eNB; //was fixed to 2 ant -void **tx_eNB; //was fixed to 2 ant - -openair0_timestamp timestamp_eNB_tx[4]= {0,0,0,0};// all antennas must have the same ts -openair0_timestamp timestamp_eNB_rx[4]= {0,0,0,0}; -openair0_timestamp timestamp_rx=0,timestamp_tx=0; - -unsigned int rx_pos=0, next_rx_pos=0; -unsigned int tx_pos=0, tx_pos_rf=0, prev_tx_pos=0; -unsigned int rt_period=0; - -struct itimerspec timerspec; -pthread_mutex_t timer_mutex; - - - -/*! \fn void *rrh_eNB_rx_thread(void *arg) - * \brief this function - * \param[in] - * \return none - * \note - * @ingroup _oai - */ -void *rrh_eNB_rx_thread(void *); -/*! \fn void *rrh_eNB_tx_thread(void *arg) - * \brief this function - * \param[in] - * \return none - * \note - * @ingroup _oai - */ -void *rrh_eNB_tx_thread(void *); -/*! \fn void *rrh_eNB_thread(void *arg) - * \brief this function - * \param[in] - * \return none - * \note - * @ingroup _oai - */ -void *rrh_eNB_thread(void *); -/*! \fn void check_dev_config( rrh_module_t *mod_enb) - * \brief this function - * \param[in] *mod_enb - * \return none - * \note - * @ingroup _oai - */ -static void check_dev_config( rrh_module_t *mod_enb); -/*! \fn void calc_rt_period_ns( openair0_config_t openair0_cfg) - * \brief this function - * \param[in] openair0_cfg - * \return none - * \note - * @ingroup _oai - */ -static void calc_rt_period_ns( openair0_config_t *openair0_cfg); - - - -void config_BBU_mod( rrh_module_t *mod_enb, uint8_t RT_flag, uint8_t NRT_flag) { - - int error_code_eNB; - pthread_t main_rrh_eNB_thread; - pthread_attr_t attr; - struct sched_param sched_param_rrh; - - RT_flag_eNB=RT_flag; - NRT_flag_eNB=NRT_flag; - - /* init socket and have handshake-like msg with client to exchange parameters */ - mod_enb->eth_dev.trx_start_func(&mod_enb->eth_dev);//change port make it plus_id - - mod_enb->devs->openair0_cfg = mod_enb->eth_dev.openair0_cfg; - - /* check sanity of configuration parameters and print */ - check_dev_config(mod_enb); - if (rf_config_file[0] == '\0') - mod_enb->devs->openair0_cfg->configFilename = NULL; - else - mod_enb->devs->openair0_cfg->configFilename = rf_config_file; - /* initialize and configure the RF device */ - if (openair0_device_load(mod_enb->devs, mod_enb->devs->openair0_cfg)<0) { - LOG_E(RRH,"Exiting, cannot initialize RF device.\n"); - exit(-1); - } else { - if (mod_enb->devs->type != NONE_DEV) { - /* start RF device */ - if (mod_enb->devs->type == EXMIMO_DEV) { - //call start function for exmino - } else { - - if (mod_enb->devs->trx_start_func(mod_enb->devs)!=0) - LOG_E(RRH,"Unable to initiate RF device.\n"); - else - LOG_I(RRH,"RF device has been initiated.\n"); - } - - } - } - - /* create main eNB module thread - main_rrh_eNB_thread allocates memory - for TX/RX buffers and creates TX/RX - threads for every eNB module */ - pthread_attr_init(&attr); - sched_param_rrh.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_attr_setschedparam(&attr,&sched_param_rrh); - pthread_attr_setschedpolicy(&attr,SCHED_FIFO); - error_code_eNB = pthread_create(&main_rrh_eNB_thread, &attr, rrh_eNB_thread, (void *)mod_enb); - - if (error_code_eNB) { - LOG_E(RRH,"Error while creating eNB thread\n"); - exit(-1); - } - -} - - -void *rrh_eNB_thread(void *arg) { - - rrh_module_t *dev=(rrh_module_t *)arg; - pthread_t eNB_rx_thread, eNB_tx_thread; - int error_code_eNB_rx, error_code_eNB_tx; - int32_t i,j; - void *tmp; - unsigned int samples_per_frame=0; - - samples_per_frame = dev->eth_dev.openair0_cfg->samples_per_frame; - - while (rrh_exit==0) { - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TRX, 1 ); - - /* calculate packet period */ - calc_rt_period_ns(dev->eth_dev.openair0_cfg); - - /* allocate memory for TX/RX buffers - each antenna port has a TX and a RX buffer - each TX and RX buffer is of (samples_per_frame + HEADER_SIZE) samples (size of samples is 4 bytes) */ - rx_buffer_eNB = (int32_t**)malloc16(dev->eth_dev.openair0_cfg->rx_num_channels*sizeof(int32_t*)); - tx_buffer_eNB = (int32_t**)malloc16(dev->eth_dev.openair0_cfg->tx_num_channels*sizeof(int32_t*)); - LOG_D(RRH,"rx_buffer_eNB address =%p tx_buffer_eNB address =%p \n",rx_buffer_eNB,tx_buffer_eNB); - - /* rx_buffer_eNB points to the beginning of data */ - for (i=0; i<dev->eth_dev.openair0_cfg->rx_num_channels; i++) { - tmp=(void *)malloc16(sizeof(int32_t)*(samples_per_frame + 32)); - memset(tmp,0,sizeof(int32_t)*(samples_per_frame + 32)); - rx_buffer_eNB[i]=( tmp + (32*sizeof(int32_t)) ); - LOG_D(RRH,"i=%d rx_buffer_eNB[i]=%p tmp= %p\n",i,rx_buffer_eNB[i],tmp); - } - /* tx_buffer_eNB points to the beginning of data */ - for (i=0; i<dev->eth_dev.openair0_cfg->tx_num_channels; i++) { - tmp=(void *)malloc16(sizeof(int32_t)*(samples_per_frame + 32)); - memset(tmp,0,sizeof(int32_t)*(samples_per_frame + 32)); - tx_buffer_eNB[i]=( tmp + (32*sizeof(int32_t)) ); - LOG_D(RRH,"i= %d tx_buffer_eNB[i]=%p tmp= %p \n",i,tx_buffer_eNB[i],tmp); - } - /* dummy initialization for TX/RX buffers */ - for (i=0; i<dev->eth_dev.openair0_cfg->rx_num_channels; i++) { - for (j=0; j<samples_per_frame; j++) { - rx_buffer_eNB[i][j]=32+i; - } - } - /* dummy initialization for TX/RX buffers */ - for (i=0; i<dev->eth_dev.openair0_cfg->tx_num_channels; i++) { - for (j=0; j<samples_per_frame; j++) { - tx_buffer_eNB[i][j]=12+i; - } - } - /* allocate TX/RX buffers pointers used in write/read operations */ - rx_eNB = (void**)malloc16(dev->eth_dev.openair0_cfg->rx_num_channels*sizeof(int32_t*)); - tx_eNB = (void**)malloc16(dev->eth_dev.openair0_cfg->tx_num_channels*sizeof(int32_t*)); - - /* init mutexes */ - for (i=0; i<dev->eth_dev.openair0_cfg->tx_num_channels; i++) { - pthread_mutex_init(&sync_eNB_mutex[i],NULL); - pthread_cond_init(&sync_eNB_cond[i],NULL); - } - /* init mutexes */ - pthread_mutex_init(&sync_trx_mutex,NULL); - - /* create eNB module's TX/RX threads */ -#ifdef DEADLINE_SCHEDULER - error_code_eNB_rx = pthread_create(&eNB_rx_thread, NULL, rrh_eNB_rx_thread, (void *)dev); - error_code_eNB_tx = pthread_create(&eNB_tx_thread, NULL, rrh_eNB_tx_thread, (void *)dev); - LOG_I(RRH,"[eNB][SCHED] deadline scheduling applied to eNB TX/RX threads\n"); -#else - pthread_attr_t attr_eNB_rx, attr_eNB_tx; - struct sched_param sched_param_eNB_rx, sched_param_eNB_tx; - - pthread_attr_init(&attr_eNB_rx); - pthread_attr_init(&attr_eNB_tx); - sched_param_eNB_rx.sched_priority = sched_get_priority_max(SCHED_FIFO); - sched_param_eNB_tx.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_attr_setschedparam(&attr_eNB_rx,&sched_param_eNB_rx); - pthread_attr_setschedparam(&attr_eNB_tx,&sched_param_eNB_tx); - pthread_attr_setschedpolicy(&attr_eNB_rx,SCHED_FIFO); - pthread_attr_setschedpolicy(&attr_eNB_tx,SCHED_FIFO); - - error_code_eNB_rx = pthread_create(&eNB_rx_thread, &attr_eNB_rx, rrh_eNB_rx_thread, (void *)dev); - error_code_eNB_tx = pthread_create(&eNB_tx_thread, &attr_eNB_tx, rrh_eNB_tx_thread, (void *)dev); - LOG_I(RRH,"[eNB][SCHED] FIFO scheduling applied to eNB TX/RX threads\n"); -#endif - - if (error_code_eNB_rx) { - LOG_E(RRH,"[eNB] Error while creating eNB RX thread\n"); - exit(-1); - } - if (error_code_eNB_tx) { - LOG_E(RRH,"[eNB] Error while creating eNB TX thread\n"); - exit(-1); - } - - /* create timer thread; when no RF device is present a software clock is generated */ - if (dev->devs->type == NONE_DEV) { - - int error_code_timer; - pthread_t main_timer_proc_thread; - - LOG_I(RRH,"Creating timer thread with rt period %d ns.\n",rt_period); - - /* setup the timer to generate an interrupt: - -for the first time in (sample_per_packet/sample_rate) ns - -and then every (sample_per_packet/sample_rate) ns */ - timerspec.it_value.tv_sec = rt_period/1000000000; - timerspec.it_value.tv_nsec = rt_period%1000000000; - timerspec.it_interval.tv_sec = rt_period/1000000000; - timerspec.it_interval.tv_nsec = rt_period%1000000000; - - -#ifdef DEADLINE_SCHEDULER - error_code_timer = pthread_create(&main_timer_proc_thread, NULL, timer_proc, (void *)&timerspec); - LOG_I(RRH,"[eNB][SCHED] deadline scheduling applied to timer thread \n"); -#else - pthread_attr_t attr_timer; - struct sched_param sched_param_timer; - - pthread_attr_init(&attr_timer); - sched_param_timer.sched_priority = sched_get_priority_max(SCHED_FIFO-1); - pthread_attr_setschedparam(&attr_timer,&sched_param_timer); - pthread_attr_setschedpolicy(&attr_timer,SCHED_FIFO-1); - - pthread_mutex_init(&timer_mutex,NULL); - - error_code_timer = pthread_create(&main_timer_proc_thread, &attr_timer, timer_proc, (void *)&timerspec); - LOG_I(RRH,"[eNB][SCHED] FIFO scheduling applied to timer thread \n"); -#endif - - if (error_code_timer) { - LOG_E(RRH,"Error while creating timer proc thread\n"); - exit(-1); - } - - } - - while (rrh_exit==0) - sleep(1); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TRX,0 ); - } - - rrh_eNB_thread_status = 0; - pthread_exit(&rrh_eNB_thread_status); - return(0); -} - -/* Receive from RF and transmit to RRH */ - -void *rrh_eNB_rx_thread(void *arg) { - - /* measurement related vars */ - struct timespec time0,time1,time2; - unsigned long long max_rx_time=0, min_rx_time=rt_period, total_rx_time=0, average_rx_time=rt_period, s_period=0, trial=0; - int trace_cnt=0; - - struct timespec time_req_1us, time_rem_1us; - rrh_module_t *dev = (rrh_module_t *)arg; - ssize_t bytes_sent; - int i=0 ,pck_rx=0, s_cnt=0; - openair0_timestamp last_hw_counter=0; //volatile int64_t - unsigned int samples_per_frame=0,samples_per_subframe=0, spp_rf=0, spp_eth=0; - uint8_t loopback=0,measurements=0; - unsigned int subframe=0; - unsigned int frame=0; - - time_req_1us.tv_sec = 0; - time_req_1us.tv_nsec =1000; //time_req_1us.tv_nsec = (int)rt_period/2;--->granularity issue - spp_eth = dev->eth_dev.openair0_cfg->samples_per_packet; - spp_rf = dev->devs->openair0_cfg->samples_per_packet; - - samples_per_frame = dev->eth_dev.openair0_cfg->samples_per_frame; - samples_per_subframe = (unsigned int)samples_per_frame/10; - loopback = dev->loopback; - measurements = dev->measurements; - next_rx_pos = spp_eth; - -#ifdef DEADLINE_SCHEDULER - struct sched_attr attr; - unsigned int flags = 0; - - attr.size = sizeof(attr); - attr.sched_flags = 0; - attr.sched_nice = 0; - attr.sched_priority = 0; - - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = (0.8 * 100) * 10000;//4 * 10000; - attr.sched_deadline = (0.9 * 100) * 10000;//rt_period-2000; - attr.sched_period = 1 * 1000000;//rt_period; - - if (sched_setattr(0, &attr, flags) < 0 ) { - perror("[SCHED] eNB RX thread: sched_setattr failed (run with sudo)\n"); - exit(-1); - } -#endif - - while (rrh_exit == 0) { - while (rx_pos <(1 + subframe)*samples_per_subframe) { - //LOG_D(RRH,"starting a new send:%d %d\n",sync_trx,frame); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_RX, 1 ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_HW_FRAME_RX, frame); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_HW_SUBFRAME_RX, subframe ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_PCK, pck_rx ); - LOG_D(RRH,"pack=%d rx_pos=%d subframe=%d frame=%d\n ",pck_rx, rx_pos, subframe,frame); - - if (dev->devs->type == NONE_DEV) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_HWCNT, hw_counter ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_LHWCNT, last_hw_counter ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_CNT, s_cnt ); - if (!eNB_rx_started) { - eNB_rx_started=1; // set this flag to 1 to indicate that eNB started - if (RT_flag_eNB==1) { - last_hw_counter=hw_counter;//get current counter - } - } else { - if (RT_flag_eNB==1) { - if (hw_counter > last_hw_counter+1) { - printf("LR"); - } else { - while ((hw_counter < last_hw_counter+1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_RX_SLEEP, 1 ); - nanosleep(&time_req_1us,&time_rem_1us); //rt_sleep_ns(sleep_ns); - s_cnt++; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_RX_SLEEP, 0 ); - } - } - } - } - } - - - if (measurements == 1 ) clock_gettime(CLOCK_MONOTONIC,&time1); - - if (loopback == 1 ) { - if (sync_eNB_rx[i]==0) { - rx_eNB[i] = (void*)&tx_buffer_eNB[i][tx_pos]; - LOG_I(RRH,"tx_buffer_eNB[i][tx_pos]=%d ,tx_pos=%d\n",tx_buffer_eNB[i][tx_pos],tx_pos); - } else { - rx_eNB[i] = (void*)&rx_buffer_eNB[i][rx_pos]; - LOG_I(RRH,"rx_buffer_eNB[i][rx_pos]=%d ,rx_pos=%d\n",rx_buffer_eNB[i][rx_pos],rx_pos); - } - } - - for (i=0; i<dev->eth_dev.openair0_cfg->rx_num_channels; i++) { - rx_eNB[i] = (void*)&rx_buffer_eNB[i][rx_pos]; - LOG_D(RRH," rx_eNB[i]=%p rx_buffer_eNB[i][rx_pos]=%p ,rx_pos=%d, i=%d ts=%d\n",rx_eNB[i],&rx_buffer_eNB[i][rx_pos],rx_pos,i,timestamp_rx); - } - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RXCNT, rx_pos ); - if (dev->devs->type != NONE_DEV) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_RF, 1 ); - /* Read operation to RF device (RX)*/ - if ( dev->devs->trx_read_func (dev->devs, - ×tamp_rx, - rx_eNB, - spp_rf, - dev->devs->openair0_cfg->rx_num_channels - )<0) { - perror("RRH eNB : USRP read"); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_RF, 0 ); - } - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_TS, timestamp_rx&0xffffffff ); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); - if ((bytes_sent = dev->eth_dev.trx_write_func (&dev->eth_dev, - timestamp_rx, - rx_eNB, - spp_eth, - dev->eth_dev.openair0_cfg->rx_num_channels, - 0))<0) { - perror("RRH eNB : ETHERNET write"); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - - /* when there is no RF timestamp is updated by number of samples */ - if (dev->devs->type == NONE_DEV) { - timestamp_rx+=spp_eth; - last_hw_counter=hw_counter; - } - - if (measurements == 1 ) { - - clock_gettime(CLOCK_MONOTONIC,&time2); - - if (trace_cnt++ > 10) { - total_rx_time = (unsigned int)(time2.tv_nsec - time0.tv_nsec); - if (total_rx_time < 0) - total_rx_time=1000000000-total_rx_time; - - if ((total_rx_time > 0) && (total_rx_time < 1000000000)) { - trial++; - if (total_rx_time < min_rx_time) - min_rx_time = total_rx_time; - if (total_rx_time > max_rx_time){ - max_rx_time = total_rx_time; - LOG_I(RRH,"Max value %d update at rx_position %d \n",total_rx_time,timestamp_rx); - } - average_rx_time = (long long unsigned int)((average_rx_time*trial)+total_rx_time)/(trial+1); - } - if (s_period++ == PRINTF_PERIOD) { - s_period=0; - LOG_I(RRH,"Average eNB RX time : %lu ns\tMax RX time : %lu ns\tMin RXX time : %lu ns\n",average_rx_time,max_rx_time,min_rx_time); - } - } - - memcpy(&time0,&time2,sizeof(struct timespec)); - } - - if (loopback == 1 ) { - pthread_mutex_lock(&sync_eNB_mutex[i]); - sync_eNB_rx[i]--; - pthread_mutex_unlock(&sync_eNB_mutex[i]); - } - - rx_pos += spp_eth; - pck_rx++; - next_rx_pos=(rx_pos+spp_eth); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_RX, 0 ); - /* - if (frame>50) { - pthread_mutex_lock(&sync_trx_mutex); - while (sync_trx) { - pthread_cond_wait(&sync_trx_cond,&sync_trx_mutex); - } - sync_trx=1; - LOG_D(RRH,"out of while send:%d %d\n",sync_trx,frame); - pthread_cond_signal(&sync_trx_cond); - pthread_mutex_unlock(&sync_trx_mutex); - }*/ - } // while - - subframe++; - s_cnt=0; - - /* wrap around rx buffer index */ - if (next_rx_pos >= samples_per_frame) - next_rx_pos -= samples_per_frame; - if (rx_pos >= samples_per_frame) - rx_pos -= samples_per_frame; - /* wrap around subframe number */ - if (subframe == 10 ) { - subframe = 0; - frame++; - } - - - } //while (eNB_exit==0) - return 0; -} - -/* Receive from eNB and transmit to RF */ - -void *rrh_eNB_tx_thread(void *arg) { - - struct timespec time0,time1,time2; - - rrh_module_t *dev = (rrh_module_t *)arg; - struct timespec time_req_1us, time_rem_1us; - ssize_t bytes_received; - int i; - //openair0_timestamp last_hw_counter=0; - unsigned int samples_per_frame=0,samples_per_subframe=0; - unsigned int spp_rf=0, spp_eth=0; - uint8_t loopback=0,measurements=0; - unsigned int subframe=0,frame=0; - unsigned int pck_tx=0; - -#ifdef DEADLINE_SCHEDULER - struct sched_attr attr; - unsigned int flags = 0; - - attr.size = sizeof(attr); - attr.sched_flags = 0; - attr.sched_nice = 0; - attr.sched_priority = 0; - - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = (0.8 * 100) * 10000; - attr.sched_deadline = (0.9 * 100) * 10000; - attr.sched_period = 1 * 1000000; - - if (sched_setattr(0, &attr, flags) < 0 ) { - perror("[SCHED] eNB TX thread: sched_setattr failed\n"); - exit(-1); - } -#endif - - time_req_1us.tv_sec = 1; - time_req_1us.tv_nsec = 0; - spp_eth = dev->eth_dev.openair0_cfg->samples_per_packet; - spp_rf = dev->devs->openair0_cfg->samples_per_packet; - samples_per_frame = dev->eth_dev.openair0_cfg->samples_per_frame; - samples_per_subframe = (unsigned int)samples_per_frame/10; - tx_pos=0; - - loopback = dev->loopback; - measurements = dev->measurements; - - while (rrh_exit == 0) { - while (tx_pos < (1 + subframe)*samples_per_subframe) { - - //LOG_D(RRH,"bef lock read:%d %d\n",sync_trx,frame); - //pthread_mutex_lock(&sync_trx_mutex); - - //while (!sync_trx) { - //LOG_D(RRH,"in sync read:%d %d\n",sync_trx,frame); - //pthread_cond_wait(&sync_trx_cond,&sync_trx_mutex); - //} - //LOG_D(RRH,"out of while read:%d %d\n",sync_trx,frame); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TX, 1 ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_HW_FRAME, frame); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_HW_SUBFRAME, subframe ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TX_PCK, pck_tx ); - - if (measurements == 1 ) clock_gettime(CLOCK_MONOTONIC,&time1); - for (i=0; i<dev->eth_dev.openair0_cfg->tx_num_channels; i++) tx_eNB[i] = (void*)&tx_buffer_eNB[i][tx_pos]; - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TXCNT, tx_pos ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); - - /* Read operation to ETHERNET device */ - if (( bytes_received = dev->eth_dev.trx_read_func(&dev->eth_dev, - ×tamp_tx, - tx_eNB, - spp_eth, - dev->eth_dev.openair0_cfg->tx_num_channels))<0) { - perror("RRH eNB : ETHERNET read"); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - - if (dev->devs->type != NONE_DEV) { - LOG_D(RRH," tx_buffer_eNB[i][tx_pos]=%x t_buffer_eNB[i][tx_pos+1]=%x t_buffer_eNB[i][tx_pos+2]=%x \n",tx_buffer_eNB[0][tx_pos],tx_buffer_eNB[0][tx_pos+1],tx_buffer_eNB[0][tx_pos+2]); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_RF, 1 ); - /* Write operation to RF device (TX)*/ - if ( dev->devs->trx_write_func (dev->devs, - timestamp_tx, - tx_eNB, - spp_rf, - dev->devs->openair0_cfg->tx_num_channels, - 1)<0){ - perror("RRH eNB : USRP write"); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_RF, 0 ); - } - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TX_TS, timestamp_tx&0xffffffff ); - - - //if (dev->devs->type == NONE_DEV) last_hw_counter=hw_counter; - - - if (loopback ==1 ) { - while (sync_eNB_rx[i]==0) - nanosleep(&time_req_1us,&time_rem_1us); - - pthread_mutex_lock(&sync_eNB_mutex[i]); - sync_eNB_rx[i]++; - pthread_mutex_unlock(&sync_eNB_mutex[i]); - } - - if (measurements == 1 ) { - clock_gettime(CLOCK_MONOTONIC,&time2); - memcpy(&time0,&time2,sizeof(struct timespec)); - } - - prev_tx_pos=tx_pos; - tx_pos += spp_eth; - pck_tx++; - - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TX, 0 ); - //sync_trx=0; - //pthread_cond_signal(&sync_trx_cond); - //pthread_mutex_unlock(&sync_trx_mutex); - } - - /* wrap around tx buffer index */ - if (tx_pos >= samples_per_frame) - tx_pos -= samples_per_frame; - /* wrap around subframe number */ - subframe++; - if (subframe == 10 ) { - subframe = 0; // the radio frame is complete, start over - frame++; - } - - } //while (eNB_exit==0) - return 0; -} - - -static void calc_rt_period_ns( openair0_config_t *openair0_cfg) { - - rt_period= (double)(openair0_cfg->samples_per_packet/(openair0_cfg->samples_per_frame/10.0)*1000000); - AssertFatal(rt_period > 0, "Invalid rt period !%u\n", rt_period); - LOG_I(RRH,"[eNB] Real time period is set to %u ns\n", rt_period); -} - - -static void check_dev_config( rrh_module_t *mod_enb) { - - AssertFatal( (mod_enb->devs->openair0_cfg->num_rb_dl==100 || mod_enb->devs->openair0_cfg->num_rb_dl==50 || mod_enb->devs->openair0_cfg->num_rb_dl==25 || mod_enb->devs->openair0_cfg->num_rb_dl==6) , "Invalid number of resource blocks! %d\n", mod_enb->devs->openair0_cfg->num_rb_dl); - AssertFatal( mod_enb->devs->openair0_cfg->samples_per_frame > 0 , "Invalid number of samples per frame! %d\n",mod_enb->devs->openair0_cfg->samples_per_frame); - AssertFatal( mod_enb->devs->openair0_cfg->sample_rate > 0.0, "Invalid sample rate! %f\n", mod_enb->devs->openair0_cfg->sample_rate); - AssertFatal( mod_enb->devs->openair0_cfg->samples_per_packet > 0 , "Invalid number of samples per packet! %d\n",mod_enb->devs->openair0_cfg->samples_per_packet); - AssertFatal( mod_enb->devs->openair0_cfg->rx_num_channels > 0 , "Invalid number of RX antennas! %d\n", mod_enb->devs->openair0_cfg->rx_num_channels); - AssertFatal( mod_enb->devs->openair0_cfg->tx_num_channels > 0 , "Invalid number of TX antennas! %d\n", mod_enb->devs->openair0_cfg->tx_num_channels); - AssertFatal( mod_enb->devs->openair0_cfg->rx_freq[0] > 0.0 ,"Invalid RX frequency! %f\n", mod_enb->devs->openair0_cfg->rx_freq[0]); - AssertFatal( mod_enb->devs->openair0_cfg->tx_freq[0] > 0.0 ,"Invalid TX frequency! %f\n", mod_enb->devs->openair0_cfg->tx_freq[0]); - AssertFatal( mod_enb->devs->openair0_cfg->rx_gain[0] > 0.0 ,"Invalid RX gain! %f\n", mod_enb->devs->openair0_cfg->rx_gain[0]); - AssertFatal( mod_enb->devs->openair0_cfg->tx_gain[0] > 0.0 ,"Invalid TX gain! %f\n", mod_enb->devs->openair0_cfg->tx_gain[0]); - AssertFatal( mod_enb->devs->openair0_cfg->rx_bw > 0.0 ,"Invalid RX bw! %f\n", mod_enb->devs->openair0_cfg->rx_bw); - AssertFatal( mod_enb->devs->openair0_cfg->tx_bw > 0.0 ,"Invalid RX bw! %f\n", mod_enb->devs->openair0_cfg->tx_bw); - AssertFatal( mod_enb->devs->openair0_cfg->autocal[0] > 0 , "Invalid auto calibration choice! %d\n", mod_enb->devs->openair0_cfg->autocal[0]); - - printf("\n---------------------RF device configuration parameters---------------------\n"); - - printf("\tMod_id=%d\n \tlog level=%d\n \tDL_RB=%d\n \tsamples_per_frame=%d\n \tsample_rate=%f\n \tsamples_per_packet=%d\n \ttx_sample_advance=%d\n \trx_num_channels=%d\n \ttx_num_channels=%d\n \trx_freq_0=%f\n \ttx_freq_0=%f\n \trx_freq_1=%f\n \ttx_freq_1=%f\n \trx_freq_2=%f\n \ttx_freq_2=%f\n \trx_freq_3=%f\n \ttx_freq_3=%f\n \trxg_mode=%d\n \trx_gain_0=%f\n \ttx_gain_0=%f\n \trx_gain_1=%f\n \ttx_gain_1=%f\n \trx_gain_2=%f\n \ttx_gain_2=%f\n \trx_gain_3=%f\n \ttx_gain_3=%f\n \trx_gain_offset_2=%f\n \ttx_gain_offset_3=%f\n \trx_bw=%f\n \ttx_bw=%f\n \tautocal=%d\n", - mod_enb->devs->openair0_cfg->Mod_id, - mod_enb->devs->openair0_cfg->log_level, - mod_enb->devs->openair0_cfg->num_rb_dl, - mod_enb->devs->openair0_cfg->samples_per_frame, - mod_enb->devs->openair0_cfg->sample_rate, - mod_enb->devs->openair0_cfg->samples_per_packet, - mod_enb->devs->openair0_cfg->tx_sample_advance, - mod_enb->devs->openair0_cfg->rx_num_channels, - mod_enb->devs->openair0_cfg->tx_num_channels, - mod_enb->devs->openair0_cfg->rx_freq[0], - mod_enb->devs->openair0_cfg->tx_freq[0], - mod_enb->devs->openair0_cfg->rx_freq[1], - mod_enb->devs->openair0_cfg->tx_freq[1], - mod_enb->devs->openair0_cfg->rx_freq[2], - mod_enb->devs->openair0_cfg->tx_freq[2], - mod_enb->devs->openair0_cfg->rx_freq[3], - mod_enb->devs->openair0_cfg->tx_freq[3], - mod_enb->devs->openair0_cfg->rxg_mode[0], - mod_enb->devs->openair0_cfg->tx_gain[0], - mod_enb->devs->openair0_cfg->tx_gain[0], - mod_enb->devs->openair0_cfg->rx_gain[1], - mod_enb->devs->openair0_cfg->tx_gain[1], - mod_enb->devs->openair0_cfg->rx_gain[2], - mod_enb->devs->openair0_cfg->tx_gain[2], - mod_enb->devs->openair0_cfg->rx_gain[3], - mod_enb->devs->openair0_cfg->tx_gain[3], - //mod_enb->devs->openair0_cfg->rx_gain_offset[0], - //mod_enb->devs->openair0_cfg->rx_gain_offset[1], - mod_enb->devs->openair0_cfg->rx_gain_offset[2], - mod_enb->devs->openair0_cfg->rx_gain_offset[3], - mod_enb->devs->openair0_cfg->rx_bw, - mod_enb->devs->openair0_cfg->tx_bw, - mod_enb->devs->openair0_cfg->autocal[0] - ); - - printf("----------------------------------------------------------------------------\n"); - - -} diff --git a/targets/RT/USER/emos-raw.c b/targets/RT/USER/emos-raw.c deleted file mode 100644 index 2cf0e18c7171f51cde0cacbbba2a79bfc5e6b40a..0000000000000000000000000000000000000000 --- a/targets/RT/USER/emos-raw.c +++ /dev/null @@ -1,1603 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file lte-softmodem.c -* \brief main program to control HW and scheduling -* \author R. Knopp, F. Kaltenberger -* \date 2012 -* \version 0.1 -* \company Eurecom -* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr -* \note -* \warning -*/ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> - -#include "rt_wrapper.h" - -#include "PHY/types.h" -#include "PHY/TOOLS/defs.h" -#include "openair0_lib.h" - -#include "UTIL/LOG/log.h" -#include "UTIL/LOG/vcd_signal_dumper.h" - -#include "gain_control.h" - -#if defined(ENABLE_ITTI) -# include "intertask_interface_init.h" -# include "timer.h" -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -# include "sctp_eNB_task.h" -# endif -#endif - -#define OPENAIR_THREAD_PRIORITY 255 -#define OPENAIR_THREAD_STACK_SIZE 8192 - -#ifdef XFORMS -/* -#include "PHY/TOOLS/lte_phy_scope.h" -#include "stats.h" -// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) -// at eNB 0, an UL scope for every UE -FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; -FD_lte_phy_scope_enb *form_enb[NUMBER_OF_UE_MAX]; -FD_stats_form *form_stats=NULL; -char title[255]; -unsigned char scope_enb_num_ue = 1; -*/ -#include "lte_scope.h" -FD_lte_scope *form_lte; -char title[255]; -#endif //XFORMS - -#ifdef EMOS -#include <gps.h> -struct gps_fix_t dummy_gps_data; -#ifdef RTAI -#include <rtai_fifos.h> -#endif - -//#define CHANSOUNDER_FIFO_SIZE 10485760 // 10 Mbytes FIFO -//#define CHANSOUNDER_FIFO_SIZE 20971520 // 20 Mbytes FIFO -#define CHANSOUNDER_FIFO_SIZE 52428800 // 50 Mbytes FIFO -//#define CHANSOUNDER_FIFO_SIZE 104857600 // 100 Mbytes FIFO -//#define CHANSOUNDER_FIFO_SIZE 1073741824 // 1Gbyte FIFO -#define CHANSOUNDER_FIFO_MINOR 4 // minor of the FIFO device - this is /dev/rtf3 -#define CHANSOUNDER_FIFO_DEV "/dev/rtf4" -#endif - -#define FRAME_PERIOD 100000000ULL -#define DAQ_PERIOD 66667ULL -#define LTE_SLOTS_PER_FRAME 20 -//#define RESAMPLING_FACTOR 0 -#define SAMPLES_PER_SLOT 15360 -#define FRAME_LENGTH_COMPLEX_SAMPLES (SAMPLES_PER_SLOT*LTE_SLOTS_PER_FRAME) -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all - -#ifdef RTAI -static SEM *mutex; -//static CND *cond; - -static long int thread0; -//static long int thread1; -//static long int sync_thread; -#else -pthread_t thread0; -//pthread_t thread1; -pthread_attr_t attr_dlsch_threads; -struct sched_param sched_param_dlsch; -#endif - -pthread_t thread2; //xforms -pthread_t thread3; //emos -pthread_t thread4; //GPS -pthread_t thread5; //log - -/* -static int instance_cnt=-1; //0 means worker is busy, -1 means its free -int instance_cnt_ptr_kern,*instance_cnt_ptr_user; -int pci_interface_ptr_kern; -*/ -//extern unsigned int bigphys_top; -//extern unsigned int mem_base; - -int number_of_cards = 1; -exmimo_config_t *p_exmimo_config; -exmimo_id_t *p_exmimo_id; -volatile unsigned int *DAQ_MBOX; - -int oai_exit = 0; - -//int time_offset[4] = {-138,-138,-138,-138}; -//int time_offset[4] = {-145,-145,-145,-145}; -int time_offset[4] = {0,0,0,0}; - -int fs4_test=0; -char UE_flag=0; -uint8_t eNB_id=0,UE_id=0; - -// this array sets the bandwidth used for each card (and applies to all chains on one card). -exmimo_bw_t bandwidth[MAX_CARDS] = {BW5,BW5,BW5,BW5}; -// the array carrier_freq sets the frequency for each chain of each card. A 0 means that the chain is disabled. -// Please make sure that the total number of channels enabled per card is in accordance with the following rules: -// BW20: one channel, BW10: 2 channels, BW5: 4 channels -//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0}}; -//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0},{0,0,0,0}}; -uint32_t carrier_freq[MAX_CARDS][4] = {{771500000,771500000,771500000,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}; - -// the following paramters set the aquisition time and period. These parameters have to be set in accordance with the write speed of your harddisk and the required throughput according to the setting above (see also channel_buffer_size which is computed later). -#define AQU_LENGTH_FRAMES 100 //Aquisition time in frames -#define AQU_PERIOD_FRAMES 100 //Repetition time of aquisition in frames -#define AQU_LENGTH_SLOTS (AQU_LENGTH_FRAMES*LTE_SLOTS_PER_FRAME) //Aquisition time in slots -#define AQU_PERIOD_SLOTS (AQU_PERIOD_FRAMES*LTE_SLOTS_PER_FRAME) //Repetition time of aquisition in slots - -int32_t rx_total_gain_dB[3] = {-112, -124, -136}; - -/* -// this array sets the bandwidth used for each card (and applies to all chains on one card). -exmimo_bw_t bandwidth[MAX_CARDS] = {BW20,BW20,BW10,BW5}; -// the array carrier_freq sets the frequency for each chain of each card. A 0 means that the chain is disabled. -// Please make sure that the total number of channels enabled per card is in accordance with the following rules: -// BW20: one channel, BW10: 2 channels, BW5: 4 channels -uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0}}; -//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0},{0,0,0,0}}; -//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}; - -// the following paramters set the aquisition time and period. These parameters have to be set in accordance with the write speed of your harddisk and the required throughput according to the setting above (see also channel_buffer_size which is computed later). -#define AQU_LENGTH_FRAMES 100 //Aquisition time in frames -#define AQU_PERIOD_FRAMES 200 //Repetition time of aquisition in frames -#define AQU_LENGTH_SLOTS (AQU_LENGTH_FRAMES*LTE_SLOTS_PER_FRAME) //Aquisition time in slots -#define AQU_PERIOD_SLOTS (AQU_PERIOD_FRAMES*LTE_SLOTS_PER_FRAME) //Repetition time of aquisition in slots - -int32_t rx_total_gain_dB[3] = {-105, -110, -115}; -*/ - -char dumpfile_dir[256] = "/mnt/emos"; - -char *conf_config_file_name = NULL; - -unsigned int lost_bytes=0; -unsigned int rssi_lin[MAX_CARDS][4],rssi_lin_max[MAX_CARDS],rssi_lin_avg[MAX_CARDS]; -uint8_t rssi_avg_dB[MAX_CARDS]; -long long unsigned int total_bytes=0; - -struct timing_info_t { - //unsigned int frame, hw_slot, last_slot, next_slot; - RTIME time_min, time_max, time_avg, time_last, time_now; - //unsigned int mbox0, mbox1, mbox2, mbox_target; - unsigned int n_samples; -} timing_info; - -extern int16_t* sync_corr_ue0; -extern int16_t prach_ifft[4][1024*2]; - -unsigned int frame; -int rx_input_level_dBm; -#ifdef XFORMS -extern int otg_enabled; -#else -int otg_enabled; -#endif - -int mbox_bounds[20] = {8,16,24,30,38,46,54,60,68,76,84,90,98,106,114,120,128,136,144, 0}; ///boundaries of slots in terms ob mbox counter rounded up to even numbers -//int mbox_bounds[20] = {6,14,22,28,36,44,52,58,66,74,82,88,96,104,112,118,126,134,142, 148}; ///boundaries of slots in terms ob mbox counter rounded up to even numbers - -//void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier); -//void setup_eNB_buffers(PHY_VARS_eNB *phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms, int carrier); -void test_config(int card, int ant, unsigned int rf_mode, int UE_flag); - -unsigned int build_rflocal(int txi, int txq, int rxi, int rxq) -{ - return (txi + (txq<<6) + (rxi<<12) + (rxq<<18)); -} -unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) -{ - return (dcoff_i_rxfe + (dcoff_q_rxfe<<8)); -} - -void signal_handler(int sig) -{ - void *array[10]; - size_t size; - - if (sig==SIGSEGV) { - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(-1); - } else { - oai_exit=1; - } -} - -void exit_fun(const char* s) -{ - void *array[10]; - size_t size; - - printf("Exiting: %s\n",s); - - oai_exit=1; - //rt_sleep_ns(FRAME_PERIOD); - - //exit (-1); -} - -#ifdef XFORMS -extern void ia_receiver_on_off( FL_OBJECT * form, long arg) {} - - -void *scope_thread(void *arg) -{ - int16_t prach_corr[1024]; - char stats_buffer[16384]; - //FILE *UE_stats, *eNB_stats; - int i,len=0; - float rxsig_t_dB[4][FRAME_LENGTH_COMPLEX_SAMPLES]; - float time[FRAME_LENGTH_COMPLEX_SAMPLES]; - struct sched_param sched_param; - int card,ant,idx; - - sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; - sched_setscheduler(0, SCHED_FIFO,&sched_param); - - printf("Scope thread has priority %d\n",sched_param.sched_priority); - - /* - if (UE_flag==1) - UE_stats = fopen("UE_stats.txt", "w"); - else - eNB_stats = fopen("eNB_stats.txt", "w"); - */ - - while (!oai_exit) { - /* - if (UE_flag==1) { - len = dump_ue_stats (PHY_vars_UE_g[0], stats_buffer, 0, mode,rx_input_level_dBm); - fl_set_object_label(form_stats->stats_text, stats_buffer); - //rewind (UE_stats); - //fwrite (stats_buffer, 1, len, UE_stats); - - phy_scope_UE(form_ue[UE_id], - PHY_vars_UE_g[UE_id], - eNB_id, - UE_id,7); - - } else { - len = dump_eNB_stats (PHY_vars_eNB_g[0], stats_buffer, 0); - fl_set_object_label(form_stats->stats_text, stats_buffer); - //rewind (eNB_stats); - //fwrite (stats_buffer, 1, len, eNB_stats); - for(UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { - phy_scope_eNB(form_enb[UE_id], - PHY_vars_eNB_g[eNB_id], - UE_id); - } - - } - */ - - idx = 0; - - for (card=0; card<number_of_cards; card++) { - for (ant=0; ant<4; ant++) { - if ((carrier_freq[card][ant] != 0) && (idx<4)) { - len = FRAME_LENGTH_COMPLEX_SAMPLES/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[ant]); - - for (i=0; i<len; i++) { - //rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i])*(((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i])+(((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i+1])*(((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i+1]))); - rxsig_t_dB[0][i] = (float) ((((int16_t*) openair0_exmimo_pci[card].adc_head[ant])[2*i])); - rxsig_t_dB[1][i] = (float) ((((int16_t*) openair0_exmimo_pci[card].adc_head[ant])[2*i+1])); - time[i] = (float) i; - } - - fl_set_xyplot_data(form_lte->channel_t_re[idx],time,rxsig_t_dB[0],len,"","",""); - fl_set_xyplot_data(form_lte->channel_t_im[idx],time,rxsig_t_dB[1],len,"","",""); - idx++; - } - } - } - - //printf("doing forms\n"); - usleep(100000); - } - - //fclose (UE_stats); - //fclose (eNB_stats); - - pthread_exit((void*)arg); -} -#endif - -int dummy_tx_buffer[3840*4] __attribute__((aligned(16))); - - -#ifdef EMOS -void* gps_thread (void *arg) -{ - - struct gps_data_t gps_data; - struct gps_data_t *gps_data_ptr = &gps_data; - struct sched_param sched_param; - int ret; - - sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; - sched_setscheduler(0, SCHED_FIFO,&sched_param); - - printf("GPS thread has priority %d\n",sched_param.sched_priority); - - memset(&dummy_gps_data,0,sizeof(struct gps_fix_t)); - -#if GPSD_API_MAJOR_VERSION>=5 - ret = gps_open("127.0.0.1","2947",gps_data_ptr); - - if (ret!=0) -#else - gps_data_ptr = gps_open("127.0.0.1","2947"); - - if (gps_data_ptr == NULL) -#endif - { - printf("[EMOS] Could not open GPS\n"); - pthread_exit((void*)arg); - } - -#if GPSD_API_MAJOR_VERSION>=4 - else if (gps_stream(gps_data_ptr, WATCH_ENABLE,NULL) != 0) -#else - else if (gps_query(gps_data_ptr, "w+x") != 0) -#endif - { - printf("[EMOS] Error sending command to GPS\n"); - pthread_exit((void*) arg); - } else - printf("[EMOS] Opened GPS, gps_data=%p\n", gps_data_ptr); - - - while (!oai_exit) { - printf("[EMOS] polling data from gps\n"); -#if GPSD_API_MAJOR_VERSION>=5 - - if (gps_waiting(gps_data_ptr,500)) { - if (gps_read(gps_data_ptr) <= 0) { -#else - - if (gps_waiting(gps_data_ptr)) { - if (gps_poll(gps_data_ptr) != 0) { -#endif - printf("[EMOS] problem polling data from gps\n"); - } else { - memcpy(&dummy_gps_data,&(gps_data_ptr->fix),sizeof(struct gps_fix_t)); - printf("[EMOS] lat %g, lon %g\n",gps_data_ptr->fix.latitude,gps_data_ptr->fix.longitude); - } - } //gps_waiting - else { - printf("[EMOS] WARNING: No GPS data available, storing dummy packet\n"); - } - - //rt_sleep_ns(1000000000LL); - sleep(1); - } //oai_exit - - pthread_exit((void*) arg); - -} - -void *log_thread (void *arg) -{ - //struct tm now_sec; - struct timeval now; - int card; - FILE *logfile_id; - char logfile_name[1024]; - time_t starttime_tmp; - struct tm starttime; - - //open file - time(&starttime_tmp); - localtime_r(&starttime_tmp,&starttime); - snprintf(logfile_name,1024,"%s/%s_data_%d%02d%02d_%02d%02d%02d.log", - dumpfile_dir, - (UE_flag==0) ? "eNB" : "UE", - 1900+starttime.tm_year, starttime.tm_mon+1, starttime.tm_mday, starttime.tm_hour, starttime.tm_min, starttime.tm_sec); - logfile_id = fopen(logfile_name,"w"); - - if ((logfile_id == NULL)) { - fprintf(stderr, "[EMOS] Error opening logfile %s\n",logfile_name); - exit(EXIT_FAILURE); - } - - fprintf(logfile_id, - "#time, frame, total bytes wrote, total bytes lost, GPS time, GPS mode, lat, lon, alt, speed, rssi_lin_max[0], rssi_lin_avg[0], rssi_avg_dBm[0], rssi_avg_dB[0], rx_gain[0], LNA[0], ...\n"); - - while (!oai_exit) { - gettimeofday(&now,NULL); - //localtime_r(&(now.tv_sec),&now_sec); - fprintf(logfile_id,"%d.%06d, %d, %llu, %u, %e, %d, %e, %e, %e, %e, ", - (int) now.tv_sec, (int)now.tv_usec, - frame, total_bytes,lost_bytes, - dummy_gps_data.time, dummy_gps_data.mode, dummy_gps_data.latitude, dummy_gps_data.longitude, dummy_gps_data.altitude, dummy_gps_data.speed); - - for (card=0; card<number_of_cards; card++) - if (carrier_freq[card][0] != 0) - fprintf(logfile_id,"%d, %d, %d, %d, %d, %d, ", rssi_lin_max[card], rssi_lin_avg[card], - rssi_avg_dB[card] + rx_total_gain_dB[((openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14)-1] - openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0], - rssi_avg_dB[card], openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0], (openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14); - - fprintf(logfile_id,"\n"); - usleep(10000); - } - - //close file - fclose(logfile_id); - - pthread_exit((void*) arg); - -} - -void *emos_thread (void *arg) -{ - char c; - char *fifo2file_buffer, *fifo2file_ptr; - - int fifo, counter=0, bytes; - - FILE *dumpfile_id; - char dumpfile_name[1024]; - time_t starttime_tmp; - struct tm starttime; - - //time_t timer; - struct tm now_sec; - struct timeval now; - - struct sched_param sched_param; - int ret; - - int card, ant; - int channel_buffer_size=0; //in bytes - - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL); - - sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO)-1; - sched_setscheduler(0, SCHED_FIFO,&sched_param); - - printf("EMOS thread has priority %d\n",sched_param.sched_priority); - - //timer = time(NULL); - //now = localtime(&timer); - - for (card=0; card<number_of_cards; card++) - for (ant=0; ant<4; ant++) - if (carrier_freq[card][ant] != 0) { - printf("card %d, ant %d: freq %u, BW %d\n",card,ant,carrier_freq[card][ant],bandwidth[card]); - channel_buffer_size += SAMPLES_PER_SLOT/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[ant]); - } - - channel_buffer_size *= 4; //4 bytes per sample - - // allocate memory for NO_FRAMES_DISK channes estimations - fifo2file_buffer = malloc(AQU_LENGTH_SLOTS*channel_buffer_size); - fifo2file_ptr = fifo2file_buffer; - - if (fifo2file_buffer == NULL) { - printf("[EMOS] Cound not allocate memory for fifo2file_buffer\n"); - exit(EXIT_FAILURE); - } - - if ((fifo = open(CHANSOUNDER_FIFO_DEV, O_RDONLY)) < 0) { - fprintf(stderr, "[EMOS] Error opening the fifo\n"); - exit(EXIT_FAILURE); - } - - - time(&starttime_tmp); - localtime_r(&starttime_tmp,&starttime); - snprintf(dumpfile_name,1024,"%s/%s_data_%d%02d%02d_%02d%02d%02d.EMOS", - dumpfile_dir, - (UE_flag==0) ? "eNB" : "UE", - 1900+starttime.tm_year, starttime.tm_mon+1, starttime.tm_mday, starttime.tm_hour, starttime.tm_min, starttime.tm_sec); - - dumpfile_id = fopen(dumpfile_name,"w"); - - if ((dumpfile_id == NULL)) { - fprintf(stderr, "[EMOS] Error opening dumpfile %s\n",dumpfile_name); - exit(EXIT_FAILURE); - } - - printf("[EMOS] starting dump, channel_buffer_size=%d ...\n",channel_buffer_size); - - while (!oai_exit) { - //bytes = rtf_read_timed(fifo, fifo2file_ptr, channel_buffer_size,100); - bytes = rtf_read_all_at_once(fifo, fifo2file_ptr, channel_buffer_size); - - if (bytes<=0) { - usleep(100); - continue; - } - - if (bytes != channel_buffer_size) { - printf("[EMOS] Frame %d: ERROR! Only got %d bytes instead of %d!\n",frame,bytes,channel_buffer_size); - } - - /* - if (UE_flag==0) - printf("eNB: count %d, frame %d, read: %d bytes from the fifo\n",counter, ((fifo_dump_emos_eNB*)fifo2file_ptr)->frame_tx,bytes); - else - printf("UE: count %d, frame %d, read: %d bytes from the fifo\n",counter, ((fifo_dump_emos_UE*)fifo2file_ptr)->frame_rx,bytes); - */ - - fifo2file_ptr += channel_buffer_size; - counter ++; - total_bytes += bytes; - - if ((counter%AQU_LENGTH_SLOTS)==0) { - //reset stuff - fifo2file_ptr = fifo2file_buffer; - //counter = 0; - - printf("[EMOS] Frame %d: start writing %d bytes to disk\n",frame,AQU_LENGTH_SLOTS*channel_buffer_size); - - //flush buffer to disk - if (fwrite(fifo2file_buffer, sizeof(char), AQU_LENGTH_SLOTS*channel_buffer_size, dumpfile_id) != AQU_LENGTH_SLOTS*channel_buffer_size) { - fprintf(stderr, "[EMOS] Error writing to dumpfile\n"); - exit(EXIT_FAILURE); - } else - printf("[EMOS] Frame %d: wrote %d bytes to disk\n",frame,AQU_LENGTH_SLOTS*channel_buffer_size); - - } - - if ((counter%AQU_LENGTH_SLOTS)==0) { - //time(&starttime_tmp); - gettimeofday(&now,NULL); - localtime_r(&(now.tv_sec),&now_sec); - printf("[EMOS] %02d:%02d:%02d.%03d, frame %d, total bytes wrote %llu, bytes lost %u\n", - now_sec.tm_hour, now_sec.tm_min, now_sec.tm_sec, (int)(now.tv_usec/1000), frame, total_bytes,lost_bytes); - - for (card=0; card<number_of_cards; card++) - if (carrier_freq[card][0] != 0) - printf("[EMOS] %02d:%02d:%02d.%03d, card %d, rssi_lin_max %d, rssi_lin_avg %d, rssi_avg_dBm %d (rssi_avg_dB %d, rx_gain %d, LNA %d)\n", - now_sec.tm_hour, now_sec.tm_min, now_sec.tm_sec, (int)(now.tv_usec/1000), card, rssi_lin_max[card], rssi_lin_avg[card], - rssi_avg_dB[card] + rx_total_gain_dB[((openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14)-1] - openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0], - rssi_avg_dB[card], openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0], (openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14); - - //printf("[EMOS] %02d:%02d:%02d, frame %d, GPS time %e, GPS mode %d, lat %e, lon %e, alt %e, speed %e\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, counter/20, dummy_gps_data.time, dummy_gps_data.mode, dummy_gps_data.latitude, dummy_gps_data.longitude, dummy_gps_data.altitude, dummy_gps_data.speed); - } - } - - free(fifo2file_buffer); - fclose(dumpfile_id); - close(fifo); - - pthread_exit((void*) arg); - -} -#endif - -/* This is the main eNB thread. It gets woken up by the kernel driver using the RTAI message mechanism (rt_send and rt_receive). */ -static void *eNB_thread(void *arg) -{ -#ifdef RTAI - RT_TASK *task; -#endif - unsigned char slot=0,last_slot, next_slot, hw_slot; - unsigned int msg1; - unsigned int aa,slot_offset, slot_offset_F; - int diff; - int delay_cnt; - RTIME time_in, time_diff; - int mbox_target=0,mbox_current=0; - int i,ret; - int tx_offset; - int bytes, bytes_tot=0, bytes_len; - long long int k1=1000; - long long int k2=1024-k1; - int ant,len,card = 0; - -#ifdef RTAI - task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF); - LOG_D(HW,"Started eNB thread (id %p)\n",task); -#endif - -#ifdef HARD_RT - rt_make_hard_real_time(); -#endif - - mlockall(MCL_CURRENT | MCL_FUTURE); - - timing_info.time_min = 100000000ULL; - timing_info.time_max = 0; - timing_info.time_avg = 0; - timing_info.n_samples = 0; - - while (!oai_exit) { - hw_slot = (((((volatile unsigned int *)DAQ_MBOX)[0]+1)%150)<<1)/15; - //LOG_D(HW,"eNB frame %d, time %llu: slot %d, hw_slot %d (mbox %d)\n",frame,rt_get_time_ns(),slot,hw_slot,((unsigned int *)DAQ_MBOX)[0]); - //this is the mbox counter where we should be - //mbox_target = ((((slot+1)%20)*15+1)>>1)%150; - mbox_target = mbox_bounds[slot]; - //this is the mbox counter where we are - mbox_current = ((volatile unsigned int *)DAQ_MBOX)[0]; - - //this is the time we need to sleep in order to synchronize with the hw (in multiples of DAQ_PERIOD) - if ((mbox_current>=135) && (mbox_target<15)) //handle the frame wrap-arround - diff = 150-mbox_current+mbox_target; - else if ((mbox_current<15) && (mbox_target>=135)) - diff = -150+mbox_target-mbox_current; - else - diff = mbox_target - mbox_current; - - if (diff < (-7)) { - // at the eNB, even slots have double as much time since most of the processing is done here and almost nothing in odd slots - LOG_D(HW,"eNB Frame %d, time %llu: missed slot, proceeding with next one (slot %d, hw_slot %d, diff %d)\n",frame, rt_get_time_ns(), slot, hw_slot, diff); - slot++; - - //if (frame>0) - //oai_exit=1; - if (slot==20) { - slot=0; - frame++; - } - - continue; - } - - if (diff>8) - LOG_D(HW,"eNB Frame %d, time %llu: skipped slot, waiting for hw to catch up (slot %d, hw_slot %d, mbox_current %d, mbox_target %d, diff %d)\n",frame, rt_get_time_ns(), slot, hw_slot, mbox_current, - mbox_target, diff); - - delay_cnt = 0; - - while ((diff>0) && (!oai_exit)) { - time_in = rt_get_time_ns(); - //LOG_D(HW,"eNB Frame %d delaycnt %d : hw_slot %d (%d), slot %d, (slot+1)*15=%d, diff %d, time %llu\n",frame,delay_cnt,hw_slot,((unsigned int *)DAQ_MBOX)[0],slot,(((slot+1)*15)>>1),diff,time_in); - //LOG_D(HW,"eNB Frame %d, time %llu: sleeping for %llu (slot %d, hw_slot %d, diff %d, mbox %d, delay_cnt %d)\n", frame, time_in, diff*DAQ_PERIOD,slot,hw_slot,diff,((volatile unsigned int *)DAQ_MBOX)[0],delay_cnt); - ret = rt_sleep_ns(diff*DAQ_PERIOD); - - if (ret) - LOG_D(HW,"eNB Frame %d, time %llu: rt_sleep_ns returned %d\n",frame, time_in); - - hw_slot = (((((volatile unsigned int *)DAQ_MBOX)[0]+1)%150)<<1)/15; - //LOG_D(HW,"eNB Frame %d : hw_slot %d, time %llu\n",frame,hw_slot,rt_get_time_ns()); - delay_cnt++; - - if (delay_cnt == 10) { - oai_exit = 1; - LOG_D(HW,"eNB Frame %d: HW stopped ... \n",frame); - } - - mbox_current = ((volatile unsigned int *)DAQ_MBOX)[0]; - - if ((mbox_current>=135) && (mbox_target<15)) //handle the frame wrap-arround - diff = 150-mbox_current+mbox_target; - else if ((mbox_current<15) && (mbox_target>=135)) - diff = -150+mbox_target-mbox_current; - else - diff = mbox_target - mbox_current; - } - - last_slot = (slot)%LTE_SLOTS_PER_FRAME; - - if (last_slot <0) - last_slot+=20; - - next_slot = (slot+3)%LTE_SLOTS_PER_FRAME; - - if (frame>=AQU_LENGTH_FRAMES) { - timing_info.time_last = timing_info.time_now; - timing_info.time_now = rt_get_time_ns(); - - if (timing_info.n_samples>0) { - time_diff = timing_info.time_now - timing_info.time_last; - - if (time_diff < timing_info.time_min) - timing_info.time_min = time_diff; - - if (time_diff > timing_info.time_max) - timing_info.time_max = time_diff; - - timing_info.time_avg += time_diff; - } - - timing_info.n_samples++; - - // do measurements for rssi - if (last_slot==0) { - for (card=0; card<number_of_cards; card++) { - len = SAMPLES_PER_SLOT/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[0]); - rssi_lin_max[card] = 0; - - for (ant=0; ant<4; ant++) { - if (carrier_freq[card][ant] != 0) { - rssi_lin[card][ant] = signal_energy(&(((int32_t*) openair0_exmimo_pci[card].adc_head[ant])[last_slot*len]), len); - rssi_lin_max[card] = max(rssi_lin_max[card],rssi_lin[card][ant]); - } - } - - rssi_lin_avg[card] = (int) ((k1*((long long int)(rssi_lin_avg[card])) + (k2*((long long int)(rssi_lin_max[card]))))>>10); - rssi_avg_dB[card] = dB_fixed(rssi_lin_avg[card]); - - if (frame%100==0) { - gain_control_all(rssi_avg_dB[card],card); - //printf("AGC for card %d: rx_power_fil_dB=%d, rx_gain=%d, LNA=%d (1=Byp,2=Med,3=Max)\n",card,rssi_avg_dB,openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0],(openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0]&LNAGAINMASK)>>14); - } - } - } - -#ifdef EMOS - - // save raw samples here - if ((last_slot==0) && ((frame%AQU_PERIOD_FRAMES)==0)) { - printf("[EMOS] Frame %d: start writing to FIFO\n",frame); - bytes_tot=0; - } - - if ((frame%AQU_PERIOD_FRAMES)<AQU_LENGTH_FRAMES) { - for (card=0; card<number_of_cards; card++) { - for (ant=0; ant<4; ant++) { - if (carrier_freq[card][ant] != 0) { - len = SAMPLES_PER_SLOT/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[ant]); - bytes_len = len*4; - bytes = rtf_put(CHANSOUNDER_FIFO_MINOR, &(((int32_t*) openair0_exmimo_pci[card].adc_head[ant])[last_slot*len]), bytes_len); - bytes_tot += bytes; - - if (bytes!=bytes_len) { - lost_bytes += bytes_len - bytes; - LOG_W(PHY,"Frame %d, slot %d: Problem writing EMOS data to FIFO (bytes=%d, size=%d)\n", - frame, last_slot, bytes, bytes_len); - } - } - } - } - - if ((last_slot==19) && ((frame%AQU_PERIOD_FRAMES)==99)) - printf("[EMOS] Frame %d: sent %d bytes to FIFO\n",frame,bytes_tot); - - } - -#endif - } - - slot++; - - if (slot==20) { - slot=0; - frame++; - } - -#if defined(ENABLE_ITTI) - itti_update_lte_time(frame, slot); -#endif - } - - LOG_D(HW,"eNB_thread: finished, ran %d times.\n",frame); - -#ifdef HARD_RT - rt_make_soft_real_time(); -#endif - - // clean task -#ifdef RTAI - rt_task_delete(task); -#endif - LOG_D(HW,"Task deleted. returning\n"); - return 0; -} - - -int main(int argc, char **argv) -{ - -#ifdef RTAI - RT_TASK *task; -#endif - int i,j,aa; - void *status; - int card = 0; - - uint32_t rf_mode_base = TXLPFNORM + TXLPFEN + RXLPFNORM + RXLPFEN + LNA1ON +LNAMax + RFBBNORM; - uint32_t rf_local[4] = {8255000,8255000,8255000,8255000}; // UE zepto - //{8254617, 8254617, 8254617, 8254617}; //eNB khalifa - //{8255067,8254810,8257340,8257340}; // eNB PETRONAS - uint32_t rf_vcocal[4] = {910,910,910,910}; - uint32_t rf_vcocal_850[4] = {2015, 2015, 2015, 2015}; - uint32_t rf_rxdc[4] = {32896,32896,32896,32896}; - uint32_t rxgain[4] = {30,30,30,30}; - uint32_t txgain[4] = {0,0,0,0}; - - uint16_t Nid_cell = 0; - uint8_t cooperation_flag=0, transmission_mode=1, abstraction_flag=0; - uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; - - int c; - char do_forms=0; - unsigned int fd; - unsigned int tcxo = 114; - - int amp; - uint8_t prach_fmt; - int N_ZC; - - char rxg_fname[100]; - char txg_fname[100]; - char rflo_fname[100]; - char rfdc_fname[100]; - FILE *rxg_fd=NULL; - FILE *txg_fd=NULL; - FILE *rflo_fd=NULL; - FILE *rfdc_fd=NULL; - unsigned int rxg_max[4]= {133,133,133,133}, rxg_med[4]= {127,127,127,127}, rxg_byp[4]= {120,120,120,120}; - int tx_max_power=0; - - char line[1000]; - int l; - int ret, ant; - int ant_offset=0; - - int error_code; - char *itti_dump_file = NULL; - - const struct option long_options[] = { - {"calib-ue-rx", required_argument, NULL, 256}, - {"calib-ue-rx-med", required_argument, NULL, 257}, - {"calib-ue-rx-byp", required_argument, NULL, 258}, - {"debug-ue-prach", no_argument, NULL, 259}, - {"no-L2-connect", no_argument, NULL, 260}, - {NULL, 0, NULL, 0} - }; - - //mode = normal_txrx; - - - while ((c = getopt_long (argc, argv, "C:K:O:ST:UdF:V",long_options,NULL)) != -1) { - switch (c) { - case 'V': - ouput_vcd = 1; - break; - - case 'd': - do_forms=1; - break; - - case 'U': - UE_flag = 1; - break; - - case 'C': - for (card=0; card<MAX_CARDS; card++) { - carrier_freq[card][0] = atof(optarg); - carrier_freq[card][1] = atof(optarg); - carrier_freq[card][2] = atof(optarg); - carrier_freq[card][3] = atof(optarg); - } - - break; - - case 'S': - fs4_test=1; - break; - - case 'T': - tcxo=atoi(optarg); - break; - - case 'K': -#if defined(ENABLE_ITTI) - itti_dump_file = strdup(optarg); -#else - printf("-K option is disabled when ENABLE_ITTI is not defined\n"); -#endif - break; - - case 'O': - conf_config_file_name = optarg; - break; - - case 'F': - sprintf(rxg_fname,"%srxg.lime",optarg); - rxg_fd = fopen(rxg_fname,"r"); - - if (rxg_fd) { - printf("Loading RX Gain parameters from %s\n",rxg_fname); - l=0; - - while (fgets(line, sizeof(line), rxg_fd)) { - if ((strlen(line)==0) || (*line == '#')) continue; //ignore empty or comment lines - else { - if (l==0) sscanf(line,"%d %d %d %d",&rxg_max[0],&rxg_max[1],&rxg_max[2],&rxg_max[3]); - - if (l==1) sscanf(line,"%d %d %d %d",&rxg_med[0],&rxg_med[1],&rxg_med[2],&rxg_med[3]); - - if (l==2) sscanf(line,"%d %d %d %d",&rxg_byp[0],&rxg_byp[1],&rxg_byp[2],&rxg_byp[3]); - - l++; - } - } - } else - printf("%s not found, running with defaults\n",rxg_fname); - - sprintf(txg_fname,"%stxg.lime",optarg); - txg_fd = fopen(txg_fname,"r"); - - if (txg_fd) { - printf("Loading TX Gain parameters from %s\n",txg_fname); - l=0; - - while (fgets(line, sizeof(line), txg_fd)) { - if ((strlen(line)==0) || (*line == '#')) { - continue; //ignore empty or comment lines - } else { - if (l==0) sscanf(line,"%d %d %d %d",&txgain[0],&txgain[1],&txgain[2],&txgain[3]); - - if (l==1) sscanf(line,"%d",&tx_max_power); - - l++; - } - } - } else - printf("%s not found, running with defaults\n",txg_fname); - - sprintf(rflo_fname,"%srflo.lime",optarg); - rflo_fd = fopen(rflo_fname,"r"); - - if (rflo_fd) { - printf("Loading RF LO parameters from %s\n",rflo_fname); - fscanf(rflo_fd,"%d %d %d %d",&rf_local[0],&rf_local[1],&rf_local[2],&rf_local[3]); - } else - printf("%s not found, running with defaults\n",rflo_fname); - - sprintf(rfdc_fname,"%srfdc.lime",optarg); - rfdc_fd = fopen(rfdc_fname,"r"); - - if (rfdc_fd) { - printf("Loading RF DC parameters from %s\n",rfdc_fname); - fscanf(rfdc_fd,"%d %d %d %d",&rf_rxdc[0],&rf_rxdc[1],&rf_rxdc[2],&rf_rxdc[3]); - } else - printf("%s not found, running with defaults\n",rfdc_fname); - - break; - - /* - case 256: - mode = rx_calib_ue; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA max), input level %d dBm\n",rx_input_level_dBm); - break; - case 257: - mode = rx_calib_ue_med; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA med), input level %d dBm\n",rx_input_level_dBm); - break; - case 258: - mode = rx_calib_ue_byp; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA byp), input level %d dBm\n",rx_input_level_dBm); - break; - case 259: - mode = debug_prach; - break; - case 260: - mode = no_L2_connect; - break; - */ - default: - break; - } - } - - if (UE_flag==1) - printf("configuring for UE\n"); - else - printf("configuring for eNB\n"); - - //randominit (0); - //set_taus_seed (0); - - // initialize the log (see log.h for details) - logInit(); - -#if defined(ENABLE_ITTI) - itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file); - -# if defined(ENABLE_USE_MME) - - if (itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0) { - LOG_E(EMU, "Create task failed"); - LOG_D(EMU, "Initializing SCTP task interface: FAILED\n"); - return -1; - } - - if (itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL) < 0) { - LOG_E(EMU, "Create task failed"); - LOG_D(EMU, "Initializing S1AP task interface: FAILED\n"); - return -1; - } - -# endif - - if (itti_create_task(TASK_L2L1, l2l1_task, NULL) < 0) { - LOG_E(EMU, "Create task failed"); - LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n"); - return -1; - } - - // Handle signals until all tasks are terminated - // itti_wait_tasks_end(); -#endif - - if (ouput_vcd) { - if (UE_flag==1) - VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_UE.vcd"); - else - VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_eNB.vcd"); - } - -#ifdef PDCP_USE_NETLINK - netlink_init(); -#endif - - // to make a graceful exit when ctrl-c is pressed - signal(SIGSEGV, signal_handler); - signal(SIGINT, signal_handler); - -#ifndef RTAI - check_clock(); -#endif - - g_log->log_component[HW].level = LOG_DEBUG; - g_log->log_component[HW].flag = LOG_HIGH; -#ifdef OPENAIR2 - g_log->log_component[PHY].level = LOG_INFO; -#else - g_log->log_component[PHY].level = LOG_DEBUG; -#endif - g_log->log_component[PHY].flag = LOG_HIGH; - g_log->log_component[MAC].level = LOG_INFO; - g_log->log_component[MAC].flag = LOG_HIGH; - g_log->log_component[RLC].level = LOG_INFO; - g_log->log_component[RLC].flag = LOG_HIGH; - g_log->log_component[PDCP].level = LOG_INFO; - g_log->log_component[PDCP].flag = LOG_HIGH; - g_log->log_component[OTG].level = LOG_INFO; - g_log->log_component[OTG].flag = LOG_HIGH; - g_log->log_component[RRC].level = LOG_INFO; - g_log->log_component[RRC].flag = LOG_HIGH; - - - // Initialize card - ret = openair0_open(); - - if ( ret != 0 ) { - if (ret == -1) - printf("Error opening /dev/openair0"); - - if (ret == -2) - printf("Error mapping bigshm"); - - if (ret == -3) - printf("Error mapping RX or TX buffer"); - - return(ret); - } - - number_of_cards = openair0_num_detected_cards; - - for (card=0; card<number_of_cards; card++) { - printf ("Configuring card %d of %d (number of antennas %d).\n", card, openair0_num_detected_cards, openair0_num_antennas[card]); - - p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr; - p_exmimo_id = openair0_exmimo_pci[card].exmimo_id_ptr; - - printf("Card %d: ExpressMIMO %d, HW Rev %d, SW Rev 0x%d\n", card, p_exmimo_id->board_exmimoversion, p_exmimo_id->board_hwrev, p_exmimo_id->board_swrev); - - if (p_exmimo_id->board_swrev>=BOARD_SWREV_CNTL2) - p_exmimo_config->framing.eNB_flag = 0; - else - p_exmimo_config->framing.eNB_flag = !UE_flag; - - if (card==0) - p_exmimo_config->framing.multicard_syncmode = SYNCMODE_MASTER; - else - p_exmimo_config->framing.multicard_syncmode = SYNCMODE_SLAVE; - - //p_exmimo_config->framing.multicard_syncmode = SYNCMODE_FREE; - - - p_exmimo_config->framing.tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTRX; //TXRXSWITCH_LSB; - - /* - for (ant=0;ant<max(frame_parms->nb_antennas_tx,frame_parms->nb_antennas_rx);ant++) - p_exmimo_config->rf.rf_mode[ant] = rf_mode_base; - for (ant=0;ant<frame_parms->nb_antennas_tx;ant++) - p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX); - for (ant=0;ant<frame_parms->nb_antennas_rx;ant++) - p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX); - for (ant=max(frame_parms->nb_antennas_tx,frame_parms->nb_antennas_rx);ant<4;ant++) { - p_exmimo_config->rf.rf_mode[ant] = 0; - carrier_freq[ant] = 0; //this turns off all other LIMEs - } - */ - - for (ant=0; ant<4; ant++) { - if (carrier_freq[card][ant] != 0) { - p_exmimo_config->rf.rf_mode[ant] = rf_mode_base; - - switch (bandwidth[card]) { - case BW20: - p_exmimo_config->framing.resampling_factor[ant] = 0; - p_exmimo_config->rf.rf_mode[ant] += RXLPF10 + TXLPF10; - break; - - case BW10: - p_exmimo_config->framing.resampling_factor[ant] = 1; - p_exmimo_config->rf.rf_mode[ant] += RXLPF5 + TXLPF5; - break; - - case BW5: - p_exmimo_config->framing.resampling_factor[ant] = 2; - p_exmimo_config->rf.rf_mode[ant] += RXLPF25 + TXLPF25; - break; - } - - //p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX); - p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX); - } else { - p_exmimo_config->rf.rf_mode[ant] = 0; - } - } - - for (ant = 0; ant<4; ant++) { - p_exmimo_config->rf.do_autocal[ant] = 1; - p_exmimo_config->rf.rf_freq_rx[ant] = carrier_freq[card][ant]; - p_exmimo_config->rf.rf_freq_tx[ant] = carrier_freq[card][ant]; - p_exmimo_config->rf.rx_gain[ant][0] = rxgain[ant]; - p_exmimo_config->rf.tx_gain[ant][0] = txgain[ant]; - - p_exmimo_config->rf.rf_local[ant] = rf_local[ant]; - p_exmimo_config->rf.rf_rxdc[ant] = rf_rxdc[ant]; - - if ((carrier_freq[card][ant] >= 850000000) && (carrier_freq[card][ant] <= 865000000)) { - p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal_850[ant]; - p_exmimo_config->rf.rffe_band_mode[ant] = DD_TDD; - } else if ((carrier_freq[card][ant] >= 1900000000) && (carrier_freq[card][ant] <= 2000000000)) { - p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant]; - p_exmimo_config->rf.rffe_band_mode[ant] = B19G_TDD; - } else { - p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant]; - p_exmimo_config->rf.rffe_band_mode[ant] = 0; - } - - p_exmimo_config->rf.rffe_gain_txlow[ant] = 31; - p_exmimo_config->rf.rffe_gain_txhigh[ant] = 31; - p_exmimo_config->rf.rffe_gain_rxfinal[ant] = 52; - p_exmimo_config->rf.rffe_gain_rxlow[ant] = 31; - } - - - openair0_dump_config(card); - - printf("EXMIMO_CONFIG card %d: freq0..3 %u %u %u %u Hz, freqtx0..1 %u %u Hz, RX gain0..1 %d %d dB\n", - card, - p_exmimo_config->rf.rf_freq_rx[0], - p_exmimo_config->rf.rf_freq_rx[1], - p_exmimo_config->rf.rf_freq_rx[2], - p_exmimo_config->rf.rf_freq_rx[3], - p_exmimo_config->rf.rf_freq_tx[0], - p_exmimo_config->rf.rf_freq_tx[1], - p_exmimo_config->rf.rx_gain[0][0], - p_exmimo_config->rf.rx_gain[1][0]); - printf("EXMIMO_CONFIG card %d: rf_mode 0x %x %x %x %x, [0]: TXRXEn %d, TXLPFEn %d, TXLPF %d, RXLPFEn %d, RXLPF %d, RFBB %d, LNA %d, LNAGain %d, RXLPFMode %d, SWITCH %d, rf_rxdc %d, rf_local %d, rf_vcocal %d\n", - card, - p_exmimo_config->rf.rf_mode[0], - p_exmimo_config->rf.rf_mode[1], - p_exmimo_config->rf.rf_mode[2], - p_exmimo_config->rf.rf_mode[3], - (p_exmimo_config->rf.rf_mode[0]&3), // RXen+TXen - (p_exmimo_config->rf.rf_mode[0]&4)>>2, //TXLPFen - (p_exmimo_config->rf.rf_mode[0]&TXLPFMASK)>>3, //TXLPF - (p_exmimo_config->rf.rf_mode[0]&128)>>7, //RXLPFen - (p_exmimo_config->rf.rf_mode[0]&RXLPFMASK)>>8, //TXLPF - (p_exmimo_config->rf.rf_mode[0]&RFBBMASK)>>16, // RFBB mode - (p_exmimo_config->rf.rf_mode[0]&LNAMASK)>>12, // RFBB mode - (p_exmimo_config->rf.rf_mode[0]&LNAGAINMASK)>>14, // RFBB mode - (p_exmimo_config->rf.rf_mode[0]&RXLPFMODEMASK)>>19, // RXLPF mode - (p_exmimo_config->framing.tdd_config&TXRXSWITCH_MASK)>>1, // Switch mode - p_exmimo_config->rf.rf_rxdc[0], - p_exmimo_config->rf.rf_local[0], - p_exmimo_config->rf.rf_vcocal[0]); - - for (ant=0; ant<4; ant++) - p_exmimo_config->rf.do_autocal[ant] = 0; - } //card - - card=0; - -#ifdef EMOS - error_code = rtf_create(CHANSOUNDER_FIFO_MINOR,CHANSOUNDER_FIFO_SIZE); - - if (error_code==0) - printf("[OPENAIR][SCHED][INIT] Created EMOS FIFO %d\n",CHANSOUNDER_FIFO_MINOR); - else if (error_code==ENODEV) - printf("[OPENAIR][SCHED][INIT] Problem: EMOS FIFO %d is greater than or equal to RTF_NO\n",CHANSOUNDER_FIFO_MINOR); - else if (error_code==ENOMEM) - printf("[OPENAIR][SCHED][INIT] Problem: cannot allocate memory for EMOS FIFO %d\n",CHANSOUNDER_FIFO_MINOR); - else - printf("[OPENAIR][SCHED][INIT] Problem creating EMOS FIFO %d, error_code %d\n",CHANSOUNDER_FIFO_MINOR,error_code); - -#endif - - mlockall(MCL_CURRENT | MCL_FUTURE); - -#ifdef RTAI - // make main thread LXRT soft realtime - task = rt_task_init_schmod(nam2num("MYTASK"), 9, 0, 0, SCHED_FIFO, 0xF); - - // start realtime timer and scheduler - //rt_set_oneshot_mode(); - rt_set_periodic_mode(); - start_rt_timer(0); - - //now = rt_get_time() + 10*PERIOD; - //rt_task_make_periodic(task, now, PERIOD); - - printf("Init mutex\n"); - //mutex = rt_get_adr(nam2num("MUTEX")); - mutex = rt_sem_init(nam2num("MUTEX"), 1); - - if (mutex==0) { - printf("Error init mutex\n"); - exit(-1); - } else - printf("mutex=%p\n",mutex); - -#endif - - DAQ_MBOX = (volatile unsigned int *) openair0_exmimo_pci[0].rxcnt_ptr[0]; - - // this starts the DMA transfers - if (UE_flag!=1) - for (card=0; card<number_of_cards; card++) - openair0_start_rt_acquisition(card); - - -#ifdef XFORMS - - if (do_forms==1) { - fl_initialize (&argc, argv, NULL, 0, 0); - /* - form_stats = create_form_stats_form(); - if (UE_flag==1) { - form_ue[UE_id] = create_lte_phy_scope_ue(); - sprintf (title, "LTE DL SCOPE UE"); - fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - } else { - for(UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { - form_enb[UE_id] = create_lte_phy_scope_enb(); - sprintf (title, "UE%d LTE UL SCOPE eNB",UE_id+1); - fl_show_form (form_enb[UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - } - } - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - if (UE_flag==0) { - for (UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { - if (otg_enabled) { - fl_set_button(form_enb[UE_id]->button_0,1); - fl_set_object_label(form_enb[UE_id]->button_0,"DL Traffic ON"); - } - else { - fl_set_button(form_enb[UE_id]->button_0,0); - fl_set_object_label(form_enb[UE_id]->button_0,"DL Traffic OFF"); - } - } - } - else { - if (openair_daq_vars.use_ia_receiver) { - fl_set_button(form_ue[UE_id]->button_0,1); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); - } - else { - fl_set_button(form_ue[UE_id]->button_0,0); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); - } - } - */ - form_lte = create_form_lte_scope(); - fl_show_form (form_lte->lte_scope, FL_PLACE_HOTSPOT, FL_FULLBORDER, "Scope"); - - ret = pthread_create(&thread2, NULL, scope_thread, NULL); - printf("Scope thread created, ret=%d\n",ret); - } - -#endif - -#ifdef EMOS - ret = pthread_create(&thread3, NULL, emos_thread, NULL); - printf("EMOS thread created, ret=%d\n",ret); - ret = pthread_create(&thread4, NULL, gps_thread, NULL); - printf("GPS thread created, ret=%d\n",ret); - ret = pthread_create(&thread5, NULL, log_thread, NULL); - printf("LOG thread created, ret=%d\n",ret); -#endif - - rt_sleep_ns(10*FRAME_PERIOD); - -#ifndef RTAI - pthread_attr_init (&attr_dlsch_threads); - pthread_attr_setstacksize(&attr_dlsch_threads,OPENAIR_THREAD_STACK_SIZE); - //attr_dlsch_threads.priority = 1; - sched_param_dlsch.sched_priority = sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY; - pthread_attr_setschedparam (&attr_dlsch_threads, &sched_param_dlsch); - pthread_attr_setschedpolicy (&attr_dlsch_threads, SCHED_FIFO); -#endif - - // start the main thread - if (UE_flag == 1) { - /* - #ifdef RTAI - thread1 = rt_thread_create(UE_thread, NULL, 100000000); - #else - error_code = pthread_create(&thread1, &attr_dlsch_threads, UE_thread, NULL); - if (error_code!= 0) { - LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code); - return(error_code); - } - else { - LOG_D(HW,"[lte-softmodem.c] Allocate UE_thread successful\n"); - } - #endif - #ifdef DLSCH_THREAD - init_rx_pdsch_thread(); - rt_sleep_ns(FRAME_PERIOD/10); - init_dlsch_threads(); - #endif - printf("UE threads created\n"); - */ - } else { -#ifdef RTAI - thread0 = rt_thread_create(eNB_thread, NULL, 100000000); -#else - error_code = pthread_create(&thread0, &attr_dlsch_threads, eNB_thread, NULL); - - if (error_code!= 0) { - LOG_D(HW,"[lte-softmodem.c] Could not allocate eNB_thread, error %d\n",error_code); - return(error_code); - } else { - LOG_D(HW,"[lte-softmodem.c] Allocate eNB_thread successful\n"); - } - -#endif -#ifdef ULSCH_THREAD - init_ulsch_threads(); -#endif - printf("eNB threads created\n"); - } - - - // wait for end of program - printf("TYPE <CTRL-C> TO TERMINATE\n"); - - //getchar(); - while (oai_exit==0) - rt_sleep_ns(FRAME_PERIOD); - - // stop threads -#ifdef XFORMS - printf("waiting for XFORMS thread\n"); - - if (do_forms==1) { - pthread_join(thread2,&status); - /* - fl_hide_form(form_stats->stats_form); - fl_free_form(form_stats->stats_form); - if (UE_flag==1) { - fl_hide_form(form_ue[UE_id]->lte_phy_scope_ue); - fl_free_form(form_ue[UE_id]->lte_phy_scope_ue); - } else { - for(UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { - fl_hide_form(form_enb[UE_id]->lte_phy_scope_enb); - fl_free_form(form_enb[UE_id]->lte_phy_scope_enb); - } - } - */ - fl_hide_form(form_lte->lte_scope); - fl_free_form(form_lte->lte_scope); - } - -#endif - - printf("stopping MODEM threads\n"); - - // cleanup - if (UE_flag == 1) { - /* - #ifdef RTAI - rt_thread_join(thread1); - #else - pthread_join(thread1,&status); - #endif - #ifdef DLSCH_THREAD - cleanup_dlsch_threads(); - cleanup_rx_pdsch_thread(); - #endif - */ - } else { -#ifdef RTAI - rt_thread_join(thread0); -#else - pthread_join(thread0,&status); -#endif -#ifdef ULSCH_THREAD - cleanup_ulsch_threads(); -#endif - } - -#ifdef OPENAIR2 - //cleanup_pdcp_thread(); -#endif - -#ifdef RTAI - stop_rt_timer(); -#endif - - printf("stopping card\n"); - - for (card=0; card<number_of_cards; card++) - openair0_stop(card); - - printf("closing openair0_lib\n"); - openair0_close(); - -#ifdef EMOS - printf("waiting for EMOS thread\n"); - pthread_cancel(thread3); - pthread_join(thread3,&status); - printf("waiting for GPS thread\n"); - pthread_cancel(thread4); - pthread_join(thread4,&status); - printf("waiting for log thread\n"); - pthread_cancel(thread5); - pthread_join(thread5,&status); -#endif - -#ifdef EMOS - error_code = rtf_destroy(CHANSOUNDER_FIFO_MINOR); - - while (error_code>0) - error_code = rtf_destroy(CHANSOUNDER_FIFO_MINOR); - - printf("[OPENAIR][SCHED][CLEANUP] EMOS FIFO closed, error_code %d\n", error_code); -#endif - - if (ouput_vcd) - VCD_SIGNAL_DUMPER_CLOSE(); - - logClean(); - - return 0; -} - -void test_config(int card, int ant, unsigned int rf_mode, int UE_flag) -{ - p_exmimo_config->framing.eNB_flag = !UE_flag; - p_exmimo_config->framing.tdd_config = 0; - p_exmimo_config->framing.resampling_factor[ant] = 2; - - p_exmimo_config->rf.rf_freq_rx[ant] = 1907600000; - p_exmimo_config->rf.rf_freq_tx[ant] = 1907600000;; - p_exmimo_config->rf.rx_gain[ant][0] = 20; - p_exmimo_config->rf.tx_gain[ant][0] = 10; - p_exmimo_config->rf.rf_mode[ant] = rf_mode; - - p_exmimo_config->rf.rf_local[ant] = build_rflocal(20,25,26,04); - p_exmimo_config->rf.rf_rxdc[ant] = build_rfdc(128, 128); - p_exmimo_config->rf.rf_vcocal[ant] = (0xE<<6) + 0xE; -} - -/* -void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier) { - - int i; - if (phy_vars_ue) { - - if ((frame_parms->nb_antennas_rx>1) && (carrier>0)) { - printf("RX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - if ((frame_parms->nb_antennas_tx>1) && (carrier>0)) { - printf("TX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - // replace RX signal buffers with mmaped HW versions - for (i=0;i<frame_parms->nb_antennas_rx;i++) { - free(phy_vars_ue->lte_ue_common_vars.rxdata[i]); - phy_vars_ue->lte_ue_common_vars.rxdata[i] = (int32_t*) openair0_exmimo_pci[card].adc_head[i+carrier]; - - - printf("rxdata[%d] @ %p\n",i,phy_vars_ue->lte_ue_common_vars.rxdata[i]); - } - for (i=0;i<frame_parms->nb_antennas_tx;i++) { - free(phy_vars_ue->lte_ue_common_vars.txdata[i]); - phy_vars_ue->lte_ue_common_vars.txdata[i] = (int32_t*) openair0_exmimo_pci[card].dac_head[i+carrier]; - - printf("txdata[%d] @ %p\n",i,phy_vars_ue->lte_ue_common_vars.txdata[i]); - } - } -} - -void setup_eNB_buffers(PHY_VARS_eNB *phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms, int carrier) { - - int i,j; - - if (phy_vars_eNB) { - if ((frame_parms->nb_antennas_rx>1) && (carrier>0)) { - printf("RX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - if ((frame_parms->nb_antennas_tx>1) && (carrier>0)) { - printf("TX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - // replace RX signal buffers with mmaped HW versions - for (i=0;i<frame_parms->nb_antennas_rx;i++) { - free(phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i]); - phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i] = (int32_t*) openair0_exmimo_pci[card].adc_head[i+carrier]; - - printf("rxdata[%d] @ %p\n",i,phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i]); - for (j=0;j<16;j++) { - printf("rxbuffer %d: %x\n",j,phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i][j]); - phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i][j] = 16-j; - } - } - for (i=0;i<frame_parms->nb_antennas_tx;i++) { - free(phy_vars_eNB->lte_eNB_common_vars.txdata[0][i]); - phy_vars_eNB->lte_eNB_common_vars.txdata[0][i] = (int32_t*) openair0_exmimo_pci[card].dac_head[i+carrier]; - - printf("txdata[%d] @ %p\n",i,phy_vars_eNB->lte_eNB_common_vars.txdata[0][i]); - for (j=0;j<16;j++) { - printf("txbuffer %d: %x\n",j,phy_vars_eNB->lte_eNB_common_vars.txdata[0][i][j]); - phy_vars_eNB->lte_eNB_common_vars.txdata[0][i][j] = 16-j; - } - } - } -} -*/ diff --git a/targets/RT/USER/init_rtai.sh b/targets/RT/USER/init_rtai.sh deleted file mode 100755 index 69b127de3322ae5388a46a28f6ae83fb05de1d0f..0000000000000000000000000000000000000000 --- a/targets/RT/USER/init_rtai.sh +++ /dev/null @@ -1,5 +0,0 @@ -sudo insmod /usr/realtime/modules/rtai_hal.ko -sudo insmod /usr/realtime/modules/rtai_sched.ko -sudo insmod /usr/realtime/modules/rtai_sem.ko -sudo insmod /usr/realtime/modules/rtai_fifos.ko -sudo insmod /usr/realtime/modules/rtai_mbx.ko diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index e6778859e34ae07daad5620b8251186852a658d7..570ee35ad025d1688bea768c7c388d2f38ff96ab 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -124,6 +124,7 @@ extern int oaisim_flag; //uint16_t sf_ahead=4; extern uint16_t sf_ahead; + //pthread_t main_eNB_thread; time_stats_t softmodem_stats_mt; // main thread @@ -175,8 +176,8 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // ******************************************************************* - if (nfapi_mode == 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; uint16_t subframe = proc->subframe_rx; @@ -185,22 +186,29 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam //oai_subframe_ind(proc->frame_tx, proc->subframe_tx); //LOG_D(PHY, "oai_subframe_ind(frame:%u, subframe:%d) - NOT CALLED ********\n", frame, subframe); - start_meas(&nfapi_meas); + + start_meas(&nfapi_meas); oai_subframe_ind(frame, subframe); - stop_meas(&nfapi_meas); - - LOG_D(PHY, "UL_info[rx_ind:%d:%d harqs:%d:%d crcs:%d:%d preambles:%d:%d cqis:%d] RX:%d%d TX:%d%d num_pdcch_symbols:%d\n", - NFAPI_SFNSF2DEC(eNB->UL_INFO.rx_ind.sfn_sf), eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, - NFAPI_SFNSF2DEC(eNB->UL_INFO.harq_ind.sfn_sf), eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, - NFAPI_SFNSF2DEC(eNB->UL_INFO.crc_ind.sfn_sf), eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, - NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, - eNB->UL_INFO.cqi_ind.number_of_cqis, - proc->frame_rx, proc->subframe_rx, + stop_meas(&nfapi_meas); + + if (eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus|| + eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs || + eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs || + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || + eNB->UL_INFO.cqi_ind.number_of_cqis + ) { + LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d num_pdcch_symbols:%d\n", + NFAPI_SFNSF2DEC(eNB->UL_INFO.rx_ind.sfn_sf), eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, + NFAPI_SFNSF2DEC(eNB->UL_INFO.harq_ind.sfn_sf), eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, + NFAPI_SFNSF2DEC(eNB->UL_INFO.crc_ind.sfn_sf), eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, + NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, + eNB->UL_INFO.cqi_ind.number_of_cqis, + proc->frame_rx, proc->subframe_rx, proc->frame_tx, proc->subframe_tx, eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols); + } } - if (nfapi_mode == 1 && eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0) - { + if (nfapi_mode == 1 && eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0) { LOG_E(PHY, "eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0"); return 0; } @@ -212,7 +220,6 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // if this is IF5 or 3GPP_eNB if (eNB && eNB->RU_list && eNB->RU_list[0] && eNB->RU_list[0]->function < NGFI_RAU_IF4p5) { - //LOG_D(PHY,"%s:%s() %u/%u Before wakeup_prach_eNB() proc->instance_cnt_rxtx:%d\n", thread_name, __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->instance_cnt_rxtx); wakeup_prach_eNB(eNB,NULL,proc->frame_rx,proc->subframe_rx); //LOG_D(PHY,"%s:%s() %u/%u Before wakeup_prach_eNB_br() proc->instance_cnt_rxtx:%d\n", thread_name, __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->instance_cnt_rxtx); #ifdef Rel14 @@ -222,9 +229,6 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam } // UE-specific RX processing for subframe n - - - // Panos: Substitute with call to get_nfapi_indications() from the socket. if (nfapi_mode == 0 || nfapi_mode == 1) { phy_procedures_eNB_uespec_RX(eNB, proc, no_relay ); } @@ -249,22 +253,21 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if (oai_exit) return(-1); - // Panos: Substitute with call to send_nfapi_sched_response() to the UE through the socket. phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); stop_meas( &softmodem_stats_rxtx_sf ); - LOG_D(PHY,"%s() Exit proc[rx:%d%d tx:%d%d] rxtx:%lld nfapi:%lld", - __FUNCTION__, proc->frame_rx, proc->subframe_rx, proc->frame_tx, proc->subframe_tx, - softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now); + LOG_D(PHY,"%s() Exit proc[rx:%d%d tx:%d%d]\n", __FUNCTION__, proc->frame_rx, proc->subframe_rx, proc->frame_tx, proc->subframe_tx); - LOG_D(PHY, "phy:%lld tx:%lld rx:%lld prach:%lld ofdm:%lld ", +#if 0 + LOG_D(PHY, "rxtx:%lld nfapi:%lld phy:%lld tx:%lld rx:%lld prach:%lld ofdm:%lld ", + softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now, TICK_TO_US(eNB->phy_proc), TICK_TO_US(eNB->phy_proc_tx), TICK_TO_US(eNB->phy_proc_rx), TICK_TO_US(eNB->rx_prach), - TICK_TO_US(eNB->ofdm_mod_stats)); - + TICK_TO_US(eNB->ofdm_mod_stats), + softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now); LOG_D(PHY, "dlsch[enc:%lld mod:%lld scr:%lld rm:%lld t:%lld i:%lld] rx_dft:%lld ", TICK_TO_US(eNB->dlsch_encoding_stats), @@ -296,6 +299,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam TICK_TO_US(eNB->ulsch_tc_intl1_stats), TICK_TO_US(eNB->ulsch_tc_intl2_stats) ); +#endif //softmodem_stats_rxtx_sf.in, softmodem_stats_rxtx_sf.diff_now, softmodem_stats_rxtx_sf.max, @@ -348,8 +352,6 @@ static void* eNB_thread_rxtx( void* param ) { } - //LOG_D(PHY,"%s:%s() TX:%u/%u DONE rxtx()\n", thread_name, __FUNCTION__, proc->frame_tx, proc->subframe_tx); - if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; } // while !oai_exit @@ -395,9 +397,6 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) proc->subframe_rx = subframe_rx; if (!oai_exit) { - //LOG_D(PHY,"eNB_top in %p (proc %p, CC_id %d), frame %d, subframe %d, instance_cnt_prach %d\n", - //(void*)pthread_self(), proc, eNB->CC_id, proc->frame_rx,proc->subframe_rx,proc->instance_cnt_prach); - T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); proc_rxtx->subframe_rx = proc->subframe_rx; @@ -408,7 +407,7 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) proc_rxtx->timestamp_tx = proc->timestamp_tx; if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); - //LOG_D(PHY,"eNB_top out %p (proc %p, CC_id %d), frame %d, subframe %d, instance_cnt_prach %d\n", (void*)pthread_self(), proc, eNB->CC_id, proc->frame_rx,proc->subframe_rx,proc->instance_cnt_prach); + } } @@ -466,7 +465,7 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { } #endif - // wake up TX for subframe n+2 + // wake up TX for subframe n+sf_ahead // lock the TX mutex and make sure the thread is ready if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); @@ -488,8 +487,7 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { proc_rxtx->subframe_rx = proc->subframe_rx; proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > (9-sf_ahead)) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + sf_ahead)%10; - - LOG_D(PHY,"Signal &proc_rxtx->cond_rxtx\n"); + // the thread can now be woken up if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { @@ -918,7 +916,7 @@ void init_transport(PHY_VARS_eNB *eNB) { int j; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - LOG_E(PHY, "Initialise transport\n"); + LOG_I(PHY, "Initialise transport\n"); for (i=0; i<NUMBER_OF_UE_MAX; i++) { LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i); @@ -997,12 +995,12 @@ void init_eNB_afterRU(void) { LOG_I(PHY,"Mapping RX ports from %d RUs to eNB %d\n",eNB->num_RU,eNB->Mod_id); eNB->frame_parms.nb_antennas_rx = 0; - LOG_E(PHY,"Overwriting eNB->prach_vars.rxsigF[0]:%p\n", eNB->prach_vars.rxsigF[0]); + LOG_I(PHY,"Overwriting eNB->prach_vars.rxsigF[0]:%p\n", eNB->prach_vars.rxsigF[0]); eNB->prach_vars.rxsigF[0] = (int16_t**)malloc16(64*sizeof(int16_t*)); #ifdef Rel14 for (int ce_level=0;ce_level<4;ce_level++) { - LOG_E(PHY,"Overwriting eNB->prach_vars_br.rxsigF.rxsigF[0]:%p\n", eNB->prach_vars_br.rxsigF[ce_level]); + LOG_I(PHY,"Overwriting eNB->prach_vars_br.rxsigF.rxsigF[0]:%p\n", eNB->prach_vars_br.rxsigF[ce_level]); eNB->prach_vars_br.rxsigF[ce_level] = (int16_t**)malloc16(64*sizeof(int16_t*)); } #endif @@ -1034,6 +1032,10 @@ void init_eNB_afterRU(void) { + /* TODO: review this code, there is something wrong. + * In monolithic mode, we come here with nb_antennas_rx == 0 + * (not tested in other modes). + */ if (eNB->frame_parms.nb_antennas_rx < 1) { LOG_I(PHY, "%s() ************* DJP ***** eNB->frame_parms.nb_antennas_rx:%d - GOING TO HARD CODE TO 1", __FUNCTION__, eNB->frame_parms.nb_antennas_rx); @@ -1041,7 +1043,7 @@ void init_eNB_afterRU(void) { } else { - LOG_I(PHY," Delete code\n"); + //LOG_I(PHY," Delete code\n"); } if (eNB->frame_parms.nb_antennas_tx < 1) @@ -1051,7 +1053,7 @@ void init_eNB_afterRU(void) { } else { - LOG_I(PHY," Delete code\n"); + //LOG_I(PHY," Delete code\n"); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index c0dd7033ba647387be2323efb5426f316b14b7e2..3d5b645d108ea97d166cc7ecd7c6ec497082faa5 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -95,6 +95,9 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "enb_config.h" //#include "PHY/TOOLS/time_meas.h" +#include "ENB_APP/enb_paramdef.h" +#include "common/config/config_userapi.h" + #ifndef OPENAIR2 #include "UTIL/OTG/otg_extern.h" #endif @@ -130,6 +133,7 @@ int attach_rru(RU_t *ru); int connect_rau(RU_t *ru); extern uint8_t nfapi_mode; + extern uint16_t sf_ahead; /*************************************************************/ @@ -593,19 +597,20 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { uint32_t symbol_number,symbol_mask,symbol_mask_full; int subframe_tx,frame_tx; -LOG_E(PHY, "%s(ru:%p frame, subframe)\n", __FUNCTION__, ru); + 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 { recv_IF4p5(ru, &frame_tx, &subframe_tx, &packet_type, &symbol_number); - if ((subframe_select(fp,*subframe) == SF_DL) && (symbol_number == 0)) start_meas(&ru->rx_fhaul); + 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); 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 { AssertFatal(frame_tx == *frame, @@ -619,14 +624,15 @@ LOG_E(PHY, "%s(ru:%p frame, subframe)\n", __FUNCTION__, ru); 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) == SF_DL) stop_meas(&ru->rx_fhaul); + if (subframe_select(fp,subframe_tx) == SF_DL) stop_meas(&ru->rx_fhaul); proc->subframe_tx = subframe_tx; proc->frame_tx = frame_tx; if ((frame_tx == 0)&&(subframe_tx == 0)) proc->frame_tx_unwrap += 1024; - proc->timestamp_tx = (((frame_tx + proc->frame_tx_unwrap) * 10) + subframe_tx) * fp->samples_per_tti; + 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 if (ru == RC.ru[0]) { @@ -759,6 +765,8 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { if (rxs != fp->samples_per_tti) { //exit_fun( "problem receiving samples" ); + + LOG_E(PHY, "problem receiving samples"); } } @@ -876,7 +884,10 @@ static void* ru_thread_asynch_rxtx( void* param ) { // 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) ru->fh_north_asynch_in(ru,&frame,&subframe); + 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"); } @@ -945,8 +956,6 @@ static void* ru_thread_prach( void* param ) { thread_top_init("ru_thread_prach",1,500000L,1000000L,20000000L); -LOG_E(PHY,"In rach thread\n"); - while (RC.ru_mask>0) { usleep(1e6); LOG_I(PHY,"%s() RACH waiting for RU to be configured\n", __FUNCTION__); @@ -958,13 +967,27 @@ LOG_E(PHY,"In rach thread\n"); if (oai_exit) break; if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"ru_prach_thread") < 0) break; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_RU_PRACH_RX, 1 ); - prach_procedures( + if (ru->eNB_list[0]){ + prach_procedures( ru->eNB_list[0] #ifdef Rel14 ,0 #endif ); - + } + else { + rx_prach(NULL, + ru, + NULL, + NULL, + NULL, + proc->frame_prach, + 0 +#ifdef Rel14 + ,0 +#endif + ); + } 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; } @@ -1114,14 +1137,14 @@ void wakeup_eNBs(RU_t *ru) { int i; PHY_VARS_eNB **eNB_list = ru->eNB_list; - //LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top); + LOG_D(PHY,"wakeup_eNBs (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) { // 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); + 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); } else { @@ -1158,10 +1181,11 @@ static inline int wakeup_prach_ru(RU_t *ru) { ru->proc.subframe_prach = ru->proc.subframe_rx; // DJP - think prach_procedures() is looking at eNB frame_prach - 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); + if (ru->eNB_list[0]) { + ru->eNB_list[0]->proc.frame_prach = ru->proc.frame_rx; + ru->eNB_list[0]->proc.subframe_prach = ru->proc.subframe_rx; + } + LOG_I(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"); } @@ -1377,8 +1401,11 @@ static void* ru_stats_thread(void* param) { 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); - + 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); @@ -1477,6 +1504,7 @@ static void* ru_thread( void* param ) { if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&subframe); else AssertFatal(1==0, "No fronthaul interface at south port"); +/* LOG_D(PHY,"AFTER fh_south_in - SFN/SF:%d%d RU->proc[RX:%d%d TX:%d%d] RC.eNB[0][0]:[RX:%d%d TX(SFN):%d]\n", frame,subframe, proc->frame_rx,proc->subframe_rx, @@ -1484,19 +1512,12 @@ static void* ru_thread( void* param ) { RC.eNB[0][0]->proc.frame_rx,RC.eNB[0][0]->proc.subframe_rx, RC.eNB[0][0]->proc.frame_tx); - if (nfapi_mode == 1) // PNF - { - // This is the earliest I think we can do this - //wakeup_nfapi_subframe_thread(); - } - - if (0 && is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)) 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)) { +*/ + if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { wakeup_prach_ru(ru); } #ifdef Rel14 @@ -1520,7 +1541,6 @@ static void* ru_thread( void* param ) { // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_eNBs(ru); - //LOG_E(PHY,"%s() Before wait_on_condition()\n", __FUNCTION__); // wait until eNBs are finished subframe RX n and TX n+sf_ahead wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); @@ -1728,7 +1748,7 @@ void init_RU_proc(RU_t *ru) { } else if (ru->function == eNodeB_3GPP && ru->if_south == LOCAL_RF) { // DJP - need something else to distinguish between monolithic and PNF - LOG_E(PHY,"%s() DJP - added creation of pthread_prach\n", __FUNCTION__); + LOG_I(PHY,"%s() DJP - added creation of pthread_prach\n", __FUNCTION__); pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); } @@ -1866,8 +1886,11 @@ void configure_rru(int idx, 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) { - LOG_I(PHY,"Setting ru->function to NGFI_RRU_IF4p5, prach_FrequOffset %d, prach_ConfigIndex %d\n", - config->prach_FreqOffset[0],config->prach_ConfigIndex[0]); + 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]; #ifdef Rel14 @@ -1881,6 +1904,8 @@ void configure_rru(int idx, init_frame_parms(&ru->frame_parms,1); + fill_rf_config(ru,ru->rf_config_file); + phy_init_RU(ru); @@ -1923,7 +1948,7 @@ void init_RU(char *rf_config_file) { int ru_id; RU_t *ru; int ret; - PHY_VARS_eNB *eNB0; + PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; int i; int CC_id; @@ -1941,9 +1966,9 @@ void init_RU(char *rf_config_file) { 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_E(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); + LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { -LOG_E(PHY,"Process RC.ru[%d]\n",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; @@ -1951,25 +1976,26 @@ LOG_E(PHY,"Process RC.ru[%d]\n",ru_id); // use eNB_list[0] as a reference for RU frame parameters // NOTE: multiple CC_id are not handled here yet! - printf("%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->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_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; + 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 + { + LOG_E(PHY,"DJP - delete code above this %s:%d\n", __FILE__, __LINE__); + } } - else - { - LOG_E(PHY,"DJP - delete code above this %s:%d\n", __FILE__, __LINE__); - } - eNB0 = ru->eNB_list[0]; - printf("RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south); - printf("eNB0:%p\n", eNB0); + 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)) @@ -1980,7 +2006,7 @@ LOG_E(PHY,"Process RC.ru[%d]\n",ru_id); memcpy((void*)&ru->frame_parms,(void*)&eNB0->frame_parms,sizeof(LTE_DL_FRAME_PARMS)); // attach all RU to all eNBs in its list/ - LOG_E(PHY,"ru->num_eNB:%d eNB0->num_RU:%d\n", ru->num_eNB, eNB0->num_RU); + 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; @@ -1990,7 +2016,7 @@ LOG_E(PHY,"Process RC.ru[%d]\n",ru_id); // 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_E(PHY,"ru->if_south:%d\n", ru->if_south); + LOG_D(PHY,"ru->if_south:%d\n", ru->if_south); switch (ru->if_south) { case LOCAL_RF: // this is an RU with integrated RF (RRU, eNB) @@ -2009,6 +2035,8 @@ LOG_E(PHY,"ru->if_south:%d\n", ru->if_south); 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_id); @@ -2032,6 +2060,8 @@ LOG_E(PHY,"ru->if_south:%d\n", ru->if_south); 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_id); @@ -2154,3 +2184,134 @@ void stop_ru(RU_t *ru) { } + +/* --------------------------------------------------------*/ +/* 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); + + + if ( RUParamList.numelt > 0) { + + RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*)); + + + + + RC.ru_mask=(1<<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]->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]; + + + 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)); + 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]; + } //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; + } + RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + } /* 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); + + }// j=0..num_rus + } else { + RC.nb_RU = 0; + } // setting != NULL + + return; + +} diff --git a/targets/RT/USER/lte-softmodem-stub.c b/targets/RT/USER/lte-softmodem-stub.c index 13b15808da4c961e90ed6e6ecdd4f65cceb0099a..a478c5ff445b6463ba38b64dd9b60d58b254af4c 100644 --- a/targets/RT/USER/lte-softmodem-stub.c +++ b/targets/RT/USER/lte-softmodem-stub.c @@ -90,6 +90,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "enb_config.h" +#include "targets/COMMON/create_tasks.h" //#include "PHY/TOOLS/time_meas.h" #ifndef OPENAIR2 @@ -1224,7 +1225,8 @@ int main( int argc, char **argv ) if (UE_flag == 1) { // don't create if node doesn't connect to RRC/S1/GTP - if (create_tasks(UE_flag ? 0 : 1, UE_flag ? 1 : 0) < 0) { + //if (create_tasks(UE_flag ? 0 : 1, UE_flag ? 1 : 0) < 0) { + if (create_tasks_ue(1) < 0) { printf("cannot create ITTI tasks\n"); exit(-1); // need a softer mode } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index b76f8734361c05756bfc89a7bfd9061687d896bb..83f68882927660dbe72dd31a400e02158894412d 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -243,6 +243,9 @@ threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; */ uint8_t abstraction_flag=0; +/* forward declarations */ +void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); + /*---------------------BMC: timespec helpers -----------------------------*/ struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; @@ -612,8 +615,10 @@ static void get_options(void) { uint8_t n_rb_dl; nfapi_mode=0; + paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; - paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; + + paramdef_t cmdline_ueparams[] = CMDLINE_UEPARAMS_DESC; set_default_frame_parms(frame_parms); @@ -626,20 +631,22 @@ static void get_options(void) { input_fd = fopen(loopfile,"r"); AssertFatal(input_fd != NULL,"Please provide a valid input file\n"); } + if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp; if ( (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = debug_prach; if ( (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = no_L2_connect; - if ( (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = calib_prach_tx; - if (dumpframe > 0) mode = rx_dump_frame; + if ( (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = calib_prach_tx; + if ( (cmdline_uemodeparams[CMDLINE_DUMPMEMORY_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_dump_frame; + //if (dumpframe > 0) mode = rx_dump_frame; if ( downlink_frequency[0][0] > 0) { - printf("Downlink frequency set to %u\n", downlink_frequency[0][0]); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; - } - UE_scan=0; + printf("Downlink frequency set to %u\n", downlink_frequency[0][0]); + 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) { @@ -672,13 +679,13 @@ static void get_options(void) { } } - - for (CC_id=1;CC_id<MAX_NUM_CCs;CC_id++) { - tx_max_power[CC_id]=tx_max_power[0]; - rx_gain[0][CC_id] = rx_gain[0][0]; - tx_gain[0][CC_id] = tx_gain[0][0]; + for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { + tx_max_power[CC_id]=tx_max_power[0]; + rx_gain[0][CC_id] = rx_gain[0][0]; + tx_gain[0][CC_id] = tx_gain[0][0]; } } /* UE_flag > 0 */ + #if T_TRACER paramdef_t cmdline_ttraceparams[] =CMDLINE_TTRACEPARAMS_DESC ; config_process_cmdline( cmdline_ttraceparams,sizeof(cmdline_ttraceparams)/sizeof(paramdef_t),NULL); @@ -693,11 +700,12 @@ static void get_options(void) { NB_RU = RC.nb_RU; printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,NB_RU); } - } else if (UE_flag == 1 && (CONFIG_GETCONFFILE != NULL)) { + } else if (UE_flag == 1 && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) { // Here the configuration file is the XER encoded UE capabilities // Read it in and store in asn1c data structures strcpy(uecap_xer,CONFIG_GETCONFFILE); // uecap_xer_in=1; + } /* UE with config file */ } @@ -709,7 +717,7 @@ int T_dont_fork = 0; /* default is to fork, see 'T_init' to understand */ #endif -void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); + void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { int CC_id; @@ -746,11 +754,12 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; - downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. - downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; - downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; - downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; +// downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. +// downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; +// downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; +// downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; //printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); + frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0]; } @@ -874,8 +883,10 @@ void wait_eNBs(void) { while (waiting==1) { - printf("Waiting for eNB L1 instances to all get configured ... sleeping 500ms (nb_L1_inst %d)\n",RC.nb_L1_inst); - usleep(5000000); + printf("Waiting for eNB L1 instances to all get configured ... sleeping 50ms (nb_L1_inst %d)\n",RC.nb_L1_inst); + usleep(50*1000); + //usleep(5000000); + waiting=0; for (i=0;i<RC.nb_L1_inst;i++) { @@ -943,6 +954,7 @@ int main( int argc, char **argv ) // set default parameters //if (UE_flag == 1) set_default_frame_parms(frame_parms); + logInit(); printf("Reading in command-line options\n"); @@ -967,7 +979,7 @@ int main( int argc, char **argv ) printf("configuring for UE\n"); set_comp_log(HW, LOG_DEBUG, LOG_HIGH, 1); - set_comp_log(PHY, LOG_DEBUG, LOG_HIGH, 1); + set_comp_log(PHY, LOG_INFO, LOG_HIGH, 1); set_comp_log(MAC, LOG_INFO, LOG_HIGH, 1); set_comp_log(RLC, LOG_INFO, LOG_HIGH | FLAG_THREAD, 1); set_comp_log(PDCP, LOG_INFO, LOG_HIGH, 1); @@ -1059,6 +1071,7 @@ int main( int argc, char **argv ) + printf("Before CC \n"); for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { @@ -1118,10 +1131,12 @@ int main( int argc, char **argv ) else if (frame_parms[CC_id]->N_RB_DL == 25) UE[CC_id]->N_TA_offset = 624/4; } - init_openair0(); + init_openair0(); } + } + printf("Runtime table\n"); fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); cpuf=get_cpu_freq_GHz(); @@ -1169,16 +1184,23 @@ int main( int argc, char **argv ) #if defined(ENABLE_ITTI) - + if ((UE_flag == 1)|| (RC.nb_inst > 0)) { // don't create if node doesn't connect to RRC/S1/GTP - if (create_tasks(UE_flag ? 0 : 1, UE_flag ? 1 : 0) < 0) { - printf("cannot create ITTI tasks\n"); - exit(-1); // need a softer mode + if (UE_flag == 0) { + if (create_tasks(1) < 0) { + printf("cannot create ITTI tasks\n"); + exit(-1); // need a softer mode + } + } + else { + if (create_tasks_ue(1) < 0) { + printf("cannot create ITTI tasks\n"); + exit(-1); // need a softer mode + } } - printf("ITTI tasks created\n"); } else { @@ -1186,6 +1208,12 @@ int main( int argc, char **argv ) RCconfig_L1(); } #endif + + + // init UE_PF_PO and mutex lock + pthread_mutex_init(&ue_pf_po_mutex, NULL); + memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); + mlockall(MCL_CURRENT | MCL_FUTURE); @@ -1252,6 +1280,13 @@ int main( int argc, char **argv ) #endif rt_sleep_ns(10*100000000ULL); + + if (nfapi_mode) { + + printf("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); + } if (nfapi_mode) { @@ -1287,7 +1322,8 @@ int main( int argc, char **argv ) // start the main threads if (UE_flag == 1) { int eMBMS_active = 0; - init_UE(1,eMBMS_active,uecap_xer_in); + init_UE(1,eMBMS_active,uecap_xer_in,0); + if (phy_test==0) { printf("Filling UE band info\n"); fill_ue_band_info(); @@ -1295,7 +1331,6 @@ int main( int argc, char **argv ) } 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+chain_offset; @@ -1311,8 +1346,10 @@ int main( int argc, char **argv ) // for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0); } + printf("wait_eNBs()\n"); wait_eNBs(); + printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); if (RC.nb_RU >0) { printf("Initializing RU threads\n"); init_RU(rf_config_file); @@ -1324,8 +1361,7 @@ int main( int argc, char **argv ) config_sync_var=0; - if (nfapi_mode==1) // PNF - { + if (nfapi_mode==1) { // PNF wait_nfapi_init("main?"); } @@ -1455,6 +1491,7 @@ int main( int argc, char **argv ) pthread_mutex_destroy(&nfapi_sync_mutex); + pthread_mutex_destroy(&ue_pf_po_mutex); // *** Handle per CC_id openair0 if (UE_flag==1) { diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index a1efac88606c8f580d2a60e904ef4aae121280f3..69f34e6aa4a31755394a4b2747f700aee8e410e7 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -65,7 +65,7 @@ #define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" #define CONFIG_HLP_TADV "Set timing_advance\n" #define CONFIG_HLP_DLF "Set the downlink frequency for all component carriers\n" -#define CONFIG_HLP_CHOFF "Channel id offset" +#define CONFIG_HLP_CHOFF "Channel id offset\n" #define CONFIG_HLP_SOFTS "Enable soft scope and L1 and L2 stats (Xforms)\n" #define CONFIG_HLP_EXMCAL "Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n" #define CONFIG_HLP_ITTIL "Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n" @@ -251,7 +251,7 @@ extern void init_RU(const char*); extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); -extern void init_UE(int,int,int); +extern void init_UE(int,int,int,int); extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name); extern void reset_opp_meas(void); diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 448ccf36342252e353601e365a0fe1d1a754c8d1..c784b9a3b8fffbd059e590a8dd7c3ecb7517b2cd 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -77,7 +77,7 @@ typedef enum { void init_UE_threads(int); void init_UE_threads_stub(int); void *UE_thread(void *arg); -void init_UE(int nb_inst,int,int); +void init_UE(int nb_inst,int,int,int); void init_UE_stub(int nb_inst,int,int,char*); extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); //extern int tx_req_UE_MAC1(); @@ -223,7 +223,7 @@ void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_ } -void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in) { +void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correction) { PHY_VARS_UE *UE; int inst; @@ -239,6 +239,8 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in) { LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]); PHY_vars_UE_g[inst][0] = init_ue_vars(NULL,inst,0); + // turn off timing control loop in UE + PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction; LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); init_UE_threads(inst); @@ -359,6 +361,7 @@ static void *UE_thread_synch(void *arg) } while (ind < sizeof(eutra_bands) / sizeof(eutra_bands[0])); if (found == 0) { + LOG_E(PHY,"Can't find EUTRA band for frequency %d",UE->frame_parms.dl_CarrierFreq); exit_fun("Can't find EUTRA band for frequency"); return &UE_thread_synch_retval; } @@ -1166,168 +1169,173 @@ void *UE_thread(void *arg) { UE->frame_parms.nb_antennas_rx); } #endif - } - - } // UE->is_synchronized==0 - else { - if (start_rx_stream==0) { - start_rx_stream=1; - if (UE->mode != loop_through_memory) { - if (UE->no_timing_correction==0) { - LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); - AssertFatal(UE->rx_offset == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - (void**)UE->common_vars.rxdata, - UE->rx_offset, - UE->frame_parms.nb_antennas_rx),""); - } - UE->rx_offset=0; - UE->time_sync_cell=0; - //UE->proc.proc_rxtx[0].frame_rx++; - //UE->proc.proc_rxtx[1].frame_rx++; - for (th_id=0; th_id < RX_NB_TH; th_id++) { - UE->proc.proc_rxtx[th_id].frame_rx++; - } - - // read in first symbol - AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - (void**)UE->common_vars.rxdata, - UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, - UE->frame_parms.nb_antennas_rx),""); - slot_fep(UE,0, 0, 0, 0, 0); - } //UE->mode != loop_through_memory - else - rt_sleep_ns(1000*1000); - - } else { - sub_frame++; - sub_frame%=10; - UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[thread_idx]; - // update thread index for received subframe - UE->current_thread_id[sub_frame] = thread_idx; - - LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); - - thread_idx++; - if(thread_idx>=RX_NB_TH) - thread_idx = 0; - - - if (UE->mode != loop_through_memory) { - for (i=0; i<UE->frame_parms.nb_antennas_rx; i++) - rxp[i] = (void*)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+ - UE->frame_parms.nb_prefix_samples0+ - sub_frame*UE->frame_parms.samples_per_tti]; - for (i=0; i<UE->frame_parms.nb_antennas_tx; i++) - txp[i] = (void*)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti]; - - int readBlockSize, writeBlockSize; - if (sub_frame<9) { - readBlockSize=UE->frame_parms.samples_per_tti; - writeBlockSize=UE->frame_parms.samples_per_tti; - } else { - // set TO compensation to zero - UE->rx_offset_diff = 0; - // compute TO compensation that should be applied for this frame - if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti && - UE->rx_offset > 0 ) - UE->rx_offset_diff = -1 ; - if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti && - UE->rx_offset < 10*UE->frame_parms.samples_per_tti ) - UE->rx_offset_diff = 1; - - LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset); - readBlockSize=UE->frame_parms.samples_per_tti - - UE->frame_parms.ofdm_symbol_size - - UE->frame_parms.nb_prefix_samples0 - - UE->rx_offset_diff; - writeBlockSize=UE->frame_parms.samples_per_tti - - UE->rx_offset_diff; - } - - AssertFatal(readBlockSize == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp, - rxp, - readBlockSize, - UE->frame_parms.nb_antennas_rx),""); - AssertFatal( writeBlockSize == - UE->rfdevice.trx_write_func(&UE->rfdevice, - timestamp+ - (2*UE->frame_parms.samples_per_tti) - - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - - openair0_cfg[0].tx_sample_advance, - txp, - writeBlockSize, - UE->frame_parms.nb_antennas_tx, - 1),""); - if( sub_frame==9) { - // read in first symbol of next frame and adjust for timing drift - int first_symbols=writeBlockSize-readBlockSize; - if ( first_symbols > 0 ) - AssertFatal(first_symbols == - UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp1, - (void**)UE->common_vars.rxdata, - first_symbols, - UE->frame_parms.nb_antennas_rx),""); - if ( first_symbols <0 ) - LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); - } - pickTime(gotIQs); - // operate on thread sf mod 2 - AssertFatal(pthread_mutex_lock(&proc->mutex_rxtx) ==0,""); - if(sub_frame == 0) { - //UE->proc.proc_rxtx[0].frame_rx++; - //UE->proc.proc_rxtx[1].frame_rx++; - for (th_id=0; th_id < RX_NB_TH; th_id++) { - UE->proc.proc_rxtx[th_id].frame_rx++; - } - } - //UE->proc.proc_rxtx[0].gotIQs=readTime(gotIQs); - //UE->proc.proc_rxtx[1].gotIQs=readTime(gotIQs); - for (th_id=0; th_id < RX_NB_TH; th_id++) { - UE->proc.proc_rxtx[th_id].gotIQs=readTime(gotIQs); - } - proc->subframe_rx=sub_frame; - proc->subframe_tx=(sub_frame+4)%10; - proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); - proc->timestamp_tx = timestamp+ - (4*UE->frame_parms.samples_per_tti)- - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0; - - proc->instance_cnt_rxtx++; - LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx); - if (proc->instance_cnt_rxtx == 0) { - if (pthread_cond_signal(&proc->cond_rxtx) != 0) { - LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id); - exit_fun("nothing to add"); - } - } else { - LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", UE->Mod_id, proc->instance_cnt_rxtx); - if (proc->instance_cnt_rxtx > 2) - exit_fun("instance_cnt_rxtx > 2"); - } - - AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0 ,""); - AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,""); - initRefTimes(t1); - initStaticTime(lastTime); - updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)"); - pickStaticTime(lastTime); - - } else { - printf("Processing subframe %d",proc->subframe_rx); - getchar(); } - } // start_rx_stream==1 - } // UE->is_synchronized==1 - } // while !oai_exit - return NULL; + } // UE->is_synchronized==0 + else { + if (start_rx_stream==0) { + start_rx_stream=1; + if (UE->mode != loop_through_memory) { + if (UE->no_timing_correction==0) { + LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); + AssertFatal(UE->rx_offset == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + (void**)UE->common_vars.rxdata, + UE->rx_offset, + UE->frame_parms.nb_antennas_rx),""); + } + UE->rx_offset=0; + UE->time_sync_cell=0; + //UE->proc.proc_rxtx[0].frame_rx++; + //UE->proc.proc_rxtx[1].frame_rx++; + for (th_id=0; th_id < RX_NB_TH; th_id++) { + UE->proc.proc_rxtx[th_id].frame_rx++; + } + + // read in first symbol + AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + (void**)UE->common_vars.rxdata, + UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, + UE->frame_parms.nb_antennas_rx),""); + slot_fep(UE,0, 0, 0, 0, 0); + } //UE->mode != loop_through_memory + else + rt_sleep_ns(1000*1000); + + } else { + sub_frame++; + sub_frame%=10; + UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[thread_idx]; + // update thread index for received subframe + UE->current_thread_id[sub_frame] = thread_idx; + + LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); + + thread_idx++; + if(thread_idx>=RX_NB_TH) + thread_idx = 0; + + + if (UE->mode != loop_through_memory) { + for (i=0; i<UE->frame_parms.nb_antennas_rx; i++) + rxp[i] = (void*)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+ + UE->frame_parms.nb_prefix_samples0+ + sub_frame*UE->frame_parms.samples_per_tti]; + for (i=0; i<UE->frame_parms.nb_antennas_tx; i++) + txp[i] = (void*)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti]; + + int readBlockSize, writeBlockSize; + if (sub_frame<9) { + readBlockSize=UE->frame_parms.samples_per_tti; + writeBlockSize=UE->frame_parms.samples_per_tti; + } else { + // set TO compensation to zero + + UE->rx_offset_diff = 0; + + // compute TO compensation that should be applied for this frame + + if (UE->no_timing_correction == 0) { + if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti && + UE->rx_offset > 0 ) + UE->rx_offset_diff = -1 ; + if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti && + UE->rx_offset < 10*UE->frame_parms.samples_per_tti ) + UE->rx_offset_diff = 1; + } + + LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset); + readBlockSize=UE->frame_parms.samples_per_tti - + UE->frame_parms.ofdm_symbol_size - + UE->frame_parms.nb_prefix_samples0 - + UE->rx_offset_diff; + writeBlockSize=UE->frame_parms.samples_per_tti - + UE->rx_offset_diff; + } + + AssertFatal(readBlockSize == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp, + rxp, + readBlockSize, + UE->frame_parms.nb_antennas_rx),""); + AssertFatal( writeBlockSize == + UE->rfdevice.trx_write_func(&UE->rfdevice, + timestamp+ + (2*UE->frame_parms.samples_per_tti) - + UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - + openair0_cfg[0].tx_sample_advance, + txp, + writeBlockSize, + UE->frame_parms.nb_antennas_tx, + 1),""); + if( sub_frame==9) { + // read in first symbol of next frame and adjust for timing drift + int first_symbols=writeBlockSize-readBlockSize; + if ( first_symbols > 0 ) + AssertFatal(first_symbols == + UE->rfdevice.trx_read_func(&UE->rfdevice, + ×tamp1, + (void**)UE->common_vars.rxdata, + first_symbols, + UE->frame_parms.nb_antennas_rx),""); + if ( first_symbols <0 ) + LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); + } + pickTime(gotIQs); + // operate on thread sf mod 2 + AssertFatal(pthread_mutex_lock(&proc->mutex_rxtx) ==0,""); + if(sub_frame == 0) { + //UE->proc.proc_rxtx[0].frame_rx++; + //UE->proc.proc_rxtx[1].frame_rx++; + for (th_id=0; th_id < RX_NB_TH; th_id++) { + UE->proc.proc_rxtx[th_id].frame_rx++; + } + } + //UE->proc.proc_rxtx[0].gotIQs=readTime(gotIQs); + //UE->proc.proc_rxtx[1].gotIQs=readTime(gotIQs); + for (th_id=0; th_id < RX_NB_TH; th_id++) { + UE->proc.proc_rxtx[th_id].gotIQs=readTime(gotIQs); + } + proc->subframe_rx=sub_frame; + proc->subframe_tx=(sub_frame+4)%10; + proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); + proc->timestamp_tx = timestamp+ + (4*UE->frame_parms.samples_per_tti)- + UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0; + + proc->instance_cnt_rxtx++; + LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx); + if (proc->instance_cnt_rxtx == 0) { + if (pthread_cond_signal(&proc->cond_rxtx) != 0) { + LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id); + exit_fun("nothing to add"); + } + } else { + LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", UE->Mod_id, proc->instance_cnt_rxtx); + if (proc->instance_cnt_rxtx > 2) + exit_fun("instance_cnt_rxtx > 2"); + } + + AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0 ,""); + AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,""); + initRefTimes(t1); + initStaticTime(lastTime); + updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)"); + pickStaticTime(lastTime); + + } else { + printf("Processing subframe %d",proc->subframe_rx); + getchar(); + } + } // start_rx_stream==1 + } // UE->is_synchronized==1 + + } // while !oai_exit + return NULL; } diff --git a/targets/RT/USER/make_for_usrp.sh b/targets/RT/USER/make_for_usrp.sh deleted file mode 100755 index 998cd7c462d5a0f4a66926d5d4890509c0b21050..0000000000000000000000000000000000000000 --- a/targets/RT/USER/make_for_usrp.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -############### make nasmesh.ko ############### -sudo rmmod nasmesh -#cd ${OPENAIR2_DIR} && make nasmesh_netlink.ko -#cd ${OPENAIR2_DIR}/NAS/DRIVER/MESH/RB_TOOL/ && make -#make all -sudo insmod $OPENAIR2_DIR/NAS/DRIVER/MESH/nasmesh.ko - -############## Ethernet config #################### -sudo ifconfig eth0 mtu 4000 -sudo sysctl -w net.core.wmem_max=1048576 -sudo sysctl -w net.core.rmem_max=50000000 - -############## rtai modules ################### -if test \! -c /dev/rtai_shm; then - sudo mknod -m 666 /dev/rtai_shm c 10 254 -fi -for n in `seq 0 9`; do - f=/dev/rtf$n - if test \! -c $f; then - sudo mknod -m 666 $f c 150 $n - fi -done -sudo modprobe rtai_hal -sudo modprobe rtai_sched -sudo modprobe rtai_fifos -sudo modprobe rtai_sem -sudo modprobe rtai_mbx -sudo modprobe rtai_msg - -############## make ################### -make lte-softmodem-usrp NAS=1 USRP=1 XFORMS=1 RTAI=1 HARD_RT=1 #DRIVER2013=1 -#make lte-softmodem NAS=1 XFORMS=1 USRP=0 RTAI=1 DRIVER2013=1 -echo DONE! -exit 0 diff --git a/targets/RT/USER/msg_helper.c b/targets/RT/USER/msg_helper.c deleted file mode 100644 index ac99e48ff747f6edef813c4ff29f9a28902bb42c..0000000000000000000000000000000000000000 --- a/targets/RT/USER/msg_helper.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <rtai_sem.h> - -#include "msg_many.h" - -/* - * Add a task task to ri->worker. - * Return the used index in ri->worker on success - * Return -TM_WORKER_FULL_ERROR if ri->worker full - * Return -TM_WORKER_ERROR else -*/ -int tm_add_task(RT_TASK *task, run_info_t *ri) -{ - if(ri->used >= NUM_THREADS) - return -TM_WORKER_FULL_ERROR; - - rt_sem_wait(ri->update_sem); - (*ri->worker)[ri->used] = task; - ri->used++; - rt_sem_signal(ri->update_sem); - - return ri->used - 1; -} - -/* - * Remove the a hole in worker at index index by - * shift the next slots by one. - * This function assume that update_sem are locked. - * Return the new used counter. -*/ -int _tm_clean_worker(RT_TASK *(*worker)[], int index, int used) -{ - int i; - - for(i = index; i < used; i++) - (*worker)[i] = (*worker)[i + 1]; - - return used - 1; -} - -/* - * Remove a task from ri->worker a index task_index - * Return 0 on success - * Return -TM_WORKER_ERROR else -*/ -int tm_del_task(int task_index, run_info_t *ri) -{ - rt_sem_wait(ri->update_sem); - ri->used = _tm_clean_worker(ri->worker, task_index, ri->used); - rt_sem_signal(ri->update_sem); - - return 0; -} - -/* - * Return next index to use on ri->worker. - * It depends on the old_index and ri->used. - * Return -TM_WORKER_ERROR if ri->used == 0. -*/ -inline int tm_get_next_task_index(int old_index, run_info_t *ri) -{ - if(ri->used == 0) - return -TM_WORKER_ERROR; - - return (old_index + 1) % ri->used; -} - diff --git a/targets/RT/USER/msg_many.c b/targets/RT/USER/msg_many.c deleted file mode 100644 index 17e03c6c5a023bd3135a404d31f2958f18c48d34..0000000000000000000000000000000000000000 --- a/targets/RT/USER/msg_many.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sched.h> - -#include <rtai_lxrt.h> -#include <rtai_sem.h> -#include <rtai_msg.h> - -#include "msg_many.h" - -static void *msg_test_thread(void *arg) -{ - RT_TASK *self; - RT_TASK *sender_task; - thread_info_t *ti = (thread_info_t *)arg; - run_info_t *ri = ti->ri; - unsigned int msg; - int counter = 0; - char name[6]; - int task_index; - - /* Build custom task name for each thread */ - snprintf(name, 6, "%s%03i", THREAD_NAME_PREFIX, ti->thread_num); - - self = rt_task_init_schmod(nam2num(name), 0, 0, 0, SCHED_FIFO, 0xF); - mlockall(MCL_CURRENT | MCL_FUTURE); - - rt_make_hard_real_time(); - - task_index = tm_add_task(self, ri); - - if(task_index != -TM_WORKER_FULL_ERROR) { - while (*(ri->exit_condition) == 0) { - // wait only one PERIOD to avoid wait for ever - sender_task = rt_receive_timed(ri->sender, &msg, ri->period); - - //sender_task = rt_receive(0, &msg); - if(sender_task == ri->sender) - counter++; - } - - rt_printk("%s: counter == %i\n", name, counter); - tm_del_task(task_index, ri); - } else { - rt_printk("%s: Worker array full!\n", name); - } - - rt_make_soft_real_time(); - - rt_task_delete(self); - - free((void *) ti); - - return 0; -} - - -int main(void) -{ - RT_TASK *self; - RT_TASK *tmp_worker_task; - RT_TASK *worker_tasks[NUM_THREADS]; - int worker_threads[NUM_THREADS]; - RTIME now; - unsigned int i, ii; - run_info_t ri; - thread_info_t *ti; - uint8_t exit_condition = 0; - int fail_count = 0; - int old_index = 0; - uint8_t lost; - - // make main thread LXRT soft realtime - self = rt_task_init_schmod(nam2num("MAINTK"), 10, 0, 0, SCHED_FIFO, 0xF); - mlockall(MCL_CURRENT | MCL_FUTURE); - - rt_make_hard_real_time(); - rt_set_periodic_mode(); - start_rt_timer(0); - - /* Build all information need to run in main and the thread */ - ri.sender = self; - ri.exit_condition = &exit_condition; - ri.period = nano2count(PERIOD); - ri.update_sem = rt_sem_init(nam2num("MUTEX"), 1); - - if(ri.update_sem == 0) - exit(-1); - - ri.used = 0; - ri.worker = &worker_tasks; - - now = rt_get_time() + ri.period; - rt_task_make_periodic(self, now, ri.period); - - /* start all threads */ - for(i = 0; i < NUM_THREADS; i++) { - ti = (thread_info_t *)malloc(sizeof(thread_info_t)); - - if(ti == NULL) { - rt_printk("MAINTK: can't get memory!\n"); - exit(-1); - } - - ti->ri = &ri; - ti->thread_num = i; - worker_threads[i] = rt_thread_create(msg_test_thread, ti , 10000); - } - - rt_sleep(NUM_THREADS * ri.period); - - rt_printk("start\n"); - - for(i = 0; i < THRESHOLD; i++) { - rt_task_wait_period(); - lost = 1; - - for(ii = 0; ii < ri.used; ii++) { - old_index = tm_get_next_task_index(old_index, &ri); - - if(old_index == -TM_WORKER_ERROR) { - rt_printk("MAINTK: No Tasks!\n"); - break; - } - - tmp_worker_task = rt_send_if(worker_tasks[old_index], i); - - if(tmp_worker_task == worker_tasks[old_index]) { - lost = 0; - break; - } - } - - if(lost) - fail_count++; - } - - rt_printk("fail_count == %i\n", fail_count); - - // cleanup - exit_condition = 1; - rt_make_soft_real_time(); - - rt_task_delete(self); - - /* wait for the worker threadss */ - for(ii = 0; ii < ri.used; ii++) { - rt_thread_join(worker_threads[ii]); - } - - stop_rt_timer(); - return 0; -} diff --git a/targets/RT/USER/msg_many.h b/targets/RT/USER/msg_many.h deleted file mode 100644 index 5b9d465e33658b9f8b992d3058cae13b99a93619..0000000000000000000000000000000000000000 --- a/targets/RT/USER/msg_many.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef __MSG_MANY_H__ -#define __MSG_MANY_H__ -#include <stdint.h> - -#define PERIOD 500000 /* in nano seconds */ -#define THRESHOLD 1000000 -#define THREAD_NAME_PREFIX "TK" -#define NUM_THREADS 10 - -#define TM_WORKER_FULL_ERROR 1 -#define TM_WORKER_ERROR 2 - -typedef struct run_info { - RT_TASK *sender; - uint8_t *exit_condition; - long long period; - SEM *update_sem; /* protect the task array */ - int used; /* counter of used slots in worker */ - RT_TASK *(*worker)[]; /* declare worker as pointer to array of pointer to RT_TASK */ -} run_info_t; - -typedef struct thread_info { - run_info_t *ri; - uint8_t thread_num; -} thread_info_t; - -int tm_add_task(RT_TASK *task, run_info_t *ri); -int tm_del_task(int task_index, run_info_t *ri); -inline int tm_get_next_task_index(int old_index, run_info_t *ri); - -#endif - diff --git a/targets/RT/USER/rrh.c b/targets/RT/USER/rrh.c deleted file mode 100644 index 88bd3f644dde90213cbffa24a287a7df9681a454..0000000000000000000000000000000000000000 --- a/targets/RT/USER/rrh.c +++ /dev/null @@ -1,1220 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/** ethernet_lib : API to stream I/Q samples over standard ethernet (RRH component) -* -* Authors: Raymond Knopp <raymond.knopp@eurecom.fr>, Riadh Ghaddab <riadh.ghaddab@eurecom.fr> -* -* Changelog: -* 06.10.2014: Initial version -*/ - -#include <arpa/inet.h> -#include <linux/if_packet.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/ether.h> -#include <unistd.h> -#include <signal.h> -#include <execinfo.h> -#include <pthread.h> -#include <time.h> - -#include "common_lib.h" - -#define BUF_LEN 4096+32 -#define RRH_eNB_PORT 50000 -#define RRH_eNB_DEST_IP "127.0.0.1" -#define RRH_UE_PORT 51000 -#define RRH_UE_DEST_IP "127.0.0.1" - -#define FRAME_MAX_SIZE 307200//76800 -#define DEFAULT_PERIOD_NS 133333//200000 - -#define START_CMD 1 -#define PRINTF_PERIOD 3750 - -typedef struct { - int eNB_port; - char eNB_dest_ip[20]; - int UE_port; - char UE_dest_ip[20]; - struct timespec time_req; -} rrh_desc_t; - -typedef struct { - int32_t nsamps; - int32_t antenna_index_eNB_rx; - int32_t antenna_index_eNB_tx; - int sockid_eNB; - struct sockaddr clientaddr; - socklen_t clientaddrlen; -} rrh_eNB_desc_t; - -typedef struct { - int32_t nsamps; - int32_t antenna_index_UE_rx; - int32_t antenna_index_UE_tx; - int sockid_UE; - struct sockaddr clientaddr; - socklen_t clientaddrlen; -} rrh_UE_desc_t; - -int rrh_exit=0; - -int32_t tx_buffer_eNB[4][(1+(sizeof(openair0_timestamp)>>2))+FRAME_MAX_SIZE],rx_buffer_eNB[4][(1+(sizeof(openair0_timestamp)>>2))+FRAME_MAX_SIZE]; -int32_t tx_buffer_UE[4][(1+(sizeof(openair0_timestamp)>>2))+FRAME_MAX_SIZE],rx_buffer_UE[4][(1+(sizeof(openair0_timestamp)>>2))+FRAME_MAX_SIZE]; -void *rrh_eNB_thread_status; -void *rrh_UE_thread_status; -int32_t counter_UE_rx[4]= {0,0,0,0}; -int32_t counter_UE_tx[4]= {0,0,0,0}; -int32_t counter_eNB_rx[4]= {0,0,0,0}; -int32_t counter_eNB_tx[4]= {0,0,0,0}; -int32_t overflow_rx_buffer_UE[4]= {0,0,0,0}; -int32_t overflow_rx_buffer_eNB[4]= {0,0,0,0}; -int32_t nsamps_eNB[4]= {0,0,0,0}; -int32_t nsamps_UE[4]= {0,0,0,0}; -int32_t UE_tx_started=0,eNB_tx_started=0, UE_rx_started=0,eNB_rx_started=0; -int32_t RT_FLAG=0, NRT_FLAG=1; -openair0_timestamp nrt_eNB_counter[4]= {0,0,0,0}; -openair0_timestamp nrt_UE_counter[4]= {0,0,0,0}; - -openair0_timestamp timestamp_eNB_tx[4],timestamp_eNB_rx[4]= {0,0,0,0}; -openair0_timestamp timestamp_UE_tx[4],timestamp_UE_rx[4]= {0,0,0,0}; -openair0_timestamp hw_counter=0; - -pthread_cond_t sync_UE_cond[4]; -pthread_mutex_t sync_UE_mutex[4]; -pthread_cond_t sync_eNB_cond[4]; -pthread_mutex_t sync_eNB_mutex[4]; -pthread_mutex_t timer_mutex; - -int sync_UE_rx[4]= {-1,-1,-1,-1}; -int sync_eNB_rx[4]= {-1,-1,-1,-1}; - -//functions prototype -void timer_signal_handler(int); -void *timer_proc(void *); -void *rrh_proc_eNB_thread(); -void *rrh_proc_UE_thread(); -void *rrh_UE_thread(void *); -void *rrh_UE_rx_thread(void *); -void *rrh_UE_tx_thread(void *); -void *rrh_eNB_thread(void *); -void *rrh_eNB_rx_thread(void *); -void *rrh_eNB_tx_thread(void *); - -void timer_signal_handler(int sig) -{ - - if (sig == SIGALRM) { - pthread_mutex_lock(&timer_mutex); - hw_counter ++; - //printf("[RRH] : hw_counter : %d\n",(int)hw_counter); - pthread_mutex_unlock(&timer_mutex); - } - - -} - - -void *timer_proc(void *arg) -{ - timer_t timerid; // timer ID for timer - //struct sigevent event; // event to deliver - struct itimerspec *timer = (struct itimerspec*)arg; // the timer data structure - struct itimerspec *old_value; - - - //printf("Starting the timer\n"); - if (timer_create (CLOCK_REALTIME, NULL, &timerid) == -1) { - fprintf (stderr, "couldn't create a timer\n"); - perror (NULL); - exit (EXIT_FAILURE); - } - - signal(SIGALRM, timer_signal_handler); - // and start it! - timer_settime (timerid, 0, timer, old_value); - - while (!rrh_exit) { - sleep(1); - } - - timer_delete(timerid); - return (0); - - -} - - -void *rrh_proc_eNB_thread() -{ - - //rrh_desc_t *rrh_desc = (rrh_desc_t *)arg; - int antenna_index,i; - openair0_timestamp truncated_timestamp, truncated_timestamp_final, last_hw_counter=0; - struct timespec time_req, time_rem; - int16_t *rxp,*txp; - - time_req.tv_sec = 0; - time_req.tv_nsec = 1000; - - while (rrh_exit==0) { - //wait until some data has been copied - for (antenna_index=0; antenna_index<4; antenna_index++) { - if (sync_eNB_rx[antenna_index]==0) { - if (!eNB_tx_started) { - eNB_tx_started=1; // set this flag to 1 to indicate that eNB started - - if (RT_FLAG==1) { - last_hw_counter=hw_counter; - } - } else { - if (RT_FLAG==1) { - if (hw_counter > last_hw_counter+1) { - printf("L"); - // goto end_copy_eNB; - } else { - //printf("hw_counter : %llu, last_hw_counter : %llu\n",hw_counter,last_hw_counter); - while (hw_counter < last_hw_counter+1) - nanosleep(&time_req,&time_rem); - } - } - } - - truncated_timestamp = timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE); - truncated_timestamp_final = (timestamp_eNB_tx[antenna_index]+nsamps_eNB[antenna_index])%FRAME_MAX_SIZE; - - if ((truncated_timestamp + nsamps_eNB[antenna_index]) > FRAME_MAX_SIZE) { - if ((timestamp_UE_rx[antenna_index]%FRAME_MAX_SIZE < nsamps_eNB[antenna_index]) && (UE_rx_started==1)) { - overflow_rx_buffer_UE[antenna_index]++; - printf("UE Overflow[%d] : %d, timestamp : %d\n",antenna_index,overflow_rx_buffer_UE[antenna_index],(int)truncated_timestamp); - - if (NRT_FLAG==1) { - while ((timestamp_UE_rx[antenna_index]%FRAME_MAX_SIZE) < nsamps_eNB[antenna_index]) - nanosleep(&time_req,&time_rem); - } - } - - rxp = (int16_t*)&rx_buffer_UE[antenna_index][truncated_timestamp+(sizeof(openair0_timestamp)>>2)]; - txp = (int16_t*)&tx_buffer_eNB[antenna_index][truncated_timestamp+(sizeof(openair0_timestamp)>>2)]; - - for (i=0; i<(FRAME_MAX_SIZE<<1)-(truncated_timestamp<<1); i++) { - rxp[i] = txp[i]>>6; - } - - rxp = (int16_t*)&rx_buffer_UE[antenna_index][(sizeof(openair0_timestamp)>>2)]; - txp = (int16_t*)&tx_buffer_eNB[antenna_index][0]; - - for (i=0; i<nsamps_eNB[antenna_index]-(FRAME_MAX_SIZE)+(truncated_timestamp); i++) { - rxp[i] = txp[i]>>6; - } - - /* memcpy(&rx_buffer_UE[antenna_index][truncated_timestamp + (sizeof(openair0_timestamp)>>2)],&tx_buffer_eNB[antenna_index][truncated_timestamp],(FRAME_MAX_SIZE<<2)-(truncated_timestamp<<2)); - memcpy(&rx_buffer_UE[antenna_index][(sizeof(openair0_timestamp)>>2)],&tx_buffer_eNB[antenna_index][0],(nsamps_eNB[antenna_index]<<2)-(FRAME_MAX_SIZE<<2)+(truncated_timestamp<<2));*/ - } else { - if (((truncated_timestamp < (timestamp_UE_rx[antenna_index]%FRAME_MAX_SIZE)) && (truncated_timestamp_final > (timestamp_UE_rx[antenna_index]%FRAME_MAX_SIZE))) && (UE_rx_started==1)) { - overflow_rx_buffer_UE[antenna_index]++; - printf("UE Overflow[%d] : %d, timestamp : %d\n",antenna_index,overflow_rx_buffer_UE[antenna_index],(int)truncated_timestamp); - - if (NRT_FLAG==1) { - while (truncated_timestamp_final > timestamp_UE_rx[antenna_index]%FRAME_MAX_SIZE) - nanosleep(&time_req,&time_rem); - } - } - - rxp = (int16_t*)&rx_buffer_UE[antenna_index][truncated_timestamp+(sizeof(openair0_timestamp))]; - txp = (int16_t*)&tx_buffer_eNB[antenna_index][truncated_timestamp]; - - for (i=0; i<(nsamps_eNB[antenna_index]); i++) { - rxp[i] =txp[i]>>6; - } - - /* - memcpy(&rx_buffer_UE[antenna_index][truncated_timestamp + (sizeof(openair0_timestamp)>>2)],&tx_buffer_eNB[antenna_index][truncated_timestamp],(nsamps_eNB[antenna_index]<<2));*/ - } - - - // end_copy_eNB : - last_hw_counter=hw_counter; - pthread_mutex_lock(&sync_eNB_mutex[antenna_index]); - sync_eNB_rx[antenna_index]--; - pthread_mutex_unlock(&sync_eNB_mutex[antenna_index]); - - } - } - - } - - return(0); -} - -void *rrh_proc_UE_thread() -{ - - //rrh_desc_t *rrh_desc = (rrh_desc_t *)arg; - int antenna_index,i; - openair0_timestamp truncated_timestamp, truncated_timestamp_final, last_hw_counter=0; - struct timespec time_req, time_rem; - int16_t *txp,*rxp; - - time_req.tv_sec = 0; - time_req.tv_nsec = 1000; - - - while (rrh_exit==0) { - //wait until some data has been copied - for (antenna_index=0; antenna_index<4; antenna_index++) { - if (sync_UE_rx[antenna_index]==0) { - if (!UE_tx_started) { - UE_tx_started=1; //Set this flag to 1 to indicate that a UE started retrieving data - - if (RT_FLAG==1) { - last_hw_counter=hw_counter; - } - } else { - if (RT_FLAG==1) { - if (hw_counter > last_hw_counter+1) { - printf("L1"); - // goto end_copy_UE; - } else { - while (hw_counter < last_hw_counter+1) - nanosleep(&time_req,&time_rem); - } - } - } - - truncated_timestamp = timestamp_UE_tx[antenna_index]%(FRAME_MAX_SIZE); - truncated_timestamp_final = (timestamp_UE_tx[antenna_index]+nsamps_UE[antenna_index])%FRAME_MAX_SIZE; - - if ((truncated_timestamp + nsamps_UE[antenna_index]) > FRAME_MAX_SIZE) { - if ((timestamp_eNB_rx[antenna_index]%FRAME_MAX_SIZE < nsamps_UE[antenna_index]) && (eNB_rx_started==1)) { - overflow_rx_buffer_eNB[antenna_index]++; - printf("eNB Overflow[%d] : %d, timestamp : %d\n",antenna_index,overflow_rx_buffer_eNB[antenna_index],(int)truncated_timestamp); - - if (NRT_FLAG==1) { - while ((timestamp_eNB_rx[antenna_index]%FRAME_MAX_SIZE) < nsamps_UE[antenna_index]) - nanosleep(&time_req,&time_rem); - } - } - - rxp = (int16_t*)&rx_buffer_eNB[antenna_index][truncated_timestamp+(sizeof(openair0_timestamp)>>2)]; - txp = (int16_t*)&tx_buffer_UE[antenna_index][truncated_timestamp+(sizeof(openair0_timestamp)>>2)]; - - for (i=0; i<(FRAME_MAX_SIZE<<1)-(truncated_timestamp<<1); i++) { - rxp[i] = txp[i]>>6; - } - - rxp = (int16_t*)&rx_buffer_eNB[antenna_index][(sizeof(openair0_timestamp)>>2)]; - txp = (int16_t*)&tx_buffer_UE[antenna_index][0]; - - for (i=0; i<nsamps_eNB[antenna_index]-(FRAME_MAX_SIZE)+(truncated_timestamp); i++) { - rxp[i] = txp[i]>>6; - } - - /* - memcpy(&rx_buffer_eNB[antenna_index][truncated_timestamp + (sizeof(openair0_timestamp)>>2)],&tx_buffer_UE[antenna_index][truncated_timestamp],(FRAME_MAX_SIZE<<2)-(truncated_timestamp<<2)); - memcpy(&rx_buffer_eNB[antenna_index][(sizeof(openair0_timestamp)>>2)],&tx_buffer_UE[antenna_index][0],(nsamps_UE[antenna_index]<<2)-(FRAME_MAX_SIZE<<2)+(truncated_timestamp<<2));*/ - - } else { - if (((truncated_timestamp < (timestamp_eNB_rx[antenna_index]%FRAME_MAX_SIZE)) && (truncated_timestamp_final > (timestamp_eNB_rx[antenna_index]%FRAME_MAX_SIZE))) && (eNB_rx_started==1)) { - overflow_rx_buffer_eNB[antenna_index]++; - printf("eNB Overflow[%d] : %d, timestamp : %d\n",antenna_index,overflow_rx_buffer_eNB[antenna_index],(int)truncated_timestamp); - - if (NRT_FLAG==1) { - while (truncated_timestamp_final > timestamp_eNB_rx[antenna_index]%FRAME_MAX_SIZE) - nanosleep(&time_req,&time_rem); - } - } - - rxp = (int16_t*)&rx_buffer_eNB[antenna_index][truncated_timestamp+(sizeof(openair0_timestamp))]; - txp = (int16_t*)&tx_buffer_UE[antenna_index][truncated_timestamp]; - - for (i=0; i<(nsamps_eNB[antenna_index]); i++) { - rxp[i] =txp[i]>>6; - } - - /* memcpy(&rx_buffer_eNB[antenna_index][truncated_timestamp+ (sizeof(openair0_timestamp)>>2)],&tx_buffer_UE[antenna_index][truncated_timestamp],(nsamps_UE[antenna_index]<<2));*/ - } - - //end_copy_UE : - last_hw_counter=hw_counter; - pthread_mutex_lock(&sync_UE_mutex[antenna_index]); - sync_UE_rx[antenna_index]--; - pthread_mutex_unlock(&sync_UE_mutex[antenna_index]); - - } - } - - } - - return(0); -} - - -void *rrh_UE_rx_thread(void *arg) -{ - - struct sockaddr clientaddr; - socklen_t clientaddrlen; - rrh_UE_desc_t *rrh_UE_rx_desc = (rrh_UE_desc_t *)arg; - struct timespec time0,time1,time2; - struct timespec time_req_1us, time_rem_1us; - ssize_t bytes_sent; - int antenna_index, nsamps; - int trace_cnt=0; - int sockid; - char str[INET_ADDRSTRLEN]; - unsigned long long max_rx_time=0, min_rx_time=133333, total_rx_time=0, average_rx_time=133333, s_period=0, trial=0; - - openair0_timestamp temp, last_hw_counter=0; - - antenna_index = rrh_UE_rx_desc->antenna_index_UE_rx; - nsamps = rrh_UE_rx_desc->nsamps; - sockid = rrh_UE_rx_desc->sockid_UE; - - - bzero((void*)&clientaddr,sizeof(struct sockaddr)); - clientaddrlen = sizeof(struct sockaddr); - //printf("Waiting for eNB ...\n"); - //printf("[RRH eNB RX thread] received parameters : nsamps : %d, antenna_index : %d\n",nsamps,antenna_index); - clientaddr = rrh_UE_rx_desc->clientaddr; - clientaddrlen = rrh_UE_rx_desc->clientaddrlen; - - inet_ntop(AF_INET, &(((struct sockaddr_in*)&clientaddr)->sin_addr), str, INET_ADDRSTRLEN); - printf("Received UE RX request for antenna %d, nsamps %d (from %s:%d)\n",antenna_index,nsamps,str, - ntohs(((struct sockaddr_in*)&clientaddr)->sin_port)); - - while (rrh_exit == 0) { - if (!UE_rx_started) { - UE_rx_started=1; //Set this flag to 1 to indicate that a UE started retrieving data - - if (RT_FLAG==1) { - last_hw_counter=hw_counter; - } - } else { - if (RT_FLAG==1) { - if (hw_counter > last_hw_counter+1) { - printf("L1"); - // goto end_copy_UE; - } else { - while (hw_counter < last_hw_counter+1) - nanosleep(&time_req_1us,&time_rem_1us); - } - } - } - - clock_gettime(CLOCK_MONOTONIC,&time1); - - // send return - temp=*(openair0_timestamp*)&rx_buffer_UE[antenna_index][timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE)]; - *(openair0_timestamp*)&rx_buffer_UE[antenna_index][timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE)]=timestamp_UE_rx[antenna_index]; - - if ((timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE)+nsamps) > FRAME_MAX_SIZE) { // Wrap around if nsamps exceeds the buffer limit - if (((timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE)) < ((timestamp_UE_rx[antenna_index]+nsamps)%(FRAME_MAX_SIZE))) && (eNB_tx_started==1)) { - printf("UE underflow wraparound timestamp_UE_rx : %d, timestamp_eNB_tx : %d\n",(int)(timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE)),(int)(timestamp_eNB_tx[antenna_index]%FRAME_MAX_SIZE)); - - if (NRT_FLAG==1) { - while ((timestamp_eNB_tx[antenna_index]%FRAME_MAX_SIZE) < ((timestamp_UE_rx[antenna_index]+nsamps)%(FRAME_MAX_SIZE))) - nanosleep(&time_req_1us,&time_rem_1us); - } - } - - if ((bytes_sent = sendto(sockid, - &rx_buffer_UE[antenna_index][timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE)], - ((FRAME_MAX_SIZE)<<2) - ((timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE))<<2) + sizeof(openair0_timestamp), - 0, - (struct sockaddr*)&clientaddr, - sizeof(struct sockaddr)))<0) - perror("RRH UE : sendto for RX"); - - if ((bytes_sent = sendto(sockid, - &rx_buffer_UE[antenna_index][0], - (nsamps<<2) - ((FRAME_MAX_SIZE)<<2) + ((timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE))<<2), - 0, - (struct sockaddr*)&clientaddr, - sizeof(struct sockaddr)))<0) - perror("RRH UE : sendto for RX"); - } else { - if (((timestamp_UE_rx[antenna_index]%FRAME_MAX_SIZE)< timestamp_eNB_tx[antenna_index]%FRAME_MAX_SIZE) - && (((timestamp_UE_rx[antenna_index]+nsamps)%FRAME_MAX_SIZE) > (timestamp_eNB_tx[antenna_index]%FRAME_MAX_SIZE)) && (eNB_tx_started==1) ) { - printf("UE underflow timestamp_UE_rx : %d, timestamp_eNB_tx : %d\n",(int)(timestamp_UE_rx[antenna_index]%FRAME_MAX_SIZE),(int)(timestamp_eNB_tx[antenna_index]%FRAME_MAX_SIZE)); - - if (NRT_FLAG==1) { - while (((timestamp_UE_rx[antenna_index]+nsamps)%FRAME_MAX_SIZE) > (timestamp_eNB_tx[antenna_index]%FRAME_MAX_SIZE)) { - nanosleep(&time_req_1us,&time_rem_1us); - } - } - } - - - if ((bytes_sent = sendto(sockid, - &rx_buffer_UE[antenna_index][timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE)], - (nsamps<<2)+sizeof(openair0_timestamp), - 0, - (struct sockaddr*)&clientaddr, - sizeof(struct sockaddr)))<0) - perror("RRH UE thread: sendto for RX"); - } - - //printf("bytes_sent %d(timestamp_UE_rx[%d] %d)\n",(int)bytes_sent,antenna_index,(int)timestamp_UE_rx[antenna_index]); - *(openair0_timestamp*)&rx_buffer_UE[antenna_index][timestamp_UE_rx[antenna_index]%(FRAME_MAX_SIZE)]=temp; - timestamp_UE_rx[antenna_index]+=nsamps; - last_hw_counter=hw_counter; - - clock_gettime(CLOCK_MONOTONIC,&time2); - - if (trace_cnt++ > 10) { - total_rx_time = (unsigned int)(time2.tv_nsec - time0.tv_nsec); - - if (total_rx_time < 0) total_rx_time=1000000000-total_rx_time; - - if ((total_rx_time > 0) && (total_rx_time < 1000000000)) { - trial++; - - if (total_rx_time < min_rx_time) - min_rx_time = total_rx_time; - - if (total_rx_time > max_rx_time) - max_rx_time = total_rx_time; - - average_rx_time = (long long unsigned int)((average_rx_time*trial)+total_rx_time)/(trial+1); - } - - if (s_period++ == PRINTF_PERIOD) { - s_period=0; - printf("Average UE RX time : %lu\tMax RX time : %lu\tMin RX time : %lu\n",average_rx_time,max_rx_time,min_rx_time); - - } - - //printf("RX: t1 %llu (time from last send), t2 %llu (sendto of %lu bytes) total time : %llu\n",(long long unsigned int)(time1.tv_nsec - time0.tv_nsec), (long long unsigned int)(time2.tv_nsec - time1.tv_nsec), - // (nsamps<<2)+sizeof(openair0_timestamp),(long long unsigned int)(time2.tv_nsec - time0.tv_nsec)); - - } - - memcpy(&time0,&time2,sizeof(struct timespec)); - - - } //while (rrh_exit==0) - - return(0); - -} - - -void *rrh_UE_tx_thread(void *arg) -{ - struct sockaddr clientaddr; - socklen_t clientaddrlen; - struct timespec time0a,time0,time1,time2; - rrh_UE_desc_t *rrh_UE_tx_desc = (rrh_UE_desc_t *)arg; - // struct timespec time_rem; - struct timespec time_req_1us, time_rem_1us; - ssize_t bytes_received; - int antenna_index, nsamps; - int8_t buf[BUF_LEN]; - int trace_cnt=0; - int sockid; - - bzero((void*)&clientaddr,sizeof(struct sockaddr)); - clientaddrlen = sizeof(struct sockaddr); - - antenna_index = rrh_UE_tx_desc->antenna_index_UE_tx; - nsamps = rrh_UE_tx_desc->nsamps; - sockid = rrh_UE_tx_desc->sockid_UE; - - while (rrh_exit == 0) { - - clock_gettime(CLOCK_MONOTONIC,&time0a); - - bytes_received = recvfrom(sockid,buf,BUF_LEN,0,&clientaddr,&clientaddrlen); - timestamp_eNB_tx[antenna_index] = *(openair0_timestamp*)(buf+4); - - clock_gettime(CLOCK_MONOTONIC,&time1); - - if (NRT_FLAG==1) { - nrt_UE_counter[antenna_index]++; - } - - //printf("Received UE TX request for antenna %d, nsamps %d, timestamp %d bytes_received %d\n",antenna_index,nsamps,(int)timestamp_UE_tx[antenna_index],(int)bytes_received); - if ((timestamp_UE_tx[antenna_index]%(FRAME_MAX_SIZE)+nsamps) > FRAME_MAX_SIZE) { // Wrap around if nsamps exceeds the buffer limit - memcpy(&tx_buffer_UE[antenna_index][timestamp_UE_tx[antenna_index]%(FRAME_MAX_SIZE)],buf+sizeof(openair0_timestamp)+2*sizeof(int16_t), - (FRAME_MAX_SIZE<<2)-((timestamp_UE_tx[antenna_index]%(FRAME_MAX_SIZE))<<2)); - memcpy(&tx_buffer_UE[antenna_index][0],buf+sizeof(openair0_timestamp)+2*sizeof(int16_t)+(FRAME_MAX_SIZE*4)-((timestamp_UE_tx[antenna_index]%(FRAME_MAX_SIZE))<<2), - (nsamps<<2)-((FRAME_MAX_SIZE-(timestamp_UE_tx[antenna_index]%(FRAME_MAX_SIZE)))<<2)); - //printf("Received UE TX samples for antenna %d, nsamps %d (%d)\n",antenna_index,nsamps,(int)(bytes_received>>2)); - } else { - memcpy(&tx_buffer_UE[antenna_index][timestamp_UE_tx[antenna_index]%(FRAME_MAX_SIZE)],buf+sizeof(openair0_timestamp)+2*sizeof(int16_t),(nsamps<<2)); - } - - //printf("Received UE TX samples for antenna %d, nsamps %d (%d)\n",antenna_index,nsamps,(int)(bytes_received>>2)); - - while (sync_UE_rx[antenna_index]==0) - nanosleep(&time_req_1us,&time_rem_1us); - - pthread_mutex_lock(&sync_UE_mutex[antenna_index]); - sync_UE_rx[antenna_index]++; - - if (!sync_UE_rx[antenna_index]) { - counter_UE_tx[antenna_index]=(counter_UE_tx[antenna_index]+nsamps)%FRAME_MAX_SIZE; - nsamps_UE[antenna_index]=nsamps; - } else { - printf("rrh_eNB_proc thread is busy, will exit\n"); - exit(-1); - } - - pthread_mutex_unlock(&sync_UE_mutex[antenna_index]); - - clock_gettime(CLOCK_MONOTONIC,&time2); - - memcpy(&time0,&time2,sizeof(struct timespec)); - - } - - return(0); - -} - - - -void *rrh_UE_thread(void *arg) -{ - - int sockid=-1; - struct sockaddr_in serveraddr; - struct sockaddr clientaddr; - socklen_t clientaddrlen; - rrh_desc_t *rrh_desc = (rrh_desc_t *)arg; - char str[INET_ADDRSTRLEN]; - //int8_t msg_header[4+sizeof(openair0_timestamp)]; - int8_t buf[BUF_LEN]; - int16_t cmd; //,nsamps,antenna_index; - ssize_t bytes_received; - // struct timespec time_rem; - // ssize_t bytes_sent; - // openair0_timestamp temp; - // openair0_timestamp last_hw_counter=0; - struct timespec time_req_1us, time_rem_1us; - - rrh_UE_desc_t rrh_UE_desc; - pthread_t UE_rx_thread, UE_tx_thread; - pthread_attr_t attr_UE_rx, attr_UE_tx; - struct sched_param sched_param_UE_rx, sched_param_UE_tx; - int error_code_UE_rx, error_code_UE_tx; - - time_req_1us.tv_sec = 0; - time_req_1us.tv_nsec = 1000; - - while (rrh_exit==0) { - - - sockid=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); - - if (sockid==-1) { - perror("Cannot create UE socket: "); - rrh_exit=1; - } - - - bzero((char *)&serveraddr,sizeof(serveraddr)); - serveraddr.sin_family=AF_INET; - serveraddr.sin_port=htons(rrh_desc->UE_port); - inet_pton(AF_INET,rrh_desc->UE_dest_ip,&serveraddr.sin_addr.s_addr); - - inet_ntop(AF_INET, &(serveraddr.sin_addr), str, INET_ADDRSTRLEN); - printf("Binding to UE socket for %s:%d\n",str,ntohs(serveraddr.sin_port)); - - if (bind(sockid,(struct sockaddr *)&serveraddr,sizeof(serveraddr))<0) { - perror("Cannot bind to UE socket: "); - rrh_exit = 1; - } - - // now wait for commands from eNB - - // get header info - bzero((void*)&clientaddr,sizeof(struct sockaddr)); - clientaddrlen = sizeof(struct sockaddr); - //printf("Waiting for UE ...\n"); - - bytes_received = recvfrom(sockid,buf,BUF_LEN,0,&clientaddr,&clientaddrlen); - cmd = buf[0]; - - rrh_UE_desc.antenna_index_UE_rx = cmd>>1; - rrh_UE_desc.antenna_index_UE_tx = cmd>>1; - //rrh_eNB_desc.timestamp_eNB_tx[rrh_eNB_desc.antenna_index_eNB_tx] = *(openair0_timestamp*)(buf+4); //we don't need timestamp when receiving the first command - rrh_UE_desc.nsamps = *(int16_t *)(buf+2); - rrh_UE_desc.sockid_UE = sockid; - rrh_UE_desc.clientaddr = clientaddr; - rrh_UE_desc.clientaddrlen = clientaddrlen; - - cmd = cmd&1; - inet_ntop(AF_INET, &(((struct sockaddr_in*)&clientaddr)->sin_addr), str, INET_ADDRSTRLEN); - - if (cmd==START_CMD) { - - pthread_attr_init(&attr_UE_rx); - pthread_attr_init(&attr_UE_tx); - sched_param_UE_rx.sched_priority = sched_get_priority_max(SCHED_FIFO); - sched_param_UE_tx.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_attr_setschedparam(&attr_UE_rx,&sched_param_UE_rx); - pthread_attr_setschedparam(&attr_UE_tx,&sched_param_UE_tx); - pthread_attr_setschedpolicy(&attr_UE_rx,SCHED_FIFO); - pthread_attr_setschedpolicy(&attr_UE_tx,SCHED_FIFO); - - error_code_UE_rx = pthread_create(&UE_rx_thread, &attr_UE_rx, rrh_UE_rx_thread, (void *)&rrh_UE_desc); - error_code_UE_tx = pthread_create(&UE_tx_thread, &attr_UE_tx, rrh_UE_tx_thread, (void *)&rrh_UE_desc); - - if (error_code_UE_rx) { - printf("Error while creating UE RX thread\n"); - exit(-1); - } - - if (error_code_UE_tx) { - printf("Error while creating UE TX thread\n"); - exit(-1); - } - - while (rrh_exit==0) - sleep(1); - } - } - - close(sockid); - - rrh_UE_thread_status = 0; - pthread_exit(&rrh_UE_thread_status); - - return(0); -} - - - -void *rrh_eNB_rx_thread(void *arg) -{ - - struct sockaddr clientaddr; - socklen_t clientaddrlen; - rrh_eNB_desc_t *rrh_eNB_rx_desc = (rrh_eNB_desc_t *)arg; - struct timespec time0,time1,time2; - struct timespec time_req_1us, time_rem_1us; - ssize_t bytes_sent; - int antenna_index, nsamps; - int trace_cnt=0; - int sockid; - char str[INET_ADDRSTRLEN]; - unsigned long long max_rx_time=0, min_rx_time=133333, total_rx_time=0, average_rx_time=133333, s_period=0, trial=0; - - openair0_timestamp temp, last_hw_counter=0; - - antenna_index = rrh_eNB_rx_desc->antenna_index_eNB_rx; - nsamps = rrh_eNB_rx_desc->nsamps; - sockid = rrh_eNB_rx_desc->sockid_eNB; - - - bzero((void*)&clientaddr,sizeof(struct sockaddr)); - clientaddrlen = sizeof(struct sockaddr); - //printf("Waiting for eNB ...\n"); - //printf("[RRH eNB RX thread] received parameters : nsamps : %d, antenna_index : %d\n",nsamps,antenna_index); - clientaddr = rrh_eNB_rx_desc->clientaddr; - clientaddrlen = rrh_eNB_rx_desc->clientaddrlen; - - inet_ntop(AF_INET, &(((struct sockaddr_in*)&clientaddr)->sin_addr), str, INET_ADDRSTRLEN); - printf("Received eNB RX request for antenna %d, nsamps %d (from %s:%d)\n",antenna_index,nsamps,str, - ntohs(((struct sockaddr_in*)&clientaddr)->sin_port)); - - while (rrh_exit == 0) { - //printf("Received eNB RX request for antenna %d, nsamps %d (from %s:%d)\n",antenna_index,nsamps,str, - // ntohs(((struct sockaddr_in*)&clientaddr)->sin_port)); - - if (!eNB_rx_started) { - eNB_rx_started=1; // set this flag to 1 to indicate that eNB started - - if (RT_FLAG==1) { - last_hw_counter=hw_counter; - } - } else { - if (RT_FLAG==1) { - if (hw_counter > last_hw_counter+1) { - printf("L"); - // goto end_copy_eNB; - } else { - while (hw_counter < last_hw_counter+1) - nanosleep(&time_req_1us,&time_rem_1us); - } - } - } - - clock_gettime(CLOCK_MONOTONIC,&time1); - - // send return - temp=*(openair0_timestamp*)&rx_buffer_eNB[antenna_index][timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE)]; - *(openair0_timestamp*)&rx_buffer_eNB[antenna_index][timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE)]=timestamp_eNB_rx[antenna_index]; - - if ((timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE)+nsamps) > FRAME_MAX_SIZE) { // Wrap around if nsamps exceeds the buffer limit - if ((timestamp_UE_tx[antenna_index]%FRAME_MAX_SIZE < ((timestamp_eNB_rx[antenna_index]+nsamps)%FRAME_MAX_SIZE)) && (UE_tx_started==1)) { - printf("eNB underflow\n"); - - if (NRT_FLAG==1) { - while ((timestamp_UE_tx[antenna_index]%FRAME_MAX_SIZE) < nsamps) - nanosleep(&time_req_1us,&time_rem_1us); - } - } - - - if ((bytes_sent = sendto(sockid, - &rx_buffer_eNB[antenna_index][timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE)], - ((FRAME_MAX_SIZE)<<2) - ((timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE))<<2) + sizeof(openair0_timestamp), - 0, - (struct sockaddr*)&clientaddr, - sizeof(struct sockaddr)))<0) - perror("RRH eNB : sendto for RX"); - - if ((bytes_sent = sendto(sockid, - &rx_buffer_eNB[antenna_index][0], - (nsamps<<2) - ((FRAME_MAX_SIZE)<<2) + ((timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE))<<2), - 0, - (struct sockaddr*)&clientaddr, - sizeof(struct sockaddr)))<0) - perror("RRH eNB : sendto for RX"); - } else { - if (((timestamp_eNB_rx[antenna_index]%FRAME_MAX_SIZE)< timestamp_UE_tx[antenna_index]%FRAME_MAX_SIZE) - && (((timestamp_eNB_rx[antenna_index]+nsamps)%FRAME_MAX_SIZE) > (timestamp_UE_tx[antenna_index]%FRAME_MAX_SIZE)) && (UE_tx_started==1)) { - printf("eNB underflow\n"); - - if (NRT_FLAG==1) { - while (((timestamp_eNB_rx[antenna_index]+nsamps)%FRAME_MAX_SIZE) > (timestamp_UE_tx[antenna_index]%FRAME_MAX_SIZE)) - nanosleep(&time_req_1us,&time_rem_1us); - } - } - - if ((bytes_sent = sendto(sockid, - &rx_buffer_eNB[antenna_index][timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE)], - (nsamps<<2)+sizeof(openair0_timestamp), - 0, - (struct sockaddr*)&clientaddr, - sizeof(struct sockaddr)))<0) - perror("RRH eNB : sendto for RX"); - - } - - //printf("bytes_sent %d(timestamp_eNB_rx[%d] %d)\n",(int)bytes_sent,antenna_index,(int)timestamp_eNB_rx[antenna_index]); - - - *(openair0_timestamp*)&rx_buffer_eNB[antenna_index][timestamp_eNB_rx[antenna_index]%(FRAME_MAX_SIZE)]=temp; - timestamp_eNB_rx[antenna_index]+=nsamps; - last_hw_counter=hw_counter; - - clock_gettime(CLOCK_MONOTONIC,&time2); - - if (trace_cnt++ > 10) { - total_rx_time = (unsigned int)(time2.tv_nsec - time0.tv_nsec); - - if (total_rx_time < 0) total_rx_time=1000000000-total_rx_time; - - if ((total_rx_time > 0) && (total_rx_time < 1000000000)) { - trial++; - - if (total_rx_time < min_rx_time) - min_rx_time = total_rx_time; - - if (total_rx_time > max_rx_time) - max_rx_time = total_rx_time; - - average_rx_time = (long long unsigned int)((average_rx_time*trial)+total_rx_time)/(trial+1); - } - - if (s_period++ == PRINTF_PERIOD) { - s_period=0; - printf("Average eNB RX time : %lu\tMax RX time : %lu\tMin RX time : %lu\n",average_rx_time,max_rx_time,min_rx_time); - - } - - //printf("RX: t1 %llu (time from last send), t2 %llu (sendto of %lu bytes) total time : %llu\n",(long long unsigned int)(time1.tv_nsec - time0.tv_nsec), (long long unsigned int)(time2.tv_nsec - time1.tv_nsec), - // (nsamps<<2)+sizeof(openair0_timestamp),(long long unsigned int)(time2.tv_nsec - time0.tv_nsec)); - - } - - memcpy(&time0,&time2,sizeof(struct timespec)); - - - } //while (rrh_exit==0) - - return(0); - -} - - -void *rrh_eNB_tx_thread(void *arg) -{ - - struct sockaddr clientaddr; - socklen_t clientaddrlen; - struct timespec time0a,time0,time1,time2; - rrh_eNB_desc_t *rrh_eNB_tx_desc = (rrh_eNB_desc_t *)arg; - // struct timespec time_rem; - struct timespec time_req_1us, time_rem_1us; - ssize_t bytes_received; - int antenna_index, nsamps; - int8_t buf[BUF_LEN]; - int trace_cnt=0; - int sockid; - - bzero((void*)&clientaddr,sizeof(struct sockaddr)); - clientaddrlen = sizeof(struct sockaddr); - //printf("Waiting for eNB ...\n"); - - antenna_index = rrh_eNB_tx_desc->antenna_index_eNB_tx; - nsamps = rrh_eNB_tx_desc->nsamps; - sockid = rrh_eNB_tx_desc->sockid_eNB; - - while (rrh_exit == 0) { - - clock_gettime(CLOCK_MONOTONIC,&time0a); - - bytes_received = recvfrom(sockid,buf,BUF_LEN,0,&clientaddr,&clientaddrlen); - timestamp_eNB_tx[antenna_index] = *(openair0_timestamp*)(buf+4); - - clock_gettime(CLOCK_MONOTONIC,&time1); - - if (NRT_FLAG==1) { - nrt_eNB_counter[antenna_index]++; - } - - //printf("Received eNB TX request for antenna %d, nsamps %d, timestamp %d bytes_received %d\n",antenna_index,nsamps,(int)timestamp_eNB_tx[antenna_index],(int)bytes_received); - - if ((timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE)+nsamps) > FRAME_MAX_SIZE) { // Wrap around if nsamps exceeds the buffer limit - memcpy(&tx_buffer_eNB[antenna_index][timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE)],buf+sizeof(openair0_timestamp)+2*sizeof(int16_t), - ((FRAME_MAX_SIZE)<<2)-((timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE))<<2)); - //printf("Done first part size : %d\n",(int32_t)(((FRAME_MAX_SIZE)<<2)-((timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE))<<2))); - memcpy(&tx_buffer_eNB[antenna_index][0],buf+sizeof(openair0_timestamp)+2*sizeof(int16_t) + ((FRAME_MAX_SIZE)<<2) -((timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE))<<2), - (nsamps<<2)-((FRAME_MAX_SIZE)<<2)+((timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE))<<2)); - //printf("Received eNB TX samples for antenna %d, nsamps %d (%d)\n",antenna_index,nsamps,(int)(bytes_received>>2)); - } else { - memcpy(&tx_buffer_eNB[antenna_index][timestamp_eNB_tx[antenna_index]%(FRAME_MAX_SIZE)],buf+sizeof(openair0_timestamp)+2*sizeof(int16_t),nsamps<<2); - } - - while (sync_eNB_rx[antenna_index]==0) - nanosleep(&time_req_1us,&time_rem_1us); - - //printf("launching eNB proc\n"); - pthread_mutex_lock(&sync_eNB_mutex[antenna_index]); - sync_eNB_rx[antenna_index]++; - - if (!sync_eNB_rx[antenna_index]) { - counter_eNB_tx[antenna_index]=(counter_eNB_tx[antenna_index]+nsamps)%FRAME_MAX_SIZE; - nsamps_eNB[antenna_index]=nsamps; - } else { - printf("rrh_eNB_proc thread is busy, will exit\n"); - exit(-1); - } - - pthread_mutex_unlock(&sync_eNB_mutex[antenna_index]); - - clock_gettime(CLOCK_MONOTONIC,&time2); - - //if (trace_cnt++ < 10) - // printf("TX: t0 %llu (time from previous run) t1 %llu (time of memcpy TX samples), t2 %llu (total time)\n",(long long unsigned int)(time1.tv_nsec - time0.tv_nsec), - // (long long unsigned int)(time2.tv_nsec - time1.tv_nsec), - // (long long unsigned int)(time2.tv_nsec - time0.tv_nsec)); - - memcpy(&time0,&time2,sizeof(struct timespec)); - - - - } - - return(0); - -} - -void *rrh_eNB_thread(void *arg) -{ - - int sockid=-1; - struct sockaddr_in serveraddr; - struct sockaddr clientaddr; - socklen_t clientaddrlen; - rrh_desc_t *rrh_desc = (rrh_desc_t *)arg; - char str[INET_ADDRSTRLEN]; - //int8_t msg_header[4+sizeof(openair0_timestamp)]; - int8_t buf[BUF_LEN]; - int16_t cmd; //,nsamps,antenna_index; - ssize_t bytes_received; - //ssize_t bytes_sent; - //openair0_timestamp temp, last_hw_counter=0; - //struct timespec time_rem; - struct timespec time_req_1us, time_rem_1us; - //struct timespec time0a,time0,time1,time2; - //int trace_cnt=0; - rrh_eNB_desc_t rrh_eNB_desc; - pthread_t eNB_rx_thread, eNB_tx_thread; - pthread_attr_t attr_eNB_rx, attr_eNB_tx; - struct sched_param sched_param_eNB_rx, sched_param_eNB_tx; - int error_code_eNB_rx, error_code_eNB_tx; - - time_req_1us.tv_sec = 0; - time_req_1us.tv_nsec = 1000; - - - while (rrh_exit==0) { - - - sockid=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); - - if (sockid==-1) { - perror("Cannot create eNB socket: "); - rrh_exit=1; - } - - - bzero((char *)&serveraddr,sizeof(serveraddr)); - serveraddr.sin_family=AF_INET; - serveraddr.sin_port=htons(rrh_desc->eNB_port); - inet_pton(AF_INET,rrh_desc->eNB_dest_ip,&serveraddr.sin_addr.s_addr); - - inet_ntop(AF_INET, &(serveraddr.sin_addr), str, INET_ADDRSTRLEN); - printf("Binding to eNB socket for %s:%d\n",str,ntohs(serveraddr.sin_port)); - - if (bind(sockid,(struct sockaddr *)&serveraddr,sizeof(serveraddr))<0) { - perror("Cannot bind to eNB socket: "); - rrh_exit = 1; - } - - // now wait for commands from eNB - - // get header info - bzero((void*)&clientaddr,sizeof(struct sockaddr)); - clientaddrlen = sizeof(struct sockaddr); - //printf("Waiting for eNB ...\n"); - - - - bytes_received = recvfrom(sockid,buf,BUF_LEN,0,&clientaddr,&clientaddrlen); - cmd = buf[0]; - rrh_eNB_desc.antenna_index_eNB_rx = cmd>>1; - rrh_eNB_desc.antenna_index_eNB_tx = cmd>>1; - //rrh_eNB_desc.timestamp_eNB_tx[rrh_eNB_desc.antenna_index_eNB_tx] = *(openair0_timestamp*)(buf+4); //we don't need timestamp when receiving the first command - rrh_eNB_desc.nsamps = *(int16_t *)(buf+2); - rrh_eNB_desc.sockid_eNB = sockid; - rrh_eNB_desc.clientaddr = clientaddr; - rrh_eNB_desc.clientaddrlen = clientaddrlen; - - //cmd = cmd&1; - cmd = cmd|1;//in order to make cmd evalution dummy (the first message from lte to rrh has changed, see: @ethernet_lib.c trx_start_func has been substituted by trx_request_func ) - inet_ntop(AF_INET, &(((struct sockaddr_in*)&clientaddr)->sin_addr), str, INET_ADDRSTRLEN); - - if (cmd==START_CMD) { - - pthread_attr_init(&attr_eNB_rx); - pthread_attr_init(&attr_eNB_tx); - sched_param_eNB_rx.sched_priority = sched_get_priority_max(SCHED_FIFO); - sched_param_eNB_tx.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_attr_setschedparam(&attr_eNB_rx,&sched_param_eNB_rx); - pthread_attr_setschedparam(&attr_eNB_tx,&sched_param_eNB_tx); - pthread_attr_setschedpolicy(&attr_eNB_rx,SCHED_FIFO); - pthread_attr_setschedpolicy(&attr_eNB_tx,SCHED_FIFO); - - error_code_eNB_rx = pthread_create(&eNB_rx_thread, &attr_eNB_rx, rrh_eNB_rx_thread, (void *)&rrh_eNB_desc); - error_code_eNB_tx = pthread_create(&eNB_tx_thread, &attr_eNB_tx, rrh_eNB_tx_thread, (void *)&rrh_eNB_desc); - - if (error_code_eNB_rx) { - printf("Error while creating eNB RX thread\n"); - exit(-1); - } - - if (error_code_eNB_tx) { - printf("Error while creating eNB TX thread\n"); - exit(-1); - } - - while (rrh_exit==0) - sleep(1); - - } - - - } //while (rrh_exit==0) - - close(sockid); - - rrh_eNB_thread_status = 0; - pthread_exit(&rrh_eNB_thread_status); - - return(0); -} - - -void signal_handler(int sig) -{ - void *array[10]; - size_t size; - - if (sig==SIGSEGV) { - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(-1); - } else { - printf("trying to exit gracefully...\n"); - rrh_exit = 1; - } -} - -int main(int argc, char **argv) -{ - - pthread_t main_rrh_eNB_thread, main_rrh_UE_thread, main_rrh_proc_eNB_thread, main_rrh_proc_UE_thread, main_timer_proc_thread; - pthread_attr_t attr, attr_proc, attr_timer; - struct sched_param sched_param_rrh, sched_param_rrh_proc, sched_param_timer; - int error_code_eNB, error_code_UE, error_code_proc_eNB, error_code_proc_UE, error_code_timer; - int i; - int opt; - int nsecs=0, rt_period=0; - rrh_desc_t rrh; - struct itimerspec timer; - - - rrh.time_req.tv_sec = 0; - rrh.time_req.tv_nsec = 0; - - rrh.eNB_port = RRH_eNB_PORT; - strcpy(rrh.eNB_dest_ip,RRH_eNB_DEST_IP); - rrh.UE_port = RRH_UE_PORT; - strcpy(rrh.UE_dest_ip ,RRH_UE_DEST_IP); - - nsecs = 0; - - while ((opt = getopt(argc, argv, "t:rE:U:")) != -1) { - switch (opt) { - case 't': - rt_period = atoi(optarg); - RT_FLAG=1; - NRT_FLAG=0; - break; - - case 'r': - rt_period = DEFAULT_PERIOD_NS; - RT_FLAG=1; - NRT_FLAG=0; - break; - - case 'E': - strcpy(rrh.eNB_dest_ip,optarg); - break; - - case 'U': - strcpy(rrh.UE_dest_ip,optarg); - break; - - default: /* '?' */ - fprintf(stderr, "Usage: %s [-d nsecs]\n", argv[0]); - exit(-1); - } - } - - // if (optind >= argc) { - // fprintf(stderr, "Expected argument after options\n"); - // exit(EXIT_FAILURE); - // } - - // setup the timer (1s delay, 1s reload) - timer.it_value.tv_sec = rt_period/1000000000; - timer.it_value.tv_nsec = rt_period%1000000000; - timer.it_interval.tv_sec = rt_period/1000000000; - timer.it_interval.tv_nsec = rt_period%1000000000; - - - // to make a graceful exit when ctrl-c is pressed - signal(SIGSEGV, signal_handler); - signal(SIGINT, signal_handler); - - - pthread_attr_init(&attr); - sched_param_rrh.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_attr_init(&attr_proc); - sched_param_rrh_proc.sched_priority = sched_get_priority_max(SCHED_FIFO-1); - pthread_attr_init(&attr_timer); - sched_param_timer.sched_priority = sched_get_priority_max(SCHED_FIFO-2); - - pthread_attr_setschedparam(&attr,&sched_param_rrh); - pthread_attr_setschedpolicy(&attr,SCHED_FIFO); - pthread_attr_setschedparam(&attr_proc,&sched_param_rrh_proc); - pthread_attr_setschedpolicy(&attr_proc,SCHED_FIFO-1); - pthread_attr_setschedparam(&attr_timer,&sched_param_timer); - pthread_attr_setschedpolicy(&attr_timer,SCHED_FIFO-2); - - for (i=0; i<4; i++) { - pthread_mutex_init(&sync_eNB_mutex[i],NULL); - pthread_cond_init(&sync_eNB_cond[i],NULL); - pthread_mutex_init(&sync_UE_mutex[i],NULL); - pthread_cond_init(&sync_UE_cond[i],NULL); - } - - pthread_mutex_init(&timer_mutex,NULL); - - error_code_eNB = pthread_create(&main_rrh_eNB_thread, &attr, rrh_eNB_thread, (void *)&rrh); - error_code_UE = pthread_create(&main_rrh_UE_thread, &attr, rrh_UE_thread, (void *)&rrh); - error_code_proc_UE = pthread_create(&main_rrh_proc_UE_thread, &attr_proc, rrh_proc_UE_thread, NULL); - error_code_proc_eNB = pthread_create(&main_rrh_proc_eNB_thread, &attr_proc, rrh_proc_eNB_thread, NULL); - error_code_timer = pthread_create(&main_timer_proc_thread, &attr_timer, timer_proc, (void *)&timer); - - if (error_code_eNB) { - printf("Error while creating eNB thread\n"); - exit(-1); - } - - if (error_code_UE) { - printf("Error while creating UE thread\n"); - exit(-1); - } - - if (error_code_proc_UE) { - printf("Error while creating UE proc thread\n"); - exit(-1); - } - - if (error_code_proc_eNB) { - printf("Error while creating eNB proc thread\n"); - exit(-1); - } - - if (error_code_timer) { - printf("Error while creating timer proc thread\n"); - exit(-1); - } - - printf("TYPE <CTRL-C> TO TERMINATE\n"); - - while (rrh_exit==0) - sleep(1); - - - //pthread_join(main_rrh_eNB_thread,&rrh_eNB_thread_status); - return 0; -} diff --git a/targets/RT/USER/rrh.gtkw b/targets/RT/USER/rrh.gtkw deleted file mode 100644 index 891f23ada52417ffd360f617eab2eeecd2ef16cd..0000000000000000000000000000000000000000 --- a/targets/RT/USER/rrh.gtkw +++ /dev/null @@ -1,195 +0,0 @@ -[*] -[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Fri Jan 29 16:34:46 2016 -[*] -[dumpfile] "/tmp/openair_dump_rrh.vcd" -[dumpfile_mtime] "Fri Jan 29 16:20:55 2016" -[dumpfile_size] 224259458 -[savefile] "/home/guepe/openairinterface5g_rrh/openairinterface5g/targets/RT/USER/rrh.gtkw" -[timestart] 31315875900 -[size] 1004 1028 -[pos] 926 -1 -*-17.429794 31316090054 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -[sst_width] 224 -[signals_width] 261 -[sst_expanded] 1 -[sst_vpaned_height] 278 -@24 -[color] 1 -variables.hw_frame_rx[63:0] -[color] 1 -variables.hw_subframe_rx[63:0] -@28 -[color] 1 -functions.eNB_rx -functions.eNB_rx_sleep -[color] 3 -functions.trx_read_rf -[color] 7 -functions.trx_write -@c00024 -variables.rxcnt[63:0] -@28 -(0)variables.rxcnt[63:0] -(1)variables.rxcnt[63:0] -(2)variables.rxcnt[63:0] -(3)variables.rxcnt[63:0] -(4)variables.rxcnt[63:0] -(5)variables.rxcnt[63:0] -(6)variables.rxcnt[63:0] -(7)variables.rxcnt[63:0] -(8)variables.rxcnt[63:0] -(9)variables.rxcnt[63:0] -(10)variables.rxcnt[63:0] -(11)variables.rxcnt[63:0] -(12)variables.rxcnt[63:0] -(13)variables.rxcnt[63:0] -(14)variables.rxcnt[63:0] -(15)variables.rxcnt[63:0] -(16)variables.rxcnt[63:0] -(17)variables.rxcnt[63:0] -(18)variables.rxcnt[63:0] -(19)variables.rxcnt[63:0] -(20)variables.rxcnt[63:0] -(21)variables.rxcnt[63:0] -(22)variables.rxcnt[63:0] -(23)variables.rxcnt[63:0] -(24)variables.rxcnt[63:0] -(25)variables.rxcnt[63:0] -(26)variables.rxcnt[63:0] -(27)variables.rxcnt[63:0] -(28)variables.rxcnt[63:0] -(29)variables.rxcnt[63:0] -(30)variables.rxcnt[63:0] -(31)variables.rxcnt[63:0] -(32)variables.rxcnt[63:0] -(33)variables.rxcnt[63:0] -(34)variables.rxcnt[63:0] -(35)variables.rxcnt[63:0] -(36)variables.rxcnt[63:0] -(37)variables.rxcnt[63:0] -(38)variables.rxcnt[63:0] -(39)variables.rxcnt[63:0] -(40)variables.rxcnt[63:0] -(41)variables.rxcnt[63:0] -(42)variables.rxcnt[63:0] -(43)variables.rxcnt[63:0] -(44)variables.rxcnt[63:0] -(45)variables.rxcnt[63:0] -(46)variables.rxcnt[63:0] -(47)variables.rxcnt[63:0] -(48)variables.rxcnt[63:0] -(49)variables.rxcnt[63:0] -(50)variables.rxcnt[63:0] -(51)variables.rxcnt[63:0] -(52)variables.rxcnt[63:0] -(53)variables.rxcnt[63:0] -(54)variables.rxcnt[63:0] -(55)variables.rxcnt[63:0] -(56)variables.rxcnt[63:0] -(57)variables.rxcnt[63:0] -(58)variables.rxcnt[63:0] -(59)variables.rxcnt[63:0] -(60)variables.rxcnt[63:0] -(61)variables.rxcnt[63:0] -(62)variables.rxcnt[63:0] -(63)variables.rxcnt[63:0] -@1401200 --group_end -@24 -variables.pck_rx[63:0] -variables.rx_ts[63:0] -@c00024 -variables.tx_seq_num[63:0] -@28 -(0)variables.tx_seq_num[63:0] -(1)variables.tx_seq_num[63:0] -(2)variables.tx_seq_num[63:0] -(3)variables.tx_seq_num[63:0] -(4)variables.tx_seq_num[63:0] -(5)variables.tx_seq_num[63:0] -(6)variables.tx_seq_num[63:0] -(7)variables.tx_seq_num[63:0] -(8)variables.tx_seq_num[63:0] -(9)variables.tx_seq_num[63:0] -(10)variables.tx_seq_num[63:0] -(11)variables.tx_seq_num[63:0] -(12)variables.tx_seq_num[63:0] -(13)variables.tx_seq_num[63:0] -(14)variables.tx_seq_num[63:0] -(15)variables.tx_seq_num[63:0] -(16)variables.tx_seq_num[63:0] -(17)variables.tx_seq_num[63:0] -(18)variables.tx_seq_num[63:0] -(19)variables.tx_seq_num[63:0] -(20)variables.tx_seq_num[63:0] -(21)variables.tx_seq_num[63:0] -(22)variables.tx_seq_num[63:0] -(23)variables.tx_seq_num[63:0] -(24)variables.tx_seq_num[63:0] -(25)variables.tx_seq_num[63:0] -(26)variables.tx_seq_num[63:0] -(27)variables.tx_seq_num[63:0] -(28)variables.tx_seq_num[63:0] -(29)variables.tx_seq_num[63:0] -(30)variables.tx_seq_num[63:0] -(31)variables.tx_seq_num[63:0] -(32)variables.tx_seq_num[63:0] -(33)variables.tx_seq_num[63:0] -(34)variables.tx_seq_num[63:0] -(35)variables.tx_seq_num[63:0] -(36)variables.tx_seq_num[63:0] -(37)variables.tx_seq_num[63:0] -(38)variables.tx_seq_num[63:0] -(39)variables.tx_seq_num[63:0] -(40)variables.tx_seq_num[63:0] -(41)variables.tx_seq_num[63:0] -(42)variables.tx_seq_num[63:0] -(43)variables.tx_seq_num[63:0] -(44)variables.tx_seq_num[63:0] -(45)variables.tx_seq_num[63:0] -(46)variables.tx_seq_num[63:0] -(47)variables.tx_seq_num[63:0] -(48)variables.tx_seq_num[63:0] -(49)variables.tx_seq_num[63:0] -(50)variables.tx_seq_num[63:0] -(51)variables.tx_seq_num[63:0] -(52)variables.tx_seq_num[63:0] -(53)variables.tx_seq_num[63:0] -(54)variables.tx_seq_num[63:0] -(55)variables.tx_seq_num[63:0] -(56)variables.tx_seq_num[63:0] -(57)variables.tx_seq_num[63:0] -(58)variables.tx_seq_num[63:0] -(59)variables.tx_seq_num[63:0] -(60)variables.tx_seq_num[63:0] -(61)variables.tx_seq_num[63:0] -(62)variables.tx_seq_num[63:0] -(63)variables.tx_seq_num[63:0] -@1401200 --group_end -@24 -variables.hw_frame[63:0] -variables.hw_subframe[63:0] -@28 -[color] 1 -functions.eNB_tx -functions.eNB_tx_sleep -[color] 7 -functions.trx_read -[color] 3 -functions.trx_write_rf -@24 -variables.txcnt[63:0] -variables.pck_tx[63:0] -variables.tx_ts[63:0] -@25 -variables.rx_seq_num_prv[63:0] -@24 -variables.rx_seq_num[63:0] -variables.hw_cnt_rx[63:0] -variables.lhw_cnt_rx[63:0] -[color] 3 -variables.cnt[63:0] -[pattern_trace] 1 -[pattern_trace] 0 diff --git a/targets/RT/USER/rrh_gw.c b/targets/RT/USER/rrh_gw.c deleted file mode 100644 index 7aea0484be466aacab2783c4078e1552622970cc..0000000000000000000000000000000000000000 --- a/targets/RT/USER/rrh_gw.c +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - - -/*! \file rrh_gw.h - * \brief top-level for the remote radio head gateway (RRH_gw) module reusing the ethernet library - * \author Navid Nikaein, Katerina Trilyraki, Raymond Knopp - * \date 2015 - * \version 0.1 - * \company Eurecom - * \maintainer: navid.nikaein@eurecom.fr - * \note - * \warning very experimental - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <signal.h> -#include <execinfo.h> -#include <unistd.h> -#include <sys/socket.h> -#include <arpa/inet.h> -#include <net/if.h> -#include <time.h> - -#include "common_lib.h" -#include "rrh_gw.h" -#include "rt_wrapper.h" -#include "rrh_gw_externs.h" - - -#include "log_if.h" -#include "log_extern.h" -#include "vcd_signal_dumper.h" - -/***************************************************************************************** - * ---------- * - * ------- RRH_BBU_IF ------- RRH_RF_IF -------USRP - COTS_UE- * - * - BBU - --------------- - RRH - ------------- -------BLADERF ---------- * - * ------- ------- -------EXMIMO * - * --------- * - * -------ETH_IF - EMU_UE- * - * --------- * - *****************************************************************************************/ - - -/* local IP/MAC address is detected*/ -char rrh_ip[20] = "0.0.0.0"; -unsigned char rrh_mac[20] = "0:0:0:0:0:0"; -int rrh_port = 50000; // has to be an option - -/* log */ -int16_t glog_level = LOG_DEBUG; -int16_t glog_verbosity = LOG_MED; -int16_t rrh_log_level = LOG_INFO; -int16_t rrh_log_verbosity = LOG_MED; -int16_t enb_log_level = LOG_INFO; -int16_t enb_log_verbosity = LOG_MED; -int16_t ue_log_level = LOG_INFO; -int16_t ue_log_verbosity = LOG_MED; - - -/* flag definitions */ -uint8_t eNB_flag=0; -uint8_t UE_flag=0; -uint8_t EXMIMO_flag=0; -uint8_t USRP_flag=0; -uint8_t RT_flag=0, NRT_flag=1; -uint8_t rrh_exit=0; -uint8_t loopback_flag=0; -uint8_t measurements_flag=0; - -/* Default operation as RRH: - - there are neither eNB nor UE modules - - no RF hardware is specified (NONE_IF) - - default ethernet interface is local */ -uint8_t num_eNB_mod=0; -uint8_t num_UE_mod=0; -char* if_name="lo"; -uint8_t eth_mode=ETH_UDP_MODE; - -rrh_module_t *enb_array; -rrh_module_t *ue_array; - -openair0_vtimestamp hw_counter=0; - -char rf_config_file[1024]; - -static void debug_init(void); -static void get_options(int argc, char *argv[]); -static void print_help(void); - -/*!\fn static rrh_module_t new_module(unsigned int id); -* \brief creation of a eNB/UE module -* \param[in] module id -* \return module -* \note -* @ingroup _oai -*/ -static rrh_module_t new_module(unsigned int id); - -/*!\fn static int get_address(char* if_name, uint8_t flag); - * \brief retrieves IP address from the specified network interface - * \param[in] name of network interface - * \return 0 - * \note - * @ingroup _oai - */ -static int get_address(char* if_name, uint8_t flag); - - - - - -int main(int argc, char **argv) { - - unsigned int i; - rf_config_file[0]='\0'; - /* parse input arguments */ - get_options(argc, argv); - /* initialize logger and signal analyzer */ - debug_init(); - /* */ - set_latency_target(); - /* make a graceful exit when ctrl-c is pressed */ - signal(SIGSEGV, signal_handler); - signal(SIGINT, signal_handler); - - /* create modules based on input arguments */ - if (eNB_flag==1){ - enb_array=(rrh_module_t*)malloc(num_eNB_mod*sizeof(rrh_module_t)); - for(i=0;i<num_eNB_mod;i++){ - enb_array[i]=new_module(i);//enb_array[i]=new_module(i, get_RF_interfaces(&hardware_target)); - config_BBU_mod(&enb_array[i],RT_flag,NRT_flag); - LOG_I(RRH,"[eNB %d] module(s) created (out of %u) \n",i,num_eNB_mod); - } - } - if (UE_flag==1){ - ue_array=(rrh_module_t*)malloc(num_UE_mod*sizeof(rrh_module_t)); - for(i=0;i<num_UE_mod;i++){ - ue_array[i]=new_module(i); - config_UE_mod(&ue_array[i],RT_flag,NRT_flag); - LOG_I(RRH,"[UE %d] module(s) created (out of %u)\n",i, num_UE_mod); - } - } - - printf("TYPE <CTRL-C> TO TERMINATE\n"); - - while (rrh_exit==0) - sleep(1); - - return EXIT_SUCCESS; -} - - -static rrh_module_t new_module (unsigned int id) { - - rrh_module_t rrh_mod; - openair0_config_t openair0_cfg; - - rrh_mod.id=id; - rrh_mod.loopback=loopback_flag; - rrh_mod.measurements=measurements_flag; - - /* each module is associated with an ethernet device */ - rrh_mod.eth_dev.type=NONE_DEV; - rrh_mod.eth_dev.transp_type=NONE_TP; - /* ethernet device is functioning within RRH */ - rrh_mod.eth_dev.host_type=RRH_HOST; - /* */ - rrh_mod.eth_dev.openair0_cfg = (openair0_config_t*)malloc(sizeof(openair0_config_t)); - memset(rrh_mod.eth_dev.openair0_cfg,0,sizeof(openair0_config_t)); - /* get IP and MAC address */ - get_address(if_name,eth_mode); - - if(eth_mode==ETH_UDP_MODE) { - openair0_cfg.my_addr = &rrh_ip[0]; - openair0_cfg.my_port = rrh_port; - LOG_I(RRH,"UDP mode selected for ethernet.\n"); - } else if (eth_mode==ETH_RAW_MODE) { - openair0_cfg.my_addr = (char*)&rrh_mac[0]; - openair0_cfg.my_port = rrh_port; - LOG_I(RRH,"RAW mode selected for ethernet.\n"); - } - - /* */ - eth_params_t *eth_params = (eth_params_t*)malloc(sizeof(eth_params_t)); - memset(eth_params, 0, sizeof(eth_params_t)); - eth_params->local_if_name = if_name; - eth_params->transp_preference = eth_mode; - - /* ethernet device initialization */ - if (openair0_transport_load(&rrh_mod.eth_dev, &openair0_cfg,eth_params)<0) { - LOG_E(RRH,"Exiting, cannot initialize ethernet interface.\n"); - exit(-1); - } - - /* allocate space and specify associated RF device */ - openair0_device *oai_dv = (openair0_device *)malloc(sizeof(openair0_device)); - memset(oai_dv,0,sizeof(openair0_device)); - - rrh_mod.devs=oai_dv; - rrh_mod.devs->type=NONE_DEV; - rrh_mod.devs->transp_type=NONE_TP; - rrh_mod.devs->host_type=RRH_HOST; - - return rrh_mod; -} - -static void debug_init(void) { - - /* log initialization */ - logInit(); - set_glog(glog_level, glog_verbosity); - - set_comp_log(RRH, rrh_log_level, rrh_log_verbosity, 1); - //set_comp_log(ENB_LOG, enb_log_level, enb_log_verbosity, 1); - //set_comp_log(UE_LOG, ue_log_level, ue_log_verbosity, 1); - - /* vcd initialization */ - if (ouput_vcd) { - vcd_signal_dumper_init("/tmp/openair_dump_rrh.vcd"); - - } -} - - -static void get_options(int argc, char *argv[]) { - - int opt; - - while ((opt = getopt(argc, argv, "xvhlte:n:u:g:r:m:i:f:")) != -1) { - - switch (opt) { - case 'n': - eNB_flag=1; - num_eNB_mod=atoi(optarg); - break; - case 'u': - UE_flag=1; - num_UE_mod=atoi(optarg); - break; - case 'g': - glog_level=atoi(optarg); - break; - case 'i': - if (optarg) { - if_name=strdup(optarg); - printf("RRH interface name is set to %s\n", if_name); - } - break; - case 'm': - eth_mode=atoi(optarg); - break; - case 'r': - //rrh_log_level=atoi(optarg); - break; - case 'e': - //enb_log_level=atoi(optarg); - break; - case 'x': - rt_period = DEFAULT_PERIOD_NS; - RT_flag=1; - NRT_flag=0; - break; - case 'v': - /* extern from vcd */ - ouput_vcd=1; - break; - case 'l': - /*In loopback mode rrh sends back to bbu what it receives*/ - loopback_flag=1; - break; - case 'f': - if (optarg){ - if ((strcmp("null", optarg) == 0) || (strcmp("NULL", optarg) == 0)) { - printf("no configuration filename is provided\n"); - } - else if (strlen(optarg)<=1024){ - // rf_config_file = strdup(optarg); - strcpy(rf_config_file,optarg); - }else { - printf("Configuration filename is too long\n"); - exit(-1); - } - } - break; - case 't': - /* When measurements are enabled statistics related to TX/RX time are printed */ - measurements_flag=1; - break; - case 'h': - print_help(); - exit(-1); - default: /* '?' */ - //fprintf(stderr, "Usage: \n", argv[0]); - exit(-1); - } -} - -} - -static int get_address(char* if_name, uint8_t flag) { - - int fd; - struct ifreq ifr; - - fd = socket(AF_INET, SOCK_DGRAM, 0); - /* I want to get an IPv4 IP address */ - ifr.ifr_addr.sa_family = AF_INET; - /* I want IP address attached to "if_name" */ - strncpy(ifr.ifr_name, if_name, IFNAMSIZ-1); - - if (flag==ETH_UDP_MODE) { - if ( ioctl(fd, SIOCGIFADDR, &ifr)<0 ) { - perror("IOCTL:"); - exit(-1); - } - snprintf(&rrh_ip[0],20,"%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr)); - LOG_I(RRH,"%s: IP address: %s\n",if_name,rrh_ip); - } else if (flag==ETH_RAW_MODE) { - if ( ioctl(fd, SIOCGIFHWADDR, &ifr)<0 ) { - perror("IOCTL:"); - exit(-1); - } - ether_ntoa_r ((struct ether_addr *)ifr.ifr_hwaddr.sa_data, (char*)rrh_mac); - LOG_I(RRH,"%s: MAC address: %s\n",if_name,rrh_mac); - } - - close(fd); - return 0; -} - - -static void print_help(void) { - - puts("Usage: \n"); - puts(" sudo -E chrt 99 ./rrh -n1 -g6 -v -t -i lo -m1"); - puts("Options:\n"); - puts("\t -n create eNB module\n"); - puts("\t -u create UE module\n"); - puts("\t -g define global log level\n"); - puts("\t -i set the RRH interface (default lo)\n"); - puts("\t -m set ethernet mode to be used by RRH, valid options: (1:raw, 0:udp) \n"); - puts("\t -r define rrh log level\n"); - puts("\t -e define eNB log level\n"); - puts("\t -x enable real time bahaviour\n"); - puts("\t -v enable vcd dump\n"); - puts("\t -l enable loopback mode\n"); - puts("\t -t enable measurements\n"); - puts("\t -h display info\n"); - -} - - -void *timer_proc(void *arg) { - - timer_t timerid; - struct itimerspec *timer= (struct itimerspec *)arg ; // the timer data structure - struct itimerspec old_value; - - -#ifdef DEADLINE_SCHEDULER - struct sched_attr attr; - unsigned int flags = 0; - - attr.size = sizeof(attr); - attr.sched_flags = 0; - attr.sched_nice = 0; - attr.sched_priority = 0; - - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = (0.1 * 100) * 10000; // - attr.sched_deadline = rt_period-30000;//(0.1 * 100) * 10000; - attr.sched_period = rt_period;//(0.1 * 100) * 10000; // each TX/RX thread has, as a function of RT PERIOD ?? - - if (sched_setattr(0, &attr, flags) < 0 ) { - perror("[SCHED] timer thread: sched_setattr failed\n"); - exit(-1); - } -#endif - - if (timer_create (CLOCK_REALTIME, NULL, &timerid) == -1) { - fprintf (stderr, "couldn't create a timer\n"); - perror (NULL); - exit (EXIT_FAILURE); - } - - signal(SIGALRM, timer_signal_handler); - LOG_I(RRH,"Timer has started!\n"); - timer_settime (timerid, 0, timer, &old_value); - - while (!rrh_exit) { - sleep(1); - } - - timer_delete(timerid); - - return (0); -} - - -void timer_signal_handler(int sig) { - - if (sig == SIGALRM) { - pthread_mutex_lock(&timer_mutex); - hw_counter ++; - pthread_mutex_unlock(&timer_mutex); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_CNT, hw_counter);//USED ELSEWHERE - } -} - - -void signal_handler(int sig) { - - void *array[10]; - size_t size; - - if (sig==SIGSEGV) { - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(-1); - } else { - printf("trying to exit gracefully...\n"); - rrh_exit = 1; - } -} - -void exit_fun(const char* s) { - if (s != NULL) { - printf("%s %s() Exiting RRH: %s\n",__FILE__, __FUNCTION__, s); - } - rrh_exit = 1; - exit (-1); -} - - diff --git a/targets/RT/USER/rrh_gw.h b/targets/RT/USER/rrh_gw.h deleted file mode 100644 index 97ffa5a893fb25cbda241a57c4fa677b39032129..0000000000000000000000000000000000000000 --- a/targets/RT/USER/rrh_gw.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rrh_gw.h - * \brief header file for remote radio head gateway (RRH_gw) module - * \author Navid Nikaein, Katerina Trilyraki, Raymond Knopp - * \date 2015 - * \version 0.1 - * \company Eurecom - * \maintainer: navid.nikaein@eurecom.fr - * \note - * \warning very experimental - */ - -#ifndef RRH_GW_H_ -#define RRH_GW_H_ - -#include "ethernet_lib.h" -#include "vcd_signal_dumper.h" -#include "assertions.h" - -#define DEFAULT_PERIOD_NS 200000 /* default value is calculated for 25 PRB */ -#define RRH_UE_PORT 51000 -#define RRH_UE_DEST_IP "127.0.0.1" - -/*! \brief RRH supports two types of modules: eNB and UE - each module is associated with an ethernet device (device of ETH_IF) - and optionally with a RF device (device type can be USRP_B200/USRP_X300/BLADERF_IF/EXMIMO_IF/NONE_IF) - UE modules will always have RF device type NONE_IF */ -typedef struct { -/*! \brief module id */ - uint8_t id; -/*! \brief! loopback flag */ -uint8_t loopback; -/*! \brief measurement flag */ -uint8_t measurements; -/*! \brief module's ethernet device */ -openair0_device eth_dev; -/*! \brief pointer to RF module's device (pointer->since it's optional) */ -openair0_device *devs; -}rrh_module_t; - -/*! \fn void timer_signal_handler(int sig) - * \brief this function - * \param[in] signal type - * \return none - * \note - * @ingroup _oai -*/ -void timer_signal_handler(int); - -/*! \fn void *timer_proc(void *arg) - * \brief this function - * \param[in] - * \param[out] - * \return - * \note - * @ingroup _oai - */ -void *timer_proc(void *); - -/*! \fn void config_BBU_mod( rrh_module_t *mod_enb, uint8_t RT_flag,uint8_t NRT_flag) - * \brief receive and apply configuration to modules' optional device - * \param[in] *mod_enb pointer to module - * \param[in] RT_flag real time flag - * \return none - * \note - * @ingroup _oai - */ -void config_BBU_mod( rrh_module_t *mod_enb, uint8_t RT_flag, uint8_t NRT_flag); - -/*! \fn void config_UE_mod( rrh_module_t *dev_ue, uint8_t RT_flag,uint8_t NRT_flag) - * \brief this function - * \param[in] *mod_ue pointer to module - * \param[in] - * \return none - * \note - * @ingroup _oai - */ -void config_UE_mod( rrh_module_t *dev_ue, uint8_t RT_flag, uint8_t NRT_flag); - - - -void signal_handler(int sig); - -#endif diff --git a/targets/RT/USER/rrh_gw_externs.h b/targets/RT/USER/rrh_gw_externs.h deleted file mode 100644 index 0786743399630eda5240be1c44ab89365ad2be10..0000000000000000000000000000000000000000 --- a/targets/RT/USER/rrh_gw_externs.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file rrh_gw_extern.h - * \brief rrh gatewy external vars - * \author Navid Nikaein, Katerina Trilyraki, Raymond Knopp - * \date 2015 - * \version 0.1 - * \company Eurecom - * \maintainer: navid.nikaein@eurecom.fr - * \note - * \warning very experimental - */ - -#ifndef RRH_GW_EXTERNS_H_ -#define RRH_GW_EXTERNS_H_ -extern char rf_config_file[1024]; - -extern openair0_timestamp timestamp_UE_tx[4] ,timestamp_UE_rx[4] ,timestamp_eNB_rx[4],timestamp_eNB_tx[4]; -extern openair0_vtimestamp hw_counter; -extern int32_t UE_tx_started,UE_rx_started,eNB_rx_started ,eNB_tx_started; -extern int32_t nsamps_UE[4],nsamps_eNB[4]; -extern int32_t overflow_rx_buffer_eNB[4],overflow_rx_buffer_UE[4]; -extern uint8_t rrh_exit; -extern int32_t **rx_buffer_eNB, **rx_buffer_UE; -extern unsigned int rt_period; -extern pthread_mutex_t timer_mutex; - - -#endif diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index 8751e3c81646ed0c80be34785a9a20efd7c9219c..c1e5996d44375f4d40f3eeb433ebced1279810f9 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -345,6 +345,8 @@ void thread_top_init(char *thread_name, exit_fun("Error getting thread priority"); } + pthread_setname_np(pthread_self(), thread_name); + LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(), (policy == SCHED_FIFO) ? "SCHED_FIFO" : (policy == SCHED_RR) ? "SCHED_RR" : diff --git a/targets/RT/USER/sleeptest.c b/targets/RT/USER/sleeptest.c deleted file mode 100644 index ba5cb0ce1551dfb56f3a8dc717b87ecadaa31412..0000000000000000000000000000000000000000 --- a/targets/RT/USER/sleeptest.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file lte-softmodem.c -* \brief main program to control HW and scheduling -* \author R. Knopp, F. Kaltenberger -* \date 2012 -* \version 0.1 -* \company Eurecom -* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr -* \note -* \warning -*/ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> -#include <pthread.h> - -#include "rt_wrapper.h" - -#define TIMER_ONESHOT_MODE -#define FRAME_PERIOD 10000000ULL -#define DAQ_PERIOD 500000ULL -#define LTE_SLOTS_PER_FRAME 20 - -#ifdef RTAI -static SEM *mutex; -//static CND *cond; - -static long int thread0; -static long int thread1; -//static long int sync_thread; -#else -#define OPENAIR_THREAD_STACK_SIZE 8192 -#define OPENAIR_THREAD_PRIORITY 255 -pthread_t thread0; -//pthread_t thread1; -pthread_attr_t attr_dlsch_threads; -struct sched_param sched_param_dlsch; -#endif - -int oai_exit = 0; - -struct timing_info_t { - //unsigned int frame, hw_slot, last_slot, next_slot; - RTIME time_min, time_max, time_avg, time_last, time_now; - //unsigned int mbox0, mbox1, mbox2, mbox_target; - unsigned int n_samples; -} timing_info; - -void signal_handler(int sig) -{ - void *array[10]; - size_t size; - - if (sig==SIGSEGV) { - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(-1); - } else { - oai_exit=1; - } -} - -void exit_fun(const char* s) -{ - void *array[10]; - size_t size; - - printf("Exiting: %s\n",s); - - oai_exit=1; - //rt_sleep_ns(FRAME_PERIOD); - - //exit (-1); -} - -int frame=0,slot=0; - -/* This is the main eNB thread. It gets woken up by the kernel driver using the RTAI message mechanism (rt_send and rt_receive). */ -static void *eNB_thread(void *arg) -{ -#ifdef RTAI - RT_TASK *task; - RTIME now; -#endif - unsigned char last_slot, next_slot; - RTIME time_in, time_diff; - int ret; - -#ifdef RTAI - task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF); - printf("Started eNB thread (id %p)\n",task); -#ifndef TIMER_ONESHOT_MODE - now = rt_get_time(); - ret = rt_task_make_periodic(task, now, nano2count(DAQ_PERIOD)); - - if (ret!=0) - printf("Problem with periodic timer\n"); - -#endif -#endif - -#ifdef HARD_RT - rt_make_hard_real_time(); -#endif - - mlockall(MCL_CURRENT | MCL_FUTURE); - - timing_info.time_min = 100000000ULL; - timing_info.time_max = 0; - timing_info.time_avg = 0; - timing_info.n_samples = 0; - - while (!oai_exit) { - time_in = rt_get_time_ns(); -#ifdef TIMER_ONESHOT_MODE - ret = rt_sleep_ns(DAQ_PERIOD); - - if (ret) - printf("eNB Frame %d, time %llu: rt_sleep_ns returned %d\n",frame,time_in,ret); - -#else - rt_task_wait_period(); -#endif - time_diff = rt_get_time_ns() - time_in; - - if (time_diff > timing_info.time_max) - timing_info.time_max = time_diff; - - if (time_diff < timing_info.time_min) - timing_info.time_min = time_diff; - - timing_info.time_avg = (timing_info.time_avg*timing_info.n_samples + time_diff)/(timing_info.n_samples+1); - timing_info.n_samples++; - - last_slot = (slot)%LTE_SLOTS_PER_FRAME; - - if (last_slot <0) - last_slot+=20; - - next_slot = (slot+3)%LTE_SLOTS_PER_FRAME; - - slot++; - - if (slot==20) { - slot=0; - frame++; - } - } - - printf("eNB_thread: finished, ran %d times.\n",frame); - -#ifdef HARD_RT - rt_make_soft_real_time(); -#endif - - // clean task -#ifdef RTAI - rt_task_delete(task); -#endif - printf("Task deleted. returning\n"); - return 0; -} - - -int main(int argc, char **argv) -{ - -#ifdef RTAI - RT_TASK *task; - RTIME period; -#else - int error_code; -#endif - int i,j,aa; - void *status; - - // to make a graceful exit when ctrl-c is pressed - signal(SIGSEGV, signal_handler); - signal(SIGINT, signal_handler); - -#ifndef RTAI - check_clock(); -#endif - - mlockall(MCL_CURRENT | MCL_FUTURE); - -#ifdef RTAI - // make main thread LXRT soft realtime - task = rt_task_init_schmod(nam2num("MYTASK"), 9, 0, 0, SCHED_FIFO, 0xF); - - // start realtime timer and scheduler -#ifdef TIMER_ONESHOT_MODE - rt_set_oneshot_mode(); - start_rt_timer(0); - printf("started RTAI timer in oneshot mode\n"); -#else - rt_set_periodic_mode(); - period = start_rt_timer(nano2count(500000)); - printf("started RTAI timer with period %llu ns\n",count2nano(period)); -#endif - - printf("Init mutex\n"); - //mutex = rt_get_adr(nam2num("MUTEX")); - mutex = rt_sem_init(nam2num("MUTEX"), 1); - - if (mutex==0) { - printf("Error init mutex\n"); - exit(-1); - } else - printf("mutex=%p\n",mutex); - -#endif - - rt_sleep_ns(10*FRAME_PERIOD); - -#ifndef RTAI - pthread_attr_init (&attr_dlsch_threads); - pthread_attr_setstacksize(&attr_dlsch_threads,OPENAIR_THREAD_STACK_SIZE); - //attr_dlsch_threads.priority = 1; - sched_param_dlsch.sched_priority = sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY; - pthread_attr_setschedparam (&attr_dlsch_threads, &sched_param_dlsch); - pthread_attr_setschedpolicy (&attr_dlsch_threads, SCHED_FIFO); -#endif - -#ifdef RTAI - thread0 = rt_thread_create(eNB_thread, NULL, 100000000); -#else - error_code = pthread_create(&thread0, &attr_dlsch_threads, eNB_thread, NULL); - - if (error_code!= 0) { - printf("[lte-softmodem.c] Could not allocate eNB_thread, error %d\n",error_code); - return(error_code); - } else { - printf("[lte-softmodem.c] Allocate eNB_thread successful\n"); - } - -#endif - printf("eNB threads created\n"); - - - - // wait for end of program - printf("TYPE <CTRL-C> TO TERMINATE\n"); - - //getchar(); - while (oai_exit==0) { - - printf("eNB Frame %d, hw_slot %d (time %llu): period %llu, sleep time (avg/min/max/samples) %llu / %llu / %llu / %d, ratio %f\n",frame,slot,rt_get_time_ns(),DAQ_PERIOD,timing_info.time_avg, - timing_info.time_min,timing_info.time_max,timing_info.n_samples,(double)timing_info.time_avg/DAQ_PERIOD); - - - rt_sleep_ns(100*FRAME_PERIOD); - } - - // stop threads -#ifdef RTAI - rt_thread_join(thread0); -#else - pthread_join(thread0,&status); -#endif - -#ifdef RTAI - stop_rt_timer(); -#endif - - return 0; -} - diff --git a/targets/RT/USER/synctest.c b/targets/RT/USER/synctest.c deleted file mode 100644 index ff65231df1d05622c4fbb559b1002ecdbfbb82fb..0000000000000000000000000000000000000000 --- a/targets/RT/USER/synctest.c +++ /dev/null @@ -1,1318 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file lte-softmodem.c -* \brief main program to control HW and scheduling -* \author R. Knopp, F. Kaltenberger -* \date 2012 -* \version 0.1 -* \company Eurecom -* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr -* \note -* \warning -*/ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> - -#include "rt_wrapper.h" - -#include "PHY/types.h" -//#include "PHY/defs.h" -#include "openair0_lib.h" - -#include "UTIL/LOG/log.h" -#include "UTIL/LOG/vcd_signal_dumper.h" - -#if defined(ENABLE_ITTI) -# include "intertask_interface_init.h" -# include "timer.h" -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -# include "sctp_eNB_task.h" -# endif -#endif - -#ifdef XFORMS -#include "PHY/TOOLS/lte_phy_scope.h" -#include "stats.h" -// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) -// at eNB 0, an UL scope for every UE -FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; -FD_lte_phy_scope_enb *form_enb[NUMBER_OF_UE_MAX]; -FD_stats_form *form_stats=NULL; -char title[255]; -unsigned char scope_enb_num_ue = 1; -#endif //XFORMS - -#ifdef EMOS -#include <gps.h> -#include <rtai_fifos.h> - -//#define CHANSOUNDER_FIFO_SIZE 10485760 // 10 Mbytes FIFO -#define CHANSOUNDER_FIFO_SIZE 20971520 // 20 Mbytes FIFO -#define CHANSOUNDER_FIFO_MINOR 4 // minor of the FIFO device - this is /dev/rtf3 -#define CHANSOUNDER_FIFO_DEV "/dev/rtf4" -#endif - -#define TIMER_ONESHOT_MODE -#define FRAME_PERIOD 100000000ULL -#define DAQ_PERIOD 66667ULL -#define LTE_SLOTS_PER_FRAME 20 -#define RESAMPLING_FACTOR 2 -#define SAMPLES_PER_SLOT (15360/(1<<RESAMPLING_FACTOR)) -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all - -#ifdef RTAI -static SEM *mutex; -//static CND *cond; - -static long int thread0; -static long int thread1; -//static long int sync_thread; -#else -#define OPENAIR_THREAD_STACK_SIZE 8192 -#define OPENAIR_THREAD_PRIORITY 255 -pthread_t thread0; -//pthread_t thread1; -pthread_attr_t attr_dlsch_threads; -struct sched_param sched_param_dlsch; -#endif - -pthread_t thread2; //xforms -pthread_t thread3; //emos - -/* -static int instance_cnt=-1; //0 means worker is busy, -1 means its free -int instance_cnt_ptr_kern,*instance_cnt_ptr_user; -int pci_interface_ptr_kern; -*/ -//extern unsigned int bigphys_top; -//extern unsigned int mem_base; - -int card = 0; -exmimo_config_t *p_exmimo_config; -exmimo_id_t *p_exmimo_id; -volatile unsigned int *DAQ_MBOX; - -int oai_exit = 0; - -//int time_offset[4] = {-138,-138,-138,-138}; -//int time_offset[4] = {-145,-145,-145,-145}; -int time_offset[4] = {0,0,0,0}; - -int fs4_test=0; -char UE_flag=0; -uint8_t eNB_id=0,UE_id=0; - -uint32_t carrier_freq[4]= {1907600000,1907600000,1907600000,1907600000}; - -struct timing_info_t { - //unsigned int frame, hw_slot, last_slot, next_slot; - RTIME time_min, time_max, time_avg, time_last, time_now; - //unsigned int mbox0, mbox1, mbox2, mbox_target; - unsigned int n_samples; -} timing_info; - -extern int16_t* sync_corr_ue0; -extern int16_t prach_ifft[4][1024*2]; - - -int rx_input_level_dBm; -#ifdef XFORMS -extern int otg_enabled; -#else -int otg_enabled; -#endif -int number_of_cards = 1; - -int mbox_bounds[20] = {8,16,24,30,38,46,54,60,68,76,84,90,98,106,114,120,128,136,144, 0}; ///boundaries of slots in terms ob mbox counter rounded up to even numbers -//int mbox_bounds[20] = {6,14,22,28,36,44,52,58,66,74,82,88,96,104,112,118,126,134,142, 148}; ///boundaries of slots in terms ob mbox counter rounded up to even numbers - -int init_dlsch_threads(void); -void cleanup_dlsch_threads(void); -int32_t init_rx_pdsch_thread(void); -void cleanup_rx_pdsch_thread(void); -int init_ulsch_threads(void); -void cleanup_ulsch_threads(void); - -//void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier); -//void setup_eNB_buffers(PHY_VARS_eNB *phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms, int carrier); -void test_config(int card, int ant, unsigned int rf_mode, int UE_flag); - -unsigned int build_rflocal(int txi, int txq, int rxi, int rxq) -{ - return (txi + (txq<<6) + (rxi<<12) + (rxq<<18)); -} -unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) -{ - return (dcoff_i_rxfe + (dcoff_q_rxfe<<8)); -} - -void signal_handler(int sig) -{ - void *array[10]; - size_t size; - - if (sig==SIGSEGV) { - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(-1); - } else { - oai_exit=1; - } -} - -void exit_fun(const char* s) -{ - void *array[10]; - size_t size; - - printf("Exiting: %s\n",s); - - oai_exit=1; - //rt_sleep_ns(FRAME_PERIOD); - - //exit (-1); -} - -#ifdef XFORMS -void *scope_thread(void *arg) -{ - int16_t prach_corr[1024], i; - char stats_buffer[16384]; - //FILE *UE_stats, *eNB_stats; - int len=0; - struct sched_param sched_param; - - sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; - sched_setscheduler(0, SCHED_FIFO,&sched_param); - - printf("Scope thread has priority %d\n",sched_param.sched_priority); - - /* - if (UE_flag==1) - UE_stats = fopen("UE_stats.txt", "w"); - else - eNB_stats = fopen("eNB_stats.txt", "w"); - */ - - while (!oai_exit) { - if (UE_flag==1) { - len = dump_ue_stats (PHY_vars_UE_g[0], stats_buffer, 0, mode,rx_input_level_dBm); - fl_set_object_label(form_stats->stats_text, stats_buffer); - //rewind (UE_stats); - //fwrite (stats_buffer, 1, len, UE_stats); - - phy_scope_UE(form_ue[UE_id], - PHY_vars_UE_g[UE_id], - eNB_id, - UE_id,7); - - } else { - len = dump_eNB_stats (PHY_vars_eNB_g[0], stats_buffer, 0); - fl_set_object_label(form_stats->stats_text, stats_buffer); - - //rewind (eNB_stats); - //fwrite (stats_buffer, 1, len, eNB_stats); - for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - phy_scope_eNB(form_enb[UE_id], - PHY_vars_eNB_g[eNB_id], - UE_id); - } - - } - - //printf("doing forms\n"); - usleep(100000); - } - - //fclose (UE_stats); - //fclose (eNB_stats); - - pthread_exit((void*)arg); -} -#endif - -int dummy_tx_buffer[3840*4] __attribute__((aligned(16))); - -#ifdef EMOS -#define NO_ESTIMATES_DISK 20 //No. of estimates that are aquired before dumped to disk -int channel_buffer_size = SAMPLES_PER_SLOT*4; //one slot, 4 byte per sample - - -void *emos_thread (void *arg) -{ - char c; - char *fifo2file_buffer, *fifo2file_ptr; - - int fifo, counter=0, bytes; - long long unsigned int total_bytes=0; - - FILE *dumpfile_id; - char dumpfile_name[1024]; - time_t starttime_tmp; - struct tm starttime; - - time_t timer; - struct tm *now; - - struct gps_data_t *gps_data = NULL; - struct gps_fix_t dummy_gps_data; - - struct sched_param sched_param; - int ret; - - sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO)-1; - sched_setscheduler(0, SCHED_FIFO,&sched_param); - - printf("EMOS thread has priority %d\n",sched_param.sched_priority); - - timer = time(NULL); - now = localtime(&timer); - - memset(&dummy_gps_data,1,sizeof(struct gps_fix_t)); - -#if GPSD_API_MAJOR_VERSION>=5 - ret = gps_open("127.0.0.1","2947",gps_data); - - if (ret!=0) -#else - gps_data = gps_open("127.0.0.1","2947"); - - if (gps_data == NULL) -#endif - { - printf("[EMOS] Could not open GPS\n"); - //exit(-1); - } - -#if GPSD_API_MAJOR_VERSION>=4 - else if (gps_stream(gps_data, WATCH_ENABLE,NULL) != 0) -#else - else if (gps_query(gps_data, "w+x") != 0) -#endif - { - //sprintf(tmptxt,"Error sending command to GPS, gps_data = %x", gps_data); - printf("[EMOS] Error sending command to GPS\n"); - //exit(-1); - } else - printf("[EMOS] Opened GPS, gps_data=%p\n", gps_data); - - /* - if (UE_flag==0) - channel_buffer_size = sizeof(fifo_dump_emos_eNB); - else - channel_buffer_size = sizeof(fifo_dump_emos_UE); - */ - - // allocate memory for NO_FRAMES_DISK channes estimations - fifo2file_buffer = malloc(NO_ESTIMATES_DISK*channel_buffer_size); - fifo2file_ptr = fifo2file_buffer; - - if (fifo2file_buffer == NULL) { - printf("[EMOS] Cound not allocate memory for fifo2file_buffer\n"); - exit(EXIT_FAILURE); - } - - if ((fifo = open(CHANSOUNDER_FIFO_DEV, O_RDONLY)) < 0) { - fprintf(stderr, "[EMOS] Error opening the fifo\n"); - exit(EXIT_FAILURE); - } - - - time(&starttime_tmp); - localtime_r(&starttime_tmp,&starttime); - snprintf(dumpfile_name,1024,"/tmp/%s_data_%d%02d%02d_%02d%02d%02d.EMOS", - (UE_flag==0) ? "eNB" : "UE", - 1900+starttime.tm_year, starttime.tm_mon+1, starttime.tm_mday, starttime.tm_hour, starttime.tm_min, starttime.tm_sec); - - dumpfile_id = fopen(dumpfile_name,"w"); - - if (dumpfile_id == NULL) { - fprintf(stderr, "[EMOS] Error opening dumpfile %s\n",dumpfile_name); - exit(EXIT_FAILURE); - } - - - printf("[EMOS] starting dump, channel_buffer_size=%d ...\n",channel_buffer_size); - - while (!oai_exit) { - bytes = rtf_read_timed(fifo, fifo2file_ptr, channel_buffer_size,100); - - if (bytes<=0) - continue; - - /* - if (UE_flag==0) - printf("eNB: count %d, frame %d, read: %d bytes from the fifo\n",counter, ((fifo_dump_emos_eNB*)fifo2file_ptr)->frame_tx,bytes); - else - printf("UE: count %d, frame %d, read: %d bytes from the fifo\n",counter, ((fifo_dump_emos_UE*)fifo2file_ptr)->frame_rx,bytes); - */ - - fifo2file_ptr += channel_buffer_size; - counter ++; - total_bytes += bytes; - - if ((counter%NO_ESTIMATES_DISK)==0) { - //reset stuff - fifo2file_ptr = fifo2file_buffer; - //counter = 0; - - //flush buffer to disk - if (fwrite(fifo2file_buffer, sizeof(char), NO_ESTIMATES_DISK*channel_buffer_size, dumpfile_id) != NO_ESTIMATES_DISK*channel_buffer_size) { - fprintf(stderr, "[EMOS] Error writing to dumpfile\n"); - exit(EXIT_FAILURE); - } - - /* - if (gps_data) - { - if (gps_poll(gps_data) != 0) { - printf("[EMOS] problem polling data from gps\n"); - } - else { - printf("[EMOS] lat %g, lon %g\n",gps_data->fix.latitude,gps_data->fix.longitude); - } - if (fwrite(&(gps_data->fix), sizeof(char), sizeof(struct gps_fix_t), dumpfile_id) != sizeof(struct gps_fix_t)) - { - printf("[EMOS] Error writing to dumpfile, stopping recording\n"); - exit(EXIT_FAILURE); - } - } - else - { - printf("[EMOS] WARNING: No GPS data available, storing dummy packet\n"); - if (fwrite(&(dummy_gps_data), sizeof(char), sizeof(struct gps_fix_t), dumpfile_id) != sizeof(struct gps_fix_t)) - { - printf("[EMOS] Error writing to dumpfile, stopping recording\n"); - exit(EXIT_FAILURE); - } - } - */ - } - - if ((counter%2000)==0) - printf("[EMOS] count %d (%d sec), total bytes wrote %llu\n", counter, counter/2000, total_bytes); - } - - free(fifo2file_buffer); - fclose(dumpfile_id); - close(fifo); - - pthread_exit((void*) arg); - -} -#endif - -/* This is the main eNB thread. It gets woken up by the kernel driver using the RTAI message mechanism (rt_send and rt_receive). */ -static void *eNB_thread(void *arg) -{ -#ifdef RTAI - RT_TASK *task; - RTIME now; -#endif - unsigned char slot=0,last_slot, next_slot; - int hw_slot,frame=0; - unsigned int msg1; - unsigned int aa,slot_offset, slot_offset_F; - int diff; - int delay_cnt; - RTIME time_in, time_diff; - int mbox_target=0,mbox_current=0; - int i,ret; - int tx_offset; - int bytes; - -#ifdef RTAI - task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF); - LOG_D(HW,"Started eNB thread (id %p)\n",task); -#ifndef TIMER_ONESHOT_MODE - now = rt_get_time(); - ret = rt_task_make_periodic(task, now, nano2count(500000LL)); - - if (ret!=0) - LOG_E(HW,"Problem with periodic timer\n"); - -#endif -#endif - -#ifdef HARD_RT - rt_make_hard_real_time(); -#endif - - mlockall(MCL_CURRENT | MCL_FUTURE); - - timing_info.time_min = 100000000ULL; - timing_info.time_max = 0; - timing_info.time_avg = 0; - timing_info.n_samples = 0; - - while (!oai_exit) { - hw_slot = (((((volatile unsigned int *)DAQ_MBOX)[0]+1)%150)<<1)/15; - //LOG_D(HW,"eNB frame %d, time %llu: slot %d, hw_slot %d (mbox %d)\n",frame,rt_get_time_ns(),slot,hw_slot,((unsigned int *)DAQ_MBOX)[0]); - //this is the mbox counter where we should be - //mbox_target = ((((slot+1)%20)*15+1)>>1)%150; - mbox_target = mbox_bounds[slot]; - //this is the mbox counter where we are - mbox_current = ((volatile unsigned int *)DAQ_MBOX)[0]; - - //this is the time we need to sleep in order to synchronize with the hw (in multiples of DAQ_PERIOD) - if ((mbox_current>=135) && (mbox_target<15)) //handle the frame wrap-arround - diff = 150-mbox_current+mbox_target; - else if ((mbox_current<15) && (mbox_target>=135)) - diff = -150+mbox_target-mbox_current; - else - diff = mbox_target - mbox_current; - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SLOT_NUMBER_ENB, slot); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_ENB, frame); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DAQ_MBOX, *((volatile unsigned int *) openair0_exmimo_pci[card].rxcnt_ptr[0])); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DIFF, diff); - - time_in = rt_get_time_ns(); - //LOG_D(HW,"eNB Frame %d delaycnt %d : hw_slot %d (%d), slot %d, (slot+1)*15=%d, diff %d, time %llu\n",frame,delay_cnt,hw_slot,((unsigned int *)DAQ_MBOX)[0],slot,(((slot+1)*15)>>1),diff,time_in); - //LOG_D(HW,"eNB Frame %d, time %llu: sleeping for %llu (slot %d, hw_slot %d, diff %d, mbox %d, delay_cnt %d)\n", frame, time_in, diff*DAQ_PERIOD,slot,hw_slot,diff,((volatile unsigned int *)DAQ_MBOX)[0],delay_cnt); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RT_SLEEP,1); -#ifdef TIMER_ONESHOT_MODE - //ret = rt_sleep_ns(DAQ_PERIOD * (slot%4==0?6:8)); - ret = rt_sleep_ns(500000); - - if (ret) - LOG_D(HW,"eNB Frame %d, time %llu: rt_sleep_ns returned %d\n",frame, time_in); - -#else - rt_task_wait_period(); -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RT_SLEEP,0); - - //hw_slot = (((((volatile unsigned int *)DAQ_MBOX)[0]+1)%150)<<1)/15; - //LOG_D(HW,"eNB Frame %d : hw_slot %d, time %llu\n",frame,hw_slot,rt_get_time_ns()); - - mbox_current = ((volatile unsigned int *)DAQ_MBOX)[0]; - - if ((mbox_current>=135) && (mbox_target<15)) //handle the frame wrap-arround - diff = 150-mbox_current+mbox_target; - else if ((mbox_current<15) && (mbox_target>=135)) - diff = -150+mbox_target-mbox_current; - else - diff = mbox_target - mbox_current; - - - last_slot = (slot)%LTE_SLOTS_PER_FRAME; - - if (last_slot <0) - last_slot+=20; - - next_slot = (slot+3)%LTE_SLOTS_PER_FRAME; - - slot++; - - if (slot==20) { - slot=0; - frame++; - } - - if (frame==1000) - oai_exit=1; - -#if defined(ENABLE_ITTI) - itti_update_lte_time(frame, slot); -#endif - } - - LOG_D(HW,"eNB_thread: finished, ran %d times.\n",frame); - -#ifdef HARD_RT - rt_make_soft_real_time(); -#endif - - // clean task -#ifdef RTAI - rt_task_delete(task); -#endif - LOG_D(HW,"Task deleted. returning\n"); - return 0; -} - - -int main(int argc, char **argv) -{ - -#ifdef RTAI - RT_TASK *task; - RTIME period; -#endif - int i,j,aa; - void *status; - - /* - uint32_t rf_mode_max[4] = {55759,55759,55759,55759}; - uint32_t rf_mode_med[4] = {39375,39375,39375,39375}; - uint32_t rf_mode_byp[4] = {22991,22991,22991,22991}; - */ - uint32_t my_rf_mode = RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX; - uint32_t rf_mode_base = TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM; - uint32_t rf_mode[4] = {my_rf_mode,0,0,0}; - uint32_t rf_local[4] = {8255000,8255000,8255000,8255000}; // UE zepto - //{8254617, 8254617, 8254617, 8254617}; //eNB khalifa - //{8255067,8254810,8257340,8257340}; // eNB PETRONAS - - uint32_t rf_vcocal[4] = {910,910,910,910}; - uint32_t rf_vcocal_850[4] = {2015, 2015, 2015, 2015}; - uint32_t rf_rxdc[4] = {32896,32896,32896,32896}; - uint32_t rxgain[4] = {20,20,20,20}; - uint32_t txgain[4] = {20,20,20,20}; - - uint16_t Nid_cell = 0; - uint8_t cooperation_flag=0, transmission_mode=1, abstraction_flag=0; - uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; - - int c; - char do_forms=0; - unsigned int fd; - unsigned int tcxo = 114; - - int amp; - uint8_t prach_fmt; - int N_ZC; - - char rxg_fname[100]; - char txg_fname[100]; - char rflo_fname[100]; - char rfdc_fname[100]; - FILE *rxg_fd=NULL; - FILE *txg_fd=NULL; - FILE *rflo_fd=NULL; - FILE *rfdc_fd=NULL; - unsigned int rxg_max[4]= {133,133,133,133}, rxg_med[4]= {127,127,127,127}, rxg_byp[4]= {120,120,120,120}; - int tx_max_power=0; - - char line[1000]; - int l; - int ret, ant; - int ant_offset=0; - - int error_code; - char *itti_dump_file = NULL; - - const struct option long_options[] = { - {"calib-ue-rx", required_argument, NULL, 256}, - {"calib-ue-rx-med", required_argument, NULL, 257}, - {"calib-ue-rx-byp", required_argument, NULL, 258}, - {"debug-ue-prach", no_argument, NULL, 259}, - {"no-L2-connect", no_argument, NULL, 260}, - {NULL, 0, NULL, 0} - }; - - //mode = normal_txrx; - - - while ((c = getopt_long (argc, argv, "C:K:O:ST:UdF:V",long_options,NULL)) != -1) { - switch (c) { - case 'V': - ouput_vcd = 1; - break; - - case 'd': - do_forms=1; - break; - - case 'U': - UE_flag = 1; - break; - - case 'C': - carrier_freq[0] = atoi(optarg); - carrier_freq[1] = atoi(optarg); - carrier_freq[2] = atoi(optarg); - carrier_freq[3] = atoi(optarg); - break; - - case 'S': - fs4_test=1; - break; - - case 'T': - tcxo=atoi(optarg); - break; - - case 'K': -#if defined(ENABLE_ITTI) - itti_dump_file = strdup(optarg); -#else - printf("-K option is disabled when ENABLE_ITTI is not defined\n"); -#endif - break; - - case 'O': -#if defined(ENABLE_USE_MME) - EPC_MODE_ENABLED = 1; - - if (optarg == NULL) { /* No IP address provided: use localhost */ - memcpy(&EPC_MODE_MME_ADDRESS[0], "127.0.0.1", 10); - } else { - uint8_t ip_length = strlen(optarg) + 1; - memcpy(&EPC_MODE_MME_ADDRESS[0], optarg, - ip_length > 16 ? 16 : ip_length); - } - -#else - printf("You enabled mme mode without s1ap compiled...\n"); -#endif - break; - - case 'F': - sprintf(rxg_fname,"%srxg.lime",optarg); - rxg_fd = fopen(rxg_fname,"r"); - - if (rxg_fd) { - printf("Loading RX Gain parameters from %s\n",rxg_fname); - l=0; - - while (fgets(line, sizeof(line), rxg_fd)) { - if ((strlen(line)==0) || (*line == '#')) continue; //ignore empty or comment lines - else { - if (l==0) sscanf(line,"%d %d %d %d",&rxg_max[0],&rxg_max[1],&rxg_max[2],&rxg_max[3]); - - if (l==1) sscanf(line,"%d %d %d %d",&rxg_med[0],&rxg_med[1],&rxg_med[2],&rxg_med[3]); - - if (l==2) sscanf(line,"%d %d %d %d",&rxg_byp[0],&rxg_byp[1],&rxg_byp[2],&rxg_byp[3]); - - l++; - } - } - } else - printf("%s not found, running with defaults\n",rxg_fname); - - sprintf(txg_fname,"%stxg.lime",optarg); - txg_fd = fopen(txg_fname,"r"); - - if (txg_fd) { - printf("Loading TX Gain parameters from %s\n",txg_fname); - l=0; - - while (fgets(line, sizeof(line), txg_fd)) { - if ((strlen(line)==0) || (*line == '#')) { - continue; //ignore empty or comment lines - } else { - if (l==0) sscanf(line,"%d %d %d %d",&txgain[0],&txgain[1],&txgain[2],&txgain[3]); - - if (l==1) sscanf(line,"%d",&tx_max_power); - - l++; - } - } - } else - printf("%s not found, running with defaults\n",txg_fname); - - sprintf(rflo_fname,"%srflo.lime",optarg); - rflo_fd = fopen(rflo_fname,"r"); - - if (rflo_fd) { - printf("Loading RF LO parameters from %s\n",rflo_fname); - fscanf(rflo_fd,"%d %d %d %d",&rf_local[0],&rf_local[1],&rf_local[2],&rf_local[3]); - } else - printf("%s not found, running with defaults\n",rflo_fname); - - sprintf(rfdc_fname,"%srfdc.lime",optarg); - rfdc_fd = fopen(rfdc_fname,"r"); - - if (rfdc_fd) { - printf("Loading RF DC parameters from %s\n",rfdc_fname); - fscanf(rfdc_fd,"%d %d %d %d",&rf_rxdc[0],&rf_rxdc[1],&rf_rxdc[2],&rf_rxdc[3]); - } else - printf("%s not found, running with defaults\n",rfdc_fname); - - break; - - /* - case 256: - mode = rx_calib_ue; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA max), input level %d dBm\n",rx_input_level_dBm); - break; - case 257: - mode = rx_calib_ue_med; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA med), input level %d dBm\n",rx_input_level_dBm); - break; - case 258: - mode = rx_calib_ue_byp; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA byp), input level %d dBm\n",rx_input_level_dBm); - break; - case 259: - mode = debug_prach; - break; - case 260: - mode = no_L2_connect; - break; - */ - default: - break; - } - } - - if (UE_flag==1) - printf("configuring for UE\n"); - else - printf("configuring for eNB\n"); - - //randominit (0); - //set_taus_seed (0); - - // initialize the log (see log.h for details) - logInit(); - -#if defined(ENABLE_ITTI) - itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file); - -# if defined(ENABLE_USE_MME) - - if (itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0) { - LOG_E(EMU, "Create task failed"); - LOG_D(EMU, "Initializing SCTP task interface: FAILED\n"); - return -1; - } - - if (itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL) < 0) { - LOG_E(EMU, "Create task failed"); - LOG_D(EMU, "Initializing S1AP task interface: FAILED\n"); - return -1; - } - -# endif - - if (itti_create_task(TASK_L2L1, l2l1_task, NULL) < 0) { - LOG_E(EMU, "Create task failed"); - LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n"); - return -1; - } - - // Handle signals until all tasks are terminated - // itti_wait_tasks_end(); -#endif - - if (ouput_vcd) { - if (UE_flag==1) - VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_UE.vcd"); - else - VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_eNB.vcd"); - } - -#ifdef PDCP_USE_NETLINK - netlink_init(); -#endif - - // to make a graceful exit when ctrl-c is pressed - signal(SIGSEGV, signal_handler); - signal(SIGINT, signal_handler); - -#ifndef RTAI - check_clock(); -#endif - - g_log->log_component[HW].level = LOG_DEBUG; - g_log->log_component[HW].flag = LOG_HIGH; -#ifdef OPENAIR2 - g_log->log_component[PHY].level = LOG_INFO; -#else - g_log->log_component[PHY].level = LOG_INFO; -#endif - g_log->log_component[PHY].flag = LOG_HIGH; - g_log->log_component[MAC].level = LOG_INFO; - g_log->log_component[MAC].flag = LOG_HIGH; - g_log->log_component[RLC].level = LOG_INFO; - g_log->log_component[RLC].flag = LOG_HIGH; - g_log->log_component[PDCP].level = LOG_INFO; - g_log->log_component[PDCP].flag = LOG_HIGH; - g_log->log_component[OTG].level = LOG_INFO; - g_log->log_component[OTG].flag = LOG_HIGH; - g_log->log_component[RRC].level = LOG_INFO; - g_log->log_component[RRC].flag = LOG_HIGH; - - - // Initialize card - ret = openair0_open(); - - if ( ret != 0 ) { - if (ret == -1) - printf("Error opening /dev/openair0"); - - if (ret == -2) - printf("Error mapping bigshm"); - - if (ret == -3) - printf("Error mapping RX or TX buffer"); - - return(ret); - } - - printf ("Detected %d number of cards, %d number of antennas.\n", openair0_num_detected_cards, openair0_num_antennas[card]); - - p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr; - p_exmimo_id = openair0_exmimo_pci[card].exmimo_id_ptr; - - printf("Card %d: ExpressMIMO %d, HW Rev %d, SW Rev 0x%d\n", card, p_exmimo_id->board_exmimoversion, p_exmimo_id->board_hwrev, p_exmimo_id->board_swrev); - - if (p_exmimo_id->board_swrev>=BOARD_SWREV_CNTL2) - p_exmimo_config->framing.eNB_flag = 0; - else - p_exmimo_config->framing.eNB_flag = !UE_flag; - - p_exmimo_config->framing.tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB; - - for (ant=0; ant<4; ant++) - p_exmimo_config->framing.resampling_factor[ant] = RESAMPLING_FACTOR; - - /* - for (ant=0;ant<max(frame_parms->nb_antennas_tx,frame_parms->nb_antennas_rx);ant++) - p_exmimo_config->rf.rf_mode[ant] = rf_mode_base; - for (ant=0;ant<frame_parms->nb_antennas_tx;ant++) - p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX); - for (ant=0;ant<frame_parms->nb_antennas_rx;ant++) - p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX); - for (ant=max(frame_parms->nb_antennas_tx,frame_parms->nb_antennas_rx);ant<4;ant++) { - p_exmimo_config->rf.rf_mode[ant] = 0; - carrier_freq[ant] = 0; //this turns off all other LIMEs - } - */ - - ant_offset = 0; - - for (ant=0; ant<4; ant++) { - if (ant==ant_offset) { - //if (1) { - p_exmimo_config->rf.rf_mode[ant] = rf_mode_base; - //p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX); - p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX); - } else { - p_exmimo_config->rf.rf_mode[ant] = 0; - carrier_freq[ant] = 0; //this turns off all other LIMEs - } - } - - for (ant = 0; ant<4; ant++) { - p_exmimo_config->rf.do_autocal[ant] = 1; - p_exmimo_config->rf.rf_freq_rx[ant] = carrier_freq[ant]; - p_exmimo_config->rf.rf_freq_tx[ant] = carrier_freq[ant]; - p_exmimo_config->rf.rx_gain[ant][0] = rxgain[ant]; - p_exmimo_config->rf.tx_gain[ant][0] = txgain[ant]; - - p_exmimo_config->rf.rf_local[ant] = rf_local[ant]; - p_exmimo_config->rf.rf_rxdc[ant] = rf_rxdc[ant]; - - if ((carrier_freq[ant] >= 850000000) && (carrier_freq[ant] <= 865000000)) { - p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal_850[ant]; - p_exmimo_config->rf.rffe_band_mode[ant] = DD_TDD; - } else if ((carrier_freq[ant] >= 1900000000) && (carrier_freq[ant] <= 2000000000)) { - p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant]; - p_exmimo_config->rf.rffe_band_mode[ant] = B19G_TDD; - } else { - p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant]; - p_exmimo_config->rf.rffe_band_mode[ant] = 0; - } - - p_exmimo_config->rf.rffe_gain_txlow[ant] = 31; - p_exmimo_config->rf.rffe_gain_txhigh[ant] = 31; - p_exmimo_config->rf.rffe_gain_rxfinal[ant] = 52; - p_exmimo_config->rf.rffe_gain_rxlow[ant] = 31; - } - - - number_of_cards = openair0_num_detected_cards; - /* - if (p_exmimo_id->board_exmimoversion==1) //ExpressMIMO1 - openair_daq_vars.timing_advance = 138; - else //ExpressMIMO2 - openair_daq_vars.timing_advance = 0; - */ - - openair0_dump_config(card); - - printf("EXMIMO_CONFIG: rf_mode 0x %x %x %x %x, [0]: TXRXEn %d, TXLPFEn %d, TXLPF %d, RXLPFEn %d, RXLPF %d, RFBB %d, LNA %d, LNAGain %d, RXLPFMode %d, SWITCH %d, rf_rxdc %d, rf_local %d, rf_vcocal %d\n", - p_exmimo_config->rf.rf_mode[0], - p_exmimo_config->rf.rf_mode[1], - p_exmimo_config->rf.rf_mode[2], - p_exmimo_config->rf.rf_mode[3], - (p_exmimo_config->rf.rf_mode[0]&3), // RXen+TXen - (p_exmimo_config->rf.rf_mode[0]&4)>>2, //TXLPFen - (p_exmimo_config->rf.rf_mode[0]&TXLPFMASK)>>3, //TXLPF - (p_exmimo_config->rf.rf_mode[0]&128)>>7, //RXLPFen - (p_exmimo_config->rf.rf_mode[0]&RXLPFMASK)>>8, //TXLPF - (p_exmimo_config->rf.rf_mode[0]&RFBBMASK)>>16, // RFBB mode - (p_exmimo_config->rf.rf_mode[0]&LNAMASK)>>12, // RFBB mode - (p_exmimo_config->rf.rf_mode[0]&LNAGAINMASK)>>14, // RFBB mode - (p_exmimo_config->rf.rf_mode[0]&RXLPFMODEMASK)>>19, // RXLPF mode - (p_exmimo_config->framing.tdd_config&TXRXSWITCH_MASK)>>1, // Switch mode - p_exmimo_config->rf.rf_rxdc[0], - p_exmimo_config->rf.rf_local[0], - p_exmimo_config->rf.rf_vcocal[0]); - - for (ant=0; ant<4; ant++) - p_exmimo_config->rf.do_autocal[ant] = 0; - -#ifdef EMOS - error_code = rtf_create(CHANSOUNDER_FIFO_MINOR,CHANSOUNDER_FIFO_SIZE); - - if (error_code==0) - printf("[OPENAIR][SCHED][INIT] Created EMOS FIFO %d\n",CHANSOUNDER_FIFO_MINOR); - else if (error_code==ENODEV) - printf("[OPENAIR][SCHED][INIT] Problem: EMOS FIFO %d is greater than or equal to RTF_NO\n",CHANSOUNDER_FIFO_MINOR); - else if (error_code==ENOMEM) - printf("[OPENAIR][SCHED][INIT] Problem: cannot allocate memory for EMOS FIFO %d\n",CHANSOUNDER_FIFO_MINOR); - else - printf("[OPENAIR][SCHED][INIT] Problem creating EMOS FIFO %d, error_code %d\n",CHANSOUNDER_FIFO_MINOR,error_code); - -#endif - - mlockall(MCL_CURRENT | MCL_FUTURE); - -#ifdef RTAI - // make main thread LXRT soft realtime - task = rt_task_init_schmod(nam2num("MYTASK"), 9, 0, 0, SCHED_FIFO, 0xF); - - // start realtime timer and scheduler -#ifdef TIMER_ONESHOT_MODE - rt_set_oneshot_mode(); - start_rt_timer(0); - printf("started RTAI timer inoneshot mode\n"); -#else - rt_set_periodic_mode(); - period = start_rt_timer(nano2count(500000)); - printf("started RTAI timer with period %llu ns\n",count2nano(period)); -#endif - - printf("Init mutex\n"); - //mutex = rt_get_adr(nam2num("MUTEX")); - mutex = rt_sem_init(nam2num("MUTEX"), 1); - - if (mutex==0) { - printf("Error init mutex\n"); - exit(-1); - } else - printf("mutex=%p\n",mutex); - -#endif - - DAQ_MBOX = (volatile unsigned int *) openair0_exmimo_pci[card].rxcnt_ptr[0]; - - // this starts the DMA transfers - if (UE_flag!=1) - openair0_start_rt_acquisition(card); - - -#ifdef XFORMS - - if (do_forms==1) { - fl_initialize (&argc, argv, NULL, 0, 0); - form_stats = create_form_stats_form(); - - if (UE_flag==1) { - form_ue[UE_id] = create_lte_phy_scope_ue(); - sprintf (title, "LTE DL SCOPE UE"); - fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - } else { - for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - form_enb[UE_id] = create_lte_phy_scope_enb(); - sprintf (title, "UE%d LTE UL SCOPE eNB",UE_id+1); - fl_show_form (form_enb[UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - } - } - - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - - if (UE_flag==0) { - for (UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - if (otg_enabled) { - fl_set_button(form_enb[UE_id]->button_0,1); - fl_set_object_label(form_enb[UE_id]->button_0,"DL Traffic ON"); - } else { - fl_set_button(form_enb[UE_id]->button_0,0); - fl_set_object_label(form_enb[UE_id]->button_0,"DL Traffic OFF"); - } - } - } else { - if (openair_daq_vars.use_ia_receiver) { - fl_set_button(form_ue[UE_id]->button_0,1); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); - } else { - fl_set_button(form_ue[UE_id]->button_0,0); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); - } - } - - ret = pthread_create(&thread2, NULL, scope_thread, NULL); - printf("Scope thread created, ret=%d\n",ret); - } - -#endif - -#ifdef EMOS - ret = pthread_create(&thread3, NULL, emos_thread, NULL); - printf("EMOS thread created, ret=%d\n",ret); -#endif - - rt_sleep_ns(10*FRAME_PERIOD); - -#ifndef RTAI - pthread_attr_init (&attr_dlsch_threads); - pthread_attr_setstacksize(&attr_dlsch_threads,OPENAIR_THREAD_STACK_SIZE); - //attr_dlsch_threads.priority = 1; - sched_param_dlsch.sched_priority = sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY; - pthread_attr_setschedparam (&attr_dlsch_threads, &sched_param_dlsch); - pthread_attr_setschedpolicy (&attr_dlsch_threads, SCHED_FIFO); -#endif - - // start the main thread - if (UE_flag == 1) { - /* - #ifdef RTAI - thread1 = rt_thread_create(UE_thread, NULL, 100000000); - #else - error_code = pthread_create(&thread1, &attr_dlsch_threads, UE_thread, NULL); - if (error_code!= 0) { - LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code); - return(error_code); - } - else { - LOG_D(HW,"[lte-softmodem.c] Allocate UE_thread successful\n"); - } - #endif - #ifdef DLSCH_THREAD - init_rx_pdsch_thread(); - rt_sleep_ns(FRAME_PERIOD/10); - init_dlsch_threads(); - #endif - printf("UE threads created\n"); - */ - } else { -#ifdef RTAI - thread0 = rt_thread_create(eNB_thread, NULL, 100000000); -#else - error_code = pthread_create(&thread0, &attr_dlsch_threads, eNB_thread, NULL); - - if (error_code!= 0) { - LOG_D(HW,"[lte-softmodem.c] Could not allocate eNB_thread, error %d\n",error_code); - return(error_code); - } else { - LOG_D(HW,"[lte-softmodem.c] Allocate eNB_thread successful\n"); - } - -#endif -#ifdef ULSCH_THREAD - init_ulsch_threads(); -#endif - printf("eNB threads created\n"); - } - - - // wait for end of program - printf("TYPE <CTRL-C> TO TERMINATE\n"); - - //getchar(); - while (oai_exit==0) - rt_sleep_ns(FRAME_PERIOD); - - // stop threads -#ifdef XFORMS - printf("waiting for XFORMS thread\n"); - - if (do_forms==1) { - pthread_join(thread2,&status); - fl_hide_form(form_stats->stats_form); - fl_free_form(form_stats->stats_form); - - if (UE_flag==1) { - fl_hide_form(form_ue[UE_id]->lte_phy_scope_ue); - fl_free_form(form_ue[UE_id]->lte_phy_scope_ue); - } else { - for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - fl_hide_form(form_enb[UE_id]->lte_phy_scope_enb); - fl_free_form(form_enb[UE_id]->lte_phy_scope_enb); - } - } - } - -#endif - - printf("stopping MODEM threads\n"); - - // cleanup - if (UE_flag == 1) { - /* - #ifdef RTAI - rt_thread_join(thread1); - #else - pthread_join(thread1,&status); - #endif - #ifdef DLSCH_THREAD - cleanup_dlsch_threads(); - cleanup_rx_pdsch_thread(); - #endif - */ - } else { -#ifdef RTAI - rt_thread_join(thread0); -#else - pthread_join(thread0,&status); -#endif -#ifdef ULSCH_THREAD - cleanup_ulsch_threads(); -#endif - } - -#ifdef OPENAIR2 - //cleanup_pdcp_thread(); -#endif - -#ifdef RTAI - stop_rt_timer(); -#endif - - printf("stopping card\n"); - openair0_stop(card); - printf("closing openair0_lib\n"); - openair0_close(); - -#ifdef EMOS - printf("waiting for EMOS thread\n"); - pthread_cancel(thread3); - pthread_join(thread3,&status); -#endif - -#ifdef EMOS - error_code = rtf_destroy(CHANSOUNDER_FIFO_MINOR); - printf("[OPENAIR][SCHED][CLEANUP] EMOS FIFO closed, error_code %d\n", error_code); -#endif - - if (ouput_vcd) - VCD_SIGNAL_DUMPER_CLOSE(); - - logClean(); - - return 0; -} - -void test_config(int card, int ant, unsigned int rf_mode, int UE_flag) -{ - p_exmimo_config->framing.eNB_flag = !UE_flag; - p_exmimo_config->framing.tdd_config = 0; - p_exmimo_config->framing.resampling_factor[ant] = 2; - - p_exmimo_config->rf.rf_freq_rx[ant] = 1907600000; - p_exmimo_config->rf.rf_freq_tx[ant] = 1907600000;; - p_exmimo_config->rf.rx_gain[ant][0] = 20; - p_exmimo_config->rf.tx_gain[ant][0] = 10; - p_exmimo_config->rf.rf_mode[ant] = rf_mode; - - p_exmimo_config->rf.rf_local[ant] = build_rflocal(20,25,26,04); - p_exmimo_config->rf.rf_rxdc[ant] = build_rfdc(128, 128); - p_exmimo_config->rf.rf_vcocal[ant] = (0xE<<6) + 0xE; -} - -/* -void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier) { - - int i; - if (phy_vars_ue) { - - if ((frame_parms->nb_antennas_rx>1) && (carrier>0)) { - printf("RX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - if ((frame_parms->nb_antennas_tx>1) && (carrier>0)) { - printf("TX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - // replace RX signal buffers with mmaped HW versions - for (i=0;i<frame_parms->nb_antennas_rx;i++) { - free(phy_vars_ue->lte_ue_common_vars.rxdata[i]); - phy_vars_ue->lte_ue_common_vars.rxdata[i] = (int32_t*) openair0_exmimo_pci[card].adc_head[i+carrier]; - - - printf("rxdata[%d] @ %p\n",i,phy_vars_ue->lte_ue_common_vars.rxdata[i]); - } - for (i=0;i<frame_parms->nb_antennas_tx;i++) { - free(phy_vars_ue->lte_ue_common_vars.txdata[i]); - phy_vars_ue->lte_ue_common_vars.txdata[i] = (int32_t*) openair0_exmimo_pci[card].dac_head[i+carrier]; - - printf("txdata[%d] @ %p\n",i,phy_vars_ue->lte_ue_common_vars.txdata[i]); - } - } -} - -void setup_eNB_buffers(PHY_VARS_eNB *phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms, int carrier) { - - int i,j; - - if (phy_vars_eNB) { - if ((frame_parms->nb_antennas_rx>1) && (carrier>0)) { - printf("RX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - if ((frame_parms->nb_antennas_tx>1) && (carrier>0)) { - printf("TX antennas > 1 and carrier > 0 not possible\n"); - exit(-1); - } - - // replace RX signal buffers with mmaped HW versions - for (i=0;i<frame_parms->nb_antennas_rx;i++) { - free(phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i]); - phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i] = (int32_t*) openair0_exmimo_pci[card].adc_head[i+carrier]; - - printf("rxdata[%d] @ %p\n",i,phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i]); - for (j=0;j<16;j++) { - printf("rxbuffer %d: %x\n",j,phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i][j]); - phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i][j] = 16-j; - } - } - for (i=0;i<frame_parms->nb_antennas_tx;i++) { - free(phy_vars_eNB->lte_eNB_common_vars.txdata[0][i]); - phy_vars_eNB->lte_eNB_common_vars.txdata[0][i] = (int32_t*) openair0_exmimo_pci[card].dac_head[i+carrier]; - - printf("txdata[%d] @ %p\n",i,phy_vars_eNB->lte_eNB_common_vars.txdata[0][i]); - for (j=0;j<16;j++) { - printf("txbuffer %d: %x\n",j,phy_vars_eNB->lte_eNB_common_vars.txdata[0][i][j]); - phy_vars_eNB->lte_eNB_common_vars.txdata[0][i][j] = 16-j; - } - } - } -} -*/ diff --git a/targets/SIMU/USER/Makefile b/targets/SIMU/USER/Makefile index 7de5f9382fc6577e919ed15381de13ddeebca7b1..ec5f5eb0ccb382c0e0e38420a3dccc68f4660fde 100644 --- a/targets/SIMU/USER/Makefile +++ b/targets/SIMU/USER/Makefile @@ -29,13 +29,12 @@ endif CFLAGS += -Wpointer-sign -CFLAGS += -DUSER_MODE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 $(CPUFLAGS) -I/usr/include/X11 #-Wno-packed-bitfield-compat +CFLAGS += -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 $(CPUFLAGS) -I/usr/include/X11 #-Wno-packed-bitfield-compat ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES -CFLAGS += -DOPENAIR_LTE -DPUCCH #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE -CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 -DPHY_ABSTRACTION #-DPHY_ABSTRACTION_UL #-DRLC_UM_TEST_TRAFFIC=1 -CFLAGS += -DNEW_FFT +CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE +CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 #-DRLC_UM_TEST_TRAFFIC=1 #CFLAGS += -DLLR8 CFLAGS += -DPACKAGE_NAME='"oaisim"' @@ -48,15 +47,6 @@ DISABLE_XER_PRINT=0 MSG_PRINT=1 endif -ifndef OPENAIR_EMU -export OPENAIR_EMU=1 -CFLAGS += -DOAISIM -endif - -ifdef EMOS -CFLAGS+=-DEMOS -endif - ifeq ($(LOCALIZATION), 1) CFLAGS += -DLOCALIZATION endif @@ -141,8 +131,6 @@ CFLAGS += -DSTOP_ON_IP_TRAFFIC_OVERLOAD endif -ifeq ($(MIH_C_MEDIEVAL_EXTENSIONS), 1) -CFLAGS += -DMIH_C_MEDIEVAL_EXTENSIONS ifeq ($(USE_3GPP_ADDR_AS_LINK_ADDR), 1) CFLAGS += -DUSE_3GPP_ADDR_AS_LINK_ADDR endif @@ -179,7 +167,7 @@ ifdef OAI_NW_DRIVER_TYPE_ETHERNET CFLAGS+=-DOAI_NW_DRIVER_TYPE_ETHERNET endif -CFLAGS += -DENABLE_FXP -DOAI_EMU -DENABLE_USE_CPU_EXECUTION_TIME +CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME ifndef DISABLE_XER_PRINT CFLAGS += -DXER_PRINT endif @@ -272,7 +260,7 @@ endif # Check if libpgm is installed and use it if found instead of the unreliable # multicast ifeq ($(PGM_FOUND), 1) -CFLAGS += $(PGM_CFLAGS) -DENABLE_PGM_TRANSPORT +CFLAGS += $(PGM_CFLAGS) LIBS += $(PGM_LIBS) endif diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index 91fc1cd0591934c539fc99ae893b41987beb2ff2..e2420a1c77e21ff051c5acfdd1342bc77de4b145 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -60,7 +60,7 @@ #include "oaisim.h" #define RF -#define DEBUG_SIM +//#define DEBUG_SIM int number_rb_ul; int first_rbUL ; @@ -83,8 +83,8 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM node_desc_t *enb_data[NUMBER_OF_RU_MAX], node_desc_t *ue_data[NUMBER_OF_UE_MAX], uint16_t subframe, - uint16_t offset, - uint16_t length, + uint32_t offset, + uint32_t length, uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *ue_frame_parms, uint8_t UE_id, int CC_id) @@ -244,22 +244,54 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM frame_parms = &RC.ru[ru_id]->frame_parms; sf_offset = (subframe*frame_parms->samples_per_tti) + offset; - LOG_D(EMU,"TXPATH: RU %d : DL_sig reading TX for subframe %d (sf_offset %d, length %d) from %p\n",ru_id,subframe,sf_offset,length,txdata[0]+sf_offset); + LOG_D(EMU,">>>>>>>>>>>>>>>>>TXPATH: RU %d : DL_sig reading TX for subframe %d (sf_offset %d, length %d) from %p\n",ru_id,subframe,sf_offset,length,txdata[0]+sf_offset); int length_meas = frame_parms->ofdm_symbol_size; - tx_pwr = dac_fixed_gain(s_re, - s_im, - txdata, - sf_offset, - nb_antennas_tx, - length, - sf_offset, - length_meas, - 14, - frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE - 0, - &ru_amp[ru_id], - frame_parms->N_RB_DL*12); + if (sf_offset+length <= frame_parms->samples_per_tti*10) { + tx_pwr = dac_fixed_gain(s_re, + s_im, + txdata, + sf_offset, + nb_antennas_tx, + length, + sf_offset, + length_meas, + 14, + frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE + 0, + &ru_amp[ru_id], + frame_parms->N_RB_DL*12); + + } + else { + tx_pwr = dac_fixed_gain(s_re, + s_im, + txdata, + sf_offset, + nb_antennas_tx, + (frame_parms->samples_per_tti*10)-sf_offset, + sf_offset, + length_meas, + 14, + frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE + 0, + &ru_amp[ru_id], + frame_parms->N_RB_DL*12); + + tx_pwr = dac_fixed_gain(s_re, + s_im, + txdata, + sf_offset, + nb_antennas_tx, + length+sf_offset-(frame_parms->samples_per_tti*10), + sf_offset, + length_meas, + 14, + frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE + 0, + &ru_amp[ru_id], + frame_parms->N_RB_DL*12); + } #ifdef DEBUG_SIM LOG_D(PHY,"[SIM][DL] subframe %d: txp (time) %d dB\n", subframe,dB_fixed(signal_energy(&txdata[0][sf_offset],length_meas))); @@ -403,9 +435,6 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM { int32_t **txdata,**rxdata; -#ifdef PHY_ABSTRACTION_UL - int32_t att_eNB_id=-1; -#endif uint8_t UE_id=0; uint8_t nb_antennas_rx = UE2RU[0][0][CC_id]->nb_rx; // number of rx antennas at eNB @@ -418,14 +447,6 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM uint8_t hold_channel=0; -#ifdef PHY_ABSTRACTION_UL - double min_path_loss=-200; - uint16_t ul_nb_rb=0 ; - uint16_t ul_fr_rb=0; - int ulnbrb2 ; - int ulfrrb2 ; - uint8_t harq_pid; -#endif double s_re0[30720]; double s_re1[30720]; double *s_re[2]; @@ -450,38 +471,6 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM r_im0[1] = r_im01; if (abstraction_flag!=0) { -#ifdef PHY_ABSTRACTION_UL - // wire this to 0 until we figure this out - int eNB_id=0; - - for (UE_id=0; UE_id<NB_UE_INST; UE_id++) { - if (!hold_channel) { - random_channel(UE2RU[UE_id][eNB_id][CC_id],abstraction_flag); - freq_channel(UE2RU[UE_id][eNB_id][CC_id], frame_parms->N_RB_UL,frame_parms->N_RB_UL*12+1); - - // REceived power at the eNB - rx_pwr = signal_energy_fp2(UE2RU[UE_id][eNB_id][CC_id]->ch[0], - UE2RU[UE_id][eNB_id][CC_id]->channel_length)*UE2RU[UE_id][att_eNB_id][CC_id]->channel_length; // calculate the rx power at the eNB - } - - // write_output("SINRch.m","SINRch",PHY_vars_eNB_g[att_eNB_id]->sinr_dB_eNB,frame_parms->N_RB_UL*12+1,1,1); - if(subframe>1 && subframe <5) { - harq_pid = subframe2harq_pid(frame_parms,frame,subframe); - ul_nb_rb = RC.eNB[att_eNB_id][CC_id].ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->nb_rb; - ul_fr_rb = RC.eNB[att_eNB_id][CC_id].ulsch_eNB[(uint8_t)UE_id]->harq_processes[harq_pid]->first_rb; - } - - if(ul_nb_rb>1 && (ul_fr_rb < 25 && ul_fr_rb > -1)) { - number_rb_ul = ul_nb_rb; - first_rbUL = ul_fr_rb; - init_snr_up(UE2RU[UE_id][att_eNB_id][CC_id],enb_data[att_eNB_id], ue_data[UE_id],PHY_vars_eNB_g[att_eNB_id][CC_id]->sinr_dB,&PHY_vars_UE_g[att_eNB_id][CC_id]->N0,ul_nb_rb,ul_fr_rb); - - } - } //UE_id - -#else - -#endif } else { //without abstraction pthread_mutex_lock(&UE_output_mutex[ru_id]); @@ -503,7 +492,7 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM if (((double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe] + UE2RU[UE_id][ru_id][CC_id]->path_loss_dB) <= -125.0) { // don't simulate a UE that is too weak - LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n", + LOG_D(OCM,"[SIM][UL] ULPOWERS UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n", UE_id, PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe], @@ -522,7 +511,7 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM 1, NULL, PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]); // This make the previous argument the total power - LOG_D(OCM,"[SIM][UL] UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n", + LOG_D(OCM,"[SIM][UL] ULPOWERS UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n", UE_id, 10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]), PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], @@ -582,11 +571,11 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM 1e3/UE2RU[0][ru_id][CC_id]->sampling_rate, // sampling time (ns) (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later) -#ifdef DEBUG_SIM + //#ifdef DEBUG_SIM rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0);//*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL; LOG_D(OCM,"[SIM][UL] rx_pwr (ADC in) %f dB for subframe %d (rx_gain %f)\n",10*log10(rx_pwr),subframe, (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx); -#endif + //#endif rxdata = RC.ru[ru_id]->common.rxdata; sf_offset = subframe*frame_parms->samples_per_tti; diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 94e05dd754b1b11afdfbc3015925aad04f1dac14..7d8b33f12c0b9f9feb729958ac9873a440f1b66a 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -160,6 +160,8 @@ volatile int oai_exit = 0; //int32_t **rxdata; //int32_t **txdata; +uint16_t sf_ahead=4; +uint8_t nfapi_mode = 0; // Added for PHY abstraction extern node_list* ue_node_list; @@ -377,7 +379,7 @@ int omv_write(int pfd, node_list* enb_node_list, node_list* ue_node_list, Data_F omv_data.geo[i].node_type = 0; //eNB enb_node_list = enb_node_list->next; omv_data.geo[i].Neighbors = 0; - +/* for (j = NB_RU; j < NB_UE_INST + NB_RU; j++) { if (is_UE_active (i, j - NB_RU) == 1) { omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; @@ -387,6 +389,7 @@ int omv_write(int pfd, node_list* enb_node_list, node_list* ue_node_list, Data_F "[RU %d][UE %d] is_UE_active(i,j) %d geo (x%d, y%d) num neighbors %d\n", i, j-NB_RU, is_UE_active(i,j-NB_RU), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); } } +*/ } } @@ -413,7 +416,7 @@ int omv_write(int pfd, node_list* enb_node_list, node_list* ue_node_list, Data_F ue_node_list = ue_node_list->next; omv_data.geo[i].Neighbors = 0; - +/* for (j = 0; j < NB_RU; j++) { if (is_UE_active (j, i - NB_RU) == 1) { omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; @@ -423,6 +426,7 @@ int omv_write(int pfd, node_list* enb_node_list, node_list* ue_node_list, Data_F "[UE %d][RU %d] is_UE_active %d geo (x%d, y%d) num neighbors %d\n", i-NB_RU, j, is_UE_active(j,i-NB_RU), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); } } +*/ } } @@ -524,11 +528,6 @@ l2l1_task (void *args_p) } } - // UL scope at eNB 0 - form_enb[UE_inst] = create_lte_phy_scope_enb(); - sprintf (title, "LTE UL SCOPE UE %d to eNB %d", UE_inst, eNB_inst); - fl_show_form (form_enb[UE_inst]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - } } @@ -747,7 +746,7 @@ l2l1_task (void *args_p) int subframe_ru_mask_local = subframe_ru_mask; int subframe_UE_mask_local = subframe_UE_mask; pthread_mutex_unlock(&subframe_mutex); - LOG_D(EMU,"Frame %d, Subframe %d: Checking masks %x,%x\n",frame,sf,subframe_ru_mask_local,subframe_UE_mask_local); + LOG_D(EMU,"Frame %d, Subframe %d, NB_RU %d, NB_UE %d: Checking masks %x,%x\n",frame,sf,NB_RU,NB_UE_INST,subframe_ru_mask_local,subframe_UE_mask_local); if ((subframe_ru_mask_local == ((1<<NB_RU)-1)) && (subframe_UE_mask_local == ((1<<NB_UE_INST)-1))) all_done=1; @@ -840,200 +839,6 @@ l2l1_task (void *args_p) #endif - /* - clear_UE_transport_info (oai_emulation.info.nb_ue_local); - clear_UE_transport_info (oai_emulation.info.nb_ue_local); - - for (UE_inst = oai_emulation.info.first_ue_local; - (UE_inst < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local)); - UE_inst++) { - if (oai_emulation.info.cli_start_ue[UE_inst] != 0) { -#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - -#else - - if (frame >= (UE_inst * 20)) // activate UE only after 20*UE_id frames so that different UEs turn on separately -#endif - { - LOG_D(EMU, - "PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n", - UE_inst, frame % MAX_FRAME_NUMBER, slot, next_slot >> 1, - last_slot >> 1); - - if (PHY_vars_UE_g[UE_inst][0]->UE_mode[0] - != NOT_SYNCHED) { - if (frame > 0) { - PHY_vars_UE_g[UE_inst][0]->frame_rx = frame % MAX_FRAME_NUMBER; - PHY_vars_UE_g[UE_inst][0]->slot_rx = last_slot; - PHY_vars_UE_g[UE_inst][0]->slot_tx = next_slot; - - if (next_slot > 1) - PHY_vars_UE_g[UE_inst][0]->frame_tx = frame % MAX_FRAME_NUMBER; - else - PHY_vars_UE_g[UE_inst][0]->frame_tx = (frame + 1) % MAX_FRAME_NUMBER; -#ifdef OPENAIR2 - //Application - update_otg_UE (UE_inst, oai_emulation.info.time_ms); - - //Access layer - // PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE_inst, ENB_FLAG_NO, NOT_A_RNTI, frame, next_slot>>1, 0); - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE_inst, 0, ENB_FLAG_NO, NOT_A_RNTI, frame % MAX_FRAME_NUMBER, next_slot); - pdcp_run (&ctxt); -#endif - - for (CC_id = 0; CC_id < MAX_NUM_CCs; - CC_id++) { - phy_procedures_UE_lte ( - PHY_vars_UE_g[UE_inst][CC_id], - 0, abstraction_flag, - normal_txrx, no_relay, - NULL); - } - - ue_data[UE_inst]->tx_power_dBm = - PHY_vars_UE_g[UE_inst][0]->tx_power_dBm; - } - } else { - if (abstraction_flag == 1) { - LOG_E(EMU, - "sync not supported in abstraction mode (UE%d,mode%d)\n", - UE_inst, - PHY_vars_UE_g[UE_inst][0]->UE_mode[0]); - exit (-1); - } - - if ((frame > 0) - && (last_slot - == (LTE_SLOTS_PER_FRAME - - 2))) { - initial_sync (PHY_vars_UE_g[UE_inst][0], - normal_txrx); - - } - } - -#ifdef PRINT_STATS - - if(last_slot==2 && frame%10==0) { - if (UE_stats_th[UE_inst]) { - fprintf(UE_stats_th[UE_inst],"%d %d\n",frame%MAX_FRAME_NUMBER, PHY_vars_UE_g[UE_inst][0]->bitrate[0]/1000); - } - } - - if (UE_stats[UE_inst]) { - len = dump_ue_stats (PHY_vars_UE_g[UE_inst][0], stats_buffer, 0, normal_txrx, 0); - rewind (UE_stats[UE_inst]); - fwrite (stats_buffer, 1, len, UE_stats[UE_inst]); - fflush(UE_stats[UE_inst]); - } - -#endif - } - } - } - -#if defined(Rel10) || defined(Rel14) - - for (RN_id=oai_emulation.info.first_rn_local; - RN_id<oai_emulation.info.first_rn_local+oai_emulation.info.nb_rn_local; - RN_id++) { - // UE id and eNB id of the RN - UE_inst= oai_emulation.info.first_ue_local+oai_emulation.info.nb_ue_local + RN_id;// NB_UE_INST + RN_id - eNB_inst= oai_emulation.info.first_enb_local+oai_emulation.info.nb_enb_local + RN_id;// NB_eNB_INST + RN_id - - // currently only works in FDD - if (oai_emulation.info.eMBMS_active_state == 4) { - r_type = multicast_relay; - //LOG_I(EMU,"Activating the multicast relaying\n"); - } else { - LOG_E(EMU,"Not supported eMBMS option when relaying is enabled %d\n", r_type); - exit(-1); - } - - PHY_vars_RN_g[RN_id]->frame = frame % MAX_FRAME_NUMBER; - - if ( oai_emulation.info.frame_type == 0) { - // RN == UE - if (frame>0) { - if (PHY_vars_UE_g[UE_inst][0]->UE_mode[0] != NOT_SYNCHED) { - LOG_D(EMU,"[RN %d] PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n", - RN_id, UE_inst, frame, slot, next_slot >> 1,last_slot>>1); - PHY_vars_UE_g[UE_inst][0]->frame_rx = frame % MAX_FRAME_NUMBER; - PHY_vars_UE_g[UE_inst][0]->slot_rx = last_slot; - PHY_vars_UE_g[UE_inst][0]->slot_tx = next_slot; - - if (next_slot>1) PHY_vars_UE_g[UE_inst][0]->frame_tx = frame % MAX_FRAME_NUMBER; - else PHY_vars_UE_g[UE_inst][0]->frame_tx = (frame+1) % MAX_FRAME_NUMBER; - - phy_procedures_UE_lte (PHY_vars_UE_g[UE_inst][0], 0, abstraction_flag,normal_txrx, - r_type, PHY_vars_RN_g[RN_id]); - } else if (last_slot == (LTE_SLOTS_PER_FRAME-2)) { - initial_sync(PHY_vars_UE_g[UE_inst][0],normal_txrx); - } - } - - emu_transport (frame % MAX_FRAME_NUMBER, sf<<1, ((sf+4)%10)<<1, subframe_select(&PHY_vars_eNB_g[0][0]->frame_parms,sf), - oai_emulation.info.frame_type[0], ethernet_flag); - - start_meas (&dl_chan_stats); - - for (UE_inst = 0; UE_inst < NB_UE_INST; UE_inst++) - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - //#warning figure out what to do with UE frame_parms during initial_sync - do_DL_sig (r_re0, - r_im0, - r_re, - r_im, - s_re, - s_im, - eNB2UE, - enb_data, - ue_data, - PHY_vars_eNB_g[0][CC_id]->proc.proc_rxtx[sf&1].subframe_tx<<1, - abstraction_flag, - &PHY_vars_eNB_g[0][CC_id]->frame_parms, - UE_inst, CC_id); - do_DL_sig (r_re0, - r_im0, - r_re, - r_im,n - - s_re, - s_im, - eNB2UE, - enb_data, - ue_data, - (PHY_vars_eNB_g[0][CC_id]->proc.proc_rxtx[sf&1].subframe_tx<<1)+1, - abstraction_flag, - &PHY_vars_eNB_g[0][CC_id]->frame_parms, - UE_inst, CC_id); - } - - stop_meas (&dl_chan_stats); - - - start_meas (&ul_chan_stats); - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - //#warning figure out what to do with UE frame_parms during initial_sync - do_UL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, UE2eNB, - enb_data, ue_data, - PHY_vars_UE_g[0][CC_id]->proc.proc_rxtx[sf&1].subframe_tx<<1, - abstraction_flag, - &PHY_vars_eNB_g[0][CC_id]->frame_parms, - frame % MAX_FRAME_NUMBER, CC_id); - do_UL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, UE2eNB, - enb_data, ue_data, - (PHY_vars_UE_g[0][CC_id]->proc.proc_rxtx[sf&1].subframe_tx<<1)+1, - abstraction_flag, - &PHY_vars_eNB_g[0][CC_id]->frame_parms, - frame % MAX_FRAME_NUMBER, CC_id); - } - - stop_meas (&ul_chan_stats); - - */ - if ((sf == 0) && ((frame % MAX_FRAME_NUMBER) == 0) && (abstraction_flag == 0) && (oai_emulation.info.n_frames == 1)) { @@ -1237,9 +1042,22 @@ void wait_RUs() { printf("RUs are ready, let's go\n"); } -void init_UE(int,int,int); +void init_UE(int,int,int,int); void init_RU(const char*); +void set_UE_defaults(int nb_ue) { + + for (int UE_id = 0;UE_id<nb_ue;UE_id++) { + for (int CC_id = 0;CC_id<MAX_NUM_CCs;CC_id++) { + for (uint8_t i=0; i<RX_NB_TH_MAX; i++) { + PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[i][0]->dciFormat = 0; + PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[i][0]->agregationLevel = 0xFF; + } + PHY_vars_UE_g[UE_id][CC_id]->current_dlsch_cqi[0] = 10; + } + } +} + static void print_current_directory(void) { @@ -1364,15 +1182,17 @@ main (int argc, char **argv) - if (create_tasks(0, - oai_emulation.info.nb_ue_local) < 0) + if (create_tasks_ue(oai_emulation.info.nb_ue_local) < 0) exit(-1); // need a softer mode printf("Waiting for RUs to get set up\n"); wait_RUs(); - init_UE(NB_UE_INST,0,0); + init_UE(NB_UE_INST,0,0,1); + + set_UE_defaults(NB_UE_INST); + init_ocm (); printf("Sending sync to all threads\n"); @@ -1493,6 +1313,8 @@ reset_opp_meas_oaisim (void) reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_turbo_encoding_stats); reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_interleaving_stats); reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_multiplexing_stats); + + /* * L2 functions */ @@ -1513,6 +1335,7 @@ reset_opp_meas_oaisim (void) reset_meas (&UE_pdcp_stats[UE_id].pdcp_ip); reset_meas (&UE_pdcp_stats[UE_id].ip_pdcp); + } for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { @@ -1951,9 +1774,6 @@ oai_shutdown (void) } } //End of PHY abstraction changes -#ifdef OPENAIR2 - mac_top_cleanup (); -#endif // stop OMG stop_mobility_generator (omg_param_list); //omg_param_list.mobility_type @@ -2006,3 +1826,10 @@ get_OAI_emulation () } +// dummy function declarations + +void *rrc_enb_task(void *args_p) { + + +} + diff --git a/targets/SIMU/USER/oaisim.h b/targets/SIMU/USER/oaisim.h index ce21470ed4918e57310472946a20f930e6b305f2..0fdc4002e47cd053fd8ffe56a4b4d7d5f2bd94d8 100644 --- a/targets/SIMU/USER/oaisim.h +++ b/targets/SIMU/USER/oaisim.h @@ -48,10 +48,11 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM uint32_t frame,int eNB_id,uint8_t CC_id); void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs], - node_desc_t *enb_data[NUMBER_OF_RU_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX], + node_desc_t *enb_data[NUMBER_OF_RU_MAX], + node_desc_t *ue_data[NUMBER_OF_UE_MAX], uint16_t subframe, - uint16_t offset, - uint16_t length, + uint32_t offset, + uint32_t length, uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms,uint8_t UE_id,int CC_id); void init_ue(node_desc_t *ue_data, UE_Antenna ue_ant);//Abstraction changes diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index dce104dc0afba2b16288141c66e996f1877684f5..be8f66fb9336873e3b5bb311af3987cf4881e1f6 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -80,6 +80,9 @@ #include "../../ARCH/COMMON/common_lib.h" #include "../../ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" +#include "ENB_APP/enb_paramdef.h" +#include "common/config/config_userapi.h" + #ifdef SMBV extern uint8_t config_smbv; extern char smbv_ip[16]; @@ -177,6 +180,18 @@ extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int oaisim_flag=1; +void RCConfig_sim(void) { + + paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; + + + // Get num RU instances + config_getlist( &RUParamList,NULL,0, NULL); + RC.nb_RU = RUParamList.numelt; + + +} + void get_simulation_options(int argc, char *argv[]) { int option; @@ -782,10 +797,13 @@ void get_simulation_options(int argc, char *argv[]) } } - + if ( load_configmodule(argc,argv) == NULL) { + exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); + } + if (RC.config_file_name != NULL) { /* Read eNB configuration file */ - RCConfig(); + RCConfig_sim(); printf("returned with %d eNBs, %d rus\n",RC.nb_inst,RC.nb_RU); oai_emulation.info.nb_enb_local = RC.nb_inst; oai_emulation.info.nb_ru_local = RC.nb_RU; @@ -1096,62 +1114,70 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** int UE_id = device->Mod_id; int CC_id = device->CC_id; - int subframe,new_subframe; + int subframe; int sample_count=0; int read_size; + int sptti = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti; *ptimestamp = last_UE_rx_timestamp[UE_id][CC_id]; - LOG_D(EMU,"[TXPATH]UE_trx_read nsamps %d TS %llu (%llu) antenna %d\n",nsamps, + LOG_D(EMU,"UE %d DL simulation 0: UE_trx_read nsamps %d TS %llu (%llu, offset %d) antenna %d\n", + UE_id, + nsamps, (unsigned long long)current_UE_rx_timestamp[UE_id][CC_id], (unsigned long long)last_UE_rx_timestamp[UE_id][CC_id], + (int)(last_UE_rx_timestamp[UE_id][CC_id]%sptti), cc); - if (nsamps < PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti) + if (nsamps < sptti) read_size = nsamps; else - read_size = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti; + read_size = sptti; while (sample_count<nsamps) { + LOG_D(EMU,"UE %d: DL simulation 1: UE_trx_read : current TS now %llu, last TS %llu\n",UE_id,current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); while (current_UE_rx_timestamp[UE_id][CC_id] < (last_UE_rx_timestamp[UE_id][CC_id]+read_size)) { - LOG_D(EMU,"[TXPATH]UE_trx_read : current TS %d, last TS %d, sleeping\n",current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); + LOG_D(EMU,"UE %d: DL simulation 2: UE_trx_read : current TS %llu, last TS %llu, sleeping\n",UE_id,current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); usleep(500); } - - // LOG_D(EMU,"UE_trx_read : current TS %d, last TS %d, sleeping\n",current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); + LOG_D(EMU,"UE %d: DL simulation 3: UE_trx_read : current TS now %llu, last TS %llu\n",UE_id,current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); // if we cross a subframe-boundary - subframe = (last_UE_rx_timestamp[UE_id][CC_id]/PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti)%10; - new_subframe = ((last_UE_rx_timestamp[UE_id][CC_id]+read_size)/PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti)%10; - if (new_subframe!=subframe) { - // tell top-level we are busy - pthread_mutex_lock(&subframe_mutex); - subframe_UE_mask|=(1<<UE_id); - LOG_D(EMU,"Setting UE_id %d mask to busy (%d)\n",UE_id,subframe_UE_mask); - pthread_mutex_unlock(&subframe_mutex); + subframe = (last_UE_rx_timestamp[UE_id][CC_id]/sptti)%10; - } + // tell top-level we are busy + pthread_mutex_lock(&subframe_mutex); + subframe_UE_mask|=(1<<UE_id); + LOG_D(EMU,"Setting UE_id %d mask to busy (%d)\n",UE_id,subframe_UE_mask); + pthread_mutex_unlock(&subframe_mutex); + + + + LOG_D(PHY,"UE %d: DL simulation 4: UE_trx_read generating DL subframe %d (Ts %llu, current TS %llu,nsamps %d)\n", + UE_id,subframe,(unsigned long long)*ptimestamp, + (unsigned long long)current_UE_rx_timestamp[UE_id][CC_id], + nsamps); + + LOG_D(EMU,"UE %d: DL simulation 5: Doing DL simulation for %d samples starting in subframe %d at offset %d\n", + UE_id,nsamps,subframe, + (int)(last_UE_rx_timestamp[UE_id][CC_id]%sptti)); - LOG_D(PHY,"UE_trx_read generating DL subframe %d (Ts %llu, current TS %llu)\n", - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)current_UE_rx_timestamp[UE_id][CC_id]); do_DL_sig(RU2UE, enb_data, ue_data, subframe, - last_UE_rx_timestamp[UE_id][CC_id]%PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti, - nsamps, + last_UE_rx_timestamp[UE_id][CC_id]%sptti, + sptti, 0, //abstraction_flag, &PHY_vars_UE_g[UE_id][CC_id]->frame_parms, UE_id, CC_id); - - LOG_D(EMU,"[TXPATH]UE_trx_read @ TS %llu (%llu)=> frame %d, subframe %d\n", - (unsigned long long)current_UE_rx_timestamp[UE_id][CC_id], + LOG_D(EMU,"UE %d: DL simulation 6: UE_trx_read @ TS %llu (%llu)=> frame %d, subframe %d\n", + UE_id,(unsigned long long)current_UE_rx_timestamp[UE_id][CC_id], (unsigned long long)last_UE_rx_timestamp[UE_id][CC_id], - ((unsigned long long)last_UE_rx_timestamp[UE_id][CC_id]/(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti*10))&1023, + ((unsigned long long)last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023, subframe); last_UE_rx_timestamp[UE_id][CC_id] += read_size; @@ -1326,7 +1352,9 @@ void init_devices(void){ PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_freq_func = UE_trx_set_freq; PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_gains_func = UE_trx_set_gains; last_UE_rx_timestamp[UE_id][CC_id] = 0; - + + + } } } @@ -1355,9 +1383,6 @@ void init_ocm(void) if (abstraction_flag) { get_beta_map(); -#ifdef PHY_ABSTRACTION_UL - get_beta_map_up(); -#endif get_MIESM_param(); //load_pbch_desc(); @@ -1396,7 +1421,7 @@ void init_ocm(void) for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - LOG_D(OCM,"Initializing channel (%s, %d) from eNB %d to UE %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, + LOG_I(OCM,"Initializing channel (%s, %d) from RU %d to UE %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), ru_id, UE_id); @@ -1539,7 +1564,7 @@ void update_ocm() for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { AssertFatal(RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); - AssertFatal(UE2RU[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); + AssertFatal(UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE if (ru_id == (UE_id % RC.nb_RU)) { RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; @@ -1566,7 +1591,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) #if defined(USER_MODE) && defined(OAI_EMU) //int rrc_state=0; - +/* if (oai_emulation.info.otg_enabled ==1 ) { int dst_id, app_id; @@ -1576,7 +1601,8 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) for_times += 1; // generate traffic if the ue is rrc reconfigured state - //if ((rrc_state=mac_eNB_get_rrc_status(enb_module_idP, dst_id)) > 2 /*RRC_CONNECTED*/ ) { + //if ((rrc_state=mac_eNB_get_rrc_status(enb_module_idP, dst_id)) > 2 //RRC_CONNECTED + { if (mac_eNB_get_rrc_status(enb_module_idP, oai_emulation.info.eNB_ue_module_id_to_rnti[enb_module_idP][dst_id]) > 2 ){ if_times += 1; @@ -1636,7 +1662,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) otg_pkt=NULL; } - +*/ // old version /* // MBSM multicast traffic #if defined(Rel10) || defined(Rel14) @@ -1662,13 +1688,14 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) } // end multicast traffic #endif */ - +/* } } } } // end multicast traffic +*/ #endif } @@ -1700,57 +1727,11 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) } } } - -#endif #endif } void update_otg_UE(module_id_t ue_mod_idP, unsigned int ctime) { -#if defined(USER_MODE) && defined(OAI_EMU) - - int app_id; - if (oai_emulation.info.otg_enabled ==1 ) { - module_id_t dst_id, src_id; //dst_id = eNB_index - module_id_t module_id = ue_mod_idP+NB_eNB_INST; - - src_id = module_id; - - for (dst_id=0; dst_id<NB_SIG_CNX_UE; dst_id++) { - // only consider the first attached eNB - if (mac_UE_get_rrc_status(ue_mod_idP, dst_id ) > 2 /*RRC_CONNECTED*/) { - for (app_id=0; app_id<MAX_NUM_APPLICATION; app_id++) { - Packet_otg_elt_t *otg_pkt = malloc (sizeof(Packet_otg_elt_t)); - - if (otg_pkt!=NULL) - memset(otg_pkt,0,sizeof(Packet_otg_elt_t)); - else { - LOG_E(OTG,"not enough memory\n"); - exit(-1); - }// Manage to add this packet to the tail of your list - - (otg_pkt->otg_pkt).sdu_buffer = (uint8_t*) packet_gen(src_id, dst_id, app_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); - - if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { - (otg_pkt->otg_pkt).rb_id = DTCH-2; - (otg_pkt->otg_pkt).module_id = module_id; - (otg_pkt->otg_pkt).dst_id = dst_id; - (otg_pkt->otg_pkt).is_ue = 1; - //Adding the packet to the OTG-PDCP buffer - (otg_pkt->otg_pkt).mode = PDCP_TRANSMISSION_MODE_DATA; - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id])); - LOG_D(EMU, "[UE %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d \n", - (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); - } else { - free(otg_pkt); - otg_pkt=NULL; - } - } - } - } - } - -#endif } #endif @@ -1821,6 +1802,13 @@ void init_time() td_avg = TARGET_SF_TIME_NS; } +// dummy function +int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) { + + return(0); + +} + /* int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params) { diff --git a/targets/SIMU/USER/sinr_sim.c b/targets/SIMU/USER/sinr_sim.c index 522f4147cebd44392442afe16ed24a6fde2606e5..7c752ce432f2b268cc7d11b2efd1f770a2c2482b 100644 --- a/targets/SIMU/USER/sinr_sim.c +++ b/targets/SIMU/USER/sinr_sim.c @@ -475,70 +475,6 @@ void init_snr(channel_desc_t* eNB2UE, node_desc_t *enb_data, node_desc_t *ue_dat }//switch }//function ends -#ifdef PHY_ABSTRACTION_UL -void init_snr_up(channel_desc_t* UE2eNB, node_desc_t *enb_data, node_desc_t *ue_data, double* sinr_dB, double* N0,uint16_t nb_rb,uint16_t fr_rb) -{ - - int return_value; - double thermal_noise; - int count; - int aarx; - - // nb_rb = phy_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->nb_rb; - /* Thermal noise is calculated using 10log10(K*T*B) K = Boltzmann's constant T = room temperature B = bandwidth */ - thermal_noise = -174 + 10*log10(UE2eNB->sampling_rate*1e6); //value in dBm - *N0 = thermal_noise + enb_data->rx_noise_level;//? all the element have the same noise level????? - double lambda ; - double residual; - double sinrlin; - double residual_db; - residual = 0 ; - int ccc; - /* - for (count = (fr_rb*12) ; count < (12 * (fr_rb+nb_rb)); count++) - { - residual += ( 1 / ( pow((UE2eNB -> chF[0][count].x),2) + pow((UE2eNB -> chF[0][count].y),2))); - } - *///sinreff(nn) = ((sum((1/p).*(snrm(nn,:)./(snrm(nn,:)+1)),2).^(-1) )-1).^-1; - - sinrlin = 0 ; - lambda = 0; - - ////First calculate SINRs of subcarriers just like OFDM - for (count = (fr_rb*12) ; count < (12 * (fr_rb+nb_rb)); count++) { - sinr_dB[count] = ue_data->tx_power_dBm - + UE2eNB->path_loss_dB - - (thermal_noise + enb_data->rx_noise_level) - + 10 * log10 (pow(UE2eNB->chF[0][count].x, 2) - + pow(UE2eNB->chF[0][count].y, 2)); - - - } - - //Then apply formula : - if(nb_rb > 0) { - //calculate lambdas and fill the same with all but just use one of them when necessary for abstraction - for (count = fr_rb*12; count < (12 * (fr_rb+nb_rb)); count++) { - sinrlin = pow((sinr_dB[count]/10),10); // convert SINR to linear - lambda += (sinrlin / (sinrlin + 1)) ; - } - - for (count = fr_rb*12; count < (12 * (fr_rb+nb_rb)); count++) { - sinr_dB[count] = pow(lambda,2) /(((nb_rb)*lambda)-pow(lambda,2)) ; - sinr_dB[count] = 10*log10(sinr_dB[count]) ; //save it in db - } - - printf("tx_power %g, path_loss %g, sinr_dB[0] %g\n",ue_data->tx_power_dBm ,UE2eNB->path_loss_dB,sinr_dB[count-1]); - - for (ccc = 0; ccc < 301 ; ccc++ ) { - SINRpost_eff[ccc] = 0; - SINRpost_eff[ccc] = sinr_dB[ccc]; - } - } -}//function ends - -#endif - void calculate_sinr(channel_desc_t* eNB2UE, node_desc_t *enb_data, node_desc_t *ue_data, double *sinr_dB, uint16_t nb_rb) { @@ -737,60 +673,7 @@ void get_MIESM_param() free(file_path); } -#ifdef PHY_ABSTRACTION_UL -void get_beta_map_up() -{ - char *file_path = NULL; - int table_len = 0; - int mcs = 0; - char *sinr_bler; - char buffer[1000]; - FILE *fp; - file_path = (char*) malloc(512); - - for (mcs = 0; mcs < MCS_COUNT; mcs++) { - sprintf(file_path,"%s/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/awgn_abst/awgn_snr_bler_mcs%d_up.csv",getenv("OPENAIR1_DIR"),mcs); - fp = fopen(file_path,"r"); - - if (fp == NULL) { - LOG_W(OCM,"ERROR: Unable to open the file %s, try an alternative path\n", file_path); - memset(file_path, 0, 512); - sprintf(file_path,"AWGN/awgn_snr_bler_mcs%d.csv",mcs); - LOG_I(OCM,"Opening the alternative path %s\n", file_path); - fp = fopen(file_path,"r"); - - if (fp == NULL) { - LOG_E(OCM,"ERROR: Unable to open the file %s, exisitng\n", file_path); - exit(-1); - } - } - - // else { - fgets(buffer, 1000, fp); - table_len=0; - - while (!feof(fp)) { - sinr_bler = strtok(buffer, ","); - sinr_bler_map_up[mcs][0][table_len] = atof(sinr_bler); - sinr_bler = strtok(NULL,","); - sinr_bler_map_up[mcs][1][table_len] = atof(sinr_bler); - table_len++; - fgets(buffer, 1000, fp); - } - - fclose(fp); - // } - LOG_D(OCM,"Print the table for mcs %d\n",mcs); - - for (table_len = 0; table_len < 16; table_len++) - LOG_D(OCM,"%lf %lf \n ",sinr_bler_map_up[mcs][0][table_len],sinr_bler_map_up[mcs][1][table_len]); - } - - free(file_path); -} - -#endif diff --git a/targets/TEST/AT_COMMANDS/Makefile b/targets/TEST/AT_COMMANDS/Makefile index 2939b30c0175f546c371e9e56179152e0d3a7c22..fc5f55032914228525f3c6d903eba69bae54b317 100755 --- a/targets/TEST/AT_COMMANDS/Makefile +++ b/targets/TEST/AT_COMMANDS/Makefile @@ -6,7 +6,7 @@ OPENAIR2_TOP = $(OPENAIR2_DIR) OPENAIR3_TOP = $(OPENAIR3_DIR) OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -m32 -DPHYSIM -DNODE_RG -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 +CFLAGS += -m32 -DPHYSIM -DNODE_RG -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES @@ -23,8 +23,6 @@ ifdef PDCP_USE_NETLINK CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif -CFLAGS += -DPHY_ABSTRACTION #-DEMIT_ASN_DEBUG=1 - #include $(OPENAIR1_DIR)/PHY/Makefile.inc #include $(OPENAIR1_DIR)/SCHED/Makefile.inc diff --git a/targets/TEST/OAI/case01.py b/targets/TEST/OAI/case01.py index cdc3bd9eb48d1c90459118eadb206f0ddfbe0227..9595f7e35d0b2103ff10fe8c168506ed2d66a193 100644 --- a/targets/TEST/OAI/case01.py +++ b/targets/TEST/OAI/case01.py @@ -246,7 +246,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): log.start() test = '14' name = 'Compile oai.rel8.itti.ral.make' - conf = 'make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1' + conf = 'make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1' trace = logdir + '/log_' + case + test + '.txt;' tee = ' 2>&1 | tee ' + trace diag = 'check the compilation errors for ITTI Rel8' @@ -254,7 +254,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): oai.send('make cleanall;') oai.send('make cleanasn1;') oai.send('rm -f ./oaisim.rel8.itti.ral.'+host) - oai.send_expect_false('make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1 -j4' + tee, makerr1, timeout) + oai.send_expect_false('make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel8=1 -j4' + tee, makerr1, timeout) oai.send('cp ./oaisim ./oaisim.rel8.itti.ral.'+host) except log.err, e: log.fail(case, test, name, conf, e.value, diag, logfile,trace) @@ -265,7 +265,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): log.start() test = '15' name = 'Compile oai.rel10.itti.ral.make' - conf = 'make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1' + conf = 'make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1' trace = logdir + '/log_' + case + test + '.txt;' tee = ' 2>&1 | tee ' + trace diag = 'check the compilation errors for ITTI Rel10' @@ -273,7 +273,7 @@ def execute(oai, user, pw, host, logfile,logdir,debug,timeout): oai.send('make cleanall;') oai.send('make cleanasn1;') oai.send('rm -f ./oaisim.rel10.itti.ral.'+host) - oai.send_expect_false('make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 USER_MODE=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1 -j4' + tee, makerr1, timeout) + oai.send_expect_false('make DISABLE_XER_PRINT=1 LINK_ENB_PDCP_TO_IP_DRIVER=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 ENABLE_RAL=1 MIH_C_MEDIEVAL_EXTENSIONS=1 RLC_STOP_ON_LOST_PDU=1 Rel10=1 -j4' + tee, makerr1, timeout) oai.send('cp ./oaisim ./oaisim.rel10.itti.ral.'+host) except log.err, e: log.fail(case, test, name, conf, e.value, diag, logfile,trace) diff --git a/targets/TEST/PACKET_TRACER/Makefile b/targets/TEST/PACKET_TRACER/Makefile index 46fa86037ce67df98240d1b321cb76072ae00bf4..e7a4e70bf9318779c1c2af091f46d07f60254326 100755 --- a/targets/TEST/PACKET_TRACER/Makefile +++ b/targets/TEST/PACKET_TRACER/Makefile @@ -6,21 +6,17 @@ OPENAIR2_TOP = $(OPENAIR2_DIR) OPENAIR3_TOP = $(OPENAIR3_DIR) OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -m32 -DPHYSIM -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 +CFLAGS += -m32 -DPHYSIM -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES -CFLAGS += -DOPENAIR_LTE -DPUCCH #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE -CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 -DPHY_ABSTRACTION -DOAI_EMU +CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE +CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 CFLAGS += -DEMIT_ASN_DEBUG=1 ifndef OPENAIR2 OPENAIR2=1 endif -ifndef OPENAIR_EMU -export OPENAIR_EMU=1 -endif - # activate OCG and libxml only under linux ifeq ($(linux),1) CFLAGS += -I/usr/include/libxml2 -L/usr/local/lib -I/usr/include/atlas -L/usr/X11R6/lib @@ -61,8 +57,6 @@ ifdef TRAFFIC_TM5 CFLAGS += -DRLC_UM_TEST_TRAFFIC=1 -DFULL_BUFFER=1 endif -CFLAGS += -DOAI_EMU - include $(OPENAIR1_DIR)/PHY/Makefile.inc include $(OPENAIR1_DIR)/SCHED/Makefile.inc include $(OPENAIR2_DIR)/LAYER2/Makefile.inc diff --git a/targets/TEST/PDCP/Makefile b/targets/TEST/PDCP/Makefile index 66af847af5ee7aeeea6dd0d1e2f10df1f75d0259..805cabe7cb53e2cb5af930e36c230acc6a5a6c6d 100755 --- a/targets/TEST/PDCP/Makefile +++ b/targets/TEST/PDCP/Makefile @@ -8,7 +8,7 @@ OPENAIR3 = $(OPENAIR3_DIR) EXE_FILE_NAME = test_pdcp -CFLAGS += -m32 -DPHYSIM -DNODE_RG -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 +CFLAGS += -m32 -DPHYSIM -DNODE_RG -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES @@ -25,8 +25,6 @@ ifdef PDCP_USE_NETLINK CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif -CFLAGS += -DPHY_ABSTRACTION #-DEMIT_ASN_DEBUG=1 - #include $(OPENAIR1_DIR)/PHY/Makefile.inc #include $(OPENAIR1_DIR)/SCHED/Makefile.inc diff --git a/targets/TEST/PDCP/with_rlc/Makefile.data_bearer b/targets/TEST/PDCP/with_rlc/Makefile.data_bearer index 00f07c1b928fdf7772b2baa00353209aa16522c2..d1397d3f4986c84b30a5d9cf639c2456ebfa17d0 100755 --- a/targets/TEST/PDCP/with_rlc/Makefile.data_bearer +++ b/targets/TEST/PDCP/with_rlc/Makefile.data_bearer @@ -8,7 +8,7 @@ OPENAIR3 = $(OPENAIR3_DIR) EXE_FILE_NAME = test_pdcp_rlc -CFLAGS += -m32 -DPHYSIM -DNODE_RG -DUSER_MODE -DPC_TARGET -DPC_DSP -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 +CFLAGS += -m32 -DPHYSIM -DNODE_RG -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -DMAX_MODULES=1 -I/usr/include/X11 ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES @@ -25,8 +25,6 @@ ifdef PDCP_USE_NETLINK CFLAGS += -DPDCP_USE_NETLINK -DLINUX -DDEBUG_CONTROL endif -CFLAGS += -DPHY_ABSTRACTION #-DEMIT_ASN_DEBUG=1 - #include $(OPENAIR1_DIR)/PHY/Makefile.inc #include $(OPENAIR1_DIR)/SCHED/Makefile.inc diff --git a/targets/TEST/RLC_AM_V9.3.0/Makefile b/targets/TEST/RLC_AM_V9.3.0/Makefile index 9c807cd82654af0fa2487169e07516b6e64dbb6a..8884d7b667fc6eb96f14fcacd29960afa81966db 100755 --- a/targets/TEST/RLC_AM_V9.3.0/Makefile +++ b/targets/TEST/RLC_AM_V9.3.0/Makefile @@ -8,27 +8,18 @@ OPENAIR2_TOP = $(OPENAIR2_DIR) OPENAIR3_TOP = $(OPENAIR3_DIR) OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -m32 -DUSER_MODE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 +CFLAGS += -m32 -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES -CFLAGS += -DOPENAIR_LTE -DPUCCH #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE -CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 -DPHY_ABSTRACTION #-DPHY_ABSTRACTION_UL #-DRLC_UM_TEST_TRAFFIC=1 -CFLAGS += -DNEW_FFT +CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE +CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 #-DRLC_UM_TEST_TRAFFIC=1 #CFLAGS += -DLLR8 ifndef OPENAIR2 OPENAIR2=1 endif -ifndef OPENAIR_EMU -export OPENAIR_EMU=1 -endif - -ifdef EMOS -CFLAGS+=-DEMOS -endif - ifdef TRAFFIC_TM5 CFLAGS += -DRLC_UM_TEST_TRAFFIC=1 #-DFULL_BUFFER=1 endif @@ -114,7 +105,7 @@ endif CFLAGS += $(shell if [ `uname -o` = "Cygwin" ] ; then echo "-DCYGWIN" ;fi) -CFLAGS += -DENABLE_FXP -DOAI_EMU -DENABLE_USE_CPU_EXECUTION_TIME +CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME ifneq ($(USE_MME), R8) UPDATE_RELEASE_9=1 diff --git a/targets/TEST/RLC_UM_V9.3.0/Makefile b/targets/TEST/RLC_UM_V9.3.0/Makefile index b01ea156f4f639a39d534435fe6f25d1dc2f481e..919def5f1e29680119a8fee96545d61802a8d69b 100755 --- a/targets/TEST/RLC_UM_V9.3.0/Makefile +++ b/targets/TEST/RLC_UM_V9.3.0/Makefile @@ -8,27 +8,18 @@ OPENAIR2_TOP = $(OPENAIR2_DIR) OPENAIR3_TOP = $(OPENAIR3_DIR) OPENAIR3 = $(OPENAIR3_DIR) -CFLAGS += -m32 -DUSER_MODE -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TXRX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 +CFLAGS += -m32 -DNB_ANTENNAS_RX=2 -DNB_ANTENNAS_TX=2 -I/usr/include/X11 ASN1_MSG_INC = $(OPENAIR2_DIR)/RRC/LITE/MESSAGES -CFLAGS += -DOPENAIR_LTE -DPUCCH #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE -CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 -DPHY_ABSTRACTION #-DPHY_ABSTRACTION_UL #-DRLC_UM_TEST_TRAFFIC=1 -CFLAGS += -DNEW_FFT +CFLAGS += -DOPENAIR_LTE #-DOFDMA_ULSCH -DIFFT_FPGA -DIFFT_FPGA_UE +CFLAGS += -DMAC_CONTEXT=1 -DPHY_CONTEXT=1 #-DRLC_UM_TEST_TRAFFIC=1 #CFLAGS += -DLLR8 ifndef OPENAIR2 OPENAIR2=1 endif -ifndef OPENAIR_EMU -export OPENAIR_EMU=1 -endif - -ifdef EMOS -CFLAGS+=-DEMOS -endif - ifdef TRAFFIC_TM5 CFLAGS += -DRLC_UM_TEST_TRAFFIC=1 #-DFULL_BUFFER=1 endif @@ -109,7 +100,7 @@ ifdef OAI_NW_DRIVER_TYPE_ETHERNET CFLAGS+=-DOAI_NW_DRIVER_TYPE_ETHERNET endif -CFLAGS += -DENABLE_FXP -DOAI_EMU -DENABLE_USE_CPU_EXECUTION_TIME +CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME ifneq ($(USE_MME), R8) UPDATE_RELEASE_9=1