diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 09e13f9a39a82aa7f50bff6cb5f608a154262274..699e5c92abb27775224c92656651da2b44d27f85 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -284,13 +284,13 @@ set(protobuf_generated_dir ${OPENAIR_BIN_DIR}) add_list2_option(RRC_ASN1_VERSION "Rel14" "ASN.1 version of RRC interface" "Rel8" "Rel10" "Rel14" "CBA") if (${RRC_ASN1_VERSION} STREQUAL "Rel8") - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn) elseif (${RRC_ASN1_VERSION} STREQUAL "CBA") - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn) elseif (${RRC_ASN1_VERSION} STREQUAL "Rel10") - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn) else() - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn) endif (${RRC_ASN1_VERSION} STREQUAL "Rel8") set (RRC_FULL_DIR ${asn1_generated_dir}/${RRC_ASN1_VERSION}) @@ -315,8 +315,8 @@ file(GLOB rrc_h ${RRC_FULL_DIR}/*.h) set(rrc_h ${rrc_h} ${RRC_FULL_DIR}/asn1_constants.h) set_source_files_properties(${rrc_source} PROPERTIES COMPILE_FLAGS -w) # suppress warnings from generated code add_library(RRC_LIB ${rrc_h} ${rrc_source} - ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1_msg.c - ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c) + ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg.c + ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c) include_directories ("${RRC_FULL_DIR}") # add the command to generate the source code @@ -635,12 +635,6 @@ add_boolean_option(DEBUG_PHY False "Enable PHY layer debugging opt add_boolean_option(DEBUG_PHY_PROC False "Enable debugging of PHY layer procedures") add_boolean_option(DEBUG_DLSCH False "Enable debugging of DLSCH physical layer channel") -########################## -# 802.21 options -########################## -add_boolean_option(ENABLE_RAL False "ENABLE 802.21 INTERFACE") -add_boolean_option(USE_3GPP_ADDR_AS_LINK_ADDR False "As per attribute name") - ########################## # NAS LAYER OPTIONS ########################## @@ -709,7 +703,7 @@ include_directories("${OPENAIR_BIN_DIR}") # add directories to find all include files # the internal rule is to use generic names such as defs.h # but to make it uniq name as adding the relative path in the include directtive -# example: #include "RRC/LITE/defs.h" +# example: #include "RRC/LTE/rrc_defs.h" #find_path (include_dirs_all *.h ${OPENAIR_DIR}) #find_path (include_dirs_all *.h PATHS /usr/include NO_CMAKE_PATH) #include_directories("${include_dirs_all}") @@ -741,11 +735,8 @@ include_directories("${OPENAIR2_DIR}/LAYER2/RLC/AM_v9.3.0") include_directories("${OPENAIR2_DIR}/LAYER2/RLC/UM_v9.3.0") include_directories("${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0") include_directories("${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0") -include_directories("${OPENAIR2_DIR}/RRC/LITE/MESSAGES") -include_directories("${OPENAIR2_DIR}/RRC/LITE") -include_directories("${OPENAIR3_DIR}/RAL-LTE/INTERFACE-802.21/INCLUDE") -include_directories("${OPENAIR3_DIR}/RAL-LTE/LTE_RAL_ENB/INCLUDE") -include_directories("${OPENAIR3_DIR}/RAL-LTE/LTE_RAL_UE/INCLUDE") +include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES") +include_directories("${OPENAIR2_DIR}/RRC/LTE") include_directories("${OPENAIR_DIR}/common/utils") include_directories("${OPENAIR_DIR}/common/utils/itti") include_directories("${OPENAIR3_DIR}/NAS/COMMON") @@ -782,7 +773,7 @@ include_directories("${OPENAIR2_DIR}/UTIL/OTG") include_directories("${OPENAIR2_DIR}/UTIL/CLI") include_directories("${OPENAIR2_DIR}/UTIL/OPT") include_directories("${OPENAIR2_DIR}/UTIL/OMV") -include_directories("${OPENAIR2_DIR}/RRC/LITE/MESSAGES") +include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES") include_directories("${OPENAIR3_DIR}/GTPV1-U/nw-gtpv1u/shared") include_directories("${OPENAIR3_DIR}/GTPV1-U/nw-gtpv1u/include") include_directories("${OPENAIR_DIR}") @@ -894,9 +885,9 @@ endif() include_directories(${OPENAIR_DIR}/common/utils/msc) set(UTIL_SRC - ${OPENAIR2_DIR}/UTIL/CLI/cli.c - ${OPENAIR2_DIR}/UTIL/CLI/cli_cmd.c - ${OPENAIR2_DIR}/UTIL/CLI/cli_server.c +# ${OPENAIR2_DIR}/UTIL/CLI/cli.c +# ${OPENAIR2_DIR}/UTIL/CLI/cli_cmd.c +# ${OPENAIR2_DIR}/UTIL/CLI/cli_server.c ${OPENAIR2_DIR}/UTIL/FIFO/pad_list.c ${OPENAIR2_DIR}/UTIL/LISTS/list.c ${OPENAIR2_DIR}/UTIL/LISTS/list2.c @@ -904,32 +895,32 @@ set(UTIL_SRC ${OPENAIR2_DIR}/UTIL/LOG/vcd_signal_dumper.c ${OPENAIR2_DIR}/UTIL/MATH/oml.c ${OPENAIR2_DIR}/UTIL/MEM/mem_block.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_create_dir.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_detect_file.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_generate_report.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_filename.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_XML.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_save_XML.c - ${OPENAIR2_DIR}/UTIL/OMG/common.c - ${OPENAIR2_DIR}/UTIL/OMG/grid.c - ${OPENAIR2_DIR}/UTIL/OMG/job.c - ${OPENAIR2_DIR}/UTIL/OMG/mobility_parser.c - ${OPENAIR2_DIR}/UTIL/OMG/omg.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_create_dir.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_detect_file.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_generate_report.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_filename.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_XML.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_save_XML.c +# ${OPENAIR2_DIR}/UTIL/OMG/common.c +# ${OPENAIR2_DIR}/UTIL/OMG/grid.c +# ${OPENAIR2_DIR}/UTIL/OMG/job.c +# ${OPENAIR2_DIR}/UTIL/OMG/mobility_parser.c +# ${OPENAIR2_DIR}/UTIL/OMG/omg.c #${OPENAIR2_DIR}/UTIL/OMG/omg_hashtable.c - ${OPENAIR2_DIR}/UTIL/OMG/rwalk.c - ${OPENAIR2_DIR}/UTIL/OMG/rwp.c - ${OPENAIR2_DIR}/UTIL/OMG/static.c - ${OPENAIR2_DIR}/UTIL/OMG/steadystaterwp.c - ${OPENAIR2_DIR}/UTIL/OMG/trace.c - ${OPENAIR2_DIR}/UTIL/OMG/trace_hashtable.c +# ${OPENAIR2_DIR}/UTIL/OMG/rwalk.c +# ${OPENAIR2_DIR}/UTIL/OMG/rwp.c +# ${OPENAIR2_DIR}/UTIL/OMG/static.c +# ${OPENAIR2_DIR}/UTIL/OMG/steadystaterwp.c +# ${OPENAIR2_DIR}/UTIL/OMG/trace.c +# ${OPENAIR2_DIR}/UTIL/OMG/trace_hashtable.c ${OPENAIR2_DIR}/UTIL/OPT/probe.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_tx.c - ${OPENAIR2_DIR}/UTIL/OTG/otg.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_kpi.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_models.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_form.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_rx.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_tx.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_kpi.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_models.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_form.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_rx.c ) add_library(UTIL ${UTIL_SRC}) @@ -963,30 +954,27 @@ set(SECU_CN_SRC ) add_library(SECU_CN ${SECU_CN_SRC}) -# Scheduler +# Physical Channel Procedures Scheduling ################################" set(SCHED_SRC ${OPENAIR1_DIR}/SCHED/fapi_l1.c ${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 - ${OPENAIR1_DIR}/SCHED/pusch_pc.c - ${OPENAIR1_DIR}/SCHED/srs_pc.c ) 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 +set(SCHED_SRC_RU ${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_RU_LIB ${SCHED_SRC_RU}) + +set(SCHED_SRC_UE + ${OPENAIR1_DIR}/SCHED_UE/phy_procedures_lte_ue.c + ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c + ${OPENAIR1_DIR}/SCHED_UE/pucch_pc.c + ${OPENAIR1_DIR}/SCHED_UE/pusch_pc.c + ${OPENAIR1_DIR}/SCHED_UE/srs_pc.c ) add_library(SCHED_UE_LIB ${SCHED_SRC_UE}) @@ -1057,67 +1045,26 @@ set(PHY_TURBOIF ) add_library(coding MODULE ${PHY_TURBOSRC} ) -set(PHY_SRC +set(PHY_SRC_COMMON # 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/dci_tools_common.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/slss.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sldch.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slsch.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/LTE_TRANSPORT/phich_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pcfich_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/power_control.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/srs_modulation.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 @@ -1127,14 +1074,12 @@ set(PHY_SRC ${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 ${PHY_TURBOIF} ${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.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 @@ -1152,9 +1097,7 @@ set(PHY_SRC ${OPENAIR1_DIR}/PHY/TOOLS/lut.c ) -set(PHY_SRC_UE - # depend on code generation from asn1c - ${RRC_FULL_DIR}/asn1_constants.h +set(PHY_SRC # actual source ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pss.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss.c @@ -1162,89 +1105,75 @@ set(PHY_SRC_UE ${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/slss.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sldch.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slsch.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/uci_tools.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/freq_equalization.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_eNB_measurements.c + ${OPENAIR1_DIR}/PHY/INIT/lte_init.c + ) + +set(PHY_SRC_RU + # actual source ${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/INIT/lte_init_ru.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c + + ) + +set(PHY_SRC_UE + # actual source + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/sss_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pbch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dci_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/phich_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pcfich_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pucch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/prach_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pmch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/drs_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/ulsch_coding.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/initial_sync.c + ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c + ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_mbsfn.c + ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz_ue.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_adjust_sync_ue.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 - ${PHY_TURBOIF} - ${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 - ${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 ) if (${SMBV}) @@ -1252,12 +1181,13 @@ if (${SMBV}) 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) + set(PHY_SRC_UE ${PHY_SRC_UE} ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c) endif () +add_library(PHY_COMMON ${PHY_SRC_COMMON}) add_library(PHY ${PHY_SRC}) add_library(PHY_UE ${PHY_SRC_UE}) +add_library(PHY_RU ${PHY_SRC_RU}) #Layer 2 library ##################### @@ -1267,7 +1197,7 @@ set(RLC_DIR ${OPENAIR2_DIR}/LAYER2/RLC) set(RLC_UM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/UM_v9.3.0) set(RLC_AM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/AM_v9.3.0) set(RLC_TM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0) -set(RRC_DIR ${OPENAIR2_DIR}/RRC/LITE) +set(RRC_DIR ${OPENAIR2_DIR}/RRC/LTE) set(PDCP_DIR ${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0) set(L2_SRC ${OPENAIR2_DIR}/LAYER2/openair2_proc.c @@ -1360,12 +1290,12 @@ 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}/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}/rar_tools_ue.c ${MAC_DIR}/eNB_scheduler.c ${MAC_DIR}/eNB_scheduler_dlsch.c ${MAC_DIR}/eNB_scheduler_ulsch.c @@ -1376,7 +1306,7 @@ set (MAC_SRC ${MAC_DIR}/eNB_scheduler_phytest.c ${MAC_DIR}/pre_processor.c ${MAC_DIR}/config.c - ${MAC_DIR}/config_ue.c + #${MAC_DIR}/config_ue.c ) set (MAC_SRC_UE @@ -1411,32 +1341,6 @@ include_directories(${NFAPI_USER_DIR}) # L3 Libs ########################## -set(RAL_LTE_DIR ${OPENAIR3_DIR}/RAL-LTE/) -if (${ENABLE_RAL}) - set(RAL_LTE_SRC - ${RRC_DIR}/rrc_UE_ral.c - ${RRC_DIR}/rrc_eNB_ral.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_action.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_main.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_mih_msg.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_parameters.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_process.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_rrc_msg.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_subscribe.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_thresholds.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_action.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_main.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_mih_msg.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_parameters.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_process.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_rrc_msg.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_subscribe.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_thresholds.c - ) - add_library(RAL ${RAL_LTE_SRC}) - set(RAL_LIB RAL) -endif() - # CN libs ########################## @@ -1783,8 +1687,8 @@ ${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/rangen_double.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_channel.c -${OPENAIR1_DIR}/SIMULATION/TOOLS/abstraction.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_tv_channel.c +${OPENAIR1_DIR}/SIMULATION/TOOLS/abstraction.c ${OPENAIR1_DIR}/SIMULATION/RF/rf.c ${OPENAIR1_DIR}/SIMULATION/RF/dac.c ${OPENAIR1_DIR}/SIMULATION/RF/adc.c @@ -1971,7 +1875,6 @@ add_executable(lte-softmodem ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -1990,7 +1893,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 + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2012,7 +1915,6 @@ add_executable(lte-softmodem-nos1 ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c @@ -2029,7 +1931,7 @@ add_executable(lte-softmodem-nos1 ) target_link_libraries (lte-softmodem-nos1 -Wl,--start-group - RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} + RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 ${MSC_LIB} ${RAL_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 ) @@ -2045,12 +1947,11 @@ target_link_libraries (lte-softmodem-nos1 ${T_LIB}) add_executable(lte-uesoftmodem ${rrc_h} ${s1ap_h} - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -2068,7 +1969,7 @@ add_executable(lte-uesoftmodem target_link_libraries (lte-uesoftmodem -Wl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_UE LFDS L2_UE + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2083,12 +1984,11 @@ target_link_libraries (lte-uesoftmodem ${T_LIB}) add_executable(lte-uesoftmodem-nos1 ${rrc_h} ${s1ap_h} - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c @@ -2107,7 +2007,7 @@ add_executable(lte-uesoftmodem-nos1 target_link_libraries (lte-uesoftmodem-nos1 -Wl,--start-group - RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_UE_LIB PHY_UE LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} + RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl ) @@ -2155,8 +2055,7 @@ add_executable(oaisim ${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 - ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c +# ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c ${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c ${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c @@ -2179,7 +2078,7 @@ 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 SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_UE LFDS L2_UE ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} + RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 -Wl,--end-group z dl) @@ -2200,10 +2099,10 @@ add_executable(oaisim_nos1 ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-ru.c + ${OPENAIR1_DIR}/SCHED/prach_procedures.c ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c - ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c +# ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c ${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c ${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c @@ -2222,7 +2121,7 @@ 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_UE_LIB PHY_UE LFDS ${MSC_LIB} ${ITTI_LIB} SIMU L2_UE ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 + RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU 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}) @@ -2241,20 +2140,20 @@ target_link_libraries (oaisim_nos1 ${T_LIB}) #special case for dlim TM4, which uses its own version of phy_scope code add_executable(dlsim_tm4 - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/dlsim_tm4.c ${OPENAIR1_DIR}/PHY/TOOLS/lte_phy_scope_tm4.c ${T_SOURCE} ) target_link_libraries (dlsim_tm4 - -Wl,--start-group SIMU UTIL SCHED_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group + -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group pthread m rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} ) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) add_executable(${myExe} - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c ${XFORMS_SOURCE} ${T_SOURCE} @@ -2263,7 +2162,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr ) target_link_libraries (${myExe} - -Wl,--start-group SIMU UTIL SCHED_LIB PHY LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group + -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY PHY_UE PHY_RU LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group pthread m rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} dl ) endforeach(myExe) @@ -2276,7 +2175,7 @@ add_executable(test_epc_generate_scenario ${OPENAIR2_DIR}/COMMON/messages_def.h ${OPENAIR2_DIR}/COMMON/messages_types.h ${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ) target_link_libraries (test_epc_generate_scenario -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} @@ -2300,7 +2199,7 @@ add_executable(test_epc_play_scenario ) target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c) target_link_libraries (test_epc_play_scenario - -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} + -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} ) @@ -2457,7 +2356,7 @@ list(APPEND oai_nw_drv_src device.c common.c ioctl.c classifier.c tool.c) if(OAI_NW_DRIVER_USE_NETLINK) list(APPEND oai_nw_drv_src netlink.c) endif() -make_driver(oai_nw_drv ${OPENAIR2_DIR}/NETWORK_DRIVER/LITE ${oai_nw_drv_src}) +make_driver(oai_nw_drv ${OPENAIR2_DIR}/NETWORK_DRIVER/LTE ${oai_nw_drv_src}) # Exmimo board drivers ######################### diff --git a/cmake_targets/lte-simulators/CMakeLists.txt b/cmake_targets/lte-simulators/CMakeLists.txt index ca754449d7f9c6bbea10e1dcf726160df18a9f97..b7e83a92a03282f9dfae9b54633a8ea745763cee 100644 --- a/cmake_targets/lte-simulators/CMakeLists.txt +++ b/cmake_targets/lte-simulators/CMakeLists.txt @@ -8,5 +8,5 @@ set(DEBUG_PHY False) set(MU_RECIEVER False) set(NAS_UE False) set(MESSAGE_CHART_GENERATOR False) - +set(RRC_ASN1_VERSION "Rel14") include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt) diff --git a/common/ran_context.h b/common/ran_context.h index 4380dc65f12f167a5b2dc99a6a0b98590e74a1de..08c05411c98fa36829c39cb5cf04ec35c0f95dfc 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -35,11 +35,11 @@ #include <pthread.h> #include "COMMON/platform_constants.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "PHY/types.h" #include "PHY/impl_defs_top.h" #include "PHY/impl_defs_lte.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "flexran_agent_defs.h" #include "gtpv1u.h" @@ -49,7 +49,7 @@ #include "gtpv1u_eNB_defs.h" #include "PHY/defs_L1_NB_IoT.h" -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" typedef struct { /// RAN context config file name char *config_file_name; diff --git a/common/utils/load_module_shlib.c b/common/utils/load_module_shlib.c index fecdc2a58c624139f24bb44189b220dbf1f0d1d5..656f6a885224abaf3e6565368bd99d5f95225620 100644 --- a/common/utils/load_module_shlib.c +++ b/common/utils/load_module_shlib.c @@ -37,7 +37,7 @@ #include <errno.h> #include <sys/ioctl.h> #include <dlfcn.h> -#include "openair1/PHY/defs.h" +#include "openair1/PHY/defs_common.h" #define LOAD_MODULE_SHLIB_MAIN #include "common/config/config_userapi.h" diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 2a6fc334f439cc6eb1a801c6bf71a2fcb05da977..dee4e8d310023fba1c22cc073800c1c2c1f2003c 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -48,7 +48,10 @@ extern RAN_CONTEXT_t RC; #include "fapi_stub.h" //#include "fapi_l1.h" #include "UTIL/LOG/log.h" -#include "openair2/LAYER2/MAC/proto.h" +#include "openair2/LAYER2/MAC/mac_proto.h" + +#include "PHY/INIT/phy_init.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" #define NUM_P5_PHY 2 diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index e77aa2b3765abd743c7831b7f4fd5443f569677f..74e999528c51fc7d40f4eea48d56cd069a7ced04 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -37,7 +37,8 @@ #include "vendor_ext.h" #include "nfapi_vnf.h" - +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" #include "common/ran_context.h" extern RAN_CONTEXT_t RC; diff --git a/openair1/PHY/CODING/3gpplte.c b/openair1/PHY/CODING/3gpplte.c index 61acdb2ad9d3040dca9ed68d4264cc0fe0e332c4..ae476a118f0ab99f777e7ad2270fedfcb467a815 100644 --- a/openair1/PHY/CODING/3gpplte.c +++ b/openair1/PHY/CODING/3gpplte.c @@ -29,7 +29,7 @@ #endif #include <stdint.h> #include <stdio.h> -#include "PHY/CODING/defs.h" +#include "PHY/CODING/coding_defs.h" #include "extern_3GPPinterleaver.h" //#define DEBUG_TURBO_ENCODER 1 diff --git a/openair1/PHY/CODING/3gpplte_sse.c b/openair1/PHY/CODING/3gpplte_sse.c index 8150f02da89abd7ed2e5351de2cf25057c238263..e2eb7eb52af2897cfcbf02a5b3407e492cc681d6 100644 --- a/openair1/PHY/CODING/3gpplte_sse.c +++ b/openair1/PHY/CODING/3gpplte_sse.c @@ -26,10 +26,10 @@ date: 09.2012 */ #ifndef TC_MAIN -#include "defs.h" +#include "coding_defs.h" #include "extern_3GPPinterleaver.h" #else -#include "vars.h" +#include "coding_vars.h" #include <stdint.h> #endif #include <stdio.h> diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder.c b/openair1/PHY/CODING/3gpplte_turbo_decoder.c index c0e4ca12db42a30e768718336467da778dac3aa3..572127a5e0bd4118a4082d94e51c402743a33689 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder.c @@ -27,8 +27,8 @@ */ -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c index ef0ca48df465971ed2b89b66068f366a4937a519..a541c223934e00d2d3cf31eaf01d10a748b3dd3a 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c @@ -42,8 +42,9 @@ #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/impl_defs_top.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "extern_3GPPinterleaver.h" #else diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c index ae3ce531d037cce540522aa6454a20ab96733132..7daa86b8bb296218b17955532c96267c2688c24d 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c @@ -41,8 +41,9 @@ #include "PHY/sse_intrin.h" #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/impl_defs_top.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "extern_3GPPinterleaver.h" #else diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c index 5b7174e98964b9c9fec7e450fb892778755e57ff..f22ec21ff0ac25bfb876a8bac56c22b02129ca2c 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c @@ -39,8 +39,8 @@ #include "PHY/sse_intrin.h" #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "extern_3GPPinterleaver.h" #else diff --git a/openair1/PHY/CODING/ccoding_byte.c b/openair1/PHY/CODING/ccoding_byte.c index 8511a5ea0f7103cfcf252a9ededf4103ab8e4977..db91e68dc8f020c63b1d610cfbfb6d1f93ebaa3a 100644 --- a/openair1/PHY/CODING/ccoding_byte.c +++ b/openair1/PHY/CODING/ccoding_byte.c @@ -24,7 +24,7 @@ author: raymond.knopp@eurecom.fr, based on similar code for 3GPP convolutional code (UMTS) by P. Humblet (2000) date: 10.2004 */ -#include "defs.h" +#include "coding_defs.h" unsigned short gdot11[] = { 0133, 0171 }; // {A,B} diff --git a/openair1/PHY/CODING/ccoding_byte_lte.c b/openair1/PHY/CODING/ccoding_byte_lte.c index 6eb654827bc874c9d27a405d2975b014a572a32d..870e9ba4700c15e16c42d4b18e3a975ef757e51e 100644 --- a/openair1/PHY/CODING/ccoding_byte_lte.c +++ b/openair1/PHY/CODING/ccoding_byte_lte.c @@ -24,7 +24,7 @@ author: raymond.knopp@eurecom.fr date: 21.10.2009 */ -#include "defs.h" +#include "coding_defs.h" //#define DEBUG_CCODE 1 diff --git a/openair1/PHY/CODING/defs.h b/openair1/PHY/CODING/coding_defs.h similarity index 96% rename from openair1/PHY/CODING/defs.h rename to openair1/PHY/CODING/coding_defs.h index 40e19964dfa1abc0d847f84bfc2560ee3f2ea96f..d2975f3f9360dc09a55eb7329e625694895dfb5d 100644 --- a/openair1/PHY/CODING/defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -29,7 +29,7 @@ #include <stdint.h> -#include "PHY/defs.h" +#include "PHY/defs_common.h" #define CRC24_A 0 #define CRC24_B 1 @@ -75,20 +75,7 @@ int32_t lte_segmentation(uint8_t *input_buffer, uint32_t *Kminus, uint32_t *F); -/** \fn int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs) - \brief this functions calculates the delta MCS in dB based on the lte_segmentation function -\param tbs transport block size -\param nb_rb number of required rb -\param control_only a flag for the type of data -\param ncp cyclic prefix -\param use_srs a flag indicating the use of srs in the current SF -\returns ue_tx_power estimated ue tx power = delat_ mcs + bw_factor -*/ -int16_t estimate_ue_tx_power(uint32_t tbs, - uint32_t nb_rb, - uint8_t control_only, - lte_prefix_type_t ncp, - uint8_t use_srs); + /** \fn uint32_t sub_block_interleaving_turbo(uint32_t D, uint8_t *d,uint8_t *w) \brief This is the subblock interleaving algorithm from 36-212 (Release 8, 8.6 2009-03), pages 15-16. diff --git a/openair1/PHY/CODING/extern.h b/openair1/PHY/CODING/coding_extern.h similarity index 100% rename from openair1/PHY/CODING/extern.h rename to openair1/PHY/CODING/coding_extern.h diff --git a/openair1/PHY/CODING/coding_load.c b/openair1/PHY/CODING/coding_load.c index 31f71e6b31965e7777cba5fb9b4a2f260c56da51..76ab04f2207734355d209e71e5338567303a92f8 100644 --- a/openair1/PHY/CODING/coding_load.c +++ b/openair1/PHY/CODING/coding_load.c @@ -33,8 +33,8 @@ #include <sys/types.h> -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" #include "common/utils/load_module_shlib.h" #include "common/utils/telnetsrv/telnetsrv.h" diff --git a/openair1/PHY/CODING/vars.h b/openair1/PHY/CODING/coding_vars.h similarity index 100% rename from openair1/PHY/CODING/vars.h rename to openair1/PHY/CODING/coding_vars.h diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 21427de19b88c1568ac96b4a08b40b4d0813f1f2..0e1f0e065f36b8ade81d103fb2ccc70915a09751 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -31,7 +31,7 @@ */ -#include "defs.h" +#include "coding_defs.h" /*ref 36-212 v8.6.0 , pp 8-9 */ diff --git a/openair1/PHY/CODING/lte_rate_matching.c b/openair1/PHY/CODING/lte_rate_matching.c index 41c3c5e5a91b314c62c2d9a701c1802def0b306c..af5d1a169e950fa0a35b7237c47ad5390a195288 100644 --- a/openair1/PHY/CODING/lte_rate_matching.c +++ b/openair1/PHY/CODING/lte_rate_matching.c @@ -28,8 +28,8 @@ #include <stdio.h> #include <stdlib.h> #endif -#include "PHY/defs.h" -#include "assertions.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_common.h" //#define cmin(a,b) ((a)<(b) ? (a) : (b)) diff --git a/openair1/PHY/CODING/lte_segmentation.c b/openair1/PHY/CODING/lte_segmentation.c index 3ae65e20900e95323efee6563cbc9d7dd705b856..ba79b0171e4e31dac4d411e07b4ab22b66263cbf 100644 --- a/openair1/PHY/CODING/lte_segmentation.c +++ b/openair1/PHY/CODING/lte_segmentation.c @@ -24,8 +24,9 @@ author: raymond.knopp@eurecom.fr date: 21.10.2009 */ -#include "PHY/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_common.h" +#include "PHY/CODING/coding_defs.h" //#define DEBUG_SEGMENTATION diff --git a/openair1/PHY/CODING/viterbi_lte.c b/openair1/PHY/CODING/viterbi_lte.c index 5e11cb3453ab9dd2f425a175389acfd0edcca432..553192a4a8ee723ff3afb12292f53cb10c4463ac 100644 --- a/openair1/PHY/CODING/viterbi_lte.c +++ b/openair1/PHY/CODING/viterbi_lte.c @@ -29,8 +29,8 @@ */ #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" #else #include <stdio.h> #include <stdlib.h> diff --git a/openair1/PHY/INIT/extern.h b/openair1/PHY/INIT/init_extern.h similarity index 100% rename from openair1/PHY/INIT/extern.h rename to openair1/PHY/INIT/init_extern.h diff --git a/openair1/PHY/INIT/init_top.c b/openair1/PHY/INIT/init_top.c index 6213520b8c8bf042aaf7c7212ea8a5a237156ba8..f033a7e5c17d3db534b91d2008fe49913c2c0c07 100644 --- a/openair1/PHY/INIT/init_top.c +++ b/openair1/PHY/INIT/init_top.c @@ -20,9 +20,50 @@ */ /*!\brief Initilization and reconfiguration routines for LTE PHY */ -#include "defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/extern.h" +#include "phy_init.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" + +void generate_64qam_table(void) +{ + + int a,b,c,index; + + + for (a=-1; a<=1; a+=2) + for (b=-1; b<=1; b+=2) + for (c=-1; c<=1; c+=2) { + index = (1+a)*2 + (1+b) + (1+c)/2; + qam64_table[index] = -a*(QAM64_n1 + b*(QAM64_n2 + (c*QAM64_n3))); // 0 1 2 + } +} + +void generate_16qam_table(void) +{ + + int a,b,index; + + for (a=-1; a<=1; a+=2) + for (b=-1; b<=1; b+=2) { + index = (1+a) + (1+b)/2; + qam16_table[index] = -a*(QAM16_n1 + (b*QAM16_n2)); + } +} + +void generate_qpsk_table(void) +{ + + int a,index; + + for (a=-1; a<=1; a+=2) { + index = (1+a)/2; + qpsk_table[index] = -a*QPSK; + } +} + void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) { diff --git a/openair1/PHY/INIT/vars.h b/openair1/PHY/INIT/init_vars.h similarity index 100% rename from openair1/PHY/INIT/vars.h rename to openair1/PHY/INIT/init_vars.h diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 474207a407ae1e54db3dc425e46d7de77b58fdff..c226099da90be0ceab3e9a7490208e172794b2bb 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -19,14 +19,17 @@ * contact@openairinterface.org */ -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "PHY/defs_eNB.h" +#include "phy_init.h" +#include "SCHED/sched_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "SIMULATION/TOOLS/sim.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" @@ -721,24 +724,6 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id, -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; - - if (eNB_flag == 0 ) { - //LOG_D(PHY,"[UE %d] configure cba group %d with rnti %x, num active cba grp %d\n", index, index, cba_rnti, num_active_cba_groups); - PHY_vars_UE_g[Mod_id][CC_id]->ulsch[index]->num_active_cba_groups=num_active_cba_groups; - PHY_vars_UE_g[Mod_id][CC_id]->ulsch[index]->cba_rnti[cba_group_id]=cba_rnti; - } else { - //for (i=index; i < NUMBER_OF_UE_MAX; i+=num_active_cba_groups){ - // LOG_D(PHY,"[eNB %d] configure cba group %d with rnti %x for UE %d, num active cba grp %d\n",Mod_id, i%num_active_cba_groups, cba_rnti, i, num_active_cba_groups); - RC.eNB[Mod_id][CC_id]->ulsch[index]->num_active_cba_groups=num_active_cba_groups; - RC.eNB[Mod_id][CC_id]->ulsch[index]->cba_rnti[cba_group_id] = cba_rnti; - //} - } -} - - 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 index 91681930748052dd38dd69a74cd7a782e1d6cf6d..8c270fe7ba6960cb0a608dfc1877f66b858af66d 100644 --- a/openair1/PHY/INIT/lte_init_ru.c +++ b/openair1/PHY/INIT/lte_init_ru.c @@ -19,14 +19,13 @@ * contact@openairinterface.org */ -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "phy_init.h" +#include "SCHED/sched_eNB.h" +#include "PHY/phy_extern.h" +#include "SIMULATION/TOOLS/sim.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" diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index 84b045d9608b6837e8f2b7d627545a9dd0757be8..763272e5860bfcb101df93826713e2d379da29a7 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -19,19 +19,20 @@ * contact@openairinterface.org */ -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "phy_init.h" +#include "SCHED_UE/sched_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SIMULATION/TOOLS/sim.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> - +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10}; extern uint8_t nfapi_mode; @@ -655,7 +656,7 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, 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); + diff --git a/openair1/PHY/INIT/lte_param_init.c b/openair1/PHY/INIT/lte_param_init.c index 6cf05769e52e4ca2b4dfc4a0bba6ac5d4848239f..0830058a8fb4bda41bb692a4e29b9aa460fb7104 100644 --- a/openair1/PHY/INIT/lte_param_init.c +++ b/openair1/PHY/INIT/lte_param_init.c @@ -25,10 +25,14 @@ #include <execinfo.h> #include <signal.h> -#include "SIMULATION/TOOLS/defs.h" +#include "SIMULATION/TOOLS/sim.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern.h" +#include "phy_init.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" extern PHY_VARS_eNB *eNB; extern PHY_VARS_UE *UE; diff --git a/openair1/PHY/INIT/lte_parms.c b/openair1/PHY/INIT/lte_parms.c index 2f2bd95617ebcffa60092376e9778935bd3ce877..e7c4ced5d37351977dc61f7d21e9c85ff8516905 100644 --- a/openair1/PHY/INIT/lte_parms.c +++ b/openair1/PHY/INIT/lte_parms.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "phy_init.h" #include "log.h" uint16_t dl_S_table_normal[10]={3,9,10,11,12,3,9,10,11,6}; diff --git a/openair1/PHY/INIT/defs.h b/openair1/PHY/INIT/phy_init.h similarity index 99% rename from openair1/PHY/INIT/defs.h rename to openair1/PHY/INIT/phy_init.h index be3e5c160b61a7ad71562befd3f2da89cd3a8fb0..652ae6a2d1c71b30b0b9c535eb534c2c029239ff 100644 --- a/openair1/PHY/INIT/defs.h +++ b/openair1/PHY/INIT/phy_init.h @@ -22,8 +22,8 @@ #ifndef __INIT_DEFS__H__ #define __INIT_DEFS__H__ -#include "PHY/defs.h" - +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "SystemInformationBlockType2.h" //#include "RadioResourceConfigCommonSIB.h" diff --git a/openair1/PHY/LTE_ESTIMATION/adjust_gain.c b/openair1/PHY/LTE_ESTIMATION/adjust_gain.c index 7272b7247d93f451754d41eadfa5edfaf2b51057..27e6c106863e98a5d317bfad32926583536205bc 100644 --- a/openair1/PHY/LTE_ESTIMATION/adjust_gain.c +++ b/openair1/PHY/LTE_ESTIMATION/adjust_gain.c @@ -20,8 +20,8 @@ */ #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" void phy_adjust_gain (PHY_VARS_UE *ue, uint32_t rx_power_fil_dB, uint8_t eNB_id) diff --git a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c index 2c318d85e401d529bb78f5bdda5ffc6c74be5c05..3fd58a4989701d795401ae296b3a4241e159136a 100644 --- a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c +++ b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" // This is 512/(1:256) in __m128i format diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c index 18444076f315de40ee4ef925e31ccd93043b1d37..8810752398f1991361c2826519d70075bf645a30 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c @@ -20,10 +20,11 @@ */ #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "openair2/LAYER2/MAC/mac_proto.h" #define DEBUG_PHY @@ -134,128 +135,3 @@ void lte_adjust_synch(LTE_DL_FRAME_PARMS *frame_parms, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_OUT); } } - - -int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, - LTE_eNB_SRS *lte_eNB_srs, - unsigned int *eNB_id, - unsigned char clear, - unsigned char number_of_cards, - short coef) - -{ - - static int max_pos_fil2 = 0; - int temp, i, aa, max_pos = 0,ind; - int max_val=0; - short Re,Im,ncoef; -#ifdef DEBUG_PHY - char fname[100],vname[100]; -#endif - - ncoef = 32768 - coef; - - for (ind=0; ind<number_of_cards; ind++) { - - if (ind==0) - max_val=0; - - - for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { - // do ifft of channel estimate - switch(frame_parms->N_RB_DL) { - case 6: - dft128((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - case 25: - dft512((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - case 50: - dft1024((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - case 100: - dft2048((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - } -#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 - } - - // we only use channel estimates from tx antenna 0 here - // remember we fixed the SRS to use only every second subcarriers - for (i = 0; i < frame_parms->ofdm_symbol_size/2; i++) { - temp = 0; - - for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { - Re = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[(i<<1)]; - Im = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[1+(i<<1)]; - temp += (Re*Re/2) + (Im*Im/2); - } - - if (temp > max_val) { - max_pos = i; - max_val = temp; - *eNB_id = ind; - } - } - } - - // filter position to reduce jitter - if (clear == 1) - max_pos_fil2 = max_pos; - else - max_pos_fil2 = ((max_pos_fil2 * coef) + (max_pos * ncoef)) >> 15; - - return(max_pos_fil2); -} - - -int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id) -{ - int temp, i, aa, max_pos=0, max_val=0; - short Re,Im; - - LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - LTE_eNB_PUSCH *eNB_pusch_vars = eNB->pusch_vars[UE_id]; - int32_t **ul_ch_estimates_time= eNB_pusch_vars->drs_ch_estimates_time; - uint8_t cyclic_shift = 0; - int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); - - AssertFatal(frame_parms->ofdm_symbol_size > 127,"frame_parms->ofdm_symbol_size %d<128\n",frame_parms->ofdm_symbol_size); - AssertFatal(frame_parms->nb_antennas_rx >0 && frame_parms->nb_antennas_rx<3,"frame_parms->nb_antennas_rx %d not in [0,1]\n", - frame_parms->nb_antennas_rx); - for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { - temp = 0; - - for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { - Re = ((int16_t*)ul_ch_estimates_time[aa])[(i<<1)]; - Im = ((int16_t*)ul_ch_estimates_time[aa])[1+(i<<1)]; - temp += (Re*Re/2) + (Im*Im/2); - } - - if (temp > max_val) { - max_pos = i; - max_val = temp; - } - } - - if (max_pos>frame_parms->ofdm_symbol_size/2) - max_pos = max_pos-frame_parms->ofdm_symbol_size; - - //#ifdef DEBUG_PHY - LOG_D(PHY,"frame %d: max_pos = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,sync_pos); - //#endif //DEBUG_PHY - - return max_pos - sync_pos; -} diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c new file mode 100644 index 0000000000000000000000000000000000000000..3bf4c40adeab61602225124d9d53d8f3ff73e851 --- /dev/null +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c @@ -0,0 +1,153 @@ +/* + * 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 "PHY/types.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" + +#include "UTIL/LOG/vcd_signal_dumper.h" + +#define DEBUG_PHY + +int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, + LTE_eNB_SRS *lte_eNB_srs, + unsigned int *eNB_id, + unsigned char clear, + unsigned char number_of_cards, + short coef) + +{ + + static int max_pos_fil2 = 0; + int temp, i, aa, max_pos = 0,ind; + int max_val=0; + short Re,Im,ncoef; +#ifdef DEBUG_PHY + char fname[100],vname[100]; +#endif + + ncoef = 32768 - coef; + + for (ind=0; ind<number_of_cards; ind++) { + + if (ind==0) + max_val=0; + + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + // do ifft of channel estimate + switch(frame_parms->N_RB_DL) { + case 6: + dft128((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + case 25: + dft512((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + case 50: + dft1024((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + case 100: + dft2048((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + } +#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 + } + + // we only use channel estimates from tx antenna 0 here + // remember we fixed the SRS to use only every second subcarriers + for (i = 0; i < frame_parms->ofdm_symbol_size/2; i++) { + temp = 0; + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[(i<<1)]; + Im = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[1+(i<<1)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + *eNB_id = ind; + } + } + } + + // filter position to reduce jitter + if (clear == 1) + max_pos_fil2 = max_pos; + else + max_pos_fil2 = ((max_pos_fil2 * coef) + (max_pos * ncoef)) >> 15; + + return(max_pos_fil2); +} + + +int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id) +{ + int temp, i, aa, max_pos=0, max_val=0; + short Re,Im; + + LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; + LTE_eNB_PUSCH *eNB_pusch_vars = eNB->pusch_vars[UE_id]; + int32_t **ul_ch_estimates_time= eNB_pusch_vars->drs_ch_estimates_time; + uint8_t cyclic_shift = 0; + int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); + + AssertFatal(frame_parms->ofdm_symbol_size > 127,"frame_parms->ofdm_symbol_size %d<128\n",frame_parms->ofdm_symbol_size); + AssertFatal(frame_parms->nb_antennas_rx >0 && frame_parms->nb_antennas_rx<3,"frame_parms->nb_antennas_rx %d not in [0,1]\n", + frame_parms->nb_antennas_rx); + for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { + temp = 0; + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)ul_ch_estimates_time[aa])[(i<<1)]; + Im = ((int16_t*)ul_ch_estimates_time[aa])[1+(i<<1)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + } + } + + if (max_pos>frame_parms->ofdm_symbol_size/2) + max_pos = max_pos-frame_parms->ofdm_symbol_size; + + //#ifdef DEBUG_PHY + LOG_D(PHY,"frame %d: max_pos = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,sync_pos); + //#endif //DEBUG_PHY + + return max_pos - sync_pos; +} + diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..06ef4a5d1a16fd68083c4f03b973ed5a215ef079 --- /dev/null +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c @@ -0,0 +1,138 @@ +/* + * 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 "PHY/types.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/impl_defs_top.h" +#include "openair2/LAYER2/MAC/mac_proto.h" + +#include "UTIL/LOG/vcd_signal_dumper.h" + +#define DEBUG_PHY + +// Adjust location synchronization point to account for drift +// The adjustment is performed once per frame based on the +// last channel estimate of the receiver + +void lte_adjust_synch(LTE_DL_FRAME_PARMS *frame_parms, + PHY_VARS_UE *ue, + unsigned char eNB_id, + uint8_t subframe, + unsigned char clear, + short coef) +{ + + static int max_pos_fil = 0; + static int count_max_pos_ok = 0; + static int first_time = 1; + int temp = 0, i, aa, max_val = 0, max_pos = 0; + int diff; + short Re,Im,ncoef; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_IN); + + ncoef = 32767 - coef; + +#ifdef DEBUG_PHY + LOG_D(PHY,"AbsSubframe %d.%d: rx_offset (before) = %d\n",ue->proc.proc_rxtx[0].frame_rx%1024,subframe,ue->rx_offset); +#endif //DEBUG_PHY + + + // we only use channel estimates from tx antenna 0 here + for (i = 0; i < frame_parms->nb_prefix_samples; i++) { + temp = 0; + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id][aa])[(i<<2)]; + Im = ((int16_t*)ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id][aa])[1+(i<<2)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + } + } + + // filter position to reduce jitter + if (clear == 1) + max_pos_fil = max_pos; + else + max_pos_fil = ((max_pos_fil * coef) + (max_pos * ncoef)) >> 15; + + // do not filter to have proactive timing adjustment + max_pos_fil = max_pos; + + if(subframe == 6) + { + diff = max_pos_fil - (frame_parms->nb_prefix_samples>>3); + + if ( abs(diff) < SYNCH_HYST ) + ue->rx_offset = 0; + else + ue->rx_offset = diff; + + if(abs(diff)<5) + count_max_pos_ok ++; + else + count_max_pos_ok = 0; + + if(count_max_pos_ok > 10 && first_time == 1) + { + first_time = 0; + ue->time_sync_cell = 1; + if (ue->mac_enabled==1) { + LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id); + //mac_resynch(); + dl_phy_sync_success(ue->Mod_id,ue->proc.proc_rxtx[0].frame_rx,0,1);//ue->common_vars.eNb_id); + ue->UE_mode[0] = PRACH; + } + else { + ue->UE_mode[0] = PUSCH; + } + } + + if ( ue->rx_offset < 0 ) + ue->rx_offset += FRAME_LENGTH_COMPLEX_SAMPLES; + + if ( ue->rx_offset >= FRAME_LENGTH_COMPLEX_SAMPLES ) + ue->rx_offset -= FRAME_LENGTH_COMPLEX_SAMPLES; + + + + #ifdef DEBUG_PHY + LOG_D(PHY,"AbsSubframe %d.%d: ThreadId %d diff =%i rx_offset (final) = %i : clear %d,max_pos = %d,max_pos_fil = %d (peak %d) max_val %d target_pos %d \n", + ue->proc.proc_rxtx[ue->current_thread_id[subframe]].frame_rx, + subframe, + ue->current_thread_id[subframe], + diff, + ue->rx_offset, + clear, + max_pos, + max_pos_fil, + temp,max_val, + (frame_parms->nb_prefix_samples>>3)); + #endif //DEBUG_PHY + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_OUT); + } +} 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 55d2cf6c5c5f2aae5eb34b045f394fdfeea08f24..8d1fb20d6b79b828130666254a629c9cd255b355 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c @@ -20,8 +20,10 @@ */ #include <string.h> -#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" +#include "lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + #include "filt16_32.h" //#define DEBUG_BF_CH diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c index a4b29bb25ec407efbbb4ec696bada4557bbd1ec1..a72563f7e6d58754111b3657ea50ec7fa7230576 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c @@ -20,12 +20,13 @@ */ #include <string.h> -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" #include "filt96_32.h" #include "T.h" //#define DEBUG_CH +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "SCHED_UE/sched_UE.h" int lte_dl_channel_estimation(PHY_VARS_UE *ue, uint8_t eNB_id, 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 17d44b22f8815442a5c10921410e685b02d64f1a..c4fc80a8c11635868e1a7d97590ff048553500ef 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c @@ -20,8 +20,9 @@ */ #include <string.h> -#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" +#include "lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_CH int lte_dl_mbsfn_channel_estimation(PHY_VARS_UE *ue, diff --git a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c index 42409cbaae6c4d9e53029483543adf79430eb14b..b416ff9e79ba3148552b8f57c1931ebfdad4b9a4 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c index cce1e06df4bce134e149558b4b64c8a4b3f95de5..ed82aeb09e36c602ee2b8d71d2db425176b19b60 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c @@ -25,7 +25,7 @@ date: 19.11.2009 */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" //#define DEBUG_PHY #if defined(__x86_64__) || defined(__i386__) diff --git a/openair1/PHY/LTE_ESTIMATION/defs.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h similarity index 99% rename from openair1/PHY/LTE_ESTIMATION/defs.h rename to openair1/PHY/LTE_ESTIMATION/lte_estimation.h index a7b5d14701874da4fb4894dca2382bfd7102708b..4512fc0d9be15bf9d52efaf1f68248725fc0d8ba 100644 --- a/openair1/PHY/LTE_ESTIMATION/defs.h +++ b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h @@ -22,7 +22,9 @@ #ifndef __LTE_ESTIMATION_DEFS__H__ #define __LTE_ESTIMATION_DEFS__H__ -#include "PHY/defs.h" + +#include "PHY/defs_UE.h" +#include "PHY/defs_eNB.h" /** @addtogroup _PHY_PARAMETER_ESTIMATION_BLOCKS_ * @{ */ diff --git a/openair1/PHY/LTE_ESTIMATION/extern.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation_extern.h similarity index 100% rename from openair1/PHY/LTE_ESTIMATION/extern.h rename to openair1/PHY/LTE_ESTIMATION/lte_estimation_extern.h diff --git a/openair1/PHY/LTE_ESTIMATION/vars.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation_vars.h similarity index 100% rename from openair1/PHY/LTE_ESTIMATION/vars.h rename to openair1/PHY/LTE_ESTIMATION/lte_estimation_vars.h diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index 21e33cf1c0ce5325168e1d06b6beaaf047ecb149..587dbed6c506f4221797cd27b83e2d7723ae60d6 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -26,19 +26,15 @@ */ //#include <string.h> -#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include <math.h> -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" -#endif -//#define DEBUG_PHY + +#include "LAYER2/MAC/mac.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" + int* sync_corr_ue0 = NULL; int* sync_corr_ue1 = NULL; @@ -487,8 +483,6 @@ int lte_sync_time(int **rxdata, ///rx data in time domain } -//#define DEBUG_PHY - int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain LTE_DL_FRAME_PARMS *frame_parms, uint32_t length, @@ -578,3 +572,6 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain } + + + diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c index d428f8e6e6d9f927da6dbc7be5a0ffd77ebbf501..fd7b8d601ab9db9811c99a7df8b6b75cd0e2a9e0 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c @@ -36,8 +36,8 @@ */ //#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #if defined(__x86_64__) || defined(__i386__) #include "pss6144.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c index ce6cd869599087d1b4a1258d4d894bc1fbaec717..199fc2d846def40512bf97215c6e43928d082cfc 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c @@ -21,10 +21,8 @@ // this function fills the PHY_vars->PHY_measurement structure -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "log.h" #include "PHY/sse_intrin.h" @@ -454,397 +452,339 @@ void ue_rrc_measurements(PHY_VARS_UE *ue, } -void lte_ue_measurements(PHY_VARS_UE *ue, - unsigned int subframe_offset, - unsigned char N0_symbol, - unsigned char abstraction_flag, - unsigned char rank_adaptation, - uint8_t subframe) +void conjch0_mult_ch1(int *ch0, + int *ch1, + int32_t *ch0conj_ch1, + unsigned short nb_rb, + unsigned char output_shift0) { + //This function is used to compute multiplications in Hhermitian * H matrix + unsigned short rb; + __m128i *dl_ch0_128,*dl_ch1_128, *ch0conj_ch1_128, mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; + dl_ch0_128 = (__m128i *)ch0; + dl_ch1_128 = (__m128i *)ch1; - int aarx,aatx,eNB_id=0; //,gain_offset=0; - //int rx_power[NUMBER_OF_CONNECTED_eNB_MAX]; - int i; - unsigned int limit,subband; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch0_128,*dl_ch1_128; -#elif defined(__arm__) - int16x8_t *dl_ch0_128, *dl_ch1_128; -#endif - int *dl_ch0,*dl_ch1; - - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int nb_subbands,subband_size,last_subband_size; - int N_RB_DL = frame_parms->N_RB_DL; + ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; + for (rb=0; rb<3*nb_rb; rb++) { - int rank_tm3_tm4; + mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]); + mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch1_128[0]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + ch0conj_ch1_128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - ue->measurements.nb_antennas_rx = frame_parms->nb_antennas_rx; +#ifdef DEBUG_RANK_EST + printf("\n Computing conjugates \n"); + print_shorts("ch0:",(int16_t*)&dl_ch0_128[0]); + print_shorts("ch1:",(int16_t*)&dl_ch1_128[0]); + print_shorts("pack:",(int16_t*)&ch0conj_ch1_128[0]); +#endif + dl_ch0_128+=1; + dl_ch1_128+=1; + ch0conj_ch1_128+=1; + } + _mm_empty(); + _m_empty(); +} - switch (N_RB_DL) { - case 6: - nb_subbands = 6; - subband_size = 12; - last_subband_size = 0; - break; +void construct_HhH_elements(int *ch0conj_ch0, //00_00 + int *ch1conj_ch1,//01_01 + int *ch2conj_ch2,//11_11 + int *ch3conj_ch3,//10_10 + int *ch0conj_ch1,//00_01 + int *ch1conj_ch0,//01_00 + int *ch2conj_ch3,//10_11 + int *ch3conj_ch2,//11_10 + int32_t *after_mf_00, + int32_t *after_mf_01, + int32_t *after_mf_10, + int32_t *after_mf_11, + unsigned short nb_rb) +{ + unsigned short rb; + __m128i *ch0conj_ch0_128, *ch1conj_ch1_128, *ch2conj_ch2_128, *ch3conj_ch3_128; + __m128i *ch0conj_ch1_128, *ch1conj_ch0_128, *ch2conj_ch3_128, *ch3conj_ch2_128; + __m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128; - default: - case 25: - nb_subbands = 7; - subband_size = 4*12; - last_subband_size = 12; - break; + ch0conj_ch0_128 = (__m128i *)ch0conj_ch0; + ch1conj_ch1_128 = (__m128i *)ch1conj_ch1; + ch2conj_ch2_128 = (__m128i *)ch2conj_ch2; + ch3conj_ch3_128 = (__m128i *)ch3conj_ch3; + ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; + ch1conj_ch0_128 = (__m128i *)ch1conj_ch0; + ch2conj_ch3_128 = (__m128i *)ch2conj_ch3; + ch3conj_ch2_128 = (__m128i *)ch3conj_ch2; + after_mf_00_128 = (__m128i *)after_mf_00; + after_mf_01_128 = (__m128i *)after_mf_01; + after_mf_10_128 = (__m128i *)after_mf_10; + after_mf_11_128 = (__m128i *)after_mf_11; - case 50: - nb_subbands = 9; - subband_size = 6*12; - last_subband_size = 2*12; - break; + for (rb=0; rb<3*nb_rb; rb++) { - case 100: - nb_subbands = 13; - subband_size = 8*12; - last_subband_size = 4*12; - break; - } + after_mf_00_128[0] =_mm_adds_epi16(ch0conj_ch0_128[0],ch3conj_ch3_128[0]);// _mm_adds_epi32(ch0conj_ch0_128[0], ch3conj_ch3_128[0]); //00_00 + 10_10 + after_mf_11_128[0] =_mm_adds_epi16(ch1conj_ch1_128[0], ch2conj_ch2_128[0]); //01_01 + 11_11 + after_mf_01_128[0] =_mm_adds_epi16(ch0conj_ch1_128[0], ch2conj_ch3_128[0]);//00_01 + 10_11 + after_mf_10_128[0] =_mm_adds_epi16(ch1conj_ch0_128[0], ch3conj_ch2_128[0]);//01_00 + 11_10 - // signal measurements - for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) { - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { - ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = - (signal_energy_nodc(&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][(aatx<<1) + aarx][0], - (N_RB_DL*12))); - //- ue->measurements.n0_power[aarx]; +#ifdef DEBUG_RANK_EST + printf(" \n construct_HhH_elements \n"); + print_shorts("ch0conj_ch0_128:",(int16_t*)&ch0conj_ch0_128[0]); + print_shorts("ch1conj_ch1_128:",(int16_t*)&ch1conj_ch1_128[0]); + print_shorts("ch2conj_ch2_128:",(int16_t*)&ch2conj_ch2_128[0]); + print_shorts("ch3conj_ch3_128:",(int16_t*)&ch3conj_ch3_128[0]); + print_shorts("ch0conj_ch1_128:",(int16_t*)&ch0conj_ch1_128[0]); + print_shorts("ch1conj_ch0_128:",(int16_t*)&ch1conj_ch0_128[0]); + print_shorts("ch2conj_ch3_128:",(int16_t*)&ch2conj_ch3_128[0]); + print_shorts("ch3conj_ch2_128:",(int16_t*)&ch3conj_ch2_128[0]); + print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]); + print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]); + print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]); + print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]); +#endif - if (ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]<0) - ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = 0; //ue->measurements.n0_power[aarx]; + ch0conj_ch0_128+=1; + ch1conj_ch1_128+=1; + ch2conj_ch2_128+=1; + ch3conj_ch3_128+=1; + ch0conj_ch1_128+=1; + ch1conj_ch0_128+=1; + ch2conj_ch3_128+=1; + ch3conj_ch2_128+=1; - ue->measurements.rx_spatial_power_dB[eNB_id][aatx][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]); + after_mf_00_128+=1; + after_mf_01_128+=1; + after_mf_10_128+=1; + after_mf_11_128+=1; + } + _mm_empty(); + _m_empty(); +} - if (aatx==0) - ue->measurements.rx_power[eNB_id][aarx] = ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; - else - ue->measurements.rx_power[eNB_id][aarx] += ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; - } //aatx - ue->measurements.rx_power_dB[eNB_id][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_power[eNB_id][aarx]); +void squared_matrix_element(int32_t *Hh_h_00, + int32_t *Hh_h_00_sq, + unsigned short nb_rb) +{ + unsigned short rb; + __m128i *Hh_h_00_128,*Hh_h_00_sq_128; - if (aarx==0) - ue->measurements.rx_power_tot[eNB_id] = ue->measurements.rx_power[eNB_id][aarx]; - else - ue->measurements.rx_power_tot[eNB_id] += ue->measurements.rx_power[eNB_id][aarx]; - } //aarx + Hh_h_00_128 = (__m128i *)Hh_h_00; + Hh_h_00_sq_128 = (__m128i *)Hh_h_00_sq; - ue->measurements.rx_power_tot_dB[eNB_id] = (unsigned short) dB_fixed(ue->measurements.rx_power_tot[eNB_id]); + for (rb=0; rb<3*nb_rb; rb++) { - } //eNB_id + Hh_h_00_sq_128[0] = _mm_madd_epi16(Hh_h_00_128[0],Hh_h_00_128[0]); - eNB_id=0; - if (ue->transmission_mode[0]==4 || ue->transmission_mode[0]==3){ - if (rank_adaptation == 1) - rank_tm3_tm4 = rank_estimation_tm3_tm4(&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][0][4], - &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][2][4], - &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][1][4], - &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][3][4], - N_RB_DL); - else - rank_tm3_tm4=1; #ifdef DEBUG_RANK_EST - printf("rank tm3 or tm4 %d\n", rank_tm3_tm4); + printf("\n Computing squared_matrix_element \n"); + print_shorts("Hh_h_00_128:",(int16_t*)&Hh_h_00_128[0]); + print_ints("Hh_h_00_sq_128:",(int32_t*)&Hh_h_00_sq_128[0]); #endif + + Hh_h_00_sq_128+=1; + Hh_h_00_128+=1; } + _mm_empty(); + _m_empty(); +} - if (ue->transmission_mode[eNB_id]!=4 && ue->transmission_mode[eNB_id]!=3) - ue->measurements.rank[eNB_id] = 0; - else - ue->measurements.rank[eNB_id] = rank_tm3_tm4; - // printf ("tx mode %d\n", ue->transmission_mode[eNB_id]); - // printf ("rank %d\n", ue->PHY_measurements.rank[eNB_id]); - // filter to remove jitter - if (ue->init_averaging == 0) { - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) - ue->measurements.rx_power_avg[eNB_id] = (int) - (((k1*((long long int)(ue->measurements.rx_power_avg[eNB_id]))) + - (k2*((long long int)(ue->measurements.rx_power_tot[eNB_id]))))>>10); - //LOG_I(PHY,"Noise Power Computation: k1 %d k2 %d n0 avg %d n0 tot %d\n", k1, k2, ue->measurements.n0_power_avg, - // ue->measurements.n0_power_tot); - ue->measurements.n0_power_avg = (int) - (((k1*((long long int) (ue->measurements.n0_power_avg))) + - (k2*((long long int) (ue->measurements.n0_power_tot))))>>10); - } else { - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) - ue->measurements.rx_power_avg[eNB_id] = ue->measurements.rx_power_tot[eNB_id]; +void det_HhH(int32_t *after_mf_00, + int32_t *after_mf_01, + int32_t *after_mf_10, + int32_t *after_mf_11, + int32_t *det_fin, + unsigned short nb_rb) - ue->measurements.n0_power_avg = ue->measurements.n0_power_tot; - ue->init_averaging = 0; - } +{ + unsigned short rb; + __m128i *after_mf_00_128,*after_mf_01_128, *after_mf_10_128, *after_mf_11_128, ad_re_128, bc_re_128; + __m128i *det_fin_128, det_128; - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { - ue->measurements.rx_power_avg_dB[eNB_id] = dB_fixed( ue->measurements.rx_power_avg[eNB_id]); - ue->measurements.wideband_cqi_tot[eNB_id] = dB_fixed2(ue->measurements.rx_power_tot[eNB_id],ue->measurements.n0_power_tot); - ue->measurements.wideband_cqi_avg[eNB_id] = dB_fixed2(ue->measurements.rx_power_avg[eNB_id],ue->measurements.n0_power_avg); - ue->measurements.rx_rssi_dBm[eNB_id] = ue->measurements.rx_power_avg_dB[eNB_id] - ue->rx_total_gain_dB; -#ifdef DEBUG_MEAS_UE - LOG_I(PHY,"[eNB %d] Subframe %d, RSSI %d dBm, RSSI (digital) %d dB, WBandCQI %d dB, rxPwrAvg %d, n0PwrAvg %d\n", - eNB_id, - subframe, - ue->measurements.rx_rssi_dBm[eNB_id], - ue->measurements.rx_power_avg_dB[eNB_id], - ue->measurements.wideband_cqi_avg[eNB_id], - ue->measurements.rx_power_avg[eNB_id], - ue->measurements.n0_power_tot); -#endif - } + after_mf_00_128 = (__m128i *)after_mf_00; + after_mf_01_128 = (__m128i *)after_mf_01; + after_mf_10_128 = (__m128i *)after_mf_10; + after_mf_11_128 = (__m128i *)after_mf_11; - ue->measurements.n0_power_avg_dB = dB_fixed( ue->measurements.n0_power_avg); + det_fin_128 = (__m128i *)det_fin; - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { - if (frame_parms->nb_antenna_ports_eNB!=1) { - // cqi/pmi information + for (rb=0; rb<3*nb_rb; rb++) { - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - dl_ch1 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; + ad_re_128 = _mm_madd_epi16(after_mf_00_128[0],after_mf_11_128[0]); + bc_re_128 = _mm_madd_epi16(after_mf_01_128[0],after_mf_01_128[0]); + det_128 = _mm_sub_epi32(ad_re_128, bc_re_128); + det_fin_128[0] = _mm_abs_epi32(det_128); - for (subband=0; subband<nb_subbands; subband++) { +#ifdef DEBUG_RANK_EST + printf("\n Computing denominator \n"); + print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]); + print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]); + print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]); + print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]); + print_ints("ad_re_128:",(int32_t*)&ad_re_128); + print_ints("bc_re_128:",(int32_t*)&bc_re_128); + print_ints("det_fin_128:",(int32_t*)&det_fin_128[0]); +#endif - // cqi - if (aarx==0) - ue->measurements.subband_cqi_tot[eNB_id][subband]=0; + det_fin_128+=1; + after_mf_00_128+=1; + after_mf_01_128+=1; + after_mf_10_128+=1; + after_mf_11_128+=1; + } + _mm_empty(); + _m_empty(); +} - if ((subband<(nb_subbands-1))||(N_RB_DL==6)) { - /*for (i=0;i<48;i++) - msg("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - */ - ue->measurements.subband_cqi[eNB_id][aarx][subband] = - (signal_energy_nodc(dl_ch0,subband_size) + signal_energy_nodc(dl_ch1,subband_size)); +void numer(int32_t *Hh_h_00_sq, + int32_t *Hh_h_01_sq, + int32_t *Hh_h_10_sq, + int32_t *Hh_h_11_sq, + int32_t *num_fin, + unsigned short nb_rb) - if ( ue->measurements.subband_cqi[eNB_id][aarx][subband] < 0) - ue->measurements.subband_cqi[eNB_id][aarx][subband]=0; +{ + unsigned short rb; + __m128i *h_h_00_sq_128, *h_h_01_sq_128, *h_h_10_sq_128, *h_h_11_sq_128; + __m128i *num_fin_128, sq_a_plus_sq_d_128, sq_b_plus_sq_c_128; - /* - else - ue->measurements.subband_cqi[eNB_id][aarx][subband]-=ue->measurements.n0_power[aarx]; - */ + h_h_00_sq_128 = (__m128i *)Hh_h_00_sq; + h_h_01_sq_128 = (__m128i *)Hh_h_01_sq; + h_h_10_sq_128 = (__m128i *)Hh_h_10_sq; + h_h_11_sq_128 = (__m128i *)Hh_h_11_sq; - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } else { // this is for the last subband which is smaller in size - // for (i=0;i<12;i++) - // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,last_subband_size) + - signal_energy_nodc(dl_ch1,last_subband_size)); // - ue->measurements.n0_power[aarx]; - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } + num_fin_128 = (__m128i *)num_fin; - dl_ch1+=subband_size; - dl_ch0+=subband_size; - // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); - } + for (rb=0; rb<3*nb_rb; rb++) { - } + sq_a_plus_sq_d_128 = _mm_add_epi32(h_h_00_sq_128[0],h_h_11_sq_128[0]); + sq_b_plus_sq_c_128 = _mm_add_epi32(h_h_01_sq_128[0],h_h_10_sq_128[0]); + num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128); - for (subband=0; subband<nb_subbands; subband++) { - ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); - // msg("subband_cqi_tot[%d][%d] => %d dB (n0 %d)\n",eNB_id,subband,ue->measurements.subband_cqi_tot_dB[eNB_id][subband],ue->measurements.n0_power_tot); - } +#ifdef DEBUG_RANK_EST + printf("\n Computing numerator \n"); + print_ints("h_h_00_sq_128:",(int32_t*)&h_h_00_sq_128[0]); + print_ints("h_h_01_sq_128:",(int32_t*)&h_h_01_sq_128[0]); + print_ints("h_h_10_sq_128:",(int32_t*)&h_h_10_sq_128[0]); + print_ints("h_h_11_sq_128:",(int32_t*)&h_h_11_sq_128[0]); + print_shorts("sq_a_plus_sq_d_128:",(int16_t*)&sq_a_plus_sq_d_128); + print_shorts("sq_b_plus_sq_c_128:",(int16_t*)&sq_b_plus_sq_c_128); + print_shorts("num_fin_128:",(int16_t*)&num_fin_128[0]); +#endif - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - //printf("aarx=%d", aarx); - // skip the first 4 RE due to interpolation filter length of 5 (not possible to skip 5 due to 128i alignment, must be multiple of 128bit) + num_fin_128+=1; + h_h_00_sq_128+=1; + h_h_01_sq_128+=1; + h_h_10_sq_128+=1; + h_h_11_sq_128+=1; + } + _mm_empty(); + _m_empty(); +} -#if defined(__x86_64__) || defined(__i386__) - __m128i pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1 /* ,mmtmpPMI2,mmtmpPMI3 */ ; +void dlsch_channel_level_TM34_meas(int *ch00, + int *ch01, + int *ch10, + int *ch11, + int *avg_0, + int *avg_1, + unsigned short nb_rb) +{ - dl_ch0_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - dl_ch1_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; -#elif defined(__arm__) - int32x4_t pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1,mmtmpPMI0b,mmtmpPMI1b; +#if defined(__x86_64__)||defined(__i386__) - dl_ch0_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - dl_ch1_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; + short rb; + unsigned char nre=12; + __m128i *ch00_128, *ch01_128, *ch10_128, *ch11_128; + __m128i avg_0_row0_128D, avg_1_row0_128D, avg_0_row1_128D, avg_1_row1_128D; + __m128i ch00_128_tmp, ch01_128_tmp, ch10_128_tmp, ch11_128_tmp; -#endif - for (subband=0; subband<nb_subbands; subband++) { + avg_0[0] = 0; + avg_0[1] = 0; + avg_1[0] = 0; + avg_1[1] = 0; + ch00_128 = (__m128i *)ch00; + ch01_128 = (__m128i *)ch01; + ch10_128 = (__m128i *)ch10; + ch11_128 = (__m128i *)ch11; - // pmi -#if defined(__x86_64__) || defined(__i386__) + avg_0_row0_128D = _mm_setzero_si128(); + avg_1_row0_128D = _mm_setzero_si128(); + avg_0_row1_128D = _mm_setzero_si128(); + avg_1_row1_128D = _mm_setzero_si128(); - pmi128_re = _mm_xor_si128(pmi128_re,pmi128_re); - pmi128_im = _mm_xor_si128(pmi128_im,pmi128_im); -#elif defined(__arm__) + for (rb=0; rb<3*nb_rb; rb++) { + ch00_128_tmp = _mm_load_si128(&ch00_128[0]); + ch01_128_tmp = _mm_load_si128(&ch01_128[0]); + ch10_128_tmp = _mm_load_si128(&ch10_128[0]); + ch11_128_tmp = _mm_load_si128(&ch11_128[0]); - pmi128_re = vdupq_n_s32(0); - pmi128_im = vdupq_n_s32(0); -#endif - // limit is the number of groups of 4 REs in a subband (12 = 4 RBs, 3 = 1 RB) - // for 5 MHz channelization, there are 7 subbands, 6 of size 4 RBs and 1 of size 1 RB - if ((N_RB_DL==6) || (subband<(nb_subbands-1))) - limit = subband_size>>2; - else - limit = last_subband_size>>2; + avg_0_row0_128D = _mm_add_epi32(avg_0_row0_128D,_mm_madd_epi16(ch00_128_tmp,ch00_128_tmp)); + avg_1_row0_128D = _mm_add_epi32(avg_1_row0_128D,_mm_madd_epi16(ch01_128_tmp,ch01_128_tmp)); + avg_0_row1_128D = _mm_add_epi32(avg_0_row1_128D,_mm_madd_epi16(ch10_128_tmp,ch10_128_tmp)); + avg_1_row1_128D = _mm_add_epi32(avg_1_row1_128D,_mm_madd_epi16(ch11_128_tmp,ch11_128_tmp)); - for (i=0; i<limit; i++) { + ch00_128+=1; + ch01_128+=1; + ch10_128+=1; + ch11_128+=1; + } -#if defined(__x86_64__) || defined(__i386__) - mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); - mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); + avg_0[0] = (((int*)&avg_0_row0_128D)[0])/(nb_rb*nre) + + (((int*)&avg_0_row0_128D)[1])/(nb_rb*nre) + + (((int*)&avg_0_row0_128D)[2])/(nb_rb*nre) + + (((int*)&avg_0_row0_128D)[3])/(nb_rb*nre); - // For each RE in subband perform ch0 * conj(ch1) - // multiply by conjugated channel - // print_ints("ch0",&dl_ch0_128[0]); - // print_ints("ch1",&dl_ch1_128[0]); + avg_1[0] = (((int*)&avg_1_row0_128D)[0])/(nb_rb*nre) + + (((int*)&avg_1_row0_128D)[1])/(nb_rb*nre) + + (((int*)&avg_1_row0_128D)[2])/(nb_rb*nre) + + (((int*)&avg_1_row0_128D)[3])/(nb_rb*nre); - mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]); - // print_ints("re",&mmtmpPMI0); - mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[0],_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate[0]); - // print_ints("_mm_sign_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[0]); - // print_ints("mm_madd_epi16",&mmtmpPMI1); - // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) - pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); - // print_ints(" pmi128_re 0",&pmi128_re); - pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); - // print_ints(" pmi128_im 0 ",&pmi128_im); + avg_0[1] = (((int*)&avg_0_row1_128D)[0])/(nb_rb*nre) + + (((int*)&avg_0_row1_128D)[1])/(nb_rb*nre) + + (((int*)&avg_0_row1_128D)[2])/(nb_rb*nre) + + (((int*)&avg_0_row1_128D)[3])/(nb_rb*nre); - /* mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); - mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); + avg_1[1] = (((int*)&avg_1_row1_128D)[0])/(nb_rb*nre) + + (((int*)&avg_1_row1_128D)[1])/(nb_rb*nre) + + (((int*)&avg_1_row1_128D)[2])/(nb_rb*nre) + + (((int*)&avg_1_row1_128D)[3])/(nb_rb*nre); - mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[1],dl_ch1_128[1]); - // print_ints("re",&mmtmpPMI0); - mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[1],_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate); - // print_ints("_mm_sign_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[1]); - // print_ints("mm_madd_epi16",&mmtmpPMI1); - // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) - pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); - // print_ints(" pmi128_re 1",&pmi128_re); - pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); - //print_ints(" pmi128_im 1 ",&pmi128_im);*/ + avg_0[0] = avg_0[0] + avg_0[1]; + avg_1[0] = avg_1[0] + avg_1[1]; + avg_0[0] = min (avg_0[0], avg_1[0]); + avg_1[0] = avg_0[0]; + + _mm_empty(); + _m_empty(); #elif defined(__arm__) - mmtmpPMI0 = vmull_s16(((int16x4_t*)dl_ch0_128)[0], ((int16x4_t*)dl_ch1_128)[0]); - mmtmpPMI1 = vmull_s16(((int16x4_t*)dl_ch0_128)[1], ((int16x4_t*)dl_ch1_128)[1]); - pmi128_re = vqaddq_s32(pmi128_re,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0),vget_high_s32(mmtmpPMI0)),vpadd_s32(vget_low_s32(mmtmpPMI1),vget_high_s32(mmtmpPMI1)))); +#endif +} - mmtmpPMI0b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[0],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[0]); - mmtmpPMI1b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[1],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[1]); - pmi128_im = vqaddq_s32(pmi128_im,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0b),vget_high_s32(mmtmpPMI0b)),vpadd_s32(vget_low_s32(mmtmpPMI1b),vget_high_s32(mmtmpPMI1b)))); +uint8_t rank_estimation_tm3_tm4 (int *dl_ch_estimates_00, // please respect the order of channel estimates + int *dl_ch_estimates_01, + int *dl_ch_estimates_10, + int *dl_ch_estimates_11, + unsigned short nb_rb) +{ -#endif - dl_ch0_128++; - dl_ch1_128++; - } - - ue->measurements.subband_pmi_re[eNB_id][subband][aarx] = (((int *)&pmi128_re)[0] + ((int *)&pmi128_re)[1] + ((int *)&pmi128_re)[2] + ((int *)&pmi128_re)[3])>>2; - ue->measurements.subband_pmi_im[eNB_id][subband][aarx] = (((int *)&pmi128_im)[0] + ((int *)&pmi128_im)[1] + ((int *)&pmi128_im)[2] + ((int *)&pmi128_im)[3])>>2; - ue->measurements.wideband_pmi_re[eNB_id][aarx] += ue->measurements.subband_pmi_re[eNB_id][subband][aarx]; - ue->measurements.wideband_pmi_im[eNB_id][aarx] += ue->measurements.subband_pmi_im[eNB_id][subband][aarx]; - } // subband loop - } // rx antenna loop - } // if frame_parms->mode1_flag == 0 - else { - // cqi information only for mode 1 - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - - for (subband=0; subband<7; subband++) { - - // cqi - if (aarx==0) - ue->measurements.subband_cqi_tot[eNB_id][subband]=0; - - if (subband<6) { - // for (i=0;i<48;i++) - // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = - (signal_energy_nodc(dl_ch0,48) ) - ue->measurements.n0_power[aarx]; - - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } else { - // for (i=0;i<12;i++) - // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,12) ) - ue->measurements.n0_power[aarx]; - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } - - dl_ch1+=48; - // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); - } - } - - for (subband=0; subband<nb_subbands; subband++) { - ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); - } - } - - //ue->measurements.rank[eNB_id] = 0; - - for (i=0; i<nb_subbands; i++) { - ue->measurements.selected_rx_antennas[eNB_id][i] = 0; - - if (frame_parms->nb_antennas_rx>1) { - if (ue->measurements.subband_cqi_dB[eNB_id][0][i] >= ue->measurements.subband_cqi_dB[eNB_id][1][i]) - ue->measurements.selected_rx_antennas[eNB_id][i] = 0; - else - ue->measurements.selected_rx_antennas[eNB_id][i] = 1; - } else - ue->measurements.selected_rx_antennas[eNB_id][i] = 0; - } - - // if(eNB_id==0) - // printf("in lte_ue_measurements: selected rx_antenna[eNB_id==0]:%u\n", ue->measurements.selected_rx_antennas[eNB_id][i]); - } // eNB_id loop - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - - -void lte_ue_measurements_emul(PHY_VARS_UE *ue,uint8_t subframe,uint8_t eNB_id) -{ - - LOG_D(PHY,"EMUL UE lte_ue_measurements_emul subframe %d, eNB_id %d\n",subframe,eNB_id); -} - - -uint8_t rank_estimation_tm3_tm4 (int *dl_ch_estimates_00, // please respect the order of channel estimates - int *dl_ch_estimates_01, - int *dl_ch_estimates_10, - int *dl_ch_estimates_11, - unsigned short nb_rb) -{ - - int i=0; - int rank=0; - int N_RB=nb_rb; - int *ch00_rank, *ch01_rank, *ch10_rank, *ch11_rank; + int i=0; + int rank=0; + int N_RB=nb_rb; + int *ch00_rank, *ch01_rank, *ch10_rank, *ch11_rank; int32_t shift; int avg_0[2]; @@ -1058,328 +998,390 @@ uint8_t rank_estimation_tm3_tm4 (int *dl_ch_estimates_00, // please respect the return(rank); } -void conjch0_mult_ch1(int *ch0, - int *ch1, - int32_t *ch0conj_ch1, - unsigned short nb_rb, - unsigned char output_shift0) -{ - //This function is used to compute multiplications in Hhermitian * H matrix - unsigned short rb; - __m128i *dl_ch0_128,*dl_ch1_128, *ch0conj_ch1_128, mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3; - dl_ch0_128 = (__m128i *)ch0; - dl_ch1_128 = (__m128i *)ch1; - ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; - for (rb=0; rb<3*nb_rb; rb++) { - mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]); - mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch1_128[0]); - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - ch0conj_ch1_128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); -#ifdef DEBUG_RANK_EST - printf("\n Computing conjugates \n"); - print_shorts("ch0:",(int16_t*)&dl_ch0_128[0]); - print_shorts("ch1:",(int16_t*)&dl_ch1_128[0]); - print_shorts("pack:",(int16_t*)&ch0conj_ch1_128[0]); +void lte_ue_measurements(PHY_VARS_UE *ue, + unsigned int subframe_offset, + unsigned char N0_symbol, + unsigned char abstraction_flag, + unsigned char rank_adaptation, + uint8_t subframe) +{ + + + int aarx,aatx,eNB_id=0; //,gain_offset=0; + //int rx_power[NUMBER_OF_CONNECTED_eNB_MAX]; + int i; + unsigned int limit,subband; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch0_128,*dl_ch1_128; +#elif defined(__arm__) + int16x8_t *dl_ch0_128, *dl_ch1_128; #endif + int *dl_ch0,*dl_ch1; - dl_ch0_128+=1; - dl_ch1_128+=1; - ch0conj_ch1_128+=1; - } - _mm_empty(); - _m_empty(); -} + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int nb_subbands,subband_size,last_subband_size; + int N_RB_DL = frame_parms->N_RB_DL; -void construct_HhH_elements(int *ch0conj_ch0, //00_00 - int *ch1conj_ch1,//01_01 - int *ch2conj_ch2,//11_11 - int *ch3conj_ch3,//10_10 - int *ch0conj_ch1,//00_01 - int *ch1conj_ch0,//01_00 - int *ch2conj_ch3,//10_11 - int *ch3conj_ch2,//11_10 - int32_t *after_mf_00, - int32_t *after_mf_01, - int32_t *after_mf_10, - int32_t *after_mf_11, - unsigned short nb_rb) -{ - unsigned short rb; - __m128i *ch0conj_ch0_128, *ch1conj_ch1_128, *ch2conj_ch2_128, *ch3conj_ch3_128; - __m128i *ch0conj_ch1_128, *ch1conj_ch0_128, *ch2conj_ch3_128, *ch3conj_ch2_128; - __m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128; - ch0conj_ch0_128 = (__m128i *)ch0conj_ch0; - ch1conj_ch1_128 = (__m128i *)ch1conj_ch1; - ch2conj_ch2_128 = (__m128i *)ch2conj_ch2; - ch3conj_ch3_128 = (__m128i *)ch3conj_ch3; - ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; - ch1conj_ch0_128 = (__m128i *)ch1conj_ch0; - ch2conj_ch3_128 = (__m128i *)ch2conj_ch3; - ch3conj_ch2_128 = (__m128i *)ch3conj_ch2; - after_mf_00_128 = (__m128i *)after_mf_00; - after_mf_01_128 = (__m128i *)after_mf_01; - after_mf_10_128 = (__m128i *)after_mf_10; - after_mf_11_128 = (__m128i *)after_mf_11; + int rank_tm3_tm4; - for (rb=0; rb<3*nb_rb; rb++) { - after_mf_00_128[0] =_mm_adds_epi16(ch0conj_ch0_128[0],ch3conj_ch3_128[0]);// _mm_adds_epi32(ch0conj_ch0_128[0], ch3conj_ch3_128[0]); //00_00 + 10_10 - after_mf_11_128[0] =_mm_adds_epi16(ch1conj_ch1_128[0], ch2conj_ch2_128[0]); //01_01 + 11_11 - after_mf_01_128[0] =_mm_adds_epi16(ch0conj_ch1_128[0], ch2conj_ch3_128[0]);//00_01 + 10_11 - after_mf_10_128[0] =_mm_adds_epi16(ch1conj_ch0_128[0], ch3conj_ch2_128[0]);//01_00 + 11_10 + ue->measurements.nb_antennas_rx = frame_parms->nb_antennas_rx; -#ifdef DEBUG_RANK_EST - printf(" \n construct_HhH_elements \n"); - print_shorts("ch0conj_ch0_128:",(int16_t*)&ch0conj_ch0_128[0]); - print_shorts("ch1conj_ch1_128:",(int16_t*)&ch1conj_ch1_128[0]); - print_shorts("ch2conj_ch2_128:",(int16_t*)&ch2conj_ch2_128[0]); - print_shorts("ch3conj_ch3_128:",(int16_t*)&ch3conj_ch3_128[0]); - print_shorts("ch0conj_ch1_128:",(int16_t*)&ch0conj_ch1_128[0]); - print_shorts("ch1conj_ch0_128:",(int16_t*)&ch1conj_ch0_128[0]); - print_shorts("ch2conj_ch3_128:",(int16_t*)&ch2conj_ch3_128[0]); - print_shorts("ch3conj_ch2_128:",(int16_t*)&ch3conj_ch2_128[0]); - print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]); - print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]); - print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]); - print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]); -#endif - ch0conj_ch0_128+=1; - ch1conj_ch1_128+=1; - ch2conj_ch2_128+=1; - ch3conj_ch3_128+=1; - ch0conj_ch1_128+=1; - ch1conj_ch0_128+=1; - ch2conj_ch3_128+=1; - ch3conj_ch2_128+=1; + switch (N_RB_DL) { + case 6: + nb_subbands = 6; + subband_size = 12; + last_subband_size = 0; + break; - after_mf_00_128+=1; - after_mf_01_128+=1; - after_mf_10_128+=1; - after_mf_11_128+=1; + default: + case 25: + nb_subbands = 7; + subband_size = 4*12; + last_subband_size = 12; + break; + + case 50: + nb_subbands = 9; + subband_size = 6*12; + last_subband_size = 2*12; + break; + + case 100: + nb_subbands = 13; + subband_size = 8*12; + last_subband_size = 4*12; + break; } - _mm_empty(); - _m_empty(); -} + // signal measurements + for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) { + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { + ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = + (signal_energy_nodc(&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][(aatx<<1) + aarx][0], + (N_RB_DL*12))); + //- ue->measurements.n0_power[aarx]; -void squared_matrix_element(int32_t *Hh_h_00, - int32_t *Hh_h_00_sq, - unsigned short nb_rb) -{ - unsigned short rb; - __m128i *Hh_h_00_128,*Hh_h_00_sq_128; + if (ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]<0) + ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = 0; //ue->measurements.n0_power[aarx]; - Hh_h_00_128 = (__m128i *)Hh_h_00; - Hh_h_00_sq_128 = (__m128i *)Hh_h_00_sq; + ue->measurements.rx_spatial_power_dB[eNB_id][aatx][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]); - for (rb=0; rb<3*nb_rb; rb++) { + if (aatx==0) + ue->measurements.rx_power[eNB_id][aarx] = ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; + else + ue->measurements.rx_power[eNB_id][aarx] += ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; + } //aatx - Hh_h_00_sq_128[0] = _mm_madd_epi16(Hh_h_00_128[0],Hh_h_00_128[0]); + ue->measurements.rx_power_dB[eNB_id][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_power[eNB_id][aarx]); + + if (aarx==0) + ue->measurements.rx_power_tot[eNB_id] = ue->measurements.rx_power[eNB_id][aarx]; + else + ue->measurements.rx_power_tot[eNB_id] += ue->measurements.rx_power[eNB_id][aarx]; + } //aarx + + ue->measurements.rx_power_tot_dB[eNB_id] = (unsigned short) dB_fixed(ue->measurements.rx_power_tot[eNB_id]); + } //eNB_id + + eNB_id=0; + if (ue->transmission_mode[0]==4 || ue->transmission_mode[0]==3){ + if (rank_adaptation == 1) + rank_tm3_tm4 = rank_estimation_tm3_tm4(&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][0][4], + &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][2][4], + &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][1][4], + &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][3][4], + N_RB_DL); + else + rank_tm3_tm4=1; #ifdef DEBUG_RANK_EST - printf("\n Computing squared_matrix_element \n"); - print_shorts("Hh_h_00_128:",(int16_t*)&Hh_h_00_128[0]); - print_ints("Hh_h_00_sq_128:",(int32_t*)&Hh_h_00_sq_128[0]); + printf("rank tm3 or tm4 %d\n", rank_tm3_tm4); #endif + } - Hh_h_00_sq_128+=1; - Hh_h_00_128+=1; + if (ue->transmission_mode[eNB_id]!=4 && ue->transmission_mode[eNB_id]!=3) + ue->measurements.rank[eNB_id] = 0; + else + ue->measurements.rank[eNB_id] = rank_tm3_tm4; + // printf ("tx mode %d\n", ue->transmission_mode[eNB_id]); + // printf ("rank %d\n", ue->PHY_measurements.rank[eNB_id]); + + // filter to remove jitter + if (ue->init_averaging == 0) { + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) + ue->measurements.rx_power_avg[eNB_id] = (int) + (((k1*((long long int)(ue->measurements.rx_power_avg[eNB_id]))) + + (k2*((long long int)(ue->measurements.rx_power_tot[eNB_id]))))>>10); + + //LOG_I(PHY,"Noise Power Computation: k1 %d k2 %d n0 avg %d n0 tot %d\n", k1, k2, ue->measurements.n0_power_avg, + // ue->measurements.n0_power_tot); + ue->measurements.n0_power_avg = (int) + (((k1*((long long int) (ue->measurements.n0_power_avg))) + + (k2*((long long int) (ue->measurements.n0_power_tot))))>>10); + } else { + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) + ue->measurements.rx_power_avg[eNB_id] = ue->measurements.rx_power_tot[eNB_id]; + + ue->measurements.n0_power_avg = ue->measurements.n0_power_tot; + ue->init_averaging = 0; } - _mm_empty(); - _m_empty(); -} + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { + ue->measurements.rx_power_avg_dB[eNB_id] = dB_fixed( ue->measurements.rx_power_avg[eNB_id]); + ue->measurements.wideband_cqi_tot[eNB_id] = dB_fixed2(ue->measurements.rx_power_tot[eNB_id],ue->measurements.n0_power_tot); + ue->measurements.wideband_cqi_avg[eNB_id] = dB_fixed2(ue->measurements.rx_power_avg[eNB_id],ue->measurements.n0_power_avg); + ue->measurements.rx_rssi_dBm[eNB_id] = ue->measurements.rx_power_avg_dB[eNB_id] - ue->rx_total_gain_dB; +#ifdef DEBUG_MEAS_UE + LOG_I(PHY,"[eNB %d] Subframe %d, RSSI %d dBm, RSSI (digital) %d dB, WBandCQI %d dB, rxPwrAvg %d, n0PwrAvg %d\n", + eNB_id, + subframe, + ue->measurements.rx_rssi_dBm[eNB_id], + ue->measurements.rx_power_avg_dB[eNB_id], + ue->measurements.wideband_cqi_avg[eNB_id], + ue->measurements.rx_power_avg[eNB_id], + ue->measurements.n0_power_tot); +#endif + } + ue->measurements.n0_power_avg_dB = dB_fixed( ue->measurements.n0_power_avg); -void det_HhH(int32_t *after_mf_00, - int32_t *after_mf_01, - int32_t *after_mf_10, - int32_t *after_mf_11, - int32_t *det_fin, - unsigned short nb_rb) + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { + if (frame_parms->nb_antenna_ports_eNB!=1) { + // cqi/pmi information -{ - unsigned short rb; - __m128i *after_mf_00_128,*after_mf_01_128, *after_mf_10_128, *after_mf_11_128, ad_re_128, bc_re_128; - __m128i *det_fin_128, det_128; + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; + dl_ch1 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; - after_mf_00_128 = (__m128i *)after_mf_00; - after_mf_01_128 = (__m128i *)after_mf_01; - after_mf_10_128 = (__m128i *)after_mf_10; - after_mf_11_128 = (__m128i *)after_mf_11; + for (subband=0; subband<nb_subbands; subband++) { - det_fin_128 = (__m128i *)det_fin; + // cqi + if (aarx==0) + ue->measurements.subband_cqi_tot[eNB_id][subband]=0; - for (rb=0; rb<3*nb_rb; rb++) { + if ((subband<(nb_subbands-1))||(N_RB_DL==6)) { + /*for (i=0;i<48;i++) + msg("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + */ + ue->measurements.subband_cqi[eNB_id][aarx][subband] = + (signal_energy_nodc(dl_ch0,subband_size) + signal_energy_nodc(dl_ch1,subband_size)); - ad_re_128 = _mm_madd_epi16(after_mf_00_128[0],after_mf_11_128[0]); - bc_re_128 = _mm_madd_epi16(after_mf_01_128[0],after_mf_01_128[0]); - det_128 = _mm_sub_epi32(ad_re_128, bc_re_128); - det_fin_128[0] = _mm_abs_epi32(det_128); + if ( ue->measurements.subband_cqi[eNB_id][aarx][subband] < 0) + ue->measurements.subband_cqi[eNB_id][aarx][subband]=0; -#ifdef DEBUG_RANK_EST - printf("\n Computing denominator \n"); - print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]); - print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]); - print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]); - print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]); - print_ints("ad_re_128:",(int32_t*)&ad_re_128); - print_ints("bc_re_128:",(int32_t*)&bc_re_128); - print_ints("det_fin_128:",(int32_t*)&det_fin_128[0]); -#endif + /* + else + ue->measurements.subband_cqi[eNB_id][aarx][subband]-=ue->measurements.n0_power[aarx]; + */ + + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } else { // this is for the last subband which is smaller in size + // for (i=0;i<12;i++) + // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,last_subband_size) + + signal_energy_nodc(dl_ch1,last_subband_size)); // - ue->measurements.n0_power[aarx]; + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } + + dl_ch1+=subband_size; + dl_ch0+=subband_size; + // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); + } + + } - det_fin_128+=1; - after_mf_00_128+=1; - after_mf_01_128+=1; - after_mf_10_128+=1; - after_mf_11_128+=1; - } - _mm_empty(); - _m_empty(); -} + for (subband=0; subband<nb_subbands; subband++) { + ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); + // msg("subband_cqi_tot[%d][%d] => %d dB (n0 %d)\n",eNB_id,subband,ue->measurements.subband_cqi_tot_dB[eNB_id][subband],ue->measurements.n0_power_tot); + } -void numer(int32_t *Hh_h_00_sq, - int32_t *Hh_h_01_sq, - int32_t *Hh_h_10_sq, - int32_t *Hh_h_11_sq, - int32_t *num_fin, - unsigned short nb_rb) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + //printf("aarx=%d", aarx); + // skip the first 4 RE due to interpolation filter length of 5 (not possible to skip 5 due to 128i alignment, must be multiple of 128bit) -{ - unsigned short rb; - __m128i *h_h_00_sq_128, *h_h_01_sq_128, *h_h_10_sq_128, *h_h_11_sq_128; - __m128i *num_fin_128, sq_a_plus_sq_d_128, sq_b_plus_sq_c_128; +#if defined(__x86_64__) || defined(__i386__) + __m128i pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1 /* ,mmtmpPMI2,mmtmpPMI3 */ ; - h_h_00_sq_128 = (__m128i *)Hh_h_00_sq; - h_h_01_sq_128 = (__m128i *)Hh_h_01_sq; - h_h_10_sq_128 = (__m128i *)Hh_h_10_sq; - h_h_11_sq_128 = (__m128i *)Hh_h_11_sq; + dl_ch0_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; + dl_ch1_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; +#elif defined(__arm__) + int32x4_t pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1,mmtmpPMI0b,mmtmpPMI1b; - num_fin_128 = (__m128i *)num_fin; + dl_ch0_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; + dl_ch1_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; - for (rb=0; rb<3*nb_rb; rb++) { +#endif + for (subband=0; subband<nb_subbands; subband++) { - sq_a_plus_sq_d_128 = _mm_add_epi32(h_h_00_sq_128[0],h_h_11_sq_128[0]); - sq_b_plus_sq_c_128 = _mm_add_epi32(h_h_01_sq_128[0],h_h_10_sq_128[0]); - num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128); -#ifdef DEBUG_RANK_EST - printf("\n Computing numerator \n"); - print_ints("h_h_00_sq_128:",(int32_t*)&h_h_00_sq_128[0]); - print_ints("h_h_01_sq_128:",(int32_t*)&h_h_01_sq_128[0]); - print_ints("h_h_10_sq_128:",(int32_t*)&h_h_10_sq_128[0]); - print_ints("h_h_11_sq_128:",(int32_t*)&h_h_11_sq_128[0]); - print_shorts("sq_a_plus_sq_d_128:",(int16_t*)&sq_a_plus_sq_d_128); - print_shorts("sq_b_plus_sq_c_128:",(int16_t*)&sq_b_plus_sq_c_128); - print_shorts("num_fin_128:",(int16_t*)&num_fin_128[0]); + // pmi +#if defined(__x86_64__) || defined(__i386__) + + pmi128_re = _mm_xor_si128(pmi128_re,pmi128_re); + pmi128_im = _mm_xor_si128(pmi128_im,pmi128_im); +#elif defined(__arm__) + + pmi128_re = vdupq_n_s32(0); + pmi128_im = vdupq_n_s32(0); #endif + // limit is the number of groups of 4 REs in a subband (12 = 4 RBs, 3 = 1 RB) + // for 5 MHz channelization, there are 7 subbands, 6 of size 4 RBs and 1 of size 1 RB + if ((N_RB_DL==6) || (subband<(nb_subbands-1))) + limit = subband_size>>2; + else + limit = last_subband_size>>2; - num_fin_128+=1; - h_h_00_sq_128+=1; - h_h_01_sq_128+=1; - h_h_10_sq_128+=1; - h_h_11_sq_128+=1; - } - _mm_empty(); - _m_empty(); -} + for (i=0; i<limit; i++) { +#if defined(__x86_64__) || defined(__i386__) + mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); + mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); + // For each RE in subband perform ch0 * conj(ch1) + // multiply by conjugated channel + // print_ints("ch0",&dl_ch0_128[0]); + // print_ints("ch1",&dl_ch1_128[0]); + mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]); + // print_ints("re",&mmtmpPMI0); + mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[0],_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate[0]); + // print_ints("_mm_sign_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[0]); + // print_ints("mm_madd_epi16",&mmtmpPMI1); + // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) + pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); + // print_ints(" pmi128_re 0",&pmi128_re); + pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); + // print_ints(" pmi128_im 0 ",&pmi128_im); + /* mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); + mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); -void dlsch_channel_level_TM34_meas(int *ch00, - int *ch01, - int *ch10, - int *ch11, - int *avg_0, - int *avg_1, - unsigned short nb_rb) -{ + mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[1],dl_ch1_128[1]); + // print_ints("re",&mmtmpPMI0); + mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[1],_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate); + // print_ints("_mm_sign_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[1]); + // print_ints("mm_madd_epi16",&mmtmpPMI1); + // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) + pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); + // print_ints(" pmi128_re 1",&pmi128_re); + pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); + //print_ints(" pmi128_im 1 ",&pmi128_im);*/ -#if defined(__x86_64__)||defined(__i386__) +#elif defined(__arm__) - short rb; - unsigned char nre=12; - __m128i *ch00_128, *ch01_128, *ch10_128, *ch11_128; - __m128i avg_0_row0_128D, avg_1_row0_128D, avg_0_row1_128D, avg_1_row1_128D; - __m128i ch00_128_tmp, ch01_128_tmp, ch10_128_tmp, ch11_128_tmp; + mmtmpPMI0 = vmull_s16(((int16x4_t*)dl_ch0_128)[0], ((int16x4_t*)dl_ch1_128)[0]); + mmtmpPMI1 = vmull_s16(((int16x4_t*)dl_ch0_128)[1], ((int16x4_t*)dl_ch1_128)[1]); + pmi128_re = vqaddq_s32(pmi128_re,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0),vget_high_s32(mmtmpPMI0)),vpadd_s32(vget_low_s32(mmtmpPMI1),vget_high_s32(mmtmpPMI1)))); - avg_0[0] = 0; - avg_0[1] = 0; - avg_1[0] = 0; - avg_1[1] = 0; + mmtmpPMI0b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[0],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[0]); + mmtmpPMI1b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[1],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[1]); + pmi128_im = vqaddq_s32(pmi128_im,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0b),vget_high_s32(mmtmpPMI0b)),vpadd_s32(vget_low_s32(mmtmpPMI1b),vget_high_s32(mmtmpPMI1b)))); - ch00_128 = (__m128i *)ch00; - ch01_128 = (__m128i *)ch01; - ch10_128 = (__m128i *)ch10; - ch11_128 = (__m128i *)ch11; +#endif + dl_ch0_128++; + dl_ch1_128++; + } - avg_0_row0_128D = _mm_setzero_si128(); - avg_1_row0_128D = _mm_setzero_si128(); - avg_0_row1_128D = _mm_setzero_si128(); - avg_1_row1_128D = _mm_setzero_si128(); + ue->measurements.subband_pmi_re[eNB_id][subband][aarx] = (((int *)&pmi128_re)[0] + ((int *)&pmi128_re)[1] + ((int *)&pmi128_re)[2] + ((int *)&pmi128_re)[3])>>2; + ue->measurements.subband_pmi_im[eNB_id][subband][aarx] = (((int *)&pmi128_im)[0] + ((int *)&pmi128_im)[1] + ((int *)&pmi128_im)[2] + ((int *)&pmi128_im)[3])>>2; + ue->measurements.wideband_pmi_re[eNB_id][aarx] += ue->measurements.subband_pmi_re[eNB_id][subband][aarx]; + ue->measurements.wideband_pmi_im[eNB_id][aarx] += ue->measurements.subband_pmi_im[eNB_id][subband][aarx]; + } // subband loop + } // rx antenna loop + } // if frame_parms->mode1_flag == 0 + else { + // cqi information only for mode 1 + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - for (rb=0; rb<3*nb_rb; rb++) { - ch00_128_tmp = _mm_load_si128(&ch00_128[0]); - ch01_128_tmp = _mm_load_si128(&ch01_128[0]); - ch10_128_tmp = _mm_load_si128(&ch10_128[0]); - ch11_128_tmp = _mm_load_si128(&ch11_128[0]); + for (subband=0; subband<7; subband++) { - avg_0_row0_128D = _mm_add_epi32(avg_0_row0_128D,_mm_madd_epi16(ch00_128_tmp,ch00_128_tmp)); - avg_1_row0_128D = _mm_add_epi32(avg_1_row0_128D,_mm_madd_epi16(ch01_128_tmp,ch01_128_tmp)); - avg_0_row1_128D = _mm_add_epi32(avg_0_row1_128D,_mm_madd_epi16(ch10_128_tmp,ch10_128_tmp)); - avg_1_row1_128D = _mm_add_epi32(avg_1_row1_128D,_mm_madd_epi16(ch11_128_tmp,ch11_128_tmp)); + // cqi + if (aarx==0) + ue->measurements.subband_cqi_tot[eNB_id][subband]=0; - ch00_128+=1; - ch01_128+=1; - ch10_128+=1; - ch11_128+=1; - } + if (subband<6) { + // for (i=0;i<48;i++) + // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + ue->measurements.subband_cqi[eNB_id][aarx][subband] = + (signal_energy_nodc(dl_ch0,48) ) - ue->measurements.n0_power[aarx]; - avg_0[0] = (((int*)&avg_0_row0_128D)[0])/(nb_rb*nre) + - (((int*)&avg_0_row0_128D)[1])/(nb_rb*nre) + - (((int*)&avg_0_row0_128D)[2])/(nb_rb*nre) + - (((int*)&avg_0_row0_128D)[3])/(nb_rb*nre); + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } else { + // for (i=0;i<12;i++) + // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,12) ) - ue->measurements.n0_power[aarx]; + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } - avg_1[0] = (((int*)&avg_1_row0_128D)[0])/(nb_rb*nre) + - (((int*)&avg_1_row0_128D)[1])/(nb_rb*nre) + - (((int*)&avg_1_row0_128D)[2])/(nb_rb*nre) + - (((int*)&avg_1_row0_128D)[3])/(nb_rb*nre); + dl_ch1+=48; + // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); + } + } - avg_0[1] = (((int*)&avg_0_row1_128D)[0])/(nb_rb*nre) + - (((int*)&avg_0_row1_128D)[1])/(nb_rb*nre) + - (((int*)&avg_0_row1_128D)[2])/(nb_rb*nre) + - (((int*)&avg_0_row1_128D)[3])/(nb_rb*nre); + for (subband=0; subband<nb_subbands; subband++) { + ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); + } + } - avg_1[1] = (((int*)&avg_1_row1_128D)[0])/(nb_rb*nre) + - (((int*)&avg_1_row1_128D)[1])/(nb_rb*nre) + - (((int*)&avg_1_row1_128D)[2])/(nb_rb*nre) + - (((int*)&avg_1_row1_128D)[3])/(nb_rb*nre); + //ue->measurements.rank[eNB_id] = 0; - avg_0[0] = avg_0[0] + avg_0[1]; - avg_1[0] = avg_1[0] + avg_1[1]; - avg_0[0] = min (avg_0[0], avg_1[0]); - avg_1[0] = avg_0[0]; + for (i=0; i<nb_subbands; i++) { + ue->measurements.selected_rx_antennas[eNB_id][i] = 0; + + if (frame_parms->nb_antennas_rx>1) { + if (ue->measurements.subband_cqi_dB[eNB_id][0][i] >= ue->measurements.subband_cqi_dB[eNB_id][1][i]) + ue->measurements.selected_rx_antennas[eNB_id][i] = 0; + else + ue->measurements.selected_rx_antennas[eNB_id][i] = 1; + } else + ue->measurements.selected_rx_antennas[eNB_id][i] = 0; + } + // if(eNB_id==0) + // printf("in lte_ue_measurements: selected rx_antenna[eNB_id==0]:%u\n", ue->measurements.selected_rx_antennas[eNB_id][i]); + } // eNB_id loop + +#if defined(__x86_64__) || defined(__i386__) _mm_empty(); _m_empty(); +#endif +} -#elif defined(__arm__) -#endif +void lte_ue_measurements_emul(PHY_VARS_UE *ue,uint8_t subframe,uint8_t eNB_id) +{ + + LOG_D(PHY,"EMUL UE lte_ue_measurements_emul subframe %d, eNB_id %d\n",subframe,eNB_id); } + + + diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 9ef23f23d06ebcaee853c03d4d110de305ee4130..74ef6798c78c57baaada40d1044b137988a60774 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -19,13 +19,14 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" //#define DEBUG_CH #include "UTIL/LOG/log.h" - +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" #include "T.h" +#include "lte_estimation.h" // round(exp(sqrt(-1)*(pi/2)*[0:1:N-1]/N)*pow2(15)) static int16_t ru_90[2*128] = {32767, 0,32766, 402,32758, 804,32746, 1206,32729, 1608,32706, 2009,32679, 2411,32647, 2811,32610, 3212,32568, 3612,32522, 4011,32470, 4410,32413, 4808,32352, 5205,32286, 5602,32214, 5998,32138, 6393,32058, 6787,31972, 7180,31881, 7571,31786, 7962,31686, 8351,31581, 8740,31471, 9127,31357, 9512,31238, 9896,31114, 10279,30986, 10660,30853, 11039,30715, 11417,30572, 11793,30425, 12167,30274, 12540,30118, 12910,29957, 13279,29792, 13646,29622, 14010,29448, 14373,29269, 14733,29086, 15091,28899, 15447,28707, 15800,28511, 16151,28311, 16500,28106, 16846,27897, 17190,27684, 17531,27467, 17869,27246, 18205,27020, 18538,26791, 18868,26557, 19195,26320, 19520,26078, 19841,25833, 20160,25583, 20475,25330, 20788,25073, 21097,24812, 21403,24548, 21706,24279, 22006,24008, 22302,23732, 22595,23453, 22884,23170, 23170,22884, 23453,22595, 23732,22302, 24008,22006, 24279,21706, 24548,21403, 24812,21097, 25073,20788, 25330,20475, 25583,20160, 25833,19841, 26078,19520, 26320,19195, 26557,18868, 26791,18538, 27020,18205, 27246,17869, 27467,17531, 27684,17190, 27897,16846, 28106,16500, 28311,16151, 28511,15800, 28707,15447, 28899,15091, 29086,14733, 29269,14373, 29448,14010, 29622,13646, 29792,13279, 29957,12910, 30118,12540, 30274,12167, 30425,11793, 30572,11417, 30715,11039, 30853,10660, 30986,10279, 31114,9896, 31238,9512, 31357,9127, 31471,8740, 31581,8351, 31686,7962, 31786,7571, 31881,7180, 31972,6787, 32058,6393, 32138,5998, 32214,5602, 32286,5205, 32352,4808, 32413,4410, 32470,4011, 32522,3612, 32568,3212, 32610,2811, 32647,2411, 32679,2009, 32706,1608, 32729,1206, 32746,804, 32758,402, 32766}; diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c b/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c index 5bf69578d194269b656266e0245d38fbd2a39b56..56d8aaf1dfce1826cedefec58e856a64620aabd7 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c @@ -22,8 +22,9 @@ #include <stdio.h> #include <stdlib.h> -#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_top.h" //extern unsigned int lte_gold_table[3][20][2][14]; //#define DEBUG_DL_CELL_SPEC diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c index 35e5fe6affa62885f33bde299fe1d63a7375d475..54f52ef40b9d3990abbf044d48aed421cdb31f78 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c @@ -24,8 +24,10 @@ #include <stdio.h> #include <stdlib.h> -#include "defs.h" -#include "PHY/defs.h" +#include "lte_refsig.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_top.h" //extern unsigned int lte_gold_table[10][3][42]; //#define DEBUG_DL_MBSFN diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c b/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c index a7db8fd5aa321848cb1a4b903b5fb2b1cc780842..fc03299f2b60bda1ff969d5307c478b51f9fa686 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c @@ -33,9 +33,11 @@ #include <stdio.h> #include <stdlib.h> -#include "defs.h" -#include "PHY/defs.h" +#include "lte_refsig.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "log.h" +#include "PHY/impl_defs_top.h" //extern unsigned int lte_gold_table[3][20][2][14]; //#define DEBUG_DL_CELL_SPEC diff --git a/openair1/PHY/LTE_REFSIG/lte_gold.c b/openair1/PHY/LTE_REFSIG/lte_gold.c index c3a3f42456293460213b3bea994b8757b0be37a0..78fae8b8f3304a69a1d2c0d67cac522e08209135 100644 --- a/openair1/PHY/LTE_REFSIG/lte_gold.c +++ b/openair1/PHY/LTE_REFSIG/lte_gold.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "lte_refsig.h" /* c(n) = x1(n+Nc) + x2(n+Nc) mod 2 diff --git a/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c b/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c index 66d7fa8fb253c3cb3ed3d6220e475f0d526ab7b3..14def309b7bdb11043ef66712b0828d5546898d6 100644 --- a/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c +++ b/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c @@ -42,7 +42,7 @@ //unsigned int lte_gold_table[10][3][42]; // need 165 bytes for sequence //slot index x pilot within slot x sequence*/ -#include "defs.h" +#include "lte_refsig.h" void lte_gold_mbsfn(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_mbsfn_table[10][3][42],uint16_t Nid_mbsfn) { diff --git a/openair1/PHY/LTE_REFSIG/defs.h b/openair1/PHY/LTE_REFSIG/lte_refsig.h similarity index 99% rename from openair1/PHY/LTE_REFSIG/defs.h rename to openair1/PHY/LTE_REFSIG/lte_refsig.h index 838406b4444222c2ca341f69ad85213fcd27018c..27788e5e1a92c2266b23cad399af48f2506a2580 100644 --- a/openair1/PHY/LTE_REFSIG/defs.h +++ b/openair1/PHY/LTE_REFSIG/lte_refsig.h @@ -23,7 +23,8 @@ /* Author R. Knopp / EURECOM / OpenAirInterface.org */ #ifndef __LTE_REFSIG_DEFS__H__ #define __LTE_REFSIG_DEFS__H__ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" /** @ingroup _PHY_REF_SIG * @{ diff --git a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c index 93ca7646e63cdaabfc0d229d2e8241cdf8480541..01b27205c21b619bc273b8ef43309073de21a7e1 100644 --- a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c +++ b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c @@ -24,7 +24,8 @@ #include <stdlib.h> #include <math.h> #endif -#include "defs.h" +#include "lte_refsig.h" +#include "PHY/defs_eNB.h" uint16_t dftsizes[33] = {12,24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,864,900,960,972,1080,1152,1200}; diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index 71cc8130b2da66552fc4bf12df5e4a514717bb20..2bf3ec50155da7189aef47cf60756379191b57af 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -32,16 +32,19 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "SIMULATION/TOOLS/sim.h" // for taus #include "PHY/sse_intrin.h" - +#include "transport_proto.h" +#include "transport_common_proto.h" #include "assertions.h" #include "T.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_TRANSPORT/transport_extern.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_DCI_ENCODING 1 //#define DEBUG_DCI_DECODING 1 @@ -52,109 +55,6 @@ //extern uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; //extern uint16_t pcfich_reg[4]; -uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi) -{ - - uint16_t i; - uint16_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - uint16_t mprime; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - if ((lprime>0) && (frame_parms->Ncp==0) ) - return(0); - - // printf("check_phich_reg : mi %d\n",mi); - - // compute REG based on symbol - if ((lprime == 0)|| - ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4))) - mprime = kprime/6; - else - mprime = kprime>>2; - - // check if PCFICH uses mprime - if ((lprime==0) && - ((mprime == pcfich_reg[0]) || - (mprime == pcfich_reg[1]) || - (mprime == pcfich_reg[2]) || - (mprime == pcfich_reg[3]))) { -#ifdef DEBUG_DCI_ENCODING - printf("[PHY] REG %d allocated to PCFICH\n",mprime); -#endif - return(1); - } - - // handle Special subframe case for TDD !!! - - // printf("Checking phich_reg %d\n",mprime); - if (mi > 0) { - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - if (frame_parms->Ncp == 1) { - Ngroup_PHICH<<=1; - } - - - - for (i=0; i<Ngroup_PHICH; i++) { - if ((mprime == frame_parms->phich_reg[i][0]) || - (mprime == frame_parms->phich_reg[i][1]) || - (mprime == frame_parms->phich_reg[i][2])) { -#ifdef DEBUG_DCI_ENCODING - printf("[PHY] REG %d (lprime %d) allocated to PHICH\n",mprime,lprime); -#endif - return(1); - } - } - } - - return(0); -} - -uint16_t extract_crc(uint8_t *dci,uint8_t dci_len) -{ - - uint16_t crc16; - // uint8_t i; - - /* - uint8_t crc; - crc = ((uint16_t *)dci)[DCI_LENGTH>>4]; - printf("crc1: %x, shift %d (DCI_LENGTH %d)\n",crc,DCI_LENGTH&0xf,DCI_LENGTH); - crc = (crc>>(DCI_LENGTH&0xf)); - // clear crc bits - ((uint16_t *)dci)[DCI_LENGTH>>4] &= (0xffff>>(16-(DCI_LENGTH&0xf))); - printf("crc2: %x, dci0 %x\n",crc,((int16_t *)dci)[DCI_LENGTH>>4]); - crc |= (((uint16_t *)dci)[1+(DCI_LENGTH>>4)])<<(16-(DCI_LENGTH&0xf)); - // clear crc bits - (((uint16_t *)dci)[1+(DCI_LENGTH>>4)]) = 0; - printf("extract_crc: crc %x\n",crc); - */ -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY,"dci_crc (%x,%x,%x), dci_len&0x7=%d\n",dci[dci_len>>3],dci[1+(dci_len>>3)],dci[2+(dci_len>>3)], - dci_len&0x7); -#endif - - if ((dci_len&0x7) > 0) { - ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]<<(dci_len&0x7) | dci[2+(dci_len>>3)]>>(8-(dci_len&0x7)); - ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]<<(dci_len&0x7) | dci[1+(dci_len>>3)]>>(8-(dci_len&0x7)); - } else { - ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]; - ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]; - } - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY,"dci_crc =>%x\n",crc16); -#endif - - // dci[(dci_len>>3)]&=(0xffff<<(dci_len&0xf)); - // dci[(dci_len>>3)+1] = 0; - // dci[(dci_len>>3)+2] = 0; - return((uint16_t)crc16); - -} - static uint8_t d[3*(MAX_DCI_SIZE_BITS + 16) + 96]; @@ -271,15 +171,10 @@ uint8_t *generate_dci0(uint8_t *dci, uint32_t Y; -#define CCEBITS 72 -#define CCEPERSYMBOL 33 // This is for 1200 RE -#define CCEPERSYMBOL0 22 // This is for 1200 RE -#define DCI_BITS_MAX ((2*CCEPERSYMBOL+CCEPERSYMBOL0)*CCEBITS) -#define Msymb (DCI_BITS_MAX/2) -//#define Mquad (Msymb/4) -static uint32_t bitrev_cc_dci[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30}; -static int32_t wtemp[2][Msymb]; + + + void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi) { @@ -292,6 +187,8 @@ void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **w #ifdef RM_DEBUG int32_t nulled=0; #endif + uint32_t Msymb=(DCI_BITS_MAX/2); + int32_t wtemp[2][Msymb]; // printf("[PHY] PDCCH Interleaving Mquad %d (Nsymb %d)\n",Mquad,n_symbols_pdcch); if ((Mquad&0x1f) > 0) @@ -346,1853 +243,34 @@ void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **w } } -void pdcch_demapping(uint16_t *llr,uint16_t *wbar,LTE_DL_FRAME_PARMS *frame_parms,uint8_t num_pdcch_symbols,uint8_t mi) -{ - - uint32_t i, lprime; - uint16_t kprime,kprime_mod12,mprime,symbol_offset,tti_offset,tti_offset0; - int16_t re_offset,re_offset0; - - // This is the REG allocation algorithm from 36-211, second part of Section 6.8.5 - - int Msymb2; - - switch (frame_parms->N_RB_DL) { - case 100: - Msymb2 = Msymb; - break; - - case 75: - Msymb2 = 3*Msymb/4; - break; - - case 50: - Msymb2 = Msymb>>1; - break; - - case 25: - Msymb2 = Msymb>>2; - break; - - case 15: - Msymb2 = Msymb*15/100; - break; - - case 6: - Msymb2 = Msymb*6/100; - break; - - default: - Msymb2 = Msymb>>2; - break; - } - - mprime=0; - - - re_offset = 0; - re_offset0 = 0; // counter for symbol with pilots (extracted outside!) - - for (kprime=0; kprime<frame_parms->N_RB_DL*12; kprime++) { - for (lprime=0; lprime<num_pdcch_symbols; lprime++) { - - symbol_offset = (uint32_t)frame_parms->N_RB_DL*12*lprime; - - tti_offset = symbol_offset + re_offset; - tti_offset0 = symbol_offset + re_offset0; - - // if REG is allocated to PHICH, skip it - if (check_phich_reg(frame_parms,kprime,lprime,mi) == 1) { - // printf("dci_demapping : skipping REG %d (RE %d)\n",(lprime==0)?kprime/6 : kprime>>2,kprime); - if ((lprime == 0)&&((kprime%6)==0)) - re_offset0+=4; - } else { // not allocated to PHICH/PCFICH - // printf("dci_demapping: REG %d\n",(lprime==0)?kprime/6 : kprime>>2); - if (lprime == 0) { - // first symbol, or second symbol+4 TX antennas skip pilots - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 6)) { - // kprime represents REG - - for (i=0; i<4; i++) { - wbar[mprime] = llr[tti_offset0+i]; -#ifdef DEBUG_DCI_DECODING -// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset0+i,symbol_offset,re_offset0,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); -#endif - mprime++; - re_offset0++; - } - } - } else if ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4)) { - // LATER!!!! - } else { // no pilots in this symbol - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 4) || (kprime_mod12 == 8)) { - // kprime represents REG - for (i=0; i<4; i++) { - wbar[mprime] = llr[tti_offset+i]; -#ifdef DEBUG_DCI_DECODING -// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset+i,symbol_offset,re_offset+i,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); -#endif - mprime++; - } - } // is representative - } // no pilots case - } // not allocated to PHICH/PCFICH - - // Stop when all REGs are copied in - if (mprime>=Msymb2) - break; - } //lprime loop - - re_offset++; - - } // kprime loop -} - -static uint16_t wtemp_rx[Msymb]; -void pdcch_deinterleaving(LTE_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t *wbar,uint8_t number_pdcch_symbols,uint8_t mi) -{ - - uint16_t *wptr,*zptr,*wptr2; - - uint16_t Mquad=get_nquad(number_pdcch_symbols,frame_parms,mi); - uint32_t RCC = (Mquad>>5), ND; - uint32_t row,col,Kpi,index; - int32_t i,k; - - - // printf("Mquad %d, RCC %d\n",Mquad,RCC); - - AssertFatal(z!=NULL,"dci.c: pdcch_deinterleaving: FATAL z is Null\n"); - - // undo permutation - for (i=0; i<Mquad; i++) { - wptr = &wtemp_rx[((i+frame_parms->Nid_cell)%Mquad)<<2]; - wptr2 = &wbar[i<<2]; - - wptr[0] = wptr2[0]; - wptr[1] = wptr2[1]; - wptr[2] = wptr2[2]; - wptr[3] = wptr2[3]; - /* - printf("pdcch_deinterleaving (%p,%p): quad %d (%d) -> (%d,%d %d,%d %d,%d %d,%d)\n",wptr,wptr2,i,(i+frame_parms->Nid_cell)%Mquad, - ((char*)wptr2)[0], - ((char*)wptr2)[1], - ((char*)wptr2)[2], - ((char*)wptr2)[3], - ((char*)wptr2)[4], - ((char*)wptr2)[5], - ((char*)wptr2)[6], - ((char*)wptr2)[7]); - */ - - } - - if ((Mquad&0x1f) > 0) - RCC++; - - Kpi = (RCC<<5); - ND = Kpi - Mquad; - - k=0; - - for (col=0; col<32; col++) { - index = bitrev_cc_dci[col]; - - for (row=0; row<RCC; row++) { - // printf("row %d, index %d, Nd %d\n",row,index,ND); - if (index>=ND) { - - - - wptr = &wtemp_rx[k<<2]; - zptr = &z[(index-ND)<<2]; - - zptr[0] = wptr[0]; - zptr[1] = wptr[1]; - zptr[2] = wptr[2]; - zptr[3] = wptr[3]; - - /* - printf("deinterleaving ; k %d, index-Nd %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",k,(index-ND), - ((int8_t *)wptr)[0], - ((int8_t *)wptr)[1], - ((int8_t *)wptr)[2], - ((int8_t *)wptr)[3], - ((int8_t *)wptr)[4], - ((int8_t *)wptr)[5], - ((int8_t *)wptr)[6], - ((int8_t *)wptr)[7]); - */ - k++; - } - - index+=32; - - } - } - - for (i=0; i<Mquad; i++) { - zptr = &z[i<<2]; - /* - printf("deinterleaving ; quad %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",i, - ((int8_t *)zptr)[0], - ((int8_t *)zptr)[1], - ((int8_t *)zptr)[2], - ((int8_t *)zptr)[3], - ((int8_t *)zptr)[4], - ((int8_t *)zptr)[5], - ((int8_t *)zptr)[6], - ((int8_t *)zptr)[7]); - */ - } - -} - - -int32_t pdcch_qpsk_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho_i, - int16_t *pdcch_llr16, - int16_t *pdcch_llr8in, - uint8_t symbol) -{ - - int16_t *rxF=(int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rxF_i=(int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rho=(int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *llr128; - int32_t i; - char *pdcch_llr8; - int16_t *pdcch_llr; - pdcch_llr8 = (char *)&pdcch_llr8in[symbol*frame_parms->N_RB_DL*12]; - pdcch_llr = &pdcch_llr16[symbol*frame_parms->N_RB_DL*12]; - - // printf("dlsch_qpsk_qpsk: symbol %d\n",symbol); - - llr128 = (int16_t*)pdcch_llr; - - if (!llr128) { - printf("dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol); - return -1; - } - - qpsk_qpsk(rxF, - rxF_i, - llr128, - rho, - frame_parms->N_RB_DL*12); - - //prepare for Viterbi which accepts 8 bit, but prefers 4 bit, soft input. - for (i=0; i<(frame_parms->N_RB_DL*24); i++) { - if (*pdcch_llr>7) - *pdcch_llr8=7; - else if (*pdcch_llr<-8) - *pdcch_llr8=-8; - else - *pdcch_llr8 = (char)(*pdcch_llr); - - pdcch_llr++; - pdcch_llr8++; - } - - return(0); -} - - -int32_t pdcch_llr(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - char *pdcch_llr, - uint8_t symbol) -{ - - int16_t *rxF= (int16_t*) &rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int32_t i; - char *pdcch_llr8; - - pdcch_llr8 = &pdcch_llr[2*symbol*frame_parms->N_RB_DL*12]; - - if (!pdcch_llr8) { - printf("pdcch_qpsk_llr: llr is null, symbol %d\n",symbol); - return(-1); - } - - // printf("pdcch qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llr8-pdcch_llr); - - for (i=0; i<(frame_parms->N_RB_DL*((symbol==0) ? 16 : 24)); i++) { - - if (*rxF>31) - *pdcch_llr8=31; - else if (*rxF<-32) - *pdcch_llr8=-32; - else - *pdcch_llr8 = (char)(*rxF); - - // printf("%d %d => %d\n",i,*rxF,*pdcch_llr8); - rxF++; - pdcch_llr8++; - } - - return(0); - -} - -//__m128i avg128P; - -//compute average channel_level on each (TX,RX) antenna pair -void pdcch_channel_level(int32_t **dl_ch_estimates_ext, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t *avg, - uint8_t nb_rb) -{ - - int16_t rb; - uint8_t aatx,aarx; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128; - __m128i avg128P; -#elif defined(__arm__) - int16x8_t *dl_ch128; - int32x4_t *avg128P; -#endif - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - //clear average level -#if defined(__x86_64__) || defined(__i386__) - avg128P = _mm_setzero_si128(); - dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][0]; -#elif defined(__arm__) - -#endif - for (rb=0; rb<nb_rb; rb++) { - -#if defined(__x86_64__) || defined(__i386__) - avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); - avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); - avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); -#elif defined(__arm__) - -#endif - dl_ch128+=3; - /* - if (rb==0) { - print_shorts("dl_ch128",&dl_ch128[0]); - print_shorts("dl_ch128",&dl_ch128[1]); - print_shorts("dl_ch128",&dl_ch128[2]); - } - */ - } - - DevAssert( nb_rb ); - avg[(aatx<<1)+aarx] = (((int32_t*)&avg128P)[0] + - ((int32_t*)&avg128P)[1] + - ((int32_t*)&avg128P)[2] + - ((int32_t*)&avg128P)[3])/(nb_rb*12); - - // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - -#if defined(__x86_64) || defined(__i386__) -__m128i mmtmpPD0,mmtmpPD1,mmtmpPD2,mmtmpPD3; -#elif defined(__arm__) - -#endif -void pdcch_dual_stream_correlation(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - int32_t **dl_ch_estimates_ext, - int32_t **dl_ch_estimates_ext_i, - int32_t **dl_ch_rho_ext, - uint8_t output_shift) -{ - - uint16_t rb; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*dl_ch128i,*dl_ch_rho128; -#elif defined(__arm__) - -#endif - uint8_t aarx; - - // printf("dlsch_dual_stream_correlation: symbol %d\n",symbol); - - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128i = (__m128i *)&dl_ch_estimates_ext_i[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch_rho128 = (__m128i *)&dl_ch_rho_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - // multiply by conjugated channel -#if defined(__x86_64__) || defined(__i386__) - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128i[0]); - // print_ints("re",&mmtmpPD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[0]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpPD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpPD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - dl_ch_rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - //print_shorts("rx:",dl_ch128_2); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rho128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128i[1]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[1]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - - dl_ch_rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+1); - //print_shorts("ch:",dl_ch128+1); - //print_shorts("pack:",rho128+1); - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128i[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - dl_ch_rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+2); - //print_shorts("ch:",dl_ch128+2); - //print_shorts("pack:",rho128+2); - - dl_ch128+=3; - dl_ch128i+=3; - dl_ch_rho128+=3; - - -#elif defined(__arm__) - -#endif - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - - -void pdcch_detection_mrc_i(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho, - int32_t **rho_i, - uint8_t symbol) +void pdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + uint8_t *e, + uint32_t length) { - - uint8_t aatx; - -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; -#endif - int32_t i; - - if (frame_parms->nb_antennas_rx>1) { - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { - //if (frame_parms->mode1_flag && (aatx>0)) break; - -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#endif - // MRC on each re of rb on MF output - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); -#endif - } - } - -#if defined(__x86_64__) || defined(__i386__) - rho128_0 = (__m128i *) &rho[0][symbol*frame_parms->N_RB_DL*12]; - rho128_1 = (__m128i *) &rho[1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rho128_0 = (int16x8_t *) &rho[0][symbol*frame_parms->N_RB_DL*12]; - rho128_1 = (int16x8_t *) &rho[1][symbol*frame_parms->N_RB_DL*12]; -#endif - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1)); -#elif defined(__arm__) - rho128_0[i] = vhaddq_s16(rho128_0[i],rho128_1[i]); -#endif - } - -#if defined(__x86_64__) || defined(__i386__) - rho128_i0 = (__m128i *) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; - rho128_i1 = (__m128i *) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i0 = (__m128i *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i1 = (__m128i *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rho128_i0 = (int16x8_t*) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; - rho128_i1 = (int16x8_t*) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i0 = (int16x8_t *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i1 = (int16x8_t *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; - -#endif - // MRC on each re of rb on MF and rho - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_i0[i],1),_mm_srai_epi16(rxdataF_comp128_i1[i],1)); - rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_i0[i] = vhaddq_s16(rxdataF_comp128_i0[i],rxdataF_comp128_i1[i]); - rho128_i0[i] = vhaddq_s16(rho128_i0[i],rho128_i1[i]); - -#endif - } - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - - -void pdcch_extract_rbs_single(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - uint8_t symbol, - uint32_t high_speed_flag, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - - uint16_t rb,nb_rb=0; - uint8_t i,j,aarx; - int32_t *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; - - - int nushiftmod3 = frame_parms->nushift%3; - uint8_t symbol_mod; - - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod); -#endif - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (high_speed_flag == 1) - dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; - else - dl_ch0 = &dl_ch_estimates[aarx][5]; - - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - - rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; - - if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - // For second half of RBs skip DC carrier - if (rb==(frame_parms->N_RB_DL>>1)) { - rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; - - //dl_ch0++; - } - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - - for (i=0; i<12; i++) { - - rxF_ext[i]=rxF[i]; - - } - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j++]=dl_ch0[i]; - // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } - } - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - rxF+=12; - } - } - } else { // Odd number of RBs - for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j++]=dl_ch0[i]; - // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } - } - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - rxF+=12; - } - } - - // Do middle RB (around DC) - // printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]); - - if (symbol_mod==0) { - j=0; - - for (i=0; i<6; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3))) { - dl_ch0_ext[j]=dl_ch0[i]; - rxF_ext[j++]=rxF[i]; - // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); - } - } - - rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - if ((i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - dl_ch0_ext[j]=dl_ch0[i]; - rxF_ext[j++]=rxF[(1+i-6)]; - // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); - } - } - - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - dl_ch0+=12; - rxF+=7; - rb++; - } else { - for (i=0; i<6; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - rxF_ext[i]=rxF[i]; - } - - rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - rxF_ext[i]=rxF[(1+i-6)]; - } - - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - dl_ch0+=12; - rxF+=7; - rb++; - } - - for (; rb<frame_parms->N_RB_DL; rb++) { - if (symbol_mod > 0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=(nushiftmod3)) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j++]=dl_ch0[i]; - } - } - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - rxF+=12; - } - } - } - } -} - -void pdcch_extract_rbs_dual(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - uint8_t symbol, - uint32_t high_speed_flag, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - - uint16_t rb,nb_rb=0; - uint8_t i,aarx,j; - int32_t *dl_ch0,*dl_ch0_ext,*dl_ch1,*dl_ch1_ext,*rxF,*rxF_ext; - uint8_t symbol_mod; - int nushiftmod3 = frame_parms->nushift%3; - - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "extract_rbs_dual: symbol_mod %d\n",symbol_mod); -#endif - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (high_speed_flag==1) { - dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; - dl_ch1 = &dl_ch_estimates[2+aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; - } else { - dl_ch0 = &dl_ch_estimates[aarx][5]; - dl_ch1 = &dl_ch_estimates[2+aarx][5]; - } - - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(frame_parms->N_RB_DL*12)]; - - // printf("pdcch extract_rbs: rxF_ext pos %d\n",symbol*(frame_parms->N_RB_DL*12)); - rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; - - if ((frame_parms->N_RB_DL&1) == 0) // even number of RBs - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - // For second half of RBs skip DC carrier - if (rb==(frame_parms->N_RB_DL>>1)) { - rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; - // dl_ch0++; - //dl_ch1++; - } - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); - - /* - printf("rb %d\n",rb); - for (i=0;i<12;i++) - printf("(%d %d)",((int16_t *)dl_ch0)[i<<1],((int16_t*)dl_ch0)[1+(i<<1)]); - printf("\n"); - */ - for (i=0; i<12; i++) { - rxF_ext[i]=rxF[i]; - // printf("%d : (%d,%d)\n",(rxF+(2*i)-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))*2])/2, - // ((int16_t*)&rxF[i<<1])[0],((int16_t*)&rxF[i<<1])[0]); - } - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3) && - (i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j] =dl_ch0[i]; - dl_ch1_ext[j++]=dl_ch1[i]; - } - } - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - } - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } - - else { // Odd number of RBs - for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { - - // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3) && - (i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j++]=dl_ch1[i]; - // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } - } - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } - } - - // Do middle RB (around DC) - - if (symbol_mod > 0) { - for (i=0; i<6; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - dl_ch1_ext[i]=dl_ch1[i]; - rxF_ext[i]=rxF[i]; - } - - rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - dl_ch1_ext[i]=dl_ch1[i]; - rxF_ext[i]=rxF[(1+i)]; - } - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=7; - rb++; - } else { - j=0; - - for (i=0; i<6; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3)) { - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j]=dl_ch1[i]; - rxF_ext[j++]=rxF[i]; - // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); - } - } - - rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - if ((i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j]=dl_ch1[i]; - rxF_ext[j++]=rxF[(1+i-6)]; - // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); - } - } - - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - dl_ch0+=12; - dl_ch1+=12; - rxF+=7; - rb++; - } - - for (; rb<frame_parms->N_RB_DL; rb++) { - - if (symbol_mod>0) { - // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3) && - (i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j++]=dl_ch1[i]; - } - } - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } - } - } - } -} - - -void pdcch_channel_compensation(int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - int32_t **rxdataF_comp, - int32_t **rho, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - uint8_t output_shift) -{ - - uint16_t rb; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; - __m128i *dl_ch128_2, *rho128; -#elif defined(__arm__) - -#endif - uint8_t aatx,aarx,pilots=0; - - - - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "PDCCH comp: symbol %d\n",symbol); -#endif - - if (symbol==0) - pilots=1; - - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { - //if (frame_parms->mode1_flag && aatx>0) break; //if mode1_flag is set then there is only one stream to extract, independent of nb_antenna_ports_eNB - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - -#if defined(__x86_64__) || defined(__i386__) - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpPD0); - - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[0]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpPD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpPD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[1]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - // multiply by conjugated channel - if (pilots == 0) { - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - } - - // print_shorts("rx:",rxdataF128+2); - // print_shorts("ch:",dl_ch128+2); - // print_shorts("pack:",rxdataF_comp128+2); - - if (pilots==0) { - dl_ch128+=3; - rxdataF128+=3; - rxdataF_comp128+=3; - } else { - dl_ch128+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } -#elif defined(__arm__) - -#endif - } - } - } - - - if (rho) { - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { -#if defined(__x86_64__) || defined(__i386__) - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128_2[0]); - // print_ints("re",&mmtmpD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[0]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - //print_shorts("rx:",dl_ch128_2); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rho128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128_2[1]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[1]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - - rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+1); - //print_shorts("ch:",dl_ch128+1); - //print_shorts("pack:",rho128+1); - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128_2[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+2); - //print_shorts("ch:",dl_ch128+2); - //print_shorts("pack:",rho128+2); - - dl_ch128+=3; - dl_ch128_2+=3; - rho128+=3; - -#elif defined(__arm_) - - -#endif - } - } - - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void pdcch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - uint8_t symbol) -{ - - uint8_t aatx; - -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; -#endif - int32_t i; - - if (frame_parms->nb_antennas_rx>1) { - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#endif - // MRC on each re of rb - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); -#endif - } - } - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - -void pdcch_siso(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - uint8_t l) -{ - - - uint8_t rb,re,jj,ii; - - jj=0; - ii=0; - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - for (re=0; re<12; re++) { - - rxdataF_comp[0][jj++] = rxdataF_comp[0][ii]; - ii++; - } - } -} - - -void pdcch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - uint8_t symbol) -{ - - - int16_t *rxF0,*rxF1; - uint8_t rb,re; - int32_t jj=(symbol*frame_parms->N_RB_DL*12); - - rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y - rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - for (re=0; re<12; re+=2) { - - // Alamouti RX combining - - rxF0[0] = rxF0[0] + rxF1[2]; - rxF0[1] = rxF0[1] - rxF1[3]; - - rxF0[2] = rxF0[2] - rxF1[0]; - rxF0[3] = rxF0[3] + rxF1[1]; - - rxF0+=4; - rxF1+=4; - } - } - - -} - -int32_t avgP[4]; - -int32_t rx_pdcch(PHY_VARS_UE *ue, - uint32_t frame, - uint8_t subframe, - uint8_t eNB_id, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t is_secondary_ue) -{ - - LTE_UE_COMMON *common_vars = &ue->common_vars; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; - - uint8_t log2_maxh,aatx,aarx; -#ifdef MU_RECEIVER - uint8_t eNB_id_i=eNB_id+1;//add 1 to eNB_id to separate from wanted signal, chosen as the B/F'd pilots from the SeNB are shifted by 1 -#endif - int32_t avgs; - uint8_t n_pdcch_symbols; - uint8_t mi = get_mi(frame_parms,subframe); - - //printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d \n",subframe,eNB_id,pdcch_vars); - // procress ofdm symbol 0 - if (is_secondary_ue == 1) { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id+1], //add 1 to eNB_id to compensate for the shifted B/F'd pilots from the SeNB - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); -#ifdef MU_RECEIVER - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id_i - 1],//subtract 1 to eNB_id_i to compensate for the non-shifted pilots from the PeNB - pdcch_vars[eNB_id_i]->rxdataF_ext,//shift by two to simulate transmission from a second antenna - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext,//shift by two to simulate transmission from a second antenna - 0, - high_speed_flag, - frame_parms); -#endif //MU_RECEIVER - } else if (frame_parms->nb_antenna_ports_eNB>1) { - pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); - } else { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); - } - - - // compute channel level based on ofdm symbol 0 - pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, - frame_parms, - avgP, - frame_parms->N_RB_DL); - - avgs = 0; - - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) - avgs = cmax(avgs,avgP[(aarx<<1)+aatx]); - - log2_maxh = (log2_approx(avgs)/2) + 5; //+frame_parms->nb_antennas_rx; -#ifdef UE_DEBUG_TRACE - LOG_D(PHY,"subframe %d: pdcch log2_maxh = %d (%d,%d)\n",subframe,log2_maxh,avgP[0],avgs); -#endif - - T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(frame%1024), T_INT(subframe), - T_INT(avgP[0]), T_INT(avgP[1]), T_INT(avgP[2]), T_INT(avgP[3])); - - // compute LLRs for ofdm symbol 0 only - pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, - frame_parms, - 0, - log2_maxh); // log2_maxh+I0_shift - - -#ifdef DEBUG_PHY - - if (subframe==5) - write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); - -#endif - -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - //get MF output for interfering stream - pdcch_channel_compensation(pdcch_vars[eNB_id_i]->rxdataF_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id_i]->rho : NULL, - frame_parms, - 0, - log2_maxh); // log2_maxh+I0_shift -#ifdef DEBUG_PHY - write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif - pdcch_dual_stream_correlation(frame_parms, - 0, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - log2_maxh); - } - -#endif //MU_RECEIVER - - - if (frame_parms->nb_antennas_rx > 1) { -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - pdcch_detection_mrc_i(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->rho, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - 0); -#ifdef DEBUG_PHY - write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); - write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif - } else -#endif //MU_RECEIVER - pdcch_detection_mrc(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - 0); - } - - if (mimo_mode == SISO) - pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); - else - pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); - - -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - pdcch_qpsk_qpsk_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - pdcch_vars[eNB_id]->llr16, //subsequent function require 16 bit llr, but output must be 8 bit (actually clipped to 4, because of the Viterbi decoder) - pdcch_vars[eNB_id]->llr, - 0); - /* - #ifdef DEBUG_PHY - if (subframe==5) { - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - write_output("llr16_seq.m","llr16",&pdcch_vars[eNB_id]->llr16[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - } - #endif*/ - } else { -#endif //MU_RECEIVER - pdcch_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - (char *)pdcch_vars[eNB_id]->llr, - 0); - /*#ifdef DEBUG_PHY - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - #endif*/ - -#ifdef MU_RECEIVER - } - -#endif //MU_RECEIVER - - - // decode pcfich here and find out pdcch ofdm symbol number - n_pdcch_symbols = rx_pcfich(frame_parms, - subframe, - pdcch_vars[eNB_id], - mimo_mode); - - - if (n_pdcch_symbols>3) - n_pdcch_symbols=1; - -#if T_TRACER - T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), - T_INT(n_pdcch_symbols), - T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4)); -#endif - - -#ifdef DEBUG_DCI_DECODING - - LOG_I(PHY,"demapping: subframe %d, mi %d, tdd_config %d\n",subframe,get_mi(frame_parms,subframe),frame_parms->tdd_config); -#endif - - // process pdcch ofdm symbol 1 and 2 if necessary - for (int s=1; s<n_pdcch_symbols; s++){ - if (is_secondary_ue == 1) { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id+1], //add 1 to eNB_id to compensate for the shifted B/F'd pilots from the SeNB - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - s, - high_speed_flag, - frame_parms); -#ifdef MU_RECEIVER -pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id_i - 1],//subtract 1 to eNB_id_i to compensate for the non-shifted pilots from the PeNB - pdcch_vars[eNB_id_i]->rxdataF_ext,//shift by two to simulate transmission from a second antenna - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext,//shift by two to simulate transmission from a second antenna - s, - high_speed_flag, - frame_parms); -#endif //MU_RECEIVER - } else if (frame_parms->nb_antenna_ports_eNB>1) { - pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - s, - high_speed_flag, - frame_parms); - } else { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - s, - high_speed_flag, - frame_parms); - } - - - pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, - frame_parms, - s, - log2_maxh); // log2_maxh+I0_shift - - -#ifdef DEBUG_PHY - -if (subframe==5) - write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); - -#endif - -#ifdef MU_RECEIVER - -if (is_secondary_ue) { - //get MF output for interfering stream - pdcch_channel_compensation(pdcch_vars[eNB_id_i]->rxdataF_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id_i]->rho : NULL, - frame_parms, - s, - log2_maxh); // log2_maxh+I0_shift -#ifdef DEBUG_PHY -write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif -pdcch_dual_stream_correlation(frame_parms, - s, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - log2_maxh); -} - -#endif //MU_RECEIVER - - -if (frame_parms->nb_antennas_rx > 1) { -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - pdcch_detection_mrc_i(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->rho, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - s); -#ifdef DEBUG_PHY -write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif - } else -#endif //MU_RECEIVER - pdcch_detection_mrc(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - s); - -} - -if (mimo_mode == SISO) - pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); -else - pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); - - -#ifdef MU_RECEIVER - -if (is_secondary_ue) { - pdcch_qpsk_qpsk_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - pdcch_vars[eNB_id]->llr16, //subsequent function require 16 bit llr, but output must be 8 bit (actually clipped to 4, because of the Viterbi decoder) - pdcch_vars[eNB_id]->llr, - s); - /* - #ifdef DEBUG_PHY - if (subframe==5) { - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - write_output("llr16_seq.m","llr16",&pdcch_vars[eNB_id]->llr16[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - } - #endif*/ -} else { -#endif //MU_RECEIVER - pdcch_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - (char *)pdcch_vars[eNB_id]->llr, - s); - /*#ifdef DEBUG_PHY - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - #endif*/ - -#ifdef MU_RECEIVER -} - -#endif //MU_RECEIVER - - } - - pdcch_demapping(pdcch_vars[eNB_id]->llr, - pdcch_vars[eNB_id]->wbar, - frame_parms, - n_pdcch_symbols, - get_mi(frame_parms,subframe)); - - pdcch_deinterleaving(frame_parms, - (uint16_t*)pdcch_vars[eNB_id]->e_rx, - pdcch_vars[eNB_id]->wbar, - n_pdcch_symbols, - mi); - - pdcch_unscrambling(frame_parms, - subframe, - pdcch_vars[eNB_id]->e_rx, - get_nCCE(n_pdcch_symbols,frame_parms,mi)*72); - - pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols; - - return(0); -} - - -void pdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - uint8_t *e, - uint32_t length) -{ - int i; - uint8_t reset; - uint32_t x1, x2, s=0; + int i; + uint8_t reset; + uint32_t x1, x2, s=0; //LOG_D(PHY, "%s(fp, subframe:%d, e, length:%d)\n", __FUNCTION__, subframe, length); reset = 1; - // x1 is set in lte_gold_generic - - x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 - - for (i=0; i<length; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - //printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - // printf("scrambling %d : e %d, c %d\n",i,e[i],((s>>(i&0x1f))&1)); - if (e[i] != 2) // <NIL> element is 2 - e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1); - } -} - -void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - int8_t* llr, - uint32_t length) -{ - - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in first call to lte_gold_generic + // x1 is set in lte_gold_generic x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 for (i=0; i<length; i++) { if ((i&0x1f)==0) { s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); + //printf("lte_gold[%d]=%x\n",i,s); reset = 0; } - - // printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); - if (((s>>(i%32))&1)==0) - llr[i] = -llr[i]; - // printf("%d\n",llr[i]); - - } -} - -/* -uint8_t get_num_pdcch_symbols(uint8_t num_dci, - DCI_ALLOC_t *dci_alloc, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe) -{ - - uint16_t numCCE = 0; - uint8_t i; - uint8_t nCCEmin = 0; - uint16_t CCE_max_used_index = 0; - uint16_t firstCCE_max = dci_alloc[0].firstCCE; - uint8_t L = dci_alloc[0].L; - - // check pdcch duration imposed by PHICH duration (Section 6.9 of 36-211) - if (frame_parms->Ncp==1) { // extended prefix - if ((frame_parms->frame_type == TDD) && - ((frame_parms->tdd_config<3)||(frame_parms->tdd_config==6)) && - ((subframe==1) || (subframe==6))) // subframes 1 and 6 (S-subframes) for 5ms switching periodicity are 2 symbols - nCCEmin = 2; - else { // 10ms switching periodicity is always 3 symbols, any DL-only subframe is 3 symbols - nCCEmin = 3; - } - } - - // compute numCCE - for (i=0; i<num_dci; i++) { - // printf("dci %d => %d\n",i,dci_alloc[i].L); - numCCE += (1<<(dci_alloc[i].L)); - - if(firstCCE_max < dci_alloc[i].firstCCE) { - firstCCE_max = dci_alloc[i].firstCCE; - L = dci_alloc[i].L; - } - } - CCE_max_used_index = firstCCE_max + (1<<L) - 1; - - //if ((9*numCCE) <= (frame_parms->N_RB_DL*2)) - if (CCE_max_used_index < get_nCCE(1, frame_parms, get_mi(frame_parms, subframe))) - return(cmax(1,nCCEmin)); - //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 4 : 5))) - else if (CCE_max_used_index < get_nCCE(2, frame_parms, get_mi(frame_parms, subframe))) - return(cmax(2,nCCEmin)); - //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 7 : 8))) - else if (CCE_max_used_index < get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))) - return(cmax(3,nCCEmin)); - else if (frame_parms->N_RB_DL<=10) { - if (frame_parms->Ncp == 0) { // normal CP - printf("numCCE %d, N_RB_DL = %d : should be returning 4 PDCCH symbols (%d,%d,%d)\n",numCCE,frame_parms->N_RB_DL, - get_nCCE(1, frame_parms, get_mi(frame_parms, subframe)), - get_nCCE(2, frame_parms, get_mi(frame_parms, subframe)), - get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))); - - if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 10 : 11))) - return(4); - } else { // extended CP - if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 9 : 10))) - return(4); - } + // printf("scrambling %d : e %d, c %d\n",i,e[i],((s>>(i&0x1f))&1)); + if (e[i] != 2) // <NIL> element is 2 + e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1); } - - - - // LOG_I(PHY," dci.c: get_num_pdcch_symbols subframe %d FATAL, illegal numCCE %d (num_dci %d)\n",subframe,numCCE,num_dci); - //for (i=0;i<num_dci;i++) { - // printf("dci_alloc[%d].L = %d\n",i,dci_alloc[i].L); - //} - //exit(-1); -exit(1); - return(0); } -*/ - uint8_t generate_dci_top(uint8_t num_pdcch_symbols, uint8_t num_dci, @@ -2211,8 +289,9 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, uint32_t gain_lin_QPSK,kprime,kprime_mod12,mprime,nsymb,symbol_offset,tti_offset; int16_t re_offset; uint8_t mi = get_mi(frame_parms,subframe); - static uint8_t e[DCI_BITS_MAX]; - static int32_t yseq0[Msymb],yseq1[Msymb],wbar0[Msymb],wbar1[Msymb]; + uint8_t e[DCI_BITS_MAX]; + uint32_t Msymb=(DCI_BITS_MAX/2); + int32_t yseq0[Msymb],yseq1[Msymb],wbar0[Msymb],wbar1[Msymb]; int32_t *y[2]; int32_t *wbar[2]; @@ -2541,1706 +620,3 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, } - -void dci_decoding(uint8_t DCI_LENGTH, - uint8_t aggregation_level, - int8_t *e, - uint8_t *decoded_output) -{ - - uint8_t dummy_w_rx[3*(MAX_DCI_SIZE_BITS+16+64)]; - int8_t w_rx[3*(MAX_DCI_SIZE_BITS+16+32)],d_rx[96+(3*(MAX_DCI_SIZE_BITS+16))]; - - uint16_t RCC; - - uint16_t D=(DCI_LENGTH+16+64); - uint16_t coded_bits; -#ifdef DEBUG_DCI_DECODING - int32_t i; -#endif - - AssertFatal(aggregation_level<4, - "dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); - - coded_bits = 72 * (1<<aggregation_level); - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," Doing DCI decoding for %d bits, DCI_LENGTH %d,coded_bits %d, e %p\n",3*(DCI_LENGTH+16),DCI_LENGTH,coded_bits,e); -#endif - - // now do decoding - memset((void*)dummy_w_rx,0,3*D); - RCC = generate_dummy_w_cc(DCI_LENGTH+16, - dummy_w_rx); - - - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," Doing DCI Rate Matching RCC %d, w %p\n",RCC,w); -#endif - - lte_rate_matching_cc_rx(RCC,coded_bits,w_rx,dummy_w_rx,e); - - sub_block_deinterleaving_cc((uint32_t)(DCI_LENGTH+16), - &d_rx[96], - &w_rx[0]); - -#ifdef DEBUG_DCI_DECODING - - for (i=0; i<16+DCI_LENGTH; i++) - LOG_I(PHY," DCI %d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); - -#endif - memset(decoded_output,0,2+((16+DCI_LENGTH)>>3)); - -#ifdef DEBUG_DCI_DECODING - printf("Before Viterbi\n"); - - for (i=0; i<16+DCI_LENGTH; i++) - printf("%d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); - -#endif - //debug_printf("Doing DCI Viterbi \n"); - phy_viterbi_lte_sse2(d_rx+96,decoded_output,16+DCI_LENGTH); - //debug_printf("Done DCI Viterbi \n"); -} - - -static uint8_t dci_decoded_output[RX_NB_TH][(MAX_DCI_SIZE_BITS+64)/8]; - -uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) -{ - return(get_nquad(num_pdcch_symbols,frame_parms,mi)/9); -} - -uint16_t get_nquad(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) -{ - - uint16_t Nreg=0; - uint8_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - if (frame_parms->Ncp == 1) { - Ngroup_PHICH<<=1; - } - - Ngroup_PHICH*=mi; - - if ((num_pdcch_symbols>0) && (num_pdcch_symbols<4)) - switch (frame_parms->N_RB_DL) { - case 6: - Nreg=12+(num_pdcch_symbols-1)*18; - break; - - case 25: - Nreg=50+(num_pdcch_symbols-1)*75; - break; - - case 50: - Nreg=100+(num_pdcch_symbols-1)*150; - break; - - case 100: - Nreg=200+(num_pdcch_symbols-1)*300; - break; - - default: - return(0); - } - - // printf("Nreg %d (%d)\n",Nreg,Nreg - 4 - (3*Ngroup_PHICH)); - return(Nreg - 4 - (3*Ngroup_PHICH)); -} - -uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe) -{ - - // check for eNB only ! - return(get_nCCE(num_pdcch_symbols, - &RC.eNB[Mod_id][CC_id]->frame_parms, - get_mi(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe))); -} - - -int get_nCCE_offset_l1(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); - - // printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); - - for (m = nb_candidates-1 ; m >=0 ; m--) { - - 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; - } - } - - if (search_space_free == 1) { - - // printf("returning %d\n",m*L); - - for (l=0; l<L; l++) - CCE_table[(m*L)+l]=1; - return(m*L); - } - } - - 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; - - for (i=0; i<=subframe; i++) - Yk = (Yk*39827)%65537; - - Yk = Yk % (nCCE/L); - - - switch (L) { - case 1: - case 2: - nb_candidates = 6; - break; - - case 4: - case 8: - nb_candidates = 2; - 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); - - 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; - } - } - - 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(-1); - } -} - - -void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars, - int do_common, - dci_detect_mode_t mode, - uint8_t subframe, - DCI_ALLOC_t *dci_alloc, - int16_t eNB_id, - uint8_t current_thread_id, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t mi, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint8_t L, - uint8_t format_si, - uint8_t format_p, - uint8_t format_ra, - uint8_t format_c, - uint8_t sizeof_bits, - uint8_t sizeof_bytes, - uint8_t *dci_cnt, - uint8_t *format0_found, - uint8_t *format_c_found, - uint32_t *CCEmap0, - uint32_t *CCEmap1, - uint32_t *CCEmap2) -{ - - uint16_t crc,CCEind,nCCE; - uint32_t *CCEmap=NULL,CCEmap_mask=0; - int L2=(1<<L); - unsigned int Yk,nb_candidates = 0,i,m; - unsigned int CCEmap_cand; - - nCCE = get_nCCE(pdcch_vars[eNB_id]->num_pdcch_symbols,frame_parms,mi); - - if (nCCE > get_nCCE(3,frame_parms,1)) { - LOG_D(PHY,"skip DCI decoding: nCCE=%d > get_nCCE(3,frame_parms,1)=%d\n", nCCE, get_nCCE(3,frame_parms,1)); - return; - } - - if (nCCE<L2) { - LOG_D(PHY,"skip DCI decoding: nCCE=%d < L2=%d\n", nCCE, L2); - return; - } - - if (mode == NO_DCI) { - LOG_D(PHY, "skip DCI decoding: expect no DCIs at subframe %d\n", subframe); - return; - } - - if (do_common == 1) { - nb_candidates = (L2==4) ? 4 : 2; - Yk=0; - } 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)pdcch_vars[eNB_id]->crnti; - - for (i=0; i<=subframe; i++) - Yk = (Yk*39827)%65537; - - Yk = Yk % (nCCE/L2); - - switch (L2) { - case 1: - case 2: - nb_candidates = 6; - break; - - case 4: - case 8: - nb_candidates = 2; - break; - - default: - DevParam(L2, do_common, eNB_id); - break; - } - } - - /* for (CCEind=0; - CCEind<nCCE2; - CCEind+=(1<<L)) {*/ - - if (nb_candidates*L2 > nCCE) - nb_candidates = nCCE/L2; - - for (m=0; m<nb_candidates; m++) { - - CCEind = (((Yk+m)%(nCCE/L2))*L2); - - if (CCEind<32) - CCEmap = CCEmap0; - else if (CCEind<64) - CCEmap = CCEmap1; - else if (CCEind<96) - CCEmap = CCEmap2; - else { - AssertFatal(1==0, - "Illegal CCEind %d (Yk %d, m %d, nCCE %d, L2 %d\n",CCEind,Yk,m,nCCE,L2); - } - - switch (L2) { - case 1: - CCEmap_mask = (1<<(CCEind&0x1f)); - break; - - case 2: - CCEmap_mask = (3<<(CCEind&0x1f)); - break; - - case 4: - CCEmap_mask = (0xf<<(CCEind&0x1f)); - break; - - case 8: - CCEmap_mask = (0xff<<(CCEind&0x1f)); - break; - - default: - AssertFatal(1==0, - "Illegal L2 value %d\n", L2 ); - } - - CCEmap_cand = (*CCEmap)&CCEmap_mask; - - // CCE is not allocated yet - - if (CCEmap_cand == 0) { - - if (do_common == 1) - LOG_D(PHY,"[DCI search nPdcch %d - common] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n", - pdcch_vars[eNB_id]->num_pdcch_symbols,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask); - else - LOG_D(PHY,"[DCI search nPdcch %d - ue spec %x] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x) format %d\n", - pdcch_vars[eNB_id]->num_pdcch_symbols,pdcch_vars[eNB_id]->crnti,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask,format_c); - - dci_decoding(sizeof_bits, - L, - &pdcch_vars[eNB_id]->e_rx[CCEind*72], - &dci_decoded_output[current_thread_id][0]); - /* - for (i=0;i<3+(sizeof_bits>>3);i++) - printf("dci_decoded_output[%d][%d] => %x\n",current_thread_id,i,dci_decoded_output[current_thread_id][i]); - */ - - crc = (crc16(&dci_decoded_output[current_thread_id][0],sizeof_bits)>>16) ^ extract_crc(&dci_decoded_output[current_thread_id][0],sizeof_bits); -#ifdef DEBUG_DCI_DECODING - printf("crc =>%x\n",crc); -#endif - - if (((L>1) && ((crc == si_rnti)|| - (crc == p_rnti)|| - (crc == ra_rnti)))|| - (crc == pdcch_vars[eNB_id]->crnti)) { - dci_alloc[*dci_cnt].dci_length = sizeof_bits; - dci_alloc[*dci_cnt].rnti = crc; - dci_alloc[*dci_cnt].L = L; - dci_alloc[*dci_cnt].firstCCE = CCEind; - - //printf("DCI FOUND !!! crc =>%x, sizeof_bits %d, sizeof_bytes %d \n",crc, sizeof_bits, sizeof_bytes); - if (sizeof_bytes<=4) { - dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0]; - dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1]; - dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3]; -#ifdef DEBUG_DCI_DECODING - printf("DCI => %x,%x,%x,%x\n",dci_decoded_output[current_thread_id][0], - dci_decoded_output[current_thread_id][1], - dci_decoded_output[current_thread_id][2], - dci_decoded_output[current_thread_id][3]); -#endif - } else { - dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0]; - dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[current_thread_id][1]; - dci_alloc[*dci_cnt].dci_pdu[5] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3]; - dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][4]; - dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][5]; - dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][6]; - dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][7]; -#ifdef DEBUG_DCI_DECODING - printf("DCI => %x,%x,%x,%x,%x,%x,%x,%x\n", - dci_decoded_output[current_thread_id][0],dci_decoded_output[current_thread_id][1],dci_decoded_output[current_thread_id][2],dci_decoded_output[current_thread_id][3], - dci_decoded_output[current_thread_id][4],dci_decoded_output[current_thread_id][5],dci_decoded_output[current_thread_id][6],dci_decoded_output[current_thread_id][7]); -#endif - } - - if (crc==si_rnti) { - dci_alloc[*dci_cnt].format = format_si; - *dci_cnt = *dci_cnt+1; - } else if (crc==p_rnti) { - dci_alloc[*dci_cnt].format = format_p; - *dci_cnt = *dci_cnt+1; - } else if (crc==ra_rnti) { - dci_alloc[*dci_cnt].format = format_ra; - // store first nCCE of group for PUCCH transmission of ACK/NAK - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - *dci_cnt = *dci_cnt+1; - } else if (crc==pdcch_vars[eNB_id]->crnti) { - - if ((mode&UL_DCI)&&(format_c == format0)&&((dci_decoded_output[current_thread_id][0]&0x80)==0)) {// check if pdu is format 0 or 1A - if (*format0_found == 0) { - dci_alloc[*dci_cnt].format = format0; - *format0_found = 1; - *dci_cnt = *dci_cnt+1; - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - } - } else if (format_c == format0) { // this is a format 1A DCI - dci_alloc[*dci_cnt].format = format1A; - *dci_cnt = *dci_cnt+1; - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - } else { - // store first nCCE of group for PUCCH transmission of ACK/NAK - if (*format_c_found == 0) { - dci_alloc[*dci_cnt].format = format_c; - *dci_cnt = *dci_cnt+1; - *format_c_found = 1; - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - } - } - } - - //LOG_I(PHY,"DCI decoding CRNTI [format: %d, nCCE[subframe: %d]: %d ], AggregationLevel %d \n",format_c, subframe, pdcch_vars[eNB_id]->nCCE[subframe],L2); - // memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_decoded_output,sizeof_bytes); - - - - switch (1<<L) { - case 1: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - - case 2: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - - case 4: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - - case 8: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - } - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY,"[DCI search] Found DCI %d rnti %x Aggregation %d length %d format %s in CCE %d (CCEmap %x) candidate %d / %d \n", - *dci_cnt,crc,1<<L,sizeof_bits,dci_format_strings[dci_alloc[*dci_cnt-1].format],CCEind,*CCEmap,m,nb_candidates ); - dump_dci(frame_parms,&dci_alloc[*dci_cnt-1]); - -#endif - return; - } // rnti match - } // CCEmap_cand == 0 -/* - if ( agregationLevel != 0xFF && - (format_c == format0 && m==0 && si_rnti != SI_RNTI)) - { - //Only valid for OAI : Save some processing time when looking for DCI format0. From the log we see the DCI only on candidate 0. - return; - } -*/ - } // candidate loop -} - -uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue, - DCI_ALLOC_t *dci_alloc, - uint8_t DCIFormat, - uint8_t agregationLevel, - int16_t eNB_id, - uint8_t subframe) -{ - - uint8_t dci_cnt=0,old_dci_cnt=0; - uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; - LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t mi = get_mi(&ue->frame_parms,subframe); - uint16_t ra_rnti=99; - uint8_t format0_found=0,format_c_found=0; - uint8_t tmode = ue->transmission_mode[eNB_id]; - uint8_t frame_type = frame_parms->frame_type; - uint8_t format0_size_bits=0,format0_size_bytes=0; - uint8_t format1_size_bits=0,format1_size_bytes=0; - dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - - } else { - format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); - } - - break; - - case 25: - default: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); - } else { - format0_size_bits = sizeof_DCI0_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); - } - - break; - - case 50: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_10MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); - - } else { - format0_size_bits = sizeof_DCI0_10MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); - format1_size_bits = sizeof_DCI1_10MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); - } - - break; - - case 100: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_20MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); - } else { - format0_size_bits = sizeof_DCI0_20MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); - format1_size_bits = sizeof_DCI1_20MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); - } - - break; - } - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - agregationLevel, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (DCIFormat == format1) - { - if ((tmode < 3) || (tmode == 7)) { - //printf("Crnti decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); - - // Now check UE_SPEC format 1 search spaces at aggregation 1 - - //printf("[DCI search] Format 1/1A aggregation 1\n"); - - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //printf("Crnti 1 decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); - - } - else if (DCIFormat == format1A) - { - AssertFatal(0,"Other Transmission mode not yet coded\n"); - } - } - else - { - LOG_W(PHY,"DCI format %d wrong or not yet implemented \n",DCIFormat); - } - - return(dci_cnt); - -} - -uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, - DCI_ALLOC_t *dci_alloc, - int do_common, - int16_t eNB_id, - uint8_t subframe) -{ - - uint8_t dci_cnt=0,old_dci_cnt=0; - uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; - LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t mi = get_mi(&ue->frame_parms,subframe); - uint16_t ra_rnti=99; - uint8_t format0_found=0,format_c_found=0; - uint8_t tmode = ue->transmission_mode[eNB_id]; - uint8_t frame_type = frame_parms->frame_type; - uint8_t format1A_size_bits=0,format1A_size_bytes=0; - uint8_t format1C_size_bits=0,format1C_size_bytes=0; - uint8_t format0_size_bits=0,format0_size_bytes=0; - uint8_t format1_size_bits=0,format1_size_bytes=0; - uint8_t format2_size_bits=0,format2_size_bytes=0; - uint8_t format2A_size_bits=0,format2A_size_bytes=0; - dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_1_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); - format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_1_5MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_1_5MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_1_5MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_1_5MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_1_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); - format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_1_5MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_1_5MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_FDD_t); - } - } - - break; - - case 25: - default: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_5MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_5MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_5MHz_t); - format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_5MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_5MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_5MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_5MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_5MHz_t); - format0_size_bits = sizeof_DCI0_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_5MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_5MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_4A_FDD_t); - } - } - - break; - - case 50: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_10MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_10MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_10MHz_t; - format1C_size_bytes = sizeof(DCI1C_10MHz_t); - format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_10MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_10MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_10MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_10MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_10MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_10MHz_t; - format1C_size_bytes = sizeof(DCI1C_10MHz_t); - format0_size_bits = sizeof_DCI0_10MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); - format1_size_bits = sizeof_DCI1_10MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_10MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_10MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_4A_FDD_t); - } - } - - break; - - case 100: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_20MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_20MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_20MHz_t; - format1C_size_bytes = sizeof(DCI1C_20MHz_t); - format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_20MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_20MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_20MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_20MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_20MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_20MHz_t; - format1C_size_bytes = sizeof(DCI1C_20MHz_t); - format0_size_bits = sizeof_DCI0_20MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); - format1_size_bits = sizeof_DCI1_20MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_20MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_20MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_4A_FDD_t); - } - } - - break; - } - - if (do_common == 1) { -#ifdef DEBUG_DCI_DECODING - printf("[DCI search] subframe %d: doing common search/format0 aggregation 4\n",subframe); -#endif - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // First check common search spaces at aggregation 4 (SI_RNTI, P_RNTI and RA_RNTI format 0/1A), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0) , - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format0, - format1A_size_bits, - format1A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 4 (SI_RNTI,P_RNTI and RA_RNTI and C-RNTI format 1C), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1C, - format1C, - format1C, - format1C, - format1C_size_bits, - format1C_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 8 (SI_RNTI,P_RNTI and RA_RNTI format 1A), - // and UE_SPEC format0 (PUSCH) too while we're at it - // printf("[DCI search] doing common search/format0 aggregation 3\n"); -#ifdef DEBUG_DCI_DECODING - printf("[DCI search] doing common search/format0 aggregation 8\n"); -#endif - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - P_RNTI, - ra_rnti, - 3, - format1A, - format1A, - format1A, - format0, - format1A_size_bits, - format1A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 8 (SI_RNTI and RA_RNTI and C-RNTI format 1C), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1C, - format1C, - format1C, - format1C, - format1C_size_bits, - format1C_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - - } - - if (ue->UE_mode[eNB_id] <= PRACH) - return(dci_cnt); - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 - // printf("[DCI search] Format 0/1A aggregation 8\n"); - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 1 dci_cnt %d\n",dci_cnt); - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 4 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - - //printf("[DCI search] Format 0 aggregation 2 dci_cnt %d\n",dci_cnt); - } - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 2 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 4 dci_cnt %d\n",dci_cnt); - } - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 1 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 8 dci_cnt %d\n",dci_cnt); - - } - // These are for CRNTI based on transmission mode - if ((tmode < 3) || (tmode == 7)) { - // Now check UE_SPEC format 1 search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 1 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff) || - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1 search spaces at aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 2 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1 search spaces at aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 4 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 1 search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 8 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#endif //ALL_AGGREGATION - } else if (tmode == 3) { - - - // LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 1 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - // Now check UE_SPEC format 2A_2A search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - LOG_D(PHY," format 2A_2A search CCEmap0 %x, format0_found %d, format_c_found %d \n", CCEmap0, format0_found, format_c_found); - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2 search spaces at aggregation 2 - LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 2 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2_2A search spaces at aggregation 4 - // LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 4 \n"); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 2_2A search spaces at aggregation 8 - LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 8 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - } else if (tmode == 4) { - - // Now check UE_SPEC format 2_2A search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2 search spaces at aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2_2A search spaces at aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 2_2A search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - } else if ((tmode==5) || (tmode==6)) { // This is MU-MIMO - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 1 -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," MU-MIMO check UE_SPEC format 1E_2A_M10PRB\n"); -#endif - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#endif //ALL_AGGREGATION - - } - - return(dci_cnt); -} diff --git a/openair1/PHY/LTE_TRANSPORT/dci.h b/openair1/PHY/LTE_TRANSPORT/dci.h index 9381dd63fdd1a3d49b50e6ce4b27793c1a1074c1..c5654aa7428203ca04b4c709eaedae3612adf84d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci.h +++ b/openair1/PHY/LTE_TRANSPORT/dci.h @@ -30,8 +30,18 @@ * \warning */ +#ifndef __DCI__h__ +#define __DCI__h__ + #include <stdint.h> +#define CCEBITS 72 +#define CCEPERSYMBOL 33 // This is for 1200 RE +#define CCEPERSYMBOL0 22 // This is for 1200 RE +#define DCI_BITS_MAX ((2*CCEPERSYMBOL+CCEPERSYMBOL0)*CCEBITS) + +//#define Mquad (Msymb/4) + /// DCI Format Type 0 (5 MHz,TDD0, 27 bits) struct DCI0_5MHz_TDD0 { /// type = 0 => DCI Format 0, type = 1 => DCI Format 1A @@ -3014,3 +3024,5 @@ struct DCI_INFO_EXTRACTED { uint64_t ap_si_nl_id:3; }; typedef struct DCI_INFO_EXTRACTED DCI_INFO_EXTRACTED_t; + +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index db36040a7d56469e653b5c0749a286fff731788f..048eb200683208c4f624cd497da72355c58084ef 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -30,776 +30,23 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" #ifdef DEBUG_DCI_TOOLS -#include "PHY/vars.h" +#include "PHY/phy_vars.h" #endif #include "assertions.h" #include "nfapi_interface.h" //#define DEBUG_HARQ -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" -//#define DEBUG_DCI - -uint32_t localRIV2alloc_LUT6[32]; -uint32_t distRIV2alloc_even_LUT6[32]; -uint32_t distRIV2alloc_odd_LUT6[32]; -uint16_t RIV2nb_rb_LUT6[32]; -uint16_t RIV2first_rb_LUT6[32]; -uint16_t RIV_max6=0; - -uint32_t localRIV2alloc_LUT25[512]; -uint32_t distRIV2alloc_even_LUT25[512]; -uint32_t distRIV2alloc_odd_LUT25[512]; -uint16_t RIV2nb_rb_LUT25[512]; -uint16_t RIV2first_rb_LUT25[512]; -uint16_t RIV_max25=0; - - -uint32_t localRIV2alloc_LUT50_0[1600]; -uint32_t localRIV2alloc_LUT50_1[1600]; -uint32_t distRIV2alloc_gap0_even_LUT50_0[1600]; -uint32_t distRIV2alloc_gap0_odd_LUT50_0[1600]; -uint32_t distRIV2alloc_gap0_even_LUT50_1[1600]; -uint32_t distRIV2alloc_gap0_odd_LUT50_1[1600]; -uint32_t distRIV2alloc_gap1_even_LUT50_0[1600]; -uint32_t distRIV2alloc_gap1_odd_LUT50_0[1600]; -uint32_t distRIV2alloc_gap1_even_LUT50_1[1600]; -uint32_t distRIV2alloc_gap1_odd_LUT50_1[1600]; -uint16_t RIV2nb_rb_LUT50[1600]; -uint16_t RIV2first_rb_LUT50[1600]; -uint16_t RIV_max50=0; - -uint32_t localRIV2alloc_LUT100_0[6000]; -uint32_t localRIV2alloc_LUT100_1[6000]; -uint32_t localRIV2alloc_LUT100_2[6000]; -uint32_t localRIV2alloc_LUT100_3[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_0[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_0[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_1[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_1[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_2[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_2[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_3[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_3[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_0[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_0[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_1[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_1[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_2[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_2[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_3[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_3[6000]; -uint16_t RIV2nb_rb_LUT100[6000]; -uint16_t RIV2first_rb_LUT100[6000]; -uint16_t RIV_max100=0; - - -extern uint32_t current_dlsch_cqi; - -// Table 8.6.3-3 36.213 -uint16_t beta_cqi[16] = {0, //reserved - 0, //reserved - 9, //1.125 - 10, //1.250 - 11, //1.375 - 13, //1.625 - 14, //1.750 - 16, //2.000 - 18, //2.250 - 20, //2.500 - 23, //2.875 - 25, //3.125 - 28, //3.500 - 32, //4.000 - 40, //5.000 - 50 - }; //6.250 - -// Table 8.6.3-2 36.213 -uint16_t beta_ri[16] = {10, //1.250 - 13, //1.625 - 16, //2.000 - 20, //2.500 - 25, //3.125 - 32, //4.000 - 40, //5.000 - 50, //6.250 - 64, //8.000 - 80, //10.000 - 101, //12.625 - 127, //15.875 - 160, //20.000 - 0, //reserved - 0, //reserved - 0 - }; //reserved - -// Table 8.6.3-2 36.213 -uint16_t beta_ack[16] = {16, //2.000 - 20, //2.500 - 25, //3.125 - 32, //4.000 - 40, //5.000 - 50, //6.250 - 64, //8.000 - 80, //10.000 - 101, //12.625 - 127, //15.875 - 160, //20.000 - 248, //31.000 - 400, //50.000 - 640, //80.000 - 808 - };//126.00 - -int8_t delta_PUSCH_abs[4] = {-4,-1,1,4}; -int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; - -int8_t *delta_PUCCH_lut = delta_PUSCH_acc; - -void conv_eMTC_rballoc(uint16_t resource_block_coding, - uint32_t N_RB_DL, - uint32_t *rb_alloc) { - - - int narrowband = resource_block_coding>>5; - int RIV = resource_block_coding&31; - int N_NB_DL = N_RB_DL/6; - int i0 = (N_RB_DL>>1) - (3*N_NB_DL); - int first_rb = (6*narrowband)+i0; - int alloc = localRIV2alloc_LUT6[RIV]; - int ind = first_rb>>5; - int ind_mod = first_rb&31; - - if (((N_RB_DL&1) > 0) && (narrowband>=(N_NB_DL>>1))) first_rb++; - rb_alloc[0] = 0; - rb_alloc[1] = 0; - rb_alloc[2] = 0; - rb_alloc[3] = 0; - rb_alloc[ind] = alloc<<ind_mod; - if (ind_mod > 26) rb_alloc[ind+1] = alloc>>(6-(ind_mod-26)); -} - -void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2) -{ - - uint32_t i,shift,subset; - rb_alloc2[0] = 0; - rb_alloc2[1] = 0; - rb_alloc2[2] = 0; - rb_alloc2[3] = 0; - - // printf("N_RB_DL %d, ra_header %d, rb_alloc %x\n",N_RB_DL,ra_header,rb_alloc); - - switch (N_RB_DL) { - - case 6: - rb_alloc2[0] = rb_alloc&0x3f; - break; - - case 25: - if (ra_header == 0) {// Type 0 Allocation - - for (i=12; i>0; i--) { - if ((rb_alloc&(1<<i)) != 0) - rb_alloc2[0] |= (3<<((2*(12-i)))); - - // printf("rb_alloc2 (type 0) %x\n",rb_alloc2); - } - - if ((rb_alloc&1) != 0) - rb_alloc2[0] |= (1<<24); - } else { - subset = rb_alloc&1; - shift = (rb_alloc>>1)&1; - - for (i=0; i<11; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - rb_alloc2[0] |= (1<<(2*i)); - - //printf("rb_alloc2 (type 1) %x\n",rb_alloc2); - } - - if ((shift == 0) && (subset == 1)) - rb_alloc2[0]<<=1; - else if ((shift == 1) && (subset == 0)) - rb_alloc2[0]<<=4; - else if ((shift == 1) && (subset == 1)) - rb_alloc2[0]<<=3; - } - - break; - - case 50: - AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=50\n"); - - for (i=16; i>0; i--) { - if ((rb_alloc&(1<<i)) != 0) - rb_alloc2[(3*(16-i))>>5] |= (7<<((3*(16-i))%32)); - } - - // bit mask across - if ((rb_alloc2[0]>>31)==1) - rb_alloc2[1] |= 1; - - if ((rb_alloc&1) != 0) - rb_alloc2[1] |= (3<<16); - break; - - case 100: - AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=100\n"); - for (i=0; i<25; i++) { - if ((rb_alloc&(1<<(24-i))) != 0) - rb_alloc2[(4*i)>>5] |= (0xf<<((4*i)%32)); - - // printf("rb_alloc2[%d] (type 0) %x (%d)\n",(4*i)>>5,rb_alloc2[(4*i)>>5],rb_alloc&(1<<i)); - } - - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", N_RB_DL); - DevParam (N_RB_DL, 0, 0); - break; - } - -} - - - -uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL) -{ - - uint32_t nprb=0,i; - - switch (N_RB_DL) { - case 6: - for (i=0; i<6; i++) { - if ((rb_alloc&(1<<i)) != 0) - nprb += 1; - } - - break; - - case 25: - if (ra_header == 0) {// Type 0 Allocation - - for (i=12; i>0; i--) { - if ((rb_alloc&(1<<i)) != 0) - nprb += 2; - } - - if ((rb_alloc&1) != 0) - nprb += 1; - } else { - for (i=0; i<11; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - nprb += 1; - } - } - - break; - - case 50: - if (ra_header == 0) {// Type 0 Allocation - - for (i=0; i<16; i++) { - if ((rb_alloc&(1<<(16-i))) != 0) - nprb += 3; - } - - if ((rb_alloc&1) != 0) - nprb += 2; - - } else { - for (i=0; i<17; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - nprb += 1; - } - } - - break; - - case 100: - if (ra_header == 0) {// Type 0 Allocation - - for (i=0; i<25; i++) { - if ((rb_alloc&(1<<(24-i))) != 0) - nprb += 4; - } - } else { - for (i=0; i<25; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - nprb += 1; - } - } - - break; - - default: - LOG_E(PHY,"Invalide N_RB_DL %d\n", N_RB_DL); - DevParam (N_RB_DL, 0, 0); - break; - } - - return(nprb); -} - -uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs) -{ - - 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); - - return(RIV); -} - -// Convert a DCI Format 1C RIV to a Format 1A RIV -// This extracts the start and length in PRBs from the 1C rballoc and -// recomputes the RIV as if it were the 1A rballoc - -uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL) { - - int NpDLVRB,N_RB_step,LpCRBsm1,RBpstart; - - switch (N_RB_DL) { - - case 6: // N_RB_step = 2, NDLVRB = 6, NpDLVRB = 3 - NpDLVRB = 3; - N_RB_step = 2; - break; - case 25: // N_RB_step = 2, NDLVRB = 24, NpDLVRB = 12 - NpDLVRB = 12; - N_RB_step = 2; - break; - case 50: // N_RB_step = 4, NDLVRB = 46, NpDLVRB = 11 - NpDLVRB = 11; - N_RB_step = 4; - break; - case 100: // N_RB_step = 4, NDLVRB = 96, NpDLVRB = 24 - NpDLVRB = 24; - N_RB_step = 4; - break; - default: - NpDLVRB = 24; - N_RB_step = 4; - break; - } - - // This is the 1C part from 7.1.6.3 in 36.213 - LpCRBsm1 = rballoc/NpDLVRB; - // printf("LpCRBs = %d\n",LpCRBsm1+1); - - if (LpCRBsm1 <= (NpDLVRB/2)) { - RBpstart = rballoc % NpDLVRB; - } - else { - LpCRBsm1 = NpDLVRB-LpCRBsm1; - RBpstart = NpDLVRB-(rballoc%NpDLVRB); - } - // printf("RBpstart %d\n",RBpstart); - return(computeRIV(N_RB_DL,N_RB_step*RBpstart,N_RB_step*(LpCRBsm1+1))); - -} - -uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { - - int offset; - - switch (N_RB_DL) { - - case 6: - // N_RB_DL = tildeN_RB_DL = 6 - // Ngap = 4 , P=1, Nrow = 2, Nnull = 2 - - switch (vrb) { - case 0: // even: 0->0, 1->2, odd: 0->3, 1->5 - case 1: - return ((3*odd_slot) + 2*(vrb&3))%6; - break; - case 2: // even: 2->3, 3->5, odd: 2->0, 3->2 - case 3: - return ((3*odd_slot) + 2*(vrb&3) + 5)%6; - break; - case 4: // even: 4->1, odd: 4->4 - return ((3*odd_slot) + 1)%6; - case 5: // even: 5->4, odd: 5->1 - return ((3*odd_slot) + 4)%6; - break; - } - break; - - case 15: - if (vrb<12) { - if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11 - return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); - else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13 - return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); - } - if (vrb==12) - return (3+(7*odd_slot)) % 14; - if (vrb==13) - return (10+(7*odd_slot)) % 14; - return 14; - break; - - case 25: - return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); - break; - - case 50: // P=3 - if (Ngap==0) { - // Nrow=12,Nnull=2,NVRBDL=46,Ngap1= 27 - if (vrb>=23) - offset=4; - else - offset=0; - if (vrb<44) { - if ((vrb&3)>=2) - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; - else - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; - } - if (vrb==44) // even: 44->11, odd: 45->34 - return offset+((23*odd_slot) + 22-12+1); - if (vrb==45) // even: 45->10, odd: 45->33 - return offset+((23*odd_slot) + 22+12); - if (vrb==46) - return offset+46+((23*odd_slot) + 23-12+1) % 46; - if (vrb==47) - return offset+46+((23*odd_slot) + 23+12) % 46; - if (vrb==48) - return offset+46+((23*odd_slot) + 23-12+1) % 46; - if (vrb==49) - return offset+46+((23*odd_slot) + 23+12) % 46; - } - else { - // Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27 - if (vrb>=9) - offset=18; - else - offset=0; - - if (vrb<12) { - if ((vrb&3)>=2) - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; - else - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; - } - else { - return offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18); - } - } - break; - case 75: - // Ngap1 = 32, NVRBRL=64, P=4, Nrow= 16, Nnull=0 - if (Ngap ==0) { - return ((32*odd_slot) + 16*(vrb&3) + (vrb>>2))%64 + (vrb/64); - } else { - // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); - } - break; - case 100: - // Ngap1 = 48, NVRBDL=96, Nrow=24, Nnull=0 - if (Ngap ==0) { - return ((48*odd_slot) + 24*(vrb&3) + (vrb>>2))%96 + (vrb/96); - } else { - // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); - } - break; - default: - LOG_E(PHY,"Unknown N_RB_DL %d\n",N_RB_DL); - return 0; - } - return 0; - -} - - -void generate_RIV_tables() -{ - - // 6RBs localized RIV - uint8_t Lcrbs,RBstart; - uint16_t RIV; - uint32_t alloc0,allocdist0_0_even,allocdist0_0_odd,allocdist0_1_even,allocdist0_1_odd; - uint32_t alloc1,allocdist1_0_even,allocdist1_0_odd,allocdist1_1_even,allocdist1_1_odd; - uint32_t alloc2,allocdist2_0_even,allocdist2_0_odd,allocdist2_1_even,allocdist2_1_odd; - uint32_t alloc3,allocdist3_0_even,allocdist3_0_odd,allocdist3_1_even,allocdist3_1_odd; - uint32_t nVRB,nVRB_even_dist,nVRB_odd_dist; - - for (RBstart=0; RBstart<6; RBstart++) { - alloc0 = 0; - allocdist0_0_even = 0; - allocdist0_0_odd = 0; - for (Lcrbs=1; Lcrbs<=(6-RBstart); Lcrbs++) { - //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); - nVRB = Lcrbs-1+RBstart; - alloc0 |= (1<<nVRB); - allocdist0_0_even |= (1<<get_prb(6,0,nVRB,0)); - allocdist0_0_odd |= (1<<get_prb(6,1,nVRB,0)); - RIV=computeRIV(6,RBstart,Lcrbs); - - if (RIV>RIV_max6) - RIV_max6 = RIV; - - // printf("RIV %d (%d) : first_rb %d NBRB %d\n",RIV,localRIV2alloc_LUT25[RIV],RBstart,Lcrbs); - localRIV2alloc_LUT6[RIV] = alloc0; - distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even; - distRIV2alloc_odd_LUT6[RIV] = allocdist0_0_odd; - RIV2nb_rb_LUT6[RIV] = Lcrbs; - RIV2first_rb_LUT6[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<25; RBstart++) { - alloc0 = 0; - allocdist0_0_even = 0; - allocdist0_0_odd = 0; - for (Lcrbs=1; Lcrbs<=(25-RBstart); Lcrbs++) { - nVRB = Lcrbs-1+RBstart; - //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); - alloc0 |= (1<<nVRB); - allocdist0_0_even |= (1<<get_prb(25,0,nVRB,0)); - allocdist0_0_odd |= (1<<get_prb(25,1,nVRB,0)); - - //printf("alloc 0 %x, allocdist0_even %x, allocdist0_odd %x\n",alloc0,allocdist0_0_even,allocdist0_0_odd); - RIV=computeRIV(25,RBstart,Lcrbs); - - if (RIV>RIV_max25) - RIV_max25 = RIV;; - - - localRIV2alloc_LUT25[RIV] = alloc0; - distRIV2alloc_even_LUT25[RIV] = allocdist0_0_even; - distRIV2alloc_odd_LUT25[RIV] = allocdist0_0_odd; - RIV2nb_rb_LUT25[RIV] = Lcrbs; - RIV2first_rb_LUT25[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<50; RBstart++) { - alloc0 = 0; - alloc1 = 0; - allocdist0_0_even=0; - allocdist1_0_even=0; - allocdist0_0_odd=0; - allocdist1_0_odd=0; - allocdist0_1_even=0; - allocdist1_1_even=0; - allocdist0_1_odd=0; - allocdist1_1_odd=0; - - for (Lcrbs=1; Lcrbs<=(50-RBstart); Lcrbs++) { - - nVRB = Lcrbs-1+RBstart; - - - if (nVRB<32) - alloc0 |= (1<<nVRB); - else - alloc1 |= (1<<(nVRB-32)); - - // Distributed Gap1, even slot - nVRB_even_dist = get_prb(50,0,nVRB,0); - if (nVRB_even_dist<32) - allocdist0_0_even |= (1<<nVRB_even_dist); - else - allocdist1_0_even |= (1<<(nVRB_even_dist-32)); - - // Distributed Gap1, odd slot - nVRB_odd_dist = get_prb(50,1,nVRB,0); - if (nVRB_odd_dist<32) - allocdist0_0_odd |= (1<<nVRB_odd_dist); - else - allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); - - // Distributed Gap2, even slot - nVRB_even_dist = get_prb(50,0,nVRB,1); - if (nVRB_even_dist<32) - allocdist0_1_even |= (1<<nVRB_even_dist); - else - allocdist1_1_even |= (1<<(nVRB_even_dist-32)); - - // Distributed Gap2, odd slot - nVRB_odd_dist = get_prb(50,1,nVRB,1); - if (nVRB_odd_dist<32) - allocdist0_1_odd |= (1<<nVRB_odd_dist); - else - allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); - - RIV=computeRIV(50,RBstart,Lcrbs); - - if (RIV>RIV_max50) - RIV_max50 = RIV; - - // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); - localRIV2alloc_LUT50_0[RIV] = alloc0; - localRIV2alloc_LUT50_1[RIV] = alloc1; - distRIV2alloc_gap0_even_LUT50_0[RIV] = allocdist0_0_even; - distRIV2alloc_gap0_even_LUT50_1[RIV] = allocdist1_0_even; - distRIV2alloc_gap0_odd_LUT50_0[RIV] = allocdist0_0_odd; - distRIV2alloc_gap0_odd_LUT50_1[RIV] = allocdist1_0_odd; - distRIV2alloc_gap1_even_LUT50_0[RIV] = allocdist0_1_even; - distRIV2alloc_gap1_even_LUT50_1[RIV] = allocdist1_1_even; - distRIV2alloc_gap1_odd_LUT50_0[RIV] = allocdist0_1_odd; - distRIV2alloc_gap1_odd_LUT50_1[RIV] = allocdist1_1_odd; - RIV2nb_rb_LUT50[RIV] = Lcrbs; - RIV2first_rb_LUT50[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<100; RBstart++) { - alloc0 = 0; - alloc1 = 0; - alloc2 = 0; - alloc3 = 0; - allocdist0_0_even=0; - allocdist1_0_even=0; - allocdist2_0_even=0; - allocdist3_0_even=0; - allocdist0_0_odd=0; - allocdist1_0_odd=0; - allocdist2_0_odd=0; - allocdist3_0_odd=0; - allocdist0_1_even=0; - allocdist1_1_even=0; - allocdist2_1_even=0; - allocdist3_1_even=0; - allocdist0_1_odd=0; - allocdist1_1_odd=0; - allocdist2_1_odd=0; - allocdist3_1_odd=0; - - for (Lcrbs=1; Lcrbs<=(100-RBstart); Lcrbs++) { - - nVRB = Lcrbs-1+RBstart; - - if (nVRB<32) - alloc0 |= (1<<nVRB); - else if (nVRB<64) - alloc1 |= (1<<(nVRB-32)); - else if (nVRB<96) - alloc2 |= (1<<(nVRB-64)); - else - alloc3 |= (1<<(nVRB-96)); - - // Distributed Gap1, even slot - nVRB_even_dist = get_prb(100,0,nVRB,0); - -// if ((RBstart==0) && (Lcrbs<=8)) -// printf("nVRB %d => nVRB_even_dist %d\n",nVRB,nVRB_even_dist); - - - if (nVRB_even_dist<32) - allocdist0_0_even |= (1<<nVRB_even_dist); - else if (nVRB_even_dist<64) - allocdist1_0_even |= (1<<(nVRB_even_dist-32)); - else if (nVRB_even_dist<96) - allocdist2_0_even |= (1<<(nVRB_even_dist-64)); - else - allocdist3_0_even |= (1<<(nVRB_even_dist-96)); -/* if ((RBstart==0) && (Lcrbs<=8)) - printf("rballoc =>(%08x.%08x.%08x.%08x)\n", - allocdist0_0_even, - allocdist1_0_even, - allocdist2_0_even, - allocdist3_0_even - ); -*/ - // Distributed Gap1, odd slot - nVRB_odd_dist = get_prb(100,1,nVRB,0); - if (nVRB_odd_dist<32) - allocdist0_0_odd |= (1<<nVRB_odd_dist); - else if (nVRB_odd_dist<64) - allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); - else if (nVRB_odd_dist<96) - allocdist2_0_odd |= (1<<(nVRB_odd_dist-64)); - else - allocdist3_0_odd |= (1<<(nVRB_odd_dist-96)); - - - // Distributed Gap2, even slot - nVRB_even_dist = get_prb(100,0,nVRB,1); - if (nVRB_even_dist<32) - allocdist0_1_even |= (1<<nVRB_even_dist); - else if (nVRB_even_dist<64) - allocdist1_1_even |= (1<<(nVRB_even_dist-32)); - else if (nVRB_even_dist<96) - allocdist2_1_even |= (1<<(nVRB_even_dist-64)); - else - allocdist3_1_even |= (1<<(nVRB_even_dist-96)); - - - // Distributed Gap2, odd slot - nVRB_odd_dist = get_prb(100,1,nVRB,1); - if (nVRB_odd_dist<32) - allocdist0_1_odd |= (1<<nVRB_odd_dist); - else if (nVRB_odd_dist<64) - allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); - else if (nVRB_odd_dist<96) - allocdist2_1_odd |= (1<<(nVRB_odd_dist-64)); - else - allocdist3_1_odd |= (1<<(nVRB_odd_dist-96)); - - - RIV=computeRIV(100,RBstart,Lcrbs); - - if (RIV>RIV_max100) - RIV_max100 = RIV; - - // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); - localRIV2alloc_LUT100_0[RIV] = alloc0; - localRIV2alloc_LUT100_1[RIV] = alloc1; - localRIV2alloc_LUT100_2[RIV] = alloc2; - localRIV2alloc_LUT100_3[RIV] = alloc3; - distRIV2alloc_gap0_even_LUT100_0[RIV] = allocdist0_0_even; - distRIV2alloc_gap0_even_LUT100_1[RIV] = allocdist1_0_even; - distRIV2alloc_gap0_even_LUT100_2[RIV] = allocdist2_0_even; - distRIV2alloc_gap0_even_LUT100_3[RIV] = allocdist3_0_even; - distRIV2alloc_gap0_odd_LUT100_0[RIV] = allocdist0_0_odd; - distRIV2alloc_gap0_odd_LUT100_1[RIV] = allocdist1_0_odd; - distRIV2alloc_gap0_odd_LUT100_2[RIV] = allocdist2_0_odd; - distRIV2alloc_gap0_odd_LUT100_3[RIV] = allocdist3_0_odd; - distRIV2alloc_gap1_even_LUT100_0[RIV] = allocdist0_1_even; - distRIV2alloc_gap1_even_LUT100_1[RIV] = allocdist1_1_even; - distRIV2alloc_gap1_even_LUT100_2[RIV] = allocdist2_1_even; - distRIV2alloc_gap1_even_LUT100_3[RIV] = allocdist3_1_even; - distRIV2alloc_gap1_odd_LUT100_0[RIV] = allocdist0_1_odd; - distRIV2alloc_gap1_odd_LUT100_1[RIV] = allocdist1_1_odd; - distRIV2alloc_gap1_odd_LUT100_2[RIV] = allocdist2_1_odd; - distRIV2alloc_gap1_odd_LUT100_3[RIV] = allocdist3_1_odd; - - RIV2nb_rb_LUT100[RIV] = Lcrbs; - RIV2first_rb_LUT100[RIV] = RBstart; - } - } -} - -// Ngap = 3, N_VRB_DL=6, P=1, N_row=2, N_null=4*2-6=2 -// permutation for even slots : -// n_PRB'(0,2,4) = (0,1,2), n_PRB'(1,3,5) = (4,5,6) -// n_PRB''(0,1,2,3) = (0,2,4,6) -// => n_tilde_PRB(5) = (4) -// n_tilde_PRB(4) = (1) -// n_tilde_PRB(2,3) = (3,5) -// n_tilde_PRB(0,1) = (0,2) +#include "LAYER2/MAC/mac.h" +//#define DEBUG_DCI +#include "dci_tools_common_extern.h" +#include "transport_proto.h" int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) { @@ -840,25 +87,8 @@ int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) } -uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci) -{ - - return(localRIV2alloc_LUT25[rb_alloc_dci]); - -} -/* -uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti) -{ - unsigned char UE_id; - // find the UE_index corresponding to rnti - UE_id = find_ue(rnti,RC.eNB[Mod_id][CC_id]); - DevAssert( UE_id != (unsigned char)-1 ); - - return(RC.eNB[Mod_id][CC_id]->transmission_mode[UE_id]); -} -*/ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,nfapi_dl_config_dci_dl_pdu *pdu) { @@ -2710,6386 +1940,4 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame ulsch->harq_processes[harq_pid]->round); } -int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) -{ - switch (dci->format) { - - case format0: // This is an UL SCH allocation so nothing here, inform MAC - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format0 (TDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 25: - LOG_D(PHY,"DCI format0 (TDD1-6, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 50: - LOG_D(PHY,"DCI format0 (TDD1-6, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 100: - LOG_D(PHY,"DCI format0 (TDD1-6, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else if (frame_parms->frame_type == FDD) - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format0 (FDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 25: - LOG_D(PHY,"DCI format0 (FDD, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 50: - LOG_D(PHY,"DCI format0 (FDD, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 100: - LOG_D(PHY,"DCI format0 (FDD, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1: - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) - - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1 (TDD 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 25: - LOG_D(PHY,"DCI format1 (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 50: - LOG_D(PHY,"DCI format1 (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 100: - LOG_D(PHY,"DCI format1 (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else if (frame_parms->frame_type == FDD) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1 (FDD, 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format1 (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format1 (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format1 (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1A: // This is DLSCH allocation for control traffic - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1A (TDD1-6, 1_5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 25: - LOG_D(PHY,"DCI format1A (TDD1-6, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %d (NB_RB %d)\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 50: - LOG_D(PHY,"DCI format1A (TDD1-6, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 100: - LOG_D(PHY,"DCI format1A (TDD1-6, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - } else if (frame_parms->frame_type == FDD) { - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1A(FDD, 1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format1A(FDD, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format1A(FDD, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format1A(FDD, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - - break; - - case format1C: // This is DLSCH allocation for control traffic - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1C (1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n", - ((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT6[conv_1C_RIV(((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,6)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 25: - LOG_D(PHY,"DCI format1C (5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[conv_1C_RIV(((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,25)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 50: - LOG_D(PHY,"DCI format1C (10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"Ngap %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->Ngap); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,50)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 100: - LOG_D(PHY,"DCI format1C (20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"Ngap %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->Ngap); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,100)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - break; - - case format2: - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } else if (frame_parms->frame_type == FDD) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - - LOG_D(PHY,"DCI format2 2 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, swap %d, TPMI %d, TPC %d\n", - - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - - case 6: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format2A: - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap - ); - break; - - case 25: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - case 50: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - case 100: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } else if (frame_parms->frame_type == FDD) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - - case 6: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1E_2A_M10PRB: - - LOG_D(PHY,"DCI format1E_2A_M10PRB, rnti %x (%8x): harq_pid %d, rah %d, rb_alloc %x, mcs %d, rv %d, tpmi %d, ndi %d, dl_power_offset %d\n", - dci->rnti, - ((uint32_t *)&dci->dci_pdu)[0], - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->harq_pid, - //((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->dl_power_off - ); - - break; - - default: - LOG_E(PHY,"dci_tools.c: dump_dci, unknown format %d\n",dci->format); - return(-1); - } - - return(0); -} - -void extract_dci1A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - uint8_t harq_pid=0; - uint32_t rballoc=0; - uint8_t vrb_type=0; - uint8_t mcs=0; - uint8_t rv=0; - uint8_t ndi=0; - uint8_t TPC=0; - - uint8_t dai=0; - - switch (N_RB_DL) { - case 6: - if (frame_type == TDD) { - vrb_type = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - break; - - case 25: - - if (frame_type == TDD) { - vrb_type = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai; - //printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_5MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - - break; - - case 50: - if (frame_type == TDD) { - vrb_type = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_10MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_10MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, vrb_type %d, rballoc %x,ndi %d, rv %d, TPC %d\n",mcs,vrb_type,rballoc,ndi,rv,TPC); - } - break; - - case 100: - if (frame_type == TDD) { - vrb_type = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_20MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_20MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - break; - } - - pdci_info_extarcted->vrb_type = vrb_type; - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rv1 = rv; - pdci_info_extarcted->ndi1 = ndi; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->dai = dai; -} - -void extract_dci1C_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t mcs=0; - - switch (N_RB_DL) { - case 6: - mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 25: - mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 50: - mcs = ((DCI1C_10MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_10MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 100: - mcs = ((DCI1C_20MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_20MHz_t *)dci_pdu)->rballoc,6); - break; - - default: - AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",N_RB_DL); - break; - } - - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rballoc = rballoc; -} - -void extract_dci1_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t mcs=0; - uint8_t rah=0; - uint8_t rv=0; - uint8_t TPC=0; - uint8_t ndi=0; - uint8_t harq_pid=0; - - switch (N_RB_DL) { - case 6: - if (frame_type == TDD) { - mcs = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 25: - if (frame_type == TDD) { - mcs = ((DCI1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_5MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_5MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_5MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_5MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 50: - if (frame_type == TDD) { - mcs = ((DCI1_10MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_10MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_10MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_10MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_10MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_10MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_10MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_10MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_10MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_10MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_10MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_10MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_10MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 100: - if (frame_type == TDD) { - mcs = ((DCI1_20MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_20MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_20MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_20MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_20MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_20MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_20MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_20MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_20MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_20MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_20MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_20MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_20MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - } - - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rv1 = rv; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->ndi1 = ndi; - pdci_info_extarcted->harq_pid = harq_pid; - -} - -void extract_dci2_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t rah=0; - uint8_t mcs1=0; - uint8_t mcs2=0; - uint8_t rv1=0; - uint8_t rv2=0; - uint8_t ndi1=0; - uint8_t ndi2=0; - uint8_t tbswap=0; - uint8_t tpmi=0; - uint8_t harq_pid=0; - uint8_t TPC=0; - - switch (N_RB_DL) { - - case 6: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 25: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 50: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 100: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - } - - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->mcs1 = mcs1; - pdci_info_extarcted->mcs2 = mcs2; - pdci_info_extarcted->rv1 = rv1; - pdci_info_extarcted->rv2 = rv2; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->tb_swap = tbswap; - pdci_info_extarcted->tpmi = tpmi; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->ndi1 = ndi1; - pdci_info_extarcted->ndi2 = ndi2; - -} - -void extract_dci2A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t rah=0; - uint8_t mcs1=0; - uint8_t mcs2=0; - uint8_t rv1=0; - uint8_t rv2=0; - uint8_t ndi1=0; - uint8_t ndi2=0; - uint8_t tbswap=0; - uint8_t tpmi=0; - uint8_t harq_pid=0; - uint8_t TPC=0; - - AssertFatal( (nb_antenna_ports_eNB == 2) || (nb_antenna_ports_eNB == 4), "unsupported nb_antenna_ports_eNB %d\n", nb_antenna_ports_eNB); - switch (N_RB_DL) { - - case 6: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - - case 25: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - break; - - case 50: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - - case 100: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - } - - pdci_info_extarcted->mcs1 = mcs1; - pdci_info_extarcted->mcs2 = mcs2; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->rv1 = rv1; - pdci_info_extarcted->rv2 = rv2; - pdci_info_extarcted->ndi1 = ndi1; - pdci_info_extarcted->ndi2 = ndi2; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->tb_swap = tbswap; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->tpmi = tpmi; -} - -int check_dci_format1_1a_coherency(DCI_format_t dci_format, - uint8_t N_RB_DL, - uint16_t rnti, - uint16_t tc_rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint32_t frame, - uint8_t subframe, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_UE_HARQ_t *pdlsch0_harq) -{ - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t rah = pdci_info_extarcted->rah; -#ifdef DEBUG_DCI - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t ndi1 = pdci_info_extarcted->ndi1; -#endif - - uint8_t NPRB = 0; - long long int RIV_max = 0; - -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1-1A] AbsSubframe %d.%d dci_format %d\n", frame, subframe, dci_format); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rnti %x\n", rnti); - LOG_I(PHY,"[DCI-FORMAT-1-1A] harq_pid %d\n", harq_pid); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rah %d\n", rah); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rballoc %x\n", rballoc); - LOG_I(PHY,"[DCI-FORMAT-1-1A] mcs1 %d\n", mcs1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rv1 %d\n", rv1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] ndi1 %d\n", ndi1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] TPC %d\n", TPC); -#endif - - - // I- check dci content minimum coherency - if( ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) && harq_pid > 0) - { - return(0); - } - - if(harq_pid>=8) - { - // LOG_I(PHY,"bad harq id \n"); - return(0); - } - - if(dci_format == format1 && ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) ) - { - // LOG_I(PHY,"bad dci format \n"); - return(0); - } - - - if( mcs1 > 28) - { - if(pdlsch0_harq->round == 0) - { - // LOG_I(PHY,"bad dci mcs + round \n"); - return(0); - } - - if((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - // LOG_I(PHY,"bad dci mcs + rnti \n"); - return(0); - } - } - - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - NPRB = (TPC&1) + 2; - switch (N_RB_DL) { - case 6: - RIV_max = RIV_max6; - break; - case 25: - RIV_max = RIV_max25; - break; - case 50: - RIV_max = RIV_max50; - break; - case 100: - RIV_max = RIV_max100; - break; - } - } - else - { - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max6; - else - RIV_max = 0x3F; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max25; - else - RIV_max = 0x1FFF; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max50; - else - RIV_max = 0x1FFFF; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max100; - else - RIV_max = 0x1FFFFFF; - break; - } - } - - - if(dci_format == format1) - { - NPRB = conv_nprb(rah, rballoc, N_RB_DL); - } - - - if(rballoc > RIV_max) - { - // LOG_I(PHY,"bad dci rballoc rballoc %d RIV_max %lld \n",rballoc, RIV_max); - // DCI false detection - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - // LOG_I(PHY,"bad NPRB = 0 \n"); - return(0); - } - - // this a retransmission - if(pdlsch0_harq->round>0) - { - // compare old TBS to new TBS - if((mcs1<29) && (pdlsch0_harq->TBS != TBStable[get_I_TBS(mcs1)][NPRB-1])) - { - // this is an eNB issue - // retransmisison but old and new TBS are different !!! - // work around, consider it as a new transmission - LOG_E(PHY,"Format1A Retransmission but TBS are different: consider it as new transmission !!! \n"); - pdlsch0_harq->round = 0; - //return(0); // ?? to cross check - } - } - - return(1); -} - -int check_dci_format1c_coherency(uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - uint16_t rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - LTE_DL_UE_HARQ_t *pdlsch0_harq) -{ - uint32_t rballoc = pdci_info_extarcted->rballoc; - - uint8_t NPRB = 0; - uint32_t RIV_max = 0; - - // I- check dci content minimum coherency - - if((rnti!=si_rnti) && (rnti!=p_rnti) && (rnti!=ra_rnti)) - return(0); - - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - RIV_max = RIV_max6; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - RIV_max = RIV_max25; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - RIV_max = RIV_max50; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - RIV_max = RIV_max100; - break; - } - - if(rballoc > RIV_max) - { - // DCI false detection - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - return(0); - } - - return(1); -} - -int check_dci_format2_2a_coherency(DCI_format_t dci_format, - uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - uint16_t rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - LTE_DL_UE_HARQ_t *pdlsch0_harq, - LTE_DL_UE_HARQ_t *pdlsch1_harq) -{ - uint8_t rah = pdci_info_extarcted->rah; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t mcs2 = pdci_info_extarcted->mcs2; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t rv2 = pdci_info_extarcted->rv2; - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - -#ifdef DEBUG_DCI - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t ndi2 = pdci_info_extarcted->ndi2; -#endif - - uint8_t NPRB = 0; - long long RIV_max = 0; - -#ifdef DEBUG_DCI - LOG_I(PHY, "extarcted dci - dci_format %d \n", dci_format); - LOG_I(PHY, "extarcted dci - rnti %d \n", rnti); - LOG_I(PHY, "extarcted dci - rah %d \n", rah); - LOG_I(PHY, "extarcted dci - mcs1 %d \n", mcs1); - LOG_I(PHY, "extarcted dci - mcs2 %d \n", mcs2); - LOG_I(PHY, "extarcted dci - rv1 %d \n", rv1); - LOG_I(PHY, "extarcted dci - rv2 %d \n", rv2); - //LOG_I(PHY, "extarcted dci - ndi1 %d \n", ndi1); - //LOG_I(PHY, "extarcted dci - ndi2 %d \n", ndi2); - LOG_I(PHY, "extarcted dci - rballoc %x \n", rballoc); - LOG_I(PHY, "extarcted dci - harq pid %d \n", harq_pid); - LOG_I(PHY, "extarcted dci - round0 %d \n", pdlsch0_harq->round); - LOG_I(PHY, "extarcted dci - round1 %d \n", pdlsch1_harq->round); -#endif - - // I- check dci content minimum coherency - if(harq_pid>=8) - { - // LOG_I(PHY,"bad harq pid\n"); - return(0); - } - - if( (rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti) ) - { - // LOG_I(PHY,"bad rnti\n"); - return(0); - } - - - if( mcs1 > 28) - { - if(pdlsch0_harq->round == 0) - { - // LOG_I(PHY,"bad mcs1\n"); - return(0); - } - } - - if( mcs2 > 28) - { - if(pdlsch1_harq->round == 0) - { - // LOG_I(PHY,"bad mcs2\n"); - return(0); - } - } - - - if((pdlsch0_harq->round == 0) && (rv1 > 0) && (mcs1 != 0)) - { - // DCI false detection - // LOG_I(PHY,"bad rv1\n"); - return(0); - } - - if((pdlsch1_harq->round == 0) && (rv2 > 0) && (mcs2 != 0)) - { - // DCI false detection - // LOG_I(PHY,"bad rv2\n"); - return(0); - } - - - switch (N_RB_DL) { - case 6: - if (rah == 0) - { - //RBG = 1; - RIV_max = 0x3F; - } - else - { - RIV_max = RIV_max6; - } - break; - case 25: - if (rah == 0) - { - //RBG = 2; - RIV_max = 0x1FFF; - } - else - { - RIV_max = RIV_max25; - } - break; - case 50: - if (rah == 0) - { - //RBG = 3; - RIV_max = 0x1FFFF; - } - else - { - RIV_max = RIV_max50; - } - break; - case 100: - if (rah == 0) - { - //RBG = 4; - RIV_max = 0x1FFFFFF; - } - else - { - RIV_max = RIV_max100; - } - break; - } - - NPRB = conv_nprb(rah, - rballoc, - N_RB_DL); - - - - if( (rballoc > RIV_max) && (rah == 1) ) - { - // DCI false detection - // LOG_I(PHY,"bad rballoc %d RIV_max %lld\n", rballoc, RIV_max); - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - // LOG_I(PHY,"bad NPRB\n"); - return(0); - } - - return(1); -} - -void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - LTE_DL_UE_HARQ_t *dlsch0_harq, - uint8_t nb_rb_alloc, - uint8_t subframe) -{ - uint32_t pbch_pss_sss_re; - uint32_t crs_re; - uint32_t granted_re; - uint32_t data_re; - uint32_t llr_offset; - uint8_t symbol; - uint8_t symbol_mod; - - pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; - - // LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); - - //dlsch0_harq->rb_alloc_even; - //dlsch0_harq->rb_alloc_odd; - - for(symbol=pdcch_vars->num_pdcch_symbols; symbol<frame_parms->symbols_per_tti; symbol++) - { - symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; - if((symbol_mod == 0) || symbol_mod == (4-frame_parms->Ncp)) - { - if (frame_parms->nb_antennas_tx == 2) - crs_re = 4; - else - crs_re = 2; - } - else - { - crs_re = 0; - } - - granted_re = nb_rb_alloc * (12-crs_re); - pbch_pss_sss_re = adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,subframe,symbol); - pbch_pss_sss_re = (double)pbch_pss_sss_re * ((double)(12-crs_re)/12); - data_re = granted_re - pbch_pss_sss_re; - llr_offset = data_re * dlsch0_harq->Qm * 2; - - pdsch_vars->llr_length[symbol] = data_re; - 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,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, - pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); - */ - } -} -void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, - uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - uint8_t subframe, - uint16_t rnti, - uint16_t tc_rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - LTE_DL_UE_HARQ_t *pdlsch0_harq, - LTE_UE_DLSCH_t *pdlsch0) -{ - - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint8_t vrb_type = pdci_info_extarcted->vrb_type; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t rah = pdci_info_extarcted->rah; - uint8_t dai = pdci_info_extarcted->dai; - - - uint8_t NPRB = 0; - uint8_t NPRB4TBS = 0; - - if(dci_format == format1A) - { - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc]; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc]; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc]; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc]; - break; - } - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - NPRB4TBS = (TPC&1) + 2; - } - else - { - NPRB4TBS = NPRB; - /* - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - break; - } - - */ - } - } - else // format1 - { - NPRB = conv_nprb(rah, rballoc, N_RB_DL); - NPRB4TBS=NPRB; - } - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->active = 1; - pdlsch0->rnti = rnti; - if(dci_format == format1A) - pdlsch0->harq_ack[subframe].vDAI_DL = dai+1; - - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - pdlsch0_harq->round = 0; - pdlsch0_harq->status = ACTIVE; - } - else //CRNTI - { - if (rnti == tc_rnti) { - //fix for standalone Contention Resolution Id - pdlsch0_harq->DCINdi = (uint8_t)-1; - LOG_D(PHY,"UE (%x/%d): Format1A DCI: C-RNTI is temporary. Set NDI = %d and to be ignored\n", - rnti,harq_pid,pdlsch0_harq->DCINdi); - } - - // NDI has been toggled or this is the first transmission - if ((ndi1!=pdlsch0_harq->DCINdi) || (pdlsch0_harq->first_tx==1)) - { - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 0; - pdlsch0_harq->status = ACTIVE; - - }else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if (pdlsch0_harq->status == SCH_IDLE) - //packet was actually decoded in previous transmission (ACK was missed by eNB) - //However, the round is not a good check as it might have been decoded in a retransmission prior to this one. - { - // LOG_D(PHY,"skip pdsch decoding and report ack\n"); - // skip pdsch decoding and report ack - //pdlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[subframe].ack = 1; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch0->harq_ack[subframe].send_harq_status = 1; - - //pdlsch0_harq->first_tx = 0; - } - else //normal retransmission - { - // nothing special to do - } - } - else - { - pdlsch0_harq->status = ACTIVE; - } - } - - pdlsch0_harq->DCINdi = ndi1; - pdlsch0_harq->mcs = mcs1; - pdlsch0_harq->rvidx = rv1; - pdlsch0_harq->nb_rb = NPRB; - - pdlsch0_harq->codeword = 0; - pdlsch0_harq->Nl = 1; - pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; - pdlsch0_harq->dl_power_off = 1; //no power offset - pdlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC &3]; - - // compute resource allocation - if(dci_format == format1A) - { - switch (N_RB_DL) { - case 6: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT6[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; - } - break; - - case 25: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT25[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; - } - break; - - case 50: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT50_0[rballoc]; - 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]; - } else { // DISTRIBUTED - if ((rballoc&(1<<10)) == 0) { - rballoc = rballoc&(~(1<<10)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - else { - rballoc = rballoc&(~(1<<10)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - } - break; - - case 100: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = localRIV2alloc_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = localRIV2alloc_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = localRIV2alloc_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = localRIV2alloc_LUT100_3[rballoc]; - } else { - if ((rballoc&(1<<10)) == 0) { //Gap 1 - rballoc = rballoc&(~(1<<12)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; - } - else { //Gap 2 - rballoc = rballoc&(~(1<<12)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; - } - } - break; - } - } - else // format1 - { - conv_rballoc(rah,rballoc,frame_parms->N_RB_DL,pdlsch0_harq->rb_alloc_even); - pdlsch0_harq->rb_alloc_odd[0]= pdlsch0_harq->rb_alloc_even[0]; - pdlsch0_harq->rb_alloc_odd[1]= pdlsch0_harq->rb_alloc_even[1]; - pdlsch0_harq->rb_alloc_odd[2]= pdlsch0_harq->rb_alloc_even[2]; - pdlsch0_harq->rb_alloc_odd[3]= pdlsch0_harq->rb_alloc_even[3]; - } - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - pdlsch0_harq->TBS = TBStable[mcs1][NPRB4TBS-1]; - pdlsch0_harq->Qm = 2; - } - else - { - if(mcs1 < 29) - { - pdlsch0_harq->TBS = TBStable[get_I_TBS(mcs1)][NPRB4TBS-1]; - pdlsch0_harq->Qm = get_Qm(mcs1); - } - } - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - pdlsch0_harq, - NPRB, - subframe); -} - -void prepare_dl_decoding_format1C(uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - uint32_t rnti, - uint32_t si_rnti, - uint32_t ra_rnti, - uint32_t p_rnti, - uint32_t frame, - uint8_t subframe, - LTE_DL_UE_HARQ_t *pdlsch0_harq, - LTE_UE_DLSCH_t *pdlsch0) -{ - - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t Ngap = pdci_info_extarcted->Ngap; - - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 1; - pdlsch0_harq->vrb_type = DISTRIBUTED; - - if (rnti==si_rnti) { // rule from Section 5.3.1 of 36.321 - if (((frame&1) == 0) && (subframe == 5)) - pdlsch0_harq->rvidx = (((3*((frame>>1)&3))+1)>>1)&3; // SIB1 - else - pdlsch0_harq->rvidx = (((3*(subframe&3))+1)>>1)&3; // other SIBs - } - else if ((rnti==p_rnti) || (rnti==ra_rnti)) { // Section 7.1.7.3 - pdlsch0_harq->rvidx = 0; - } - - - pdlsch0_harq->Nl = 1; - pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; - pdlsch0_harq->dl_power_off = 1; //no power offset - - pdlsch0_harq->codeword = 0; - pdlsch0_harq->mcs = mcs1; - pdlsch0_harq->TBS = TBStable1C[mcs1]; - pdlsch0_harq->Qm = 2; - - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->active = 1; - pdlsch0->rnti = rnti; - - switch (N_RB_DL) { - case 6: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; - - break; - - case 25: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; - break; - - case 50: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT50[rballoc]; - if (Ngap == 0) { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT50_1[rballoc]; - } - break; - - case 100: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT100[rballoc]; - if (Ngap==0) { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; - } - break; - - default: - AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",frame_parms->N_RB_DL); - break; - } - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - pdlsch0_harq, - pdlsch0_harq->nb_rb, - subframe); - -} - -void compute_precoding_info_2cw(uint8_t tpmi, uint8_t tbswap, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch0_harq, LTE_DL_UE_HARQ_t *dlsch1_harq) -{ - -switch (tpmi) { - case 0: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); - break; - case 1: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); - break; - case 2: // PUSCH precoding - dlsch0_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - dlsch1_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - if (tbswap==0){ - dlsch0_harq->pmi_alloc = pmi_alloc; - dlsch1_harq->pmi_alloc = pmi_alloc^0x1555; - } else { - dlsch1_harq->pmi_alloc = pmi_alloc; - dlsch0_harq->pmi_alloc = pmi_alloc^0x1555; - } -#ifdef DEBUG_HARQ - printf ("\n \n compute_precoding_info_2cw pmi_alloc_new = %d\n", dlsch0_harq->pmi_alloc); - #endif - break; - default: - break; - } -} - -void compute_precoding_info_1cw(uint8_t tpmi, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch_harq) -{ - -switch (tpmi) { - case 0 : - dlsch_harq->mimo_mode = ALAMOUTI; - break; - case 1: - dlsch_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,0, 0); - break; - case 2: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); - break; - case 3: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); - break; - case 4: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); - break; - case 5: - dlsch_harq->mimo_mode = PUSCH_PRECODING0; - dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,0); - break; - case 6: - dlsch_harq->mimo_mode = PUSCH_PRECODING1; - dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,1); - break; - } - #ifdef DEBUG_HARQ - printf ("[DCI UE] I am calling from the UE side pmi_alloc_new = %d with tpmi %d\n", dlsch_harq->pmi_alloc, tpmi); - #endif - } - -void compute_precoding_info_format2A(uint8_t tpmi, - uint8_t nb_antenna_ports_eNB, - uint8_t tb0_active, - uint8_t tb1_active, - LTE_DL_UE_HARQ_t *dlsch0_harq, - LTE_DL_UE_HARQ_t *dlsch1_harq) -{ - - dlsch0_harq->dl_power_off = 0; - dlsch1_harq->dl_power_off = 0; - - if (nb_antenna_ports_eNB == 2) { - if ((tb0_active==1) && (tb1_active==1)) { - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - } else { - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - } - } else if (nb_antenna_ports_eNB == 4) { // 4 antenna case - if ((tb0_active==1) && (tb1_active==1)) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 1: // one-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 3: // - LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n"); - break; - } - } else if (tb0_active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - break; - - case 1: // two-layers on TB 0 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } else if (tb1_active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - break; - - case 1: // two-layers on TB 0 - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } - } - // printf("Format 2A: NPRB=%d (rballoc %x,mcs1 %d, mcs2 %d, frame_type %d N_RB_DL %d,active %d/%d)\n",NPRB,rballoc,mcs1,mcs2,frame_parms->frame_type,frame_parms->N_RB_DL,dlsch0->active,dlsch1->active); - //printf("UE (%x/%d): Subframe %d Format2A DCI: ndi1 %d, old_ndi1 %d, ndi2 %d, old_ndi2 %d (first tx1 %d, first tx2 %d) harq_status1 %d, harq_status2 %d\n",dlsch0->rnti,harq_pid,subframe,ndi,dlsch0_harq->DCINdi, - // dlsch0_harq->first_tx,dlsch1_harq->first_tx,dlsch0_harq->status,dlsch1_harq->status); - //printf("TBS0 %d, TBS1 %d\n",dlsch0_harq->TBS,dlsch1_harq->TBS); - -} - -void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - uint16_t rnti, - uint8_t subframe, - LTE_DL_UE_HARQ_t *dlsch0_harq, - LTE_DL_UE_HARQ_t *dlsch1_harq, - LTE_UE_DLSCH_t *pdlsch0, - LTE_UE_DLSCH_t *pdlsch1) -{ - - uint8_t rah = pdci_info_extarcted->rah; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t mcs2 = pdci_info_extarcted->mcs2; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t rv2 = pdci_info_extarcted->rv2; - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t tbswap = pdci_info_extarcted->tb_swap; - uint8_t tpmi = pdci_info_extarcted->tpmi; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t ndi2 = pdci_info_extarcted->ndi2; - - uint8_t TB0_active = 1; - uint8_t TB1_active = 1; - - // printf("inside prepare pdlsch1->pmi_alloc %d \n",pdlsch1->pmi_alloc); - - - if ((rv1 == 1) && (mcs1 == 0)) { - TB0_active=0; - } - if ((rv2 == 1) && (mcs2 == 0)) { - TB1_active=0; - } - -#ifdef DEBUG_HARQ - printf("[DCI UE]: TB0 status %d , TB1 status %d\n", TB0_active, TB1_active); -#endif - - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - dlsch0_harq->DCINdi = ndi1; - dlsch1_harq->DCINdi = ndi2; - - dlsch0_harq->codeword = 0; - dlsch1_harq->codeword = 1; - dlsch0_harq->Nl = 1; - dlsch1_harq->Nl = 1; - dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; - dlsch1_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch1->current_harq_pid = harq_pid; - pdlsch1->harq_ack[subframe].harq_id = harq_pid; - - // assume two CW are active - dlsch0_harq->status = ACTIVE; - dlsch1_harq->status = ACTIVE; - pdlsch0->active = 1; - pdlsch1->active = 1; - pdlsch0->rnti = rnti; - pdlsch1->rnti = rnti; - - - if (TB0_active && TB1_active && tbswap==1) { - dlsch0_harq->codeword = 1; - dlsch1_harq->codeword = 0; - } - - - if (!TB0_active && TB1_active){ - dlsch1_harq->codeword = 0; - } - - if (TB0_active && !TB1_active){ - dlsch0_harq->codeword = 0; - } - - - if (TB0_active==0) { - dlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - #ifdef DEBUG_HARQ - printf("[DCI UE]: TB0 is deactivated, retransmit TB1 transmit in TM6\n"); - #endif - } - - if (TB1_active==0) { - dlsch1_harq->status = SCH_IDLE; - pdlsch1->active = 0; - } - -#ifdef DEBUG_HARQ - printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); -#endif - - // compute resource allocation - if (TB0_active == 1){ - - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc_even); - - dlsch0_harq->rb_alloc_odd[0]= dlsch0_harq->rb_alloc_even[0]; - dlsch0_harq->rb_alloc_odd[1]= dlsch0_harq->rb_alloc_even[1]; - dlsch0_harq->rb_alloc_odd[2]= dlsch0_harq->rb_alloc_even[2]; - dlsch0_harq->rb_alloc_odd[3]= dlsch0_harq->rb_alloc_even[3]; - - if (TB1_active == 1){ - dlsch1_harq->rb_alloc_even[0]= dlsch0_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_even[1]= dlsch0_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_even[2]= dlsch0_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_even[3]= dlsch0_harq->rb_alloc_even[3]; - dlsch1_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_odd[0]; - dlsch1_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_odd[1]; - dlsch1_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_odd[2]; - dlsch1_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_odd[3]; - - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - //dlsch0_harq->Nl = 1; - //dlsch1_harq->Nl = 1; - } - } else if ((TB0_active == 0) && (TB1_active == 1)){ - - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch1_harq->rb_alloc_even); - - dlsch1_harq->rb_alloc_odd[0]= dlsch1_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_odd[1]= dlsch1_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_odd[2]= dlsch1_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_odd[3]= dlsch1_harq->rb_alloc_even[3]; - dlsch1_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - } - - - // compute precoding matrix + mimo mode - if(dci_format == format2) - { - if ((TB0_active) && (TB1_active)){ //two CW active - compute_precoding_info_2cw(tpmi, tbswap, pdlsch0->pmi_alloc,frame_parms, dlsch0_harq, dlsch1_harq); - - // printf("[DCI UE 1]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - } else if ((TB0_active) && (!TB1_active)) { // only CW 0 active - compute_precoding_info_1cw(tpmi, pdlsch0->pmi_alloc, frame_parms, dlsch0_harq); - } else { - compute_precoding_info_1cw(tpmi, pdlsch1->pmi_alloc, frame_parms, dlsch1_harq); - // printf("I am doing compute_precoding_info_1cw with tpmi %d \n", tpmi); - } - //printf(" UE DCI harq0 MIMO mode = %d\n", dlsch0_harq->mimo_mode); - if ((frame_parms->nb_antenna_ports_eNB == 1) && (TB0_active)) - dlsch0_harq->mimo_mode = SISO; - } - else - { - compute_precoding_info_format2A( tpmi, - frame_parms->nb_antenna_ports_eNB, - TB0_active, - TB1_active, - dlsch0_harq, - dlsch1_harq); - } - // printf("[DCI UE 2]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - // reset round + compute Qm - if (TB0_active) { - // printf("TB0 ndi1 =%d, dlsch0_harq->DCINdi =%d, dlsch0_harq->first_tx = %d\n", ndi1, dlsch0_harq->DCINdi, dlsch0_harq->first_tx); - if ((ndi1!=dlsch0_harq->DCINdi) || (dlsch0_harq->first_tx==1)) { - dlsch0_harq->round = 0; - dlsch0_harq->status = ACTIVE; - dlsch0_harq->DCINdi = ndi1; - - //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW0 subframe %d (pid %d, round %d)\n", - // subframe,harq_pid,dlsch0_harq->round); - if ( dlsch0_harq->first_tx==1) { - // LOG_D(PHY,"Format 2 DCI First TX0: Clearing flag\n"); - dlsch0_harq->first_tx = 0; - } - } - /*else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if(dlsch0_harq->status == SCH_IDLE) { - // skip pdsch decoding and report ack - //dlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[subframe].ack = 1; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch0->harq_ack[subframe].send_harq_status = 1; - }*/ - - // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest - // PDCCH for the same trasport block using Imcs in [0 .. 28] - if(dlsch0_harq->mcs <= 28) - { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - LOG_D(PHY,"[UE] DLSCH: New TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); - } - else - { - LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); - } - //if(dlsch0_harq->Nl == 2) - //dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1]; - if (mcs1 <= 28) - dlsch0_harq->Qm = get_Qm(mcs1); - else if (mcs1<=31) - dlsch0_harq->Qm = (mcs1-28)<<1; - } - - // printf("[DCI UE 3]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - - if (TB1_active) { - // printf("TB1 ndi2 =%d, dlsch1_harq->DCINdi =%d, dlsch1_harq->first_tx = %d\n", ndi2, dlsch1_harq->DCINdi, dlsch1_harq->first_tx); - if ((ndi2!=dlsch1_harq->DCINdi) || (dlsch1_harq->first_tx==1)) { - dlsch1_harq->round = 0; - dlsch1_harq->status = ACTIVE; - dlsch1_harq->DCINdi = ndi2; - //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW1 subframe %d (pid %d, round %d)\n", - // subframe,harq_pid,dlsch0_harq->round); - if (dlsch1_harq->first_tx==1) { - // LOG_D(PHY,"Format 2 DCI First TX1: Clearing flag\n"); - dlsch1_harq->first_tx = 0; - } - } - /*else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if(dlsch1_harq->status == SCH_IDLE) { - // skip pdsch decoding and report ack - //dlsch1_harq->status = SCH_IDLE; - pdlsch1->active = 0; - pdlsch1->harq_ack[subframe].ack = 1; - pdlsch1->harq_ack[subframe].harq_id = harq_pid; - pdlsch1->harq_ack[subframe].send_harq_status = 1; - } - }*/ - - // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest - // PDCCH for the same trasport block using Imcs in [0 .. 28] - if(dlsch1_harq->mcs <= 28) - { - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; - LOG_D(PHY,"[UE] DLSCH: New TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); - } - else - { - LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); - } - if (mcs2 <= 28) - dlsch1_harq->Qm = get_Qm(mcs2); - else if (mcs1<=31) - dlsch1_harq->Qm = (mcs2-28)<<1; - } - - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - dlsch0_harq, - dlsch0_harq->nb_rb, - subframe); - - - /* #ifdef DEBUG_HARQ - printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - printf("[DCI UE]: TB0_active %d , TB1_active %d\n", TB0_active, TB1_active); - if (dlsch0 != NULL && dlsch1 != NULL) - printf("[DCI UE] dlsch0_harq status = %d, dlsch1_harq status = %d\n", dlsch0_harq->status, dlsch1_harq->status); - else if (dlsch0 == NULL && dlsch1 != NULL) - printf("[DCI UE] dlsch0_harq NULL dlsch1_harq status = %d\n", dlsch1_harq->status); - else if (dlsch0 != NULL && dlsch1 == NULL) - printf("[DCI UE] dlsch1_harq NULL dlsch0_harq status = %d\n", dlsch0_harq->status); - #endif*/ -} - -int generate_ue_dlsch_params_from_dci(int frame, - uint8_t subframe, - void *dci_pdu, - uint16_t rnti, - DCI_format_t dci_format, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - LTE_UE_DLSCH_t **dlsch, - LTE_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint8_t beamforming_mode, - uint16_t tc_rnti) -{ - - uint8_t harq_pid=0; - uint8_t frame_type=frame_parms->frame_type; - uint8_t tpmi=0; - LTE_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; - LTE_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; - - DCI_INFO_EXTRACTED_t dci_info_extarcted; - uint8_t status=0; - - if (!dlsch[0]) return -1; - - #ifdef DEBUG_DCI - LOG_D(PHY,"dci_tools.c: Filling ue dlsch params -> rnti %x, SFN/SF %d/%d, dci_format %s\n", - rnti, - frame%1024, - subframe, - (dci_format==format0? "Format 0":( - dci_format==format1? "format 1":( - dci_format==format1A? "format 1A":( - dci_format==format1B? "format 1B":( - dci_format==format1C? "format 1C":( - dci_format==format1D? "format 1D":( - dci_format==format1E_2A_M10PRB? "format 1E_2A_M10PRB":( - dci_format==format2? "format 2":( - dci_format==format2A? "format 2A":( - dci_format==format2B? "format 2B":( - dci_format==format2C? "format 2C":( - dci_format==format2D? "format 2D":( - dci_format==format3? "format 3": "UNKNOWN" - )))))))))))))); - #endif - - memset(&dci_info_extarcted,0,sizeof(dci_info_extarcted)); - switch (dci_format) { - - case format0: // This is an ULSCH allocation so nothing here, inform MAC - LOG_E(PHY,"format0 not possible\n"); - return(-1); - break; - - case format1A: - { - // extract dci infomation -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d extarct dci info \n", frame, subframe); -#endif - extract_dci1A_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - - // check dci content - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d check dci coherency \n", frame, subframe); -#endif - status = check_dci_format1_1a_coherency(format1A, - frame_parms->N_RB_DL, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti,frame,subframe, - &dci_info_extarcted, - dlsch0_harq); - if(status == 0) - { - printf("bad DCI 1A !!! \n"); - return(-1); - } - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); -#endif - prepare_dl_decoding_format1_1A(format1A, - frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - subframe, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch0); - - - - break; - } - case format1C: - { - // extract dci infomation -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] extact dci information \n"); -#endif - extract_dci1C_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - - // check dci content -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] check dci content \n"); -#endif - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; - - status = check_dci_format1c_coherency(frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq); - if(status == 0) - return(-1); - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] prepare downlink decoding \n"); -#endif - prepare_dl_decoding_format1C(frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - si_rnti, - ra_rnti, - p_rnti, - frame, - subframe, - dlsch0_harq, - dlsch0); - - break; - } - - case format1: - { - // extract dci infomation -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d extarct dci info \n", frame, subframe); -#endif - extract_dci1_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - // check dci content - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; - -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d check dci coherency \n", frame, subframe); -#endif - status = check_dci_format1_1a_coherency(format1, - frame_parms->N_RB_DL, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti,frame,subframe, - &dci_info_extarcted, - dlsch0_harq); - if(status == 0) - { - printf("bad DCI 1 !!! \n"); - return(-1); - } - - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); -#endif - prepare_dl_decoding_format1_1A(format1, - frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - subframe, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch0); - break; - } - - case format2: - { - // extract dci infomation - //LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame, subframe); - extract_dci2_info(frame_parms->N_RB_DL, - frame_type, - frame_parms->nb_antenna_ports_eNB, - dci_pdu, - &dci_info_extarcted); - - - // check dci content - dlsch[0]->active = 1; - dlsch[1]->active = 1; - - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - - dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; - dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; - // printf("before coherency dlsch[1]->pmi_alloc %d\n",dlsch[1]->pmi_alloc); - // printf("before coherency dlsch1->pmi_alloc %d\n",dlsch1->pmi_alloc); - // printf("before coherency dlsch1_harq->pmi_alloc %d\n",dlsch1_harq->pmi_alloc); - - //LOG_I(PHY,"[DCI-format2] check dci content \n"); - status = check_dci_format2_2a_coherency(format2, - frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch1_harq); - if(status == 0) - return(-1); - - - // dci is correct ==> update internal structure and prepare dl decoding - //LOG_I(PHY,"[DCI-format2] update internal structure and prepare dl decoding \n"); - prepare_dl_decoding_format2_2A(format2, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - subframe, - dlsch0_harq, - dlsch1_harq, - dlsch0, - dlsch1); - } - break; - - case format2A: - { - // extract dci infomation - LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame%1024, subframe); - extract_dci2A_info(frame_parms->N_RB_DL, - frame_type, - frame_parms->nb_antenna_ports_eNB, - dci_pdu, - &dci_info_extarcted); - - // check dci content - //LOG_I(PHY,"[DCI-format2A] check dci content \n"); - //LOG_I(PHY,"[DCI-format2A] tb_swap %d harq_pid %d\n", dci_info_extarcted.tb_swap, dci_info_extarcted.harq_pid); - //dlsch[0]->active = 0; - //dlsch[1]->active = 0; - - if (dci_info_extarcted.tb_swap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } else { - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; - dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; - - //LOG_I(PHY,"[DCI-format2A] check dci content \n"); - status = check_dci_format2_2a_coherency(format2A, - frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch1_harq); - if(status == 0) - return(-1); - - // dci is correct ==> update internal structure and prepare dl decoding - //LOG_I(PHY,"[DCI-format2A] update internal structure and prepare dl decoding \n"); - prepare_dl_decoding_format2_2A(format2A, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - subframe, - dlsch0_harq, - dlsch1_harq, - dlsch0, - dlsch1); - } - break; - - case format1E_2A_M10PRB: - if (!dlsch[0]) return -1; - - harq_pid = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->harq_pid; - - if (harq_pid>=8) { - LOG_E(PHY,"Format 1E_2A_M10PRB: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - dlsch[0]->current_harq_pid = harq_pid; - dlsch[0]->harq_ack[subframe].harq_id = harq_pid; - - /* - tbswap = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tb_swap; - if (tbswap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } - else{ - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - */ - dlsch0 = dlsch[0]; - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - // Needs to be checked - dlsch0_harq->codeword=0; - conv_rballoc(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc,frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc_even); - - dlsch0_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_even[0]; - dlsch0_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_even[1]; - dlsch0_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_even[2]; - dlsch0_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_even[3]; - /* - dlsch1_harq->rb_alloc_even[0] = dlsch0_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_even[1] = dlsch0_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_even[2] = dlsch0_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_even[3] = dlsch0_harq->rb_alloc_even[3]; - */ - dlsch0_harq->nb_rb = conv_nprb(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc, - frame_parms->N_RB_DL); - //dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->TPC&3]; - - - - /* - if (dlsch0_harq->mcs>20) { - printf("dci_tools.c: mcs > 20 disabled for now (asked %d)\n",dlsch0_harq->mcs); - return(-1); - } - */ - - //dlsch1_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs2; - dlsch0_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv; - //dlsch1_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv2; - - // check if either TB is disabled (see 36-213 V8.6 p. 26) - - if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { - dlsch0_harq->status = DISABLED; - } - - //if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { - //dlsch1_harq->status = DISABLED; - //} - dlsch0_harq->Nl = 1; - - //dlsch0->layer_index = tbswap; - //dlsch1->layer_index = 1-tbswap; - - - // Fix this - tpmi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tpmi; - // printf("ue: tpmi %d\n",tpmi); - - switch (tpmi) { - case 0 : - dlsch0_harq->mimo_mode = ALAMOUTI; - break; - - case 1: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0,0); - break; - - case 2: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); - break; - - case 3: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); - - break; - - case 4: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); - break; - - case 5: - dlsch0_harq->mimo_mode = PUSCH_PRECODING0; - // pmi stored from ulsch allocation routine - dlsch0_harq->pmi_alloc = dlsch0->pmi_alloc; - //LOG_I(PHY,"XXX using PMI %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc)); - break; - - - case 6: - dlsch0_harq->mimo_mode = PUSCH_PRECODING1; - LOG_E(PHY,"Unsupported TPMI\n"); - return(-1); - break; - } - - - if (frame_parms->nb_antenna_ports_eNB == 1) - dlsch0_harq->mimo_mode = SISO; - - - if ((dlsch0_harq->DCINdi != ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi) || - (dlsch0_harq->first_tx==1)) { - - dlsch0_harq->round = 0; - dlsch0_harq->first_tx = 0; - dlsch0_harq->status = ACTIVE; - } - /* - else if (dlsch0_harq->status == SCH_IDLE) { // we got same ndi for a previously decoded process, - // this happens if either another harq process in the same - // is NAK or an ACK was not received - - dlsch0->harq_ack[subframe].ack = 1; - dlsch0->harq_ack[subframe].harq_id = harq_pid; - dlsch0->harq_ack[subframe].send_harq_status = 1; - dlsch0->active = 0; - return(0); - } - */ - - dlsch0_harq->DCINdi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi; - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - - if (dlsch0_harq->nb_rb>1) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - } else - dlsch0_harq->TBS =0; - - dlsch0->rnti = rnti; - //dlsch1->rnti = rnti; - - dlsch0->active = 1; - //dlsch1->active = 1; - - dlsch0_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; - //dlsch1_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; - - - break; - - default: - LOG_E(PHY,"format %d not yet implemented\n",dci_format); - return(-1); - break; - } - -#ifdef UE_DEBUG_TRACE - - if (dlsch[0] && (dlsch[0]->rnti != 0xffff)) { - LOG_I(PHY,"dci_format:%d Abssubframe: %d.%d \n",dci_format,frame%1024,subframe); - LOG_I(PHY,"PDSCH dlsch0 UE: rnti %x\n",dlsch[0]->rnti); - LOG_D(PHY,"PDSCH dlsch0 UE: NBRB %d\n",dlsch0_harq->nb_rb); - LOG_D(PHY,"PDSCH dlsch0 UE: rballoc %x\n",dlsch0_harq->rb_alloc_even[0]); - LOG_I(PHY,"PDSCH dlsch0 UE: harq_pid %d\n",dci_info_extarcted.harq_pid); - LOG_I(PHY,"PDSCH dlsch0 UE: g %d\n",dlsch[0]->g_pucch); - LOG_D(PHY,"PDSCH dlsch0 UE: round %d\n",dlsch0_harq->round); - LOG_D(PHY,"PDSCH dlsch0 UE: DCINdi %d\n",dlsch0_harq->DCINdi); - LOG_D(PHY,"PDSCH dlsch0 UE: rvidx %d\n",dlsch0_harq->rvidx); - LOG_D(PHY,"PDSCH dlsch0 UE: TBS %d\n",dlsch0_harq->TBS); - LOG_D(PHY,"PDSCH dlsch0 UE: mcs %d\n",dlsch0_harq->mcs); - LOG_D(PHY,"PDSCH dlsch0 UE: pwr_off %d\n",dlsch0_harq->dl_power_off); - } -#endif - -#if T_TRACER - if( (dlsch[0]->rnti != si_rnti) && (dlsch[0]->rnti != ra_rnti) && (dlsch[0]->rnti != p_rnti)) - { - T(T_UE_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame%1024), T_INT(subframe), - T_INT(dlsch[0]->rnti), T_INT(dci_format), - T_INT(harq_pid), - T_INT(dlsch0_harq->mcs), - T_INT(dlsch0_harq->TBS)); - } -#endif - - - // compute DL power control parameters - if (dlsch0_harq != NULL){ - computeRhoA_UE(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[0],dlsch0_harq->dl_power_off); - } - - if (dlsch1_harq != NULL) { - computeRhoA_UE(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[1],dlsch1_harq->dl_power_off); - } - - - return(0); -} - - -uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) -{ - uint8_t ret = 255; - - if (frame_parms->frame_type == FDD) { - ret = (((frame*10)+subframe)&7); - } else { - - switch (frame_parms->tdd_config) { - - 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: - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - break; - } - - break; - - case 2: - if ((subframe!=2) && (subframe!=7)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret=255; - } - else ret = (subframe/7); - break; - - case 3: - if ((subframe<2) || (subframe>4)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - } - else ret = (subframe-2); - break; - - case 4: - if ((subframe<2) || (subframe>3)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - } - else ret = (subframe-2); - break; - - case 5: - if (subframe!=2) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - } - else ret = (subframe-2); - break; - - default: - LOG_E(PHY,"subframe2_harq_pid, Unsupported TDD mode %d\n",frame_parms->tdd_config); - ret = (255); - } - } - - AssertFatal(ret!=255, - "invalid harq_pid(%d) at SFN/SF = %d/%d\n", (int8_t)ret, frame, subframe); - return ret; -} - -uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) -{ - uint8_t ul_subframe = 255; - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_subframe = ((n+6)%10); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - ((n==0)||(n==1)||(n==5)||(n==6))) - ul_subframe = ((n+7)%10); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - (n==9)) // tdd_config 6 SF 9 - ul_subframe = ((n+5)%10); - else - ul_subframe = ((n+4)%10); - - 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; -} - -uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) -{ - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==7)||(n==2))) // tdd_config 0,1 SF 1,5 - return((n==7)? 1 : 6); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - ((n==7)||(n==8)||(n==2)||(n==3))) - return((n+3)%10); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - (n==4)) // tdd_config 6 SF 9 - return(9); - else - return((n+6)%10); -} - -uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) -{ - uint32_t ul_frame; - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_frame = (frame + (n==1 ? 0 : 1)); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - ((n==0)||(n==1)||(n==5)||(n==6))) - ul_frame = (frame + (n>=5 ? 1 : 0)); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - (n==9)) // tdd_config 6 SF 9 - ul_frame = (frame+1); - else - ul_frame = (frame+(n>=6 ? 1 : 0)); - - LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame); - return ul_frame % 1024; -} - -int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb) -{ - int nb_subbands = 0; - int32_t pmi_alloc_new = 0, pmi_new = 0, pmi_old = 0; - int i; - - switch (nb_rb) { - case 6: - nb_subbands = 6; - break; - default: - case 25: - nb_subbands = 7; - break; - case 50: - nb_subbands = 9; - break; - case 100: - nb_subbands = 13; - break; - } - - for (i = 0; i < nb_subbands; i++) { - pmi_old = (pmi_alloc >> i)&1; - - if (pmi_old == 0) - if (tpmi == 5) - pmi_new = 0; - else - pmi_new = 1; - else - if (tpmi == 5) - pmi_new = 2; - else - pmi_new = 3; - - pmi_alloc_new|=pmi_new<<(2*i); - - } -#ifdef DEBUG_HARQ -printf(" [DCI UE] pmi_alloc_old %d, pmi_alloc_new %d pmi_old %d , pmi_new %d\n", pmi_alloc, pmi_alloc_new,pmi_old, pmi_new ); -#endif -return(pmi_alloc_new); - -} - -uint16_t quantize_subband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,int nb_rb) -{ - - int i, aarx; - uint16_t pmiq=0; - uint32_t pmivect = 0; - uint8_t rank = meas->rank[eNB_id]; - int pmi_re,pmi_im; - int nb_subbands=0; - - - switch (nb_rb) { - case 6: - nb_subbands = 6; - break; - default: - case 25: - nb_subbands = 7; - break; - case 50: - nb_subbands = 9; - break; - case 100: - nb_subbands = 13; - break; - } - - - for (i=0; i<nb_subbands; i++) { - pmi_re = 0; - pmi_im = 0; - - if (rank == 0) { - for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { - pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; - pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; - } - - // pmi_re = meas->subband_pmi_re[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; - // pmi_im = meas->subband_pmi_im[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; - - // printf("pmi => (%d,%d)\n",pmi_re,pmi_im); - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - // printf("subband %d, pmi%d \n",i,pmiq); - pmivect |= (pmiq<<(2*i)); - } - - else if (rank==1) { - for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { - pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; - //printf("meas->subband_pmi_re[eNB_id][i][%d]=%d\n", aarx, meas->subband_pmi_re[eNB_id][i][aarx]); - pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; - //printf("meas->subband_pmi_im[eNB_id][i][%d]=%d\n",aarx, meas->subband_pmi_im[eNB_id][i][aarx]); - } - if (pmi_re >= pmi_im) // this is not orthogonal - // this is orthogonal - //if (((pmi_re >= pmi_im) && (pmi_re >= -pmi_im)) || ((pmi_re <= pmi_im) && (pmi_re >= -pmi_im))) - pmiq = PMI_2A_R1_11; - else - pmiq = PMI_2A_R1_1j; - - // printf("subband %d, pmi_re %d, pmi_im %d, pmiq %d \n",i,pmi_re,pmi_im,pmiq); - // printf("subband %d, pmi%d \n",i,pmiq); - //According to Section 7.2.4 of 36.213 - - pmivect |= ((pmiq-1)<<(i)); //shift 1 since only one bit - } - else { - LOG_E(PHY,"PMI feedback for rank>1 not supported!\n"); - pmivect = 0; - } - - } -#ifdef DEBUG_HARQ - printf( "quantize_subband_pmi pmivect %d \n", pmivect); -#endif - return(pmivect); -} - -uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands) -{ - - uint8_t i; - uint16_t pmiq=0; - uint16_t pmivect = 0; - uint8_t rank = meas->rank[eNB_id]; - int pmi_re,pmi_im; - - for (i=0; i<nb_subbands; i++) { - - if (rank == 0) { - pmi_re = meas->subband_pmi_re[eNB_id][i][a_id]; - pmi_im = meas->subband_pmi_im[eNB_id][i][a_id]; - - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - pmivect |= (pmiq<<(2*i)); - } else { - // This needs to be done properly!!! - pmivect = 0; - } - } - - return(pmivect); -} - -uint16_t quantize_wideband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) -{ - - uint16_t pmiq=0; - uint8_t rank = meas->rank[eNB_id]; - //int pmi; - int pmi_re,pmi_im; - - if (rank == 1) { - //pmi = - pmi_re = meas->wideband_pmi_re[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; - pmi_im = meas->wideband_pmi_im[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; - - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - } else { - // This needs to be done properly! - pmiq = PMI_2A_11; - } - - - return(pmiq); -} -/* - uint8_t sinr2cqi(int sinr) { - if (sinr<-3) - return(0); - if (sinr>14) - return(10); - else - return(3+(sinr>>1)); - } -*/ - -uint8_t sinr2cqi(double sinr,uint8_t trans_mode) -{ - // int flag_LA=0; - - uint8_t retValue = 0; - - if(flag_LA==0) { - // Ideal Channel Estimation - if (sinr<=-4.89) - retValue = (0); - else if (sinr < -3.53) - retValue = (3); - else if (sinr <= -1.93) - retValue = (4); - else if (sinr <= -0.43) - retValue = (5); - else if (sinr <= 1.11) - retValue = (6); - else if (sinr <= 3.26) - retValue = (7); - else if (sinr <= 5.0) - retValue = (8); - else if (sinr <= 7.0) - retValue = (9); - else if (sinr <= 9.0) - retValue = (10); - else if (sinr <= 11.0) - retValue = (11); - else if (sinr <= 13.0) - retValue = (12); - else if (sinr <= 15.5) - retValue = (13); - else if (sinr <= 17.5) - retValue = (14); - else - retValue = (15); - } else { - int h=0; - int trans_mode_tmp; - - if (trans_mode ==5) - trans_mode_tmp=2; - else if(trans_mode ==6) - trans_mode_tmp=3; - else - trans_mode_tmp = trans_mode-1; - - for(h=0; h<16; h++) { - if(sinr<=sinr_to_cqi[trans_mode_tmp][h]) - retValue = (h); - } - } - - LOG_D(PHY, "sinr=%f trans_mode=%d cqi=%d\n", sinr, trans_mode, retValue); - return retValue; -} -//uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) { -// -// uint8_t i; -//// uint16_t cqivect = 0; -// uint32_t cqivect = 0; -// -//// char diff_cqi; -// int diff_cqi=0; -// -// for (i=0;i<NUMBER_OF_SUBBANDS;i++) { -// -// diff_cqi = -sinr2cqi(meas->wideband_cqi_dB[eNB_id][0]) + sinr2cqi(meas->subband_cqi_dB[eNB_id][0][i]); -// -// // Note, this is Table 7.2.1-2 from 36.213 -// if (diff_cqi<=-1) -// diff_cqi = 3; -// else if (diff_cqi>2) -// diff_cqi = 2; -// cqivect |= (diff_cqi<<(2*i)); -// -// } -// -// return(cqivect); -//} - - -uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t trans_mode,int nb_subbands) -{ - - uint8_t i; - - uint32_t cqivect = 0,offset=0; - - - int diff_cqi=0; - - for (i=0; i<nb_subbands; i++) { - - diff_cqi = -sinr2cqi(meas->wideband_cqi_avg[eNB_id],trans_mode) + sinr2cqi(meas->subband_cqi_tot_dB[eNB_id][i],trans_mode); - - // Note, this is Table 7.2.1-2 from 36.213 - if (diff_cqi<=-1) - offset = 3; - else if (diff_cqi>=2) - offset = 2; - else - offset=(uint32_t)diff_cqi; - - cqivect |= (offset<<(2*i)); - - } - - return(cqivect); -} - -void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t harq_pid,int N_RB_DL,uint16_t rnti, uint8_t trans_mode, double sinr_eff) -{ - - // printf("[PHY][UE] Filling CQI for eNB %d, meas->wideband_cqi_tot[%d] %d\n", - // eNB_id,eNB_id,meas->wideband_cqi_tot[eNB_id]); - double sinr_tmp; - uint8_t *o = ulsch->o; - UCI_format_t uci_format = ulsch->uci_format; - - if(flag_LA==1) - sinr_tmp = sinr_eff; - else - sinr_tmp = (double) meas->wideband_cqi_avg[eNB_id]; - - - - //LOG_I(PHY,"[UE][UCI] Filling CQI format %d for eNB %d N_RB_DL %d\n",uci_format,eNB_id,N_RB_DL); - - switch (N_RB_DL) { - - case 6: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti = rnti; - LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - case 25: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - case 50: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - case 100: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - } - - -} - -void reset_cba_uci(void *o) -{ - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = 0; //fixme - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = 0x0; -} - - -uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank) -{ - - uint8_t i,wideband_pmi2; - uint32_t pmi_ex = 0; - - if (frame_parms->N_RB_DL!=25) { - LOG_E(PHY,"pmi_extend not yet implemented for anything else than 25PRB\n"); - return(-1); - } - - if (rank==0) { - wideband_pmi2=wideband_pmi&3; - for (i=0; i<14; i+=2) - pmi_ex|=(wideband_pmi2<<i); - } - else if (rank==1) { - wideband_pmi2=wideband_pmi&1; - for (i=0; i<7; i++) - pmi_ex|=(wideband_pmi2<<i); - } - else { - LOG_E(PHY,"unsupported rank\n"); - return(-1); - } - - return(pmi_ex); -} - - -int generate_ue_ulsch_params_from_dci(void *dci_pdu, - uint16_t rnti, - uint8_t subframe, - DCI_format_t dci_format, - PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t eNB_id, - uint8_t use_srs) -{ - - uint8_t harq_pid; - uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - ANFBmode_t AckNackFBMode; - LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - LTE_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[subframe]][0]; - PHY_MEASUREMENTS *meas = &ue->measurements; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - // uint32_t current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; - - if(frame_parms->frame_type == TDD) - { - AckNackFBMode = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; - } - else - { - AckNackFBMode = 1; // 1: multiplexing for FDD - } - - uint32_t cqi_req; - uint32_t dai=3; - uint32_t cshift; - uint32_t TPC; - uint32_t ndi; - uint32_t mcs; - uint32_t rballoc,RIV_max; - uint16_t* RIV2first_rb_LUT; - uint16_t* RIV2nb_rb_LUT; - - // uint32_t hopping; - // uint32_t type; - - if (dci_format == format0) { - - if (!ulsch) - return -1; - - if (rnti == ra_rnti) - harq_pid = 0; - else - 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", - proc->frame_rx, subframe, rnti, dci_format); - return(-1); - } - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max6; - RIV2first_rb_LUT = RIV2first_rb_LUT6; - RIV2nb_rb_LUT = RIV2nb_rb_LUT6; - - break; - - case 25: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_5MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max25; - RIV2first_rb_LUT = RIV2first_rb_LUT25; - RIV2nb_rb_LUT = RIV2nb_rb_LUT25; - // printf("***********rballoc %d, first_rb %d, nb_rb %d (dci %p)\n",rballoc,ulsch->harq_processes[harq_pid]->first_rb,ulsch->harq_processes[harq_pid]->nb_rb,dci_pdu); - break; - - case 50: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_10MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max50; - RIV2first_rb_LUT = RIV2first_rb_LUT50; - RIV2nb_rb_LUT = RIV2nb_rb_LUT50; - - break; - - case 100: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_20MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max100; - RIV2first_rb_LUT = RIV2first_rb_LUT100; - RIV2nb_rb_LUT = RIV2nb_rb_LUT100; - - // printf("rb_alloc (20 MHz dci) %d\n",rballoc); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - if (rballoc > RIV_max) { - LOG_E(PHY,"frame %d, subframe %d, rnti %x, format %d: FATAL ERROR: generate_ue_ulsch_params_from_dci, rb_alloc[%d] > RIV_max[%d]\n", - proc->frame_rx, subframe, rnti, dci_format,rballoc,RIV_max); - LOG_E(PHY,"Wrong DCI0 detection, do not transmit PUSCH for HARQID: %d\n",harq_pid); - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - return(-1); - } - - - // indicate that this process is to be serviced in subframe n+4 - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1; //+=1 this indicates the number of dci / cba group: not supported in the data struct - else - { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - //LOG_I(PHY,"[HARQ-UL harqId: %d] DCI0 ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - - } - - ulsch->harq_processes[harq_pid]->TPC = TPC; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; - - if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", - ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, - delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); - ulsch->f_pusch += delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; - } else { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ABS) %d, adjusting to %d (TPC %d)\n", - ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, - delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); - ulsch->f_pusch = delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; - } - - if (ulsch->harq_processes[harq_pid]->first_tx==1) { - // ulsch->harq_processes[harq_pid]->Ndi = 1; - ulsch->harq_processes[harq_pid]->first_tx=0; - ulsch->harq_processes[harq_pid]->DCINdi= ndi; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - if (ulsch->harq_processes[harq_pid]->DCINdi!=ndi) { // new SDU opportunity - // ulsch->harq_processes[harq_pid]->Ndi = 1; - ulsch->harq_processes[harq_pid]->DCINdi= ndi; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - // ulsch->harq_processes[harq_pid]->Ndi = 0; - //ulsch->harq_processes[harq_pid]->round++; // This is done in phich RX - - //#ifdef DEBUG_PHICH - //LOG_I(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d Adaptative Retrans, NDI not toggled => Nack. maxHARQ_Tx %d \n", - // ue->Mod_id,harq_pid, - // proc->frame_rx, - // subframe, - // ulsch->Mlimit); - //#endif -/* - if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich - { - // ulsch->harq_processes[harq_pid]->round++; already done on phich_rx - // ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; - // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); - - if (ulsch->harq_processes[harq_pid]->round >= ulsch->Mlimit) //UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) - { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - ulsch->harq_processes[harq_pid]->round = 0; - ulsch->harq_processes[harq_pid]->status = IDLE; - //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - } - else - { - // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - uint8_t rv_table[4] = {0, 2, 3, 1}; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); - } - } -*/ - } - } - - ulsch->harq_processes[harq_pid]->n_DMRS = cshift; - - //printf("nb_rb %d, first_rb %d (RIV %d)\n",ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb,rballoc); - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - // ulsch->cba_rnti[0]=rnti; - } else { - ulsch->rnti = rnti; - } - - // printf("[PHY][UE] DCI format 0: harq_pid %d nb_rb %d, rballoc %d\n",harq_pid,ulsch->harq_processes[harq_pid]->nb_rb, - // ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc); - //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) - if(cshift == 0) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; - else if(cshift == 1) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; - else if(cshift == 2) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; - else if(cshift == 3) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; - else if(cshift == 4) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; - else if(cshift == 5) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; - else if(cshift == 6) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; - else if(cshift == 7) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - - - //reserved for cooperative communication - /* - if(ulsch->n_DMRS2 == 6) - ulsch->cooperation_flag = 2; - else - ulsch->cooperation_flag = 0; - */ - - if ((ulsch->harq_processes[harq_pid]->nb_rb>0) && (ulsch->harq_processes[harq_pid]->nb_rb < 25)) - ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb-1]; - - // if (ulsch->harq_processes[harq_pid]->Ndi == 1) - // ulsch->harq_processes[harq_pid]->status = ACTIVE; - - - if (cqi_req == 1) { - - if( (AntennaInfoDedicated__transmissionMode_tm3 == transmission_mode) || (AntennaInfoDedicated__transmissionMode_tm4 == transmission_mode) ) - { - ulsch->O_RI = 1; - } - else - { - ulsch->O_RI = 0; - } - //ulsch->O_RI = 0; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table - - switch(transmission_mode) { - // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling - case 1: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 2: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 3: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 4: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 5: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 6: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 7: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - default: - LOG_E(PHY,"Incorrect Transmission Mode \n"); - break; - } - } else { - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - } - - print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); - - ulsch->bundling = 1-AckNackFBMode; - - if (frame_parms->frame_type == FDD) { - //int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); - int dl_subframe = subframe; - - if (ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_ack[dl_subframe].send_harq_status>0) { // we have downlink transmission - ulsch->harq_processes[harq_pid]->O_ACK = 1; - } else { - ulsch->harq_processes[harq_pid]->O_ACK = 0; - } - /*LOG_I(PHY,"DCI 0 Processing: dl_subframe %d send_harq_status Odd %d send_harq_status Even %d harq_pid %d O_ACK %d\n", dl_subframe, - ue->dlsch[0][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, - ue->dlsch[1][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, - harq_pid, - ulsch->harq_processes[harq_pid]->O_ACK);*/ - - } else { - if (ulsch->bundling) - ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; - else - ulsch->harq_processes[harq_pid]->O_ACK = (dai >= 2)? 2 : (dai+1)&3; //(dai+1)&3; - - // ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; - } - - dlsch[0]->harq_ack[subframe].vDAI_UL = dai+1; - - - 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"), - cqi_req, cshift, TPC, dai, subframe, dlsch[0]->harq_ack[subframe].vDAI_UL, ndi, mcs, rballoc, - 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); - - 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); - - ulsch->beta_offset_cqi_times8 = beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index];//18; - ulsch->beta_offset_ri_times8 = beta_ri[ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index];//10; - ulsch->beta_offset_harqack_times8 = beta_ack[ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index];//16; - - ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); - ulsch->srs_active = use_srs; - - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; - else - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - ulsch->harq_processes[harq_pid]->rvidx = 0; - - // ulsch->harq_processes[harq_pid]->calibration_flag =0; - if (mcs < 29) { - ulsch->harq_processes[harq_pid]->mcs = mcs; - // ulsch->harq_processes[harq_pid]->round = 0; - } else { - ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; - if (ulsch->harq_processes[harq_pid]->round == 0) { - LOG_W(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); - } else { - LOG_D(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); - } - //LOG_E(PHY,"Fatal: mcs(%d) > 28!!! and round == 0\n", mcs); - } - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - - /* - else if (ulsch->harq_processes[harq_pid]->mcs == 29) { - ulsch->harq_processes[harq_pid]->mcs = 4; - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - // ulsch->harq_processes[harq_pid]->calibration_flag =1; - // printf("Auto-Calibration (UE): mcs %d, TBS %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->TBS,ulsch->harq_processes[harq_pid]->nb_rb); - }*/ - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->Nsymb_pusch; - - // a Ndi=1 automatically acknowledges previous PUSCH transmission - if (ue->ulsch_Msg3_active[eNB_id] == 1) - ue->ulsch_Msg3_active[eNB_id] = 0; - - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d), nb_rb %d, first_rb %d, mcs %d, round %d, rv %d, ulsch_ue_Msg3_active %d, cqi_req %d => O %d\n", - ue->Mod_id,harq_pid, - proc->frame_rx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift,ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb, - ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->round,ulsch->harq_processes[harq_pid]->rvidx, ue->ulsch_Msg3_active[eNB_id],cqi_req,ulsch->O); - - // ulsch->n_DMRS2 = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - -#ifdef UE_DEBUG_TRACE - - 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); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): harq_pid %d\n",harq_pid); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_tx %d\n",ulsch->harq_processes[harq_pid]->first_tx); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): DCINdi %d\n",ulsch->harq_processes[harq_pid]->DCINdi); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): round %d\n",ulsch->harq_processes[harq_pid]->round); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): O %d\n",ulsch->O); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): cqiReq %d\n",cqi_req); - //if (frame_parms->frame_type == TDD) - // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK/DAI %d/%d\n",ulsch->harq_processes[harq_pid]->O_ACK,dai); - //else - // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK %d\n",ulsch->harq_processes[harq_pid]->O_ACK); - - LOG_D(PHY,"Format 0 DCI :ulsch (ue): Nsymb_pusch %d\n",ulsch->Nsymb_pusch); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): phich status %d\n",ulsch->harq_processes[harq_pid]->status); -#else - UNUSED_VARIABLE(dai); -#endif - return(0); - } else { - LOG_E(PHY,"frame %d, subframe %d: FATAL ERROR, generate_ue_ulsch_params_from_dci, Illegal dci_format %d\n", - proc->frame_rx, subframe,dci_format); - return(-1); - } - -} - -/* -int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - void *dci_pdu, - uint16_t rnti, - DCI_format_t dci_format, - uint8_t UE_id, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t use_srs) -{ - - uint8_t harq_pid; - uint32_t rb_alloc; - uint8_t transmission_mode=eNB->transmission_mode[UE_id]; - ANFBmode_t AckNackFBMode = eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode; - LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id]; - LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - int subframe = proc->subframe_tx; - - uint32_t cqi_req = 0; - uint32_t dai = 0; - uint32_t cshift = 0; - uint32_t TPC = 0; - uint32_t mcs = 0; - uint32_t rballoc = UINT32_MAX; - uint32_t RIV_max = 0; - // uint32_t hopping; - // uint32_t type; - -#ifdef DEBUG_DCI - printf("filling eNB ulsch params for rnti %x, dci format %d, dci %x, subframe %d\n", - rnti,dci_format,*(uint32_t*)dci_pdu,subframe); -#endif - - if (dci_format == format0) { - - harq_pid = subframe2harq_pid(frame_parms, - pdcch_alloc2ul_frame(frame_parms, - proc->frame_tx, - subframe), - pdcch_alloc2ul_subframe(frame_parms,subframe)); - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max6; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT6[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT6[rballoc]; - - break; - - case 25: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max25; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT25[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT25[rballoc]; - - break; - - case 50: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max50; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT50[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT50[rballoc]; - - break; - - case 100: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max100; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT100[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT100[rballoc]; - - //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - rb_alloc = rballoc; - AssertFatal(rb_alloc>RIV_max, - "Format 0: rb_alloc (%d) > RIV_max (%d)\n",rb_alloc,RIV_max); -#ifdef DEBUG_DCI - printf("generate_eNB_ulsch_params_from_dci: subframe %d, rnti %x,harq_pid %d,cqi_req %d\n",subframe,rnti,harq_pid,cqi_req); -#endif - - ulsch->harq_processes[harq_pid]->dci_alloc = 1; - ulsch->harq_processes[harq_pid]->rar_alloc = 0; - ulsch->harq_processes[harq_pid]->TPC = TPC; - ulsch->harq_processes[harq_pid]->n_DMRS = cshift; - - - if (cqi_req == 1) { - // 36.213 7.2.1 (release 10) says: - // "RI is only reported for transmission modes 3 and 4, - // as well as transmission modes 8 and 9 with PMI/RI reporting" - // This is for aperiodic reporting. - // TODO: deal with TM 8&9 correctly when they are implemented. - // TODO: deal with periodic reporting if we implement it. - // - if (transmission_mode == 3 || transmission_mode == 4) - ulsch->harq_processes[harq_pid]->O_RI = 1; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table - else - ulsch->harq_processes[harq_pid]->O_RI = 0; - - switch(transmission_mode) { - // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling - case 1: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 2: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 3: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 4: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 5: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 6: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 7: - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - break; - - default: - LOG_E(PHY,"Incorrect Transmission Mode \n"); - break; - } - } else { - ulsch->harq_processes[harq_pid]->O_RI = 0; - ulsch->harq_processes[harq_pid]->Or2 = 0; - ulsch->harq_processes[harq_pid]->Or1 = 0; - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - ulsch->bundling = 1-AckNackFBMode; - - if (frame_parms->frame_type == FDD) { - int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); - - if (eNB->dlsch[UE_id][0]->subframe_tx[dl_subframe]>0) { // we have downlink transmission - ulsch->harq_processes[harq_pid]->O_ACK = 1; - } else { - ulsch->harq_processes[harq_pid]->O_ACK = 0; - } - } else { - if (ulsch->bundling) - ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; - else - ulsch->harq_processes[harq_pid]->O_ACK = (dai+1)&3; - - ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; - } - - ulsch->beta_offset_cqi_times8 = beta_cqi[eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index];//18; - ulsch->beta_offset_ri_times8 = beta_ri[eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index];//10; - ulsch->beta_offset_harqack_times8 = beta_ack[eNB->pusch_config_dedicated[UE_id].betaOffset_ACK_Index];//16; - - ulsch->harq_processes[harq_pid]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); - ulsch->harq_processes[harq_pid]->srs_active = use_srs; - - //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) - if(cshift == 0) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; - else if(cshift == 1) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; - else if(cshift == 2) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; - else if(cshift == 3) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; - else if(cshift == 4) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; - else if(cshift == 5) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; - else if(cshift == 6) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; - else if(cshift == 7) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - - - LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d)\n", - eNB->Mod_id,harq_pid,proc->frame_tx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift); - - - - if (ulsch->harq_processes[harq_pid]->round == 0) { - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; - else - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = mcs; - // ulsch->harq_processes[harq_pid]->calibration_flag = 0; - //if (ulsch->harq_processes[harq_pid]->mcs) - // - //if (ulsch->harq_processes[harq_pid]->mcs == 29) { - //ulsch->harq_processes[harq_pid]->mcs = 4; - // ulsch->harq_processes[harq_pid]->calibration_flag = 1; - // printf("Auto-Calibration (eNB): mcs %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->nb_rb); - //} - - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->harq_processes[harq_pid]->Nsymb_pusch; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - if (mcs>28) - ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; - else { - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = mcs; - } - - // ulsch->harq_processes[harq_pid]->round++; - } - - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->cba_rnti[0] = rnti; - } else { - ulsch->rnti = rnti; - } - - //ulsch->n_DMRS2 = cshift; - -#ifdef DEBUG_DCI - printf("ulsch (eNB): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - printf("ulsch (eNB): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); - printf("ulsch (eNB): harq_pid %d\n",harq_pid); - printf("ulsch (eNB): round %d\n",ulsch->harq_processes[harq_pid]->round); - printf("ulsch (eNB): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - printf("ulsch (eNB): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - printf("ulsch (eNB): Or1 %d\n",ulsch->harq_processes[harq_pid]->Or1); - printf("ulsch (eNB): Nsymb_pusch %d\n",ulsch->harq_processes[harq_pid]->Nsymb_pusch); - printf("ulsch (eNB): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); -#else - UNUSED_VARIABLE(dai); -#endif - return(0); - } else { - LOG_E(PHY,"generate_eNB_ulsch_params_from_dci, Illegal dci_format %d\n",dci_format); - return(-1); - } - -} -*/ - -double sinr_eff_cqi_calc(PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe) -{ - uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - PHY_MEASUREMENTS *meas = &ue->measurements; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int32_t **dl_channel_est = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id]; - double *s_dB; - s_dB = ue->sinr_CQI_dB; - // LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - //for the calculation of SINR_eff for CQI calculation - int count,a_rx,a_tx; - double abs_channel=0; - double channelx=0; - double channely=0; - double channelx_i=0; - double channely_i=0; - uint16_t q = quantize_subband_pmi(meas,eNB_id,7); - uint8_t qq; - - switch(transmission_mode) { - case 1: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - s_dB[count] = 10*log10(pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2], - 2)) - meas->n0_power_avg_dB; - } - } - } - - break; - - case 2: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - abs_channel=0; - - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - abs_channel += (pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2],2)); - } - } - - s_dB[count] = 10*log10(abs_channel/2) - meas->n0_power_avg_dB; - } - - break; - - case 5: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - channelx=0; - channely=0; - channelx_i=0; - channely_i=0; - qq = (q>>(((count/12)>>2)<<1))&3; - - //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - switch(qq) { - case 0: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 1: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 2: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 3: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - default: - printf("Problem in SINR Calculation for TM5 \n"); - break; - }//switch(qq) - }//a_rx - }//a_tx - - s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - 10 * log10 ((pow(channelx_i,2) + pow(channely_i,2))/2) - meas->n0_power_avg_dB; - }//count - - break; - - case 6: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - channelx=0; - channely=0; - qq = (q>>(((count/12)>>2)<<1))&3; - - //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - switch(qq) { - case 0: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 1: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 2: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 3: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - default: - printf("Problem in SINR Calculation for TM6 \n"); - break; - }//switch(qq) - }//a_rx - }//a_tx - - s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - meas->n0_power_avg_dB; - }//count - - break; - - default: - printf("Problem in SINR Calculation for CQI \n"); - break; - } - - int ii; - double sinr_eff = 0; - double sinr_eff_qpsk=0; - double sinr_eff_qam16=0; - double sinr_eff_qam64=0; - double x = 0; - double I_qpsk=0; - double I_qam16=0; - double I_qam64=0; - double I_qpsk_avg=0; - double I_qam16_avg=0; - double I_qam64_avg=0; - double qpsk_max=12.2; - double qam16_max=19.2; - double qam64_max=25.2; - double sinr_min = -20; - int offset=0; - - - for (offset = 0; offset <= 24; offset++) { - for(ii=0; ii<12; ii++) { - //x is the sinr_dB in dB - x = s_dB[(offset*12)+ii]; - - if(x<sinr_min) { - I_qpsk +=0; - I_qam16 +=0; - I_qam64 +=0; - } else { - if(x>qpsk_max) - I_qpsk += 1; - else - I_qpsk += (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]); - - if(x>qam16_max) - I_qam16 += 1; - else - I_qam16 += (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]); - - if(x>qam64_max) - I_qam64 += 1; - else - I_qam64 += (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_qpsk_avg = I_qpsk/(12*frame_parms->N_RB_DL); - I_qam16_avg = I_qam16/(12*frame_parms->N_RB_DL); - I_qam64_avg = I_qam64/(12*frame_parms->N_RB_DL); - - // I->SINR_effective Mapping - - sinr_eff_qpsk = (p_qpsk[0]*pow(I_qpsk_avg,7) + p_qpsk[1]*pow(I_qpsk_avg,6) + p_qpsk[2]*pow(I_qpsk_avg,5) + p_qpsk[3]*pow(I_qpsk_avg,4) + p_qpsk[4]*pow(I_qpsk_avg,3) + p_qpsk[5]*pow(I_qpsk_avg, - 2) + p_qpsk[6]*I_qpsk_avg + p_qpsk[7]); - - sinr_eff_qam16 = (p_qam16[0]*pow(I_qam16_avg,7) + p_qam16[1]*pow(I_qam16_avg,6) + p_qam16[2]*pow(I_qam16_avg,5) + p_qam16[3]*pow(I_qam16_avg,4) + p_qam16[4]*pow(I_qam16_avg, - 3) + p_qam16[5]*pow(I_qam16_avg,2) + p_qam16[6]*I_qam16_avg + p_qam16[7]); - - sinr_eff_qam64 = (p_qam64[0]*pow(I_qam64_avg,7) + p_qam64[1]*pow(I_qam64_avg,6) + p_qam64[2]*pow(I_qam64_avg,5) + p_qam64[3]*pow(I_qam64_avg,4) + p_qam64[4]*pow(I_qam64_avg, - 3) + p_qam64[5]*pow(I_qam64_avg,2) + p_qam64[6]*I_qam64_avg + p_qam64[7]); - sinr_eff = cmax3(sinr_eff_qpsk,sinr_eff_qam16,sinr_eff_qam64); - - //printf("SINR_Eff = %e\n",sinr_eff); - - return(sinr_eff); -} -// - - - -#ifdef DEBUG_DLSCH_TOOLS -main() -{ - - int i; - uint8_t rah; - uint32_t rballoc; - - generate_RIV_tables(); - - rah = 0; - rballoc = 0x1fff; - printf("rballoc 0 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rah = 1; - - rballoc = 0x1678; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - - rballoc = 0xfffc; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xfffd; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xffff; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xfffe; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); -} - -#endif diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c new file mode 100644 index 0000000000000000000000000000000000000000..8f0f8a6cab6fc308be46b61e562c149de5f74f66 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c @@ -0,0 +1,2276 @@ +/* + * 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/LTE_TRANSPORT/dci_tools.c + * \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler. + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#ifdef DEBUG_DCI_TOOLS +#include "PHY/phy_vars.h" +#endif +#include "assertions.h" +#include "nfapi_interface.h" +#include "transport_common_proto.h" +#include "SCHED/sched_common.h" +//#define DEBUG_HARQ + + +#include "LAYER2/MAC/mac.h" + +//#define DEBUG_DCI + +uint32_t localRIV2alloc_LUT6[32]; +uint32_t distRIV2alloc_even_LUT6[32]; +uint32_t distRIV2alloc_odd_LUT6[32]; +uint16_t RIV2nb_rb_LUT6[32]; +uint16_t RIV2first_rb_LUT6[32]; +uint16_t RIV_max6=0; + +uint32_t localRIV2alloc_LUT25[512]; +uint32_t distRIV2alloc_even_LUT25[512]; +uint32_t distRIV2alloc_odd_LUT25[512]; +uint16_t RIV2nb_rb_LUT25[512]; +uint16_t RIV2first_rb_LUT25[512]; +uint16_t RIV_max25=0; + + +uint32_t localRIV2alloc_LUT50_0[1600]; +uint32_t localRIV2alloc_LUT50_1[1600]; +uint32_t distRIV2alloc_gap0_even_LUT50_0[1600]; +uint32_t distRIV2alloc_gap0_odd_LUT50_0[1600]; +uint32_t distRIV2alloc_gap0_even_LUT50_1[1600]; +uint32_t distRIV2alloc_gap0_odd_LUT50_1[1600]; +uint32_t distRIV2alloc_gap1_even_LUT50_0[1600]; +uint32_t distRIV2alloc_gap1_odd_LUT50_0[1600]; +uint32_t distRIV2alloc_gap1_even_LUT50_1[1600]; +uint32_t distRIV2alloc_gap1_odd_LUT50_1[1600]; +uint16_t RIV2nb_rb_LUT50[1600]; +uint16_t RIV2first_rb_LUT50[1600]; +uint16_t RIV_max50=0; + +uint32_t localRIV2alloc_LUT100_0[6000]; +uint32_t localRIV2alloc_LUT100_1[6000]; +uint32_t localRIV2alloc_LUT100_2[6000]; +uint32_t localRIV2alloc_LUT100_3[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_0[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_0[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_1[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_1[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_2[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_2[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_3[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_3[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_0[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_0[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_1[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_1[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_2[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_2[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_3[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_3[6000]; +uint16_t RIV2nb_rb_LUT100[6000]; +uint16_t RIV2first_rb_LUT100[6000]; +uint16_t RIV_max100=0; + +extern RAN_CONTEXT_t RC; + +extern uint32_t current_dlsch_cqi; + +// Table 8.6.3-3 36.213 +uint16_t beta_cqi[16] = {0, //reserved + 0, //reserved + 9, //1.125 + 10, //1.250 + 11, //1.375 + 13, //1.625 + 14, //1.750 + 16, //2.000 + 18, //2.250 + 20, //2.500 + 23, //2.875 + 25, //3.125 + 28, //3.500 + 32, //4.000 + 40, //5.000 + 50 + }; //6.250 + +// Table 8.6.3-2 36.213 +uint16_t beta_ri[16] = {10, //1.250 + 13, //1.625 + 16, //2.000 + 20, //2.500 + 25, //3.125 + 32, //4.000 + 40, //5.000 + 50, //6.250 + 64, //8.000 + 80, //10.000 + 101, //12.625 + 127, //15.875 + 160, //20.000 + 0, //reserved + 0, //reserved + 0 + }; //reserved + +// Table 8.6.3-2 36.213 +uint16_t beta_ack[16] = {16, //2.000 + 20, //2.500 + 25, //3.125 + 32, //4.000 + 40, //5.000 + 50, //6.250 + 64, //8.000 + 80, //10.000 + 101, //12.625 + 127, //15.875 + 160, //20.000 + 248, //31.000 + 400, //50.000 + 640, //80.000 + 808 + };//126.00 + +int8_t delta_PUSCH_abs[4] = {-4,-1,1,4}; +int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; + +int8_t *delta_PUCCH_lut = delta_PUSCH_acc; + +uint8_t get_pmi(uint8_t N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb) +{ + /* + MIMO_mode_t mode = dlsch_harq->mimo_mode; + uint32_t pmi_alloc = dlsch_harq->pmi_alloc; + */ + + switch (N_RB_DL) { + case 6: // 1 PRB per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>(rb<<1))&3); + else + return((pmi_alloc>>rb)&1); + + break; + + default: + case 25: // 4 PRBs per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>((rb>>2)<<1))&3); + else + return((pmi_alloc>>(rb>>2))&1); + + break; + + case 50: // 6 PRBs per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>((rb/6)<<1))&3); + else + return((pmi_alloc>>(rb/6))&1); + + break; + + case 100: // 8 PRBs per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>((rb>>3)<<1))&3); + else + return((pmi_alloc>>(rb>>3))&1); + + break; + } +} + +uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi) +{ + + uint16_t i; + uint16_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + uint16_t mprime; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + if ((lprime>0) && (frame_parms->Ncp==0) ) + return(0); + + // printf("check_phich_reg : mi %d\n",mi); + + // compute REG based on symbol + if ((lprime == 0)|| + ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4))) + mprime = kprime/6; + else + mprime = kprime>>2; + + // check if PCFICH uses mprime + if ((lprime==0) && + ((mprime == pcfich_reg[0]) || + (mprime == pcfich_reg[1]) || + (mprime == pcfich_reg[2]) || + (mprime == pcfich_reg[3]))) { +#ifdef DEBUG_DCI_ENCODING + printf("[PHY] REG %d allocated to PCFICH\n",mprime); +#endif + return(1); + } + + // handle Special subframe case for TDD !!! + + // printf("Checking phich_reg %d\n",mprime); + if (mi > 0) { + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + if (frame_parms->Ncp == 1) { + Ngroup_PHICH<<=1; + } + + + + for (i=0; i<Ngroup_PHICH; i++) { + if ((mprime == frame_parms->phich_reg[i][0]) || + (mprime == frame_parms->phich_reg[i][1]) || + (mprime == frame_parms->phich_reg[i][2])) { +#ifdef DEBUG_DCI_ENCODING + printf("[PHY] REG %d (lprime %d) allocated to PHICH\n",mprime,lprime); +#endif + return(1); + } + } + } + + return(0); +} + +uint16_t get_nquad(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) +{ + + uint16_t Nreg=0; + uint8_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + if (frame_parms->Ncp == 1) { + Ngroup_PHICH<<=1; + } + + Ngroup_PHICH*=mi; + + if ((num_pdcch_symbols>0) && (num_pdcch_symbols<4)) + switch (frame_parms->N_RB_DL) { + case 6: + Nreg=12+(num_pdcch_symbols-1)*18; + break; + + case 25: + Nreg=50+(num_pdcch_symbols-1)*75; + break; + + case 50: + Nreg=100+(num_pdcch_symbols-1)*150; + break; + + case 100: + Nreg=200+(num_pdcch_symbols-1)*300; + break; + + default: + return(0); + } + + // printf("Nreg %d (%d)\n",Nreg,Nreg - 4 - (3*Ngroup_PHICH)); + return(Nreg - 4 - (3*Ngroup_PHICH)); +} + +uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) +{ + return(get_nquad(num_pdcch_symbols,frame_parms,mi)/9); +} + + + +uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe) +{ + + // check for eNB only ! + return(get_nCCE(num_pdcch_symbols, + &RC.eNB[Mod_id][CC_id]->frame_parms, + get_mi(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe))); +} + + +void conv_eMTC_rballoc(uint16_t resource_block_coding, + uint32_t N_RB_DL, + uint32_t *rb_alloc) { + + + int narrowband = resource_block_coding>>5; + int RIV = resource_block_coding&31; + int N_NB_DL = N_RB_DL/6; + int i0 = (N_RB_DL>>1) - (3*N_NB_DL); + int first_rb = (6*narrowband)+i0; + int alloc = localRIV2alloc_LUT6[RIV]; + int ind = first_rb>>5; + int ind_mod = first_rb&31; + + if (((N_RB_DL&1) > 0) && (narrowband>=(N_NB_DL>>1))) first_rb++; + rb_alloc[0] = 0; + rb_alloc[1] = 0; + rb_alloc[2] = 0; + rb_alloc[3] = 0; + rb_alloc[ind] = alloc<<ind_mod; + if (ind_mod > 26) rb_alloc[ind+1] = alloc>>(6-(ind_mod-26)); +} + +void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2) +{ + + uint32_t i,shift,subset; + rb_alloc2[0] = 0; + rb_alloc2[1] = 0; + rb_alloc2[2] = 0; + rb_alloc2[3] = 0; + + // printf("N_RB_DL %d, ra_header %d, rb_alloc %x\n",N_RB_DL,ra_header,rb_alloc); + + switch (N_RB_DL) { + + case 6: + rb_alloc2[0] = rb_alloc&0x3f; + break; + + case 25: + if (ra_header == 0) {// Type 0 Allocation + + for (i=12; i>0; i--) { + if ((rb_alloc&(1<<i)) != 0) + rb_alloc2[0] |= (3<<((2*(12-i)))); + + // printf("rb_alloc2 (type 0) %x\n",rb_alloc2); + } + + if ((rb_alloc&1) != 0) + rb_alloc2[0] |= (1<<24); + } else { + subset = rb_alloc&1; + shift = (rb_alloc>>1)&1; + + for (i=0; i<11; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + rb_alloc2[0] |= (1<<(2*i)); + + //printf("rb_alloc2 (type 1) %x\n",rb_alloc2); + } + + if ((shift == 0) && (subset == 1)) + rb_alloc2[0]<<=1; + else if ((shift == 1) && (subset == 0)) + rb_alloc2[0]<<=4; + else if ((shift == 1) && (subset == 1)) + rb_alloc2[0]<<=3; + } + + break; + + case 50: + AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=50\n"); + + for (i=16; i>0; i--) { + if ((rb_alloc&(1<<i)) != 0) + rb_alloc2[(3*(16-i))>>5] |= (7<<((3*(16-i))%32)); + } + + // bit mask across + if ((rb_alloc2[0]>>31)==1) + rb_alloc2[1] |= 1; + + if ((rb_alloc&1) != 0) + rb_alloc2[1] |= (3<<16); + break; + + case 100: + AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=100\n"); + for (i=0; i<25; i++) { + if ((rb_alloc&(1<<(24-i))) != 0) + rb_alloc2[(4*i)>>5] |= (0xf<<((4*i)%32)); + + // printf("rb_alloc2[%d] (type 0) %x (%d)\n",(4*i)>>5,rb_alloc2[(4*i)>>5],rb_alloc&(1<<i)); + } + + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", N_RB_DL); + DevParam (N_RB_DL, 0, 0); + break; + } + +} + + + +uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL) +{ + + uint32_t nprb=0,i; + + switch (N_RB_DL) { + case 6: + for (i=0; i<6; i++) { + if ((rb_alloc&(1<<i)) != 0) + nprb += 1; + } + + break; + + case 25: + if (ra_header == 0) {// Type 0 Allocation + + for (i=12; i>0; i--) { + if ((rb_alloc&(1<<i)) != 0) + nprb += 2; + } + + if ((rb_alloc&1) != 0) + nprb += 1; + } else { + for (i=0; i<11; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + nprb += 1; + } + } + + break; + + case 50: + if (ra_header == 0) {// Type 0 Allocation + + for (i=0; i<16; i++) { + if ((rb_alloc&(1<<(16-i))) != 0) + nprb += 3; + } + + if ((rb_alloc&1) != 0) + nprb += 2; + + } else { + for (i=0; i<17; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + nprb += 1; + } + } + + break; + + case 100: + if (ra_header == 0) {// Type 0 Allocation + + for (i=0; i<25; i++) { + if ((rb_alloc&(1<<(24-i))) != 0) + nprb += 4; + } + } else { + for (i=0; i<25; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + nprb += 1; + } + } + + break; + + default: + LOG_E(PHY,"Invalide N_RB_DL %d\n", N_RB_DL); + DevParam (N_RB_DL, 0, 0); + break; + } + + return(nprb); +} + +uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs) +{ + + 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); + + return(RIV); +} + +// Convert a DCI Format 1C RIV to a Format 1A RIV +// This extracts the start and length in PRBs from the 1C rballoc and +// recomputes the RIV as if it were the 1A rballoc + +uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL) { + + int NpDLVRB,N_RB_step,LpCRBsm1,RBpstart; + + switch (N_RB_DL) { + + case 6: // N_RB_step = 2, NDLVRB = 6, NpDLVRB = 3 + NpDLVRB = 3; + N_RB_step = 2; + break; + case 25: // N_RB_step = 2, NDLVRB = 24, NpDLVRB = 12 + NpDLVRB = 12; + N_RB_step = 2; + break; + case 50: // N_RB_step = 4, NDLVRB = 46, NpDLVRB = 11 + NpDLVRB = 11; + N_RB_step = 4; + break; + case 100: // N_RB_step = 4, NDLVRB = 96, NpDLVRB = 24 + NpDLVRB = 24; + N_RB_step = 4; + break; + default: + NpDLVRB = 24; + N_RB_step = 4; + break; + } + + // This is the 1C part from 7.1.6.3 in 36.213 + LpCRBsm1 = rballoc/NpDLVRB; + // printf("LpCRBs = %d\n",LpCRBsm1+1); + + if (LpCRBsm1 <= (NpDLVRB/2)) { + RBpstart = rballoc % NpDLVRB; + } + else { + LpCRBsm1 = NpDLVRB-LpCRBsm1; + RBpstart = NpDLVRB-(rballoc%NpDLVRB); + } + // printf("RBpstart %d\n",RBpstart); + return(computeRIV(N_RB_DL,N_RB_step*RBpstart,N_RB_step*(LpCRBsm1+1))); + +} + +uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { + + int offset; + + switch (N_RB_DL) { + + case 6: + // N_RB_DL = tildeN_RB_DL = 6 + // Ngap = 4 , P=1, Nrow = 2, Nnull = 2 + + switch (vrb) { + case 0: // even: 0->0, 1->2, odd: 0->3, 1->5 + case 1: + return ((3*odd_slot) + 2*(vrb&3))%6; + break; + case 2: // even: 2->3, 3->5, odd: 2->0, 3->2 + case 3: + return ((3*odd_slot) + 2*(vrb&3) + 5)%6; + break; + case 4: // even: 4->1, odd: 4->4 + return ((3*odd_slot) + 1)%6; + case 5: // even: 5->4, odd: 5->1 + return ((3*odd_slot) + 4)%6; + break; + } + break; + + case 15: + if (vrb<12) { + if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11 + return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); + else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13 + return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); + } + if (vrb==12) + return (3+(7*odd_slot)) % 14; + if (vrb==13) + return (10+(7*odd_slot)) % 14; + return 14; + break; + + case 25: + return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); + break; + + case 50: // P=3 + if (Ngap==0) { + // Nrow=12,Nnull=2,NVRBDL=46,Ngap1= 27 + if (vrb>=23) + offset=4; + else + offset=0; + if (vrb<44) { + if ((vrb&3)>=2) + return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; + else + return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; + } + if (vrb==44) // even: 44->11, odd: 45->34 + return offset+((23*odd_slot) + 22-12+1); + if (vrb==45) // even: 45->10, odd: 45->33 + return offset+((23*odd_slot) + 22+12); + if (vrb==46) + return offset+46+((23*odd_slot) + 23-12+1) % 46; + if (vrb==47) + return offset+46+((23*odd_slot) + 23+12) % 46; + if (vrb==48) + return offset+46+((23*odd_slot) + 23-12+1) % 46; + if (vrb==49) + return offset+46+((23*odd_slot) + 23+12) % 46; + } + else { + // Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27 + if (vrb>=9) + offset=18; + else + offset=0; + + if (vrb<12) { + if ((vrb&3)>=2) + return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; + else + return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; + } + else { + return offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18); + } + } + break; + case 75: + // Ngap1 = 32, NVRBRL=64, P=4, Nrow= 16, Nnull=0 + if (Ngap ==0) { + return ((32*odd_slot) + 16*(vrb&3) + (vrb>>2))%64 + (vrb/64); + } else { + // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 + return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); + } + break; + case 100: + // Ngap1 = 48, NVRBDL=96, Nrow=24, Nnull=0 + if (Ngap ==0) { + return ((48*odd_slot) + 24*(vrb&3) + (vrb>>2))%96 + (vrb/96); + } else { + // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 + return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); + } + break; + default: + LOG_E(PHY,"Unknown N_RB_DL %d\n",N_RB_DL); + return 0; + } + return 0; + +} + + +void generate_RIV_tables(void) +{ + + // 6RBs localized RIV + uint8_t Lcrbs,RBstart; + uint16_t RIV; + uint32_t alloc0,allocdist0_0_even,allocdist0_0_odd,allocdist0_1_even,allocdist0_1_odd; + uint32_t alloc1,allocdist1_0_even,allocdist1_0_odd,allocdist1_1_even,allocdist1_1_odd; + uint32_t alloc2,allocdist2_0_even,allocdist2_0_odd,allocdist2_1_even,allocdist2_1_odd; + uint32_t alloc3,allocdist3_0_even,allocdist3_0_odd,allocdist3_1_even,allocdist3_1_odd; + uint32_t nVRB,nVRB_even_dist,nVRB_odd_dist; + + for (RBstart=0; RBstart<6; RBstart++) { + alloc0 = 0; + allocdist0_0_even = 0; + allocdist0_0_odd = 0; + for (Lcrbs=1; Lcrbs<=(6-RBstart); Lcrbs++) { + //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); + nVRB = Lcrbs-1+RBstart; + alloc0 |= (1<<nVRB); + allocdist0_0_even |= (1<<get_prb(6,0,nVRB,0)); + allocdist0_0_odd |= (1<<get_prb(6,1,nVRB,0)); + RIV=computeRIV(6,RBstart,Lcrbs); + + if (RIV>RIV_max6) + RIV_max6 = RIV; + + // printf("RIV %d (%d) : first_rb %d NBRB %d\n",RIV,localRIV2alloc_LUT25[RIV],RBstart,Lcrbs); + localRIV2alloc_LUT6[RIV] = alloc0; + distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even; + distRIV2alloc_odd_LUT6[RIV] = allocdist0_0_odd; + RIV2nb_rb_LUT6[RIV] = Lcrbs; + RIV2first_rb_LUT6[RIV] = RBstart; + } + } + + + for (RBstart=0; RBstart<25; RBstart++) { + alloc0 = 0; + allocdist0_0_even = 0; + allocdist0_0_odd = 0; + for (Lcrbs=1; Lcrbs<=(25-RBstart); Lcrbs++) { + nVRB = Lcrbs-1+RBstart; + //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); + alloc0 |= (1<<nVRB); + allocdist0_0_even |= (1<<get_prb(25,0,nVRB,0)); + allocdist0_0_odd |= (1<<get_prb(25,1,nVRB,0)); + + //printf("alloc 0 %x, allocdist0_even %x, allocdist0_odd %x\n",alloc0,allocdist0_0_even,allocdist0_0_odd); + RIV=computeRIV(25,RBstart,Lcrbs); + + if (RIV>RIV_max25) + RIV_max25 = RIV;; + + + localRIV2alloc_LUT25[RIV] = alloc0; + distRIV2alloc_even_LUT25[RIV] = allocdist0_0_even; + distRIV2alloc_odd_LUT25[RIV] = allocdist0_0_odd; + RIV2nb_rb_LUT25[RIV] = Lcrbs; + RIV2first_rb_LUT25[RIV] = RBstart; + } + } + + + for (RBstart=0; RBstart<50; RBstart++) { + alloc0 = 0; + alloc1 = 0; + allocdist0_0_even=0; + allocdist1_0_even=0; + allocdist0_0_odd=0; + allocdist1_0_odd=0; + allocdist0_1_even=0; + allocdist1_1_even=0; + allocdist0_1_odd=0; + allocdist1_1_odd=0; + + for (Lcrbs=1; Lcrbs<=(50-RBstart); Lcrbs++) { + + nVRB = Lcrbs-1+RBstart; + + + if (nVRB<32) + alloc0 |= (1<<nVRB); + else + alloc1 |= (1<<(nVRB-32)); + + // Distributed Gap1, even slot + nVRB_even_dist = get_prb(50,0,nVRB,0); + if (nVRB_even_dist<32) + allocdist0_0_even |= (1<<nVRB_even_dist); + else + allocdist1_0_even |= (1<<(nVRB_even_dist-32)); + + // Distributed Gap1, odd slot + nVRB_odd_dist = get_prb(50,1,nVRB,0); + if (nVRB_odd_dist<32) + allocdist0_0_odd |= (1<<nVRB_odd_dist); + else + allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); + + // Distributed Gap2, even slot + nVRB_even_dist = get_prb(50,0,nVRB,1); + if (nVRB_even_dist<32) + allocdist0_1_even |= (1<<nVRB_even_dist); + else + allocdist1_1_even |= (1<<(nVRB_even_dist-32)); + + // Distributed Gap2, odd slot + nVRB_odd_dist = get_prb(50,1,nVRB,1); + if (nVRB_odd_dist<32) + allocdist0_1_odd |= (1<<nVRB_odd_dist); + else + allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); + + RIV=computeRIV(50,RBstart,Lcrbs); + + if (RIV>RIV_max50) + RIV_max50 = RIV; + + // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); + localRIV2alloc_LUT50_0[RIV] = alloc0; + localRIV2alloc_LUT50_1[RIV] = alloc1; + distRIV2alloc_gap0_even_LUT50_0[RIV] = allocdist0_0_even; + distRIV2alloc_gap0_even_LUT50_1[RIV] = allocdist1_0_even; + distRIV2alloc_gap0_odd_LUT50_0[RIV] = allocdist0_0_odd; + distRIV2alloc_gap0_odd_LUT50_1[RIV] = allocdist1_0_odd; + distRIV2alloc_gap1_even_LUT50_0[RIV] = allocdist0_1_even; + distRIV2alloc_gap1_even_LUT50_1[RIV] = allocdist1_1_even; + distRIV2alloc_gap1_odd_LUT50_0[RIV] = allocdist0_1_odd; + distRIV2alloc_gap1_odd_LUT50_1[RIV] = allocdist1_1_odd; + RIV2nb_rb_LUT50[RIV] = Lcrbs; + RIV2first_rb_LUT50[RIV] = RBstart; + } + } + + + for (RBstart=0; RBstart<100; RBstart++) { + alloc0 = 0; + alloc1 = 0; + alloc2 = 0; + alloc3 = 0; + allocdist0_0_even=0; + allocdist1_0_even=0; + allocdist2_0_even=0; + allocdist3_0_even=0; + allocdist0_0_odd=0; + allocdist1_0_odd=0; + allocdist2_0_odd=0; + allocdist3_0_odd=0; + allocdist0_1_even=0; + allocdist1_1_even=0; + allocdist2_1_even=0; + allocdist3_1_even=0; + allocdist0_1_odd=0; + allocdist1_1_odd=0; + allocdist2_1_odd=0; + allocdist3_1_odd=0; + + for (Lcrbs=1; Lcrbs<=(100-RBstart); Lcrbs++) { + + nVRB = Lcrbs-1+RBstart; + + if (nVRB<32) + alloc0 |= (1<<nVRB); + else if (nVRB<64) + alloc1 |= (1<<(nVRB-32)); + else if (nVRB<96) + alloc2 |= (1<<(nVRB-64)); + else + alloc3 |= (1<<(nVRB-96)); + + // Distributed Gap1, even slot + nVRB_even_dist = get_prb(100,0,nVRB,0); + +// if ((RBstart==0) && (Lcrbs<=8)) +// printf("nVRB %d => nVRB_even_dist %d\n",nVRB,nVRB_even_dist); + + + if (nVRB_even_dist<32) + allocdist0_0_even |= (1<<nVRB_even_dist); + else if (nVRB_even_dist<64) + allocdist1_0_even |= (1<<(nVRB_even_dist-32)); + else if (nVRB_even_dist<96) + allocdist2_0_even |= (1<<(nVRB_even_dist-64)); + else + allocdist3_0_even |= (1<<(nVRB_even_dist-96)); +/* if ((RBstart==0) && (Lcrbs<=8)) + printf("rballoc =>(%08x.%08x.%08x.%08x)\n", + allocdist0_0_even, + allocdist1_0_even, + allocdist2_0_even, + allocdist3_0_even + ); +*/ + // Distributed Gap1, odd slot + nVRB_odd_dist = get_prb(100,1,nVRB,0); + if (nVRB_odd_dist<32) + allocdist0_0_odd |= (1<<nVRB_odd_dist); + else if (nVRB_odd_dist<64) + allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); + else if (nVRB_odd_dist<96) + allocdist2_0_odd |= (1<<(nVRB_odd_dist-64)); + else + allocdist3_0_odd |= (1<<(nVRB_odd_dist-96)); + + + // Distributed Gap2, even slot + nVRB_even_dist = get_prb(100,0,nVRB,1); + if (nVRB_even_dist<32) + allocdist0_1_even |= (1<<nVRB_even_dist); + else if (nVRB_even_dist<64) + allocdist1_1_even |= (1<<(nVRB_even_dist-32)); + else if (nVRB_even_dist<96) + allocdist2_1_even |= (1<<(nVRB_even_dist-64)); + else + allocdist3_1_even |= (1<<(nVRB_even_dist-96)); + + + // Distributed Gap2, odd slot + nVRB_odd_dist = get_prb(100,1,nVRB,1); + if (nVRB_odd_dist<32) + allocdist0_1_odd |= (1<<nVRB_odd_dist); + else if (nVRB_odd_dist<64) + allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); + else if (nVRB_odd_dist<96) + allocdist2_1_odd |= (1<<(nVRB_odd_dist-64)); + else + allocdist3_1_odd |= (1<<(nVRB_odd_dist-96)); + + + RIV=computeRIV(100,RBstart,Lcrbs); + + if (RIV>RIV_max100) + RIV_max100 = RIV; + + // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); + localRIV2alloc_LUT100_0[RIV] = alloc0; + localRIV2alloc_LUT100_1[RIV] = alloc1; + localRIV2alloc_LUT100_2[RIV] = alloc2; + localRIV2alloc_LUT100_3[RIV] = alloc3; + distRIV2alloc_gap0_even_LUT100_0[RIV] = allocdist0_0_even; + distRIV2alloc_gap0_even_LUT100_1[RIV] = allocdist1_0_even; + distRIV2alloc_gap0_even_LUT100_2[RIV] = allocdist2_0_even; + distRIV2alloc_gap0_even_LUT100_3[RIV] = allocdist3_0_even; + distRIV2alloc_gap0_odd_LUT100_0[RIV] = allocdist0_0_odd; + distRIV2alloc_gap0_odd_LUT100_1[RIV] = allocdist1_0_odd; + distRIV2alloc_gap0_odd_LUT100_2[RIV] = allocdist2_0_odd; + distRIV2alloc_gap0_odd_LUT100_3[RIV] = allocdist3_0_odd; + distRIV2alloc_gap1_even_LUT100_0[RIV] = allocdist0_1_even; + distRIV2alloc_gap1_even_LUT100_1[RIV] = allocdist1_1_even; + distRIV2alloc_gap1_even_LUT100_2[RIV] = allocdist2_1_even; + distRIV2alloc_gap1_even_LUT100_3[RIV] = allocdist3_1_even; + distRIV2alloc_gap1_odd_LUT100_0[RIV] = allocdist0_1_odd; + distRIV2alloc_gap1_odd_LUT100_1[RIV] = allocdist1_1_odd; + distRIV2alloc_gap1_odd_LUT100_2[RIV] = allocdist2_1_odd; + distRIV2alloc_gap1_odd_LUT100_3[RIV] = allocdist3_1_odd; + + RIV2nb_rb_LUT100[RIV] = Lcrbs; + RIV2first_rb_LUT100[RIV] = RBstart; + } + } +} + +// Ngap = 3, N_VRB_DL=6, P=1, N_row=2, N_null=4*2-6=2 +// permutation for even slots : +// n_PRB'(0,2,4) = (0,1,2), n_PRB'(1,3,5) = (4,5,6) +// n_PRB''(0,1,2,3) = (0,2,4,6) +// => n_tilde_PRB(5) = (4) +// n_tilde_PRB(4) = (1) +// n_tilde_PRB(2,3) = (3,5) +// n_tilde_PRB(0,1) = (0,2) + +uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci) +{ + + return(localRIV2alloc_LUT25[rb_alloc_dci]); + +} + +uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) +{ + uint8_t ret = 255; + + if (frame_parms->frame_type == FDD) { + ret = (((frame*10)+subframe)&7); + } else { + + switch (frame_parms->tdd_config) { + + 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: + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + break; + } + + break; + + case 2: + if ((subframe!=2) && (subframe!=7)) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret=255; + } + else ret = (subframe/7); + break; + + case 3: + if ((subframe<2) || (subframe>4)) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + } + else ret = (subframe-2); + break; + + case 4: + if ((subframe<2) || (subframe>3)) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + } + else ret = (subframe-2); + break; + + case 5: + if (subframe!=2) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + } + else ret = (subframe-2); + break; + + default: + LOG_E(PHY,"subframe2_harq_pid, Unsupported TDD mode %d\n",frame_parms->tdd_config); + ret = (255); + } + } + + AssertFatal(ret!=255, + "invalid harq_pid(%d) at SFN/SF = %d/%d\n", (int8_t)ret, frame, subframe); + return ret; +} + +uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) +{ + uint8_t ul_subframe = 255; + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1) && + ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 + ul_subframe = ((n+6)%10); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + ((n==0)||(n==1)||(n==5)||(n==6))) + ul_subframe = ((n+7)%10); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + (n==9)) // tdd_config 6 SF 9 + ul_subframe = ((n+5)%10); + else + ul_subframe = ((n+4)%10); + + 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; +} + +uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) +{ + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1) && + ((n==7)||(n==2))) // tdd_config 0,1 SF 1,5 + return((n==7)? 1 : 6); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + ((n==7)||(n==8)||(n==2)||(n==3))) + return((n+3)%10); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + (n==4)) // tdd_config 6 SF 9 + return(9); + else + return((n+6)%10); +} + +uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) +{ + uint32_t ul_frame; + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1) && + ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 + ul_frame = (frame + (n==1 ? 0 : 1)); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + ((n==0)||(n==1)||(n==5)||(n==6))) + ul_frame = (frame + (n>=5 ? 1 : 0)); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + (n==9)) // tdd_config 6 SF 9 + ul_frame = (frame+1); + else + ul_frame = (frame+(n>=6 ? 1 : 0)); + + LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame); + return ul_frame % 1024; +} + +uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank) +{ + + uint8_t i,wideband_pmi2; + uint32_t pmi_ex = 0; + + if (frame_parms->N_RB_DL!=25) { + LOG_E(PHY,"pmi_extend not yet implemented for anything else than 25PRB\n"); + return(-1); + } + + if (rank==0) { + wideband_pmi2=wideband_pmi&3; + for (i=0; i<14; i+=2) + pmi_ex|=(wideband_pmi2<<i); + } + else if (rank==1) { + wideband_pmi2=wideband_pmi&1; + for (i=0; i<7; i++) + pmi_ex|=(wideband_pmi2<<i); + } + else { + LOG_E(PHY,"unsupported rank\n"); + return(-1); + } + + return(pmi_ex); +} + +uint64_t pmi2hex_2Ar1(uint32_t pmi) +{ + + uint64_t pmil = (uint64_t)pmi; + + return ((pmil&3) + (((pmil>>2)&3)<<4) + (((pmil>>4)&3)<<8) + (((pmil>>6)&3)<<12) + + (((pmil>>8)&3)<<16) + (((pmil>>10)&3)<<20) + (((pmil>>12)&3)<<24) + + (((pmil>>14)&3)<<28) + (((pmil>>16)&3)<<32) + (((pmil>>18)&3)<<36) + + (((pmil>>20)&3)<<40) + (((pmil>>22)&3)<<44) + (((pmil>>24)&3)<<48)); +} + +uint64_t pmi2hex_2Ar2(uint32_t pmi) +{ + + uint64_t pmil = (uint64_t)pmi; + return ((pmil&1) + (((pmil>>1)&1)<<4) + (((pmil>>2)&1)<<8) + (((pmil>>3)&1)<<12) + + (((pmil>>4)&1)<<16) + (((pmil>>5)&1)<<20) + (((pmil>>6)&1)<<24) + + (((pmil>>7)&1)<<28) + (((pmil>>8)&1)<<32) + (((pmil>>9)&1)<<36) + + (((pmil>>10)&1)<<40) + (((pmil>>11)&1)<<44) + (((pmil>>12)&1)<<48)); +} + + +int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) +{ + switch (dci->format) { + + case format0: // This is an UL SCH allocation so nothing here, inform MAC + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format0 (TDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 25: + LOG_D(PHY,"DCI format0 (TDD1-6, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 50: + LOG_D(PHY,"DCI format0 (TDD1-6, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 100: + LOG_D(PHY,"DCI format0 (TDD1-6, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + else if (frame_parms->frame_type == FDD) + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format0 (FDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 25: + LOG_D(PHY,"DCI format0 (FDD, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 50: + LOG_D(PHY,"DCI format0 (FDD, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 100: + LOG_D(PHY,"DCI format0 (FDD, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format1: + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) + + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1 (TDD 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + case 25: + LOG_D(PHY,"DCI format1 (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + case 50: + LOG_D(PHY,"DCI format1 (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + case 100: + LOG_D(PHY,"DCI format1 (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + else if (frame_parms->frame_type == FDD) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1 (FDD, 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format1 (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format1 (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format1 (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format1A: // This is DLSCH allocation for control traffic + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) { + switch (frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1A (TDD1-6, 1_5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + case 25: + LOG_D(PHY,"DCI format1A (TDD1-6, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %d (NB_RB %d)\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + case 50: + LOG_D(PHY,"DCI format1A (TDD1-6, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + case 100: + LOG_D(PHY,"DCI format1A (TDD1-6, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + } else if (frame_parms->frame_type == FDD) { + switch (frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1A(FDD, 1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format1A(FDD, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format1A(FDD, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format1A(FDD, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + + break; + + case format1C: // This is DLSCH allocation for control traffic + switch (frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1C (1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n", + ((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT6[conv_1C_RIV(((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,6)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + case 25: + LOG_D(PHY,"DCI format1C (5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[conv_1C_RIV(((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,25)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + case 50: + LOG_D(PHY,"DCI format1C (10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"Ngap %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->Ngap); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,50)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + case 100: + LOG_D(PHY,"DCI format1C (20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"Ngap %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->Ngap); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,100)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + + break; + + case format2: + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi + ); + break; + + case 25: + LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 50: + LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 100: + LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi + ); + break; + + case 25: + LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 50: + LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 100: + LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } else if (frame_parms->frame_type == FDD) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + + LOG_D(PHY,"DCI format2 2 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, swap %d, TPMI %d, TPC %d\n", + + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2 2 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2 2 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + + case 6: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } + + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format2A: + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap + ); + break; + + case 25: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); + break; + + case 50: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); + break; + + case 100: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi + ); + break; + + case 25: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 50: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 100: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } else if (frame_parms->frame_type == FDD) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + + case 6: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } + + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format1E_2A_M10PRB: + + LOG_D(PHY,"DCI format1E_2A_M10PRB, rnti %x (%8x): harq_pid %d, rah %d, rb_alloc %x, mcs %d, rv %d, tpmi %d, ndi %d, dl_power_offset %d\n", + dci->rnti, + ((uint32_t *)&dci->dci_pdu)[0], + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->harq_pid, + //((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->dl_power_off + ); + + break; + + default: + LOG_E(PHY,"dci_tools.c: dump_dci, unknown format %d\n",dci->format); + return(-1); + } + + return(0); +} diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common_extern.h b/openair1/PHY/LTE_TRANSPORT/dci_tools_common_extern.h new file mode 100644 index 0000000000000000000000000000000000000000..b0a06fb9f1e2359d0e512eb7a78effd1549d88a9 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common_extern.h @@ -0,0 +1,89 @@ +/* + * 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/LTE_TRANSPORT/dci_tools_common_extern.h + * \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler. + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include <stdint.h> + +extern uint32_t localRIV2alloc_LUT6[32]; +extern uint32_t distRIV2alloc_even_LUT6[32]; +extern uint32_t distRIV2alloc_odd_LUT6[32]; +extern uint16_t RIV2nb_rb_LUT6[32]; +extern uint16_t RIV2first_rb_LUT6[32]; +extern uint16_t RIV_max6; + +extern uint32_t localRIV2alloc_LUT25[512]; +extern uint32_t distRIV2alloc_even_LUT25[512]; +extern uint32_t distRIV2alloc_odd_LUT25[512]; +extern uint16_t RIV2nb_rb_LUT25[512]; +extern uint16_t RIV2first_rb_LUT25[512]; +extern uint16_t RIV_max25; + + +extern uint32_t localRIV2alloc_LUT50_0[1600]; +extern uint32_t localRIV2alloc_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap0_even_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap0_odd_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap0_even_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap0_odd_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap1_even_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap1_odd_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap1_even_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap1_odd_LUT50_1[1600]; +extern uint16_t RIV2nb_rb_LUT50[1600]; +extern uint16_t RIV2first_rb_LUT50[1600]; +extern uint16_t RIV_max50; + +extern uint32_t localRIV2alloc_LUT100_0[6000]; +extern uint32_t localRIV2alloc_LUT100_1[6000]; +extern uint32_t localRIV2alloc_LUT100_2[6000]; +extern uint32_t localRIV2alloc_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_3[6000]; +extern uint16_t RIV2nb_rb_LUT100[6000]; +extern uint16_t RIV2first_rb_LUT100[6000]; +extern uint16_t RIV_max100; + +extern int8_t *delta_PUCCH_lut; +extern int8_t delta_PUSCH_acc[4]; +extern int8_t delta_PUSCH_abs[4]; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 49db69cff483840ec5eab89e7d1ed36c44558196..a726621022743e5daebaaee5cae84d536da3f267 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -30,15 +30,14 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "SCHED/defs.h" -#include "defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/LOG/log.h" #include <syscall.h> @@ -398,12 +397,12 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, - time_stats_t *te_wait_stats, - time_stats_t *te_main_stats, - time_stats_t *te_wakeup_stats0, - time_stats_t *te_wakeup_stats1, - time_stats_t *i_stats, - int worker_num) + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats, + int worker_num) { //start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); @@ -900,186 +899,6 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, } -int dlsch_encoding_SIC(PHY_VARS_UE *ue, - unsigned char *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *i_stats) -{ - - unsigned int G; - unsigned int crc=1; - unsigned short iind; - - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - unsigned char harq_pid = ue->dlsch[subframe&2][0][0]->rnti; - unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; - unsigned int A; - unsigned char mod_order; - unsigned int Kr=0,Kr_bytes,r,r_offset=0; - // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; - uint8_t beamforming_mode=0; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); - - A = dlsch->harq_processes[harq_pid]->TBS; //6228 - // printf("Encoder: A: %d\n",A); - mod_order = dlsch->harq_processes[harq_pid]->Qm; - - if(dlsch->harq_processes[harq_pid]->mimo_mode == TM7) - beamforming_mode = 7; - else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM8) - beamforming_mode = 8; - else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM9_10) - beamforming_mode = 9; - G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe,beamforming_mode); - - - // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet -#ifdef DEBUG_DLSCH_CODING - printf("SIC encoding thinks this is a new packet \n"); -#endif - /* - int i; - printf("dlsch (tx): \n"); - for (i=0;i<(A>>3);i++) - printf("%02x.",a[i]); - printf("\n"); - */ - // Add 24-bit crc (polynomial A) to payload - crc = crc24a(a, - A)>>8; - a[A>>3] = ((uint8_t*)&crc)[2]; - a[1+(A>>3)] = ((uint8_t*)&crc)[1]; - a[2+(A>>3)] = ((uint8_t*)&crc)[0]; - // printf("CRC %x (A %d)\n",crc,A); - - dlsch->harq_processes[harq_pid]->B = A+24; - // dlsch->harq_processes[harq_pid]->b = a; - memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); - - if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, - dlsch->harq_processes[harq_pid]->c, - dlsch->harq_processes[harq_pid]->B, - &dlsch->harq_processes[harq_pid]->C, - &dlsch->harq_processes[harq_pid]->Cplus, - &dlsch->harq_processes[harq_pid]->Cminus, - &dlsch->harq_processes[harq_pid]->Kplus, - &dlsch->harq_processes[harq_pid]->Kminus, - &dlsch->harq_processes[harq_pid]->F)<0) - return(-1); - - for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { - - if (r<dlsch->harq_processes[harq_pid]->Cminus) - Kr = dlsch->harq_processes[harq_pid]->Kminus; - else - Kr = dlsch->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; - - // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) - if (Kr_bytes<=64) - iind = (Kr_bytes-5); - else if (Kr_bytes <=128) - iind = 59 + ((Kr_bytes-64)>>1); - else if (Kr_bytes <= 256) - iind = 91 + ((Kr_bytes-128)>>2); - else if (Kr_bytes <= 768) - iind = 123 + ((Kr_bytes-256)>>3); - else { - printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); - return(-1); - } - - -#ifdef DEBUG_DLSCH_CODING - printf("Generating Code Segment %d (%d bits)\n",r,Kr); - // generate codewords - - printf("bits_per_codeword (Kr)= %d, A %d\n",Kr,A); - printf("N_RB = %d\n",nb_rb); - printf("Ncp %d\n",frame_parms->Ncp); - printf("mod_order %d\n",mod_order); -#endif - - -#ifdef DEBUG_DLSCH_CODING - printf("Encoding ... iind %d f1 %d, f2 %d\n",iind,f1f2mat_old[iind*2],f1f2mat_old[(iind*2)+1]); -#endif - start_meas(te_stats); - encoder(dlsch->harq_processes[harq_pid]->c[r], - Kr>>3, - &dlsch->harq_processes[harq_pid]->d[r][96], - (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, - f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) - f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) - ); - stop_meas(te_stats); -#ifdef DEBUG_DLSCH_CODING - - if (r==0) - write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[r][96],(3*8*Kr_bytes)+12,1,4); - -#endif - start_meas(i_stats); - dlsch->harq_processes[harq_pid]->RTC[r] = - sub_block_interleaving_turbo(4+(Kr_bytes*8), - &dlsch->harq_processes[harq_pid]->d[r][96], - dlsch->harq_processes[harq_pid]->w[r]); - stop_meas(i_stats); - } - - } - - // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the - // outputs for each code segment, see Section 5.1.5 p.20 - - for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { -#ifdef DEBUG_DLSCH_CODING - printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", - r, - G, - Kr*3, - mod_order,nb_rb); -#endif - - start_meas(rm_stats); -#ifdef DEBUG_DLSCH_CODING - printf("rvidx in SIC encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx); -#endif - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r - stop_meas(rm_stats); -#ifdef DEBUG_DLSCH_CODING - - if (r==dlsch->harq_processes[harq_pid]->C-1) - write_output("enc_output.m","enc",dlsch->harq_processes[harq_pid]->e,r_offset,1,4); - -#endif - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); - - return(0); -} diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 3bd174c3b39343c0334e0af42235884937711c4c..a2f8f08073827072f130f0424bc019a3e7e4c97c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -29,14 +29,14 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" //#define DEBUG_DLSCH_MODULATION #define NEW_ALLOC_RE @@ -95,42 +95,7 @@ uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, return(0); } -void generate_64qam_table(void) -{ - - int a,b,c,index; - - - for (a=-1; a<=1; a+=2) - for (b=-1; b<=1; b+=2) - for (c=-1; c<=1; c+=2) { - index = (1+a)*2 + (1+b) + (1+c)/2; - qam64_table[index] = -a*(QAM64_n1 + b*(QAM64_n2 + (c*QAM64_n3))); // 0 1 2 - } -} - -void generate_16qam_table(void) -{ - - int a,b,index; - for (a=-1; a<=1; a+=2) - for (b=-1; b<=1; b+=2) { - index = (1+a) + (1+b)/2; - qam16_table[index] = -a*(QAM16_n1 + (b*QAM16_n2)); - } -} - -void generate_qpsk_table(void) -{ - - int a,index; - - for (a=-1; a<=1; a+=2) { - index = (1+a)/2; - qpsk_table[index] = -a*QPSK; - } -} @@ -1970,48 +1935,6 @@ int allocate_REs_in_RB_MCH(int32_t **txdataF, return(0); } -uint8_t get_pmi(uint8_t N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb) -{ - /* - MIMO_mode_t mode = dlsch_harq->mimo_mode; - uint32_t pmi_alloc = dlsch_harq->pmi_alloc; - */ - - switch (N_RB_DL) { - case 6: // 1 PRB per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>(rb<<1))&3); - else - return((pmi_alloc>>rb)&1); - - break; - - default: - case 25: // 4 PRBs per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>((rb>>2)<<1))&3); - else - return((pmi_alloc>>(rb>>2))&1); - - break; - - case 50: // 6 PRBs per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>((rb/6)<<1))&3); - else - return((pmi_alloc>>(rb/6))&1); - - break; - - case 100: // 8 PRBs per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>((rb>>3)<<1))&3); - else - return((pmi_alloc>>(rb>>3))&1); - - break; - } -} inline int check_skip(int rb,int subframe_offset,LTE_DL_FRAME_PARMS *frame_parms,int l,int nsymb) __attribute__((always_inline)); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c index 8d650bbe217db458bcacef79a463469c66c6813a..21a7018d609ad4359f751cce98014ce03b2602cd 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c @@ -32,12 +32,12 @@ //#define DEBUG_SCRAMBLING 1 -#include "PHY/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "defs.h" -#include "extern.h" -#include "PHY/extern.h" +#include "transport_eNB.h" +#include "PHY/phy_extern.h" #include "UTIL/LOG/vcd_signal_dumper.h" static inline unsigned int lte_gold_scram(unsigned int *x1, unsigned int *x2, unsigned char reset) __attribute__((always_inline)); @@ -187,6 +187,20 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, } + + +void init_scrambling_lut(void) { + + uint32_t s; + int i=0,j; + + for (s=0;s<=65535;s++) { + for (j=0;j<16;j++) { + scrambling_lut[i++] = (uint8_t)((s>>j)&1); + } + } +} + void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, int mbsfn_flag, LTE_UE_DLSCH_t *dlsch, @@ -228,7 +242,7 @@ void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, } } -void init_unscrambling_lut() { +void init_unscrambling_lut(void) { uint32_t s; int i=0,j; @@ -239,15 +253,3 @@ void init_unscrambling_lut() { } } } - -void init_scrambling_lut() { - - uint32_t s; - int i=0,j; - - for (s=0;s<=65535;s++) { - for (j=0;j<16;j++) { - scrambling_lut[i++] = (uint8_t)((s>>j)&1); - } - } -} diff --git a/openair1/PHY/LTE_TRANSPORT/edci.c b/openair1/PHY/LTE_TRANSPORT/edci.c index 5caf5bcd710f6da6e42ded836e5eca0ed547082e..bf1309900430282e3c716bde160644774ea89df2 100755 --- a/openair1/PHY/LTE_TRANSPORT/edci.c +++ b/openair1/PHY/LTE_TRANSPORT/edci.c @@ -32,15 +32,17 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "SIMULATION/TOOLS/sim.h" // for taus #include "PHY/sse_intrin.h" - +#include "transport_proto.h" +#include "transport_common_proto.h" #include "assertions.h" #include "T.h" #include "UTIL/LOG/log.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_DCI_ENCODING 1 //#define DEBUG_DCI_DECODING 1 diff --git a/openair1/PHY/LTE_TRANSPORT/group_hopping.c b/openair1/PHY/LTE_TRANSPORT/group_hopping.c index a7c8921c2ca0c10a76b666c9b79995b0fb8e10c1..6fc1f0a3e44ade5363eeaa05ce409ec711f135ee 100644 --- a/openair1/PHY/LTE_TRANSPORT/group_hopping.c +++ b/openair1/PHY/LTE_TRANSPORT/group_hopping.c @@ -29,7 +29,8 @@ * \note * \warning */ -#include "PHY/defs.h" +#include "PHY/defs_common.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_GROUPHOP 1 diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 88312e4a4611af3cab61f73476e003429fc4e073..cfe4cf85588d882492ba0a81ba3b06e5b1faafd4 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -30,10 +30,10 @@ * \warning */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "PHY/TOOLS/alaw_lut.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" //#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h index 0a95e60ead3c7af2bad4c55e73f742fc0308e4f1..4fcf537f832bcbbfb6ffc1a53213f8a1a2bde30f 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h @@ -32,7 +32,7 @@ #ifndef __IF4_TOOLS_H__ #define __IF4_TOOLS_H__ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" /// Macro for IF4 packet type #define IF4p5_PACKET_TYPE 0x080A diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c index b160318a6ee9899366430f656c2f300582a53251..06b4a4ad806fd746323c678dc8a568379f73c82a 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c @@ -30,7 +30,7 @@ * \warning */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "PHY/TOOLS/alaw_lut.h" #include "time_utils.h" diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.h b/openair1/PHY/LTE_TRANSPORT/if5_tools.h index 84ad5305261b2fa29bbc6fb20aec20f9013715c4..0f24f7becee0334c1e2d900a5b79133bb9130ba8 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.h @@ -34,7 +34,7 @@ #define __IF5_TOOLS_H__ #include <stdint.h> -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #define IF5_RRH_GW_DL 0x0022 #define IF5_RRH_GW_UL 0x0023 diff --git a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c index 910610b9694c806262928ccd891a5d38f7128150..a66344611b8c61921472f70b3a2766d9e6586cfe 100644 --- a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c +++ b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c @@ -30,9 +30,9 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/LTE_TRANSPORT/proto.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" unsigned char get_Qm(unsigned char I_MCS) { diff --git a/openair1/PHY/LTE_TRANSPORT/mdci.h b/openair1/PHY/LTE_TRANSPORT/mdci.h index 060227eac033a3f979d32b29077b5de1f0aaa577..7be278530860fc88792c315130f62e84d77d4292 100644 --- a/openair1/PHY/LTE_TRANSPORT/mdci.h +++ b/openair1/PHY/LTE_TRANSPORT/mdci.h @@ -30,6 +30,9 @@ * \warning */ +#ifndef __M_DCI__H__ +#define __M_DCI__H__ + #include <stdint.h> @@ -467,3 +470,4 @@ struct DCI6_2_di_20MHz { typedef struct DCI6_2_di_20MHz DCI6_2_di_20MHz_t; #define sizeof_DCI6_2_20MHz_t 13 +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c index 9e5b6757fc84e9411c32e28fecd2465b575aac0b..eae88a6afeb794deade5d27373be0bebf142a91f 100644 --- a/openair1/PHY/LTE_TRANSPORT/pbch.c +++ b/openair1/PHY/LTE_TRANSPORT/pbch.c @@ -29,13 +29,14 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "defs.h" -#include "extern.h" -#include "PHY/extern.h" +#include "transport_eNB.h" +#include "transport_proto.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_PBCH 1 //#define DEBUG_PBCH_ENCODING @@ -138,6 +139,31 @@ int allocate_pbch_REs_in_RB(LTE_DL_FRAME_PARMS *frame_parms, return(0); } +void pbch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t *pbch_e, + uint32_t length) +{ + int i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in lte_gold_generic + x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 + // msg("pbch_scrambling: Nid_cell = %d\n",x2); + + for (i=0; i<length; i++) { + if ((i&0x1f)==0) { + s = lte_gold_generic(&x1, &x2, reset); + // printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + pbch_e[i] = (pbch_e[i]&1) ^ ((s>>(i&0x1f))&1); + + } +} + //uint8_t pbch_d[96+(3*(16+PBCH_A))], pbch_w[3*3*(16+PBCH_A)],pbch_e[1920]; //one bit per byte int generate_pbch(LTE_eNB_PBCH *eNB_pbch, int32_t **txdataF, @@ -393,623 +419,5 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch, return(0); } -int32_t generate_pbch_emul(PHY_VARS_eNB *phy_vars_eNB,uint8_t *pbch_pdu) -{ - - LOG_D(PHY,"[eNB %d] generate_pbch_emul \n",phy_vars_eNB->Mod_id); - eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].cntl.pbch_flag=1; - // Copy PBCH payload - eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].cntl.pbch_payload=*(uint32_t *)pbch_pdu; - return(0); -} - -uint16_t pbch_extract(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - uint32_t symbol, - uint32_t high_speed_flag, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - - uint16_t rb,nb_rb=6; - uint8_t i,j,aarx,aatx; - int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; - - uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; - uint32_t symbol_mod = symbol % nsymb; - - int rx_offset = frame_parms->ofdm_symbol_size-3*12; - int ch_offset = frame_parms->N_RB_DL*6-3*12; - int nushiftmod3 = frame_parms->nushift%3; - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - /* - printf("extract_rbs (nushift %d): symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",frame_parms->nushift,symbol_mod, - (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, - LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); - */ - - rxF = &rxdataF[aarx][(rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; - rxF_ext = &rxdataF_ext[aarx][symbol_mod*(6*12)]; - - for (rb=0; rb<nb_rb; rb++) { - // skip DC carrier - if (rb==3) { - rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; - } - - if ((symbol_mod==0) || (symbol_mod==1)) { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j++]=rxF[i]; - } - } - - rxF+=12; - rxF_ext+=8; - } else { - for (i=0; i<12; i++) { - rxF_ext[i]=rxF[i]; - } - - rxF+=12; - rxF_ext+=12; - } - } - - for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { - if (high_speed_flag == 1) - dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset+(symbol*(frame_parms->ofdm_symbol_size))]; - else - dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset]; - - dl_ch0_ext = &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*(6*12)]; - - for (rb=0; rb<nb_rb; rb++) { - // skip DC carrier - // if (rb==3) dl_ch0++; - if (symbol_mod>1) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int)); - dl_ch0+=12; - dl_ch0_ext+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - // printf("PBCH extract i %d j %d => (%d,%d)\n",i,j,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - dl_ch0_ext[j++]=dl_ch0[i]; - } - } - - dl_ch0+=12; - dl_ch0_ext+=8; - } - } - } //tx antenna loop - - } - - return(0); -} - -//__m128i avg128; - -//compute average channel_level on each (TX,RX) antenna pair -int pbch_channel_level(int **dl_ch_estimates_ext, - LTE_DL_FRAME_PARMS *frame_parms, - uint32_t symbol) -{ - - int16_t rb, nb_rb=6; - uint8_t aatx,aarx; - -#if defined(__x86_64__) || defined(__i386__) - __m128i avg128; - __m128i *dl_ch128; -#elif defined(__arm__) - int32x4_t avg128; - int16x8_t *dl_ch128; -#endif - int avg1=0,avg2=0; - - uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; - uint32_t symbol_mod = symbol % nsymb; - - for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - //clear average level - -#if defined(__x86_64__) || defined(__i386__) - avg128 = _mm_setzero_si128(); - dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; -#elif defined(__arm__) - avg128 = vdupq_n_s32(0); - dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; - -#endif - for (rb=0; rb<nb_rb; rb++) { -#if defined(__x86_64__) || defined(__i386__) - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); -#elif defined(__arm__) -// to be filled in -#endif - dl_ch128+=3; - /* - if (rb==0) { - print_shorts("dl_ch128",&dl_ch128[0]); - print_shorts("dl_ch128",&dl_ch128[1]); - print_shorts("dl_ch128",&dl_ch128[2]); - } - */ - } - - avg1 = (((int*)&avg128)[0] + - ((int*)&avg128)[1] + - ((int*)&avg128)[2] + - ((int*)&avg128)[3])/(nb_rb*12); - - if (avg1>avg2) - avg2 = avg1; - - //msg("Channel level : %d, %d\n",avg1, avg2); - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - return(avg2); - -} - -#if defined(__x86_64__) || defined(__i386__) -__m128i mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; -#elif defined(__arm__) -int16x8_t mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; -#endif -void pbch_channel_compensation(int **rxdataF_ext, - int **dl_ch_estimates_ext, - int **rxdataF_comp, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - uint8_t output_shift) -{ - - uint16_t rb,nb_rb=6; - uint8_t aatx,aarx,symbol_mod; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; -#elif defined(__arm__) - -#endif - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - - for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol_mod*6*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol_mod*6*12]; - -#elif defined(__arm__) -// to be filled in -#endif - - for (rb=0; rb<nb_rb; rb++) { - //printf("rb %d\n",rb); -#if defined(__x86_64__) || defined(__i386__) - // multiply by conjugated channel - mmtmpP0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpP0); - // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) - mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpP1); - mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[0]); - // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); - // print_ints("re(shift)",&mmtmpP0); - mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); - // print_ints("im(shift)",&mmtmpP1); - mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); - mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); - // print_ints("c0",&mmtmpP2); - // print_ints("c1",&mmtmpP3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpP0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); - // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) - mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); - mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[1]); - // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); - mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); - mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); - mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - - if (symbol_mod>1) { - // multiply by conjugated channel - mmtmpP0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); - // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) - mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); - mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[2]); - // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); - mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); - mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); - mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128+2); - // print_shorts("ch:",dl_ch128+2); - // print_shorts("pack:",rxdataF_comp128+2); - - dl_ch128+=3; - rxdataF128+=3; - rxdataF_comp128+=3; - } else { - dl_ch128+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } -#elif defined(__arm__) -// to be filled in -#endif - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void pbch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - uint8_t symbol) -{ - - uint8_t aatx, symbol_mod; - int i, nb_rb=6; -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; -#endif - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - - if (frame_parms->nb_antennas_rx>1) { - for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; - -#endif - // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) - for (i=0; i<nb_rb*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); - -#endif - } - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void pbch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t *pbch_e, - uint32_t length) -{ - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in lte_gold_generic - x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 - // msg("pbch_scrambling: Nid_cell = %d\n",x2); - - for (i=0; i<length; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - pbch_e[i] = (pbch_e[i]&1) ^ ((s>>(i&0x1f))&1); - - } -} - -void pbch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, - int8_t* llr, - uint32_t length, - uint8_t frame_mod4) -{ - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in first call to lte_gold_generic - x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 - // msg("pbch_unscrambling: Nid_cell = %d\n",x2); - - for (i=0; i<length; i++) { - if (i%32==0) { - s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - // take the quarter of the PBCH that corresponds to this frame - if ((i>=(frame_mod4*(length>>2))) && (i<((1+frame_mod4)*(length>>2)))) { - - if (((s>>(i%32))&1)==0) - llr[i] = -llr[i]; - } - } -} - -void pbch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - uint8_t symbol) -{ - - int16_t *rxF0,*rxF1; - // __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b; - uint8_t rb,re,symbol_mod; - int jj; - // printf("Doing alamouti\n"); - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - jj = (symbol_mod*6*12); - - rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y - rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y - - for (rb=0; rb<6; rb++) { - - for (re=0; re<12; re+=2) { - - // Alamouti RX combining - - rxF0[0] = rxF0[0] + rxF1[2]; - rxF0[1] = rxF0[1] - rxF1[3]; - - rxF0[2] = rxF0[2] - rxF1[0]; - rxF0[3] = rxF0[3] + rxF1[1]; - - rxF0+=4; - rxF1+=4; - } - - } - -} - -void pbch_quantize(int8_t *pbch_llr8, - int16_t *pbch_llr, - uint16_t len) -{ - - uint16_t i; - - for (i=0; i<len; i++) { - if (pbch_llr[i]>7) - pbch_llr8[i]=7; - else if (pbch_llr[i]<-8) - pbch_llr8[i]=-8; - else - pbch_llr8[i] = (char)(pbch_llr[i]); - - } -} - -static unsigned char dummy_w_rx[3*3*(16+PBCH_A)]; -static int8_t pbch_w_rx[3*3*(16+PBCH_A)],pbch_d_rx[96+(3*(16+PBCH_A))]; - - -uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars, - LTE_UE_PBCH *lte_ue_pbch_vars, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t eNB_id, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t frame_mod4) -{ - - uint8_t log2_maxh;//,aatx,aarx; - int max_h=0; - - int symbol,i; - uint32_t nsymb = (frame_parms->Ncp==0) ? 14:12; - uint16_t pbch_E; - uint8_t pbch_a[8]; - uint8_t RCC; - - int8_t *pbch_e_rx; - uint8_t *decoded_output = lte_ue_pbch_vars->decoded_output; - uint16_t crc; - - - // pbch_D = 16+PBCH_A; - - pbch_E = (frame_parms->Ncp==0) ? 1920 : 1728; //RE/RB * #RB * bits/RB (QPSK) - pbch_e_rx = <e_ue_pbch_vars->llr[frame_mod4*(pbch_E>>2)]; -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode); -#endif - - // clear LLR buffer - memset(lte_ue_pbch_vars->llr,0,pbch_E); - - for (symbol=(nsymb>>1); symbol<(nsymb>>1)+4; symbol++) { - -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] starting extract\n"); -#endif - pbch_extract(lte_ue_common_vars->common_vars_rx_data_per_thread[0].rxdataF, - lte_ue_common_vars->common_vars_rx_data_per_thread[0].dl_ch_estimates[eNB_id], - lte_ue_pbch_vars->rxdataF_ext, - lte_ue_pbch_vars->dl_ch_estimates_ext, - symbol, - high_speed_flag, - frame_parms); -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PHY] PBCH Symbol %d\n",symbol); - LOG_D(PHY,"[PHY] PBCH starting channel_level\n"); -#endif - - max_h = pbch_channel_level(lte_ue_pbch_vars->dl_ch_estimates_ext, - frame_parms, - symbol); - log2_maxh = 3+(log2_approx(max_h)/2); - -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",log2_maxh,max_h); -#endif - - pbch_channel_compensation(lte_ue_pbch_vars->rxdataF_ext, - lte_ue_pbch_vars->dl_ch_estimates_ext, - lte_ue_pbch_vars->rxdataF_comp, - frame_parms, - symbol, - log2_maxh); // log2_maxh+I0_shift - - if (frame_parms->nb_antennas_rx > 1) - pbch_detection_mrc(frame_parms, - lte_ue_pbch_vars->rxdataF_comp, - symbol); - - - if (mimo_mode == ALAMOUTI) { - pbch_alamouti(frame_parms,lte_ue_pbch_vars->rxdataF_comp,symbol); - } else if (mimo_mode != SISO) { - LOG_D(PHY,"[PBCH][RX] Unsupported MIMO mode\n"); - return(-1); - } - - if (symbol>(nsymb>>1)+1) { - pbch_quantize(pbch_e_rx, - (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), - 144); - - pbch_e_rx+=144; - } else { - pbch_quantize(pbch_e_rx, - (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), - 96); - - pbch_e_rx+=96; - } - - - } - - pbch_e_rx = lte_ue_pbch_vars->llr; - - - - //un-scrambling -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] doing unscrambling\n"); -#endif - - - pbch_unscrambling(frame_parms, - pbch_e_rx, - pbch_E, - frame_mod4); - - - - //un-rate matching -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] doing un-rate-matching\n"); -#endif - - - memset(dummy_w_rx,0,3*3*(16+PBCH_A)); - RCC = generate_dummy_w_cc(16+PBCH_A, - dummy_w_rx); - - - lte_rate_matching_cc_rx(RCC,pbch_E,pbch_w_rx,dummy_w_rx,pbch_e_rx); - - sub_block_deinterleaving_cc((unsigned int)(PBCH_A+16), - &pbch_d_rx[96], - &pbch_w_rx[0]); - - memset(pbch_a,0,((16+PBCH_A)>>3)); - - - - - phy_viterbi_lte_sse2(pbch_d_rx+96,pbch_a,16+PBCH_A); - - // Fix byte endian of PBCH (bit 23 goes in first) - for (i=0; i<(PBCH_A>>3); i++) - decoded_output[(PBCH_A>>3)-i-1] = pbch_a[i]; - -#ifdef DEBUG_PBCH - - for (i=0; i<(PBCH_A>>3); i++) - LOG_I(PHY,"[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); - -#endif //DEBUG_PBCH - -#ifdef DEBUG_PBCH - LOG_I(PHY,"PBCH CRC %x : %x\n", - crc16(pbch_a,PBCH_A), - ((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); -#endif - - crc = (crc16(pbch_a,PBCH_A)>>16) ^ - (((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); - - if (crc == 0x0000) - return(1); - else if (crc == 0xffff) - return(2); - else if (crc == 0x5555) - return(4); - else - return(-1); - - -} diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich.c b/openair1/PHY/LTE_TRANSPORT/pcfich.c index b7e24cb87dad212b71f461996a6a6a89f02468fa..18a156c3fbc004f0421c67eb635c08102833d5e8 100644 --- a/openair1/PHY/LTE_TRANSPORT/pcfich.c +++ b/openair1/PHY/LTE_TRANSPORT/pcfich.c @@ -29,48 +29,13 @@ * \note * \warning */ -#include "PHY/defs.h" +#include "PHY/impl_defs_top.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_PCFICH +extern uint8_t pcfich_b[4][32]; -void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) -{ - - uint16_t kbar = 6 * (frame_parms->Nid_cell %(2*frame_parms->N_RB_DL)); - uint16_t first_reg; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - pcfich_reg[0] = kbar/6; - first_reg = pcfich_reg[0]; - - frame_parms->pcfich_first_reg_idx=0; - - pcfich_reg[1] = ((kbar + (frame_parms->N_RB_DL>>1)*6)%(frame_parms->N_RB_DL*12))/6; - - if (pcfich_reg[1] < pcfich_reg[0]) { - frame_parms->pcfich_first_reg_idx = 1; - first_reg = pcfich_reg[1]; - } - - pcfich_reg[2] = ((kbar + (frame_parms->N_RB_DL)*6)%(frame_parms->N_RB_DL*12))/6; - - if (pcfich_reg[2] < first_reg) { - frame_parms->pcfich_first_reg_idx = 2; - first_reg = pcfich_reg[2]; - } - - pcfich_reg[3] = ((kbar + ((3*frame_parms->N_RB_DL)>>1)*6)%(frame_parms->N_RB_DL*12))/6; - - if (pcfich_reg[3] < first_reg) { - frame_parms->pcfich_first_reg_idx = 3; - first_reg = pcfich_reg[3]; - } - - - //#ifdef DEBUG_PCFICH - printf("pcfich_reg : %d,%d,%d,%d\n",pcfich_reg[0],pcfich_reg[1],pcfich_reg[2],pcfich_reg[3]); - //#endif -} void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, uint8_t subframe, @@ -96,37 +61,7 @@ void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, } } -void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - int16_t *d) -{ - - uint32_t i; - uint8_t reset; - uint32_t x1, x2, s=0; - reset = 1; - // x1 is set in lte_gold_generic - x2 = ((((2*frame_parms->Nid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 - - for (i=0; i<32; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - //printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - if (((s>>(i&0x1f))&1) == 1) - d[i]=-d[i]; - - } -} - -uint8_t pcfich_b[4][32]= {{0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1}, - {1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0}, - {1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} -}; void generate_pcfich(uint8_t num_pdcch_symbols, int16_t amp, @@ -215,98 +150,3 @@ void generate_pcfich(uint8_t num_pdcch_symbols, } -uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - LTE_UE_PDCCH *lte_ue_pdcch_vars, - MIMO_mode_t mimo_mode) -{ - - uint8_t pcfich_quad; - uint8_t i,j; - uint16_t reg_offset; - - int32_t **rxdataF_comp = lte_ue_pdcch_vars->rxdataF_comp; - int16_t pcfich_d[32],*pcfich_d_ptr; - int32_t metric,old_metric=-16384; - uint8_t num_pdcch_symbols=3; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - // demapping - // loop over 4 quadruplets and lookup REGs - // m=0; - pcfich_d_ptr = pcfich_d; - - for (pcfich_quad=0; pcfich_quad<4; pcfich_quad++) { - reg_offset = (pcfich_reg[pcfich_quad]*4); - - for (i=0; i<4; i++) { - - pcfich_d_ptr[0] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0]; // RE component - pcfich_d_ptr[1] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1]; // IM component -#ifdef DEBUG_PCFICH - printf("rx_pcfich: quad %d, i %d, offset %d => (%d,%d) => pcfich_d_ptr[0] %d \n",pcfich_quad,i,reg_offset+i, - ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0], - ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1], - pcfich_d_ptr[0]); -#endif - pcfich_d_ptr+=2; - } - - /* - } - else { // ALAMOUTI - for (i=0;i<4;i+=2) { - pcfich_d_ptr[0] = 0; - pcfich_d_ptr[1] = 0; - pcfich_d_ptr[2] = 0; - pcfich_d_ptr[3] = 0; - for (j=0;j<frame_parms->nb_antennas_rx;j++) { - - pcfich_d_ptr[0] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[0]+ - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[0]); // RE component - pcfich_d_ptr[1] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[1] - - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[1]);// IM component - - pcfich_d_ptr[2] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[0]- - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[0]); // RE component - pcfich_d_ptr[3] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[1] + - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[1]);// IM component - - - } - - pcfich_d_ptr+=4; - - } - */ - } - - // pcfhich unscrambling - - pcfich_unscrambling(frame_parms,subframe,pcfich_d); - - // pcfich detection - - for (i=0; i<3; i++) { - metric = 0; - - for (j=0; j<32; j++) { - // printf("pcfich_b[%d][%d] %d => pcfich_d[%d] %d\n",i,j,pcfich_b[i][j],j,pcfich_d[j]); - metric += (int32_t)(((pcfich_b[i][j]==0) ? (pcfich_d[j]) : (-pcfich_d[j]))); - } - -#ifdef DEBUG_PCFICH - printf("metric %d : %d\n",i,metric); -#endif - - if (metric > old_metric) { - num_pdcch_symbols = 1+i; - old_metric = metric; - } - } - -#ifdef DEBUG_PCFICH - printf("[PHY] PCFICH detected for %d PDCCH symbols\n",num_pdcch_symbols); -#endif - return(num_pdcch_symbols); -} diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich_common.c b/openair1/PHY/LTE_TRANSPORT/pcfich_common.c new file mode 100644 index 0000000000000000000000000000000000000000..d6466862a79ba02d4187ab74ada21bfc431549b9 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pcfich_common.c @@ -0,0 +1,72 @@ +/* + * 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/LTE_TRANSPORT/pcfich.c +* \brief Top-level routines for generating and decoding the PCFICH/CFI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/impl_defs_top.h" +#include "PHY/defs_eNB.h" + +void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) +{ + + uint16_t kbar = 6 * (frame_parms->Nid_cell %(2*frame_parms->N_RB_DL)); + uint16_t first_reg; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + pcfich_reg[0] = kbar/6; + first_reg = pcfich_reg[0]; + + frame_parms->pcfich_first_reg_idx=0; + + pcfich_reg[1] = ((kbar + (frame_parms->N_RB_DL>>1)*6)%(frame_parms->N_RB_DL*12))/6; + + if (pcfich_reg[1] < pcfich_reg[0]) { + frame_parms->pcfich_first_reg_idx = 1; + first_reg = pcfich_reg[1]; + } + + pcfich_reg[2] = ((kbar + (frame_parms->N_RB_DL)*6)%(frame_parms->N_RB_DL*12))/6; + + if (pcfich_reg[2] < first_reg) { + frame_parms->pcfich_first_reg_idx = 2; + first_reg = pcfich_reg[2]; + } + + pcfich_reg[3] = ((kbar + ((3*frame_parms->N_RB_DL)>>1)*6)%(frame_parms->N_RB_DL*12))/6; + + if (pcfich_reg[3] < first_reg) { + frame_parms->pcfich_first_reg_idx = 3; + first_reg = pcfich_reg[3]; + } + + + //#ifdef DEBUG_PCFICH + printf("pcfich_reg : %d,%d,%d,%d\n",pcfich_reg[0],pcfich_reg[1],pcfich_reg[2],pcfich_reg[3]); + //#endif +} diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 2bd7140c32ccc96524b58d9e489280bae5cf7754..2e8a6e410c3a9804d109fb0c72b22f8a610e9df4 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -1,3 +1,4 @@ + /* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,7 +21,7 @@ */ /*! \file PHY/LTE_TRANSPORT/phich.c -* \brief Top-level routines for generating and decoding the PHICH/HI physical/transport channel V8.6 2009-03 +* \brief Top-level routines for generating the PHICH/HI physical/transport channel V8.6 2009-03 * \author R. Knopp * \date 2011 * \version 0.1 @@ -30,15 +31,11 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "defs.h" - -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" - +#include "PHY/defs_eNB.h" +#include "PHY/impl_defs_top.h" #include "T.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "transport_common_proto.h" //#define DEBUG_PHICH 1 @@ -48,365 +45,6 @@ //unsigned short phich_reg[MAX_NUM_PHICH_GROUPS][3]; -uint8_t rv_table[4] = {0, 2, 3, 1}; - -uint8_t get_mi(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) -{ - - // for FDD - if (frame_parms->frame_type == FDD) - return 1; - - // for TDD - switch (frame_parms->tdd_config) { - - case 0: - if ((subframe==0) || (subframe==5)) - return(2); - else return(1); - - break; - - case 1: - if ((subframe==0) || (subframe==5)) - return(0); - else return(1); - - break; - - case 2: - if ((subframe==3) || (subframe==8)) - return(1); - else return(0); - - break; - - case 3: - if ((subframe==0) || (subframe==8) || (subframe==9)) - return(1); - else return(0); - - break; - - case 4: - if ((subframe==8) || (subframe==9)) - return(1); - else return(0); - - break; - - case 5: - if (subframe==8) - return(1); - else return(0); - - break; - - case 6: - return(1); - break; - - default: - return(0); - } -} - -unsigned char subframe2_ul_harq(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) -{ - - if (frame_parms->frame_type == FDD) - return(subframe&7); - - switch (frame_parms->tdd_config) { - case 3: - if ( (subframe == 8) || (subframe == 9) ) { - return(subframe-8); - } else if (subframe==0) - return(2); - else { - LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - return(0); - } - - break; - - case 4: - if ( (subframe == 8) || (subframe == 9) ) { - return(subframe-8); - } else { - LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - return(0); - } - - break; - - } - - return(0); -} - -int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe) -{ - int pusch_frame; - - if (frame_parms->frame_type == FDD) { - pusch_frame = subframe<4 ? frame + 1024 - 1 : frame; - } else { - // Note this is not true, but it doesn't matter, the frame number is irrelevant for TDD! - pusch_frame = (frame); - } - - //LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, subframe, pusch_frame); - return pusch_frame % 1024; -} - -uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) -{ - uint8_t pusch_subframe = 255; - - if (frame_parms->frame_type == FDD) - return subframe < 4 ? subframe + 6 : subframe - 4; - - switch (frame_parms->tdd_config) { - case 0: - if (subframe == 0) - pusch_subframe = (3); - else if (subframe == 5) { - pusch_subframe = (8); - } else if (subframe == 6) - pusch_subframe = (2); - else if (subframe == 1) - pusch_subframe = (7); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 1: - if (subframe == 6) - pusch_subframe = (2); - else if (subframe == 9) - pusch_subframe = (3); - else if (subframe == 1) - pusch_subframe = (7); - else if (subframe == 4) - pusch_subframe = (8); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 2: - if (subframe == 8) - pusch_subframe = (2); - else if (subframe == 3) - pusch_subframe = (7); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 3: - if ( (subframe == 8) || (subframe == 9) ) { - pusch_subframe = (subframe-6); - } else if (subframe==0) - pusch_subframe = (4); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 4: - if ( (subframe == 8) || (subframe == 9) ) { - pusch_subframe = (subframe-6); - } else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 5: - if (subframe == 8) { - pusch_subframe = (2); - } else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 6: - if (subframe == 6) { - pusch_subframe = (2); - } else if (subframe == 9) { - pusch_subframe = (3); - } else if (subframe == 0) { - pusch_subframe = (4); - } else if (subframe == 1) { - pusch_subframe = (7); - } else if (subframe == 5) { - pusch_subframe = (8); - } else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - default: - AssertFatal(1==0, "no implementation for TDD UL/DL-config = %d!\n", frame_parms->tdd_config); - pusch_subframe = (0); - } - - LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", subframe, pusch_subframe); - return pusch_subframe; -} - -int check_pcfich(LTE_DL_FRAME_PARMS *frame_parms,uint16_t reg) -{ - - if ((reg == frame_parms->pcfich_reg[0]) || - (reg == frame_parms->pcfich_reg[1]) || - (reg == frame_parms->pcfich_reg[2]) || - (reg == frame_parms->pcfich_reg[3])) - return(1); - - return(0); -} - -void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) -{ - - unsigned short n0 = (frame_parms->N_RB_DL * 2) - 4; // 2 REG per RB less the 4 used by PCFICH in first symbol - unsigned short n1 = (frame_parms->N_RB_DL * 3); // 3 REG per RB in second and third symbol - unsigned short n2 = n1; - unsigned short mprime = 0; - unsigned short Ngroup_PHICH; - // uint16_t *phich_reg = frame_parms->phich_reg; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - // compute Ngroup_PHICH (see formula at beginning of Section 6.9 in 36-211 - Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - - - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - // check if Extended prefix - if (frame_parms->Ncp == 1) { - Ngroup_PHICH<<=1; - } - -#ifdef DEBUG_PHICH - LOG_D(PHY,"Ngroup_PHICH %d (phich_config_common.phich_resource %d,phich_config_common.phich_duration %s, NidCell %d,Ncp %d, frame_type %d), smallest pcfich REG %d, n0 %d, n1 %d (first PHICH REG %d)\n", - ((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)), - frame_parms->phich_config_common.phich_resource, - frame_parms->phich_config_common.phich_duration==normal?"normal":"extended", - frame_parms->Nid_cell,frame_parms->Ncp,frame_parms->frame_type, - pcfich_reg[frame_parms->pcfich_first_reg_idx], - n0, - n1, - ((frame_parms->Nid_cell))%n0); -#endif - - // This is the algorithm from Section 6.9.3 in 36-211, it works only for normal PHICH duration for now ... - - for (mprime=0; - mprime<((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)); - mprime++) { - - if (frame_parms->phich_config_common.phich_duration==normal) { // normal PHICH duration - - frame_parms->phich_reg[mprime][0] = (frame_parms->Nid_cell + mprime)%n0; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) - frame_parms->phich_reg[mprime][0]++; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) - frame_parms->phich_reg[mprime][0]++; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) - frame_parms->phich_reg[mprime][0]++; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) - frame_parms->phich_reg[mprime][0]++; - - frame_parms->phich_reg[mprime][1] = (frame_parms->Nid_cell + mprime + (n0/3))%n0; - - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) - frame_parms->phich_reg[mprime][1]++; - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) - frame_parms->phich_reg[mprime][1]++; - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) - frame_parms->phich_reg[mprime][1]++; - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) - frame_parms->phich_reg[mprime][1]++; - - - frame_parms->phich_reg[mprime][2] = (frame_parms->Nid_cell + mprime + (2*n0/3))%n0; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) - frame_parms->phich_reg[mprime][2]++; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) - frame_parms->phich_reg[mprime][2]++; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) - frame_parms->phich_reg[mprime][2]++; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) - frame_parms->phich_reg[mprime][2]++; - -#ifdef DEBUG_PHICH - printf("phich_reg :%d => %d,%d,%d\n",mprime,frame_parms->phich_reg[mprime][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); -#endif - } else { // extended PHICH duration - frame_parms->phich_reg[mprime<<1][0] = (frame_parms->Nid_cell + mprime)%n0; - frame_parms->phich_reg[1+(mprime<<1)][0] = (frame_parms->Nid_cell + mprime)%n0; - - frame_parms->phich_reg[mprime<<1][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; - frame_parms->phich_reg[mprime<<1][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; - - frame_parms->phich_reg[1+(mprime<<1)][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; - frame_parms->phich_reg[1+(mprime<<1)][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; - //#ifdef DEBUG_PHICH - printf("phich_reg :%d => %d,%d,%d\n",mprime<<1,frame_parms->phich_reg[mprime<<1][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); - printf("phich_reg :%d => %d,%d,%d\n",1+(mprime<<1),frame_parms->phich_reg[1+(mprime<<1)][0],frame_parms->phich_reg[1+(mprime<<1)][1],frame_parms->phich_reg[1+(mprime<<1)][2]); - //#endif - } - } // mprime loop -} // num_pdcch_symbols loop - - -void generate_phich_emul(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t HI, - uint8_t subframe) -{ - - -} int32_t alam_bpsk_perm1[4] = {2,1,4,3}; // -conj(x) 1 (-1-j) -> 2 (1-j), 2->1, 3 (-1+j) -> (4) 1+j, 4->3 int32_t alam_bpsk_perm2[4] = {3,4,2,1}; // conj(x) 1 (-1-j) -> 3 (-1+j), 3->1, 2 (1-j) -> 4 (1+j), 4->2 @@ -1065,436 +703,6 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, } // normal/extended prefix } -// This routine demodulates the PHICH and updates PUSCH/ULSCH parameters - -void rx_phich(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - uint8_t subframe, - uint8_t eNB_id) -{ - - - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - LTE_UE_PDCCH **pdcch_vars = &ue->pdcch_vars[ue->current_thread_id[subframe]][eNB_id]; - - // uint8_t HI; - uint8_t harq_pid = phich_subframe_to_harq_pid(frame_parms,proc->frame_rx,subframe); - LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - int16_t phich_d[24],*phich_d_ptr,HI16; - // unsigned int i,aa; - int8_t d[24],*dp; - uint16_t reg_offset; - - // scrambling - uint32_t x1, x2, s=0; - uint8_t reset = 1; - int16_t cs[12]; - uint32_t i,i2,i3,phich_quad; - int32_t **rxdataF_comp = pdcch_vars[eNB_id]->rxdataF_comp; - uint8_t Ngroup_PHICH,ngroup_PHICH,nseq_PHICH; - uint8_t NSF_PHICH = 4; - uint8_t pusch_subframe; - - int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; - - // check if we're expecting a PHICH in this subframe - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); - - if (!ulsch) - return; - - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX Status: %d \n",ue->Mod_id,harq_pid,proc->frame_rx,subframe, ulsch->harq_processes[harq_pid]->status); - - if (ulsch->harq_processes[harq_pid]->status == ACTIVE) { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX ACTIVE\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); - Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - if (frame_parms->Ncp == 1) - NSF_PHICH = 2; - - - ngroup_PHICH = (ulsch->harq_processes[harq_pid]->first_rb + - ulsch->harq_processes[harq_pid]->n_DMRS)%Ngroup_PHICH; - - if ((frame_parms->tdd_config == 0) && (frame_parms->frame_type == TDD) ) { - pusch_subframe = phich_subframe2_pusch_subframe(frame_parms,subframe); - - if ((pusch_subframe == 4) || (pusch_subframe == 9)) - ngroup_PHICH += Ngroup_PHICH; - } - - nseq_PHICH = ((ulsch->harq_processes[harq_pid]->first_rb/Ngroup_PHICH) + - ulsch->harq_processes[harq_pid]->n_DMRS)%(2*NSF_PHICH); - } else { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX %s\n", - ue->Mod_id, - harq_pid, - proc->frame_rx, - subframe, - (ulsch->harq_processes[harq_pid]->status==SCH_IDLE? "SCH_IDLE" : - (ulsch->harq_processes[harq_pid]->status==ACTIVE? "ACTIVE" : - (ulsch->harq_processes[harq_pid]->status==CBA_ACTIVE? "CBA_ACTIVE": - (ulsch->harq_processes[harq_pid]->status==DISABLED? "DISABLED" : "UNKNOWN"))))); - - return; - } - - memset(d,0,24*sizeof(int8_t)); - phich_d_ptr = phich_d; - - // x1 is set in lte_gold_generic - x2 = (((subframe+1)*((frame_parms->Nid_cell<<1)+1))<<9) + frame_parms->Nid_cell; - - s = lte_gold_generic(&x1, &x2, reset); - - // compute scrambling sequence - for (i=0; i<12; i++) { - cs[i] = 1-(((s>>(i&0x1f))&1)<<1); - } - - if (frame_parms->Ncp == 0) { // Normal Cyclic Prefix - - - // 12 output symbols (Msymb) - - for (i=0,i2=0,i3=0; i<3; i++,i2+=4,i3+=8) { - switch (nseq_PHICH) { - case 0: // +1 +1 +1 +1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = cs[1+i2]; - d[3+i3] = cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[5+i3] = cs[2+i2]; - d[6+i3] = cs[3+i2]; - d[7+i3] = cs[3+i2]; - break; - - case 1: // +1 -1 +1 -1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = -cs[1+i2]; - d[3+i3] = -cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[5+i3] = cs[2+i2]; - d[6+i3] = -cs[3+i2]; - d[7+i3] = -cs[3+i2]; - break; - - case 2: // +1 +1 -1 -1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = cs[1+i2]; - d[3+i3] = cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[5+i3] = -cs[2+i2]; - d[6+i3] = -cs[3+i2]; - d[7+i3] = -cs[3+i2]; - break; - - case 3: // +1 -1 -1 +1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = -cs[1+i2]; - d[3+i3] = -cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[5+i3] = -cs[2+i2]; - d[6+i3] = cs[3+i2]; - d[7+i3] = cs[3+i2]; - break; - - case 4: // +j +j +j +j - d[i3] = -cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = -cs[1+i2]; - d[3+i3] = cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[5+i3] = cs[2+i2]; - d[6+i3] = -cs[3+i2]; - d[7+i3] = cs[3+i2]; - break; - - case 5: // +j -j +j -j - d[1+i3] = cs[i2]; - d[3+i3] = -cs[1+i2]; - d[5+i3] = cs[2+i2]; - d[7+i3] = -cs[3+i2]; - d[i3] = -cs[i2]; - d[2+i3] = cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[6+i3] = cs[3+i2]; - break; - - case 6: // +j +j -j -j - d[1+i3] = cs[i2]; - d[3+i3] = cs[1+i2]; - d[5+i3] = -cs[2+i2]; - d[7+i3] = -cs[3+i2]; - d[i3] = -cs[i2]; - d[2+i3] = -cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[6+i3] = cs[3+i2]; - break; - - case 7: // +j -j -j +j - d[1+i3] = cs[i2]; - d[3+i3] = -cs[1+i2]; - d[5+i3] = -cs[2+i2]; - d[7+i3] = cs[3+i2]; - d[i3] = -cs[i2]; - d[2+i3] = cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[6+i3] = -cs[3+i2]; - break; - - default: - AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); - } // nseq_PHICH - } - -#ifdef DEBUG_PHICH - LOG_D(PHY,"PHICH =>"); - - for (i=0; i<24; i++) { - LOG_D(PHY,"%2d,",d[i]); - } - - LOG_D(PHY,"\n"); -#endif - // demodulation here - - - } else { // extended prefix - - // 6 output symbols - if ((ngroup_PHICH & 1) == 1) - dp = &d[4]; - else - dp = d; - - switch (nseq_PHICH) { - case 0: // +1 +1 - dp[0] = cs[0]; - dp[2] = cs[1]; - dp[8] = cs[2]; - dp[10] = cs[3]; - dp[16] = cs[4]; - dp[18] = cs[5]; - dp[1] = cs[0]; - dp[3] = cs[1]; - dp[9] = cs[2]; - dp[11] = cs[3]; - dp[17] = cs[4]; - dp[19] = cs[5]; - break; - - case 1: // +1 -1 - dp[0] = cs[0]; - dp[2] = -cs[1]; - dp[8] = cs[2]; - dp[10] = -cs[3]; - dp[16] = cs[4]; - dp[18] = -cs[5]; - dp[1] = cs[0]; - dp[3] = -cs[1]; - dp[9] = cs[2]; - dp[11] = -cs[3]; - dp[17] = cs[4]; - dp[19] = -cs[5]; - break; - - case 2: // +j +j - dp[1] = cs[0]; - dp[3] = cs[1]; - dp[9] = cs[2]; - dp[11] = cs[3]; - dp[17] = cs[4]; - dp[19] = cs[5]; - dp[0] = -cs[0]; - dp[2] = -cs[1]; - dp[8] = -cs[2]; - dp[10] = -cs[3]; - dp[16] = -cs[4]; - dp[18] = -cs[5]; - - break; - - case 3: // +j -j - dp[1] = cs[0]; - dp[3] = -cs[1]; - dp[9] = cs[2]; - dp[11] = -cs[3]; - dp[17] = cs[4]; - dp[19] = -cs[5]; - dp[0] = -cs[0]; - dp[2] = cs[1]; - dp[8] = -cs[2]; - dp[10] = cs[3]; - dp[16] = -cs[4]; - dp[18] = cs[5]; - break; - - default: - AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); - } - } - - HI16 = 0; - - //#ifdef DEBUG_PHICH - - //#endif - /* - for (i=0;i<200;i++) - printf("re %d: %d %d\n",i,((int16_t*)&rxdataF_comp[0][i])[0],((int16_t*)&rxdataF_comp[0][i])[1]); - */ - for (phich_quad=0; phich_quad<3; phich_quad++) { - if (frame_parms->Ncp == 1) - reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4)+ (phich_quad*frame_parms->N_RB_DL*12); - else - reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4); - - // msg("\n[PUSCH 0]PHICH (RX) quad %d (%d)=>",phich_quad,reg_offset); - dp = &d[phich_quad*8];; - - for (i=0; i<8; i++) { - phich_d_ptr[i] = ((int16_t*)&rxdataF_comp[0][reg_offset])[i]; - -#ifdef DEBUG_PHICH - LOG_D(PHY,"%d,",((int16_t*)&rxdataF_comp[0][reg_offset])[i]); -#endif - - HI16 += (phich_d_ptr[i] * dp[i]); - } - } - -#ifdef DEBUG_PHICH - LOG_D(PHY,"\n"); - LOG_D(PHY,"HI16 %d\n",HI16); -#endif - - if (HI16>0) { //NACK - if (ue->ulsch_Msg3_active[eNB_id] == 1) { - LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received NAK (%d) nseq %d, ngroup %d\n", - ue->Mod_id,harq_pid, - proc->frame_rx, - subframe, - HI16, - nseq_PHICH, - ngroup_PHICH); - - ulsch->f_pusch += delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC]; - - LOG_D(PHY,"[PUSCH %d] AbsSubframe %d.%d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", - harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, - delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC], - ulsch->harq_processes[harq_pid]->TPC); - - - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - // ulsch->harq_processes[harq_pid]->Ndi = 0; - ulsch->harq_processes[harq_pid]->round++; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - - if (ulsch->harq_processes[harq_pid]->round>=ue->frame_parms.maxHARQ_Msg3Tx) { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag =0; - ulsch->harq_processes[harq_pid]->status = SCH_IDLE; - // inform MAC that Msg3 transmission has failed - ue->ulsch_Msg3_active[eNB_id] = 0; - } - } else { -#ifdef UE_DEBUG_TRACE - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received NAK (%d) nseq %d, ngroup %d round %d (Mlimit %d)\n", - ue->Mod_id,harq_pid, - proc->frame_rx%1024, - subframe, - HI16, - nseq_PHICH, - ngroup_PHICH, - ulsch->harq_processes[harq_pid]->round, - ulsch->Mlimit); -#endif - - // ulsch->harq_processes[harq_pid]->Ndi = 0; - ulsch->harq_processes[harq_pid]->round++; - - if ( ulsch->harq_processes[harq_pid]->round >= (ulsch->Mlimit - 1) ) - { - // this is last push re transmission - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - - // disable phich decoding since it is the last retransmission - ulsch->harq_processes[harq_pid]->status = SCH_IDLE; - - //ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - //ulsch->harq_processes[harq_pid]->round = 0; - - //LOG_I(PHY,"PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); - //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->Mlimit, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - } - else - { - // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); - } - } -#if T_TRACER - T(T_UE_PHY_ULSCH_UE_NACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), - T_INT(harq_pid)); -#endif - - } else { //ACK - if (ue->ulsch_Msg3_active[eNB_id] == 1) { - LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", - ue->Mod_id,harq_pid, - proc->frame_rx, - subframe, - HI16, - nseq_PHICH,ngroup_PHICH); - } else { -#ifdef UE_DEBUG_TRACE - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", - ue->Mod_id,harq_pid, - proc->frame_rx%1024, - subframe, HI16, - nseq_PHICH,ngroup_PHICH); -#endif - } - - // LOG_I(PHY,"[HARQ-UL harqId: %d] subframe_scheduling_flag = %d \n",harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag); - - // Incase of adaptive retransmission, PHICH is always decoded as ACK (at least with OAI-eNB) - // Workaround: - // rely only on DCI0 decoding and check if NDI has toggled - // save current harq_processes content in temporary struct - // harqId-8 corresponds to the temporary struct. In total we have 8 harq process(0 ..7) + 1 temporary harq process() - //ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; - - - ulsch->harq_processes[harq_pid]->status = SCH_IDLE; - ulsch->harq_processes[harq_pid]->round = 0; - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - // inform MAC? - ue->ulsch_Msg3_active[eNB_id] = 0; - -#if T_TRACER - T(T_UE_PHY_ULSCH_UE_ACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), - T_INT(harq_pid)); -#endif - - } - -} void generate_phich_top(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, diff --git a/openair1/PHY/LTE_TRANSPORT/phich_common.c b/openair1/PHY/LTE_TRANSPORT/phich_common.c new file mode 100644 index 0000000000000000000000000000000000000000..a3bc5250d5f79699e693cc77fd4855905a946801 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/phich_common.c @@ -0,0 +1,383 @@ +/* + * 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/LTE_TRANSPORT/phich_common.c +* \brief Top-level routines for generating and decoding the PHICH/HI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ + +#include "PHY/defs_eNB.h" + + +uint8_t get_mi(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) +{ + + // for FDD + if (frame_parms->frame_type == FDD) + return 1; + + // for TDD + switch (frame_parms->tdd_config) { + + case 0: + if ((subframe==0) || (subframe==5)) + return(2); + else return(1); + + break; + + case 1: + if ((subframe==0) || (subframe==5)) + return(0); + else return(1); + + break; + + case 2: + if ((subframe==3) || (subframe==8)) + return(1); + else return(0); + + break; + + case 3: + if ((subframe==0) || (subframe==8) || (subframe==9)) + return(1); + else return(0); + + break; + + case 4: + if ((subframe==8) || (subframe==9)) + return(1); + else return(0); + + break; + + case 5: + if (subframe==8) + return(1); + else return(0); + + break; + + case 6: + return(1); + break; + + default: + return(0); + } +} + +unsigned char subframe2_ul_harq(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) +{ + + if (frame_parms->frame_type == FDD) + return(subframe&7); + + switch (frame_parms->tdd_config) { + case 3: + if ( (subframe == 8) || (subframe == 9) ) { + return(subframe-8); + } else if (subframe==0) + return(2); + else { + LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + return(0); + } + + break; + + case 4: + if ( (subframe == 8) || (subframe == 9) ) { + return(subframe-8); + } else { + LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + return(0); + } + + break; + + } + + return(0); +} + +int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe) +{ + int pusch_frame; + + if (frame_parms->frame_type == FDD) { + pusch_frame = subframe<4 ? frame + 1024 - 1 : frame; + } else { + // Note this is not true, but it doesn't matter, the frame number is irrelevant for TDD! + pusch_frame = (frame); + } + + //LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, subframe, pusch_frame); + return pusch_frame % 1024; +} + +uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) +{ + uint8_t pusch_subframe = 255; + + if (frame_parms->frame_type == FDD) + return subframe < 4 ? subframe + 6 : subframe - 4; + + switch (frame_parms->tdd_config) { + case 0: + if (subframe == 0) + pusch_subframe = (3); + else if (subframe == 5) { + pusch_subframe = (8); + } else if (subframe == 6) + pusch_subframe = (2); + else if (subframe == 1) + pusch_subframe = (7); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 1: + if (subframe == 6) + pusch_subframe = (2); + else if (subframe == 9) + pusch_subframe = (3); + else if (subframe == 1) + pusch_subframe = (7); + else if (subframe == 4) + pusch_subframe = (8); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 2: + if (subframe == 8) + pusch_subframe = (2); + else if (subframe == 3) + pusch_subframe = (7); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 3: + if ( (subframe == 8) || (subframe == 9) ) { + pusch_subframe = (subframe-6); + } else if (subframe==0) + pusch_subframe = (4); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 4: + if ( (subframe == 8) || (subframe == 9) ) { + pusch_subframe = (subframe-6); + } else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 5: + if (subframe == 8) { + pusch_subframe = (2); + } else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 6: + if (subframe == 6) { + pusch_subframe = (2); + } else if (subframe == 9) { + pusch_subframe = (3); + } else if (subframe == 0) { + pusch_subframe = (4); + } else if (subframe == 1) { + pusch_subframe = (7); + } else if (subframe == 5) { + pusch_subframe = (8); + } else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + default: + AssertFatal(1==0, "no implementation for TDD UL/DL-config = %d!\n", frame_parms->tdd_config); + pusch_subframe = (0); + } + + LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", subframe, pusch_subframe); + return pusch_subframe; +} + +int check_pcfich(LTE_DL_FRAME_PARMS *frame_parms,uint16_t reg) +{ + + if ((reg == frame_parms->pcfich_reg[0]) || + (reg == frame_parms->pcfich_reg[1]) || + (reg == frame_parms->pcfich_reg[2]) || + (reg == frame_parms->pcfich_reg[3])) + return(1); + + return(0); +} + +void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) +{ + + unsigned short n0 = (frame_parms->N_RB_DL * 2) - 4; // 2 REG per RB less the 4 used by PCFICH in first symbol + unsigned short n1 = (frame_parms->N_RB_DL * 3); // 3 REG per RB in second and third symbol + unsigned short n2 = n1; + unsigned short mprime = 0; + unsigned short Ngroup_PHICH; + // uint16_t *phich_reg = frame_parms->phich_reg; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + // compute Ngroup_PHICH (see formula at beginning of Section 6.9 in 36-211 + Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + + + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + // check if Extended prefix + if (frame_parms->Ncp == 1) { + Ngroup_PHICH<<=1; + } + +#ifdef DEBUG_PHICH + LOG_D(PHY,"Ngroup_PHICH %d (phich_config_common.phich_resource %d,phich_config_common.phich_duration %s, NidCell %d,Ncp %d, frame_type %d), smallest pcfich REG %d, n0 %d, n1 %d (first PHICH REG %d)\n", + ((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)), + frame_parms->phich_config_common.phich_resource, + frame_parms->phich_config_common.phich_duration==normal?"normal":"extended", + frame_parms->Nid_cell,frame_parms->Ncp,frame_parms->frame_type, + pcfich_reg[frame_parms->pcfich_first_reg_idx], + n0, + n1, + ((frame_parms->Nid_cell))%n0); +#endif + + // This is the algorithm from Section 6.9.3 in 36-211, it works only for normal PHICH duration for now ... + + for (mprime=0; + mprime<((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)); + mprime++) { + + if (frame_parms->phich_config_common.phich_duration==normal) { // normal PHICH duration + + frame_parms->phich_reg[mprime][0] = (frame_parms->Nid_cell + mprime)%n0; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) + frame_parms->phich_reg[mprime][0]++; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) + frame_parms->phich_reg[mprime][0]++; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) + frame_parms->phich_reg[mprime][0]++; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) + frame_parms->phich_reg[mprime][0]++; + + frame_parms->phich_reg[mprime][1] = (frame_parms->Nid_cell + mprime + (n0/3))%n0; + + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) + frame_parms->phich_reg[mprime][1]++; + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) + frame_parms->phich_reg[mprime][1]++; + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) + frame_parms->phich_reg[mprime][1]++; + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) + frame_parms->phich_reg[mprime][1]++; + + + frame_parms->phich_reg[mprime][2] = (frame_parms->Nid_cell + mprime + (2*n0/3))%n0; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) + frame_parms->phich_reg[mprime][2]++; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) + frame_parms->phich_reg[mprime][2]++; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) + frame_parms->phich_reg[mprime][2]++; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) + frame_parms->phich_reg[mprime][2]++; + +#ifdef DEBUG_PHICH + printf("phich_reg :%d => %d,%d,%d\n",mprime,frame_parms->phich_reg[mprime][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); +#endif + } else { // extended PHICH duration + frame_parms->phich_reg[mprime<<1][0] = (frame_parms->Nid_cell + mprime)%n0; + frame_parms->phich_reg[1+(mprime<<1)][0] = (frame_parms->Nid_cell + mprime)%n0; + + frame_parms->phich_reg[mprime<<1][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; + frame_parms->phich_reg[mprime<<1][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; + + frame_parms->phich_reg[1+(mprime<<1)][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; + frame_parms->phich_reg[1+(mprime<<1)][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; + //#ifdef DEBUG_PHICH + printf("phich_reg :%d => %d,%d,%d\n",mprime<<1,frame_parms->phich_reg[mprime<<1][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); + printf("phich_reg :%d => %d,%d,%d\n",1+(mprime<<1),frame_parms->phich_reg[1+(mprime<<1)][0],frame_parms->phich_reg[1+(mprime<<1)][1],frame_parms->phich_reg[1+(mprime<<1)][2]); + //#endif + } + } // mprime loop +} // num_pdcch_symbols loop diff --git a/openair1/PHY/LTE_TRANSPORT/pilots.c b/openair1/PHY/LTE_TRANSPORT/pilots.c index 01b4bb7a8ea4e1ec0703e6ff51ce018e51d3da77..921f93ddb103ccf41017644057f97c92137ba320 100644 --- a/openair1/PHY/LTE_TRANSPORT/pilots.c +++ b/openair1/PHY/LTE_TRANSPORT/pilots.c @@ -29,8 +29,8 @@ * \note * \warning */ -//#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" void generate_pilots(PHY_VARS_eNB *eNB, int32_t **txdataF, diff --git a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c index 90e9ae329caed2bf17853f64ea511e4315ec21d8..fddc29b5242f4d005851fedf1b95b6d639619d24 100644 --- a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c +++ b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c @@ -29,9 +29,9 @@ * \note * \warning */ -//#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" int generate_mbsfn_pilot(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, diff --git a/openair1/PHY/LTE_TRANSPORT/pilots_ue_spec.c b/openair1/PHY/LTE_TRANSPORT/pilots_ue_spec.c deleted file mode 100644 index 63aac7f091b0288eb172e775ca103e5eec6a80f2..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_TRANSPORT/pilots_ue_spec.c +++ /dev/null @@ -1,209 +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 PHY/LTE_TRANSPORT/uespec_pilots.c -* \brief Top-level routines for generating DL ue-specific reference signals V12.5 2015-03 -* \author X.JIANG -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: xiwen.jiangeurecom.fr -* \note -* \warning -*/ -//#include "defs.h" -#include "PHY/defs.h" - -void generate_ue_spec_pilots(PHY_VARS_eNB *phy_vars_eNB, - uint8_t UE_id, - int32_t **txdataF, - int16_t amp, - uint16_t Ntti, - uint8_t beamforming_mode) -{ - - /*LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->lte_frame_parms; - - uint32_t tti,tti_offset,slot_offset,Nsymb,samples_per_symbol; - uint8_t second_pilot,aa; - - // printf("Doing TX pilots Nsymb %d, second_pilot %d\n",Nsymb,second_pilot); - - switch(beamforming_mode){ - case 7: - for (tti=0; tti<Ntti; tti++) { - - tti_offset = tti*frame_parms->ofdm_symbol_size*Nsymb; - samples_per_symbol = frame_parms->ofdm_symbol_size; - slot_offset = (tti*2)%20; - - // printf("tti %d : offset %d (slot %d)\n",tti,tti_offset,slot_offset); - //Generate UE specific Pilots - printf("generate_dl_ue_spec:tti_offset=%d\n",tti_offset); - - if(frame_parms->Ncp==0) { - for(aa=0;aa<frame_parms->nb_antennas_tx;aa++){ - //antenna port 5 symbol 0 slot 0 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+3*samples_per_symbol], - amp, - slot_offset, - 1, - 5, - 0); - - //antenna port 5 symbol 1 slot 0 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+6*samples_per_symbol], - amp, - slot_offset, - 1, - 5, - 0); - - //antenna port 5 symbol 0 slot 1 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+9*samples_per_symbol], - amp, - slot_offset+1, - 0, - 5, - 0); - - //antenna port 5 symbol 1 slot 1 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+12*samples_per_symbol], - amp, - slot_offset+1, - 1, - 5, - 0); - } - } else{ - msg("generate_ue_soec_pilots:Extented Cyclic Prefix for TM7 is not supported yet.\n"); - } - - - } - break; - - case 8: - case 9: - case 10: - default: - msg("[generate_ue_spec_pilots(in uespec_pilots.c)]ERROR:beamforming mode %d is not supported\n",beamforming_mode); - - }*/ -} - -/*int generate_ue_spec_pilots_slot(PHY_VARS_eNB *phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint16_t slot, - int first_pilot_only) -{ - - LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->lte_frame_parms; - uint32_t slot_offset,Nsymb,samples_per_symbol; - uint8_t second_pilot; - - if (slot<0 || slot>= 20) { - msg("generate_pilots_slot: slot not in range (%d)\n",slot); - return(-1); - } - - Nsymb = (frame_parms->Ncp==0)?7:6; - second_pilot = (frame_parms->Ncp==0)?4:3; - - - slot_offset = slot*frame_parms->ofdm_symbol_size*Nsymb; - samples_per_symbol = frame_parms->ofdm_symbol_size; - - // printf("tti %d : offset %d (slot %d)\n",tti,tti_offset,slot_offset); - //Generate Pilots - - //antenna 0 symbol 0 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[0][slot_offset], - amp, - slot, - 0, - 0); - - - if (first_pilot_only==0) { - //antenna 0 symbol 3 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[0][slot_offset+(second_pilot*samples_per_symbol)], - amp, - slot, - 1, - 0); - } - - if (frame_parms->nb_antennas_tx > 1) { - if (frame_parms->mode1_flag) { - // antenna 1 symbol 0 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset], - amp, - slot, - 0, - 0); - - if (first_pilot_only==0) { - // antenna 1 symbol 3 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset+(second_pilot*samples_per_symbol)], - amp, - slot, - 1, - 0); - } - } else { - - // antenna 1 symbol 0 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset], - amp, - slot, - 0, - 1); - - if (first_pilot_only == 0) { - // antenna 1 symbol 3 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset+(second_pilot*samples_per_symbol)], - amp, - slot, - 1, - 1); - } - } - } - - return(0); -}*/ - diff --git a/openair1/PHY/LTE_TRANSPORT/pmch.c b/openair1/PHY/LTE_TRANSPORT/pmch.c index e756df1fe1a5b4fd4612d0f019bca3bd57c7a64f..23bc07f17448806c4c2a8563f47bf86f647fc024 100644 --- a/openair1/PHY/LTE_TRANSPORT/pmch.c +++ b/openair1/PHY/LTE_TRANSPORT/pmch.c @@ -19,10 +19,11 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/sse_intrin.h" - +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "transport_eNB.h" +#include "transport_proto.h" +#include "transport_common_proto.h" // Mask for identifying subframe for MBMS #define MBSFN_TDD_SF3 0x80// for TDD #define MBSFN_TDD_SF4 0x40 @@ -30,7 +31,7 @@ #define MBSFN_TDD_SF8 0x10 #define MBSFN_TDD_SF9 0x08 -#include "PHY/defs.h" + #define MBSFN_FDD_SF1 0x80// for FDD #define MBSFN_FDD_SF2 0x40 @@ -41,148 +42,6 @@ -void dump_mch(PHY_VARS_UE *ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe) -{ - - unsigned int nsymb_pmch=12; - char fname[32],vname[32]; - int N_RB_DL=ue->frame_parms.N_RB_DL; - - sprintf(fname,"mch_rxF_ext0.m"); - sprintf(vname,"pmch_rxF_ext0"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb_pmch,1,1); - sprintf(fname,"mch_ch_ext00.m"); - sprintf(vname,"pmch_ch_ext00"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb_pmch,1,1); - /* - write_output("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb_pmch,1,1); - write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb_pmch,1,1); - write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb_pmch,1,1); - write_output("dlsch%d_rho.m","dl_rho",pdsch_vars[eNB_id]->rho[0],12*N_RB_DL*nsymb_pmch,1,1); - */ - sprintf(fname,"mch_rxF_comp0.m"); - sprintf(vname,"pmch_rxF_comp0"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb_pmch,1,1); - sprintf(fname,"mch_rxF_llr.m"); - sprintf(vname,"pmch_llr"); - write_output(fname,vname, ue->pdsch_vars_MCH[eNB_id]->llr[0],coded_bits_per_codeword,1,0); - sprintf(fname,"mch_mag1.m"); - sprintf(vname,"pmch_mag1"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_mag0[0],12*N_RB_DL*nsymb_pmch,1,1); - sprintf(fname,"mch_mag2.m"); - sprintf(vname,"pmch_mag2"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_magb0[0],12*N_RB_DL*nsymb_pmch,1,1); - - write_output("mch00_ch0.m","pmch00_ch0", - &(ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][0][0]), - ue->frame_parms.ofdm_symbol_size*12,1,1); - - write_output("rxsig_mch.m","rxs_mch", - &ue->common_vars.rxdata[0][subframe*ue->frame_parms.samples_per_tti], - ue->frame_parms.samples_per_tti,1,1); - - /* - if (PHY_vars_eNB_g) - write_output("txsig_mch.m","txs_mch", - &PHY_vars_eNB_g[0][0]->common_vars.txdata[0][0][subframe*ue->frame_parms.samples_per_tti], - ue->frame_parms.samples_per_tti,1,1);*/ -} - -int is_pmch_subframe(uint32_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms) -{ - - uint32_t period; - uint8_t i; - - // LOG_D(PHY,"is_pmch_subframe: frame %d, subframe %d, num_MBSFN_config %d\n", - // frame,subframe,frame_parms->num_MBSFN_config); - - for (i=0; i<frame_parms->num_MBSFN_config; i++) { // we have at least one MBSFN configuration - period = 1<<frame_parms->MBSFN_config[i].radioframeAllocationPeriod; - - if ((frame % period) == frame_parms->MBSFN_config[i].radioframeAllocationOffset) { - if (frame_parms->MBSFN_config[i].fourFrames_flag == 0) { - if (frame_parms->frame_type == FDD) { - switch (subframe) { - - case 1: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF1) > 0) - return(1); - - break; - - case 2: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF2) > 0) - return(1); - - break; - - case 3: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF3) > 0) - return(1); - - break; - - case 6: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF6) > 0) - return(1); - - break; - - case 7: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF7) > 0) - return(1); - - break; - - case 8: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF8) > 0) - return(1); - - break; - } - } else { - switch (subframe) { - case 3: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF3) > 0) - return(1); - - break; - - case 4: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF4) > 0) - return(1); - - break; - - case 7: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF7) > 0) - return(1); - - break; - - case 8: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF8) > 0) - return(1); - - break; - - case 9: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF9) > 0) - return(1); - - break; - } - } - - } else { // handle 4 frames case - - } - } - } - - return(0); -} void fill_eNB_dlsch_MCH(PHY_VARS_eNB *eNB,int mcs,int ndi,int rvidx) { @@ -221,64 +80,8 @@ void fill_eNB_dlsch_MCH(PHY_VARS_eNB *eNB,int mcs,int ndi,int rvidx) break; } - if (eNB->abstraction_flag) { - eNB_transport_info[eNB->Mod_id][eNB->CC_id].cntl.pmch_flag=1; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].num_pmch=1; // assumption: there is always one pmch in each SF - eNB_transport_info[eNB->Mod_id][eNB->CC_id].num_common_dci=0; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].num_ue_spec_dci=0; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].dlsch_type[0]=5;// put at the reserved position for PMCH - eNB_transport_info[eNB->Mod_id][eNB->CC_id].harq_pid[0]=0; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].ue_id[0]=255;//broadcast - eNB_transport_info[eNB->Mod_id][eNB->CC_id].tbs[0]=dlsch->harq_processes[0]->TBS>>3; - } - } -void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id) -{ - - LTE_UE_DLSCH_t *dlsch = ue->dlsch_MCH[eNB_id]; - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - - // dlsch->rnti = M_RNTI; - dlsch->harq_processes[0]->mcs = mcs; - dlsch->harq_processes[0]->rvidx = rvidx; - // dlsch->harq_processes[0]->Ndi = ndi; - dlsch->harq_processes[0]->Nl = 1; - dlsch->harq_processes[0]->TBS = TBStable[get_I_TBS(dlsch->harq_processes[0]->mcs)][frame_parms->N_RB_DL-1]; - dlsch->current_harq_pid = 0; - dlsch->harq_processes[0]->nb_rb = frame_parms->N_RB_DL; - - switch(frame_parms->N_RB_DL) { - case 6: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0x3f; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x3f; - break; - - case 25: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0x1ffffff; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x1ffffff; - break; - - case 50: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[1] = 0x3ffff; - dlsch->harq_processes[0]->rb_alloc_odd[1] = 0x3ffff; - break; - - case 100: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[1] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[1] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[2] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[2] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[3] = 0xf; - dlsch->harq_processes[0]->rb_alloc_odd[3] = 0xf; - break; - } -} void generate_mch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t *a) { @@ -287,759 +90,36 @@ void generate_mch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t *a) int subframe = proc->subframe_tx; int frame = proc->frame_tx; - if (eNB->abstraction_flag != 0) { - if (eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]!=0) - printf("[PHY][EMU] PMCH transport block position is different than zero %d \n", eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]); - - memcpy(eNB->dlsch_MCH->harq_processes[0]->b, - a, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - LOG_D(PHY, "[eNB %d] dlsch_encoding_emul pmch , tbs is %d \n", - eNB->Mod_id, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - - memcpy(&eNB_transport_info[eNB->Mod_id][eNB->CC_id].transport_blocks[eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]], - a, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]+= eNB->dlsch_MCH->harq_processes[0]->TBS>>3;//=eNB_transport_info[eNB->Mod_id].tbs[0]; - } else { - G = get_G(&eNB->frame_parms, - eNB->frame_parms.N_RB_DL, - eNB->dlsch_MCH->harq_processes[0]->rb_alloc, - get_Qm(eNB->dlsch_MCH->harq_processes[0]->mcs),1, - 2,proc->frame_tx,subframe,0); - - generate_mbsfn_pilot(eNB,proc, - eNB->common_vars.txdataF, - AMP); - - - AssertFatal(dlsch_encoding(eNB, - a, - 1, - eNB->dlsch_MCH, - proc->frame_tx, - subframe, - &eNB->dlsch_rate_matching_stats, - &eNB->dlsch_turbo_encoding_stats, - &eNB->dlsch_interleaving_stats)==0, - "problem in dlsch_encoding"); - - dlsch_scrambling(&eNB->frame_parms,1,eNB->dlsch_MCH,0,G,0,frame,subframe<<1); - - - mch_modulation(eNB->common_vars.txdataF, - AMP, - subframe, - &eNB->frame_parms, - eNB->dlsch_MCH); - } - -} - -void mch_extract_rbs(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - unsigned char symbol, - unsigned char subframe, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - int pilots=0,i,j,offset,aarx; - - // printf("Extracting PMCH: symbol %d\n",symbol); - if ((symbol==2)|| - (symbol==10)) { - pilots = 1; - offset = 1; - } else if (symbol==6) { - pilots = 1; - offset = 0; - } - - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (pilots==1) { - for (i=offset,j=0; i<frame_parms->N_RB_DL*6; i+=2,j++) { - /* printf("MCH with pilots: i %d, j %d => %d,%d\n",i,j, - *(int16_t*)&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], - *(int16_t*)(1+&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)])); - */ - rxdataF_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)]; - rxdataF_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+1+ (symbol*frame_parms->ofdm_symbol_size)]; - dl_ch_estimates_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(symbol*frame_parms->ofdm_symbol_size)]; - dl_ch_estimates_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(frame_parms->N_RB_DL*6)+(symbol*frame_parms->ofdm_symbol_size)]; - } - } else { - - memcpy((void*)&rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], - (void*)&rxdataF[aarx][frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], - frame_parms->N_RB_DL*24); - memcpy((void*)&rxdataF_ext[aarx][(frame_parms->N_RB_DL*6) + symbol*(frame_parms->N_RB_DL*12)], - (void*)&rxdataF[aarx][1 + (symbol*frame_parms->ofdm_symbol_size)], - frame_parms->N_RB_DL*24); - memcpy((void*)&dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], - (void*)&dl_ch_estimates[aarx][(symbol*frame_parms->ofdm_symbol_size)], - frame_parms->N_RB_DL*48); - - } - - } - - - -} - -void mch_channel_level(int **dl_ch_estimates_ext, - LTE_DL_FRAME_PARMS *frame_parms, - int *avg, - uint8_t symbol, - unsigned short nb_rb) -{ - - int i,aarx,nre; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,avg128; -#elif defined(__arm__) - int32x4_t avg128; -#endif - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { -#if defined(__x86_64__) || defined(__i386__) - //clear average level - avg128 = _mm_setzero_si128(); - // 5 is always a symbol with no pilots for both normal and extended prefix - - dl_ch128=(__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - - -#endif - if ((symbol == 2) || (symbol == 6) || (symbol == 10)) - nre = (frame_parms->N_RB_DL*6); - else - nre = (frame_parms->N_RB_DL*12); - - for (i=0; i<(nre>>2); i++) { -#if defined(__x86_64__) || defined(__i386__) - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); -#elif defined(__arm__) - -#endif - } - - avg[aarx] = (((int*)&avg128)[0] + - ((int*)&avg128)[1] + - ((int*)&avg128)[2] + - ((int*)&avg128)[3])/nre; - - // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void mch_channel_compensation(int **rxdataF_ext, - int **dl_ch_estimates_ext, - int **dl_ch_mag, - int **dl_ch_magb, - int **rxdataF_comp, - LTE_DL_FRAME_PARMS *frame_parms, - unsigned char symbol, - unsigned char mod_order, - unsigned char output_shift) -{ - - int aarx,nre,i; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; -#elif defined(__arm__) - -#endif - if ((symbol == 2) || (symbol == 6) || (symbol == 10)) - nre = frame_parms->N_RB_DL*6; - else - nre = frame_parms->N_RB_DL*12; - -#if defined(__x86_64__) || defined(__i386__) - if (mod_order == 4) { - QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) - QAM_amp128b = _mm_setzero_si128(); - } else if (mod_order == 6) { - QAM_amp128 = _mm_set1_epi16(QAM64_n1); // - QAM_amp128b = _mm_set1_epi16(QAM64_n2); - } -#elif defined(__arm__) - -#endif - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128 = (__m128i *)&dl_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128b = (__m128i *)&dl_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - -#endif - - for (i=0; i<(nre>>2); i+=2) { - if (mod_order>2) { - // get channel amplitude if not QPSK -#if defined(__x86_64__) || defined(__i386__) - - mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128[0]); - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - - mmtmpD1 = _mm_madd_epi16(dl_ch128[1],dl_ch128[1]); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - - mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1); - - // store channel magnitude here in a new field of dlsch - - dl_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0); - dl_ch_mag128b[0] = dl_ch_mag128[0]; - dl_ch_mag128[0] = _mm_mulhi_epi16(dl_ch_mag128[0],QAM_amp128); - dl_ch_mag128[0] = _mm_slli_epi16(dl_ch_mag128[0],1); - - dl_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0); - dl_ch_mag128b[1] = dl_ch_mag128[1]; - dl_ch_mag128[1] = _mm_mulhi_epi16(dl_ch_mag128[1],QAM_amp128); - dl_ch_mag128[1] = _mm_slli_epi16(dl_ch_mag128[1],1); - - - dl_ch_mag128b[0] = _mm_mulhi_epi16(dl_ch_mag128b[0],QAM_amp128b); - dl_ch_mag128b[0] = _mm_slli_epi16(dl_ch_mag128b[0],1); - - - dl_ch_mag128b[1] = _mm_mulhi_epi16(dl_ch_mag128b[1],QAM_amp128b); - dl_ch_mag128b[1] = _mm_slli_epi16(dl_ch_mag128b[1],1); - -#elif defined(__arm__) - -#endif - } - -#if defined(__x86_64__) || defined(__i386__) - - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpD1); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - // print_ints("c0",&mmtmpD2); - // print_ints("c1",&mmtmpD3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - - dl_ch128+=2; - dl_ch_mag128+=2; - dl_ch_mag128b+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - -#elif defined(__arm__) - -#endif - } - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - -void mch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **dl_ch_mag, - int **dl_ch_magb, - unsigned char symbol) -{ - - - int i; -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; -#endif - if (frame_parms->nb_antennas_rx>1) { - -#if defined(__x86_64__) || defined(__i386__) - - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0 = (int16x8_t *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1 = (int16x8_t *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0b = (int16x8_t *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1b = (int16x8_t *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; - -#endif - // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); - dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1)); - dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); - dl_ch_mag128_0[i] = vhaddq_s16(dl_ch_mag128_0[i],dl_ch_mag128_1[i]); - dl_ch_mag128_0b[i] = vhaddq_s16(dl_ch_mag128_0b[i],dl_ch_mag128_1b[i]); -#endif - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -int mch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - short *dlsch_llr, - unsigned char symbol, - short **llr32p) -{ - - uint32_t *rxF = (uint32_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - uint32_t *llr32; - int i,len; - - if (symbol==2) { - llr32 = (uint32_t*)dlsch_llr; - } else { - llr32 = (uint32_t*)(*llr32p); - } - - AssertFatal(llr32!=NULL,"dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32); - - - if ((symbol==2) || (symbol==6) || (symbol==10)) { - len = frame_parms->N_RB_DL*6; - } else { - len = frame_parms->N_RB_DL*12; - } - - // printf("dlsch_qpsk_llr: symbol %d,len %d,pbch_pss_sss_adjust %d\n",symbol,len,pbch_pss_sss_adjust); - for (i=0; i<len; i++) { - *llr32 = *rxF; - rxF++; - llr32++; - } - - *llr32p = (short *)llr32; - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - - return(0); -} - -//---------------------------------------------------------------------------------------------- -// 16-QAM -//---------------------------------------------------------------------------------------------- - -void mch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - short *dlsch_llr, - int **dl_ch_mag, - unsigned char symbol, - int16_t **llr32p) -{ - -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - __m128i *ch_mag; - __m128i llr128[2],xmm0; - uint32_t *llr32; -#elif defined(__arm__) - int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int16x8_t *ch_mag; - int16x8_t llr128[2],xmm0; - int16_t *llr16; -#endif - int i,len; - unsigned char len_mod4=0; - -#if defined(__x86_64__) || defined(__i386__) - if (symbol==2) { - llr32 = (uint32_t*)dlsch_llr; - } else { - llr32 = (uint32_t*)*llr32p; - } -#elif defined(__arm__) - if (symbol==2) { - llr16 = (int16_t*)dlsch_llr; - } else { - llr16 = (int16_t*)*llr32p; - } -#endif -#if defined(__x86_64__) || defined(__i386__) - ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; -#elif defined(__arm__) - ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; -#endif - if ((symbol==2) || (symbol==6) || (symbol==10)) { - len = frame_parms->N_RB_DL*6; - } else { - len = frame_parms->N_RB_DL*12; - } - - - - // update output pointer according to number of REs in this symbol (<<2 because 4 bits per RE) - if (symbol==2) - *llr32p = dlsch_llr + (len<<2); - else - *llr32p += (len<<2); - - len_mod4 = len&3; - len>>=2; // length in quad words (4 REs) - len+=(len_mod4==0 ? 0 : 1); - - for (i=0; i<len; i++) { - -#if defined(__x86_64__) || defined(__i386__) - xmm0 = _mm_abs_epi16(rxF[i]); - xmm0 = _mm_subs_epi16(ch_mag[i],xmm0); - - // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 - llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0); - llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0); - llr32[0] = ((uint32_t *)&llr128[0])[0]; - llr32[1] = ((uint32_t *)&llr128[0])[1]; - llr32[2] = ((uint32_t *)&llr128[0])[2]; - llr32[3] = ((uint32_t *)&llr128[0])[3]; - llr32[4] = ((uint32_t *)&llr128[1])[0]; - llr32[5] = ((uint32_t *)&llr128[1])[1]; - llr32[6] = ((uint32_t *)&llr128[1])[2]; - llr32[7] = ((uint32_t *)&llr128[1])[3]; - llr32+=8; - -#elif defined(__arm__) - xmm0 = vabsq_s16(rxF[i]); - xmm0 = vsubq_s16(ch_mag[i],xmm0); - - // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 - - llr16[0] = vgetq_lane_s16(rxF[i],0); - llr16[1] = vgetq_lane_s16(xmm0,0); - llr16[2] = vgetq_lane_s16(rxF[i],1); - llr16[3] = vgetq_lane_s16(xmm0,1); - llr16[4] = vgetq_lane_s16(rxF[i],2); - llr16[5] = vgetq_lane_s16(xmm0,2); - llr16[6] = vgetq_lane_s16(rxF[i],2); - llr16[7] = vgetq_lane_s16(xmm0,3); - llr16[8] = vgetq_lane_s16(rxF[i],4); - llr16[9] = vgetq_lane_s16(xmm0,4); - llr16[10] = vgetq_lane_s16(rxF[i],5); - llr16[11] = vgetq_lane_s16(xmm0,5); - llr16[12] = vgetq_lane_s16(rxF[i],6); - llr16[13] = vgetq_lane_s16(xmm0,6); - llr16[14] = vgetq_lane_s16(rxF[i],7); - llr16[15] = vgetq_lane_s16(xmm0,7); - llr16+=16; -#endif - - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -//---------------------------------------------------------------------------------------------- -// 64-QAM -//---------------------------------------------------------------------------------------------- - -void mch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - short *dlsch_llr, - int **dl_ch_mag, - int **dl_ch_magb, - unsigned char symbol, - short **llr_save) -{ - -#if defined(__x86_64__) || defined(__i386__) - __m128i xmm1,xmm2,*ch_mag,*ch_magb; - __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; -#elif defined(__arm__) - int16x8_t xmm1,xmm2,*ch_mag,*ch_magb; - int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; -#endif - - int i,len,len2; - // int j=0; - unsigned char len_mod4; - short *llr; - int16_t *llr2; - - if (symbol==2) - llr = dlsch_llr; - else - llr = *llr_save; - -#if defined(__x86_64__) || defined(__i386__) - ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; - ch_magb = (__m128i*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; -#elif defined(__arm__) - ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; - ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; -#endif - if ((symbol==2) || (symbol==6) || (symbol==10)) { - len = frame_parms->N_RB_DL*6; - } else { - len = frame_parms->N_RB_DL*12; - } - - - llr2 = llr; - llr += (len*6); - - len_mod4 =len&3; - len2=len>>2; // length in quad words (4 REs) - len2+=(len_mod4?0:1); - - - for (i=0; i<len2; i++) { -#if defined(__x86_64__) || defined(__i386__) - xmm1 = _mm_abs_epi16(rxF[i]); - xmm1 = _mm_subs_epi16(ch_mag[i],xmm1); - xmm2 = _mm_abs_epi16(xmm1); - xmm2 = _mm_subs_epi16(ch_magb[i],xmm2); -#elif defined(__arm__) - xmm1 = vabsq_s16(rxF[i]); - xmm1 = vsubq_s16(ch_mag[i],xmm1); - xmm2 = vabsq_s16(xmm1); - xmm2 = vsubq_s16(ch_magb[i],xmm2); -#endif - - /* - printf("pmch i: %d => mag (%d,%d) (%d,%d)\n",i,((short *)&ch_mag[i])[0],((short *)&ch_magb[i])[0], - ((short *)&rxF[i])[0],((short *)&rxF[i])[1]); - */ - // loop over all LLRs in quad word (24 coded bits) - /* - for (j=0;j<8;j+=2) { - llr2[0] = ((short *)&rxF[i])[j]; - llr2[1] = ((short *)&rxF[i])[j+1]; - llr2[2] = _mm_extract_epi16(xmm1,j); - llr2[3] = _mm_extract_epi16(xmm1,j+1);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,j);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,j+1);//((short *)&xmm2)[j+1]; - - llr2+=6; - } - */ - llr2[0] = ((short *)&rxF[i])[0]; - llr2[1] = ((short *)&rxF[i])[1]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,0); - llr2[3] = _mm_extract_epi16(xmm1,1);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,0);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,1);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,0); - llr2[3] = vgetq_lane_s16(xmm1,1);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,0);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,1);//((short *)&xmm2)[j+1]; -#endif - - llr2+=6; - llr2[0] = ((short *)&rxF[i])[2]; - llr2[1] = ((short *)&rxF[i])[3]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,2); - llr2[3] = _mm_extract_epi16(xmm1,3);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,2);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,3);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,2); - llr2[3] = vgetq_lane_s16(xmm1,3);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,2);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,3);//((short *)&xmm2)[j+1]; -#endif - llr2+=6; - llr2[0] = ((short *)&rxF[i])[4]; - llr2[1] = ((short *)&rxF[i])[5]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,4); - llr2[3] = _mm_extract_epi16(xmm1,5);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,4);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,5);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,4); - llr2[3] = vgetq_lane_s16(xmm1,5);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,4);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,5);//((short *)&xmm2)[j+1]; -#endif - llr2+=6; - llr2[0] = ((short *)&rxF[i])[6]; - llr2[1] = ((short *)&rxF[i])[7]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,6); - llr2[3] = _mm_extract_epi16(xmm1,7);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,6);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,7);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,6); - llr2[3] = vgetq_lane_s16(xmm1,7);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,6);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,7);//((short *)&xmm2)[j+1]; -#endif - llr2+=6; - } - - *llr_save = llr; -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -int avg_pmch[4]; -int rx_pmch(PHY_VARS_UE *ue, - unsigned char eNB_id, - uint8_t subframe, - unsigned char symbol) -{ - - LTE_UE_COMMON *common_vars = &ue->common_vars; - LTE_UE_PDSCH **pdsch_vars = &ue->pdsch_vars_MCH[eNB_id]; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - LTE_UE_DLSCH_t **dlsch = &ue->dlsch_MCH[eNB_id]; - int avgs,aarx; - - //printf("*********************mch: symbol %d\n",symbol); - - mch_extract_rbs(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdsch_vars[eNB_id]->rxdataF_ext, - pdsch_vars[eNB_id]->dl_ch_estimates_ext, - symbol, - subframe, - frame_parms); - - if (symbol == 2) { - mch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext, - frame_parms, - avg_pmch, - symbol, - frame_parms->N_RB_DL); - } - - avgs = 0; - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) - avgs = cmax(avgs,avg_pmch[aarx]); - - if (get_Qm(dlsch[0]->harq_processes[0]->mcs)==2) - pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) ;// + 2 - else - pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2); // + 5;// + 2 - - mch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext, - pdsch_vars[eNB_id]->dl_ch_estimates_ext, - pdsch_vars[eNB_id]->dl_ch_mag0, - pdsch_vars[eNB_id]->dl_ch_magb0, - pdsch_vars[eNB_id]->rxdataF_comp0, - frame_parms, - symbol, - get_Qm(dlsch[0]->harq_processes[0]->mcs), - pdsch_vars[eNB_id]->log2_maxh); - - - if (frame_parms->nb_antennas_rx > 1) - mch_detection_mrc(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->dl_ch_mag0, - pdsch_vars[eNB_id]->dl_ch_magb0, - symbol); - - switch (get_Qm(dlsch[0]->harq_processes[0]->mcs)) { - case 2 : - mch_qpsk_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], - symbol, - pdsch_vars[eNB_id]->llr128); - break; - - case 4: - mch_16qam_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], - pdsch_vars[eNB_id]->dl_ch_mag0, - symbol, - pdsch_vars[eNB_id]->llr128); - break; - - case 6: - mch_64qam_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], - pdsch_vars[eNB_id]->dl_ch_mag0, - pdsch_vars[eNB_id]->dl_ch_magb0, - symbol, - pdsch_vars[eNB_id]->llr128); - break; - } + G = get_G(&eNB->frame_parms, + eNB->frame_parms.N_RB_DL, + eNB->dlsch_MCH->harq_processes[0]->rb_alloc, + get_Qm(eNB->dlsch_MCH->harq_processes[0]->mcs),1, + 2,proc->frame_tx,subframe,0); + + generate_mbsfn_pilot(eNB,proc, + eNB->common_vars.txdataF, + AMP); + + + AssertFatal(dlsch_encoding(eNB, + a, + 1, + eNB->dlsch_MCH, + proc->frame_tx, + subframe, + &eNB->dlsch_rate_matching_stats, + &eNB->dlsch_turbo_encoding_stats, + &eNB->dlsch_interleaving_stats)==0, + "problem in dlsch_encoding"); + + dlsch_scrambling(&eNB->frame_parms,1,eNB->dlsch_MCH,0,G,0,frame,subframe<<1); + + + mch_modulation(eNB->common_vars.txdataF, + AMP, + subframe, + &eNB->frame_parms, + eNB->dlsch_MCH); - return(0); } diff --git a/openair1/PHY/LTE_TRANSPORT/pmch_common.c b/openair1/PHY/LTE_TRANSPORT/pmch_common.c new file mode 100644 index 0000000000000000000000000000000000000000..1d12c79621ea403c93c1eaa6389da0fa5065aa8c --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pmch_common.c @@ -0,0 +1,119 @@ +/* + * 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 "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" + +int is_pmch_subframe(uint32_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms) +{ + + uint32_t period; + uint8_t i; + + // LOG_D(PHY,"is_pmch_subframe: frame %d, subframe %d, num_MBSFN_config %d\n", + // frame,subframe,frame_parms->num_MBSFN_config); + + for (i=0; i<frame_parms->num_MBSFN_config; i++) { // we have at least one MBSFN configuration + period = 1<<frame_parms->MBSFN_config[i].radioframeAllocationPeriod; + + if ((frame % period) == frame_parms->MBSFN_config[i].radioframeAllocationOffset) { + if (frame_parms->MBSFN_config[i].fourFrames_flag == 0) { + if (frame_parms->frame_type == FDD) { + switch (subframe) { + + case 1: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF1) > 0) + return(1); + + break; + + case 2: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF2) > 0) + return(1); + + break; + + case 3: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF3) > 0) + return(1); + + break; + + case 6: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF6) > 0) + return(1); + + break; + + case 7: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF7) > 0) + return(1); + + break; + + case 8: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF8) > 0) + return(1); + + break; + } + } else { + switch (subframe) { + case 3: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF3) > 0) + return(1); + + break; + + case 4: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF4) > 0) + return(1); + + break; + + case 7: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF7) > 0) + return(1); + + break; + + case 8: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF8) > 0) + return(1); + + break; + + case 9: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF9) > 0) + return(1); + + break; + } + } + + } else { // handle 4 frames case + + } + } + } + + return(0); +} diff --git a/openair1/PHY/LTE_TRANSPORT/power_control.c b/openair1/PHY/LTE_TRANSPORT/power_control.c index 36b2bfbeab81abcaac6287a9219898f24160742e..32273015ce9417bd80cb8f408ffb662f043afcbc 100644 --- a/openair1/PHY/LTE_TRANSPORT/power_control.c +++ b/openair1/PHY/LTE_TRANSPORT/power_control.c @@ -19,7 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "PHY/impl_defs_lte.h" //#define DEBUG_PC 0 @@ -94,7 +95,6 @@ double computeRhoB_eNB(uint8_t pa, return(rho_b_dB); } - double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, LTE_UE_DLSCH_t *dlsch_ue, unsigned char dl_power_off, @@ -150,3 +150,4 @@ double computeRhoB_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, #endif return(rho_b_dB); } + diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index b58aa91636a4d83fb9aa5d6aabfa3a476fc2e884..1eb66f83386e31047e496de8e5054367115d851b 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -30,1064 +30,18 @@ * \warning */ #include "PHY/sse_intrin.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" //#include "prach.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "SCHED/sched_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "prach_extern.h" //#define PRACH_DEBUG 1 //#define PRACH_WRITE_OUTPUT_DEBUG 1 -uint16_t NCS_unrestricted[16] = {0,13,15,18,22,26,32,38,46,59,76,93,119,167,279,419}; -uint16_t NCS_restricted[15] = {15,18,22,26,32,38,46,55,68,82,100,128,158,202,237}; // high-speed case -uint16_t NCS_4[7] = {2,4,6,8,10,12,15}; - -int16_t ru[2*839]; // quantized roots of unity -uint32_t ZC_inv[839]; // multiplicative inverse for roots u -uint16_t du[838]; - -typedef struct { - uint8_t f_ra; - uint8_t t0_ra; - uint8_t t1_ra; - uint8_t t2_ra; -} PRACH_TDD_PREAMBLE_MAP_elem; -typedef struct { - uint8_t num_prach; - PRACH_TDD_PREAMBLE_MAP_elem map[6]; -} PRACH_TDD_PREAMBLE_MAP; - -// This is table 5.7.1-4 from 36.211 -PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7] = { - // TDD Configuration Index 0 - { {1,{{0,1,0,2}}},{1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}}, - // TDD Configuration Index 1 - { {1,{{0,2,0,2}}},{1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}}, - // TDD Configuration Index 2 - { {1,{{0,1,1,2}}},{1,{{0,1,1,1}}}, {1,{{0,1,1,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,1}}}}, - // TDD Configuration Index 3 - { {1,{{0,0,0,2}}},{1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}}, - // TDD Configuration Index 4 - { {1,{{0,0,1,2}}},{1,{{0,0,1,1}}}, {1,{{0,0,1,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,1}}}}, - // TDD Configuration Index 5 - { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, - // TDD Configuration Index 6 - { {2,{{0,0,0,2},{0,0,1,2}}}, {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {2,{{0,0,0,1},{0,0,0,2}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {2,{{0,0,0,2},{0,0,1,1}}}}, - // TDD Configuration Index 7 - { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,2}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, - // TDD Configuration Index 8 - { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,1,1}}}}, - // TDD Configuration Index 9 - { {3,{{0,0,0,1},{0,0,0,2},{0,0,1,2}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,0,2}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {3,{{0,0,0,1},{0,0,0,2},{0,0,1,1}}}}, - // TDD Configuration Index 10 - { {3,{{0,0,0,0},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,2},{0,0,1,0}}}}, - // TDD Configuration Index 11 - { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}}, - // TDD Configuration Index 12 - { {4,{{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, - {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,2}}}, - {4,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {4,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} - }, - // TDD Configuration Index 13 - { {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1}}} - }, - // TDD Configuration Index 14 - { {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} - }, - // TDD Configuration Index 15 - { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1}}}, - {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1},{1,0,0,2}}}, - {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,1}}}, {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, - {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} - }, - // TDD Configuration Index 16 - { {5,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,1,1}}}, - {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,1,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,2}}}, - {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} - }, - // TDD Configuration Index 17 - { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} - }, - // TDD Configuration Index 18 - { {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, - {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1},{1,0,0,2}}}, - {6,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0},{2,0,0,1}}}, - {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,0,2}}} - }, - // TDD Configuration Index 19 - { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0},{1,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,1,1}}} - }, - // TDD Configuration Index 20 - { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, - // TDD Configuration Index 21 - { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, - - // TDD Configuration Index 22 - { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, - - // TDD Configuration Index 23 - { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, - - // TDD Configuration Index 24 - { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, - - // TDD Configuration Index 25 - { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, - - // TDD Configuration Index 26 - { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, - - // TDD Configuration Index 27 - { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} - }, - - // TDD Configuration Index 28 - { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, - {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} - }, - - // TDD Configuration Index 29 - { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, - {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, - {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} - }, - - - // TDD Configuration Index 30 - { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, - - // TDD Configuration Index 31 - { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, - - // TDD Configuration Index 32 - { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, - - // TDD Configuration Index 33 - { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, - - // TDD Configuration Index 34 - { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, - - // TDD Configuration Index 35 - { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, - - // TDD Configuration Index 36 - { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, - - // TDD Configuration Index 37 - { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} - }, - - // TDD Configuration Index 38 - { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, - {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} - }, - - // TDD Configuration Index 39 - { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, - {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, - {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} - }, - - // TDD Configuration Index 40 - { {1,{{0,1,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}}, - // TDD Configuration Index 41 - { {1,{{0,2,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}}, - - // TDD Configuration Index 42 - { {1,{{0,1,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, - - // TDD Configuration Index 43 - { {1,{{0,0,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}}, - - // TDD Configuration Index 44 - { {1,{{0,0,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, - - // TDD Configuration Index 45 - { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}}, - - // TDD Configuration Index 46 - { {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}}, - - // TDD Configuration Index 47 - { {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}} - } -}; - - - -uint16_t prach_root_sequence_map0_3[838] = { 129, 710, 140, 699, 120, 719, 210, 629, 168, 671, 84, 755, 105, 734, 93, 746, 70, 769, 60, 779, - 2, 837, 1, 838, - 56, 783, 112, 727, 148, 691, - 80, 759, 42, 797, 40, 799, - 35, 804, 73, 766, 146, 693, - 31, 808, 28, 811, 30, 809, 27, 812, 29, 810, - 24, 815, 48, 791, 68, 771, 74, 765, 178, 661, 136, 703, - 86, 753, 78, 761, 43, 796, 39, 800, 20, 819, 21, 818, - 95, 744, 202, 637, 190, 649, 181, 658, 137, 702, 125, 714, 151, 688, - 217, 622, 128, 711, 142, 697, 122, 717, 203, 636, 118, 721, 110, 729, 89, 750, 103, 736, 61, - 778, 55, 784, 15, 824, 14, 825, - 12, 827, 23, 816, 34, 805, 37, 802, 46, 793, 207, 632, 179, 660, 145, 694, 130, 709, 223, 616, - 228, 611, 227, 612, 132, 707, 133, 706, 143, 696, 135, 704, 161, 678, 201, 638, 173, 666, 106, - 733, 83, 756, 91, 748, 66, 773, 53, 786, 10, 829, 9, 830, - 7, 832, 8, 831, 16, 823, 47, 792, 64, 775, 57, 782, 104, 735, 101, 738, 108, 731, 208, 631, 184, - 655, 197, 642, 191, 648, 121, 718, 141, 698, 149, 690, 216, 623, 218, 621, - 152, 687, 144, 695, 134, 705, 138, 701, 199, 640, 162, 677, 176, 663, 119, 720, 158, 681, 164, - 675, 174, 665, 171, 668, 170, 669, 87, 752, 169, 670, 88, 751, 107, 732, 81, 758, 82, 757, 100, - 739, 98, 741, 71, 768, 59, 780, 65, 774, 50, 789, 49, 790, 26, 813, 17, 822, 13, 826, 6, 833, - 5, 834, 33, 806, 51, 788, 75, 764, 99, 740, 96, 743, 97, 742, 166, 673, 172, 667, 175, 664, 187, - 652, 163, 676, 185, 654, 200, 639, 114, 725, 189, 650, 115, 724, 194, 645, 195, 644, 192, 647, - 182, 657, 157, 682, 156, 683, 211, 628, 154, 685, 123, 716, 139, 700, 212, 627, 153, 686, 213, - 626, 215, 624, 150, 689, - 225, 614, 224, 615, 221, 618, 220, 619, 127, 712, 147, 692, 124, 715, 193, 646, 205, 634, 206, - 633, 116, 723, 160, 679, 186, 653, 167, 672, 79, 760, 85, 754, 77, 762, 92, 747, 58, 781, 62, - 777, 69, 770, 54, 785, 36, 803, 32, 807, 25, 814, 18, 821, 11, 828, 4, 835, - 3, 836, 19, 820, 22, 817, 41, 798, 38, 801, 44, 795, 52, 787, 45, 794, 63, 776, 67, 772, 72, - 767, 76, 763, 94, 745, 102, 737, 90, 749, 109, 730, 165, 674, 111, 728, 209, 630, 204, 635, 117, - 722, 188, 651, 159, 680, 198, 641, 113, 726, 183, 656, 180, 659, 177, 662, 196, 643, 155, 684, - 214, 625, 126, 713, 131, 708, 219, 620, 222, 617, 226, 613, - 230, 609, 232, 607, 262, 577, 252, 587, 418, 421, 416, 423, 413, 426, 411, 428, 376, 463, 395, - 444, 283, 556, 285, 554, 379, 460, 390, 449, 363, 476, 384, 455, 388, 451, 386, 453, 361, 478, - 387, 452, 360, 479, 310, 529, 354, 485, 328, 511, 315, 524, 337, 502, 349, 490, 335, 504, 324, - 515, - 323, 516, 320, 519, 334, 505, 359, 480, 295, 544, 385, 454, 292, 547, 291, 548, 381, 458, 399, - 440, 380, 459, 397, 442, 369, 470, 377, 462, 410, 429, 407, 432, 281, 558, 414, 425, 247, 592, - 277, 562, 271, 568, 272, 567, 264, 575, 259, 580, - 237, 602, 239, 600, 244, 595, 243, 596, 275, 564, 278, 561, 250, 589, 246, 593, 417, 422, 248, - 591, 394, 445, 393, 446, 370, 469, 365, 474, 300, 539, 299, 540, 364, 475, 362, 477, 298, 541, - 312, 527, 313, 526, 314, 525, 353, 486, 352, 487, 343, 496, 327, 512, 350, 489, 326, 513, 319, - 520, 332, 507, 333, 506, 348, 491, 347, 492, 322, 517, - 330, 509, 338, 501, 341, 498, 340, 499, 342, 497, 301, 538, 366, 473, 401, 438, 371, 468, 408, - 431, 375, 464, 249, 590, 269, 570, 238, 601, 234, 605, - 257, 582, 273, 566, 255, 584, 254, 585, 245, 594, 251, 588, 412, 427, 372, 467, 282, 557, 403, - 436, 396, 443, 392, 447, 391, 448, 382, 457, 389, 450, 294, 545, 297, 542, 311, 528, 344, 495, - 345, 494, 318, 521, 331, 508, 325, 514, 321, 518, - 346, 493, 339, 500, 351, 488, 306, 533, 289, 550, 400, 439, 378, 461, 374, 465, 415, 424, 270, - 569, 241, 598, - 231, 608, 260, 579, 268, 571, 276, 563, 409, 430, 398, 441, 290, 549, 304, 535, 308, 531, 358, - 481, 316, 523, - 293, 546, 288, 551, 284, 555, 368, 471, 253, 586, 256, 583, 263, 576, - 242, 597, 274, 565, 402, 437, 383, 456, 357, 482, 329, 510, - 317, 522, 307, 532, 286, 553, 287, 552, 266, 573, 261, 578, - 236, 603, 303, 536, 356, 483, - 355, 484, 405, 434, 404, 435, 406, 433, - 235, 604, 267, 572, 302, 537, - 309, 530, 265, 574, 233, 606, - 367, 472, 296, 543, - 336, 503, 305, 534, 373, 466, 280, 559, 279, 560, 419, 420, 240, 599, 258, 581, 229, 610 - }; - -uint16_t prach_root_sequence_map4[138] = { 1,138,2,137,3,136,4,135,5,134,6,133,7,132,8,131,9,130,10,129, - 11,128,12,127,13,126,14,125,15,124,16,123,17,122,18,121,19,120,20,119, - 21,118,22,117,23,116,24,115,25,114,26,113,27,112,28,111,29,110,30,109, - 31,108,32,107,33,106,34,105,35,104,36,103,37,102,38,101,39,100,40,99, - 41,98,42,97,43,96,44,95,45,94,46,93,47,92,48,91,49,90,50,89, - 51,88,52,87,53,86,54,85,55,84,56,83,57,82,58,81,59,80,60,79, - 61,78,62,77,63,76,64,75,65,74,66,73,67,72,68,71,69,70 - }; - -void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) -{ - - FILE *fd; - - fd = fopen("prach_config.txt","w"); - fprintf(fd,"prach_config: subframe = %d\n",subframe); - fprintf(fd,"prach_config: N_RB_UL = %d\n",frame_parms->N_RB_UL); - fprintf(fd,"prach_config: frame_type = %s\n",(frame_parms->frame_type==1) ? "TDD":"FDD"); - - if(frame_parms->frame_type==1) fprintf(fd,"prach_config: tdd_config = %d\n",frame_parms->tdd_config); - - fprintf(fd,"prach_config: rootSequenceIndex = %d\n",frame_parms->prach_config_common.rootSequenceIndex); - fprintf(fd,"prach_config: prach_ConfigIndex = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex); - fprintf(fd,"prach_config: Ncs_config = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig); - fprintf(fd,"prach_config: highSpeedFlag = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag); - fprintf(fd,"prach_config: n_ra_prboffset = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset); - fclose(fd); - -} - -// This function computes the du -void fill_du(uint8_t prach_fmt) -{ - - uint16_t iu,u,p; - uint16_t N_ZC; - uint16_t *prach_root_sequence_map; - - if (prach_fmt<4) { - N_ZC = 839; - prach_root_sequence_map = prach_root_sequence_map0_3; - } else { - N_ZC = 139; - prach_root_sequence_map = prach_root_sequence_map4; - } - - for (iu=0; iu<(N_ZC-1); iu++) { - - u=prach_root_sequence_map[iu]; - p=1; - - while (((u*p)%N_ZC)!=1) - p++; - - du[u] = ((p<(N_ZC>>1)) ? p : (N_ZC-p)); - } - -} - -uint8_t get_num_prach_tdd(module_id_t Mod_id) -{ - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; - return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].num_prach); -} - -uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index) -{ - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; - return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].map[tdd_map_index].f_ra); -} - -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type) -{ - - if (frame_type == FDD) // FDD - return(prach_ConfigIndex>>4); - - else { - if (prach_ConfigIndex < 20) - return (0); - - if (prach_ConfigIndex < 30) - return (1); - - if (prach_ConfigIndex < 40) - return (2); - - if (prach_ConfigIndex < 48) - return (3); - else - return (4); - } -} - -uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t prach_ConfigIndex, - uint8_t n_ra_prboffset, - uint8_t tdd_mapindex, uint16_t Nf) -{ - lte_frame_type_t frame_type = frame_parms->frame_type; - uint8_t tdd_config = frame_parms->tdd_config; - - uint8_t n_ra_prb; - uint8_t f_ra,t1_ra; - uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); - uint8_t Nsp=2; - - if (frame_type == TDD) { // TDD - - if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { - LOG_E(PHY, "Illegal prach_ConfigIndex %"PRIu8"", prach_ConfigIndex); - return(-1); - } - - // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) - f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; - - if (prach_fmt < 4) { - if ((f_ra&1) == 0) { - n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); - } else { - n_ra_prb = frame_parms->N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); - } - } else { - if ((tdd_config >2) && (tdd_config<6)) - Nsp = 2; - - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { - n_ra_prb = 6*f_ra; - } else { - n_ra_prb = frame_parms->N_RB_UL - 6*(f_ra+1); - } - } - } - else { //FDD - n_ra_prb = n_ra_prboffset; - } - return(n_ra_prb); -} - -int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe) -{ - // uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - uint8_t tdd_config = frame_parms->tdd_config; - uint8_t t0_ra; - uint8_t t1_ra; - uint8_t t2_ra; - - int prach_mask = 0; - - if (frame_parms->frame_type == FDD) { //FDD - //implement Table 5.7.1-2 from 36.211 (Rel-10, p.41) - if ((((frame&1) == 1) && (subframe < 9)) || - (((frame&1) == 0) && (subframe == 9))) // This is an odd frame, ignore even-only PRACH frames - if (((prach_ConfigIndex&0xf)<3) || // 0,1,2,16,17,18,32,33,34,48,49,50 - ((prach_ConfigIndex&0x1f)==18) || // 18,50 - ((prach_ConfigIndex&0xf)==15)) // 15,47 - return(0); - - switch (prach_ConfigIndex&0x1f) { - case 0: - case 3: - if (subframe==1) prach_mask = 1; - break; - - case 1: - case 4: - if (subframe==4) prach_mask = 1; - break; - - case 2: - case 5: - if (subframe==7) prach_mask = 1; - break; - - case 6: - if ((subframe==1) || (subframe==6)) prach_mask=1; - break; - - case 7: - if ((subframe==2) || (subframe==7)) prach_mask=1; - break; - - case 8: - if ((subframe==3) || (subframe==8)) prach_mask=1; - break; - - case 9: - if ((subframe==1) || (subframe==4) || (subframe==7)) prach_mask=1; - break; - - case 10: - if ((subframe==2) || (subframe==5) || (subframe==8)) prach_mask=1; - break; - - case 11: - if ((subframe==3) || (subframe==6) || (subframe==9)) prach_mask=1; - break; - - case 12: - if ((subframe&1)==0) prach_mask=1; - break; - - case 13: - if ((subframe&1)==1) prach_mask=1; - break; - - case 14: - prach_mask=1; - break; - - case 15: - if (subframe==9) prach_mask=1; - break; - } - } else { // TDD - - AssertFatal(prach_ConfigIndex<64, - "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); - AssertFatal(tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach>0, - "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); - - t0_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t0_ra; - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - t2_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t2_ra; -#ifdef PRACH_DEBUG - LOG_I(PHY,"[PRACH] Checking for PRACH format (ConfigIndex %d) in TDD subframe %d (%d,%d,%d)\n", - prach_ConfigIndex, - subframe, - t0_ra,t1_ra,t2_ra); -#endif - - if ((((t0_ra == 1) && ((frame &1)==0))|| // frame is even and PRACH is in even frames - ((t0_ra == 2) && ((frame &1)==1))|| // frame is odd and PRACH is in odd frames - (t0_ra == 0)) && // PRACH is in all frames - (((subframe<5)&&(t1_ra==0)) || // PRACH is in 1st half-frame - (((subframe>4)&&(t1_ra==1))))) { // PRACH is in 2nd half-frame - if ((prach_ConfigIndex<48) && // PRACH only in normal UL subframe - (((subframe%5)-2)==t2_ra)) prach_mask=1; - else if ((prach_ConfigIndex>47) && (((subframe%5)-1)==t2_ra)) prach_mask=1; // PRACH can be in UpPTS - } - } - - return(prach_mask); -} - -int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) { - - uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - int prach_mask = is_prach_subframe0(frame_parms,prach_ConfigIndex,frame,subframe); - -#ifdef Rel14 - int i; - - for (i=0;i<4;i++) { - if (frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] == 1) - prach_mask|=(is_prach_subframe0(frame_parms,frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i],frame,subframe)<<(i+1)); - } -#endif - return(prach_mask); -} - -int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint16_t Nf ) -{ - - lte_frame_type_t frame_type = ue->frame_parms.frame_type; - //uint8_t tdd_config = ue->frame_parms.tdd_config; - uint16_t rootSequenceIndex = ue->frame_parms.prach_config_common.rootSequenceIndex; - uint8_t prach_ConfigIndex = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - uint8_t Ncs_config = ue->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig; - uint8_t restricted_set = ue->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag; - //uint8_t n_ra_prboffset = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; - uint8_t preamble_index = ue->prach_resources[eNB_id]->ra_PreambleIndex; - uint8_t tdd_mapindex = ue->prach_resources[eNB_id]->ra_TDD_map_index; - int16_t *prachF = ue->prach_vars[eNB_id]->prachF; - static int16_t prach_tmp[45600*2] __attribute__((aligned(32))); - int16_t *prach = prach_tmp; - int16_t *prach2; - int16_t amp = ue->prach_vars[eNB_id]->amp; - int16_t Ncp; - uint8_t n_ra_prb; - uint16_t NCS; - uint16_t *prach_root_sequence_map; - uint16_t preamble_offset,preamble_shift; - uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar; - uint16_t d_start,numshift; - - uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); - //uint8_t Nsp=2; - //uint8_t f_ra,t1_ra; - uint16_t N_ZC = (prach_fmt<4)?839:139; - uint8_t not_found; - int k; - int16_t *Xu; - uint16_t u; - int32_t Xu_re,Xu_im; - uint16_t offset,offset2; - int prach_start; - int i, prach_len; - uint16_t first_nonzero_root_idx=0; - -#if defined(EXMIMO) || defined(OAI_USRP) - prach_start = (ue->rx_offset+subframe*ue->frame_parms.samples_per_tti-ue->hw_timing_advance-ue->N_TA_offset); -#ifdef PRACH_DEBUG - LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, - prach_start, - ue->rx_offset, - ue->hw_timing_advance, - ue->N_TA_offset); -#endif - - if (prach_start<0) - prach_start+=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); - - if (prach_start>=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) - prach_start-=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); - -#else //normal case (simulation) - prach_start = subframe*ue->frame_parms.samples_per_tti-ue->N_TA_offset; - LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, - prach_start, - ue->rx_offset, - ue->hw_timing_advance, - ue->N_TA_offset); - -#endif - - - // First compute physical root sequence - if (restricted_set == 0) { - AssertFatal(Ncs_config <= 15, - "[PHY] FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", Ncs_config ); - NCS = NCS_unrestricted[Ncs_config]; - } else { - AssertFatal(Ncs_config <= 14, - "[PHY] FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", Ncs_config ); - NCS = NCS_restricted[Ncs_config]; - } - - n_ra_prb = get_prach_prb_offset(&(ue->frame_parms), - ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset, - tdd_mapindex, Nf); - prach_root_sequence_map = (prach_fmt<4) ? prach_root_sequence_map0_3 : prach_root_sequence_map4; - - /* - // this code is not part of get_prach_prb_offset - if (frame_type == TDD) { // TDD - - if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { - LOG_E( PHY, "[PHY][UE %"PRIu8"] Illegal prach_ConfigIndex %"PRIu8" for ", ue->Mod_id, prach_ConfigIndex ); - } - - // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) - f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; - - if (prach_fmt < 4) { - if ((f_ra&1) == 0) { - n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); - } else { - n_ra_prb = ue->frame_parms.N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); - } - } else { - if ((tdd_config >2) && (tdd_config<6)) - Nsp = 2; - - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - - if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { - n_ra_prb = 6*f_ra; - } else { - n_ra_prb = ue->frame_parms.N_RB_UL - 6*(f_ra+1); - } - } - } - */ - - // This is the relative offset (for unrestricted case) in the root sequence table (5.7.2-4 from 36.211) for the given preamble index - preamble_offset = ((NCS==0)? preamble_index : (preamble_index/(N_ZC/NCS))); - - if (restricted_set == 0) { - // This is the \nu corresponding to the preamble index - preamble_shift = (NCS==0)? 0 : (preamble_index % (N_ZC/NCS)); - preamble_shift *= NCS; - } else { // This is the high-speed case - -#ifdef PRACH_DEBUG - LOG_I(PHY,"[UE %d] High-speed mode, NCS_config %d\n",ue->Mod_id,Ncs_config); -#endif - - not_found = 1; - preamble_index0 = preamble_index; - // set preamble_offset to initial rootSequenceIndex and look if we need more root sequences for this - // preamble index and find the corresponding cyclic shift - preamble_offset = 0; // relative rootSequenceIndex; - - while (not_found == 1) { - // current root depending on rootSequenceIndex and preamble_offset - int index = (rootSequenceIndex + preamble_offset) % N_ZC; - - if (prach_fmt<4) { - // prach_root_sequence_map points to prach_root_sequence_map0_3 - DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); - } else { - // prach_root_sequence_map points to prach_root_sequence_map4 - DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); - } - - u = prach_root_sequence_map[index]; - - uint16_t n_group_ra = 0; - - if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { - n_shift_ra = du[u]/NCS; - d_start = (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = N_ZC/d_start; - n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); - } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { - n_shift_ra = (N_ZC - (du[u]<<1))/NCS; - d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = du[u]/d_start; - n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); - } else { - n_shift_ra = 0; - n_shift_ra_bar = 0; - } - - // This is the number of cyclic shifts for the current root u - numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; - - if (numshift>0 && preamble_index0==preamble_index) - first_nonzero_root_idx = preamble_offset; - - if (preamble_index0 < numshift) { - not_found = 0; - preamble_shift = (d_start * (preamble_index0/n_shift_ra)) + ((preamble_index0%n_shift_ra)*NCS); - - } else { // skip to next rootSequenceIndex and recompute parameters - preamble_offset++; - preamble_index0 -= numshift; - } - } - } - - // now generate PRACH signal -#ifdef PRACH_DEBUG - - if (NCS>0) - LOG_I(PHY,"Generate PRACH for RootSeqIndex %d, Preamble Index %d, NCS %d (NCS_config %d, N_ZC/NCS %d) n_ra_prb %d: Preamble_offset %d, Preamble_shift %d\n", - rootSequenceIndex,preamble_index,NCS,Ncs_config,N_ZC/NCS,n_ra_prb, - preamble_offset,preamble_shift); - -#endif - - // nsymb = (frame_parms->Ncp==0) ? 14:12; - // subframe_offset = (unsigned int)frame_parms->ofdm_symbol_size*subframe*nsymb; - - k = (12*n_ra_prb) - 6*ue->frame_parms.N_RB_UL; - - if (k<0) - k+=ue->frame_parms.ofdm_symbol_size; - - k*=12; - k+=13; - - Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; - - /* - k+=(12*ue->frame_parms.first_carrier_offset); - if (k>(12*ue->frame_parms.ofdm_symbol_size)) - k-=(12*ue->frame_parms.ofdm_symbol_size); - */ - k*=2; - - switch (ue->frame_parms.N_RB_UL) { - case 6: - memset((void*)prachF,0,4*1536); - break; - - case 15: - memset((void*)prachF,0,4*3072); - break; - - case 25: - memset((void*)prachF,0,4*6144); - break; - - case 50: - memset((void*)prachF,0,4*12288); - break; - - case 75: - memset((void*)prachF,0,4*18432); - break; - - case 100: - if (ue->frame_parms.threequarter_fs == 0) - memset((void*)prachF,0,4*24576); - else - memset((void*)prachF,0,4*18432); - break; - } - - for (offset=0,offset2=0; offset<N_ZC; offset++,offset2+=preamble_shift) { - - if (offset2 >= N_ZC) - offset2 -= N_ZC; - - Xu_re = (((int32_t)Xu[offset<<1]*amp)>>15); - Xu_im = (((int32_t)Xu[1+(offset<<1)]*amp)>>15); - prachF[k++]= ((Xu_re*ru[offset2<<1]) - (Xu_im*ru[1+(offset2<<1)]))>>15; - prachF[k++]= ((Xu_im*ru[offset2<<1]) + (Xu_re*ru[1+(offset2<<1)]))>>15; - - if (k==(12*2*ue->frame_parms.ofdm_symbol_size)) - k=0; - } - - switch (prach_fmt) { - case 0: - Ncp = 3168; - break; - - case 1: - case 3: - Ncp = 21024; - break; - - case 2: - Ncp = 6240; - break; - - case 4: - Ncp = 448; - break; - - default: - Ncp = 3168; - break; - } - - switch (ue->frame_parms.N_RB_UL) { - case 6: - Ncp>>=4; - prach+=4; // makes prach2 aligned to 128-bit - break; - - case 15: - Ncp>>=3; - break; - - case 25: - Ncp>>=2; - break; - - case 50: - Ncp>>=1; - break; - - case 75: - Ncp=(Ncp*3)>>2; - break; - } - - if (ue->frame_parms.threequarter_fs == 1) - Ncp=(Ncp*3)>>2; - - prach2 = prach+(Ncp<<1); - - // do IDFT - switch (ue->frame_parms.N_RB_UL) { - case 6: - if (prach_fmt == 4) { - idft256(prachF,prach2,1); - memmove( prach, prach+512, Ncp<<2 ); - prach_len = 256+Ncp; - } else { - idft1536(prachF,prach2,1); - memmove( prach, prach+3072, Ncp<<2 ); - prach_len = 1536+Ncp; - - if (prach_fmt>1) { - memmove( prach2+3072, prach2, 6144 ); - prach_len = 2*1536+Ncp; - } - } - - break; - - case 15: - if (prach_fmt == 4) { - idft512(prachF,prach2,1); - //TODO: account for repeated format in dft output - memmove( prach, prach+1024, Ncp<<2 ); - prach_len = 512+Ncp; - } else { - idft3072(prachF,prach2); - memmove( prach, prach+6144, Ncp<<2 ); - prach_len = 3072+Ncp; - - if (prach_fmt>1) { - memmove( prach2+6144, prach2, 12288 ); - prach_len = 2*3072+Ncp; - } - } - - break; - - case 25: - default: - if (prach_fmt == 4) { - idft1024(prachF,prach2,1); - memmove( prach, prach+2048, Ncp<<2 ); - prach_len = 1024+Ncp; - } else { - idft6144(prachF,prach2); - /*for (i=0;i<6144*2;i++) - prach2[i]<<=1;*/ - memmove( prach, prach+12288, Ncp<<2 ); - prach_len = 6144+Ncp; - - if (prach_fmt>1) { - memmove( prach2+12288, prach2, 24576 ); - prach_len = 2*6144+Ncp; - } - } - - break; - - case 50: - if (prach_fmt == 4) { - idft2048(prachF,prach2,1); - memmove( prach, prach+4096, Ncp<<2 ); - prach_len = 2048+Ncp; - } else { - idft12288(prachF,prach2); - memmove( prach, prach+24576, Ncp<<2 ); - prach_len = 12288+Ncp; - - if (prach_fmt>1) { - memmove( prach2+24576, prach2, 49152 ); - prach_len = 2*12288+Ncp; - } - } - - break; - - case 75: - if (prach_fmt == 4) { - idft3072(prachF,prach2); - //TODO: account for repeated format in dft output - memmove( prach, prach+6144, Ncp<<2 ); - prach_len = 3072+Ncp; - } else { - idft18432(prachF,prach2); - memmove( prach, prach+36864, Ncp<<2 ); - prach_len = 18432+Ncp; - - if (prach_fmt>1) { - memmove( prach2+36834, prach2, 73728 ); - prach_len = 2*18432+Ncp; - } - } - - break; - - case 100: - if (ue->frame_parms.threequarter_fs == 0) { - if (prach_fmt == 4) { - idft4096(prachF,prach2,1); - memmove( prach, prach+8192, Ncp<<2 ); - prach_len = 4096+Ncp; - } else { - idft24576(prachF,prach2); - memmove( prach, prach+49152, Ncp<<2 ); - prach_len = 24576+Ncp; - - if (prach_fmt>1) { - memmove( prach2+49152, prach2, 98304 ); - prach_len = 2* 24576+Ncp; - } - } - } - else { - if (prach_fmt == 4) { - idft3072(prachF,prach2); - //TODO: account for repeated format in dft output - memmove( prach, prach+6144, Ncp<<2 ); - prach_len = 3072+Ncp; - } else { - idft18432(prachF,prach2); - memmove( prach, prach+36864, Ncp<<2 ); - prach_len = 18432+Ncp; - printf("Generated prach for 100 PRB, 3/4 sampling\n"); - if (prach_fmt>1) { - memmove( prach2+36834, prach2, 73728 ); - prach_len = 2*18432+Ncp; - } - } - } - - break; - } - - //LOG_I(PHY,"prach_len=%d\n",prach_len); - - AssertFatal(prach_fmt<4, - "prach_fmt4 not fully implemented" ); -#if defined(EXMIMO) || defined(OAI_USRP) - int j; - int overflow = prach_start + prach_len - LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*ue->frame_parms.samples_per_tti; - LOG_I( PHY, "prach_start=%d, overflow=%d\n", prach_start, overflow ); - - for (i=prach_start,j=0; i<min(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,prach_start+prach_len); i++,j++) { - ((int16_t*)ue->common_vars.txdata[0])[2*i] = prach[2*j]<<4; - ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]<<4; - } - - for (i=0; i<overflow; i++,j++) { - ((int16_t*)ue->common_vars.txdata[0])[2*i] = prach[2*j]<<4; - ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]<<4; - } -#if defined(EXMIMO) - // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on - for (k=prach_start - (ue->frame_parms.samples_per_tti>>1) ; k<prach_start ; k++) { - if (k<0) - ue->common_vars.txdata[0][k+ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; - else if (k>(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) - ue->common_vars.txdata[0][k-ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; - else - ue->common_vars.txdata[0][k] &= 0xFFFEFFFE; - } -#endif -#else - - for (i=0; i<prach_len; i++) { - ((int16_t*)(&ue->common_vars.txdata[0][prach_start]))[2*i] = prach[2*i]; - ((int16_t*)(&ue->common_vars.txdata[0][prach_start]))[2*i+1] = prach[2*i+1]; - } - -#endif - - - -#if defined(PRACH_WRITE_OUTPUT_DEBUG) - write_output("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1); - write_output("prach_tx0.m","prachtx0",prach+(Ncp<<1),prach_len-Ncp,1,1); - write_output("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][0]),2*ue->frame_parms.samples_per_tti,1,1); - exit(-1); -#endif - - return signal_energy( (int*)prach, 256 ); -} -//__m128i mmtmpX0,mmtmpX1,mmtmpX2,mmtmpX3; #ifndef Rel14 #define rx_prach0 rx_prach @@ -1766,8 +720,6 @@ void rx_prach0(PHY_VARS_eNB *eNB, } - - #ifdef Rel14 void rx_prach(PHY_VARS_eNB *eNB, @@ -1812,189 +764,4 @@ void rx_prach(PHY_VARS_eNB *eNB, #endif /* Rel14 */ -void init_prach_tables(int N_ZC) -{ - - int i,m; - - // Compute the modular multiplicative inverse 'iu' of u s.t. iu*u = 1 mod N_ZC - ZC_inv[0] = 0; - ZC_inv[1] = 1; - - for (i=2; i<N_ZC; i++) { - for (m=2; m<N_ZC; m++) - if (((i*m)%N_ZC) == 1) { - ZC_inv[i] = m; - break; - } - -#ifdef PRACH_DEBUG - - if (i<16) - printf("i %d : inv %d\n",i,ZC_inv[i]); -#endif - } - - // Compute quantized roots of unity - for (i=0; i<N_ZC; i++) { - ru[i<<1] = (int16_t)(floor(32767.0*cos(2*M_PI*(double)i/N_ZC))); - ru[1+(i<<1)] = (int16_t)(floor(32767.0*sin(2*M_PI*(double)i/N_ZC))); -#ifdef PRACH_DEBUG - - if (i<16) - printf("i %d : runity %d,%d\n",i,ru[i<<1],ru[1+(i<<1)]); - -#endif - } -} - -void compute_prach_seq(uint16_t rootSequenceIndex, - uint8_t prach_ConfigIndex, - uint8_t zeroCorrelationZoneConfig, - uint8_t highSpeedFlag, - lte_frame_type_t frame_type, - uint32_t X_u[64][839]) -{ - - // Compute DFT of x_u => X_u[k] = x_u(inv(u)*k)^* X_u[k] = exp(j\pi u*inv(u)*k*(inv(u)*k+1)/N_ZC) - unsigned int k,inv_u,i,NCS=0,num_preambles; - int N_ZC; - uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); - uint16_t *prach_root_sequence_map; - uint16_t u, preamble_offset; - uint16_t n_shift_ra,n_shift_ra_bar, d_start,numshift; - uint8_t not_found; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_IN); - -#ifdef PRACH_DEBUG - LOG_I(PHY,"compute_prach_seq: NCS_config %d, prach_fmt %d\n",zeroCorrelationZoneConfig, prach_fmt); -#endif - - AssertFatal(prach_fmt<4, - "PRACH sequence is only precomputed for prach_fmt<4 (have %"PRIu8")\n", prach_fmt ); - N_ZC = (prach_fmt < 4) ? 839 : 139; - //init_prach_tables(N_ZC); //moved to phy_init_lte_ue/eNB, since it takes to long in real-time - - if (prach_fmt < 4) { - prach_root_sequence_map = prach_root_sequence_map0_3; - } else { - // FIXME cannot be reached - prach_root_sequence_map = prach_root_sequence_map4; - } - - -#ifdef PRACH_DEBUG - LOG_I( PHY, "compute_prach_seq: done init prach_tables\n" ); -#endif - - if (highSpeedFlag== 0) { - -#ifdef PRACH_DEBUG - LOG_I(PHY,"Low speed prach : NCS_config %d\n",zeroCorrelationZoneConfig); -#endif - - AssertFatal(zeroCorrelationZoneConfig<=15, - "FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); - NCS = NCS_unrestricted[zeroCorrelationZoneConfig]; - - num_preambles = (NCS==0) ? 64 : ((64*NCS)/N_ZC); - - if (NCS>0) num_preambles++; - - preamble_offset = 0; - } else { - -#ifdef PRACH_DEBUG - LOG_I( PHY, "high speed prach : NCS_config %"PRIu8"\n", zeroCorrelationZoneConfig ); -#endif - - AssertFatal(zeroCorrelationZoneConfig<=14, - "FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); - NCS = NCS_restricted[zeroCorrelationZoneConfig]; - fill_du(prach_fmt); - - num_preambles = 64; // compute ZC sequence for 64 possible roots - // find first non-zero shift root (stored in preamble_offset) - not_found = 1; - preamble_offset = 0; - - while (not_found == 1) { - // current root depending on rootSequenceIndex - int index = (rootSequenceIndex + preamble_offset) % N_ZC; - - if (prach_fmt<4) { - // prach_root_sequence_map points to prach_root_sequence_map0_3 - DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); - } else { - // prach_root_sequence_map points to prach_root_sequence_map4 - DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); - } - - u = prach_root_sequence_map[index]; - - uint16_t n_group_ra = 0; - - if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { - n_shift_ra = du[u]/NCS; - d_start = (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = N_ZC/d_start; - n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); - } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { - n_shift_ra = (N_ZC - (du[u]<<1))/NCS; - d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = du[u]/d_start; - n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); - } else { - n_shift_ra = 0; - n_shift_ra_bar = 0; - } - - // This is the number of cyclic shifts for the current root u - numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; - - // skip to next root and recompute parameters if numshift==0 - if (numshift>0) - not_found = 0; - else - preamble_offset++; - } - } - -#ifdef PRACH_DEBUG - - if (NCS>0) - LOG_I( PHY, "Initializing %u preambles for PRACH (NCS_config %"PRIu8", NCS %u, N_ZC/NCS %u)\n", - num_preambles, zeroCorrelationZoneConfig, NCS, N_ZC/NCS ); - -#endif - - for (i=0; i<num_preambles; i++) { - int index = (rootSequenceIndex+i+preamble_offset) % N_ZC; - - if (prach_fmt<4) { - // prach_root_sequence_map points to prach_root_sequence_map0_3 - DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); - } else { - // prach_root_sequence_map points to prach_root_sequence_map4 - DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); - } - - u = prach_root_sequence_map[index]; - - inv_u = ZC_inv[u]; // multiplicative inverse of u - - - // X_u[0] stores the first ZC sequence where the root u has a non-zero number of shifts - // for the unrestricted case X_u[0] is the first root indicated by the rootSequenceIndex - - for (k=0; k<N_ZC; k++) { - // 420 is the multiplicative inverse of 2 (required since ru is exp[j 2\pi n]) - X_u[i][k] = ((uint32_t*)ru)[(((k*(1+(inv_u*k)))%N_ZC)*420)%N_ZC]; - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_OUT); - -} diff --git a/openair1/PHY/LTE_TRANSPORT/prach.h b/openair1/PHY/LTE_TRANSPORT/prach.h deleted file mode 100644 index f135af6d811b5187a2fe5d4892bdce7b7ff88b7b..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_TRANSPORT/prach.h +++ /dev/null @@ -1,35 +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 - */ - -short __attribute__((aligned(16))) X_u839[4][2*839] = {{25792,20209,24697,21533,21208,24977,14453,29407,3673,32560,-10603,31004,-25018,21161,-32697,2145,-25717,-20307,-2330,-32685,24778,-21441,31178,10078,4403,32469,-28990,15273,-22038,-24250,20546,-25526,26673,19030,-20065,25905,-22930,-23408,28086,-16877,6820,32049,-31985,-7121,22218,-24084,6580,32099,-28459,-16242,31873,-7599,-20642,25448,4038,-32518,10834,30923,-21115,-25058,26955,18629,-29699,-13845,30607,11698,-30291,-12497,28519,16134,-24291,-21993,16188,28488,-3308,-32600,-13118,30026,27959,-17087,-32353,-5193,18679,26921,9552,-31344,-31534,8904,22308,24000,14122,-29568,-32314,-5435,490,32763,32605,-3247,-2819,-32646,-32758,-798,-7539,31887,28149,16771,26458,-19330,-4283,-32487,-29271,-14729,-30052,13061,-12213,30405,9669,31307,25331,20784,32111,6520,32182,-6160,29046,-15165,25563,-20499,23450,-22887,23450,-22887,25563,-20499,29046,-15165,32182,-6160,32111,6520,25331,20784,9669,31307,-12213,30405,-30052,13061,-29271,-14729,-4283,-32487,26458,-19330,28149,16771,-7539,31887,-32758,-798,-2819,-32646,32605,-3247,490,32763,-32314,-5435,14122,-29568,22308,24000,-31534,8904,9552,-31344,18679,26921,-32353,-5193,27959,-17087,-13118,30026,-3308,-32600,16188,28488,-24291,-21993,28519,16134,-30291,-12497,30607,11698,-29699,-13845,26955,18629,-21115,-25058,10834,30923,4038,-32518,-20642,25448,31873,-7599,-28459,-16242,6580,32099,22218,-24084,-31985,-7121,6820,32049,28086,-16877,-22930,-23408,-20065,25905,26673,19030,20546,-25526,-22038,-24250,-28990,15273,4403,32469,31178,10078,24778,-21441,-2330,-32685,-25717,-20307,-32697,2145,-25018,21161,-10603,31004,3673,32560,14453,29407,21208,24977,24697,21533,25792,20209,24858,21348,21579,24657,15110,29074,4646,32435,-9435,31379,-24042,22263,-32540,3855,-26887,-18731,-4526,-32454,23104,-23235,31902,7479,7299,31943,-27368,18019,-24455,-21810,17555,-27668,28757,15705,-16614,28243,-25868,-20114,25409,-20690,11526,30672,-32705,-2024,17967,-27402,11984,30496,-30904,-10893,29902,-13399,-15328,28960,-2574,-32666,17034,27991,-26018,-19919,30428,12155,-32088,-6641,32509,4099,-32428,-4708,31663,8431,-29160,-14947,23191,23148,-12099,-30452,-4161,32501,21855,-24414,-32445,4585,25942,20016,-614,-32762,-27095,18426,28874,15490,3551,-32575,-32251,5797,11756,30585,29379,-14509,-14344,-29461,-30780,11238,4889,32400,32409,4828,16929,-28055,-16719,-28181,-32719,-1779,-22129,24166,1471,32733,21946,24331,31786,7956,31756,-8076,26166,-19724,19180,-26567,13454,-29878,10253,-31122,10020,-31198,12779,-30173,18172,-27267,25096,-21068,31140,-10196,32333,5313,24207,22082,5131,32362,-18881,26780,-32641,2879,-20927,-25215,11870,-30542,32741,-1288,11296,30758,-27635,17607,-20737,-25371,24938,-21255,19279,26494,-29435,14398,-5979,-32218,32205,6038,-19871,26054,-11412,-30716,31253,9845,-28640,15920,11181,-30801,8727,31583,-23278,-23062,30694,11469,-32751,-1043,32135,-6401,-31024,10544,30651,-11585,-31326,9610,32461,-4465,-32525,-3978,29103,15056,-19577,-26277,2940,32634,17347,-27799,-31600,8668,27501,17813,-1840,-32716,-27232,18223,28023,16981,6700,-32075,-32747,1165,5857,32239,31929,-7360,-5737,-32261,-32755,920,-7061,31997,27765,17399,27568,-17711,-1105,-32749,-27026,-18529,-31846,7717,-18275,27197,1716,32721,18477,27060,28397,16348,32292,5555,32650,-2758,31815,-7838,31289,-9729,31631,-8550,32493,-4222,32593,3368,29750,13733,21394,24818,6098,32194,-13790,29724,-29953,13286,-30196,-12724,-8373,-31680,22398,-23917,31396,9375,2451,32675,-30863,11008,-16082,-28550,27300,-18122,17451,27732,-29647,13955,-7181,-31971,32617,3123,-15975,28609,-17140,-27928,32711,1900,-22666,23663,-123,-32767,20450,25601,-31064,-10429,32390,-4951,-28275,16560,22576,-23748,-17866,27468,15436,-28904,-15760,28728,18780,-26851,-23875,22443,29487,-14289,-32726,1655,29541,14177,-16508,-28306,-5375,32323,26745,-18931,-31567,-8787,10137,31159,22754,-23579,-30475,-12042,-2697,32655,32553,-3735,-6941,-32024,-32011,7000,3916,32532,32679,2390,11641,-30630,-23959,-22354,-30945,10776,-8016,31771,19674,26202,32477,4342,27700,-17504,13005,-30076,-3063,-32624,-15653,-28787,-23621,-22710,-27831,-17296,-29594,-14067,-29802,-13623,-28580,-16029,-25254,-20879,-18579,-26991,-7420,-31916,7896,-31802,23790,-22533,32629,-3002,25640,20402,1226,32744,-26092,19821,-30100,-12950,-369,-32765,30984,-10661,17243,27862,-25487,20593,-21302,-24899,26312,-19527,14892,29187,-32062,6760,5010,-32382,26815,18830,-30149,12836,8134,-31742,17658,27601,-31501,-9023,30821,-11124,-21021,25135,8609,-31616,2206,32692,-9787,-31272,14011,29620,-15220,-29019,13566,29826,-8846,-31551,736,32758,10486,-31044,-22843,23492,31695,-8313,-30384,-12270,14232,29514,12326,-30361,-31726,8193,23364,22973,10718,-30965,-32765,429,8490,31647,30001,-13175,-14783,-29243,-29853,13510,9199,31449,32731,-1534,9317,-31415,-24617,-21626,-31103,10312,-9904,31234,16824,28117,31466,9140,30563,-11814,19772,-26130,6219,-32172,-5496,-32303,-13678,-29776,-18377,-27130,-20162,-25830,-19379,-26423,-15868,-28669,-9082,-31484,1349,-32740,14563,-29353,27163,-18326,32760,674,24372,21901,981,32752,-25176,20973,-31216,-9963,-5254,-32344,28212,-16667,23705,22621,-18071,27333,-28699,-15814,16294,-28429,26385,19428,-24536,21717,-13231,-29978,32765,-307,-15545,28845,-15002,-29132,31957,7240,-27896,17191,10950,-30884,7777,31830,-21672,-24577,29325,14618,-32272,-5677,32762,-553,-32568,3612,32580,-3491,-32767,184,32159,6279,-28933,-15382,20831,25292,-6461,-32124,-12441,30313,28816,-15599,-31432,-9259,12892,30123,17762,-27536,-32671,-2513,10370,31082,26602,-19131,-24125,-22174,-19478,26349,26530,19230,21487,-24739,-20355,-25679,-30337,12383,245,32766,29215,14837,28336,-16455,4768,-32419,-19968,-25981,-32037,-6881,-30244,12610,-20259,25754,-8254,31710,1961,32708,8963,31517,12666,30219,13342,29927,11065,30841,5616,32282,-3186,32611,-14674,29297,-26240,19625,-32661,2635,-27435,-17917,-7659,-31860,18980,-26710,32766,-62,16401,28366,-19081,26638,-31362,-9494,2084,-32701,32688,-2269,3429,32587,-32737,1410,3794,-32547,30518,11927,-21764,24495,-12554,-30267,32372,5071,-23536,22798,-859,-32756,22487,23832,-32229,-5919,30736,-11355,-23018,23321,13900,-29673,-6340,32147,1594,-32729,0,32767,1594,-32729,-6340,32147,13900,-29673,-23018,23321,30736,-11355,-32229,-5919,22487,23832,-859,-32756,-23536,22798,32372,5071,-12554,-30267,-21764,24495,30518,11927,3794,-32547,-32737,1410,3429,32587,32688,-2269,2084,-32701,-31362,-9494,-19081,26638,16401,28366,32766,-62,18980,-26710,-7659,-31860,-27435,-17917,-32661,2635,-26240,19625,-14674,29297,-3186,32611,5616,32282,11065,30841,13342,29927,12666,30219,8963,31517,1961,32708,-8254,31710,-20259,25754,-30244,12610,-32037,-6881,-19968,-25981,4768,-32419,28336,-16455,29215,14837,245,32766,-30337,12383,-20355,-25679,21487,-24739,26530,19230,-19478,26349,-24125,-22174,26602,-19131,10370,31082,-32671,-2513,17762,-27536,12892,30123,-31432,-9259,28816,-15599,-12441,30313,-6461,-32124,20831,25292,-28933,-15382,32159,6279,-32767,184,32580,-3491,-32568,3612,32762,-553,-32272,-5677,29325,14618,-21672,-24577,7777,31830,10950,-30884,-27896,17191,31957,7240,-15002,-29132,-15545,28845,32765,-307,-13231,-29978,-24536,21717,26385,19428,16294,-28429,-28699,-15814,-18071,27333,23705,22621,28212,-16667,-5254,-32344,-31216,-9963,-25176,20973,981,32752,24372,21901,32760,674,27163,-18326,14563,-29353,1349,-32740,-9082,-31484,-15868,-28669,-19379,-26423,-20162,-25830,-18377,-27130,-13678,-29776,-5496,-32303,6219,-32172,19772,-26130,30563,-11814,31466,9140,16824,28117,-9904,31234,-31103,10312,-24617,-21626,9317,-31415,32731,-1534,9199,31449,-29853,13510,-14783,-29243,30001,-13175,8490,31647,-32765,429,10718,-30965,23364,22973,-31726,8193,12326,-30361,14232,29514,-30384,-12270,31695,-8313,-22843,23492,10486,-31044,736,32758,-8846,-31551,13566,29826,-15220,-29019,14011,29620,-9787,-31272,2206,32692,8609,-31616,-21021,25135,30821,-11124,-31501,-9023,17658,27601,8134,-31742,-30149,12836,26815,18830,5010,-32382,-32062,6760,14892,29187,26312,-19527,-21302,-24899,-25487,20593,17243,27862,30984,-10661,-369,-32765,-30100,-12950,-26092,19821,1226,32744,25640,20402,32629,-3002,23790,-22533,7896,-31802,-7420,-31916,-18579,-26991,-25254,-20879,-28580,-16029,-29802,-13623,-29594,-14067,-27831,-17296,-23621,-22710,-15653,-28787,-3063,-32624,13005,-30076,27700,-17504,32477,4342,19674,26202,-8016,31771,-30945,10776,-23959,-22354,11641,-30630,32679,2390,3916,32532,-32011,7000,-6941,-32024,32553,-3735,-2697,32655,-30475,-12042,22754,-23579,10137,31159,-31567,-8787,26745,-18931,-5375,32323,-16508,-28306,29541,14177,-32726,1655,29487,-14289,-23875,22443,18780,-26851,-15760,28728,15436,-28904,-17866,27468,22576,-23748,-28275,16560,32390,-4951,-31064,-10429,20450,25601,-123,-32767,-22666,23663,32711,1900,-17140,-27928,-15975,28609,32617,3123,-7181,-31971,-29647,13955,17451,27732,27300,-18122,-16082,-28550,-30863,11008,2451,32675,31396,9375,22398,-23917,-8373,-31680,-30196,-12724,-29953,13286,-13790,29724,6098,32194,21394,24818,29750,13733,32593,3368,32493,-4222,31631,-8550,31289,-9729,31815,-7838,32650,-2758,32292,5555,28397,16348,18477,27060,1716,32721,-18275,27197,-31846,7717,-27026,-18529,-1105,-32749,27568,-17711,27765,17399,-7061,31997,-32755,920,-5737,-32261,31929,-7360,5857,32239,-32747,1165,6700,-32075,28023,16981,-27232,18223,-1840,-32716,27501,17813,-31600,8668,17347,-27799,2940,32634,-19577,-26277,29103,15056,-32525,-3978,32461,-4465,-31326,9610,30651,-11585,-31024,10544,32135,-6401,-32751,-1043,30694,11469,-23278,-23062,8727,31583,11181,-30801,-28640,15920,31253,9845,-11412,-30716,-19871,26054,32205,6038,-5979,-32218,-29435,14398,19279,26494,24938,-21255,-20737,-25371,-27635,17607,11296,30758,32741,-1288,11870,-30542,-20927,-25215,-32641,2879,-18881,26780,5131,32362,24207,22082,32333,5313,31140,-10196,25096,-21068,18172,-27267,12779,-30173,10020,-31198,10253,-31122,13454,-29878,19180,-26567,26166,-19724,31756,-8076,31786,7956,21946,24331,1471,32733,-22129,24166,-32719,-1779,-16719,-28181,16929,-28055,32409,4828,4889,32400,-30780,11238,-14344,-29461,29379,-14509,11756,30585,-32251,5797,3551,-32575,28874,15490,-27095,18426,-614,-32762,25942,20016,-32445,4585,21855,-24414,-4161,32501,-12099,-30452,23191,23148,-29160,-14947,31663,8431,-32428,-4708,32509,4099,-32088,-6641,30428,12155,-26018,-19919,17034,27991,-2574,-32666,-15328,28960,29902,-13399,-30904,-10893,11984,30496,17967,-27402,-32705,-2024,11526,30672,25409,-20690,-25868,-20114,-16614,28243,28757,15705,17555,-27668,-24455,-21810,-27368,18019,7299,31943,31902,7479,23104,-23235,-4526,-32454,-26887,-18731,-32540,3855,-24042,22263,-9435,31379,4646,32435,15110,29074,21579,24657,24858,21348}, - {25792,-20210,24858,-21349,21579,-24658,15110,-29075,4646,-32436,-9435,-31380,-24042,-22264,-32540,-3856,-26887,18730,-4526,32453,23104,23234,31902,-7480,7299,-31944,-27368,-18020,-24455,21809,17555,27667,28757,-15706,-16614,-28244,-25868,20113,25409,20689,11526,-30673,-32705,2023,17967,27401,11984,-30497,-30904,10892,29902,13398,-15328,-28961,-2574,32665,17034,-27992,-26018,19918,30428,-12156,-32088,6640,32509,-4100,-32428,4707,31663,-8432,-29160,14946,23191,-23149,-12099,30451,-4161,-32502,21855,24413,-32445,-4586,25942,-20017,-614,32761,-27095,-18427,28874,-15491,3551,32574,-32251,-5798,11756,-30586,29379,14508,-14344,29460,-30780,-11239,4889,-32401,32409,-4829,16929,28054,-16719,28180,-32719,1778,-22129,-24167,1471,-32734,21946,-24332,31786,-7957,31756,8075,26166,19723,19180,26566,13454,29877,10253,31121,10020,31197,12779,30172,18172,27266,25096,21067,31140,10195,32333,-5314,24207,-22083,5131,-32363,-18881,-26781,-32641,-2880,-20927,25214,11870,30541,32741,1287,11296,-30759,-27635,-17608,-20737,25370,24938,21254,19279,-26495,-29435,-14399,-5979,32217,32205,-6039,-19871,-26055,-11412,30715,31253,-9846,-28640,-15921,11181,30800,8727,-31584,-23278,23061,30694,-11470,-32751,1042,32135,6400,-31024,-10545,30651,11584,-31326,-9611,32461,4464,-32525,3977,29103,-15057,-19577,26276,2940,-32635,17347,27798,-31600,-8669,27501,-17814,-1840,32715,-27232,-18224,28023,-16982,6700,32074,-32747,-1166,5857,-32240,31929,7359,-5737,32260,-32755,-921,-7061,-31998,27765,-17400,27568,17710,-1105,32748,-27026,18528,-31846,-7718,-18275,-27198,1716,-32722,18477,-27061,28397,-16349,32292,-5556,32650,2757,31815,7837,31289,9728,31631,8549,32493,4221,32593,-3369,29750,-13734,21394,-24819,6098,-32195,-13790,-29725,-29953,-13287,-30196,12723,-8373,31679,22398,23916,31396,-9376,2451,-32676,-30863,-11009,-16082,28549,27300,18121,17451,-27733,-29647,-13956,-7181,31970,32617,-3124,-15975,-28610,-17140,27927,32711,-1901,-22666,-23664,-123,32766,20450,-25602,-31064,10428,32390,4950,-28275,-16561,22576,23747,-17866,-27469,15436,28903,-15760,-28729,18780,26850,-23875,-22444,29487,14288,-32726,-1656,29541,-14178,-16508,28305,-5375,-32324,26745,18930,-31567,8786,10137,-31160,22754,23578,-30475,12041,-2697,-32656,32553,3734,-6941,32023,-32011,-7001,3916,-32533,32679,-2391,11641,30629,-23959,22353,-30945,-10777,-8016,-31772,19674,-26203,32477,-4343,27700,17503,13005,30075,-3063,32623,-15653,28786,-23621,22709,-27831,17295,-29594,14066,-29802,13622,-28580,16028,-25254,20878,-18579,26990,-7420,31915,7896,31801,23790,22532,32629,3001,25640,-20403,1226,-32745,-26092,-19822,-30100,12949,-369,32764,30984,10660,17243,-27863,-25487,-20594,-21302,24898,26312,19526,14892,-29188,-32062,-6761,5010,32381,26815,-18831,-30149,-12837,8134,31741,17658,-27602,-31501,9022,30821,11123,-21021,-25136,8609,31615,2206,-32693,-9787,31271,14011,-29621,-15220,29018,13566,-29827,-8846,31550,736,-32759,10486,31043,-22843,-23493,31695,8312,-30384,12269,14232,-29515,12326,30360,-31726,-8194,23364,-22974,10718,30964,-32765,-430,8490,-31648,30001,13174,-14783,29242,-29853,-13511,9199,-31450,32731,1533,9317,31414,-24617,21625,-31103,-10313,-9904,-31235,16824,-28118,31466,-9141,30563,11813,19772,26129,6219,32171,-5496,32302,-13678,29775,-18377,27129,-20162,25829,-19379,26422,-15868,28668,-9082,31483,1349,32739,14563,29352,27163,18325,32760,-675,24372,-21902,981,-32753,-25176,-20974,-31216,9962,-5254,32343,28212,16666,23705,-22622,-18071,-27334,-28699,15813,16294,28428,26385,-19429,-24536,-21718,-13231,29977,32765,306,-15545,-28846,-15002,29131,31957,-7241,-27896,-17192,10950,30883,7777,-31831,-21672,24576,29325,-14619,-32272,5676,32762,552,-32568,-3613,32580,3490,-32767,-185,32159,-6280,-28933,15381,20831,-25293,-6461,32123,-12441,-30314,28816,15598,-31432,9258,12892,-30124,17762,27535,-32671,2512,10370,-31083,26602,19130,-24125,22173,-19478,-26350,26530,-19231,21487,24738,-20355,25678,-30337,-12384,245,-32767,29215,-14838,28336,16454,4768,32418,-19968,25980,-32037,6880,-30244,-12611,-20259,-25755,-8254,-31711,1961,-32709,8963,-31518,12666,-30220,13342,-29928,11065,-30842,5616,-32283,-3186,-32612,-14674,-29298,-26240,-19626,-32661,-2636,-27435,17916,-7659,31859,18980,26709,32766,61,16401,-28367,-19081,-26639,-31362,9493,2084,32700,32688,2268,3429,-32588,-32737,-1411,3794,32546,30518,-11928,-21764,-24496,-12554,30266,32372,-5072,-23536,-22799,-859,32755,22487,-23833,-32229,5918,30736,11354,-23018,-23322,13900,29672,-6340,-32148,1594,32728,-1,-32767,1594,32728,-6340,-32148,13900,29672,-23018,-23322,30736,11354,-32229,5918,22487,-23833,-859,32755,-23536,-22799,32372,-5072,-12554,30266,-21764,-24496,30518,-11928,3794,32546,-32737,-1411,3429,-32588,32688,2268,2084,32700,-31362,9493,-19081,-26639,16401,-28367,32766,61,18980,26709,-7659,31859,-27435,17916,-32661,-2636,-26240,-19626,-14674,-29298,-3186,-32612,5616,-32283,11065,-30842,13342,-29928,12666,-30220,8963,-31518,1961,-32709,-8254,-31711,-20259,-25755,-30244,-12611,-32037,6880,-19968,25980,4768,32418,28336,16454,29215,-14838,245,-32767,-30337,-12384,-20355,25678,21487,24738,26530,-19231,-19478,-26350,-24125,22173,26602,19130,10370,-31083,-32671,2512,17762,27535,12892,-30124,-31432,9258,28816,15598,-12441,-30314,-6461,32123,20831,-25293,-28933,15381,32159,-6280,-32767,-185,32580,3490,-32568,-3613,32762,552,-32272,5676,29325,-14619,-21672,24576,7777,-31831,10950,30883,-27896,-17192,31957,-7241,-15002,29131,-15545,-28846,32765,306,-13231,29977,-24536,-21718,26385,-19429,16294,28428,-28699,15813,-18071,-27334,23705,-22622,28212,16666,-5254,32343,-31216,9962,-25176,-20974,981,-32753,24372,-21902,32760,-675,27163,18325,14563,29352,1349,32739,-9082,31483,-15868,28668,-19379,26422,-20162,25829,-18377,27129,-13678,29775,-5496,32302,6219,32171,19772,26129,30563,11813,31466,-9141,16824,-28118,-9904,-31235,-31103,-10313,-24617,21625,9317,31414,32731,1533,9199,-31450,-29853,-13511,-14783,29242,30001,13174,8490,-31648,-32765,-430,10718,30964,23364,-22974,-31726,-8194,12326,30360,14232,-29515,-30384,12269,31695,8312,-22843,-23493,10486,31043,736,-32759,-8846,31550,13566,-29827,-15220,29018,14011,-29621,-9787,31271,2206,-32693,8609,31615,-21021,-25136,30821,11123,-31501,9022,17658,-27602,8134,31741,-30149,-12837,26815,-18831,5010,32381,-32062,-6761,14892,-29188,26312,19526,-21302,24898,-25487,-20594,17243,-27863,30984,10660,-369,32764,-30100,12949,-26092,-19822,1226,-32745,25640,-20403,32629,3001,23790,22532,7896,31801,-7420,31915,-18579,26990,-25254,20878,-28580,16028,-29802,13622,-29594,14066,-27831,17295,-23621,22709,-15653,28786,-3063,32623,13005,30075,27700,17503,32477,-4343,19674,-26203,-8016,-31772,-30945,-10777,-23959,22353,11641,30629,32679,-2391,3916,-32533,-32011,-7001,-6941,32023,32553,3734,-2697,-32656,-30475,12041,22754,23578,10137,-31160,-31567,8786,26745,18930,-5375,-32324,-16508,28305,29541,-14178,-32726,-1656,29487,14288,-23875,-22444,18780,26850,-15760,-28729,15436,28903,-17866,-27469,22576,23747,-28275,-16561,32390,4950,-31064,10428,20450,-25602,-123,32766,-22666,-23664,32711,-1901,-17140,27927,-15975,-28610,32617,-3124,-7181,31970,-29647,-13956,17451,-27733,27300,18121,-16082,28549,-30863,-11009,2451,-32676,31396,-9376,22398,23916,-8373,31679,-30196,12723,-29953,-13287,-13790,-29725,6098,-32195,21394,-24819,29750,-13734,32593,-3369,32493,4221,31631,8549,31289,9728,31815,7837,32650,2757,32292,-5556,28397,-16349,18477,-27061,1716,-32722,-18275,-27198,-31846,-7718,-27026,18528,-1105,32748,27568,17710,27765,-17400,-7061,-31998,-32755,-921,-5737,32260,31929,7359,5857,-32240,-32747,-1166,6700,32074,28023,-16982,-27232,-18224,-1840,32715,27501,-17814,-31600,-8669,17347,27798,2940,-32635,-19577,26276,29103,-15057,-32525,3977,32461,4464,-31326,-9611,30651,11584,-31024,-10545,32135,6400,-32751,1042,30694,-11470,-23278,23061,8727,-31584,11181,30800,-28640,-15921,31253,-9846,-11412,30715,-19871,-26055,32205,-6039,-5979,32217,-29435,-14399,19279,-26495,24938,21254,-20737,25370,-27635,-17608,11296,-30759,32741,1287,11870,30541,-20927,25214,-32641,-2880,-18881,-26781,5131,-32363,24207,-22083,32333,-5314,31140,10195,25096,21067,18172,27266,12779,30172,10020,31197,10253,31121,13454,29877,19180,26566,26166,19723,31756,8075,31786,-7957,21946,-24332,1471,-32734,-22129,-24167,-32719,1778,-16719,28180,16929,28054,32409,-4829,4889,-32401,-30780,-11239,-14344,29460,29379,14508,11756,-30586,-32251,-5798,3551,32574,28874,-15491,-27095,-18427,-614,32761,25942,-20017,-32445,-4586,21855,24413,-4161,-32502,-12099,30451,23191,-23149,-29160,14946,31663,-8432,-32428,4707,32509,-4100,-32088,6640,30428,-12156,-26018,19918,17034,-27992,-2574,32665,-15328,-28961,29902,13398,-30904,10892,11984,-30497,17967,27401,-32705,2023,11526,-30673,25409,20689,-25868,20113,-16614,-28244,28757,-15706,17555,27667,-24455,21809,-27368,-18020,7299,-31944,31902,-7480,23104,23234,-4526,32453,-26887,18730,-32540,-3856,-24042,-22264,-9435,-31380,4646,-32436,15110,-29075,21579,-24658,24858,-21349,25792,-20210,24697,-21534,21208,-24978,14453,-29408,3673,-32561,-10603,-31005,-25018,-21162,-32697,-2146,-25717,20306,-2330,32684,24778,21440,31178,-10079,4403,-32470,-28990,-15274,-22038,24249,20546,25525,26673,-19031,-20065,-25906,-22930,23407,28086,16876,6820,-32050,-31985,7120,22218,24083,6580,-32100,-28459,16241,31873,7598,-20642,-25449,4038,32517,10834,-30924,-21115,25057,26955,-18630,-29699,13844,30607,-11699,-30291,12496,28519,-16135,-24291,21992,16188,-28489,-3308,32599,-13118,-30027,27959,17086,-32353,5192,18679,-26922,9552,31343,-31534,-8905,22308,-24001,14122,29567,-32314,5434,490,-32764,32605,3246,-2819,32645,-32758,797,-7539,-31888,28149,-16772,26458,19329,-4283,32486,-29271,14728,-30052,-13062,-12213,-30406,9669,-31308,25331,-20785,32111,-6521,32182,6159,29046,15164,25563,20498,23450,22886,23450,22886,25563,20498,29046,15164,32182,6159,32111,-6521,25331,-20785,9669,-31308,-12213,-30406,-30052,-13062,-29271,14728,-4283,32486,26458,19329,28149,-16772,-7539,-31888,-32758,797,-2819,32645,32605,3246,490,-32764,-32314,5434,14122,29567,22308,-24001,-31534,-8905,9552,31343,18679,-26922,-32353,5192,27959,17086,-13118,-30027,-3308,32599,16188,-28489,-24291,21992,28519,-16135,-30291,12496,30607,-11699,-29699,13844,26955,-18630,-21115,25057,10834,-30924,4038,32517,-20642,-25449,31873,7598,-28459,16241,6580,-32100,22218,24083,-31985,7120,6820,-32050,28086,16876,-22930,23407,-20065,-25906,26673,-19031,20546,25525,-22038,24249,-28990,-15274,4403,-32470,31178,-10079,24778,21440,-2330,32684,-25717,20306,-32697,-2146,-25018,-21162,-10603,-31005,3673,-32561,14453,-29408,21208,-24978,24697,-21534}, - {-4283,-32487,4889,32400,-6941,-32024,10370,31082,-15002,-29132,20450,25601,-26018,-19919,30607,11698,-32751,-1043,30821,-11124,-23536,22798,10718,-30965,5857,32239,-22038,-24250,31902,7479,-29953,13286,14563,-29353,8963,31517,-28580,-16029,31140,-10196,-12213,30405,-16719,-28181,32679,2390,-19478,26349,-13231,-29978,32711,1900,-15328,28960,-21115,-25058,30651,-11585,2206,32692,-32229,-5919,12326,-30361,28023,16981,-20065,25905,-24455,-21810,22398,-23917,24372,21901,-20259,25754,-27831,-17296,12779,-30173,32111,6520,1471,32733,-30945,10776,-20355,-25679,16294,-28429,32617,3123,11984,30496,-20642,25448,-32525,-3978,-15220,-29019,13900,-29673,31695,-8313,27501,17813,6820,32049,-16614,28243,-30863,11008,-31216,-9963,-19968,-25981,-3063,-32624,13454,-29878,25563,-20499,31756,-8076,32477,4342,29215,14837,23705,22621,17451,27732,11526,30672,6580,32099,2940,32634,736,32758,0,32767,736,32758,2940,32634,6580,32099,11526,30672,17451,27732,23705,22621,29215,14837,32477,4342,31756,-8076,25563,-20499,13454,-29878,-3063,-32624,-19968,-25981,-31216,-9963,-30863,11008,-16614,28243,6820,32049,27501,17813,31695,-8313,13900,-29673,-15220,-29019,-32525,-3978,-20642,25448,11984,30496,32617,3123,16294,-28429,-20355,-25679,-30945,10776,1471,32733,32111,6520,12779,-30173,-27831,-17296,-20259,25754,24372,21901,22398,-23917,-24455,-21810,-20065,25905,28023,16981,12326,-30361,-32229,-5919,2206,32692,30651,-11585,-21115,-25058,-15328,28960,32711,1900,-13231,-29978,-19478,26349,32679,2390,-16719,-28181,-12213,30405,31140,-10196,-28580,-16029,8963,31517,14563,-29353,-29953,13286,31902,7479,-22038,-24250,5857,32239,10718,-30965,-23536,22798,30821,-11124,-32751,-1043,30607,11698,-26018,-19919,20450,25601,-15002,-29132,10370,31082,-6941,-32024,4889,32400,-4283,-32487,5131,32362,-7420,-31916,11065,30841,-15868,-28669,21394,24818,-26887,-18731,31178,10078,-32755,920,30001,-13175,-21764,24495,8134,-31742,8727,31583,-24291,-21993,32509,4099,-28275,16560,10950,-30884,12892,30123,-30475,-12042,29379,-14509,-7539,31887,-20927,-25215,32629,-3002,-14674,29297,-18377,-27130,32493,-4222,-9435,31379,-25717,-20307,27568,-17711,9199,31449,-32737,1410,5010,-32382,31253,9845,-13118,30026,-29160,-14947,15436,-28904,29325,14618,-12441,30313,-31567,-8787,3551,-32575,32605,-3247,11296,30758,-26092,19821,-27435,-17917,6219,-32172,31815,-7838,21579,24657,-10603,31004,-31846,7717,-24617,-21626,2084,-32701,26312,-19527,32205,6038,18679,26921,-4161,32501,-23875,22443,-32568,3612,-28933,-15382,-16508,-28306,-614,-32762,14122,-29568,24938,-21255,30984,-10661,32766,-62,31466,9140,28397,16348,24697,21533,21208,24977,18477,27060,16824,28117,16401,28366,17243,27862,19279,26494,22308,24000,25942,20016,29541,14177,32159,6279,32580,-3491,29487,-14289,21855,-24414,9552,-31344,-5979,-32218,-21302,-24899,-31362,-9494,-31103,10312,-18275,27197,3673,32560,24858,21348,32650,-2758,19772,-26130,-7659,-31860,-30100,-12950,-27635,17607,490,32763,28874,15490,26745,-18931,-6461,-32124,-32272,-5677,-15760,28728,23191,23148,27959,-17087,-11412,-30716,-32062,6760,3429,32587,32731,-1534,-1105,-32749,-32697,2145,4646,32435,31631,-8550,-13678,-29776,-26240,19625,25640,20402,11870,-30542,-32758,-798,11756,30585,22754,-23579,-31432,-9259,7777,31830,22576,-23748,-32428,-4708,16188,28488,11181,-30801,-30149,12836,30518,11927,-14783,-29243,-7061,31997,24778,-21441,-32540,3855,29750,13733,-19379,-26423,5616,32282,7896,-31802,-18881,26780,26458,-19330,-30780,11238,32553,-3735,-32671,-2513,31957,7240,-31064,-10429,30428,12155,-30291,-12497,30694,11469,-31501,-9023,32372,5071,-32765,429,31929,-7360,-28990,15273,23104,-23235,-13790,29724,1349,-32740,12666,30219,-25254,-20879,32333,5313,-30052,13061,16929,-28055,3916,32532,-24125,-22174,32765,-307,-22666,23663,-2574,-32666,26955,18629,-31024,10544,8609,-31616,22487,23832,-31726,8193,6700,-32075,26673,19030,-27368,18019,-8373,-31680,32760,674,-8254,31710,-29594,-14067,18172,-27267,25331,20784,-22129,24166,-23959,-22354,21487,-24739,26385,19428,-15975,28609,-30904,-10893,4038,-32518,32461,-4465,14011,29620,-23018,23321,-30384,-12270,-1840,-32716,28086,-16877,28757,15705,2451,32675,-25176,20973,-32037,-6881,-15653,-28787,10253,-31122,29046,-15165,31786,7956,19674,26202,245,32766,-18071,27333,-29647,13955,-32705,-2024,-28459,-16242,-19577,-26277,-8846,-31551,1594,-32729,10486,-31044,17347,-27799,22218,-24084,25409,-20690,27300,-18122,28212,-16667,28336,-16455,27700,-17504,26166,-19724,23450,-22887,19180,-26567,13005,-30076,4768,-32419,-5254,-32344,-16082,-28550,-25868,-20114,-31985,-7121,-31600,8668,-22843,23492,-6340,32147,13566,29826,29103,15056,31873,-7599,17967,-27402,-7181,-31971,-28699,-15814,-30337,12383,-8016,31771,21946,24331,32182,-6160,10020,-31198,-23621,-22710,-30244,12610,981,32752,31396,9375,17555,-27668,-22930,-23408,-27232,18223,14232,29514,30736,-11355,-9787,-31272,-31326,9610,10834,30923,29902,-13399,-17140,-27928,-24536,21717,26530,19230,11641,-30630,-32719,-1779,9669,31307,25096,-21068,-29802,-13623,1961,32708,27163,-18326,-30196,-12724,7299,31943,20546,-25526,-32747,1165,23364,22973,-859,-32756,-21021,25135,32135,-6401,-29699,-13845,17034,27991,-123,-32767,-15545,28845,26602,-19131,-32011,7000,32409,4828,-29271,-14729,24207,22082,-18579,-26991,13342,29927,-9082,-31484,6098,32194,-4526,-32454,4403,32469,-5737,-32261,8490,31647,-12554,-30267,17658,27601,-23278,-23062,28519,16134,-32088,-6641,32390,-4951,-27896,17191,17762,-27536,-2697,32655,-14344,-29461,28149,16771,-32641,2879,23790,-22533,-3186,32611,-20162,-25830,32593,3368,-24042,22263,-2330,-32685,27765,17399,-29853,13510,3794,-32547,26815,18830,-28640,15920,-3308,-32600,31663,8431,-17866,27468,-21672,-24577,28816,-15599,10137,31159,-32251,5797,-2819,-32646,32741,-1288,1226,32744,-32661,2635,-5496,-32303,31289,-9729,15110,29074,-25018,21161,-27026,-18529,9317,-31415,32688,-2269,14892,29187,-19871,26054,-32353,-5193,-12099,-30452,18780,-26851,32762,-553,20831,25292,-5375,32323,-27095,18426,-32314,-5435,-20737,-25371,-369,-32765,18980,-26710,30563,-11814,32292,5555,25792,20209,14453,29407,1716,32721,-9904,31234,-19081,26638,-25487,20593,-29435,14398,-31534,8904,-32445,4585,-32726,1655,-32767,184,-32767,184,-32726,1655,-32445,4585,-31534,8904,-29435,14398,-25487,20593,-19081,26638,-9904,31234,1716,32721,14453,29407,25792,20209,32292,5555,30563,-11814,18980,-26710,-369,-32765,-20737,-25371,-32314,-5435,-27095,18426,-5375,32323,20831,25292,32762,-553,18780,-26851,-12099,-30452,-32353,-5193,-19871,26054,14892,29187,32688,-2269,9317,-31415,-27026,-18529,-25018,21161,15110,29074,31289,-9729,-5496,-32303,-32661,2635,1226,32744,32741,-1288,-2819,-32646,-32251,5797,10137,31159,28816,-15599,-21672,-24577,-17866,27468,31663,8431,-3308,-32600,-28640,15920,26815,18830,3794,-32547,-29853,13510,27765,17399,-2330,-32685,-24042,22263,32593,3368,-20162,-25830,-3186,32611,23790,-22533,-32641,2879,28149,16771,-14344,-29461,-2697,32655,17762,-27536,-27896,17191,32390,-4951,-32088,-6641,28519,16134,-23278,-23062,17658,27601,-12554,-30267,8490,31647,-5737,-32261,4403,32469,-4526,-32454,6098,32194,-9082,-31484,13342,29927,-18579,-26991,24207,22082,-29271,-14729,32409,4828,-32011,7000,26602,-19131,-15545,28845,-123,-32767,17034,27991,-29699,-13845,32135,-6401,-21021,25135,-859,-32756,23364,22973,-32747,1165,20546,-25526,7299,31943,-30196,-12724,27163,-18326,1961,32708,-29802,-13623,25096,-21068,9669,31307,-32719,-1779,11641,-30630,26530,19230,-24536,21717,-17140,-27928,29902,-13399,10834,30923,-31326,9610,-9787,-31272,30736,-11355,14232,29514,-27232,18223,-22930,-23408,17555,-27668,31396,9375,981,32752,-30244,12610,-23621,-22710,10020,-31198,32182,-6160,21946,24331,-8016,31771,-30337,12383,-28699,-15814,-7181,-31971,17967,-27402,31873,-7599,29103,15056,13566,29826,-6340,32147,-22843,23492,-31600,8668,-31985,-7121,-25868,-20114,-16082,-28550,-5254,-32344,4768,-32419,13005,-30076,19180,-26567,23450,-22887,26166,-19724,27700,-17504,28336,-16455,28212,-16667,27300,-18122,25409,-20690,22218,-24084,17347,-27799,10486,-31044,1594,-32729,-8846,-31551,-19577,-26277,-28459,-16242,-32705,-2024,-29647,13955,-18071,27333,245,32766,19674,26202,31786,7956,29046,-15165,10253,-31122,-15653,-28787,-32037,-6881,-25176,20973,2451,32675,28757,15705,28086,-16877,-1840,-32716,-30384,-12270,-23018,23321,14011,29620,32461,-4465,4038,-32518,-30904,-10893,-15975,28609,26385,19428,21487,-24739,-23959,-22354,-22129,24166,25331,20784,18172,-27267,-29594,-14067,-8254,31710,32760,674,-8373,-31680,-27368,18019,26673,19030,6700,-32075,-31726,8193,22487,23832,8609,-31616,-31024,10544,26955,18629,-2574,-32666,-22666,23663,32765,-307,-24125,-22174,3916,32532,16929,-28055,-30052,13061,32333,5313,-25254,-20879,12666,30219,1349,-32740,-13790,29724,23104,-23235,-28990,15273,31929,-7360,-32765,429,32372,5071,-31501,-9023,30694,11469,-30291,-12497,30428,12155,-31064,-10429,31957,7240,-32671,-2513,32553,-3735,-30780,11238,26458,-19330,-18881,26780,7896,-31802,5616,32282,-19379,-26423,29750,13733,-32540,3855,24778,-21441,-7061,31997,-14783,-29243,30518,11927,-30149,12836,11181,-30801,16188,28488,-32428,-4708,22576,-23748,7777,31830,-31432,-9259,22754,-23579,11756,30585,-32758,-798,11870,-30542,25640,20402,-26240,19625,-13678,-29776,31631,-8550,4646,32435,-32697,2145,-1105,-32749,32731,-1534,3429,32587,-32062,6760,-11412,-30716,27959,-17087,23191,23148,-15760,28728,-32272,-5677,-6461,-32124,26745,-18931,28874,15490,490,32763,-27635,17607,-30100,-12950,-7659,-31860,19772,-26130,32650,-2758,24858,21348,3673,32560,-18275,27197,-31103,10312,-31362,-9494,-21302,-24899,-5979,-32218,9552,-31344,21855,-24414,29487,-14289,32580,-3491,32159,6279,29541,14177,25942,20016,22308,24000,19279,26494,17243,27862,16401,28366,16824,28117,18477,27060,21208,24977,24697,21533,28397,16348,31466,9140,32766,-62,30984,-10661,24938,-21255,14122,-29568,-614,-32762,-16508,-28306,-28933,-15382,-32568,3612,-23875,22443,-4161,32501,18679,26921,32205,6038,26312,-19527,2084,-32701,-24617,-21626,-31846,7717,-10603,31004,21579,24657,31815,-7838,6219,-32172,-27435,-17917,-26092,19821,11296,30758,32605,-3247,3551,-32575,-31567,-8787,-12441,30313,29325,14618,15436,-28904,-29160,-14947,-13118,30026,31253,9845,5010,-32382,-32737,1410,9199,31449,27568,-17711,-25717,-20307,-9435,31379,32493,-4222,-18377,-27130,-14674,29297,32629,-3002,-20927,-25215,-7539,31887,29379,-14509,-30475,-12042,12892,30123,10950,-30884,-28275,16560,32509,4099,-24291,-21993,8727,31583,8134,-31742,-21764,24495,30001,-13175,-32755,920,31178,10078,-26887,-18731,21394,24818,-15868,-28669,11065,30841,-7420,-31916,5131,32362}, - {-4283,32486,5131,-32363,-7420,31915,11065,-30842,-15868,28668,21394,-24819,-26887,18730,31178,-10079,-32755,-921,30001,13174,-21764,-24496,8134,31741,8727,-31584,-24291,21992,32509,-4100,-28275,-16561,10950,30883,12892,-30124,-30475,12041,29379,14508,-7539,-31888,-20927,25214,32629,3001,-14674,-29298,-18377,27129,32493,4221,-9435,-31380,-25717,20306,27568,17710,9199,-31450,-32737,-1411,5010,32381,31253,-9846,-13118,-30027,-29160,14946,15436,28903,29325,-14619,-12441,-30314,-31567,8786,3551,32574,32605,3246,11296,-30759,-26092,-19822,-27435,17916,6219,32171,31815,7837,21579,-24658,-10603,-31005,-31846,-7718,-24617,21625,2084,32700,26312,19526,32205,-6039,18679,-26922,-4161,-32502,-23875,-22444,-32568,-3613,-28933,15381,-16508,28305,-614,32761,14122,29567,24938,21254,30984,10660,32766,61,31466,-9141,28397,-16349,24697,-21534,21208,-24978,18477,-27061,16824,-28118,16401,-28367,17243,-27863,19279,-26495,22308,-24001,25942,-20017,29541,-14178,32159,-6280,32580,3490,29487,14288,21855,24413,9552,31343,-5979,32217,-21302,24898,-31362,9493,-31103,-10313,-18275,-27198,3673,-32561,24858,-21349,32650,2757,19772,26129,-7659,31859,-30100,12949,-27635,-17608,490,-32764,28874,-15491,26745,18930,-6461,32123,-32272,5676,-15760,-28729,23191,-23149,27959,17086,-11412,30715,-32062,-6761,3429,-32588,32731,1533,-1105,32748,-32697,-2146,4646,-32436,31631,8549,-13678,29775,-26240,-19626,25640,-20403,11870,30541,-32758,797,11756,-30586,22754,23578,-31432,9258,7777,-31831,22576,23747,-32428,4707,16188,-28489,11181,30800,-30149,-12837,30518,-11928,-14783,29242,-7061,-31998,24778,21440,-32540,-3856,29750,-13734,-19379,26422,5616,-32283,7896,31801,-18881,-26781,26458,19329,-30780,-11239,32553,3734,-32671,2512,31957,-7241,-31064,10428,30428,-12156,-30291,12496,30694,-11470,-31501,9022,32372,-5072,-32765,-430,31929,7359,-28990,-15274,23104,23234,-13790,-29725,1349,32739,12666,-30220,-25254,20878,32333,-5314,-30052,-13062,16929,28054,3916,-32533,-24125,22173,32765,306,-22666,-23664,-2574,32665,26955,-18630,-31024,-10545,8609,31615,22487,-23833,-31726,-8194,6700,32074,26673,-19031,-27368,-18020,-8373,31679,32760,-675,-8254,-31711,-29594,14066,18172,27266,25331,-20785,-22129,-24167,-23959,22353,21487,24738,26385,-19429,-15975,-28610,-30904,10892,4038,32517,32461,4464,14011,-29621,-23018,-23322,-30384,12269,-1840,32715,28086,16876,28757,-15706,2451,-32676,-25176,-20974,-32037,6880,-15653,28786,10253,31121,29046,15164,31786,-7957,19674,-26203,245,-32767,-18071,-27334,-29647,-13956,-32705,2023,-28459,16241,-19577,26276,-8846,31550,1594,32728,10486,31043,17347,27798,22218,24083,25409,20689,27300,18121,28212,16666,28336,16454,27700,17503,26166,19723,23450,22886,19180,26566,13005,30075,4768,32418,-5254,32343,-16082,28549,-25868,20113,-31985,7120,-31600,-8669,-22843,-23493,-6340,-32148,13566,-29827,29103,-15057,31873,7598,17967,27401,-7181,31970,-28699,15813,-30337,-12384,-8016,-31772,21946,-24332,32182,6159,10020,31197,-23621,22709,-30244,-12611,981,-32753,31396,-9376,17555,27667,-22930,23407,-27232,-18224,14232,-29515,30736,11354,-9787,31271,-31326,-9611,10834,-30924,29902,13398,-17140,27927,-24536,-21718,26530,-19231,11641,30629,-32719,1778,9669,-31308,25096,21067,-29802,13622,1961,-32709,27163,18325,-30196,12723,7299,-31944,20546,25525,-32747,-1166,23364,-22974,-859,32755,-21021,-25136,32135,6400,-29699,13844,17034,-27992,-123,32766,-15545,-28846,26602,19130,-32011,-7001,32409,-4829,-29271,14728,24207,-22083,-18579,26990,13342,-29928,-9082,31483,6098,-32195,-4526,32453,4403,-32470,-5737,32260,8490,-31648,-12554,30266,17658,-27602,-23278,23061,28519,-16135,-32088,6640,32390,4950,-27896,-17192,17762,27535,-2697,-32656,-14344,29460,28149,-16772,-32641,-2880,23790,22532,-3186,-32612,-20162,25829,32593,-3369,-24042,-22264,-2330,32684,27765,-17400,-29853,-13511,3794,32546,26815,-18831,-28640,-15921,-3308,32599,31663,-8432,-17866,-27469,-21672,24576,28816,15598,10137,-31160,-32251,-5798,-2819,32645,32741,1287,1226,-32745,-32661,-2636,-5496,32302,31289,9728,15110,-29075,-25018,-21162,-27026,18528,9317,31414,32688,2268,14892,-29188,-19871,-26055,-32353,5192,-12099,30451,18780,26850,32762,552,20831,-25293,-5375,-32324,-27095,-18427,-32314,5434,-20737,25370,-369,32764,18980,26709,30563,11813,32292,-5556,25792,-20210,14453,-29408,1716,-32722,-9904,-31235,-19081,-26639,-25487,-20594,-29435,-14399,-31534,-8905,-32445,-4586,-32726,-1656,-32767,-185,-32767,-185,-32726,-1656,-32445,-4586,-31534,-8905,-29435,-14399,-25487,-20594,-19081,-26639,-9904,-31235,1716,-32722,14453,-29408,25792,-20210,32292,-5556,30563,11813,18980,26709,-369,32764,-20737,25370,-32314,5434,-27095,-18427,-5375,-32324,20831,-25293,32762,552,18780,26850,-12099,30451,-32353,5192,-19871,-26055,14892,-29188,32688,2268,9317,31414,-27026,18528,-25018,-21162,15110,-29075,31289,9728,-5496,32302,-32661,-2636,1226,-32745,32741,1287,-2819,32645,-32251,-5798,10137,-31160,28816,15598,-21672,24576,-17866,-27469,31663,-8432,-3308,32599,-28640,-15921,26815,-18831,3794,32546,-29853,-13511,27765,-17400,-2330,32684,-24042,-22264,32593,-3369,-20162,25829,-3186,-32612,23790,22532,-32641,-2880,28149,-16772,-14344,29460,-2697,-32656,17762,27535,-27896,-17192,32390,4950,-32088,6640,28519,-16135,-23278,23061,17658,-27602,-12554,30266,8490,-31648,-5737,32260,4403,-32470,-4526,32453,6098,-32195,-9082,31483,13342,-29928,-18579,26990,24207,-22083,-29271,14728,32409,-4829,-32011,-7001,26602,19130,-15545,-28846,-123,32766,17034,-27992,-29699,13844,32135,6400,-21021,-25136,-859,32755,23364,-22974,-32747,-1166,20546,25525,7299,-31944,-30196,12723,27163,18325,1961,-32709,-29802,13622,25096,21067,9669,-31308,-32719,1778,11641,30629,26530,-19231,-24536,-21718,-17140,27927,29902,13398,10834,-30924,-31326,-9611,-9787,31271,30736,11354,14232,-29515,-27232,-18224,-22930,23407,17555,27667,31396,-9376,981,-32753,-30244,-12611,-23621,22709,10020,31197,32182,6159,21946,-24332,-8016,-31772,-30337,-12384,-28699,15813,-7181,31970,17967,27401,31873,7598,29103,-15057,13566,-29827,-6340,-32148,-22843,-23493,-31600,-8669,-31985,7120,-25868,20113,-16082,28549,-5254,32343,4768,32418,13005,30075,19180,26566,23450,22886,26166,19723,27700,17503,28336,16454,28212,16666,27300,18121,25409,20689,22218,24083,17347,27798,10486,31043,1594,32728,-8846,31550,-19577,26276,-28459,16241,-32705,2023,-29647,-13956,-18071,-27334,245,-32767,19674,-26203,31786,-7957,29046,15164,10253,31121,-15653,28786,-32037,6880,-25176,-20974,2451,-32676,28757,-15706,28086,16876,-1840,32715,-30384,12269,-23018,-23322,14011,-29621,32461,4464,4038,32517,-30904,10892,-15975,-28610,26385,-19429,21487,24738,-23959,22353,-22129,-24167,25331,-20785,18172,27266,-29594,14066,-8254,-31711,32760,-675,-8373,31679,-27368,-18020,26673,-19031,6700,32074,-31726,-8194,22487,-23833,8609,31615,-31024,-10545,26955,-18630,-2574,32665,-22666,-23664,32765,306,-24125,22173,3916,-32533,16929,28054,-30052,-13062,32333,-5314,-25254,20878,12666,-30220,1349,32739,-13790,-29725,23104,23234,-28990,-15274,31929,7359,-32765,-430,32372,-5072,-31501,9022,30694,-11470,-30291,12496,30428,-12156,-31064,10428,31957,-7241,-32671,2512,32553,3734,-30780,-11239,26458,19329,-18881,-26781,7896,31801,5616,-32283,-19379,26422,29750,-13734,-32540,-3856,24778,21440,-7061,-31998,-14783,29242,30518,-11928,-30149,-12837,11181,30800,16188,-28489,-32428,4707,22576,23747,7777,-31831,-31432,9258,22754,23578,11756,-30586,-32758,797,11870,30541,25640,-20403,-26240,-19626,-13678,29775,31631,8549,4646,-32436,-32697,-2146,-1105,32748,32731,1533,3429,-32588,-32062,-6761,-11412,30715,27959,17086,23191,-23149,-15760,-28729,-32272,5676,-6461,32123,26745,18930,28874,-15491,490,-32764,-27635,-17608,-30100,12949,-7659,31859,19772,26129,32650,2757,24858,-21349,3673,-32561,-18275,-27198,-31103,-10313,-31362,9493,-21302,24898,-5979,32217,9552,31343,21855,24413,29487,14288,32580,3490,32159,-6280,29541,-14178,25942,-20017,22308,-24001,19279,-26495,17243,-27863,16401,-28367,16824,-28118,18477,-27061,21208,-24978,24697,-21534,28397,-16349,31466,-9141,32766,61,30984,10660,24938,21254,14122,29567,-614,32761,-16508,28305,-28933,15381,-32568,-3613,-23875,-22444,-4161,-32502,18679,-26922,32205,-6039,26312,19526,2084,32700,-24617,21625,-31846,-7718,-10603,-31005,21579,-24658,31815,7837,6219,32171,-27435,17916,-26092,-19822,11296,-30759,32605,3246,3551,32574,-31567,8786,-12441,-30314,29325,-14619,15436,28903,-29160,14946,-13118,-30027,31253,-9846,5010,32381,-32737,-1411,9199,-31450,27568,17710,-25717,20306,-9435,-31380,32493,4221,-18377,27129,-14674,-29298,32629,3001,-20927,25214,-7539,-31888,29379,14508,-30475,12041,12892,-30124,10950,30883,-28275,-16561,32509,-4100,-24291,21992,8727,-31584,8134,31741,-21764,-24496,30001,13174,-32755,-921,31178,-10079,-26887,18730,21394,-24819,-15868,28668,11065,-30842,-7420,31915,5131,-32363,-4283,32486,4889,-32401,-6941,32023,10370,-31083,-15002,29131,20450,-25602,-26018,19918,30607,-11699,-32751,1042,30821,11123,-23536,-22799,10718,30964,5857,-32240,-22038,24249,31902,-7480,-29953,-13287,14563,29352,8963,-31518,-28580,16028,31140,10195,-12213,-30406,-16719,28180,32679,-2391,-19478,-26350,-13231,29977,32711,-1901,-15328,-28961,-21115,25057,30651,11584,2206,-32693,-32229,5918,12326,30360,28023,-16982,-20065,-25906,-24455,21809,22398,23916,24372,-21902,-20259,-25755,-27831,17295,12779,30172,32111,-6521,1471,-32734,-30945,-10777,-20355,25678,16294,28428,32617,-3124,11984,-30497,-20642,-25449,-32525,3977,-15220,29018,13900,29672,31695,8312,27501,-17814,6820,-32050,-16614,-28244,-30863,-11009,-31216,9962,-19968,25980,-3063,32623,13454,29877,25563,20498,31756,8075,32477,-4343,29215,-14838,23705,-22622,17451,-27733,11526,-30673,6580,-32100,2940,-32635,736,-32759,-1,-32767,736,-32759,2940,-32635,6580,-32100,11526,-30673,17451,-27733,23705,-22622,29215,-14838,32477,-4343,31756,8075,25563,20498,13454,29877,-3063,32623,-19968,25980,-31216,9962,-30863,-11009,-16614,-28244,6820,-32050,27501,-17814,31695,8312,13900,29672,-15220,29018,-32525,3977,-20642,-25449,11984,-30497,32617,-3124,16294,28428,-20355,25678,-30945,-10777,1471,-32734,32111,-6521,12779,30172,-27831,17295,-20259,-25755,24372,-21902,22398,23916,-24455,21809,-20065,-25906,28023,-16982,12326,30360,-32229,5918,2206,-32693,30651,11584,-21115,25057,-15328,-28961,32711,-1901,-13231,29977,-19478,-26350,32679,-2391,-16719,28180,-12213,-30406,31140,10195,-28580,16028,8963,-31518,14563,29352,-29953,-13287,31902,-7480,-22038,24249,5857,-32240,10718,30964,-23536,-22799,30821,11123,-32751,1042,30607,-11699,-26018,19918,20450,-25602,-15002,29131,10370,-31083,-6941,32023,4889,-32401} -}; -short __attribute__((aligned(16))) X_u139[4][2*139] = {{23300,23038,23300,23038,24317,21962,26201,19676,28620,15954,31023,10547,32597,3326,32297,-5528,28973,-15304,21685,-24565,10195,-31141,-4430,-32467,-19380,-26422,-30238,-12625,-32165,6256,-22236,24067,-2221,32691,19971,25977,32414,4796,25749,-20265,1480,-32734,-24808,-21407,-31849,7703,-10898,30901,21125,25048,32014,-6982,7342,-31934,-26640,-19080,-27064,18472,9489,31362,32748,-1111,5892,-32233,-30777,-11246,-14975,29145,27870,17231,18165,-27271,-27474,-17857,-16277,28438,29944,13304,8778,-31570,-32665,-2590,5162,32357,29635,-13979,-22774,-23560,-13643,29791,32764,370,-14313,-29476,-18778,26852,32714,1850,-16916,-28064,-12283,30377,31253,-9844,-28253,-16597,8062,31759,15629,-28800,-30515,11938,31468,9134,-20554,-25520,3695,32557,12965,-30093,-25286,20840,31666,-8422,-32515,-4063,29312,14644,-23816,-22507,17544,27674,-11593,-30648,6619,32091,-2959,-32634,740,32758,-1,-32767,740,32758,-2959,-32634,6619,32091,-11593,-30648,17544,27674,-23816,-22507,29312,14644,-32515,-4063,31666,-8422,-25286,20840,12965,-30093,3695,32557,-20554,-25520,31468,9134,-30515,11938,15629,-28800,8062,31759,-28253,-16597,31253,-9844,-12283,30377,-16916,-28064,32714,1850,-18778,26852,-14313,-29476,32764,370,-13643,29791,-22774,-23560,29635,-13979,5162,32357,-32665,-2590,8778,-31570,29944,13304,-16277,28438,-27474,-17857,18165,-27271,27870,17231,-14975,29145,-30777,-11246,5892,-32233,32748,-1111,9489,31362,-27064,18472,-26640,-19080,7342,-31934,32014,-6982,21125,25048,-10898,30901,-31849,7703,-24808,-21407,1480,-32734,25749,-20265,32414,4796,19971,25977,-2221,32691,-22236,24067,-32165,6256,-30238,-12625,-19380,-26422,-4430,-32467,10195,-31141,21685,-24565,28973,-15304,32297,-5528,32597,3326,31023,10547,28620,15954,26201,19676,24317,21962}, - {23300,-23039,24317,-21963,26201,-19677,28620,-15955,31023,-10548,32597,-3327,32297,5527,28973,15303,21685,24564,10195,31140,-4430,32466,-19380,26421,-30238,12624,-32165,-6257,-22236,-24068,-2221,-32692,19971,-25978,32414,-4797,25749,20264,1480,32733,-24808,21406,-31849,-7704,-10898,-30902,21125,-25049,32014,6981,7342,31933,-26640,19079,-27064,-18473,9489,-31363,32748,1110,5892,32232,-30777,11245,-14975,-29146,27870,-17232,18165,27270,-27474,17856,-16277,-28439,29944,-13305,8778,31569,-32665,2589,5162,-32358,29635,13978,-22774,23559,-13643,-29792,32764,-371,-14313,29475,-18778,-26853,32714,-1851,-16916,28063,-12283,-30378,31253,9843,-28253,16596,8062,-31760,15629,28799,-30515,-11939,31468,-9135,-20554,25519,3695,-32558,12965,30092,-25286,-20841,31666,8421,-32515,4062,29312,-14645,-23816,22506,17544,-27675,-11593,30647,6619,-32092,-2959,32633,740,-32759,0,32767,740,-32759,-2959,32633,6619,-32092,-11593,30647,17544,-27675,-23816,22506,29312,-14645,-32515,4062,31666,8421,-25286,-20841,12965,30092,3695,-32558,-20554,25519,31468,-9135,-30515,-11939,15629,28799,8062,-31760,-28253,16596,31253,9843,-12283,-30378,-16916,28063,32714,-1851,-18778,-26853,-14313,29475,32764,-371,-13643,-29792,-22774,23559,29635,13978,5162,-32358,-32665,2589,8778,31569,29944,-13305,-16277,-28439,-27474,17856,18165,27270,27870,-17232,-14975,-29146,-30777,11245,5892,32232,32748,1110,9489,-31363,-27064,-18473,-26640,19079,7342,31933,32014,6981,21125,-25049,-10898,-30902,-31849,-7704,-24808,21406,1480,32733,25749,20264,32414,-4797,19971,-25978,-2221,-32692,-22236,-24068,-32165,-6257,-30238,12624,-19380,26421,-4430,32466,10195,31140,21685,24564,28973,15303,32297,5527,32597,-3327,31023,-10548,28620,-15955,26201,-19677,24317,-21963,23300,-23039}, - {32764,-371,0,32767,32764,-371,1480,32733,32597,-3327,5892,32232,31468,-9135,12965,30092,27870,-17232,21685,24564,19971,-25978,29635,13978,6619,-32092,32714,-1851,-10898,-30902,26201,-19677,-27064,-18473,8062,-31760,-32515,4062,-16277,-28439,-19380,26421,-32165,-6257,8778,31569,-23816,22506,31253,9843,7342,31933,23300,-23039,32014,6981,-12283,-30378,17544,-27675,-32665,2589,-22236,-24068,-4430,32466,-27474,17856,31666,8421,15629,28799,9489,-31363,28620,-15955,-31849,-7704,-18778,-26853,-2959,32633,-22774,23559,32414,-4797,28973,15303,-14975,-29146,3695,-32558,-20554,25519,-30777,11245,32297,5527,25749,20264,-13643,-29792,740,-32759,-14313,29475,-24808,21406,31023,-10548,32748,1110,-30515,-11939,-25286,-20841,18165,27270,10195,31140,-2221,-32692,5162,-32358,-11593,30647,-16916,28063,21125,-25049,24317,-21963,-26640,19079,-28253,16596,29312,-14645,29944,-13305,-30238,12624,-30238,12624,29944,-13305,29312,-14645,-28253,16596,-26640,19079,24317,-21963,21125,-25049,-16916,28063,-11593,30647,5162,-32358,-2221,-32692,10195,31140,18165,27270,-25286,-20841,-30515,-11939,32748,1110,31023,-10548,-24808,21406,-14313,29475,740,-32759,-13643,-29792,25749,20264,32297,5527,-30777,11245,-20554,25519,3695,-32558,-14975,-29146,28973,15303,32414,-4797,-22774,23559,-2959,32633,-18778,-26853,-31849,-7704,28620,-15955,9489,-31363,15629,28799,31666,8421,-27474,17856,-4430,32466,-22236,-24068,-32665,2589,17544,-27675,-12283,-30378,32014,6981,23300,-23039,7342,31933,31253,9843,-23816,22506,8778,31569,-32165,-6257,-19380,26421,-16277,-28439,-32515,4062,8062,-31760,-27064,-18473,26201,-19677,-10898,-30902,32714,-1851,6619,-32092,29635,13978,19971,-25978,21685,24564,27870,-17232,12965,30092,31468,-9135,5892,32232,32597,-3327,1480,32733}, - {32764,370,1480,-32734,32597,3326,5892,-32233,31468,9134,12965,-30093,27870,17231,21685,-24565,19971,25977,29635,-13979,6619,32091,32714,1850,-10898,30901,26201,19676,-27064,18472,8062,31759,-32515,-4063,-16277,28438,-19380,-26422,-32165,6256,8778,-31570,-23816,-22507,31253,-9844,7342,-31934,23300,23038,32014,-6982,-12283,30377,17544,27674,-32665,-2590,-22236,24067,-4430,-32467,-27474,-17857,31666,-8422,15629,-28800,9489,31362,28620,15954,-31849,7703,-18778,26852,-2959,-32634,-22774,-23560,32414,4796,28973,-15304,-14975,29145,3695,32557,-20554,-25520,-30777,-11246,32297,-5528,25749,-20265,-13643,29791,740,32758,-14313,-29476,-24808,-21407,31023,10547,32748,-1111,-30515,11938,-25286,20840,18165,-27271,10195,-31141,-2221,32691,5162,32357,-11593,-30648,-16916,-28064,21125,25048,24317,21962,-26640,-19080,-28253,-16597,29312,14644,29944,13304,-30238,-12625,-30238,-12625,29944,13304,29312,14644,-28253,-16597,-26640,-19080,24317,21962,21125,25048,-16916,-28064,-11593,-30648,5162,32357,-2221,32691,10195,-31141,18165,-27271,-25286,20840,-30515,11938,32748,-1111,31023,10547,-24808,-21407,-14313,-29476,740,32758,-13643,29791,25749,-20265,32297,-5528,-30777,-11246,-20554,-25520,3695,32557,-14975,29145,28973,-15304,32414,4796,-22774,-23560,-2959,-32634,-18778,26852,-31849,7703,28620,15954,9489,31362,15629,-28800,31666,-8422,-27474,-17857,-4430,-32467,-22236,24067,-32665,-2590,17544,27674,-12283,30377,32014,-6982,23300,23038,7342,-31934,31253,-9844,-23816,-22507,8778,-31570,-32165,6256,-19380,-26422,-16277,28438,-32515,-4063,8062,31759,-27064,18472,26201,19676,-10898,30901,32714,1850,6619,32091,29635,-13979,19971,25977,21685,-24565,27870,17231,12965,-30093,31468,9134,5892,-32233,32597,3326,1480,-32734,32764,370,0,-32768} -}; - -int16_t e839[839*2] = {32767,0,32766,245,32763,490,32758,736,32752,981,32744,1226,32733,1471,32721,1716,32708,1961,32692,2206,32675,2451,32655,2696,32634,2940,32611,3185,32587,3429,32560,3673,32532,3916,32501,4160,32469,4403,32435,4646,32400,4889,32362,5131,32323,5374,32282,5616,32239,5857,32194,6098,32147,6339,32099,6580,32049,6820,31997,7060,31943,7299,31887,7538,31830,7777,31771,8015,31710,8253,31647,8490,31583,8727,31517,8963,31449,9199,31379,9434,31307,9669,31234,9903,31159,10137,31082,10370,31004,10602,30923,10834,30841,11065,30758,11296,30672,11526,30585,11756,30496,11984,30405,12212,30313,12440,30219,12666,30123,12892,30026,13117,29927,13342,29826,13566,29724,13789,29620,14011,29514,14232,29407,14453,29297,14673,29187,14892,29074,15110,28960,15327,28845,15544,28728,15759,28609,15974,28488,16188,28366,16401,28243,16613,28117,16824,27991,17034,27862,17243,27732,17451,27601,17658,27468,17865,27333,18070,27197,18274,27060,18477,26921,18679,26780,18880,26638,19080,26494,19279,26349,19477,26202,19674,26054,19870,25905,20064,25754,20258,25601,20450,25448,20641,25292,20831,25135,21020,24977,21208,24818,21394,24657,21579,24495,21763,24331,21946,24166,22128,24000,22308,23832,22487,23663,22665,23492,22842,23321,23017,23148,23191,22973,23364,22798,23535,22621,23705,22443,23874,22263,24041,22082,24207,21901,24372,21717,24535,21533,24697,21348,24858,21161,25017,20973,25175,20784,25331,20593,25486,20402,25640,20209,25792,20016,25942,19821,26091,19625,26239,19428,26385,19230,26530,19030,26673,18830,26815,18629,26955,18426,27094,18223,27231,18019,27367,17813,27501,17607,27634,17399,27765,17191,27895,16981,28023,16771,28149,16560,28274,16348,28397,16134,28519,15920,28639,15705,28757,15490,28874,15273,28989,15056,29103,14837,29215,14618,29325,14398,29434,14177,29541,13955,29646,13733,29750,13510,29852,13286,29952,13061,30051,12836,30148,12610,30243,12383,30336,12155,30428,11927,30518,11698,30607,11469,30694,11238,30779,11008,30862,10776,30944,10544,31023,10312,31102,10078,31178,9845,31253,9610,31325,9375,31396,9140,31466,8904,31533,8668,31599,8431,31663,8193,31725,7956,31786,7717,31845,7479,31902,7240,31957,7000,32010,6760,32061,6520,32111,6279,32159,6038,32205,5797,32250,5555,32292,5313,32333,5071,32372,4828,32409,4585,32444,4342,32477,4099,32509,3855,32539,3612,32567,3368,32593,3123,32617,2879,32640,2635,32660,2390,32679,2145,32696,1900,32711,1655,32725,1410,32736,1165,32746,920,32754,674,32760,429,32764,184,32766,-62,32766,-307,32765,-553,32762,-798,32757,-1043,32750,-1288,32741,-1534,32731,-1779,32718,-2024,32704,-2269,32688,-2513,32670,-2758,32650,-3002,32629,-3247,32605,-3491,32580,-3735,32553,-3978,32524,-4222,32493,-4465,32461,-4708,32427,-4951,32390,-5193,32352,-5435,32313,-5677,32271,-5919,32228,-6160,32182,-6401,32135,-6641,32087,-6881,32036,-7121,31984,-7360,31929,-7599,31873,-7838,31815,-8076,31756,-8313,31695,-8550,31631,-8787,31566,-9023,31500,-9259,31431,-9494,31361,-9729,31289,-9963,31215,-10196,31140,-10429,31063,-10661,30984,-10893,30903,-11124,30821,-11355,30736,-11585,30651,-11814,30563,-12042,30474,-12270,30383,-12497,30290,-12724,30195,-12950,30099,-13175,30001,-13399,29902,-13623,29801,-13845,29698,-14067,29593,-14289,29487,-14509,29379,-14729,29270,-14947,29159,-15165,29046,-15382,28932,-15599,28816,-15814,28698,-16029,28579,-16242,28458,-16455,28336,-16667,28212,-16877,28086,-17087,27959,-17296,27830,-17504,27700,-17711,27568,-17917,27434,-18122,27300,-18326,27163,-18529,27025,-18731,26886,-18931,26745,-19131,26602,-19330,26458,-19527,26312,-19724,26166,-19919,26017,-20114,25867,-20307,25716,-20499,25563,-20690,25409,-20879,25253,-21068,25096,-21255,24938,-21441,24778,-21626,24616,-21810,24454,-21993,24290,-22174,24124,-22354,23958,-22533,23790,-22710,23620,-22887,23450,-23062,23277,-23235,23104,-23408,22929,-23579,22754,-23748,22576,-23917,22398,-24084,22218,-24250,22037,-24414,21855,-24577,21671,-24739,21487,-24899,21301,-25058,21114,-25215,20926,-25371,20736,-25526,20546,-25679,20354,-25830,20161,-25981,19967,-26130,19772,-26277,19576,-26423,19378,-26567,19180,-26710,18980,-26851,18780,-26991,18578,-27130,18376,-27267,18172,-27402,17967,-27536,17762,-27668,17555,-27799,17347,-27928,17139,-28055,16929,-28181,16718,-28306,16507,-28429,16294,-28550,16081,-28669,15867,-28787,15652,-28904,15436,-29019,15219,-29132,15001,-29243,14782,-29353,14563,-29461,14343,-29568,14122,-29673,13900,-29776,13677,-29878,13454,-29978,13230,-30076,13005,-30173,12779,-30267,12553,-30361,12326,-30452,12098,-30542,11870,-30630,11641,-30716,11411,-30801,11181,-30884,10950,-30965,10718,-31044,10486,-31122,10253,-31198,10020,-31272,9786,-31344,9552,-31415,9317,-31484,9081,-31551,8845,-31616,8609,-31680,8372,-31742,8134,-31802,7896,-31860,7658,-31916,7419,-31971,7180,-32024,6940,-32075,6700,-32124,6460,-32172,6219,-32218,5978,-32261,5736,-32303,5495,-32344,5253,-32382,5010,-32419,4768,-32454,4525,-32487,4282,-32518,4038,-32547,3794,-32575,3551,-32600,3307,-32624,3062,-32646,2818,-32666,2573,-32685,2329,-32701,2084,-32716,1839,-32729,1594,-32740,1349,-32749,1104,-32756,858,-32762,613,-32765,368,-32767,122,-32767,-123,-32765,-369,-32762,-614,-32756,-859,-32749,-1105,-32740,-1350,-32729,-1595,-32716,-1840,-32701,-2085,-32685,-2330,-32666,-2574,-32646,-2819,-32624,-3063,-32600,-3308,-32575,-3552,-32547,-3795,-32518,-4039,-32487,-4283,-32454,-4526,-32419,-4769,-32382,-5011,-32344,-5254,-32303,-5496,-32261,-5737,-32218,-5979,-32172,-6220,-32124,-6461,-32075,-6701,-32024,-6941,-31971,-7181,-31916,-7420,-31860,-7659,-31802,-7897,-31742,-8135,-31680,-8373,-31616,-8610,-31551,-8846,-31484,-9082,-31415,-9318,-31344,-9553,-31272,-9787,-31198,-10021,-31122,-10254,-31044,-10487,-30965,-10719,-30884,-10951,-30801,-11182,-30716,-11412,-30630,-11642,-30542,-11871,-30452,-12099,-30361,-12327,-30267,-12554,-30173,-12780,-30076,-13006,-29978,-13231,-29878,-13455,-29776,-13678,-29673,-13901,-29568,-14123,-29461,-14344,-29353,-14564,-29243,-14783,-29132,-15002,-29019,-15220,-28904,-15437,-28787,-15653,-28669,-15868,-28550,-16082,-28429,-16295,-28306,-16508,-28181,-16719,-28055,-16930,-27928,-17140,-27799,-17348,-27668,-17556,-27536,-17763,-27402,-17968,-27267,-18173,-27130,-18377,-26991,-18579,-26851,-18781,-26710,-18981,-26567,-19181,-26423,-19379,-26277,-19577,-26130,-19773,-25981,-19968,-25830,-20162,-25679,-20355,-25526,-20547,-25371,-20737,-25215,-20927,-25058,-21115,-24899,-21302,-24739,-21488,-24577,-21672,-24414,-21856,-24250,-22038,-24084,-22219,-23917,-22399,-23748,-22577,-23579,-22755,-23408,-22930,-23235,-23105,-23062,-23278,-22887,-23451,-22710,-23621,-22533,-23791,-22354,-23959,-22174,-24125,-21993,-24291,-21810,-24455,-21626,-24617,-21441,-24779,-21255,-24939,-21068,-25097,-20879,-25254,-20690,-25410,-20499,-25564,-20307,-25717,-20114,-25868,-19919,-26018,-19724,-26167,-19527,-26313,-19330,-26459,-19131,-26603,-18931,-26746,-18731,-26887,-18529,-27026,-18326,-27164,-18122,-27301,-17917,-27435,-17711,-27569,-17504,-27701,-17296,-27831,-17087,-27960,-16877,-28087,-16667,-28213,-16455,-28337,-16242,-28459,-16029,-28580,-15814,-28699,-15599,-28817,-15382,-28933,-15165,-29047,-14947,-29160,-14729,-29271,-14509,-29380,-14289,-29488,-14067,-29594,-13845,-29699,-13623,-29802,-13399,-29903,-13175,-30002,-12950,-30100,-12724,-30196,-12497,-30291,-12270,-30384,-12042,-30475,-11814,-30564,-11585,-30652,-11355,-30737,-11124,-30822,-10893,-30904,-10661,-30985,-10429,-31064,-10196,-31141,-9963,-31216,-9729,-31290,-9494,-31362,-9259,-31432,-9023,-31501,-8787,-31567,-8550,-31632,-8313,-31696,-8076,-31757,-7838,-31816,-7599,-31874,-7360,-31930,-7121,-31985,-6881,-32037,-6641,-32088,-6401,-32136,-6160,-32183,-5919,-32229,-5677,-32272,-5435,-32314,-5193,-32353,-4951,-32391,-4708,-32428,-4465,-32462,-4222,-32494,-3978,-32525,-3735,-32554,-3491,-32581,-3247,-32606,-3002,-32630,-2758,-32651,-2513,-32671,-2269,-32689,-2024,-32705,-1779,-32719,-1534,-32732,-1288,-32742,-1043,-32751,-798,-32758,-553,-32763,-307,-32766,-62,-32767,184,-32767,429,-32765,674,-32761,920,-32755,1165,-32747,1410,-32737,1655,-32726,1900,-32712,2145,-32697,2390,-32680,2635,-32661,2879,-32641,3123,-32618,3368,-32594,3612,-32568,3855,-32540,4099,-32510,4342,-32478,4585,-32445,4828,-32410,5071,-32373,5313,-32334,5555,-32293,5797,-32251,6038,-32206,6279,-32160,6520,-32112,6760,-32062,7000,-32011,7240,-31958,7479,-31903,7717,-31846,7956,-31787,8193,-31726,8431,-31664,8668,-31600,8904,-31534,9140,-31467,9375,-31397,9610,-31326,9845,-31254,10078,-31179,10312,-31103,10544,-31024,10776,-30945,11008,-30863,11238,-30780,11469,-30695,11698,-30608,11927,-30519,12155,-30429,12383,-30337,12610,-30244,12836,-30149,13061,-30052,13286,-29953,13510,-29853,13733,-29751,13955,-29647,14177,-29542,14398,-29435,14618,-29326,14837,-29216,15056,-29104,15273,-28990,15490,-28875,15705,-28758,15920,-28640,16134,-28520,16348,-28398,16560,-28275,16771,-28150,16981,-28024,17191,-27896,17399,-27766,17607,-27635,17813,-27502,18019,-27368,18223,-27232,18426,-27095,18629,-26956,18830,-26816,19030,-26674,19230,-26531,19428,-26386,19625,-26240,19821,-26092,20016,-25943,20209,-25793,20402,-25641,20593,-25487,20784,-25332,20973,-25176,21161,-25018,21348,-24859,21533,-24698,21717,-24536,21901,-24373,22082,-24208,22263,-24042,22443,-23875,22621,-23706,22798,-23536,22973,-23365,23148,-23192,23321,-23018,23492,-22843,23663,-22666,23832,-22488,24000,-22309,24166,-22129,24331,-21947,24495,-21764,24657,-21580,24818,-21395,24977,-21209,25135,-21021,25292,-20832,25448,-20642,25601,-20451,25754,-20259,25905,-20065,26054,-19871,26202,-19675,26349,-19478,26494,-19280,26638,-19081,26780,-18881,26921,-18680,27060,-18478,27197,-18275,27333,-18071,27468,-17866,27601,-17659,27732,-17452,27862,-17244,27991,-17035,28117,-16825,28243,-16614,28366,-16402,28488,-16189,28609,-15975,28728,-15760,28845,-15545,28960,-15328,29074,-15111,29187,-14893,29297,-14674,29407,-14454,29514,-14233,29620,-14012,29724,-13790,29826,-13567,29927,-13343,30026,-13118,30123,-12893,30219,-12667,30313,-12441,30405,-12213,30496,-11985,30585,-11757,30672,-11527,30758,-11297,30841,-11066,30923,-10835,31004,-10603,31082,-10371,31159,-10138,31234,-9904,31307,-9670,31379,-9435,31449,-9200,31517,-8964,31583,-8728,31647,-8491,31710,-8254,31771,-8016,31830,-7778,31887,-7539,31943,-7300,31997,-7061,32049,-6821,32099,-6581,32147,-6340,32194,-6099,32239,-5858,32282,-5617,32323,-5375,32362,-5132,32400,-4890,32435,-4647,32469,-4404,32501,-4161,32532,-3917,32560,-3674,32587,-3430,32611,-3186,32634,-2941,32655,-2697,32675,-2452,32692,-2207,32708,-1962,32721,-1717,32733,-1472,32744,-1227,32752,-982,32758,-737,32763,-491,32766,-246}; - -int16_t e139[139*2] = {32767,0,32733,1480,32633,2958,32466,4429,32232,5892,31933,7342,31569,8778,31140,10195,30647,11592,30092,12965,29475,14312,28799,15629,28063,16915,27270,18165,26421,19379,25519,20553,24564,21685,23559,22773,22506,23815,21406,24807,20264,25749,19079,26639,17856,27473,16596,28252,15303,28973,13978,29635,12624,30237,11245,30776,9843,31253,8421,31666,6981,32014,5527,32297,4062,32514,2589,32664,1110,32748,-371,32764,-1851,32714,-3327,32597,-4797,32414,-6257,32164,-7704,31848,-9135,31468,-10548,31023,-11939,30514,-13305,29944,-14645,29312,-15955,28620,-17232,27870,-18473,27063,-19677,26201,-20841,25285,-21963,24317,-23039,23300,-24068,22235,-25049,21125,-25978,19971,-26853,18777,-27675,17544,-28439,16276,-29146,14974,-29792,13642,-30378,12282,-30902,10897,-31363,9489,-31760,8062,-32092,6619,-32358,5162,-32558,3695,-32692,2220,-32759,740,-32759,-741,-32692,-2221,-32558,-3696,-32358,-5163,-32092,-6620,-31760,-8063,-31363,-9490,-30902,-10898,-30378,-12283,-29792,-13643,-29146,-14975,-28439,-16277,-27675,-17545,-26853,-18778,-25978,-19972,-25049,-21126,-24068,-22236,-23039,-23301,-21963,-24318,-20841,-25286,-19677,-26202,-18473,-27064,-17232,-27871,-15955,-28621,-14645,-29313,-13305,-29945,-11939,-30515,-10548,-31024,-9135,-31469,-7704,-31849,-6257,-32165,-4797,-32415,-3327,-32598,-1851,-32715,-371,-32765,1110,-32749,2589,-32665,4062,-32515,5527,-32298,6981,-32015,8421,-31667,9843,-31254,11245,-30777,12624,-30238,13978,-29636,15303,-28974,16596,-28253,17856,-27474,19079,-26640,20264,-25750,21406,-24808,22506,-23816,23559,-22774,24564,-21686,25519,-20554,26421,-19380,27270,-18166,28063,-16916,28799,-15630,29475,-14313,30092,-12966,30647,-11593,31140,-10196,31569,-8779,31933,-7343,32232,-5893,32466,-4430,32633,-2959,32733,-1481}; diff --git a/openair1/PHY/LTE_TRANSPORT/prach_common.c b/openair1/PHY/LTE_TRANSPORT/prach_common.c new file mode 100644 index 0000000000000000000000000000000000000000..2f39346be2027e4fc1d9460ec6cb508026b9f666 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/prach_common.c @@ -0,0 +1,771 @@ +/* + * 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/LTE_TRANSPORT/prach_common.c + * \brief Common routines for UE/eNB PRACH physical channel V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include "PHY/sse_intrin.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" +#include "PHY/phy_extern_ue.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + + +uint16_t NCS_unrestricted[16] = {0,13,15,18,22,26,32,38,46,59,76,93,119,167,279,419}; +uint16_t NCS_restricted[15] = {15,18,22,26,32,38,46,55,68,82,100,128,158,202,237}; // high-speed case +uint16_t NCS_4[7] = {2,4,6,8,10,12,15}; + +int16_t ru[2*839]; // quantized roots of unity +uint32_t ZC_inv[839]; // multiplicative inverse for roots u +uint16_t du[838]; + +// This is table 5.7.1-4 from 36.211 +PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7] = { + // TDD Configuration Index 0 + { {1,{{0,1,0,2}}},{1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}}, + // TDD Configuration Index 1 + { {1,{{0,2,0,2}}},{1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}}, + // TDD Configuration Index 2 + { {1,{{0,1,1,2}}},{1,{{0,1,1,1}}}, {1,{{0,1,1,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,1}}}}, + // TDD Configuration Index 3 + { {1,{{0,0,0,2}}},{1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}}, + // TDD Configuration Index 4 + { {1,{{0,0,1,2}}},{1,{{0,0,1,1}}}, {1,{{0,0,1,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,1}}}}, + // TDD Configuration Index 5 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + // TDD Configuration Index 6 + { {2,{{0,0,0,2},{0,0,1,2}}}, {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {2,{{0,0,0,1},{0,0,0,2}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {2,{{0,0,0,2},{0,0,1,1}}}}, + // TDD Configuration Index 7 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,2}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + // TDD Configuration Index 8 + { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,1,1}}}}, + // TDD Configuration Index 9 + { {3,{{0,0,0,1},{0,0,0,2},{0,0,1,2}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,0,2}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {3,{{0,0,0,1},{0,0,0,2},{0,0,1,1}}}}, + // TDD Configuration Index 10 + { {3,{{0,0,0,0},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,2},{0,0,1,0}}}}, + // TDD Configuration Index 11 + { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}}, + // TDD Configuration Index 12 + { {4,{{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, + {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,2}}}, + {4,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {4,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 13 + { {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1}}} + }, + // TDD Configuration Index 14 + { {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 15 + { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1}}}, + {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1},{1,0,0,2}}}, + {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,1}}}, {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, + {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 16 + { {5,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,1,1}}}, + {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,1,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,2}}}, + {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} + }, + // TDD Configuration Index 17 + { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} + }, + // TDD Configuration Index 18 + { {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1},{1,0,0,2}}}, + {6,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0},{2,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,0,2}}} + }, + // TDD Configuration Index 19 + { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,1,1}}} + }, + // TDD Configuration Index 20 + { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, + // TDD Configuration Index 21 + { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, + + // TDD Configuration Index 22 + { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, + + // TDD Configuration Index 23 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + + // TDD Configuration Index 24 + { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, + + // TDD Configuration Index 25 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + + // TDD Configuration Index 26 + { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, + + // TDD Configuration Index 27 + { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} + }, + + // TDD Configuration Index 28 + { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, + {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} + }, + + // TDD Configuration Index 29 + { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} + }, + + + // TDD Configuration Index 30 + { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, + + // TDD Configuration Index 31 + { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, + + // TDD Configuration Index 32 + { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, + + // TDD Configuration Index 33 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + + // TDD Configuration Index 34 + { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, + + // TDD Configuration Index 35 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + + // TDD Configuration Index 36 + { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, + + // TDD Configuration Index 37 + { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} + }, + + // TDD Configuration Index 38 + { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, + {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} + }, + + // TDD Configuration Index 39 + { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} + }, + + // TDD Configuration Index 40 + { {1,{{0,1,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}}, + // TDD Configuration Index 41 + { {1,{{0,2,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}}, + + // TDD Configuration Index 42 + { {1,{{0,1,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, + + // TDD Configuration Index 43 + { {1,{{0,0,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}}, + + // TDD Configuration Index 44 + { {1,{{0,0,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, + + // TDD Configuration Index 45 + { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}}, + + // TDD Configuration Index 46 + { {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}}, + + // TDD Configuration Index 47 + { {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}} + } +}; + + + +uint16_t prach_root_sequence_map0_3[838] = { 129, 710, 140, 699, 120, 719, 210, 629, 168, 671, 84, 755, 105, 734, 93, 746, 70, 769, 60, 779, + 2, 837, 1, 838, + 56, 783, 112, 727, 148, 691, + 80, 759, 42, 797, 40, 799, + 35, 804, 73, 766, 146, 693, + 31, 808, 28, 811, 30, 809, 27, 812, 29, 810, + 24, 815, 48, 791, 68, 771, 74, 765, 178, 661, 136, 703, + 86, 753, 78, 761, 43, 796, 39, 800, 20, 819, 21, 818, + 95, 744, 202, 637, 190, 649, 181, 658, 137, 702, 125, 714, 151, 688, + 217, 622, 128, 711, 142, 697, 122, 717, 203, 636, 118, 721, 110, 729, 89, 750, 103, 736, 61, + 778, 55, 784, 15, 824, 14, 825, + 12, 827, 23, 816, 34, 805, 37, 802, 46, 793, 207, 632, 179, 660, 145, 694, 130, 709, 223, 616, + 228, 611, 227, 612, 132, 707, 133, 706, 143, 696, 135, 704, 161, 678, 201, 638, 173, 666, 106, + 733, 83, 756, 91, 748, 66, 773, 53, 786, 10, 829, 9, 830, + 7, 832, 8, 831, 16, 823, 47, 792, 64, 775, 57, 782, 104, 735, 101, 738, 108, 731, 208, 631, 184, + 655, 197, 642, 191, 648, 121, 718, 141, 698, 149, 690, 216, 623, 218, 621, + 152, 687, 144, 695, 134, 705, 138, 701, 199, 640, 162, 677, 176, 663, 119, 720, 158, 681, 164, + 675, 174, 665, 171, 668, 170, 669, 87, 752, 169, 670, 88, 751, 107, 732, 81, 758, 82, 757, 100, + 739, 98, 741, 71, 768, 59, 780, 65, 774, 50, 789, 49, 790, 26, 813, 17, 822, 13, 826, 6, 833, + 5, 834, 33, 806, 51, 788, 75, 764, 99, 740, 96, 743, 97, 742, 166, 673, 172, 667, 175, 664, 187, + 652, 163, 676, 185, 654, 200, 639, 114, 725, 189, 650, 115, 724, 194, 645, 195, 644, 192, 647, + 182, 657, 157, 682, 156, 683, 211, 628, 154, 685, 123, 716, 139, 700, 212, 627, 153, 686, 213, + 626, 215, 624, 150, 689, + 225, 614, 224, 615, 221, 618, 220, 619, 127, 712, 147, 692, 124, 715, 193, 646, 205, 634, 206, + 633, 116, 723, 160, 679, 186, 653, 167, 672, 79, 760, 85, 754, 77, 762, 92, 747, 58, 781, 62, + 777, 69, 770, 54, 785, 36, 803, 32, 807, 25, 814, 18, 821, 11, 828, 4, 835, + 3, 836, 19, 820, 22, 817, 41, 798, 38, 801, 44, 795, 52, 787, 45, 794, 63, 776, 67, 772, 72, + 767, 76, 763, 94, 745, 102, 737, 90, 749, 109, 730, 165, 674, 111, 728, 209, 630, 204, 635, 117, + 722, 188, 651, 159, 680, 198, 641, 113, 726, 183, 656, 180, 659, 177, 662, 196, 643, 155, 684, + 214, 625, 126, 713, 131, 708, 219, 620, 222, 617, 226, 613, + 230, 609, 232, 607, 262, 577, 252, 587, 418, 421, 416, 423, 413, 426, 411, 428, 376, 463, 395, + 444, 283, 556, 285, 554, 379, 460, 390, 449, 363, 476, 384, 455, 388, 451, 386, 453, 361, 478, + 387, 452, 360, 479, 310, 529, 354, 485, 328, 511, 315, 524, 337, 502, 349, 490, 335, 504, 324, + 515, + 323, 516, 320, 519, 334, 505, 359, 480, 295, 544, 385, 454, 292, 547, 291, 548, 381, 458, 399, + 440, 380, 459, 397, 442, 369, 470, 377, 462, 410, 429, 407, 432, 281, 558, 414, 425, 247, 592, + 277, 562, 271, 568, 272, 567, 264, 575, 259, 580, + 237, 602, 239, 600, 244, 595, 243, 596, 275, 564, 278, 561, 250, 589, 246, 593, 417, 422, 248, + 591, 394, 445, 393, 446, 370, 469, 365, 474, 300, 539, 299, 540, 364, 475, 362, 477, 298, 541, + 312, 527, 313, 526, 314, 525, 353, 486, 352, 487, 343, 496, 327, 512, 350, 489, 326, 513, 319, + 520, 332, 507, 333, 506, 348, 491, 347, 492, 322, 517, + 330, 509, 338, 501, 341, 498, 340, 499, 342, 497, 301, 538, 366, 473, 401, 438, 371, 468, 408, + 431, 375, 464, 249, 590, 269, 570, 238, 601, 234, 605, + 257, 582, 273, 566, 255, 584, 254, 585, 245, 594, 251, 588, 412, 427, 372, 467, 282, 557, 403, + 436, 396, 443, 392, 447, 391, 448, 382, 457, 389, 450, 294, 545, 297, 542, 311, 528, 344, 495, + 345, 494, 318, 521, 331, 508, 325, 514, 321, 518, + 346, 493, 339, 500, 351, 488, 306, 533, 289, 550, 400, 439, 378, 461, 374, 465, 415, 424, 270, + 569, 241, 598, + 231, 608, 260, 579, 268, 571, 276, 563, 409, 430, 398, 441, 290, 549, 304, 535, 308, 531, 358, + 481, 316, 523, + 293, 546, 288, 551, 284, 555, 368, 471, 253, 586, 256, 583, 263, 576, + 242, 597, 274, 565, 402, 437, 383, 456, 357, 482, 329, 510, + 317, 522, 307, 532, 286, 553, 287, 552, 266, 573, 261, 578, + 236, 603, 303, 536, 356, 483, + 355, 484, 405, 434, 404, 435, 406, 433, + 235, 604, 267, 572, 302, 537, + 309, 530, 265, 574, 233, 606, + 367, 472, 296, 543, + 336, 503, 305, 534, 373, 466, 280, 559, 279, 560, 419, 420, 240, 599, 258, 581, 229, 610 + }; + +uint16_t prach_root_sequence_map4[138] = { 1,138,2,137,3,136,4,135,5,134,6,133,7,132,8,131,9,130,10,129, + 11,128,12,127,13,126,14,125,15,124,16,123,17,122,18,121,19,120,20,119, + 21,118,22,117,23,116,24,115,25,114,26,113,27,112,28,111,29,110,30,109, + 31,108,32,107,33,106,34,105,35,104,36,103,37,102,38,101,39,100,40,99, + 41,98,42,97,43,96,44,95,45,94,46,93,47,92,48,91,49,90,50,89, + 51,88,52,87,53,86,54,85,55,84,56,83,57,82,58,81,59,80,60,79, + 61,78,62,77,63,76,64,75,65,74,66,73,67,72,68,71,69,70 + }; + +void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) +{ + + FILE *fd; + + fd = fopen("prach_config.txt","w"); + fprintf(fd,"prach_config: subframe = %d\n",subframe); + fprintf(fd,"prach_config: N_RB_UL = %d\n",frame_parms->N_RB_UL); + fprintf(fd,"prach_config: frame_type = %s\n",(frame_parms->frame_type==1) ? "TDD":"FDD"); + + if(frame_parms->frame_type==1) fprintf(fd,"prach_config: tdd_config = %d\n",frame_parms->tdd_config); + + fprintf(fd,"prach_config: rootSequenceIndex = %d\n",frame_parms->prach_config_common.rootSequenceIndex); + fprintf(fd,"prach_config: prach_ConfigIndex = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex); + fprintf(fd,"prach_config: Ncs_config = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig); + fprintf(fd,"prach_config: highSpeedFlag = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag); + fprintf(fd,"prach_config: n_ra_prboffset = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset); + fclose(fd); + +} + +// This function computes the du +void fill_du(uint8_t prach_fmt) +{ + + uint16_t iu,u,p; + uint16_t N_ZC; + uint16_t *prach_root_sequence_map; + + if (prach_fmt<4) { + N_ZC = 839; + prach_root_sequence_map = prach_root_sequence_map0_3; + } else { + N_ZC = 139; + prach_root_sequence_map = prach_root_sequence_map4; + } + + for (iu=0; iu<(N_ZC-1); iu++) { + + u=prach_root_sequence_map[iu]; + p=1; + + while (((u*p)%N_ZC)!=1) + p++; + + du[u] = ((p<(N_ZC>>1)) ? p : (N_ZC-p)); + } + +} + +uint8_t get_num_prach_tdd(module_id_t Mod_id) +{ + LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; + return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].num_prach); +} + +uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index) +{ + LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; + return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].map[tdd_map_index].f_ra); +} + +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type) +{ + + if (frame_type == FDD) // FDD + return(prach_ConfigIndex>>4); + + else { + if (prach_ConfigIndex < 20) + return (0); + + if (prach_ConfigIndex < 30) + return (1); + + if (prach_ConfigIndex < 40) + return (2); + + if (prach_ConfigIndex < 48) + return (3); + else + return (4); + } +} + +uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf) +{ + lte_frame_type_t frame_type = frame_parms->frame_type; + uint8_t tdd_config = frame_parms->tdd_config; + + uint8_t n_ra_prb; + uint8_t f_ra,t1_ra; + uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); + uint8_t Nsp=2; + + if (frame_type == TDD) { // TDD + + if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { + LOG_E(PHY, "Illegal prach_ConfigIndex %"PRIu8"", prach_ConfigIndex); + return(-1); + } + + // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) + f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; + + if (prach_fmt < 4) { + if ((f_ra&1) == 0) { + n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); + } else { + n_ra_prb = frame_parms->N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); + } + } else { + if ((tdd_config >2) && (tdd_config<6)) + Nsp = 2; + + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + + if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { + n_ra_prb = 6*f_ra; + } else { + n_ra_prb = frame_parms->N_RB_UL - 6*(f_ra+1); + } + } + } + else { //FDD + n_ra_prb = n_ra_prboffset; + } + return(n_ra_prb); +} + +int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe) +{ + // uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + uint8_t tdd_config = frame_parms->tdd_config; + uint8_t t0_ra; + uint8_t t1_ra; + uint8_t t2_ra; + + int prach_mask = 0; + + if (frame_parms->frame_type == FDD) { //FDD + //implement Table 5.7.1-2 from 36.211 (Rel-10, p.41) + if ((((frame&1) == 1) && (subframe < 9)) || + (((frame&1) == 0) && (subframe == 9))) // This is an odd frame, ignore even-only PRACH frames + if (((prach_ConfigIndex&0xf)<3) || // 0,1,2,16,17,18,32,33,34,48,49,50 + ((prach_ConfigIndex&0x1f)==18) || // 18,50 + ((prach_ConfigIndex&0xf)==15)) // 15,47 + return(0); + + switch (prach_ConfigIndex&0x1f) { + case 0: + case 3: + if (subframe==1) prach_mask = 1; + break; + + case 1: + case 4: + if (subframe==4) prach_mask = 1; + break; + + case 2: + case 5: + if (subframe==7) prach_mask = 1; + break; + + case 6: + if ((subframe==1) || (subframe==6)) prach_mask=1; + break; + + case 7: + if ((subframe==2) || (subframe==7)) prach_mask=1; + break; + + case 8: + if ((subframe==3) || (subframe==8)) prach_mask=1; + break; + + case 9: + if ((subframe==1) || (subframe==4) || (subframe==7)) prach_mask=1; + break; + + case 10: + if ((subframe==2) || (subframe==5) || (subframe==8)) prach_mask=1; + break; + + case 11: + if ((subframe==3) || (subframe==6) || (subframe==9)) prach_mask=1; + break; + + case 12: + if ((subframe&1)==0) prach_mask=1; + break; + + case 13: + if ((subframe&1)==1) prach_mask=1; + break; + + case 14: + prach_mask=1; + break; + + case 15: + if (subframe==9) prach_mask=1; + break; + } + } else { // TDD + + AssertFatal(prach_ConfigIndex<64, + "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); + AssertFatal(tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach>0, + "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); + + t0_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t0_ra; + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + t2_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t2_ra; +#ifdef PRACH_DEBUG + LOG_I(PHY,"[PRACH] Checking for PRACH format (ConfigIndex %d) in TDD subframe %d (%d,%d,%d)\n", + prach_ConfigIndex, + subframe, + t0_ra,t1_ra,t2_ra); +#endif + + if ((((t0_ra == 1) && ((frame &1)==0))|| // frame is even and PRACH is in even frames + ((t0_ra == 2) && ((frame &1)==1))|| // frame is odd and PRACH is in odd frames + (t0_ra == 0)) && // PRACH is in all frames + (((subframe<5)&&(t1_ra==0)) || // PRACH is in 1st half-frame + (((subframe>4)&&(t1_ra==1))))) { // PRACH is in 2nd half-frame + if ((prach_ConfigIndex<48) && // PRACH only in normal UL subframe + (((subframe%5)-2)==t2_ra)) prach_mask=1; + else if ((prach_ConfigIndex>47) && (((subframe%5)-1)==t2_ra)) prach_mask=1; // PRACH can be in UpPTS + } + } + + return(prach_mask); +} + +int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) { + + uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + int prach_mask = is_prach_subframe0(frame_parms,prach_ConfigIndex,frame,subframe); + +#ifdef Rel14 + int i; + + for (i=0;i<4;i++) { + if (frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] == 1) + prach_mask|=(is_prach_subframe0(frame_parms,frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i],frame,subframe)<<(i+1)); + } +#endif + return(prach_mask); +} + + +void compute_prach_seq(uint16_t rootSequenceIndex, + uint8_t prach_ConfigIndex, + uint8_t zeroCorrelationZoneConfig, + uint8_t highSpeedFlag, + lte_frame_type_t frame_type, + uint32_t X_u[64][839]) +{ + + // Compute DFT of x_u => X_u[k] = x_u(inv(u)*k)^* X_u[k] = exp(j\pi u*inv(u)*k*(inv(u)*k+1)/N_ZC) + unsigned int k,inv_u,i,NCS=0,num_preambles; + int N_ZC; + uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); + uint16_t *prach_root_sequence_map; + uint16_t u, preamble_offset; + uint16_t n_shift_ra,n_shift_ra_bar, d_start,numshift; + uint8_t not_found; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_IN); + +#ifdef PRACH_DEBUG + LOG_I(PHY,"compute_prach_seq: NCS_config %d, prach_fmt %d\n",zeroCorrelationZoneConfig, prach_fmt); +#endif + + AssertFatal(prach_fmt<4, + "PRACH sequence is only precomputed for prach_fmt<4 (have %"PRIu8")\n", prach_fmt ); + N_ZC = (prach_fmt < 4) ? 839 : 139; + //init_prach_tables(N_ZC); //moved to phy_init_lte_ue/eNB, since it takes to long in real-time + + if (prach_fmt < 4) { + prach_root_sequence_map = prach_root_sequence_map0_3; + } else { + // FIXME cannot be reached + prach_root_sequence_map = prach_root_sequence_map4; + } + + +#ifdef PRACH_DEBUG + LOG_I( PHY, "compute_prach_seq: done init prach_tables\n" ); +#endif + + if (highSpeedFlag== 0) { + +#ifdef PRACH_DEBUG + LOG_I(PHY,"Low speed prach : NCS_config %d\n",zeroCorrelationZoneConfig); +#endif + + AssertFatal(zeroCorrelationZoneConfig<=15, + "FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); + NCS = NCS_unrestricted[zeroCorrelationZoneConfig]; + + num_preambles = (NCS==0) ? 64 : ((64*NCS)/N_ZC); + + if (NCS>0) num_preambles++; + + preamble_offset = 0; + } else { + +#ifdef PRACH_DEBUG + LOG_I( PHY, "high speed prach : NCS_config %"PRIu8"\n", zeroCorrelationZoneConfig ); +#endif + + AssertFatal(zeroCorrelationZoneConfig<=14, + "FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); + NCS = NCS_restricted[zeroCorrelationZoneConfig]; + fill_du(prach_fmt); + + num_preambles = 64; // compute ZC sequence for 64 possible roots + // find first non-zero shift root (stored in preamble_offset) + not_found = 1; + preamble_offset = 0; + + while (not_found == 1) { + // current root depending on rootSequenceIndex + int index = (rootSequenceIndex + preamble_offset) % N_ZC; + + if (prach_fmt<4) { + // prach_root_sequence_map points to prach_root_sequence_map0_3 + DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); + } else { + // prach_root_sequence_map points to prach_root_sequence_map4 + DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); + } + + u = prach_root_sequence_map[index]; + + uint16_t n_group_ra = 0; + + if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { + n_shift_ra = du[u]/NCS; + d_start = (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = N_ZC/d_start; + n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); + } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { + n_shift_ra = (N_ZC - (du[u]<<1))/NCS; + d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = du[u]/d_start; + n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); + } else { + n_shift_ra = 0; + n_shift_ra_bar = 0; + } + + // This is the number of cyclic shifts for the current root u + numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; + + // skip to next root and recompute parameters if numshift==0 + if (numshift>0) + not_found = 0; + else + preamble_offset++; + } + } + +#ifdef PRACH_DEBUG + + if (NCS>0) + LOG_I( PHY, "Initializing %u preambles for PRACH (NCS_config %"PRIu8", NCS %u, N_ZC/NCS %u)\n", + num_preambles, zeroCorrelationZoneConfig, NCS, N_ZC/NCS ); + +#endif + + for (i=0; i<num_preambles; i++) { + int index = (rootSequenceIndex+i+preamble_offset) % N_ZC; + + if (prach_fmt<4) { + // prach_root_sequence_map points to prach_root_sequence_map0_3 + DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); + } else { + // prach_root_sequence_map points to prach_root_sequence_map4 + DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); + } + + u = prach_root_sequence_map[index]; + + inv_u = ZC_inv[u]; // multiplicative inverse of u + + + // X_u[0] stores the first ZC sequence where the root u has a non-zero number of shifts + // for the unrestricted case X_u[0] is the first root indicated by the rootSequenceIndex + + for (k=0; k<N_ZC; k++) { + // 420 is the multiplicative inverse of 2 (required since ru is exp[j 2\pi n]) + X_u[i][k] = ((uint32_t*)ru)[(((k*(1+(inv_u*k)))%N_ZC)*420)%N_ZC]; + } + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_OUT); + +} + +void init_prach_tables(int N_ZC) +{ + + int i,m; + + // Compute the modular multiplicative inverse 'iu' of u s.t. iu*u = 1 mod N_ZC + ZC_inv[0] = 0; + ZC_inv[1] = 1; + + for (i=2; i<N_ZC; i++) { + for (m=2; m<N_ZC; m++) + if (((i*m)%N_ZC) == 1) { + ZC_inv[i] = m; + break; + } + +#ifdef PRACH_DEBUG + + if (i<16) + printf("i %d : inv %d\n",i,ZC_inv[i]); + +#endif + } + + // Compute quantized roots of unity + for (i=0; i<N_ZC; i++) { + ru[i<<1] = (int16_t)(floor(32767.0*cos(2*M_PI*(double)i/N_ZC))); + ru[1+(i<<1)] = (int16_t)(floor(32767.0*sin(2*M_PI*(double)i/N_ZC))); +#ifdef PRACH_DEBUG + + if (i<16) + printf("i %d : runity %d,%d\n",i,ru[i<<1],ru[1+(i<<1)]); + +#endif + } +} + diff --git a/openair1/PHY/LTE_TRANSPORT/prach_extern.h b/openair1/PHY/LTE_TRANSPORT/prach_extern.h new file mode 100644 index 0000000000000000000000000000000000000000..2f8a83e24f2a052e3359cd499e8dddf395a5671d --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/prach_extern.h @@ -0,0 +1,93 @@ +/* + * 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/LTE_TRANSPORT/prach_common.c + * \brief Common routines for UE/eNB PRACH physical channel V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include "PHY/sse_intrin.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" + +//#define PRACH_DEBUG 1 +//#define PRACH_WRITE_OUTPUT_DEBUG 1 + +extern uint16_t NCS_unrestricted[16]; +extern uint16_t NCS_restricted[15]; +extern uint16_t NCS_4[7]; + +extern int16_t ru[2*839]; // quantized roots of unity +extern uint32_t ZC_inv[839]; // multiplicative inverse for roots u +extern uint16_t du[838]; + + + +// This is table 5.7.1-4 from 36.211 +extern PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7]; + + + + +extern uint16_t prach_root_sequence_map0_3[838]; + + +extern uint16_t prach_root_sequence_map4[138]; + +void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + + +// This function computes the du +void fill_du(uint8_t prach_fmt); + + +uint8_t get_num_prach_tdd(module_id_t Mod_id); + + +uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index); + + +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); + + +uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf); + + +int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe); + +int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe); + + +void compute_prach_seq(uint16_t rootSequenceIndex, + uint8_t prach_ConfigIndex, + uint8_t zeroCorrelationZoneConfig, + uint8_t highSpeedFlag, + lte_frame_type_t frame_type, + uint32_t X_u[64][839]); + diff --git a/openair1/PHY/LTE_TRANSPORT/print_stats.c b/openair1/PHY/LTE_TRANSPORT/print_stats.c deleted file mode 100644 index 9e328353a4fdd975b26640822813bd4d5a909846..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_TRANSPORT/print_stats.c +++ /dev/null @@ -1,804 +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 PHY/LTE_TRANSPORT/print_stats.c -* \brief PHY statstic logging function -* \author R. Knopp, F. Kaltenberger, navid nikaein -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr -* \note -* \warning -*/ - -#include "PHY/LTE_TRANSPORT/proto.h" - -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" - -#ifdef OPENAIR2 -#include "../openair2/LAYER2/MAC/proto.h" -#include "../openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#endif - -extern int mac_get_rrc_status(uint8_t Mod_id,uint8_t eNB_flag,uint8_t index); -#if defined(OAI_USRP) || defined(EXMIMO) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) -#include "common_lib.h" -extern openair0_config_t openair0_cfg[]; -#endif - -int dump_ue_stats(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,char* buffer, int length, runmode_t mode, int input_level_dBm) -{ - - uint8_t eNB=0; - uint32_t RRC_status; - int len=length; - int harq_pid,round; - - if (ue==NULL) - return 0; - - if ((mode == normal_txrx) || (mode == no_L2_connect)) { - len += sprintf(&buffer[len], "[UE_PROC] UE %d, RNTI %x\n",ue->Mod_id, ue->pdcch_vars[0][0]->crnti); - len += sprintf(&buffer[len],"[UE PROC] RSRP[0] %.2f dBm/RE, RSSI %.2f dBm, RSRQ[0] %.2f dB, N0 %d dBm/RE (NF %.1f dB)\n", - 10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB, - 10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB, - 10*log10(ue->measurements.rsrq[0]), - ue->measurements.n0_power_tot_dBm, - (double)ue->measurements.n0_power_tot_dBm+132.24); - - /* - len += sprintf(&buffer[len], - "[UE PROC] Frame count: %d\neNB0 RSSI %d dBm/RE (%d dB, %d dB)\neNB1 RSSI %d dBm/RE (%d dB, %d dB)neNB2 RSSI %d dBm/RE (%d dB, %d dB)\nN0 %d dBm/RE, %f dBm/%dPRB (%d dB, %d dB)\n", - proc->frame_rx, - ue->measurements.rx_rssi_dBm[0], - ue->measurements.rx_power_dB[0][0], - ue->measurements.rx_power_dB[0][1], - ue->measurements.rx_rssi_dBm[1], - ue->measurements.rx_power_dB[1][0], - ue->measurements.rx_power_dB[1][1], - ue->measurements.rx_rssi_dBm[2], - ue->measurements.rx_power_dB[2][0], - ue->measurements.rx_power_dB[2][1], - ue->measurements.n0_power_tot_dBm, - ue->measurements.n0_power_tot_dBm+10*log10(12*ue->frame_parms.N_RB_DL), - ue->frame_parms.N_RB_DL, - ue->measurements.n0_power_dB[0], - ue->measurements.n0_power_dB[1]); - */ - -#ifdef EXMIMO - len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (LNA %d, vga %d dB)\n",ue->rx_total_gain_dB, openair0_cfg[0].rxg_mode[0],(int)openair0_cfg[0].rx_gain[0]); -#endif -#if defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB\n",ue->rx_total_gain_dB); -#endif -#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - len += sprintf(&buffer[len], "[UE_PROC] Frequency offset %d Hz, estimated carrier frequency %f Hz\n",ue->common_vars.freq_offset,openair0_cfg[0].rx_freq[0]-ue->common_vars.freq_offset); -#endif - len += sprintf(&buffer[len], "[UE PROC] UE mode = %s (%d)\n",mode_string[ue->UE_mode[0]],ue->UE_mode[0]); - len += sprintf(&buffer[len], "[UE PROC] timing_advance = %d\n",ue->timing_advance); - if (ue->UE_mode[0]==PUSCH) { - len += sprintf(&buffer[len], "[UE PROC] Po_PUSCH = %d dBm (PL %d dB, Po_NOMINAL_PUSCH %d dBm, PHR %d dB)\n", - ue->ulsch[0]->Po_PUSCH, - get_PL(ue->Mod_id,ue->CC_id,0), - ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH, - ue->ulsch[0]->PHR); - len += sprintf(&buffer[len], "[UE PROC] Po_PUCCH = %d dBm (Po_NOMINAL_PUCCH %d dBm, g_pucch %d dB)\n", - get_PL(ue->Mod_id,ue->CC_id,0)+ - ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH+ - ue->dlsch[0][0][0]->g_pucch, - ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH, - ue->dlsch[0][0][0]->g_pucch); - } - //for (eNB=0;eNB<NUMBER_OF_eNB_MAX;eNB++) { - for (eNB=0; eNB<1; eNB++) { - len += sprintf(&buffer[len], "[UE PROC] RX spatial power eNB%d: [%d %d; %d %d] dB\n", - eNB, - ue->measurements.rx_spatial_power_dB[eNB][0][0], - ue->measurements.rx_spatial_power_dB[eNB][0][1], - ue->measurements.rx_spatial_power_dB[eNB][1][0], - ue->measurements.rx_spatial_power_dB[eNB][1][1]); - - len += sprintf(&buffer[len], "[UE PROC] RX total power eNB%d: %d dB, avg: %d dB\n",eNB,ue->measurements.rx_power_tot_dB[eNB],ue->measurements.rx_power_avg_dB[eNB]); - len += sprintf(&buffer[len], "[UE PROC] RX total power lin: %d, avg: %d, RX total noise lin: %d, avg: %d\n",ue->measurements.rx_power_tot[eNB], - ue->measurements.rx_power_avg[eNB], ue->measurements.n0_power_tot, ue->measurements.n0_power_avg); - len += sprintf(&buffer[len], "[UE PROC] effective SINR %.2f dB\n",ue->sinr_eff); - len += sprintf(&buffer[len], "[UE PROC] Wideband CQI eNB %d: %d dB, avg: %d dB\n",eNB,ue->measurements.wideband_cqi_tot[eNB],ue->measurements.wideband_cqi_avg[eNB]); - - switch (ue->frame_parms.N_RB_DL) { - case 6: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,6))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,6)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,6))); - break; - - case 25: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5], - ue->measurements.subband_cqi_dB[eNB][0][6]); - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5], - ue->measurements.subband_cqi_dB[eNB][1][6]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0], - ue->measurements.subband_pmi_re[eNB][6][0], - ue->measurements.subband_pmi_im[eNB][6][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1], - ue->measurements.subband_pmi_re[eNB][6][1], - ue->measurements.subband_pmi_im[eNB][6][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5], - ue->measurements.selected_rx_antennas[eNB][6]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,7))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,7)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,7))); - break; - - case 50: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5], - ue->measurements.subband_cqi_dB[eNB][0][6], - ue->measurements.subband_cqi_dB[eNB][0][7], - ue->measurements.subband_cqi_dB[eNB][0][8]); - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5], - ue->measurements.subband_cqi_dB[eNB][1][6], - ue->measurements.subband_cqi_dB[eNB][1][7], - ue->measurements.subband_cqi_dB[eNB][1][8]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0], - ue->measurements.subband_pmi_re[eNB][6][0], - ue->measurements.subband_pmi_im[eNB][6][0], - ue->measurements.subband_pmi_re[eNB][7][0], - ue->measurements.subband_pmi_im[eNB][7][0], - ue->measurements.subband_pmi_re[eNB][8][0], - ue->measurements.subband_pmi_im[eNB][8][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1], - ue->measurements.subband_pmi_re[eNB][6][1], - ue->measurements.subband_pmi_im[eNB][6][1], - ue->measurements.subband_pmi_re[eNB][7][1], - ue->measurements.subband_pmi_im[eNB][7][1], - ue->measurements.subband_pmi_re[eNB][8][1], - ue->measurements.subband_pmi_im[eNB][8][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5], - ue->measurements.selected_rx_antennas[eNB][6], - ue->measurements.selected_rx_antennas[eNB][7], - ue->measurements.selected_rx_antennas[eNB][8]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,9))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,9)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,9))); - break; - - case 100: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5], - ue->measurements.subband_cqi_dB[eNB][0][6], - ue->measurements.subband_cqi_dB[eNB][0][7], - ue->measurements.subband_cqi_dB[eNB][0][8], - ue->measurements.subband_cqi_dB[eNB][0][9], - ue->measurements.subband_cqi_dB[eNB][0][10], - ue->measurements.subband_cqi_dB[eNB][0][11], - ue->measurements.subband_cqi_dB[eNB][0][12]); - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5], - ue->measurements.subband_cqi_dB[eNB][1][6], - ue->measurements.subband_cqi_dB[eNB][1][7], - ue->measurements.subband_cqi_dB[eNB][1][8], - ue->measurements.subband_cqi_dB[eNB][1][9], - ue->measurements.subband_cqi_dB[eNB][1][10], - ue->measurements.subband_cqi_dB[eNB][1][11], - ue->measurements.subband_cqi_dB[eNB][1][12]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0], - ue->measurements.subband_pmi_re[eNB][6][0], - ue->measurements.subband_pmi_im[eNB][6][0], - ue->measurements.subband_pmi_re[eNB][7][0], - ue->measurements.subband_pmi_im[eNB][7][0], - ue->measurements.subband_pmi_re[eNB][8][0], - ue->measurements.subband_pmi_im[eNB][8][0], - ue->measurements.subband_pmi_re[eNB][9][0], - ue->measurements.subband_pmi_im[eNB][9][0], - ue->measurements.subband_pmi_re[eNB][10][0], - ue->measurements.subband_pmi_im[eNB][10][0], - ue->measurements.subband_pmi_re[eNB][11][0], - ue->measurements.subband_pmi_im[eNB][11][0], - ue->measurements.subband_pmi_re[eNB][12][0], - ue->measurements.subband_pmi_im[eNB][12][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1], - ue->measurements.subband_pmi_re[eNB][6][1], - ue->measurements.subband_pmi_im[eNB][6][1], - ue->measurements.subband_pmi_re[eNB][7][1], - ue->measurements.subband_pmi_im[eNB][7][1], - ue->measurements.subband_pmi_re[eNB][8][1], - ue->measurements.subband_pmi_im[eNB][8][1], - ue->measurements.subband_pmi_re[eNB][9][1], - ue->measurements.subband_pmi_im[eNB][9][1], - ue->measurements.subband_pmi_re[eNB][10][1], - ue->measurements.subband_pmi_im[eNB][10][1], - ue->measurements.subband_pmi_re[eNB][11][1], - ue->measurements.subband_pmi_im[eNB][11][1], - ue->measurements.subband_pmi_re[eNB][12][1], - ue->measurements.subband_pmi_im[eNB][12][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5], - ue->measurements.selected_rx_antennas[eNB][6], - ue->measurements.selected_rx_antennas[eNB][7], - ue->measurements.selected_rx_antennas[eNB][8], - ue->measurements.selected_rx_antennas[eNB][9], - ue->measurements.selected_rx_antennas[eNB][10], - ue->measurements.selected_rx_antennas[eNB][11], - ue->measurements.selected_rx_antennas[eNB][12]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,13))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,13)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,13))); - break; - } - -#ifdef OPENAIR2 - RRC_status = mac_UE_get_rrc_status(ue->Mod_id, 0); - len += sprintf(&buffer[len],"[UE PROC] RRC status = %d\n",RRC_status); -#endif - - - len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d \n",ue->transmission_mode[eNB]); - len += sprintf(&buffer[len], "[UE PROC] PBCH err conseq %d, PBCH error total %d, PBCH FER %d\n", - ue->pbch_vars[eNB]->pdu_errors_conseq, - ue->pbch_vars[eNB]->pdu_errors, - ue->pbch_vars[eNB]->pdu_fer); - - if (ue->transmission_mode[eNB] == 6) - len += sprintf(&buffer[len], "[UE PROC] Mode 6 Wideband CQI eNB %d : %d dB\n",eNB,ue->measurements.precoded_cqi_dB[eNB][0]); - - for (harq_pid=0;harq_pid<8;harq_pid++) { - len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 0 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][0]->harq_processes[harq_pid]->mcs); - for (round=0;round<8;round++) - len+=sprintf(&buffer[len],"%d/%d ", - ue->dlsch[0][0][0]->harq_processes[harq_pid]->errors[round], - ue->dlsch[0][0][0]->harq_processes[harq_pid]->trials[round]); - len+=sprintf(&buffer[len],"\n"); - } - if (ue->dlsch[0][0] && ue->dlsch[0][0][0] && ue->dlsch[0][0][1]) { - len += sprintf(&buffer[len], "[UE PROC] Saved PMI for DLSCH eNB %d : %jx (%p)\n",eNB,pmi2hex_2Ar1(ue->dlsch[0][0][0]->pmi_alloc),ue->dlsch[0][0][0]); - - len += sprintf(&buffer[len], "[UE PROC] eNB %d: dl_power_off = %d\n",eNB,ue->dlsch[0][0][0]->harq_processes[0]->dl_power_off); - - for (harq_pid=0;harq_pid<8;harq_pid++) { - len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 1 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][1]->harq_processes[0]->mcs); - for (round=0;round<8;round++) - len+=sprintf(&buffer[len],"%d/%d ", - ue->dlsch[0][0][1]->harq_processes[harq_pid]->errors[round], - ue->dlsch[0][0][1]->harq_processes[harq_pid]->trials[round]); - len+=sprintf(&buffer[len],"\n"); - } - } - - len += sprintf(&buffer[len], "[UE PROC] DLSCH Total %d, Error %d, FER %d\n",ue->dlsch_received[0],ue->dlsch_errors[0],ue->dlsch_fer[0]); - len += sprintf(&buffer[len], "[UE PROC] DLSCH (SI) Total %d, Error %d\n",ue->dlsch_SI_received[0],ue->dlsch_SI_errors[0]); - len += sprintf(&buffer[len], "[UE PROC] DLSCH (RA) Total %d, Error %d\n",ue->dlsch_ra_received[0],ue->dlsch_ra_errors[0]); -#if defined(Rel10) || defined(Rel14) - int i=0; - - //len += sprintf(&buffer[len], "[UE PROC] MCH Total %d\n", ue->dlsch_mch_received[0]); - for(i=0; i <ue->frame_parms.num_MBSFN_config; i++ ) { - len += sprintf(&buffer[len], "[UE PROC] MCH (MCCH MBSFN %d) Total %d, Error %d, Trials %d\n", - i, ue->dlsch_mcch_received[i][0],ue->dlsch_mcch_errors[i][0],ue->dlsch_mcch_trials[i][0]); - len += sprintf(&buffer[len], "[UE PROC] MCH (MTCH MBSFN %d) Total %d, Error %d, Trials %d\n", - i, ue->dlsch_mtch_received[i][0],ue->dlsch_mtch_errors[i][0],ue->dlsch_mtch_trials[i][0]); - } - -#endif - len += sprintf(&buffer[len], "[UE PROC] DLSCH Bitrate %dkbps\n",(ue->bitrate[0]/1000)); - len += sprintf(&buffer[len], "[UE PROC] Total Received Bits %dkbits\n",(ue->total_received_bits[0]/1000)); - len += sprintf(&buffer[len], "[UE PROC] IA receiver %d\n",ue->use_ia_receiver); - - } - - } else { - len += sprintf(&buffer[len], "[UE PROC] Frame count: %d, RSSI %3.2f dB (%d dB, %d dB), N0 %3.2f dB (%d dB, %d dB)\n", - proc->frame_rx, - 10*log10(ue->measurements.rssi), - ue->measurements.rx_power_dB[0][0], - ue->measurements.rx_power_dB[0][1], - 10*log10(ue->measurements.n0_power_tot), - ue->measurements.n0_power_dB[0], - ue->measurements.n0_power_dB[1]); -#ifdef EXMIMO - ue->rx_total_gain_dB = ((int)(10*log10(ue->measurements.rssi)))-input_level_dBm; - len += sprintf(&buffer[len], "[UE PROC] rxg_mode %d, input level (set by user) %d dBm, VGA gain %d dB ==> total gain %3.2f dB, noise figure %3.2f dB\n", - openair0_cfg[0].rxg_mode[0], - input_level_dBm, - (int)openair0_cfg[0].rx_gain[0], - 10*log10(ue->measurements.rssi)-input_level_dBm, - 10*log10(ue->measurements.n0_power_tot)-ue->rx_total_gain_dB+105); -#endif - } - - len += sprintf(&buffer[len],"EOF\n"); - - return len; -} // is_clusterhead - -/* -int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length) -{ - - unsigned int success=0; - uint8_t eNB_id,UE_id,i,j,number_of_cards_l=1; - uint32_t ulsch_errors=0,dlsch_errors=0; - uint32_t ulsch_round_attempts[4]= {0,0,0,0},ulsch_round_errors[4]= {0,0,0,0}; - uint32_t dlsch_round_attempts[4]= {0,0,0,0},dlsch_round_errors[4]= {0,0,0,0}; - uint32_t UE_id_mac, RRC_status; - eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0]; - if (eNB==NULL) - return 0; - - int len = length; - - // if(eNB->frame==0){ - eNB->total_dlsch_bitrate = 0;//eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate; - eNB->total_transmitted_bits = 0;// eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_transmitted_bits; - eNB->total_system_throughput = 0;//eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput; - // } - - for (eNB_id=0; eNB_id<number_of_cards_l; eNB_id++) { - len += sprintf(&buffer[len],"eNB %d/%d Frame %d: RX Gain %d dB, I0 %d dBm (%d,%d) dB \n", - eNB_id,number_of_cards_l, - proc->frame_tx, - eNB->rx_total_gain_dB, - eNB->measurements.n0_power_tot_dBm, - eNB->measurements.n0_power_dB[0], - eNB->measurements.n0_power_dB[1]); - - len += sprintf(&buffer[len],"PRB I0 (%X.%X.%X.%X): ", - eNB->rb_mask_ul[0], - eNB->rb_mask_ul[1],eNB->rb_mask_ul[2],eNB->rb_mask_ul[3]); - - for (i=0; i<eNB->frame_parms.N_RB_UL; i++) { - len += sprintf(&buffer[len],"%4d ", - eNB->measurements.n0_subband_power_tot_dBm[i]); - if ((i>0) && ((i%25) == 0)) - len += sprintf(&buffer[len],"\n"); - } - len += sprintf(&buffer[len],"\n"); - len += sprintf(&buffer[len],"\nPERFORMANCE PARAMETERS\n"); - - for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - if (eNB && - (eNB->dlsch!=NULL) && - (eNB->dlsch[(uint8_t)UE_id]!=NULL) && - (eNB->dlsch[(uint8_t)UE_id][0]->rnti>0)&& - (eNB->UE_stats[UE_id].mode == PUSCH)) { - - eNB->total_dlsch_bitrate = eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate; - eNB->total_transmitted_bits = eNB->UE_stats[UE_id].total_TBS + eNB->total_transmitted_bits; - - //eNB->total_system_throughput = eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput; - - for (i=0; i<8; i++) - success = success + (eNB->UE_stats[UE_id].dlsch_trials[i][0] - eNB->UE_stats[UE_id].dlsch_l2_errors[i]); - - - - len += sprintf(&buffer[len],"Total DLSCH %d kbits / %d frames ",(eNB->total_transmitted_bits/1000),proc->frame_tx+1); - len += sprintf(&buffer[len],"Total DLSCH throughput %d kbps ",(eNB->total_dlsch_bitrate/1000)); - len += sprintf(&buffer[len],"Total DLSCH trans %d / %d frames\n",success,proc->frame_tx+1); - //len += sprintf(&buffer[len],"[eNB PROC] FULL MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->FULL_MUMIMO_transmissions,eNB->check_for_total_transmissions); - //len += sprintf(&buffer[len],"[eNB PROC] MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_MUMIMO_transmissions,eNB->check_for_total_transmissions); - //len += sprintf(&buffer[len],"[eNB PROC] SU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_SUMIMO_transmissions,eNB->check_for_total_transmissions); - - len += sprintf(&buffer[len],"UE %d (%x) Power: (%d,%d) dB, Po_PUSCH: (%d,%d) dBm, Po_PUCCH (%d/%d) dBm, Po_PUCCH1 (%d,%d) dBm, PUCCH1 Thres %d dBm \n", - UE_id, - eNB->UE_stats[UE_id].crnti, - dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[0]), - dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[1]), - eNB->UE_stats[UE_id].UL_rssi[0], - eNB->UE_stats[UE_id].UL_rssi[1], - dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB, - eNB->frame_parms.ul_power_control_config_common.p0_NominalPUCCH, - dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_below/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB, - dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_above/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB, - PUCCH1_THRES+eNB->measurements.n0_power_tot_dBm-dB_fixed(eNB->frame_parms.N_RB_UL)); - - len+= sprintf(&buffer[len],"DL mcs %d, UL mcs %d, UL rb %d, delta_TF %d, ", - eNB->dlsch[(uint8_t)UE_id][0]->harq_processes[0]->mcs, - eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->mcs, - eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->nb_rb, - eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->delta_TF); - - len += sprintf(&buffer[len],"Wideband CQI: (%d,%d) dB\n", - eNB->measurements.wideband_cqi_dB[UE_id][0], - eNB->measurements.wideband_cqi_dB[UE_id][1]); - - len += sprintf(&buffer[len],"DL TM %d, DL_cqi %d, DL_pmi_single %jx ", - eNB->transmission_mode[UE_id], - eNB->UE_stats[UE_id].DL_cqi[0], - pmi2hex_2Ar1(eNB->UE_stats[UE_id].DL_pmi_single)); - - len += sprintf(&buffer[len],"Timing advance %d samples (%d 16Ts), update %d ", - eNB->UE_stats[UE_id].UE_timing_offset, - eNB->UE_stats[UE_id].UE_timing_offset>>2, - eNB->UE_stats[UE_id].timing_advance_update); - - len += sprintf(&buffer[len],"Mode = %s(%d) ", - mode_string[eNB->UE_stats[UE_id].mode], - eNB->UE_stats[UE_id].mode); - UE_id_mac = find_UE_id(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti); - - if (UE_id_mac != -1) { - RRC_status = mac_eNB_get_rrc_status(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti); - len += sprintf(&buffer[len],"UE_id_mac = %d, RRC status = %d\n",UE_id_mac,RRC_status); - } else - len += sprintf(&buffer[len],"UE_id_mac = -1\n"); - - len += sprintf(&buffer[len],"SR received/total: %d/%d (diff %d)\n", - eNB->UE_stats[UE_id].sr_received, - eNB->UE_stats[UE_id].sr_total, - eNB->UE_stats[UE_id].sr_total-eNB->UE_stats[UE_id].sr_received); - - len += sprintf(&buffer[len],"DL Subband CQI: "); - - int nb_sb; - switch (eNB->frame_parms.N_RB_DL) { - case 6: - nb_sb=0; - break; - case 15: - nb_sb = 4; - case 25: - nb_sb = 7; - break; - case 50: - nb_sb = 9; - break; - case 75: - nb_sb = 10; - break; - case 100: - nb_sb = 13; - break; - default: - nb_sb=0; - break; - } - for (i=0; i<nb_sb; i++) - len += sprintf(&buffer[len],"%2d ", - eNB->UE_stats[UE_id].DL_subband_cqi[0][i]); - len += sprintf(&buffer[len],"\n"); - - - - ulsch_errors = 0; - - for (j=0; j<4; j++) { - ulsch_round_attempts[j]=0; - ulsch_round_errors[j]=0; - } - - len += sprintf(&buffer[len],"ULSCH errors/attempts per harq (per round): \n"); - - for (i=0; i<8; i++) { - len += sprintf(&buffer[len]," harq %d: %d/%d (fer %d) (%d/%d, %d/%d, %d/%d, %d/%d) ", - i, - eNB->UE_stats[UE_id].ulsch_errors[i], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0], - eNB->UE_stats[UE_id].ulsch_round_fer[i][0], - eNB->UE_stats[UE_id].ulsch_round_errors[i][0], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0], - eNB->UE_stats[UE_id].ulsch_round_errors[i][1], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][1], - eNB->UE_stats[UE_id].ulsch_round_errors[i][2], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][2], - eNB->UE_stats[UE_id].ulsch_round_errors[i][3], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][3]); - if ((i&1) == 1) - len += sprintf(&buffer[len],"\n"); - - ulsch_errors+=eNB->UE_stats[UE_id].ulsch_errors[i]; - - for (j=0; j<4; j++) { - ulsch_round_attempts[j]+=eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][j]; - ulsch_round_errors[j]+=eNB->UE_stats[UE_id].ulsch_round_errors[i][j]; - } - } - - len += sprintf(&buffer[len],"ULSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d)\n", - ulsch_errors,ulsch_round_attempts[0], - - ulsch_round_errors[0],ulsch_round_attempts[0], - ulsch_round_errors[1],ulsch_round_attempts[1], - ulsch_round_errors[2],ulsch_round_attempts[2], - ulsch_round_errors[3],ulsch_round_attempts[3]); - - dlsch_errors = 0; - - for (j=0; j<4; j++) { - dlsch_round_attempts[j]=0; - dlsch_round_errors[j]=0; - } - - len += sprintf(&buffer[len],"DLSCH errors/attempts per harq (per round): \n"); - - for (i=0; i<8; i++) { - len += sprintf(&buffer[len]," harq %d: %d/%d (%d/%d/%d, %d/%d/%d, %d/%d/%d, %d/%d/%d) ", - i, - eNB->UE_stats[UE_id].dlsch_l2_errors[i], - eNB->UE_stats[UE_id].dlsch_trials[i][0], - eNB->UE_stats[UE_id].dlsch_ACK[i][0], - eNB->UE_stats[UE_id].dlsch_NAK[i][0], - eNB->UE_stats[UE_id].dlsch_trials[i][0], - eNB->UE_stats[UE_id].dlsch_ACK[i][1], - eNB->UE_stats[UE_id].dlsch_NAK[i][1], - eNB->UE_stats[UE_id].dlsch_trials[i][1], - eNB->UE_stats[UE_id].dlsch_ACK[i][2], - eNB->UE_stats[UE_id].dlsch_NAK[i][2], - eNB->UE_stats[UE_id].dlsch_trials[i][2], - eNB->UE_stats[UE_id].dlsch_ACK[i][3], - eNB->UE_stats[UE_id].dlsch_NAK[i][3], - eNB->UE_stats[UE_id].dlsch_trials[i][3]); - if ((i&1) == 1) - len += sprintf(&buffer[len],"\n"); - - - dlsch_errors+=eNB->UE_stats[UE_id].dlsch_l2_errors[i]; - - for (j=0; j<4; j++) { - dlsch_round_attempts[j]+=eNB->UE_stats[UE_id].dlsch_trials[i][j]; - dlsch_round_errors[j]+=eNB->UE_stats[UE_id].dlsch_NAK[i][j]; - } - } - - len += sprintf(&buffer[len],"DLSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d): \n", - dlsch_errors,dlsch_round_attempts[0], - dlsch_round_errors[0],dlsch_round_attempts[0], - dlsch_round_errors[1],dlsch_round_attempts[1], - dlsch_round_errors[2],dlsch_round_attempts[2], - dlsch_round_errors[3],dlsch_round_attempts[3]); - - - len += sprintf(&buffer[len],"DLSCH total bits from MAC: %dkbit ",(eNB->UE_stats[UE_id].total_TBS_MAC)/1000); - len += sprintf(&buffer[len],"DLSCH total bits ack'ed: %dkbit ",(eNB->UE_stats[UE_id].total_TBS)/1000); - len += sprintf(&buffer[len],"DLSCH Average throughput (100 frames): %dkbps\n",(eNB->UE_stats[UE_id].dlsch_bitrate/1000)); - // len += sprintf(&buffer[len],"[eNB PROC] Transmission Mode %d\n",eNB->transmission_mode[UE_id]); - } - } - - len += sprintf(&buffer[len],"\n"); - } - - len += sprintf(&buffer[len],"EOF\n"); - - return len; -} -*/ diff --git a/openair1/PHY/LTE_TRANSPORT/pss.c b/openair1/PHY/LTE_TRANSPORT/pss.c index c746a331db246e2e46139d4386120389d3549557..c02d08750bf40e90ef5fd34ce555fb581aee6b12 100644 --- a/openair1/PHY/LTE_TRANSPORT/pss.c +++ b/openair1/PHY/LTE_TRANSPORT/pss.c @@ -36,8 +36,8 @@ */ //#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" int generate_pss(int32_t **txdataF, short amp, @@ -105,10 +105,3 @@ int generate_pss(int32_t **txdataF, return(0); } -int generate_pss_emul(PHY_VARS_eNB *phy_vars_eNb,uint8_t sect_id) -{ - - LOG_D(PHY,"EMUL eNB generate_pss_emul eNB %d, sect_id %d\n",phy_vars_eNb->Mod_id,sect_id); - eNB_transport_info[phy_vars_eNb->Mod_id][phy_vars_eNb->CC_id].cntl.pss=sect_id; - return(0); -} diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index bb0ae8e11cee2ee59987b62b80d12945abbe40ba..e7aa11d30ad4b6b2fa069b6a2dd3f254979a734f 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -29,9 +29,10 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "LAYER2/MAC/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "LAYER2/MAC/mac.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" @@ -42,6 +43,8 @@ //#define DEBUG_PUCCH_TXS //#define DEBUG_PUCCH_RX +#include "pucch_extern.h" + int16_t cfo_pucch_np[24*7] = {20787,-25330,27244,-18205,31356,-9512,32767,0,31356,9511,27244,18204,20787,25329, 27244,-18205,30272,-12540,32137,-6393,32767,0,32137,6392,30272,12539,27244,18204, 31356,-9512,32137,-6393,32609,-3212,32767,0,32609,3211,32137,6392,31356,9511, @@ -61,1083 +64,6 @@ int16_t cfo_pucch_ep[24*6] = {24278,-22005,29621,-14010,32412,-4808,32412,4807,2 }; -void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]) -{ - - uint8_t ns,l,reset=1,i,N_UL_symb; - uint32_t x1,x2,j=0,s=0; - - N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; - x2 = frame_parms->Nid_cell; - - for (ns=0; ns<20; ns++) { - - for (l=0; l<N_UL_symb; l++) { - ncs_cell[ns][l]=0; - - for (i=0; i<8; i++) { - if ((j%32) == 0) { - s = lte_gold_generic(&x1,&x2,reset); - // printf("s %x\n",s); - reset=0; - } - - if (((s>>(j%32))&1)==1) - ncs_cell[ns][l] += (1<<i); - - j++; - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH ncs_cell init (j %d): Ns %d, l %d => ncs_cell %d\n",j,ns,l,ncs_cell[ns][l]); -#endif - } - - } -} - -int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377}; -int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384}; - -int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, - {32767,-32768, 32767,-32768}, - {32767,-32768,-32768, 32767} -}; -int16_t W3_re[3][6] = {{32767, 32767, 32767}, - {32767,-16384,-16384}, - {32767,-16384,-16384} -}; - -int16_t W3_im[3][6] = {{0 ,0 ,0 }, - {0 , 28377,-28378}, - {0 ,-28378, 28377} -}; - -char *pucch_format_string[] = { - "format 1", - "format 1a", - "format 1b", - "pucch_format1b_csA2", - "pucch_format1b_csA3", - "pucch_format1b_csA4", - "format 2", - "format 2a", - "format 2b", - "pucch_format3" -}; - -/* PUCCH format3 >> */ -#define D_I 0 -#define D_Q 1 -#define D_IQDATA 2 -#define D_NSLT1SF 2 -#define D_NSYM1SLT 7 -#define D_NSYM1SF 2*7 -#define D_NSC1RB 12 -#define D_NRB1PUCCH 2 -#define D_NPUCCH_SF5 5 -#define D_NPUCCH_SF4 4 - -uint8_t chcod_tbl[128][48] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1}, - {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0}, - {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0}, - {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1}, - {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1}, - {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}, - {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0}, - {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1}, - {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1}, - {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0}, - {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0}, - {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1}, - {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1}, - {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1}, - {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}, - {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0}, - {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1}, - {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1}, - {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0}, - {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1}, - {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1}, - {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0}, - {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0}, - {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1}, - {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, - {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, - {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0}, - {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, - {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, - {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1}, - {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1}, - {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0}, - {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0}, - {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1}, - {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1}, - {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0}, - {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0}, - {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1}, - {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1}, - {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0}, - {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0}, - {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1}, - {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, - {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, - {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1}, - {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0}, - {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0}, - {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1}, - {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1}, - {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0}, - {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0}, - {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1}, - {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1}, - {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0}, - {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, - {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1}, - {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1}, - {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0}, - {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1}, - {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0}, - {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0}, - {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1}, - {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, - {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, - {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1}, - {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1}, - {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}, - {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0}, - {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1}, - {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1}, - {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0}, - {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0}, - {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1}, - {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0}, - {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1}, - {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1}, - {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0}, - {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0}, - {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1}, - {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1}, - {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0}, - {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1}, - {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1}, - {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0}, - {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0}, - {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1}, - {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0}, - {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1}, - {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1}, - {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0}, - {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}, - {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1}, - {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1}, - {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0}, - {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0}, - {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1}, - {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1}, - {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0}, - {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0}, - {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1}, - {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1}, - {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1}, - {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0}, - {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1}, - {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, - {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, - {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0}, - {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1}, - {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}, - {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0}, - {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0}, - {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1}, - {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1}, - {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0}, - {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0}, - {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1} }; - -// W5_TBL -int16_t W5_fmt3_re[5][5] = { {32767, 32767, 32767, 32767, 32767}, - {32767, 10125, -26509, -26509, 10125}, - {32767, -26509, 10125, 10125, -26509}, - {32767, -26509, 10125, 10125, -26509}, - {32767, 10125, -26509, -26509, 10125} }; - -int16_t W5_fmt3_im[5][5] = { {0, 0, 0, 0, 0}, - {0, 31163, 19259, -19259, -31163}, - {0, 19259, -31163, 31163, -19259}, - {0, -19259, 31163, -31163, 19259}, - {0, -31163, -19259, 19259, 31163} }; - -int16_t W4_fmt3[4][4] = { {32767, 32767, 32767, 32767}, - {32767, -32767, 32767, -32767}, - {32767, 32767, -32767, -32767}, - {32767, -32767, -32767, 32767} }; - -// W2 TBL -int16_t W2[2] = {32767, 32767}; - -// e^j*pai*floor (ncs_cell(ns,l)/64)/2 -int16_t RotTBL_re[4] = {32767, 0, -32767, 0}; -int16_t RotTBL_im[4] = {0, 32767, 0, -32767}; - -//np4_tbl, np5_tbl -uint8_t Np5_TBL[5] = {0, 3, 6, 8, 10}; -uint8_t Np4_TBL[4] = {0, 3, 6, 9}; - -// alpha_TBL -int16_t alphaTBL_re[12] = {32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383, 0, 16383, 28377}; -int16_t alphaTBL_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383}; - -/* PUCCH format3 << */ - -void generate_pucch1x(int32_t **txdataF, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n1_pucch, - uint8_t shortened_format, - uint8_t *payload, - int16_t amp, - uint8_t subframe) -{ - - uint32_t u,v,n; - uint32_t z[12*14],*zptr; - int16_t d0; - uint8_t ns,N_UL_symb,nsymb,n_oc,n_oc0,n_oc1; - uint8_t c = (frame_parms->Ncp==0) ? 3 : 2; - uint16_t nprime,nprime0,nprime1; - uint16_t i,j,re_offset,thres,h; - uint8_t Nprime_div_deltaPUCCH_Shift,Nprime,d; - uint8_t m,l,refs; - uint8_t n_cs,S,alpha_ind,rem; - int16_t tmp_re,tmp_im,ref_re,ref_im,W_re=0,W_im=0; - int32_t *txptr; - uint32_t symbol_offset; - - uint8_t deltaPUCCH_Shift = frame_parms->pucch_config_common.deltaPUCCH_Shift; - uint8_t NRB2 = frame_parms->pucch_config_common.nRB_CQI; - uint8_t Ncs1 = frame_parms->pucch_config_common.nCS_AN; - uint8_t Ncs1_div_deltaPUCCH_Shift = Ncs1/deltaPUCCH_Shift; - - LOG_D(PHY,"generate_pucch Start [deltaPUCCH_Shift %d, NRB2 %d, Ncs1_div_deltaPUCCH_Shift %d, n1_pucch %d]\n", deltaPUCCH_Shift, NRB2, Ncs1_div_deltaPUCCH_Shift,n1_pucch); - - - uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; - uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; - uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; - uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; - - if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { - printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); - return; - } - - if (Ncs1_div_deltaPUCCH_Shift > 7) { - printf("[PHY] generate_pucch: Illegal Ncs1_div_deltaPUCCH_Shift %d (should be 0...7)\n",Ncs1_div_deltaPUCCH_Shift); - return; - } - - zptr = z; - thres = (c*Ncs1_div_deltaPUCCH_Shift); - Nprime_div_deltaPUCCH_Shift = (n1_pucch < thres) ? Ncs1_div_deltaPUCCH_Shift : (12/deltaPUCCH_Shift); - Nprime = Nprime_div_deltaPUCCH_Shift * deltaPUCCH_Shift; - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: cNcs1/deltaPUCCH_Shift %d, Nprime %d, n1_pucch %d\n",thres,Nprime,n1_pucch); -#endif - - LOG_D(PHY,"[PHY] PUCCH: n1_pucch %d, thres %d Ncs1_div_deltaPUCCH_Shift %d (12/deltaPUCCH_Shift) %d Nprime_div_deltaPUCCH_Shift %d \n", - n1_pucch, thres, Ncs1_div_deltaPUCCH_Shift, (int)(12/deltaPUCCH_Shift), Nprime_div_deltaPUCCH_Shift); - LOG_D(PHY,"[PHY] PUCCH: deltaPUCCH_Shift %d, Nprime %d\n",deltaPUCCH_Shift,Nprime); - - - N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; - - if (n1_pucch < thres) - nprime0=n1_pucch; - else - nprime0 = (n1_pucch - thres)%(12*c/deltaPUCCH_Shift); - - if (n1_pucch >= thres) - nprime1= ((c*(nprime0+1))%((12*c/deltaPUCCH_Shift)+1))-1; - else { - d = (frame_parms->Ncp==0) ? 2 : 0; - h= (nprime0+d)%(c*Nprime_div_deltaPUCCH_Shift); -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: h %d, d %d\n",h,d); -#endif - nprime1 = (h/c) + (h%c)*Nprime_div_deltaPUCCH_Shift; - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: nprime0 %d nprime1 %d, %s, payload (%d,%d)\n",nprime0,nprime1,pucch_format_string[fmt],payload[0],payload[1]); -#endif - - n_oc0 = nprime0/Nprime_div_deltaPUCCH_Shift; - - if (frame_parms->Ncp==1) - n_oc0<<=1; - - n_oc1 = nprime1/Nprime_div_deltaPUCCH_Shift; - - if (frame_parms->Ncp==1) // extended CP - n_oc1<<=1; - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: noc0 %d noc1 %d\n",n_oc0,n_oc1); -#endif - - nprime=nprime0; - n_oc =n_oc0; - - // loop over 2 slots - for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { - - if ((nprime&1) == 0) - S=0; // 1 - else - S=1; // j - - //loop over symbols in slot - for (l=0; l<N_UL_symb; l++) { - // Compute n_cs (36.211 p. 18) - n_cs = ncs_cell[ns][l]; - - if (frame_parms->Ncp==0) { // normal CP - n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc%deltaPUCCH_Shift))%Nprime)%12; - } else { - n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc>>1))%Nprime)%12; - } - - - refs=0; - - // Comput W_noc(m) (36.211 p. 19) - if ((ns==(1+(subframe<<1))) && (shortened_format==1)) { // second slot and shortened format - - if (l<2) { // data - W_re=W3_re[n_oc][l]; - W_im=W3_im[n_oc][l]; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP - W_re=W3_re[n_oc][l-2]; - W_im=W3_im[n_oc][l-2]; - refs=1; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP - W_re=W4[n_oc][l-2]; - W_im=0; - refs=1; - } else if ((l>=N_UL_symb-2)) { // data - W_re=W3_re[n_oc][l-N_UL_symb+4]; - W_im=W3_im[n_oc][l-N_UL_symb+4]; - } - } else { - if (l<2) { // data - W_re=W4[n_oc][l]; - W_im=0; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP - W_re=W3_re[n_oc][l-2]; - W_im=W3_im[n_oc][l-2]; - refs=1; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP - W_re=W4[n_oc][l-2]; - W_im=0; - refs=1; - } else if ((l>=N_UL_symb-2)) { // data - W_re=W4[n_oc][l-N_UL_symb+4]; - W_im=0; - } - } - - // multiply W by S(ns) (36.211 p.17). only for data, reference symbols do not have this factor - if ((S==1)&&(refs==0)) { - tmp_re = W_re; - W_re = -W_im; - W_im = tmp_re; - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: ncs[%d][%d]=%d, W_re %d, W_im %d, S %d, refs %d\n",ns,l,n_cs,W_re,W_im,S,refs); -#endif - alpha_ind=0; - // compute output sequence - - for (n=0; n<12; n++) { - - // this is r_uv^alpha(n) - tmp_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); - tmp_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); - - // this is S(ns)*w_noc(m)*r_uv^alpha(n) - ref_re = (tmp_re*W_re - tmp_im*W_im)>>15; - ref_im = (tmp_re*W_im + tmp_im*W_re)>>15; - - if ((l<2)||(l>=(N_UL_symb-2))) { //these are PUCCH data symbols - switch (fmt) { - case pucch_format1: //OOK 1-bit - - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; - - break; - - case pucch_format1a: //BPSK 1-bit - d0 = (payload[0]&1)==0 ? amp : -amp; - ((int16_t *)&zptr[n])[0] = ((int32_t)d0*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)d0*ref_im)>>15; - // printf("d0 %d\n",d0); - break; - - case pucch_format1b: //QPSK 2-bits (Table 5.4.1-1 from 36.211, pg. 18) - if (((payload[0]&1)==0) && ((payload[1]&1)==0)) {// 1 - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; - } else if (((payload[0]&1)==0) && ((payload[1]&1)==1)) { // -j - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_im)>>15; - ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_re)>>15; - } else if (((payload[0]&1)==1) && ((payload[1]&1)==0)) { // j - ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_im)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_re)>>15; - } else { // -1 - ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_im)>>15; - } - - break; - case pucch_format1b_csA2: - case pucch_format1b_csA3: - case pucch_format1b_csA4: - AssertFatal(1==0,"PUCCH format 1b_csX not supported yet\n"); - break; - case pucch_format2: - case pucch_format2a: - case pucch_format2b: - AssertFatal(1==0,"should not go here\n"); - break; - - case pucch_format3: - fprintf(stderr, "PUCCH format 3 not handled\n"); - abort(); - } // switch fmt - } else { // These are PUCCH reference symbols - - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; - // printf("ref\n"); - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH subframe %d z(%d,%d) => %d,%d, alpha(%d) => %d,%d\n",subframe,l,n,((int16_t *)&zptr[n])[0],((int16_t *)&zptr[n])[1], - alpha_ind,alpha_re[alpha_ind],alpha_im[alpha_ind]); -#endif - alpha_ind = (alpha_ind + n_cs)%12; - } // n - - zptr+=12; - } // l - - nprime=nprime1; - n_oc =n_oc1; - } // ns - - rem = ((((12*Ncs1_div_deltaPUCCH_Shift)>>3)&7)>0) ? 1 : 0; - - m = (n1_pucch < thres) ? NRB2 : (((n1_pucch-thres)/(12*c/deltaPUCCH_Shift))+NRB2+((deltaPUCCH_Shift*Ncs1_div_deltaPUCCH_Shift)>>3)+rem); - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: m %d\n",m); -#endif - nsymb = N_UL_symb<<1; - - //for (j=0,l=0;l<(nsymb-1);l++) { - for (j=0,l=0; l<(nsymb); l++) { - if ((l<(nsymb>>1)) && ((m&1) == 0)) - re_offset = (m*6) + frame_parms->first_carrier_offset; - else if ((l<(nsymb>>1)) && ((m&1) == 1)) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else if ((m&1) == 0) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else - re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; - - if (re_offset > frame_parms->ofdm_symbol_size) - re_offset -= (frame_parms->ofdm_symbol_size); - - symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb)); - txptr = &txdataF[0][symbol_offset]; - - for (i=0; i<12; i++,j++) { - txptr[re_offset++] = z[j]; - - if (re_offset==frame_parms->ofdm_symbol_size) - re_offset = 0; - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); -#endif - } - } - -} - -void generate_pucch_emul(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - PUCCH_FMT_t format, - uint8_t ncs1, - uint8_t *pucch_payload, - uint8_t sr) - -{ - - int subframe = proc->subframe_tx; - - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_flag = format; - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_Ncs1 = ncs1; - - - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.sr = sr; - // the value of ue->pucch_sel[subframe] is set by get_n1_pucch - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_sel = ue->pucch_sel[subframe]; - - // LOG_I(PHY,"subframe %d emu tx pucch_sel is %d sr is %d \n", subframe, UE_transport_info[ue->Mod_id].cntl.pucch_sel, sr); - - if (format == pucch_format1a) { - - ue->pucch_payload[0] = pucch_payload[0]; - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_payload = pucch_payload[0]; - } else if (format == pucch_format1b) { - ue->pucch_payload[0] = pucch_payload[0] + (pucch_payload[1]<<1); - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_payload = pucch_payload[0] + (pucch_payload[1]<<1); - } else if (format == pucch_format1) { - // LOG_D(PHY,"[UE %d] Frame %d subframe %d Generating PUCCH for SR %d\n",ue->Mod_id,proc->frame_tx,subframe,sr); - } - - ue->sr[subframe] = sr; - -} - - -inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) __attribute__((always_inline)); -inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) { - - uint32_t x1, x2, s=0; - int i; - uint8_t c; - - x2 = (rnti) + ((uint32_t)(1+subframe)<<16)*(1+(fp->Nid_cell<<1)); //this is c_init in 36.211 Sec 6.3.1 - s = lte_gold_generic(&x1, &x2, 1); - for (i=0;i<19;i++) { - c = (uint8_t)((s>>i)&1); - btilde[i] = (((B>>i)&1) ^ c); - } -} - -inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) __attribute__((always_inline)); -inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) { - - int i; - - for (i=0;i<20;i++) - d[i] = btilde[i] == 1 ? -amp : amp; - -} - - - -uint32_t pucch_code[13] = {0xFFFFF,0x5A933,0x10E5A,0x6339C,0x73CE0, - 0xFFC00,0xD8E64,0x4F6B0,0x218EC,0x1B746, - 0x0FFFF,0x33FFF,0x3FFFC}; - - -void generate_pucch2x(int32_t **txdataF, - LTE_DL_FRAME_PARMS *fp, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n2_pucch, - uint8_t *payload, - int A, - int B2, - int16_t amp, - uint8_t subframe, - uint16_t rnti) { - - int i,j; - uint32_t B=0; - uint8_t btilde[20]; - int16_t d[22]; - uint8_t deltaPUCCH_Shift = fp->pucch_config_common.deltaPUCCH_Shift; - uint8_t NRB2 = fp->pucch_config_common.nRB_CQI; - uint8_t Ncs1 = fp->pucch_config_common.nCS_AN; - - uint32_t u0 = fp->pucch_config_common.grouphop[subframe<<1]; - uint32_t u1 = fp->pucch_config_common.grouphop[1+(subframe<<1)]; - uint32_t v0 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; - uint32_t v1 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; - - uint32_t z[12*14],*zptr; - uint32_t u,v,n; - uint8_t ns,N_UL_symb,nsymb_slot0,nsymb_pertti; - uint32_t nprime,l,n_cs; - int alpha_ind,data_ind; - int16_t ref_re,ref_im; - int m,re_offset,symbol_offset; - int32_t *txptr; - - if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { - printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); - return; - } - - if (Ncs1 > 7) { - printf("[PHY] generate_pucch: Illegal Ncs1 %d (should be 0...7)\n",Ncs1); - return; - } - - // pucch2x_encoding - for (i=0;i<A;i++) - if ((*payload & (1<<i)) > 0) - B=B^pucch_code[i]; - - // scrambling - pucch2x_scrambling(fp,subframe,rnti,B,btilde); - // modulation - pucch2x_modulation(btilde,d,amp); - - // add extra symbol for 2a/2b - d[20]=0; - d[21]=0; - if (fmt==pucch_format2a) - d[20] = (B2 == 0) ? amp : -amp; - else if (fmt==pucch_format2b) { - switch (B2) { - case 0: - d[20] = amp; - break; - case 1: - d[21] = -amp; - break; - case 2: - d[21] = amp; - break; - case 3: - d[20] = -amp; - break; - default: - AssertFatal(1==0,"Illegal modulation symbol %d for PUCCH %s\n",B2,pucch_format_string[fmt]); - break; - } - } - - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH2x: n2_pucch %d\n",n2_pucch); -#endif - - N_UL_symb = (fp->Ncp==0) ? 7 : 6; - data_ind = 0; - zptr = z; - nprime = 0; - for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { - - if ((ns&1) == 0) - nprime = (n2_pucch < 12*NRB2) ? - n2_pucch % 12 : - (n2_pucch+Ncs1 + 1)%12; - else { - nprime = (n2_pucch < 12*NRB2) ? - ((12*(nprime+1)) % 13)-1 : - (10-n2_pucch)%12; - } - //loop over symbols in slot - for (l=0; l<N_UL_symb; l++) { - // Compute n_cs (36.211 p. 18) - n_cs = (ncs_cell[ns][l]+nprime)%12; - - alpha_ind = 0; - for (n=0; n<12; n++) - { - // this is r_uv^alpha(n) - ref_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); - ref_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); - - if ((l!=1)&&(l!=5)) { //these are PUCCH data symbols - ((int16_t *)&zptr[n])[0] = ((int32_t)d[data_ind]*ref_re - (int32_t)d[data_ind+1]*ref_im)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)d[data_ind]*ref_im + (int32_t)d[data_ind+1]*ref_re)>>15; - //LOG_I(PHY,"slot %d ofdm# %d ==> d[%d,%d] \n",ns,l,data_ind,n); - } - else { - if ((l==1) || ( (l==5) && (fmt==pucch_format2) )) - { - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re>>15); - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im>>15); - } - // l == 5 && pucch format 2a - else if (fmt==pucch_format2a) - { - ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); - ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); - } - // l == 5 && pucch format 2b - else if (fmt==pucch_format2b) - { - ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); - ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); - } - } // l==1 || l==5 - alpha_ind = (alpha_ind + n_cs)%12; - } // n - zptr+=12; - - if ((l!=1)&&(l!=5)) //these are PUCCH data symbols so increment data index - data_ind+=2; - } // l - } //ns - - m = n2_pucch/12; - -#ifdef DEBUG_PUCCH_TX - LOG_D(PHY,"[PHY] PUCCH: n2_pucch %d m %d\n",n2_pucch,m); -#endif - - nsymb_slot0 = ((fp->Ncp==0) ? 7 : 6); - nsymb_pertti = nsymb_slot0 << 1; - - //nsymb = nsymb_slot0<<1; - - //for (j=0,l=0;l<(nsymb-1);l++) { - for (j=0,l=0; l<(nsymb_pertti); l++) { - - if ((l<nsymb_slot0) && ((m&1) == 0)) - re_offset = (m*6) + fp->first_carrier_offset; - else if ((l<nsymb_slot0) && ((m&1) == 1)) - re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; - else if ((m&1) == 0) - re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; - else - re_offset = ((m-1)*6) + fp->first_carrier_offset; - - if (re_offset > fp->ofdm_symbol_size) - re_offset -= (fp->ofdm_symbol_size); - - - - symbol_offset = (unsigned int)fp->ofdm_symbol_size*(l+(subframe*nsymb_pertti)); - txptr = &txdataF[0][symbol_offset]; - - //LOG_I(PHY,"ofdmSymb %d/%d, firstCarrierOffset %d, symbolOffset[sfn %d] %d, reOffset %d, &txptr: %x \n", l, nsymb, fp->first_carrier_offset, subframe, symbol_offset, re_offset, &txptr[0]); - - for (i=0; i<12; i++,j++) { - txptr[re_offset] = z[j]; - - re_offset++; - - if (re_offset==fp->ofdm_symbol_size) - re_offset -= (fp->ofdm_symbol_size); - -#ifdef DEBUG_PUCCH_TX - LOG_D(PHY,"[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); -#endif - } - } -} - -/* PUCCH format3 >> */ -/* DFT */ -void pucchfmt3_Dft( int16_t *x, int16_t *y ) -{ - int16_t i, k; - int16_t tmp[2]; - int16_t calctmp[D_NSC1RB*2]={0}; - - for (i=0; i<D_NSC1RB; i++) { - for(k=0; k<D_NSC1RB; k++) { - tmp[0] = alphaTBL_re[(12-((i*k)%12))%12]; - tmp[1] = alphaTBL_im[(12-((i*k)%12))%12]; - - calctmp[2*i] += (((int32_t)x[2*k] * tmp[0] - (int32_t)x[2*k+1] * tmp[1])>>15); - calctmp[2*i+1] += (((int32_t)x[2*k+1] * tmp[0] + (int32_t)x[2*k] * tmp[1])>>15); - } - y[2*i] = (int16_t)( (double) calctmp[2*i] / sqrt(D_NSC1RB)); - y[2*i+1] = (int16_t)((double) calctmp[2*i+1] / sqrt(D_NSC1RB)); - } -} - -void generate_pucch3x(int32_t **txdataF, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n3_pucch, - uint8_t shortened_format, - uint8_t *payload, - int16_t amp, - uint8_t subframe, - uint16_t rnti) -{ - - uint32_t u, v; - uint16_t i, j, re_offset; - uint32_t z[12*14], *zptr; - uint32_t y_tilda[12*14]={}, *y_tilda_ptr; - uint8_t ns, nsymb, n_oc, n_oc0, n_oc1; - uint8_t N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; - uint8_t m, l; - uint8_t n_cs; - int16_t tmp_re, tmp_im, W_re=0, W_im=0; - int32_t *txptr; - uint32_t symbol_offset; - - uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; - uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; - uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; - uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; - - // variables for channel coding - uint8_t chcod_tbl_idx = 0; - //uint8_t chcod_dt[48] = {}; - - // variables for Scrambling - uint32_t cinit = 0; - uint32_t x1; - uint32_t s,s0,s1; - uint8_t C[48] ={}; - uint8_t scr_dt[48]={}; - - // variables for Modulation - int16_t d_re[24]={}; - int16_t d_im[24]={}; - - // variables for orthogonal sequence selection - uint8_t N_PUCCH_SF0 = 5; - uint8_t N_PUCCH_SF1 = (shortened_format==0)? 5:4; - uint8_t first_slot = 0; - int16_t rot_re=0; - int16_t rot_im=0; - - uint8_t dt_offset; - uint8_t sym_offset; - int16_t y_re[14][12]; //={0}; - int16_t y_im[14][12]; //={0}; - - // DMRS - uint8_t alpha_idx=0; - uint8_t m_alpha_idx=0; - - // TODO - // "SR+ACK/NACK" length is only 7 bits. - // This restriction will be lifted in the future. - // "CQI/PMI/RI+ACK/NACK" will be supported in the future. - - // Channel Coding - for (uint8_t i=0; i<7; i++) { - chcod_tbl_idx += (payload[i]<<i); - } - - // Scrambling - cinit = (subframe + 1) * ((2 * frame_parms->Nid_cell + 1)<<16) + rnti; - s0 = lte_gold_generic(&x1,&cinit,1); - s1 = lte_gold_generic(&x1,&cinit,0); - - for (i=0; i<48; i++) { - s = (i<32)? s0:s1; - j = (i<32)? i:(i-32); - C[i] = ((s>>j)&1); - } - - for (i=0; i<48; i++) { - scr_dt[i] = chcod_tbl[chcod_tbl_idx][i] ^ C[i]; - } - - // Modulation - for (uint8_t i=0; i<48; i+=2){ - if (scr_dt[i]==0 && scr_dt[i+1]==0){ - d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); - d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); - } else if (scr_dt[i]==0 && scr_dt[i+1]==1) { - d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); - d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp) >>15); - } else if (scr_dt[i]==1 && scr_dt[i+1]==0) { - d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); - d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp)>>15); - } else if (scr_dt[i]==1 && scr_dt[i+1]==1) { - d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); - d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); - } else { - //***log Modulation Error! - } - } - - // Calculate Orthogonal Sequence index - n_oc0 = n3_pucch % N_PUCCH_SF1; - if (N_PUCCH_SF1 == 5) { - n_oc1 = (3 * n_oc0) % N_PUCCH_SF1; - } else { - n_oc1 = n_oc0 % N_PUCCH_SF1; - } - - y_tilda_ptr = y_tilda; - zptr = z; - - // loop over 2 slots - for (ns=(subframe<<1), u=u0, v=v0; ns<(2+(subframe<<1)); ns++, u=u1, v=v1) { - first_slot = (ns==(subframe<<1))?1:0; - - //loop over symbols in slot - for (l=0; l<N_UL_symb; l++) { - rot_re = RotTBL_re[(uint8_t) ncs_cell[ns][l]/64] ; - rot_im = RotTBL_im[(uint8_t) ncs_cell[ns][l]/64] ; - - // Comput W_noc(m) (36.211 p. 19) - if ( first_slot == 0 && shortened_format==1) { // second slot and shortened format - n_oc = n_oc1; - - if (l<1) { // data - W_re=W4_fmt3[n_oc][l]; - W_im=0; - } else if (l==1) { // DMRS - W_re=W2[0]; - W_im=0; - } else if (l>=2 && l<5) { // data - W_re=W4_fmt3[n_oc][l-1]; - W_im=0; - } else if (l==5) { // DMRS - W_re=W2[1]; - W_im=0; - } else if ((l>=N_UL_symb-2)) { // data - ; - } else { - //***log W Select Error! - } - } else { - if (first_slot == 1) { // 1st slot or 2nd slot and not shortened - n_oc=n_oc0; - } else { - n_oc=n_oc1; - } - - if (l<1) { // data - W_re=W5_fmt3_re[n_oc][l]; - W_im=W5_fmt3_im[n_oc][l]; - } else if (l==1) { // DMRS - W_re=W2[0]; - W_im=0; - } else if (l>=2 && l<5) { // data - W_re=W5_fmt3_re[n_oc][l-1]; - W_im=W5_fmt3_im[n_oc][l-1]; - } else if (l==5) { // DMRS - W_re=W2[1]; - W_im=0; - } else if ((l>=N_UL_symb-1)) { // data - W_re=W5_fmt3_re[n_oc][l-N_UL_symb+5]; - W_im=W5_fmt3_im[n_oc][l-N_UL_symb+5]; - } else { - //***log W Select Error! - } - } // W Selection end - - // Compute n_cs (36.211 p. 18) - n_cs = ncs_cell[ns][l]; - if (N_PUCCH_SF1 == 5) { - alpha_idx = (n_cs + Np5_TBL[n_oc]) % 12; - } else { - alpha_idx = (n_cs + Np4_TBL[n_oc]) % 12; - } - - // generate pucch data - dt_offset = (first_slot == 1) ? 0:12; - sym_offset = (first_slot == 1) ? 0:7; - - for (i=0; i<12; i++) { - // Calculate yn(i) - tmp_re = (((int32_t) (W_re*rot_re - W_im*rot_im)) >>15); - tmp_im = (((int32_t) (W_re*rot_im + W_im*rot_re)) >>15); - y_re[l+sym_offset][i] = (((int32_t) (tmp_re*d_re[i+dt_offset] - tmp_im*d_im[i+dt_offset]))>>15); - y_im[l+sym_offset][i] = (((int32_t) (tmp_re*d_im[i+dt_offset] + tmp_im*d_re[i+dt_offset]))>>15); - - // cyclic shift - ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[0] = y_re[l+sym_offset][i]; - ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[1] = y_im[l+sym_offset][i]; - - // DMRS - m_alpha_idx = (alpha_idx * i) % 12; - if (l==1 || l==5) { - ((int16_t *)&zptr[(l+sym_offset)*12+i])[0] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][i<<1] - (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][1+(i<<1)])>>15) * (int32_t)amp)>>15); - ((int16_t *)&zptr[(l+sym_offset)*12+i])[1] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][1+(i<<1)] + (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][i<<1])>>15) * (int32_t)amp)>>15); - } - } - - } // l loop - } // ns - - // DFT for pucch-data - for (l=0; l<14; l++) { - if (l==1 || l==5 || l==8 || l==12) { - ; - } else { - pucchfmt3_Dft((int16_t*)&y_tilda_ptr[l*12],(int16_t*)&zptr[l*12]); - } - } - - - // Mapping - m = n3_pucch / N_PUCCH_SF0; - - if (shortened_format == 1) { - nsymb = (N_UL_symb<<1) - 1; - } else { - nsymb = (N_UL_symb<<1); - } - - for (j=0,l=0; l<(nsymb); l++) { - - if ((l<7) && ((m&1) == 0)) - re_offset = (m*6) + frame_parms->first_carrier_offset; - else if ((l<7) && ((m&1) == 1)) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else if ((m&1) == 0) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else - re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; - - if (re_offset > frame_parms->ofdm_symbol_size) - re_offset -= (frame_parms->ofdm_symbol_size); - - symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*14)); - txptr = &txdataF[0][symbol_offset]; - - for (i=0; i<12; i++,j++) { - txptr[re_offset++] = z[j]; - - if (re_offset==frame_parms->ofdm_symbol_size) - re_offset = 0; - -#ifdef DEBUG_PUCCH_TX - msg("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); -#endif - } - } - -} - -/* PUCCH format3 << */ - - -//#define Amax 13 -//void init_pucch2x_rx() {}; /* PUCCH format3 >> */ diff --git a/openair1/PHY/LTE_TRANSPORT/pucch_common.c b/openair1/PHY/LTE_TRANSPORT/pucch_common.c new file mode 100644 index 0000000000000000000000000000000000000000..a9181a8b3dfe8107f42ad5b880b5eba3b5171d00 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pucch_common.c @@ -0,0 +1,270 @@ +/* + * 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/LTE_TRANSPORT/pucch_common.c +* \brief Top-level routines common to eNB/UE for the PUCCH physical channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "LAYER2/MAC/mac.h" + +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +#include "T.h" + +void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]) +{ + + uint8_t ns,l,reset=1,i,N_UL_symb; + uint32_t x1,x2,j=0,s=0; + + N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; + x2 = frame_parms->Nid_cell; + + for (ns=0; ns<20; ns++) { + + for (l=0; l<N_UL_symb; l++) { + ncs_cell[ns][l]=0; + + for (i=0; i<8; i++) { + if ((j%32) == 0) { + s = lte_gold_generic(&x1,&x2,reset); + // printf("s %x\n",s); + reset=0; + } + + if (((s>>(j%32))&1)==1) + ncs_cell[ns][l] += (1<<i); + + j++; + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH ncs_cell init (j %d): Ns %d, l %d => ncs_cell %d\n",j,ns,l,ncs_cell[ns][l]); +#endif + } + + } +} + +int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, + {32767,-32768, 32767,-32768}, + {32767,-32768,-32768, 32767} +}; +int16_t W3_re[3][6] = {{32767, 32767, 32767}, + {32767,-16384,-16384}, + {32767,-16384,-16384} +}; + +int16_t W3_im[3][6] = {{0 ,0 ,0 }, + {0 , 28377,-28378}, + {0 ,-28378, 28377} +}; + +char *pucch_format_string[] = { + "format 1", + "format 1a", + "format 1b", + "pucch_format1b_csA2", + "pucch_format1b_csA3", + "pucch_format1b_csA4", + "format 2", + "format 2a", + "format 2b", + "pucch_format3" +}; + + + +uint8_t chcod_tbl[128][48] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1}, + {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0}, + {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0}, + {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1}, + {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1}, + {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}, + {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0}, + {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1}, + {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1}, + {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0}, + {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0}, + {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1}, + {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1}, + {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1}, + {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}, + {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0}, + {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1}, + {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1}, + {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0}, + {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0}, + {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1}, + {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1}, + {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0}, + {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0}, + {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1}, + {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, + {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, + {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0}, + {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, + {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, + {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1}, + {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1}, + {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0}, + {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0}, + {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1}, + {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1}, + {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0}, + {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0}, + {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1}, + {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1}, + {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0}, + {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0}, + {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, + {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, + {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1}, + {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0}, + {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0}, + {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1}, + {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1}, + {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0}, + {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0}, + {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1}, + {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1}, + {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0}, + {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, + {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1}, + {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1}, + {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0}, + {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1}, + {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0}, + {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0}, + {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1}, + {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0}, + {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1}, + {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1}, + {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}, + {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0}, + {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1}, + {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1}, + {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0}, + {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0}, + {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1}, + {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0}, + {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1}, + {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1}, + {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0}, + {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0}, + {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1}, + {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1}, + {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0}, + {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0}, + {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1}, + {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1}, + {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0}, + {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0}, + {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1}, + {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0}, + {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1}, + {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1}, + {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0}, + {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}, + {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1}, + {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1}, + {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0}, + {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0}, + {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1}, + {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1}, + {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0}, + {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1}, + {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1}, + {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1}, + {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0}, + {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1}, + {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, + {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, + {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0}, + {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1}, + {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}, + {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0}, + {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0}, + {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1}, + {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1}, + {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0}, + {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0}, + {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1} }; + +int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377}; +int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384}; + +// W5_TBL +int16_t W5_fmt3_re[5][5] = { {32767, 32767, 32767, 32767, 32767}, + {32767, 10125, -26509, -26509, 10125}, + {32767, -26509, 10125, 10125, -26509}, + {32767, -26509, 10125, 10125, -26509}, + {32767, 10125, -26509, -26509, 10125} }; + +int16_t W5_fmt3_im[5][5] = { {0, 0, 0, 0, 0}, + {0, 31163, 19259, -19259, -31163}, + {0, 19259, -31163, 31163, -19259}, + {0, -19259, 31163, -31163, 19259}, + {0, -31163, -19259, 19259, 31163} }; + +int16_t W4_fmt3[4][4] = { {32767, 32767, 32767, 32767}, + {32767, -32767, 32767, -32767}, + {32767, 32767, -32767, -32767}, + {32767, -32767, -32767, 32767} }; + +// W2 TBL +int16_t W2[2] = {32767, 32767}; + +// e^j*pai*floor (ncs_cell(ns,l)/64)/2 +int16_t RotTBL_re[4] = {32767, 0, -32767, 0}; +int16_t RotTBL_im[4] = {0, 32767, 0, -32767}; + +//np4_tbl, np5_tbl +uint8_t Np5_TBL[5] = {0, 3, 6, 8, 10}; +uint8_t Np4_TBL[4] = {0, 3, 6, 9}; + +// alpha_TBL +int16_t alphaTBL_re[12] = {32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383, 0, 16383, 28377}; +int16_t alphaTBL_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383}; + diff --git a/openair1/PHY/LTE_TRANSPORT/pucch_extern.h b/openair1/PHY/LTE_TRANSPORT/pucch_extern.h new file mode 100644 index 0000000000000000000000000000000000000000..899b90430670af54af65a918d859689646e1129c --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pucch_extern.h @@ -0,0 +1,78 @@ +/* + * 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/LTE_TRANSPORT/pucch.c +* \brief Top-level routines for generating and decoding the PUCCH physical channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ + +#include <stdint.h> + +/* PUCCH format3 >> */ +#define D_I 0 +#define D_Q 1 +#define D_IQDATA 2 +#define D_NSLT1SF 2 +#define D_NSYM1SLT 7 +#define D_NSYM1SF 2*7 +#define D_NSC1RB 12 +#define D_NRB1PUCCH 2 +#define D_NPUCCH_SF5 5 +#define D_NPUCCH_SF4 4 + +extern int16_t W4[3][4]; + +extern int16_t W3_re[3][6]; + + +extern int16_t W3_im[3][6]; + +extern int16_t alpha_re[12]; +extern int16_t alpha_im[12]; + +extern char *pucch_format_string[]; + +extern uint8_t chcod_tbl[128][48]; + +extern int16_t W5_fmt3_re[5][5]; + +extern int16_t W5_fmt3_im[5][5]; + +extern int16_t W4_fmt3[4][4]; + +extern int16_t W2[2]; + +extern int16_t RotTBL_re[4]; +extern int16_t RotTBL_im[4]; + +//np4_tbl, np5_tbl +extern uint8_t Np5_TBL[5]; +extern uint8_t Np4_TBL[4]; + +// alpha_TBL +extern int16_t alphaTBL_re[12]; +extern int16_t alphaTBL_im[12]; diff --git a/openair1/PHY/LTE_TRANSPORT/rar_tools.c b/openair1/PHY/LTE_TRANSPORT/rar_tools.c index 9934b71d78b0165c32d9b4df855e97779c43ee33..ab4656716bcc509cfddf46ba96582c81adcc89fd 100644 --- a/openair1/PHY/LTE_TRANSPORT/rar_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/rar_tools.c @@ -20,7 +20,7 @@ */ /*! \file PHY/LTE_TRANSPORT/rar_tools.c -* \brief Routine for filling the PUSCH/ULSCH data structures based on a random-access response (RAR) SDU from MAC. Note this is both for UE and eNB. V8.6 2009-03 +* \brief Routine for filling the PUSCH/ULSCH data structures based on a random-access response (RAR) SDU from MAC. Note this is for eNB. * \author R. Knopp * \date 2011 * \version 0.1 @@ -29,14 +29,12 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "SCHED/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/LOG/vcd_signal_dumper.h" - +#include "PHY/LTE_TRANSPORT/transport_proto.h" #include "assertions.h" extern uint16_t RIV2nb_rb_LUT6[32]; @@ -194,159 +192,3 @@ int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, return(0); } -int8_t delta_PUSCH_msg2[8] = {-6,-4,-2,0,2,4,6,8}; - -int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - unsigned char eNB_id ) -{ - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_IN); - - // RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)rar_pdu; - uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - unsigned char *rar_pdu = ue->dlsch_ra[eNB_id]->harq_processes[0]->b; - unsigned char subframe = ue->ulsch_Msg3_subframe[eNB_id]; - LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - PHY_MEASUREMENTS *meas = &ue->measurements; - - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - // int current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; - - uint8_t *rar = (uint8_t *)(rar_pdu+1); - uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_tx,subframe); - uint16_t rballoc; - uint8_t cqireq; - uint16_t *RIV2nb_rb_LUT, *RIV2first_rb_LUT; - uint16_t RIV_max = 0; - - LOG_D(PHY,"[eNB][RAPROC] Frame %d: generate_ue_ulsch_params_from_rar: subframe %d (harq_pid %d)\n",proc->frame_tx,subframe,harq_pid); - - switch (frame_parms->N_RB_DL) { - case 6: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT6[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT6[0]; - RIV_max = RIV_max6; - break; - - case 25: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT25[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT25[0]; - RIV_max = RIV_max25; - break; - - case 50: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT50[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT50[0]; - RIV_max = RIV_max50; - break; - - case 100: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT100[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT100[0]; - RIV_max = RIV_max100; - break; - - default: - DevParam(frame_parms->N_RB_DL, eNB_id, harq_pid); - break; - } - - - - ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7;//rar->TPC; - - rballoc = (((uint16_t)(rar[1]&7))<<7)|(rar[2]>>1); - cqireq=rar[3]&1; - - if (rballoc>RIV_max) { - LOG_D(PHY,"rar_tools.c: ERROR: rb_alloc (%x) > RIV_max\n",rballoc); - return(-1); - } - - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; - - AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb >0, "nb_rb == 0\n"); - - ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb]; - - AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb <= 6,"unlikely rb count for RAR grant : nb_rb > 6\n"); - - // ulsch->harq_processes[harq_pid]->Ndi = 1; - if (ulsch->harq_processes[harq_pid]->round == 0) - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - if (cqireq==1) { - ulsch->O_RI = 1; - - if (meas->rank[eNB_id] == 1) { - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->o_RI[0] = 1; - } else { - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - ulsch->o_RI[0] = 0; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - fill_CQI(ulsch,meas,eNB_id,0,ue->frame_parms.N_RB_DL,0, transmission_mode,ue->sinr_eff); - - if (((proc->frame_tx % 100) == 0) || (proc->frame_tx < 10)) - print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); - } else { - ulsch->O_RI = 0; - ulsch->O = 0; - } - - ulsch->harq_processes[harq_pid]->O_ACK = 0;//2; - - ulsch->beta_offset_cqi_times8 = 18; - ulsch->beta_offset_ri_times8 = 10; - ulsch->beta_offset_harqack_times8 = 16; - - ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1); - ulsch->rnti = (((uint16_t)rar[4])<<8)+rar[5]; //rar->t_crnti; - - if (ulsch->harq_processes[harq_pid]->round == 0) { - ulsch->harq_processes[harq_pid]->status = ACTIVE; - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = ((rar[2]&1)<<3)|(rar[3]>>5); - ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7; - //ulsch->harq_processes[harq_pid]->TBS = dlsch_tbs25[ulsch->harq_processes[harq_pid]->mcs][ulsch->harq_processes[harq_pid]->nb_rb-1]; - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = 9; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->round++; - } - - // initialize power control based on PRACH power - ulsch->f_pusch = delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC] + - get_deltaP_rampup(ue->Mod_id,ue->CC_id); - LOG_D(PHY,"[UE %d][PUSCH PC] Initializing f_pusch to %d dB, TPC %d (delta_PUSCH_msg2 %d dB), deltaP_rampup %d dB\n", - ue->Mod_id,ulsch->f_pusch,ulsch->harq_processes[harq_pid]->TPC,delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC], - get_deltaP_rampup(ue->Mod_id,ue->CC_id)); - - - //#ifdef DEBUG_RAR - LOG_D(PHY,"ulsch ra (UE): harq_pid %d\n",harq_pid); - LOG_D(PHY,"ulsch ra (UE): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"ulsch ra (UE): first_rb %x\n",ulsch->harq_processes[harq_pid]->first_rb); - LOG_D(PHY,"ulsch ra (UE): nb_rb %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"ulsch ra (UE): round %d\n",ulsch->harq_processes[harq_pid]->round); - LOG_D(PHY,"ulsch ra (UE): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - LOG_D(PHY,"ulsch ra (UE): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - LOG_D(PHY,"ulsch ra (UE): TPC %d\n",ulsch->harq_processes[harq_pid]->TPC); - LOG_D(PHY,"ulsch ra (UE): O %d\n",ulsch->O); - LOG_D(PHY,"ulsch ra (UE): ORI %d\n",ulsch->O_RI); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_OUT); - - //#endif - return(0); -} - diff --git a/openair1/PHY/LTE_TRANSPORT/sldch.c b/openair1/PHY/LTE_TRANSPORT/sldch.c index 64d13c46890bc1f55184fd34e79e30969ea2208b..b26cb312a376127c21c2fd4b7319a62dc79ef0e4 100644 --- a/openair1/PHY/LTE_TRANSPORT/sldch.c +++ b/openair1/PHY/LTE_TRANSPORT/sldch.c @@ -31,7 +31,7 @@ */ #ifndef __LTE_TRANSPORT_SLSS__C__ #define __LTE_TRANSPORT_SLSS__C__ -#include "PHY/defs.h" +#include "PHY/defs_UE.h" extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); diff --git a/openair1/PHY/LTE_TRANSPORT/slsch.c b/openair1/PHY/LTE_TRANSPORT/slsch.c index 9c199456e22f3c8d1a7e6a42c20895a55fa06f91..096b4d9a8e69446b02d08b67c40a3749eaee4a77 100644 --- a/openair1/PHY/LTE_TRANSPORT/slsch.c +++ b/openair1/PHY/LTE_TRANSPORT/slsch.c @@ -31,7 +31,7 @@ */ #ifndef __LTE_TRANSPORT_SLSS__C__ #define __LTE_TRANSPORT_SLSS__C__ -#include "PHY/defs.h" +#include "PHY/defs_UE.h" extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); diff --git a/openair1/PHY/LTE_TRANSPORT/slss.c b/openair1/PHY/LTE_TRANSPORT/slss.c index a8c9b75ae03e7065dfc88be9cc54c8ea43c9bf1d..18bc5a28dec8826a63ebef68eec43654561bf6da 100644 --- a/openair1/PHY/LTE_TRANSPORT/slss.c +++ b/openair1/PHY/LTE_TRANSPORT/slss.c @@ -31,7 +31,7 @@ */ #ifndef __LTE_TRANSPORT_SLSS__C__ #define __LTE_TRANSPORT_SLSS__C__ -#include "PHY/defs.h" +#include "PHY/defs_UE.h" void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss,int frame_tx,int subframe_tx) { diff --git a/openair1/PHY/LTE_TRANSPORT/sss.c b/openair1/PHY/LTE_TRANSPORT/sss.c index 17a4680c54f7a19beee1b91225b9ef54095ea672..bf03c185ef9664790957fafbb22a2295c8e24bfd 100644 --- a/openair1/PHY/LTE_TRANSPORT/sss.c +++ b/openair1/PHY/LTE_TRANSPORT/sss.c @@ -29,9 +29,9 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "transport_eNB.h" +#include "PHY/phy_extern.h" //#define DEBUG_SSS @@ -82,383 +82,3 @@ int generate_sss(int32_t **txdataF, return(0); } -int pss_ch_est(PHY_VARS_UE *ue, - int32_t pss_ext[4][72], - int32_t sss_ext[4][72]) -{ - - int16_t *pss; - int16_t *pss_ext2,*sss_ext2,*sss_ext3,tmp_re,tmp_im,tmp_re2,tmp_im2; - uint8_t aarx,i; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - - switch (ue->common_vars.eNb_id) { - - case 0: - pss = &primary_synch0[10]; - break; - - case 1: - pss = &primary_synch1[10]; - break; - - case 2: - pss = &primary_synch2[10]; - break; - - default: - pss = &primary_synch0[10]; - break; - } - - sss_ext3 = (int16_t*)&sss_ext[0][5]; - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - sss_ext2 = (int16_t*)&sss_ext[aarx][5]; - pss_ext2 = (int16_t*)&pss_ext[aarx][5]; - - for (i=0; i<62; i++) { - - // This is H*(PSS) = R* \cdot PSS - tmp_re = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[i<<1])>>15) + ((pss_ext2[1+(i<<1)] * (int32_t)pss[1+(i<<1)])>>15)); - tmp_im = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[1+(i<<1)])>>15) - ((pss_ext2[1+(i<<1)] * (int32_t)pss[(i<<1)])>>15)); - // printf("H*(%d,%d) : (%d,%d)\n",aarx,i,tmp_re,tmp_im); - // This is R(SSS) \cdot H*(PSS) - tmp_re2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[i<<1])>>15) - ((tmp_im * (int32_t)sss_ext2[1+(i<<1)]>>15))); - tmp_im2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[1+(i<<1)])>>15) + ((tmp_im * (int32_t)sss_ext2[(i<<1)]>>15))); - - // printf("SSSi(%d,%d) : (%d,%d)\n",aarx,i,sss_ext2[i<<1],sss_ext2[1+(i<<1)]); - // printf("SSSo(%d,%d) : (%d,%d)\n",aarx,i,tmp_re2,tmp_im2); - // MRC on RX antennas - if (aarx==0) { - sss_ext3[i<<1] = tmp_re2; - sss_ext3[1+(i<<1)] = tmp_im2; - } else { - sss_ext3[i<<1] += tmp_re2; - sss_ext3[1+(i<<1)] += tmp_im2; - } - } - } - - // sss_ext now contains the compensated SSS - return(0); -} - - -int _do_pss_sss_extract(PHY_VARS_UE *ue, - int32_t pss_ext[4][72], - int32_t sss_ext[4][72], - uint8_t doPss, uint8_t doSss, - uint8_t subframe) // add flag to indicate extracting only PSS, only SSS, or both -{ - - - - uint16_t rb,nb_rb=6; - uint8_t i,aarx; - int32_t *pss_rxF,*pss_rxF_ext; - int32_t *sss_rxF,*sss_rxF_ext; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t next_thread_id = ue->current_thread_id[subframe]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[subframe]+1); - - int rx_offset = frame_parms->ofdm_symbol_size-3*12; - uint8_t pss_symb,sss_symb; - - int32_t **rxdataF; - - //LOG_I(PHY,"do_pss_sss_extract subframe %d \n",subframe); - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (frame_parms->frame_type == FDD) { - pss_symb = 6-frame_parms->Ncp; - sss_symb = pss_symb-1; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - - } else { - pss_symb = 2; - sss_symb = frame_parms->symbols_per_tti-1; - - if(subframe==5 || subframe==0) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else if(subframe==6 || subframe==1) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else - { - AssertFatal(0,""); - } - - } - //printf("extract_rbs: symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",symbol_mod, - // (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, - // LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); - - pss_rxF_ext = &pss_ext[aarx][0]; - sss_rxF_ext = &sss_ext[aarx][0]; - - for (rb=0; rb<nb_rb; rb++) { - // skip DC carrier - if (rb==3) { - if(frame_parms->frame_type == FDD) - { - sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else - { - if(subframe==5 || subframe==0) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else if(subframe==6 || subframe==1) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else - { - AssertFatal(0,""); - } - } - } - - for (i=0; i<12; i++) { - if (doPss) {pss_rxF_ext[i]=pss_rxF[i];} - if (doSss) {sss_rxF_ext[i]=sss_rxF[i];} - } - - pss_rxF+=12; - sss_rxF+=12; - pss_rxF_ext+=12; - sss_rxF_ext+=12; - } - - } - - return(0); -} - -int pss_sss_extract(PHY_VARS_UE *phy_vars_ue, - int32_t pss_ext[4][72], - int32_t sss_ext[4][72], - uint8_t subframe) -{ - return _do_pss_sss_extract(phy_vars_ue, pss_ext, sss_ext, 1 /* doPss */, 1 /* doSss */, subframe); -} - -int pss_only_extract(PHY_VARS_UE *phy_vars_ue, - int32_t pss_ext[4][72], - uint8_t subframe) -{ - static int32_t dummy[4][72]; - return _do_pss_sss_extract(phy_vars_ue, pss_ext, dummy, 1 /* doPss */, 0 /* doSss */, subframe); -} - - -int sss_only_extract(PHY_VARS_UE *phy_vars_ue, - int32_t sss_ext[4][72], - uint8_t subframe) -{ - static int32_t dummy[4][72]; - return _do_pss_sss_extract(phy_vars_ue, dummy, sss_ext, 0 /* doPss */, 1 /* doSss */, subframe); -} - - -int16_t phase_re[7] = {16383, 25101, 30791, 32767, 30791, 25101, 16383}; -int16_t phase_im[7] = {-28378, -21063, -11208, 0, 11207, 21062, 28377}; - - -int rx_sss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *flip_max,uint8_t *phase_max) -{ - - uint8_t i; - int32_t pss_ext[4][72]; - int32_t sss0_ext[4][72],sss5_ext[4][72]; - uint8_t Nid2 = ue->common_vars.eNb_id; - uint8_t flip,phase; - uint16_t Nid1; - int16_t *sss0,*sss5; - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - int32_t metric; - int16_t *d0,*d5; - - if (frame_parms->frame_type == FDD) { -#ifdef DEBUG_SSS - - if (frame_parms->Ncp == NORMAL) - msg("[PHY][UE%d] Doing SSS for FDD Normal Prefix\n",ue->Mod_id); - else - msg("[PHY][UE%d] Doing SSS for FDD Extended Prefix\n",ue->Mod_id); - -#endif - // Do FFTs for SSS/PSS - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-2, // second to last symbol of - 0, // slot 0 - ue->rx_offset, - 0, - 1); - // PSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-1, // last symbol of - 0, // slot 0 - ue->rx_offset, - 0, - 1); - } else { // TDD -#ifdef DEBUG_SSS - if (ue->frame_parms->Ncp == NORMAL) - msg("[PHY][UE%d] Doing SSS for TDD Normal Prefix\n",ue->Mod_id); - else - msg("[PHY][UE%d] Doing SSS for TDD Extended Prefix\n",ue->Mod_id); - -#endif - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti>>1)-1, // last symbol of - 1, // slot 1 - ue->rx_offset, - 0, - 1); - // PSS - slot_fep(ue, - 2, // symbol 2 of - 2, // slot 2 - ue->rx_offset, - 0, - 1); - } - // pss sss extract for subframe 0 - pss_sss_extract(ue, - pss_ext, - sss0_ext,0); - /* - write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata[0][0],ue->frame_parms.samples_per_tti,1,1); - write_output("rxdataF0.m","rxF0",&ue->common_vars.rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,2,1); - write_output("pss_ext0.m","pssext0",pss_ext,72,1,1); - write_output("sss0_ext0.m","sss0ext0",sss0_ext,72,1,1); - */ - - // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS - // and do channel estimation and compensation based on PSS - - pss_ch_est(ue, - pss_ext, - sss0_ext); - - // write_output("sss0_comp0.m","sss0comp0",sss0_ext,72,1,1); - - if (ue->frame_parms.frame_type == FDD) { // FDD - - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-2, - 10, - ue->rx_offset, - 0,1); - // PSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-1, - 10, - ue->rx_offset, - 0,1); - } else { // TDD - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti>>1)-1, - 11, - ue->rx_offset, - 0, - 1); - // PSS - slot_fep(ue, - 2, - 12, - ue->rx_offset, - 0, - 1); - } - - // pss sss extract for subframe 5 - pss_sss_extract(ue, - pss_ext, - sss5_ext,5); - - // write_output("sss5_ext0.m","sss5ext0",sss5_ext,72,1,1); - // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS - // and do channel estimation and compensation based on PSS - - pss_ch_est(ue, - pss_ext, - sss5_ext); - - - - // now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h - - *tot_metric = -99999999; - - - sss0 = (int16_t*)&sss0_ext[0][5]; - sss5 = (int16_t*)&sss5_ext[0][5]; - - for (flip=0; flip<2; flip++) { // d0/d5 flip in RX frame - for (phase=0; phase<7; phase++) { // phase offset between PSS and SSS - for (Nid1 = 0 ; Nid1 <= 167; Nid1++) { // 168 possible Nid1 values - metric = 0; - - if (flip==0) { - d0 = &d0_sss[62*(Nid2 + (Nid1*3))]; - d5 = &d5_sss[62*(Nid2 + (Nid1*3))]; - } else { - d5 = &d0_sss[62*(Nid2 + (Nid1*3))]; - d0 = &d5_sss[62*(Nid2 + (Nid1*3))]; - } - - // This is the inner product using one particular value of each unknown parameter - for (i=0; i<62; i++) { - metric += (int16_t)(((d0[i]*((((phase_re[phase]*(int32_t)sss0[i<<1])>>19)-((phase_im[phase]*(int32_t)sss0[1+(i<<1)])>>19)))) + - (d5[i]*((((phase_re[phase]*(int32_t)sss5[i<<1])>>19)-((phase_im[phase]*(int32_t)sss5[1+(i<<1)])>>19)))))); - } - - // if the current metric is better than the last save it - if (metric > *tot_metric) { - *tot_metric = metric; - ue->frame_parms.Nid_cell = Nid2+(3*Nid1); - *phase_max = phase; - *flip_max=flip; -#ifdef DEBUG_SSS - msg("(flip,phase,Nid1) (%d,%d,%d), metric_phase %d tot_metric %d, phase_max %d, flip_max %d\n",flip,phase,Nid1,metric,*tot_metric,*phase_max,*flip_max); -#endif - - } - } - } - } - - return(0); -} - diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common.h b/openair1/PHY/LTE_TRANSPORT/transport_common.h new file mode 100644 index 0000000000000000000000000000000000000000..167e2b111a566a7929e1f76cc3003a41623ea756 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/transport_common.h @@ -0,0 +1,282 @@ +/* + * 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/LTE_TRANSPORT/transport_commont.h +* \brief data structures for PDSCH/DLSCH/PUSCH/ULSCH physical and transport channel descriptors (TX/RX) common to both eNB/UE +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: raymond.knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it +* \note +* \warning +*/ +#ifndef __TRANSPORT_COMMON__H__ +#define __TRANSPORT_COMMON__H__ +#include "PHY/defs_common.h" +#include "PHY/impl_defs_lte.h" +#include "dci.h" +#include "mdci.h" +//#include "uci.h" +#ifndef STANDALONE_COMPILE +#include "UTIL/LISTS/list.h" +#endif + +#define MOD_TABLE_QPSK_OFFSET 1 +#define MOD_TABLE_16QAM_OFFSET 5 +#define MOD_TABLE_64QAM_OFFSET 21 +#define MOD_TABLE_PSS_OFFSET 85 + +// structures below implement 36-211 and 36-212 + +/** @addtogroup _PHY_TRANSPORT_ + * @{ + */ + + + +#define NSOFT 1827072 +#define LTE_NULL 2 + +// maximum of 3 segments before each coding block if data length exceeds 6144 bits. + +#define MAX_NUM_DLSCH_SEGMENTS 16 +#define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS +#define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768) +#define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768) + +#define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE +#define MAX_NUM_RE (14*1200) + +#if !defined(SI_RNTI) +#define SI_RNTI (rnti_t)0xffff +#endif +#if !defined(M_RNTI) +#define M_RNTI (rnti_t)0xfffd +#endif +#if !defined(P_RNTI) +#define P_RNTI (rnti_t)0xfffe +#endif +#if !defined(CBA_RNTI) +#define CBA_RNTI (rnti_t)0xfff4 +#endif +#if !defined(C_RNTI) +#define C_RNTI (rnti_t)0x1234 +#endif +// These are the codebook indexes according to Table 6.3.4.2.3-1 of 36.211 +//1 layer +#define PMI_2A_11 0 +#define PMI_2A_1m1 1 +#define PMI_2A_1j 2 +#define PMI_2A_1mj 3 +//2 layers +#define PMI_2A_R1_10 0 +#define PMI_2A_R1_11 1 +#define PMI_2A_R1_1j 2 + +typedef enum { SEARCH_EXIST=0, + SEARCH_EXIST_OR_FREE} find_type_t; + +typedef enum { + SCH_IDLE=0, + ACTIVE, + CBA_ACTIVE, + DISABLED +} SCH_status_t; + + + + +#ifdef Rel14 +typedef enum { + CEmodeA = 0, + CEmodeB = 1 +} CEmode_t; +#endif + +#define PUSCH_x 2 +#define PUSCH_y 3 + +typedef enum { + pucch_format1=0, + pucch_format1a, + pucch_format1b, + pucch_format1b_csA2, + pucch_format1b_csA3, + pucch_format1b_csA4, + pucch_format2, + pucch_format2a, + pucch_format2b, + pucch_format3 // PUCCH format3 +} PUCCH_FMT_t; + +typedef enum { + SR, + HARQ, + CQI, + HARQ_SR, + HARQ_CQI, + SR_CQI, + HARQ_SR_CQI +} UCI_type_t; + +#ifdef Rel14 +typedef enum { + NOCE, + CEMODEA, + CEMODEB +} UE_type_t; +#endif + + + + + +typedef enum { + SI_PDSCH=0, + RA_PDSCH, + P_PDSCH, + PDSCH, + PDSCH1, + PMCH +} PDSCH_t; + +typedef enum { + rx_standard=0, + rx_IC_single_stream, + rx_IC_dual_stream, + rx_SIC_dual_stream +} RX_type_t; + + +typedef enum { + DCI_COMMON_SPACE, + DCI_UE_SPACE +} dci_space_t; + +typedef struct { + uint8_t f_ra; + uint8_t t0_ra; + uint8_t t1_ra; + uint8_t t2_ra; +} PRACH_TDD_PREAMBLE_MAP_elem; +typedef struct { + uint8_t num_prach; + PRACH_TDD_PREAMBLE_MAP_elem map[6]; +} PRACH_TDD_PREAMBLE_MAP; + +#ifdef Rel14 + +typedef struct { + uint16_t slss_id; + uint8_t *slmib; +} SLSS_t; + +typedef struct { + // SL Configuration + /// Number of SL resource blocks (1-100) + uint32_t N_SL_RB; + /// prb-start (0-99) + uint32_t prb_Start; + /// prb-End (0-99) + uint32_t prb_End; + /// SL-OffsetIndicator (0-10239) + uint32_t SL_OffsetIndicator; + /// PSCCH subframe bitmap, first 64-bits (up to 40 bits for Rel 12) + uint64_t bitmap1; + /// PSCCH subframe bitmap, 2nd 64-bits (up to 100 bits for Rel 14) + uint64_t bitmap2; + + // SCI parameters + /// npscch resource index + uint32_t n_pscch; + /// format of SCI (0,1) + uint32_t format; + /// SCI0 frequency hopping flag + uint32_t freq_hopping_flag; + /// SCI0 Resource Block Coding + uint32_t resource_block_coding; + /// SCI0 Time Resource Pattern for SLSCH + uint32_t time_resource_pattern; + /// SCI0 MCS for SLSCH + uint32_t mcs; + /// SCI0 Timing advance indication for SLSCH + uint32_t timing_advance_indication; + /// SCI0 Group Destination ID for SLSCH + uint32_t group_destination_id; + + // SLSCH Parameters + /// Number of Subbands (36.213 14.1.1.2) + uint32_t Nsb; + /// N_RB_HO (36.213 14.1.1.2) + uint32_t N_RB_HO; + /// n_ss_PSSCH (36.211 9.2.4) + uint32_t n_ss_PSSCH; + /// n_ssf_PSSCH + uint32_t n_ssf_PSSCH; + /// cinit (36.331 hoppingParameter-r12) + uint32_t cinit; + /// redundancy version + uint32_t rvidx; + /// n_prime_VRB (36.213 14.1.1.2.1) + uint32_t n_prime_VRB; + /// M_RB_PSSCH_RP (36.213 14.1.3 + uint32_t M_RB_PSSCH_RP; + /// n_prime_PRB (36.213 14.1.1.4 + uint32_t n_prime_PRB; + /// m_nprime_PRB_PSSCH (36.213 14.1.3) + uint32_t m_nprime_PRB_PSCCH; + /// payload length + int payload_length; + /// pointer to payload + uint8_t *payload; +} SLSCH_t; + +typedef struct { + /// payload length + int payload_length; + uint8_t payload[100]; +} SLDCH_t; + +#define TTI_SYNC 0 +#define SLSS 1 +#define SLDCH 2 +#define SLSCH 3 + +typedef struct UE_tport_header_s { + int packet_type; + uint16_t absSF; +} UE_tport_header_t; + +typedef struct UE_tport_s { + UE_tport_header_t header; + union { + SLSS_t slss; + SLDCH_t sldch; + SLSCH_t slsch; + }; + uint8_t payload[1500]; +} UE_tport_t; + +#endif + +/**@}*/ +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h new file mode 100644 index 0000000000000000000000000000000000000000..ebf0d99c4e45a9966f47c39dc0dd736d713e343f --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h @@ -0,0 +1,294 @@ +/* + * 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/LTE_TRANSPORT/transport_proto.h + * \brief Function prototypes for eNB PHY physical/transport channel processing and generation V8.6 2009-03 + * \author R. Knopp, F. Kaltenberger + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#ifndef __LTE_TRANSPORT_COMMON_PROTO__H__ +#define __LTE_TRANSPORT_COMMON_PROTO__H__ +#include "PHY/defs_common.h" + + + + +// Functions below implement minor procedures from 36-211 and 36-212 + +/** \brief Compute Q (modulation order) based on I_MCS PDSCH. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS */ +uint8_t get_Qm(uint8_t I_MCS); + +/** \brief Compute Q (modulation order) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213. + @param I_MCS */ +uint8_t get_Qm_ul(uint8_t I_MCS); + +/** \brief Compute I_TBS (transport-block size) based on I_MCS for PDSCH. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS */ +uint8_t get_I_TBS(uint8_t I_MCS); + +/** \brief Compute I_TBS (transport-block size) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213. + @param I_MCS */ +unsigned char get_I_TBS_UL(unsigned char I_MCS); + +/** \brief Compute Q (modulation order) based on downlink I_MCS. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS + @param nb_rb + @return Transport block size */ +uint32_t get_TBS_DL(uint8_t mcs, uint16_t nb_rb); + +/** \brief Compute Q (modulation order) based on uplink I_MCS. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS + @param nb_rb + @return Transport block size */ +uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb); + +/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type + @param N_RB_DL number of PRB on DL + @param indicator for even/odd slot + @param vrb vrb index + @param Ngap Gap indicator +*/ +uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap); + +/* \brief Return prb for a given vrb index + @param vrb_type VRB type (0=localized,1=distributed) + @param rb_alloc_dci rballoc field from DCI +*/ +uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci); + + +/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type + @returns Transmission mode (1-7) +*/ +uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); + + +/* \brief + @param ra_header Header of resource allocation (0,1) (See sections 7.1.6.1/7.1.6.2 of 36.213 Rel8.6) + @param rb_alloc Bitmap allocation from DCI (format 1,2) + @returns number of physical resource blocks +*/ +uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL); + +int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe, uint8_t beamforming_mode); + +int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe); +int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); + + +#ifndef modOrder +#define modOrder(I_MCS,I_TBS) ((I_MCS-I_TBS)*2+2) // Find modulation order from I_TBS and I_MCS +#endif + +/** \fn uint8_t I_TBS2I_MCS(uint8_t I_TBS); + \brief This function maps I_tbs to I_mcs according to Table 7.1.7.1-1 in 3GPP TS 36.213 V8.6.0. Where there is two supported modulation orders for the same I_TBS then either high or low modulation is chosen by changing the equality of the two first comparisons in the if-else statement. + \param I_TBS Index of Transport Block Size + \return I_MCS given I_TBS +*/ +uint8_t I_TBS2I_MCS(uint8_t I_TBS); + +/** \fn uint8_t SE2I_TBS(float SE, + uint8_t N_PRB, + uint8_t symbPerRB); + \brief This function maps a requested throughput in number of bits to I_tbs. The throughput is calculated as a function of modulation order, RB allocation and number of symbols per RB. The mapping orginates in the "Transport block size table" (Table 7.1.7.2.1-1 in 3GPP TS 36.213 V8.6.0) + \param SE Spectral Efficiency (before casting to integer, multiply by 1024, remember to divide result by 1024!) + \param N_PRB Number of PhysicalResourceBlocks allocated \sa lte_frame_parms->N_RB_DL + \param symbPerRB Number of symbols per resource block allocated to this channel + \return I_TBS given an SE and an N_PRB +*/ +uint8_t SE2I_TBS(float SE, + uint8_t N_PRB, + uint8_t symbPerRB); +/** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 36.211 v8.6.0. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence. + @param frame_parms LTE DL Frame Parameters + @param soundingrs_ul_config_dedicated Dynamic configuration from RRC during Connection Establishment + @param txdataF pointer to the frequency domain TX signal + @returns 0 on success*/ + +int generate_srs(LTE_DL_FRAME_PARMS *frame_parms, + SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated, + int *txdataF, + int16_t amp, + uint32_t subframe); + + +/*! + \brief This function generates the downlink reference signal for the PUSCH according to 36.211 v8.6.0. The DRS occuies the RS defined by rb_alloc and the symbols 2 and 8 for extended CP and 3 and 10 for normal CP. +*/ + + +/*! + \brief This function initializes the Group Hopping, Sequence Hopping and nPRS sequences for PUCCH/PUSCH according to 36.211 v8.6.0. It should be called after configuration of UE (reception of SIB2/3) and initial configuration of eNB (or after reconfiguration of cell-specific parameters). + @param frame_parms Pointer to a LTE_DL_FRAME_PARMS structure (eNB or UE)*/ +void init_ul_hopping(LTE_DL_FRAME_PARMS *frame_parms); + + +int32_t compareints (const void * a, const void * b); + +uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); + +int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci); + +void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms); + +void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms); + +uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi); + +void generate_RIV_tables(void); + +/** \brief This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH subframe (Table 8.3.-1 from 36.213). + @param frame_parms Pointer to DL frame configuration parameters + @param subframe Subframe of received/transmitted PHICH + @returns subframe of PUSCH transmission +*/ +uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + +/** \brief This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH frame (Table 8.3.-1 from 36.213). + @param frame_parms Pointer to DL frame configuration parameters + @param frame Frame of received/transmitted PHICH + @param subframe Subframe of received/transmitted PHICH + @returns frame of PUSCH transmission +*/ +int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe); + +uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); + +int get_nCCE_offset_l1(int *CCE_table, + const unsigned char L, + const int nCCE, + const int common_dci, + const unsigned short rnti, + const unsigned char subframe); + +uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi); + +uint16_t get_nquad(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi); + +uint8_t get_mi(LTE_DL_FRAME_PARMS *frame,uint8_t subframe); + +uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe); + +uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + +void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]); + +/*! + \brief Check for PRACH TXop in subframe + @param frame_parms Pointer to LTE_DL_FRAME_PARMS + @param frame frame index to check + @param subframe subframe index to check + @returns 0 on success +*/ +int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe); + +/*! + \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 + @returns 0-5 depending on number of available prach +*/ +uint8_t get_num_prach_tdd(module_id_t Mod_id); + +/*! + \brief Return the PRACH format as a function of the Configuration Index and Frame type. + @param prach_ConfigIndex PRACH Configuration Index + @param frame_type 0-FDD, 1-TDD + @returns 0-1 accordingly +*/ +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); + +/*! + \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index + @param frame_parms Pointer to LTE_DL_FRAME_PARMS structure + @returns 0-5 depending on number of available prach +*/ +uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index); + +/*! + \brief Comp ute DFT of PRACH ZC sequences. Used for generation of prach in UE and reception of PRACH in eNB. + @param rootSequenceIndex PRACH root sequence + #param prach_ConfigIndex PRACH Configuration Index + @param zeroCorrelationZoneConfig PRACH ncs_config + @param highSpeedFlat PRACH High-Speed Flag + @param frame_type TDD/FDD flag + @param Xu DFT output +*/ +void compute_prach_seq(uint16_t rootSequenceIndex, + uint8_t prach_ConfigIndex, + uint8_t zeroCorrelationZoneConfig, + uint8_t highSpeedFlag, + lte_frame_type_t frame_type, + uint32_t X_u[64][839]); + + +void init_prach_tables(int N_ZC); + +/*! + \brief Return the status of MBSFN in this frame/subframe + @param frame Frame index + @param subframe Subframe index + @param frame_parms Pointer to frame parameters + @returns 1 if subframe is for MBSFN +*/ +int is_pmch_subframe(frame_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms); + + +/** \brief This routine expands a single (wideband) PMI to subband PMI bitmap similar to the one used in the UCI and in the dlsch_modulation routine + @param frame_parms Pointer to DL frame configuration parameters + @param wideband_pmi (0,1,2,3 for rank 0 and 0,1 for rank 1) + @param rank (0 or 1) + @returns subband PMI bitmap +*/ +uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank); + +uint64_t pmi2hex_2Ar1(uint32_t pmi); + +uint64_t pmi2hex_2Ar2(uint32_t pmi); + +uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb); + +// DL power control functions +double get_pa_dB(uint8_t pa); + +void init_scrambling_lut(void); + +void init_unscrambling_lut(void); + + +uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf); + +uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); +uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); + +uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL); + +void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2); + +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h similarity index 51% rename from openair1/PHY/LTE_TRANSPORT/defs.h rename to openair1/PHY/LTE_TRANSPORT/transport_eNB.h index e4d9b47986f7ad1edf4f34bc9f6e230688f33f24..8c3fb51692535fe4fe26533e4b347c9b6cbe760a 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h @@ -29,21 +29,18 @@ * \note * \warning */ -#ifndef __LTE_TRANSPORT_DEFS__H__ -#define __LTE_TRANSPORT_DEFS__H__ -#include "PHY/defs.h" +#ifndef __TRANSPORT_ENB__H__ +#define __TRANSPORT_ENB__H__ +#include "transport_common.h" +//#include "PHY/defs_eNB.h" #include "PHY/impl_defs_lte.h" #include "dci.h" #include "mdci.h" -#include "uci.h" +#include "uci_common.h" #ifndef STANDALONE_COMPILE #include "UTIL/LISTS/list.h" #endif -#define MOD_TABLE_QPSK_OFFSET 1 -#define MOD_TABLE_16QAM_OFFSET 5 -#define MOD_TABLE_64QAM_OFFSET 21 -#define MOD_TABLE_PSS_OFFSET 85 // structures below implement 36-211 and 36-212 @@ -53,56 +50,6 @@ -#define NSOFT 1827072 -#define LTE_NULL 2 - -// maximum of 3 segments before each coding block if data length exceeds 6144 bits. - -#define MAX_NUM_DLSCH_SEGMENTS 16 -#define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS -#define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768) -#define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768) - -#define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE -#define MAX_NUM_RE (14*1200) - -#if !defined(SI_RNTI) -#define SI_RNTI (rnti_t)0xffff -#endif -#if !defined(M_RNTI) -#define M_RNTI (rnti_t)0xfffd -#endif -#if !defined(P_RNTI) -#define P_RNTI (rnti_t)0xfffe -#endif -#if !defined(CBA_RNTI) -#define CBA_RNTI (rnti_t)0xfff4 -#endif -#if !defined(C_RNTI) -#define C_RNTI (rnti_t)0x1234 -#endif -// These are the codebook indexes according to Table 6.3.4.2.3-1 of 36.211 -//1 layer -#define PMI_2A_11 0 -#define PMI_2A_1m1 1 -#define PMI_2A_1j 2 -#define PMI_2A_1mj 3 -//2 layers -#define PMI_2A_R1_10 0 -#define PMI_2A_R1_11 1 -#define PMI_2A_R1_1j 2 - -typedef enum { SEARCH_EXIST=0, - SEARCH_EXIST_OR_FREE} find_type_t; - -typedef enum { - SCH_IDLE=0, - ACTIVE, - CBA_ACTIVE, - DISABLED -} SCH_status_t; - - typedef struct { /// Status Flag indicating for this DLSCH (idle,active,disabled) SCH_status_t status; @@ -180,86 +127,6 @@ typedef struct { uint8_t codeword; } LTE_DL_eNB_HARQ_t; -typedef struct { - /// Indicator of first transmission - uint8_t first_tx; - /// Last Ndi received for this process on DCI (used for C-RNTI only) - uint8_t DCINdi; - /// Flag indicating that this ULSCH has a new packet (start of new round) - // uint8_t Ndi; - /// Status Flag indicating for this ULSCH (idle,active,disabled) - SCH_status_t status; - /// Subframe scheduling indicator (i.e. Transmission opportunity indicator) - uint8_t subframe_scheduling_flag; - /// Subframe cba scheduling indicator (i.e. Transmission opportunity indicator) - uint8_t subframe_cba_scheduling_flag; - /// First Allocated RB - uint16_t first_rb; - /// Current Number of RBs - uint16_t nb_rb; - /// Last TPC command - uint8_t TPC; - /// Transport block size - uint32_t TBS; - /// The payload + CRC size in bits, "B" from 36-212 - uint32_t B; - /// Length of ACK information (bits) - uint8_t O_ACK; - /// Pointer to the payload - uint8_t *b; - /// Pointers to transport block segments - uint8_t *c[MAX_NUM_ULSCH_SEGMENTS]; - /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) - uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS]; - /// Index of current HARQ round for this ULSCH - uint8_t round; - /// MCS format of this ULSCH - uint8_t mcs; - /// Redundancy-version of the current sub-frame - uint8_t rvidx; - /// Turbo-code outputs (36-212 V8.6 2009-03, p.12 - uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))]; - /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17) - uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144]; - /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) - uint32_t C; - /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cminus; - /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cplus; - /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kminus; - /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kplus; - /// Total number of bits across all segments - uint32_t sumKr; - /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t F; - /// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27) - uint16_t Msc_initial; - /// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27) - uint8_t Nsymb_initial; - /// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) - uint8_t n_DMRS; - /// n_DMRS2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1) - uint8_t n_DMRS2; - /// Flag to indicate that this is a control only ULSCH (i.e. no MAC SDU) - uint8_t control_only; - /// Flag to indicate that this is a calibration ULSCH (i.e. no MAC SDU and filled with TDD calibration information) - // int calibration_flag; - /// Number of soft channel bits - uint32_t G; - - // decode phich - uint8_t decode_phich; -} LTE_UL_UE_HARQ_t; - -#ifdef Rel14 -typedef enum { - CEmodeA = 0, - CEmodeB = 1 -} CEmode_t; -#endif typedef struct { /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding) @@ -311,81 +178,7 @@ typedef struct { #endif } LTE_eNB_DLSCH_t; -#define PUSCH_x 2 -#define PUSCH_y 3 -typedef struct { - /// Current Number of Symbols - uint8_t Nsymb_pusch; - /// SRS active flag - uint8_t srs_active; - /// Pointers to 8 HARQ processes for the ULSCH - LTE_UL_UE_HARQ_t *harq_processes[8]; - /// Pointer to CQI data (+1 for 8 bits crc) - uint8_t o[1+MAX_CQI_BYTES]; - /// Length of CQI data (bits) - uint8_t O; - /// Format of CQI data - UCI_format_t uci_format; - /// Rank information - uint8_t o_RI[2]; - /// Length of rank information (bits) - uint8_t O_RI; - /// Pointer to ACK - uint8_t o_ACK[4]; - /// Minimum number of CQI bits for PUSCH (36-212 r8.6, Sec 5.2.4.1 p. 37) - uint8_t O_CQI_MIN; - /// ACK/NAK Bundling flag - uint8_t bundling; - /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - uint8_t e[MAX_NUM_CHANNEL_BITS]; - /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - uint8_t h[MAX_NUM_CHANNEL_BITS]; - /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14) - uint8_t b_tilde[MAX_NUM_CHANNEL_BITS]; - /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14) - int32_t d[MAX_NUM_RE]; - /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15) - int32_t z[MAX_NUM_RE]; - /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) - uint8_t q[MAX_CQI_PAYLOAD]; - /// coded and interleaved CQI bits - uint8_t o_w[(MAX_CQI_BITS+8)*3]; - /// coded CQI bits - uint8_t o_d[96+((MAX_CQI_BITS+8)*3)]; - /// coded ACK bits - uint8_t q_ACK[MAX_ACK_PAYLOAD]; - /// coded RI bits - uint8_t q_RI[MAX_RI_PAYLOAD]; - /// beta_offset_cqi times 8 - uint16_t beta_offset_cqi_times8; - /// beta_offset_ri times 8 - uint16_t beta_offset_ri_times8; - /// beta_offset_harqack times 8 - uint16_t beta_offset_harqack_times8; - /// power_offset - uint8_t power_offset; - // for cooperative communication - uint8_t cooperation_flag; - /// RNTI attributed to this ULSCH - uint16_t rnti; - /// f_PUSCH parameter for PUSCH power control - int16_t f_pusch; - /// Po_PUSCH - target output power for PUSCH - int16_t Po_PUSCH; - /// PHR - current power headroom (based on last PUSCH transmission) - int16_t PHR; - /// Po_SRS - target output power for SRS - int16_t Po_SRS; - /// num active cba group - uint8_t num_active_cba_groups; - /// num dci found for cba - uint8_t num_cba_dci[10]; - /// allocated CBA RNTI - uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; - /// UL max-harq-retransmission - uint8_t Mlimit; -} LTE_UE_ULSCH_t; typedef struct { /// Flag indicating that this ULSCH has been allocated by a DCI (otherwise it is a retransmission based on PHICH NAK) @@ -510,38 +303,6 @@ typedef struct { int32_t delta_TF; } LTE_UL_eNB_HARQ_t; - -typedef enum { - pucch_format1=0, - pucch_format1a, - pucch_format1b, - pucch_format1b_csA2, - pucch_format1b_csA3, - pucch_format1b_csA4, - pucch_format2, - pucch_format2a, - pucch_format2b, - pucch_format3 // PUCCH format3 -} PUCCH_FMT_t; - -typedef enum { - SR, - HARQ, - CQI, - HARQ_SR, - HARQ_CQI, - SR_CQI, - HARQ_SR_CQI -} UCI_type_t; - -#ifdef Rel14 -typedef enum { - NOCE, - CEMODEA, - CEMODEB -} UE_type_t; -#endif - typedef struct { uint8_t active; /// Absolute frame for this UCI @@ -592,124 +353,6 @@ typedef struct { #endif } LTE_eNB_UCI; -typedef struct { - /// HARQ process mask, indicates which processes are currently active - uint16_t harq_mask; - /// Pointers to 8 HARQ processes for the ULSCH - LTE_UL_eNB_HARQ_t *harq_processes[8]; - /// Maximum number of HARQ rounds - uint8_t Mlimit; - /// Maximum number of iterations used in eNB turbo decoder - uint8_t max_turbo_iterations; - /// ACK/NAK Bundling flag - uint8_t bundling; - /// beta_offset_cqi times 8 - uint16_t beta_offset_cqi_times8; - /// beta_offset_ri times 8 - uint16_t beta_offset_ri_times8; - /// beta_offset_harqack times 8 - uint16_t beta_offset_harqack_times8; - /// Flag to indicate that eNB awaits UE Msg3 - uint8_t Msg3_active; - /// RNTI attributed to this ULSCH - uint16_t rnti; - /// cyclic shift for DM RS - uint8_t cyclicShift; - /// cooperation flag - uint8_t cooperation_flag; - /// num active cba group - uint8_t num_active_cba_groups; - /// allocated CBA RNTI for this ulsch - uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; -#ifdef LOCALIZATION - /// epoch timestamp in millisecond - int32_t reference_timestamp_ms; - /// aggregate physical states every n millisecond - int32_t aggregation_period_ms; - /// a set of lists used for localization - struct list loc_rss_list[10], loc_rssi_list[10], loc_subcarrier_rss_list[10], loc_timing_advance_list[10], loc_timing_update_list[10]; - struct list tot_loc_rss_list, tot_loc_rssi_list, tot_loc_subcarrier_rss_list, tot_loc_timing_advance_list, tot_loc_timing_update_list; -#endif -} LTE_eNB_ULSCH_t; - -typedef struct { - /// Indicator of first transmission - uint8_t first_tx; - /// Last Ndi received for this process on DCI (used for C-RNTI only) - uint8_t DCINdi; - /// DLSCH status flag indicating - SCH_status_t status; - /// Transport block size - uint32_t TBS; - /// The payload + CRC size in bits - uint32_t B; - /// Pointer to the payload - uint8_t *b; - /// Pointers to transport block segments - uint8_t *c[MAX_NUM_DLSCH_SEGMENTS]; - /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) - uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS]; - /// Index of current HARQ round for this DLSCH - uint8_t round; - /// MCS format for this DLSCH - uint8_t mcs; - /// Qm (modulation order) for this DLSCH - uint8_t Qm; - /// Redundancy-version of the current sub-frame - uint8_t rvidx; - /// MIMO mode for this DLSCH - MIMO_mode_t mimo_mode; - /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - int16_t w[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)]; - /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - double w_abs[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)]; - /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - int16_t *d[MAX_NUM_DLSCH_SEGMENTS]; - /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) - uint32_t C; - /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cminus; - /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cplus; - /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kminus; - /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kplus; - /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t F; - /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17) - uint8_t Nl; - /// current delta_pucch - int8_t delta_PUCCH; - /// Number of soft channel bits - uint32_t G; - /// Current Number of RBs - uint16_t nb_rb; - /// Current subband PMI allocation - uint16_t pmi_alloc; - /// Current RB allocation (even slots) - uint32_t rb_alloc_even[4]; - /// Current RB allocation (odd slots) - uint32_t rb_alloc_odd[4]; - /// distributed/localized flag - vrb_t vrb_type; - /// downlink power offset field - uint8_t dl_power_off; - /// trials per round statistics - uint32_t trials[8]; - /// error statistics per round - uint32_t errors[8]; - /// codeword this transport block is mapped to - uint8_t codeword; -} LTE_DL_UE_HARQ_t; - -typedef struct { - /// time-based localization, relying on TA and TOA - double time_based; - /// power-based localization, relying on RSS and RSSI - double power_based; -} eNB_UE_estimated_distances; - typedef struct { /// UL RSSI per receive antenna int32_t UL_rssi[NB_ANTENNAS_RX]; @@ -782,187 +425,39 @@ typedef struct { int total_TBS_last; /// Bitrate on the PDSCH [bps] unsigned int dlsch_bitrate; - // unsigned int total_transmitted_bits; -#ifdef LOCALIZATION - eNB_UE_estimated_distances distance; - int32_t *subcarrier_rssi; -#endif } LTE_eNB_UE_stats; typedef struct { - /// HARQ process id - uint8_t harq_id; - /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX - uint8_t ack; - /// send status (for PUCCH) - uint8_t send_harq_status; - /// nCCE (for PUCCH) - uint8_t nCCE; - /// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched - uint8_t vDAI_DL; - /// DAI value detected from DCI0/4. 0xff indicates not touched - uint8_t vDAI_UL; -} harq_status_t; - -typedef struct { - /// RNTI - uint16_t rnti; - /// Active flag for DLSCH demodulation - uint8_t active; - /// Transmission mode - uint8_t mode1_flag; - /// amplitude of PDSCH (compared to RS) in symbols without pilots - int16_t sqrt_rho_a; - /// amplitude of PDSCH (compared to RS) in symbols containing pilots - int16_t sqrt_rho_b; - /// Current HARQ process id threadRx Odd and threadRx Even - uint8_t current_harq_pid; - /// Current subband antenna selection - uint32_t antenna_alloc; - /// Current subband RI allocation - uint32_t ri_alloc; - /// Current subband CQI1 allocation - uint32_t cqi_alloc1; - /// Current subband CQI2 allocation - uint32_t cqi_alloc2; - /// saved subband PMI allocation from last PUSCH/PUCCH report - uint16_t pmi_alloc; - /// HARQ-ACKs - harq_status_t harq_ack[10]; - /// Pointers to up to 8 HARQ processes - LTE_DL_UE_HARQ_t *harq_processes[8]; - /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17 - uint8_t Mdlharq; - /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17) - uint8_t Kmimo; - /// Nsoft parameter related to UE Category - uint32_t Nsoft; - /// Maximum number of Turbo iterations + /// HARQ process mask, indicates which processes are currently active + uint16_t harq_mask; + /// Pointers to 8 HARQ processes for the ULSCH + LTE_UL_eNB_HARQ_t *harq_processes[8]; + /// Maximum number of HARQ rounds + uint8_t Mlimit; + /// Maximum number of iterations used in eNB turbo decoder uint8_t max_turbo_iterations; - /// number of iterations used in last turbo decoding - uint8_t last_iteration_cnt; - /// accumulated tx power adjustment for PUCCH - int8_t g_pucch; -} LTE_UE_DLSCH_t; - - - -typedef enum { - SI_PDSCH=0, - RA_PDSCH, - P_PDSCH, - PDSCH, - PDSCH1, - PMCH -} PDSCH_t; - -typedef enum { - rx_standard=0, - rx_IC_single_stream, - rx_IC_dual_stream, - rx_SIC_dual_stream -} RX_type_t; - - -#ifdef Rel14 -typedef enum { - DCI_COMMON_SPACE, - DCI_UE_SPACE -} dci_space_t; - - -typedef struct { - uint16_t slss_id; - uint8_t *slmib; -} SLSS_t; - -typedef struct { - // SL Configuration - /// Number of SL resource blocks (1-100) - uint32_t N_SL_RB; - /// prb-start (0-99) - uint32_t prb_Start; - /// prb-End (0-99) - uint32_t prb_End; - /// SL-OffsetIndicator (0-10239) - uint32_t SL_OffsetIndicator; - /// PSCCH subframe bitmap, first 64-bits (up to 40 bits for Rel 12) - uint64_t bitmap1; - /// PSCCH subframe bitmap, 2nd 64-bits (up to 100 bits for Rel 14) - uint64_t bitmap2; - - // SCI parameters - /// npscch resource index - uint32_t n_pscch; - /// format of SCI (0,1) - uint32_t format; - /// SCI0 frequency hopping flag - uint32_t freq_hopping_flag; - /// SCI0 Resource Block Coding - uint32_t resource_block_coding; - /// SCI0 Time Resource Pattern for SLSCH - uint32_t time_resource_pattern; - /// SCI0 MCS for SLSCH - uint32_t mcs; - /// SCI0 Timing advance indication for SLSCH - uint32_t timing_advance_indication; - /// SCI0 Group Destination ID for SLSCH - uint32_t group_destination_id; - - // SLSCH Parameters - /// Number of Subbands (36.213 14.1.1.2) - uint32_t Nsb; - /// N_RB_HO (36.213 14.1.1.2) - uint32_t N_RB_HO; - /// n_ss_PSSCH (36.211 9.2.4) - uint32_t n_ss_PSSCH; - /// n_ssf_PSSCH - uint32_t n_ssf_PSSCH; - /// cinit (36.331 hoppingParameter-r12) - uint32_t cinit; - /// redundancy version - uint32_t rvidx; - /// n_prime_VRB (36.213 14.1.1.2.1) - uint32_t n_prime_VRB; - /// M_RB_PSSCH_RP (36.213 14.1.3 - uint32_t M_RB_PSSCH_RP; - /// n_prime_PRB (36.213 14.1.1.4 - uint32_t n_prime_PRB; - /// m_nprime_PRB_PSSCH (36.213 14.1.3) - uint32_t m_nprime_PRB_PSCCH; - /// payload length - int payload_length; - /// pointer to payload - uint8_t *payload; -} SLSCH_t; - -typedef struct { - /// payload length - int payload_length; - uint8_t payload[100]; -} SLDCH_t; - -#define TTI_SYNC 0 -#define SLSS 1 -#define SLDCH 2 -#define SLSCH 3 - -typedef struct UE_tport_header_s { - int packet_type; - uint16_t absSF; -} UE_tport_header_t; - -typedef struct UE_tport_s { - UE_tport_header_t header; - union { - SLSS_t slss; - SLDCH_t sldch; - SLSCH_t slsch; - }; - uint8_t payload[1500]; -} UE_tport_t; + /// ACK/NAK Bundling flag + uint8_t bundling; + /// beta_offset_cqi times 8 + uint16_t beta_offset_cqi_times8; + /// beta_offset_ri times 8 + uint16_t beta_offset_ri_times8; + /// beta_offset_harqack times 8 + uint16_t beta_offset_harqack_times8; + /// Flag to indicate that eNB awaits UE Msg3 + uint8_t Msg3_active; + /// RNTI attributed to this ULSCH + uint16_t rnti; + /// cyclic shift for DM RS + uint8_t cyclicShift; + /// cooperation flag + uint8_t cooperation_flag; + /// num active cba group + uint8_t num_active_cba_groups; + /// allocated CBA RNTI for this ulsch + uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; +} LTE_eNB_ULSCH_t; -#endif /**@}*/ #endif diff --git a/openair1/PHY/LTE_TRANSPORT/extern.h b/openair1/PHY/LTE_TRANSPORT/transport_extern.h similarity index 98% rename from openair1/PHY/LTE_TRANSPORT/extern.h rename to openair1/PHY/LTE_TRANSPORT/transport_extern.h index 7ab9031010ba0fa16341899e31a81e17f7b69210..6a9fa49405a9bb3d8d3161aedc4ab4b1159b44c7 100644 --- a/openair1/PHY/LTE_TRANSPORT/extern.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_extern.h @@ -48,3 +48,5 @@ extern int16_t d0_sss[504*62],d5_sss[504*62]; extern uint8_t wACK[5][4]; extern int8_t wACK_RX[5][4]; + +extern uint32_t bitrev_cc_dci[32]; diff --git a/openair1/PHY/LTE_TRANSPORT/transport_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_proto.h new file mode 100644 index 0000000000000000000000000000000000000000..5547c308e9c320d1ea2c003b927f2f9e1776d3e0 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/transport_proto.h @@ -0,0 +1,621 @@ +/* + * 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/LTE_TRANSPORT/transport_proto.h + * \brief Function prototypes for eNB PHY physical/transport channel processing and generation V8.6 2009-03 + * \author R. Knopp, F. Kaltenberger + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#ifndef __LTE_TRANSPORT_PROTO__H__ +#define __LTE_TRANSPORT_PROTO__H__ +#include "PHY/defs_eNB.h" +#include <math.h> +#include "nfapi_interface.h" +#include "transport_common_proto.h" + +// Functions below implement 36-211 and 36-212 + +/** @addtogroup _PHY_TRANSPORT_ + * @{ + */ + +/** \fn free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch,unsigned char N_RB_DL) + \brief This function frees memory allocated for a particular DLSCH at eNB + @param dlsch Pointer to DLSCH to be removed +*/ +void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch); + +void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); + +/** \fn new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms) + \brief This function allocates structures for a particular DLSCH at eNB + @returns Pointer to DLSCH to be removed + @param Kmimo Kmimo factor from 36-212/36-213 + @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) + @param Nsoft Soft-LLR buffer size from UE-Category + @params N_RB_DL total number of resource blocks (determine the operating BW) + @param abstraction_flag Flag to indicate abstracted interface + @param frame_parms Pointer to frame descriptor structure +*/ +LTE_eNB_DLSCH_t *new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms); + +void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); + +/** \fn free_eNB_ulsch(LTE_eNB_DLSCH_t *dlsch) + \brief This function frees memory allocated for a particular ULSCH at eNB + @param ulsch Pointer to ULSCH to be removed +*/ +void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch); + +LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); + +int dlsch_encoding_all(PHY_VARS_eNB *eNB, + unsigned char *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats); + +/** \fn dlsch_encoding(PHY_VARS_eNB *eNB, + uint8_t *input_buffer, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe) + \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). The implemented functions are: + - CRC computation and addition + - Code block segmentation and sub-block CRC addition + - Channel coding (Turbo coding) + - Rate matching (sub-block interleaving, bit collection, selection and transmission + - Code block concatenation + @param eNB Pointer to eNB PHY context + @param input_buffer Pointer to input buffer for sub-frame + @param frame_parms Pointer to frame descriptor structure + @param num_pdcch_symbols Number of PDCCH symbols in this subframe + @param dlsch Pointer to dlsch to be encoded + @param frame Frame number + @param subframe Subframe number + @param rm_stats Time statistics for rate-matching + @param te_stats Time statistics for turbo-encoding + @param i_stats Time statistics for interleaving + @returns status +*/ +int32_t dlsch_encoding(PHY_VARS_eNB *eNB, + uint8_t *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *i_stats); + + + + +/** \fn dlsch_encoding_2threads(PHY_VARS_eNB *eNB, + uint8_t *input_buffer, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe) + \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). This version spawns 1 worker thread. The implemented functions are: + - CRC computation and addition + - Code block segmentation and sub-block CRC addition + - Channel coding (Turbo coding) + - Rate matching (sub-block interleaving, bit collection, selection and transmission + - Code block concatenation + @param eNB Pointer to eNB PHY context + @param input_buffer Pointer to input buffer for sub-frame + @param num_pdcch_symbols Number of PDCCH symbols in this subframe + @param dlsch Pointer to dlsch to be encoded + @param frame Frame number + @param subframe Subframe number + @param rm_stats Time statistics for rate-matching + @param te_stats Time statistics for turbo-encoding + @param i_stats Time statistics for interleaving + @returns status +*/ +int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, + uint8_t *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats, + int worker_num); + +// Functions below implement 36-211 + +/** \fn allocate_REs_in_RB(int32_t **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + int16_t *qam_table_s, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t use2ndpilots, + LTE_DL_FRAME_PARMS *frame_parms); + + \brief Fills RB with data + \param txdataF pointer to output data (frequency domain signal) + \param jj index to output (from CW 1) + \param jj index to output (from CW 2) + \param re_offset index of the first RE of the RB + \param symbol_offset index to the OFDM symbol + \param dlsch0_harq Pointer to Transport block 0 HARQ structure + \param dlsch0_harq Pointer to Transport block 1 HARQ structure + \param pilots =1 if symbol_offset is an OFDM symbol that contains pilots, 0 otherwise + \param amp Amplitude for symbols + \param qam_table_s0 pointer to scaled QAM table for Transport Block 0 (by rho_a or rho_b) + \param qam_table_s1 pointer to scaled QAM table for Transport Block 1 (by rho_a or rho_b) + \param re_allocated pointer to allocation counter + \param skip_dc offset for positive RBs + \param skip_half indicate that first or second half of RB must be skipped for PBCH/PSS/SSS + \param use2ndpilots Set to use the pilots from antenna port 1 for PDSCH + \param frame_parms Frame parameter descriptor +*/ + +int32_t allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, + int32_t **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + uint8_t precoder_index, + int16_t *qam_table_s0, + int16_t *qam_table_s1, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t lprime, + uint8_t mprime, + uint8_t Ns, + int *P1_SHIFT, + int *P2_SHIFT); + + +/** \fn int32_t dlsch_modulation(int32_t **txdataF, + int16_t amp, + uint32_t sub_frame_offset, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch); + + \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for DLSCH. + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param sub_frame_offset Offset of this subframe in units of subframes (usually 0) + @param frame_parms Pointer to frame descriptor + @param num_pdcch_symbols Number of PDCCH symbols in this subframe + @param dlsch0 Pointer to Transport Block 0 DLSCH descriptor for this allocation + @param dlsch1 Pointer to Transport Block 0 DLSCH descriptor for this allocation +*/ +int32_t dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, + int32_t **txdataF, + int16_t amp, + uint32_t sub_frame_offset, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch0, + LTE_eNB_DLSCH_t *dlsch1); + +int32_t dlsch_modulation_SIC(int32_t **sic_buffer, + uint32_t sub_frame_offset, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch0, + int G); +/* + \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for MCH. + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param subframe_offset Offset of this subframe in units of subframes (usually 0) + @param frame_parms Pointer to frame descriptor + @param dlsch Pointer to DLSCH descriptor for this allocation +*/ +int mch_modulation(int32_t **txdataF, + int16_t amp, + uint32_t subframe_offset, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_eNB_DLSCH_t *dlsch); + +/** \brief Top-level generation function for eNB TX of MBSFN + @param phy_vars_eNB Pointer to eNB variables + @param a Pointer to transport block + @param abstraction_flag + +*/ +void generate_mch(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,uint8_t *a); + +/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) + @param phy_vars_eNB Pointer to eNB variables + @param proc Pointer to RXn-TXnp4 proc information + @param mcs MCS for MBSFN + @param ndi new data indicator + @param rdvix +*/ +void fill_eNB_dlsch_MCH(PHY_VARS_eNB *phy_vars_eNB,int mcs,int ndi,int rvidx); + +/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) + @param phy_vars_ue Pointer to UE variables + @param mcs MCS for MBSFN + @param eNB_id index of eNB in ue variables +*/ + +/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) + for N subframes. + @param phy_vars_eNB Pointer to eNB variables + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param N Number of sub-frames to generate +*/ +void generate_pilots(PHY_VARS_eNB *phy_vars_eNB, + int32_t **txdataF, + int16_t amp, + uint16_t N); + +/** + \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) for one slot only + @param phy_vars_eNB Pointer to eNB variables + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param slot index (0..19) + @param first_pilot_only (0 no) +*/ +int32_t generate_pilots_slot(PHY_VARS_eNB *phy_vars_eNB, + int32_t **txdataF, + int16_t amp, + uint16_t slot, + int first_pilot_only); + +int32_t generate_mbsfn_pilot(PHY_VARS_eNB *phy_vars_eNB, + eNB_rxtx_proc_t *proc, + int32_t **txdataF, + int16_t amp); + +void generate_ue_spec_pilots(PHY_VARS_eNB *phy_vars_eNB, + uint8_t UE_id, + int32_t **txdataF, + int16_t amp, + uint16_t Ntti, + uint8_t beamforming_mode); + +int32_t generate_pss(int32_t **txdataF, + int16_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + uint16_t l, + uint16_t Ns); + + +int32_t generate_sss(int32_t **txdataF, + short amp, + LTE_DL_FRAME_PARMS *frame_parms, + unsigned short symbol, + unsigned short slot_offset); + +int32_t generate_pbch(LTE_eNB_PBCH *eNB_pbch, + int32_t **txdataF, + int32_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t *pbch_pdu, + uint8_t frame_mod4); + + + + +/*! \brief DCI Encoding. This routine codes an arbitrary DCI PDU after appending the 8-bit 3GPP CRC. It then applied sub-block interleaving and rate matching. + \param a Pointer to DCI PDU (coded in bytes) + \param A Length of DCI PDU in bits + \param E Length of DCI PDU in coded bits + \param e Pointer to sequence + \param rnti RNTI for CRC scrambling*/ +void dci_encoding(uint8_t *a, + uint8_t A, + uint16_t E, + uint8_t *e, + uint16_t rnti); + +/*! \brief Top-level DCI entry point. This routine codes an set of DCI PDUs and performs PDCCH modulation, interleaving and mapping. + \param num_dci Number of pdcch symbols + \param num_dci Number of DCI pdus to encode + \param dci_alloc Allocation vectors for each DCI pdu + \param n_rnti n_RNTI (see ) + \param amp Amplitude of QPSK symbols + \param frame_parms Pointer to DL Frame parameter structure + \param txdataF Pointer to tx signal buffers + \param sub_frame_offset subframe offset in frame + @returns Number of PDCCH symbols +*/ + +uint8_t generate_dci_top(uint8_t num_pdcch_symbols, + uint8_t num_dci, + DCI_ALLOC_t *dci_alloc, + uint32_t n_rnti, + int16_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t **txdataF, + uint32_t sub_frame_offset); + + +void generate_64qam_table(void); +void generate_16qam_table(void); + + + + + + + + +void ulsch_extract_rbs_single(int32_t **rxdataF, + int32_t **rxdataF_ext, + uint32_t first_rb, + uint32_t nb_rb, + uint8_t l, + uint8_t Ns, + LTE_DL_FRAME_PARMS *frame_parms); + + + + + +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,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); + +int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, + unsigned char *rar_pdu, + uint32_t frame, + unsigned char subframe); + +int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *PHY_vars_eNB, + eNB_rxtx_proc_t *proc, + void *dci_pdu, + rnti_t rnti, + DCI_format_t dci_format, + uint8_t UE_id, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint16_t cba_rnti, + uint8_t use_srs); + + +void dump_ulsch(PHY_VARS_eNB *phy_vars_eNB,int frame, int subframe, uint8_t UE_id,int round); + + + + + +void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + uint8_t *b, + uint8_t *bt); + + +void generate_pcfich(uint8_t num_pdcch_symbols, + int16_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t **txdataF, + uint8_t subframe); + + + + + +void init_transport_channels(uint8_t); + + + +void rx_ulsch(PHY_VARS_eNB *eNB, + eNB_rxtx_proc_t *proc, + uint8_t UE_id); + + +int ulsch_decoding_data_all(PHY_VARS_eNB *eNB, + int UE_id, + int harq_pid, + int llr8_flag); + +/*! + \brief Decoding of PUSCH/ACK/RI/ACK from 36-212. + @param phy_vars_eNB Pointer to eNB top-level descriptor + @param proc Pointer to RXTX proc variables + @param UE_id ID of UE transmitting this PUSCH + @param subframe Index of subframe for PUSCH + @param control_only_flag Receive PUSCH with control information only + @param Nbundled Nbundled parameter for ACK/NAK scrambling from 36-212/36-213 + @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used + @returns 0 on success +*/ +unsigned int ulsch_decoding(PHY_VARS_eNB *phy_vars_eNB, + eNB_rxtx_proc_t *proc, + uint8_t UE_id, + uint8_t control_only_flag, + uint8_t Nbundled, + uint8_t llr8_flag); + +/*! + \brief Decoding of ULSCH data component from 36-212. This one spawns 1 worker thread in parallel,half of the segments in each thread. + @param phy_vars_eNB Pointer to eNB top-level descriptor + @param UE_id ID of UE transmitting this PUSCH + @param harq_pid HARQ process ID + @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used + @returns 0 on success +*/ +int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB, + int UE_id, + int harq_pid, + int llr8_flag); + +/*! + \brief Decoding of ULSCH data component from 36-212. This one is single thread. + @param phy_vars_eNB Pointer to eNB top-level descriptor + @param UE_id ID of UE transmitting this PUSCH + @param harq_pid HARQ process ID + @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used + @returns 0 on success +*/ +int ulsch_decoding_data(PHY_VARS_eNB *eNB, + int UE_id, + int harq_pid, + int llr8_flag); + +void generate_phich_top(PHY_VARS_eNB *phy_vars_eNB, + eNB_rxtx_proc_t *proc, + int16_t amp); + + + + + + + +void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi); + +void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + int8_t* llr, + uint32_t length); + + +void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + int mbsfn_flag, + LTE_eNB_DLSCH_t *dlsch, + int hard_pid, + int G, + uint8_t q, + uint16_t frame, + uint8_t Ns); + + + +uint32_t rx_pucch(PHY_VARS_eNB *phy_vars_eNB, + PUCCH_FMT_t fmt, + uint8_t UE_id, + uint16_t n1_pucch, + uint16_t n2_pucch, + uint8_t shortened_format, + uint8_t *payload, + int frame, + uint8_t subframe, + uint8_t pucch1_thres); + + +/*! + \brief Process PRACH waveform + @param phy_vars_eNB Pointer to eNB top-level descriptor. If NULL, then this is an RRU + @param ru Pointer to RU top-level descriptor. If NULL, then this is an eNB and we make use of the RU_list + @param max_preamble most likely preamble + @param max_preamble_energy Estimated Energy of most likely preamble + @param max_preamble_delay Estimated Delay of most likely preamble + @param Nf System frame number + @param tdd_mapindex Index of PRACH resource in Table 5.7.1-4 (TDD) + @param br_flag indicator to act on eMTC PRACH + @returns 0 on success + +*/ +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, + uint16_t Nf, uint8_t tdd_mapindex +#ifdef Rel14 + , + uint8_t br_flag +#endif + ); + + +void init_unscrambling_lut(void); + + + +uint8_t is_not_pilot(uint8_t pilots, uint8_t re, uint8_t nushift, uint8_t use2ndpilots); + +uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, uint8_t beamforming_mode); + + + +double computeRhoA_eNB(uint8_t pa, + LTE_eNB_DLSCH_t *dlsch_eNB, + int dl_power_off, + uint8_t n_antenna_port); + +double computeRhoB_eNB(uint8_t pa, + uint8_t pb, + uint8_t n_antenna_port, + LTE_eNB_DLSCH_t *dlsch_eNB, + int dl_power_off); + + + +void conv_eMTC_rballoc(uint16_t resource_block_coding, + uint32_t N_RB_DL, + uint32_t *rb_alloc); + +int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); + +int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); + +int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); + +/**@}*/ +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/vars.h b/openair1/PHY/LTE_TRANSPORT/transport_vars.h similarity index 89% rename from openair1/PHY/LTE_TRANSPORT/vars.h rename to openair1/PHY/LTE_TRANSPORT/transport_vars.h index 41ee40b64af7a3df0b484706e67d08f8da45a26f..611028e1e9805d748de9c9c4f77ba0b8856b2170 100644 --- a/openair1/PHY/LTE_TRANSPORT/vars.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_vars.h @@ -78,3 +78,11 @@ char dci_format_strings[15][13] = {"0","1","1A","1B","1C","1D","1E_2A_M10PRB", uint8_t wACK[5][4] = {{1,1,1,1},{1,0,1,0},{1,1,0,0},{1,0,0,1},{0,0,0,0}}; int8_t wACK_RX[5][4] = {{-1,-1,-1,-1},{-1,1,-1,1},{-1,-1,1,1},{-1,1,1,-1},{1,1,1,1}}; + +uint32_t bitrev_cc_dci[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30}; + +uint8_t pcfich_b[4][32]= {{0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1}, + {1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0}, + {1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +}; diff --git a/openair1/PHY/LTE_TRANSPORT/uci.h b/openair1/PHY/LTE_TRANSPORT/uci_common.h similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/uci.h rename to openair1/PHY/LTE_TRANSPORT/uci_common.h index c7741533da543b909aa00bbaad4151274b210595..78555d4928c2f8b45f95092212ddc9ff36c924cd 100644 --- a/openair1/PHY/LTE_TRANSPORT/uci.h +++ b/openair1/PHY/LTE_TRANSPORT/uci_common.h @@ -19,6 +19,8 @@ * contact@openairinterface.org */ +#ifndef __UCI_COMMON__H +#define __UCI_COMMON__H #include "PHY/types.h" @@ -318,3 +320,5 @@ HLC_subband_cqi_mcs_CBA_20MHz; #define MAX_CQI_BYTES (sizeof(HLC_subband_cqi_rank2_2A_20MHz)) #define MAX_ACK_PAYLOAD 18 #define MAX_RI_PAYLOAD 6 + +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/uci_tools.c b/openair1/PHY/LTE_TRANSPORT/uci_tools.c index 65640e2ec713331c9531e5b852dd953a45707bea..539d5476ab8a92ff67b9ec8e36f1a685e2551fd1 100644 --- a/openair1/PHY/LTE_TRANSPORT/uci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/uci_tools.c @@ -29,765 +29,13 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" #ifdef DEBUG_UCI_TOOLS #include "PHY/vars.h" #endif //#define DEBUG_UCI 1 -uint64_t pmi2hex_2Ar1(uint32_t pmi) -{ - - uint64_t pmil = (uint64_t)pmi; - - return ((pmil&3) + (((pmil>>2)&3)<<4) + (((pmil>>4)&3)<<8) + (((pmil>>6)&3)<<12) + - (((pmil>>8)&3)<<16) + (((pmil>>10)&3)<<20) + (((pmil>>12)&3)<<24) + - (((pmil>>14)&3)<<28) + (((pmil>>16)&3)<<32) + (((pmil>>18)&3)<<36) + - (((pmil>>20)&3)<<40) + (((pmil>>22)&3)<<44) + (((pmil>>24)&3)<<48)); -} - -uint64_t pmi2hex_2Ar2(uint32_t pmi) -{ - - uint64_t pmil = (uint64_t)pmi; - return ((pmil&1) + (((pmil>>1)&1)<<4) + (((pmil>>2)&1)<<8) + (((pmil>>3)&1)<<12) + - (((pmil>>4)&1)<<16) + (((pmil>>5)&1)<<20) + (((pmil>>6)&1)<<24) + - (((pmil>>7)&1)<<28) + (((pmil>>8)&1)<<32) + (((pmil>>9)&1)<<36) + - (((pmil>>10)&1)<<40) + (((pmil>>11)&1)<<44) + (((pmil>>12)&1)<<48)); -} - -uint64_t cqi2hex(uint32_t cqi) -{ - - uint64_t cqil = (uint64_t)cqi; - return ((cqil&3) + (((cqil>>2)&3)<<4) + (((cqil>>4)&3)<<8) + (((cqil>>6)&3)<<12) + - (((cqil>>8)&3)<<16) + (((cqil>>10)&3)<<20) + (((cqil>>12)&3)<<24) + - (((cqil>>14)&3)<<28) + (((cqil>>16)&3)<<32) + (((cqil>>18)&3)<<36) + - (((cqil>>20)&3)<<40) + (((cqil>>22)&3)<<44) + (((cqil>>24)&3)<<48)); -} - -//void do_diff_cqi(uint8_t N_RB_DL, -// uint8_t *DL_subband_cqi, -// uint8_t DL_cqi, -// uint32_t diffcqi1) { -// -// uint8_t nb_sb,i,offset; -// -// // This is table 7.2.1-3 from 36.213 (with k replaced by the number of subbands, nb_sb) -// switch (N_RB_DL) { -// case 6: -// nb_sb=0; -// break; -// case 15: -// nb_sb = 4; -// case 25: -// nb_sb = 7; -// break; -// case 50: -// nb_sb = 9; -// break; -// case 75: -// nb_sb = 10; -// break; -// case 100: -// nb_sb = 13; -// break; -// default: -// nb_sb=0; -// break; -// } -// -// memset(DL_subband_cqi,0,13); -// -// for (i=0;i<nb_sb;i++) { -// offset = (DL_cqi>>(2*i))&3; -// if (offset == 3) -// DL_subband_cqi[i] = DL_cqi - 1; -// else -// DL_subband_cqi[i] = DL_cqi + offset; -// } -//} - - -void do_diff_cqi(uint8_t N_RB_DL, - uint8_t *DL_subband_cqi, - uint8_t DL_cqi, - uint32_t diffcqi1) -{ - - uint8_t nb_sb,i,offset; - - // This is table 7.2.1-3 from 36.213 (with k replaced by the number of subbands, nb_sb) - switch (N_RB_DL) { - case 6: - nb_sb=1; - break; - - case 15: - nb_sb = 4; - break; - - case 25: - nb_sb = 7; - break; - - case 50: - nb_sb = 9; - break; - - case 75: - nb_sb = 10; - break; - - case 100: - nb_sb = 13; - break; - - default: - nb_sb=0; - break; - } - - memset(DL_subband_cqi,0,13); - - for (i=0; i<nb_sb; i++) { - offset = (diffcqi1>>(2*i))&3; - - if (offset == 3) - DL_subband_cqi[i] = DL_cqi - 1; - else - DL_subband_cqi[i] = DL_cqi + offset; - } -} - -void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats, uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode) -{ - - //unsigned char rank; - //UCI_format fmt; - //uint8_t N_RB_DL = 25; - uint8_t i; - LOG_D(PHY,"[eNB][UCI] N_RB_DL %d uci format %d\n", N_RB_DL,uci_format); - - switch(N_RB_DL) { - case 6: - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_1_5MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (rb %d)\n",N_RB_DL); - break; - } - - break; - - case 25: - - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_5MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_5MHz *)o)->pmi; - //this translates the 2-layer PMI into a single layer PMI for the first codeword - //the PMI for the second codeword will be stats->DL_pmi_single^0x1555 - stats->DL_pmi_single = 0; - for (i=0;i<7;i++) - stats->DL_pmi_single = stats->DL_pmi_single | (((stats->DL_pmi_dual&(1<i))>>i)*2)<<2*i; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (rb %d)\n",N_RB_DL); - break; - } - - break; - - case 50: - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_10MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_10MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_10MHz *)o)->pmi; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (RB %d)\n",N_RB_DL); - break; - } - - break; - - case 100: - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_20MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_20MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_20MHz *)o)->pmi; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (RB %d)\n",N_RB_DL); - break; - } - - break; - - default: - LOG_N(PHY,"[eNB][UCI] unknown RB %d\n",N_RB_DL); - break; - } - - /* - switch (tmode) { - - case 1: - case 2: - case 3: - case 5: - case 6: - case 7: - default: - fmt = hlc_cqi; - break; - case 4: - fmt = wideband_cqi; - break; - } - - rank = o_RI[0]; - //printf("extract_CQI: rank = %d\n",rank); - - switch (fmt) { - - case wideband_cqi: //and subband pmi - if (rank == 0) { - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_5MHz *)o)->pmi; - } - else { - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - if (stats->DL_cqi[1] > 15) - stats->DL_cqi[1] = 15; - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_5MHz *)o)->pmi; - } - break; - case hlc_cqi: - if (tmode > 2) { - if (rank == 0) { - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi; - } - else { - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - if (stats->DL_cqi[1] > 15) - stats->DL_cqi[1] = 15; - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi; - } - } - else { - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1); - - } - break; - default: - break; - } - */ - -} - - -void print_CQI(void *o,UCI_format_t uci_format,unsigned char eNB_id,int N_RB_DL) -{ - - - switch(uci_format) { - case wideband_cqi_rank1_2A: -#ifdef DEBUG_UCI - LOG_D(PHY,"[PRINT CQI] flat_LA %d\n", flag_LA); - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi)); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_5MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)o)->pmi)); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_10MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_10MHz *)o)->pmi)); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_20MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_20MHz *)o)->pmi)); - break; - } - -#endif //DEBUG_UCI - break; - - case wideband_cqi_rank2_2A: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi)); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_5MHz *)o)->pmi)); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_10MHz *)o)->pmi)); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_20MHz *)o)->pmi)); - break; - } - -#endif //DEBUG_UCI - break; - - case HLC_subband_cqi_nopmi: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1)); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1)); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1)); - break; - } - -#endif //DEBUG_UCI - break; - - case HLC_subband_cqi_rank1_2A: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - } - -#endif //DEBUG_UCI - break; - - case HLC_subband_cqi_rank2_2A: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi); - break; - } - -#endif //DEBUG_UCI - break; - - case ue_selected: -#ifdef DEBUG_UCI - LOG_W(PHY,"[PRINT CQI] ue_selected CQI not supported yet!!!\n"); -#endif //DEBUG_UCI - break; - - default: -#ifdef DEBUG_UCI - LOG_E(PHY,"[PRINT CQI] unsupported CQI mode (%d)!!!\n",uci_format); -#endif //DEBUG_UCI - break; - } - - /* - switch (tmode) { - - case 1: - case 2: - case 3: - case 5: - case 6: - case 7: - default: - fmt = hlc_cqi; - break; - case 4: - fmt = wideband_cqi; - break; - } - - switch (fmt) { - - case wideband_cqi: - if (rank == 0) { - #ifdef DEBUG_UCI - msg("[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id,((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id,((wideband_cqi_rank1_2A_5MHz *)o)->pmi,pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)o)->pmi)); - #endif //DEBUG_UCI - } - else { - #ifdef DEBUG_UCI - msg("[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - msg("[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_5MHz *)o)->pmi)); - #endif //DEBUG_UCI - } - break; - case hlc_cqi: - if (tmode > 2) { - if (rank == 0) { - #ifdef DEBUG_UCI - msg("[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - msg("[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - #endif //DEBUG_UCI - } - else { - #ifdef DEBUG_UCI - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi); - #endif //DEBUG_UCI - } - } - else { - #ifdef DEBUG_UCI - msg("[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - #endif //DEBUG_UCI - } - break; - case ue_selected: - #ifdef DEBUG_UCI - msg("dci_tools.c: print_CQI ue_selected CQI not supported yet!!!\n"); - #endif //DEBUG_UCI - break; - } - */ - -} - int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type) { uint8_t i; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 2f4cfd23442a022d694606f8d199a27c1eb43306..50f469011f0237923c090dc48c0c59d8492d0cf7 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -30,23 +30,20 @@ * \warning */ -//#include "defs.h" + #include <syscall.h> -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/extern.h" -#include "extern.h" -#include "SCHED/extern.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" -#endif +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_extern.h" +#include "SCHED/sched_eNB.h" +#include "LAYER2/MAC/mac.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_ULSCH_DECODING #include "targets/RT/USER/rt_wrapper.h" +#include "transport_proto.h" extern int codingw; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 920d8ff3fdbdfd1505d6f7e059217ec844bd632e..0ffe3d735b23f86748fac00508501f9d24c07c65 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -30,12 +30,14 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "transport_eNB.h" //#define DEBUG_ULSCH #include "PHY/sse_intrin.h" +#include "transport_common_proto.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/MODULATION/modulation_eNB.h" #include "T.h" @@ -1104,7 +1106,7 @@ void ulsch_channel_level(int32_t **drs_ch_estimates_ext, int ulsch_power_LUT[750]; -void init_ulsch_power_LUT() { +void init_ulsch_power_LUT(void) { int i; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..82dedd9bc999895101ce99aeb0b00879227e8867 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c @@ -0,0 +1,5160 @@ +/* + * 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/LTE_UE_TRANSPORT/dci_tools_ue.c + * \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler. + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#ifdef DEBUG_DCI_TOOLS +#include "PHY/phy_vars.h" +#endif +#include "assertions.h" + + +//#define DEBUG_HARQ + + +#include "LAYER2/MAC/mac.h" + +//#define DEBUG_DCI + +#include "../LTE_TRANSPORT/dci_tools_common_extern.h" +#include "../LTE_TRANSPORT/transport_proto.h" +#include "transport_proto_ue.h" +#include "../LTE_TRANSPORT/transport_common_proto.h" +#include "SCHED/sched_common.h" + +extern uint16_t beta_cqi[16]; +extern uint16_t beta_ri[16]; +extern uint16_t beta_ack[16]; + +void extract_dci1A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +{ + uint8_t harq_pid=0; + uint32_t rballoc=0; + uint8_t vrb_type=0; + uint8_t mcs=0; + uint8_t rv=0; + uint8_t ndi=0; + uint8_t TPC=0; + + uint8_t dai=0; + + switch (N_RB_DL) { + case 6: + if (frame_type == TDD) { + vrb_type = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; + // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } + break; + + case 25: + + if (frame_type == TDD) { + vrb_type = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai; + //printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_5MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_5MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } + + break; + + case 50: + if (frame_type == TDD) { + vrb_type = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai; + // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_10MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_10MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_10MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, vrb_type %d, rballoc %x,ndi %d, rv %d, TPC %d\n",mcs,vrb_type,rballoc,ndi,rv,TPC); + } + break; + + case 100: + if (frame_type == TDD) { + vrb_type = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai; + // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_20MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_20MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_20MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } + break; + } + + pdci_info_extarcted->vrb_type = vrb_type; + pdci_info_extarcted->mcs1 = mcs; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->rv1 = rv; + pdci_info_extarcted->ndi1 = ndi; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->harq_pid = harq_pid; + pdci_info_extarcted->dai = dai; +} + +void extract_dci1C_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +{ + + uint32_t rballoc=0; + uint8_t mcs=0; + + switch (N_RB_DL) { + case 6: + mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); + + break; + + case 25: + mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); + + break; + + case 50: + mcs = ((DCI1C_10MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_10MHz_t *)dci_pdu)->rballoc,6); + + break; + + case 100: + mcs = ((DCI1C_20MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_20MHz_t *)dci_pdu)->rballoc,6); + break; + + default: + AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",N_RB_DL); + break; + } + + pdci_info_extarcted->mcs1 = mcs; + pdci_info_extarcted->rballoc = rballoc; +} + +void extract_dci1_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +{ + + uint32_t rballoc=0; + uint8_t mcs=0; + uint8_t rah=0; + uint8_t rv=0; + uint8_t TPC=0; + uint8_t ndi=0; + uint8_t harq_pid=0; + + switch (N_RB_DL) { + case 6: + if (frame_type == TDD) { + mcs = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + + case 25: + if (frame_type == TDD) { + mcs = ((DCI1_5MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_5MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_5MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_5MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_5MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_5MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_5MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_5MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_5MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_5MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_5MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_5MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + + case 50: + if (frame_type == TDD) { + mcs = ((DCI1_10MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_10MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_10MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_10MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_10MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_10MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_10MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_10MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_10MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_10MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_10MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_10MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_10MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_10MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + + case 100: + if (frame_type == TDD) { + mcs = ((DCI1_20MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_20MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_20MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_20MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_20MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_20MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_20MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_20MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_20MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_20MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_20MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_20MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_20MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_20MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + } + + pdci_info_extarcted->mcs1 = mcs; + pdci_info_extarcted->rah = rah; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->rv1 = rv; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->ndi1 = ndi; + pdci_info_extarcted->harq_pid = harq_pid; + +} + +void extract_dci2_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +{ + + uint32_t rballoc=0; + uint8_t rah=0; + uint8_t mcs1=0; + uint8_t mcs2=0; + uint8_t rv1=0; + uint8_t rv2=0; + uint8_t ndi1=0; + uint8_t ndi2=0; + uint8_t tbswap=0; + uint8_t tpmi=0; + uint8_t harq_pid=0; + uint8_t TPC=0; + + switch (N_RB_DL) { + + case 6: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + + case 25: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + + case 50: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + + case 100: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + } + + pdci_info_extarcted->rah = rah; + pdci_info_extarcted->mcs1 = mcs1; + pdci_info_extarcted->mcs2 = mcs2; + pdci_info_extarcted->rv1 = rv1; + pdci_info_extarcted->rv2 = rv2; + pdci_info_extarcted->harq_pid = harq_pid; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->tb_swap = tbswap; + pdci_info_extarcted->tpmi = tpmi; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->ndi1 = ndi1; + pdci_info_extarcted->ndi2 = ndi2; + +} + +void extract_dci2A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) +{ + + uint32_t rballoc=0; + uint8_t rah=0; + uint8_t mcs1=0; + uint8_t mcs2=0; + uint8_t rv1=0; + uint8_t rv2=0; + uint8_t ndi1=0; + uint8_t ndi2=0; + uint8_t tbswap=0; + uint8_t tpmi=0; + uint8_t harq_pid=0; + uint8_t TPC=0; + + AssertFatal( (nb_antenna_ports_eNB == 2) || (nb_antenna_ports_eNB == 4), "unsupported nb_antenna_ports_eNB %d\n", nb_antenna_ports_eNB); + switch (N_RB_DL) { + + case 6: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + + break; + + case 25: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + break; + + case 50: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + + break; + + case 100: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + + break; + } + + pdci_info_extarcted->mcs1 = mcs1; + pdci_info_extarcted->mcs2 = mcs2; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->rah = rah; + pdci_info_extarcted->rv1 = rv1; + pdci_info_extarcted->rv2 = rv2; + pdci_info_extarcted->ndi1 = ndi1; + pdci_info_extarcted->ndi2 = ndi2; + pdci_info_extarcted->harq_pid = harq_pid; + pdci_info_extarcted->tb_swap = tbswap; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->tpmi = tpmi; +} + +int check_dci_format1_1a_coherency(DCI_format_t dci_format, + uint8_t N_RB_DL, + uint16_t rnti, + uint16_t tc_rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint32_t frame, + uint8_t subframe, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_UE_HARQ_t *pdlsch0_harq) +{ + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t TPC = pdci_info_extarcted->TPC; + uint8_t rah = pdci_info_extarcted->rah; +#ifdef DEBUG_DCI + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t ndi1 = pdci_info_extarcted->ndi1; +#endif + + uint8_t NPRB = 0; + long long int RIV_max = 0; + +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1-1A] AbsSubframe %d.%d dci_format %d\n", frame, subframe, dci_format); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rnti %x\n", rnti); + LOG_I(PHY,"[DCI-FORMAT-1-1A] harq_pid %d\n", harq_pid); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rah %d\n", rah); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rballoc %x\n", rballoc); + LOG_I(PHY,"[DCI-FORMAT-1-1A] mcs1 %d\n", mcs1); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rv1 %d\n", rv1); + LOG_I(PHY,"[DCI-FORMAT-1-1A] ndi1 %d\n", ndi1); + LOG_I(PHY,"[DCI-FORMAT-1-1A] TPC %d\n", TPC); +#endif + + + // I- check dci content minimum coherency + if( ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) && harq_pid > 0) + { + return(0); + } + + if(harq_pid>=8) + { + // LOG_I(PHY,"bad harq id \n"); + return(0); + } + + if(dci_format == format1 && ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) ) + { + // LOG_I(PHY,"bad dci format \n"); + return(0); + } + + + if( mcs1 > 28) + { + if(pdlsch0_harq->round == 0) + { + // LOG_I(PHY,"bad dci mcs + round \n"); + return(0); + } + + if((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + // LOG_I(PHY,"bad dci mcs + rnti \n"); + return(0); + } + } + + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + NPRB = (TPC&1) + 2; + switch (N_RB_DL) { + case 6: + RIV_max = RIV_max6; + break; + case 25: + RIV_max = RIV_max25; + break; + case 50: + RIV_max = RIV_max50; + break; + case 100: + RIV_max = RIV_max100; + break; + } + } + else + { + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max6; + else + RIV_max = 0x3F; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max25; + else + RIV_max = 0x1FFF; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max50; + else + RIV_max = 0x1FFFF; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max100; + else + RIV_max = 0x1FFFFFF; + break; + } + } + + + if(dci_format == format1) + { + NPRB = conv_nprb(rah, rballoc, N_RB_DL); + } + + + if(rballoc > RIV_max) + { + // LOG_I(PHY,"bad dci rballoc rballoc %d RIV_max %lld \n",rballoc, RIV_max); + // DCI false detection + return(0); + } + + if(NPRB == 0) + { + // DCI false detection + // LOG_I(PHY,"bad NPRB = 0 \n"); + return(0); + } + + // this a retransmission + if(pdlsch0_harq->round>0) + { + // compare old TBS to new TBS + if((mcs1<29) && (pdlsch0_harq->TBS != TBStable[get_I_TBS(mcs1)][NPRB-1])) + { + // this is an eNB issue + // retransmisison but old and new TBS are different !!! + // work around, consider it as a new transmission + LOG_E(PHY,"Format1A Retransmission but TBS are different: consider it as new transmission !!! \n"); + pdlsch0_harq->round = 0; + //return(0); // ?? to cross check + } + } + + return(1); +} + +int check_dci_format1c_coherency(uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + uint16_t rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + LTE_DL_UE_HARQ_t *pdlsch0_harq) +{ + uint32_t rballoc = pdci_info_extarcted->rballoc; + + uint8_t NPRB = 0; + uint32_t RIV_max = 0; + + // I- check dci content minimum coherency + + if((rnti!=si_rnti) && (rnti!=p_rnti) && (rnti!=ra_rnti)) + return(0); + + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; + RIV_max = RIV_max6; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; + RIV_max = RIV_max25; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; + RIV_max = RIV_max50; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; + RIV_max = RIV_max100; + break; + } + + if(rballoc > RIV_max) + { + // DCI false detection + return(0); + } + + if(NPRB == 0) + { + // DCI false detection + return(0); + } + + return(1); +} + +int check_dci_format2_2a_coherency(DCI_format_t dci_format, + uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + uint16_t rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + LTE_DL_UE_HARQ_t *pdlsch0_harq, + LTE_DL_UE_HARQ_t *pdlsch1_harq) +{ + uint8_t rah = pdci_info_extarcted->rah; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t mcs2 = pdci_info_extarcted->mcs2; + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t rv2 = pdci_info_extarcted->rv2; + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + +#ifdef DEBUG_DCI + uint8_t ndi1 = pdci_info_extarcted->ndi1; + uint8_t ndi2 = pdci_info_extarcted->ndi2; +#endif + + uint8_t NPRB = 0; + long long RIV_max = 0; + +#ifdef DEBUG_DCI + LOG_I(PHY, "extarcted dci - dci_format %d \n", dci_format); + LOG_I(PHY, "extarcted dci - rnti %d \n", rnti); + LOG_I(PHY, "extarcted dci - rah %d \n", rah); + LOG_I(PHY, "extarcted dci - mcs1 %d \n", mcs1); + LOG_I(PHY, "extarcted dci - mcs2 %d \n", mcs2); + LOG_I(PHY, "extarcted dci - rv1 %d \n", rv1); + LOG_I(PHY, "extarcted dci - rv2 %d \n", rv2); + //LOG_I(PHY, "extarcted dci - ndi1 %d \n", ndi1); + //LOG_I(PHY, "extarcted dci - ndi2 %d \n", ndi2); + LOG_I(PHY, "extarcted dci - rballoc %x \n", rballoc); + LOG_I(PHY, "extarcted dci - harq pid %d \n", harq_pid); + LOG_I(PHY, "extarcted dci - round0 %d \n", pdlsch0_harq->round); + LOG_I(PHY, "extarcted dci - round1 %d \n", pdlsch1_harq->round); +#endif + + // I- check dci content minimum coherency + if(harq_pid>=8) + { + // LOG_I(PHY,"bad harq pid\n"); + return(0); + } + + if( (rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti) ) + { + // LOG_I(PHY,"bad rnti\n"); + return(0); + } + + + if( mcs1 > 28) + { + if(pdlsch0_harq->round == 0) + { + // LOG_I(PHY,"bad mcs1\n"); + return(0); + } + } + + if( mcs2 > 28) + { + if(pdlsch1_harq->round == 0) + { + // LOG_I(PHY,"bad mcs2\n"); + return(0); + } + } + + + if((pdlsch0_harq->round == 0) && (rv1 > 0) && (mcs1 != 0)) + { + // DCI false detection + // LOG_I(PHY,"bad rv1\n"); + return(0); + } + + if((pdlsch1_harq->round == 0) && (rv2 > 0) && (mcs2 != 0)) + { + // DCI false detection + // LOG_I(PHY,"bad rv2\n"); + return(0); + } + + + switch (N_RB_DL) { + case 6: + if (rah == 0) + { + //RBG = 1; + RIV_max = 0x3F; + } + else + { + RIV_max = RIV_max6; + } + break; + case 25: + if (rah == 0) + { + //RBG = 2; + RIV_max = 0x1FFF; + } + else + { + RIV_max = RIV_max25; + } + break; + case 50: + if (rah == 0) + { + //RBG = 3; + RIV_max = 0x1FFFF; + } + else + { + RIV_max = RIV_max50; + } + break; + case 100: + if (rah == 0) + { + //RBG = 4; + RIV_max = 0x1FFFFFF; + } + else + { + RIV_max = RIV_max100; + } + break; + } + + NPRB = conv_nprb(rah, + rballoc, + N_RB_DL); + + + + if( (rballoc > RIV_max) && (rah == 1) ) + { + // DCI false detection + // LOG_I(PHY,"bad rballoc %d RIV_max %lld\n", rballoc, RIV_max); + return(0); + } + + if(NPRB == 0) + { + // DCI false detection + // LOG_I(PHY,"bad NPRB\n"); + return(0); + } + + return(1); +} + +void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + LTE_DL_UE_HARQ_t *dlsch0_harq, + uint8_t nb_rb_alloc, + uint8_t subframe) +{ + uint32_t pbch_pss_sss_re; + uint32_t crs_re; + uint32_t granted_re; + uint32_t data_re; + uint32_t llr_offset; + uint8_t symbol; + uint8_t symbol_mod; + + pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; + + LOG_D(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); + + //dlsch0_harq->rb_alloc_even; + //dlsch0_harq->rb_alloc_odd; + + for(symbol=pdcch_vars->num_pdcch_symbols; symbol<frame_parms->symbols_per_tti; symbol++) + { + symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; + if((symbol_mod == 0) || symbol_mod == (4-frame_parms->Ncp)) + { + if (frame_parms->nb_antennas_tx == 2) + crs_re = 4; + else + crs_re = 2; + } + else + { + crs_re = 0; + } + + granted_re = nb_rb_alloc * (12-crs_re); + pbch_pss_sss_re = adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,subframe,symbol); + pbch_pss_sss_re = (double)pbch_pss_sss_re * ((double)(12-crs_re)/12); + data_re = granted_re - pbch_pss_sss_re; + llr_offset = data_re * dlsch0_harq->Qm * 2; + + pdsch_vars->llr_length[symbol] = data_re; + if(symbol < (frame_parms->symbols_per_tti-1)) + pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; + + LOG_D(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); + LOG_D(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); + LOG_D(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); + LOG_D(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); + + + + LOG_D(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, + pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); + } +} +void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, + uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + uint8_t subframe, + uint16_t rnti, + uint16_t tc_rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + LTE_DL_UE_HARQ_t *pdlsch0_harq, + LTE_UE_DLSCH_t *pdlsch0) +{ + + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint8_t vrb_type = pdci_info_extarcted->vrb_type; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t ndi1 = pdci_info_extarcted->ndi1; + uint8_t TPC = pdci_info_extarcted->TPC; + uint8_t rah = pdci_info_extarcted->rah; + uint8_t dai = pdci_info_extarcted->dai; + + + uint8_t NPRB = 0; + uint8_t NPRB4TBS = 0; + + if(dci_format == format1A) + { + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc]; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc]; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc]; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc]; + break; + } + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + NPRB4TBS = (TPC&1) + 2; + } + else + { + NPRB4TBS = NPRB; + /* + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; + break; + } + + */ + } + } + else // format1 + { + NPRB = conv_nprb(rah, rballoc, N_RB_DL); + NPRB4TBS=NPRB; + } + + pdlsch0->current_harq_pid = harq_pid; + pdlsch0->active = 1; + pdlsch0->rnti = rnti; + if(dci_format == format1A) + pdlsch0->harq_ack[subframe].vDAI_DL = dai+1; + + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + pdlsch0_harq->round = 0; + pdlsch0_harq->status = ACTIVE; + } + else //CRNTI + { + if (rnti == tc_rnti) { + //fix for standalone Contention Resolution Id + pdlsch0_harq->DCINdi = (uint8_t)-1; + LOG_D(PHY,"UE (%x/%d): Format1A DCI: C-RNTI is temporary. Set NDI = %d and to be ignored\n", + rnti,harq_pid,pdlsch0_harq->DCINdi); + } + + // NDI has been toggled or this is the first transmission + if ((ndi1!=pdlsch0_harq->DCINdi) || (pdlsch0_harq->first_tx==1)) + { + pdlsch0_harq->round = 0; + pdlsch0_harq->first_tx = 0; + pdlsch0_harq->status = ACTIVE; + + }else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if (pdlsch0_harq->status == SCH_IDLE) + //packet was actually decoded in previous transmission (ACK was missed by eNB) + //However, the round is not a good check as it might have been decoded in a retransmission prior to this one. + { + // LOG_D(PHY,"skip pdsch decoding and report ack\n"); + // skip pdsch decoding and report ack + //pdlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + pdlsch0->harq_ack[subframe].ack = 1; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch0->harq_ack[subframe].send_harq_status = 1; + + //pdlsch0_harq->first_tx = 0; + } + else //normal retransmission + { + // nothing special to do + } + } + else + { + pdlsch0_harq->status = ACTIVE; + } + } + + pdlsch0_harq->DCINdi = ndi1; + pdlsch0_harq->mcs = mcs1; + pdlsch0_harq->rvidx = rv1; + pdlsch0_harq->nb_rb = NPRB; + + pdlsch0_harq->codeword = 0; + pdlsch0_harq->Nl = 1; + pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; + pdlsch0_harq->dl_power_off = 1; //no power offset + pdlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC &3]; + + // compute resource allocation + if(dci_format == format1A) + { + switch (N_RB_DL) { + case 6: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT6[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; + } + break; + + case 25: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT25[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; + } + break; + + case 50: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT50_0[rballoc]; + 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]; + } else { // DISTRIBUTED + if ((rballoc&(1<<10)) == 0) { + rballoc = rballoc&(~(1<<10)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; + } + else { + rballoc = rballoc&(~(1<<10)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; + } + } + break; + + case 100: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = localRIV2alloc_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = localRIV2alloc_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = localRIV2alloc_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = localRIV2alloc_LUT100_3[rballoc]; + } else { + if ((rballoc&(1<<10)) == 0) { //Gap 1 + rballoc = rballoc&(~(1<<12)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; + } + else { //Gap 2 + rballoc = rballoc&(~(1<<12)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; + } + } + break; + } + } + else // format1 + { + conv_rballoc(rah,rballoc,frame_parms->N_RB_DL,pdlsch0_harq->rb_alloc_even); + pdlsch0_harq->rb_alloc_odd[0]= pdlsch0_harq->rb_alloc_even[0]; + pdlsch0_harq->rb_alloc_odd[1]= pdlsch0_harq->rb_alloc_even[1]; + pdlsch0_harq->rb_alloc_odd[2]= pdlsch0_harq->rb_alloc_even[2]; + pdlsch0_harq->rb_alloc_odd[3]= pdlsch0_harq->rb_alloc_even[3]; + } + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + pdlsch0_harq->TBS = TBStable[mcs1][NPRB4TBS-1]; + pdlsch0_harq->Qm = 2; + } + else + { + if(mcs1 < 29) + { + pdlsch0_harq->TBS = TBStable[get_I_TBS(mcs1)][NPRB4TBS-1]; + pdlsch0_harq->Qm = get_Qm(mcs1); + } + } + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + pdlsch0_harq, + NPRB, + subframe); +} + +void prepare_dl_decoding_format1C(uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + uint32_t rnti, + uint32_t si_rnti, + uint32_t ra_rnti, + uint32_t p_rnti, + uint32_t frame, + uint8_t subframe, + LTE_DL_UE_HARQ_t *pdlsch0_harq, + LTE_UE_DLSCH_t *pdlsch0) +{ + + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t Ngap = pdci_info_extarcted->Ngap; + + pdlsch0_harq->round = 0; + pdlsch0_harq->first_tx = 1; + pdlsch0_harq->vrb_type = DISTRIBUTED; + + if (rnti==si_rnti) { // rule from Section 5.3.1 of 36.321 + if (((frame&1) == 0) && (subframe == 5)) + pdlsch0_harq->rvidx = (((3*((frame>>1)&3))+1)>>1)&3; // SIB1 + else + pdlsch0_harq->rvidx = (((3*(subframe&3))+1)>>1)&3; // other SIBs + } + else if ((rnti==p_rnti) || (rnti==ra_rnti)) { // Section 7.1.7.3 + pdlsch0_harq->rvidx = 0; + } + + + pdlsch0_harq->Nl = 1; + pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; + pdlsch0_harq->dl_power_off = 1; //no power offset + + pdlsch0_harq->codeword = 0; + pdlsch0_harq->mcs = mcs1; + pdlsch0_harq->TBS = TBStable1C[mcs1]; + pdlsch0_harq->Qm = 2; + + + pdlsch0->current_harq_pid = harq_pid; + pdlsch0->active = 1; + pdlsch0->rnti = rnti; + + switch (N_RB_DL) { + case 6: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; + + break; + + case 25: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; + break; + + case 50: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT50[rballoc]; + if (Ngap == 0) { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT50_1[rballoc]; + } + break; + + case 100: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT100[rballoc]; + if (Ngap==0) { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; + } + break; + + default: + AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",frame_parms->N_RB_DL); + break; + } + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + pdlsch0_harq, + pdlsch0_harq->nb_rb, + subframe); + +} + +void compute_precoding_info_2cw(uint8_t tpmi, uint8_t tbswap, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch0_harq, LTE_DL_UE_HARQ_t *dlsch1_harq) +{ + +switch (tpmi) { + case 0: + dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; + dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); + dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); + break; + case 1: + dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; + dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); + dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); + break; + case 2: // PUSCH precoding + dlsch0_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; + dlsch1_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; + if (tbswap==0){ + dlsch0_harq->pmi_alloc = pmi_alloc; + dlsch1_harq->pmi_alloc = pmi_alloc^0x1555; + } else { + dlsch1_harq->pmi_alloc = pmi_alloc; + dlsch0_harq->pmi_alloc = pmi_alloc^0x1555; + } +#ifdef DEBUG_HARQ + printf ("\n \n compute_precoding_info_2cw pmi_alloc_new = %d\n", dlsch0_harq->pmi_alloc); + #endif + break; + default: + break; + } +} + +void compute_precoding_info_1cw(uint8_t tpmi, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch_harq) +{ + +switch (tpmi) { + case 0 : + dlsch_harq->mimo_mode = ALAMOUTI; + break; + case 1: + dlsch_harq->mimo_mode = UNIFORM_PRECODING11; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,0, 0); + break; + case 2: + dlsch_harq->mimo_mode = UNIFORM_PRECODING1m1; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); + break; + case 3: + dlsch_harq->mimo_mode = UNIFORM_PRECODING1j; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); + break; + case 4: + dlsch_harq->mimo_mode = UNIFORM_PRECODING1mj; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); + break; + case 5: + dlsch_harq->mimo_mode = PUSCH_PRECODING0; + dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,0); + break; + case 6: + dlsch_harq->mimo_mode = PUSCH_PRECODING1; + dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,1); + break; + } + #ifdef DEBUG_HARQ + printf ("[DCI UE] I am calling from the UE side pmi_alloc_new = %d with tpmi %d\n", dlsch_harq->pmi_alloc, tpmi); + #endif + } + +void compute_precoding_info_format2A(uint8_t tpmi, + uint8_t nb_antenna_ports_eNB, + uint8_t tb0_active, + uint8_t tb1_active, + LTE_DL_UE_HARQ_t *dlsch0_harq, + LTE_DL_UE_HARQ_t *dlsch1_harq) +{ + + dlsch0_harq->dl_power_off = 0; + dlsch1_harq->dl_power_off = 0; + + if (nb_antenna_ports_eNB == 2) { + if ((tb0_active==1) && (tb1_active==1)) { + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + } else { + dlsch0_harq->mimo_mode = ALAMOUTI; + dlsch1_harq->mimo_mode = ALAMOUTI; + } + } else if (nb_antenna_ports_eNB == 4) { // 4 antenna case + if ((tb0_active==1) && (tb1_active==1)) { + switch (tpmi) { + case 0: // one layer per transport block + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + break; + + case 1: // one-layers on TB 0, two on TB 1 + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + break; + + case 2: // two-layers on TB 0, two on TB 1 + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + break; + + case 3: // + LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n"); + break; + } + } else if (tb0_active == 1) { + switch (tpmi) { + case 0: // one layer per transport block + dlsch0_harq->mimo_mode = ALAMOUTI; + dlsch1_harq->mimo_mode = ALAMOUTI; + break; + + case 1: // two-layers on TB 0 + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + break; + + case 2: // two-layers on TB 0, two on TB 1 + case 3: // + LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); + break; + } + } else if (tb1_active == 1) { + switch (tpmi) { + case 0: // one layer per transport block + dlsch0_harq->mimo_mode = ALAMOUTI; + dlsch1_harq->mimo_mode = ALAMOUTI; + break; + + case 1: // two-layers on TB 0 + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + break; + + case 2: // two-layers on TB 0, two on TB 1 + case 3: // + LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); + break; + } + } + } + // printf("Format 2A: NPRB=%d (rballoc %x,mcs1 %d, mcs2 %d, frame_type %d N_RB_DL %d,active %d/%d)\n",NPRB,rballoc,mcs1,mcs2,frame_parms->frame_type,frame_parms->N_RB_DL,dlsch0->active,dlsch1->active); + //printf("UE (%x/%d): Subframe %d Format2A DCI: ndi1 %d, old_ndi1 %d, ndi2 %d, old_ndi2 %d (first tx1 %d, first tx2 %d) harq_status1 %d, harq_status2 %d\n",dlsch0->rnti,harq_pid,subframe,ndi,dlsch0_harq->DCINdi, + // dlsch0_harq->first_tx,dlsch1_harq->first_tx,dlsch0_harq->status,dlsch1_harq->status); + //printf("TBS0 %d, TBS1 %d\n",dlsch0_harq->TBS,dlsch1_harq->TBS); + +} + +void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + uint16_t rnti, + uint8_t subframe, + LTE_DL_UE_HARQ_t *dlsch0_harq, + LTE_DL_UE_HARQ_t *dlsch1_harq, + LTE_UE_DLSCH_t *pdlsch0, + LTE_UE_DLSCH_t *pdlsch1) +{ + + uint8_t rah = pdci_info_extarcted->rah; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t mcs2 = pdci_info_extarcted->mcs2; + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t rv2 = pdci_info_extarcted->rv2; + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t tbswap = pdci_info_extarcted->tb_swap; + uint8_t tpmi = pdci_info_extarcted->tpmi; + uint8_t TPC = pdci_info_extarcted->TPC; + uint8_t ndi1 = pdci_info_extarcted->ndi1; + uint8_t ndi2 = pdci_info_extarcted->ndi2; + + uint8_t TB0_active = 1; + uint8_t TB1_active = 1; + + // printf("inside prepare pdlsch1->pmi_alloc %d \n",pdlsch1->pmi_alloc); + + + if ((rv1 == 1) && (mcs1 == 0)) { + TB0_active=0; + } + if ((rv2 == 1) && (mcs2 == 0)) { + TB1_active=0; + } + +#ifdef DEBUG_HARQ + printf("[DCI UE]: TB0 status %d , TB1 status %d\n", TB0_active, TB1_active); +#endif + + dlsch0_harq->mcs = mcs1; + dlsch1_harq->mcs = mcs2; + dlsch0_harq->rvidx = rv1; + dlsch1_harq->rvidx = rv2; + dlsch0_harq->DCINdi = ndi1; + dlsch1_harq->DCINdi = ndi2; + + dlsch0_harq->codeword = 0; + dlsch1_harq->codeword = 1; + dlsch0_harq->Nl = 1; + dlsch1_harq->Nl = 1; + dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; + dlsch1_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + + pdlsch0->current_harq_pid = harq_pid; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch1->current_harq_pid = harq_pid; + pdlsch1->harq_ack[subframe].harq_id = harq_pid; + + // assume two CW are active + dlsch0_harq->status = ACTIVE; + dlsch1_harq->status = ACTIVE; + pdlsch0->active = 1; + pdlsch1->active = 1; + pdlsch0->rnti = rnti; + pdlsch1->rnti = rnti; + + + if (TB0_active && TB1_active && tbswap==1) { + dlsch0_harq->codeword = 1; + dlsch1_harq->codeword = 0; + } + + + if (!TB0_active && TB1_active){ + dlsch1_harq->codeword = 0; + } + + if (TB0_active && !TB1_active){ + dlsch0_harq->codeword = 0; + } + + + if (TB0_active==0) { + dlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + #ifdef DEBUG_HARQ + printf("[DCI UE]: TB0 is deactivated, retransmit TB1 transmit in TM6\n"); + #endif + } + + if (TB1_active==0) { + dlsch1_harq->status = SCH_IDLE; + pdlsch1->active = 0; + } + +#ifdef DEBUG_HARQ + printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); +#endif + + // compute resource allocation + if (TB0_active == 1){ + + dlsch0_harq->nb_rb = conv_nprb(rah, + rballoc, + frame_parms->N_RB_DL); + conv_rballoc(rah, + rballoc, + frame_parms->N_RB_DL, + dlsch0_harq->rb_alloc_even); + + dlsch0_harq->rb_alloc_odd[0]= dlsch0_harq->rb_alloc_even[0]; + dlsch0_harq->rb_alloc_odd[1]= dlsch0_harq->rb_alloc_even[1]; + dlsch0_harq->rb_alloc_odd[2]= dlsch0_harq->rb_alloc_even[2]; + dlsch0_harq->rb_alloc_odd[3]= dlsch0_harq->rb_alloc_even[3]; + + if (TB1_active == 1){ + dlsch1_harq->rb_alloc_even[0]= dlsch0_harq->rb_alloc_even[0]; + dlsch1_harq->rb_alloc_even[1]= dlsch0_harq->rb_alloc_even[1]; + dlsch1_harq->rb_alloc_even[2]= dlsch0_harq->rb_alloc_even[2]; + dlsch1_harq->rb_alloc_even[3]= dlsch0_harq->rb_alloc_even[3]; + dlsch1_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_odd[0]; + dlsch1_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_odd[1]; + dlsch1_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_odd[2]; + dlsch1_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_odd[3]; + + dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; + + //dlsch0_harq->Nl = 1; + //dlsch1_harq->Nl = 1; + } + } else if ((TB0_active == 0) && (TB1_active == 1)){ + + conv_rballoc(rah, + rballoc, + frame_parms->N_RB_DL, + dlsch1_harq->rb_alloc_even); + + dlsch1_harq->rb_alloc_odd[0]= dlsch1_harq->rb_alloc_even[0]; + dlsch1_harq->rb_alloc_odd[1]= dlsch1_harq->rb_alloc_even[1]; + dlsch1_harq->rb_alloc_odd[2]= dlsch1_harq->rb_alloc_even[2]; + dlsch1_harq->rb_alloc_odd[3]= dlsch1_harq->rb_alloc_even[3]; + dlsch1_harq->nb_rb = conv_nprb(rah, + rballoc, + frame_parms->N_RB_DL); + } + + + // compute precoding matrix + mimo mode + if(dci_format == format2) + { + if ((TB0_active) && (TB1_active)){ //two CW active + compute_precoding_info_2cw(tpmi, tbswap, pdlsch0->pmi_alloc,frame_parms, dlsch0_harq, dlsch1_harq); + + // printf("[DCI UE 1]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + } else if ((TB0_active) && (!TB1_active)) { // only CW 0 active + compute_precoding_info_1cw(tpmi, pdlsch0->pmi_alloc, frame_parms, dlsch0_harq); + } else { + compute_precoding_info_1cw(tpmi, pdlsch1->pmi_alloc, frame_parms, dlsch1_harq); + // printf("I am doing compute_precoding_info_1cw with tpmi %d \n", tpmi); + } + //printf(" UE DCI harq0 MIMO mode = %d\n", dlsch0_harq->mimo_mode); + if ((frame_parms->nb_antenna_ports_eNB == 1) && (TB0_active)) + dlsch0_harq->mimo_mode = SISO; + } + else + { + compute_precoding_info_format2A( tpmi, + frame_parms->nb_antenna_ports_eNB, + TB0_active, + TB1_active, + dlsch0_harq, + dlsch1_harq); + } + // printf("[DCI UE 2]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + // reset round + compute Qm + if (TB0_active) { + // printf("TB0 ndi1 =%d, dlsch0_harq->DCINdi =%d, dlsch0_harq->first_tx = %d\n", ndi1, dlsch0_harq->DCINdi, dlsch0_harq->first_tx); + if ((ndi1!=dlsch0_harq->DCINdi) || (dlsch0_harq->first_tx==1)) { + dlsch0_harq->round = 0; + dlsch0_harq->status = ACTIVE; + dlsch0_harq->DCINdi = ndi1; + + //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW0 subframe %d (pid %d, round %d)\n", + // subframe,harq_pid,dlsch0_harq->round); + if ( dlsch0_harq->first_tx==1) { + // LOG_D(PHY,"Format 2 DCI First TX0: Clearing flag\n"); + dlsch0_harq->first_tx = 0; + } + } + /*else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if(dlsch0_harq->status == SCH_IDLE) { + // skip pdsch decoding and report ack + //dlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + pdlsch0->harq_ack[subframe].ack = 1; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch0->harq_ack[subframe].send_harq_status = 1; + }*/ + + // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest + // PDCCH for the same trasport block using Imcs in [0 .. 28] + if(dlsch0_harq->mcs <= 28) + { + dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; + LOG_D(PHY,"[UE] DLSCH: New TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); + } + else + { + LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); + } + //if(dlsch0_harq->Nl == 2) + //dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1]; + if (mcs1 <= 28) + dlsch0_harq->Qm = get_Qm(mcs1); + else if (mcs1<=31) + dlsch0_harq->Qm = (mcs1-28)<<1; + } + + // printf("[DCI UE 3]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + + if (TB1_active) { + // printf("TB1 ndi2 =%d, dlsch1_harq->DCINdi =%d, dlsch1_harq->first_tx = %d\n", ndi2, dlsch1_harq->DCINdi, dlsch1_harq->first_tx); + if ((ndi2!=dlsch1_harq->DCINdi) || (dlsch1_harq->first_tx==1)) { + dlsch1_harq->round = 0; + dlsch1_harq->status = ACTIVE; + dlsch1_harq->DCINdi = ndi2; + //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW1 subframe %d (pid %d, round %d)\n", + // subframe,harq_pid,dlsch0_harq->round); + if (dlsch1_harq->first_tx==1) { + // LOG_D(PHY,"Format 2 DCI First TX1: Clearing flag\n"); + dlsch1_harq->first_tx = 0; + } + } + /*else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if(dlsch1_harq->status == SCH_IDLE) { + // skip pdsch decoding and report ack + //dlsch1_harq->status = SCH_IDLE; + pdlsch1->active = 0; + pdlsch1->harq_ack[subframe].ack = 1; + pdlsch1->harq_ack[subframe].harq_id = harq_pid; + pdlsch1->harq_ack[subframe].send_harq_status = 1; + } + }*/ + + // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest + // PDCCH for the same trasport block using Imcs in [0 .. 28] + if(dlsch1_harq->mcs <= 28) + { + dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; + LOG_D(PHY,"[UE] DLSCH: New TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); + } + else + { + LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); + } + if (mcs2 <= 28) + dlsch1_harq->Qm = get_Qm(mcs2); + else if (mcs1<=31) + dlsch1_harq->Qm = (mcs2-28)<<1; + } + + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + dlsch0_harq, + dlsch0_harq->nb_rb, + subframe); + + + /* #ifdef DEBUG_HARQ + printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + printf("[DCI UE]: TB0_active %d , TB1_active %d\n", TB0_active, TB1_active); + if (dlsch0 != NULL && dlsch1 != NULL) + printf("[DCI UE] dlsch0_harq status = %d, dlsch1_harq status = %d\n", dlsch0_harq->status, dlsch1_harq->status); + else if (dlsch0 == NULL && dlsch1 != NULL) + printf("[DCI UE] dlsch0_harq NULL dlsch1_harq status = %d\n", dlsch1_harq->status); + else if (dlsch0 != NULL && dlsch1 == NULL) + printf("[DCI UE] dlsch1_harq NULL dlsch0_harq status = %d\n", dlsch0_harq->status); + #endif*/ +} + +int generate_ue_dlsch_params_from_dci(int frame, + uint8_t subframe, + void *dci_pdu, + uint16_t rnti, + DCI_format_t dci_format, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + LTE_UE_DLSCH_t **dlsch, + LTE_DL_FRAME_PARMS *frame_parms, + PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint8_t beamforming_mode, + uint16_t tc_rnti) +{ + + uint8_t harq_pid=0; + uint8_t frame_type=frame_parms->frame_type; + uint8_t tpmi=0; + LTE_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; + LTE_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; + + DCI_INFO_EXTRACTED_t dci_info_extarcted; + uint8_t status=0; + + if (!dlsch[0]) return -1; + + #ifdef DEBUG_DCI + LOG_D(PHY,"dci_tools.c: Filling ue dlsch params -> rnti %x, SFN/SF %d/%d, dci_format %s\n", + rnti, + frame%1024, + subframe, + (dci_format==format0? "Format 0":( + dci_format==format1? "format 1":( + dci_format==format1A? "format 1A":( + dci_format==format1B? "format 1B":( + dci_format==format1C? "format 1C":( + dci_format==format1D? "format 1D":( + dci_format==format1E_2A_M10PRB? "format 1E_2A_M10PRB":( + dci_format==format2? "format 2":( + dci_format==format2A? "format 2A":( + dci_format==format2B? "format 2B":( + dci_format==format2C? "format 2C":( + dci_format==format2D? "format 2D":( + dci_format==format3? "format 3": "UNKNOWN" + )))))))))))))); + #endif + + memset(&dci_info_extarcted,0,sizeof(dci_info_extarcted)); + switch (dci_format) { + + case format0: // This is an ULSCH allocation so nothing here, inform MAC + LOG_E(PHY,"format0 not possible\n"); + return(-1); + break; + + case format1A: + { + // extract dci infomation +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d extarct dci info \n", frame, subframe); +#endif + extract_dci1A_info(frame_parms->N_RB_DL, + frame_type, + dci_pdu, + &dci_info_extarcted); + + + // check dci content + dlsch0 = dlsch[0]; + dlsch0->active = 0; + dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d check dci coherency \n", frame, subframe); +#endif + status = check_dci_format1_1a_coherency(format1A, + frame_parms->N_RB_DL, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti,frame,subframe, + &dci_info_extarcted, + dlsch0_harq); + if(status == 0) + { + printf("bad DCI 1A !!! \n"); + return(-1); + } + + // dci is correct ==> update internal structure and prepare dl decoding +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); +#endif + prepare_dl_decoding_format1_1A(format1A, + frame_parms->N_RB_DL, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + subframe, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch0); + + + + break; + } + case format1C: + { + // extract dci infomation +#ifdef DEBUG_DL_DECODING + LOG_I(PHY,"[DCI Format-1C] extact dci information \n"); +#endif + extract_dci1C_info(frame_parms->N_RB_DL, + frame_type, + dci_pdu, + &dci_info_extarcted); + + + // check dci content +#ifdef DEBUG_DL_DECODING + LOG_I(PHY,"[DCI Format-1C] check dci content \n"); +#endif + dlsch0 = dlsch[0]; + dlsch0->active = 0; + dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; + + status = check_dci_format1c_coherency(frame_parms->N_RB_DL, + &dci_info_extarcted, + rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq); + if(status == 0) + return(-1); + + // dci is correct ==> update internal structure and prepare dl decoding +#ifdef DEBUG_DL_DECODING + LOG_I(PHY,"[DCI Format-1C] prepare downlink decoding \n"); +#endif + prepare_dl_decoding_format1C(frame_parms->N_RB_DL, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + rnti, + si_rnti, + ra_rnti, + p_rnti, + frame, + subframe, + dlsch0_harq, + dlsch0); + + break; + } + + case format1: + { + // extract dci infomation +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d extarct dci info \n", frame, subframe); +#endif + extract_dci1_info(frame_parms->N_RB_DL, + frame_type, + dci_pdu, + &dci_info_extarcted); + + // check dci content + dlsch0 = dlsch[0]; + dlsch0->active = 0; + dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; + +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d check dci coherency \n", frame, subframe); +#endif + status = check_dci_format1_1a_coherency(format1, + frame_parms->N_RB_DL, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti,frame,subframe, + &dci_info_extarcted, + dlsch0_harq); + if(status == 0) + { + printf("bad DCI 1 !!! \n"); + return(-1); + } + + + // dci is correct ==> update internal structure and prepare dl decoding +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); +#endif + prepare_dl_decoding_format1_1A(format1, + frame_parms->N_RB_DL, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + subframe, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch0); + break; + } + + case format2: + { + // extract dci infomation + //LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame, subframe); + extract_dci2_info(frame_parms->N_RB_DL, + frame_type, + frame_parms->nb_antenna_ports_eNB, + dci_pdu, + &dci_info_extarcted); + + + // check dci content + dlsch[0]->active = 1; + dlsch[1]->active = 1; + + dlsch0 = dlsch[0]; + dlsch1 = dlsch[1]; + + dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; + dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; + // printf("before coherency dlsch[1]->pmi_alloc %d\n",dlsch[1]->pmi_alloc); + // printf("before coherency dlsch1->pmi_alloc %d\n",dlsch1->pmi_alloc); + // printf("before coherency dlsch1_harq->pmi_alloc %d\n",dlsch1_harq->pmi_alloc); + + //LOG_I(PHY,"[DCI-format2] check dci content \n"); + status = check_dci_format2_2a_coherency(format2, + frame_parms->N_RB_DL, + &dci_info_extarcted, + rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch1_harq); + if(status == 0) + return(-1); + + + // dci is correct ==> update internal structure and prepare dl decoding + //LOG_I(PHY,"[DCI-format2] update internal structure and prepare dl decoding \n"); + prepare_dl_decoding_format2_2A(format2, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + rnti, + subframe, + dlsch0_harq, + dlsch1_harq, + dlsch0, + dlsch1); + } + break; + + case format2A: + { + // extract dci infomation + LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame%1024, subframe); + extract_dci2A_info(frame_parms->N_RB_DL, + frame_type, + frame_parms->nb_antenna_ports_eNB, + dci_pdu, + &dci_info_extarcted); + + // check dci content + //LOG_I(PHY,"[DCI-format2A] check dci content \n"); + //LOG_I(PHY,"[DCI-format2A] tb_swap %d harq_pid %d\n", dci_info_extarcted.tb_swap, dci_info_extarcted.harq_pid); + //dlsch[0]->active = 0; + //dlsch[1]->active = 0; + + if (dci_info_extarcted.tb_swap == 0) { + dlsch0 = dlsch[0]; + dlsch1 = dlsch[1]; + } else { + dlsch0 = dlsch[1]; + dlsch1 = dlsch[0]; + } + dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; + dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; + + //LOG_I(PHY,"[DCI-format2A] check dci content \n"); + status = check_dci_format2_2a_coherency(format2A, + frame_parms->N_RB_DL, + &dci_info_extarcted, + rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch1_harq); + if(status == 0) + return(-1); + + // dci is correct ==> update internal structure and prepare dl decoding + //LOG_I(PHY,"[DCI-format2A] update internal structure and prepare dl decoding \n"); + prepare_dl_decoding_format2_2A(format2A, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + rnti, + subframe, + dlsch0_harq, + dlsch1_harq, + dlsch0, + dlsch1); + } + break; + + case format1E_2A_M10PRB: + if (!dlsch[0]) return -1; + + harq_pid = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->harq_pid; + + if (harq_pid>=8) { + LOG_E(PHY,"Format 1E_2A_M10PRB: harq_pid=%d >= 8\n", harq_pid); + return(-1); + } + + dlsch[0]->current_harq_pid = harq_pid; + dlsch[0]->harq_ack[subframe].harq_id = harq_pid; + + /* + tbswap = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tb_swap; + if (tbswap == 0) { + dlsch0 = dlsch[0]; + dlsch1 = dlsch[1]; + } + else{ + dlsch0 = dlsch[1]; + dlsch1 = dlsch[0]; + } + */ + dlsch0 = dlsch[0]; + + dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; + // Needs to be checked + dlsch0_harq->codeword=0; + conv_rballoc(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc,frame_parms->N_RB_DL, + dlsch0_harq->rb_alloc_even); + + dlsch0_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_even[0]; + dlsch0_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_even[1]; + dlsch0_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_even[2]; + dlsch0_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_even[3]; + /* + dlsch1_harq->rb_alloc_even[0] = dlsch0_harq->rb_alloc_even[0]; + dlsch1_harq->rb_alloc_even[1] = dlsch0_harq->rb_alloc_even[1]; + dlsch1_harq->rb_alloc_even[2] = dlsch0_harq->rb_alloc_even[2]; + dlsch1_harq->rb_alloc_even[3] = dlsch0_harq->rb_alloc_even[3]; + */ + dlsch0_harq->nb_rb = conv_nprb(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc, + frame_parms->N_RB_DL); + //dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; + + dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; + dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->TPC&3]; + + + + /* + if (dlsch0_harq->mcs>20) { + printf("dci_tools.c: mcs > 20 disabled for now (asked %d)\n",dlsch0_harq->mcs); + return(-1); + } + */ + + //dlsch1_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs2; + dlsch0_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv; + //dlsch1_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv2; + + // check if either TB is disabled (see 36-213 V8.6 p. 26) + + if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { + dlsch0_harq->status = DISABLED; + } + + //if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { + //dlsch1_harq->status = DISABLED; + //} + dlsch0_harq->Nl = 1; + + //dlsch0->layer_index = tbswap; + //dlsch1->layer_index = 1-tbswap; + + + // Fix this + tpmi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tpmi; + // printf("ue: tpmi %d\n",tpmi); + + switch (tpmi) { + case 0 : + dlsch0_harq->mimo_mode = ALAMOUTI; + break; + + case 1: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING11; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0,0); + break; + + case 2: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); + break; + + case 3: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); + + break; + + case 4: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); + break; + + case 5: + dlsch0_harq->mimo_mode = PUSCH_PRECODING0; + // pmi stored from ulsch allocation routine + dlsch0_harq->pmi_alloc = dlsch0->pmi_alloc; + //LOG_I(PHY,"XXX using PMI %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc)); + break; + + + case 6: + dlsch0_harq->mimo_mode = PUSCH_PRECODING1; + LOG_E(PHY,"Unsupported TPMI\n"); + return(-1); + break; + } + + + if (frame_parms->nb_antenna_ports_eNB == 1) + dlsch0_harq->mimo_mode = SISO; + + + if ((dlsch0_harq->DCINdi != ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi) || + (dlsch0_harq->first_tx==1)) { + + dlsch0_harq->round = 0; + dlsch0_harq->first_tx = 0; + dlsch0_harq->status = ACTIVE; + } + /* + else if (dlsch0_harq->status == SCH_IDLE) { // we got same ndi for a previously decoded process, + // this happens if either another harq process in the same + // is NAK or an ACK was not received + + dlsch0->harq_ack[subframe].ack = 1; + dlsch0->harq_ack[subframe].harq_id = harq_pid; + dlsch0->harq_ack[subframe].send_harq_status = 1; + dlsch0->active = 0; + return(0); + } + */ + + dlsch0_harq->DCINdi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi; + dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; + + if (dlsch0_harq->nb_rb>1) { + dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; + } else + dlsch0_harq->TBS =0; + + dlsch0->rnti = rnti; + //dlsch1->rnti = rnti; + + dlsch0->active = 1; + //dlsch1->active = 1; + + dlsch0_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; + //dlsch1_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; + + + break; + + default: + LOG_E(PHY,"format %d not yet implemented\n",dci_format); + return(-1); + break; + } + +#ifdef UE_DEBUG_TRACE + + if (dlsch[0] && (dlsch[0]->rnti != 0xffff)) { + LOG_I(PHY,"dci_format:%d Abssubframe: %d.%d \n",dci_format,frame%1024,subframe); + LOG_I(PHY,"PDSCH dlsch0 UE: rnti %x\n",dlsch[0]->rnti); + LOG_D(PHY,"PDSCH dlsch0 UE: NBRB %d\n",dlsch0_harq->nb_rb); + LOG_D(PHY,"PDSCH dlsch0 UE: rballoc %x\n",dlsch0_harq->rb_alloc_even[0]); + LOG_I(PHY,"PDSCH dlsch0 UE: harq_pid %d\n",dci_info_extarcted.harq_pid); + LOG_I(PHY,"PDSCH dlsch0 UE: g %d\n",dlsch[0]->g_pucch); + LOG_D(PHY,"PDSCH dlsch0 UE: round %d\n",dlsch0_harq->round); + LOG_D(PHY,"PDSCH dlsch0 UE: DCINdi %d\n",dlsch0_harq->DCINdi); + LOG_D(PHY,"PDSCH dlsch0 UE: rvidx %d\n",dlsch0_harq->rvidx); + LOG_D(PHY,"PDSCH dlsch0 UE: TBS %d\n",dlsch0_harq->TBS); + LOG_D(PHY,"PDSCH dlsch0 UE: mcs %d\n",dlsch0_harq->mcs); + LOG_D(PHY,"PDSCH dlsch0 UE: pwr_off %d\n",dlsch0_harq->dl_power_off); + } +#endif + +#if T_TRACER + if( (dlsch[0]->rnti != si_rnti) && (dlsch[0]->rnti != ra_rnti) && (dlsch[0]->rnti != p_rnti)) + { + T(T_UE_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame%1024), T_INT(subframe), + T_INT(dlsch[0]->rnti), T_INT(dci_format), + T_INT(harq_pid), + T_INT(dlsch0_harq->mcs), + T_INT(dlsch0_harq->TBS)); + } +#endif + + + // compute DL power control parameters + if (dlsch0_harq != NULL){ + computeRhoA_UE(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); + computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[0],dlsch0_harq->dl_power_off); + } + + if (dlsch1_harq != NULL) { + computeRhoA_UE(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); + computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[1],dlsch1_harq->dl_power_off); + } + + + return(0); +} + + + +int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb) +{ + int nb_subbands = 0; + int32_t pmi_alloc_new = 0, pmi_new = 0, pmi_old = 0; + int i; + + switch (nb_rb) { + case 6: + nb_subbands = 6; + break; + default: + case 25: + nb_subbands = 7; + break; + case 50: + nb_subbands = 9; + break; + case 100: + nb_subbands = 13; + break; + } + + for (i = 0; i < nb_subbands; i++) { + pmi_old = (pmi_alloc >> i)&1; + + if (pmi_old == 0) + if (tpmi == 5) + pmi_new = 0; + else + pmi_new = 1; + else + if (tpmi == 5) + pmi_new = 2; + else + pmi_new = 3; + + pmi_alloc_new|=pmi_new<<(2*i); + + } +#ifdef DEBUG_HARQ +printf(" [DCI UE] pmi_alloc_old %d, pmi_alloc_new %d pmi_old %d , pmi_new %d\n", pmi_alloc, pmi_alloc_new,pmi_old, pmi_new ); +#endif +return(pmi_alloc_new); + +} + +uint16_t quantize_subband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,int nb_rb) +{ + + int i, aarx; + uint16_t pmiq=0; + uint32_t pmivect = 0; + uint8_t rank = meas->rank[eNB_id]; + int pmi_re,pmi_im; + int nb_subbands=0; + + + switch (nb_rb) { + case 6: + nb_subbands = 6; + break; + default: + case 25: + nb_subbands = 7; + break; + case 50: + nb_subbands = 9; + break; + case 100: + nb_subbands = 13; + break; + } + + + for (i=0; i<nb_subbands; i++) { + pmi_re = 0; + pmi_im = 0; + + if (rank == 0) { + for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { + pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; + pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; + } + + // pmi_re = meas->subband_pmi_re[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; + // pmi_im = meas->subband_pmi_im[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; + + // printf("pmi => (%d,%d)\n",pmi_re,pmi_im); + if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_11; + else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_1j; + else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1m1; + else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1mj; + + // printf("subband %d, pmi%d \n",i,pmiq); + pmivect |= (pmiq<<(2*i)); + } + + else if (rank==1) { + for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { + pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; + //printf("meas->subband_pmi_re[eNB_id][i][%d]=%d\n", aarx, meas->subband_pmi_re[eNB_id][i][aarx]); + pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; + //printf("meas->subband_pmi_im[eNB_id][i][%d]=%d\n",aarx, meas->subband_pmi_im[eNB_id][i][aarx]); + } + if (pmi_re >= pmi_im) // this is not orthogonal + // this is orthogonal + //if (((pmi_re >= pmi_im) && (pmi_re >= -pmi_im)) || ((pmi_re <= pmi_im) && (pmi_re >= -pmi_im))) + pmiq = PMI_2A_R1_11; + else + pmiq = PMI_2A_R1_1j; + + // printf("subband %d, pmi_re %d, pmi_im %d, pmiq %d \n",i,pmi_re,pmi_im,pmiq); + // printf("subband %d, pmi%d \n",i,pmiq); + //According to Section 7.2.4 of 36.213 + + pmivect |= ((pmiq-1)<<(i)); //shift 1 since only one bit + } + else { + LOG_E(PHY,"PMI feedback for rank>1 not supported!\n"); + pmivect = 0; + } + + } +#ifdef DEBUG_HARQ + printf( "quantize_subband_pmi pmivect %d \n", pmivect); +#endif + return(pmivect); +} + +uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands) +{ + + uint8_t i; + uint16_t pmiq=0; + uint16_t pmivect = 0; + uint8_t rank = meas->rank[eNB_id]; + int pmi_re,pmi_im; + + for (i=0; i<nb_subbands; i++) { + + if (rank == 0) { + pmi_re = meas->subband_pmi_re[eNB_id][i][a_id]; + pmi_im = meas->subband_pmi_im[eNB_id][i][a_id]; + + if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_11; + else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_1j; + else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1m1; + else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1mj; + + pmivect |= (pmiq<<(2*i)); + } else { + // This needs to be done properly!!! + pmivect = 0; + } + } + + return(pmivect); +} + +uint16_t quantize_wideband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) +{ + + uint16_t pmiq=0; + uint8_t rank = meas->rank[eNB_id]; + //int pmi; + int pmi_re,pmi_im; + + if (rank == 1) { + //pmi = + pmi_re = meas->wideband_pmi_re[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; + pmi_im = meas->wideband_pmi_im[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; + + if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_11; + else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_1j; + else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1m1; + else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1mj; + + } else { + // This needs to be done properly! + pmiq = PMI_2A_11; + } + + + return(pmiq); +} +/* + uint8_t sinr2cqi(int sinr) { + if (sinr<-3) + return(0); + if (sinr>14) + return(10); + else + return(3+(sinr>>1)); + } +*/ + +uint8_t sinr2cqi(double sinr,uint8_t trans_mode) +{ + // int flag_LA=0; + + uint8_t retValue = 0; + + if(flag_LA==0) { + // Ideal Channel Estimation + if (sinr<=-4.89) + retValue = (0); + else if (sinr < -3.53) + retValue = (3); + else if (sinr <= -1.93) + retValue = (4); + else if (sinr <= -0.43) + retValue = (5); + else if (sinr <= 1.11) + retValue = (6); + else if (sinr <= 3.26) + retValue = (7); + else if (sinr <= 5.0) + retValue = (8); + else if (sinr <= 7.0) + retValue = (9); + else if (sinr <= 9.0) + retValue = (10); + else if (sinr <= 11.0) + retValue = (11); + else if (sinr <= 13.0) + retValue = (12); + else if (sinr <= 15.5) + retValue = (13); + else if (sinr <= 17.5) + retValue = (14); + else + retValue = (15); + } else { + int h=0; + int trans_mode_tmp; + + if (trans_mode ==5) + trans_mode_tmp=2; + else if(trans_mode ==6) + trans_mode_tmp=3; + else + trans_mode_tmp = trans_mode-1; + + for(h=0; h<16; h++) { + if(sinr<=sinr_to_cqi[trans_mode_tmp][h]) + retValue = (h); + } + } + + LOG_D(PHY, "sinr=%f trans_mode=%d cqi=%d\n", sinr, trans_mode, retValue); + return retValue; +} +//uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) { +// +// uint8_t i; +//// uint16_t cqivect = 0; +// uint32_t cqivect = 0; +// +//// char diff_cqi; +// int diff_cqi=0; +// +// for (i=0;i<NUMBER_OF_SUBBANDS;i++) { +// +// diff_cqi = -sinr2cqi(meas->wideband_cqi_dB[eNB_id][0]) + sinr2cqi(meas->subband_cqi_dB[eNB_id][0][i]); +// +// // Note, this is Table 7.2.1-2 from 36.213 +// if (diff_cqi<=-1) +// diff_cqi = 3; +// else if (diff_cqi>2) +// diff_cqi = 2; +// cqivect |= (diff_cqi<<(2*i)); +// +// } +// +// return(cqivect); +//} + + +uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t trans_mode,int nb_subbands) +{ + + uint8_t i; + + uint32_t cqivect = 0,offset=0; + + + int diff_cqi=0; + + for (i=0; i<nb_subbands; i++) { + + diff_cqi = -sinr2cqi(meas->wideband_cqi_avg[eNB_id],trans_mode) + sinr2cqi(meas->subband_cqi_tot_dB[eNB_id][i],trans_mode); + + // Note, this is Table 7.2.1-2 from 36.213 + if (diff_cqi<=-1) + offset = 3; + else if (diff_cqi>=2) + offset = 2; + else + offset=(uint32_t)diff_cqi; + + cqivect |= (offset<<(2*i)); + + } + + return(cqivect); +} + +void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t harq_pid,int N_RB_DL,uint16_t rnti, uint8_t trans_mode, double sinr_eff) +{ + + // printf("[PHY][UE] Filling CQI for eNB %d, meas->wideband_cqi_tot[%d] %d\n", + // eNB_id,eNB_id,meas->wideband_cqi_tot[eNB_id]); + double sinr_tmp; + uint8_t *o = ulsch->o; + UCI_format_t uci_format = ulsch->uci_format; + + if(flag_LA==1) + sinr_tmp = sinr_eff; + else + sinr_tmp = (double) meas->wideband_cqi_avg[eNB_id]; + + + + //LOG_I(PHY,"[UE][UCI] Filling CQI format %d for eNB %d N_RB_DL %d\n",uci_format,eNB_id,N_RB_DL); + + switch (N_RB_DL) { + + case 6: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti = rnti; + LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + case 25: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = rnti; + LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + case 50: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti = rnti; + LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + case 100: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti = rnti; + LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + } + + +} + +void reset_cba_uci(void *o) +{ + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = 0; //fixme + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = 0x0; +} + + + + + +int generate_ue_ulsch_params_from_dci(void *dci_pdu, + uint16_t rnti, + uint8_t subframe, + DCI_format_t dci_format, + PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint16_t cba_rnti, + uint8_t eNB_id, + uint8_t use_srs) +{ + + uint8_t harq_pid; + uint8_t transmission_mode = ue->transmission_mode[eNB_id]; + ANFBmode_t AckNackFBMode; + LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + LTE_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[subframe]][0]; + PHY_MEASUREMENTS *meas = &ue->measurements; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + // uint32_t current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; + + if(frame_parms->frame_type == TDD) + { + AckNackFBMode = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; + } + else + { + AckNackFBMode = 1; // 1: multiplexing for FDD + } + + uint32_t cqi_req; + uint32_t dai=3; + uint32_t cshift; + uint32_t TPC; + uint32_t ndi; + uint32_t mcs; + uint32_t rballoc,RIV_max; + uint16_t* RIV2first_rb_LUT; + uint16_t* RIV2nb_rb_LUT; + + // uint32_t hopping; + // uint32_t type; + + if (dci_format == format0) { + + if (!ulsch) + return -1; + + if (rnti == ra_rnti) + harq_pid = 0; + else + 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", + proc->frame_rx, subframe, rnti, dci_format); + return(-1); + } + + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max6; + RIV2first_rb_LUT = RIV2first_rb_LUT6; + RIV2nb_rb_LUT = RIV2nb_rb_LUT6; + + break; + + case 25: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_5MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max25; + RIV2first_rb_LUT = RIV2first_rb_LUT25; + RIV2nb_rb_LUT = RIV2nb_rb_LUT25; + // printf("***********rballoc %d, first_rb %d, nb_rb %d (dci %p)\n",rballoc,ulsch->harq_processes[harq_pid]->first_rb,ulsch->harq_processes[harq_pid]->nb_rb,dci_pdu); + break; + + case 50: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_10MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max50; + RIV2first_rb_LUT = RIV2first_rb_LUT50; + RIV2nb_rb_LUT = RIV2nb_rb_LUT50; + + break; + + case 100: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_20MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max100; + RIV2first_rb_LUT = RIV2first_rb_LUT100; + RIV2nb_rb_LUT = RIV2nb_rb_LUT100; + + // printf("rb_alloc (20 MHz dci) %d\n",rballoc); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + + if (rballoc > RIV_max) { + LOG_E(PHY,"frame %d, subframe %d, rnti %x, format %d: FATAL ERROR: generate_ue_ulsch_params_from_dci, rb_alloc[%d] > RIV_max[%d]\n", + proc->frame_rx, subframe, rnti, dci_format,rballoc,RIV_max); + LOG_E(PHY,"Wrong DCI0 detection, do not transmit PUSCH for HARQID: %d\n",harq_pid); + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + return(-1); + } + + + // indicate that this process is to be serviced in subframe n+4 + if ((rnti >= cba_rnti) && (rnti < p_rnti)) + ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1; //+=1 this indicates the number of dci / cba group: not supported in the data struct + else + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + //LOG_I(PHY,"[HARQ-UL harqId: %d] DCI0 ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + + } + + ulsch->harq_processes[harq_pid]->TPC = TPC; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; + + if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", + ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, + delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], + ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); + ulsch->f_pusch += delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; + } else { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ABS) %d, adjusting to %d (TPC %d)\n", + ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, + delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], + ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); + ulsch->f_pusch = delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; + } + + if (ulsch->harq_processes[harq_pid]->first_tx==1) { + // ulsch->harq_processes[harq_pid]->Ndi = 1; + ulsch->harq_processes[harq_pid]->first_tx=0; + ulsch->harq_processes[harq_pid]->DCINdi= ndi; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + if (ulsch->harq_processes[harq_pid]->DCINdi!=ndi) { // new SDU opportunity + // ulsch->harq_processes[harq_pid]->Ndi = 1; + ulsch->harq_processes[harq_pid]->DCINdi= ndi; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + // ulsch->harq_processes[harq_pid]->Ndi = 0; + //ulsch->harq_processes[harq_pid]->round++; // This is done in phich RX + + //#ifdef DEBUG_PHICH + //LOG_I(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d Adaptative Retrans, NDI not toggled => Nack. maxHARQ_Tx %d \n", + // ue->Mod_id,harq_pid, + // proc->frame_rx, + // subframe, + // ulsch->Mlimit); + //#endif +/* + if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich + { + // ulsch->harq_processes[harq_pid]->round++; already done on phich_rx + // ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; + // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); + + if (ulsch->harq_processes[harq_pid]->round >= ulsch->Mlimit) //UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ulsch->harq_processes[harq_pid]->round = 0; + ulsch->harq_processes[harq_pid]->status = IDLE; + //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + } + else + { + // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + uint8_t rv_table[4] = {0, 2, 3, 1}; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + } + } +*/ + } + } + + ulsch->harq_processes[harq_pid]->n_DMRS = cshift; + + //printf("nb_rb %d, first_rb %d (RIV %d)\n",ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb,rballoc); + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + // ulsch->cba_rnti[0]=rnti; + } else { + ulsch->rnti = rnti; + } + + // printf("[PHY][UE] DCI format 0: harq_pid %d nb_rb %d, rballoc %d\n",harq_pid,ulsch->harq_processes[harq_pid]->nb_rb, + // ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc); + //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) + if(cshift == 0) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; + else if(cshift == 1) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; + else if(cshift == 2) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; + else if(cshift == 3) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; + else if(cshift == 4) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; + else if(cshift == 5) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; + else if(cshift == 6) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; + else if(cshift == 7) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; + + + //reserved for cooperative communication + /* + if(ulsch->n_DMRS2 == 6) + ulsch->cooperation_flag = 2; + else + ulsch->cooperation_flag = 0; + */ + + if ((ulsch->harq_processes[harq_pid]->nb_rb>0) && (ulsch->harq_processes[harq_pid]->nb_rb < 25)) + ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb-1]; + + // if (ulsch->harq_processes[harq_pid]->Ndi == 1) + // ulsch->harq_processes[harq_pid]->status = ACTIVE; + + + if (cqi_req == 1) { + + if( (AntennaInfoDedicated__transmissionMode_tm3 == transmission_mode) || (AntennaInfoDedicated__transmissionMode_tm4 == transmission_mode) ) + { + ulsch->O_RI = 1; + } + else + { + ulsch->O_RI = 0; + } + //ulsch->O_RI = 0; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table + + switch(transmission_mode) { + // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling + case 1: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + case 2: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + case 3: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + case 4: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->o_RI[0] = 1; + } + + break; + + case 5: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->o_RI[0] = 1; + } + + break; + + case 6: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->o_RI[0] = 1; + } + + break; + + case 7: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + default: + LOG_E(PHY,"Incorrect Transmission Mode \n"); + break; + } + } else { + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + } + + print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); + + ulsch->bundling = 1-AckNackFBMode; + + if (frame_parms->frame_type == FDD) { + //int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); + int dl_subframe = subframe; + + if (ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_ack[dl_subframe].send_harq_status>0) { // we have downlink transmission + ulsch->harq_processes[harq_pid]->O_ACK = 1; + } else { + ulsch->harq_processes[harq_pid]->O_ACK = 0; + } + /*LOG_I(PHY,"DCI 0 Processing: dl_subframe %d send_harq_status Odd %d send_harq_status Even %d harq_pid %d O_ACK %d\n", dl_subframe, + ue->dlsch[0][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, + ue->dlsch[1][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, + harq_pid, + ulsch->harq_processes[harq_pid]->O_ACK);*/ + + } else { + if (ulsch->bundling) + ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; + else + ulsch->harq_processes[harq_pid]->O_ACK = (dai >= 2)? 2 : (dai+1)&3; //(dai+1)&3; + + // ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; + } + + dlsch[0]->harq_ack[subframe].vDAI_UL = dai+1; + + + 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"), + cqi_req, cshift, TPC, dai, subframe, dlsch[0]->harq_ack[subframe].vDAI_UL, ndi, mcs, rballoc, + 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); + + 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); + + ulsch->beta_offset_cqi_times8 = beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index];//18; + ulsch->beta_offset_ri_times8 = beta_ri[ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index];//10; + ulsch->beta_offset_harqack_times8 = beta_ack[ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index];//16; + + ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); + ulsch->srs_active = use_srs; + + if ((rnti >= cba_rnti) && (rnti < p_rnti)) + ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; + else + ulsch->harq_processes[harq_pid]->status = ACTIVE; + + ulsch->harq_processes[harq_pid]->rvidx = 0; + + // ulsch->harq_processes[harq_pid]->calibration_flag =0; + if (mcs < 29) { + ulsch->harq_processes[harq_pid]->mcs = mcs; + // ulsch->harq_processes[harq_pid]->round = 0; + } else { + ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; + if (ulsch->harq_processes[harq_pid]->round == 0) { + LOG_W(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); + } else { + LOG_D(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); + } + //LOG_E(PHY,"Fatal: mcs(%d) > 28!!! and round == 0\n", mcs); + } + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + + /* + else if (ulsch->harq_processes[harq_pid]->mcs == 29) { + ulsch->harq_processes[harq_pid]->mcs = 4; + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + // ulsch->harq_processes[harq_pid]->calibration_flag =1; + // printf("Auto-Calibration (UE): mcs %d, TBS %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->TBS,ulsch->harq_processes[harq_pid]->nb_rb); + }*/ + ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; + ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->Nsymb_pusch; + + // a Ndi=1 automatically acknowledges previous PUSCH transmission + if (ue->ulsch_Msg3_active[eNB_id] == 1) + ue->ulsch_Msg3_active[eNB_id] = 0; + + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d), nb_rb %d, first_rb %d, mcs %d, round %d, rv %d, ulsch_ue_Msg3_active %d, cqi_req %d => O %d\n", + ue->Mod_id,harq_pid, + proc->frame_rx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift,ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb, + ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->round,ulsch->harq_processes[harq_pid]->rvidx, ue->ulsch_Msg3_active[eNB_id],cqi_req,ulsch->O); + + // ulsch->n_DMRS2 = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + +#ifdef UE_DEBUG_TRACE + + 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); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): harq_pid %d\n",harq_pid); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_tx %d\n",ulsch->harq_processes[harq_pid]->first_tx); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): DCINdi %d\n",ulsch->harq_processes[harq_pid]->DCINdi); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): round %d\n",ulsch->harq_processes[harq_pid]->round); + //LOG_I(PHY,"Format 0 DCI :ulsch (ue): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); + //LOG_I(PHY,"Format 0 DCI :ulsch (ue): O %d\n",ulsch->O); + //LOG_I(PHY,"Format 0 DCI :ulsch (ue): cqiReq %d\n",cqi_req); + //if (frame_parms->frame_type == TDD) + // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK/DAI %d/%d\n",ulsch->harq_processes[harq_pid]->O_ACK,dai); + //else + // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK %d\n",ulsch->harq_processes[harq_pid]->O_ACK); + + LOG_D(PHY,"Format 0 DCI :ulsch (ue): Nsymb_pusch %d\n",ulsch->Nsymb_pusch); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): phich status %d\n",ulsch->harq_processes[harq_pid]->status); +#else + UNUSED_VARIABLE(dai); +#endif + return(0); + } else { + LOG_E(PHY,"frame %d, subframe %d: FATAL ERROR, generate_ue_ulsch_params_from_dci, Illegal dci_format %d\n", + proc->frame_rx, subframe,dci_format); + return(-1); + } + +} + +/* +int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *eNB, + eNB_rxtx_proc_t *proc, + void *dci_pdu, + uint16_t rnti, + DCI_format_t dci_format, + uint8_t UE_id, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint16_t cba_rnti, + uint8_t use_srs) +{ + + uint8_t harq_pid; + uint32_t rb_alloc; + uint8_t transmission_mode=eNB->transmission_mode[UE_id]; + ANFBmode_t AckNackFBMode = eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode; + LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id]; + LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; + int subframe = proc->subframe_tx; + + uint32_t cqi_req = 0; + uint32_t dai = 0; + uint32_t cshift = 0; + uint32_t TPC = 0; + uint32_t mcs = 0; + uint32_t rballoc = UINT32_MAX; + uint32_t RIV_max = 0; + // uint32_t hopping; + // uint32_t type; + +#ifdef DEBUG_DCI + printf("filling eNB ulsch params for rnti %x, dci format %d, dci %x, subframe %d\n", + rnti,dci_format,*(uint32_t*)dci_pdu,subframe); +#endif + + if (dci_format == format0) { + + harq_pid = subframe2harq_pid(frame_parms, + pdcch_alloc2ul_frame(frame_parms, + proc->frame_tx, + subframe), + pdcch_alloc2ul_subframe(frame_parms,subframe)); + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max6; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT6[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT6[rballoc]; + + break; + + case 25: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping; + // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping; + // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max25; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT25[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT25[rballoc]; + + break; + + case 50: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping; + // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping; + // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max50; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT50[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT50[rballoc]; + + break; + + case 100: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping; + // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping; + // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max100; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT100[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT100[rballoc]; + + //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + + rb_alloc = rballoc; + AssertFatal(rb_alloc>RIV_max, + "Format 0: rb_alloc (%d) > RIV_max (%d)\n",rb_alloc,RIV_max); +#ifdef DEBUG_DCI + printf("generate_eNB_ulsch_params_from_dci: subframe %d, rnti %x,harq_pid %d,cqi_req %d\n",subframe,rnti,harq_pid,cqi_req); +#endif + + ulsch->harq_processes[harq_pid]->dci_alloc = 1; + ulsch->harq_processes[harq_pid]->rar_alloc = 0; + ulsch->harq_processes[harq_pid]->TPC = TPC; + ulsch->harq_processes[harq_pid]->n_DMRS = cshift; + + + if (cqi_req == 1) { + // 36.213 7.2.1 (release 10) says: + // "RI is only reported for transmission modes 3 and 4, + // as well as transmission modes 8 and 9 with PMI/RI reporting" + // This is for aperiodic reporting. + // TODO: deal with TM 8&9 correctly when they are implemented. + // TODO: deal with periodic reporting if we implement it. + // + if (transmission_mode == 3 || transmission_mode == 4) + ulsch->harq_processes[harq_pid]->O_RI = 1; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table + else + ulsch->harq_processes[harq_pid]->O_RI = 0; + + switch(transmission_mode) { + // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling + case 1: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + break; + + case 2: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + break; + + case 3: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + break; + + case 4: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + + } + + ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; + } + + break; + + case 5: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; + } + + break; + + case 6: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; + } + + break; + + case 7: + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + break; + + default: + LOG_E(PHY,"Incorrect Transmission Mode \n"); + break; + } + } else { + ulsch->harq_processes[harq_pid]->O_RI = 0; + ulsch->harq_processes[harq_pid]->Or2 = 0; + ulsch->harq_processes[harq_pid]->Or1 = 0; + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + ulsch->bundling = 1-AckNackFBMode; + + if (frame_parms->frame_type == FDD) { + int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); + + if (eNB->dlsch[UE_id][0]->subframe_tx[dl_subframe]>0) { // we have downlink transmission + ulsch->harq_processes[harq_pid]->O_ACK = 1; + } else { + ulsch->harq_processes[harq_pid]->O_ACK = 0; + } + } else { + if (ulsch->bundling) + ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; + else + ulsch->harq_processes[harq_pid]->O_ACK = (dai+1)&3; + + ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; + } + + ulsch->beta_offset_cqi_times8 = beta_cqi[eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index];//18; + ulsch->beta_offset_ri_times8 = beta_ri[eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index];//10; + ulsch->beta_offset_harqack_times8 = beta_ack[eNB->pusch_config_dedicated[UE_id].betaOffset_ACK_Index];//16; + + ulsch->harq_processes[harq_pid]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); + ulsch->harq_processes[harq_pid]->srs_active = use_srs; + + //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) + if(cshift == 0) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; + else if(cshift == 1) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; + else if(cshift == 2) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; + else if(cshift == 3) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; + else if(cshift == 4) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; + else if(cshift == 5) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; + else if(cshift == 6) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; + else if(cshift == 7) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; + + + LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d)\n", + eNB->Mod_id,harq_pid,proc->frame_tx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift); + + + + if (ulsch->harq_processes[harq_pid]->round == 0) { + if ((rnti >= cba_rnti) && (rnti < p_rnti)) + ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; + else + ulsch->harq_processes[harq_pid]->status = ACTIVE; + + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->mcs = mcs; + // ulsch->harq_processes[harq_pid]->calibration_flag = 0; + //if (ulsch->harq_processes[harq_pid]->mcs) + // + //if (ulsch->harq_processes[harq_pid]->mcs == 29) { + //ulsch->harq_processes[harq_pid]->mcs = 4; + // ulsch->harq_processes[harq_pid]->calibration_flag = 1; + // printf("Auto-Calibration (eNB): mcs %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->nb_rb); + //} + + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + + ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; + ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->harq_processes[harq_pid]->Nsymb_pusch; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + if (mcs>28) + ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; + else { + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->mcs = mcs; + } + + // ulsch->harq_processes[harq_pid]->round++; + } + + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->cba_rnti[0] = rnti; + } else { + ulsch->rnti = rnti; + } + + //ulsch->n_DMRS2 = cshift; + +#ifdef DEBUG_DCI + printf("ulsch (eNB): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); + printf("ulsch (eNB): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); + printf("ulsch (eNB): harq_pid %d\n",harq_pid); + printf("ulsch (eNB): round %d\n",ulsch->harq_processes[harq_pid]->round); + printf("ulsch (eNB): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); + printf("ulsch (eNB): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); + printf("ulsch (eNB): Or1 %d\n",ulsch->harq_processes[harq_pid]->Or1); + printf("ulsch (eNB): Nsymb_pusch %d\n",ulsch->harq_processes[harq_pid]->Nsymb_pusch); + printf("ulsch (eNB): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); +#else + UNUSED_VARIABLE(dai); +#endif + return(0); + } else { + LOG_E(PHY,"generate_eNB_ulsch_params_from_dci, Illegal dci_format %d\n",dci_format); + return(-1); + } + +} +*/ + +double sinr_eff_cqi_calc(PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe) +{ + uint8_t transmission_mode = ue->transmission_mode[eNB_id]; + PHY_MEASUREMENTS *meas = &ue->measurements; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int32_t **dl_channel_est = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id]; + double *s_dB; + s_dB = ue->sinr_CQI_dB; + // LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + //for the calculation of SINR_eff for CQI calculation + int count,a_rx,a_tx; + double abs_channel=0; + double channelx=0; + double channely=0; + double channelx_i=0; + double channely_i=0; + uint16_t q = quantize_subband_pmi(meas,eNB_id,7); + uint8_t qq; + + switch(transmission_mode) { + case 1: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + s_dB[count] = 10*log10(pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2], + 2)) - meas->n0_power_avg_dB; + } + } + } + + break; + + case 2: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + abs_channel=0; + + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + abs_channel += (pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2],2)); + } + } + + s_dB[count] = 10*log10(abs_channel/2) - meas->n0_power_avg_dB; + } + + break; + + case 5: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + channelx=0; + channely=0; + channelx_i=0; + channely_i=0; + qq = (q>>(((count/12)>>2)<<1))&3; + + //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + switch(qq) { + case 0: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 1: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 2: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 3: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + default: + printf("Problem in SINR Calculation for TM5 \n"); + break; + }//switch(qq) + }//a_rx + }//a_tx + + s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - 10 * log10 ((pow(channelx_i,2) + pow(channely_i,2))/2) - meas->n0_power_avg_dB; + }//count + + break; + + case 6: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + channelx=0; + channely=0; + qq = (q>>(((count/12)>>2)<<1))&3; + + //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + switch(qq) { + case 0: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 1: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 2: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 3: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + default: + printf("Problem in SINR Calculation for TM6 \n"); + break; + }//switch(qq) + }//a_rx + }//a_tx + + s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - meas->n0_power_avg_dB; + }//count + + break; + + default: + printf("Problem in SINR Calculation for CQI \n"); + break; + } + + int ii; + double sinr_eff = 0; + double sinr_eff_qpsk=0; + double sinr_eff_qam16=0; + double sinr_eff_qam64=0; + double x = 0; + double I_qpsk=0; + double I_qam16=0; + double I_qam64=0; + double I_qpsk_avg=0; + double I_qam16_avg=0; + double I_qam64_avg=0; + double qpsk_max=12.2; + double qam16_max=19.2; + double qam64_max=25.2; + double sinr_min = -20; + int offset=0; + + + for (offset = 0; offset <= 24; offset++) { + for(ii=0; ii<12; ii++) { + //x is the sinr_dB in dB + x = s_dB[(offset*12)+ii]; + + if(x<sinr_min) { + I_qpsk +=0; + I_qam16 +=0; + I_qam64 +=0; + } else { + if(x>qpsk_max) + I_qpsk += 1; + else + I_qpsk += (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]); + + if(x>qam16_max) + I_qam16 += 1; + else + I_qam16 += (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]); + + if(x>qam64_max) + I_qam64 += 1; + else + I_qam64 += (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_qpsk_avg = I_qpsk/(12*frame_parms->N_RB_DL); + I_qam16_avg = I_qam16/(12*frame_parms->N_RB_DL); + I_qam64_avg = I_qam64/(12*frame_parms->N_RB_DL); + + // I->SINR_effective Mapping + + sinr_eff_qpsk = (p_qpsk[0]*pow(I_qpsk_avg,7) + p_qpsk[1]*pow(I_qpsk_avg,6) + p_qpsk[2]*pow(I_qpsk_avg,5) + p_qpsk[3]*pow(I_qpsk_avg,4) + p_qpsk[4]*pow(I_qpsk_avg,3) + p_qpsk[5]*pow(I_qpsk_avg, + 2) + p_qpsk[6]*I_qpsk_avg + p_qpsk[7]); + + sinr_eff_qam16 = (p_qam16[0]*pow(I_qam16_avg,7) + p_qam16[1]*pow(I_qam16_avg,6) + p_qam16[2]*pow(I_qam16_avg,5) + p_qam16[3]*pow(I_qam16_avg,4) + p_qam16[4]*pow(I_qam16_avg, + 3) + p_qam16[5]*pow(I_qam16_avg,2) + p_qam16[6]*I_qam16_avg + p_qam16[7]); + + sinr_eff_qam64 = (p_qam64[0]*pow(I_qam64_avg,7) + p_qam64[1]*pow(I_qam64_avg,6) + p_qam64[2]*pow(I_qam64_avg,5) + p_qam64[3]*pow(I_qam64_avg,4) + p_qam64[4]*pow(I_qam64_avg, + 3) + p_qam64[5]*pow(I_qam64_avg,2) + p_qam64[6]*I_qam64_avg + p_qam64[7]); + sinr_eff = cmax3(sinr_eff_qpsk,sinr_eff_qam16,sinr_eff_qam64); + + //printf("SINR_Eff = %e\n",sinr_eff); + + return(sinr_eff); +} +// + + + +#ifdef DEBUG_DLSCH_TOOLS +main() +{ + + int i; + uint8_t rah; + uint32_t rballoc; + + generate_RIV_tables(); + + rah = 0; + rballoc = 0x1fff; + printf("rballoc 0 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rah = 1; + + rballoc = 0x1678; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + + rballoc = 0xfffc; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rballoc = 0xfffd; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rballoc = 0xffff; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rballoc = 0xfffe; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); +} + +#endif + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c new file mode 100755 index 0000000000000000000000000000000000000000..f7afb08286ddb8f58e359bec492d0bdbfca0258d --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c @@ -0,0 +1,3245 @@ +/* + * 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/LTE_TRANSPORT/dci.c +* \brief Implements PDCCH physical channel TX/RX procedures (36.211) and DCI encoding/decoding (36.212/36.213). Current LTE compliance V8.6 2009-03. +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "PHY/defs_UE.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "SIMULATION/TOOLS/sim.h" // for taus +#include "PHY/sse_intrin.h" +#include "PHY/LTE_TRANSPORT/transport_extern.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "SCHED/sched_common.h" + +#include "assertions.h" +#include "T.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +//#define DEBUG_DCI_ENCODING 1 +//#define DEBUG_DCI_DECODING 1 +//#define DEBUG_PHY + +//#undef ALL_AGGREGATION + + +uint16_t extract_crc(uint8_t *dci,uint8_t dci_len) +{ + + uint16_t crc16; + // uint8_t i; + + /* + uint8_t crc; + crc = ((uint16_t *)dci)[DCI_LENGTH>>4]; + printf("crc1: %x, shift %d (DCI_LENGTH %d)\n",crc,DCI_LENGTH&0xf,DCI_LENGTH); + crc = (crc>>(DCI_LENGTH&0xf)); + // clear crc bits + ((uint16_t *)dci)[DCI_LENGTH>>4] &= (0xffff>>(16-(DCI_LENGTH&0xf))); + printf("crc2: %x, dci0 %x\n",crc,((int16_t *)dci)[DCI_LENGTH>>4]); + crc |= (((uint16_t *)dci)[1+(DCI_LENGTH>>4)])<<(16-(DCI_LENGTH&0xf)); + // clear crc bits + (((uint16_t *)dci)[1+(DCI_LENGTH>>4)]) = 0; + printf("extract_crc: crc %x\n",crc); + */ +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"dci_crc (%x,%x,%x), dci_len&0x7=%d\n",dci[dci_len>>3],dci[1+(dci_len>>3)],dci[2+(dci_len>>3)], + dci_len&0x7); +#endif + + if ((dci_len&0x7) > 0) { + ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]<<(dci_len&0x7) | dci[2+(dci_len>>3)]>>(8-(dci_len&0x7)); + ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]<<(dci_len&0x7) | dci[1+(dci_len>>3)]>>(8-(dci_len&0x7)); + } else { + ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]; + ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]; + } + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"dci_crc =>%x\n",crc16); +#endif + + // dci[(dci_len>>3)]&=(0xffff<<(dci_len&0xf)); + // dci[(dci_len>>3)+1] = 0; + // dci[(dci_len>>3)+2] = 0; + return((uint16_t)crc16); + +} + + + +void pdcch_demapping(uint16_t *llr,uint16_t *wbar,LTE_DL_FRAME_PARMS *frame_parms,uint8_t num_pdcch_symbols,uint8_t mi) +{ + + uint32_t i, lprime; + uint16_t kprime,kprime_mod12,mprime,symbol_offset,tti_offset,tti_offset0; + int16_t re_offset,re_offset0; + uint32_t Msymb=(DCI_BITS_MAX/2); + + // This is the REG allocation algorithm from 36-211, second part of Section 6.8.5 + + int Msymb2; + + switch (frame_parms->N_RB_DL) { + case 100: + Msymb2 = Msymb; + break; + + case 75: + Msymb2 = 3*Msymb/4; + break; + + case 50: + Msymb2 = Msymb>>1; + break; + + case 25: + Msymb2 = Msymb>>2; + break; + + case 15: + Msymb2 = Msymb*15/100; + break; + + case 6: + Msymb2 = Msymb*6/100; + break; + + default: + Msymb2 = Msymb>>2; + break; + } + + mprime=0; + + + re_offset = 0; + re_offset0 = 0; // counter for symbol with pilots (extracted outside!) + + for (kprime=0; kprime<frame_parms->N_RB_DL*12; kprime++) { + for (lprime=0; lprime<num_pdcch_symbols; lprime++) { + + symbol_offset = (uint32_t)frame_parms->N_RB_DL*12*lprime; + + tti_offset = symbol_offset + re_offset; + tti_offset0 = symbol_offset + re_offset0; + + // if REG is allocated to PHICH, skip it + if (check_phich_reg(frame_parms,kprime,lprime,mi) == 1) { +// printf("dci_demapping : skipping REG %d (RE %d)\n",(lprime==0)?kprime/6 : kprime>>2,kprime); + if ((lprime == 0)&&((kprime%6)==0)) + re_offset0+=4; + } else { // not allocated to PHICH/PCFICH + // printf("dci_demapping: REG %d\n",(lprime==0)?kprime/6 : kprime>>2); + if (lprime == 0) { + // first symbol, or second symbol+4 TX antennas skip pilots + kprime_mod12 = kprime%12; + + if ((kprime_mod12 == 0) || (kprime_mod12 == 6)) { + // kprime represents REG + + for (i=0; i<4; i++) { + wbar[mprime] = llr[tti_offset0+i]; +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset0+i,symbol_offset,re_offset0,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); +#endif + mprime++; + re_offset0++; + } + } + } else if ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4)) { + // LATER!!!! + } else { // no pilots in this symbol + kprime_mod12 = kprime%12; + + if ((kprime_mod12 == 0) || (kprime_mod12 == 4) || (kprime_mod12 == 8)) { + // kprime represents REG + for (i=0; i<4; i++) { + wbar[mprime] = llr[tti_offset+i]; +#ifdef DEBUG_DCI_DECODING +// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset+i,symbol_offset,re_offset+i,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); +#endif + mprime++; + } + } // is representative + } // no pilots case + } // not allocated to PHICH/PCFICH + + // Stop when all REGs are copied in + if (mprime>=Msymb2) + break; + } //lprime loop + + re_offset++; + + } // kprime loop +} + + +void pdcch_deinterleaving(LTE_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t *wbar,uint8_t number_pdcch_symbols,uint8_t mi) +{ + + uint16_t *wptr,*zptr,*wptr2; + uint32_t Msymb=(DCI_BITS_MAX/2); + uint16_t wtemp_rx[Msymb]; + uint16_t Mquad=get_nquad(number_pdcch_symbols,frame_parms,mi); + uint32_t RCC = (Mquad>>5), ND; + uint32_t row,col,Kpi,index; + int32_t i,k; + + + // printf("Mquad %d, RCC %d\n",Mquad,RCC); + + AssertFatal(z!=NULL,"dci.c: pdcch_deinterleaving: FATAL z is Null\n"); + + // undo permutation + for (i=0; i<Mquad; i++) { + wptr = &wtemp_rx[((i+frame_parms->Nid_cell)%Mquad)<<2]; + wptr2 = &wbar[i<<2]; + + wptr[0] = wptr2[0]; + wptr[1] = wptr2[1]; + wptr[2] = wptr2[2]; + wptr[3] = wptr2[3]; + /* + printf("pdcch_deinterleaving (%p,%p): quad %d (%d) -> (%d,%d %d,%d %d,%d %d,%d)\n",wptr,wptr2,i,(i+frame_parms->Nid_cell)%Mquad, + ((char*)wptr2)[0], + ((char*)wptr2)[1], + ((char*)wptr2)[2], + ((char*)wptr2)[3], + ((char*)wptr2)[4], + ((char*)wptr2)[5], + ((char*)wptr2)[6], + ((char*)wptr2)[7]); + */ + + } + + if ((Mquad&0x1f) > 0) + RCC++; + + Kpi = (RCC<<5); + ND = Kpi - Mquad; + + k=0; + + for (col=0; col<32; col++) { + index = bitrev_cc_dci[col]; + + for (row=0; row<RCC; row++) { + // printf("row %d, index %d, Nd %d\n",row,index,ND); + if (index>=ND) { + + + + wptr = &wtemp_rx[k<<2]; + zptr = &z[(index-ND)<<2]; + + zptr[0] = wptr[0]; + zptr[1] = wptr[1]; + zptr[2] = wptr[2]; + zptr[3] = wptr[3]; + + /* + printf("deinterleaving ; k %d, index-Nd %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",k,(index-ND), + ((int8_t *)wptr)[0], + ((int8_t *)wptr)[1], + ((int8_t *)wptr)[2], + ((int8_t *)wptr)[3], + ((int8_t *)wptr)[4], + ((int8_t *)wptr)[5], + ((int8_t *)wptr)[6], + ((int8_t *)wptr)[7]); + */ + k++; + } + + index+=32; + + } + } + + for (i=0; i<Mquad; i++) { + zptr = &z[i<<2]; + /* + printf("deinterleaving ; quad %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",i, + ((int8_t *)zptr)[0], + ((int8_t *)zptr)[1], + ((int8_t *)zptr)[2], + ((int8_t *)zptr)[3], + ((int8_t *)zptr)[4], + ((int8_t *)zptr)[5], + ((int8_t *)zptr)[6], + ((int8_t *)zptr)[7]); + */ + } + +} + + + +int32_t pdcch_llr(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + char *pdcch_llr, + uint8_t symbol) +{ + + int16_t *rxF= (int16_t*) &rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + int32_t i; + char *pdcch_llr8; + + pdcch_llr8 = &pdcch_llr[2*symbol*frame_parms->N_RB_DL*12]; + + if (!pdcch_llr8) { + printf("pdcch_qpsk_llr: llr is null, symbol %d\n",symbol); + return(-1); + } + + // printf("pdcch qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llr8-pdcch_llr); + + for (i=0; i<(frame_parms->N_RB_DL*((symbol==0) ? 16 : 24)); i++) { + + if (*rxF>31) + *pdcch_llr8=31; + else if (*rxF<-32) + *pdcch_llr8=-32; + else + *pdcch_llr8 = (char)(*rxF); + + // printf("rxF->llr : %d %d => %d\n",i,*rxF,*pdcch_llr8); + rxF++; + pdcch_llr8++; + } + + return(0); + +} + +//__m128i avg128P; + +//compute average channel_level on each (TX,RX) antenna pair +void pdcch_channel_level(int32_t **dl_ch_estimates_ext, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t *avg, + uint8_t nb_rb) +{ + + int16_t rb; + uint8_t aatx,aarx; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128; + __m128i avg128P; +#elif defined(__arm__) + int16x8_t *dl_ch128; + int32x4_t *avg128P; +#endif + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + //clear average level +#if defined(__x86_64__) || defined(__i386__) + avg128P = _mm_setzero_si128(); + dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][0]; +#elif defined(__arm__) + +#endif + for (rb=0; rb<nb_rb; rb++) { + +#if defined(__x86_64__) || defined(__i386__) + avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); + avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); + avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); +#elif defined(__arm__) + +#endif + dl_ch128+=3; + /* + if (rb==0) { + print_shorts("dl_ch128",&dl_ch128[0]); + print_shorts("dl_ch128",&dl_ch128[1]); + print_shorts("dl_ch128",&dl_ch128[2]); + } + */ + } + + DevAssert( nb_rb ); + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128P)[0] + + ((int32_t*)&avg128P)[1] + + ((int32_t*)&avg128P)[2] + + ((int32_t*)&avg128P)[3])/(nb_rb*12); + + // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + +} + + + +void pdcch_detection_mrc_i(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + int32_t **rxdataF_comp_i, + int32_t **rho, + int32_t **rho_i, + uint8_t symbol) +{ + + uint8_t aatx; + +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; +#endif + int32_t i; + + if (frame_parms->nb_antennas_rx>1) { + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { + //if (frame_parms->mode1_flag && (aatx>0)) break; + +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#endif + // MRC on each re of rb on MF output + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); +#endif + } + } + +#if defined(__x86_64__) || defined(__i386__) + rho128_0 = (__m128i *) &rho[0][symbol*frame_parms->N_RB_DL*12]; + rho128_1 = (__m128i *) &rho[1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rho128_0 = (int16x8_t *) &rho[0][symbol*frame_parms->N_RB_DL*12]; + rho128_1 = (int16x8_t *) &rho[1][symbol*frame_parms->N_RB_DL*12]; +#endif + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1)); +#elif defined(__arm__) + rho128_0[i] = vhaddq_s16(rho128_0[i],rho128_1[i]); +#endif + } + +#if defined(__x86_64__) || defined(__i386__) + rho128_i0 = (__m128i *) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; + rho128_i1 = (__m128i *) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i0 = (__m128i *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i1 = (__m128i *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rho128_i0 = (int16x8_t*) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; + rho128_i1 = (int16x8_t*) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i0 = (int16x8_t *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i1 = (int16x8_t *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; + +#endif + // MRC on each re of rb on MF and rho + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_i0[i],1),_mm_srai_epi16(rxdataF_comp128_i1[i],1)); + rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_i0[i] = vhaddq_s16(rxdataF_comp128_i0[i],rxdataF_comp128_i1[i]); + rho128_i0[i] = vhaddq_s16(rho128_i0[i],rho128_i1[i]); + +#endif + } + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + + +void pdcch_extract_rbs_single(int32_t **rxdataF, + int32_t **dl_ch_estimates, + int32_t **rxdataF_ext, + int32_t **dl_ch_estimates_ext, + uint8_t symbol, + uint32_t high_speed_flag, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + + uint16_t rb,nb_rb=0; + uint8_t i,j,aarx; + int32_t *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; + + + int nushiftmod3 = frame_parms->nushift%3; + uint8_t symbol_mod; + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod); +#endif + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (high_speed_flag == 1) + dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; + else + dl_ch0 = &dl_ch_estimates[aarx][5]; + + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + + rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + + rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; + + if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + // For second half of RBs skip DC carrier + if (rb==(frame_parms->N_RB_DL>>1)) { + rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; + + //dl_ch0++; + } + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + + for (i=0; i<12; i++) { + + rxF_ext[i]=rxF[i]; + + } + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j]=rxF[i]; + //printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j++]=dl_ch0[i]; + //printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + } + } + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + rxF+=12; + } + } + } else { // Odd number of RBs + for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j++]=dl_ch0[i]; + // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + } + } + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + rxF+=12; + } + } + + // Do middle RB (around DC) + // printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]); + + if (symbol_mod==0) { + j=0; + + for (i=0; i<6; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3))) { + dl_ch0_ext[j]=dl_ch0[i]; + rxF_ext[j++]=rxF[i]; + // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); + } + } + + rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + if ((i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + dl_ch0_ext[j]=dl_ch0[i]; + rxF_ext[j++]=rxF[(1+i-6)]; + // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); + } + } + + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + dl_ch0+=12; + rxF+=7; + rb++; + } else { + for (i=0; i<6; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + rxF_ext[i]=rxF[i]; + } + + rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + rxF_ext[i]=rxF[(1+i-6)]; + } + + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + dl_ch0+=12; + rxF+=7; + rb++; + } + + for (; rb<frame_parms->N_RB_DL; rb++) { + if (symbol_mod > 0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=(nushiftmod3)) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j++]=dl_ch0[i]; + } + } + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + rxF+=12; + } + } + } + } +} + +void pdcch_extract_rbs_dual(int32_t **rxdataF, + int32_t **dl_ch_estimates, + int32_t **rxdataF_ext, + int32_t **dl_ch_estimates_ext, + uint8_t symbol, + uint32_t high_speed_flag, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + + uint16_t rb,nb_rb=0; + uint8_t i,aarx,j; + int32_t *dl_ch0,*dl_ch0_ext,*dl_ch1,*dl_ch1_ext,*rxF,*rxF_ext; + uint8_t symbol_mod; + int nushiftmod3 = frame_parms->nushift%3; + + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY, "extract_rbs_dual: symbol_mod %d\n",symbol_mod); +#endif + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (high_speed_flag==1) { + dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; + dl_ch1 = &dl_ch_estimates[2+aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; + } else { + dl_ch0 = &dl_ch_estimates[aarx][5]; + dl_ch1 = &dl_ch_estimates[2+aarx][5]; + } + + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(frame_parms->N_RB_DL*12)]; + + // printf("pdcch extract_rbs: rxF_ext pos %d\n",symbol*(frame_parms->N_RB_DL*12)); + rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + + rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; + + if ((frame_parms->N_RB_DL&1) == 0) // even number of RBs + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + // For second half of RBs skip DC carrier + if (rb==(frame_parms->N_RB_DL>>1)) { + rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; + // dl_ch0++; + //dl_ch1++; + } + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); + + /* + printf("rb %d\n",rb); + for (i=0;i<12;i++) + printf("(%d %d)",((int16_t *)dl_ch0)[i<<1],((int16_t*)dl_ch0)[1+(i<<1)]); + printf("\n"); + */ + for (i=0; i<12; i++) { + rxF_ext[i]=rxF[i]; + // printf("%d : (%d,%d)\n",(rxF+(2*i)-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))*2])/2, + // ((int16_t*)&rxF[i<<1])[0],((int16_t*)&rxF[i<<1])[0]); + } + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3) && + (i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j] =dl_ch0[i]; + dl_ch1_ext[j++]=dl_ch1[i]; + } + } + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + } + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } + + else { // Odd number of RBs + for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { + + // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3) && + (i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j++]=dl_ch1[i]; + // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + } + } + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } + } + + // Do middle RB (around DC) + + if (symbol_mod > 0) { + for (i=0; i<6; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + dl_ch1_ext[i]=dl_ch1[i]; + rxF_ext[i]=rxF[i]; + } + + rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + dl_ch1_ext[i]=dl_ch1[i]; + rxF_ext[i]=rxF[(1+i)]; + } + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=7; + rb++; + } else { + j=0; + + for (i=0; i<6; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3)) { + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j]=dl_ch1[i]; + rxF_ext[j++]=rxF[i]; + // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); + } + } + + rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + if ((i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j]=dl_ch1[i]; + rxF_ext[j++]=rxF[(1+i-6)]; + // printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); + } + } + + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + dl_ch0+=12; + dl_ch1+=12; + rxF+=7; + rb++; + } + + for (; rb<frame_parms->N_RB_DL; rb++) { + + if (symbol_mod>0) { + // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3) && + (i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j++]=dl_ch1[i]; + } + } + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } + } + } + } +} + + +void pdcch_channel_compensation(int32_t **rxdataF_ext, + int32_t **dl_ch_estimates_ext, + int32_t **rxdataF_comp, + int32_t **rho, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t symbol, + uint8_t output_shift) +{ + + uint16_t rb; + +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; + __m128i *dl_ch128_2, *rho128; + __m128i mmtmpPD0,mmtmpPD1,mmtmpPD2,mmtmpPD3; +#elif defined(__arm__) + +#endif + uint8_t aatx,aarx,pilots=0; + + + + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY, "PDCCH comp: symbol %d\n",symbol); +#endif + + if (symbol==0) + pilots=1; + + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { + //if (frame_parms->mode1_flag && aatx>0) break; //if mode1_flag is set then there is only one stream to extract, independent of nb_antenna_ports_eNB + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; + +#elif defined(__arm__) + +#endif + + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + +#if defined(__x86_64__) || defined(__i386__) + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpPD0); + + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpPD1); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[0]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + // print_ints("re(shift)",&mmtmpPD0); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + // print_ints("im(shift)",&mmtmpPD1); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + // print_ints("c0",&mmtmpPD2); + // print_ints("c1",&mmtmpPD3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",dl_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[1]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",dl_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + // multiply by conjugated channel + if (pilots == 0) { + mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[2]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + rxdataF_comp128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + } + + // print_shorts("rx:",rxdataF128+2); + // print_shorts("ch:",dl_ch128+2); + // print_shorts("pack:",rxdataF_comp128+2); + + if (pilots==0) { + dl_ch128+=3; + rxdataF128+=3; + rxdataF_comp128+=3; + } else { + dl_ch128+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + } +#elif defined(__arm__) + +#endif + } + } + } + + + if (rho) { + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12]; + +#elif defined(__arm__) + +#endif + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { +#if defined(__x86_64__) || defined(__i386__) + + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128_2[0]); + // print_ints("re",&mmtmpD0); + + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpPD1); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[0]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + // print_ints("re(shift)",&mmtmpD0); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + // print_ints("im(shift)",&mmtmpD1); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + // print_ints("c0",&mmtmpPD2); + // print_ints("c1",&mmtmpPD3); + rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + + //print_shorts("rx:",dl_ch128_2); + //print_shorts("ch:",dl_ch128); + //print_shorts("pack:",rho128); + + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128_2[1]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[1]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + + rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); + //print_shorts("rx:",dl_ch128_2+1); + //print_shorts("ch:",dl_ch128+1); + //print_shorts("pack:",rho128+1); + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128_2[2]); + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[2]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + //print_shorts("rx:",dl_ch128_2+2); + //print_shorts("ch:",dl_ch128+2); + //print_shorts("pack:",rho128+2); + + dl_ch128+=3; + dl_ch128_2+=3; + rho128+=3; + +#elif defined(__arm_) + + +#endif + } + } + + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void pdcch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + uint8_t symbol) +{ + + uint8_t aatx; + +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; +#endif + int32_t i; + + if (frame_parms->nb_antennas_rx>1) { + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#endif + // MRC on each re of rb + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); +#endif + } + } + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + +} + +void pdcch_siso(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + uint8_t l) +{ + + + uint8_t rb,re,jj,ii; + + jj=0; + ii=0; + + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + for (re=0; re<12; re++) { + + rxdataF_comp[0][jj++] = rxdataF_comp[0][ii]; + ii++; + } + } +} + + +void pdcch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + uint8_t symbol) +{ + + + int16_t *rxF0,*rxF1; + uint8_t rb,re; + int32_t jj=(symbol*frame_parms->N_RB_DL*12); + + rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y + rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y + + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + for (re=0; re<12; re+=2) { + + // Alamouti RX combining + + rxF0[0] = rxF0[0] + rxF1[2]; + rxF0[1] = rxF0[1] - rxF1[3]; + + rxF0[2] = rxF0[2] - rxF1[0]; + rxF0[3] = rxF0[3] + rxF1[1]; + + rxF0+=4; + rxF1+=4; + } + } + + +} + +int32_t avgP[4]; + +int32_t rx_pdcch(PHY_VARS_UE *ue, + uint32_t frame, + uint8_t subframe, + uint8_t eNB_id, + MIMO_mode_t mimo_mode, + uint32_t high_speed_flag) +{ + + LTE_UE_COMMON *common_vars = &ue->common_vars; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; + + uint8_t log2_maxh,aatx,aarx; + int32_t avgs; + uint8_t n_pdcch_symbols; + uint8_t mi = get_mi(frame_parms,subframe); + + // printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d, handling symbol 0 \n",subframe,eNB_id,pdcch_vars); + // procress ofdm symbol 0 + if (frame_parms->nb_antenna_ports_eNB>1) { + pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + 0, + high_speed_flag, + frame_parms); + } else { + pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + 0, + high_speed_flag, + frame_parms); + } + + + // compute channel level based on ofdm symbol 0 + pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, + frame_parms, + avgP, + frame_parms->N_RB_DL); + + avgs = 0; + + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) + avgs = cmax(avgs,avgP[(aarx<<1)+aatx]); + + log2_maxh = (log2_approx(avgs)/2) + 5; //+frame_parms->nb_antennas_rx; +#ifdef UE_DEBUG_TRACE + LOG_I(PHY,"subframe %d: pdcch log2_maxh = %d (%d,%d)\n",subframe,log2_maxh,avgP[0],avgs); +#endif + + T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(frame%1024), T_INT(subframe), + T_INT(avgP[0]), T_INT(avgP[1]), T_INT(avgP[2]), T_INT(avgP[3])); + + // compute LLRs for ofdm symbol 0 only + pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + pdcch_vars[eNB_id]->rxdataF_comp, + (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, + frame_parms, + 0, + log2_maxh); // log2_maxh+I0_shift + + +#ifdef DEBUG_PHY + + if (subframe==5) { + printf("Writing output s0\n"); + write_output("rxF_comp_d0.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][0*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); + } +#endif + + if (frame_parms->nb_antennas_rx > 1) { + pdcch_detection_mrc(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + 0); + } + + if (mimo_mode == SISO) + pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); + else + pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); + + pdcch_llr(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + (char *)pdcch_vars[eNB_id]->llr, + 0); + + + // decode pcfich here and find out pdcch ofdm symbol number + n_pdcch_symbols = rx_pcfich(frame_parms, + subframe, + pdcch_vars[eNB_id], + mimo_mode); + + // printf("In rx_pdcch, subframe %d, num_pdcch_symbols %d \n",subframe,n_pdcch_symbols); + + if (n_pdcch_symbols>3) + n_pdcch_symbols=1; + +#if T_TRACER + T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), + T_INT(n_pdcch_symbols), + T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4)); +#endif + + +#ifdef DEBUG_DCI_DECODING + + if (subframe==5) LOG_I(PHY,"demapping: subframe %d, num_pdcch_symbols %d\n",subframe,n_pdcch_symbols); +#endif + + // process pdcch ofdm symbol 1 and 2 if necessary + for (int s=1; s<n_pdcch_symbols; s++){ + // printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d, handling symbol %d \n",subframe,eNB_id,pdcch_vars,s); + if (frame_parms->nb_antenna_ports_eNB>1) { + pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + s, + high_speed_flag, + frame_parms); + } else { + pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + s, + high_speed_flag, + frame_parms); + } + + + pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + pdcch_vars[eNB_id]->rxdataF_comp, + (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, + frame_parms, + s, + log2_maxh); // log2_maxh+I0_shift + + +#ifdef DEBUG_PHY + + if (subframe==5) { + write_output("rxF_comp_ds.m","rxF_c_ds",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); + } +#endif + + + + if (frame_parms->nb_antennas_rx > 1) { + pdcch_detection_mrc(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + s); + + } + + if (mimo_mode == SISO) + pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); + else + pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); + + + // printf("subframe %d computing llrs for symbol %d : %p\n",subframe,s,pdcch_vars[eNB_id]->llr); + pdcch_llr(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + (char *)pdcch_vars[eNB_id]->llr, + s); + /*#ifdef DEBUG_PHY + write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); + #endif*/ + } + + pdcch_demapping(pdcch_vars[eNB_id]->llr, + pdcch_vars[eNB_id]->wbar, + frame_parms, + n_pdcch_symbols, + get_mi(frame_parms,subframe)); + + pdcch_deinterleaving(frame_parms, + (uint16_t*)pdcch_vars[eNB_id]->e_rx, + pdcch_vars[eNB_id]->wbar, + n_pdcch_symbols, + mi); + + pdcch_unscrambling(frame_parms, + subframe, + pdcch_vars[eNB_id]->e_rx, + get_nCCE(n_pdcch_symbols,frame_parms,mi)*72); + + pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols; + + // if ((frame&1) ==0 && subframe==5) exit(-1); + return(0); +} + + +void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + int8_t* llr, + uint32_t length) +{ + + int i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in first call to lte_gold_generic + + x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 + + for (i=0; i<length; i++) { + if ((i&0x1f)==0) { + s = lte_gold_generic(&x1, &x2, reset); + // printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + + // if (subframe == 5) printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); + if (((s>>(i%32))&1)==0) + llr[i] = -llr[i]; + // if (subframe == 5) printf("%d\n",llr[i]); + + } +} + +/* +uint8_t get_num_pdcch_symbols(uint8_t num_dci, + DCI_ALLOC_t *dci_alloc, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe) +{ + + uint16_t numCCE = 0; + uint8_t i; + uint8_t nCCEmin = 0; + uint16_t CCE_max_used_index = 0; + uint16_t firstCCE_max = dci_alloc[0].firstCCE; + uint8_t L = dci_alloc[0].L; + + // check pdcch duration imposed by PHICH duration (Section 6.9 of 36-211) + if (frame_parms->Ncp==1) { // extended prefix + if ((frame_parms->frame_type == TDD) && + ((frame_parms->tdd_config<3)||(frame_parms->tdd_config==6)) && + ((subframe==1) || (subframe==6))) // subframes 1 and 6 (S-subframes) for 5ms switching periodicity are 2 symbols + nCCEmin = 2; + else { // 10ms switching periodicity is always 3 symbols, any DL-only subframe is 3 symbols + nCCEmin = 3; + } + } + + // compute numCCE + for (i=0; i<num_dci; i++) { + // printf("dci %d => %d\n",i,dci_alloc[i].L); + numCCE += (1<<(dci_alloc[i].L)); + + if(firstCCE_max < dci_alloc[i].firstCCE) { + firstCCE_max = dci_alloc[i].firstCCE; + L = dci_alloc[i].L; + } + } + CCE_max_used_index = firstCCE_max + (1<<L) - 1; + + //if ((9*numCCE) <= (frame_parms->N_RB_DL*2)) + if (CCE_max_used_index < get_nCCE(1, frame_parms, get_mi(frame_parms, subframe))) + return(cmax(1,nCCEmin)); + //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 4 : 5))) + else if (CCE_max_used_index < get_nCCE(2, frame_parms, get_mi(frame_parms, subframe))) + return(cmax(2,nCCEmin)); + //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 7 : 8))) + else if (CCE_max_used_index < get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))) + return(cmax(3,nCCEmin)); + else if (frame_parms->N_RB_DL<=10) { + if (frame_parms->Ncp == 0) { // normal CP + printf("numCCE %d, N_RB_DL = %d : should be returning 4 PDCCH symbols (%d,%d,%d)\n",numCCE,frame_parms->N_RB_DL, + get_nCCE(1, frame_parms, get_mi(frame_parms, subframe)), + get_nCCE(2, frame_parms, get_mi(frame_parms, subframe)), + get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))); + + if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 10 : 11))) + return(4); + } else { // extended CP + if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 9 : 10))) + return(4); + } + } + + + + // LOG_I(PHY," dci.c: get_num_pdcch_symbols subframe %d FATAL, illegal numCCE %d (num_dci %d)\n",subframe,numCCE,num_dci); + //for (i=0;i<num_dci;i++) { + // printf("dci_alloc[%d].L = %d\n",i,dci_alloc[i].L); + //} + //exit(-1); +exit(1); + return(0); +} +*/ + + + +void dci_decoding(uint8_t DCI_LENGTH, + uint8_t aggregation_level, + int8_t *e, + uint8_t *decoded_output) +{ + + uint8_t dummy_w_rx[3*(MAX_DCI_SIZE_BITS+16+64)]; + int8_t w_rx[3*(MAX_DCI_SIZE_BITS+16+32)],d_rx[96+(3*(MAX_DCI_SIZE_BITS+16))]; + + uint16_t RCC; + + uint16_t D=(DCI_LENGTH+16+64); + uint16_t coded_bits; +#ifdef DEBUG_DCI_DECODING + int32_t i; +#endif + + AssertFatal(aggregation_level<4, + "dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); + + coded_bits = 72 * (1<<aggregation_level); + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY," Doing DCI decoding for %d bits, DCI_LENGTH %d,coded_bits %d, e %p\n",3*(DCI_LENGTH+16),DCI_LENGTH,coded_bits,e); +#endif + + // now do decoding + memset((void*)dummy_w_rx,0,3*D); + RCC = generate_dummy_w_cc(DCI_LENGTH+16, + dummy_w_rx); + + + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY," Doing DCI Rate Matching RCC %d, w %p\n",RCC,w_rx); +#endif + + lte_rate_matching_cc_rx(RCC,coded_bits,w_rx,dummy_w_rx,e); + + sub_block_deinterleaving_cc((uint32_t)(DCI_LENGTH+16), + &d_rx[96], + &w_rx[0]); + +#ifdef DEBUG_DCI_DECODING + if (DCI_LENGTH==27 && ((1<<aggregation_level) == 4)) + for (int i=0; i<16+DCI_LENGTH; i++) + LOG_I(PHY," DCI %d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); + +#endif + memset(decoded_output,0,2+((16+DCI_LENGTH)>>3)); + +#ifdef DEBUG_DCI_DECODING + printf("Before Viterbi\n"); + + for (i=0; i<16+DCI_LENGTH; i++) + printf("%d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); + +#endif + //debug_printf("Doing DCI Viterbi \n"); + phy_viterbi_lte_sse2(d_rx+96,decoded_output,16+DCI_LENGTH); + //debug_printf("Done DCI Viterbi \n"); +} + + +static uint8_t dci_decoded_output[RX_NB_TH][(MAX_DCI_SIZE_BITS+64)/8]; + + + + +int get_nCCE_offset_l1(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); + + // printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); + + for (m = nb_candidates-1 ; m >=0 ; m--) { + + 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; + } + } + + if (search_space_free == 1) { + + // printf("returning %d\n",m*L); + + for (l=0; l<L; l++) + CCE_table[(m*L)+l]=1; + return(m*L); + } + } + + 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; + + for (i=0; i<=subframe; i++) + Yk = (Yk*39827)%65537; + + Yk = Yk % (nCCE/L); + + + switch (L) { + case 1: + case 2: + nb_candidates = 6; + break; + + case 4: + case 8: + nb_candidates = 2; + 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); + + 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; + } + } + + 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(-1); + } +} + + +void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars, + int do_common, + dci_detect_mode_t mode, + uint8_t subframe, + DCI_ALLOC_t *dci_alloc, + int16_t eNB_id, + uint8_t current_thread_id, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t mi, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint8_t L, + uint8_t format_si, + uint8_t format_p, + uint8_t format_ra, + uint8_t format_c, + uint8_t sizeof_bits, + uint8_t sizeof_bytes, + uint8_t *dci_cnt, + uint8_t *format0_found, + uint8_t *format_c_found, + uint32_t *CCEmap0, + uint32_t *CCEmap1, + uint32_t *CCEmap2) +{ + + uint16_t crc,CCEind,nCCE; + uint32_t *CCEmap=NULL,CCEmap_mask=0; + int L2=(1<<L); + unsigned int Yk,nb_candidates = 0,i,m; + unsigned int CCEmap_cand; + + nCCE = get_nCCE(pdcch_vars[eNB_id]->num_pdcch_symbols,frame_parms,mi); + + if (nCCE > get_nCCE(3,frame_parms,1)) { + LOG_D(PHY,"skip DCI decoding: nCCE=%d > get_nCCE(3,frame_parms,1)=%d\n", nCCE, get_nCCE(3,frame_parms,1)); + return; + } + + if (nCCE<L2) { + LOG_D(PHY,"skip DCI decoding: nCCE=%d < L2=%d\n", nCCE, L2); + return; + } + + if (mode == NO_DCI) { + LOG_D(PHY, "skip DCI decoding: expect no DCIs at subframe %d\n", subframe); + return; + } + + if (do_common == 1) { + nb_candidates = (L2==4) ? 4 : 2; + Yk=0; + } 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)pdcch_vars[eNB_id]->crnti; + + for (i=0; i<=subframe; i++) + Yk = (Yk*39827)%65537; + + Yk = Yk % (nCCE/L2); + + switch (L2) { + case 1: + case 2: + nb_candidates = 6; + break; + + case 4: + case 8: + nb_candidates = 2; + break; + + default: + DevParam(L2, do_common, eNB_id); + break; + } + } + + /* for (CCEind=0; + CCEind<nCCE2; + CCEind+=(1<<L)) {*/ + + if (nb_candidates*L2 > nCCE) + nb_candidates = nCCE/L2; + + for (m=0; m<nb_candidates; m++) { + + CCEind = (((Yk+m)%(nCCE/L2))*L2); + + if (CCEind<32) + CCEmap = CCEmap0; + else if (CCEind<64) + CCEmap = CCEmap1; + else if (CCEind<96) + CCEmap = CCEmap2; + else { + AssertFatal(1==0, + "Illegal CCEind %d (Yk %d, m %d, nCCE %d, L2 %d\n",CCEind,Yk,m,nCCE,L2); + } + + switch (L2) { + case 1: + CCEmap_mask = (1<<(CCEind&0x1f)); + break; + + case 2: + CCEmap_mask = (3<<(CCEind&0x1f)); + break; + + case 4: + CCEmap_mask = (0xf<<(CCEind&0x1f)); + break; + + case 8: + CCEmap_mask = (0xff<<(CCEind&0x1f)); + break; + + default: + AssertFatal(1==0, + "Illegal L2 value %d\n", L2 ); + } + + CCEmap_cand = (*CCEmap)&CCEmap_mask; + + // CCE is not allocated yet + + if (CCEmap_cand == 0) { + + if (do_common == 1) + LOG_D(PHY,"[DCI search nPdcch %d - common] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n", + pdcch_vars[eNB_id]->num_pdcch_symbols,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask); + else + LOG_D(PHY,"[DCI search nPdcch %d - ue spec %x] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x) format %d\n", + pdcch_vars[eNB_id]->num_pdcch_symbols,pdcch_vars[eNB_id]->crnti,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask,format_c); + + dci_decoding(sizeof_bits, + L, + &pdcch_vars[eNB_id]->e_rx[CCEind*72], + &dci_decoded_output[current_thread_id][0]); + /* + for (i=0;i<3+(sizeof_bits>>3);i++) + printf("dci_decoded_output[%d][%d] => %x\n",current_thread_id,i,dci_decoded_output[current_thread_id][i]); + */ + + crc = (crc16(&dci_decoded_output[current_thread_id][0],sizeof_bits)>>16) ^ extract_crc(&dci_decoded_output[current_thread_id][0],sizeof_bits); +#ifdef DEBUG_DCI_DECODING + printf("crc =>%x\n",crc); +#endif + + if (((L>1) && ((crc == si_rnti)|| + (crc == p_rnti)|| + (crc == ra_rnti)))|| + (crc == pdcch_vars[eNB_id]->crnti)) { + dci_alloc[*dci_cnt].dci_length = sizeof_bits; + dci_alloc[*dci_cnt].rnti = crc; + dci_alloc[*dci_cnt].L = L; + dci_alloc[*dci_cnt].firstCCE = CCEind; + + //printf("DCI FOUND !!! crc =>%x, sizeof_bits %d, sizeof_bytes %d \n",crc, sizeof_bits, sizeof_bytes); + if (sizeof_bytes<=4) { + dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0]; + dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1]; + dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2]; + dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3]; +#ifdef DEBUG_DCI_DECODING + printf("DCI => %x,%x,%x,%x\n",dci_decoded_output[current_thread_id][0], + dci_decoded_output[current_thread_id][1], + dci_decoded_output[current_thread_id][2], + dci_decoded_output[current_thread_id][3]); +#endif + } else { + dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0]; + dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[current_thread_id][1]; + dci_alloc[*dci_cnt].dci_pdu[5] = dci_decoded_output[current_thread_id][2]; + dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3]; + dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][4]; + dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][5]; + dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][6]; + dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][7]; +#ifdef DEBUG_DCI_DECODING + printf("DCI => %x,%x,%x,%x,%x,%x,%x,%x\n", + dci_decoded_output[current_thread_id][0],dci_decoded_output[current_thread_id][1],dci_decoded_output[current_thread_id][2],dci_decoded_output[current_thread_id][3], + dci_decoded_output[current_thread_id][4],dci_decoded_output[current_thread_id][5],dci_decoded_output[current_thread_id][6],dci_decoded_output[current_thread_id][7]); +#endif + } + + if (crc==si_rnti) { + dci_alloc[*dci_cnt].format = format_si; + *dci_cnt = *dci_cnt+1; + } else if (crc==p_rnti) { + dci_alloc[*dci_cnt].format = format_p; + *dci_cnt = *dci_cnt+1; + } else if (crc==ra_rnti) { + dci_alloc[*dci_cnt].format = format_ra; + // store first nCCE of group for PUCCH transmission of ACK/NAK + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + *dci_cnt = *dci_cnt+1; + } else if (crc==pdcch_vars[eNB_id]->crnti) { + + if ((mode&UL_DCI)&&(format_c == format0)&&((dci_decoded_output[current_thread_id][0]&0x80)==0)) {// check if pdu is format 0 or 1A + if (*format0_found == 0) { + dci_alloc[*dci_cnt].format = format0; + *format0_found = 1; + *dci_cnt = *dci_cnt+1; + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + } + } else if (format_c == format0) { // this is a format 1A DCI + dci_alloc[*dci_cnt].format = format1A; + *dci_cnt = *dci_cnt+1; + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + } else { + // store first nCCE of group for PUCCH transmission of ACK/NAK + if (*format_c_found == 0) { + dci_alloc[*dci_cnt].format = format_c; + *dci_cnt = *dci_cnt+1; + *format_c_found = 1; + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + } + } + } + + //LOG_I(PHY,"DCI decoding CRNTI [format: %d, nCCE[subframe: %d]: %d ], AggregationLevel %d \n",format_c, subframe, pdcch_vars[eNB_id]->nCCE[subframe],L2); + // memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_decoded_output,sizeof_bytes); + + + + switch (1<<L) { + case 1: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + + case 2: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + + case 4: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + + case 8: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + } + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"[DCI search] Found DCI %d rnti %x Aggregation %d length %d format %s in CCE %d (CCEmap %x) candidate %d / %d \n", + *dci_cnt,crc,1<<L,sizeof_bits,dci_format_strings[dci_alloc[*dci_cnt-1].format],CCEind,*CCEmap,m,nb_candidates ); + dump_dci(frame_parms,&dci_alloc[*dci_cnt-1]); + +#endif + return; + } // rnti match + } // CCEmap_cand == 0 +/* + if ( agregationLevel != 0xFF && + (format_c == format0 && m==0 && si_rnti != SI_RNTI)) + { + //Only valid for OAI : Save some processing time when looking for DCI format0. From the log we see the DCI only on candidate 0. + return; + } +*/ + } // candidate loop +} + +uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue, + DCI_ALLOC_t *dci_alloc, + uint8_t DCIFormat, + uint8_t agregationLevel, + int16_t eNB_id, + uint8_t subframe) +{ + + uint8_t dci_cnt=0,old_dci_cnt=0; + uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; + LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + uint8_t mi = get_mi(&ue->frame_parms,subframe); + uint16_t ra_rnti=99; + uint8_t format0_found=0,format_c_found=0; + uint8_t tmode = ue->transmission_mode[eNB_id]; + uint8_t frame_type = frame_parms->frame_type; + uint8_t format0_size_bits=0,format0_size_bytes=0; + uint8_t format1_size_bits=0,format1_size_bytes=0; + dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); + + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); + + } else { + format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); + } + + break; + + case 25: + default: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); + } else { + format0_size_bits = sizeof_DCI0_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); + } + + break; + + case 50: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_10MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); + + } else { + format0_size_bits = sizeof_DCI0_10MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); + format1_size_bits = sizeof_DCI1_10MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); + } + + break; + + case 100: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_20MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); + } else { + format0_size_bits = sizeof_DCI0_20MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); + format1_size_bits = sizeof_DCI1_20MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); + } + + break; + } + + if (ue->prach_resources[eNB_id]) + ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; + + // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + agregationLevel, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (DCIFormat == format1) + { + if ((tmode < 3) || (tmode == 7)) { + //printf("Crnti decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); + + // Now check UE_SPEC format 1 search spaces at aggregation 1 + + //printf("[DCI search] Format 1/1A aggregation 1\n"); + + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff) || + (format_c_found==1)) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //printf("Crnti 1 decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); + + } + else if (DCIFormat == format1A) + { + AssertFatal(0,"Other Transmission mode not yet coded\n"); + } + } + else + { + LOG_W(PHY,"DCI format %d wrong or not yet implemented \n",DCIFormat); + } + + return(dci_cnt); + +} + +uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, + DCI_ALLOC_t *dci_alloc, + int do_common, + int16_t eNB_id, + uint8_t subframe) +{ + + uint8_t dci_cnt=0,old_dci_cnt=0; + uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; + LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + uint8_t mi = get_mi(&ue->frame_parms,subframe); + uint16_t ra_rnti=99; + uint8_t format0_found=0,format_c_found=0; + uint8_t tmode = ue->transmission_mode[eNB_id]; + uint8_t frame_type = frame_parms->frame_type; + uint8_t format1A_size_bits=0,format1A_size_bytes=0; + uint8_t format1C_size_bits=0,format1C_size_bytes=0; + uint8_t format0_size_bits=0,format0_size_bytes=0; + uint8_t format1_size_bits=0,format1_size_bytes=0; + uint8_t format2_size_bits=0,format2_size_bytes=0; + uint8_t format2A_size_bits=0,format2A_size_bytes=0; + dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); + + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_1_5MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_1_5MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_1_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); + format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_1_5MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_1_5MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_1_5MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_1_5MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_1_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); + format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_1_5MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_1_5MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_FDD_t); + } + } + + break; + + case 25: + default: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_5MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_5MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_5MHz_t); + format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_5MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_5MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_5MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_5MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_5MHz_t); + format0_size_bits = sizeof_DCI0_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_5MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_5MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_4A_FDD_t); + } + } + + break; + + case 50: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_10MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_10MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_10MHz_t; + format1C_size_bytes = sizeof(DCI1C_10MHz_t); + format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_10MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_10MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_10MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_10MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_10MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_10MHz_t; + format1C_size_bytes = sizeof(DCI1C_10MHz_t); + format0_size_bits = sizeof_DCI0_10MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); + format1_size_bits = sizeof_DCI1_10MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_10MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_10MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_4A_FDD_t); + } + } + + break; + + case 100: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_20MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_20MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_20MHz_t; + format1C_size_bytes = sizeof(DCI1C_20MHz_t); + format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_20MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_20MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_20MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_20MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_20MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_20MHz_t; + format1C_size_bytes = sizeof(DCI1C_20MHz_t); + format0_size_bits = sizeof_DCI0_20MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); + format1_size_bits = sizeof_DCI1_20MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_20MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_20MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_4A_FDD_t); + } + } + + break; + } + + if (do_common == 1) { +#ifdef DEBUG_DCI_DECODING + printf("[DCI search] subframe %d: doing common search/format0 aggregation 4\n",subframe); +#endif + + if (ue->prach_resources[eNB_id]) + ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; + + // First check common search spaces at aggregation 4 (SI_RNTI, P_RNTI and RA_RNTI format 0/1A), + // and UE_SPEC format0 (PUSCH) too while we're at it + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0) , + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format0, + format1A_size_bits, + format1A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff) || + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + // Now check common search spaces at aggregation 4 (SI_RNTI,P_RNTI and RA_RNTI and C-RNTI format 1C), + // and UE_SPEC format0 (PUSCH) too while we're at it + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1C, + format1C, + format1C, + format1C, + format1C_size_bits, + format1C_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff) || + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + // Now check common search spaces at aggregation 8 (SI_RNTI,P_RNTI and RA_RNTI format 1A), + // and UE_SPEC format0 (PUSCH) too while we're at it + // printf("[DCI search] doing common search/format0 aggregation 3\n"); +#ifdef DEBUG_DCI_DECODING + printf("[DCI search] doing common search/format0 aggregation 8\n"); +#endif + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + P_RNTI, + ra_rnti, + 3, + format1A, + format1A, + format1A, + format0, + format1A_size_bits, + format1A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + // Now check common search spaces at aggregation 8 (SI_RNTI and RA_RNTI and C-RNTI format 1C), + // and UE_SPEC format0 (PUSCH) too while we're at it + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1C, + format1C, + format1C, + format1C, + format1C_size_bits, + format1C_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //#endif + + } + + if (ue->UE_mode[eNB_id] <= PRACH) + return(dci_cnt); + + if (ue->prach_resources[eNB_id]) + ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; + + // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 + // printf("[DCI search] Format 0/1A aggregation 8\n"); + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + //printf("[DCI search] Format 0 aggregation 1 dci_cnt %d\n",dci_cnt); + + if (dci_cnt == 0) + { + // Now check UE_SPEC format 0 search spaces at aggregation 4 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + + //printf("[DCI search] Format 0 aggregation 2 dci_cnt %d\n",dci_cnt); + } + + if (dci_cnt == 0) + { + // Now check UE_SPEC format 0 search spaces at aggregation 2 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + //printf("[DCI search] Format 0 aggregation 4 dci_cnt %d\n",dci_cnt); + } + + if (dci_cnt == 0) + { + // Now check UE_SPEC format 0 search spaces at aggregation 1 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + //printf("[DCI search] Format 0 aggregation 8 dci_cnt %d\n",dci_cnt); + + } + // These are for CRNTI based on transmission mode + if ((tmode < 3) || (tmode == 7)) { + // Now check UE_SPEC format 1 search spaces at aggregation 1 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 1 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff) || + (format_c_found==1)) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1 search spaces at aggregation 2 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 2 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff)|| + (format_c_found==1)) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1 search spaces at aggregation 4 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 4 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + // Now check UE_SPEC format 1 search spaces at aggregation 8 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 8 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#endif //ALL_AGGREGATION + } else if (tmode == 3) { + + + // LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 1 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); + // Now check UE_SPEC format 2A_2A search spaces at aggregation 1 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + LOG_D(PHY," format 2A_2A search CCEmap0 %x, format0_found %d, format_c_found %d \n", CCEmap0, format0_found, format_c_found); + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2 search spaces at aggregation 2 + LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 2 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2_2A search spaces at aggregation 4 + // LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 4 \n"); + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + // Now check UE_SPEC format 2_2A search spaces at aggregation 8 + LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 8 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //#endif + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + } else if (tmode == 4) { + + // Now check UE_SPEC format 2_2A search spaces at aggregation 1 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2 search spaces at aggregation 2 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2_2A search spaces at aggregation 4 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + // Now check UE_SPEC format 2_2A search spaces at aggregation 8 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //#endif + } else if ((tmode==5) || (tmode==6)) { // This is MU-MIMO + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 1 +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY," MU-MIMO check UE_SPEC format 1E_2A_M10PRB\n"); +#endif + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 2 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 4 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces at aggregation 8 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#endif //ALL_AGGREGATION + + } + + return(dci_cnt); +} diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c similarity index 77% rename from openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c index 4020056e6f68043a591f4792c287202e49a76ab0..30f7733be24ad0459eacc25df2d2e0a385a6bb1e 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c @@ -31,11 +31,12 @@ */ //#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/extern.h" -#include "SCHED/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "PHY/defs_UE.h" +#include "PHY/CODING/coding_extern.h" +#include "SCHED/sched_common_extern.h" +#include "SIMULATION/TOOLS/sim.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" //#define DEBUG_DLSCH_DECODING //#define UE_DEBUG_TRACE 1 @@ -746,3 +747,183 @@ decoder_if_t tc; return(ret); } +int dlsch_encoding_SIC(PHY_VARS_UE *ue, + unsigned char *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *i_stats) +{ + + unsigned int G; + unsigned int crc=1; + unsigned short iind; + + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + unsigned char harq_pid = ue->dlsch[subframe&2][0][0]->rnti; + unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; + unsigned int A; + unsigned char mod_order; + unsigned int Kr=0,Kr_bytes,r,r_offset=0; + // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; + uint8_t beamforming_mode=0; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); + + A = dlsch->harq_processes[harq_pid]->TBS; //6228 + // printf("Encoder: A: %d\n",A); + mod_order = dlsch->harq_processes[harq_pid]->Qm; + + if(dlsch->harq_processes[harq_pid]->mimo_mode == TM7) + beamforming_mode = 7; + else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM8) + beamforming_mode = 8; + else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM9_10) + beamforming_mode = 9; + G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe,beamforming_mode); + + + // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet + if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet +#ifdef DEBUG_DLSCH_CODING + printf("SIC encoding thinks this is a new packet \n"); +#endif + /* + int i; + printf("dlsch (tx): \n"); + for (i=0;i<(A>>3);i++) + printf("%02x.",a[i]); + printf("\n"); + */ + // Add 24-bit crc (polynomial A) to payload + crc = crc24a(a, + A)>>8; + a[A>>3] = ((uint8_t*)&crc)[2]; + a[1+(A>>3)] = ((uint8_t*)&crc)[1]; + a[2+(A>>3)] = ((uint8_t*)&crc)[0]; + // printf("CRC %x (A %d)\n",crc,A); + + dlsch->harq_processes[harq_pid]->B = A+24; + // dlsch->harq_processes[harq_pid]->b = a; + memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); + + if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, + dlsch->harq_processes[harq_pid]->c, + dlsch->harq_processes[harq_pid]->B, + &dlsch->harq_processes[harq_pid]->C, + &dlsch->harq_processes[harq_pid]->Cplus, + &dlsch->harq_processes[harq_pid]->Cminus, + &dlsch->harq_processes[harq_pid]->Kplus, + &dlsch->harq_processes[harq_pid]->Kminus, + &dlsch->harq_processes[harq_pid]->F)<0) + return(-1); + + for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { + + if (r<dlsch->harq_processes[harq_pid]->Cminus) + Kr = dlsch->harq_processes[harq_pid]->Kminus; + else + Kr = dlsch->harq_processes[harq_pid]->Kplus; + + Kr_bytes = Kr>>3; + + // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) + if (Kr_bytes<=64) + iind = (Kr_bytes-5); + else if (Kr_bytes <=128) + iind = 59 + ((Kr_bytes-64)>>1); + else if (Kr_bytes <= 256) + iind = 91 + ((Kr_bytes-128)>>2); + else if (Kr_bytes <= 768) + iind = 123 + ((Kr_bytes-256)>>3); + else { + printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); + return(-1); + } + + +#ifdef DEBUG_DLSCH_CODING + printf("Generating Code Segment %d (%d bits)\n",r,Kr); + // generate codewords + + printf("bits_per_codeword (Kr)= %d, A %d\n",Kr,A); + printf("N_RB = %d\n",nb_rb); + printf("Ncp %d\n",frame_parms->Ncp); + printf("mod_order %d\n",mod_order); +#endif + + +#ifdef DEBUG_DLSCH_CODING + printf("Encoding ... iind %d f1 %d, f2 %d\n",iind,f1f2mat_old[iind*2],f1f2mat_old[(iind*2)+1]); +#endif + start_meas(te_stats); + encoder(dlsch->harq_processes[harq_pid]->c[r], + Kr>>3, + &dlsch->harq_processes[harq_pid]->d[r][96], + (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, + f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) + f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) + ); + stop_meas(te_stats); +#ifdef DEBUG_DLSCH_CODING + + if (r==0) + write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[r][96],(3*8*Kr_bytes)+12,1,4); + +#endif + start_meas(i_stats); + dlsch->harq_processes[harq_pid]->RTC[r] = + sub_block_interleaving_turbo(4+(Kr_bytes*8), + &dlsch->harq_processes[harq_pid]->d[r][96], + dlsch->harq_processes[harq_pid]->w[r]); + stop_meas(i_stats); + } + + } + + // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the + // outputs for each code segment, see Section 5.1.5 p.20 + + for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { +#ifdef DEBUG_DLSCH_CODING + printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", + r, + G, + Kr*3, + mod_order,nb_rb); +#endif + + start_meas(rm_stats); +#ifdef DEBUG_DLSCH_CODING + printf("rvidx in SIC encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx); +#endif + r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], + G, //G + dlsch->harq_processes[harq_pid]->w[r], + dlsch->harq_processes[harq_pid]->e+r_offset, + dlsch->harq_processes[harq_pid]->C, // C + dlsch->Nsoft, // Nsoft, + dlsch->Mdlharq, + dlsch->Kmimo, + dlsch->harq_processes[harq_pid]->rvidx, + dlsch->harq_processes[harq_pid]->Qm, + dlsch->harq_processes[harq_pid]->Nl, + r, + nb_rb); + // m); // r + stop_meas(rm_stats); +#ifdef DEBUG_DLSCH_CODING + + if (r==dlsch->harq_processes[harq_pid]->C-1) + write_output("enc_output.m","enc",dlsch->harq_processes[harq_pid]->e,r_offset,1,4); + +#endif + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); + + return(0); +} diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index a104633a640ab61da74f3655821336343bcff652..665d5cead04d59a18aaebce0701066b9f1861600 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -29,11 +29,11 @@ * \note * \warning */ -//#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "transport_ue.h" +#include "transport_proto_ue.h" #include "PHY/sse_intrin.h" #include "T.h" diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c index 7682045ae1307ca6a10ee83ef071091f7e28528d..525c8db676b1e60f76e751fee197ff56352e18c1 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c @@ -30,11 +30,12 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/TOOLS/defs.h" -#include "PHY/extern.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/TOOLS/tools_defs.h" +#include "PHY/phy_extern_ue.h" +#include "transport_ue.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" +#include "transport_proto_ue.h" #include "PHY/sse_intrin.h" //#define DEBUG_LLR_SIC diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c index 588adfbc55c65f736444797013a08ab37ade4a65..81cd18c954f647ceb9bd58c50a828fdf94a35b14 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c @@ -30,11 +30,10 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/TOOLS/defs.h" -#include "PHY/extern.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/TOOLS/tools_defs.h" +#include "PHY/phy_extern_ue.h" +#include "transport_ue.h" #include "PHY/sse_intrin.h" int16_t ones256[16] __attribute__ ((aligned(32))) = {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff}; diff --git a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c similarity index 98% rename from openair1/PHY/LTE_TRANSPORT/drs_modulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c index a0bde219b57706e59b5d5746f8408bc1307f46be..96ff82ba162d2cd6278c54a77a4129a65f7c186a 100644 --- a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c @@ -29,9 +29,11 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "PHY/sse_intrin.h" +#include "transport_proto_ue.h" + //#define DEBUG_DRS int generate_drs_pusch(PHY_VARS_UE *ue, diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c similarity index 98% rename from openair1/PHY/LTE_TRANSPORT/initial_sync.c rename to openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c index 918696968b373ce1830f4abe081fa01505e4e7ae..b1d5b9b70e3b50dc3ca03ddbbdeddaff6d629b1e 100644 --- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c @@ -30,18 +30,20 @@ * \warning */ #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "defs.h" -#include "extern.h" - - +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "transport_proto_ue.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "openair2/LAYER2/MAC/mac_proto.h" #include "common_lib.h" +#include "PHY/INIT/phy_init.h" + extern openair0_config_t openair0_cfg[]; -#define DEBUG_INITIAL_SYNCH +//#define DEBUG_INITIAL_SYNCH int pbch_detection(PHY_VARS_UE *ue, runmode_t mode) { diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pbch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pbch_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..a6acec9ca3762499a8c7fbed3032f253c3f1a7cf --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pbch_ue.c @@ -0,0 +1,632 @@ +/* + * 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/LTE_TRANSPORT/pbch.c +* \brief Top-level routines for generating and decoding the PBCH/BCH physical/transport channel V8.6 2009-03 +* \author R. Knopp, F. Kaltenberger +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr,florian.kaltenberger.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/CODING/lte_interleaver_inline.h" +#include "transport_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/sse_intrin.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +//#define DEBUG_PBCH 1 +//#define DEBUG_PBCH_ENCODING +//#define INTERFERENCE_MITIGATION 1 + + +#define PBCH_A 24 + +uint16_t pbch_extract(int **rxdataF, + int **dl_ch_estimates, + int **rxdataF_ext, + int **dl_ch_estimates_ext, + uint32_t symbol, + uint32_t high_speed_flag, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + + uint16_t rb,nb_rb=6; + uint8_t i,j,aarx,aatx; + int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; + + uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; + uint32_t symbol_mod = symbol % nsymb; + + int rx_offset = frame_parms->ofdm_symbol_size-3*12; + int ch_offset = frame_parms->N_RB_DL*6-3*12; + int nushiftmod3 = frame_parms->nushift%3; + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + /* + printf("extract_rbs (nushift %d): symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",frame_parms->nushift,symbol_mod, + (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, + LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); + */ + + rxF = &rxdataF[aarx][(rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; + rxF_ext = &rxdataF_ext[aarx][symbol_mod*(6*12)]; + + for (rb=0; rb<nb_rb; rb++) { + // skip DC carrier + if (rb==3) { + rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; + } + + if ((symbol_mod==0) || (symbol_mod==1)) { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j++]=rxF[i]; + } + } + + rxF+=12; + rxF_ext+=8; + } else { + for (i=0; i<12; i++) { + rxF_ext[i]=rxF[i]; + } + + rxF+=12; + rxF_ext+=12; + } + } + + for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { + if (high_speed_flag == 1) + dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset+(symbol*(frame_parms->ofdm_symbol_size))]; + else + dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset]; + + dl_ch0_ext = &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*(6*12)]; + + for (rb=0; rb<nb_rb; rb++) { + // skip DC carrier + // if (rb==3) dl_ch0++; + if (symbol_mod>1) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int)); + dl_ch0+=12; + dl_ch0_ext+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + // printf("PBCH extract i %d j %d => (%d,%d)\n",i,j,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + dl_ch0_ext[j++]=dl_ch0[i]; + } + } + + dl_ch0+=12; + dl_ch0_ext+=8; + } + } + } //tx antenna loop + + } + + return(0); +} + +//__m128i avg128; + +//compute average channel_level on each (TX,RX) antenna pair +int pbch_channel_level(int **dl_ch_estimates_ext, + LTE_DL_FRAME_PARMS *frame_parms, + uint32_t symbol) +{ + + int16_t rb, nb_rb=6; + uint8_t aatx,aarx; + +#if defined(__x86_64__) || defined(__i386__) + __m128i avg128; + __m128i *dl_ch128; +#elif defined(__arm__) + int32x4_t avg128; + int16x8_t *dl_ch128; +#endif + int avg1=0,avg2=0; + + uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; + uint32_t symbol_mod = symbol % nsymb; + + for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + //clear average level + +#if defined(__x86_64__) || defined(__i386__) + avg128 = _mm_setzero_si128(); + dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; +#elif defined(__arm__) + avg128 = vdupq_n_s32(0); + dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; + +#endif + for (rb=0; rb<nb_rb; rb++) { +#if defined(__x86_64__) || defined(__i386__) + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); +#elif defined(__arm__) +// to be filled in +#endif + dl_ch128+=3; + /* + if (rb==0) { + print_shorts("dl_ch128",&dl_ch128[0]); + print_shorts("dl_ch128",&dl_ch128[1]); + print_shorts("dl_ch128",&dl_ch128[2]); + } + */ + } + + avg1 = (((int*)&avg128)[0] + + ((int*)&avg128)[1] + + ((int*)&avg128)[2] + + ((int*)&avg128)[3])/(nb_rb*12); + + if (avg1>avg2) + avg2 = avg1; + + //msg("Channel level : %d, %d\n",avg1, avg2); + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + return(avg2); + +} + +#if defined(__x86_64__) || defined(__i386__) +__m128i mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; +#elif defined(__arm__) +int16x8_t mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; +#endif +void pbch_channel_compensation(int **rxdataF_ext, + int **dl_ch_estimates_ext, + int **rxdataF_comp, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t symbol, + uint8_t output_shift) +{ + + uint16_t rb,nb_rb=6; + uint8_t aatx,aarx,symbol_mod; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; +#elif defined(__arm__) + +#endif + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol_mod*6*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol_mod*6*12]; + +#elif defined(__arm__) +// to be filled in +#endif + + for (rb=0; rb<nb_rb; rb++) { + //printf("rb %d\n",rb); +#if defined(__x86_64__) || defined(__i386__) + // multiply by conjugated channel + mmtmpP0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpP0); + // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) + mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpP1); + mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[0]); + // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); + // print_ints("re(shift)",&mmtmpP0); + mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); + // print_ints("im(shift)",&mmtmpP1); + mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); + mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); + // print_ints("c0",&mmtmpP2); + // print_ints("c1",&mmtmpP3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpP2,mmtmpP3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",dl_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpP0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); + // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) + mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); + mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[1]); + // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); + mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); + mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); + mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpP2,mmtmpP3); + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",dl_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + + if (symbol_mod>1) { + // multiply by conjugated channel + mmtmpP0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); + // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) + mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); + mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[2]); + // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); + mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); + mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); + mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); + rxdataF_comp128[2] = _mm_packs_epi32(mmtmpP2,mmtmpP3); + // print_shorts("rx:",rxdataF128+2); + // print_shorts("ch:",dl_ch128+2); + // print_shorts("pack:",rxdataF_comp128+2); + + dl_ch128+=3; + rxdataF128+=3; + rxdataF_comp128+=3; + } else { + dl_ch128+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + } +#elif defined(__arm__) +// to be filled in +#endif + } + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void pbch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + uint8_t symbol) +{ + + uint8_t aatx, symbol_mod; + int i, nb_rb=6; +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; +#endif + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + if (frame_parms->nb_antennas_rx>1) { + for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; + +#endif + // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) + for (i=0; i<nb_rb*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); + +#endif + } + } + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void pbch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + int8_t* llr, + uint32_t length, + uint8_t frame_mod4) +{ + int i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in first call to lte_gold_generic + x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 + // msg("pbch_unscrambling: Nid_cell = %d\n",x2); + + for (i=0; i<length; i++) { + if (i%32==0) { + s = lte_gold_generic(&x1, &x2, reset); + // printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + // take the quarter of the PBCH that corresponds to this frame + if ((i>=(frame_mod4*(length>>2))) && (i<((1+frame_mod4)*(length>>2)))) { + + if (((s>>(i%32))&1)==0) + llr[i] = -llr[i]; + } + } +} + +void pbch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + uint8_t symbol) +{ + + + int16_t *rxF0,*rxF1; + // __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b; + uint8_t rb,re,symbol_mod; + int jj; + + // printf("Doing alamouti\n"); + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + jj = (symbol_mod*6*12); + + rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y + rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y + + for (rb=0; rb<6; rb++) { + + for (re=0; re<12; re+=2) { + + // Alamouti RX combining + + rxF0[0] = rxF0[0] + rxF1[2]; + rxF0[1] = rxF0[1] - rxF1[3]; + + rxF0[2] = rxF0[2] - rxF1[0]; + rxF0[3] = rxF0[3] + rxF1[1]; + + rxF0+=4; + rxF1+=4; + } + + } + +} + +void pbch_quantize(int8_t *pbch_llr8, + int16_t *pbch_llr, + uint16_t len) +{ + + uint16_t i; + + for (i=0; i<len; i++) { + if (pbch_llr[i]>7) + pbch_llr8[i]=7; + else if (pbch_llr[i]<-8) + pbch_llr8[i]=-8; + else + pbch_llr8[i] = (char)(pbch_llr[i]); + + } +} + +static unsigned char dummy_w_rx[3*3*(16+PBCH_A)]; +static int8_t pbch_w_rx[3*3*(16+PBCH_A)],pbch_d_rx[96+(3*(16+PBCH_A))]; + + +uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars, + LTE_UE_PBCH *lte_ue_pbch_vars, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t eNB_id, + MIMO_mode_t mimo_mode, + uint32_t high_speed_flag, + uint8_t frame_mod4) +{ + + uint8_t log2_maxh;//,aatx,aarx; + int max_h=0; + + int symbol,i; + uint32_t nsymb = (frame_parms->Ncp==0) ? 14:12; + uint16_t pbch_E; + uint8_t pbch_a[8]; + uint8_t RCC; + + int8_t *pbch_e_rx; + uint8_t *decoded_output = lte_ue_pbch_vars->decoded_output; + uint16_t crc; + + + // pbch_D = 16+PBCH_A; + + pbch_E = (frame_parms->Ncp==0) ? 1920 : 1728; //RE/RB * #RB * bits/RB (QPSK) + pbch_e_rx = <e_ue_pbch_vars->llr[frame_mod4*(pbch_E>>2)]; +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode); +#endif + + // clear LLR buffer + memset(lte_ue_pbch_vars->llr,0,pbch_E); + + for (symbol=(nsymb>>1); symbol<(nsymb>>1)+4; symbol++) { + +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] starting extract\n"); +#endif + pbch_extract(lte_ue_common_vars->common_vars_rx_data_per_thread[0].rxdataF, + lte_ue_common_vars->common_vars_rx_data_per_thread[0].dl_ch_estimates[eNB_id], + lte_ue_pbch_vars->rxdataF_ext, + lte_ue_pbch_vars->dl_ch_estimates_ext, + symbol, + high_speed_flag, + frame_parms); +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PHY] PBCH Symbol %d\n",symbol); + LOG_D(PHY,"[PHY] PBCH starting channel_level\n"); +#endif + + max_h = pbch_channel_level(lte_ue_pbch_vars->dl_ch_estimates_ext, + frame_parms, + symbol); + log2_maxh = 3+(log2_approx(max_h)/2); + +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",log2_maxh,max_h); +#endif + + pbch_channel_compensation(lte_ue_pbch_vars->rxdataF_ext, + lte_ue_pbch_vars->dl_ch_estimates_ext, + lte_ue_pbch_vars->rxdataF_comp, + frame_parms, + symbol, + log2_maxh); // log2_maxh+I0_shift + + if (frame_parms->nb_antennas_rx > 1) + pbch_detection_mrc(frame_parms, + lte_ue_pbch_vars->rxdataF_comp, + symbol); + + + if (mimo_mode == ALAMOUTI) { + pbch_alamouti(frame_parms,lte_ue_pbch_vars->rxdataF_comp,symbol); + } else if (mimo_mode != SISO) { + LOG_D(PHY,"[PBCH][RX] Unsupported MIMO mode\n"); + return(-1); + } + + if (symbol>(nsymb>>1)+1) { + pbch_quantize(pbch_e_rx, + (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), + 144); + + pbch_e_rx+=144; + } else { + pbch_quantize(pbch_e_rx, + (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), + 96); + + pbch_e_rx+=96; + } + + + } + + pbch_e_rx = lte_ue_pbch_vars->llr; + + + + //un-scrambling +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] doing unscrambling\n"); +#endif + + + pbch_unscrambling(frame_parms, + pbch_e_rx, + pbch_E, + frame_mod4); + + + + //un-rate matching +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] doing un-rate-matching\n"); +#endif + + + memset(dummy_w_rx,0,3*3*(16+PBCH_A)); + RCC = generate_dummy_w_cc(16+PBCH_A, + dummy_w_rx); + + + lte_rate_matching_cc_rx(RCC,pbch_E,pbch_w_rx,dummy_w_rx,pbch_e_rx); + + sub_block_deinterleaving_cc((unsigned int)(PBCH_A+16), + &pbch_d_rx[96], + &pbch_w_rx[0]); + + memset(pbch_a,0,((16+PBCH_A)>>3)); + + + + + phy_viterbi_lte_sse2(pbch_d_rx+96,pbch_a,16+PBCH_A); + + // Fix byte endian of PBCH (bit 23 goes in first) + for (i=0; i<(PBCH_A>>3); i++) + decoded_output[(PBCH_A>>3)-i-1] = pbch_a[i]; + +#ifdef DEBUG_PBCH + + for (i=0; i<(PBCH_A>>3); i++) + LOG_I(PHY,"[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); + +#endif //DEBUG_PBCH + +#ifdef DEBUG_PBCH + LOG_I(PHY,"PBCH CRC %x : %x\n", + crc16(pbch_a,PBCH_A), + ((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); +#endif + + crc = (crc16(pbch_a,PBCH_A)>>16) ^ + (((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); + + if (crc == 0x0000) + return(1); + else if (crc == 0xffff) + return(2); + else if (crc == 0x5555) + return(4); + else + return(-1); + + +} diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..82bb0a2659ed9ff4e4ea8a09fc4d068f2c516092 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c @@ -0,0 +1,162 @@ +/* + * 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/LTE_TRANSPORT/pcfich.c +* \brief Top-level routines for generating and decoding the PCFICH/CFI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +//#define DEBUG_PCFICH + +extern uint8_t pcfich_b[4][32]; + + + + +void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + int16_t *d) +{ + + uint32_t i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in lte_gold_generic + x2 = ((((2*frame_parms->Nid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 + + for (i=0; i<32; i++) { + if ((i&0x1f)==0) { + s = lte_gold_generic(&x1, &x2, reset); + //printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + if (((s>>(i&0x1f))&1) == 1) + d[i]=-d[i]; + + } +} + +uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + LTE_UE_PDCCH *lte_ue_pdcch_vars, + MIMO_mode_t mimo_mode) +{ + + uint8_t pcfich_quad; + uint8_t i,j; + uint16_t reg_offset; + + int32_t **rxdataF_comp = lte_ue_pdcch_vars->rxdataF_comp; + int16_t pcfich_d[32],*pcfich_d_ptr; + int32_t metric,old_metric=-16384; + uint8_t num_pdcch_symbols=3; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + // demapping + // loop over 4 quadruplets and lookup REGs + // m=0; + pcfich_d_ptr = pcfich_d; + + for (pcfich_quad=0; pcfich_quad<4; pcfich_quad++) { + reg_offset = (pcfich_reg[pcfich_quad]*4); + + for (i=0; i<4; i++) { + + pcfich_d_ptr[0] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0]; // RE component + pcfich_d_ptr[1] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1]; // IM component +#ifdef DEBUG_PCFICH + printf("rx_pcfich: quad %d, i %d, offset %d => (%d,%d) => pcfich_d_ptr[0] %d \n",pcfich_quad,i,reg_offset+i, + ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0], + ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1], + pcfich_d_ptr[0]); +#endif + pcfich_d_ptr+=2; + } + + /* + } + else { // ALAMOUTI + for (i=0;i<4;i+=2) { + pcfich_d_ptr[0] = 0; + pcfich_d_ptr[1] = 0; + pcfich_d_ptr[2] = 0; + pcfich_d_ptr[3] = 0; + for (j=0;j<frame_parms->nb_antennas_rx;j++) { + + pcfich_d_ptr[0] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[0]+ + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[0]); // RE component + pcfich_d_ptr[1] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[1] - + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[1]);// IM component + + pcfich_d_ptr[2] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[0]- + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[0]); // RE component + pcfich_d_ptr[3] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[1] + + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[1]);// IM component + + + } + + pcfich_d_ptr+=4; + + } + */ + } + + // pcfhich unscrambling + + pcfich_unscrambling(frame_parms,subframe,pcfich_d); + + // pcfich detection + + for (i=0; i<3; i++) { + metric = 0; + + for (j=0; j<32; j++) { + // printf("pcfich_b[%d][%d] %d => pcfich_d[%d] %d\n",i,j,pcfich_b[i][j],j,pcfich_d[j]); + metric += (int32_t)(((pcfich_b[i][j]==0) ? (pcfich_d[j]) : (-pcfich_d[j]))); + } + +#ifdef DEBUG_PCFICH + printf("metric %d : %d\n",i,metric); +#endif + + if (metric > old_metric) { + num_pdcch_symbols = 1+i; + old_metric = metric; + } + } + +#ifdef DEBUG_PCFICH + printf("[PHY] PCFICH detected for %d PDCCH symbols\n",num_pdcch_symbols); +#endif + return(num_pdcch_symbols); +} diff --git a/openair1/PHY/LTE_TRANSPORT/pch.c b/openair1/PHY/LTE_UE_TRANSPORT/pch_ue.c similarity index 97% rename from openair1/PHY/LTE_TRANSPORT/pch.c rename to openair1/PHY/LTE_UE_TRANSPORT/pch_ue.c index 600c5215bdd5c4bbde741ff86b4dad7196620633..aed3ddabc15b6279393c7405961edde780c51cd2 100644 --- a/openair1/PHY/LTE_TRANSPORT/pch.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/pch_ue.c @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "assertions.h" const unsigned int Ttab[4] = {32,64,128,256}; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..669e0937c6c57bc559d4e2f87c546fd550419ac5 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c @@ -0,0 +1,489 @@ +/* + * 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/LTE_TRANSPORT/phich_ue.c +* \brief Top-level routines for decoding the PHICH/HI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ + +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "transport_ue.h" +#include "transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +#include "LAYER2/MAC/mac.h" + +#include "T.h" + +//#define DEBUG_PHICH 1 + +//extern unsigned short pcfich_reg[4]; +//extern unsigned char pcfich_first_reg_idx; + +//unsigned short phich_reg[MAX_NUM_PHICH_GROUPS][3]; + + +uint8_t rv_table[4] = {0, 2, 3, 1}; + + + + + + +// This routine demodulates the PHICH and updates PUSCH/ULSCH parameters + +void rx_phich(PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, + uint8_t subframe, + uint8_t eNB_id) +{ + + + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + LTE_UE_PDCCH **pdcch_vars = &ue->pdcch_vars[ue->current_thread_id[subframe]][eNB_id]; + + // uint8_t HI; + uint8_t harq_pid = phich_subframe_to_harq_pid(frame_parms,proc->frame_rx,subframe); + LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + int16_t phich_d[24],*phich_d_ptr,HI16; + // unsigned int i,aa; + int8_t d[24],*dp; + uint16_t reg_offset; + + // scrambling + uint32_t x1, x2, s=0; + uint8_t reset = 1; + int16_t cs[12]; + uint32_t i,i2,i3,phich_quad; + int32_t **rxdataF_comp = pdcch_vars[eNB_id]->rxdataF_comp; + uint8_t Ngroup_PHICH,ngroup_PHICH,nseq_PHICH; + uint8_t NSF_PHICH = 4; + uint8_t pusch_subframe; + + int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; + + // check if we're expecting a PHICH in this subframe + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); + + if (!ulsch) + return; + + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX Status: %d \n",ue->Mod_id,harq_pid,proc->frame_rx,subframe, ulsch->harq_processes[harq_pid]->status); + + if (ulsch->harq_processes[harq_pid]->status == ACTIVE) { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX ACTIVE\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); + Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + if (frame_parms->Ncp == 1) + NSF_PHICH = 2; + + + ngroup_PHICH = (ulsch->harq_processes[harq_pid]->first_rb + + ulsch->harq_processes[harq_pid]->n_DMRS)%Ngroup_PHICH; + + if ((frame_parms->tdd_config == 0) && (frame_parms->frame_type == TDD) ) { + pusch_subframe = phich_subframe2_pusch_subframe(frame_parms,subframe); + + if ((pusch_subframe == 4) || (pusch_subframe == 9)) + ngroup_PHICH += Ngroup_PHICH; + } + + nseq_PHICH = ((ulsch->harq_processes[harq_pid]->first_rb/Ngroup_PHICH) + + ulsch->harq_processes[harq_pid]->n_DMRS)%(2*NSF_PHICH); + } else { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX %s\n", + ue->Mod_id, + harq_pid, + proc->frame_rx, + subframe, + (ulsch->harq_processes[harq_pid]->status==SCH_IDLE? "SCH_IDLE" : + (ulsch->harq_processes[harq_pid]->status==ACTIVE? "ACTIVE" : + (ulsch->harq_processes[harq_pid]->status==CBA_ACTIVE? "CBA_ACTIVE": + (ulsch->harq_processes[harq_pid]->status==DISABLED? "DISABLED" : "UNKNOWN"))))); + + return; + } + + memset(d,0,24*sizeof(int8_t)); + phich_d_ptr = phich_d; + + // x1 is set in lte_gold_generic + x2 = (((subframe+1)*((frame_parms->Nid_cell<<1)+1))<<9) + frame_parms->Nid_cell; + + s = lte_gold_generic(&x1, &x2, reset); + + // compute scrambling sequence + for (i=0; i<12; i++) { + cs[i] = 1-(((s>>(i&0x1f))&1)<<1); + } + + if (frame_parms->Ncp == 0) { // Normal Cyclic Prefix + + + // 12 output symbols (Msymb) + + for (i=0,i2=0,i3=0; i<3; i++,i2+=4,i3+=8) { + switch (nseq_PHICH) { + case 0: // +1 +1 +1 +1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = cs[1+i2]; + d[3+i3] = cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[5+i3] = cs[2+i2]; + d[6+i3] = cs[3+i2]; + d[7+i3] = cs[3+i2]; + break; + + case 1: // +1 -1 +1 -1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = -cs[1+i2]; + d[3+i3] = -cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[5+i3] = cs[2+i2]; + d[6+i3] = -cs[3+i2]; + d[7+i3] = -cs[3+i2]; + break; + + case 2: // +1 +1 -1 -1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = cs[1+i2]; + d[3+i3] = cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[5+i3] = -cs[2+i2]; + d[6+i3] = -cs[3+i2]; + d[7+i3] = -cs[3+i2]; + break; + + case 3: // +1 -1 -1 +1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = -cs[1+i2]; + d[3+i3] = -cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[5+i3] = -cs[2+i2]; + d[6+i3] = cs[3+i2]; + d[7+i3] = cs[3+i2]; + break; + + case 4: // +j +j +j +j + d[i3] = -cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = -cs[1+i2]; + d[3+i3] = cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[5+i3] = cs[2+i2]; + d[6+i3] = -cs[3+i2]; + d[7+i3] = cs[3+i2]; + break; + + case 5: // +j -j +j -j + d[1+i3] = cs[i2]; + d[3+i3] = -cs[1+i2]; + d[5+i3] = cs[2+i2]; + d[7+i3] = -cs[3+i2]; + d[i3] = -cs[i2]; + d[2+i3] = cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[6+i3] = cs[3+i2]; + break; + + case 6: // +j +j -j -j + d[1+i3] = cs[i2]; + d[3+i3] = cs[1+i2]; + d[5+i3] = -cs[2+i2]; + d[7+i3] = -cs[3+i2]; + d[i3] = -cs[i2]; + d[2+i3] = -cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[6+i3] = cs[3+i2]; + break; + + case 7: // +j -j -j +j + d[1+i3] = cs[i2]; + d[3+i3] = -cs[1+i2]; + d[5+i3] = -cs[2+i2]; + d[7+i3] = cs[3+i2]; + d[i3] = -cs[i2]; + d[2+i3] = cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[6+i3] = -cs[3+i2]; + break; + + default: + AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); + } // nseq_PHICH + } + +#ifdef DEBUG_PHICH + LOG_D(PHY,"PHICH =>"); + + for (i=0; i<24; i++) { + LOG_D(PHY,"%2d,",d[i]); + } + + LOG_D(PHY,"\n"); +#endif + // demodulation here + + + } else { // extended prefix + + // 6 output symbols + if ((ngroup_PHICH & 1) == 1) + dp = &d[4]; + else + dp = d; + + switch (nseq_PHICH) { + case 0: // +1 +1 + dp[0] = cs[0]; + dp[2] = cs[1]; + dp[8] = cs[2]; + dp[10] = cs[3]; + dp[16] = cs[4]; + dp[18] = cs[5]; + dp[1] = cs[0]; + dp[3] = cs[1]; + dp[9] = cs[2]; + dp[11] = cs[3]; + dp[17] = cs[4]; + dp[19] = cs[5]; + break; + + case 1: // +1 -1 + dp[0] = cs[0]; + dp[2] = -cs[1]; + dp[8] = cs[2]; + dp[10] = -cs[3]; + dp[16] = cs[4]; + dp[18] = -cs[5]; + dp[1] = cs[0]; + dp[3] = -cs[1]; + dp[9] = cs[2]; + dp[11] = -cs[3]; + dp[17] = cs[4]; + dp[19] = -cs[5]; + break; + + case 2: // +j +j + dp[1] = cs[0]; + dp[3] = cs[1]; + dp[9] = cs[2]; + dp[11] = cs[3]; + dp[17] = cs[4]; + dp[19] = cs[5]; + dp[0] = -cs[0]; + dp[2] = -cs[1]; + dp[8] = -cs[2]; + dp[10] = -cs[3]; + dp[16] = -cs[4]; + dp[18] = -cs[5]; + + break; + + case 3: // +j -j + dp[1] = cs[0]; + dp[3] = -cs[1]; + dp[9] = cs[2]; + dp[11] = -cs[3]; + dp[17] = cs[4]; + dp[19] = -cs[5]; + dp[0] = -cs[0]; + dp[2] = cs[1]; + dp[8] = -cs[2]; + dp[10] = cs[3]; + dp[16] = -cs[4]; + dp[18] = cs[5]; + break; + + default: + AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); + } + } + + HI16 = 0; + + //#ifdef DEBUG_PHICH + + //#endif + /* + for (i=0;i<200;i++) + printf("re %d: %d %d\n",i,((int16_t*)&rxdataF_comp[0][i])[0],((int16_t*)&rxdataF_comp[0][i])[1]); + */ + for (phich_quad=0; phich_quad<3; phich_quad++) { + if (frame_parms->Ncp == 1) + reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4)+ (phich_quad*frame_parms->N_RB_DL*12); + else + reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4); + + // msg("\n[PUSCH 0]PHICH (RX) quad %d (%d)=>",phich_quad,reg_offset); + dp = &d[phich_quad*8];; + + for (i=0; i<8; i++) { + phich_d_ptr[i] = ((int16_t*)&rxdataF_comp[0][reg_offset])[i]; + +#ifdef DEBUG_PHICH + LOG_D(PHY,"%d,",((int16_t*)&rxdataF_comp[0][reg_offset])[i]); +#endif + + HI16 += (phich_d_ptr[i] * dp[i]); + } + } + +#ifdef DEBUG_PHICH + LOG_D(PHY,"\n"); + LOG_D(PHY,"HI16 %d\n",HI16); +#endif + + if (HI16>0) { //NACK + if (ue->ulsch_Msg3_active[eNB_id] == 1) { + LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received NAK (%d) nseq %d, ngroup %d\n", + ue->Mod_id,harq_pid, + proc->frame_rx, + subframe, + HI16, + nseq_PHICH, + ngroup_PHICH); + + ulsch->f_pusch += delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC]; + + LOG_D(PHY,"[PUSCH %d] AbsSubframe %d.%d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", + harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, + delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC], + ulsch->harq_processes[harq_pid]->TPC); + + + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + // ulsch->harq_processes[harq_pid]->Ndi = 0; + ulsch->harq_processes[harq_pid]->round++; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + + if (ulsch->harq_processes[harq_pid]->round>=ue->frame_parms.maxHARQ_Msg3Tx) { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag =0; + ulsch->harq_processes[harq_pid]->status = SCH_IDLE; + // inform MAC that Msg3 transmission has failed + ue->ulsch_Msg3_active[eNB_id] = 0; + } + } else { +#ifdef UE_DEBUG_TRACE + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received NAK (%d) nseq %d, ngroup %d round %d (Mlimit %d)\n", + ue->Mod_id,harq_pid, + proc->frame_rx%1024, + subframe, + HI16, + nseq_PHICH, + ngroup_PHICH, + ulsch->harq_processes[harq_pid]->round, + ulsch->Mlimit); +#endif + + // ulsch->harq_processes[harq_pid]->Ndi = 0; + ulsch->harq_processes[harq_pid]->round++; + + if ( ulsch->harq_processes[harq_pid]->round >= (ulsch->Mlimit - 1) ) + { + // this is last push re transmission + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + + // disable phich decoding since it is the last retransmission + ulsch->harq_processes[harq_pid]->status = SCH_IDLE; + + //ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + //ulsch->harq_processes[harq_pid]->round = 0; + + //LOG_I(PHY,"PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->Mlimit, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + } + else + { + // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + } + } +#if T_TRACER + T(T_UE_PHY_ULSCH_UE_NACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), + T_INT(harq_pid)); +#endif + + } else { //ACK + if (ue->ulsch_Msg3_active[eNB_id] == 1) { + LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", + ue->Mod_id,harq_pid, + proc->frame_rx, + subframe, + HI16, + nseq_PHICH,ngroup_PHICH); + } else { +#ifdef UE_DEBUG_TRACE + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", + ue->Mod_id,harq_pid, + proc->frame_rx%1024, + subframe, HI16, + nseq_PHICH,ngroup_PHICH); +#endif + } + + // LOG_I(PHY,"[HARQ-UL harqId: %d] subframe_scheduling_flag = %d \n",harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag); + + // Incase of adaptive retransmission, PHICH is always decoded as ACK (at least with OAI-eNB) + // Workaround: + // rely only on DCI0 decoding and check if NDI has toggled + // save current harq_processes content in temporary struct + // harqId-8 corresponds to the temporary struct. In total we have 8 harq process(0 ..7) + 1 temporary harq process() + //ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; + + + ulsch->harq_processes[harq_pid]->status = SCH_IDLE; + ulsch->harq_processes[harq_pid]->round = 0; + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + // inform MAC? + ue->ulsch_Msg3_active[eNB_id] = 0; + +#if T_TRACER + T(T_UE_PHY_ULSCH_UE_ACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), + T_INT(harq_pid)); +#endif + + } + +} + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pmch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pmch_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..d944491b6399ead88d0c3d163f22c2e300787376 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pmch_ue.c @@ -0,0 +1,844 @@ +/* + * 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 "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/sse_intrin.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" + +// Mask for identifying subframe for MBMS +#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_SF2 0x40 +#define MBSFN_FDD_SF3 0x20 +#define MBSFN_FDD_SF6 0x10 +#define MBSFN_FDD_SF7 0x08 +#define MBSFN_FDD_SF8 0x04 + + + +void dump_mch(PHY_VARS_UE *ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe) +{ + + unsigned int nsymb_pmch=12; + char fname[32],vname[32]; + int N_RB_DL=ue->frame_parms.N_RB_DL; + + sprintf(fname,"mch_rxF_ext0.m"); + sprintf(vname,"pmch_rxF_ext0"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb_pmch,1,1); + sprintf(fname,"mch_ch_ext00.m"); + sprintf(vname,"pmch_ch_ext00"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb_pmch,1,1); + /* + write_output("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb_pmch,1,1); + write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb_pmch,1,1); + write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb_pmch,1,1); + write_output("dlsch%d_rho.m","dl_rho",pdsch_vars[eNB_id]->rho[0],12*N_RB_DL*nsymb_pmch,1,1); + */ + sprintf(fname,"mch_rxF_comp0.m"); + sprintf(vname,"pmch_rxF_comp0"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb_pmch,1,1); + sprintf(fname,"mch_rxF_llr.m"); + sprintf(vname,"pmch_llr"); + write_output(fname,vname, ue->pdsch_vars_MCH[eNB_id]->llr[0],coded_bits_per_codeword,1,0); + sprintf(fname,"mch_mag1.m"); + sprintf(vname,"pmch_mag1"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_mag0[0],12*N_RB_DL*nsymb_pmch,1,1); + sprintf(fname,"mch_mag2.m"); + sprintf(vname,"pmch_mag2"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_magb0[0],12*N_RB_DL*nsymb_pmch,1,1); + + write_output("mch00_ch0.m","pmch00_ch0", + &(ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][0][0]), + ue->frame_parms.ofdm_symbol_size*12,1,1); + + write_output("rxsig_mch.m","rxs_mch", + &ue->common_vars.rxdata[0][subframe*ue->frame_parms.samples_per_tti], + ue->frame_parms.samples_per_tti,1,1); + + /* + if (PHY_vars_eNB_g) + write_output("txsig_mch.m","txs_mch", + &PHY_vars_eNB_g[0][0]->common_vars.txdata[0][0][subframe*ue->frame_parms.samples_per_tti], + ue->frame_parms.samples_per_tti,1,1);*/ +} + + +void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id) +{ + + LTE_UE_DLSCH_t *dlsch = ue->dlsch_MCH[eNB_id]; + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + + // dlsch->rnti = M_RNTI; + dlsch->harq_processes[0]->mcs = mcs; + dlsch->harq_processes[0]->rvidx = rvidx; + // dlsch->harq_processes[0]->Ndi = ndi; + dlsch->harq_processes[0]->Nl = 1; + dlsch->harq_processes[0]->TBS = TBStable[get_I_TBS(dlsch->harq_processes[0]->mcs)][frame_parms->N_RB_DL-1]; + dlsch->current_harq_pid = 0; + dlsch->harq_processes[0]->nb_rb = frame_parms->N_RB_DL; + + switch(frame_parms->N_RB_DL) { + case 6: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0x3f; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x3f; + break; + + case 25: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0x1ffffff; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x1ffffff; + break; + + case 50: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[1] = 0x3ffff; + dlsch->harq_processes[0]->rb_alloc_odd[1] = 0x3ffff; + break; + + case 100: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[1] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[1] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[2] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[2] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[3] = 0xf; + dlsch->harq_processes[0]->rb_alloc_odd[3] = 0xf; + break; + } +} + + + +void mch_extract_rbs(int **rxdataF, + int **dl_ch_estimates, + int **rxdataF_ext, + int **dl_ch_estimates_ext, + unsigned char symbol, + unsigned char subframe, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + int pilots=0,i,j,offset,aarx; + + // printf("Extracting PMCH: symbol %d\n",symbol); + if ((symbol==2)|| + (symbol==10)) { + pilots = 1; + offset = 1; + } else if (symbol==6) { + pilots = 1; + offset = 0; + } + + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (pilots==1) { + for (i=offset,j=0; i<frame_parms->N_RB_DL*6; i+=2,j++) { + /* printf("MCH with pilots: i %d, j %d => %d,%d\n",i,j, + *(int16_t*)&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], + *(int16_t*)(1+&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)])); + */ + rxdataF_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)]; + rxdataF_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+1+ (symbol*frame_parms->ofdm_symbol_size)]; + dl_ch_estimates_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(symbol*frame_parms->ofdm_symbol_size)]; + dl_ch_estimates_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(frame_parms->N_RB_DL*6)+(symbol*frame_parms->ofdm_symbol_size)]; + } + } else { + + memcpy((void*)&rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], + (void*)&rxdataF[aarx][frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], + frame_parms->N_RB_DL*24); + memcpy((void*)&rxdataF_ext[aarx][(frame_parms->N_RB_DL*6) + symbol*(frame_parms->N_RB_DL*12)], + (void*)&rxdataF[aarx][1 + (symbol*frame_parms->ofdm_symbol_size)], + frame_parms->N_RB_DL*24); + memcpy((void*)&dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], + (void*)&dl_ch_estimates[aarx][(symbol*frame_parms->ofdm_symbol_size)], + frame_parms->N_RB_DL*48); + + } + + } + + + +} + +void mch_channel_level(int **dl_ch_estimates_ext, + LTE_DL_FRAME_PARMS *frame_parms, + int *avg, + uint8_t symbol, + unsigned short nb_rb) +{ + + int i,aarx,nre; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,avg128; +#elif defined(__arm__) + int32x4_t avg128; +#endif + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { +#if defined(__x86_64__) || defined(__i386__) + //clear average level + avg128 = _mm_setzero_si128(); + // 5 is always a symbol with no pilots for both normal and extended prefix + + dl_ch128=(__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + + +#endif + if ((symbol == 2) || (symbol == 6) || (symbol == 10)) + nre = (frame_parms->N_RB_DL*6); + else + nre = (frame_parms->N_RB_DL*12); + + for (i=0; i<(nre>>2); i++) { +#if defined(__x86_64__) || defined(__i386__) + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); +#elif defined(__arm__) + +#endif + } + + avg[aarx] = (((int*)&avg128)[0] + + ((int*)&avg128)[1] + + ((int*)&avg128)[2] + + ((int*)&avg128)[3])/nre; + + // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void mch_channel_compensation(int **rxdataF_ext, + int **dl_ch_estimates_ext, + int **dl_ch_mag, + int **dl_ch_magb, + int **rxdataF_comp, + LTE_DL_FRAME_PARMS *frame_parms, + unsigned char symbol, + unsigned char mod_order, + unsigned char output_shift) +{ + + int aarx,nre,i; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; +#elif defined(__arm__) + +#endif + if ((symbol == 2) || (symbol == 6) || (symbol == 10)) + nre = frame_parms->N_RB_DL*6; + else + nre = frame_parms->N_RB_DL*12; + +#if defined(__x86_64__) || defined(__i386__) + if (mod_order == 4) { + QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) + QAM_amp128b = _mm_setzero_si128(); + } else if (mod_order == 6) { + QAM_amp128 = _mm_set1_epi16(QAM64_n1); // + QAM_amp128b = _mm_set1_epi16(QAM64_n2); + } +#elif defined(__arm__) + +#endif + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128 = (__m128i *)&dl_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128b = (__m128i *)&dl_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + +#endif + + for (i=0; i<(nre>>2); i+=2) { + if (mod_order>2) { + // get channel amplitude if not QPSK +#if defined(__x86_64__) || defined(__i386__) + + mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128[0]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + + mmtmpD1 = _mm_madd_epi16(dl_ch128[1],dl_ch128[1]); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + + mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1); + + // store channel magnitude here in a new field of dlsch + + dl_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0); + dl_ch_mag128b[0] = dl_ch_mag128[0]; + dl_ch_mag128[0] = _mm_mulhi_epi16(dl_ch_mag128[0],QAM_amp128); + dl_ch_mag128[0] = _mm_slli_epi16(dl_ch_mag128[0],1); + + dl_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0); + dl_ch_mag128b[1] = dl_ch_mag128[1]; + dl_ch_mag128[1] = _mm_mulhi_epi16(dl_ch_mag128[1],QAM_amp128); + dl_ch_mag128[1] = _mm_slli_epi16(dl_ch_mag128[1],1); + + + dl_ch_mag128b[0] = _mm_mulhi_epi16(dl_ch_mag128b[0],QAM_amp128b); + dl_ch_mag128b[0] = _mm_slli_epi16(dl_ch_mag128b[0],1); + + + dl_ch_mag128b[1] = _mm_mulhi_epi16(dl_ch_mag128b[1],QAM_amp128b); + dl_ch_mag128b[1] = _mm_slli_epi16(dl_ch_mag128b[1],1); + +#elif defined(__arm__) + +#endif + } + +#if defined(__x86_64__) || defined(__i386__) + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpD0); + + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpD1); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + // print_ints("re(shift)",&mmtmpD0); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + // print_ints("im(shift)",&mmtmpD1); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + // print_ints("c0",&mmtmpD2); + // print_ints("c1",&mmtmpD3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",dl_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",dl_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + + dl_ch128+=2; + dl_ch_mag128+=2; + dl_ch_mag128b+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + +#elif defined(__arm__) + +#endif + } + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + +} + +void mch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + int **dl_ch_mag, + int **dl_ch_magb, + unsigned char symbol) +{ + + + int i; +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; +#endif + if (frame_parms->nb_antennas_rx>1) { + +#if defined(__x86_64__) || defined(__i386__) + + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; + +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0 = (int16x8_t *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1 = (int16x8_t *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0b = (int16x8_t *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1b = (int16x8_t *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; + +#endif + // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); + dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1)); + dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); + dl_ch_mag128_0[i] = vhaddq_s16(dl_ch_mag128_0[i],dl_ch_mag128_1[i]); + dl_ch_mag128_0b[i] = vhaddq_s16(dl_ch_mag128_0b[i],dl_ch_mag128_1b[i]); +#endif + } + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +int mch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + short *dlsch_llr, + unsigned char symbol, + short **llr32p) +{ + + uint32_t *rxF = (uint32_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + uint32_t *llr32; + int i,len; + + if (symbol==2) { + llr32 = (uint32_t*)dlsch_llr; + } else { + llr32 = (uint32_t*)(*llr32p); + } + + AssertFatal(llr32!=NULL,"dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32); + + + if ((symbol==2) || (symbol==6) || (symbol==10)) { + len = frame_parms->N_RB_DL*6; + } else { + len = frame_parms->N_RB_DL*12; + } + + // printf("dlsch_qpsk_llr: symbol %d,len %d,pbch_pss_sss_adjust %d\n",symbol,len,pbch_pss_sss_adjust); + for (i=0; i<len; i++) { + *llr32 = *rxF; + rxF++; + llr32++; + } + + *llr32p = (short *)llr32; + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + + return(0); +} + +//---------------------------------------------------------------------------------------------- +// 16-QAM +//---------------------------------------------------------------------------------------------- + +void mch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + short *dlsch_llr, + int **dl_ch_mag, + unsigned char symbol, + int16_t **llr32p) +{ + +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + __m128i *ch_mag; + __m128i llr128[2],xmm0; + uint32_t *llr32; +#elif defined(__arm__) + int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + int16x8_t *ch_mag; + int16x8_t llr128[2],xmm0; + int16_t *llr16; +#endif + int i,len; + unsigned char len_mod4=0; + +#if defined(__x86_64__) || defined(__i386__) + if (symbol==2) { + llr32 = (uint32_t*)dlsch_llr; + } else { + llr32 = (uint32_t*)*llr32p; + } +#elif defined(__arm__) + if (symbol==2) { + llr16 = (int16_t*)dlsch_llr; + } else { + llr16 = (int16_t*)*llr32p; + } +#endif +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; +#endif + if ((symbol==2) || (symbol==6) || (symbol==10)) { + len = frame_parms->N_RB_DL*6; + } else { + len = frame_parms->N_RB_DL*12; + } + + + + // update output pointer according to number of REs in this symbol (<<2 because 4 bits per RE) + if (symbol==2) + *llr32p = dlsch_llr + (len<<2); + else + *llr32p += (len<<2); + + len_mod4 = len&3; + len>>=2; // length in quad words (4 REs) + len+=(len_mod4==0 ? 0 : 1); + + for (i=0; i<len; i++) { + +#if defined(__x86_64__) || defined(__i386__) + xmm0 = _mm_abs_epi16(rxF[i]); + xmm0 = _mm_subs_epi16(ch_mag[i],xmm0); + + // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 + llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0); + llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0); + llr32[0] = ((uint32_t *)&llr128[0])[0]; + llr32[1] = ((uint32_t *)&llr128[0])[1]; + llr32[2] = ((uint32_t *)&llr128[0])[2]; + llr32[3] = ((uint32_t *)&llr128[0])[3]; + llr32[4] = ((uint32_t *)&llr128[1])[0]; + llr32[5] = ((uint32_t *)&llr128[1])[1]; + llr32[6] = ((uint32_t *)&llr128[1])[2]; + llr32[7] = ((uint32_t *)&llr128[1])[3]; + llr32+=8; + +#elif defined(__arm__) + xmm0 = vabsq_s16(rxF[i]); + xmm0 = vsubq_s16(ch_mag[i],xmm0); + + // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 + + llr16[0] = vgetq_lane_s16(rxF[i],0); + llr16[1] = vgetq_lane_s16(xmm0,0); + llr16[2] = vgetq_lane_s16(rxF[i],1); + llr16[3] = vgetq_lane_s16(xmm0,1); + llr16[4] = vgetq_lane_s16(rxF[i],2); + llr16[5] = vgetq_lane_s16(xmm0,2); + llr16[6] = vgetq_lane_s16(rxF[i],2); + llr16[7] = vgetq_lane_s16(xmm0,3); + llr16[8] = vgetq_lane_s16(rxF[i],4); + llr16[9] = vgetq_lane_s16(xmm0,4); + llr16[10] = vgetq_lane_s16(rxF[i],5); + llr16[11] = vgetq_lane_s16(xmm0,5); + llr16[12] = vgetq_lane_s16(rxF[i],6); + llr16[13] = vgetq_lane_s16(xmm0,6); + llr16[14] = vgetq_lane_s16(rxF[i],7); + llr16[15] = vgetq_lane_s16(xmm0,7); + llr16+=16; +#endif + + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +//---------------------------------------------------------------------------------------------- +// 64-QAM +//---------------------------------------------------------------------------------------------- + +void mch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + short *dlsch_llr, + int **dl_ch_mag, + int **dl_ch_magb, + unsigned char symbol, + short **llr_save) +{ + +#if defined(__x86_64__) || defined(__i386__) + __m128i xmm1,xmm2,*ch_mag,*ch_magb; + __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; +#elif defined(__arm__) + int16x8_t xmm1,xmm2,*ch_mag,*ch_magb; + int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; +#endif + + int i,len,len2; + // int j=0; + unsigned char len_mod4; + short *llr; + int16_t *llr2; + + if (symbol==2) + llr = dlsch_llr; + else + llr = *llr_save; + +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; + ch_magb = (__m128i*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; + ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; +#endif + if ((symbol==2) || (symbol==6) || (symbol==10)) { + len = frame_parms->N_RB_DL*6; + } else { + len = frame_parms->N_RB_DL*12; + } + + + llr2 = llr; + llr += (len*6); + + len_mod4 =len&3; + len2=len>>2; // length in quad words (4 REs) + len2+=(len_mod4?0:1); + + + for (i=0; i<len2; i++) { +#if defined(__x86_64__) || defined(__i386__) + xmm1 = _mm_abs_epi16(rxF[i]); + xmm1 = _mm_subs_epi16(ch_mag[i],xmm1); + xmm2 = _mm_abs_epi16(xmm1); + xmm2 = _mm_subs_epi16(ch_magb[i],xmm2); +#elif defined(__arm__) + xmm1 = vabsq_s16(rxF[i]); + xmm1 = vsubq_s16(ch_mag[i],xmm1); + xmm2 = vabsq_s16(xmm1); + xmm2 = vsubq_s16(ch_magb[i],xmm2); +#endif + + /* + printf("pmch i: %d => mag (%d,%d) (%d,%d)\n",i,((short *)&ch_mag[i])[0],((short *)&ch_magb[i])[0], + ((short *)&rxF[i])[0],((short *)&rxF[i])[1]); + */ + // loop over all LLRs in quad word (24 coded bits) + /* + for (j=0;j<8;j+=2) { + llr2[0] = ((short *)&rxF[i])[j]; + llr2[1] = ((short *)&rxF[i])[j+1]; + llr2[2] = _mm_extract_epi16(xmm1,j); + llr2[3] = _mm_extract_epi16(xmm1,j+1);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,j);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,j+1);//((short *)&xmm2)[j+1]; + + llr2+=6; + } + */ + llr2[0] = ((short *)&rxF[i])[0]; + llr2[1] = ((short *)&rxF[i])[1]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,0); + llr2[3] = _mm_extract_epi16(xmm1,1);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,0);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,1);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,0); + llr2[3] = vgetq_lane_s16(xmm1,1);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,0);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,1);//((short *)&xmm2)[j+1]; +#endif + + llr2+=6; + llr2[0] = ((short *)&rxF[i])[2]; + llr2[1] = ((short *)&rxF[i])[3]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,2); + llr2[3] = _mm_extract_epi16(xmm1,3);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,2);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,3);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,2); + llr2[3] = vgetq_lane_s16(xmm1,3);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,2);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,3);//((short *)&xmm2)[j+1]; +#endif + llr2+=6; + llr2[0] = ((short *)&rxF[i])[4]; + llr2[1] = ((short *)&rxF[i])[5]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,4); + llr2[3] = _mm_extract_epi16(xmm1,5);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,4);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,5);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,4); + llr2[3] = vgetq_lane_s16(xmm1,5);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,4);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,5);//((short *)&xmm2)[j+1]; +#endif + llr2+=6; + llr2[0] = ((short *)&rxF[i])[6]; + llr2[1] = ((short *)&rxF[i])[7]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,6); + llr2[3] = _mm_extract_epi16(xmm1,7);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,6);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,7);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,6); + llr2[3] = vgetq_lane_s16(xmm1,7);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,6);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,7);//((short *)&xmm2)[j+1]; +#endif + llr2+=6; + } + + *llr_save = llr; +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +int avg_pmch[4]; +int rx_pmch(PHY_VARS_UE *ue, + unsigned char eNB_id, + uint8_t subframe, + unsigned char symbol) +{ + + LTE_UE_COMMON *common_vars = &ue->common_vars; + LTE_UE_PDSCH **pdsch_vars = &ue->pdsch_vars_MCH[eNB_id]; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + LTE_UE_DLSCH_t **dlsch = &ue->dlsch_MCH[eNB_id]; + int avgs,aarx; + + //printf("*********************mch: symbol %d\n",symbol); + + mch_extract_rbs(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdsch_vars[eNB_id]->rxdataF_ext, + pdsch_vars[eNB_id]->dl_ch_estimates_ext, + symbol, + subframe, + frame_parms); + + if (symbol == 2) { + mch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext, + frame_parms, + avg_pmch, + symbol, + frame_parms->N_RB_DL); + } + + avgs = 0; + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) + avgs = cmax(avgs,avg_pmch[aarx]); + + if (get_Qm(dlsch[0]->harq_processes[0]->mcs)==2) + pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) ;// + 2 + else + pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2); // + 5;// + 2 + + mch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext, + pdsch_vars[eNB_id]->dl_ch_estimates_ext, + pdsch_vars[eNB_id]->dl_ch_mag0, + pdsch_vars[eNB_id]->dl_ch_magb0, + pdsch_vars[eNB_id]->rxdataF_comp0, + frame_parms, + symbol, + get_Qm(dlsch[0]->harq_processes[0]->mcs), + pdsch_vars[eNB_id]->log2_maxh); + + + if (frame_parms->nb_antennas_rx > 1) + mch_detection_mrc(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->dl_ch_mag0, + pdsch_vars[eNB_id]->dl_ch_magb0, + symbol); + + switch (get_Qm(dlsch[0]->harq_processes[0]->mcs)) { + case 2 : + mch_qpsk_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->llr[0], + symbol, + pdsch_vars[eNB_id]->llr128); + break; + + case 4: + mch_16qam_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->llr[0], + pdsch_vars[eNB_id]->dl_ch_mag0, + symbol, + pdsch_vars[eNB_id]->llr128); + break; + + case 6: + mch_64qam_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->llr[0], + pdsch_vars[eNB_id]->dl_ch_mag0, + pdsch_vars[eNB_id]->dl_ch_magb0, + symbol, + pdsch_vars[eNB_id]->llr128); + break; + } + + return(0); +} + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..c9763465cdfbc55c8091289fc2773e2aa8e7a6a1 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c @@ -0,0 +1,534 @@ +/* + * 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/LTE_TRANSPORT/prach_ue.c + * \brief Top-level routines for decoding the PRACH physical channel V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include "PHY/sse_intrin.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +//#include "prach.h" +#include "PHY/LTE_TRANSPORT/if4_tools.h" + +#include "SCHED_UE/sched_UE.h" +#include "SCHED/sched_common_extern.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +#include "../LTE_TRANSPORT/prach_extern.h" + +int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint16_t Nf ) +{ + + lte_frame_type_t frame_type = ue->frame_parms.frame_type; + //uint8_t tdd_config = ue->frame_parms.tdd_config; + uint16_t rootSequenceIndex = ue->frame_parms.prach_config_common.rootSequenceIndex; + uint8_t prach_ConfigIndex = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + uint8_t Ncs_config = ue->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig; + uint8_t restricted_set = ue->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag; + //uint8_t n_ra_prboffset = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; + uint8_t preamble_index = ue->prach_resources[eNB_id]->ra_PreambleIndex; + uint8_t tdd_mapindex = ue->prach_resources[eNB_id]->ra_TDD_map_index; + int16_t *prachF = ue->prach_vars[eNB_id]->prachF; + static int16_t prach_tmp[45600*2] __attribute__((aligned(32))); + int16_t *prach = prach_tmp; + int16_t *prach2; + int16_t amp = ue->prach_vars[eNB_id]->amp; + int16_t Ncp; + uint8_t n_ra_prb; + uint16_t NCS; + uint16_t *prach_root_sequence_map; + uint16_t preamble_offset,preamble_shift; + uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar; + uint16_t d_start,numshift; + + uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); + //uint8_t Nsp=2; + //uint8_t f_ra,t1_ra; + uint16_t N_ZC = (prach_fmt<4)?839:139; + uint8_t not_found; + int k; + int16_t *Xu; + uint16_t u; + int32_t Xu_re,Xu_im; + uint16_t offset,offset2; + int prach_start; + int i, prach_len; + uint16_t first_nonzero_root_idx=0; + +#if defined(EXMIMO) || defined(OAI_USRP) + prach_start = (ue->rx_offset+subframe*ue->frame_parms.samples_per_tti-ue->hw_timing_advance-ue->N_TA_offset); +#ifdef PRACH_DEBUG + LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, + prach_start, + ue->rx_offset, + ue->hw_timing_advance, + ue->N_TA_offset); +#endif + + if (prach_start<0) + prach_start+=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); + + if (prach_start>=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) + prach_start-=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME); + +#else //normal case (simulation) + prach_start = subframe*ue->frame_parms.samples_per_tti-ue->N_TA_offset; + LOG_D(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, + prach_start, + ue->rx_offset, + ue->hw_timing_advance, + ue->N_TA_offset); + +#endif + + + // First compute physical root sequence + if (restricted_set == 0) { + AssertFatal(Ncs_config <= 15, + "[PHY] FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", Ncs_config ); + NCS = NCS_unrestricted[Ncs_config]; + } else { + AssertFatal(Ncs_config <= 14, + "[PHY] FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", Ncs_config ); + NCS = NCS_restricted[Ncs_config]; + } + + n_ra_prb = get_prach_prb_offset(&(ue->frame_parms), + ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset, + tdd_mapindex, Nf); + prach_root_sequence_map = (prach_fmt<4) ? prach_root_sequence_map0_3 : prach_root_sequence_map4; + + /* + // this code is not part of get_prach_prb_offset + if (frame_type == TDD) { // TDD + + if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { + LOG_E( PHY, "[PHY][UE %"PRIu8"] Illegal prach_ConfigIndex %"PRIu8" for ", ue->Mod_id, prach_ConfigIndex ); + } + + // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) + f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; + + if (prach_fmt < 4) { + if ((f_ra&1) == 0) { + n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); + } else { + n_ra_prb = ue->frame_parms.N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); + } + } else { + if ((tdd_config >2) && (tdd_config<6)) + Nsp = 2; + + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + + if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { + n_ra_prb = 6*f_ra; + } else { + n_ra_prb = ue->frame_parms.N_RB_UL - 6*(f_ra+1); + } + } + } + */ + + // This is the relative offset (for unrestricted case) in the root sequence table (5.7.2-4 from 36.211) for the given preamble index + preamble_offset = ((NCS==0)? preamble_index : (preamble_index/(N_ZC/NCS))); + + if (restricted_set == 0) { + // This is the \nu corresponding to the preamble index + preamble_shift = (NCS==0)? 0 : (preamble_index % (N_ZC/NCS)); + preamble_shift *= NCS; + } else { // This is the high-speed case + +#ifdef PRACH_DEBUG + LOG_I(PHY,"[UE %d] High-speed mode, NCS_config %d\n",ue->Mod_id,Ncs_config); +#endif + + not_found = 1; + preamble_index0 = preamble_index; + // set preamble_offset to initial rootSequenceIndex and look if we need more root sequences for this + // preamble index and find the corresponding cyclic shift + preamble_offset = 0; // relative rootSequenceIndex; + + while (not_found == 1) { + // current root depending on rootSequenceIndex and preamble_offset + int index = (rootSequenceIndex + preamble_offset) % N_ZC; + + if (prach_fmt<4) { + // prach_root_sequence_map points to prach_root_sequence_map0_3 + DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); + } else { + // prach_root_sequence_map points to prach_root_sequence_map4 + DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); + } + + u = prach_root_sequence_map[index]; + + uint16_t n_group_ra = 0; + + if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { + n_shift_ra = du[u]/NCS; + d_start = (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = N_ZC/d_start; + n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); + } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { + n_shift_ra = (N_ZC - (du[u]<<1))/NCS; + d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = du[u]/d_start; + n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); + } else { + n_shift_ra = 0; + n_shift_ra_bar = 0; + } + + // This is the number of cyclic shifts for the current root u + numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; + + if (numshift>0 && preamble_index0==preamble_index) + first_nonzero_root_idx = preamble_offset; + + if (preamble_index0 < numshift) { + not_found = 0; + preamble_shift = (d_start * (preamble_index0/n_shift_ra)) + ((preamble_index0%n_shift_ra)*NCS); + + } else { // skip to next rootSequenceIndex and recompute parameters + preamble_offset++; + preamble_index0 -= numshift; + } + } + } + + // now generate PRACH signal +#ifdef PRACH_DEBUG + + if (NCS>0) + LOG_I(PHY,"Generate PRACH for RootSeqIndex %d, Preamble Index %d, NCS %d (NCS_config %d, N_ZC/NCS %d) n_ra_prb %d: Preamble_offset %d, Preamble_shift %d\n", + rootSequenceIndex,preamble_index,NCS,Ncs_config,N_ZC/NCS,n_ra_prb, + preamble_offset,preamble_shift); + +#endif + + // nsymb = (frame_parms->Ncp==0) ? 14:12; + // subframe_offset = (unsigned int)frame_parms->ofdm_symbol_size*subframe*nsymb; + + k = (12*n_ra_prb) - 6*ue->frame_parms.N_RB_UL; + + if (k<0) + k+=ue->frame_parms.ofdm_symbol_size; + + k*=12; + k+=13; + + Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; + + /* + k+=(12*ue->frame_parms.first_carrier_offset); + if (k>(12*ue->frame_parms.ofdm_symbol_size)) + k-=(12*ue->frame_parms.ofdm_symbol_size); + */ + k*=2; + + switch (ue->frame_parms.N_RB_UL) { + case 6: + memset((void*)prachF,0,4*1536); + break; + + case 15: + memset((void*)prachF,0,4*3072); + break; + + case 25: + memset((void*)prachF,0,4*6144); + break; + + case 50: + memset((void*)prachF,0,4*12288); + break; + + case 75: + memset((void*)prachF,0,4*18432); + break; + + case 100: + if (ue->frame_parms.threequarter_fs == 0) + memset((void*)prachF,0,4*24576); + else + memset((void*)prachF,0,4*18432); + break; + } + + for (offset=0,offset2=0; offset<N_ZC; offset++,offset2+=preamble_shift) { + + if (offset2 >= N_ZC) + offset2 -= N_ZC; + + Xu_re = (((int32_t)Xu[offset<<1]*amp)>>15); + Xu_im = (((int32_t)Xu[1+(offset<<1)]*amp)>>15); + prachF[k++]= ((Xu_re*ru[offset2<<1]) - (Xu_im*ru[1+(offset2<<1)]))>>15; + prachF[k++]= ((Xu_im*ru[offset2<<1]) + (Xu_re*ru[1+(offset2<<1)]))>>15; + + if (k==(12*2*ue->frame_parms.ofdm_symbol_size)) + k=0; + } + + switch (prach_fmt) { + case 0: + Ncp = 3168; + break; + + case 1: + case 3: + Ncp = 21024; + break; + + case 2: + Ncp = 6240; + break; + + case 4: + Ncp = 448; + break; + + default: + Ncp = 3168; + break; + } + + switch (ue->frame_parms.N_RB_UL) { + case 6: + Ncp>>=4; + prach+=4; // makes prach2 aligned to 128-bit + break; + + case 15: + Ncp>>=3; + break; + + case 25: + Ncp>>=2; + break; + + case 50: + Ncp>>=1; + break; + + case 75: + Ncp=(Ncp*3)>>2; + break; + } + + if (ue->frame_parms.threequarter_fs == 1) + Ncp=(Ncp*3)>>2; + + prach2 = prach+(Ncp<<1); + + // do IDFT + switch (ue->frame_parms.N_RB_UL) { + case 6: + if (prach_fmt == 4) { + idft256(prachF,prach2,1); + memmove( prach, prach+512, Ncp<<2 ); + prach_len = 256+Ncp; + } else { + idft1536(prachF,prach2,1); + memmove( prach, prach+3072, Ncp<<2 ); + prach_len = 1536+Ncp; + + if (prach_fmt>1) { + memmove( prach2+3072, prach2, 6144 ); + prach_len = 2*1536+Ncp; + } + } + + break; + + case 15: + if (prach_fmt == 4) { + idft512(prachF,prach2,1); + //TODO: account for repeated format in dft output + memmove( prach, prach+1024, Ncp<<2 ); + prach_len = 512+Ncp; + } else { + idft3072(prachF,prach2); + memmove( prach, prach+6144, Ncp<<2 ); + prach_len = 3072+Ncp; + + if (prach_fmt>1) { + memmove( prach2+6144, prach2, 12288 ); + prach_len = 2*3072+Ncp; + } + } + + break; + + case 25: + default: + if (prach_fmt == 4) { + idft1024(prachF,prach2,1); + memmove( prach, prach+2048, Ncp<<2 ); + prach_len = 1024+Ncp; + } else { + idft6144(prachF,prach2); + /*for (i=0;i<6144*2;i++) + prach2[i]<<=1;*/ + memmove( prach, prach+12288, Ncp<<2 ); + prach_len = 6144+Ncp; + + if (prach_fmt>1) { + memmove( prach2+12288, prach2, 24576 ); + prach_len = 2*6144+Ncp; + } + } + + break; + + case 50: + if (prach_fmt == 4) { + idft2048(prachF,prach2,1); + memmove( prach, prach+4096, Ncp<<2 ); + prach_len = 2048+Ncp; + } else { + idft12288(prachF,prach2); + memmove( prach, prach+24576, Ncp<<2 ); + prach_len = 12288+Ncp; + + if (prach_fmt>1) { + memmove( prach2+24576, prach2, 49152 ); + prach_len = 2*12288+Ncp; + } + } + + break; + + case 75: + if (prach_fmt == 4) { + idft3072(prachF,prach2); + //TODO: account for repeated format in dft output + memmove( prach, prach+6144, Ncp<<2 ); + prach_len = 3072+Ncp; + } else { + idft18432(prachF,prach2); + memmove( prach, prach+36864, Ncp<<2 ); + prach_len = 18432+Ncp; + + if (prach_fmt>1) { + memmove( prach2+36834, prach2, 73728 ); + prach_len = 2*18432+Ncp; + } + } + + break; + + case 100: + if (ue->frame_parms.threequarter_fs == 0) { + if (prach_fmt == 4) { + idft4096(prachF,prach2,1); + memmove( prach, prach+8192, Ncp<<2 ); + prach_len = 4096+Ncp; + } else { + idft24576(prachF,prach2); + memmove( prach, prach+49152, Ncp<<2 ); + prach_len = 24576+Ncp; + + if (prach_fmt>1) { + memmove( prach2+49152, prach2, 98304 ); + prach_len = 2* 24576+Ncp; + } + } + } + else { + if (prach_fmt == 4) { + idft3072(prachF,prach2); + //TODO: account for repeated format in dft output + memmove( prach, prach+6144, Ncp<<2 ); + prach_len = 3072+Ncp; + } else { + idft18432(prachF,prach2); + memmove( prach, prach+36864, Ncp<<2 ); + prach_len = 18432+Ncp; + printf("Generated prach for 100 PRB, 3/4 sampling\n"); + if (prach_fmt>1) { + memmove( prach2+36834, prach2, 73728 ); + prach_len = 2*18432+Ncp; + } + } + } + + break; + } + + //LOG_I(PHY,"prach_len=%d\n",prach_len); + + AssertFatal(prach_fmt<4, + "prach_fmt4 not fully implemented" ); +#if defined(EXMIMO) || defined(OAI_USRP) + int j; + int overflow = prach_start + prach_len - LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*ue->frame_parms.samples_per_tti; + LOG_I( PHY, "prach_start=%d, overflow=%d\n", prach_start, overflow ); + + for (i=prach_start,j=0; i<min(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,prach_start+prach_len); i++,j++) { + ((int16_t*)ue->common_vars.txdata[0])[2*i] = prach[2*j]<<4; + ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]<<4; + } + + for (i=0; i<overflow; i++,j++) { + ((int16_t*)ue->common_vars.txdata[0])[2*i] = prach[2*j]<<4; + ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]<<4; + } +#if defined(EXMIMO) + // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on + for (k=prach_start - (ue->frame_parms.samples_per_tti>>1) ; k<prach_start ; k++) { + if (k<0) + ue->common_vars.txdata[0][k+ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + else if (k>(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) + ue->common_vars.txdata[0][k-ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + else + ue->common_vars.txdata[0][k] &= 0xFFFEFFFE; + } +#endif +#else + + for (i=0; i<prach_len; i++) { + ((int16_t*)(&ue->common_vars.txdata[0][prach_start]))[2*i] = prach[2*i]; + ((int16_t*)(&ue->common_vars.txdata[0][prach_start]))[2*i+1] = prach[2*i+1]; + } + +#endif + + + +#if defined(PRACH_WRITE_OUTPUT_DEBUG) + write_output("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1); + write_output("prach_tx0.m","prachtx0",prach+(Ncp<<1),prach_len-Ncp,1,1); + write_output("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][0]),2*ue->frame_parms.samples_per_tti,1,1); + exit(-1); +#endif + + return signal_energy( (int*)prach, 256 ); +} + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..c3bbd0fb1caafe229a22a5660e7991385f663515 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c @@ -0,0 +1,843 @@ +/* + * 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/LTE_TRANSPORT/pucch.c +* \brief Top-level routines for generating and decoding the PUCCH physical channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +#include "T.h" + +#include "../LTE_TRANSPORT/pucch_extern.h" + + + +void generate_pucch1x(int32_t **txdataF, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t ncs_cell[20][7], + PUCCH_FMT_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint16_t n1_pucch, + uint8_t shortened_format, + uint8_t *payload, + int16_t amp, + uint8_t subframe) +{ + + uint32_t u,v,n; + uint32_t z[12*14],*zptr; + int16_t d0; + uint8_t ns,N_UL_symb,nsymb,n_oc,n_oc0,n_oc1; + uint8_t c = (frame_parms->Ncp==0) ? 3 : 2; + uint16_t nprime,nprime0,nprime1; + uint16_t i,j,re_offset,thres,h; + uint8_t Nprime_div_deltaPUCCH_Shift,Nprime,d; + uint8_t m,l,refs; + uint8_t n_cs,S,alpha_ind,rem; + int16_t tmp_re,tmp_im,ref_re,ref_im,W_re=0,W_im=0; + int32_t *txptr; + uint32_t symbol_offset; + + uint8_t deltaPUCCH_Shift = frame_parms->pucch_config_common.deltaPUCCH_Shift; + uint8_t NRB2 = frame_parms->pucch_config_common.nRB_CQI; + uint8_t Ncs1 = frame_parms->pucch_config_common.nCS_AN; + uint8_t Ncs1_div_deltaPUCCH_Shift = Ncs1/deltaPUCCH_Shift; + + LOG_D(PHY,"generate_pucch Start [deltaPUCCH_Shift %d, NRB2 %d, Ncs1_div_deltaPUCCH_Shift %d, n1_pucch %d]\n", deltaPUCCH_Shift, NRB2, Ncs1_div_deltaPUCCH_Shift,n1_pucch); + + + uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; + uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; + uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; + uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + + if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { + printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); + return; + } + + if (Ncs1_div_deltaPUCCH_Shift > 7) { + printf("[PHY] generate_pucch: Illegal Ncs1_div_deltaPUCCH_Shift %d (should be 0...7)\n",Ncs1_div_deltaPUCCH_Shift); + return; + } + + zptr = z; + thres = (c*Ncs1_div_deltaPUCCH_Shift); + Nprime_div_deltaPUCCH_Shift = (n1_pucch < thres) ? Ncs1_div_deltaPUCCH_Shift : (12/deltaPUCCH_Shift); + Nprime = Nprime_div_deltaPUCCH_Shift * deltaPUCCH_Shift; + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: cNcs1/deltaPUCCH_Shift %d, Nprime %d, n1_pucch %d\n",thres,Nprime,n1_pucch); +#endif + + LOG_D(PHY,"[PHY] PUCCH: n1_pucch %d, thres %d Ncs1_div_deltaPUCCH_Shift %d (12/deltaPUCCH_Shift) %d Nprime_div_deltaPUCCH_Shift %d \n", + n1_pucch, thres, Ncs1_div_deltaPUCCH_Shift, (int)(12/deltaPUCCH_Shift), Nprime_div_deltaPUCCH_Shift); + LOG_D(PHY,"[PHY] PUCCH: deltaPUCCH_Shift %d, Nprime %d\n",deltaPUCCH_Shift,Nprime); + + + N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; + + if (n1_pucch < thres) + nprime0=n1_pucch; + else + nprime0 = (n1_pucch - thres)%(12*c/deltaPUCCH_Shift); + + if (n1_pucch >= thres) + nprime1= ((c*(nprime0+1))%((12*c/deltaPUCCH_Shift)+1))-1; + else { + d = (frame_parms->Ncp==0) ? 2 : 0; + h= (nprime0+d)%(c*Nprime_div_deltaPUCCH_Shift); +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: h %d, d %d\n",h,d); +#endif + nprime1 = (h/c) + (h%c)*Nprime_div_deltaPUCCH_Shift; + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: nprime0 %d nprime1 %d, %s, payload (%d,%d)\n",nprime0,nprime1,pucch_format_string[fmt],payload[0],payload[1]); +#endif + + n_oc0 = nprime0/Nprime_div_deltaPUCCH_Shift; + + if (frame_parms->Ncp==1) + n_oc0<<=1; + + n_oc1 = nprime1/Nprime_div_deltaPUCCH_Shift; + + if (frame_parms->Ncp==1) // extended CP + n_oc1<<=1; + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: noc0 %d noc1 %d\n",n_oc0,n_oc1); +#endif + + nprime=nprime0; + n_oc =n_oc0; + + // loop over 2 slots + for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { + + if ((nprime&1) == 0) + S=0; // 1 + else + S=1; // j + + //loop over symbols in slot + for (l=0; l<N_UL_symb; l++) { + // Compute n_cs (36.211 p. 18) + n_cs = ncs_cell[ns][l]; + + if (frame_parms->Ncp==0) { // normal CP + n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc%deltaPUCCH_Shift))%Nprime)%12; + } else { + n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc>>1))%Nprime)%12; + } + + + refs=0; + + // Comput W_noc(m) (36.211 p. 19) + if ((ns==(1+(subframe<<1))) && (shortened_format==1)) { // second slot and shortened format + + if (l<2) { // data + W_re=W3_re[n_oc][l]; + W_im=W3_im[n_oc][l]; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP + W_re=W3_re[n_oc][l-2]; + W_im=W3_im[n_oc][l-2]; + refs=1; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP + W_re=W4[n_oc][l-2]; + W_im=0; + refs=1; + } else if ((l>=N_UL_symb-2)) { // data + W_re=W3_re[n_oc][l-N_UL_symb+4]; + W_im=W3_im[n_oc][l-N_UL_symb+4]; + } + } else { + if (l<2) { // data + W_re=W4[n_oc][l]; + W_im=0; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP + W_re=W3_re[n_oc][l-2]; + W_im=W3_im[n_oc][l-2]; + refs=1; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP + W_re=W4[n_oc][l-2]; + W_im=0; + refs=1; + } else if ((l>=N_UL_symb-2)) { // data + W_re=W4[n_oc][l-N_UL_symb+4]; + W_im=0; + } + } + + // multiply W by S(ns) (36.211 p.17). only for data, reference symbols do not have this factor + if ((S==1)&&(refs==0)) { + tmp_re = W_re; + W_re = -W_im; + W_im = tmp_re; + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: ncs[%d][%d]=%d, W_re %d, W_im %d, S %d, refs %d\n",ns,l,n_cs,W_re,W_im,S,refs); +#endif + alpha_ind=0; + // compute output sequence + + for (n=0; n<12; n++) { + + // this is r_uv^alpha(n) + tmp_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); + tmp_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); + + // this is S(ns)*w_noc(m)*r_uv^alpha(n) + ref_re = (tmp_re*W_re - tmp_im*W_im)>>15; + ref_im = (tmp_re*W_im + tmp_im*W_re)>>15; + + if ((l<2)||(l>=(N_UL_symb-2))) { //these are PUCCH data symbols + switch (fmt) { + case pucch_format1: //OOK 1-bit + + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; + + break; + + case pucch_format1a: //BPSK 1-bit + d0 = (payload[0]&1)==0 ? amp : -amp; + ((int16_t *)&zptr[n])[0] = ((int32_t)d0*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)d0*ref_im)>>15; + // printf("d0 %d\n",d0); + break; + + case pucch_format1b: //QPSK 2-bits (Table 5.4.1-1 from 36.211, pg. 18) + if (((payload[0]&1)==0) && ((payload[1]&1)==0)) {// 1 + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; + } else if (((payload[0]&1)==0) && ((payload[1]&1)==1)) { // -j + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_im)>>15; + ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_re)>>15; + } else if (((payload[0]&1)==1) && ((payload[1]&1)==0)) { // j + ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_im)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_re)>>15; + } else { // -1 + ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_im)>>15; + } + + break; + case pucch_format1b_csA2: + case pucch_format1b_csA3: + case pucch_format1b_csA4: + AssertFatal(1==0,"PUCCH format 1b_csX not supported yet\n"); + break; + case pucch_format2: + case pucch_format2a: + case pucch_format2b: + AssertFatal(1==0,"should not go here\n"); + break; + + case pucch_format3: + fprintf(stderr, "PUCCH format 3 not handled\n"); + abort(); + } // switch fmt + } else { // These are PUCCH reference symbols + + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; + // printf("ref\n"); + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH subframe %d z(%d,%d) => %d,%d, alpha(%d) => %d,%d\n",subframe,l,n,((int16_t *)&zptr[n])[0],((int16_t *)&zptr[n])[1], + alpha_ind,alpha_re[alpha_ind],alpha_im[alpha_ind]); +#endif + alpha_ind = (alpha_ind + n_cs)%12; + } // n + + zptr+=12; + } // l + + nprime=nprime1; + n_oc =n_oc1; + } // ns + + rem = ((((12*Ncs1_div_deltaPUCCH_Shift)>>3)&7)>0) ? 1 : 0; + + m = (n1_pucch < thres) ? NRB2 : (((n1_pucch-thres)/(12*c/deltaPUCCH_Shift))+NRB2+((deltaPUCCH_Shift*Ncs1_div_deltaPUCCH_Shift)>>3)+rem); + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: m %d\n",m); +#endif + nsymb = N_UL_symb<<1; + + //for (j=0,l=0;l<(nsymb-1);l++) { + for (j=0,l=0; l<(nsymb); l++) { + if ((l<(nsymb>>1)) && ((m&1) == 0)) + re_offset = (m*6) + frame_parms->first_carrier_offset; + else if ((l<(nsymb>>1)) && ((m&1) == 1)) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else if ((m&1) == 0) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else + re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; + + if (re_offset > frame_parms->ofdm_symbol_size) + re_offset -= (frame_parms->ofdm_symbol_size); + + symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb)); + txptr = &txdataF[0][symbol_offset]; + + for (i=0; i<12; i++,j++) { + txptr[re_offset++] = z[j]; + + if (re_offset==frame_parms->ofdm_symbol_size) + re_offset = 0; + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); +#endif + } + } + +} + + + + +inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) __attribute__((always_inline)); +inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) { + + uint32_t x1, x2, s=0; + int i; + uint8_t c; + + x2 = (rnti) + ((uint32_t)(1+subframe)<<16)*(1+(fp->Nid_cell<<1)); //this is c_init in 36.211 Sec 6.3.1 + s = lte_gold_generic(&x1, &x2, 1); + for (i=0;i<19;i++) { + c = (uint8_t)((s>>i)&1); + btilde[i] = (((B>>i)&1) ^ c); + } +} + +inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) __attribute__((always_inline)); +inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) { + + int i; + + for (i=0;i<20;i++) + d[i] = btilde[i] == 1 ? -amp : amp; + +} + + + +uint32_t pucch_code[13] = {0xFFFFF,0x5A933,0x10E5A,0x6339C,0x73CE0, + 0xFFC00,0xD8E64,0x4F6B0,0x218EC,0x1B746, + 0x0FFFF,0x33FFF,0x3FFFC}; + + +void generate_pucch2x(int32_t **txdataF, + LTE_DL_FRAME_PARMS *fp, + uint8_t ncs_cell[20][7], + PUCCH_FMT_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint16_t n2_pucch, + uint8_t *payload, + int A, + int B2, + int16_t amp, + uint8_t subframe, + uint16_t rnti) { + + int i,j; + uint32_t B=0; + uint8_t btilde[20]; + int16_t d[22]; + uint8_t deltaPUCCH_Shift = fp->pucch_config_common.deltaPUCCH_Shift; + uint8_t NRB2 = fp->pucch_config_common.nRB_CQI; + uint8_t Ncs1 = fp->pucch_config_common.nCS_AN; + + uint32_t u0 = fp->pucch_config_common.grouphop[subframe<<1]; + uint32_t u1 = fp->pucch_config_common.grouphop[1+(subframe<<1)]; + uint32_t v0 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; + uint32_t v1 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + + uint32_t z[12*14],*zptr; + uint32_t u,v,n; + uint8_t ns,N_UL_symb,nsymb_slot0,nsymb_pertti; + uint32_t nprime,l,n_cs; + int alpha_ind,data_ind; + int16_t ref_re,ref_im; + int m,re_offset,symbol_offset; + int32_t *txptr; + + if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { + printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); + return; + } + + if (Ncs1 > 7) { + printf("[PHY] generate_pucch: Illegal Ncs1 %d (should be 0...7)\n",Ncs1); + return; + } + + // pucch2x_encoding + for (i=0;i<A;i++) + if ((*payload & (1<<i)) > 0) + B=B^pucch_code[i]; + + // scrambling + pucch2x_scrambling(fp,subframe,rnti,B,btilde); + // modulation + pucch2x_modulation(btilde,d,amp); + + // add extra symbol for 2a/2b + d[20]=0; + d[21]=0; + if (fmt==pucch_format2a) + d[20] = (B2 == 0) ? amp : -amp; + else if (fmt==pucch_format2b) { + switch (B2) { + case 0: + d[20] = amp; + break; + case 1: + d[21] = -amp; + break; + case 2: + d[21] = amp; + break; + case 3: + d[20] = -amp; + break; + default: + AssertFatal(1==0,"Illegal modulation symbol %d for PUCCH %s\n",B2,pucch_format_string[fmt]); + break; + } + } + + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH2x: n2_pucch %d\n",n2_pucch); +#endif + + N_UL_symb = (fp->Ncp==0) ? 7 : 6; + data_ind = 0; + zptr = z; + nprime = 0; + for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { + + if ((ns&1) == 0) + nprime = (n2_pucch < 12*NRB2) ? + n2_pucch % 12 : + (n2_pucch+Ncs1 + 1)%12; + else { + nprime = (n2_pucch < 12*NRB2) ? + ((12*(nprime+1)) % 13)-1 : + (10-n2_pucch)%12; + } + //loop over symbols in slot + for (l=0; l<N_UL_symb; l++) { + // Compute n_cs (36.211 p. 18) + n_cs = (ncs_cell[ns][l]+nprime)%12; + + alpha_ind = 0; + for (n=0; n<12; n++) + { + // this is r_uv^alpha(n) + ref_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); + ref_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); + + if ((l!=1)&&(l!=5)) { //these are PUCCH data symbols + ((int16_t *)&zptr[n])[0] = ((int32_t)d[data_ind]*ref_re - (int32_t)d[data_ind+1]*ref_im)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)d[data_ind]*ref_im + (int32_t)d[data_ind+1]*ref_re)>>15; + //LOG_I(PHY,"slot %d ofdm# %d ==> d[%d,%d] \n",ns,l,data_ind,n); + } + else { + if ((l==1) || ( (l==5) && (fmt==pucch_format2) )) + { + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re>>15); + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im>>15); + } + // l == 5 && pucch format 2a + else if (fmt==pucch_format2a) + { + ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); + ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); + } + // l == 5 && pucch format 2b + else if (fmt==pucch_format2b) + { + ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); + ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); + } + } // l==1 || l==5 + alpha_ind = (alpha_ind + n_cs)%12; + } // n + zptr+=12; + + if ((l!=1)&&(l!=5)) //these are PUCCH data symbols so increment data index + data_ind+=2; + } // l + } //ns + + m = n2_pucch/12; + +#ifdef DEBUG_PUCCH_TX + LOG_D(PHY,"[PHY] PUCCH: n2_pucch %d m %d\n",n2_pucch,m); +#endif + + nsymb_slot0 = ((fp->Ncp==0) ? 7 : 6); + nsymb_pertti = nsymb_slot0 << 1; + + //nsymb = nsymb_slot0<<1; + + //for (j=0,l=0;l<(nsymb-1);l++) { + for (j=0,l=0; l<(nsymb_pertti); l++) { + + if ((l<nsymb_slot0) && ((m&1) == 0)) + re_offset = (m*6) + fp->first_carrier_offset; + else if ((l<nsymb_slot0) && ((m&1) == 1)) + re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; + else if ((m&1) == 0) + re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; + else + re_offset = ((m-1)*6) + fp->first_carrier_offset; + + if (re_offset > fp->ofdm_symbol_size) + re_offset -= (fp->ofdm_symbol_size); + + + + symbol_offset = (unsigned int)fp->ofdm_symbol_size*(l+(subframe*nsymb_pertti)); + txptr = &txdataF[0][symbol_offset]; + + //LOG_I(PHY,"ofdmSymb %d/%d, firstCarrierOffset %d, symbolOffset[sfn %d] %d, reOffset %d, &txptr: %x \n", l, nsymb, fp->first_carrier_offset, subframe, symbol_offset, re_offset, &txptr[0]); + + for (i=0; i<12; i++,j++) { + txptr[re_offset] = z[j]; + + re_offset++; + + if (re_offset==fp->ofdm_symbol_size) + re_offset -= (fp->ofdm_symbol_size); + +#ifdef DEBUG_PUCCH_TX + LOG_D(PHY,"[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); +#endif + } + } +} + +/* PUCCH format3 >> */ +/* DFT */ +void pucchfmt3_Dft( int16_t *x, int16_t *y ) +{ + int16_t i, k; + int16_t tmp[2]; + int16_t calctmp[D_NSC1RB*2]={0}; + + for (i=0; i<D_NSC1RB; i++) { + for(k=0; k<D_NSC1RB; k++) { + tmp[0] = alphaTBL_re[(12-((i*k)%12))%12]; + tmp[1] = alphaTBL_im[(12-((i*k)%12))%12]; + + calctmp[2*i] += (((int32_t)x[2*k] * tmp[0] - (int32_t)x[2*k+1] * tmp[1])>>15); + calctmp[2*i+1] += (((int32_t)x[2*k+1] * tmp[0] + (int32_t)x[2*k] * tmp[1])>>15); + } + y[2*i] = (int16_t)( (double) calctmp[2*i] / sqrt(D_NSC1RB)); + y[2*i+1] = (int16_t)((double) calctmp[2*i+1] / sqrt(D_NSC1RB)); + } +} + +void generate_pucch3x(int32_t **txdataF, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t ncs_cell[20][7], + PUCCH_FMT_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint16_t n3_pucch, + uint8_t shortened_format, + uint8_t *payload, + int16_t amp, + uint8_t subframe, + uint16_t rnti) +{ + + uint32_t u, v; + uint16_t i, j, re_offset; + uint32_t z[12*14], *zptr; + uint32_t y_tilda[12*14]={}, *y_tilda_ptr; + uint8_t ns, nsymb, n_oc, n_oc0, n_oc1; + uint8_t N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; + uint8_t m, l; + uint8_t n_cs; + int16_t tmp_re, tmp_im, W_re=0, W_im=0; + int32_t *txptr; + uint32_t symbol_offset; + + uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; + uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; + uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; + uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + + // variables for channel coding + uint8_t chcod_tbl_idx = 0; + //uint8_t chcod_dt[48] = {}; + + // variables for Scrambling + uint32_t cinit = 0; + uint32_t x1; + uint32_t s,s0,s1; + uint8_t C[48] ={}; + uint8_t scr_dt[48]={}; + + // variables for Modulation + int16_t d_re[24]={}; + int16_t d_im[24]={}; + + // variables for orthogonal sequence selection + uint8_t N_PUCCH_SF0 = 5; + uint8_t N_PUCCH_SF1 = (shortened_format==0)? 5:4; + uint8_t first_slot = 0; + int16_t rot_re=0; + int16_t rot_im=0; + + uint8_t dt_offset; + uint8_t sym_offset; + int16_t y_re[14][12]; //={0}; + int16_t y_im[14][12]; //={0}; + + // DMRS + uint8_t alpha_idx=0; + uint8_t m_alpha_idx=0; + + // TODO + // "SR+ACK/NACK" length is only 7 bits. + // This restriction will be lifted in the future. + // "CQI/PMI/RI+ACK/NACK" will be supported in the future. + + // Channel Coding + for (uint8_t i=0; i<7; i++) { + chcod_tbl_idx += (payload[i]<<i); + } + + // Scrambling + cinit = (subframe + 1) * ((2 * frame_parms->Nid_cell + 1)<<16) + rnti; + s0 = lte_gold_generic(&x1,&cinit,1); + s1 = lte_gold_generic(&x1,&cinit,0); + + for (i=0; i<48; i++) { + s = (i<32)? s0:s1; + j = (i<32)? i:(i-32); + C[i] = ((s>>j)&1); + } + + for (i=0; i<48; i++) { + scr_dt[i] = chcod_tbl[chcod_tbl_idx][i] ^ C[i]; + } + + // Modulation + for (uint8_t i=0; i<48; i+=2){ + if (scr_dt[i]==0 && scr_dt[i+1]==0){ + d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); + d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); + } else if (scr_dt[i]==0 && scr_dt[i+1]==1) { + d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); + d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp) >>15); + } else if (scr_dt[i]==1 && scr_dt[i+1]==0) { + d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); + d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp)>>15); + } else if (scr_dt[i]==1 && scr_dt[i+1]==1) { + d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); + d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); + } else { + //***log Modulation Error! + } + } + + // Calculate Orthogonal Sequence index + n_oc0 = n3_pucch % N_PUCCH_SF1; + if (N_PUCCH_SF1 == 5) { + n_oc1 = (3 * n_oc0) % N_PUCCH_SF1; + } else { + n_oc1 = n_oc0 % N_PUCCH_SF1; + } + + y_tilda_ptr = y_tilda; + zptr = z; + + // loop over 2 slots + for (ns=(subframe<<1), u=u0, v=v0; ns<(2+(subframe<<1)); ns++, u=u1, v=v1) { + first_slot = (ns==(subframe<<1))?1:0; + + //loop over symbols in slot + for (l=0; l<N_UL_symb; l++) { + rot_re = RotTBL_re[(uint8_t) ncs_cell[ns][l]/64] ; + rot_im = RotTBL_im[(uint8_t) ncs_cell[ns][l]/64] ; + + // Comput W_noc(m) (36.211 p. 19) + if ( first_slot == 0 && shortened_format==1) { // second slot and shortened format + n_oc = n_oc1; + + if (l<1) { // data + W_re=W4_fmt3[n_oc][l]; + W_im=0; + } else if (l==1) { // DMRS + W_re=W2[0]; + W_im=0; + } else if (l>=2 && l<5) { // data + W_re=W4_fmt3[n_oc][l-1]; + W_im=0; + } else if (l==5) { // DMRS + W_re=W2[1]; + W_im=0; + } else if ((l>=N_UL_symb-2)) { // data + ; + } else { + //***log W Select Error! + } + } else { + if (first_slot == 1) { // 1st slot or 2nd slot and not shortened + n_oc=n_oc0; + } else { + n_oc=n_oc1; + } + + if (l<1) { // data + W_re=W5_fmt3_re[n_oc][l]; + W_im=W5_fmt3_im[n_oc][l]; + } else if (l==1) { // DMRS + W_re=W2[0]; + W_im=0; + } else if (l>=2 && l<5) { // data + W_re=W5_fmt3_re[n_oc][l-1]; + W_im=W5_fmt3_im[n_oc][l-1]; + } else if (l==5) { // DMRS + W_re=W2[1]; + W_im=0; + } else if ((l>=N_UL_symb-1)) { // data + W_re=W5_fmt3_re[n_oc][l-N_UL_symb+5]; + W_im=W5_fmt3_im[n_oc][l-N_UL_symb+5]; + } else { + //***log W Select Error! + } + } // W Selection end + + // Compute n_cs (36.211 p. 18) + n_cs = ncs_cell[ns][l]; + if (N_PUCCH_SF1 == 5) { + alpha_idx = (n_cs + Np5_TBL[n_oc]) % 12; + } else { + alpha_idx = (n_cs + Np4_TBL[n_oc]) % 12; + } + + // generate pucch data + dt_offset = (first_slot == 1) ? 0:12; + sym_offset = (first_slot == 1) ? 0:7; + + for (i=0; i<12; i++) { + // Calculate yn(i) + tmp_re = (((int32_t) (W_re*rot_re - W_im*rot_im)) >>15); + tmp_im = (((int32_t) (W_re*rot_im + W_im*rot_re)) >>15); + y_re[l+sym_offset][i] = (((int32_t) (tmp_re*d_re[i+dt_offset] - tmp_im*d_im[i+dt_offset]))>>15); + y_im[l+sym_offset][i] = (((int32_t) (tmp_re*d_im[i+dt_offset] + tmp_im*d_re[i+dt_offset]))>>15); + + // cyclic shift + ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[0] = y_re[l+sym_offset][i]; + ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[1] = y_im[l+sym_offset][i]; + + // DMRS + m_alpha_idx = (alpha_idx * i) % 12; + if (l==1 || l==5) { + ((int16_t *)&zptr[(l+sym_offset)*12+i])[0] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][i<<1] - (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][1+(i<<1)])>>15) * (int32_t)amp)>>15); + ((int16_t *)&zptr[(l+sym_offset)*12+i])[1] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][1+(i<<1)] + (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][i<<1])>>15) * (int32_t)amp)>>15); + } + } + + } // l loop + } // ns + + // DFT for pucch-data + for (l=0; l<14; l++) { + if (l==1 || l==5 || l==8 || l==12) { + ; + } else { + pucchfmt3_Dft((int16_t*)&y_tilda_ptr[l*12],(int16_t*)&zptr[l*12]); + } + } + + + // Mapping + m = n3_pucch / N_PUCCH_SF0; + + if (shortened_format == 1) { + nsymb = (N_UL_symb<<1) - 1; + } else { + nsymb = (N_UL_symb<<1); + } + + for (j=0,l=0; l<(nsymb); l++) { + + if ((l<7) && ((m&1) == 0)) + re_offset = (m*6) + frame_parms->first_carrier_offset; + else if ((l<7) && ((m&1) == 1)) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else if ((m&1) == 0) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else + re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; + + if (re_offset > frame_parms->ofdm_symbol_size) + re_offset -= (frame_parms->ofdm_symbol_size); + + symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*14)); + txptr = &txdataF[0][symbol_offset]; + + for (i=0; i<12; i++,j++) { + txptr[re_offset++] = z[j]; + + if (re_offset==frame_parms->ofdm_symbol_size) + re_offset = 0; + +#ifdef DEBUG_PUCCH_TX + msg("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); +#endif + } + } + +} + + + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..03df4e7f690e86b00cd8d39e3d58a9ddf1db267c --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c @@ -0,0 +1,207 @@ +/* + * 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/LTE_UE_TRANSPORT/rar_tools_ue.c +* \brief Routine for filling the PUSCH/ULSCH data structures based on a random-access response (RAR) SDU from MAC. Note this is for UE +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "LAYER2/MAC/mac.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "transport_proto_ue.h" + +#include "assertions.h" + +extern uint16_t RIV2nb_rb_LUT6[32]; +extern uint16_t RIV2first_rb_LUT6[32]; +extern uint16_t RIV2nb_rb_LUT25[512]; +extern uint16_t RIV2first_rb_LUT25[512]; +extern uint16_t RIV2nb_rb_LUT50[1600]; +extern uint16_t RIV2first_rb_LUT50[1600]; +extern uint16_t RIV2nb_rb_LUT100[6000]; +extern uint16_t RIV2first_rb_LUT100[600]; + +extern uint16_t RIV_max6,RIV_max25,RIV_max50,RIV_max100; + +int8_t delta_PUSCH_msg2[8] = {-6,-4,-2,0,2,4,6,8}; + +int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, + unsigned char eNB_id ) +{ + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_IN); + + // RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)rar_pdu; + uint8_t transmission_mode = ue->transmission_mode[eNB_id]; + unsigned char *rar_pdu = ue->dlsch_ra[eNB_id]->harq_processes[0]->b; + unsigned char subframe = ue->ulsch_Msg3_subframe[eNB_id]; + LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + PHY_MEASUREMENTS *meas = &ue->measurements; + + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + // int current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; + + uint8_t *rar = (uint8_t *)(rar_pdu+1); + uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_tx,subframe); + uint16_t rballoc; + uint8_t cqireq; + uint16_t *RIV2nb_rb_LUT, *RIV2first_rb_LUT; + uint16_t RIV_max = 0; + + LOG_D(PHY,"[eNB][RAPROC] Frame %d: generate_ue_ulsch_params_from_rar: subframe %d (harq_pid %d)\n",proc->frame_tx,subframe,harq_pid); + + switch (frame_parms->N_RB_DL) { + case 6: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT6[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT6[0]; + RIV_max = RIV_max6; + break; + + case 25: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT25[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT25[0]; + RIV_max = RIV_max25; + break; + + case 50: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT50[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT50[0]; + RIV_max = RIV_max50; + break; + + case 100: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT100[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT100[0]; + RIV_max = RIV_max100; + break; + + default: + DevParam(frame_parms->N_RB_DL, eNB_id, harq_pid); + break; + } + + + + ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7;//rar->TPC; + + rballoc = (((uint16_t)(rar[1]&7))<<7)|(rar[2]>>1); + cqireq=rar[3]&1; + + if (rballoc>RIV_max) { + LOG_D(PHY,"rar_tools.c: ERROR: rb_alloc (%x) > RIV_max\n",rballoc); + return(-1); + } + + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; + + AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb >0, "nb_rb == 0\n"); + + ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb]; + + AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb <= 6,"unlikely rb count for RAR grant : nb_rb > 6\n"); + + // ulsch->harq_processes[harq_pid]->Ndi = 1; + if (ulsch->harq_processes[harq_pid]->round == 0) + ulsch->harq_processes[harq_pid]->status = ACTIVE; + + if (cqireq==1) { + ulsch->O_RI = 1; + + if (meas->rank[eNB_id] == 1) { + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->o_RI[0] = 1; + } else { + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + ulsch->o_RI[0] = 0; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + fill_CQI(ulsch,meas,eNB_id,0,ue->frame_parms.N_RB_DL,0, transmission_mode,ue->sinr_eff); + + if (((proc->frame_tx % 100) == 0) || (proc->frame_tx < 10)) + print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); + } else { + ulsch->O_RI = 0; + ulsch->O = 0; + } + + ulsch->harq_processes[harq_pid]->O_ACK = 0;//2; + + ulsch->beta_offset_cqi_times8 = 18; + ulsch->beta_offset_ri_times8 = 10; + ulsch->beta_offset_harqack_times8 = 16; + + ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1); + ulsch->rnti = (((uint16_t)rar[4])<<8)+rar[5]; //rar->t_crnti; + + if (ulsch->harq_processes[harq_pid]->round == 0) { + ulsch->harq_processes[harq_pid]->status = ACTIVE; + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->mcs = ((rar[2]&1)<<3)|(rar[3]>>5); + ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7; + //ulsch->harq_processes[harq_pid]->TBS = dlsch_tbs25[ulsch->harq_processes[harq_pid]->mcs][ulsch->harq_processes[harq_pid]->nb_rb-1]; + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; + ulsch->harq_processes[harq_pid]->Nsymb_initial = 9; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->round++; + } + + // initialize power control based on PRACH power + ulsch->f_pusch = delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC] + + get_deltaP_rampup(ue->Mod_id,ue->CC_id); + LOG_D(PHY,"[UE %d][PUSCH PC] Initializing f_pusch to %d dB, TPC %d (delta_PUSCH_msg2 %d dB), deltaP_rampup %d dB\n", + ue->Mod_id,ulsch->f_pusch,ulsch->harq_processes[harq_pid]->TPC,delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC], + get_deltaP_rampup(ue->Mod_id,ue->CC_id)); + + + //#ifdef DEBUG_RAR + LOG_D(PHY,"ulsch ra (UE): harq_pid %d\n",harq_pid); + LOG_D(PHY,"ulsch ra (UE): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); + LOG_D(PHY,"ulsch ra (UE): first_rb %x\n",ulsch->harq_processes[harq_pid]->first_rb); + LOG_D(PHY,"ulsch ra (UE): nb_rb %d\n",ulsch->harq_processes[harq_pid]->nb_rb); + LOG_D(PHY,"ulsch ra (UE): round %d\n",ulsch->harq_processes[harq_pid]->round); + LOG_D(PHY,"ulsch ra (UE): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); + LOG_D(PHY,"ulsch ra (UE): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); + LOG_D(PHY,"ulsch ra (UE): TPC %d\n",ulsch->harq_processes[harq_pid]->TPC); + LOG_D(PHY,"ulsch ra (UE): O %d\n",ulsch->O); + LOG_D(PHY,"ulsch ra (UE): ORI %d\n",ulsch->O_RI); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_OUT); + + //#endif + return(0); +} + diff --git a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/srs_modulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c index c4c02e631279a3833da27c1b2aedceb431e55b7d..45508fcff27eb5ee25e6694b8903f114e2edcb19 100644 --- a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c @@ -29,8 +29,8 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "UTIL/LOG/log.h" unsigned short msrsb_6_40[8][4] = {{36,12,4,4}, diff --git a/openair1/PHY/LTE_UE_TRANSPORT/sss_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/sss_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..aee5d6bcf91a37fc50710f63c8cfb4d6048a8153 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/sss_ue.c @@ -0,0 +1,421 @@ +/* + * 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/LTE_TRANSPORT/sss_ue.c +* \brief Top-level routines for decoding the secondary synchronization signal (SSS) V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "transport_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/MODULATION/modulation_UE.h" + +//#define DEBUG_SSS + + + + +int pss_ch_est(PHY_VARS_UE *ue, + int32_t pss_ext[4][72], + int32_t sss_ext[4][72]) +{ + + int16_t *pss; + int16_t *pss_ext2,*sss_ext2,*sss_ext3,tmp_re,tmp_im,tmp_re2,tmp_im2; + uint8_t aarx,i; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + + switch (ue->common_vars.eNb_id) { + + case 0: + pss = &primary_synch0[10]; + break; + + case 1: + pss = &primary_synch1[10]; + break; + + case 2: + pss = &primary_synch2[10]; + break; + + default: + pss = &primary_synch0[10]; + break; + } + + sss_ext3 = (int16_t*)&sss_ext[0][5]; + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + sss_ext2 = (int16_t*)&sss_ext[aarx][5]; + pss_ext2 = (int16_t*)&pss_ext[aarx][5]; + + for (i=0; i<62; i++) { + + // This is H*(PSS) = R* \cdot PSS + tmp_re = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[i<<1])>>15) + ((pss_ext2[1+(i<<1)] * (int32_t)pss[1+(i<<1)])>>15)); + tmp_im = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[1+(i<<1)])>>15) - ((pss_ext2[1+(i<<1)] * (int32_t)pss[(i<<1)])>>15)); + // printf("H*(%d,%d) : (%d,%d)\n",aarx,i,tmp_re,tmp_im); + // This is R(SSS) \cdot H*(PSS) + tmp_re2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[i<<1])>>15) - ((tmp_im * (int32_t)sss_ext2[1+(i<<1)]>>15))); + tmp_im2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[1+(i<<1)])>>15) + ((tmp_im * (int32_t)sss_ext2[(i<<1)]>>15))); + + // printf("SSSi(%d,%d) : (%d,%d)\n",aarx,i,sss_ext2[i<<1],sss_ext2[1+(i<<1)]); + // printf("SSSo(%d,%d) : (%d,%d)\n",aarx,i,tmp_re2,tmp_im2); + // MRC on RX antennas + if (aarx==0) { + sss_ext3[i<<1] = tmp_re2; + sss_ext3[1+(i<<1)] = tmp_im2; + } else { + sss_ext3[i<<1] += tmp_re2; + sss_ext3[1+(i<<1)] += tmp_im2; + } + } + } + + // sss_ext now contains the compensated SSS + return(0); +} + + +int _do_pss_sss_extract(PHY_VARS_UE *ue, + int32_t pss_ext[4][72], + int32_t sss_ext[4][72], + uint8_t doPss, uint8_t doSss, + uint8_t subframe) // add flag to indicate extracting only PSS, only SSS, or both +{ + + + + uint16_t rb,nb_rb=6; + uint8_t i,aarx; + int32_t *pss_rxF,*pss_rxF_ext; + int32_t *sss_rxF,*sss_rxF_ext; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + uint8_t next_thread_id = ue->current_thread_id[subframe]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[subframe]+1); + + int rx_offset = frame_parms->ofdm_symbol_size-3*12; + uint8_t pss_symb,sss_symb; + + int32_t **rxdataF; + + //LOG_I(PHY,"do_pss_sss_extract subframe %d \n",subframe); + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (frame_parms->frame_type == FDD) { + pss_symb = 6-frame_parms->Ncp; + sss_symb = pss_symb-1; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + + } else { + pss_symb = 2; + sss_symb = frame_parms->symbols_per_tti-1; + + if(subframe==5 || subframe==0) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else if(subframe==6 || subframe==1) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else + { + AssertFatal(0,""); + } + + } + //printf("extract_rbs: symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",symbol_mod, + // (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, + // LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); + + pss_rxF_ext = &pss_ext[aarx][0]; + sss_rxF_ext = &sss_ext[aarx][0]; + + for (rb=0; rb<nb_rb; rb++) { + // skip DC carrier + if (rb==3) { + if(frame_parms->frame_type == FDD) + { + sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else + { + if(subframe==5 || subframe==0) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else if(subframe==6 || subframe==1) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else + { + AssertFatal(0,""); + } + } + } + + for (i=0; i<12; i++) { + if (doPss) {pss_rxF_ext[i]=pss_rxF[i];} + if (doSss) {sss_rxF_ext[i]=sss_rxF[i];} + } + + pss_rxF+=12; + sss_rxF+=12; + pss_rxF_ext+=12; + sss_rxF_ext+=12; + } + + } + + return(0); +} + +int pss_sss_extract(PHY_VARS_UE *phy_vars_ue, + int32_t pss_ext[4][72], + int32_t sss_ext[4][72], + uint8_t subframe) +{ + return _do_pss_sss_extract(phy_vars_ue, pss_ext, sss_ext, 1 /* doPss */, 1 /* doSss */, subframe); +} + +int pss_only_extract(PHY_VARS_UE *phy_vars_ue, + int32_t pss_ext[4][72], + uint8_t subframe) +{ + static int32_t dummy[4][72]; + return _do_pss_sss_extract(phy_vars_ue, pss_ext, dummy, 1 /* doPss */, 0 /* doSss */, subframe); +} + + +int sss_only_extract(PHY_VARS_UE *phy_vars_ue, + int32_t sss_ext[4][72], + uint8_t subframe) +{ + static int32_t dummy[4][72]; + return _do_pss_sss_extract(phy_vars_ue, dummy, sss_ext, 0 /* doPss */, 1 /* doSss */, subframe); +} + + +int16_t phase_re[7] = {16383, 25101, 30791, 32767, 30791, 25101, 16383}; +int16_t phase_im[7] = {-28378, -21063, -11208, 0, 11207, 21062, 28377}; + + +int rx_sss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *flip_max,uint8_t *phase_max) +{ + + uint8_t i; + int32_t pss_ext[4][72]; + int32_t sss0_ext[4][72],sss5_ext[4][72]; + uint8_t Nid2 = ue->common_vars.eNb_id; + uint8_t flip,phase; + uint16_t Nid1; + int16_t *sss0,*sss5; + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + int32_t metric; + int16_t *d0,*d5; + + if (frame_parms->frame_type == FDD) { +#ifdef DEBUG_SSS + + if (frame_parms->Ncp == NORMAL) + msg("[PHY][UE%d] Doing SSS for FDD Normal Prefix\n",ue->Mod_id); + else + msg("[PHY][UE%d] Doing SSS for FDD Extended Prefix\n",ue->Mod_id); + +#endif + // Do FFTs for SSS/PSS + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-2, // second to last symbol of + 0, // slot 0 + ue->rx_offset, + 0, + 1); + // PSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-1, // last symbol of + 0, // slot 0 + ue->rx_offset, + 0, + 1); + } else { // TDD +#ifdef DEBUG_SSS + if (ue->frame_parms->Ncp == NORMAL) + msg("[PHY][UE%d] Doing SSS for TDD Normal Prefix\n",ue->Mod_id); + else + msg("[PHY][UE%d] Doing SSS for TDD Extended Prefix\n",ue->Mod_id); + +#endif + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti>>1)-1, // last symbol of + 1, // slot 1 + ue->rx_offset, + 0, + 1); + // PSS + slot_fep(ue, + 2, // symbol 2 of + 2, // slot 2 + ue->rx_offset, + 0, + 1); + } + // pss sss extract for subframe 0 + pss_sss_extract(ue, + pss_ext, + sss0_ext,0); + /* + write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata[0][0],ue->frame_parms.samples_per_tti,1,1); + write_output("rxdataF0.m","rxF0",&ue->common_vars.rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,2,1); + write_output("pss_ext0.m","pssext0",pss_ext,72,1,1); + write_output("sss0_ext0.m","sss0ext0",sss0_ext,72,1,1); + */ + + // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS + // and do channel estimation and compensation based on PSS + + pss_ch_est(ue, + pss_ext, + sss0_ext); + + // write_output("sss0_comp0.m","sss0comp0",sss0_ext,72,1,1); + + if (ue->frame_parms.frame_type == FDD) { // FDD + + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-2, + 10, + ue->rx_offset, + 0,1); + // PSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-1, + 10, + ue->rx_offset, + 0,1); + } else { // TDD + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti>>1)-1, + 11, + ue->rx_offset, + 0, + 1); + // PSS + slot_fep(ue, + 2, + 12, + ue->rx_offset, + 0, + 1); + } + + // pss sss extract for subframe 5 + pss_sss_extract(ue, + pss_ext, + sss5_ext,5); + + // write_output("sss5_ext0.m","sss5ext0",sss5_ext,72,1,1); + // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS + // and do channel estimation and compensation based on PSS + + pss_ch_est(ue, + pss_ext, + sss5_ext); + + + + // now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h + + *tot_metric = -99999999; + + + sss0 = (int16_t*)&sss0_ext[0][5]; + sss5 = (int16_t*)&sss5_ext[0][5]; + + for (flip=0; flip<2; flip++) { // d0/d5 flip in RX frame + for (phase=0; phase<7; phase++) { // phase offset between PSS and SSS + for (Nid1 = 0 ; Nid1 <= 167; Nid1++) { // 168 possible Nid1 values + metric = 0; + + if (flip==0) { + d0 = &d0_sss[62*(Nid2 + (Nid1*3))]; + d5 = &d5_sss[62*(Nid2 + (Nid1*3))]; + } else { + d5 = &d0_sss[62*(Nid2 + (Nid1*3))]; + d0 = &d5_sss[62*(Nid2 + (Nid1*3))]; + } + + // This is the inner product using one particular value of each unknown parameter + for (i=0; i<62; i++) { + metric += (int16_t)(((d0[i]*((((phase_re[phase]*(int32_t)sss0[i<<1])>>19)-((phase_im[phase]*(int32_t)sss0[1+(i<<1)])>>19)))) + + (d5[i]*((((phase_re[phase]*(int32_t)sss5[i<<1])>>19)-((phase_im[phase]*(int32_t)sss5[1+(i<<1)])>>19)))))); + } + + // if the current metric is better than the last save it + if (metric > *tot_metric) { + *tot_metric = metric; + ue->frame_parms.Nid_cell = Nid2+(3*Nid1); + *phase_max = phase; + *flip_max=flip; +#ifdef DEBUG_SSS + msg("(flip,phase,Nid1) (%d,%d,%d), metric_phase %d tot_metric %d, phase_max %d, flip_max %d\n",flip,phase,Nid1,metric,*tot_metric,*phase_max,*flip_max); +#endif + + } + } + } + } + + return(0); +} + diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h similarity index 73% rename from openair1/PHY/LTE_TRANSPORT/proto.h rename to openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h index 91806667d268b26a0d6da09e3de431079ec30b5e..9b3a95a14a9f0814e8fc0ea81b78dda0427ca868 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -/*! \file PHY/LTE_TRANSPORT/proto.h +/*! \file PHY/LTE_UE_TRANSPORT/transport_proto_ue.h * \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03 * \author R. Knopp, F. Kaltenberger * \date 2011 @@ -29,9 +29,10 @@ * \note * \warning */ -#ifndef __LTE_TRANSPORT_PROTO__H__ -#define __LTE_TRANSPORT_PROTO__H__ -#include "PHY/defs.h" +#ifndef __LTE_TRANSPORT_PROTO_UE__H__ +#define __LTE_TRANSPORT_PROTO_UE__H__ +#include "PHY/defs_UE.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" #include <math.h> #include "nfapi_interface.h" @@ -41,26 +42,6 @@ * @{ */ -/** \fn free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch,unsigned char N_RB_DL) - \brief This function frees memory allocated for a particular DLSCH at eNB - @param dlsch Pointer to DLSCH to be removed -*/ -void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch); - -void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); - -/** \fn new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms) - \brief This function allocates structures for a particular DLSCH at eNB - @returns Pointer to DLSCH to be removed - @param Kmimo Kmimo factor from 36-212/36-213 - @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) - @param Nsoft Soft-LLR buffer size from UE-Category - @params N_RB_DL total number of resource blocks (determine the operating BW) - @param abstraction_flag Flag to indicate abstracted interface - @param frame_parms Pointer to frame descriptor structure -*/ -LTE_eNB_DLSCH_t *new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms); - /** \fn free_ue_dlsch(LTE_UE_DLSCH_t *dlsch) \brief This function frees memory allocated for a particular DLSCH at UE @param dlsch Pointer to DLSCH to be removed @@ -68,7 +49,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch); /** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag) - \brief This function allocates structures for a particular DLSCH at eNB + \brief This function allocates structures for a particular DLSCH at UE @returns Pointer to DLSCH to be removed @param Kmimo Kmimo factor from 36-212/36-213 @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) @@ -79,297 +60,13 @@ void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch); LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag); -void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); - void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch); -/** \fn free_eNB_ulsch(LTE_eNB_DLSCH_t *dlsch) - \brief This function frees memory allocated for a particular ULSCH at eNB - @param ulsch Pointer to ULSCH to be removed -*/ -void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch); - -LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag); -/** \fn dlsch_encoding(PHY_VARS_eNB *eNB, - uint8_t *input_buffer, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe) - \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). The implemented functions are: - - CRC computation and addition - - Code block segmentation and sub-block CRC addition - - Channel coding (Turbo coding) - - Rate matching (sub-block interleaving, bit collection, selection and transmission - - Code block concatenation - @param eNB Pointer to eNB PHY context - @param input_buffer Pointer to input buffer for sub-frame - @param frame_parms Pointer to frame descriptor structure - @param num_pdcch_symbols Number of PDCCH symbols in this subframe - @param dlsch Pointer to dlsch to be encoded - @param frame Frame number - @param subframe Subframe number - @param rm_stats Time statistics for rate-matching - @param te_stats Time statistics for turbo-encoding - @param i_stats Time statistics for interleaving - @returns status -*/ -int32_t dlsch_encoding(PHY_VARS_eNB *eNB, - uint8_t *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *i_stats); - -int32_t dlsch_encoding_all(PHY_VARS_eNB *eNB, - uint8_t *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *te_wait_stats, - time_stats_t *te_main_stats, - time_stats_t *te_wakeup_stats0, - time_stats_t *te_wakeup_stats1, - time_stats_t *i_stats); - -int32_t dlsch_encoding_SIC(PHY_VARS_UE *ue, - uint8_t *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *i_stats); - - - -/** \fn dlsch_encoding_2threads(PHY_VARS_eNB *eNB, - uint8_t *input_buffer, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe) - \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). This version spawns 1 worker thread. The implemented functions are: - - CRC computation and addition - - Code block segmentation and sub-block CRC addition - - Channel coding (Turbo coding) - - Rate matching (sub-block interleaving, bit collection, selection and transmission - - Code block concatenation - @param eNB Pointer to eNB PHY context - @param input_buffer Pointer to input buffer for sub-frame - @param num_pdcch_symbols Number of PDCCH symbols in this subframe - @param dlsch Pointer to dlsch to be encoded - @param frame Frame number - @param subframe Subframe number - @param rm_stats Time statistics for rate-matching - @param te_stats Time statistics for turbo-encoding - @param i_stats Time statistics for interleaving - @returns status -*/ -int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, - uint8_t *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *te_wait_stats, - time_stats_t *te_main_stats, - time_stats_t *te_wakeup_stats0, - time_stats_t *te_wakeup_stats1, - time_stats_t *i_stats, - int worker_num); - -void dlsch_encoding_emul(PHY_VARS_eNB *phy_vars_eNB, - uint8_t *DLSCH_pdu, - LTE_eNB_DLSCH_t *dlsch); - - -// Functions below implement 36-211 - -/** \fn allocate_REs_in_RB(int32_t **txdataF, - uint32_t *jj, - uint32_t *jj2, - uint16_t re_offset, - uint32_t symbol_offset, - LTE_DL_eNB_HARQ_t *dlsch0_harq, - LTE_DL_eNB_HARQ_t *dlsch1_harq, - uint8_t pilots, - int16_t amp, - int16_t *qam_table_s, - uint32_t *re_allocated, - uint8_t skip_dc, - uint8_t skip_half, - uint8_t use2ndpilots, - LTE_DL_FRAME_PARMS *frame_parms); - - \brief Fills RB with data - \param txdataF pointer to output data (frequency domain signal) - \param jj index to output (from CW 1) - \param jj2 index to output (from CW 2) - \param re_offset index of the first RE of the RB - \param symbol_offset index to the OFDM symbol - \param dlsch0_harq Pointer to Transport block 0 HARQ structure - \param dlsch0_harq Pointer to Transport block 1 HARQ structure - \param pilots =1 if symbol_offset is an OFDM symbol that contains pilots, 0 otherwise - \param amp Amplitude for symbols - \param qam_table_s0 pointer to scaled QAM table for Transport Block 0 (by rho_a or rho_b) - \param qam_table_s1 pointer to scaled QAM table for Transport Block 1 (by rho_a or rho_b) - \param re_allocated pointer to allocation counter - \param skip_dc offset for positive RBs - \param skip_half indicate that first or second half of RB must be skipped for PBCH/PSS/SSS - \param ue_spec_rs UE specific RS indicator - \param nb_antennas_tx_phy Physical antenna elements which can be different with antenna port number, especially in beamforming case - \param use2ndpilots Set to use the pilots from antenna port 1 for PDSCH - \param frame_parms Frame parameter descriptor -*/ - -// Functions below implement 36-211 - -/** \fn allocate_REs_in_RB(int32_t **txdataF, - uint32_t *jj, - uint32_t *jj2, - uint16_t re_offset, - uint32_t symbol_offset, - LTE_DL_eNB_HARQ_t *dlsch0_harq, - LTE_DL_eNB_HARQ_t *dlsch1_harq, - uint8_t pilots, - int16_t amp, - int16_t *qam_table_s, - uint32_t *re_allocated, - uint8_t skip_dc, - uint8_t skip_half, - uint8_t use2ndpilots, - LTE_DL_FRAME_PARMS *frame_parms); - - \brief Fills RB with data - \param txdataF pointer to output data (frequency domain signal) - \param jj index to output (from CW 1) - \param jj index to output (from CW 2) - \param re_offset index of the first RE of the RB - \param symbol_offset index to the OFDM symbol - \param dlsch0_harq Pointer to Transport block 0 HARQ structure - \param dlsch0_harq Pointer to Transport block 1 HARQ structure - \param pilots =1 if symbol_offset is an OFDM symbol that contains pilots, 0 otherwise - \param amp Amplitude for symbols - \param qam_table_s0 pointer to scaled QAM table for Transport Block 0 (by rho_a or rho_b) - \param qam_table_s1 pointer to scaled QAM table for Transport Block 1 (by rho_a or rho_b) - \param re_allocated pointer to allocation counter - \param skip_dc offset for positive RBs - \param skip_half indicate that first or second half of RB must be skipped for PBCH/PSS/SSS - \param use2ndpilots Set to use the pilots from antenna port 1 for PDSCH - \param frame_parms Frame parameter descriptor -*/ - -int32_t allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, - int32_t **txdataF, - uint32_t *jj, - uint32_t *jj2, - uint16_t re_offset, - uint32_t symbol_offset, - LTE_DL_eNB_HARQ_t *dlsch0_harq, - LTE_DL_eNB_HARQ_t *dlsch1_harq, - uint8_t pilots, - int16_t amp, - uint8_t precoder_index, - int16_t *qam_table_s0, - int16_t *qam_table_s1, - uint32_t *re_allocated, - uint8_t skip_dc, - uint8_t skip_half, - uint8_t lprime, - uint8_t mprime, - uint8_t Ns, - int *P1_SHIFT, - int *P2_SHIFT); - - -/** \fn int32_t dlsch_modulation(int32_t **txdataF, - int16_t amp, - uint32_t sub_frame_offset, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch); - - \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for DLSCH. - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param sub_frame_offset Offset of this subframe in units of subframes (usually 0) - @param frame_parms Pointer to frame descriptor - @param num_pdcch_symbols Number of PDCCH symbols in this subframe - @param dlsch0 Pointer to Transport Block 0 DLSCH descriptor for this allocation - @param dlsch1 Pointer to Transport Block 0 DLSCH descriptor for this allocation -*/ -int32_t dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint32_t sub_frame_offset, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch0, - LTE_eNB_DLSCH_t *dlsch1); - -int32_t dlsch_modulation_SIC(int32_t **sic_buffer, - uint32_t sub_frame_offset, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch0, - int G); -/* - \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for MCH. - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param subframe_offset Offset of this subframe in units of subframes (usually 0) - @param frame_parms Pointer to frame descriptor - @param dlsch Pointer to DLSCH descriptor for this allocation -*/ -int mch_modulation(int32_t **txdataF, - int16_t amp, - uint32_t subframe_offset, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_eNB_DLSCH_t *dlsch); - -/** \brief Top-level generation function for eNB TX of MBSFN - @param phy_vars_eNB Pointer to eNB variables - @param a Pointer to transport block - @param abstraction_flag +void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id); -*/ -void generate_mch(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,uint8_t *a); - -/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) - @param phy_vars_eNB Pointer to eNB variables - @param proc Pointer to RXn-TXnp4 proc information - @param mcs MCS for MBSFN - @param ndi new data indicator - @param rdvix -*/ -void fill_eNB_dlsch_MCH(PHY_VARS_eNB *phy_vars_eNB,int mcs,int ndi,int rvidx); - -/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) - @param phy_vars_ue Pointer to UE variables - @param mcs MCS for MBSFN - @param eNB_id index of eNB in ue variables -*/ -void fill_UE_dlsch_MCH(PHY_VARS_UE *phy_vars_ue,int mcs,int ndi,int rvidx,int eNB_id); - -/** \brief Receiver processing for MBSFN, symbols can be done separately for time/CPU-scheduling purposes - @param phy_vars_ue Pointer to UE variables - @param eNB_id index of eNB in ue variables - @param subframe Subframe index of PMCH - @param symbol Symbol index on which to act -*/ int rx_pmch(PHY_VARS_UE *phy_vars_ue, unsigned char eNB_id, uint8_t subframe, @@ -385,66 +82,6 @@ int rx_pmch(PHY_VARS_UE *phy_vars_ue, void dump_mch(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe); -/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) - for N subframes. - @param phy_vars_eNB Pointer to eNB variables - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param N Number of sub-frames to generate -*/ -void generate_pilots(PHY_VARS_eNB *phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint16_t N); - -/** - \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) for one slot only - @param phy_vars_eNB Pointer to eNB variables - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param slot index (0..19) - @param first_pilot_only (0 no) -*/ -int32_t generate_pilots_slot(PHY_VARS_eNB *phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint16_t slot, - int first_pilot_only); - -int32_t generate_mbsfn_pilot(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - int32_t **txdataF, - int16_t amp); - -void generate_ue_spec_pilots(PHY_VARS_eNB *phy_vars_eNB, - uint8_t UE_id, - int32_t **txdataF, - int16_t amp, - uint16_t Ntti, - uint8_t beamforming_mode); - -int32_t generate_pss(int32_t **txdataF, - int16_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - uint16_t l, - uint16_t Ns); - -int32_t generate_pss_emul(PHY_VARS_eNB *phy_vars_eNB,uint8_t sect_id); - -int32_t generate_sss(int32_t **txdataF, - short amp, - LTE_DL_FRAME_PARMS *frame_parms, - unsigned short symbol, - unsigned short slot_offset); - -int32_t generate_pbch(LTE_eNB_PBCH *eNB_pbch, - int32_t **txdataF, - int32_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t *pbch_pdu, - uint8_t frame_mod4); - -int32_t generate_pbch_emul(PHY_VARS_eNB *phy_vars_eNB,uint8_t *pbch_pdu); /** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception. @param stream0_in Input from channel compensated (MR combined) stream 0 @@ -1351,6 +988,7 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, uint8_t is_crnti, uint8_t llr8_flag); + uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue, uint8_t subframe, PDSCH_t dlsch_id, @@ -1390,8 +1028,7 @@ int32_t rx_pdcch(PHY_VARS_UE *ue, uint8_t subframe, uint8_t eNB_id, MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t is_secondary_ue); + uint32_t high_speed_flag); /*! \brief Extract PSS and SSS resource elements @param phy_vars_ue Pointer to UE variables @@ -1447,13 +1084,6 @@ uint16_t rx_pbch_emul(PHY_VARS_UE *phy_vars_ue, uint8_t eNB_id, uint8_t pbch_phase); -/*! \brief PBCH scrambling. Applies 36.211 PBCH scrambling procedure. - \param frame_parms Pointer to frame descriptor - \param coded_data Output of the coding and rate matching - \param length Length of the sequence*/ -void pbch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t* coded_data, - uint32_t length); /*! \brief PBCH unscrambling This is similar to pbch_scrabling with the difference that inputs are signed s16s (llr values) and instead of flipping bits we change signs. @@ -1466,44 +1096,6 @@ void pbch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, uint32_t length, uint8_t frame_mod4); -/*! \brief DCI Encoding. This routine codes an arbitrary DCI PDU after appending the 8-bit 3GPP CRC. It then applied sub-block interleaving and rate matching. - \param a Pointer to DCI PDU (coded in bytes) - \param A Length of DCI PDU in bits - \param E Length of DCI PDU in coded bits - \param e Pointer to sequence - \param rnti RNTI for CRC scrambling*/ -void dci_encoding(uint8_t *a, - uint8_t A, - uint16_t E, - uint8_t *e, - uint16_t rnti); - -/*! \brief Top-level DCI entry point. This routine codes an set of DCI PDUs and performs PDCCH modulation, interleaving and mapping. - \param num_dci Number of pdcch symbols - \param num_dci Number of DCI pdus to encode - \param dci_alloc Allocation vectors for each DCI pdu - \param n_rnti n_RNTI (see ) - \param amp Amplitude of QPSK symbols - \param frame_parms Pointer to DL Frame parameter structure - \param txdataF Pointer to tx signal buffers - \param sub_frame_offset subframe offset in frame - @returns Number of PDCCH symbols -*/ - -uint8_t generate_dci_top(uint8_t num_pdcch_symbols, - uint8_t num_dci, - DCI_ALLOC_t *dci_alloc, - uint32_t n_rnti, - int16_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t **txdataF, - uint32_t sub_frame_offset); - -uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, - int num_dci, - DCI_ALLOC_t *dci_alloc, - uint8_t subframe); - /*! \brief Top-level generation route for Sidelink BCH,PSS and SSS \param ue pointer to UE descriptor \param slss pointer to SLSS configuration and payload @@ -1683,8 +1275,6 @@ int generate_srs(LTE_DL_FRAME_PARMS *frame_parms, int16_t amp, uint32_t subframe); -int32_t generate_srs_tx_emul(PHY_VARS_UE *phy_vars_ue, - uint8_t subframe); /*! \brief This function is similar to generate_srs_tx but generates a conjugate sequence for channel estimation. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence. @@ -1737,16 +1327,9 @@ void ulsch_modulation(int32_t **txdataF, LTE_UE_ULSCH_t *ulsch); -void ulsch_extract_rbs_single(int32_t **rxdataF, - int32_t **rxdataF_ext, - uint32_t first_rb, - uint32_t nb_rb, - uint8_t l, - uint8_t Ns, - LTE_DL_FRAME_PARMS *frame_parms); -uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); -uint8_t subframe2harq_pid_eNBrx(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + + int generate_ue_dlsch_params_from_dci(int frame, uint8_t subframe, @@ -1764,38 +1347,6 @@ int generate_ue_dlsch_params_from_dci(int frame, uint8_t beamforming_mode, 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,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); - -int32_t generate_eNB_dlsch_params_from_dci(int frame, - uint8_t subframe, - void *dci_pdu, - rnti_t rnti, - DCI_format_t dci_format, - LTE_eNB_DLSCH_t **dlsch_eNB, - LTE_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t DL_pmi_single, - uint8_t beamforming_mode); - -int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, - unsigned char *rar_pdu, - uint32_t frame, - unsigned char subframe); int generate_ue_ulsch_params_from_dci(void *dci_pdu, rnti_t rnti, @@ -1819,44 +1370,20 @@ double sinr_eff_cqi_calc(PHY_VARS_UE *phy_vars_ue, uint8_t sinr2cqi(double sinr,uint8_t trans_mode); -int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *PHY_vars_eNB, - eNB_rxtx_proc_t *proc, - void *dci_pdu, - rnti_t rnti, - DCI_format_t dci_format, - uint8_t UE_id, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t use_srs); - - -void dump_ulsch(PHY_VARS_eNB *phy_vars_eNB,int frame, int subframe, uint8_t UE_id,int round); int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci); int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, UE_rxtx_proc_t *proc, char* buffer, int length, runmode_t mode, int input_level_dBm); -int dump_eNB_stats(PHY_VARS_eNB *phy_vars_eNB, char* buffer, int length); void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms); -void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - uint8_t *b, - uint8_t *bt); void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, uint8_t subframe, int16_t *d); -void generate_pcfich(uint8_t num_pdcch_symbols, - int16_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t **txdataF, - uint8_t subframe); uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms, uint8_t subframe, @@ -1879,14 +1406,6 @@ void generate_RIV_tables(void); */ int initial_sync(PHY_VARS_UE *phy_vars_ue, runmode_t mode); -void rx_ulsch(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_id); - - -void rx_ulsch_emul(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_index); /*! \brief Encoding of PUSCH/ACK/RI/ACK from 36-212. @@ -1907,78 +1426,8 @@ uint32_t ulsch_encoding(uint8_t *a, uint8_t control_only_flag, uint8_t Nbundled); -/*! - \brief Encoding of PUSCH/ACK/RI/ACK from 36-212 for emulation - @param ulsch_buffer Pointer to ulsch SDU - @param phy_vars_ue Pointer to UE top-level descriptor - @param eNB_id ID of eNB receiving this PUSCH - @param harq_pid HARQ process ID - @param control_only_flag Generate PUSCH with control information only -*/ -int32_t ulsch_encoding_emul(uint8_t *ulsch_buffer, - PHY_VARS_UE *phy_vars_ue, - uint8_t eNB_id, - uint8_t subframe_rx, - uint8_t harq_pid, - uint8_t control_only_flag); - -/*! - \brief Decoding of PUSCH/ACK/RI/ACK from 36-212. - @param phy_vars_eNB Pointer to eNB top-level descriptor - @param proc Pointer to RXTX proc variables - @param UE_id ID of UE transmitting this PUSCH - @param subframe Index of subframe for PUSCH - @param control_only_flag Receive PUSCH with control information only - @param Nbundled Nbundled parameter for ACK/NAK scrambling from 36-212/36-213 - @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used - @returns 0 on success -*/ -unsigned int ulsch_decoding(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_id, - uint8_t control_only_flag, - uint8_t Nbundled, - uint8_t llr8_flag); - -int ulsch_decoding_data_all(PHY_VARS_eNB *eNB, - int UE_id, - int harq_pid, - int llr8_flag); - -/*! - \brief Decoding of ULSCH data component from 36-212. This one spawns 1 worker thread in parallel,half of the segments in each thread. - @param phy_vars_eNB Pointer to eNB top-level descriptor - @param UE_id ID of UE transmitting this PUSCH - @param harq_pid HARQ process ID - @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used - @returns 0 on success -*/ -int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB, - int UE_id, - int harq_pid, - int llr8_flag); - -/*! - \brief Decoding of ULSCH data component from 36-212. This one is single thread. - @param phy_vars_eNB Pointer to eNB top-level descriptor - @param UE_id ID of UE transmitting this PUSCH - @param harq_pid HARQ process ID - @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used - @returns 0 on success -*/ -int ulsch_decoding_data(PHY_VARS_eNB *eNB, - int UE_id, - int harq_pid, - int llr8_flag); -uint32_t ulsch_decoding_emul(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_index, - uint16_t *crnti); -void generate_phich_top(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - int16_t amp); /* \brief This routine demodulates the PHICH and updates PUSCH/ULSCH parameters. @param phy_vars_ue Pointer to UE variables @@ -2010,8 +1459,6 @@ int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int sub void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL); -void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats,uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode); - void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id, uint8_t harq_pid,int N_RB_DL, rnti_t rnti, uint8_t trans_mode,double sinr_eff); void reset_cba_uci(void *o); @@ -2028,21 +1475,12 @@ int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb); uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands); -uint64_t pmi2hex_2Ar1(uint32_t pmi); -uint64_t pmi2hex_2Ar2(uint32_t pmi); uint64_t cqi2hex(uint32_t cqi); uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); -/** \brief This routine expands a single (wideband) PMI to subband PMI bitmap similar to the one used in the UCI and in the dlsch_modulation routine - @param frame_parms Pointer to DL frame configuration parameters - @param wideband_pmi (0,1,2,3 for rank 0 and 0,1 for rank 1) - @param rank (0 or 1) - @returns subband PMI bitmap -*/ -uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank); /** \brief This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function @param N_RB_DL number of resource blocks @@ -2077,19 +1515,7 @@ void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, int8_t* llr, uint32_t length); -void pdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - uint8_t *e, - uint32_t length); - -void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - int mbsfn_flag, - LTE_eNB_DLSCH_t *dlsch, - int hard_pid, - int G, - uint8_t q, - uint16_t frame, - uint8_t Ns); + void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, int mbsfn_flag, @@ -2137,33 +1563,6 @@ void generate_pucch3x(int32_t **txdataF, uint8_t subframe, uint16_t rnti); -void generate_pucch_emul(PHY_VARS_UE *phy_vars_ue, - UE_rxtx_proc_t *proc, - PUCCH_FMT_t format, - uint8_t ncs1, - uint8_t *pucch_ack_payload, - uint8_t sr); - - - -uint32_t rx_pucch(PHY_VARS_eNB *phy_vars_eNB, - PUCCH_FMT_t fmt, - uint8_t UE_id, - uint16_t n1_pucch, - uint16_t n2_pucch, - uint8_t shortened_format, - uint8_t *payload, - int frame, - uint8_t subframe, - uint8_t pucch1_thres); - -int32_t rx_pucch_emul(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_index, - PUCCH_FMT_t fmt, - uint8_t n1_pucch_sel, - uint8_t *payload); - void init_ulsch_power_LUT(void); @@ -2188,29 +1587,7 @@ int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t sub */ int32_t generate_prach(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,uint16_t Nf); -/*! - \brief Process PRACH waveform - @param phy_vars_eNB Pointer to eNB top-level descriptor. If NULL, then this is an RRU - @param ru Pointer to RU top-level descriptor. If NULL, then this is an eNB and we make use of the RU_list - @param max_preamble most likely preamble - @param max_preamble_energy Estimated Energy of most likely preamble - @param max_preamble_delay Estimated Delay of most likely preamble - @param Nf System frame number - @param tdd_mapindex Index of PRACH resource in Table 5.7.1-4 (TDD) - @param br_flag indicator to act on eMTC PRACH - @returns 0 on success -*/ -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, - uint16_t Nf, uint8_t tdd_mapindex -#ifdef Rel14 - , - uint8_t br_flag -#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 @@ -2277,16 +1654,6 @@ uint32_t dlsch_decoding_abstraction(double *dlsch_MIPB, // DL power control functions double get_pa_dB(uint8_t pa); -double computeRhoA_eNB(uint8_t pa, - LTE_eNB_DLSCH_t *dlsch_eNB, - int dl_power_off, - uint8_t n_antenna_port); - -double computeRhoB_eNB(uint8_t pa, - uint8_t pb, - uint8_t n_antenna_port, - LTE_eNB_DLSCH_t *dlsch_eNB, - int dl_power_off); double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, LTE_UE_DLSCH_t *dlsch_ue, @@ -2310,14 +1677,9 @@ uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, uint8_t n_ra_prboffset, uint8_t tdd_mapindex, uint16_t Nf); -uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); - -int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); -int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); -int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); /**@}*/ #endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h new file mode 100644 index 0000000000000000000000000000000000000000..e97353a902868b1417240dfc2bc97e168db4e883 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h @@ -0,0 +1,336 @@ +/* + * 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/LTE_TRANSPORT/defs.h +* \brief data structures for PDSCH/DLSCH/PUSCH/ULSCH physical and transport channel descriptors (TX/RX) +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: raymond.knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it +* \note +* \warning +*/ +#ifndef __TRANSPORT_UE__H__ +#define __TRANSPORT_UE__H__ +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_lte.h" +#include "../LTE_TRANSPORT/dci.h" +#include "../LTE_TRANSPORT/mdci.h" +#include "../LTE_TRANSPORT/uci_common.h" +#include "../LTE_TRANSPORT/transport_common.h" +#ifndef STANDALONE_COMPILE +#include "UTIL/LISTS/list.h" +#endif + +#include "../LTE_TRANSPORT/transport_common.h" + +// structures below implement 36-211 and 36-212 + +/** @addtogroup _PHY_TRANSPORT_ + * @{ + */ + + + +typedef struct { + /// Indicator of first transmission + uint8_t first_tx; + /// Last Ndi received for this process on DCI (used for C-RNTI only) + uint8_t DCINdi; + /// Flag indicating that this ULSCH has a new packet (start of new round) + // uint8_t Ndi; + /// Status Flag indicating for this ULSCH (idle,active,disabled) + SCH_status_t status; + /// Subframe scheduling indicator (i.e. Transmission opportunity indicator) + uint8_t subframe_scheduling_flag; + /// Subframe cba scheduling indicator (i.e. Transmission opportunity indicator) + uint8_t subframe_cba_scheduling_flag; + /// First Allocated RB + uint16_t first_rb; + /// Current Number of RBs + uint16_t nb_rb; + /// Last TPC command + uint8_t TPC; + /// Transport block size + uint32_t TBS; + /// The payload + CRC size in bits, "B" from 36-212 + uint32_t B; + /// Length of ACK information (bits) + uint8_t O_ACK; + /// Pointer to the payload + uint8_t *b; + /// Pointers to transport block segments + uint8_t *c[MAX_NUM_ULSCH_SEGMENTS]; + /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) + uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS]; + /// Index of current HARQ round for this ULSCH + uint8_t round; + /// MCS format of this ULSCH + uint8_t mcs; + /// Redundancy-version of the current sub-frame + uint8_t rvidx; + /// Turbo-code outputs (36-212 V8.6 2009-03, p.12 + uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))]; + /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17) + uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144]; + /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) + uint32_t C; + /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cminus; + /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cplus; + /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kminus; + /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kplus; + /// Total number of bits across all segments + uint32_t sumKr; + /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t F; + /// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27) + uint16_t Msc_initial; + /// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27) + uint8_t Nsymb_initial; + /// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) + uint8_t n_DMRS; + /// n_DMRS2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1) + uint8_t n_DMRS2; + /// Flag to indicate that this is a control only ULSCH (i.e. no MAC SDU) + uint8_t control_only; + /// Flag to indicate that this is a calibration ULSCH (i.e. no MAC SDU and filled with TDD calibration information) + // int calibration_flag; + /// Number of soft channel bits + uint32_t G; + + // decode phich + uint8_t decode_phich; +} LTE_UL_UE_HARQ_t; + +typedef struct { + /// Current Number of Symbols + uint8_t Nsymb_pusch; + /// SRS active flag + uint8_t srs_active; + /// Pointers to 8 HARQ processes for the ULSCH + LTE_UL_UE_HARQ_t *harq_processes[8]; + /// Pointer to CQI data (+1 for 8 bits crc) + uint8_t o[1+MAX_CQI_BYTES]; + /// Length of CQI data (bits) + uint8_t O; + /// Format of CQI data + UCI_format_t uci_format; + /// Rank information + uint8_t o_RI[2]; + /// Length of rank information (bits) + uint8_t O_RI; + /// Pointer to ACK + uint8_t o_ACK[4]; + /// Minimum number of CQI bits for PUSCH (36-212 r8.6, Sec 5.2.4.1 p. 37) + uint8_t O_CQI_MIN; + /// ACK/NAK Bundling flag + uint8_t bundling; + /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) + uint8_t e[MAX_NUM_CHANNEL_BITS]; + /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) + uint8_t h[MAX_NUM_CHANNEL_BITS]; + /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14) + uint8_t b_tilde[MAX_NUM_CHANNEL_BITS]; + /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14) + int32_t d[MAX_NUM_RE]; + /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15) + int32_t z[MAX_NUM_RE]; + /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) + uint8_t q[MAX_CQI_PAYLOAD]; + /// coded and interleaved CQI bits + uint8_t o_w[(MAX_CQI_BITS+8)*3]; + /// coded CQI bits + uint8_t o_d[96+((MAX_CQI_BITS+8)*3)]; + /// coded ACK bits + uint8_t q_ACK[MAX_ACK_PAYLOAD]; + /// coded RI bits + uint8_t q_RI[MAX_RI_PAYLOAD]; + /// beta_offset_cqi times 8 + uint16_t beta_offset_cqi_times8; + /// beta_offset_ri times 8 + uint16_t beta_offset_ri_times8; + /// beta_offset_harqack times 8 + uint16_t beta_offset_harqack_times8; + /// power_offset + uint8_t power_offset; + // for cooperative communication + uint8_t cooperation_flag; + /// RNTI attributed to this ULSCH + uint16_t rnti; + /// f_PUSCH parameter for PUSCH power control + int16_t f_pusch; + /// Po_PUSCH - target output power for PUSCH + int16_t Po_PUSCH; + /// PHR - current power headroom (based on last PUSCH transmission) + int16_t PHR; + /// Po_SRS - target output power for SRS + int16_t Po_SRS; + /// num active cba group + uint8_t num_active_cba_groups; + /// num dci found for cba + uint8_t num_cba_dci[10]; + /// allocated CBA RNTI + uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; + /// UL max-harq-retransmission + uint8_t Mlimit; +} LTE_UE_ULSCH_t; + + + + +typedef struct { + /// Indicator of first transmission + uint8_t first_tx; + /// Last Ndi received for this process on DCI (used for C-RNTI only) + uint8_t DCINdi; + /// DLSCH status flag indicating + SCH_status_t status; + /// Transport block size + uint32_t TBS; + /// The payload + CRC size in bits + uint32_t B; + /// Pointer to the payload + uint8_t *b; + /// Pointers to transport block segments + uint8_t *c[MAX_NUM_DLSCH_SEGMENTS]; + /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) + uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS]; + /// Index of current HARQ round for this DLSCH + uint8_t round; + /// MCS format for this DLSCH + uint8_t mcs; + /// Qm (modulation order) for this DLSCH + uint8_t Qm; + /// Redundancy-version of the current sub-frame + uint8_t rvidx; + /// MIMO mode for this DLSCH + MIMO_mode_t mimo_mode; + /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + int16_t w[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)]; + /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + double w_abs[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)]; + /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + int16_t *d[MAX_NUM_DLSCH_SEGMENTS]; + /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) + uint32_t C; + /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cminus; + /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cplus; + /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kminus; + /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kplus; + /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t F; + /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17) + uint8_t Nl; + /// current delta_pucch + int8_t delta_PUCCH; + /// Number of soft channel bits + uint32_t G; + /// Current Number of RBs + uint16_t nb_rb; + /// Current subband PMI allocation + uint16_t pmi_alloc; + /// Current RB allocation (even slots) + uint32_t rb_alloc_even[4]; + /// Current RB allocation (odd slots) + uint32_t rb_alloc_odd[4]; + /// distributed/localized flag + vrb_t vrb_type; + /// downlink power offset field + uint8_t dl_power_off; + /// trials per round statistics + uint32_t trials[8]; + /// error statistics per round + uint32_t errors[8]; + /// codeword this transport block is mapped to + uint8_t codeword; +} LTE_DL_UE_HARQ_t; + + +typedef struct { + /// HARQ process id + uint8_t harq_id; + /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX + uint8_t ack; + /// send status (for PUCCH) + uint8_t send_harq_status; + /// nCCE (for PUCCH) + uint8_t nCCE; + /// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched + uint8_t vDAI_DL; + /// DAI value detected from DCI0/4. 0xff indicates not touched + uint8_t vDAI_UL; +} harq_status_t; + +typedef struct { + /// RNTI + uint16_t rnti; + /// Active flag for DLSCH demodulation + uint8_t active; + /// Transmission mode + uint8_t mode1_flag; + /// amplitude of PDSCH (compared to RS) in symbols without pilots + int16_t sqrt_rho_a; + /// amplitude of PDSCH (compared to RS) in symbols containing pilots + int16_t sqrt_rho_b; + /// Current HARQ process id threadRx Odd and threadRx Even + uint8_t current_harq_pid; + /// Current subband antenna selection + uint32_t antenna_alloc; + /// Current subband RI allocation + uint32_t ri_alloc; + /// Current subband CQI1 allocation + uint32_t cqi_alloc1; + /// Current subband CQI2 allocation + uint32_t cqi_alloc2; + /// saved subband PMI allocation from last PUSCH/PUCCH report + uint16_t pmi_alloc; + /// HARQ-ACKs + harq_status_t harq_ack[10]; + /// Pointers to up to 8 HARQ processes + LTE_DL_UE_HARQ_t *harq_processes[8]; + /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17 + uint8_t Mdlharq; + /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17) + uint8_t Kmimo; + /// Nsoft parameter related to UE Category + uint32_t Nsoft; + /// Maximum number of Turbo iterations + uint8_t max_turbo_iterations; + /// number of iterations used in last turbo decoding + uint8_t last_iteration_cnt; + /// accumulated tx power adjustment for PUCCH + int8_t g_pucch; +} LTE_UE_DLSCH_t; + + + + +/**@}*/ +#endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..e687ccfd049f2704fd072e5ff0c196be3855f161 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c @@ -0,0 +1,244 @@ +/* + * 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/LTE_TRANSPORT/phich.c +* \brief Routines for generation of and computations regarding the uplink control information (UCI) for PUSCH. V8.6 2009-03 +* \author R. Knopp, F. Kaltenberger, A. Bhamri +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, ankit.bhamri@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#ifdef DEBUG_UCI_TOOLS +#include "PHY/phy_vars.h" +#endif + +//#define DEBUG_UCI 1 + + +uint64_t cqi2hex(uint32_t cqi) +{ + + uint64_t cqil = (uint64_t)cqi; + return ((cqil&3) + (((cqil>>2)&3)<<4) + (((cqil>>4)&3)<<8) + (((cqil>>6)&3)<<12) + + (((cqil>>8)&3)<<16) + (((cqil>>10)&3)<<20) + (((cqil>>12)&3)<<24) + + (((cqil>>14)&3)<<28) + (((cqil>>16)&3)<<32) + (((cqil>>18)&3)<<36) + + (((cqil>>20)&3)<<40) + (((cqil>>22)&3)<<44) + (((cqil>>24)&3)<<48)); +} + + +void print_CQI(void *o,UCI_format_t uci_format,unsigned char eNB_id,int N_RB_DL) +{ + + + switch(uci_format) { + case wideband_cqi_rank1_2A: +#ifdef DEBUG_UCI + LOG_D(PHY,"[PRINT CQI] flat_LA %d\n", flag_LA); + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi)); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_5MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)o)->pmi)); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_10MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_10MHz *)o)->pmi)); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_20MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_20MHz *)o)->pmi)); + break; + } + +#endif //DEBUG_UCI + break; + + case wideband_cqi_rank2_2A: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi)); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_5MHz *)o)->pmi)); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_10MHz *)o)->pmi)); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_20MHz *)o)->pmi)); + break; + } + +#endif //DEBUG_UCI + break; + + case HLC_subband_cqi_nopmi: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1)); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1)); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1)); + break; + } + +#endif //DEBUG_UCI + break; + + case HLC_subband_cqi_rank1_2A: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + } + +#endif //DEBUG_UCI + break; + + case HLC_subband_cqi_rank2_2A: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi); + break; + } + +#endif //DEBUG_UCI + break; + + case ue_selected: +#ifdef DEBUG_UCI + LOG_W(PHY,"[PRINT CQI] ue_selected CQI not supported yet!!!\n"); +#endif //DEBUG_UCI + break; + + default: +#ifdef DEBUG_UCI + LOG_E(PHY,"[PRINT CQI] unsupported CQI mode (%d)!!!\n",uci_format); +#endif //DEBUG_UCI + break; + } + +} + + + + + + diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/ulsch_coding.c rename to openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c index 09420f48ab1a7029fdbbb2015fd7f28f47ffcd8c..d913a6f77902bb33f657be1a5ea45cf64ba3b801 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c @@ -30,16 +30,13 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" -#include "extern.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_ue.h" #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_ULSCH_CODING @@ -107,7 +104,7 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) case 50: bw_scaling =2; break; - + default: bw_scaling =1; break; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c similarity index 97% rename from openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c index d1718f6e90f600927f5d93f3a18e93213bea86f8..92a8d16b44ad59045d890b4ad0e39634f3cfeb8f 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c @@ -29,14 +29,15 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_ue.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" - +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_ULSCH_MODULATION @@ -381,7 +382,7 @@ void ulsch_modulation(int32_t **txdataF, DevAssert(frame_parms); - int re_offset,re_offset0,i,Msymb,j,k,nsymb,Msc_PUSCH,l; + int re_offset,re_offset0,i,ulsch_Msymb,j,k,nsymb,Msc_PUSCH,l; // uint8_t harq_pid = (rag_flag == 1) ? 0 : subframe2harq_pid_tdd(frame_parms->tdd_config,subframe); uint8_t harq_pid = subframe2harq_pid(frame_parms,frame,subframe); uint8_t Q_m; @@ -470,12 +471,12 @@ void ulsch_modulation(int32_t **txdataF, // Modulation - Msymb = G/Q_m; + ulsch_Msymb = G/Q_m; if(ulsch->cooperation_flag == 2) // For Distributed Alamouti Scheme in Collabrative Communication { - for (i=0,j=Q_m; i<Msymb; i+=2,j+=2*Q_m) { + for (i=0,j=Q_m; i<ulsch_Msymb; i+=2,j+=2*Q_m) { switch (Q_m) { @@ -609,7 +610,7 @@ void ulsch_modulation(int32_t **txdataF, }//for }//cooperation_flag == 2 else { - for (i=0,j=0; i<Msymb; i++,j+=Q_m) { + for (i=0,j=0; i<ulsch_Msymb; i++,j+=Q_m) { switch (Q_m) { @@ -685,7 +686,7 @@ void ulsch_modulation(int32_t **txdataF, #ifdef OFDMA_ULSCH - for (i=0; i<Msymb; i++) { + for (i=0; i<ulsch_Msymb; i++) { ulsch->z[i] = ulsch->d[i]; } diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 84863c81e89ce8c6742e8ca10896cd81ed3fa92c..e2ab0cd33b827307b8a004956177f5c2545dd19f 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -29,13 +29,14 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_common.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" +#include "modulation_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" int beam_precoding(int32_t **txdataF, diff --git a/openair1/PHY/MODULATION/compute_bf_weights.c b/openair1/PHY/MODULATION/compute_bf_weights.c index 4ef8e88ca6652433efbad3ce761463bd41836325..89d76058e6d2b1859124a14408704403fc9f778b 100644 --- a/openair1/PHY/MODULATION/compute_bf_weights.c +++ b/openair1/PHY/MODULATION/compute_bf_weights.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <stdlib.h> #include "PHY/impl_defs_lte.h" +#include "PHY/defs_common.h" int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coeffs){ diff --git a/openair1/PHY/MODULATION/defs.h b/openair1/PHY/MODULATION/defs.h deleted file mode 100644 index f9bbdcd27156e82cd7e41d010f406a58a905d6ca..0000000000000000000000000000000000000000 --- a/openair1/PHY/MODULATION/defs.h +++ /dev/null @@ -1,134 +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 __MODULATION_DEFS__H__ -#define __MODULATION_DEFS__H__ -#include "PHY/defs.h" -/** @addtogroup _PHY_MODULATION_ - * @{ -*/ - -/** -\fn void PHY_ofdm_mod(int *input,int *output,int fftsize,unsigned char nb_symbols,unsigned short nb_prefix_samples,Extension_t etype) -This function performs OFDM modulation with cyclic extension or zero-padding. - -@param input The sequence input samples in the frequency-domain. This is a concatenation of the input symbols in SIMD redundant format -@param output The time-domain output signal -@param fftsize size of OFDM symbol size (\f$N_d\f$) -@param nb_symbols The number of OFDM symbols in the block -@param nb_prefix_samples The number of prefix/suffix/zero samples -@param etype Type of extension (CYCLIC_PREFIX,CYCLIC_SUFFIX,ZEROS) - -*/ -void PHY_ofdm_mod(int *input, - int *output, - int fftsize, - unsigned char nb_symbols, - unsigned short nb_prefix_samples, - Extension_t etype - ); - -#ifdef OPENAIR_LTE - -/*! -\brief This function implements the OFDM front end processor on reception (FEP) -\param phy_vars_ue Pointer to PHY variables -\param l symbol within slot (0..6/7) -\param Ns Slot number (0..19) -\param sample_offset offset within rxdata (points to beginning of subframe) -\param no_prefix if 1 prefix is removed by HW -\param reset_freq_est if non-zero it resets the frequency offset estimation loop -*/ - -int slot_fep(PHY_VARS_UE *phy_vars_ue, - unsigned char l, - unsigned char Ns, - int sample_offset, - int no_prefix, - int reset_freq_est); - -int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, - unsigned char l, - int subframe, - int sample_offset, - int no_prefix); - -int slot_fep_ul(RU_t *ru, - unsigned char l, - unsigned char Ns, - int no_prefix); - -int front_end_fft(PHY_VARS_UE *ue, - unsigned char l, - unsigned char Ns, - int sample_offset, - int no_prefix); - -int front_end_chanEst(PHY_VARS_UE *ue, - unsigned char l, - unsigned char Ns, - int reset_freq_est); - -void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms); - -void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); - -void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, RU_COMMON *common, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms,int do_precoding); - -void remove_7_5_kHz(RU_t *ru,uint8_t subframe); - -void apply_7_5_kHz(PHY_VARS_UE *phy_vars_ue,int32_t*txdata,uint8_t subframe); - -void init_prach625(LTE_DL_FRAME_PARMS *frame_parms); - -void remove_625_Hz(PHY_VARS_eNB *phy_vars_eNB,int16_t *prach); - -void apply_625_Hz(PHY_VARS_UE *phy_vars_ue,int16_t *prach); - -/** \brief This function performs beamforming precoding for common - * data - @param txdataF Table of pointers for frequency-domain TX signals - @param txdataF_BF Table of pointers for frequency-domain TX signals - @param frame_parms Frame descriptor structure -after beamforming - @param beam_weights Beamforming weights applied on each -antenna element and each carrier - @param slot Slot number - @param symbol Symbol index on which to act - @param aa physical antenna index*/ -int beam_precoding(int32_t **txdataF, - int32_t **txdataF_BF, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t ***beam_weights, - int slot, - int symbol, - int aa); - -int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coeffs); - -int estimate_DLCSI_from_ULCSI(int32_t **calib_dl_ch_estimates, int32_t **ul_ch_estimates, int32_t **tdd_calib_coeffs, int nb_ant, int nb_freq); - -int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates, PRECODE_TYPE_t precode_type, int nb_ant, int nb_freq); - - -#endif -/** @}*/ -#endif diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h new file mode 100644 index 0000000000000000000000000000000000000000..7e2a3c8a27778f75b59866ea60392916baf9c684 --- /dev/null +++ b/openair1/PHY/MODULATION/modulation_UE.h @@ -0,0 +1,74 @@ +/* + * 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 __MODULATION_DEFS__H__ +#define __MODULATION_DEFS__H__ +#include "PHY/defs_common.h" +#include "modulation_common.h" +/** @addtogroup _PHY_MODULATION_ + * @{ +*/ + + + +/*! +\brief This function implements the OFDM front end processor on reception (FEP) +\param phy_vars_ue Pointer to PHY variables +\param l symbol within slot (0..6/7) +\param Ns Slot number (0..19) +\param sample_offset offset within rxdata (points to beginning of subframe) +\param no_prefix if 1 prefix is removed by HW +\param reset_freq_est if non-zero it resets the frequency offset estimation loop +*/ + +int slot_fep(PHY_VARS_UE *phy_vars_ue, + unsigned char l, + unsigned char Ns, + int sample_offset, + int no_prefix, + int reset_freq_est); + +int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, + unsigned char l, + int subframe, + int sample_offset, + int no_prefix); + +int front_end_fft(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int sample_offset, + int no_prefix); + +int front_end_chanEst(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int reset_freq_est); + +void apply_7_5_kHz(PHY_VARS_UE *phy_vars_ue,int32_t*txdata,uint8_t subframe); + + +int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates, PRECODE_TYPE_t precode_type, int nb_ant, int nb_freq); + + + +/** @}*/ +#endif diff --git a/openair1/PHY/MODULATION/modulation_common.h b/openair1/PHY/MODULATION/modulation_common.h new file mode 100644 index 0000000000000000000000000000000000000000..2ac0dc23b3012b5bc76aa8ad7acbdf9f4fedd318 --- /dev/null +++ b/openair1/PHY/MODULATION/modulation_common.h @@ -0,0 +1,56 @@ +/* + * 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 __MODULATION_COMMON__H__ +#define __MODULATION_COMMON__H__ +#include "PHY/defs_common.h" +/** @addtogroup _PHY_MODULATION_ + * @{ +*/ + +/** +\fn void PHY_ofdm_mod(int *input,int *output,int fftsize,unsigned char nb_symbols,unsigned short nb_prefix_samples,Extension_t etype) +This function performs OFDM modulation with cyclic extension or zero-padding. + +@param input The sequence input samples in the frequency-domain. This is a concatenation of the input symbols in SIMD redundant format +@param output The time-domain output signal +@param fftsize size of OFDM symbol size (\f$N_d\f$) +@param nb_symbols The number of OFDM symbols in the block +@param nb_prefix_samples The number of prefix/suffix/zero samples +@param etype Type of extension (CYCLIC_PREFIX,CYCLIC_SUFFIX,ZEROS) + +*/ +void PHY_ofdm_mod(int *input, + int *output, + int fftsize, + unsigned char nb_symbols, + unsigned short nb_prefix_samples, + Extension_t etype + ); + + +void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms); + +void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); + + +/** @}*/ +#endif diff --git a/openair1/PHY/MODULATION/modulation_eNB.h b/openair1/PHY/MODULATION/modulation_eNB.h new file mode 100644 index 0000000000000000000000000000000000000000..360861088721af9893767520af4af5cbc81a3f88 --- /dev/null +++ b/openair1/PHY/MODULATION/modulation_eNB.h @@ -0,0 +1,66 @@ +/* + * 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 __MODULATION_ENB__H__ +#define __MODULATION_ENB__H__ +#include "PHY/defs_common.h" +#include "modulation_common.h" + +/** @addtogroup _PHY_MODULATION_ + * @{ +*/ + +int slot_fep_ul(RU_t *ru, + unsigned char l, + unsigned char Ns, + int no_prefix); + +void remove_7_5_kHz(RU_t *ru,uint8_t subframe); + +/** \brief This function performs beamforming precoding for common + * data + @param txdataF Table of pointers for frequency-domain TX signals + @param txdataF_BF Table of pointers for frequency-domain TX signals + @param frame_parms Frame descriptor structure +after beamforming + @param beam_weights Beamforming weights applied on each +antenna element and each carrier + @param slot Slot number + @param symbol Symbol index on which to act + @param aa physical antenna index*/ +int beam_precoding(int32_t **txdataF, + int32_t **txdataF_BF, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t ***beam_weights, + int slot, + int symbol, + int aa); + +int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coeffs); + +int estimate_DLCSI_from_ULCSI(int32_t **calib_dl_ch_estimates, int32_t **ul_ch_estimates, int32_t **tdd_calib_coeffs, int nb_ant, int nb_freq); + +int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates, PRECODE_TYPE_t precode_type, int nb_ant, int nb_freq); + + + +/** @}*/ +#endif diff --git a/openair1/PHY/MODULATION/vars.h b/openair1/PHY/MODULATION/modulation_extern.h similarity index 62% rename from openair1/PHY/MODULATION/vars.h rename to openair1/PHY/MODULATION/modulation_extern.h index a05999afe1661142ecb9fbbce6c5f1d46bce0f4b..2834aa00f503113987b5fa27a52f631ff1d235c5 100644 --- a/openair1/PHY/MODULATION/vars.h +++ b/openair1/PHY/MODULATION/modulation_extern.h @@ -10,7 +10,7 @@ * 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, +; * 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. @@ -19,13 +19,20 @@ * contact@openairinterface.org */ -mod_sym_t qpsk_table[4]; -mod_sym_t qam16_table[16]; -mod_sym_t qam64_table[64]; +extern int16_t s6n_kHz_7_5[1920]; +extern int16_t s6e_kHz_7_5[1920]; +extern int16_t s15n_kHz_7_5[3840]; +extern int16_t s15e_kHz_7_5[3840]; +extern int16_t s25n_kHz_7_5[7680]; +extern int16_t s25e_kHz_7_5[7680]; +extern int16_t s50n_kHz_7_5[15360]; +extern int16_t s50e_kHz_7_5[15360]; +extern int16_t s75n_kHz_7_5[23040]; +extern int16_t s75e_kHz_7_5[23040]; +extern int16_t s100n_kHz_7_5[30720]; +extern int16_t s100e_kHz_7_5[30720]; -int16_t kHz75_25PRB[1024] = {}; -int16_t kHz75_6PRB = {}; -int16_t kHz75_15PRB = {}; -int16_t kHz75_50PRB = {}; -int16_t kHz75_75PRB = {}; -int16_t kHz75_100PRB = {}; + +extern short conjugate75[8]; +extern short conjugate75_2[8]; +extern short negate[8]; diff --git a/openair1/SCHED/vars.h b/openair1/PHY/MODULATION/modulation_vars.h similarity index 80% rename from openair1/SCHED/vars.h rename to openair1/PHY/MODULATION/modulation_vars.h index 4dac375f18d0973167228192c7371f75b89d5eea..dbea92ab3f5e3e9998bab0bb417a8e7a11c629eb 100644 --- a/openair1/SCHED/vars.h +++ b/openair1/PHY/MODULATION/modulation_vars.h @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "defs.h" - - - +#include "kHz_7_5.h" +short conjugate75[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; +short conjugate75_2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; +short negate[8]__attribute__((aligned(16))) = {-1,-1,-1,-1,-1,-1,-1,-1}; diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c index 37d1a483119cda97b5e455787d51bada349b83fc..dfb6c85f33abe7f7309a7b23173506fd125490bc 100644 --- a/openair1/PHY/MODULATION/ofdm_mod.c +++ b/openair1/PHY/MODULATION/ofdm_mod.c @@ -29,10 +29,12 @@ This section deals with basic functions for OFDM Modulation. */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/impl_defs_top.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" - +#include "modulation_common.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" //#define DEBUG_OFDM_MOD diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c index 39ae90217f9b336d2afc397bd60106adc4ecb50f..b01979431dcf88212604aa71cf0d0470eb177d06 100644 --- a/openair1/PHY/MODULATION/slot_fep.c +++ b/openair1/PHY/MODULATION/slot_fep.c @@ -19,8 +19,10 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "defs.h" +#include "PHY/defs_UE.h" +#include "modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + //#define DEBUG_FEP #define SOFFSET 0 diff --git a/openair1/PHY/MODULATION/slot_fep_mbsfn.c b/openair1/PHY/MODULATION/slot_fep_mbsfn.c index 7b902bb8f1524199980c08a7b9dc3bf1208ed403..272cbc5d60b0566562fb9d838c54f3396ac37b7e 100644 --- a/openair1/PHY/MODULATION/slot_fep_mbsfn.c +++ b/openair1/PHY/MODULATION/slot_fep_mbsfn.c @@ -19,8 +19,10 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "defs.h" +#include "PHY/defs_UE.h" +#include "modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + //#define DEBUG_FEP #define SOFFSET 0 diff --git a/openair1/PHY/MODULATION/slot_fep_ul.c b/openair1/PHY/MODULATION/slot_fep_ul.c index 5beb7eccfdc14880ee953d10b198422a8b30a525..fe5488c73c7f29c136bb9730ca10e1f11149521c 100644 --- a/openair1/PHY/MODULATION/slot_fep_ul.c +++ b/openair1/PHY/MODULATION/slot_fep_ul.c @@ -19,9 +19,9 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "modulation_eNB.h" //#define DEBUG_FEP diff --git a/openair1/PHY/MODULATION/ul_7_5_kHz.c b/openair1/PHY/MODULATION/ul_7_5_kHz.c index d92dc1c8b3203bf5c0d103ec3d7fd09ce220f138..3d1d9c2b0470ad2a46c0b6534e4463d558d5d0ae 100644 --- a/openair1/PHY/MODULATION/ul_7_5_kHz.c +++ b/openair1/PHY/MODULATION/ul_7_5_kHz.c @@ -19,121 +19,11 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "extern.h" -#include "kHz_7_5.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include <math.h> #include "PHY/sse_intrin.h" - -short conjugate75[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; -short conjugate75_2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; -short negate[8]__attribute__((aligned(16))) = {-1,-1,-1,-1,-1,-1,-1,-1}; - -void apply_7_5_kHz(PHY_VARS_UE *ue,int32_t*txdata,uint8_t slot) -{ - - - uint16_t len; - uint32_t *kHz7_5ptr; -#if defined(__x86_64__) || defined(__i386__) - __m128i *txptr128,*kHz7_5ptr128,mmtmp_re,mmtmp_im,mmtmp_re2,mmtmp_im2; -#elif defined(__arm__) - int16x8_t *txptr128,*kHz7_5ptr128; - int32x4_t mmtmp_re,mmtmp_im; - int32x4_t mmtmp0,mmtmp1; -#endif - uint32_t slot_offset; - // uint8_t aa; - uint32_t i; - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - - switch (frame_parms->N_RB_UL) { - - case 6: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s6n_kHz_7_5 : (uint32_t*)s6e_kHz_7_5; - break; - - case 15: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s15n_kHz_7_5 : (uint32_t*)s15e_kHz_7_5; - break; - - case 25: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; - break; - - case 50: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s50n_kHz_7_5 : (uint32_t*)s50e_kHz_7_5; - break; - - case 75: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s75n_kHz_7_5 : (uint32_t*)s75e_kHz_7_5; - break; - - case 100: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s100n_kHz_7_5 : (uint32_t*)s100e_kHz_7_5; - break; - - default: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; - break; - } - - slot_offset = (uint32_t)slot * frame_parms->samples_per_tti/2; - len = frame_parms->samples_per_tti/2; - -#if defined(__x86_64__) || defined(__i386__) - txptr128 = (__m128i *)&txdata[slot_offset]; - kHz7_5ptr128 = (__m128i *)kHz7_5ptr; -#elif defined(__arm__) - txptr128 = (int16x8_t*)&txdata[slot_offset]; - kHz7_5ptr128 = (int16x8_t*)kHz7_5ptr; -#endif - // apply 7.5 kHz - - for (i=0; i<(len>>2); i++) { -#if defined(__x86_64__) || defined(__i386__) - mmtmp_re = _mm_madd_epi16(*txptr128,*kHz7_5ptr128); - // Real part of complex multiplication (note: 7_5kHz signal is conjugated for this to work) - mmtmp_im = _mm_shufflelo_epi16(*kHz7_5ptr128,_MM_SHUFFLE(2,3,0,1)); - mmtmp_im = _mm_shufflehi_epi16(mmtmp_im,_MM_SHUFFLE(2,3,0,1)); - mmtmp_im = _mm_sign_epi16(mmtmp_im,*(__m128i*)&conjugate75[0]); - mmtmp_im = _mm_madd_epi16(mmtmp_im,txptr128[0]); - mmtmp_re = _mm_srai_epi32(mmtmp_re,15); - mmtmp_im = _mm_srai_epi32(mmtmp_im,15); - mmtmp_re2 = _mm_unpacklo_epi32(mmtmp_re,mmtmp_im); - mmtmp_im2 = _mm_unpackhi_epi32(mmtmp_re,mmtmp_im); - - txptr128[0] = _mm_packs_epi32(mmtmp_re2,mmtmp_im2); - txptr128++; - kHz7_5ptr128++; -#elif defined(__arm__) - - mmtmp0 = vmull_s16(((int16x4_t*)txptr128)[0],((int16x4_t*)kHz7_5ptr128)[0]); - //mmtmp0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] - mmtmp1 = vmull_s16(((int16x4_t*)txptr128)[1],((int16x4_t*)kHz7_5ptr128)[1]); - //mmtmp1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] - mmtmp_re = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), - vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); - //mmtmp_re = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] - - mmtmp0 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[0],*(int16x4_t*)conjugate75_2)),((int16x4_t*)kHz7_5ptr128)[0]); - //mmtmp0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] - mmtmp1 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[1],*(int16x4_t*)conjugate75_2)), ((int16x4_t*)kHz7_5ptr128)[1]); - //mmtmp0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] - mmtmp_im = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), - vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); - //mmtmp_im = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] - - txptr128[0] = vcombine_s16(vmovn_s32(mmtmp_re),vmovn_s32(mmtmp_im)); - txptr128++; - kHz7_5ptr128++; -#endif - } - - //} -} - +#include "modulation_extern.h" void remove_7_5_kHz(RU_t *ru,uint8_t slot) { diff --git a/openair1/PHY/MODULATION/ul_7_5_kHz_ue.c b/openair1/PHY/MODULATION/ul_7_5_kHz_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..3e3a839521b3e5be66c530b0af89172ac0d76ce6 --- /dev/null +++ b/openair1/PHY/MODULATION/ul_7_5_kHz_ue.c @@ -0,0 +1,136 @@ +/* + * 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 "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "modulation_extern.h" +#include <math.h> +#include "PHY/sse_intrin.h" + +extern short conjugate75[8]; +extern short conjugate75_2[8]; +extern short negate[8]; + +void apply_7_5_kHz(PHY_VARS_UE *ue,int32_t*txdata,uint8_t slot) +{ + + + uint16_t len; + uint32_t *kHz7_5ptr; +#if defined(__x86_64__) || defined(__i386__) + __m128i *txptr128,*kHz7_5ptr128,mmtmp_re,mmtmp_im,mmtmp_re2,mmtmp_im2; +#elif defined(__arm__) + int16x8_t *txptr128,*kHz7_5ptr128; + int32x4_t mmtmp_re,mmtmp_im; + int32x4_t mmtmp0,mmtmp1; +#endif + uint32_t slot_offset; + // uint8_t aa; + uint32_t i; + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + + switch (frame_parms->N_RB_UL) { + + case 6: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s6n_kHz_7_5 : (uint32_t*)s6e_kHz_7_5; + break; + + case 15: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s15n_kHz_7_5 : (uint32_t*)s15e_kHz_7_5; + break; + + case 25: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; + break; + + case 50: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s50n_kHz_7_5 : (uint32_t*)s50e_kHz_7_5; + break; + + case 75: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s75n_kHz_7_5 : (uint32_t*)s75e_kHz_7_5; + break; + + case 100: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s100n_kHz_7_5 : (uint32_t*)s100e_kHz_7_5; + break; + + default: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; + break; + } + + slot_offset = (uint32_t)slot * frame_parms->samples_per_tti/2; + len = frame_parms->samples_per_tti/2; + +#if defined(__x86_64__) || defined(__i386__) + txptr128 = (__m128i *)&txdata[slot_offset]; + kHz7_5ptr128 = (__m128i *)kHz7_5ptr; +#elif defined(__arm__) + txptr128 = (int16x8_t*)&txdata[slot_offset]; + kHz7_5ptr128 = (int16x8_t*)kHz7_5ptr; +#endif + // apply 7.5 kHz + + for (i=0; i<(len>>2); i++) { +#if defined(__x86_64__) || defined(__i386__) + mmtmp_re = _mm_madd_epi16(*txptr128,*kHz7_5ptr128); + // Real part of complex multiplication (note: 7_5kHz signal is conjugated for this to work) + mmtmp_im = _mm_shufflelo_epi16(*kHz7_5ptr128,_MM_SHUFFLE(2,3,0,1)); + mmtmp_im = _mm_shufflehi_epi16(mmtmp_im,_MM_SHUFFLE(2,3,0,1)); + mmtmp_im = _mm_sign_epi16(mmtmp_im,*(__m128i*)&conjugate75[0]); + mmtmp_im = _mm_madd_epi16(mmtmp_im,txptr128[0]); + mmtmp_re = _mm_srai_epi32(mmtmp_re,15); + mmtmp_im = _mm_srai_epi32(mmtmp_im,15); + mmtmp_re2 = _mm_unpacklo_epi32(mmtmp_re,mmtmp_im); + mmtmp_im2 = _mm_unpackhi_epi32(mmtmp_re,mmtmp_im); + + txptr128[0] = _mm_packs_epi32(mmtmp_re2,mmtmp_im2); + txptr128++; + kHz7_5ptr128++; +#elif defined(__arm__) + + mmtmp0 = vmull_s16(((int16x4_t*)txptr128)[0],((int16x4_t*)kHz7_5ptr128)[0]); + //mmtmp0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] + mmtmp1 = vmull_s16(((int16x4_t*)txptr128)[1],((int16x4_t*)kHz7_5ptr128)[1]); + //mmtmp1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] + mmtmp_re = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), + vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); + //mmtmp_re = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] + + mmtmp0 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[0],*(int16x4_t*)conjugate75_2)),((int16x4_t*)kHz7_5ptr128)[0]); + //mmtmp0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] + mmtmp1 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[1],*(int16x4_t*)conjugate75_2)), ((int16x4_t*)kHz7_5ptr128)[1]); + //mmtmp0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] + mmtmp_im = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), + vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); + //mmtmp_im = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] + + txptr128[0] = vcombine_s16(vmovn_s32(mmtmp_re),vmovn_s32(mmtmp_im)); + txptr128++; + kHz7_5ptr128++; +#endif + } + + //} +} + + diff --git a/openair1/PHY/NBIoT_TRANSPORT/README b/openair1/PHY/NBIoT_TRANSPORT/README new file mode 100644 index 0000000000000000000000000000000000000000..938b70815c5e7019b0ca89013a71855a032d6d1f --- /dev/null +++ b/openair1/PHY/NBIoT_TRANSPORT/README @@ -0,0 +1 @@ +NB-IoT transport channel procedures for NB-IoT are here diff --git a/openair1/PHY/NR_REFSIG/README b/openair1/PHY/NR_REFSIG/README new file mode 100644 index 0000000000000000000000000000000000000000..ea7e5013f9e3581965eba215f182b50a874e54a7 --- /dev/null +++ b/openair1/PHY/NR_REFSIG/README @@ -0,0 +1 @@ +Reference signal definitions for NR diff --git a/openair1/PHY/NR_TRANSPORT/README b/openair1/PHY/NR_TRANSPORT/README new file mode 100644 index 0000000000000000000000000000000000000000..fc7dd3a338c8bfd129e29409052284ee25c642ea --- /dev/null +++ b/openair1/PHY/NR_TRANSPORT/README @@ -0,0 +1 @@ +NR gNB transport channel procedures are here diff --git a/openair1/PHY/NR_UE_TRANSPORT/README b/openair1/PHY/NR_UE_TRANSPORT/README new file mode 100644 index 0000000000000000000000000000000000000000..62393afe9343c5c70ce98a48ffa2a7756ab05d34 --- /dev/null +++ b/openair1/PHY/NR_UE_TRANSPORT/README @@ -0,0 +1 @@ +UE NR transport/physical channel procedures are here diff --git a/openair1/PHY/TOOLS/cadd_vv.c b/openair1/PHY/TOOLS/cadd_vv.c index 34808552fcaab7966d46249853b2ed4a6c9093d8..77346a97f7facdcf1e68a78b7397a709d9af6b12 100644 --- a/openair1/PHY/TOOLS/cadd_vv.c +++ b/openair1/PHY/TOOLS/cadd_vv.c @@ -19,7 +19,8 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "PHY/defs_common.h" +#include "tools_defs.h" int add_vector16(short *x, diff --git a/openair1/PHY/TOOLS/cdot_prod.c b/openair1/PHY/TOOLS/cdot_prod.c index 91ba246bddf51afeb637976ace75c8decec83cae..60bdcf45dd722f98a3eccab80a76963e01f9db1a 100644 --- a/openair1/PHY/TOOLS/cdot_prod.c +++ b/openair1/PHY/TOOLS/cdot_prod.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "tools_defs.h" #include "PHY/sse_intrin.h" // returns the complex dot product of x and y diff --git a/openair1/PHY/TOOLS/cmult_sv.c b/openair1/PHY/TOOLS/cmult_sv.c index 61970ca2b69afa6d8ce38df8fe9d3bf3cc9c9636..013fedc6e9204ed042a7f1025434301532b93656 100644 --- a/openair1/PHY/TOOLS/cmult_sv.c +++ b/openair1/PHY/TOOLS/cmult_sv.c @@ -20,7 +20,7 @@ */ #include "PHY/sse_intrin.h" -#include "defs.h" +#include "tools_defs.h" #if defined(__x86_64__) || defined(__i386__) #define simd_q15_t __m128i diff --git a/openair1/PHY/TOOLS/cmult_vv.c b/openair1/PHY/TOOLS/cmult_vv.c index 13facf69077a165a0f6c05378bb1f847c6c4ab0b..ce3ebec65fe0e29f4bd34e816f484902e7531112 100644 --- a/openair1/PHY/TOOLS/cmult_vv.c +++ b/openair1/PHY/TOOLS/cmult_vv.c @@ -19,7 +19,8 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "PHY/defs_common.h" +#include "tools_defs.h" #include <stdio.h> #if defined(__x86_64__) || defined(__i386__) diff --git a/openair1/PHY/TOOLS/dB_routines.c b/openair1/PHY/TOOLS/dB_routines.c index c99703eaf3c6139682f098aa932691a6522bcfc5..572759a68ca14ed47c4ba785816dc3ddf99f27c2 100644 --- a/openair1/PHY/TOOLS/dB_routines.c +++ b/openair1/PHY/TOOLS/dB_routines.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "tools_defs.h" // Approximate 10*log10(x) in fixed point : x = 0...(2^32)-1 diff --git a/openair1/PHY/TOOLS/lte_dfts.c b/openair1/PHY/TOOLS/lte_dfts.c index 47b39ea7d2666154005d4086e0fdea4c82d8d628..9a5a504ec41eea3d6f69ecf84ed20e5d03c0ed9f 100644 --- a/openair1/PHY/TOOLS/lte_dfts.c +++ b/openair1/PHY/TOOLS/lte_dfts.c @@ -26,9 +26,9 @@ #include <stdint.h> #ifndef MR_MAIN -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "defs.h" +#include "PHY/defs_common.h" +#include "PHY/impl_defs_top.h" +#include "tools_defs.h" #else #include "time_meas.h" #include <math.h> diff --git a/openair1/PHY/TOOLS/lte_phy_scope.c b/openair1/PHY/TOOLS/lte_phy_scope.c index eb86af916597fe0869af11ada340788751f301be..9f2ec54744941e783e0cb27cabeb19b93c95e4d5 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.c +++ b/openair1/PHY/TOOLS/lte_phy_scope.c @@ -23,6 +23,8 @@ #include <stdlib.h> #include "lte_phy_scope.h" +#include "PHY/defs_common.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" #define TPUT_WINDOW_LENGTH 100 int otg_enabled; diff --git a/openair1/PHY/TOOLS/lte_phy_scope.h b/openair1/PHY/TOOLS/lte_phy_scope.h index 1d2b2ea1ed99c5b579aaa6f77b16bf5485108a7d..af9858ebad97796def7d13b4d007171fd61ca920 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.h +++ b/openair1/PHY/TOOLS/lte_phy_scope.h @@ -25,10 +25,9 @@ #define FD_lte_scope_h_ #include <forms.h> -#include "../impl_defs_lte.h" -#include "../impl_defs_top.h" -#include "../defs.h" -#include "../../SCHED/defs.h" // for OPENAIR_DAQ_VARS +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_top.h" /* Forms and Objects */ diff --git a/openair1/PHY/TOOLS/signal_energy.c b/openair1/PHY/TOOLS/signal_energy.c index 918d2e3ba0043c636dcd67a2a875f338e7234063..13f37c4c8dbe9de6362a63abe6bd0f174321c9ef 100644 --- a/openair1/PHY/TOOLS/signal_energy.c +++ b/openair1/PHY/TOOLS/signal_energy.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "tools_defs.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/TOOLS/defs.h b/openair1/PHY/TOOLS/tools_defs.h similarity index 99% rename from openair1/PHY/TOOLS/defs.h rename to openair1/PHY/TOOLS/tools_defs.h index b92c2a42367b59acae680d167af8665f3de7093e..e3b04babdc8f2320f3a319914fbaefbaa20f4a2a 100644 --- a/openair1/PHY/TOOLS/defs.h +++ b/openair1/PHY/TOOLS/tools_defs.h @@ -30,7 +30,6 @@ */ #include <stdint.h> - #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/MODULATION/extern.h b/openair1/PHY/TOOLS/tools_extern.h similarity index 100% rename from openair1/PHY/MODULATION/extern.h rename to openair1/PHY/TOOLS/tools_extern.h diff --git a/openair1/PHY/TOOLS/extern.h b/openair1/PHY/TOOLS/tools_vars.h similarity index 100% rename from openair1/PHY/TOOLS/extern.h rename to openair1/PHY/TOOLS/tools_vars.h diff --git a/openair1/PHY/TOOLS/vars.h b/openair1/PHY/TOOLS/vars.h deleted file mode 100644 index 4690bba42e5b91f4721d727b38d41da928e0c55a..0000000000000000000000000000000000000000 --- a/openair1/PHY/TOOLS/vars.h +++ /dev/null @@ -1,21 +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 - */ - diff --git a/openair1/PHY/defs_L1_NB_IoT.h b/openair1/PHY/defs_L1_NB_IoT.h index 25ee6465482012c0c42a9457cb6dbac02b075dd3..6eb4ce0e9522f1f8a865cb199f040f22bcee92d2 100644 --- a/openair1/PHY/defs_L1_NB_IoT.h +++ b/openair1/PHY/defs_L1_NB_IoT.h @@ -40,7 +40,7 @@ #include <math.h> #include "common_lib.h" #include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h" - +#include "defs_eNB.h" //#include <complex.h> #include "assertions.h" #ifdef MEX diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h new file mode 100644 index 0000000000000000000000000000000000000000..e36b88c036b1f7426f9bcba8f4519f0b46c86d34 --- /dev/null +++ b/openair1/PHY/defs_UE.h @@ -0,0 +1,863 @@ +/* + * 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/defs.h + \brief Top-level defines and structure definitions + \author R. Knopp, F. Kaltenberger + \date 2011 + \version 0.1 + \company Eurecom + \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr + \note + \warning +*/ +#ifndef __PHY_DEFS_UE_H__ +#define __PHY_DEFS_UE_H__ + + +#define _GNU_SOURCE +#include <sched.h> +#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 <linux/sched.h> +#include <signal.h> +#include <execinfo.h> +#include <getopt.h> +#include <sys/sysinfo.h> + + +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> +#include <string.h> +#include <math.h> +#include "common_lib.h" +#include "msc.h" + +#include "defs_common.h" +#include "impl_defs_top.h" + +#include "PHY/TOOLS/time_meas.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "platform_types.h" +#include "PHY/LTE_UE_TRANSPORT/transport_ue.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" // for SIC +#include <pthread.h> +#include "assertions.h" + + +/// Context data structure for RX/TX portion of subframe processing +typedef struct { + /// index of the current UE RX/TX proc + int proc_id; + /// Component Carrier index + uint8_t CC_id; + /// timestamp transmitted to HW + openair0_timestamp timestamp_tx; + /// subframe to act upon for transmission + int subframe_tx; + /// subframe to act upon for reception + int subframe_rx; + /// frame to act upon for transmission + int frame_tx; + /// frame to act upon for reception + int frame_rx; + /// \brief Instance count for RXn-TXnp4 processing thread. + /// \internal This variable is protected by \ref mutex_rxtx. + int instance_cnt_rxtx; + /// pthread structure for RXn-TXnp4 processing thread + pthread_t pthread_rxtx; + /// pthread attributes for RXn-TXnp4 processing thread + pthread_attr_t attr_rxtx; + /// condition variable for tx processing thread + pthread_cond_t cond_rxtx; + /// mutex for RXn-TXnp4 processing thread + pthread_mutex_t mutex_rxtx; + /// scheduling parameters for RXn-TXnp4 thread + struct sched_param sched_param_rxtx; + + /// internal This variable is protected by ref mutex_fep_slot1. + //int instance_cnt_slot0_dl_processing; + int instance_cnt_slot1_dl_processing; + /// pthread descriptor fep_slot1 thread + //pthread_t pthread_slot0_dl_processing; + pthread_t pthread_slot1_dl_processing; + /// pthread attributes for fep_slot1 processing thread + // pthread_attr_t attr_slot0_dl_processing; + pthread_attr_t attr_slot1_dl_processing; + /// condition variable for UE fep_slot1 thread; + //pthread_cond_t cond_slot0_dl_processing; + pthread_cond_t cond_slot1_dl_processing; + /// mutex for UE synch thread + //pthread_mutex_t mutex_slot0_dl_processing; + pthread_mutex_t mutex_slot1_dl_processing; + // + uint8_t chan_est_pilot0_slot1_available; + uint8_t chan_est_slot1_available; + uint8_t llr_slot1_available; + uint8_t dci_slot0_available; + uint8_t first_symbol_available; + //uint8_t channel_level; + /// scheduling parameters for fep_slot1 thread + struct sched_param sched_param_fep_slot1; + + int sub_frame_start; + int sub_frame_step; + unsigned long long gotIQs; +} UE_rxtx_proc_t; + +/// Context data structure for eNB subframe processing +typedef struct { + /// Component Carrier index + uint8_t CC_id; + /// Last RX timestamp + openair0_timestamp timestamp_rx; + /// pthread attributes for main UE thread + pthread_attr_t attr_ue; + /// scheduling parameters for main UE thread + struct sched_param sched_param_ue; + /// pthread descriptor main UE thread + pthread_t pthread_ue; + /// \brief Instance count for synch thread. + /// \internal This variable is protected by \ref mutex_synch. + int instance_cnt_synch; + /// pthread attributes for synch processing thread + pthread_attr_t attr_synch; + /// scheduling parameters for synch thread + struct sched_param sched_param_synch; + /// pthread descriptor synch thread + pthread_t pthread_synch; + /// condition variable for UE synch thread; + pthread_cond_t cond_synch; + /// mutex for UE synch thread + pthread_mutex_t mutex_synch; + /// instance count for eNBs + int instance_cnt_eNBs; + /// set of scheduling variables RXn-TXnp4 threads + UE_rxtx_proc_t proc_rxtx[RX_NB_TH]; +} UE_proc_t; + +/// Panos: Structure holding timer_thread related elements (phy_stub_UE mode) +typedef struct { + pthread_t pthread_timer; + /// Panos: mutex for waiting SF ticking + pthread_mutex_t mutex_ticking; + /// Panos: \brief ticking var for ticking thread. + /// \internal This variable is protected by \ref mutex_ticking. + int ticking_var; + /// condition variable for timer_thread; + pthread_cond_t cond_ticking; + //time_stats_t timer_stats; +} SF_ticking; + +typedef struct { + //unsigned int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (linear) + //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (dB) + //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //! estimated avg received signal power (dB) + + // RRC measurements + uint32_t rssi; + int n_adj_cells; + unsigned int adj_cell_id[6]; + uint32_t rsrq[7]; + uint32_t rsrp[7]; + float rsrp_filtered[7]; // after layer 3 filtering + float rsrq_filtered[7]; + // common measurements + //! estimated noise power (linear) + unsigned int n0_power[NB_ANTENNAS_RX]; + //! estimated noise power (dB) + unsigned short n0_power_dB[NB_ANTENNAS_RX]; + //! total estimated noise power (linear) + unsigned int n0_power_tot; + //! total estimated noise power (dB) + unsigned short n0_power_tot_dB; + //! average estimated noise power (linear) + unsigned int n0_power_avg; + //! average estimated noise power (dB) + unsigned short n0_power_avg_dB; + //! total estimated noise power (dBm) + short n0_power_tot_dBm; + + // UE measurements + //! estimated received spatial signal power (linear) + int rx_spatial_power[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; + //! estimated received spatial signal power (dB) + unsigned short rx_spatial_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; + + /// estimated received signal power (sum over all TX antennas) + //int wideband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + /// estimated received signal power (sum over all TX antennas) + //int wideband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + + /// estimated received signal power (sum over all TX/RX antennas) + int rx_power_tot[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW + /// estimated received signal power (sum over all TX/RX antennas) + unsigned short rx_power_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW + + //! estimated received signal power (sum of all TX/RX antennas, time average) + int rx_power_avg[NUMBER_OF_CONNECTED_eNB_MAX]; + //! estimated received signal power (sum of all TX/RX antennas, time average, in dB) + unsigned short rx_power_avg_dB[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// SINR (sum of all TX/RX antennas, in dB) + int wideband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX]; + /// SINR (sum of all TX/RX antennas, time average, in dB) + int wideband_cqi_avg[NUMBER_OF_CONNECTED_eNB_MAX]; + + //! estimated rssi (dBm) + short rx_rssi_dBm[NUMBER_OF_CONNECTED_eNB_MAX]; + //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) + int rx_correlation[NUMBER_OF_CONNECTED_eNB_MAX][2]; + //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) + int rx_correlation_dB[NUMBER_OF_CONNECTED_eNB_MAX][2]; + + /// Wideband CQI (sum of all RX antennas, in dB, for precoded transmission modes (3,4,5,6), up to 4 spatial streams) + int precoded_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX+1][4]; + /// Subband CQI per RX antenna (= SINR) + int subband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; + /// Total Subband CQI (= SINR) + int subband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; + /// Subband CQI in dB (= SINR dB) + int subband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; + /// Total Subband CQI + int subband_cqi_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; + /// Wideband PMI for each RX antenna + int wideband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + /// Wideband PMI for each RX antenna + int wideband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + ///Subband PMI for each RX antenna + int subband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; + ///Subband PMI for each RX antenna + int subband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; + /// chosen RX antennas (1=Rx antenna 1, 2=Rx antenna 2, 3=both Rx antennas) + unsigned char selected_rx_antennas[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; + /// Wideband Rank indication + unsigned char rank[NUMBER_OF_CONNECTED_eNB_MAX]; + /// Number of RX Antennas + unsigned char nb_antennas_rx; + /// DLSCH error counter + // short dlsch_errors; + +} PHY_MEASUREMENTS; + +typedef struct { + + /// \brief Holds the received data in the frequency domain. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: symbol [0..28*ofdm_symbol_size[ + int32_t **rxdataF; + + /// \brief Hold the channel estimates in frequency domain. + /// - first index: eNB id [0..6] (hard coded) + /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - third index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ + int32_t **dl_ch_estimates[7]; + + /// \brief Hold the channel estimates in time domain (used for tracking). + /// - first index: eNB id [0..6] (hard coded) + /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - third index: samples? [0..2*ofdm_symbol_size[ + int32_t **dl_ch_estimates_time[7]; +}LTE_UE_COMMON_PER_THREAD; + +typedef struct { + /// \brief Holds the transmit data in time domain. + /// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER. + /// - first index: tx antenna [0..nb_antennas_tx[ + /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES[ + int32_t **txdata; + /// \brief Holds the transmit data in the frequency domain. + /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. + /// - first index: tx antenna [0..nb_antennas_tx[ + /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX[ + int32_t **txdataF; + + /// \brief Holds the received data in time domain. + /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES+2048[ + int32_t **rxdata; + + LTE_UE_COMMON_PER_THREAD common_vars_rx_data_per_thread[RX_NB_TH_MAX]; + + /// holds output of the sync correlator + int32_t *sync_corr; + /// estimated frequency offset (in radians) for all subcarriers + int32_t freq_offset; + /// eNb_id user is synched to + int32_t eNb_id; +} LTE_UE_COMMON; + +typedef struct { + /// \brief Received frequency-domain signal after extraction. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **rxdataF_ext; + /// \brief Received frequency-domain ue specific pilots. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..12*N_RB_DL[ + int32_t **rxdataF_uespec_pilots; + /// \brief Received frequency-domain signal after extraction and channel compensation. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **rxdataF_comp0; + /// \brief Received frequency-domain signal after extraction and channel compensation for the second stream. For the SIC receiver we need to store the history of this for each harq process and round + /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid + /// - second index: ? [0..7] (hard coded) accessed via \c round + /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - fourth index: ? [0..168*N_RB_DL[ + int32_t **rxdataF_comp1[8][8]; + /// \brief Downlink channel estimates extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_estimates_ext; + /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. For the SIC receiver we need to store the history of this for each harq process and round + /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid + /// - second index: ? [0..7] (hard coded) accessed via \c round + /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - fourth index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_rho_ext[8][8]; + /// \brief Downlink beamforming channel estimates in frequency domain. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ + int32_t **dl_bf_ch_estimates; + /// \brief Downlink beamforming channel estimates. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_bf_ch_estimates_ext; + /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_rho2_ext; + /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. + /// - first index: ressource block [0..N_RB_DL[ + uint8_t *pmi_ext; + /// \brief Magnitude of Downlink Channel first layer (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_mag0; + /// \brief Magnitude of Downlink Channel second layer (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_mag1[8][8]; + /// \brief Magnitude of Downlink Channel, first layer (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_magb0; + /// \brief Magnitude of Downlink Channel second layer (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_magb1[8][8]; + /// \brief Cross-correlation of two eNB signals. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: symbol [0..] + int32_t **rho; + /// never used... always send dl_ch_rho_ext instead... + int32_t **rho_i; + /// \brief Pointers to llr vectors (2 TBs). + /// - first index: ? [0..1] (hard coded) + /// - second index: ? [0..1179743] (hard coded) + int16_t *llr[2]; + /// \f$\log_2(\max|H_i|^2)\f$ + int16_t log2_maxh; + /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer1 channel compensation + int16_t log2_maxh0; + /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer2 channel commpensation + int16_t log2_maxh1; + /// \brief LLR shifts for subband scaling. + /// - first index: ? [0..168*N_RB_DL[ + uint8_t *llr_shifts; + /// \brief Pointer to LLR shifts. + /// - first index: ? [0..168*N_RB_DL[ + uint8_t *llr_shifts_p; + /// \brief Pointers to llr vectors (128-bit alignment). + /// - first index: ? [0..0] (hard coded) + /// - second index: ? [0..] + int16_t **llr128; + /// \brief Pointers to llr vectors (128-bit alignment). + /// - first index: ? [0..0] (hard coded) + /// - second index: ? [0..] + int16_t **llr128_2ndstream; + //uint32_t *rb_alloc; + //uint8_t Qm[2]; + //MIMO_mode_t mimo_mode; + // llr offset per ofdm symbol + uint32_t llr_offset[14]; + // llr length per ofdm symbol + uint32_t llr_length[14]; +} LTE_UE_PDSCH; + +typedef struct { + /// \brief Received frequency-domain signal after extraction. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + int32_t **rxdataF_ext; + /// \brief Received frequency-domain signal after extraction and channel compensation. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + double **rxdataF_comp; + /// \brief Downlink channel estimates extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + int32_t **dl_ch_estimates_ext; + /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + double **dl_ch_rho_ext; + /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. + /// - first index: ressource block [0..N_RB_DL[ + uint8_t *pmi_ext; + /// \brief Magnitude of Downlink Channel (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + double **dl_ch_mag; + /// \brief Magnitude of Downlink Channel (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + double **dl_ch_magb; + /// \brief Cross-correlation of two eNB signals. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..] + double **rho; + /// never used... always send dl_ch_rho_ext instead... + double **rho_i; + /// \brief Pointers to llr vectors (2 TBs). + /// - first index: ? [0..1] (hard coded) + /// - second index: ? [0..1179743] (hard coded) + int16_t *llr[2]; + /// \f$\log_2(\max|H_i|^2)\f$ + uint8_t log2_maxh; + /// \brief Pointers to llr vectors (128-bit alignment). + /// - first index: ? [0..0] (hard coded) + /// - second index: ? [0..] + int16_t **llr128; + //uint32_t *rb_alloc; + //uint8_t Qm[2]; + //MIMO_mode_t mimo_mode; +} LTE_UE_PDSCH_FLP; + +typedef struct { + /// \brief Pointers to extracted PDCCH symbols in frequency-domain. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **rxdataF_ext; + /// \brief Pointers to extracted and compensated PDCCH symbols in frequency-domain. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **rxdataF_comp; + /// \brief Pointers to extracted channel estimates of PDCCH symbols. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_estimates_ext; + /// \brief Pointers to channel cross-correlation vectors for multi-eNB detection. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_DL[ + int32_t **dl_ch_rho_ext; + /// \brief Pointers to channel cross-correlation vectors for multi-eNB detection. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..] + int32_t **rho; + /// \brief Pointer to llrs, 4-bit resolution. + /// - first index: ? [0..48*N_RB_DL[ + uint16_t *llr; + /// \brief Pointer to llrs, 16-bit resolution. + /// - first index: ? [0..96*N_RB_DL[ + uint16_t *llr16; + /// \brief \f$\overline{w}\f$ from 36-211. + /// - first index: ? [0..48*N_RB_DL[ + uint16_t *wbar; + /// \brief PDCCH/DCI e-sequence (input to rate matching). + /// - first index: ? [0..96*N_RB_DL[ + int8_t *e_rx; + /// number of PDCCH symbols in current subframe + uint8_t num_pdcch_symbols; + /// Allocated CRNTI for UE + uint16_t crnti; + /// 1: the allocated crnti is Temporary C-RNTI / 0: otherwise + uint8_t crnti_is_temporary; + /// Total number of PDU errors (diagnostic mode) + uint32_t dci_errors; + /// Total number of PDU received + uint32_t dci_received; + /// Total number of DCI False detection (diagnostic mode) + uint32_t dci_false; + /// Total number of DCI missed (diagnostic mode) + uint32_t dci_missed; + /// nCCE for PUCCH per subframe + uint8_t nCCE[10]; + //Check for specific DCIFormat and AgregationLevel + uint8_t dciFormat; + uint8_t agregationLevel; +} LTE_UE_PDCCH; + + +typedef struct { + /// \brief Pointers to extracted PBCH symbols in frequency-domain. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..287] (hard coded) + int32_t **rxdataF_ext; + /// \brief Pointers to extracted and compensated PBCH symbols in frequency-domain. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..287] (hard coded) + int32_t **rxdataF_comp; + /// \brief Pointers to downlink channel estimates in frequency-domain extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..287] (hard coded) + int32_t **dl_ch_estimates_ext; + /// \brief Pointer to PBCH llrs. + /// - first index: ? [0..1919] (hard coded) + int8_t *llr; + /// \brief Pointer to PBCH decoded output. + /// - first index: ? [0..63] (hard coded) + uint8_t *decoded_output; + /// \brief Total number of PDU errors. + uint32_t pdu_errors; + /// \brief Total number of PDU errors 128 frames ago. + uint32_t pdu_errors_last; + /// \brief Total number of consecutive PDU errors. + uint32_t pdu_errors_conseq; + /// \brief FER (in percent) . + uint32_t pdu_fer; +} LTE_UE_PBCH; + +typedef struct { + int16_t amp; + int16_t *prachF; + int16_t *prach; +} LTE_UE_PRACH; + + + +typedef enum { + /// do not detect any DCIs in the current subframe + NO_DCI = 0x0, + /// detect only downlink DCIs in the current subframe + UL_DCI = 0x1, + /// detect only uplink DCIs in the current subframe + DL_DCI = 0x2, + /// detect both uplink and downlink DCIs in the current subframe + UL_DL_DCI = 0x3} dci_detect_mode_t; + +typedef struct UE_SCAN_INFO_s { + /// 10 best amplitudes (linear) for each pss signals + int32_t amp[3][10]; + /// 10 frequency offsets (kHz) corresponding to best amplitudes, with respect do minimum DL frequency in the band + int32_t freq_offset_Hz[3][10]; +} UE_SCAN_INFO_t; + +/// Top-level PHY Data Structure for UE +typedef struct { + /// \brief Module ID indicator for this instance + uint8_t Mod_id; + /// \brief Component carrier ID for this PHY instance + uint8_t CC_id; + /// \brief Mapping of CC_id antennas to cards + openair0_rf_map rf_map; + //uint8_t local_flag; + /// \brief Indicator of current run mode of UE (normal_txrx, rx_calib_ue, no_L2_connect, debug_prach) + runmode_t mode; + /// \brief Indicator that UE should perform band scanning + int UE_scan; + /// \brief Indicator that UE should perform coarse scanning around carrier + int UE_scan_carrier; + /// \brief Indicator that UE is synchronized to an eNB + int is_synchronized; + /// Data structure for UE process scheduling + UE_proc_t proc; + /// Flag to indicate the UE shouldn't do timing correction at all + int no_timing_correction; + /// \brief Total gain of the TX chain (16-bit baseband I/Q to antenna) + uint32_t tx_total_gain_dB; + /// \brief Total gain of the RX chain (antenna to baseband I/Q) This is a function of rx_gain_mode (and the corresponding gain) and the rx_gain of the card. + uint32_t rx_total_gain_dB; + /// \brief Total gains with maximum RF gain stage (ExpressMIMO2/Lime) + uint32_t rx_gain_max[4]; + /// \brief Total gains with medium RF gain stage (ExpressMIMO2/Lime) + uint32_t rx_gain_med[4]; + /// \brief Total gains with bypassed RF gain stage (ExpressMIMO2/Lime) + uint32_t rx_gain_byp[4]; + /// \brief Current transmit power + int16_t tx_power_dBm[10]; + /// \brief Total number of REs in current transmission + int tx_total_RE[10]; + /// \brief Maximum transmit power + int8_t tx_power_max_dBm; + /// \brief Number of eNB seen by UE + uint8_t n_connected_eNB; + /// \brief indicator that Handover procedure has been initiated + uint8_t ho_initiated; + /// \brief indicator that Handover procedure has been triggered + uint8_t ho_triggered; + /// \brief Measurement variables. + PHY_MEASUREMENTS measurements; + LTE_DL_FRAME_PARMS frame_parms; + /// \brief Frame parame before ho used to recover if ho fails. + LTE_DL_FRAME_PARMS frame_parms_before_ho; + LTE_UE_COMMON common_vars; + + // point to the current rxTx thread index + uint8_t current_thread_id[10]; + + LTE_UE_PDSCH *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX+1]; // two RxTx Threads + LTE_UE_PDSCH_FLP *pdsch_vars_flp[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_SI[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_ra[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_p[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][2]; // two RxTx Threads + LTE_UE_ULSCH_t *ulsch[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; + // This is for SIC in the UE, to store the reencoded data + LTE_eNB_DLSCH_t *dlsch_eNB[NUMBER_OF_CONNECTED_eNB_MAX]; + + //Paging parameters + uint32_t IMSImod1024; + uint32_t PF; + uint32_t PO; + + // For abstraction-purposes only + uint8_t sr[10]; + uint8_t pucch_sel[10]; + uint8_t pucch_payload[22]; + + UE_MODE_t UE_mode[NUMBER_OF_CONNECTED_eNB_MAX]; + /// cell-specific reference symbols + uint32_t lte_gold_table[7][20][2][14]; + + /// UE-specific reference symbols (p=5), TM 7 + uint32_t lte_gold_uespec_port5_table[20][38]; + + /// ue-specific reference symbols + uint32_t lte_gold_uespec_table[2][20][2][21]; + + /// mbsfn reference symbols + uint32_t lte_gold_mbsfn_table[10][3][42]; + + uint32_t X_u[64][839]; + + uint32_t high_speed_flag; + uint32_t perfect_ce; + int16_t ch_est_alpha; + int generate_ul_signal[NUMBER_OF_CONNECTED_eNB_MAX]; + + UE_SCAN_INFO_t scan_info[NB_BANDS_MAX]; + + char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX]; + + + + unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_eNB_MAX]; + uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_eNB_MAX]; + unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_eNB_MAX]; + PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_eNB_MAX]; + int turbo_iterations, turbo_cntl_iterations; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t total_TBS[NUMBER_OF_CONNECTED_eNB_MAX]; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t total_TBS_last[NUMBER_OF_CONNECTED_eNB_MAX]; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t bitrate[NUMBER_OF_CONNECTED_eNB_MAX]; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t total_received_bits[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_errors_last[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_received_last[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_fer[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_SI_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_SI_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_ra_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_ra_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_p_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_p_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mch_received_sf[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mch_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mcch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mtch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mcch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mtch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mcch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mtch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX]; + unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX]; + uint8_t generate_prach; + uint8_t prach_cnt; + uint8_t prach_PreambleIndex; + // uint8_t prach_timer; + uint8_t decode_SIB; + uint8_t decode_MIB; + int rx_offset; /// Timing offset + int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP + int time_sync_cell; + int timing_advance; ///timing advance signalled from eNB + int hw_timing_advance; + int N_TA_offset; ///timing offset used in TDD + /// Flag to tell if UE is secondary user (cognitive mode) + unsigned char is_secondary_ue; + /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from. + unsigned char has_valid_precoder; + /// hold the precoder for NULL beam to the primary eNB + int **ul_precoder_S_UE; + /// holds the maximum channel/precoder coefficient + char log2_maxp; + + /// if ==0 enables phy only test mode + int mac_enabled; + + /// Flag to initialize averaging of PHY measurements + int init_averaging; + + /// \brief sinr for all subcarriers of the current link (used only for abstraction). + /// - first index: ? [0..12*N_RB_DL[ + double *sinr_dB; + + /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. + /// - first index: ? [0..12*N_RB_DL[ + double *sinr_CQI_dB; + + /// sinr_effective used for CQI calulcation + double sinr_eff; + + /// N0 (used for abstraction) + double N0; + + /// PDSCH Varaibles + PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// PUSCH Varaibles + PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// PUSCH contention-based access vars + PUSCH_CA_CONFIG_DEDICATED pusch_ca_config_dedicated[NUMBER_OF_eNB_MAX]; // lola + + /// PUCCH variables + + PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + uint8_t ncs_cell[20][7]; + + /// UL-POWER-Control + UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// TPC + TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_CONNECTED_eNB_MAX]; + TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// CQI reporting + CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// SRS Variables + SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// Scheduling Request Config + SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// Transmission mode per eNB + uint8_t transmission_mode[NUMBER_OF_CONNECTED_eNB_MAX]; + + time_stats_t phy_proc[RX_NB_TH]; + time_stats_t phy_proc_tx; + time_stats_t phy_proc_rx[RX_NB_TH]; + + uint32_t use_ia_receiver; + + time_stats_t ofdm_mod_stats; + time_stats_t ulsch_encoding_stats; + time_stats_t ulsch_modulation_stats; + time_stats_t ulsch_segmentation_stats; + time_stats_t ulsch_rate_matching_stats; + time_stats_t ulsch_turbo_encoding_stats; + time_stats_t ulsch_interleaving_stats; + time_stats_t ulsch_multiplexing_stats; + + time_stats_t generic_stat; + time_stats_t generic_stat_bis[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t ue_front_end_stat[RX_NB_TH]; + time_stats_t ue_front_end_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t pdcch_procedures_stat[RX_NB_TH]; + time_stats_t pdsch_procedures_stat[RX_NB_TH]; + time_stats_t pdsch_procedures_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t dlsch_procedures_stat[RX_NB_TH]; + + time_stats_t ofdm_demod_stats; + time_stats_t dlsch_rx_pdcch_stats; + time_stats_t rx_dft_stats; + time_stats_t dlsch_channel_estimation_stats; + time_stats_t dlsch_freq_offset_estimation_stats; + time_stats_t dlsch_decoding_stats[2]; + time_stats_t dlsch_demodulation_stats; + time_stats_t dlsch_rate_unmatching_stats; + time_stats_t dlsch_turbo_decoding_stats; + time_stats_t dlsch_deinterleaving_stats; + time_stats_t dlsch_llr_stats; + time_stats_t dlsch_llr_stats_parallelization[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t dlsch_unscrambling_stats; + time_stats_t dlsch_rate_matching_stats; + time_stats_t dlsch_turbo_encoding_stats; + time_stats_t dlsch_interleaving_stats; + time_stats_t dlsch_tc_init_stats; + time_stats_t dlsch_tc_alpha_stats; + time_stats_t dlsch_tc_beta_stats; + time_stats_t dlsch_tc_gamma_stats; + time_stats_t dlsch_tc_ext_stats; + time_stats_t dlsch_tc_intl1_stats; + time_stats_t dlsch_tc_intl2_stats; + time_stats_t tx_prach; + time_stats_t timer_stats; + + pthread_mutex_t timer_mutex; + pthread_cond_t timer_cond; + int instance_cnt_timer; + + /// RF and Interface devices per CC + + openair0_device rfdevice; +} PHY_VARS_UE; + +/* this structure is used to pass both UE phy vars and + * proc to the function UE_thread_rxn_txnp4 + */ +struct rx_tx_thread_data { + PHY_VARS_UE *UE; + UE_rxtx_proc_t *proc; +}; + + +#endif // __PHY_DEFS__H__ diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h new file mode 100644 index 0000000000000000000000000000000000000000..c253488a200b687ea107541f2991fd7d12cafd3d --- /dev/null +++ b/openair1/PHY/defs_common.h @@ -0,0 +1,1082 @@ +/* + * 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/defs.h + \brief Top-level defines and structure definitions + \author R. Knopp, F. Kaltenberger + \date 2011 + \version 0.1 + \company Eurecom + \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr + \note + \warning +*/ +#ifndef __PHY_DEFS_COMMON_H__ +#define __PHY_DEFS_COMMON_H__ + + +#define _GNU_SOURCE +#include <sched.h> +#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 <linux/sched.h> +#include <signal.h> +#include <execinfo.h> +#include <getopt.h> +#include <sys/sysinfo.h> + + +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> +#include <string.h> +#include <math.h> +#include "common_lib.h" +#include "msc.h" + + +//#include <complex.h> + + + + + + + +#include "PHY/TOOLS/time_meas.h" +#include "platform_types.h" +#define MAX_NUM_RU_PER_eNB 64 + +#include <pthread.h> + +#include "targets/ARCH/COMMON/common_lib.h" +#include "targets/COMMON/openairinterface5g_limits.h" + +#include "types.h" +#include "nfapi_interface.h" +//#include "defs.h" +#include "openair2/COMMON/platform_types.h" + +#define RX_NB_TH_MAX 2 +#define RX_NB_TH 2 + +#define LTE_SLOTS_PER_SUBFRAME 2 + +#define LTE_NUMBER_OF_SUBFRAMES_PER_FRAME 10 +#define LTE_SLOTS_PER_FRAME 20 +#define LTE_CE_FILTER_LENGTH 5 +#define LTE_CE_OFFSET LTE_CE_FILTER_LENGTH +#define TX_RX_SWITCH_SYMBOL (NUMBER_OF_SYMBOLS_PER_FRAME>>1) +#define PBCH_PDU_SIZE 3 //bytes + +#define PRACH_SYMBOL 3 //position of the UL PSS wrt 2nd slot of special subframe + +#define NUMBER_OF_FREQUENCY_GROUPS (lte_frame_parms->N_RB_DL) + +#define SSS_AMP 1148 + +#define MAX_NUM_PHICH_GROUPS 56 //110 RBs Ng=2, p.60 36-212, Sec. 6.9 + +#define MAX_MBSFN_AREA 8 + +#define NB_RX_ANTENNAS_MAX 64 + +#ifdef OCP_FRAMEWORK +#include "enums.h" +#else +typedef enum {TDD=1,FDD=0} lte_frame_type_t; + +typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t; + +typedef enum {LOCALIZED=0,DISTRIBUTED=1} vrb_t; + +/// Enumeration for parameter PHICH-Duration \ref PHICH_CONFIG_COMMON::phich_duration. +typedef enum { + normal=0, + extended=1 +} PHICH_DURATION_t; + +/// Enumeration for parameter Ng \ref PHICH_CONFIG_COMMON::phich_resource. +typedef enum { + oneSixth=1, + half=3, + one=6, + two=12 +} PHICH_RESOURCE_t; +#endif +/// PHICH-Config from 36.331 RRC spec +typedef struct { + /// Parameter: PHICH-Duration, see TS 36.211 (Table 6.9.3-1). + PHICH_DURATION_t phich_duration; + /// Parameter: Ng, see TS 36.211 (6.9). \details Value oneSixth corresponds to 1/6, half corresponds to 1/2 and so on. + PHICH_RESOURCE_t phich_resource; +} PHICH_CONFIG_COMMON; + +/// PRACH-ConfigInfo from 36.331 RRC spec +typedef struct { + /// Parameter: prach-ConfigurationIndex, see TS 36.211 (5.7.1). \vr{[0..63]} + uint8_t prach_ConfigIndex; + /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. + uint8_t highSpeedFlag; + /// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. + uint8_t zeroCorrelationZoneConfig; + /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. + uint8_t prach_FreqOffset; +} PRACH_CONFIG_INFO; + + + +/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec +typedef struct { + /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} + uint16_t rootSequenceIndex; + /// prach_Config_enabled=1 means enabled. \vr{[0..1]} + uint8_t prach_Config_enabled; + /// PRACH Configuration Information + PRACH_CONFIG_INFO prach_ConfigInfo; +} PRACH_CONFIG_COMMON; + +#ifdef Rel14 + +/// PRACH-eMTC-Config from 36.331 RRC spec +typedef struct { + /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. + uint8_t highSpeedFlag; +/// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. + uint8_t zeroCorrelationZoneConfig; + /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. + + /// PRACH starting subframe periodicity, expressed in number of subframes available for preamble transmission (PRACH opportunities), see TS 36.211. Value 2 corresponds to 2 subframes, 4 corresponds to 4 subframes and so on. EUTRAN configures the PRACH starting subframe periodicity larger than or equal to the Number of PRACH repetitions per attempt for each CE level (numRepetitionPerPreambleAttempt). + uint8_t prach_starting_subframe_periodicity[4]; + /// number of repetitions per preamble attempt per CE level + uint8_t prach_numRepetitionPerPreambleAttempt[4]; + /// prach configuration index for each CE level + uint8_t prach_ConfigIndex[4]; + /// indicator for CE level activation + uint8_t prach_CElevel_enable[4]; + /// prach frequency offset for each CE level + uint8_t prach_FreqOffset[4]; + /// indicator for CE level hopping activation + uint8_t prach_hopping_enable[4]; + /// indicator for CE level hopping activation + uint8_t prach_hopping_offset[4]; +} PRACH_eMTC_CONFIG_INFO; + +/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec +typedef struct { + /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} + uint16_t rootSequenceIndex; + /// 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; + +#endif + +/// Enumeration for parameter \f$N_\text{ANRep}\f$ \ref PUCCH_CONFIG_DEDICATED::repetitionFactor. +typedef enum { + n2=0, + n4, + n6 +} ACKNAKREP_t; + +/// Enumeration for \ref PUCCH_CONFIG_DEDICATED::tdd_AckNackFeedbackMode. +typedef enum { + bundling=0, + multiplexing +} ANFBmode_t; + +/// PUCCH-ConfigDedicated from 36.331 RRC spec +typedef struct { + /// Flag to indicate ACK NAK repetition activation, see TS 36.213 (10.1). \vr{[0..1]} + uint8_t ackNackRepetition; + /// Parameter: \f$N_\text{ANRep}\f$, see TS 36.213 (10.1). + ACKNAKREP_t repetitionFactor; + /// Parameter: \f$n^{(1)}_\text{PUCCH,ANRep}\f$, see TS 36.213 (10.1). \vr{[0..2047]} + uint16_t n1PUCCH_AN_Rep; + /// Feedback mode, see TS 36.213 (7.3). \details Applied to both PUCCH and PUSCH feedback. For TDD, should always be set to bundling. + ANFBmode_t tdd_AckNackFeedbackMode; +} PUCCH_CONFIG_DEDICATED; + +/// PUCCH-ConfigCommon from 36.331 RRC spec +typedef struct { + /// Parameter: \f$\Delta^\text{PUCCH}_\text{shift}\f$, see TS 36.211 (5.4.1). \vr{[1..3]} \note the specification sais it is an enumerated value. + uint8_t deltaPUCCH_Shift; + /// Parameter: \f$N^{(2)}_\text{RB}\f$, see TS 36.211 (5.4). \vr{[0..98]} + uint8_t nRB_CQI; + /// Parameter: \f$N^{(1)}_\text{CS}\f$, see TS 36.211 (5.4). \vr{[0..7]} + uint8_t nCS_AN; + /// Parameter: \f$N^{(1)}_\text{PUCCH}\f$ see TS 36.213 (10.1). \vr{[0..2047]} + uint16_t n1PUCCH_AN; + + /// group hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. + uint8_t grouphop[20]; + /// sequence hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. + uint8_t seqhop[20]; +} PUCCH_CONFIG_COMMON; + +/// UL-ReferenceSignalsPUSCH from 36.331 RRC spec +typedef struct { + /// Parameter: Group-hopping-enabled, see TS 36.211 (5.5.1.3). \vr{[0..1]} + uint8_t groupHoppingEnabled; + /// Parameter: \f$\Delta SS\f$, see TS 36.211 (5.5.1.3). \vr{[0..29]} + uint8_t groupAssignmentPUSCH; + /// Parameter: Sequence-hopping-enabled, see TS 36.211 (5.5.1.4). \vr{[0..1]} + uint8_t sequenceHoppingEnabled; + /// Parameter: cyclicShift, see TS 36.211 (Table 5.5.2.1.1-2). \vr{[0..7]} + uint8_t cyclicShift; + /// nPRS for cyclic shift of DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. + uint8_t nPRS[20]; + /// group hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. + uint8_t grouphop[20]; + /// sequence hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. + uint8_t seqhop[20]; +} UL_REFERENCE_SIGNALS_PUSCH_t; + +/// Enumeration for parameter Hopping-mode \ref PUSCH_CONFIG_COMMON::hoppingMode. +#ifndef OCP_FRAMEWORK +typedef enum { + interSubFrame=0, + intraAndInterSubFrame=1 +} PUSCH_HOPPING_t; +#endif + +/// PUSCH-ConfigCommon from 36.331 RRC spec. +typedef struct { + /// Parameter: \f$N_{sb}\f$, see TS 36.211 (5.3.4). \vr{[1..4]} + uint8_t n_SB; + /// Parameter: Hopping-mode, see TS 36.211 (5.3.4). + PUSCH_HOPPING_t hoppingMode; + /// Parameter: \f$N^{HO}_{RB}\f$, see TS 36.211 (5.3.4). \vr{[0..98]} + uint8_t pusch_HoppingOffset; + /// See TS 36.213 (8.6.1). \vr{[0..1]} 1 indicates 64QAM is allowed, 0 not allowed. + uint8_t enable64QAM; + /// Ref signals configuration + UL_REFERENCE_SIGNALS_PUSCH_t ul_ReferenceSignalsPUSCH; +} PUSCH_CONFIG_COMMON; + +/// UE specific PUSCH configuration. +typedef struct { + /// Parameter: \f$I^\text{HARQ-ACK}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-1). \vr{[0..15]} + uint16_t betaOffset_ACK_Index; + /// Parameter: \f$I^{RI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-2). \vr{[0..15]} + uint16_t betaOffset_RI_Index; + /// Parameter: \f$I^{CQI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-3). \vr{[0..15]} + uint16_t betaOffset_CQI_Index; +} PUSCH_CONFIG_DEDICATED; + +/// lola CBA information +typedef struct { + /// + uint16_t betaOffset_CA_Index; + /// + uint16_t cShift; +} PUSCH_CA_CONFIG_DEDICATED; + +/// PDSCH-ConfigCommon from 36.331 RRC spec +typedef struct { + /// Parameter: Reference-signal power, see TS 36.213 (5.2). \vr{[-60..50]}\n Provides the downlink reference-signal EPRE. The actual value in dBm. + int8_t referenceSignalPower; + /// Parameter: \f$P_B\f$, see TS 36.213 (Table 5.2-1). \vr{[0..3]} + uint8_t p_b; +} PDSCH_CONFIG_COMMON; + +/// Enumeration for Parameter \f$P_A\f$ \ref PDSCH_CONFIG_DEDICATED::p_a. +typedef enum { + dBm6=0, ///< (dB-6) corresponds to -6 dB + dBm477, ///< (dB-4dot77) corresponds to -4.77 dB + dBm3, ///< (dB-3) corresponds to -3 dB + dBm177, ///< (dB-1dot77) corresponds to -1.77 dB + dB0, ///< corresponds to 0 dB + dB1, ///< corresponds to 1 dB + dB2, ///< corresponds to 2 dB + dB3 ///< corresponds to 3 dB +} PA_t; + +/// PDSCH-ConfigDedicated from 36.331 RRC spec +typedef struct { + /// Parameter: \f$P_A\f$, see TS 36.213 (5.2). + PA_t p_a; +} PDSCH_CONFIG_DEDICATED; + +/// SoundingRS-UL-ConfigCommon Information Element from 36.331 RRC spec +typedef struct { + /// enabled flag=1 means SRS is enabled. \vr{[0..1]} + uint8_t enabled_flag; + /// Parameter: SRS Bandwidth Configuration, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..7]}\n Actual configuration depends on UL bandwidth. \note the specification sais it is an enumerated value. + uint8_t srs_BandwidthConfig; + /// Parameter: SRS SubframeConfiguration, see TS 36.211 (table 5.5.3.3-1 for FDD, table 5.5.3.3-2 for TDD). \vr{[0..15]} \note the specification sais it is an enumerated value. + uint8_t srs_SubframeConfig; + /// Parameter: Simultaneous-AN-and-SRS, see TS 36.213 (8.2). \vr{[0..1]} + uint8_t ackNackSRS_SimultaneousTransmission; + /// Parameter: srsMaxUpPts, see TS 36.211 (5.5.3.2). \details If this field is present, reconfiguration of \f$m^\text{max}_\text{SRS,0}\f$ applies for UpPts, otherwise reconfiguration does not apply. + uint8_t srs_MaxUpPts; +} SOUNDINGRS_UL_CONFIG_COMMON; + +/// \note UNUSED +typedef enum { + ulpc_al0=0, + ulpc_al04=1, + ulpc_al05=2, + ulpc_al06=3, + ulpc_al07=4, + ulpc_al08=5, + ulpc_al09=6, + ulpc_al11=7 +} UL_POWER_CONTROL_COMMON_alpha_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1. +typedef enum { + deltaF_PUCCH_Format1_deltaF_2 = 0, + deltaF_PUCCH_Format1_deltaF0 = 1, + deltaF_PUCCH_Format1_deltaF2 = 2 +} deltaF_PUCCH_Format1_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1b. +typedef enum { + deltaF_PUCCH_Format1b_deltaF1 = 0, + deltaF_PUCCH_Format1b_deltaF3 = 1, + deltaF_PUCCH_Format1b_deltaF5 = 2 +} deltaF_PUCCH_Format1b_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2. +typedef enum { + deltaF_PUCCH_Format2_deltaF_2 = 0, + deltaF_PUCCH_Format2_deltaF0 = 1, + deltaF_PUCCH_Format2_deltaF1 = 2, + deltaF_PUCCH_Format2_deltaF2 = 3 +} deltaF_PUCCH_Format2_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2a. +typedef enum { + deltaF_PUCCH_Format2a_deltaF_2 = 0, + deltaF_PUCCH_Format2a_deltaF0 = 1, + deltaF_PUCCH_Format2a_deltaF2 = 2 +} deltaF_PUCCH_Format2a_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2b. +typedef enum { + deltaF_PUCCH_Format2b_deltaF_2 = 0, + deltaF_PUCCH_Format2b_deltaF0 = 1, + deltaF_PUCCH_Format2b_deltaF2 = 2 +} deltaF_PUCCH_Format2b_t; + +/// DeltaFList-PUCCH from 36.331 RRC spec +typedef struct { + deltaF_PUCCH_Format1_t deltaF_PUCCH_Format1; + deltaF_PUCCH_Format1b_t deltaF_PUCCH_Format1b; + deltaF_PUCCH_Format2_t deltaF_PUCCH_Format2; + deltaF_PUCCH_Format2a_t deltaF_PUCCH_Format2a; + deltaF_PUCCH_Format2b_t deltaF_PUCCH_Format2b; +} deltaFList_PUCCH_t; + +/// SoundingRS-UL-ConfigDedicated Information Element from 36.331 RRC spec +typedef struct { + /// This descriptor is active + uint8_t active; + /// This descriptor's frame + uint16_t frame; + /// This descriptor's subframe + uint8_t subframe; + /// rnti + uint16_t rnti; + /// Parameter: \f$B_\text{SRS}\f$, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..3]} \note the specification sais it is an enumerated value. + uint8_t srs_Bandwidth; + /// Parameter: SRS hopping bandwidth \f$b_\text{hop}\in\{0,1,2,3\}\f$, see TS 36.211 (5.5.3.2) \vr{[0..3]} \note the specification sais it is an enumerated value. + uint8_t srs_HoppingBandwidth; + /// Parameter: \f$n_\text{RRC}\f$, see TS 36.211 (5.5.3.2). \vr{[0..23]} + uint8_t freqDomainPosition; + /// Parameter: Duration, see TS 36.213 (8.2). \vr{[0..1]} 0 corresponds to "single" and 1 to "indefinite". + uint8_t duration; + /// Parameter: \f$k_\text{TC}\in\{0,1\}\f$, see TS 36.211 (5.5.3.2). \vr{[0..1]} + uint8_t transmissionComb; + /// Parameter: \f$I_\text{SRS}\f$, see TS 36.213 (table 8.2-1). \vr{[0..1023]} + uint16_t srs_ConfigIndex; + /// Parameter: \f$n^\text{CS}_\text{SRS}\f$. See TS 36.211 (5.5.3.1). \vr{[0..7]} \note the specification sais it is an enumerated value. + uint8_t cyclicShift; + // Parameter: internal implementation: UE SRS configured + uint8_t srsConfigDedicatedSetup; + // Parameter: cell srs subframe for internal implementation + uint8_t srsCellSubframe; + // Parameter: ue srs subframe for internal implementation + uint8_t srsUeSubframe; +} SOUNDINGRS_UL_CONFIG_DEDICATED; + +/// UplinkPowerControlDedicated Information Element from 36.331 RRC spec +typedef struct { + /// Parameter: \f$P_\text{0\_UE\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dB. \vr{[-8..7]}\n This field is applicable for non-persistent scheduling, only. + int8_t p0_UE_PUSCH; + /// Parameter: Ks, see TS 36.213 (5.1.1.1). \vr{[0..1]}\n en0 corresponds to value 0 corresponding to state “disabledâ€. en1 corresponds to value 1.25 corresponding to “enabledâ€. \note the specification sais it is an enumerated value. \warning the enumeration values do not correspond to the given values in the specification (en1 should be 1.25). + uint8_t deltaMCS_Enabled; + /// Parameter: Accumulation-enabled, see TS 36.213 (5.1.1.1). \vr{[0..1]} 1 corresponds to "enabled" whereas 0 corresponds to "disabled". + uint8_t accumulationEnabled; + /// Parameter: \f$P_\text{0\_UE\_PUCCH}(1)\f$, see TS 36.213 (5.1.2.1), unit dB. \vr{[-8..7]} + int8_t p0_UE_PUCCH; + /// Parameter: \f$P_\text{SRS\_OFFSET}\f$, see TS 36.213 (5.1.3.1). \vr{[0..15]}\n For Ks=1.25 (\ref deltaMCS_Enabled), the actual parameter value is pSRS_Offset value - 3. For Ks=0, the actual parameter value is -10.5 + 1.5*pSRS_Offset value. + int8_t pSRS_Offset; + /// Specifies the filtering coefficient for RSRP measurements used to calculate path loss, as specified in TS 36.213 (5.1.1.1).\details The same filtering mechanism applies as for quantityConfig described in 5.5.3.2. \note the specification sais it is an enumerated value. + uint8_t filterCoefficient; +} UL_POWER_CONTROL_DEDICATED; + +#ifndef OCP_FRAMEWORK +/// Enumeration for parameter \f$\alpha\f$ \ref UL_POWER_CONTROL_CONFIG_COMMON::alpha. +typedef enum { + al0=0, + al04=1, + al05=2, + al06=3, + al07=4, + al08=5, + al09=6, + al1=7 +} PUSCH_alpha_t; +#endif + +/// \note UNUSED +typedef enum { + deltaFm2=0, + deltaF0, + deltaF1, + deltaF2, + deltaF3, + deltaF5 +} deltaF_PUCCH_t; + +/// UplinkPowerControlCommon Information Element from 36.331 RRC spec \note this structure does not currently make use of \ref deltaFList_PUCCH_t. +typedef struct { + /// Parameter: \f$P_\text{0\_NOMINAL\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dBm. \vr{[-126..24]}\n This field is applicable for non-persistent scheduling, only. + int8_t p0_NominalPUSCH; + /// Parameter: \f$\alpha\f$, see TS 36.213 (5.1.1.1) \warning the enumeration values do not correspond to the given values in the specification (al04 should be 0.4, ...)! + PUSCH_alpha_t alpha; + /// Parameter: \f$P_\text{0\_NOMINAL\_PUCCH}\f$ See TS 36.213 (5.1.2.1), unit dBm. \vr{[-127..-96]} + int8_t p0_NominalPUCCH; + /// Parameter: \f$\Delta_\text{PREAMBLE\_Msg3}\f$ see TS 36.213 (5.1.1.1). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. + int8_t deltaPreambleMsg3; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format1; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format1a; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format1b; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2, see TS 36.213 (5.1.2). \vr{[0..3]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format2; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format2a; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format2b; +} UL_POWER_CONTROL_CONFIG_COMMON; + +/// Union for \ref TPC_PDCCH_CONFIG::tpc_Index. +typedef union { + /// Index of N when DCI format 3 is used. See TS 36.212 (5.3.3.1.6). \vr{[1..15]} + uint8_t indexOfFormat3; + /// Index of M when DCI format 3A is used. See TS 36.212 (5.3.3.1.7). \vr{[1..31]} + uint8_t indexOfFormat3A; +} TPC_INDEX_t; + +/// TPC-PDCCH-Config Information Element from 36.331 RRC spec +typedef struct { + /// RNTI for power control using DCI format 3/3A, see TS 36.212. \vr{[0..65535]} + uint16_t rnti; + /// Index of N or M, see TS 36.212 (5.3.3.1.6 and 5.3.3.1.7), where N or M is dependent on the used DCI format (i.e. format 3 or 3a). + TPC_INDEX_t tpc_Index; +} TPC_PDCCH_CONFIG; + +/// Enumeration for parameter SR transmission \ref SCHEDULING_REQUEST_CONFIG::dsr_TransMax. +typedef enum { + sr_n4=0, + sr_n8=1, + sr_n16=2, + sr_n32=3, + sr_n64=4 +} DSR_TRANSMAX_t; + +/// SchedulingRequestConfig Information Element from 36.331 RRC spec +typedef struct { + /// Parameter: \f$n^{(1)}_\text{PUCCH,SRI}\f$, see TS 36.213 (10.1). \vr{[0..2047]} + uint16_t sr_PUCCH_ResourceIndex; + /// Parameter: \f$I_\text{SR}\f$, see TS 36.213 (10.1). \vr{[0..155]} + uint8_t sr_ConfigIndex; + /// Parameter for SR transmission in TS 36.321 (5.4.4). \details The value n4 corresponds to 4 transmissions, n8 corresponds to 8 transmissions and so on. + DSR_TRANSMAX_t dsr_TransMax; +} SCHEDULING_REQUEST_CONFIG; + +/// CQI-ReportPeriodic +typedef struct { + /// Parameter: \f$n^{(2)}_\text{PUCCH}\f$, see TS 36.213 (7.2). \vr{[0..1185]}, -1 indicates inactivity + int16_t cqi_PUCCH_ResourceIndex; + /// Parameter: CQI/PMI Periodicity and Offset Configuration Index \f$I_\text{CQI/PMI}\f$, see TS 36.213 (tables 7.2.2-1A and 7.2.2-1C). \vr{[0..1023]} + int16_t cqi_PMI_ConfigIndex; + /// Parameter: K, see 36.213 (4.2.2). \vr{[1..4]} + uint8_t K; + /// Parameter: RI Config Index \f$I_\text{RI}\f$, see TS 36.213 (7.2.2-1B). \vr{[0..1023]}, -1 indicates inactivity + int16_t ri_ConfigIndex; + /// Parameter: Simultaneous-AN-and-CQI, see TS 36.213 (10.1). \vr{[0..1]} 1 indicates that simultaneous transmission of ACK/NACK and CQI is allowed. + uint8_t simultaneousAckNackAndCQI; + /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C + uint16_t Npd; + /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C + uint16_t N_OFFSET_CQI; +} CQI_REPORTPERIODIC; + +/// Enumeration for parameter reporting mode \ref CQI_REPORT_CONFIG::cqi_ReportModeAperiodic. +typedef enum { + rm12=0, + rm20=1, + rm22=2, + rm30=3, + rm31=4 +} CQI_REPORTMODEAPERIODIC; + +/// CQI-ReportConfig Information Element from 36.331 RRC spec +typedef struct { + /// Parameter: reporting mode. Value rm12 corresponds to Mode 1-2, rm20 corresponds to Mode 2-0, rm22 corresponds to Mode 2-2 etc. PUSCH reporting modes are described in TS 36.213 [23, 7.2.1]. + CQI_REPORTMODEAPERIODIC cqi_ReportModeAperiodic; + /// Parameter: \f$\Delta_\text{offset}\f$, see TS 36.213 (7.2.3). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. + int8_t nomPDSCH_RS_EPRE_Offset; + CQI_REPORTPERIODIC CQI_ReportPeriodic; +} CQI_REPORT_CONFIG; + +/// MBSFN-SubframeConfig Information Element from 36.331 RRC spec \note deviates from specification. +typedef struct { + /// MBSFN subframe occurance. \details Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. \note the specification sais it is an enumerated value {n1, n2, n4, n8, n16, n32}. + int radioframeAllocationPeriod; + /// MBSFN subframe occurance. \vr{[0..7]}\n Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. + int radioframeAllocationOffset; + /// oneFrame or fourFrames. \vr{[0..1]} + int fourFrames_flag; + /// Subframe configuration. \vr{[0..63]} (\ref fourFrames_flag == 0) or \vr{[0..16777215]} (\ref fourFrames_flag == 1) + /// \par fourFrames_flag == 0 + /// "1" denotes that the corresponding subframe is allocated for MBSFN. The following mapping applies:\n FDD: The first/leftmost bit defines the MBSFN allocation for subframe #1, the second bit for #2, third bit for #3 , fourth bit for #6, fifth bit for #7, sixth bit for #8.\n TDD: The first/leftmost bit defines the allocation for subframe #3, the second bit for #4, third bit for #7, fourth bit for #8, fifth bit for #9. Uplink subframes are not allocated. The last bit is not used. + /// \par fourFrames_flag == 1 + /// A bit-map indicating MBSFN subframe allocation in four consecutive radio frames, "1" denotes that the corresponding subframe is allocated for MBSFN. The bitmap is interpreted as follows:\n FDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #1, #2, #3 , #6, #7, and #8 in the sequence of the four radio-frames.\n TDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #3, #4, #7, #8, and #9 in the sequence of the four radio-frames. The last four bits are not used. Uplink subframes are not allocated. + int mbsfn_SubframeConfig; +} MBSFN_config_t; + +typedef struct { + /// Number of resource blocks (RB) in DL + uint8_t N_RB_DL; + /// Number of resource blocks (RB) in UL + uint8_t N_RB_UL; + /// EUTRA Band + uint8_t eutra_band; + /// DL carrier frequency + uint32_t dl_CarrierFreq; + /// UL carrier frequency + uint32_t ul_CarrierFreq; + /// TX attenuation + uint32_t att_tx; + /// RX attenuation + uint32_t att_rx; + /// total Number of Resource Block Groups: this is ceil(N_PRB/P) + uint8_t N_RBG; + /// Total Number of Resource Block Groups SubSets: this is P + uint8_t N_RBGS; + /// Cell ID + uint16_t Nid_cell; + /// MBSFN Area ID + uint16_t Nid_cell_mbsfn; + /// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP) + lte_prefix_type_t Ncp; + /// Cyclic Prefix for UL (0=Normal CP, 1=Extended CP) + lte_prefix_type_t Ncp_UL; + /// shift of pilot position in one RB + uint8_t nushift; + /// Frame type (0 FDD, 1 TDD) + lte_frame_type_t frame_type; + /// TDD subframe assignment (0-7) (default = 3) (254=RX only, 255=TX only) + uint8_t tdd_config; + /// TDD S-subframe configuration (0-9) + uint8_t tdd_config_S; + /// srs extra symbol flag for TDD + uint8_t srsX; + /// indicates if node is a UE (NODE=2) or eNB (PRIMARY_CH=0). + uint8_t node_id; + /// Indicator that 20 MHz channel uses 3/4 sampling frequency + uint8_t threequarter_fs; + /// Size of FFT + uint16_t ofdm_symbol_size; + /// Number of prefix samples in all but first symbol of slot + uint16_t nb_prefix_samples; + /// Number of prefix samples in first symbol of slot + uint16_t nb_prefix_samples0; + /// Carrier offset in FFT buffer for first RE in PRB0 + uint16_t first_carrier_offset; + /// Number of samples in a subframe + uint32_t samples_per_tti; + /// Number of OFDM/SC-FDMA symbols in one subframe (to be modified to account for potential different in UL/DL) + uint16_t symbols_per_tti; + /// Number of OFDM symbols in DL portion of S-subframe + uint16_t dl_symbols_in_S_subframe; + /// Number of SC-FDMA symbols in UL portion of S-subframe + uint16_t ul_symbols_in_S_subframe; + /// Number of Physical transmit antennas in node + uint8_t nb_antennas_tx; + /// Number of Receive antennas in node + uint8_t nb_antennas_rx; + /// Number of common transmit antenna ports in eNodeB (1 or 2) + uint8_t nb_antenna_ports_eNB; + /// PRACH_CONFIG + PRACH_CONFIG_COMMON prach_config_common; +#ifdef Rel14 + /// PRACH_eMTC_CONFIG + PRACH_eMTC_CONFIG_COMMON prach_emtc_config_common; +#endif + /// PUCCH Config Common (from 36-331 RRC spec) + PUCCH_CONFIG_COMMON pucch_config_common; + /// PDSCH Config Common (from 36-331 RRC spec) + PDSCH_CONFIG_COMMON pdsch_config_common; + /// PUSCH Config Common (from 36-331 RRC spec) + PUSCH_CONFIG_COMMON pusch_config_common; + /// PHICH Config (from 36-331 RRC spec) + PHICH_CONFIG_COMMON phich_config_common; + /// SRS Config (from 36-331 RRC spec) + SOUNDINGRS_UL_CONFIG_COMMON soundingrs_ul_config_common; + /// UL Power Control (from 36-331 RRC spec) + UL_POWER_CONTROL_CONFIG_COMMON ul_power_control_config_common; + /// Number of MBSFN Configurations + int num_MBSFN_config; + /// Array of MBSFN Configurations (max 8 (maxMBSFN-Allocations) elements as per 36.331) + MBSFN_config_t MBSFN_config[8]; + /// Maximum Number of Retransmissions of RRCConnectionRequest (from 36-331 RRC Spec) + uint8_t maxHARQ_Msg3Tx; + /// Size of SI windows used for repetition of one SI message (in frames) + uint8_t SIwindowsize; + /// Period of SI windows used for repetition of one SI message (in frames) + uint16_t SIPeriod; + /// REGs assigned to PCFICH + uint16_t pcfich_reg[4]; + /// Index of first REG assigned to PCFICH + uint8_t pcfich_first_reg_idx; + /// REGs assigned to PHICH + uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; + + struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[MAX_MBSFN_AREA]; + +} LTE_DL_FRAME_PARMS; + +typedef enum { + /// TM1 + SISO=0, + /// TM2 + ALAMOUTI=1, + /// TM3 + LARGE_CDD=2, + /// the next 6 entries are for TM5 + UNIFORM_PRECODING11=3, + UNIFORM_PRECODING1m1=4, + UNIFORM_PRECODING1j=5, + UNIFORM_PRECODING1mj=6, + PUSCH_PRECODING0=7, + PUSCH_PRECODING1=8, + /// the next 3 entries are for TM4 + DUALSTREAM_UNIFORM_PRECODING1=9, + DUALSTREAM_UNIFORM_PRECODINGj=10, + DUALSTREAM_PUSCH_PRECODING=11, + TM7=12, + TM8=13, + TM9_10=14 +} MIMO_mode_t; + + +typedef enum { + /// MRT + MRT=0, + /// ZF + ZF=1, + /// MMSE + MMSE=2 +} PRECODE_TYPE_t; + +typedef enum {format0, + format1, + format1A, + format1B, + format1C, + format1D, + format1E_2A_M10PRB, + format2, + format2A, + format2B, + format2C, + format2D, + format3, + format3A, + format4, + format5, + format6_0A, + format6_0B, + format6_1A, + format6_1B, + format6_2 + } DCI_format_t; + +typedef struct { + /// Length of DCI in bits + uint8_t dci_length; + /// Aggregation level + uint8_t L; + /// Position of first CCE of the dci + int firstCCE; + /// flag to indicate that this is a RA response + boolean_t ra_flag; + /// rnti + rnti_t rnti; + /// harq_pid + rnti_t harq_pid; + /// Format + DCI_format_t format; + /// DCI pdu + uint8_t dci_pdu[8]; +} DCI_ALLOC_t; + +#define MAX_EPDCCH_PRB 8 + +typedef struct { + /// Length of DCI in bits + uint8_t dci_length; + /// Aggregation level + uint8_t L; + /// Position of first CCE of the dci + int firstCCE; + /// flag to indicate that this is a RA response + boolean_t ra_flag; + /// rnti + rnti_t rnti; + /// Format + DCI_format_t format; + /// epdcch resource assignment (0=localized,1=distributed) + uint8_t epdcch_resource_assignment_flag; + /// epdcch index + uint16_t epdcch_id; + /// epdcch start symbol + uint8_t epdcch_start_symbol; + /// epdcch number of PRBs in set + uint8_t epdcch_num_prb; + /// vector of prb ids for set + uint8_t epdcch_prb_index[MAX_EPDCCH_PRB]; + /// LBT parameter for frame configuration + uint8_t dwpts_symbols; + /// LBT parameter for frame configuration + uint8_t initial_lbt_sf; + /// DCI pdu + uint8_t dci_pdu[8]; +} eDCI_ALLOC_t; + +typedef struct { + /// Length of DCI in bits + uint8_t dci_length; + /// Aggregation level + uint8_t L; + /// Position of first CCE of the dci + int firstCCE; + /// flag to indicate that this is a RA response + boolean_t ra_flag; + /// rnti + rnti_t rnti; + /// Format + DCI_format_t format; + /// harq process index + uint8_t harq_pid; + /// Narrowband index + uint8_t narrowband; + /// number of PRB pairs for MPDCCH + uint8_t number_of_prb_pairs; + /// mpdcch resource assignment (combinatorial index r) + uint8_t resource_block_assignment; + /// transmission type (0=localized,1=distributed) + uint8_t transmission_type; + /// mpdcch start symbol + uint8_t start_symbol; + /// CE mode (1=ModeA,2=ModeB) + uint8_t ce_mode; + /// 0-503 n_EPDCCHid_i + uint16_t dmrs_scrambling_init; + /// Absolute subframe of the initial transmission (0-10239) + uint16_t i0; + /// number of mdpcch repetitions + uint16_t reps; + /// current absolute subframe number + uint16_t absSF; + /// DCI pdu + uint8_t dci_pdu[8]; +} mDCI_ALLOC_t; + +typedef struct { + /// Preamble index for PRACH (0-63) + uint8_t ra_PreambleIndex; + /// RACH MaskIndex + uint8_t ra_RACH_MaskIndex; + /// Target received power at eNB (-120 ... -82 dBm) + int8_t ra_PREAMBLE_RECEIVED_TARGET_POWER; + /// PRACH index for TDD (0 ... 6) depending on TDD configuration and prachConfigIndex + uint8_t ra_TDD_map_index; + /// Corresponding RA-RNTI for UL-grant + uint16_t ra_RNTI; + /// Pointer to Msg3 payload for UL-grant + uint8_t *Msg3; +} PRACH_RESOURCES_t; + + +typedef struct { + /// Downlink Power offset field + uint8_t dl_pow_off; + ///Subband resource allocation field + uint8_t rballoc_sub[50]; + ///Total number of PRBs indicator + uint8_t pre_nb_available_rbs; +} MU_MIMO_mode; + +typedef enum { + NOT_SYNCHED=0, + PRACH=1, + RA_RESPONSE=2, + PUSCH=3, + RESYNCH=4 +} UE_MODE_t; + + + +typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; + +#define NUMBER_OF_SUBBANDS_MAX 13 +#define NUMBER_OF_HARQ_PID_MAX 8 + +#define MAX_FRAME_NUMBER 0x400 + + + +#define NUMBER_OF_RN_MAX 3 +typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_relay} relaying_type_t; + + + +#define MCS_COUNT 28 +#define MCS_TABLE_LENGTH_MAX 64 + + +#define NUM_DCI_MAX 32 + +#define NUMBER_OF_eNB_SECTORS_MAX 3 + +#define NB_BANDS_MAX 8 + +#define MAX_BANDS_PER_RRU 4 + + +#ifdef OCP_FRAMEWORK +#include <enums.h> +#else +typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t; + +/*! \brief Extension Type */ +typedef enum { + CYCLIC_PREFIX, + CYCLIC_SUFFIX, + ZEROS, + NONE +} Extension_t; + +enum transmission_access_mode { + NO_ACCESS=0, + POSTPONED_ACCESS, + CANCELED_ACCESS, + UNKNOWN_ACCESS, + SCHEDULED_ACCESS, + CBA_ACCESS}; + +typedef enum { + eNodeB_3GPP=0, // classical eNodeB function + NGFI_RAU_IF5, // RAU with NGFI IF5 + NGFI_RAU_IF4p5, // RAU with NFGI IF4p5 + NGFI_RRU_IF5, // NGFI_RRU (NGFI remote radio-unit,IF5) + NGFI_RRU_IF4p5, // NGFI_RRU (NGFI remote radio-unit,IF4p5) + MBP_RRU_IF5 // Mobipass RRU +} node_function_t; + +typedef enum { + + synch_to_ext_device=0, // synch to RF or Ethernet device + synch_to_other, // synch to another source_(timer, other RU) + synch_to_mobipass_standalone // special case for mobipass in standalone mode +} node_timing_t; +#endif + + +void exit_fun(const char* s); + +#include "UTIL/LOG/log_extern.h" +extern pthread_cond_t sync_cond; +extern pthread_mutex_t sync_mutex; +extern int sync_var; + + +#define MODE_DECODE_NONE 0 +#define MODE_DECODE_SSE 1 +#define MODE_DECODE_C 2 +#define MODE_DECODE_AVX2 3 + +#define DECODE_INITTD8_SSE_FPTRIDX 0 +#define DECODE_INITTD16_SSE_FPTRIDX 1 +#define DECODE_INITTD_AVX2_FPTRIDX 2 +#define DECODE_TD8_SSE_FPTRIDX 3 +#define DECODE_TD16_SSE_FPTRIDX 4 +#define DECODE_TD_C_FPTRIDX 5 +#define DECODE_TD16_AVX2_FPTRIDX 6 +#define DECODE_FREETD8_FPTRIDX 7 +#define DECODE_FREETD16_FPTRIDX 8 +#define DECODE_FREETD_AVX2_FPTRIDX 9 +#define ENCODE_SSE_FPTRIDX 10 +#define ENCODE_C_FPTRIDX 11 +#define ENCODE_INIT_SSE_FPTRIDX 12 +#define DECODE_NUM_FPTR 13 + + +typedef uint8_t(*decoder_if_t)(int16_t *y, + int16_t *y2, + uint8_t *decoded_bytes, + uint8_t *decoded_bytes2, + uint16_t n, + uint16_t f1, + uint16_t f2, + uint8_t max_iterations, + uint8_t crc_type, + uint8_t F, + time_stats_t *init_stats, + time_stats_t *alpha_stats, + time_stats_t *beta_stats, + time_stats_t *gamma_stats, + time_stats_t *ext_stats, + time_stats_t *intl1_stats, + time_stats_t *intl2_stats); + +typedef uint8_t(*encoder_if_t)(uint8_t *input, + uint16_t input_length_bytes, + uint8_t *output, + uint8_t F, + uint16_t interleaver_f1, + uint16_t interleaver_f2); + + +static inline void wait_sync(char *thread_name) { + + printf( "waiting for sync (%s)\n",thread_name); + pthread_mutex_lock( &sync_mutex ); + + while (sync_var<0) + pthread_cond_wait( &sync_cond, &sync_mutex ); + + pthread_mutex_unlock(&sync_mutex); + + printf( "got sync (%s)\n", thread_name); + +} + +static inline int wakeup_thread(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { + + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + *instance_cnt = *instance_cnt + 1; + // the thread can now be woken up + if (pthread_cond_signal(cond) != 0) { + LOG_E( PHY, "ERROR pthread_cond_signal\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock(mutex); + return(0); +} + +static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + + while (*instance_cnt < 0) { + // most of the time the thread is waiting here + // proc->instance_cnt_rxtx is -1 + pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again + } + + if (pthread_mutex_unlock(mutex) != 0) { + LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + return(0); +} + +static inline int wait_on_busy_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { + + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + + while (*instance_cnt == 0) { + // most of the time the thread will skip this + // waits only if proc->instance_cnt_rxtx is 0 + pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again + } + + if (pthread_mutex_unlock(mutex) != 0) { + LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + return(0); +} + +static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *name) { + + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + + *instance_cnt=*instance_cnt-1; + + if (pthread_mutex_unlock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + return(0); +} + + +#endif // __PHY_DEFS__H__ diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs_eNB.h similarity index 53% rename from openair1/PHY/defs.h rename to openair1/PHY/defs_eNB.h index 55425596d748ba1e0643e65a7c138f1c0ae5500e..b8271ab3ad157150fd56a7023e3a8b66c8bd6e10 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs_eNB.h @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -/*! \file PHY/defs.h - \brief Top-level defines and structure definitions +/*! \file PHY/defs_eNB.h + \brief Top-level defines and structure definitions for eNB \author R. Knopp, F. Kaltenberger \date 2011 \version 0.1 @@ -29,8 +29,8 @@ \note \warning */ -#ifndef __PHY_DEFS__H__ -#define __PHY_DEFS__H__ +#ifndef __PHY_DEFS_ENB__H__ +#define __PHY_DEFS_ENB__H__ #define _GNU_SOURCE @@ -57,254 +57,20 @@ #include "common_lib.h" #include "msc.h" -#include "openair2/PHY_INTERFACE/IF_Module.h" -//#include "openair2/PHY_INTERFACE/IF_Module_UE.h" - -//#include <complex.h> -#include "assertions.h" -#ifdef MEX -# define msg mexPrintf -#endif -//use msg in the real-time thread context -#define msg_nrt printf -//use msg_nrt in the non real-time context (for initialization, ...) -#ifndef malloc16 -# ifdef __AVX2__ -# define malloc16(x) memalign(32,x) -# else -# define malloc16(x) memalign(16,x) -# endif -#endif -#define free16(y,x) free(y) -#define bigmalloc malloc -#define bigmalloc16 malloc16 -#define openair_free(y,x) free((y)) -#define PAGE_SIZE 4096 -#define free_and_zero(PtR) do { \ - if (PtR) { \ - free(PtR); \ - PtR = NULL; \ - } \ - } while (0) - -#define RX_NB_TH_MAX 2 -#define RX_NB_TH 2 - - -//! \brief Allocate \c size bytes of memory on the heap with alignment 16 and zero it afterwards. -//! If no more memory is available, this function will terminate the program with an assertion error. -static inline void* malloc16_clear( size_t size ) -{ -#ifdef __AVX2__ - void* ptr = memalign(32, size); -#else - void* ptr = memalign(16, size); -#endif - DevAssert(ptr); - memset( ptr, 0, size ); - return ptr; -} - - - -#define PAGE_MASK 0xfffff000 -#define virt_to_phys(x) (x) - -#define openair_sched_exit() exit(-1) - - -#define max(a,b) ((a)>(b) ? (a) : (b)) -#define min(a,b) ((a)<(b) ? (a) : (b)) - - -#define bzero(s,n) (memset((s),0,(n))) - -#define cmax(a,b) ((a>b) ? (a) : (b)) -#define cmin(a,b) ((a<b) ? (a) : (b)) - -#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) - -/// suppress compiler warning for unused arguments -#define UNUSED(x) (void)x; - +#include "defs_common.h" #include "impl_defs_top.h" -#include "impl_defs_lte.h" - #include "PHY/TOOLS/time_meas.h" -#include "PHY/CODING/defs.h" -#include "PHY/TOOLS/defs.h" +//#include "PHY/CODING/coding_defs.h" +#include "PHY/TOOLS/tools_defs.h" #include "platform_types.h" -#define MAX_NUM_RU_PER_eNB 64 - -#include "PHY/LTE_TRANSPORT/defs.h" +#include "PHY/LTE_TRANSPORT/transport_common.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" #include <pthread.h> -#include "targets/ARCH/COMMON/common_lib.h" -#include "targets/COMMON/openairinterface5g_limits.h" - -#include "openair2/LAYER2/MAC/defs.h" - -#if defined(EXMIMO) || defined(OAI_USRP) -//#define NUMBER_OF_eNB_MAX 1 -//#define NUMBER_OF_UE_MAX 16 - -//#define NUMBER_OF_CONNECTED_eNB_MAX 3 -#else -#ifdef LARGE_SCALE -//#define NUMBER_OF_eNB_MAX 2 -//#define NUMBER_OF_UE_MAX 120 -//#define NUMBER_OF_CONNECTED_eNB_MAX 1 // to save some memory -#else -//#define NUMBER_OF_eNB_MAX 3 -//#define NUMBER_OF_UE_MAX 16 -//#define NUMBER_OF_RU_MAX 64 -//#define NUMBER_OF_CONNECTED_eNB_MAX 1 -#endif -#endif -#define NUMBER_OF_SUBBANDS_MAX 13 -#define NUMBER_OF_HARQ_PID_MAX 8 - -#define MAX_FRAME_NUMBER 0x400 - - - -#define NUMBER_OF_RN_MAX 3 -typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_relay} relaying_type_t; - - - -#define MCS_COUNT 28 -#define MCS_TABLE_LENGTH_MAX 64 - - -#define NUM_DCI_MAX 32 - -#define NUMBER_OF_eNB_SECTORS_MAX 3 - -#define NB_BANDS_MAX 8 - -#define MAX_BANDS_PER_RRU 4 - - -#ifdef OCP_FRAMEWORK -#include <enums.h> -#else -typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t; - -/*! \brief Extension Type */ -typedef enum { - CYCLIC_PREFIX, - CYCLIC_SUFFIX, - ZEROS, - NONE -} Extension_t; - -enum transmission_access_mode { - NO_ACCESS=0, - POSTPONED_ACCESS, - CANCELED_ACCESS, - UNKNOWN_ACCESS, - SCHEDULED_ACCESS, - CBA_ACCESS}; - -typedef enum { - eNodeB_3GPP=0, // classical eNodeB function - NGFI_RAU_IF5, // RAU with NGFI IF5 - NGFI_RAU_IF4p5, // RAU with NFGI IF4p5 - NGFI_RRU_IF5, // NGFI_RRU (NGFI remote radio-unit,IF5) - NGFI_RRU_IF4p5, // NGFI_RRU (NGFI remote radio-unit,IF4p5) - MBP_RRU_IF5 // Mobipass RRU -} node_function_t; - -typedef enum { - - synch_to_ext_device=0, // synch to RF or Ethernet device - synch_to_other, // synch to another source_(timer, other RU) - synch_to_mobipass_standalone // special case for mobipass in standalone mode -} node_timing_t; -#endif - -typedef struct UE_SCAN_INFO_s { - /// 10 best amplitudes (linear) for each pss signals - int32_t amp[3][10]; - /// 10 frequency offsets (kHz) corresponding to best amplitudes, with respect do minimum DL frequency in the band - int32_t freq_offset_Hz[3][10]; -} UE_SCAN_INFO_t; - -/// Top-level PHY Data Structure for RN -typedef struct { - /// Module ID indicator for this instance - uint8_t Mod_id; - uint32_t frame; - // phy_vars_eNB - // phy_vars ue - // cuurently only used to store and forward the PMCH - uint8_t mch_avtive[10]; - uint8_t sync_area[10]; // num SF - LTE_UE_DLSCH_t *dlsch_rn_MCH[10]; - -} PHY_VARS_RN; - -/// Context data structure for RX/TX portion of subframe processing -typedef struct { - /// Component Carrier index - uint8_t CC_id; - /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; - /// subframe to act upon for transmission - int subframe_tx; - /// subframe to act upon for reception - int subframe_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for reception - int frame_rx; - /// \brief Instance count for RXn-TXnp4 processing thread. - /// \internal This variable is protected by \ref mutex_rxtx. - int instance_cnt_rxtx; - /// pthread structure for RXn-TXnp4 processing thread - pthread_t pthread_rxtx; - /// pthread attributes for RXn-TXnp4 processing thread - pthread_attr_t attr_rxtx; - /// condition variable for tx processing thread - pthread_cond_t cond_rxtx; - /// mutex for RXn-TXnp4 processing thread - pthread_mutex_t mutex_rxtx; - /// scheduling parameters for RXn-TXnp4 thread - struct sched_param sched_param_rxtx; - /// pipeline ready state - int pipe_ready; -} eNB_rxtx_proc_t; -typedef struct { - struct PHY_VARS_eNB_s *eNB; - int UE_id; - int harq_pid; - int llr8_flag; - int ret; -} td_params; +#include "openair2/PHY_INTERFACE/IF_Module.h" -typedef struct { - struct PHY_VARS_eNB_s *eNB; - LTE_eNB_DLSCH_t *dlsch; - int G; - int harq_pid; - int total_worker; - int current_worker; - /// \internal This variable is protected by \ref mutex_te. - int instance_cnt_te; - /// pthread attributes for parallel turbo-encoder thread - pthread_attr_t attr_te; - /// scheduling parameters for parallel turbo-encoder thread - struct sched_param sched_param_te; - /// pthread structure for parallel turbo-encoder thread - pthread_t pthread_te; - /// condition variable for parallel turbo-encoder thread - pthread_cond_t cond_te; - /// mutex for parallel turbo-encoder thread - pthread_mutex_t mutex_te; -} te_params; typedef struct RU_proc_t_s { /// Pointer to associated RU descriptor @@ -468,149 +234,378 @@ typedef struct RU_proc_t_s { int ru_tx_ready; } RU_proc_t; -/// Context data structure for eNB subframe processing -typedef struct eNB_proc_t_s { - /// Component Carrier index - uint8_t CC_id; - /// thread index - int thread_index; - /// timestamp received from HW - openair0_timestamp timestamp_rx; - /// timestamp to send to "slave rru" - openair0_timestamp timestamp_tx; - /// subframe to act upon for reception - int subframe_rx; - /// subframe to act upon for PRACH - int subframe_prach; -#ifdef Rel14 - /// subframe to act upon for reception of prach BL/CE UEs - int subframe_prach_br; -#endif - /// frame to act upon for reception - int frame_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for PRACH - int frame_prach; -#ifdef Rel14 - /// frame to act upon for PRACH BL/CE UEs - int frame_prach_br; -#endif - /// \internal This variable is protected by \ref mutex_td. - int instance_cnt_td; - /// \internal This variable is protected by \ref mutex_te. - //int instance_cnt_te[3]; - /// \internal This variable is protected by \ref mutex_prach. - int instance_cnt_prach; +typedef enum { + LOCAL_RF =0, + REMOTE_IF5 =1, + REMOTE_MBP_IF5 =2, + REMOTE_IF4p5 =3, + REMOTE_IF1pp =4, + MAX_RU_IF_TYPES =5 + //EMULATE_RF =6 +} RU_if_south_t; + +typedef struct RU_t_s{ + /// index of this ru + uint32_t idx; + /// Pointer to configuration file + char *rf_config_file; + /// southbound interface + RU_if_south_t if_south; + /// timing + node_timing_t if_timing; + /// function + node_function_t function; + /// Ethernet parameters for fronthaul interface + eth_params_t eth_params; + /// flag to indicate the RU is in synch with a master reference + int in_synch; + /// timing offset + int rx_offset; + /// flag to indicate the RU is a slave to another source + int is_slave; + /// Total gain of receive chain + uint32_t rx_total_gain_dB; + /// number of bands that this device can support + int num_bands; + /// band list + int band[MAX_BANDS_PER_RRU]; + /// number of RX paths on device + int nb_rx; + /// number of TX paths on device + int nb_tx; + /// maximum PDSCH RS EPRE + int max_pdschReferenceSignalPower; + /// maximum RX gain + int max_rxgain; + /// Attenuation of RX paths on device + int att_rx; + /// Attenuation of TX paths on device + int att_tx; + /// flag to indicate precoding operation in RU + int do_precoding; + /// Frame parameters + LTE_DL_FRAME_PARMS frame_parms; + ///timing offset used in TDD + int N_TA_offset; + /// RF device descriptor + openair0_device rfdevice; + /// HW configuration + openair0_config_t openair0_cfg; + /// Number of eNBs using this RU + int num_eNB; + /// list of eNBs using this RU + struct PHY_VARS_eNB_s *eNB_list[NUMBER_OF_eNB_MAX]; + /// Mapping of antenna ports to RF chain index + openair0_rf_map rf_map; + /// IF device descriptor + openair0_device ifdevice; + /// Pointer for ifdevice buffer struct + if_buffer_t ifbuffer; + /// if prach processing is to be performed in RU + int do_prach; + /// function pointer to synchronous RX fronthaul function (RRU,3GPP_eNB) + void (*fh_south_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to synchronous TX fronthaul function + void (*fh_south_out)(struct RU_t_s *ru); + /// function pointer to synchronous RX fronthaul function (RRU) + void (*fh_north_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to synchronous RX fronthaul function (RRU) + void (*fh_north_out)(struct RU_t_s *ru); + /// function pointer to asynchronous fronthaul interface + void (*fh_north_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to asynchronous fronthaul interface + void (*fh_south_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to initialization function for radio interface + int (*start_rf)(struct RU_t_s *ru); + /// function pointer to release function for radio interface + int (*stop_rf)(struct RU_t_s *ru); + /// function pointer to initialization function for radio interface + int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); + /// function pointer to RX front-end processing routine (DFTs/prefix removal or NULL) + void (*feprx)(struct RU_t_s *ru); + /// function pointer to TX front-end processing routine (IDFTs and prefix removal or NULL) + void (*feptx_ofdm)(struct RU_t_s *ru); + /// function pointer to TX front-end processing routine (PRECODING) + void (*feptx_prec)(struct RU_t_s *ru); + /// function pointer to wakeup routine in lte-enb. + int (*wakeup_rxtx)(struct PHY_VARS_eNB_s *eNB, struct RU_t_s *ru); + /// function pointer to wakeup routine in lte-enb. + void (*wakeup_prach_eNB)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); #ifdef Rel14 - /// \internal This variable is protected by \ref mutex_prach for BL/CE UEs. - int instance_cnt_prach_br; + /// function pointer to wakeup routine in lte-enb. + void (*wakeup_prach_eNB_br)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); #endif - // instance count for over-the-air eNB synchronization - int instance_cnt_synch; - /// \internal This variable is protected by \ref mutex_asynch_rxtx. - int instance_cnt_asynch_rxtx; - /// pthread structure for eNB single processing thread - pthread_t pthread_single; - /// pthread structure for asychronous RX/TX processing thread - pthread_t pthread_asynch_rxtx; - /// flag to indicate first RX acquisition - int first_rx; - /// flag to indicate first TX transmission - int first_tx; - /// pthread attributes for parallel turbo-decoder thread - pthread_attr_t attr_td; - /// pthread attributes for parallel turbo-encoder thread - //pthread_attr_t attr_te[3]; - /// pthread attributes for single eNB processing thread - pthread_attr_t attr_single; - /// pthread attributes for prach processing thread - pthread_attr_t attr_prach; -#ifdef Rel14 - /// pthread attributes for prach processing thread BL/CE UEs - pthread_attr_t attr_prach_br; -#endif - /// pthread attributes for asynchronous RX thread - pthread_attr_t attr_asynch_rxtx; - /// scheduling parameters for parallel turbo-decoder thread - struct sched_param sched_param_td; - /// scheduling parameters for parallel turbo-encoder thread - //struct sched_param sched_param_te[3]; - /// scheduling parameters for single eNB thread - struct sched_param sched_param_single; - /// scheduling parameters for prach thread - struct sched_param sched_param_prach; -#ifdef Rel14 - /// scheduling parameters for prach thread - struct sched_param sched_param_prach_br; -#endif - /// scheduling parameters for asynch_rxtx thread - struct sched_param sched_param_asynch_rxtx; - /// pthread structure for parallel turbo-decoder thread - pthread_t pthread_td; - /// pthread structure for parallel turbo-encoder thread - //pthread_t pthread_te[3]; - /// pthread structure for PRACH thread - pthread_t pthread_prach; -#ifdef Rel14 - /// pthread structure for PRACH thread BL/CE UEs - pthread_t pthread_prach_br; -#endif - /// condition variable for parallel turbo-decoder thread - pthread_cond_t cond_td; - /// condition variable for parallel turbo-encoder thread - //pthread_cond_t cond_te[3]; - /// condition variable for PRACH processing thread; - pthread_cond_t cond_prach; -#ifdef Rel14 - /// condition variable for PRACH processing thread BL/CE UEs; - pthread_cond_t cond_prach_br; -#endif - /// condition variable for asynch RX/TX thread - pthread_cond_t cond_asynch_rxtx; - /// mutex for parallel turbo-decoder thread - pthread_mutex_t mutex_td; - /// mutex for parallel turbo-encoder thread - //pthread_mutex_t mutex_te[3]; - /// mutex for PRACH thread - pthread_mutex_t mutex_prach; + /// function pointer to eNB entry routine + void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string, struct RU_t_s *ru); + /// Timing statistics + time_stats_t ofdm_demod_stats; + /// Timing statistics (TX) + time_stats_t ofdm_mod_stats; + /// Timing wait statistics + time_stats_t ofdm_demod_wait_stats; + /// Timing wakeup statistics + time_stats_t ofdm_demod_wakeup_stats; + /// Timing wait statistics (TX) + time_stats_t ofdm_mod_wait_stats; + /// Timing wakeup statistics (TX) + time_stats_t ofdm_mod_wakeup_stats; + /// Timing statistics (RX Fronthaul + Compression) + 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 + int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15]; + + /// received frequency-domain signal for PRACH (IF4p5 RRU) + int16_t **prach_rxsigF; + /// received frequency-domain signal for PRACH BR (IF4p5 RRU) + int16_t **prach_rxsigF_br[4]; + /// sequence number for IF5 + uint8_t seqno; + /// initial timestamp used as an offset make first real timestamp 0 + openair0_timestamp ts_offset; + /// process scheduling variables + RU_proc_t proc; + /// stats thread pthread descriptor + pthread_t ru_stats_thread; + +} RU_t; + + + +#define MAX_RRU_CONFIG_SIZE 1024 +typedef enum { + RAU_tick=0, + RRU_capabilities=1, + RRU_config=2, + RRU_MSG_max_num=3 +} rru_config_msg_type_t; + +typedef struct RRU_CONFIG_msg_s { + rru_config_msg_type_t type; + ssize_t len; + uint8_t msg[MAX_RRU_CONFIG_SIZE]; +} RRU_CONFIG_msg_t; + +typedef enum { + OAI_IF5_only =0, + OAI_IF4p5_only =1, + OAI_IF5_and_IF4p5 =2, + MBP_IF5 =3, + MAX_FH_FMTs =4 +} FH_fmt_options_t; + +#define MAX_BANDS_PER_RRU 4 + +typedef struct RRU_capabilities_s { + /// Fronthaul format + FH_fmt_options_t FH_fmt; + /// number of EUTRA bands (<=4) supported by RRU + uint8_t num_bands; + /// EUTRA band list supported by RRU + uint8_t band_list[MAX_BANDS_PER_RRU]; + /// Number of concurrent bands (component carriers) + uint8_t num_concurrent_bands; + /// Maximum TX EPRE of each band + int8_t max_pdschReferenceSignalPower[MAX_BANDS_PER_RRU]; + /// Maximum RX gain of each band + uint8_t max_rxgain[MAX_BANDS_PER_RRU]; + /// Number of RX ports of each band + uint8_t nb_rx[MAX_BANDS_PER_RRU]; + /// Number of TX ports of each band + uint8_t nb_tx[MAX_BANDS_PER_RRU]; + /// max DL bandwidth (1,6,15,25,50,75,100) + uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; + /// max UL bandwidth (1,6,15,25,50,75,100) + uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; +} RRU_capabilities_t; + +typedef struct RRU_config_s { + + /// Fronthaul format + RU_if_south_t FH_fmt; + /// number of EUTRA bands (<=4) configured in RRU + uint8_t num_bands; + /// EUTRA band list configured in RRU + uint8_t band_list[MAX_BANDS_PER_RRU]; + /// TDD configuration (0-6) + uint8_t tdd_config[MAX_BANDS_PER_RRU]; + /// TDD special subframe configuration (0-10) + uint8_t tdd_config_S[MAX_BANDS_PER_RRU]; + /// TX frequency + uint32_t tx_freq[MAX_BANDS_PER_RRU]; + /// RX frequency + uint32_t rx_freq[MAX_BANDS_PER_RRU]; + /// TX attenation w.r.t. max + uint8_t att_tx[MAX_BANDS_PER_RRU]; + /// RX attenuation w.r.t. max + uint8_t att_rx[MAX_BANDS_PER_RRU]; + /// DL bandwidth + uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; + /// UL bandwidth + uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; + /// 3/4 sampling rate + uint8_t threequarter_fs[MAX_BANDS_PER_RRU]; + /// prach_FreqOffset for IF4p5 + int prach_FreqOffset[MAX_BANDS_PER_RRU]; + /// prach_ConfigIndex for IF4p5 + int prach_ConfigIndex[MAX_BANDS_PER_RRU]; #ifdef Rel14 - /// mutex for PRACH thread for BL/CE UEs - pthread_mutex_t mutex_prach_br; + int emtc_prach_CElevel_enable[MAX_BANDS_PER_RRU][4]; + /// emtc_prach_FreqOffset for IF4p5 per CE Level + int emtc_prach_FreqOffset[MAX_BANDS_PER_RRU][4]; + /// emtc_prach_ConfigIndex for IF4p5 per CE Level + int emtc_prach_ConfigIndex[MAX_BANDS_PER_RRU][4]; #endif - /// mutex for asynch RX/TX thread - pthread_mutex_t mutex_asynch_rxtx; - /// mutex for RU access to eNB processing (PDSCH/PUSCH) - pthread_mutex_t mutex_RU; - /// mutex for RU access to eNB processing (PRACH) - pthread_mutex_t mutex_RU_PRACH; - /// mutex for RU access to eNB processing (PRACH BR) - pthread_mutex_t mutex_RU_PRACH_br; - /// mask for RUs serving eNB (PDSCH/PUSCH) - int RU_mask; - /// mask for RUs serving eNB (PRACH) - int RU_mask_prach; +} RRU_config_t; + + +typedef struct { + /// \brief Pointers (dynamic) to the received data in the time domain. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ + int32_t **rxdata; + /// \brief Pointers (dynamic) to the received data in the frequency domain. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ + int32_t **rxdataF; + /// \brief holds the transmit data in the frequency domain. + /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //? + /// - first index: eNB id [0..2] (hard coded) + /// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports. + /// - third index: sample [0..] + int32_t **txdataF; +} LTE_eNB_COMMON; + +typedef struct { + uint8_t num_dci; + uint8_t num_pdcch_symbols; + DCI_ALLOC_t dci_alloc[32]; +} LTE_eNB_PDCCH; + +typedef struct { + uint8_t hi; + uint8_t first_rb; + uint8_t n_DMRS; +} phich_config_t; + +typedef struct { + uint8_t num_hi; + phich_config_t config[32]; +} LTE_eNB_PHICH; + +typedef struct { + uint8_t num_dci; + eDCI_ALLOC_t edci_alloc[32]; +} LTE_eNB_EPDCCH; + +typedef struct { + /// number of active MPDCCH allocations + uint8_t num_dci; + /// MPDCCH DCI allocations from MAC + mDCI_ALLOC_t mdci_alloc[32]; + // MAX SIZE of an EPDCCH set is 16EREGs * 9REs/EREG * 8 PRB pairs = 2304 bits + uint8_t e[2304]; +} LTE_eNB_MPDCCH; + + +typedef struct { + /// \brief Hold the channel estimates in frequency domain based on SRS. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..ofdm_symbol_size[ + int32_t **srs_ch_estimates; + /// \brief Hold the channel estimates in time domain based on SRS. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..2*ofdm_symbol_size[ + int32_t **srs_ch_estimates_time; + /// \brief Holds the SRS for channel estimation at the RX. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..ofdm_symbol_size[ + int32_t *srs; +} LTE_eNB_SRS; + +typedef struct { + /// \brief Holds the received data in the frequency domain for the allocated RBs in repeated format. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..2*ofdm_symbol_size[ + int32_t **rxdataF_ext; + /// \brief Holds the received data in the frequency domain for the allocated RBs in normal format. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index (definition from phy_init_lte_eNB()): ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **rxdataF_ext2; + /// \brief Hold the channel estimates in time domain based on DRS. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..4*ofdm_symbol_size[ + int32_t **drs_ch_estimates_time; + /// \brief Hold the channel estimates in frequency domain based on DRS. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **drs_ch_estimates; + /// \brief Holds the compensated signal. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **rxdataF_comp; + /// \brief Magnitude of the UL channel estimates. Used for 2nd-bit level thresholds in LLR computation + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **ul_ch_mag; + /// \brief Magnitude of the UL channel estimates scaled for 3rd bit level thresholds in LLR computation + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **ul_ch_magb; + /// measured RX power based on DRS + int ulsch_power[2]; + /// \brief llr values. + /// - first index: ? [0..1179743] (hard coded) + int16_t *llr; +} LTE_eNB_PUSCH; + +#define PBCH_A 24 +typedef struct { + uint8_t pbch_d[96+(3*(16+PBCH_A))]; + uint8_t pbch_w[3*3*(16+PBCH_A)]; + uint8_t pbch_e[1920]; +} LTE_eNB_PBCH; + +#define MAX_NUM_RX_PRACH_PREAMBLES 4 + +typedef struct { + /// \brief ?. + /// first index: ? [0..1023] (hard coded) + int16_t *prachF; + /// \brief ?. + /// first index: ce_level [0..3] + /// second index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. + /// third index: frequency-domain sample [0..ofdm_symbol_size*12[ + int16_t **rxsigF[4]; + /// \brief local buffer to compute prach_ifft (necessary in case of multiple CCs) + /// first index: ce_level [0..3] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. + /// second index: ? [0..63] (hard coded) + /// third index: ? [0..63] (hard coded) + int32_t **prach_ifft[4]; + + /// repetition number #ifdef Rel14 - /// mask for RUs serving eNB (PRACH) - int RU_mask_prach_br; + /// indicator of first frame in a group of PRACH repetitions + int first_frame[4]; + /// current repetition for each CE level + int repetition_number[4]; #endif - /// parameters for turbo-decoding worker thread - td_params tdp; - /// parameters for turbo-encoding worker thread - te_params tep[3]; - /// set of scheduling variables RXn-TXnp4 threads - eNB_rxtx_proc_t proc_rxtx[2]; - /// stats thread pthread descriptor - pthread_t process_stats_thread; - /// for waking up tx procedure - RU_proc_t *ru_proc; -} eNB_proc_t; +} LTE_eNB_PRACH; +#include "PHY/TOOLS/time_meas.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" /// Context data structure for RX/TX portion of subframe processing typedef struct { - /// index of the current UE RX/TX proc - int proc_id; /// Component Carrier index uint8_t CC_id; /// timestamp transmitted to HW @@ -636,319 +631,181 @@ typedef struct { pthread_mutex_t mutex_rxtx; /// scheduling parameters for RXn-TXnp4 thread struct sched_param sched_param_rxtx; + /// pipeline ready state + int pipe_ready; +} eNB_rxtx_proc_t; - /// internal This variable is protected by ref mutex_fep_slot1. - //int instance_cnt_slot0_dl_processing; - int instance_cnt_slot1_dl_processing; - /// pthread descriptor fep_slot1 thread - //pthread_t pthread_slot0_dl_processing; - pthread_t pthread_slot1_dl_processing; - /// pthread attributes for fep_slot1 processing thread - // pthread_attr_t attr_slot0_dl_processing; - pthread_attr_t attr_slot1_dl_processing; - /// condition variable for UE fep_slot1 thread; - //pthread_cond_t cond_slot0_dl_processing; - pthread_cond_t cond_slot1_dl_processing; - /// mutex for UE synch thread - //pthread_mutex_t mutex_slot0_dl_processing; - pthread_mutex_t mutex_slot1_dl_processing; - // - uint8_t chan_est_pilot0_slot1_available; - uint8_t chan_est_slot1_available; - uint8_t llr_slot1_available; - uint8_t dci_slot0_available; - uint8_t first_symbol_available; - //uint8_t channel_level; - /// scheduling parameters for fep_slot1 thread - struct sched_param sched_param_fep_slot1; - - int sub_frame_start; - int sub_frame_step; - unsigned long long gotIQs; -} UE_rxtx_proc_t; +typedef struct { + struct PHY_VARS_eNB_s *eNB; + int UE_id; + int harq_pid; + int llr8_flag; + int ret; +} td_params; -/// Context data structure for eNB subframe processing typedef struct { + struct PHY_VARS_eNB_s *eNB; + LTE_eNB_DLSCH_t *dlsch; + int G; + int harq_pid; + int total_worker; + int current_worker; + /// \internal This variable is protected by \ref mutex_te. + int instance_cnt_te; + /// pthread attributes for parallel turbo-encoder thread + pthread_attr_t attr_te; + /// scheduling parameters for parallel turbo-encoder thread + struct sched_param sched_param_te; + /// pthread structure for parallel turbo-encoder thread + pthread_t pthread_te; + /// condition variable for parallel turbo-encoder thread + pthread_cond_t cond_te; + /// mutex for parallel turbo-encoder thread + pthread_mutex_t mutex_te; +} te_params; + +/// Context data structure for eNB subframe processing +typedef struct eNB_proc_t_s { /// Component Carrier index uint8_t CC_id; - /// Last RX timestamp + /// thread index + int thread_index; + /// timestamp received from HW openair0_timestamp timestamp_rx; - /// pthread attributes for main UE thread - pthread_attr_t attr_ue; - /// scheduling parameters for main UE thread - struct sched_param sched_param_ue; - /// pthread descriptor main UE thread - pthread_t pthread_ue; - /// \brief Instance count for synch thread. - /// \internal This variable is protected by \ref mutex_synch. + /// timestamp to send to "slave rru" + openair0_timestamp timestamp_tx; + /// subframe to act upon for reception + int subframe_rx; + /// subframe to act upon for PRACH + int subframe_prach; +#ifdef Rel14 + /// subframe to act upon for reception of prach BL/CE UEs + int subframe_prach_br; +#endif + /// frame to act upon for reception + int frame_rx; + /// frame to act upon for transmission + int frame_tx; + /// frame to act upon for PRACH + int frame_prach; +#ifdef Rel14 + /// frame to act upon for PRACH BL/CE UEs + int frame_prach_br; +#endif + /// \internal This variable is protected by \ref mutex_td. + int instance_cnt_td; + /// \internal This variable is protected by \ref mutex_te. + int instance_cnt_te; + /// \internal This variable is protected by \ref mutex_prach. + int instance_cnt_prach; +#ifdef Rel14 + /// \internal This variable is protected by \ref mutex_prach for BL/CE UEs. + int instance_cnt_prach_br; +#endif + // instance count for over-the-air eNB synchronization int instance_cnt_synch; - /// pthread attributes for synch processing thread - pthread_attr_t attr_synch; - /// scheduling parameters for synch thread - struct sched_param sched_param_synch; - /// pthread descriptor synch thread - pthread_t pthread_synch; - /// condition variable for UE synch thread; - pthread_cond_t cond_synch; - /// mutex for UE synch thread - pthread_mutex_t mutex_synch; - /// instance count for eNBs - int instance_cnt_eNBs; - /// set of scheduling variables RXn-TXnp4 threads - UE_rxtx_proc_t proc_rxtx[RX_NB_TH]; -} UE_proc_t; - - -/// Panos: Structure holding timer_thread related elements (phy_stub_UE mode) -typedef struct{ - pthread_t pthread_timer; - /// Panos: mutex for waiting SF ticking - pthread_mutex_t mutex_ticking; - /// Panos: \brief ticking var for ticking thread. - /// \internal This variable is protected by \ref mutex_ticking. - int ticking_var; - /// condition variable for timer_thread; - pthread_cond_t cond_ticking; - //time_stats_t timer_stats; -}SF_ticking; - - - -typedef enum { - LOCAL_RF =0, - REMOTE_IF5 =1, - REMOTE_MBP_IF5 =2, - REMOTE_IF4p5 =3, - REMOTE_IF1pp =4, - MAX_RU_IF_TYPES =5 - //EMULATE_RF =6 -} RU_if_south_t; - -typedef struct RU_t_s{ - /// index of this ru - uint32_t idx; - /// Pointer to configuration file - char *rf_config_file; - /// southbound interface - RU_if_south_t if_south; - /// timing - node_timing_t if_timing; - /// function - node_function_t function; - /// Ethernet parameters for fronthaul interface - eth_params_t eth_params; - /// flag to indicate the RU is in synch with a master reference - int in_synch; - /// timing offset - int rx_offset; - /// flag to indicate the RU is a slave to another source - int is_slave; - /// Total gain of receive chain - uint32_t rx_total_gain_dB; - /// number of bands that this device can support - int num_bands; - /// band list - int band[MAX_BANDS_PER_RRU]; - /// number of RX paths on device - int nb_rx; - /// number of TX paths on device - int nb_tx; - /// maximum PDSCH RS EPRE - int max_pdschReferenceSignalPower; - /// maximum RX gain - int max_rxgain; - /// Attenuation of RX paths on device - int att_rx; - /// Attenuation of TX paths on device - int att_tx; - /// flag to indicate precoding operation in RU - int do_precoding; - /// Frame parameters - LTE_DL_FRAME_PARMS frame_parms; - ///timing offset used in TDD - int N_TA_offset; - /// RF device descriptor - openair0_device rfdevice; - /// HW configuration - openair0_config_t openair0_cfg; - /// Number of eNBs using this RU - int num_eNB; - /// list of eNBs using this RU - struct PHY_VARS_eNB_s *eNB_list[NUMBER_OF_eNB_MAX]; - /// Mapping of antenna ports to RF chain index - openair0_rf_map rf_map; - /// IF device descriptor - openair0_device ifdevice; - /// Pointer for ifdevice buffer struct - if_buffer_t ifbuffer; - /// if prach processing is to be performed in RU - int do_prach; - /// function pointer to synchronous RX fronthaul function (RRU,3GPP_eNB) - void (*fh_south_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to synchronous TX fronthaul function - void (*fh_south_out)(struct RU_t_s *ru); - /// function pointer to synchronous RX fronthaul function (RRU) - void (*fh_north_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to synchronous RX fronthaul function (RRU) - void (*fh_north_out)(struct RU_t_s *ru); - /// function pointer to asynchronous fronthaul interface - void (*fh_north_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to asynchronous fronthaul interface - void (*fh_south_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to initialization function for radio interface - int (*start_rf)(struct RU_t_s *ru); - /// function pointer to release function for radio interface - int (*stop_rf)(struct RU_t_s *ru); - /// function pointer to initialization function for radio interface - int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); - /// function pointer to RX front-end processing routine (DFTs/prefix removal or NULL) - void (*feprx)(struct RU_t_s *ru); - /// function pointer to TX front-end processing routine (IDFTs and prefix removal or NULL) - void (*feptx_ofdm)(struct RU_t_s *ru); - /// function pointer to TX front-end processing routine (PRECODING) - void (*feptx_prec)(struct RU_t_s *ru); - /// function pointer to wakeup routine in lte-enb. - int (*wakeup_rxtx)(struct PHY_VARS_eNB_s *eNB, struct RU_t_s *ru); - /// function pointer to wakeup routine in lte-enb. - void (*wakeup_prach_eNB)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); + /// \internal This variable is protected by \ref mutex_asynch_rxtx. + int instance_cnt_asynch_rxtx; + /// pthread structure for eNB single processing thread + pthread_t pthread_single; + /// pthread structure for asychronous RX/TX processing thread + pthread_t pthread_asynch_rxtx; + /// flag to indicate first RX acquisition + int first_rx; + /// flag to indicate first TX transmission + int first_tx; + /// pthread attributes for parallel turbo-decoder thread + pthread_attr_t attr_td; + /// pthread attributes for parallel turbo-encoder thread + pthread_attr_t attr_te; + /// pthread attributes for single eNB processing thread + pthread_attr_t attr_single; + /// pthread attributes for prach processing thread + pthread_attr_t attr_prach; +#ifdef Rel14 + /// pthread attributes for prach processing thread BL/CE UEs + pthread_attr_t attr_prach_br; +#endif + /// pthread attributes for asynchronous RX thread + pthread_attr_t attr_asynch_rxtx; + /// scheduling parameters for parallel turbo-decoder thread + struct sched_param sched_param_td; + /// scheduling parameters for parallel turbo-encoder thread + struct sched_param sched_param_te; + /// scheduling parameters for single eNB thread + struct sched_param sched_param_single; + /// scheduling parameters for prach thread + struct sched_param sched_param_prach; +#ifdef Rel14 + /// scheduling parameters for prach thread + struct sched_param sched_param_prach_br; +#endif + /// scheduling parameters for asynch_rxtx thread + struct sched_param sched_param_asynch_rxtx; + /// pthread structure for parallel turbo-decoder thread + pthread_t pthread_td; + /// pthread structure for parallel turbo-encoder thread + pthread_t pthread_te; + /// pthread structure for PRACH thread + pthread_t pthread_prach; +#ifdef Rel14 + /// pthread structure for PRACH thread BL/CE UEs + pthread_t pthread_prach_br; +#endif + /// condition variable for parallel turbo-decoder thread + pthread_cond_t cond_td; + /// condition variable for parallel turbo-encoder thread + pthread_cond_t cond_te; + /// condition variable for PRACH processing thread; + pthread_cond_t cond_prach; #ifdef Rel14 - /// function pointer to wakeup routine in lte-enb. - void (*wakeup_prach_eNB_br)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); + /// condition variable for PRACH processing thread BL/CE UEs; + pthread_cond_t cond_prach_br; #endif - /// function pointer to eNB entry routine - void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string,struct RU_t_s *ru); - /// Timing statistics - time_stats_t ofdm_demod_stats; - /// Timing statistics (TX) - time_stats_t ofdm_mod_stats; - /// Timing wait statistics - time_stats_t ofdm_demod_wait_stats; - /// Timing wakeup statistics - time_stats_t ofdm_demod_wakeup_stats; - /// Timing wait statistics (TX) - time_stats_t ofdm_mod_wait_stats; - /// Timing wakeup statistics (TX) - time_stats_t ofdm_mod_wakeup_stats; - /// Timing statistics (RX Fronthaul + Compression) - 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 - int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15]; - - /// received frequency-domain signal for PRACH (IF4p5 RRU) - int16_t **prach_rxsigF; - /// received frequency-domain signal for PRACH BR (IF4p5 RRU) - int16_t **prach_rxsigF_br[4]; - /// sequence number for IF5 - uint8_t seqno; - /// initial timestamp used as an offset make first real timestamp 0 - openair0_timestamp ts_offset; - /// process scheduling variables - RU_proc_t proc; + /// condition variable for asynch RX/TX thread + pthread_cond_t cond_asynch_rxtx; + /// mutex for parallel turbo-decoder thread + pthread_mutex_t mutex_td; + /// mutex for parallel turbo-encoder thread + pthread_mutex_t mutex_te; + /// mutex for PRACH thread + pthread_mutex_t mutex_prach; +#ifdef Rel14 + /// mutex for PRACH thread for BL/CE UEs + pthread_mutex_t mutex_prach_br; +#endif + /// mutex for asynch RX/TX thread + pthread_mutex_t mutex_asynch_rxtx; + /// mutex for RU access to eNB processing (PDSCH/PUSCH) + pthread_mutex_t mutex_RU; + /// mutex for RU access to eNB processing (PRACH) + pthread_mutex_t mutex_RU_PRACH; + /// mutex for RU access to eNB processing (PRACH BR) + pthread_mutex_t mutex_RU_PRACH_br; + /// mask for RUs serving eNB (PDSCH/PUSCH) + int RU_mask; + /// mask for RUs serving eNB (PRACH) + int RU_mask_prach; +#ifdef Rel14 + /// mask for RUs serving eNB (PRACH) + int RU_mask_prach_br; +#endif + /// parameters for turbo-decoding worker thread + td_params tdp; + /// parameters for turbo-encoding worker thread + te_params tep[3]; + /// set of scheduling variables RXn-TXnp4 threads + eNB_rxtx_proc_t proc_rxtx[2]; /// stats thread pthread descriptor - pthread_t ru_stats_thread; -} RU_t; + pthread_t process_stats_thread; + /// for waking up tx procedure + RU_proc_t *ru_proc; +} eNB_proc_t; -typedef struct { - //unsigned int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (linear) - //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (dB) - //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //! estimated avg received signal power (dB) - // RRC measurements - uint32_t rssi; - int n_adj_cells; - unsigned int adj_cell_id[6]; - uint32_t rsrq[7]; - uint32_t rsrp[7]; - float rsrp_filtered[7]; // after layer 3 filtering - float rsrq_filtered[7]; - // common measurements - //! estimated noise power (linear) - unsigned int n0_power[NB_ANTENNAS_RX]; - //! estimated noise power (dB) - unsigned short n0_power_dB[NB_ANTENNAS_RX]; - //! total estimated noise power (linear) - unsigned int n0_power_tot; - //! total estimated noise power (dB) - unsigned short n0_power_tot_dB; - //! average estimated noise power (linear) - unsigned int n0_power_avg; - //! average estimated noise power (dB) - unsigned short n0_power_avg_dB; - //! total estimated noise power (dBm) - short n0_power_tot_dBm; - // UE measurements - //! estimated received spatial signal power (linear) - int rx_spatial_power[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; - //! estimated received spatial signal power (dB) - unsigned short rx_spatial_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; - - /// estimated received signal power (sum over all TX antennas) - //int wideband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - /// estimated received signal power (sum over all TX antennas) - //int wideband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - - /// estimated received signal power (sum over all TX/RX antennas) - int rx_power_tot[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW - /// estimated received signal power (sum over all TX/RX antennas) - unsigned short rx_power_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW - - //! estimated received signal power (sum of all TX/RX antennas, time average) - int rx_power_avg[NUMBER_OF_CONNECTED_eNB_MAX]; - //! estimated received signal power (sum of all TX/RX antennas, time average, in dB) - unsigned short rx_power_avg_dB[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// SINR (sum of all TX/RX antennas, in dB) - int wideband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX]; - /// SINR (sum of all TX/RX antennas, time average, in dB) - int wideband_cqi_avg[NUMBER_OF_CONNECTED_eNB_MAX]; - //! estimated rssi (dBm) - short rx_rssi_dBm[NUMBER_OF_CONNECTED_eNB_MAX]; - //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) - int rx_correlation[NUMBER_OF_CONNECTED_eNB_MAX][2]; - //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) - int rx_correlation_dB[NUMBER_OF_CONNECTED_eNB_MAX][2]; - - /// Wideband CQI (sum of all RX antennas, in dB, for precoded transmission modes (3,4,5,6), up to 4 spatial streams) - int precoded_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX+1][4]; - /// Subband CQI per RX antenna (= SINR) - int subband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; - /// Total Subband CQI (= SINR) - int subband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; - /// Subband CQI in dB (= SINR dB) - int subband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; - /// Total Subband CQI - int subband_cqi_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; - /// Wideband PMI for each RX antenna - int wideband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - /// Wideband PMI for each RX antenna - int wideband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - ///Subband PMI for each RX antenna - int subband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; - ///Subband PMI for each RX antenna - int subband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; - /// chosen RX antennas (1=Rx antenna 1, 2=Rx antenna 2, 3=both Rx antennas) - unsigned char selected_rx_antennas[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; - /// Wideband Rank indication - unsigned char rank[NUMBER_OF_CONNECTED_eNB_MAX]; - /// Number of RX Antennas - unsigned char nb_antennas_rx; - /// DLSCH error counter - // short dlsch_errors; - -} PHY_MEASUREMENTS; typedef struct { //unsigned int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (linear) @@ -1229,11 +1086,6 @@ typedef struct PHY_VARS_eNB_s { time_stats_t ulsch_tc_intl1_stats; time_stats_t ulsch_tc_intl2_stats; -#ifdef LOCALIZATION - /// time state for localization - time_stats_t localization_stats; -#endif - int32_t pucch1_stats_cnt[NUMBER_OF_UE_MAX][10]; int32_t pucch1_stats[NUMBER_OF_UE_MAX][10*1024]; int32_t pucch1_stats_thres[NUMBER_OF_UE_MAX][10*1024]; @@ -1246,538 +1098,4 @@ typedef struct PHY_VARS_eNB_s { int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240]; } PHY_VARS_eNB; -#define debug_msg if (((mac_xface->frame%100) == 0) || (mac_xface->frame < 50)) msg - -/// Top-level PHY Data Structure for UE -typedef struct { - /// \brief Module ID indicator for this instance - uint8_t Mod_id; - /// \brief Component carrier ID for this PHY instance - uint8_t CC_id; - /// \brief Mapping of CC_id antennas to cards - openair0_rf_map rf_map; - //uint8_t local_flag; - /// \brief Indicator of current run mode of UE (normal_txrx, rx_calib_ue, no_L2_connect, debug_prach) - runmode_t mode; - /// \brief Indicator that UE should perform band scanning - int UE_scan; - /// \brief Indicator that UE should perform coarse scanning around carrier - int UE_scan_carrier; - /// \brief Indicator that UE is synchronized to an eNB - int is_synchronized; - /// Data structure for UE process scheduling - UE_proc_t proc; - /// Flag to indicate the UE shouldn't do timing correction at all - int no_timing_correction; - /// \brief Total gain of the TX chain (16-bit baseband I/Q to antenna) - uint32_t tx_total_gain_dB; - /// \brief Total gain of the RX chain (antenna to baseband I/Q) This is a function of rx_gain_mode (and the corresponding gain) and the rx_gain of the card. - uint32_t rx_total_gain_dB; - /// \brief Total gains with maximum RF gain stage (ExpressMIMO2/Lime) - uint32_t rx_gain_max[4]; - /// \brief Total gains with medium RF gain stage (ExpressMIMO2/Lime) - uint32_t rx_gain_med[4]; - /// \brief Total gains with bypassed RF gain stage (ExpressMIMO2/Lime) - uint32_t rx_gain_byp[4]; - /// \brief Current transmit power - int16_t tx_power_dBm[10]; - /// \brief Total number of REs in current transmission - int tx_total_RE[10]; - /// \brief Maximum transmit power - int8_t tx_power_max_dBm; - /// \brief Number of eNB seen by UE - uint8_t n_connected_eNB; - /// \brief indicator that Handover procedure has been initiated - uint8_t ho_initiated; - /// \brief indicator that Handover procedure has been triggered - uint8_t ho_triggered; - /// \brief Measurement variables. - PHY_MEASUREMENTS measurements; - LTE_DL_FRAME_PARMS frame_parms; - /// \brief Frame parame before ho used to recover if ho fails. - LTE_DL_FRAME_PARMS frame_parms_before_ho; - LTE_UE_COMMON common_vars; - - // point to the current rxTx thread index - uint8_t current_thread_id[10]; - - LTE_UE_PDSCH *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX+1]; // two RxTx Threads - LTE_UE_PDSCH_FLP *pdsch_vars_flp[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_SI[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_ra[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_p[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][2]; // two RxTx Threads - LTE_UE_ULSCH_t *ulsch[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; - // This is for SIC in the UE, to store the reencoded data - LTE_eNB_DLSCH_t *dlsch_eNB[NUMBER_OF_CONNECTED_eNB_MAX]; - - //Paging parameters - uint32_t IMSImod1024; - uint32_t PF; - uint32_t PO; - - // For abstraction-purposes only - uint8_t sr[10]; - uint8_t pucch_sel[10]; - uint8_t pucch_payload[22]; - - UE_MODE_t UE_mode[NUMBER_OF_CONNECTED_eNB_MAX]; - /// cell-specific reference symbols - uint32_t lte_gold_table[7][20][2][14]; - - /// UE-specific reference symbols (p=5), TM 7 - uint32_t lte_gold_uespec_port5_table[20][38]; - - /// ue-specific reference symbols - uint32_t lte_gold_uespec_table[2][20][2][21]; - - /// mbsfn reference symbols - uint32_t lte_gold_mbsfn_table[10][3][42]; - - uint32_t X_u[64][839]; - - uint32_t high_speed_flag; - uint32_t perfect_ce; - int16_t ch_est_alpha; - int generate_ul_signal[NUMBER_OF_CONNECTED_eNB_MAX]; - - UE_SCAN_INFO_t scan_info[NB_BANDS_MAX]; - - char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX]; - - - - unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_eNB_MAX]; - uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_eNB_MAX]; - unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_eNB_MAX]; - PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_eNB_MAX]; - int turbo_iterations, turbo_cntl_iterations; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t total_TBS[NUMBER_OF_CONNECTED_eNB_MAX]; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t total_TBS_last[NUMBER_OF_CONNECTED_eNB_MAX]; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t bitrate[NUMBER_OF_CONNECTED_eNB_MAX]; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t total_received_bits[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_errors_last[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_received_last[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_fer[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_SI_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_SI_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_ra_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_ra_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_p_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_p_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mch_received_sf[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mch_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mcch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mtch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mcch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mtch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mcch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mtch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX]; - unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX]; - uint8_t generate_prach; - uint8_t prach_cnt; - uint8_t prach_PreambleIndex; - // uint8_t prach_timer; - uint8_t decode_SIB; - uint8_t decode_MIB; - int rx_offset; /// Timing offset - int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP - int time_sync_cell; - int timing_advance; ///timing advance signalled from eNB - int hw_timing_advance; - int N_TA_offset; ///timing offset used in TDD - /// Flag to tell if UE is secondary user (cognitive mode) - unsigned char is_secondary_ue; - /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from. - unsigned char has_valid_precoder; - /// hold the precoder for NULL beam to the primary eNB - int **ul_precoder_S_UE; - /// holds the maximum channel/precoder coefficient - char log2_maxp; - - /// if ==0 enables phy only test mode - int mac_enabled; - - /// Flag to initialize averaging of PHY measurements - int init_averaging; - - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; - - /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_CQI_dB; - - /// sinr_effective used for CQI calulcation - double sinr_eff; - - /// N0 (used for abstraction) - double N0; - - /// PDSCH Varaibles - PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// PUSCH Varaibles - PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// PUSCH contention-based access vars - PUSCH_CA_CONFIG_DEDICATED pusch_ca_config_dedicated[NUMBER_OF_eNB_MAX]; // lola - - /// PUCCH variables - - PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - uint8_t ncs_cell[20][7]; - - /// UL-POWER-Control - UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// TPC - TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_CONNECTED_eNB_MAX]; - TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// CQI reporting - CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// SRS Variables - SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// Scheduling Request Config - SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// Transmission mode per eNB - uint8_t transmission_mode[NUMBER_OF_CONNECTED_eNB_MAX]; - - time_stats_t phy_proc[RX_NB_TH]; - time_stats_t phy_proc_tx; - time_stats_t phy_proc_rx[RX_NB_TH]; - - uint32_t use_ia_receiver; - - time_stats_t ofdm_mod_stats; - time_stats_t ulsch_encoding_stats; - time_stats_t ulsch_modulation_stats; - time_stats_t ulsch_segmentation_stats; - time_stats_t ulsch_rate_matching_stats; - time_stats_t ulsch_turbo_encoding_stats; - time_stats_t ulsch_interleaving_stats; - time_stats_t ulsch_multiplexing_stats; - - time_stats_t generic_stat; - time_stats_t generic_stat_bis[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t ue_front_end_stat[RX_NB_TH]; - time_stats_t ue_front_end_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t pdcch_procedures_stat[RX_NB_TH]; - time_stats_t pdsch_procedures_stat[RX_NB_TH]; - time_stats_t pdsch_procedures_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t dlsch_procedures_stat[RX_NB_TH]; - - time_stats_t ofdm_demod_stats; - time_stats_t dlsch_rx_pdcch_stats; - time_stats_t rx_dft_stats; - time_stats_t dlsch_channel_estimation_stats; - time_stats_t dlsch_freq_offset_estimation_stats; - time_stats_t dlsch_decoding_stats[2]; - time_stats_t dlsch_demodulation_stats; - time_stats_t dlsch_rate_unmatching_stats; - time_stats_t dlsch_turbo_decoding_stats; - time_stats_t dlsch_deinterleaving_stats; - time_stats_t dlsch_llr_stats; - time_stats_t dlsch_llr_stats_parallelization[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t dlsch_unscrambling_stats; - time_stats_t dlsch_rate_matching_stats; - time_stats_t dlsch_turbo_encoding_stats; - time_stats_t dlsch_interleaving_stats; - time_stats_t dlsch_tc_init_stats; - time_stats_t dlsch_tc_alpha_stats; - time_stats_t dlsch_tc_beta_stats; - time_stats_t dlsch_tc_gamma_stats; - time_stats_t dlsch_tc_ext_stats; - time_stats_t dlsch_tc_intl1_stats; - time_stats_t dlsch_tc_intl2_stats; - time_stats_t tx_prach; - time_stats_t timer_stats; - - pthread_mutex_t timer_mutex; - pthread_cond_t timer_cond; - int instance_cnt_timer; - - /// RF and Interface devices per CC - - openair0_device rfdevice; -} PHY_VARS_UE; - -/* this structure is used to pass both UE phy vars and - * proc to the function UE_thread_rxn_txnp4 - */ -struct rx_tx_thread_data { - PHY_VARS_UE *UE; - UE_rxtx_proc_t *proc; -}; - -void exit_fun(const char* s); - -#include "UTIL/LOG/log_extern.h" -extern pthread_cond_t sync_cond; -extern pthread_mutex_t sync_mutex; -extern int sync_var; - - -#define MODE_DECODE_NONE 0 -#define MODE_DECODE_SSE 1 -#define MODE_DECODE_C 2 -#define MODE_DECODE_AVX2 3 - -#define DECODE_INITTD8_SSE_FPTRIDX 0 -#define DECODE_INITTD16_SSE_FPTRIDX 1 -#define DECODE_INITTD_AVX2_FPTRIDX 2 -#define DECODE_TD8_SSE_FPTRIDX 3 -#define DECODE_TD16_SSE_FPTRIDX 4 -#define DECODE_TD_C_FPTRIDX 5 -#define DECODE_TD16_AVX2_FPTRIDX 6 -#define DECODE_FREETD8_FPTRIDX 7 -#define DECODE_FREETD16_FPTRIDX 8 -#define DECODE_FREETD_AVX2_FPTRIDX 9 -#define ENCODE_SSE_FPTRIDX 10 -#define ENCODE_C_FPTRIDX 11 -#define ENCODE_INIT_SSE_FPTRIDX 12 -#define DECODE_NUM_FPTR 13 - - -typedef uint8_t(*decoder_if_t)(int16_t *y, - int16_t *y2, - uint8_t *decoded_bytes, - uint8_t *decoded_bytes2, - uint16_t n, - uint16_t f1, - uint16_t f2, - uint8_t max_iterations, - uint8_t crc_type, - uint8_t F, - time_stats_t *init_stats, - time_stats_t *alpha_stats, - time_stats_t *beta_stats, - time_stats_t *gamma_stats, - time_stats_t *ext_stats, - time_stats_t *intl1_stats, - time_stats_t *intl2_stats); - -typedef uint8_t(*encoder_if_t)(uint8_t *input, - uint16_t input_length_bytes, - uint8_t *output, - uint8_t F, - uint16_t interleaver_f1, - uint16_t interleaver_f2); - -#define MAX_RRU_CONFIG_SIZE 1024 -typedef enum { - RAU_tick=0, - RRU_capabilities=1, - RRU_config=2, - RRU_MSG_max_num=3 -} rru_config_msg_type_t; - -typedef struct RRU_CONFIG_msg_s { - rru_config_msg_type_t type; - ssize_t len; - uint8_t msg[MAX_RRU_CONFIG_SIZE]; -} RRU_CONFIG_msg_t; - -typedef enum { - OAI_IF5_only =0, - OAI_IF4p5_only =1, - OAI_IF5_and_IF4p5 =2, - MBP_IF5 =3, - MAX_FH_FMTs =4 -} FH_fmt_options_t; - -#define MAX_BANDS_PER_RRU 4 - -typedef struct RRU_capabilities_s { - /// Fronthaul format - FH_fmt_options_t FH_fmt; - /// number of EUTRA bands (<=4) supported by RRU - uint8_t num_bands; - /// EUTRA band list supported by RRU - uint8_t band_list[MAX_BANDS_PER_RRU]; - /// Number of concurrent bands (component carriers) - uint8_t num_concurrent_bands; - /// Maximum TX EPRE of each band - int8_t max_pdschReferenceSignalPower[MAX_BANDS_PER_RRU]; - /// Maximum RX gain of each band - uint8_t max_rxgain[MAX_BANDS_PER_RRU]; - /// Number of RX ports of each band - uint8_t nb_rx[MAX_BANDS_PER_RRU]; - /// Number of TX ports of each band - uint8_t nb_tx[MAX_BANDS_PER_RRU]; - /// max DL bandwidth (1,6,15,25,50,75,100) - uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; - /// max UL bandwidth (1,6,15,25,50,75,100) - uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; -} RRU_capabilities_t; - -typedef struct RRU_config_s { - - /// Fronthaul format - RU_if_south_t FH_fmt; - /// number of EUTRA bands (<=4) configured in RRU - uint8_t num_bands; - /// EUTRA band list configured in RRU - uint8_t band_list[MAX_BANDS_PER_RRU]; - /// TDD configuration (0-6) - uint8_t tdd_config[MAX_BANDS_PER_RRU]; - /// TDD special subframe configuration (0-10) - uint8_t tdd_config_S[MAX_BANDS_PER_RRU]; - /// TX frequency - uint32_t tx_freq[MAX_BANDS_PER_RRU]; - /// RX frequency - uint32_t rx_freq[MAX_BANDS_PER_RRU]; - /// TX attenation w.r.t. max - uint8_t att_tx[MAX_BANDS_PER_RRU]; - /// RX attenuation w.r.t. max - uint8_t att_rx[MAX_BANDS_PER_RRU]; - /// DL bandwidth - uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; - /// UL bandwidth - uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; - /// 3/4 sampling rate - uint8_t threequarter_fs[MAX_BANDS_PER_RRU]; - /// prach_FreqOffset for IF4p5 - int prach_FreqOffset[MAX_BANDS_PER_RRU]; - /// prach_ConfigIndex for IF4p5 - int prach_ConfigIndex[MAX_BANDS_PER_RRU]; -#ifdef Rel14 - int emtc_prach_CElevel_enable[MAX_BANDS_PER_RRU][4]; - /// emtc_prach_FreqOffset for IF4p5 per CE Level - int emtc_prach_FreqOffset[MAX_BANDS_PER_RRU][4]; - /// emtc_prach_ConfigIndex for IF4p5 per CE Level - int emtc_prach_ConfigIndex[MAX_BANDS_PER_RRU][4]; -#endif -} RRU_config_t; - - -static inline void wait_sync(char *thread_name) { - - printf( "waiting for sync (%s)\n",thread_name); - pthread_mutex_lock( &sync_mutex ); - - while (sync_var<0) - pthread_cond_wait( &sync_cond, &sync_mutex ); - - pthread_mutex_unlock(&sync_mutex); - - printf( "got sync (%s)\n", thread_name); - -} - -static inline int wakeup_thread(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { - - if (pthread_mutex_lock(mutex) != 0) { - LOG_E( PHY, "error locking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - *instance_cnt = *instance_cnt + 1; - // the thread can now be woken up - if (pthread_cond_signal(cond) != 0) { - LOG_E( PHY, "ERROR pthread_cond_signal\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(-1); - } - - pthread_mutex_unlock(mutex); - return(0); -} - -static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { - if (pthread_mutex_lock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - - while (*instance_cnt < 0) { - // most of the time the thread is waiting here - // proc->instance_cnt_rxtx is -1 - pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again - } - - if (pthread_mutex_unlock(mutex) != 0) { - LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - return(0); -} - -static inline int wait_on_busy_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { - - if (pthread_mutex_lock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - - while (*instance_cnt == 0) { - // most of the time the thread will skip this - // waits only if proc->instance_cnt_rxtx is 0 - pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again - } - - if (pthread_mutex_unlock(mutex) != 0) { - LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - return(0); -} - -static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *name) { - - if (pthread_mutex_lock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - - //LOG_D(PHY, "%s() name:%s instance_cnt:%u - about to decrement\n", __FUNCTION__, name, *instance_cnt); - - *instance_cnt=*instance_cnt-1; - - if (pthread_mutex_unlock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - return(0); -} - - -#include "PHY/INIT/defs.h" -#include "PHY/LTE_REFSIG/defs.h" -#include "PHY/MODULATION/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/LTE_ESTIMATION/defs.h" - -#include "SIMULATION/ETH_TRANSPORT/defs.h" -#endif // __PHY_DEFS__H__ +#endif /* __PHY_DEFS_ENB__H__ */ diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 066dc7012c317f08da23c8b5433be624f1937f6a..8ffe1fabf40533f151ade91c194e6b906a2301b4 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -34,661 +34,9 @@ #define __PHY_IMPLEMENTATION_DEFS_LTE_H__ -#include "types.h" -#include "nfapi_interface.h" -//#include "defs.h" -#include "openair2/COMMON/platform_types.h" -#define RX_NB_TH_MAX 2 -#define RX_NB_TH 2 -#define LTE_SLOTS_PER_SUBFRAME 2 -#define LTE_NUMBER_OF_SUBFRAMES_PER_FRAME 10 -#define LTE_SLOTS_PER_FRAME 20 -#define LTE_CE_FILTER_LENGTH 5 -#define LTE_CE_OFFSET LTE_CE_FILTER_LENGTH -#define TX_RX_SWITCH_SYMBOL (NUMBER_OF_SYMBOLS_PER_FRAME>>1) -#define PBCH_PDU_SIZE 3 //bytes - -#define PRACH_SYMBOL 3 //position of the UL PSS wrt 2nd slot of special subframe - -#define NUMBER_OF_FREQUENCY_GROUPS (lte_frame_parms->N_RB_DL) - -#define SSS_AMP 1148 - -#define MAX_NUM_PHICH_GROUPS 56 //110 RBs Ng=2, p.60 36-212, Sec. 6.9 - -#define MAX_MBSFN_AREA 8 - -#define NB_RX_ANTENNAS_MAX 64 - -#ifdef OCP_FRAMEWORK -#include "enums.h" -#else -typedef enum {TDD=1,FDD=0} lte_frame_type_t; - -typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t; - -typedef enum {LOCALIZED=0,DISTRIBUTED=1} vrb_t; - -/// Enumeration for parameter PHICH-Duration \ref PHICH_CONFIG_COMMON::phich_duration. -typedef enum { - normal=0, - extended=1 -} PHICH_DURATION_t; - -/// Enumeration for parameter Ng \ref PHICH_CONFIG_COMMON::phich_resource. -typedef enum { - oneSixth=1, - half=3, - one=6, - two=12 -} PHICH_RESOURCE_t; -#endif -/// PHICH-Config from 36.331 RRC spec -typedef struct { - /// Parameter: PHICH-Duration, see TS 36.211 (Table 6.9.3-1). - PHICH_DURATION_t phich_duration; - /// Parameter: Ng, see TS 36.211 (6.9). \details Value oneSixth corresponds to 1/6, half corresponds to 1/2 and so on. - PHICH_RESOURCE_t phich_resource; -} PHICH_CONFIG_COMMON; - -/// PRACH-ConfigInfo from 36.331 RRC spec -typedef struct { - /// Parameter: prach-ConfigurationIndex, see TS 36.211 (5.7.1). \vr{[0..63]} - uint8_t prach_ConfigIndex; - /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. - uint8_t highSpeedFlag; - /// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. - uint8_t zeroCorrelationZoneConfig; - /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. - uint8_t prach_FreqOffset; -} PRACH_CONFIG_INFO; - - - -/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec -typedef struct { - /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} - uint16_t rootSequenceIndex; - /// prach_Config_enabled=1 means enabled. \vr{[0..1]} - uint8_t prach_Config_enabled; - /// PRACH Configuration Information - PRACH_CONFIG_INFO prach_ConfigInfo; -} PRACH_CONFIG_COMMON; - -#ifdef Rel14 - -/// PRACH-eMTC-Config from 36.331 RRC spec -typedef struct { - /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. - uint8_t highSpeedFlag; -/// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. - uint8_t zeroCorrelationZoneConfig; - /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. - - /// PRACH starting subframe periodicity, expressed in number of subframes available for preamble transmission (PRACH opportunities), see TS 36.211. Value 2 corresponds to 2 subframes, 4 corresponds to 4 subframes and so on. EUTRAN configures the PRACH starting subframe periodicity larger than or equal to the Number of PRACH repetitions per attempt for each CE level (numRepetitionPerPreambleAttempt). - uint8_t prach_starting_subframe_periodicity[4]; - /// number of repetitions per preamble attempt per CE level - uint8_t prach_numRepetitionPerPreambleAttempt[4]; - /// prach configuration index for each CE level - uint8_t prach_ConfigIndex[4]; - /// indicator for CE level activation - uint8_t prach_CElevel_enable[4]; - /// prach frequency offset for each CE level - uint8_t prach_FreqOffset[4]; - /// indicator for CE level hopping activation - uint8_t prach_hopping_enable[4]; - /// indicator for CE level hopping activation - uint8_t prach_hopping_offset[4]; -} PRACH_eMTC_CONFIG_INFO; - -/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec -typedef struct { - /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} - uint16_t rootSequenceIndex; - /// 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; - -#endif - -/// Enumeration for parameter \f$N_\text{ANRep}\f$ \ref PUCCH_CONFIG_DEDICATED::repetitionFactor. -typedef enum { - n2=0, - n4, - n6 -} ACKNAKREP_t; - -/// Enumeration for \ref PUCCH_CONFIG_DEDICATED::tdd_AckNackFeedbackMode. -typedef enum { - bundling=0, - multiplexing -} ANFBmode_t; - -/// PUCCH-ConfigDedicated from 36.331 RRC spec -typedef struct { - /// Flag to indicate ACK NAK repetition activation, see TS 36.213 (10.1). \vr{[0..1]} - uint8_t ackNackRepetition; - /// Parameter: \f$N_\text{ANRep}\f$, see TS 36.213 (10.1). - ACKNAKREP_t repetitionFactor; - /// Parameter: \f$n^{(1)}_\text{PUCCH,ANRep}\f$, see TS 36.213 (10.1). \vr{[0..2047]} - uint16_t n1PUCCH_AN_Rep; - /// Feedback mode, see TS 36.213 (7.3). \details Applied to both PUCCH and PUSCH feedback. For TDD, should always be set to bundling. - ANFBmode_t tdd_AckNackFeedbackMode; -} PUCCH_CONFIG_DEDICATED; - -/// PUCCH-ConfigCommon from 36.331 RRC spec -typedef struct { - /// Parameter: \f$\Delta^\text{PUCCH}_\text{shift}\f$, see TS 36.211 (5.4.1). \vr{[1..3]} \note the specification sais it is an enumerated value. - uint8_t deltaPUCCH_Shift; - /// Parameter: \f$N^{(2)}_\text{RB}\f$, see TS 36.211 (5.4). \vr{[0..98]} - uint8_t nRB_CQI; - /// Parameter: \f$N^{(1)}_\text{CS}\f$, see TS 36.211 (5.4). \vr{[0..7]} - uint8_t nCS_AN; - /// Parameter: \f$N^{(1)}_\text{PUCCH}\f$ see TS 36.213 (10.1). \vr{[0..2047]} - uint16_t n1PUCCH_AN; - - /// group hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. - uint8_t grouphop[20]; - /// sequence hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. - uint8_t seqhop[20]; -} PUCCH_CONFIG_COMMON; - -/// UL-ReferenceSignalsPUSCH from 36.331 RRC spec -typedef struct { - /// Parameter: Group-hopping-enabled, see TS 36.211 (5.5.1.3). \vr{[0..1]} - uint8_t groupHoppingEnabled; - /// Parameter: \f$\Delta SS\f$, see TS 36.211 (5.5.1.3). \vr{[0..29]} - uint8_t groupAssignmentPUSCH; - /// Parameter: Sequence-hopping-enabled, see TS 36.211 (5.5.1.4). \vr{[0..1]} - uint8_t sequenceHoppingEnabled; - /// Parameter: cyclicShift, see TS 36.211 (Table 5.5.2.1.1-2). \vr{[0..7]} - uint8_t cyclicShift; - /// nPRS for cyclic shift of DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. - uint8_t nPRS[20]; - /// group hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. - uint8_t grouphop[20]; - /// sequence hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. - uint8_t seqhop[20]; -} UL_REFERENCE_SIGNALS_PUSCH_t; - -/// Enumeration for parameter Hopping-mode \ref PUSCH_CONFIG_COMMON::hoppingMode. -#ifndef OCP_FRAMEWORK -typedef enum { - interSubFrame=0, - intraAndInterSubFrame=1 -} PUSCH_HOPPING_t; -#endif - -/// PUSCH-ConfigCommon from 36.331 RRC spec. -typedef struct { - /// Parameter: \f$N_{sb}\f$, see TS 36.211 (5.3.4). \vr{[1..4]} - uint8_t n_SB; - /// Parameter: Hopping-mode, see TS 36.211 (5.3.4). - PUSCH_HOPPING_t hoppingMode; - /// Parameter: \f$N^{HO}_{RB}\f$, see TS 36.211 (5.3.4). \vr{[0..98]} - uint8_t pusch_HoppingOffset; - /// See TS 36.213 (8.6.1). \vr{[0..1]} 1 indicates 64QAM is allowed, 0 not allowed. - uint8_t enable64QAM; - /// Ref signals configuration - UL_REFERENCE_SIGNALS_PUSCH_t ul_ReferenceSignalsPUSCH; -} PUSCH_CONFIG_COMMON; - -/// UE specific PUSCH configuration. -typedef struct { - /// Parameter: \f$I^\text{HARQ-ACK}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-1). \vr{[0..15]} - uint16_t betaOffset_ACK_Index; - /// Parameter: \f$I^{RI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-2). \vr{[0..15]} - uint16_t betaOffset_RI_Index; - /// Parameter: \f$I^{CQI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-3). \vr{[0..15]} - uint16_t betaOffset_CQI_Index; -} PUSCH_CONFIG_DEDICATED; - -/// lola CBA information -typedef struct { - /// - uint16_t betaOffset_CA_Index; - /// - uint16_t cShift; -} PUSCH_CA_CONFIG_DEDICATED; - -/// PDSCH-ConfigCommon from 36.331 RRC spec -typedef struct { - /// Parameter: Reference-signal power, see TS 36.213 (5.2). \vr{[-60..50]}\n Provides the downlink reference-signal EPRE. The actual value in dBm. - int8_t referenceSignalPower; - /// Parameter: \f$P_B\f$, see TS 36.213 (Table 5.2-1). \vr{[0..3]} - uint8_t p_b; -} PDSCH_CONFIG_COMMON; - -/// Enumeration for Parameter \f$P_A\f$ \ref PDSCH_CONFIG_DEDICATED::p_a. -typedef enum { - dBm6=0, ///< (dB-6) corresponds to -6 dB - dBm477, ///< (dB-4dot77) corresponds to -4.77 dB - dBm3, ///< (dB-3) corresponds to -3 dB - dBm177, ///< (dB-1dot77) corresponds to -1.77 dB - dB0, ///< corresponds to 0 dB - dB1, ///< corresponds to 1 dB - dB2, ///< corresponds to 2 dB - dB3 ///< corresponds to 3 dB -} PA_t; - -/// PDSCH-ConfigDedicated from 36.331 RRC spec -typedef struct { - /// Parameter: \f$P_A\f$, see TS 36.213 (5.2). - PA_t p_a; -} PDSCH_CONFIG_DEDICATED; - -/// SoundingRS-UL-ConfigCommon Information Element from 36.331 RRC spec -typedef struct { - /// enabled flag=1 means SRS is enabled. \vr{[0..1]} - uint8_t enabled_flag; - /// Parameter: SRS Bandwidth Configuration, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..7]}\n Actual configuration depends on UL bandwidth. \note the specification sais it is an enumerated value. - uint8_t srs_BandwidthConfig; - /// Parameter: SRS SubframeConfiguration, see TS 36.211 (table 5.5.3.3-1 for FDD, table 5.5.3.3-2 for TDD). \vr{[0..15]} \note the specification sais it is an enumerated value. - uint8_t srs_SubframeConfig; - /// Parameter: Simultaneous-AN-and-SRS, see TS 36.213 (8.2). \vr{[0..1]} - uint8_t ackNackSRS_SimultaneousTransmission; - /// Parameter: srsMaxUpPts, see TS 36.211 (5.5.3.2). \details If this field is present, reconfiguration of \f$m^\text{max}_\text{SRS,0}\f$ applies for UpPts, otherwise reconfiguration does not apply. - uint8_t srs_MaxUpPts; -} SOUNDINGRS_UL_CONFIG_COMMON; - -/// \note UNUSED -typedef enum { - ulpc_al0=0, - ulpc_al04=1, - ulpc_al05=2, - ulpc_al06=3, - ulpc_al07=4, - ulpc_al08=5, - ulpc_al09=6, - ulpc_al11=7 -} UL_POWER_CONTROL_COMMON_alpha_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1. -typedef enum { - deltaF_PUCCH_Format1_deltaF_2 = 0, - deltaF_PUCCH_Format1_deltaF0 = 1, - deltaF_PUCCH_Format1_deltaF2 = 2 -} deltaF_PUCCH_Format1_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1b. -typedef enum { - deltaF_PUCCH_Format1b_deltaF1 = 0, - deltaF_PUCCH_Format1b_deltaF3 = 1, - deltaF_PUCCH_Format1b_deltaF5 = 2 -} deltaF_PUCCH_Format1b_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2. -typedef enum { - deltaF_PUCCH_Format2_deltaF_2 = 0, - deltaF_PUCCH_Format2_deltaF0 = 1, - deltaF_PUCCH_Format2_deltaF1 = 2, - deltaF_PUCCH_Format2_deltaF2 = 3 -} deltaF_PUCCH_Format2_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2a. -typedef enum { - deltaF_PUCCH_Format2a_deltaF_2 = 0, - deltaF_PUCCH_Format2a_deltaF0 = 1, - deltaF_PUCCH_Format2a_deltaF2 = 2 -} deltaF_PUCCH_Format2a_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2b. -typedef enum { - deltaF_PUCCH_Format2b_deltaF_2 = 0, - deltaF_PUCCH_Format2b_deltaF0 = 1, - deltaF_PUCCH_Format2b_deltaF2 = 2 -} deltaF_PUCCH_Format2b_t; - -/// DeltaFList-PUCCH from 36.331 RRC spec -typedef struct { - deltaF_PUCCH_Format1_t deltaF_PUCCH_Format1; - deltaF_PUCCH_Format1b_t deltaF_PUCCH_Format1b; - deltaF_PUCCH_Format2_t deltaF_PUCCH_Format2; - deltaF_PUCCH_Format2a_t deltaF_PUCCH_Format2a; - deltaF_PUCCH_Format2b_t deltaF_PUCCH_Format2b; -} deltaFList_PUCCH_t; - -/// SoundingRS-UL-ConfigDedicated Information Element from 36.331 RRC spec -typedef struct { - /// This descriptor is active - uint8_t active; - /// This descriptor's frame - uint16_t frame; - /// This descriptor's subframe - uint8_t subframe; - /// rnti - uint16_t rnti; - /// Parameter: \f$B_\text{SRS}\f$, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..3]} \note the specification sais it is an enumerated value. - uint8_t srs_Bandwidth; - /// Parameter: SRS hopping bandwidth \f$b_\text{hop}\in\{0,1,2,3\}\f$, see TS 36.211 (5.5.3.2) \vr{[0..3]} \note the specification sais it is an enumerated value. - uint8_t srs_HoppingBandwidth; - /// Parameter: \f$n_\text{RRC}\f$, see TS 36.211 (5.5.3.2). \vr{[0..23]} - uint8_t freqDomainPosition; - /// Parameter: Duration, see TS 36.213 (8.2). \vr{[0..1]} 0 corresponds to "single" and 1 to "indefinite". - uint8_t duration; - /// Parameter: \f$k_\text{TC}\in\{0,1\}\f$, see TS 36.211 (5.5.3.2). \vr{[0..1]} - uint8_t transmissionComb; - /// Parameter: \f$I_\text{SRS}\f$, see TS 36.213 (table 8.2-1). \vr{[0..1023]} - uint16_t srs_ConfigIndex; - /// Parameter: \f$n^\text{CS}_\text{SRS}\f$. See TS 36.211 (5.5.3.1). \vr{[0..7]} \note the specification sais it is an enumerated value. - uint8_t cyclicShift; - // Parameter: internal implementation: UE SRS configured - uint8_t srsConfigDedicatedSetup; - // Parameter: cell srs subframe for internal implementation - uint8_t srsCellSubframe; - // Parameter: ue srs subframe for internal implementation - uint8_t srsUeSubframe; -} SOUNDINGRS_UL_CONFIG_DEDICATED; - -/// UplinkPowerControlDedicated Information Element from 36.331 RRC spec -typedef struct { - /// Parameter: \f$P_\text{0\_UE\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dB. \vr{[-8..7]}\n This field is applicable for non-persistent scheduling, only. - int8_t p0_UE_PUSCH; - /// Parameter: Ks, see TS 36.213 (5.1.1.1). \vr{[0..1]}\n en0 corresponds to value 0 corresponding to state “disabledâ€. en1 corresponds to value 1.25 corresponding to “enabledâ€. \note the specification sais it is an enumerated value. \warning the enumeration values do not correspond to the given values in the specification (en1 should be 1.25). - uint8_t deltaMCS_Enabled; - /// Parameter: Accumulation-enabled, see TS 36.213 (5.1.1.1). \vr{[0..1]} 1 corresponds to "enabled" whereas 0 corresponds to "disabled". - uint8_t accumulationEnabled; - /// Parameter: \f$P_\text{0\_UE\_PUCCH}(1)\f$, see TS 36.213 (5.1.2.1), unit dB. \vr{[-8..7]} - int8_t p0_UE_PUCCH; - /// Parameter: \f$P_\text{SRS\_OFFSET}\f$, see TS 36.213 (5.1.3.1). \vr{[0..15]}\n For Ks=1.25 (\ref deltaMCS_Enabled), the actual parameter value is pSRS_Offset value - 3. For Ks=0, the actual parameter value is -10.5 + 1.5*pSRS_Offset value. - int8_t pSRS_Offset; - /// Specifies the filtering coefficient for RSRP measurements used to calculate path loss, as specified in TS 36.213 (5.1.1.1).\details The same filtering mechanism applies as for quantityConfig described in 5.5.3.2. \note the specification sais it is an enumerated value. - uint8_t filterCoefficient; -} UL_POWER_CONTROL_DEDICATED; - -#ifndef OCP_FRAMEWORK -/// Enumeration for parameter \f$\alpha\f$ \ref UL_POWER_CONTROL_CONFIG_COMMON::alpha. -typedef enum { - al0=0, - al04=1, - al05=2, - al06=3, - al07=4, - al08=5, - al09=6, - al1=7 -} PUSCH_alpha_t; -#endif - -/// \note UNUSED -typedef enum { - deltaFm2=0, - deltaF0, - deltaF1, - deltaF2, - deltaF3, - deltaF5 -} deltaF_PUCCH_t; - -/// UplinkPowerControlCommon Information Element from 36.331 RRC spec \note this structure does not currently make use of \ref deltaFList_PUCCH_t. -typedef struct { - /// Parameter: \f$P_\text{0\_NOMINAL\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dBm. \vr{[-126..24]}\n This field is applicable for non-persistent scheduling, only. - int8_t p0_NominalPUSCH; - /// Parameter: \f$\alpha\f$, see TS 36.213 (5.1.1.1) \warning the enumeration values do not correspond to the given values in the specification (al04 should be 0.4, ...)! - PUSCH_alpha_t alpha; - /// Parameter: \f$P_\text{0\_NOMINAL\_PUCCH}\f$ See TS 36.213 (5.1.2.1), unit dBm. \vr{[-127..-96]} - int8_t p0_NominalPUCCH; - /// Parameter: \f$\Delta_\text{PREAMBLE\_Msg3}\f$ see TS 36.213 (5.1.1.1). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. - int8_t deltaPreambleMsg3; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format1; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format1a; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format1b; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2, see TS 36.213 (5.1.2). \vr{[0..3]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format2; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format2a; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format2b; -} UL_POWER_CONTROL_CONFIG_COMMON; - -/// Union for \ref TPC_PDCCH_CONFIG::tpc_Index. -typedef union { - /// Index of N when DCI format 3 is used. See TS 36.212 (5.3.3.1.6). \vr{[1..15]} - uint8_t indexOfFormat3; - /// Index of M when DCI format 3A is used. See TS 36.212 (5.3.3.1.7). \vr{[1..31]} - uint8_t indexOfFormat3A; -} TPC_INDEX_t; - -/// TPC-PDCCH-Config Information Element from 36.331 RRC spec -typedef struct { - /// RNTI for power control using DCI format 3/3A, see TS 36.212. \vr{[0..65535]} - uint16_t rnti; - /// Index of N or M, see TS 36.212 (5.3.3.1.6 and 5.3.3.1.7), where N or M is dependent on the used DCI format (i.e. format 3 or 3a). - TPC_INDEX_t tpc_Index; -} TPC_PDCCH_CONFIG; - -/// Enumeration for parameter SR transmission \ref SCHEDULING_REQUEST_CONFIG::dsr_TransMax. -typedef enum { - sr_n4=0, - sr_n8=1, - sr_n16=2, - sr_n32=3, - sr_n64=4 -} DSR_TRANSMAX_t; - -/// SchedulingRequestConfig Information Element from 36.331 RRC spec -typedef struct { - /// Parameter: \f$n^{(1)}_\text{PUCCH,SRI}\f$, see TS 36.213 (10.1). \vr{[0..2047]} - uint16_t sr_PUCCH_ResourceIndex; - /// Parameter: \f$I_\text{SR}\f$, see TS 36.213 (10.1). \vr{[0..155]} - uint8_t sr_ConfigIndex; - /// Parameter for SR transmission in TS 36.321 (5.4.4). \details The value n4 corresponds to 4 transmissions, n8 corresponds to 8 transmissions and so on. - DSR_TRANSMAX_t dsr_TransMax; -} SCHEDULING_REQUEST_CONFIG; - -/// CQI-ReportPeriodic -typedef struct { - /// Parameter: \f$n^{(2)}_\text{PUCCH}\f$, see TS 36.213 (7.2). \vr{[0..1185]}, -1 indicates inactivity - int16_t cqi_PUCCH_ResourceIndex; - /// Parameter: CQI/PMI Periodicity and Offset Configuration Index \f$I_\text{CQI/PMI}\f$, see TS 36.213 (tables 7.2.2-1A and 7.2.2-1C). \vr{[0..1023]} - int16_t cqi_PMI_ConfigIndex; - /// Parameter: K, see 36.213 (4.2.2). \vr{[1..4]} - uint8_t K; - /// Parameter: RI Config Index \f$I_\text{RI}\f$, see TS 36.213 (7.2.2-1B). \vr{[0..1023]}, -1 indicates inactivity - int16_t ri_ConfigIndex; - /// Parameter: Simultaneous-AN-and-CQI, see TS 36.213 (10.1). \vr{[0..1]} 1 indicates that simultaneous transmission of ACK/NACK and CQI is allowed. - uint8_t simultaneousAckNackAndCQI; - /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C - uint16_t Npd; - /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C - uint16_t N_OFFSET_CQI; -} CQI_REPORTPERIODIC; - -/// Enumeration for parameter reporting mode \ref CQI_REPORT_CONFIG::cqi_ReportModeAperiodic. -typedef enum { - rm12=0, - rm20=1, - rm22=2, - rm30=3, - rm31=4 -} CQI_REPORTMODEAPERIODIC; - -/// CQI-ReportConfig Information Element from 36.331 RRC spec -typedef struct { - /// Parameter: reporting mode. Value rm12 corresponds to Mode 1-2, rm20 corresponds to Mode 2-0, rm22 corresponds to Mode 2-2 etc. PUSCH reporting modes are described in TS 36.213 [23, 7.2.1]. - CQI_REPORTMODEAPERIODIC cqi_ReportModeAperiodic; - /// Parameter: \f$\Delta_\text{offset}\f$, see TS 36.213 (7.2.3). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. - int8_t nomPDSCH_RS_EPRE_Offset; - CQI_REPORTPERIODIC CQI_ReportPeriodic; -} CQI_REPORT_CONFIG; - -/// MBSFN-SubframeConfig Information Element from 36.331 RRC spec \note deviates from specification. -typedef struct { - /// MBSFN subframe occurance. \details Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. \note the specification sais it is an enumerated value {n1, n2, n4, n8, n16, n32}. - int radioframeAllocationPeriod; - /// MBSFN subframe occurance. \vr{[0..7]}\n Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. - int radioframeAllocationOffset; - /// oneFrame or fourFrames. \vr{[0..1]} - int fourFrames_flag; - /// Subframe configuration. \vr{[0..63]} (\ref fourFrames_flag == 0) or \vr{[0..16777215]} (\ref fourFrames_flag == 1) - /// \par fourFrames_flag == 0 - /// "1" denotes that the corresponding subframe is allocated for MBSFN. The following mapping applies:\n FDD: The first/leftmost bit defines the MBSFN allocation for subframe #1, the second bit for #2, third bit for #3 , fourth bit for #6, fifth bit for #7, sixth bit for #8.\n TDD: The first/leftmost bit defines the allocation for subframe #3, the second bit for #4, third bit for #7, fourth bit for #8, fifth bit for #9. Uplink subframes are not allocated. The last bit is not used. - /// \par fourFrames_flag == 1 - /// A bit-map indicating MBSFN subframe allocation in four consecutive radio frames, "1" denotes that the corresponding subframe is allocated for MBSFN. The bitmap is interpreted as follows:\n FDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #1, #2, #3 , #6, #7, and #8 in the sequence of the four radio-frames.\n TDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #3, #4, #7, #8, and #9 in the sequence of the four radio-frames. The last four bits are not used. Uplink subframes are not allocated. - int mbsfn_SubframeConfig; -} MBSFN_config_t; - -typedef struct { - /// Number of resource blocks (RB) in DL - uint8_t N_RB_DL; - /// Number of resource blocks (RB) in UL - uint8_t N_RB_UL; - /// EUTRA Band - uint8_t eutra_band; - /// DL carrier frequency - uint32_t dl_CarrierFreq; - /// UL carrier frequency - uint32_t ul_CarrierFreq; - /// TX attenuation - uint32_t att_tx; - /// RX attenuation - uint32_t att_rx; - /// total Number of Resource Block Groups: this is ceil(N_PRB/P) - uint8_t N_RBG; - /// Total Number of Resource Block Groups SubSets: this is P - uint8_t N_RBGS; - /// Cell ID - uint16_t Nid_cell; - /// MBSFN Area ID - uint16_t Nid_cell_mbsfn; - /// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP) - lte_prefix_type_t Ncp; - /// Cyclic Prefix for UL (0=Normal CP, 1=Extended CP) - lte_prefix_type_t Ncp_UL; - /// shift of pilot position in one RB - uint8_t nushift; - /// Frame type (0 FDD, 1 TDD) - lte_frame_type_t frame_type; - /// TDD subframe assignment (0-7) (default = 3) (254=RX only, 255=TX only) - uint8_t tdd_config; - /// TDD S-subframe configuration (0-9) - uint8_t tdd_config_S; - /// srs extra symbol flag for TDD - uint8_t srsX; - /// indicates if node is a UE (NODE=2) or eNB (PRIMARY_CH=0). - uint8_t node_id; - /// Indicator that 20 MHz channel uses 3/4 sampling frequency - uint8_t threequarter_fs; - /// Size of FFT - uint16_t ofdm_symbol_size; - /// Number of prefix samples in all but first symbol of slot - uint16_t nb_prefix_samples; - /// Number of prefix samples in first symbol of slot - uint16_t nb_prefix_samples0; - /// Carrier offset in FFT buffer for first RE in PRB0 - uint16_t first_carrier_offset; - /// Number of samples in a subframe - uint32_t samples_per_tti; - /// Number of OFDM/SC-FDMA symbols in one subframe (to be modified to account for potential different in UL/DL) - uint16_t symbols_per_tti; - /// Number of OFDM symbols in DL portion of S-subframe - uint16_t dl_symbols_in_S_subframe; - /// Number of SC-FDMA symbols in UL portion of S-subframe - uint16_t ul_symbols_in_S_subframe; - /// Number of Physical transmit antennas in node - uint8_t nb_antennas_tx; - /// Number of Receive antennas in node - uint8_t nb_antennas_rx; - /// Number of common transmit antenna ports in eNodeB (1 or 2) - uint8_t nb_antenna_ports_eNB; - /// PRACH_CONFIG - PRACH_CONFIG_COMMON prach_config_common; -#ifdef Rel14 - /// PRACH_eMTC_CONFIG - PRACH_eMTC_CONFIG_COMMON prach_emtc_config_common; -#endif - /// PUCCH Config Common (from 36-331 RRC spec) - PUCCH_CONFIG_COMMON pucch_config_common; - /// PDSCH Config Common (from 36-331 RRC spec) - PDSCH_CONFIG_COMMON pdsch_config_common; - /// PUSCH Config Common (from 36-331 RRC spec) - PUSCH_CONFIG_COMMON pusch_config_common; - /// PHICH Config (from 36-331 RRC spec) - PHICH_CONFIG_COMMON phich_config_common; - /// SRS Config (from 36-331 RRC spec) - SOUNDINGRS_UL_CONFIG_COMMON soundingrs_ul_config_common; - /// UL Power Control (from 36-331 RRC spec) - UL_POWER_CONTROL_CONFIG_COMMON ul_power_control_config_common; - /// Number of MBSFN Configurations - int num_MBSFN_config; - /// Array of MBSFN Configurations (max 8 (maxMBSFN-Allocations) elements as per 36.331) - MBSFN_config_t MBSFN_config[8]; - /// Maximum Number of Retransmissions of RRCConnectionRequest (from 36-331 RRC Spec) - uint8_t maxHARQ_Msg3Tx; - /// Size of SI windows used for repetition of one SI message (in frames) - uint8_t SIwindowsize; - /// Period of SI windows used for repetition of one SI message (in frames) - uint16_t SIPeriod; - /// REGs assigned to PCFICH - uint16_t pcfich_reg[4]; - /// Index of first REG assigned to PCFICH - uint8_t pcfich_first_reg_idx; - /// REGs assigned to PHICH - uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; - - struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[MAX_MBSFN_AREA]; - -} LTE_DL_FRAME_PARMS; - -typedef enum { - /// TM1 - SISO=0, - /// TM2 - ALAMOUTI=1, - /// TM3 - LARGE_CDD=2, - /// the next 6 entries are for TM5 - UNIFORM_PRECODING11=3, - UNIFORM_PRECODING1m1=4, - UNIFORM_PRECODING1j=5, - UNIFORM_PRECODING1mj=6, - PUSCH_PRECODING0=7, - PUSCH_PRECODING1=8, - /// the next 3 entries are for TM4 - DUALSTREAM_UNIFORM_PRECODING1=9, - DUALSTREAM_UNIFORM_PRECODINGj=10, - DUALSTREAM_PUSCH_PRECODING=11, - TM7=12, - TM8=13, - TM9_10=14 -} MIMO_mode_t; - - -typedef enum { - /// MRT - MRT=0, - /// ZF - ZF=1, - /// MMSE - MMSE=2 -} PRECODE_TYPE_t; - -typedef struct { - /// \brief Pointers (dynamic) to the received data in the time domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ - int32_t **rxdata; - /// \brief Pointers (dynamic) to the received data in the frequency domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ - int32_t **rxdataF; - /// \brief holds the transmit data in the frequency domain. - /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //? - /// - first index: eNB id [0..2] (hard coded) - /// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports. - /// - third index: sample [0..] - int32_t **txdataF; -} LTE_eNB_COMMON; typedef struct { /// \brief Holds the transmit data in the frequency domain. @@ -725,567 +73,9 @@ typedef struct { int32_t **tdd_calib_coeffs; } RU_COMMON; -typedef enum {format0, - format1, - format1A, - format1B, - format1C, - format1D, - format1E_2A_M10PRB, - format2, - format2A, - format2B, - format2C, - format2D, - format3, - format3A, - format4, - format5, - format6_0A, - format6_0B, - format6_1A, - format6_1B, - format6_2 - } DCI_format_t; - -typedef struct { - /// Length of DCI in bits - uint8_t dci_length; - /// Aggregation level - uint8_t L; - /// Position of first CCE of the dci - int firstCCE; - /// flag to indicate that this is a RA response - boolean_t ra_flag; - /// rnti - rnti_t rnti; - /// harq_pid - rnti_t harq_pid; - /// Format - DCI_format_t format; - /// DCI pdu - uint8_t dci_pdu[8]; -} DCI_ALLOC_t; - -#define MAX_EPDCCH_PRB 8 - -typedef struct { - /// Length of DCI in bits - uint8_t dci_length; - /// Aggregation level - uint8_t L; - /// Position of first CCE of the dci - int firstCCE; - /// flag to indicate that this is a RA response - boolean_t ra_flag; - /// rnti - rnti_t rnti; - /// Format - DCI_format_t format; - /// epdcch resource assignment (0=localized,1=distributed) - uint8_t epdcch_resource_assignment_flag; - /// epdcch index - uint16_t epdcch_id; - /// epdcch start symbol - uint8_t epdcch_start_symbol; - /// epdcch number of PRBs in set - uint8_t epdcch_num_prb; - /// vector of prb ids for set - uint8_t epdcch_prb_index[MAX_EPDCCH_PRB]; - /// LBT parameter for frame configuration - uint8_t dwpts_symbols; - /// LBT parameter for frame configuration - uint8_t initial_lbt_sf; - /// DCI pdu - uint8_t dci_pdu[8]; -} eDCI_ALLOC_t; - -typedef struct { - /// Length of DCI in bits - uint8_t dci_length; - /// Aggregation level - uint8_t L; - /// Position of first CCE of the dci - int firstCCE; - /// flag to indicate that this is a RA response - boolean_t ra_flag; - /// rnti - rnti_t rnti; - /// Format - DCI_format_t format; - /// harq process index - uint8_t harq_pid; - /// Narrowband index - uint8_t narrowband; - /// number of PRB pairs for MPDCCH - uint8_t number_of_prb_pairs; - /// mpdcch resource assignment (combinatorial index r) - uint8_t resource_block_assignment; - /// transmission type (0=localized,1=distributed) - uint8_t transmission_type; - /// mpdcch start symbol - uint8_t start_symbol; - /// CE mode (1=ModeA,2=ModeB) - uint8_t ce_mode; - /// 0-503 n_EPDCCHid_i - uint16_t dmrs_scrambling_init; - /// Absolute subframe of the initial transmission (0-10239) - uint16_t i0; - /// number of mdpcch repetitions - uint16_t reps; - /// current absolute subframe number - uint16_t absSF; - /// DCI pdu - uint8_t dci_pdu[8]; -} mDCI_ALLOC_t; - - -typedef struct { - uint8_t num_dci; - uint8_t num_pdcch_symbols; - DCI_ALLOC_t dci_alloc[32]; -} LTE_eNB_PDCCH; - -typedef struct { - uint8_t hi; - uint8_t first_rb; - uint8_t n_DMRS; -} phich_config_t; - -typedef struct { - uint8_t num_hi; - phich_config_t config[32]; -} LTE_eNB_PHICH; - -typedef struct { - uint8_t num_dci; - eDCI_ALLOC_t edci_alloc[32]; -} LTE_eNB_EPDCCH; - -typedef struct { - /// number of active MPDCCH allocations - uint8_t num_dci; - /// MPDCCH DCI allocations from MAC - mDCI_ALLOC_t mdci_alloc[32]; - // MAX SIZE of an EPDCCH set is 16EREGs * 9REs/EREG * 8 PRB pairs = 2304 bits - uint8_t e[2304]; -} LTE_eNB_MPDCCH; - - -typedef struct { - /// \brief Hold the channel estimates in frequency domain based on SRS. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..ofdm_symbol_size[ - int32_t **srs_ch_estimates; - /// \brief Hold the channel estimates in time domain based on SRS. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size[ - int32_t **srs_ch_estimates_time; - /// \brief Holds the SRS for channel estimation at the RX. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..ofdm_symbol_size[ - int32_t *srs; -} LTE_eNB_SRS; - -typedef struct { - /// \brief Holds the received data in the frequency domain for the allocated RBs in repeated format. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size[ - int32_t **rxdataF_ext; - /// \brief Holds the received data in the frequency domain for the allocated RBs in normal format. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index (definition from phy_init_lte_eNB()): ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **rxdataF_ext2; - /// \brief Hold the channel estimates in time domain based on DRS. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..4*ofdm_symbol_size[ - int32_t **drs_ch_estimates_time; - /// \brief Hold the channel estimates in frequency domain based on DRS. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **drs_ch_estimates; - /// \brief Holds the compensated signal. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **rxdataF_comp; - /// \brief Magnitude of the UL channel estimates. Used for 2nd-bit level thresholds in LLR computation - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **ul_ch_mag; - /// \brief Magnitude of the UL channel estimates scaled for 3rd bit level thresholds in LLR computation - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **ul_ch_magb; - /// measured RX power based on DRS - int ulsch_power[2]; - /// \brief llr values. - /// - first index: ? [0..1179743] (hard coded) - int16_t *llr; -} LTE_eNB_PUSCH; - -typedef struct { - - /// \brief Holds the received data in the frequency domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: symbol [0..28*ofdm_symbol_size[ - int32_t **rxdataF; - - /// \brief Hold the channel estimates in frequency domain. - /// - first index: eNB id [0..6] (hard coded) - /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - third index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ - int32_t **dl_ch_estimates[7]; - - /// \brief Hold the channel estimates in time domain (used for tracking). - /// - first index: eNB id [0..6] (hard coded) - /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - third index: samples? [0..2*ofdm_symbol_size[ - int32_t **dl_ch_estimates_time[7]; -}LTE_UE_COMMON_PER_THREAD; - -typedef struct { - /// \brief Holds the transmit data in time domain. - /// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER. - /// - first index: tx antenna [0..nb_antennas_tx[ - /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES[ - int32_t **txdata; - /// \brief Holds the transmit data in the frequency domain. - /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. - /// - first index: tx antenna [0..nb_antennas_tx[ - /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX[ - int32_t **txdataF; - - /// \brief Holds the received data in time domain. - /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES+2048[ - int32_t **rxdata; - - LTE_UE_COMMON_PER_THREAD common_vars_rx_data_per_thread[RX_NB_TH_MAX]; - - /// holds output of the sync correlator - int32_t *sync_corr; - /// estimated frequency offset (in radians) for all subcarriers - int32_t freq_offset; - /// eNb_id user is synched to - int32_t eNb_id; -} LTE_UE_COMMON; - -typedef struct { - /// \brief Received frequency-domain signal after extraction. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_ext; - /// \brief Received frequency-domain ue specific pilots. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..12*N_RB_DL[ - int32_t **rxdataF_uespec_pilots; - /// \brief Received frequency-domain signal after extraction and channel compensation. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_comp0; - /// \brief Received frequency-domain signal after extraction and channel compensation for the second stream. For the SIC receiver we need to store the history of this for each harq process and round - /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid - /// - second index: ? [0..7] (hard coded) accessed via \c round - /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - fourth index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_comp1[8][8]; - /// \brief Downlink channel estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_estimates_ext; - /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. For the SIC receiver we need to store the history of this for each harq process and round - /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid - /// - second index: ? [0..7] (hard coded) accessed via \c round - /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - fourth index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_rho_ext[8][8]; - /// \brief Downlink beamforming channel estimates in frequency domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ - int32_t **dl_bf_ch_estimates; - /// \brief Downlink beamforming channel estimates. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_bf_ch_estimates_ext; - /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_rho2_ext; - /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. - /// - first index: ressource block [0..N_RB_DL[ - uint8_t *pmi_ext; - /// \brief Magnitude of Downlink Channel first layer (16QAM level/First 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_mag0; - /// \brief Magnitude of Downlink Channel second layer (16QAM level/First 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_mag1[8][8]; - /// \brief Magnitude of Downlink Channel, first layer (2nd 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_magb0; - /// \brief Magnitude of Downlink Channel second layer (2nd 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_magb1[8][8]; - /// \brief Cross-correlation of two eNB signals. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: symbol [0..] - int32_t **rho; - /// never used... always send dl_ch_rho_ext instead... - int32_t **rho_i; - /// \brief Pointers to llr vectors (2 TBs). - /// - first index: ? [0..1] (hard coded) - /// - second index: ? [0..1179743] (hard coded) - int16_t *llr[2]; - /// \f$\log_2(\max|H_i|^2)\f$ - int16_t log2_maxh; - /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer1 channel compensation - int16_t log2_maxh0; - /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer2 channel commpensation - int16_t log2_maxh1; - /// \brief LLR shifts for subband scaling. - /// - first index: ? [0..168*N_RB_DL[ - uint8_t *llr_shifts; - /// \brief Pointer to LLR shifts. - /// - first index: ? [0..168*N_RB_DL[ - uint8_t *llr_shifts_p; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128_2ndstream; - //uint32_t *rb_alloc; - //uint8_t Qm[2]; - //MIMO_mode_t mimo_mode; - // llr offset per ofdm symbol - uint32_t llr_offset[14]; - // llr length per ofdm symbol - uint32_t llr_length[14]; -} LTE_UE_PDSCH; - -typedef struct { - /// \brief Received frequency-domain signal after extraction. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - int32_t **rxdataF_ext; - /// \brief Received frequency-domain signal after extraction and channel compensation. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - double **rxdataF_comp; - /// \brief Downlink channel estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - int32_t **dl_ch_estimates_ext; - /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - double **dl_ch_rho_ext; - /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. - /// - first index: ressource block [0..N_RB_DL[ - uint8_t *pmi_ext; - /// \brief Magnitude of Downlink Channel (16QAM level/First 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - double **dl_ch_mag; - /// \brief Magnitude of Downlink Channel (2nd 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - double **dl_ch_magb; - /// \brief Cross-correlation of two eNB signals. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..] - double **rho; - /// never used... always send dl_ch_rho_ext instead... - double **rho_i; - /// \brief Pointers to llr vectors (2 TBs). - /// - first index: ? [0..1] (hard coded) - /// - second index: ? [0..1179743] (hard coded) - int16_t *llr[2]; - /// \f$\log_2(\max|H_i|^2)\f$ - uint8_t log2_maxh; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128; - //uint32_t *rb_alloc; - //uint8_t Qm[2]; - //MIMO_mode_t mimo_mode; -} LTE_UE_PDSCH_FLP; - -typedef struct { - /// \brief Pointers to extracted PDCCH symbols in frequency-domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_ext; - /// \brief Pointers to extracted and compensated PDCCH symbols in frequency-domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **rxdataF_comp; - /// \brief Pointers to extracted channel estimates of PDCCH symbols. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_estimates_ext; - /// \brief Pointers to channel cross-correlation vectors for multi-eNB detection. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_DL[ - int32_t **dl_ch_rho_ext; - /// \brief Pointers to channel cross-correlation vectors for multi-eNB detection. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..] - int32_t **rho; - /// \brief Pointer to llrs, 4-bit resolution. - /// - first index: ? [0..48*N_RB_DL[ - uint16_t *llr; - /// \brief Pointer to llrs, 16-bit resolution. - /// - first index: ? [0..96*N_RB_DL[ - uint16_t *llr16; - /// \brief \f$\overline{w}\f$ from 36-211. - /// - first index: ? [0..48*N_RB_DL[ - uint16_t *wbar; - /// \brief PDCCH/DCI e-sequence (input to rate matching). - /// - first index: ? [0..96*N_RB_DL[ - int8_t *e_rx; - /// number of PDCCH symbols in current subframe - uint8_t num_pdcch_symbols; - /// Allocated CRNTI for UE - uint16_t crnti; - /// 1: the allocated crnti is Temporary C-RNTI / 0: otherwise - uint8_t crnti_is_temporary; - /// Total number of PDU errors (diagnostic mode) - uint32_t dci_errors; - /// Total number of PDU received - uint32_t dci_received; - /// Total number of DCI False detection (diagnostic mode) - uint32_t dci_false; - /// Total number of DCI missed (diagnostic mode) - uint32_t dci_missed; - /// nCCE for PUCCH per subframe - uint8_t nCCE[10]; - //Check for specific DCIFormat and AgregationLevel - uint8_t dciFormat; - uint8_t agregationLevel; -} LTE_UE_PDCCH; - -#define PBCH_A 24 -typedef struct { - uint8_t pbch_d[96+(3*(16+PBCH_A))]; - uint8_t pbch_w[3*3*(16+PBCH_A)]; - uint8_t pbch_e[1920]; -} LTE_eNB_PBCH; - -typedef struct { - /// \brief Pointers to extracted PBCH symbols in frequency-domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..287] (hard coded) - int32_t **rxdataF_ext; - /// \brief Pointers to extracted and compensated PBCH symbols in frequency-domain. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..287] (hard coded) - int32_t **rxdataF_comp; - /// \brief Pointers to downlink channel estimates in frequency-domain extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..287] (hard coded) - int32_t **dl_ch_estimates_ext; - /// \brief Pointer to PBCH llrs. - /// - first index: ? [0..1919] (hard coded) - int8_t *llr; - /// \brief Pointer to PBCH decoded output. - /// - first index: ? [0..63] (hard coded) - uint8_t *decoded_output; - /// \brief Total number of PDU errors. - uint32_t pdu_errors; - /// \brief Total number of PDU errors 128 frames ago. - uint32_t pdu_errors_last; - /// \brief Total number of consecutive PDU errors. - uint32_t pdu_errors_conseq; - /// \brief FER (in percent) . - uint32_t pdu_fer; -} LTE_UE_PBCH; - -typedef struct { - int16_t amp; - int16_t *prachF; - int16_t *prach; -} LTE_UE_PRACH; - -#define MAX_NUM_RX_PRACH_PREAMBLES 4 - -typedef struct { - /// \brief ?. - /// first index: ? [0..1023] (hard coded) - int16_t *prachF; - /// \brief ?. - /// first index: ce_level [0..3] - /// second index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. - /// third index: frequency-domain sample [0..ofdm_symbol_size*12[ - int16_t **rxsigF[4]; - /// \brief local buffer to compute prach_ifft (necessary in case of multiple CCs) - /// first index: ce_level [0..3] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. - /// second index: ? [0..63] (hard coded) - /// third index: ? [0..63] (hard coded) - int32_t **prach_ifft[4]; - - /// repetition number -#ifdef Rel14 - /// indicator of first frame in a group of PRACH repetitions - int first_frame[4]; - /// current repetition for each CE level - int repetition_number[4]; -#endif -} LTE_eNB_PRACH; - -typedef struct { - /// Preamble index for PRACH (0-63) - uint8_t ra_PreambleIndex; - /// RACH MaskIndex - uint8_t ra_RACH_MaskIndex; - /// Target received power at eNB (-120 ... -82 dBm) - int8_t ra_PREAMBLE_RECEIVED_TARGET_POWER; - /// PRACH index for TDD (0 ... 6) depending on TDD configuration and prachConfigIndex - uint8_t ra_TDD_map_index; - /// Corresponding RA-RNTI for UL-grant - uint16_t ra_RNTI; - /// Pointer to Msg3 payload for UL-grant - uint8_t *Msg3; -} PRACH_RESOURCES_t; - - -typedef struct { - /// Downlink Power offset field - uint8_t dl_pow_off; - ///Subband resource allocation field - uint8_t rballoc_sub[50]; - ///Total number of PRBs indicator - uint8_t pre_nb_available_rbs; -} MU_MIMO_mode; - -typedef enum { - NOT_SYNCHED=0, - PRACH=1, - RA_RESPONSE=2, - PUSCH=3, - RESYNCH=4 -} UE_MODE_t; -typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; -typedef enum { - /// do not detect any DCIs in the current subframe - NO_DCI = 0x0, - /// detect only downlink DCIs in the current subframe - UL_DCI = 0x1, - /// detect only uplink DCIs in the current subframe - DL_DCI = 0x2, - /// detect both uplink and downlink DCIs in the current subframe - UL_DL_DCI = 0x3} dci_detect_mode_t; #endif diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index c3ab134d87ff88579df89773b26509cc6d239710..8b31b601621d59e7121ad6f9805b1efe402255c7 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -107,7 +107,7 @@ * @} */ -#include "defs.h" +#include "defs_eNB.h" #include "types.h" @@ -277,8 +277,43 @@ typedef struct { #define MAX_FRAME_NUMBER 0x400 #include "openairinterface5g_limits.h" - - +#include "assertions.h" + +#define cmax(a,b) ((a>b) ? (a) : (b)) +#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) +#define cmin(a,b) ((a<b) ? (a) : (b)) +#define max(a,b) cmax(a,b) +#define min(a,b) cmin(a,b) + +#ifndef malloc16 +# ifdef __AVX2__ +# define malloc16(x) memalign(32,x) +# else +# define malloc16(x) memalign(16,x) +# endif +#endif +#define free16(y,x) free(y) +#define bigmalloc malloc +#define bigmalloc16 malloc16 +#define openair_free(y,x) free((y)) +#define PAGE_SIZE 4096 +#define free_and_zero(PtR) do { \ + if (PtR) { \ + free(PtR); \ + PtR = NULL; \ + } \ + } while (0) +static inline void* malloc16_clear( size_t size ) +{ +#ifdef __AVX2__ + void* ptr = memalign(32, size); +#else + void* ptr = memalign(16, size); +#endif + DevAssert(ptr); + memset( ptr, 0, size ); + return ptr; +} #endif //__PHY_IMPLEMENTATION_DEFS_H__ /**@} diff --git a/openair1/PHY/extern.h b/openair1/PHY/phy_extern.h similarity index 93% rename from openair1/PHY/extern.h rename to openair1/PHY/phy_extern.h index 5868c1c0221ce345d81aa10267d76bfe211be1a2..4cb3cc538f91a06f55cd7705fefbb4c35dac9c81 100644 --- a/openair1/PHY/extern.h +++ b/openair1/PHY/phy_extern.h @@ -22,7 +22,7 @@ #ifndef __PHY_EXTERN_H__ #define __PHY_EXTERN_H__ -#include "PHY/defs.h" +#include "PHY/defs_common.h" #include "common/ran_context.h" extern char* namepointer_chMag ; @@ -32,23 +32,21 @@ extern char fmageren_name2[512]; extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX]; extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; -#include "PHY/LTE_TRANSPORT/extern.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" +#include "PHY/LTE_TRANSPORT/transport_extern.h" +//#include "SIMULATION/ETH_TRANSPORT/extern.h" extern unsigned int DAQ_MBOX; extern int number_of_cards; #ifndef OCP_FRAMEWORK -extern PHY_VARS_UE ***PHY_vars_UE_g; //extern PHY_VARS_eNB ***PHY_vars_eNB_g; extern RAN_CONTEXT_t RC; -extern PHY_VARS_RN **PHY_vars_RN_g; extern LTE_DL_FRAME_PARMS *lte_frame_parms_g; #else #define MAX_UE 10 #define MAX_eNB 20 -extern PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]; + extern PHY_VARS_eNB * PHY_vars_eNB_g[MAX_eNB][MAX_NUM_CCs]; #endif @@ -70,7 +68,7 @@ extern int flagMag; extern char mode_string[4][20]; -#include "PHY/LTE_TRANSPORT/extern.h" + extern unsigned char NB_RU; diff --git a/openair1/PHY/phy_extern_ue.h b/openair1/PHY/phy_extern_ue.h new file mode 100644 index 0000000000000000000000000000000000000000..98dbfb886e858da98de2d418d7afb7a84dd6b859 --- /dev/null +++ b/openair1/PHY/phy_extern_ue.h @@ -0,0 +1,124 @@ +/* + * 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_EXTERN_UE__H__ +#define __PHY_EXTERN_UE__H__ + +#include "PHY/defs_UE.h" +#include "common/ran_context.h" + +extern char* namepointer_chMag ; +extern char* namepointer_log2; +extern char fmageren_name2[512]; + +extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX]; +extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; + +#include "PHY/LTE_TRANSPORT/transport_extern.h" + +extern int number_of_cards; + + +#ifndef OCP_FRAMEWORK +extern PHY_VARS_UE ***PHY_vars_UE_g; +extern LTE_DL_FRAME_PARMS *lte_frame_parms_g; +#else +#define MAX_UE 10 +#define MAX_eNB 20 + +extern PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]; +#endif + +extern short primary_synch0[144]; +extern short primary_synch1[144]; +extern short primary_synch2[144]; +extern unsigned char primary_synch0_tab[72]; +extern unsigned char primary_synch1_tab[72]; +extern unsigned char primary_synch2_tab[72]; +extern int16_t *primary_synch0_time; //!< index: [0..ofdm_symbol_size*2[ +extern int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[ +extern int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[ +extern int *sync_corr_ue0; //!< index [0..10*samples_per_tti[ +extern int *sync_corr_ue1; //!< index [0..10*samples_per_tti[ +extern int *sync_corr_ue2; //!< index [0..10*samples_per_tti[ + +extern int flagMag; +//extern short **txdataF_rep_tmp; + +extern char mode_string[4][20]; + +extern unsigned char NB_RU; + +#ifndef OPENAIR2 +extern unsigned char NB_eNB_INST; +extern unsigned char NB_UE_INST; +extern unsigned char NB_RN_INST; +#endif + +extern unsigned int ULSCH_max_consecutive_errors; +extern int flag_LA; +extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX]; +extern double sinr_bler_map_up[MCS_COUNT][2][16]; +extern int table_length[MCS_COUNT]; +extern double sinr_to_cqi[4][16]; +extern int cqi_to_mcs[16]; + +//for MU-MIMO abstraction using MIESM +//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively +extern double MI_map_4qam[3][162]; +extern double MI_map_16qam[3][197]; +extern double MI_map_64qam[3][227]; + +extern double beta1_dlsch_MI[6][MCS_COUNT]; +extern double beta2_dlsch_MI[6][MCS_COUNT]; + +extern double q_qpsk[8]; +extern double q_qam16[8]; +extern double q_qam64[8]; + +extern double p_qpsk[8]; +extern double p_qam16[8]; +extern double p_qam64[8]; + +extern double beta1_dlsch[6][MCS_COUNT]; +extern double beta2_dlsch[6][MCS_COUNT]; + +extern char eNB_functions[6][20]; +extern char eNB_timing[2][20]; +extern char ru_if_types[MAX_RU_IF_TYPES][20]; + +extern int16_t unscrambling_lut[65536*16]; +extern uint8_t scrambling_lut[65536*16]; + +extern unsigned short msrsb_6_40[8][4]; +extern unsigned short msrsb_41_60[8][4]; +extern unsigned short msrsb_61_80[8][4]; +extern unsigned short msrsb_81_110[8][4]; +extern unsigned short Nb_6_40[8][4]; +extern unsigned short Nb_41_60[8][4]; +extern unsigned short Nb_61_80[8][4]; +extern unsigned short Nb_81_110[8][4]; + +extern uint16_t hundred_times_log10_NPRB[100]; +extern uint8_t alpha_lut[8]; +extern uint8_t max_turbo_iterations; +#endif /*__PHY_EXTERN_H__ */ + diff --git a/openair1/PHY/vars.h b/openair1/PHY/phy_vars.h similarity index 98% rename from openair1/PHY/vars.h rename to openair1/PHY/phy_vars.h index e8f4e27de13e6c5c0c818b1a721981536f3f7b3b..783a151046871bb85ecd1ee129e43a1eedfb131d 100644 --- a/openair1/PHY/vars.h +++ b/openair1/PHY/phy_vars.h @@ -23,7 +23,8 @@ #define __PHY_VARS_H__ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "common/ran_context.h" char* namepointer_chMag ; @@ -37,7 +38,9 @@ int16_t *primary_synch1_time; int16_t *primary_synch2_time; -#include "PHY/CODING/vars.h" +#include "PHY/CODING/coding_vars.h" +#include "PHY/LTE_TRANSPORT/transport_vars.h" +#include "PHY/MODULATION/modulation_vars.h" //PHY_VARS *PHY_vars; #ifndef OCP_FRAMEWORK @@ -58,7 +61,7 @@ unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048] char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"}; -#include "PHY/LTE_TRANSPORT/vars.h" + diff --git a/openair1/PHY/phy_vars_ue.h b/openair1/PHY/phy_vars_ue.h new file mode 100644 index 0000000000000000000000000000000000000000..c323d1eade612f6a3173ba5848322fefa2f5d117 --- /dev/null +++ b/openair1/PHY/phy_vars_ue.h @@ -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 + */ + +#ifndef __PHY_VARS_H__ +#define __PHY_VARS_H__ + +#include "PHY/types.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_vars_ue.h" + +#include "common/ran_context.h" + +char* namepointer_chMag ; +char fmageren_name2[512]; +char* namepointer_log2; + + +#include "PHY/LTE_REFSIG/primary_synch.h" +int16_t *primary_synch0_time; +int16_t *primary_synch1_time; +int16_t *primary_synch2_time; + + +#include "PHY/CODING/coding_vars.h" + +//PHY_VARS *PHY_vars; +#ifndef OCP_FRAMEWORK +PHY_VARS_UE ***PHY_vars_UE_g; +LTE_DL_FRAME_PARMS *lte_frame_parms_g; +#else +PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL}; + +#endif + + +unsigned short rev[2048],rev_times4[8192],rev_half[1024]; +unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192]; + + +char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"}; + + + +#include "SIMULATION/ETH_TRANSPORT/vars.h" + +unsigned char NB_RU=0; + +#ifndef OPENAIR2 +unsigned char NB_eNB_INST=0; +unsigned char NB_UE_INST=0; +unsigned char NB_RN_INST=0; +unsigned char NB_INST=0; +#endif + +unsigned int ULSCH_max_consecutive_errors = 20; + +int number_of_cards; + + +int flag_LA=0; +int flagMag; +//extern channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; +//extern double ABS_SINR_eff_BLER_table[MCS_COUNT][9][9]; +//extern double ABS_beta[MCS_COUNT];odi +double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX]; +int table_length[MCS_COUNT]; +//double sinr_bler_map_up[MCS_COUNT][2][16]; + +//for MU-MIMO abstraction using MIESM +//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively +double MI_map_4qam[3][162]; +double MI_map_16qam[3][197]; +double MI_map_64qam[3][227]; + +// here the first index is for transmission mode 1, 2, 5 and 6 whereas the second index is for the 16 sinr vaues corresponding to 16 CQIs +double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, + {-2.2360, -2.2360, -1.3919, -0.0218, 1.5319, 2.9574, 4.3234, 6.3387, 8.9879, 9.5096, 12.6609, 14.0116, 16.4984, 18.1572, 18.1572, 18.1572}, + {-1, -1.0000, -0.4198, -0.0140, 1.0362, 2.3520, 3.5793, 6.1136, 8.4836, 9.0858, 12.4723, 13.9128, 16.2054, 17.7392, 17.7392, 17.7392}, + { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} +}; + +//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; +int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; + +//for SNR to MI conversion 7 th order Polynomial coeff +double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; +double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; +double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; + +//for MI to SNR conversion 7 th order Polynomial coeff +double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; +double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; +double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; + +// ideal CE MIESM + +double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; +double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; + +//real CE MIESM +/* +double beta1_dlsch_MI[6][MCS_COUNT] = { {1.32955, 0.59522, 0.54024, 0.98698, 0.81305, 0.76976, 0.69258, 0.69713, 0.70546, 0.69111, 0.81904, 0.72664, 0.79491, 0.72562, 0.53980, 0.33134, 0.50550, 0.40602,0.40281,0.47012,0.50510,0.23540,0.32045,1}, {0.59632, 1.08475, 1.02431, 1.07020, 0.90170, 0.97719, 0.95464, 0.92764, 0.86721, 0.85986, 0.64558, 0.80631, 0.82673, 0.82888, 0.87122, 0.77245, 0.29771, 0.43477, 0.55321, 0.61027, 0.56111, 0.57292, 0.39737,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.77532, 1.07544, 1.10571, 1.04099, 0.91638, 0.88644, 0.96405, 0.86709, 0.94066, 0.84430, 1.24478, 1.09665, 1.42604, 0.79541, 0.71847, 0.71604, 0.74561, 0.36431, 0.41536, 0.52175, 0.47096, 0.49977, 0.59728,1}}; +double beta2_dlsch_MI[6][MCS_COUNT] = { {1.36875, 0.59304, 0.53870, 0.98239, 0.81637, 0.76847, 0.69842, 0.69885, 0.69967, 0.69826, 0.82660, 0.70559, 0.78404, 0.70670, 0.55393, 0.36893, 0.52225, 0.39752, 0.40494, 0.46239, 0.49247,0.26900,0.34504,1}, {0.43775, 0.78208, 0.72875, 0.77458, 0.64485, 0.69174, 0.66097, 0.63289, 0.59652, 0.61175, 0.44551, 0.56047, 0.57314, 0.57553, 0.58849, 0.52159, 0.21241, 0.30139, 0.37373, 0.32029, 0.37067, 0.36706, 0.27118,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,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.54448, 0.73731, 0.79165, 0.74407, 0.68042, 0.64906, 0.71349, 0.62109, 0.65815, 0.60940, 0.90549, 0.78708, 1.03176, 0.58431, 0.53379, 0.51224, 0.52767, 0.26848, 0.29642, 0.36879, 0.34148, 0.35279,0.40633,1}}; +*/ +//ideal channel estimation values +//double beta1_dlsch[6][MCS_COUNT] = { {2.3814, 0.4956, 0.5273, 1.1708, 0.8014, 0.7889, 0.8111, 0.8139, 0.8124, 0.8479, 1.9280, 1.9664, 2.3857, 2.5147, 2.4511, 3.0158, 2.8643, 5.3013, 5.8594, 6.5372, 7.8073, 7.8030, 7.5295, 7.1320}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; +//double beta2_dlsch[6][MCS_COUNT] = { {2.3639, 0.4952, 0.5207, 1.1572, 0.8026, 0.7864, 0.7996, 0.8034, 0.8200, 0.8367, 1.8701, 1.9212, 2.2947, 2.4472, 2.4091, 2.9479, 2.8973, 5.0591, 5.5134, 6.1483, 7.2166, 7.5177, 7.5704, 7.2248}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; +double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; +double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; + +//real channel estimation valus +/* +double beta1_dlsch[6][MCS_COUNT] = { {2.50200, 0.84047, 0.78195, 1.37929, 1.16871, 1.11906, 1.06303, 1.07447, 1.11403, 1.09223, 2.82502, 2.87556, 3.51254, 3.62920, 3.53638, 2.35980, 3.74126, 8.66532, 7.31772, 9.86882, 10.64939, 6.75208, 9.50664, 13.63057}, {0.92257, 1, 1.80445, 1.43175, 1.42093, 1.37381, 1.45392, 1.47255, 1.47451, 1.41235, 3.9079, 3.38557, 4.13059, 4.93355, 4.97277, 6.04951, 5.88896, 8.68076, 10.23746, 12.37069, 5.50538, 17.29612, 17.95050, 13.27095}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79255, 1.88213, 4.44226, 2.25150, 1.93710, 2.18504, 2.57389, 1.94322, 1.78515, 2.09265, 2.37459, 1.74442, 1.74346, 1.19705, 1.56149, 1.59604, 1.6, 1,1,1,1,1,1,1}, {0.93374, 1.40389, 1.36670, 1.38679, 1.35707, 1.26353, 1.32360, 1.40164, 1.51843, 1.34863, 3.45839, 3.13726, 3.94768, 4.21966, 4.60750, 4.97894, 5.40755, 8.12814, 10.59221, 12.96427, 13.37323, 14.27206, 16.61779, 17.19656}}; +double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.16829, 1.11186, 1.06287, 1.07292, 1.09946, 1.10650, 2.79174, 2.75655, 3.36651, 3.49011, 3.60903, 2.73517, 3.84009, 8.20312, 7.41739, 9.64081, 10.40911, 8.11765, 10.41923, 9.34300}, {0.67252, 0.8600, 1.28633, 1.01624, 1.03066, 0.97590, 1.02560, 1.01840, 1.00547, 0.97093, 2.72573, 2.33283, 2.86181, 3.40452, 3.47957, 4.08916, 3.97628, 6.14541, 7.11017, 8.42369, 4.04812, 11.42082, 11.57171, 9.28462}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.85784, 0.90361, 2.09766, 1.08385, 0.96300, 1.04432, 1.22763, 0.99249, 0.95544, 1.12333, 1.37924, 1.12913, 1.30644, 1.19253, 1.75488, 2.13813, 2.10636, 1,1,1,1,1,1,1}, {0.66288, 0.96402, 0.98545, 0.99386, 0.99981, 0.92678, 0.98978, 0.99600, 1.05538, 0.97777, 2.52504, 2.29338, 2.89631, 3.10812, 3.41916, 3.58671, 3.84166, 6.05254, 7.45821, 9.15812, 9.66330, 10.17852, 11.50519, 11.16299}}; + +*/ + +#ifdef OCP_FRAMEWORK +#include <enums.h> +#else +char eNB_functions[6][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",}; +char eNB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; +char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; +#endif + +/// lookup table for unscrambling in RX +int16_t unscrambling_lut[65536*16] __attribute__((aligned(32))); +/// lookup table for scrambling in TX +uint8_t scrambling_lut[65536*16] __attribute__((aligned(32))); + +uint8_t max_turbo_iterations=4; +#endif /*__PHY_VARS_H__ */ diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index ea891aad770f414ca796157b96dd8e5c5c6e4712..a21b7e4832f6ca013f816971bfd48e6de0d793c6 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -30,10 +30,10 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" + #include "nfapi_interface.h" #include "nfapi_pnf_interface.h" #include "fapi_l1.h" diff --git a/openair1/SCHED/fapi_l1.h b/openair1/SCHED/fapi_l1.h index f04e8581dba863b9ede033cae45810df1ede99ea..efb028f46444b73cbed6df710faf6db75bcc4080 100644 --- a/openair1/SCHED/fapi_l1.h +++ b/openair1/SCHED/fapi_l1.h @@ -30,10 +30,11 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" +#include "SCHED/sched_common.h" #include "nfapi_interface.h" void fill_uci_harq_indication(PHY_VARS_eNB *eNB,LTE_eNB_UCI *uci,int frame,int subframe,uint8_t *harq_ack,uint8_t tdd_mapping_mode,uint16_t tdd_multiplexing_mask); diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index bbb6986ce9c7c3ac375e79eb170e5c4c77b2ab72..81679f199c64b506de424bfb20bcf03ababa2deb 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -29,10 +29,10 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" void get_Msg3_alloc(LTE_DL_FRAME_PARMS *frame_parms, unsigned char current_subframe, @@ -831,12 +831,7 @@ dci_detect_mode_t dci_detect_mode_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t return ret; } -lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe) -{ - - return(subframe_select(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe)); -} uint8_t phich_subframe_to_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) { @@ -1066,3 +1061,73 @@ void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeri } } + +// uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id, +int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs) +{ + + /// The payload + CRC size in bits, "B" + uint32_t B; + /// Number of code segments + uint32_t C; + /// Number of "small" code segments + uint32_t Cminus; + /// Number of "large" code segments + uint32_t Cplus; + /// Number of bits in "small" code segments (<6144) + uint32_t Kminus; + /// Number of bits in "large" code segments (<6144) + uint32_t Kplus; + /// Total number of bits across all segments + uint32_t sumKr; + /// Number of "Filler" bits + uint32_t F; + // num resource elements + uint32_t num_re=0.0; + // num symbols + uint32_t num_symb=0.0; + /// effective spectral efficiency of the PUSCH + uint32_t MPR_x100=0; + /// beta_offset + uint16_t beta_offset_pusch_x8=8; + /// delta mcs + float delta_mcs=0.0; + /// bandwidth factor + float bw_factor=0.0; + + B= tbs+24; + lte_segmentation(NULL, + NULL, + B, + &C, + &Cplus, + &Cminus, + &Kplus, + &Kminus, + &F); + + + sumKr = Cminus*Kminus + Cplus*Kplus; + num_symb = 12-(ncp<<1)-(use_srs==0?0:1); + num_re = num_symb * nb_rb * 12; + + if (num_re == 0) + return(0); + + MPR_x100 = 100*sumKr/num_re; + + if (control_only == 1 ) + beta_offset_pusch_x8=8; // fixme + + //(beta_offset_pusch_x8=ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; + + // if deltamcs_enabledm + delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0); + bw_factor = (hundred_times_log10_NPRB[nb_rb-1]/100.0); +#ifdef DEBUG_SEGMENTATION + printf("estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n", + (int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor); +#endif + return (int16_t)ceil(delta_mcs + bw_factor); + +} diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index ecdf8e5756d66d7b24575578a682d6056bb21001..233d4f06ef3d07925f285278f41d463114595b9a 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -30,10 +30,11 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" #include "nfapi_interface.h" #include "fapi_l1.h" #include "UTIL/LOG/log.h" @@ -51,16 +52,94 @@ #endif extern uint8_t nfapi_mode; + + + +int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor) +{ + + uint32_t Nre,sumKr,MPR_x100,Kr,r; + uint16_t beta_offset_pusch; + + DevAssert( UE_id < NUMBER_OF_UE_MAX+1 ); + DevAssert( harq_pid < 8 ); + + Nre = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_initial * + eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12; + + sumKr = 0; + + for (r=0; r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->C; r++) { + if (r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->Cminus) + Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kminus; + else + Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus; + + sumKr += Kr; + } + + if (Nre==0) + return(0); + + MPR_x100 = 100*sumKr/Nre; + // Note: MPR=is the effective spectral efficiency of the PUSCH + // FK 20140908 sumKr is only set after the ulsch_encoding + + beta_offset_pusch = 8; + //(eNB->ulsch[UE_id]->harq_processes[harq_pid]->control_only == 1) ? eNB->ulsch[UE_id]->beta_offset_cqi_times8:8; + + DevAssert( UE_id < NUMBER_OF_UE_MAX ); +//#warning "This condition happens sometimes. Need more investigation" // navid + //DevAssert( MPR_x100/6 < 100 ); + + if (1==1) { //eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { + // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) + if (bw_factor == 1) { + uint8_t nb_rb = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; + return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)) + hundred_times_log10_NPRB[nb_rb-1]; + } else + return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); + } else { + return(0); + } +} + + +int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid) +{ + + int8_t UE_id; + + if ((RC.eNB == NULL) || (module_idP > RC.nb_inst) || (CC_id > RC.nb_CC[module_idP])) { + LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",module_idP,CC_id); + return -1; + } + + UE_id = find_ulsch( rnti, RC.eNB[module_idP][CC_id],SEARCH_EXIST); + + if (UE_id == -1) { + // not found + return 0; + } + + return get_hundred_times_delta_IF_eNB( RC.eNB[module_idP][CC_id], UE_id, harq_pid, 0 ); +} + int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); +lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe) +{ -void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,PHY_VARS_RN *rn,relaying_type_t r_type) { + return(subframe_select(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe)); + +} + +void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { #if defined(Rel10) || defined(Rel14) MCH_PDU *mch_pduP=NULL; - MCH_PDU mch_pdu; // uint8_t sync_area=255; #endif @@ -84,50 +163,17 @@ void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,PHY_VARS_RN *rn,rel proc->frame_tx, subframe); */ - switch (r_type) { - case no_relay: - if ((mch_pduP->Pdu_size > 0) && (mch_pduP->sync_area == 0)) // TEST: only transmit mcch for sync area 0 - LOG_D(PHY,"[eNB%"PRIu8"] Frame %d subframe %d : Got MCH pdu for MBSFN (MCS %"PRIu8", TBS %d) \n", - eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->mcs, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - else { - LOG_D(PHY,"[DeNB %"PRIu8"] Frame %d subframe %d : Do not transmit MCH pdu for MBSFN sync area %"PRIu8" (%s)\n", - eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->sync_area, - (mch_pduP->Pdu_size == 0)? "Empty MCH PDU":"Let RN transmit for the moment"); - mch_pduP = NULL; - } - - break; - - case multicast_relay: - if ((mch_pduP->Pdu_size > 0) && ((mch_pduP->mcch_active == 1) || mch_pduP->msi_active==1)) { - LOG_D(PHY,"[RN %"PRIu8"] Frame %d subframe %d: Got the MCH PDU for MBSFN sync area %"PRIu8" (MCS %"PRIu8", TBS %"PRIu16")\n", - rn->Mod_id,rn->frame, subframe, - mch_pduP->sync_area,mch_pduP->mcs,mch_pduP->Pdu_size); - } else if (rn->mch_avtive[subframe%5] == 1) { // SF2 -> SF7, SF3 -> SF8 - mch_pduP= &mch_pdu; - memcpy(&mch_pduP->payload, // could be a simple copy - rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->b, - rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->TBS>>3); - mch_pduP->Pdu_size = (uint16_t) (rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->TBS>>3); - mch_pduP->mcs = rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->mcs; - LOG_D(PHY,"[RN %"PRIu8"] Frame %d subframe %d: Forward the MCH PDU for MBSFN received on SF %d sync area %"PRIu8" (MCS %"PRIu8", TBS %"PRIu16")\n", - rn->Mod_id,rn->frame, subframe,subframe%5, - rn->sync_area[subframe%5],mch_pduP->mcs,mch_pduP->Pdu_size); - } else { - mch_pduP=NULL; - } - - rn->mch_avtive[subframe]=0; - break; + if ((mch_pduP->Pdu_size > 0) && (mch_pduP->sync_area == 0)) // TEST: only transmit mcch for sync area 0 + LOG_D(PHY,"[eNB%"PRIu8"] Frame %d subframe %d : Got MCH pdu for MBSFN (MCS %"PRIu8", TBS %d) \n", + eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->mcs, + eNB->dlsch_MCH->harq_processes[0]->TBS>>3); + else { + LOG_D(PHY,"[DeNB %"PRIu8"] Frame %d subframe %d : Do not transmit MCH pdu for MBSFN sync area %"PRIu8" (%s)\n", + eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->sync_area, + (mch_pduP->Pdu_size == 0)? "Empty MCH PDU":"Let RN transmit for the moment"); + mch_pduP = NULL; + } - default: - LOG_W(PHY,"[eNB %"PRIu8"] Frame %d subframe %d: unknown relaying type %d \n", - eNB->Mod_id,proc->frame_tx,subframe,r_type); - mch_pduP=NULL; - break; - }// switch - if (mch_pduP) { fill_eNB_dlsch_MCH(eNB,mch_pduP->mcs,1,0); // Generate PMCH @@ -408,11 +454,8 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn, int do_meas) { - UNUSED(rn); int frame=proc->frame_tx; int subframe=proc->subframe_tx; uint32_t i,aa; @@ -443,7 +486,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, if (nfapi_mode == 0 || nfapi_mode == 1) { if (is_pmch_subframe(frame,subframe,fp)) { - pmch_procedures(eNB,proc,rn,r_type); + pmch_procedures(eNB,proc); } else { // this is not a pmch subframe, so generate PSS/SSS/PBCH @@ -1918,7 +1961,7 @@ void fill_crc_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type) +void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { //RX processing for ue-specific resources (i LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index 4730eed613198c04a2ced09ae6e6b6d3fc947fcc..772dff3bfdbe1b93fb76247df6bc3095351c01aa 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -30,10 +30,9 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" #include "nfapi_interface.h" #include "fapi_l1.h" #include "nfapi_pnf.h" diff --git a/openair1/SCHED/pusch_pc.c b/openair1/SCHED/pusch_pc.c deleted file mode 100644 index a631839bf581e128ed644b4313b018ac97cae485..0000000000000000000000000000000000000000 --- a/openair1/SCHED/pusch_pc.c +++ /dev/null @@ -1,280 +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 pusch_pc.c - * \brief Implementation of UE PUSCH Power Control procedures from 36.213 LTE specifications (Section - * \author R. Knopp - * \date 2011 - * \version 0.1 - * \company Eurecom - * \email: knopp@eurecom.fr - * \note - * \warning - */ - -#include "defs.h" -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/extern.h" - -extern uint8_t nfapi_mode; - -// This is the formula from Section 5.1.1.1 in 36.213 100*10*log10((2^(MPR*Ks)-1)), where MPR is in the range [0,6] and Ks=1.25 -int16_t hundred_times_delta_TF[100] = {-32768,-1268,-956,-768,-631,-523,-431,-352,-282,-219,-161,-107,-57,-9,36,79,120,159,197,234,269,304,337,370,402,434,465,495,525,555,583,612,640,668,696,723,750,777,803,829,856,881,907,933,958,983,1008,1033,1058,1083,1108,1132,1157,1181,1205,1229,1254,1278,1302,1325,1349,1373,1397,1421,1444,1468,1491,1515,1538,1562,1585,1609,1632,1655,1679,1702,1725,1748,1772,1795,1818,1841,1864,1887,1910,1933,1956,1980,2003,2026,2049,2072,2095,2118,2141,2164,2186,2209,2232,2255}; -uint16_t hundred_times_log10_NPRB[100] = {0,301,477,602,698,778,845,903,954,1000,1041,1079,1113,1146,1176,1204,1230,1255,1278,1301,1322,1342,1361,1380,1397,1414,1431,1447,1462,1477,1491,1505,1518,1531,1544,1556,1568,1579,1591,1602,1612,1623,1633,1643,1653,1662,1672,1681,1690,1698,1707,1716,1724,1732,1740,1748,1755,1763,1770,1778,1785,1792,1799,1806,1812,1819,1826,1832,1838,1845,1851,1857,1863,1869,1875,1880,1886,1892,1897,1903,1908,1913,1919,1924,1929,1934,1939,1944,1949,1954,1959,1963,1968,1973,1977,1982,1986,1991,1995,2000}; - -int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor) -{ - - uint32_t Nre,sumKr,MPR_x100,Kr,r; - uint16_t beta_offset_pusch; - - DevAssert( UE_id < NUMBER_OF_UE_MAX+1 ); - DevAssert( harq_pid < 8 ); - - Nre = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_initial * - eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12; - - sumKr = 0; - - for (r=0; r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->C; r++) { - if (r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->Cminus) - Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kminus; - else - Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus; - - sumKr += Kr; - } - - if (Nre==0) - return(0); - - MPR_x100 = 100*sumKr/Nre; - // Note: MPR=is the effective spectral efficiency of the PUSCH - // FK 20140908 sumKr is only set after the ulsch_encoding - - beta_offset_pusch = 8; - //(eNB->ulsch[UE_id]->harq_processes[harq_pid]->control_only == 1) ? eNB->ulsch[UE_id]->beta_offset_cqi_times8:8; - - DevAssert( UE_id < NUMBER_OF_UE_MAX ); -//#warning "This condition happens sometimes. Need more investigation" // navid - //DevAssert( MPR_x100/6 < 100 ); - - if (1==1) { //eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { - // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) - if (bw_factor == 1) { - uint8_t nb_rb = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; - return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)) + hundred_times_log10_NPRB[nb_rb-1]; - } else - return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); - } else { - return(0); - } -} - -int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid) -{ - - int8_t UE_id; - - if ((RC.eNB == NULL) || (module_idP > RC.nb_inst) || (CC_id > RC.nb_CC[module_idP])) { - LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",module_idP,CC_id); - return -1; - } - - UE_id = find_ulsch( rnti, RC.eNB[module_idP][CC_id],SEARCH_EXIST); - - if (UE_id == -1) { - // not found - return 0; - } - - return get_hundred_times_delta_IF_eNB( RC.eNB[module_idP][CC_id], UE_id, harq_pid, 0 ); -} - -int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_pid) -{ - - uint32_t Nre = 2*ue->ulsch[eNB_id]->harq_processes[harq_pid]->Nsymb_initial * - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb*12; - - if (Nre==0) - return(0); - - uint32_t MPR_x100 = 100*ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/Nre; - // Note: MPR=is the effective spectral efficiency of the PUSCH - // FK 20140908 sumKr is only set after the ulsch_encoding - - uint16_t beta_offset_pusch = (ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? - ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; - - if (ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled == 1) { - // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) - return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); - } else { - return(0); - } -} - - - -uint8_t alpha_lut[8] = {0,40,50,60,70,80,90,100}; - -void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag) -{ - - - uint8_t harq_pid = subframe2harq_pid(&ue->frame_parms, - proc->frame_tx, - proc->subframe_tx); - - uint8_t nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb; - int16_t PL; - - - // P_pusch = 10*log10(nb_rb + P_opusch(j)+ alpha(u)*PL + delta_TF(i) + f(i)) - // - // P_opusch(0) = P_oPTR + deltaP_Msg3 if PUSCH is transporting Msg3 - // else - // P_opusch(0) = PO_NOMINAL_PUSCH(j) + P_O_UE_PUSCH(j) - PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id); - - ue->ulsch[eNB_id]->Po_PUSCH = (hundred_times_log10_NPRB[nb_rb-1]+ - get_hundred_times_delta_IF(ue,eNB_id,harq_pid) + - 100*ue->ulsch[eNB_id]->f_pusch)/100; - - if(ue->ulsch_Msg3_active[eNB_id] == 1) { // Msg3 PUSCH - - ue->ulsch[eNB_id]->Po_PUSCH += (get_Po_NOMINAL_PUSCH(ue->Mod_id,0) + PL); - - - LOG_I(PHY,"[UE %d][RAPROC] frame %d, subframe %d: Msg3 Po_PUSCH %d dBm (%d,%d,100*PL=%d,%d,%d)\n", - ue->Mod_id,proc->frame_tx,proc->subframe_tx,ue->ulsch[eNB_id]->Po_PUSCH, - 100*get_Po_NOMINAL_PUSCH(ue->Mod_id,0), - hundred_times_log10_NPRB[nb_rb-1], - 100*PL, - get_hundred_times_delta_IF(ue,eNB_id,harq_pid), - 100*ue->ulsch[eNB_id]->f_pusch); - } else if (j==0) { // SPS PUSCH - } else if (j==1) { // Normal PUSCH - - ue->ulsch[eNB_id]->Po_PUSCH += ((alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL)/100); - ue->ulsch[eNB_id]->Po_PUSCH += ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; - ue->ulsch[eNB_id]->PHR = ue->tx_power_max_dBm-ue->ulsch[eNB_id]->Po_PUSCH; - - if (ue->ulsch[eNB_id]->PHR < -23) - ue->ulsch[eNB_id]->PHR = -23; - else if (ue->ulsch[eNB_id]->PHR > 40) - ue->ulsch[eNB_id]->PHR = 40; - - LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubframe %d.%d: nb_rb: %d, Po_PUSCH %d dBm : tx power %d, Po_NOMINAL_PUSCH %d,log10(NPRB) %f,PHR %d, PL %d, alpha*PL %f,delta_IF %f,f_pusch %d\n", - ue->Mod_id,harq_pid,proc->frame_tx,proc->subframe_tx,nb_rb, - ue->ulsch[eNB_id]->Po_PUSCH, - ue->tx_power_max_dBm, - ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH, - hundred_times_log10_NPRB[nb_rb-1]/100.0, - ue->ulsch[eNB_id]->PHR, - PL, - alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL/100.0, - get_hundred_times_delta_IF(ue,eNB_id,harq_pid)/100.0, - ue->ulsch[eNB_id]->f_pusch); - } - -} - -int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index) -{ - - if(nfapi_mode!=3) - return PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->PHR; - else - return 40; // For nfapi_mode=3 consider ideal conditions -} - -// uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id, -int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs) -{ - - /// The payload + CRC size in bits, "B" - uint32_t B; - /// Number of code segments - uint32_t C; - /// Number of "small" code segments - uint32_t Cminus; - /// Number of "large" code segments - uint32_t Cplus; - /// Number of bits in "small" code segments (<6144) - uint32_t Kminus; - /// Number of bits in "large" code segments (<6144) - uint32_t Kplus; - /// Total number of bits across all segments - uint32_t sumKr; - /// Number of "Filler" bits - uint32_t F; - // num resource elements - uint32_t num_re=0.0; - // num symbols - uint32_t num_symb=0.0; - /// effective spectral efficiency of the PUSCH - uint32_t MPR_x100=0; - /// beta_offset - uint16_t beta_offset_pusch_x8=8; - /// delta mcs - float delta_mcs=0.0; - /// bandwidth factor - float bw_factor=0.0; - - B= tbs+24; - lte_segmentation(NULL, - NULL, - B, - &C, - &Cplus, - &Cminus, - &Kplus, - &Kminus, - &F); - - - sumKr = Cminus*Kminus + Cplus*Kplus; - num_symb = 12-(ncp<<1)-(use_srs==0?0:1); - num_re = num_symb * nb_rb * 12; - - if (num_re == 0) - return(0); - - MPR_x100 = 100*sumKr/num_re; - - if (control_only == 1 ) - beta_offset_pusch_x8=8; // fixme - - //(beta_offset_pusch_x8=ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; - - // if deltamcs_enabledm - delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0); - bw_factor = (hundred_times_log10_NPRB[nb_rb-1]/100.0); -#ifdef DEBUG_SEGMENTATION - printf("estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n", - (int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor); -#endif - return (int16_t)ceil(delta_mcs + bw_factor); - -} diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 257fef6e31150f2cd21d4c4a2c6880c39b622359..d5a78c7f98e05be2c8a72687643f9ba1c3e92313 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -30,16 +30,15 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" - +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "PHY/MODULATION/modulation_eNB.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/sched_common.h similarity index 61% rename from openair1/SCHED/defs.h rename to openair1/SCHED/sched_common.h index 5c8840f84a8b1eb8e8c5e9d9fee355d2f9fedae6..30de6dbb4a3c201761b7158bdc863f4407590b81 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/sched_common.h @@ -25,208 +25,11 @@ \email knopp@eurecom.fr */ -#ifndef __openair_SCHED_H__ -#define __openair_SCHED_H__ +#ifndef __openair_SCHED_COMMON_H__ +#define __openair_SCHED_COMMON_H__ -#include "PHY/defs.h" -#include "PHY_INTERFACE/defs.h" - -enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0, - TOP_LEVEL_SCHEDULER_THREAD_INDEX, - DLC_SCHED_THREAD_INDEX, - openair_SCHED_NB_THREADS - }; // do not modify this line - - -#define OPENAIR_THREAD_PRIORITY 255 - - -#define OPENAIR_THREAD_STACK_SIZE PTHREAD_STACK_MIN //4096 //RTL_PTHREAD_STACK_MIN*6 -//#define DLC_THREAD_STACK_SIZE 4096 //DLC stack size -//#define UE_SLOT_PARALLELISATION - -enum openair_SCHED_STATUS { - openair_SCHED_STOPPED=1, - openair_SCHED_STARTING, - openair_SCHED_STARTED, - openair_SCHED_STOPPING -}; - -enum openair_ERROR { - // HARDWARE CAUSES - openair_ERROR_HARDWARE_CLOCK_STOPPED= 1, - - // SCHEDULER CAUSE - openair_ERROR_OPENAIR_RUNNING_LATE, - openair_ERROR_OPENAIR_SCHEDULING_FAILED, - - // OTHERS - openair_ERROR_OPENAIR_TIMING_OFFSET_OUT_OF_BOUNDS, -}; - -enum openair_SYNCH_STATUS { - openair_NOT_SYNCHED=1, - openair_SYNCHED, - openair_SCHED_EXIT -}; - -enum openair_HARQ_TYPE { - openair_harq_DL = 0, - openair_harq_UL, - openair_harq_RA -}; - -#define DAQ_AGC_ON 1 -#define DAQ_AGC_OFF 0 - - -/** @addtogroup _PHY_PROCEDURES_ - * @{ - */ - - - -/*! \brief Top-level entry routine for eNB procedures. Called every slot by process scheduler. In even slots, it performs RX functions from previous subframe (if required). On odd slots, it generate TX waveform for the following subframe. - @param subframe Index of current subframe (0-9) - @param phy_vars_eNB Pointer to eNB variables on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param *phy_vars_rn pointer to RN variables -*/ -void phy_procedures_eNB_lte(uint8_t subframe,PHY_VARS_eNB **phy_vars_eNB,uint8_t abstraction_flag, relaying_type_t r_type, PHY_VARS_RN *phy_vars_rn); - -/*! \brief Top-level entry routine for UE procedures. Called every slot by process scheduler. In even slots, it performs RX functions from previous subframe (if required). On odd slots, it generate TX waveform for the following subframe. - @param phy_vars_ue Pointer to UE variables on which to act - @param eNB_id ID of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param mode calibration/debug mode - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param *phy_vars_rn pointer to RN variables -*/ -void phy_procedures_UE_lte(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); - -#if defined(Rel10) || defined(Rel14) -/*! \brief Top-level entry routine for relay node procedures when acting as eNB. This proc will make us of the existing eNB procs. - @param last_slot Index of last slot (0-19) - @param next_slot Index of next_slot (0-19) - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -int phy_procedures_RN_eNB_TX(unsigned char last_slot, unsigned char next_slot, relaying_type_t r_type); -/*! \brief Top-level entry routine for relay node procedures actinf as UE. This proc will make us of the existing UE procs. - @param last_slot Index of last slot (0-19) - @param next_slot Index of next_slot (0-19) - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -int phy_procedures_RN_UE_RX(unsigned char last_slot, unsigned char next_slot, relaying_type_t r_type); -#endif - -/*! \brief Scheduling for UE TX procedures in normal subframes. - @param phy_vars_ue Pointer to UE variables on which to act - @param proc Pointer to RXn-TXnp4 proc information - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param mode calib/normal mode - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type); -/*! \brief Scheduling for UE RX procedures in normal subframes. - @param last_slot Index of last slot (0-19) - @param phy_vars_ue Pointer to UE variables on which to act - @param proc Pointer to RXn_TXnp4 proc information - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param mode calibration/debug mode - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param phy_vars_rn pointer to RN variables -*/ -int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); - -/*! \brief Scheduling for UE Sidelink RX procedures in normal subframes. - @param ue Pointer to UE variables on which to act - @param proc Pointer to RXn_TXnp4 proc information -*/ -void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc); - -/*! \brief Scheduling for UE Sidelink TX procedures in normal subframes. - @param ue Pointer to UE variables on which to act - @param proc Pointer to RXn_TXnp4 proc information -*/ -void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc); - -int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); -#ifdef UE_SLOT_PARALLELISATION -void *UE_thread_slot1_dl_processing(void *arg); -#endif - -/*! \brief Scheduling for UE TX procedures in TDD S-subframes. - @param phy_vars_ue Pointer to UE variables on which to act - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_UE_S_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type); - -/*! \brief Scheduling for UE RX procedures in TDD S-subframes. - @param phy_vars_ue Pointer to UE variables on which to act - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_UE_S_RX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag, relaying_type_t r_type); - -/*! \brief Scheduling for eNB TX procedures in normal subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param phy_vars_rn pointer to the RN variables - @param do_meas Do inline timing measurement -*/ -void phy_procedures_eNB_TX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn,int do_meas); - -/*! \brief Scheduling for eNB RX UE-specific procedures in normal subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param proc Pointer to RXn-TXnp4 proc information - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type); - -/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param proc Pointer to RXn-TXnp4 proc information - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ - -/*! \brief Scheduling for eNB RX common procedures in normal subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param abstraction_flag Indicator of PHY abstraction -*/ -void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); - -/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ - -void phy_procedures_eNB_S_TX(PHY_VARS_eNB *phy_vars_eNB,relaying_type_t r_type); - -/*! \brief Scheduling for eNB RX procedures in TDD S-subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type); - -/*! \brief Scheduling for eNB PRACH RX procedures - @param phy_vars_eNB Pointer to eNB variables on which to act - @param br_flag indicator for eMTC PRACH -*/ -#ifdef Rel14 -void prach_procedures(PHY_VARS_eNB *eNB, - int br_flag); -#else -void prach_procedures(PHY_VARS_eNB *eNB); -#endif +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" /*! \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 @@ -251,13 +54,8 @@ lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) */ dci_detect_mode_t dci_detect_mode_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); -/*! \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. Same as subframe_select, except that it uses the Mod_id and is provided as a service to the MAC scheduler. - @param Mod_id Index of eNB - @param CC_id Component Carrier Index - @param subframe Subframe index - @returns Subframe type (DL,UL,S) -*/ -lte_subframe_t get_subframe_direction(uint8_t Mod_id, uint8_t CC_id,uint8_t subframe); + + /*! \brief Function to indicate PHICH transmission subframes. Implements Table 9.1.2-1 for TDD. @param frame_parms Pointer to DL frame parameter descriptor diff --git a/openair1/SCHED/extern.h b/openair1/SCHED/sched_common_extern.h similarity index 88% rename from openair1/SCHED/extern.h rename to openair1/SCHED/sched_common_extern.h index b1e8df67ef86a5bb11c9cf9bb2d5dd57374d2eee..b5edc6f38e390dc027a1f3699c2a05c157778092 100644 --- a/openair1/SCHED/extern.h +++ b/openair1/SCHED/sched_common_extern.h @@ -24,16 +24,7 @@ #ifndef __SCHED_EXTERN_H__ #define __SCHED_EXTERN_H__ -#include "defs.h" -//#include "dlc_engine.h" - -extern int openair_sched_status; - -//extern int exit_PHY; -//extern int exit_PHY_ack; - -extern int synch_wait_cnt; - +#include "sched_eNB.h" extern int16_t hundred_times_delta_TF[100]; extern uint16_t hundred_times_log10_NPRB[100]; diff --git a/openair1/SCHED/sched_common_vars.h b/openair1/SCHED/sched_common_vars.h new file mode 100644 index 0000000000000000000000000000000000000000..2cae2aa96f21bc49bc32dc156ac688b8c22f72eb --- /dev/null +++ b/openair1/SCHED/sched_common_vars.h @@ -0,0 +1,28 @@ +/* + * 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 <stdint.h> + + +// This is the formula from Section 5.1.1.1 in 36.213 100*10*log10((2^(MPR*Ks)-1)), where MPR is in the range [0,6] and Ks=1.25 +int16_t hundred_times_delta_TF[100] = {-32768,-1268,-956,-768,-631,-523,-431,-352,-282,-219,-161,-107,-57,-9,36,79,120,159,197,234,269,304,337,370,402,434,465,495,525,555,583,612,640,668,696,723,750,777,803,829,856,881,907,933,958,983,1008,1033,1058,1083,1108,1132,1157,1181,1205,1229,1254,1278,1302,1325,1349,1373,1397,1421,1444,1468,1491,1515,1538,1562,1585,1609,1632,1655,1679,1702,1725,1748,1772,1795,1818,1841,1864,1887,1910,1933,1956,1980,2003,2026,2049,2072,2095,2118,2141,2164,2186,2209,2232,2255}; +uint16_t hundred_times_log10_NPRB[100] = {0,301,477,602,698,778,845,903,954,1000,1041,1079,1113,1146,1176,1204,1230,1255,1278,1301,1322,1342,1361,1380,1397,1414,1431,1447,1462,1477,1491,1505,1518,1531,1544,1556,1568,1579,1591,1602,1612,1623,1633,1643,1653,1662,1672,1681,1690,1698,1707,1716,1724,1732,1740,1748,1755,1763,1770,1778,1785,1792,1799,1806,1812,1819,1826,1832,1838,1845,1851,1857,1863,1869,1875,1880,1886,1892,1897,1903,1908,1913,1919,1924,1929,1934,1939,1944,1949,1954,1959,1963,1968,1973,1977,1982,1986,1991,1995,2000}; + diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h new file mode 100644 index 0000000000000000000000000000000000000000..e03b7f6b62be7579cdefd02a17b69db3e2809c95 --- /dev/null +++ b/openair1/SCHED/sched_eNB.h @@ -0,0 +1,227 @@ +/* + * 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 + */ + +/* + \author R. Knopp, F. Kaltenberger + \company EURECOM + \email knopp@eurecom.fr +*/ + +#ifndef __openair_SCHED_ENB_H__ +#define __openair_SCHED_ENB_H__ + +#include "PHY/defs_eNB.h" +#include "PHY_INTERFACE/phy_interface.h" +#include "sched_common.h" + +enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0, + TOP_LEVEL_SCHEDULER_THREAD_INDEX, + DLC_SCHED_THREAD_INDEX, + openair_SCHED_NB_THREADS + }; // do not modify this line + + +#define OPENAIR_THREAD_PRIORITY 255 + + +#define OPENAIR_THREAD_STACK_SIZE PTHREAD_STACK_MIN //4096 //RTL_PTHREAD_STACK_MIN*6 +//#define DLC_THREAD_STACK_SIZE 4096 //DLC stack size +//#define UE_SLOT_PARALLELISATION + +enum openair_SCHED_STATUS { + openair_SCHED_STOPPED=1, + openair_SCHED_STARTING, + openair_SCHED_STARTED, + openair_SCHED_STOPPING +}; + +enum openair_ERROR { + // HARDWARE CAUSES + openair_ERROR_HARDWARE_CLOCK_STOPPED= 1, + + // SCHEDULER CAUSE + openair_ERROR_OPENAIR_RUNNING_LATE, + openair_ERROR_OPENAIR_SCHEDULING_FAILED, + + // OTHERS + openair_ERROR_OPENAIR_TIMING_OFFSET_OUT_OF_BOUNDS, +}; + +enum openair_SYNCH_STATUS { + openair_NOT_SYNCHED=1, + openair_SYNCHED, + openair_SCHED_EXIT +}; + +enum openair_HARQ_TYPE { + openair_harq_DL = 0, + openair_harq_UL, + openair_harq_RA +}; + +#define DAQ_AGC_ON 1 +#define DAQ_AGC_OFF 0 + + +/** @addtogroup _PHY_PROCEDURES_ + * @{ + */ + + + +/*! \brief Scheduling for eNB TX procedures in normal subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param abstraction_flag Indicator of PHY abstraction + @param do_meas Do inline timing measurement +*/ +void phy_procedures_eNB_TX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,int do_meas); + +/*! \brief Scheduling for eNB RX UE-specific procedures in normal subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param proc Pointer to RXn-TXnp4 proc information +*/ +void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); + +/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param proc Pointer to RXn-TXnp4 proc information + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ + +/*! \brief Scheduling for eNB RX common procedures in normal subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param abstraction_flag Indicator of PHY abstraction +*/ +void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); + +/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act +*/ + +void phy_procedures_eNB_S_TX(PHY_VARS_eNB *phy_vars_eNB); + +/*! \brief Scheduling for eNB RX procedures in TDD S-subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act +*/ +void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); + +/*! \brief Scheduling for eNB PRACH RX procedures + @param phy_vars_eNB Pointer to eNB variables on which to act + @param br_flag indicator for eMTC PRACH +*/ +#ifdef Rel14 +void prach_procedures(PHY_VARS_eNB *eNB, + int br_flag); +#else +void prach_procedures(PHY_VARS_eNB *eNB); +#endif + +/*! \brief Function to compute timing of Msg3 transmission on UL-SCH (first UE transmission in RA procedure). This implements the timing in paragraph a) from Section 6.1.1 in 36.213 (p. 17 in version 8.6). Used by eNB upon transmission of random-access response (RA_RNTI) to program corresponding ULSCH reception procedure. Used by UE upon reception of random-access response (RA_RNTI) to program corresponding ULSCH transmission procedure. This does not support the UL_delay field in RAR (always assumed to be 0). + @param frame_parms Pointer to DL frame parameter descriptor + @param current_subframe Index of subframe where RA_RNTI was received + @param current_frame Index of frame where RA_RNTI was received + @param frame Frame index where Msg3 is to be transmitted (n+6 mod 10 for FDD, different for TDD) + @param subframe subframe index where Msg3 is to be transmitted (n, n+1 or n+2) +*/ +void get_Msg3_alloc(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t current_subframe, + uint32_t current_frame, + uint32_t *frame, + uint8_t *subframe); + +/*! \brief Function to compute timing of Msg3 retransmission on UL-SCH (first UE transmission in RA procedure). + @param frame_parms Pointer to DL frame parameter descriptor + @param current_subframe Index of subframe where RA_RNTI was received + @param current_frame Index of frame where RA_RNTI was received + @param frame Frame index where Msg3 is to be transmitted (n+6 mod 10 for FDD, different for TDD) + @param subframe subframe index where Msg3 is to be transmitted (n, n+1 or n+2) +*/ +void get_Msg3_alloc_ret(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t current_subframe, + uint32_t current_frame, + uint32_t *frame, + uint8_t *subframe); + +/*! \brief Get ULSCH harq_pid for Msg3 from RAR subframe. This returns n+k mod 10 (k>6) and corresponds to the rule in Section 6.1.1 from 36.213 + @param frame_parms Pointer to DL Frame Parameters + @param frame Frame index + @param current_subframe subframe of RAR transmission + @returns harq_pid (0 ... 7) + */ +uint8_t get_Msg3_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t current_subframe); + +/*! \brief Get ULSCH harq_pid from PHICH subframe + @param frame_parms Pointer to DL Frame Parameters + @param subframe subframe of PHICH + @returns harq_pid (0 ... 7) + */ + +/*! \brief Function to indicate failure of contention resolution or RA procedure. It places the UE back in PRACH mode. + @param Mod_id Instance index of UE + @param CC_id Component Carrier Index + @param eNB_index Index of eNB + */ +void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief Indicates the SR TXOp in current subframe for eNB and particular UE index. Implements Table 10.1-5 from 36.213. + @param phy_vars_eNB Pointer to eNB variables + @param UE_id ID of UE which may be issuing the SR + @returns 1 if TXOp is active. +*/ +uint8_t is_SR_subframe(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,uint8_t UE_id); + +int8_t find_ue_dlsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); +int8_t find_ue_ulsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); + + + + + +void schedule_response(Sched_Rsp_t *Sched_INFO); + +LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti); + +/*! \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. Same as subframe_select, except that it uses the Mod_id and is provided as a service to the MAC scheduler. + @param Mod_id Index of eNB + @param CC_id Component Carrier Index + @param subframe Subframe index + @returns Subframe type (DL,UL,S) +*/ +lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe); + + +int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *phy_vars_eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor); + +int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid); + +int16_t get_target_pusch_rx_power(module_id_t module_idP, uint8_t CC_id); +int16_t get_target_pucch_rx_power(module_id_t module_idP, uint8_t CC_id); + +int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx); + +void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); + +/*@}*/ + + +#endif + + diff --git a/openair1/SCHED_NBIOT/README b/openair1/SCHED_NBIOT/README new file mode 100644 index 0000000000000000000000000000000000000000..319372ee93aa05bec7537d2b8c771fad0c7cb854 --- /dev/null +++ b/openair1/SCHED_NBIOT/README @@ -0,0 +1 @@ +213 procedures for NB-IoT eNB diff --git a/openair1/SCHED_NR/README b/openair1/SCHED_NR/README new file mode 100644 index 0000000000000000000000000000000000000000..8814a972b0e5a84dbb757a8769d485afb74ec131 --- /dev/null +++ b/openair1/SCHED_NR/README @@ -0,0 +1 @@ +213/214 procedures for NR gNB diff --git a/openair1/SCHED_NR_UE/README b/openair1/SCHED_NR_UE/README new file mode 100644 index 0000000000000000000000000000000000000000..b2bc9d09b8ae274660cf13da0636158b31811e57 --- /dev/null +++ b/openair1/SCHED_NR_UE/README @@ -0,0 +1 @@ +213/214 procedures for NR UE diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c similarity index 98% rename from openair1/SCHED/phy_procedures_lte_ue.c rename to openair1/SCHED_UE/phy_procedures_lte_ue.c index 6f9aebbc1b5a2660dd663556c3f6bbc0160073ee..30712b0ad511649c1e50f1b4e173eb3934de645f 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -33,22 +33,23 @@ #define _GNU_SOURCE #include "assertions.h" -#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include <sched.h> #include "targets/RT/USER/lte-softmodem.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + //#define DEBUG_PHY_PROC #ifndef PUCCH #define PUCCH #endif -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" @@ -58,13 +59,13 @@ # include "intertask_interface.h" #endif -#include "PHY/defs.h" +#include "PHY/defs_UE.h" -#include "PHY/CODING/extern.h" +#include "PHY/CODING/coding_extern.h" #include "T.h" -#include "PHY/TOOLS/defs.h" +#include "PHY/TOOLS/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) @@ -1390,7 +1391,6 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin frame_tx, eNB_id, subframe_tx); - LOG_D(PHY,"Got prach_resources for eNB %d address %p, RRCCommon %p\n",eNB_id,ue->prach_resources[eNB_id],UE_mac_inst[ue->Mod_id].radioResourceConfigCommon); LOG_D(PHY,"Prach resources %p\n",ue->prach_resources[eNB_id]); } } @@ -1412,7 +1412,7 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->prach_resources[eNB_id]->ra_PreambleIndex = 19; } - LOG_I(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d : Generating PRACH, preamble %d,PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n", + LOG_D(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d : Generating PRACH, preamble %d,PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n", ue->Mod_id, frame_tx, subframe_tx, @@ -2354,7 +2354,7 @@ void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) { } -void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type) { +void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) { LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; @@ -2473,7 +2473,7 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui #endif } -void phy_procedures_UE_S_TX(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type) +void phy_procedures_UE_S_TX(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag) { int aa;//i,aa; LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; @@ -2794,15 +2794,17 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint subframe_rx, eNB_id, ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI, - ue->high_speed_flag, - ue->is_secondary_ue); + ue->high_speed_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_IN); - //printf("Decode SIB frame param agregation + DCI %d %d \n",agregationLevel,dciFormat); - + /*printf("Decode SIB frame param aggregation + DCI %d %d, num_pdcch_symbols %d\n", + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dciFormat, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); + */ //agregation level == FF means no configuration on if(ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel == 0xFF || ue->decode_SIB) { @@ -4167,8 +4169,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { #ifdef UE_SLOT_PARALLELISATION int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { int l,l2; int pmch_flag=0; @@ -4218,8 +4219,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *pr } #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[%s %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", - (r_type == multicast_relay) ? "RN/UE" : "UE", + LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", ue->Mod_id,frame_rx, subframe_rx); #endif @@ -4689,8 +4689,7 @@ void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) { } int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { int l,l2; int pilot1; @@ -4739,8 +4738,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[%s %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", - (r_type == multicast_relay) ? "RN/UE" : "UE", + LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", ue->Mod_id,frame_rx, subframe_rx); #endif @@ -5165,38 +5163,9 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, return (0); } -#if defined(Rel10) || defined(Rel14) - -int phy_procedures_RN_UE_RX(uint8_t slot_rx, uint8_t next_slot, relaying_type_t r_type) -{ - - int do_proc =0; // do nothing by default - - switch(r_type) { - case no_relay: - do_proc=no_relay; // perform the normal UE operation - break; - - case multicast_relay: - if (slot_rx > 12) - do_proc = 0; // do nothing - else // SF#1, SF#2, SF3, SF#3, SF#4, SF#5, SF#6(do rx slot 12) - do_proc = multicast_relay ; // do PHY procedures UE RX - - break; - - default: // should'not be here - LOG_W(PHY,"Not supported relay type %d, do nothing \n", r_type); - do_proc= 0; - break; - } - return do_proc; -} -#endif -void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, - relaying_type_t r_type, PHY_VARS_RN *phy_vars_rn) +void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { #if defined(ENABLE_ITTI) MessageDef *msg_p; @@ -5258,30 +5227,22 @@ void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,u if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_UL)|| (ue->frame_parms.frame_type == FDD)) { - phy_procedures_UE_TX(ue,proc,eNB_id,abstraction_flag,mode,r_type); + phy_procedures_UE_TX(ue,proc,eNB_id,abstraction_flag,mode); } if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_DL) || - (ue->frame_parms.frame_type == FDD)) { -#if defined(Rel10) || defined(Rel14) - - if (phy_procedures_RN_UE_RX(subframe_rx, subframe_tx, r_type) != 0 ) -#endif - phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode,r_type,phy_vars_rn); + (ue->frame_parms.frame_type == FDD)) { + phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); } if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_S) && (slot==1)) { - phy_procedures_UE_S_TX(ue,eNB_id,abstraction_flag,r_type); + phy_procedures_UE_S_TX(ue,eNB_id,abstraction_flag); } if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_S) && - (slot==0)) { -#if defined(Rel10) || defined(Rel14) - - if (phy_procedures_RN_UE_RX(subframe_rx, subframe_tx, r_type) != 0 ) -#endif - phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode,r_type,phy_vars_rn); + (slot==0)) { + phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); } if (ue->mac_enabled==1) { diff --git a/openair1/SCHED/pucch_pc.c b/openair1/SCHED_UE/pucch_pc.c similarity index 95% rename from openair1/SCHED/pucch_pc.c rename to openair1/SCHED_UE/pucch_pc.c index f01d0d96dd7df5ddbc65cc8270d0ea4d760e5b43..f03cd93d34995b4313c1104aebd30f439b6afc8f 100644 --- a/openair1/SCHED/pucch_pc.c +++ b/openair1/SCHED_UE/pucch_pc.c @@ -30,10 +30,11 @@ * \warning */ -#include "PHY/defs.h" -#include "SCHED/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "SCHED_UE/sched_UE.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" int16_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,uint8_t eNB_id,PUCCH_FMT_t pucch_fmt) { diff --git a/openair1/SCHED_UE/pusch_pc.c b/openair1/SCHED_UE/pusch_pc.c new file mode 100644 index 0000000000000000000000000000000000000000..90c17099a04634f2193c3a73913affa40b2b0c51 --- /dev/null +++ b/openair1/SCHED_UE/pusch_pc.c @@ -0,0 +1,138 @@ +/* + * 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 pusch_pc.c + * \brief Implementation of UE PUSCH Power Control procedures from 36.213 LTE specifications (Section + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + +#include "sched_UE.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + +extern uint8_t nfapi_mode; + +int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_pid) +{ + + uint32_t Nre = 2*ue->ulsch[eNB_id]->harq_processes[harq_pid]->Nsymb_initial * + ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb*12; + + if (Nre==0) + return(0); + + uint32_t MPR_x100 = 100*ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/Nre; + // Note: MPR=is the effective spectral efficiency of the PUSCH + // FK 20140908 sumKr is only set after the ulsch_encoding + + uint16_t beta_offset_pusch = (ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? + ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; + + if (ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled == 1) { + // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) + return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); + } else { + return(0); + } +} + + + +uint8_t alpha_lut[8] = {0,40,50,60,70,80,90,100}; + +void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag) +{ + + + uint8_t harq_pid = subframe2harq_pid(&ue->frame_parms, + proc->frame_tx, + proc->subframe_tx); + + uint8_t nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb; + int16_t PL; + + + // P_pusch = 10*log10(nb_rb + P_opusch(j)+ alpha(u)*PL + delta_TF(i) + f(i)) + // + // P_opusch(0) = P_oPTR + deltaP_Msg3 if PUSCH is transporting Msg3 + // else + // P_opusch(0) = PO_NOMINAL_PUSCH(j) + P_O_UE_PUSCH(j) + PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id); + + ue->ulsch[eNB_id]->Po_PUSCH = (hundred_times_log10_NPRB[nb_rb-1]+ + get_hundred_times_delta_IF(ue,eNB_id,harq_pid) + + 100*ue->ulsch[eNB_id]->f_pusch)/100; + + if(ue->ulsch_Msg3_active[eNB_id] == 1) { // Msg3 PUSCH + + ue->ulsch[eNB_id]->Po_PUSCH += (get_Po_NOMINAL_PUSCH(ue->Mod_id,0) + PL); + + + LOG_I(PHY,"[UE %d][RAPROC] frame %d, subframe %d: Msg3 Po_PUSCH %d dBm (%d,%d,100*PL=%d,%d,%d)\n", + ue->Mod_id,proc->frame_tx,proc->subframe_tx,ue->ulsch[eNB_id]->Po_PUSCH, + 100*get_Po_NOMINAL_PUSCH(ue->Mod_id,0), + hundred_times_log10_NPRB[nb_rb-1], + 100*PL, + get_hundred_times_delta_IF(ue,eNB_id,harq_pid), + 100*ue->ulsch[eNB_id]->f_pusch); + } else if (j==0) { // SPS PUSCH + } else if (j==1) { // Normal PUSCH + + ue->ulsch[eNB_id]->Po_PUSCH += ((alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL)/100); + ue->ulsch[eNB_id]->Po_PUSCH += ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; + ue->ulsch[eNB_id]->PHR = ue->tx_power_max_dBm-ue->ulsch[eNB_id]->Po_PUSCH; + + if (ue->ulsch[eNB_id]->PHR < -23) + ue->ulsch[eNB_id]->PHR = -23; + else if (ue->ulsch[eNB_id]->PHR > 40) + ue->ulsch[eNB_id]->PHR = 40; + + LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubframe %d.%d: nb_rb: %d, Po_PUSCH %d dBm : tx power %d, Po_NOMINAL_PUSCH %d,log10(NPRB) %f,PHR %d, PL %d, alpha*PL %f,delta_IF %f,f_pusch %d\n", + ue->Mod_id,harq_pid,proc->frame_tx,proc->subframe_tx,nb_rb, + ue->ulsch[eNB_id]->Po_PUSCH, + ue->tx_power_max_dBm, + ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH, + hundred_times_log10_NPRB[nb_rb-1]/100.0, + ue->ulsch[eNB_id]->PHR, + PL, + alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL/100.0, + get_hundred_times_delta_IF(ue,eNB_id,harq_pid)/100.0, + ue->ulsch[eNB_id]->f_pusch); + } + +} + +int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index) +{ + if(nfapi_mode!=3) + return PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->PHR; + else + return 40; // For nfapi_mode=3 consider ideal conditions +} diff --git a/openair1/SCHED_UE/sched_UE.h b/openair1/SCHED_UE/sched_UE.h new file mode 100644 index 0000000000000000000000000000000000000000..32702b114893329bf0db88291e2df50be8661a34 --- /dev/null +++ b/openair1/SCHED_UE/sched_UE.h @@ -0,0 +1,288 @@ +/* + * 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 + */ + +/* + \author R. Knopp, F. Kaltenberger + \company EURECOM + \email knopp@eurecom.fr +*/ + +#ifndef __openair_SCHED_UE_H__ +#define __openair_SCHED_UE_H__ + +#include "PHY/defs_UE.h" +#include "../SCHED/sched_common.h" + +/*! \brief Scheduling for UE TX procedures in normal subframes. + @param phy_vars_ue Pointer to UE variables on which to act + @param proc Pointer to RXn-TXnp4 proc information + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param mode calib/normal mode + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ +void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode); +/*! \brief Scheduling for UE RX procedures in normal subframes. + @param last_slot Index of last slot (0-19) + @param phy_vars_ue Pointer to UE variables on which to act + @param proc Pointer to RXn_TXnp4 proc information + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param mode calibration/debug mode + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying + @param phy_vars_rn pointer to RN variables +*/ +int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode); + +/*! \brief Scheduling for UE Sidelink RX procedures in normal subframes. + @param ue Pointer to UE variables on which to act + @param proc Pointer to RXn_TXnp4 proc information +*/ +void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc); + +/*! \brief Scheduling for UE Sidelink TX procedures in normal subframes. + @param ue Pointer to UE variables on which to act + @param proc Pointer to RXn_TXnp4 proc information +*/ +void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc); + +int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode); +#ifdef UE_SLOT_PARALLELISATION +void *UE_thread_slot1_dl_processing(void *arg); +#endif + +/*! \brief Scheduling for UE TX procedures in TDD S-subframes. + @param phy_vars_ue Pointer to UE variables on which to act + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ +void phy_procedures_UE_S_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag); + +/*! \brief Scheduling for UE RX procedures in TDD S-subframes. + @param phy_vars_ue Pointer to UE variables on which to act + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ +void phy_procedures_UE_S_RX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag); + +/*! \brief Get ULSCH harq_pid for Msg3 from RAR subframe. This returns n+k mod 10 (k>6) and corresponds to the rule in Section 6.1.1 from 36.213 + @param frame_parms Pointer to DL Frame Parameters + @param frame Frame index + @param current_subframe subframe of RAR transmission + @returns harq_pid (0 ... 7) + */ +uint8_t get_Msg3_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t current_subframe); + +/*! \brief Get ULSCH harq_pid from PHICH subframe + @param frame_parms Pointer to DL Frame Parameters + @param subframe subframe of PHICH + @returns harq_pid (0 ... 7) + */ + +/*! \brief Function to indicate failure of contention resolution or RA procedure. It places the UE back in PRACH mode. + @param Mod_id Instance index of UE + @param CC_id Component Carrier Index + @param eNB_index Index of eNB + */ +void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief Function to indicate success of contention resolution or RA procedure. + @param Mod_id Instance index of UE + @param CC_id Component Carrier Index + @param eNB_index Index of eNB + */ +void ra_succeeded(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +uint8_t phich_subframe_to_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe); + +/*! \brief Get PDSCH subframe (n+k) from PDCCH subframe n using relationship from Table 8-2 from 36.213 + @param frame_parms Pointer to DL Frame Parameters + @param n subframe of PDCCH + @returns PDSCH subframe (0 ... 7) (note: this is n+k from Table 8-2) + */ +uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); + + +/*! \brief Compute ACK/NACK information for PUSCH/PUCCH for UE transmission in subframe n. This function implements table 10.1-1 of 36.213, p. 69. + @param frame_parms Pointer to DL frame parameter descriptor + @param harq_ack Pointer to dlsch_ue harq_ack status descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @param o_ACK Pointer to ACK/NAK payload for PUCCH/PUSCH + @returns status indicator for PUCCH/PUSCH transmission +*/ +uint8_t get_ack(LTE_DL_FRAME_PARMS *frame_parms,harq_status_t *harq_ack,uint8_t subframe_tx,uint8_t subframe_rx,uint8_t *o_ACK, uint8_t cw_idx); + +/*! \brief Reset ACK/NACK information + @param frame_parms Pointer to DL frame parameter descriptor + @param harq_ack Pointer to dlsch_ue harq_ack status descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @param o_ACK Pointer to ACK/NAK payload for PUCCH/PUSCH + @returns status indicator for PUCCH/PUSCH transmission +*/ +uint8_t reset_ack(LTE_DL_FRAME_PARMS *frame_parms, + harq_status_t *harq_ack, + unsigned char subframe_tx, + unsigned char subframe_rx, + unsigned char *o_ACK, + uint8_t *pN_bundled, + uint8_t cw_idx); + +/*! \brief Compute UL ACK subframe from DL subframe. This is used to retrieve corresponding DLSCH HARQ pid at eNB upon reception of ACK/NAK information on PUCCH/PUSCH. Derived from Table 10.1-1 in 36.213 (p. 69 in version 8.6) + @param frame_parms Pointer to DL frame parameter descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @param ACK_index TTI bundling index (0,1) + @returns Subframe index for corresponding DL transmission +*/ +uint8_t ul_ACK_subframe2_dl_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe,uint8_t ACK_index); + +/*! \brief Computes number of DL subframes represented by a particular ACK received on UL (M from Table 10.1-1 in 36.213, p. 69 in version 8.6) + @param frame_parms Pointer to DL frame parameter descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @returns Number of DL subframes (M) +*/ +uint8_t ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe); + +/*! \brief Indicates the SR TXOp in current subframe. Implements Table 10.1-5 from 36.213. + @param phy_vars_ue Pointer to UE variables + @param proc Pointer to RXn_TXnp4 thread context + @param eNB_id ID of eNB which is to receive the SR + @returns 1 if TXOp is active. +*/ +uint8_t is_SR_TXOp(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id); + +uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); + +/*! \brief Gives the UL frame corresponding to a PDDCH order in subframe n + @param frame_parms Pointer to DL frame parameters + @param frame Frame of received PDCCH + @param n subframe of PDCCH + @returns UL frame corresponding to pdcch order +*/ +uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n); + + +uint16_t get_Np(uint8_t N_RB_DL,uint8_t nCCE,uint8_t plus1); + + + +void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance); +void process_timing_advance_rar(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint16_t timing_advance); + +unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb); + +void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief This function retrives the resource (n1_pucch) corresponding to a PDSCH transmission in +subframe n-4 which is acknowledged in subframe n (for FDD) according to n1_pucch = Ncce + N1_pucch. For +TDD, this routine computes the complex procedure described in Section 10.1 of 36.213 (through tables 10.1-1,10.1-2) +@param phy_vars_ue Pointer to UE variables +@param proc Pointer to RXn-TXnp4 proc information +@param harq_ack Pointer to dlsch_ue harq_ack status descriptor +@param eNB_id Index of eNB +@param b Pointer to PUCCH payload (b[0],b[1]) +@param SR 1 means there's a positive SR in parallel to ACK/NAK +@returns n1_pucch +*/ +uint16_t get_n1_pucch(PHY_VARS_UE *phy_vars_ue, + UE_rxtx_proc_t *proc, + harq_status_t *harq_ack, + uint8_t eNB_id, + uint8_t *b, + uint8_t SR); + + + + +/*! \brief This function retrieves the PHY UE mode. It is used as a helper function for the UE MAC. + @param Mod_id Local UE index on which to act + @param CC_id Component Carrier Index + @param eNB_index ID of eNB + @returns UE mode +*/ +UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief This function implements the power control mechanism for PUCCH from 36.213. + @param phy_vars_ue PHY variables + @param proc Pointer to proc descriptor + @param eNB_id Index of eNB + @param pucch_fmt Format of PUCCH that is being transmitted + @returns Transmit power + */ +int16_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,uint8_t eNB_id,PUCCH_FMT_t pucch_fmt); + +/*! \brief This function implements the power control mechanism for PUCCH from 36.213. + @param phy_vars_ue PHY variables + @param proc Pointer to proc descriptor + @param eNB_id Index of eNB + @param j index of type of PUSCH (SPS, Normal, Msg3) + @returns Transmit power + */ +void pusch_power_cntl(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag); + +/*! \brief This function implements the power control mechanism for SRS from 36.213. + @param phy_vars_ue PHY variables + @param proc Pointer to proc descriptor + @param eNB_id Index of eNB + @param j index of type of PUSCH (SPS, Normal, Msg3) + @returns Transmit power + */ +void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag); + +void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id); + +int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id, uint8_t eNB_index); + + + +LTE_DL_FRAME_PARMS *get_lte_frame_parms(module_id_t Mod_id, uint8_t CC_id); + +MU_MIMO_mode* get_mu_mimo_mode (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); + +int16_t get_hundred_times_delta_IF(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t harq_pid); + + +int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid); + +int16_t get_target_pusch_rx_power(module_id_t module_idP, uint8_t CC_id); +int16_t get_target_pucch_rx_power(module_id_t module_idP, uint8_t CC_id); + +int get_ue_active_harq_pid(uint8_t Mod_id,uint8_t CC_id,uint16_t rnti,int frame, uint8_t subframe,uint8_t *harq_pid,uint8_t *round,uint8_t ul_flag); + +void dump_dlsch(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid); +void dump_dlsch_SI(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe); +void dump_dlsch_ra(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe); + +void dump_dlsch2(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe, unsigned int *coded_bits_per_codeword,int round, unsigned char harq_pid); + + +int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subframe_tx); + +void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeriodicity,uint16_t *psrsOffset); + +/*@}*/ + + +#endif + + diff --git a/openair1/SCHED/srs_pc.c b/openair1/SCHED_UE/srs_pc.c similarity index 96% rename from openair1/SCHED/srs_pc.c rename to openair1/SCHED_UE/srs_pc.c index 04dacecc25a5aa59e6feb2ea35811dbe913082fc..9463db2cd62b594db9fad1adeb7514fbcd34516e 100644 --- a/openair1/SCHED/srs_pc.c +++ b/openair1/SCHED_UE/srs_pc.c @@ -30,9 +30,10 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag) { diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index ec66e357cce2e17685822505c7125ccdff4db708..77b8c0e674d3b09cad69be0fcb6048abc7f54f46 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -36,14 +36,15 @@ #include <execinfo.h> #include <signal.h> -#include "SIMULATION/TOOLS/defs.h" +#include "SIMULATION/TOOLS/sim.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/vars.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_vars.h" -#include "SCHED/defs.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" +#include "SCHED/sched_eNB.h" +#include "SCHED/sched_common_vars.h" +#include "LAYER2/MAC/mac_vars.h" #include "OCG_vars.h" #include "UTIL/LOG/log.h" @@ -56,7 +57,18 @@ #include "dummy_functions.c" +#include "PHY/MODULATION/modulation_common.h" +#include "PHY/MODULATION/modulation_eNB.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "SCHED/sched_eNB.h" +#include "SCHED_UE/sched_UE.h" +#include "common/config/config_load_configmodule.h" +#include "PHY/INIT/phy_init.h" +void feptx_ofdm(RU_t *ru); +void feptx_prec(RU_t *ru); double cpuf; @@ -540,7 +552,6 @@ int main(int argc, char **argv) DCI_ALLOC_t da; DCI_ALLOC_t *dci_alloc = &da; - unsigned int ret; unsigned int coded_bits_per_codeword=0,nsymb; //,tbs=0; unsigned int tx_lev=0,tx_lev_dB=0,trials; @@ -563,16 +574,6 @@ int main(int argc, char **argv) unsigned char input_trch_file=0; FILE *input_fd=NULL; unsigned char input_file=0; - // char input_val_str[50],input_val_str2[50]; - - char input_trch_val[16]; - - // unsigned char pbch_pdu[6]; - - - - - // FILE *rx_frame_file; int n_frames; int n_ch_rlz = 1; @@ -595,7 +596,7 @@ int main(int argc, char **argv) // void *data; // int ii; // int bler; - double blerr[4],uncoded_ber=0; //,avg_ber; + double blerr[4]; short *uncoded_ber_bit=NULL; uint8_t N_RB_DL=25,osf=1; frame_t frame_type = FDD; @@ -1594,13 +1595,13 @@ int main(int argc, char **argv) eNB->abstraction_flag=0; schedule_response(&sched_resp); - phy_procedures_eNB_TX(eNB,proc_eNB,no_relay,NULL,1); + phy_procedures_eNB_TX(eNB,proc_eNB,1); if (uncoded_ber_bit == NULL) { // this is for user 0 only printf("nb_rb %d, rb_alloc %x, mcs %d\n", eNB->dlsch[0][0]->harq_processes[0]->nb_rb, - eNB->dlsch[0][0]->harq_processes[0]->rb_alloc, + eNB->dlsch[0][0]->harq_processes[0]->rb_alloc[0], eNB->dlsch[0][0]->harq_processes[0]->mcs); coded_bits_per_codeword = get_G(&eNB->frame_parms, @@ -1636,7 +1637,7 @@ int main(int argc, char **argv) proc_eNB->subframe_tx = subframe+1; sched_resp.subframe=subframe+1; schedule_response(&sched_resp); - phy_procedures_eNB_TX(eNB,proc_eNB,no_relay,NULL,0); + phy_procedures_eNB_TX(eNB,proc_eNB,0); ru->proc.subframe_tx=(subframe+1)%10; @@ -1725,7 +1726,7 @@ int main(int argc, char **argv) dci_received = UE->pdcch_vars[UE->current_thread_id[proc->subframe_rx]][eNB_id]->dci_received; - phy_procedures_UE_RX(UE,proc,0,0,dci_flag,normal_txrx,no_relay,NULL); + phy_procedures_UE_RX(UE,proc,0,0,dci_flag,normal_txrx); dci_received = dci_received - UE->pdcch_vars[UE->current_thread_id[proc->subframe_rx]][eNB_id]->dci_received; diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index c8909f83afb382a12f8e4f793d44ede9f10f7d70..22cac3719374c4dcd86a2e71eefc17151dc97d2f 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -33,22 +33,30 @@ #include <string.h> #include <math.h> #include <unistd.h> -#include "SIMULATION/TOOLS/defs.h" +#include "SIMULATION/TOOLS/sim.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/vars.h" +#include "PHY/defs_common.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_vars.h" -#include "SCHED/defs.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" + +#include "SCHED/sched_common_vars.h" +#include "SCHED/sched_eNB.h" +#include "SCHED_UE/sched_UE.h" +#include "LAYER2/MAC/mac_vars.h" #include "OCG_vars.h" -#include "intertask_interface_init.h" + +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/INIT/phy_init.h" #include "unitary_defs.h" #include "PHY/TOOLS/lte_phy_scope.h" #include "dummy_functions.c" +#include "common/config/config_load_configmodule.h" double cpuf; @@ -875,6 +883,7 @@ int main(int argc, char **argv) // NN: N_RB_UL has to be defined in ulsim for (int k=0;k<NUMBER_OF_UE_MAX;k++) eNB->ulsch[k] = new_eNB_ulsch(max_turbo_iterations,N_RB_DL,0); UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0); + printf("ULSCH %p\n",UE->ulsch[0]); if (parallel_flag == 1) { extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); @@ -948,34 +957,6 @@ int main(int argc, char **argv) UE->ulsch_Msg3_active[eNB_id] = 0; UE->ul_power_control_dedicated[eNB_id].accumulationEnabled=1; - /* - generate_ue_ulsch_params_from_dci((void *)&UL_alloc_pdu, - 14, - proc_rxtx->subframe_tx, - format0, - UE, - proc_rxtx_ue, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - 0, - srs_flag); - - // printf("RIV %d\n",UL_alloc_pdu.rballoc); - - generate_eNB_ulsch_params_from_dci(eNB,proc_rxtx, - (void *)&UL_alloc_pdu, - 14, - format0, - 0, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - srs_flag); - */ - coded_bits_per_codeword = nb_rb * (12 * get_Qm_ul(mcs)) * nsymb; if (cqi_flag == 1) coded_bits_per_codeword-=UE->ulsch[0]->O; @@ -1213,7 +1194,7 @@ int main(int argc, char **argv) proc_rxtx_ue->subframe_tx = proc_rxtx->subframe_rx; proc_rxtx_ue->subframe_rx = proc_rxtx->subframe_tx; - phy_procedures_UE_TX(UE,proc_rxtx_ue,0,0,normal_txrx,no_relay); + phy_procedures_UE_TX(UE,proc_rxtx_ue,0,0,normal_txrx); tx_lev = signal_energy(&UE->common_vars.txdata[0][eNB->frame_parms.samples_per_tti*subframe], @@ -1341,7 +1322,7 @@ int main(int argc, char **argv) ru->feprx(ru); - phy_procedures_eNB_uespec_RX(eNB,proc_rxtx,no_relay); + phy_procedures_eNB_uespec_RX(eNB,proc_rxtx); if (cqi_flag > 0) { diff --git a/openair1/SIMULATION/RF/dac.c b/openair1/SIMULATION/RF/dac.c index 08f1ed7ab44a89f7eacfb1686e850aa142bbd5a0..b09bd20374bf7bec5df4143443a841472c3a2876 100644 --- a/openair1/SIMULATION/RF/dac.c +++ b/openair1/SIMULATION/RF/dac.c @@ -22,8 +22,8 @@ //#define DEBUG_DAC 1 #include <math.h> #include <stdio.h> -#include "PHY/TOOLS/defs.h" - +#include "PHY/TOOLS/tools_defs.h" +#include "rf.h" void dac(double *s_re[2], double *s_im[2], uint32_t **input, diff --git a/openair1/SIMULATION/RF/rf.c b/openair1/SIMULATION/RF/rf.c index 3cf770ac7cf8c1a0f3038626807dedf18fccdef2..51b7e7524d4bb2bc953fc908a4b2fd1a5a0aa5ee 100644 --- a/openair1/SIMULATION/RF/rf.c +++ b/openair1/SIMULATION/RF/rf.c @@ -19,14 +19,13 @@ * contact@openairinterface.org */ -//#include "defs.h" #include <stdio.h> #include <stdlib.h> #include <math.h> //#include "PHY/defs.h" -#include "SIMULATION/TOOLS/defs.h" - +#include "SIMULATION/TOOLS/sim.h" +#include "rf.h" /* extern void randominit(void); extern double gaussdouble(double,double); diff --git a/openair1/SIMULATION/RF/defs.h b/openair1/SIMULATION/RF/rf.h similarity index 98% rename from openair1/SIMULATION/RF/defs.h rename to openair1/SIMULATION/RF/rf.h index 05e74647a06c0f6c4ac17d61369eb76fdb56c841..65055bc71a4257495cec26f333952103b630cd16 100644 --- a/openair1/SIMULATION/RF/defs.h +++ b/openair1/SIMULATION/RF/rf.h @@ -76,7 +76,7 @@ void adc(double *r_re[2], void dac(double *s_re[2], double *s_im[2], - int **input, + unsigned int **input, unsigned int input_offset, unsigned int nb_tx_antennas, unsigned int length, @@ -87,7 +87,7 @@ void dac(double *s_re[2], double dac_fixed_gain(double *s_re[2], double *s_im[2], - int **input, + unsigned int **input, unsigned int input_offset, unsigned int nb_tx_antennas, unsigned int length, diff --git a/openair1/SIMULATION/TOOLS/abstraction.c b/openair1/SIMULATION/TOOLS/abstraction.c index 7e99371c3736dae18f92ac18c2b6536347506087..6b846bb2d5db9e584d54cfd027792506d6363ae8 100644 --- a/openair1/SIMULATION/TOOLS/abstraction.c +++ b/openair1/SIMULATION/TOOLS/abstraction.c @@ -26,8 +26,9 @@ #include <string.h> #include <errno.h> -#include "PHY/TOOLS/defs.h" -#include "defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "PHY/TOOLS/tools_defs.h" +#include "assertions.h" // NEW code with lookup table for sin/cos based on delay profile (TO BE TESTED) diff --git a/openair1/SIMULATION/TOOLS/multipath_channel.c b/openair1/SIMULATION/TOOLS/multipath_channel.c index 757d5023de214d5ae8a823b3a3dd03e6ca045b9e..02f4abbc7e25285ca3cfa291ffdd52cd275e6126 100644 --- a/openair1/SIMULATION/TOOLS/multipath_channel.c +++ b/openair1/SIMULATION/TOOLS/multipath_channel.c @@ -23,8 +23,9 @@ #include <stdlib.h> #include <math.h> #include <string.h> -#include "defs.h" -#include "SIMULATION/RF/defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "SIMULATION/RF/rf.h" +#include "sim.h" //#define DEBUG_CH uint8_t multipath_channel_nosigconv(channel_desc_t *desc) diff --git a/openair1/SIMULATION/TOOLS/multipath_tv_channel.c b/openair1/SIMULATION/TOOLS/multipath_tv_channel.c index c2078b91d478763895c25771f24fe109260e4eb6..daa3462b1c85c1f4cf6ec22fcb29cea1e740c6e3 100644 --- a/openair1/SIMULATION/TOOLS/multipath_tv_channel.c +++ b/openair1/SIMULATION/TOOLS/multipath_tv_channel.c @@ -23,8 +23,8 @@ #include <stdlib.h> #include <math.h> #include <string.h> -#include "defs.h" -#include "SIMULATION/RF/defs.h" +#include "sim.h" +#include "SIMULATION/RF/rf.h" #include <complex.h> void tv_channel(channel_desc_t *desc,double complex ***H,uint16_t length); diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 222a196e20b9c0e171ecd3ac5c5177a88138e889..dc8df153159c58cd75506054941237c4701439fe 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -26,12 +26,14 @@ #include <string.h> -#include "PHY/TOOLS/defs.h" -#include "defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "sim.h" #include "scm_corrmat.h" #include "UTIL/LOG/log.h" //#define DEBUG_CH +#include "assertions.h" + extern void print_shorts(char *s,__m128i *x); void fill_channel_desc(channel_desc_t *chan_desc, @@ -1210,10 +1212,8 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { struct complex anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX]; struct complex phase, alpha, beta; - if ((desc->nb_tx>NB_ANTENNAS_TX) || (desc->nb_rx > NB_ANTENNAS_RX)) { - LOG_E(PHY,"random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); - return(-1); - } + AssertFatal(desc->nb_tx<=NB_ANTENNAS_TX && desc->nb_rx <= NB_ANTENNAS_RX, + "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); start_meas(&desc->random_channel); for (i=0;i<(int)desc->nb_taps;i++) { @@ -1372,8 +1372,7 @@ double N_RB2sampling_rate(uint16_t N_RB) break; default: - LOG_E(PHY,"Unknown N_PRB\n"); - return(-1); + AssertFatal(1==0,"Unknown N_PRB %d",N_RB); } return(sampling_rate); diff --git a/openair1/SIMULATION/TOOLS/rangen_double.c b/openair1/SIMULATION/TOOLS/rangen_double.c index 0fc01a8d3132233ff34502b71466e4a3886adb3a..6dcdd9418e2bf703a1d21d2780c184dc5cd2deeb 100644 --- a/openair1/SIMULATION/TOOLS/rangen_double.c +++ b/openair1/SIMULATION/TOOLS/rangen_double.c @@ -24,7 +24,7 @@ #include <math.h> #include <time.h> -#include "defs.h" +#include "sim.h" static unsigned int seed, iy, ir[98]; /* diff --git a/openair1/SIMULATION/TOOLS/defs.h b/openair1/SIMULATION/TOOLS/sim.h similarity index 99% rename from openair1/SIMULATION/TOOLS/defs.h rename to openair1/SIMULATION/TOOLS/sim.h index a958c6b4ebcfb2737c58f30fff63d6475d8446d3..420e5d0072f193a42057902ceae63d2b54cf1a51 100644 --- a/openair1/SIMULATION/TOOLS/defs.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -21,7 +21,7 @@ #ifndef __SIMULATION_TOOLS_DEFS_H__ #define __SIMULATION_TOOLS_DEFS_H__ -#include "PHY/defs.h" +#include "PHY/defs_common.h" /** @defgroup _numerical_ Useful Numerical Functions *@{ diff --git a/openair2/COMMON/phy_messages_types.h b/openair2/COMMON/phy_messages_types.h index c425efa89cb38b88fe08c804ecbcc11bf0e29ecb..1f040a0a773e00163df53a660af70c799629f5d2 100644 --- a/openair2/COMMON/phy_messages_types.h +++ b/openair2/COMMON/phy_messages_types.h @@ -29,10 +29,8 @@ #ifndef PHY_MESSAGES_TYPES_H_ #define PHY_MESSAGES_TYPES_H_ -#include "PHY/impl_defs_lte.h" -#if ENABLE_RAL -#include "ral_messages_types.h" //LG: MIH moved from repository/trunk to repository/extras -#endif +#include "PHY/defs_common.h" + //-------------------------------------------------------------------------------------------// // Defines to access message fields. #define PHY_CONFIGURATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.phy_configuration_req diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index 4debccc7b05075ce37e830420336551a29c6c323..20a7d5ecd20c52e114546305d77382bed796a3af 100644 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -69,10 +69,12 @@ #ifdef LARGE_SCALE # define MAX_MOBILES_PER_ENB 128 -//# define MAX_RG 2 +# define MAX_MOBILES_PER_ENB_NB_IoT 128 +# define MAX_eNB 2 #else # define MAX_MOBILES_PER_ENB 16 -//# define MAX_RG 2 +# define MAX_MOBILES_PER_ENB_NB_IoT 16 +# define MAX_eNB 2 #endif #define MAX_MANAGED_ENB_PER_MOBILE 2 diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 6cb79efb11ce90b8410bb2d14e7659711b5d0b2f..0545eeb3be11e59522aebcafb3161b4aaa61e60a 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -34,7 +34,7 @@ #include "flexran_agent_timer.h" #include "flexran_agent_ran_api.h" -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "liblfds700.h" @@ -836,7 +836,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle Protocol__FlexHeader *header = NULL; int i, j, UE_id; - int available_harq[NUMBER_OF_UE_MAX]; + int available_harq[MAX_MOBILES_PER_ENB]; const int xid = *((int *)params); @@ -854,7 +854,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle frame_t frame; sub_frame_t subframe; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { available_harq[i] = -1; } @@ -878,7 +878,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle sf_trigger_msg->n_dl_info = 0; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { for (j = 0; j < 8; j++) { if (RC.mac && RC.mac[mod_id] && RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid == 1) { available_harq[i] = j; @@ -904,7 +904,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle goto error; i = -1; //Fill the status of the current HARQ process for each UE - for(UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for(UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (available_harq[UE_id] < 0) { continue; } else { @@ -1262,7 +1262,7 @@ void flexran_agent_init_mac_agent(mid_t mod_id) { //Allow RINGBUFFER_SIZE messages to be stored in the ringbuffer at any time dl_mac_config_array[mod_id] = malloc( sizeof(struct lfds700_ringbuffer_element) * num_elements); lfds700_ringbuffer_init_valid_on_current_logical_core( &ringbuffer_state[mod_id], dl_mac_config_array[mod_id], num_elements, &ps[mod_id], NULL ); - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { for (j = 0; j < 8; j++) { if (RC.mac && RC.mac[mod_id]) RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid = 0; diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c index 43455fa32a4043edeac6eda7c869b0fe2c783348..b2723f718126973f96d972a3284b995c5e99c3e2 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c @@ -37,7 +37,7 @@ unsigned int pdcp_agent_registered[NUM_MAX_ENB]; /*Array containing the Agent-PDCP interfaces*/ AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB]; -// NUMBER_OF_UE_MAX +// MAX_MOBILES_PER_ENB void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id, const mid_t ue_id, diff --git a/openair2/ENB_APP/NB_IoT_interface.c b/openair2/ENB_APP/NB_IoT_interface.c index 30ffbb3bb550f6fdcb1cc19075e120df2dac5d9b..c4884453c2e9cc03d62f5c4e454bd3a3dd3f57fb 100644 --- a/openair2/ENB_APP/NB_IoT_interface.c +++ b/openair2/ENB_APP/NB_IoT_interface.c @@ -30,7 +30,7 @@ #include <sys/types.h> -#include "openair1/PHY/extern.h" +#include "openair1/PHY/phy_extern.h" #include "common/utils/load_module_shlib.h" #define NBIOT_INTERFACE_SOURCE #include "NB_IoT_interface.h" diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 481bfaa521e961ce08466ff427be69c58e6a259d..b3471d2637193b5be594ede68816fecf78cb5dc6 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -46,6 +46,7 @@ # include "gtpv1u_eNB_task.h" # endif +#include "openair1/PHY/INIT/phy_init.h" extern unsigned char NB_eNB_INST; #endif diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index fd6575f3045c3ef4a403d6b3c4ed5d9a5c2897f3..a63f5f6e5e0cd7be77a83248c3ffe281254338e1 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -45,9 +45,10 @@ #endif #include "sctp_default_values.h" #include "SystemInformationBlockType2.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" -#include "PHY/extern.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "PHY/phy_extern.h" +#include "PHY/INIT/phy_init.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" #include "nfapi_vnf.h" #include "nfapi_pnf.h" @@ -383,8 +384,10 @@ void RCconfig_macrlc() { RC.nb_macrlc_inst=MacRLC_ParamList.numelt; mac_top_init_eNB(); - for (j=0;j<RC.nb_macrlc_inst;j++) { + RC.nb_mac_CC = (int*)malloc(RC.nb_macrlc_inst*sizeof(int)); + for (j=0;j<RC.nb_macrlc_inst;j++) { + RC.nb_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr); //RC.mac[j]->phy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr); //printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j); diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h index a7eb9f3cddfd414ae3073e035bd44d478b989924..aeac43ee1c7d9e52f80364dc3c7ddf544b257ec8 100644 --- a/openair2/ENB_APP/enb_config.h +++ b/openair2/ENB_APP/enb_config.h @@ -38,7 +38,7 @@ #include "platform_types.h" #include "platform_constants.h" #include "PHY/impl_defs_lte.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "s1ap_messages_types.h" #ifdef CMAKER #include "SystemInformationBlockType2.h" @@ -47,7 +47,7 @@ #include "RRC/LITE/MESSAGES/SystemInformationBlockType2.h" #endif #include "intertask_interface_types.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\ struct in_addr inp;\ diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 4b0a22300fc5064e21e68dd4664e48a0ce977207..3bbea167d37dfacf1e8e2ca6cc0c576a2918f18d 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -35,11 +35,11 @@ #include "flexran_agent_extern.h" #include "flexran_agent_net_comm.h" #include "flexran_agent_ran_api.h" -#include "PHY/extern.h" +//#include "PHY/extern.h" #include "log.h" -#include "SCHED/defs.h" -#include "RRC/LITE/extern.h" +//#include "SCHED/defs.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rrc_eNB_UE_context.h" diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h index 242cb55ca86364db4254f250a6a97657ad73e71d..057c5b9489a7332a9cdb8923f3abeb58a44f7d46 100644 --- a/openair2/ENB_APP/flexran_agent_common.h +++ b/openair2/ENB_APP/flexran_agent_common.h @@ -42,7 +42,6 @@ #include "flexran_agent_defs.h" #include "enb_config.h" -#include "LAYER2/MAC/extern.h" #include "LAYER2/RLC/rlc.h" # include "tree.h" diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 9766d315a7fec8237738a47e93f20c1b20eb9560..2e5bccd93514671481c537884190448238a19a13 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -1219,7 +1219,7 @@ void flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint /*PDCP num tx pdu status flexRAN*/ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> NUMBER_OF_UE_MAX || lcid<0 || lcid>NB_RB_MAX) + if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> MAX_MOBILES_PER_ENB || lcid<0 || lcid>NB_RB_MAX) return -1; return Pdcp_stats_tx[mod_id][ue_id][lcid]; } diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 4e5f214af00f133cc2d2485589b17650f7af0712..3354d8ace875da91ed0dc6fc9b53f5fca5225877 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -36,14 +36,13 @@ #include "enb_config.h" -#include "LAYER2/MAC/extern.h" #include "LAYER2/RLC/rlc.h" -#include "SCHED/defs.h" +#include "SCHED/sched_eNB.h" #include "pdcp.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "RRC/LITE/rrc_eNB_UE_context.h" -#include "PHY/extern.h" +#include "RRC/LTE/rrc_eNB_UE_context.h" +#include "PHY/phy_extern.h" #include "log.h" /**************************** diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 42ed105f23b3c507416b0508e292fd6efcb9c8c5..6be1c948c94c1b45629ddf086cf7b3f20ec22882 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -32,7 +32,6 @@ #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" -#include "SCHED/defs.h" #include "SystemInformationBlockType2.h" //#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" @@ -43,9 +42,9 @@ #include "MeasObjectToAddModList.h" #include "TDD-Config.h" #include "MAC-MainConfig.h" -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" diff --git a/openair2/LAYER2/MAC/config_ue.c b/openair2/LAYER2/MAC/config_ue.c index d91792c567a2df8395879850c1f8f6dcb018aaae..2c8e6785f72de96d79372d5b2d0cf55ee2a60afe 100644 --- a/openair2/LAYER2/MAC/config_ue.c +++ b/openair2/LAYER2/MAC/config_ue.c @@ -32,7 +32,7 @@ #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" -#include "SCHED/defs.h" +#include "SCHED_UE/sched_UE.h" #include "SystemInformationBlockType2.h" //#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" @@ -43,9 +43,9 @@ #include "MeasObjectToAddModList.h" #include "TDD-Config.h" #include "MAC-MainConfig.h" -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" diff --git a/openair2/LAYER2/MAC/defs_NB_IoT.h b/openair2/LAYER2/MAC/defs_NB_IoT.h index 77c0828b283076bd4edce975379dfe99f4bbd321..02f9c47ea5cdc7d0443cd13c64492460014d4adb 100644 --- a/openair2/LAYER2/MAC/defs_NB_IoT.h +++ b/openair2/LAYER2/MAC/defs_NB_IoT.h @@ -98,7 +98,7 @@ typedef enum{ DL }message_direction_t; -#define MAX_NUMBER_OF_UE_MAX_NB_IoT 20 +#define MAX_MAX_MOBILES_PER_ENB_NB_IoT 20 #define SCH_PAYLOAD_SIZE_MAX_NB_IoT 320 #define MAX_NUMBER_OF_SIBs_NB_IoT 16 @@ -233,17 +233,17 @@ typedef struct{ typedef struct { /// DCI template and MAC connection parameters for UEs - UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; /// NPDCCH Period and searching space info NPDCCH_config_dedicated_NB_IoT_t NPDCCH_config_dedicated; - //int next[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + //int next[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; // -1:No UE in list int head; // -1:No UE in list int tail; int num_UEs; - //boolean_t active[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + //boolean_t active[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; } UE_list_NB_IoT_t; @@ -261,7 +261,7 @@ typedef struct{ // flag to indicate scheduling type1 NPDCCH CSS with different CE level uint8_t flag_type1_css[3]; // flag to indicate scheduling NPDCCH USS with UE list - uint8_t flag_uss[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + uint8_t flag_uss[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; // flag to indicate scheduling sib1/MIB uint8_t flag_fix_scheduling; // number of the type2 css to schedule in this period @@ -494,7 +494,7 @@ typedef struct eNB_MAC_INST_NB_IoT_s { RA_template_list_t RA_msg3_list; RA_template_list_t RA_msg4_list; - RA_TEMPLATE_NB_IoT RA_template[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + RA_TEMPLATE_NB_IoT RA_template[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; //int32_t last_tx_subframe; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 7dda39cce7fb4496b84337b19c3b252a6a57d85f..f2aed56146e8dcff7b282fe42433a729cacd3aba 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -30,23 +30,18 @@ */ #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" - -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -60,6 +55,8 @@ #include "intertask_interface.h" #endif +#include "assertions.h" + #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 @@ -72,6 +69,8 @@ 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) { + + eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list = &eNB->UE_list; nfapi_ul_config_request_body_t *ul_req; @@ -90,140 +89,148 @@ schedule_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) 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 - } + 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 < MAX_MOBILES_PER_ENB; UE_id++) { + if (!RC.mac[module_idP]->UE_list.active[UE_id]) 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) { - 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 - #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++) { + 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 < MAX_MOBILES_PER_ENB; UE_id++) { + if (!UE_list->active[UE_id]) 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 +#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++) { } void @@ -244,8 +251,8 @@ schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) 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; + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { + if (!RC.mac[module_idP]->UE_list.active[UE_id]) continue; ul_req = &RC.mac[module_idP]->UL_req[CC_id]; ul_req_body = &ul_req->ul_config_request_body; @@ -519,96 +526,95 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, cc[CC_id].mcch_active = 0; #endif - clear_nfapi_information(RC.mac[module_idP], CC_id, 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&127) == 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 (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + if (UE_list->active[i]) { + + rnti = UE_RNTI(module_idP, i); + CC_id = UE_PCCID(module_idP, i); + + if (((frameP&127) == 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 < MAX_MOBILES_PER_ENB; 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); + // Note: This should not be done in the MAC! + for (int ii=0; ii<MAX_MOBILES_PER_ENB; 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 ii=0; ii<MAX_MOBILES_PER_ENB; 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)); + + 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--; } - 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); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index b71683cfb6c53ebe72ad46c45cbcf48e70e61cbb..9956ddd2c81495e51d079f38bb9017a902ee3fa2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -34,24 +34,19 @@ #include "assertions.h" #include "platform_types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" #include "msc.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" - -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -61,10 +56,14 @@ #include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #include "T.h" +#include "common/ran_context.h" + +extern RAN_CONTEXT_t RC; + extern uint8_t nfapi_mode; extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); @@ -1511,18 +1510,18 @@ initiate_ra_proc(module_id_t module_idP, /* 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 }; + static int drnti[MAX_MOBILES_PER_ENB] = { 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++) { + for (j = 0; j < MAX_MOBILES_PER_ENB; 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"); + if (nb_ue >= MAX_MOBILES_PER_ENB) { + printf("No more free RNTI available, increase MAX_MOBILES_PER_ENB\n"); abort(); } ra[i].rnti = drnti[nb_ue]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index b6253034fc9ad51d759fc7d8222c88ef52f5752d..099157d9d76e5e93d488178eaf16917d5cdd01f7 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -30,22 +30,16 @@ */ #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -58,6 +52,9 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +#include "common/ran_context.h" + +extern RAN_CONTEXT_t RC; // NEED TO ADD schedule_SI_BR for SIB1_BR and SIB23_BR // CCE_allocation_infeasible to be done for EPDCCH/MPDCCH diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index dcc41ce3eb3014e2aaad1b0ec5d7a1f01a7b7e61..6377c990d9ce85fe69585da4fe2bddc89fb36524 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -29,29 +29,25 @@ */ -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus + +#include "assertions.h" #if defined(ENABLE_ITTI) #include "intertask_interface.h" @@ -1801,7 +1797,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) 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++) { + for (uint16_t i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_PF_PO[CC_id][i].enable_flag != TRUE) { continue; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index 9e2deca20252a554446944cd7defdde471949f69..71b9dfd5429f1a0b66b15e6bcfc0dbbe58bb14ed 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -29,36 +29,32 @@ */ -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" +#include "assertions.h" #if defined(ENABLE_ITTI) #include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +#include "common/ran_context.h" extern RAN_CONTEXT_t RC; @@ -662,7 +658,7 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, ); - //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]); + //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, MBMS_FLAG_NO, MTCH+(MAX_NUM_RB*(MAX_MOBILES_PER_ENB+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); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index e6258593245ea368c65d386e26dc6cc0aa5a362f..9532222fb8a7359ae988e3cb2ab546f8fb782901 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -30,22 +30,21 @@ */ #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "SCHED/sched_eNB.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #include "T.h" diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 110afc1a5ad287af94d87ac4aa071f7d97aee01f..ae8524dd5932825e8125d37513783bf88e707887 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -30,23 +30,18 @@ */ #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" - -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -61,6 +56,10 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +#include "common/ran_context.h" + +extern RAN_CONTEXT_t RC; + extern int n_active_slices; int choose(int n, int k) @@ -984,6 +983,8 @@ get_rel8_dl_cqi_pmi_size(UE_sched_ctrl * sched_ctl, int CC_idP, 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, @@ -1666,7 +1667,7 @@ void init_ue_sched_info(void) 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++) { + for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { // init DL eNB_dlsch_info[i][k][j].weight = 0; eNB_dlsch_info[i][k][j].subframe = 0; @@ -1697,7 +1698,7 @@ 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++) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; if (UE_list->UE_template[UE_PCCID(mod_idP, UE_id)][UE_id].rnti == @@ -1838,7 +1839,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP, int harq_pidP 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++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] == TRUE) continue; UE_id = i; @@ -2324,9 +2325,7 @@ int get_bw_index(module_id_t module_id, uint8_t CC_id) { 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 @@ -2359,9 +2358,7 @@ int get_bw_index(module_id_t module_id, uint8_t CC_id) 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 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 diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 9ccb0e66ab149bb333d46da09ac923515321d2d9..fd2817e3418b9ae79dca316c06c2a28ae29bb094 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -31,25 +31,21 @@ /* indented with: indent -kr eNB_scheduler_RA.c */ -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "assertions.h" //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" @@ -144,7 +140,7 @@ rx_sdu(const module_id_t enb_mod_idP, start_meas(&mac->rx_ulsch_sdu); - if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1)) + if ((UE_id > MAX_MOBILES_PER_ENB) || (UE_id == -1)) for (ii = 0; ii < NB_RB_MAX; ii++) { rx_lengths[ii] = 0; } diff --git a/openair2/LAYER2/MAC/l1_helpers.c b/openair2/LAYER2/MAC/l1_helpers.c index 6e71f66ec5f56d32a52863db3fde89d6594b9b20..0cb5c17f0f6984f22c1ac3cbb77c74b1770aa394 100644 --- a/openair2/LAYER2/MAC/l1_helpers.c +++ b/openair2/LAYER2/MAC/l1_helpers.c @@ -29,10 +29,10 @@ */ -#include "defs.h" -#include "extern.h" +#include "mac.h" +#include "mac_extern.h" #include "UTIL/LOG/log.h" -#include "proto.h" +#include "mac_proto.h" int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id) { @@ -54,6 +54,52 @@ int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id) 1) + get_DELTA_PREAMBLE(module_idP, CC_id)); } +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; + } + } else { // FDD + preambleformat = prachConfigIndex >> 2; + } + + switch (preambleformat) { + case 0: + case 1: + return (0); + + case 2: + case 3: + return (-3); + + case 4: + return (8); + + default: + AssertFatal(1 == 0, + "[UE %d] ue_procedures.c: FATAL, Illegal preambleformat %d, prachConfigIndex %d\n", + module_idP, preambleformat, prachConfigIndex); + } + +} + int8_t get_deltaP_rampup(module_id_t module_idP, uint8_t CC_id) { diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/mac.h similarity index 85% rename from openair2/LAYER2/MAC/defs.h rename to openair2/LAYER2/MAC/mac.h index 99f75175190a803d26e0f6a6c613a79e97cb7a32..c2dfc5992b70c8e115b2824f98419ae2f3757cdf 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/mac.h @@ -43,11 +43,10 @@ #include <stdlib.h> #include <string.h> -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/defs.h" #include "COMMON/platform_constants.h" #include "BCCH-BCH-Message.h" #include "RadioResourceConfigCommon.h" +#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" #include "MeasGapConfig.h" #include "SchedulingInfoList.h" @@ -69,6 +68,13 @@ #include "nfapi_interface.h" #include "PHY_INTERFACE/IF_Module.h" +#include "PHY/TOOLS/time_meas.h" + +#include "PHY/defs_common.h" // for PRACH_RESOURCES_t +#include "PHY/LTE_TRANSPORT/transport_common.h" + +#include "targets/ARCH/COMMON/common_lib.h" + /** @defgroup _mac MAC * @ingroup _oai2 * @{ @@ -491,15 +497,12 @@ typedef struct { uint16_t Pdu_size; } __attribute__ ((__packed__)) ULSCH_PDU; - /*! \brief Uplink SCH PDU Structure */ typedef struct { int8_t payload[DCH_PAYLOAD_SIZE_MAX]; /*!< \brief SACH payload */ uint16_t Pdu_size; } __attribute__ ((__packed__)) ULDCH_PDU; -#include "PHY/impl_defs_top.h" - /*!\brief RA process state*/ typedef enum { IDLE = 0, @@ -921,8 +924,8 @@ typedef struct { ///Contention resolution timer used during random access uint8_t mac_ContentionResolutionTimer; - uint16_t max_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; - uint16_t max_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; + uint16_t max_rbs_allowed_slice[NFAPI_CC_MAX][MAX_NUM_SLICES]; + uint16_t max_rbs_allowed_slice_uplink[NFAPI_CC_MAX][MAX_NUM_SLICES]; uint8_t max_mcs[MAX_NUM_LCID]; @@ -931,14 +934,14 @@ typedef struct { // resource scheduling information /// Current DL harq round per harq_pid on each CC - uint8_t round[MAX_NUM_CCs][10]; + uint8_t round[NFAPI_CC_MAX][10]; /// Current Active TBs per harq_pid on each CC - uint8_t tbcnt[MAX_NUM_CCs][10]; + uint8_t tbcnt[NFAPI_CC_MAX][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]; + uint8_t round_UL[NFAPI_CC_MAX][8]; + uint8_t dl_pow_off[NFAPI_CC_MAX]; + uint16_t pre_nb_available_rbs[NFAPI_CC_MAX]; + unsigned char rballoc_sub_UE[NFAPI_CC_MAX][N_RBG_MAX]; uint16_t ta_timer; int16_t ta_update; uint16_t ul_consecutive_errors; @@ -1053,34 +1056,34 @@ typedef struct { typedef struct { /// Dedicated information for UEs struct PhysicalConfigDedicated - *physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + *physicalConfigDedicated[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// DLSCH pdu - DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX]; + DLSCH_PDU DLSCH_pdu[NFAPI_CC_MAX][2][MAX_MOBILES_PER_ENB]; /// DCI template and MAC connection parameters for UEs - UE_TEMPLATE UE_template[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + UE_TEMPLATE UE_template[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// DCI template and MAC connection for RA processes - int pCC_id[NUMBER_OF_UE_MAX]; + int pCC_id[MAX_MOBILES_PER_ENB]; /// sorted downlink component carrier for the scheduler - int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + int ordered_CCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// number of downlink active component carrier - int numactiveCCs[NUMBER_OF_UE_MAX]; + int numactiveCCs[MAX_MOBILES_PER_ENB]; /// sorted uplink component carrier for the scheduler - int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + int ordered_ULCCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// number of uplink active component carrier - int numactiveULCCs[NUMBER_OF_UE_MAX]; + int numactiveULCCs[MAX_MOBILES_PER_ENB]; /// number of downlink active component carrier - uint8_t dl_CC_bitmap[NUMBER_OF_UE_MAX]; + uint8_t dl_CC_bitmap[MAX_MOBILES_PER_ENB]; /// eNB to UE statistics - eNB_UE_STATS eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + eNB_UE_STATS eNB_UE_stats[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// scheduling control info - UE_sched_ctrl UE_sched_ctrl[NUMBER_OF_UE_MAX]; - int next[NUMBER_OF_UE_MAX]; + UE_sched_ctrl UE_sched_ctrl[MAX_MOBILES_PER_ENB]; + int next[MAX_MOBILES_PER_ENB]; int head; - int next_ul[NUMBER_OF_UE_MAX]; + int next_ul[MAX_MOBILES_PER_ENB]; int head_ul; int avail; int num_UEs; - boolean_t active[NUMBER_OF_UE_MAX]; + boolean_t active[MAX_MOBILES_PER_ENB]; /// Sorting criteria for the UE list in the MAC preprocessor uint16_t sorting_criteria[MAX_NUM_SLICES][CR_NUM]; @@ -1161,84 +1164,82 @@ typedef struct { /*! \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]; - /// flag to enable phy-test (disables the scheduler) - uint16_t phy_test; - - /// 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; + 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[NFAPI_CC_MAX]; + /// current PDU index (BCH,MCH,DLSCH) + uint16_t pdu_index[NFAPI_CC_MAX]; + + /// NFAPI Config Request Structure + nfapi_config_request_t config[NFAPI_CC_MAX]; + /// Preallocated DL pdu list + nfapi_dl_config_request_pdu_t + dl_config_pdu_list[NFAPI_CC_MAX][MAX_NUM_DL_PDU]; + /// NFAPI DL Config Request Structure + nfapi_dl_config_request_t DL_req[NFAPI_CC_MAX]; + /// Preallocated UL pdu list + nfapi_ul_config_request_pdu_t + ul_config_pdu_list[NFAPI_CC_MAX][MAX_NUM_UL_PDU]; + /// Preallocated UL pdu list for ULSCH (n+k delay) + nfapi_ul_config_request_pdu_t + ul_config_pdu_list_tmp[NFAPI_CC_MAX][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[NFAPI_CC_MAX]; + /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests + nfapi_ul_config_request_t UL_req_tmp[NFAPI_CC_MAX][10]; + /// Preallocated HI_DCI0 pdu list + nfapi_hi_dci0_request_pdu_t + hi_dci0_pdu_list[NFAPI_CC_MAX][MAX_NUM_HI_DCI0_PDU]; + /// NFAPI HI/DCI0 Config Request Structure + nfapi_hi_dci0_request_t HI_DCI0_req[NFAPI_CC_MAX]; + /// Prealocated TX pdu list + nfapi_tx_request_pdu_t + tx_request_pdu[NFAPI_CC_MAX][MAX_NUM_TX_REQUEST_PDU]; + /// NFAPI DL PDU structure + nfapi_tx_request_t TX_req[NFAPI_CC_MAX]; + /// 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[NFAPI_CC_MAX][800]; + /// active flag for Other lcid + uint8_t lcid_active[NB_RB_MAX]; + /// eNB stats + eNB_STATS eNB_stats[NFAPI_CC_MAX]; + // 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; /* @@ -1377,27 +1378,26 @@ typedef struct { uint32_t SL_LCID[MAX_NUM_LCID]; #endif - /// pointer to TDD Configuration (NULL for FDD) - TDD_Config_t *tdd_Config; - /// Number of adjacent cells to measure - uint8_t n_adj_cells; - /// Array of adjacent physical cell ids - uint32_t adj_cell_id[6]; - /// Pointer to RRC MAC configuration - MAC_MainConfig_t *macConfig; - /// Pointer to RRC Measurement gap configuration - MeasGapConfig_t *measGapConfig; - /// Pointers to LogicalChannelConfig indexed by LogicalChannelIdentity. Note NULL means LCHAN is inactive. - LogicalChannelConfig_t *logicalChannelConfig[MAX_NUM_LCID]; - - /// Scheduling Information - UE_SCHEDULING_INFO scheduling_info; - /// Outgoing CCCH pdu for PHY - CCCH_PDU CCCH_pdu; - /// Outgoing RAR pdu for PHY - RAR_PDU RAR_pdu; - /// Incoming DLSCH pdu for PHY - DLSCH_PDU DLSCH_pdu[NUMBER_OF_UE_MAX][2]; + /// pointer to TDD Configuration (NULL for FDD) + TDD_Config_t *tdd_Config; + /// Number of adjacent cells to measure + uint8_t n_adj_cells; + /// Array of adjacent physical cell ids + uint32_t adj_cell_id[6]; + /// Pointer to RRC MAC configuration + MAC_MainConfig_t *macConfig; + /// Pointer to RRC Measurement gap configuration + MeasGapConfig_t *measGapConfig; + /// Pointers to LogicalChannelConfig indexed by LogicalChannelIdentity. Note NULL means LCHAN is inactive. + LogicalChannelConfig_t *logicalChannelConfig[MAX_NUM_LCID]; + /// Scheduling Information + UE_SCHEDULING_INFO scheduling_info; + /// Outgoing CCCH pdu for PHY + CCCH_PDU CCCH_pdu; + /// Outgoing RAR pdu for PHY + RAR_PDU RAR_pdu; + /// Incoming DLSCH pdu for PHY + DLSCH_PDU DLSCH_pdu[MAX_MOBILES_PER_ENB][2]; #ifdef Rel14 int sltx_active; SLSCH_t slsch; @@ -1405,58 +1405,58 @@ typedef struct { ULSCH_PDU slsch_pdu; int slsch_lcid; #endif - /// number of attempt for rach - uint8_t RA_attempt_number; - /// Random-access procedure flag - uint8_t RA_active; - /// Random-access window counter - int8_t RA_window_cnt; - /// Random-access Msg3 size in bytes - uint8_t RA_Msg3_size; - /// Random-access prachMaskIndex - uint8_t RA_prachMaskIndex; - /// Flag indicating Preamble set (A,B) used for first Msg3 transmission - uint8_t RA_usedGroupA; - /// Random-access Resources - PRACH_RESOURCES_t RA_prach_resources; - /// Random-access PREAMBLE_TRANSMISSION_COUNTER - uint8_t RA_PREAMBLE_TRANSMISSION_COUNTER; - /// Random-access backoff counter - int16_t RA_backoff_cnt; - /// Random-access variable for window calculation (frame of last change in window counter) - uint32_t RA_tx_frame; - /// Random-access variable for window calculation (subframe of last change in window counter) - uint8_t RA_tx_subframe; - /// Random-access Group B maximum path-loss - /// Random-access variable for backoff (frame of last change in backoff counter) - uint32_t RA_backoff_frame; - /// Random-access variable for backoff (subframe of last change in backoff counter) - uint8_t RA_backoff_subframe; - /// Random-access Group B maximum path-loss - uint16_t RA_maxPL; - /// Random-access Contention Resolution Timer active flag - uint8_t RA_contention_resolution_timer_active; - /// Random-access Contention Resolution Timer count value - uint8_t RA_contention_resolution_cnt; - /// power headroom reporitng reconfigured - uint8_t PHR_reconfigured; - /// power headroom state as configured by the higher layers - uint8_t PHR_state; - /// power backoff due to power management (as allowed by P-MPRc) for this cell - uint8_t PHR_reporting_active; - /// power backoff due to power management (as allowed by P-MPRc) for this cell - uint8_t power_backoff_db[NUMBER_OF_eNB_MAX]; - /// BSR report falg management - uint8_t BSR_reporting_active; - /// retxBSR-Timer expires flag - uint8_t retxBSRTimer_expires_flag; - /// periodBSR-Timer expires flag - uint8_t periodBSRTimer_expires_flag; - - /// MBSFN_Subframe Configuration - struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? - /// number of subframe allocation pattern available for MBSFN sync area - uint8_t num_sf_allocation_pattern; + /// number of attempt for rach + uint8_t RA_attempt_number; + /// Random-access procedure flag + uint8_t RA_active; + /// Random-access window counter + int8_t RA_window_cnt; + /// Random-access Msg3 size in bytes + uint8_t RA_Msg3_size; + /// Random-access prachMaskIndex + uint8_t RA_prachMaskIndex; + /// Flag indicating Preamble set (A,B) used for first Msg3 transmission + uint8_t RA_usedGroupA; + /// Random-access Resources + PRACH_RESOURCES_t RA_prach_resources; + /// Random-access PREAMBLE_TRANSMISSION_COUNTER + uint8_t RA_PREAMBLE_TRANSMISSION_COUNTER; + /// Random-access backoff counter + int16_t RA_backoff_cnt; + /// Random-access variable for window calculation (frame of last change in window counter) + uint32_t RA_tx_frame; + /// Random-access variable for window calculation (subframe of last change in window counter) + uint8_t RA_tx_subframe; + /// Random-access Group B maximum path-loss + /// Random-access variable for backoff (frame of last change in backoff counter) + uint32_t RA_backoff_frame; + /// Random-access variable for backoff (subframe of last change in backoff counter) + uint8_t RA_backoff_subframe; + /// Random-access Group B maximum path-loss + uint16_t RA_maxPL; + /// Random-access Contention Resolution Timer active flag + uint8_t RA_contention_resolution_timer_active; + /// Random-access Contention Resolution Timer count value + uint8_t RA_contention_resolution_cnt; + /// power headroom reporitng reconfigured + uint8_t PHR_reconfigured; + /// power headroom state as configured by the higher layers + uint8_t PHR_state; + /// power backoff due to power management (as allowed by P-MPRc) for this cell + uint8_t PHR_reporting_active; + /// power backoff due to power management (as allowed by P-MPRc) for this cell + uint8_t power_backoff_db[MAX_eNB]; + /// BSR report falg management + uint8_t BSR_reporting_active; + /// retxBSR-Timer expires flag + uint8_t retxBSRTimer_expires_flag; + /// periodBSR-Timer expires flag + uint8_t periodBSRTimer_expires_flag; + + /// MBSFN_Subframe Configuration + struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? + /// 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; @@ -1511,8 +1511,6 @@ typedef struct { uint8_t n_adj_cells; } neigh_cell_id_t; - - -#include "proto.h" +#include "mac_proto.h" /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/mac_extern.h similarity index 73% rename from openair2/LAYER2/MAC/extern.h rename to openair2/LAYER2/MAC/mac_extern.h index e7489ca8e6fffcabb25c34cbb188b1dc7f25dd7c..4ac7cf4d58e79ca0363cd9d813232135b551b9f1 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/mac_extern.h @@ -32,10 +32,10 @@ #ifndef __MAC_EXTERN_H__ #define __MAC_EXTERN_H__ -#include "PHY/defs.h" -#include "defs.h" +//#include "PHY/defs_common.h" +#include "mac.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; //extern uint32_t EBSR_Level[63]; @@ -52,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][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 +extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 @@ -75,26 +75,5 @@ extern uint32_t RRC_CONNECTION_FLAG; extern uint8_t rb_table[34]; -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 CCCH_alloc_pdu; -extern DCI1_5MHz_TDD_t DLSCH_alloc_pdu; - -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 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/proto.h b/openair2/LAYER2/MAC/mac_proto.h similarity index 98% rename from openair2/LAYER2/MAC/proto.h rename to openair2/LAYER2/MAC/mac_proto.h index b5cc7917b0f22af059c0b9f5e24f977d46120abd..01a7783d14fbc27193672aa487d54c50fc313356 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/mac_proto.h @@ -29,7 +29,8 @@ #ifndef __LAYER2_MAC_PROTO_H__ #define __LAYER2_MAC_PROTO_H__ -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" +#include "PHY/defs_common.h" // for PRACH_RESOURCES_t and lte_subframe_t /** \addtogroup _mac * @{ @@ -210,13 +211,13 @@ void dlsch_scheduler_pre_processor_reset(int module_idP, int UE_id, int subframeP, int N_RBG, uint16_t - nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], + nb_rbs_required[NFAPI_CC_MAX] + [MAX_MOBILES_PER_ENB], unsigned char - rballoc_sub[MAX_NUM_CCs] + rballoc_sub[NFAPI_CC_MAX] [N_RBG_MAX], unsigned char - MIMO_mode_indicator[MAX_NUM_CCs] + MIMO_mode_indicator[NFAPI_CC_MAX] [N_RBG_MAX]); // eNB functions @@ -232,7 +233,7 @@ void dlsch_scheduler_pre_processor(module_id_t module_idP, slice_id_t slice_idP, frame_t frameP, sub_frame_t subframe, - int N_RBG[MAX_NUM_CCs], + int N_RBG[NFAPI_CC_MAX], int *mbsfn_flag); @@ -243,19 +244,10 @@ void dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, 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]); + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + uint16_t nb_rbs_required_remaining[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + unsigned char rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX], + unsigned char MIMO_mode_indicator[NFAPI_CC_MAX][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. @@ -673,8 +665,6 @@ uint8_t *parse_ulsch_header(uint8_t * mac_header, 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 mac_init(void); int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti, int harq_pid #ifdef Rel14 diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/mac_vars.h similarity index 95% rename from openair2/LAYER2/MAC/vars.h rename to openair2/LAYER2/MAC/mac_vars.h index d153c82aeeef2e2ed132cd7c790ffd10150d18d5..f90ba1ec9e1c2e2d86abae45b8173eccc6a779e1 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/mac_vars.h @@ -32,8 +32,8 @@ #ifndef __MAC_VARS_H__ #define __MAC_VARS_H__ -#include "PHY/defs.h" -#include "defs.h" +#include "PHY/defs_common.h" +#include "mac.h" #include "COMMON/mac_rrc_primitives.h" const uint32_t BSR_TABLE[BSR_TABLE_SIZE] = @@ -103,8 +103,8 @@ 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][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 +eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 #ifdef OPENAIR2 diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index afee1632031a2da102c39c739aa18bc3dd260640..062ead2a206d1e6db672afc02d60785e3b628abd 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -29,21 +29,18 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "assertions.h" -#include "PHY_INTERFACE/extern.h" -#include "PHY/defs.h" -#include "SCHED/defs.h" +//#include "PHY_INTERFACE/phy_extern.h" +//#include "PHY/defs_eNB.h" +//#include "SCHED/sched_eNB.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_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 RAN_CONTEXT_t RC; @@ -123,7 +120,7 @@ void mac_top_init_eNB(void) UE_list->head_ul = -1; UE_list->avail = 0; - for (list_el = 0; list_el < NUMBER_OF_UE_MAX - 1; list_el++) { + for (list_el = 0; list_el < MAX_MOBILES_PER_ENB - 1; list_el++) { UE_list->next[list_el] = list_el + 1; UE_list->next_ul[list_el] = list_el + 1; } @@ -147,7 +144,7 @@ void mac_init_cell_params(int Mod_idP, int CC_idP) UE_template = (UE_TEMPLATE *) & RC.mac[Mod_idP]->UE_list.UE_template[CC_idP][0]; - for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + for (j = 0; j < MAX_MOBILES_PER_ENB; 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, diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c index 64326dec614dc9ea452c7ce7bebf73692050167b..272ca5cddd7c953ed87bc458f9018451c161d0f1 100644 --- a/openair2/LAYER2/MAC/main_ue.c +++ b/openair2/LAYER2/MAC/main_ue.c @@ -29,20 +29,18 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "assertions.h" -#include "PHY_INTERFACE/extern.h" -#include "PHY/defs.h" -#include "SCHED/defs.h" +#include "PHY_INTERFACE/phy_interface_extern.h" +#include "PHY/defs_UE.h" +#include "SCHED_UE/sched_UE.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_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" diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 245598cb549deb2204efab7771312d1bd20d12f1..68b054a8382e8be8f915e871073b49164336fc73 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -33,24 +33,21 @@ #include <stdlib.h> #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rlc.h" +#include "common/ran_context.h" + +extern RAN_CONTEXT_t RC; #define DEBUG_eNB_SCHEDULER 1 #define DEBUG_HEADER_PARSING 1 @@ -107,7 +104,7 @@ store_dlsch_buffer(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, 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++) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; @@ -196,8 +193,8 @@ 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]) + nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + int min_rb_unit[NFAPI_CC_MAX]) { uint16_t TBS = 0; @@ -208,7 +205,7 @@ assign_rbs_required(module_id_t Mod_id, int N_RB_DL; // clear rb allocations across all CC_id - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; if (!ue_slice_membership(UE_id, slice_id)) @@ -231,7 +228,7 @@ assign_rbs_required(module_id_t Mod_id, &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); + DevAssert(j < NFAPI_CC_MAX); eNB_UE_stats_j = &UE_list-> eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]][UE_id]; @@ -315,7 +312,7 @@ maxround(module_id_t Mod_id, uint16_t rnti, int frame, 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 < RC.nb_mac_CC[Mod_id]; CC_id++) { cc = &RC.mac[Mod_id]->common_channels[CC_id]; @@ -490,14 +487,14 @@ void decode_sorting_policy(module_id_t Mod_idP, slice_id_t slice_id) { void sort_UEs(module_id_t Mod_idP, slice_id_t slice_id, int frameP, sub_frame_t subframeP) { int i; - int list[NUMBER_OF_UE_MAX]; + int list[MAX_MOBILES_PER_ENB]; int list_size = 0; int rnti; struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP, slice_id }; UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] == FALSE) continue; @@ -602,11 +599,11 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int min_rb_unit[MAX_NUM_CCs], - uint8_t rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - uint8_t MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX], - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]) { + int N_RBG[NFAPI_CC_MAX], + int min_rb_unit[NFAPI_CC_MAX], + uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX], + uint8_t MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX], + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]) { int UE_id, CC_id; @@ -614,22 +611,22 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id, rnti_t rnti; uint8_t harq_pid, round, transmission_mode; - uint8_t total_rbs_used[MAX_NUM_CCs]; - uint8_t total_ue_count[MAX_NUM_CCs]; - uint16_t average_rbs_per_user[MAX_NUM_CCs]; - 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]; + uint8_t total_rbs_used[NFAPI_CC_MAX]; + uint8_t total_ue_count[NFAPI_CC_MAX]; + uint16_t average_rbs_per_user[NFAPI_CC_MAX]; + uint16_t nb_rbs_required_remaining[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; + uint16_t nb_rbs_required_remaining_1[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; int N_RB_DL; UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; UE_sched_ctrl *ue_sched_ctl; COMMON_channels_t *cc; - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) { total_ue_count[CC_id] = 0; total_rbs_used[CC_id] = 0; average_rbs_per_user[CC_id] = 0; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; ++UE_id) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; ++UE_id) { nb_rbs_required_remaining[CC_id][UE_id] = 0; } } @@ -820,9 +817,7 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id, transmission_mode, min_rb_unit [CC_id], - to_prb(RC.mac - [Mod_id]->common_channels - [CC_id].mib->message.dl_Bandwidth), + to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth), nb_rbs_required, nb_rbs_required_remaining, rballoc_sub, @@ -1002,18 +997,18 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], + int N_RBG[NFAPI_CC_MAX], int *mbsfn_flag) { int UE_id; uint8_t CC_id; uint16_t i, j; - uint8_t rballoc_sub[MAX_NUM_CCs][N_RBG_MAX]; - uint8_t MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; // If TM5 is revisited, we can move this inside accounting + uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX]; + uint8_t MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX]; // If TM5 is revisited, we can move this inside accounting - int min_rb_unit[MAX_NUM_CCs]; - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + int min_rb_unit[NFAPI_CC_MAX]; + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; UE_sched_ctrl *ue_sched_ctl; @@ -1030,14 +1025,14 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, 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 < RC.nb_mac_CC[Mod_id]; CC_id++) { 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); - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; ++UE_id) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; ++UE_id) { if (UE_list->active[UE_id] != TRUE) continue; @@ -1081,7 +1076,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, #ifdef TM5 // This has to be revisited!!!! - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) { i1 = 0; i2 = 0; i3 = 0; @@ -1155,13 +1150,13 @@ dlsch_scheduler_pre_processor_reset(int module_idP, int frameP, int subframeP, int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], + uint16_t nb_rbs_required[NFAPI_CC_MAX] + [MAX_MOBILES_PER_ENB], unsigned char - rballoc_sub[MAX_NUM_CCs] + rballoc_sub[NFAPI_CC_MAX] [N_RBG_MAX], unsigned char - MIMO_mode_indicator[MAX_NUM_CCs] + MIMO_mode_indicator[NFAPI_CC_MAX] [N_RBG_MAX]) { int i, j; @@ -1342,17 +1337,10 @@ dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, 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]) + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + uint16_t nb_rbs_required_remaining[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + unsigned char rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX], + unsigned char MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX]) { int i; @@ -1422,11 +1410,11 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, 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 total_ue_count[MAX_NUM_CCs]; + uint16_t nb_allocated_rbs[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + total_allocated_rbs[NFAPI_CC_MAX], + average_rbs_per_user[NFAPI_CC_MAX]; + int16_t total_remaining_rbs[NFAPI_CC_MAX]; + uint16_t total_ue_count[NFAPI_CC_MAX]; rnti_t rnti = -1; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; UE_TEMPLATE *UE_template = 0; @@ -1444,7 +1432,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, // we need to distribute RBs among UEs // step1: reset the vars - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { total_allocated_rbs[CC_id] = 0; total_remaining_rbs[CC_id] = 0; average_rbs_per_user[CC_id] = 0; @@ -1617,7 +1605,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, /* this logging is wrong, ue_sched_ctl may not be valid here * TODO: fix */ - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { if (total_allocated_rbs[CC_id] > 0) { LOG_D(MAC, "[eNB %d] total RB allocated for all UEs = %d/%d\n", @@ -1648,7 +1636,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, int Ncp; int N_RB_UL; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] != TRUE) continue; @@ -1676,14 +1664,11 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, // 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, + + AssertFatal(CC_id < RC.nb_mac_CC[module_idP], "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", - CC_id, MAX_NUM_CCs, n, UE_id, + CC_id, NFAPI_CC_MAX, n, UE_id, UE_list->numactiveULCCs[UE_id]); UE_template = &UE_list->UE_template[CC_id][UE_id]; @@ -1845,14 +1830,14 @@ static int ue_ul_compare(const void *_a, const void *_b, void *_params) 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[MAX_MOBILES_PER_ENB]; 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; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] == FALSE) continue; if ((rnti = UE_RNTI(module_idP, i)) == NOT_A_RNTI) diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 36518ad62210a8be718f3f7d45236fac08e11510..6cc7c58e6c3ff915e160ae0774745162001a5a0f 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -30,76 +30,24 @@ * \warning */ -#include "extern.h" -#include "defs.h" -#include "proto.h" +#include "mac_extern.h" +#include "mac.h" +#include "mac_proto.h" #include "UTIL/LOG/vcd_signal_dumper.h" -#include "PHY_INTERFACE/extern.h" -#include "SCHED/defs.h" +#include "PHY_INTERFACE/phy_interface_extern.h" +#include "SCHED_UE/sched_UE.h" #include "COMMON/mac_rrc_primitives.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "UTIL/LOG/log.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#ifdef PHY_EMUL -#include "SIMULATION/simulation_defs.h" -#endif - -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.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); - -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; - } - } else { // FDD - preambleformat = prachConfigIndex >> 2; - } - - switch (preambleformat) { - case 0: - case 1: - return (0); - - case 2: - case 3: - return (-3); - - case 4: - return (8); - - 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, diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index 6261eaf35690f672225209e7972aa333d6bd9087..68183f2f89ddcd31a65461b4c65812d6a6b4b20a 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -28,10 +28,10 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" +#include "SIMULATION/TOOLS/sim.h" #include "UTIL/LOG/log.h" #include "OCG.h" #include "OCG_extern.h" diff --git a/openair2/LAYER2/MAC/rar_tools_ue.c b/openair2/LAYER2/MAC/rar_tools_ue.c index ab193c7a66b2422473dd208af125fc815c4a7259..7d24e4c0af31c5fd2a87ea13ec06427f08902d6f 100644 --- a/openair2/LAYER2/MAC/rar_tools_ue.c +++ b/openair2/LAYER2/MAC/rar_tools_ue.c @@ -28,10 +28,10 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" +#include "SIMULATION/TOOLS/sim.h" #include "UTIL/LOG/log.h" #include "OCG.h" #include "OCG_extern.h" diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index c9ccddae37346a93a1b7fd0152fd84682a339d3a..f7f57363c6bd30e64027a6020274839f29de5ab0 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -33,20 +33,16 @@ #include <pthread.h> #endif -#include "extern.h" -#include "defs.h" -#include "proto.h" -#ifdef PHY_EMUL -#include "SIMULATION/PHY_EMULATION/impl_defs.h" -#else -#include "SCHED/defs.h" +#include "mac_extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "SCHED_UE/sched_UE.h" #include "PHY/impl_defs_top.h" -#endif -#include "PHY_INTERFACE/extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" #include "COMMON/mac_rrc_primitives.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" @@ -54,9 +50,6 @@ #include "OCG_extern.h" #include "openair2/PHY_INTERFACE/phy_stub_UE.h" -#ifdef PHY_EMUL -#include "SIMULATION/simulation_defs.h" -#endif #include "pdcp.h" #if defined(ENABLE_ITTI) @@ -65,7 +58,7 @@ #include "assertions.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #define DEBUG_HEADER_PARSING 1 #define ENABLE_MAC_PAYLOAD_DEBUG 1 diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index f2976ea8641987090da00aafcb67e2bbdd11e550..b63d7a8795e3a2c17eecd8d962646c5e1f9f370e 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -36,8 +36,8 @@ #include "pdcp_util.h" #include "pdcp_sequence_manager.h" #include "LAYER2/RLC/rlc.h" -#include "LAYER2/MAC/extern.h" -#include "RRC/LITE/proto.h" +#include "LAYER2/MAC/mac_extern.h" +#include "RRC/LTE/rrc_proto.h" #include "pdcp_primitives.h" #include "OCG.h" #include "OCG_extern.h" @@ -406,7 +406,7 @@ boolean_t pdcp_data_req( * so we return TRUE afterwards */ - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ) break; } @@ -823,7 +823,7 @@ pdcp_data_ind( * XXX Following two actions are identical, is there a merge error? */ - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ){ break; } @@ -871,7 +871,7 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ // these stats are measured for both eNB and UE on per seond basis for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); // tx stats if (Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && @@ -1080,14 +1080,14 @@ pdcp_run ( void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){ int i, ue_flag=1; //, ret=-1; to be decied later - for (i=0; i < NUMBER_OF_UE_MAX; i++){ + for (i=0; i < MAX_MOBILES_PER_ENB; i++){ if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti) { ue_flag=-1; break; } } if (ue_flag == 1 ){ - for (i=0; i < NUMBER_OF_UE_MAX ; i++){ + for (i=0; i < MAX_MOBILES_PER_ENB ; i++){ if (pdcp_enb[ctxt_pP->module_id].rnti[i] == 0 ){ pdcp_enb[ctxt_pP->module_id].rnti[i]=ctxt_pP->rnti; pdcp_enb[ctxt_pP->module_id].uid[i]=i; @@ -1115,7 +1115,7 @@ pdcp_remove_UE( int i; // check and remove SRBs first - for(int i = 0;i<NUMBER_OF_UE_MAX;i++){ + for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){ if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti){ pdcp_eNB_UE_instance_to_rnti[i] = NOT_A_RNTI; break; @@ -1136,7 +1136,7 @@ pdcp_remove_UE( (void)h_rc; /* remove gcc warning "set but not used" */ // remove ue for pdcp enb inst - for (i=0; i < NUMBER_OF_UE_MAX; i++) { + for (i=0; i < MAX_MOBILES_PER_ENB; i++) { if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti ) { LOG_I(PDCP, "remove uid is %d/%d %x\n", i, pdcp_enb[ctxt_pP->module_id].uid[i], @@ -1573,16 +1573,16 @@ pdcp_config_req_asn1 ( //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; if( srb_flagP == SRB_FLAG_NO ) { - for(int i = 0;i<NUMBER_OF_UE_MAX;i++){ + for(int i = 0;i<MAX_MOBILES_PER_ENB;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_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB; } 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) % MAX_MOBILES_PER_ENB; } - //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) % MAX_MOBILES_PER_ENB; } else { pdcp_pP->is_ue = TRUE; pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti; @@ -2030,7 +2030,7 @@ void pdcp_layer_init(void) pdcp_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, pdcp_free); AssertFatal(pdcp_coll_p != NULL, "UNRECOVERABLE error, PDCP hashtable_create failed"); - for (instance = 0; instance < NUMBER_OF_UE_MAX; instance++) { + for (instance = 0; instance < MAX_MOBILES_PER_ENB; instance++) { #if defined(Rel10) || defined(Rel14) for (service_id = 0; service_id < maxServiceCount; service_id++) { @@ -2068,7 +2068,7 @@ void pdcp_layer_init(void) memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms)); memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms)); for (i =0; i< MAX_NUM_CCs ; i ++){ - for (j=0; j< NUMBER_OF_UE_MAX;j++){ + for (j=0; j< MAX_MOBILES_PER_ENB;j++){ Pdcp_stats_tx_window_ms[i][j]=100; Pdcp_stats_rx_window_ms[i][j]=100; } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 54ae67fd4e13ba833c7d2a55d31b2e44151bd5f3..992f4873c9e354a3bb26497cd814c303f36092dc 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -67,7 +67,7 @@ #include "UTIL/LISTS/list.h" #endif //NON_ACCESS_STRATUM //----------------------------------------------------------------------------- -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "COMMON/platform_constants.h" #include "COMMON/platform_types.h" #include "DRB-ToAddMod.h" @@ -94,34 +94,34 @@ extern int pdcp_instance_cnt; int init_pdcp_thread(void); void cleanup_pdcp_thread(void); -public_pdcp(uint32_t Pdcp_stats_tx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_throughput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); - -public_pdcp(uint32_t Pdcp_stats_rx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_goodput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_window_ms[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_throughput_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); + +public_pdcp(uint32_t Pdcp_stats_rx_window_ms[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]); +public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_goodput_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const ctxt_pP)); @@ -131,8 +131,8 @@ public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const ctx //public_pdcp(uint64_t *pdcp_size_packet); typedef struct pdcp_enb_s { // used for eNB stats generation - uint16_t uid[NUMBER_OF_UE_MAX]; - rnti_t rnti[NUMBER_OF_UE_MAX]; + uint16_t uid[MAX_MOBILES_PER_ENB]; + rnti_t rnti[MAX_MOBILES_PER_ENB]; uint16_t num_ues; uint64_t sfn; @@ -532,19 +532,19 @@ typedef struct pdcp_missing_pdu_info_t { protected_pdcp(signed int pdcp_2_nas_irq;) -public_pdcp(pdcp_stats_t UE_pdcp_stats[NUMBER_OF_UE_MAX];) +public_pdcp(pdcp_stats_t UE_pdcp_stats[MAX_MOBILES_PER_ENB];) public_pdcp(pdcp_stats_t eNB_pdcp_stats[NUMBER_OF_eNB_MAX];) -//protected_pdcp(pdcp_t pdcp_array_srb_ue[NUMBER_OF_UE_MAX][2];) -//protected_pdcp(pdcp_t pdcp_array_drb_ue[NUMBER_OF_UE_MAX][maxDRB];) -//public_pdcp(pdcp_t pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][2];) -//protected_pdcp(pdcp_t pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][maxDRB];) +//protected_pdcp(pdcp_t pdcp_array_srb_ue[MAX_MOBILES_PER_ENB][2];) +//protected_pdcp(pdcp_t pdcp_array_drb_ue[MAX_MOBILES_PER_ENB][maxDRB];) +//public_pdcp(pdcp_t pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][2];) +//protected_pdcp(pdcp_t pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][maxDRB];) // for UE code conly -protected_pdcp(rnti_t pdcp_UE_UE_module_id_to_rnti[NUMBER_OF_UE_MAX];) -protected_pdcp(rnti_t pdcp_eNB_UE_instance_to_rnti[NUMBER_OF_UE_MAX];) // for noS1 mode +protected_pdcp(rnti_t pdcp_UE_UE_module_id_to_rnti[MAX_MOBILES_PER_ENB];) +protected_pdcp(rnti_t pdcp_eNB_UE_instance_to_rnti[MAX_MOBILES_PER_ENB];) // for noS1 mode protected_pdcp(unsigned int pdcp_eNB_UE_instance_to_rnti_index;) #if defined(Rel10) || defined(Rel14) -public_pdcp(pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +public_pdcp(pdcp_mbms_t pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h public_pdcp(pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h #endif protected_pdcp(sdu_size_t pdcp_output_sdu_bytes_to_write;) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index ee044bc850d22ff3dfef617fab6f5060b23649d7..0bbca96356e911b855aa19d9cc4d9588c93d6fb0 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -46,10 +46,10 @@ extern int otg_enabled; #define rtf_put write #define rtf_get read -#include "../MAC/extern.h" +#include "../MAC/mac_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "NETWORK_DRIVER/LITE/constant.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" +//#include "SIMULATION/ETH_TRANSPORT/extern.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OCG/OCG_extern.h" #include "UTIL/LOG/log.h" @@ -74,7 +74,7 @@ extern struct nlmsghdr *nas_nlh_rx; extern struct iovec nas_iov_tx; extern struct iovec nas_iov_rx; #ifdef UE_NAS_USE_TUN -extern int nas_sock_fd[NUMBER_OF_UE_MAX]; +extern int nas_sock_fd[MAX_MOBILES_PER_ENB]; #else extern int nas_sock_fd; #endif @@ -1178,7 +1178,7 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) ctxt_pP->subframe, ctxt_pP->module_id); - for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { + for (dst_id = 0; dst_id<MAX_MOBILES_PER_ENB; dst_id++) { ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id]; } } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c index 0df8e59e6d4536bd09654ac739d5651c11fc78d5..f0b15d9888d7d0268be4d43df309f89519e1c5f4 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c @@ -55,7 +55,7 @@ #include "UTIL/LOG/log.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OCG/OCG_extern.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "pdcp.h" #include "pdcp_primitives.h" diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c index 2554eb145ab9de975100795e207efe6276e39978..2c29053297d67a5b5daf836a8a99fe60b7bd8b58 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c @@ -34,7 +34,7 @@ #include "UTIL/LOG/vcd_signal_dumper.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "pdcp.h" #include "msc.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 0e21d5cfac8c8d79237b472a1ce691512eede2cb..34c9baf53784b066bd865f88ed9733690c233698 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -37,7 +37,7 @@ #include "mac_primitives.h" #include "rlc_primitives.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UL-AM-RLC.h" #include "DL-AM-RLC.h" 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 5130bde38b9f32f6a8d3b18c6d4d8e139c388c84..040145f7f03c1da8db15b77f979d0c155ef9e1cf 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -71,6 +71,7 @@ # include "rlc_am_reassembly.h" # include "rlc_am_init.h" # include "RLC-Config.h" +# include "assertions.h" //# include "rlc_am_test.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c index a133ce09920157695402118420de43ab601e610b..996dd96f353f17bf4e11d0f810eef14ce0472930 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c @@ -30,7 +30,7 @@ #define RLC_AM_IN_SDU_C 1 //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #define TRACE_RLC_AM_FREE_SDU 0 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 01a635656e24ce819f112c399f70f99ccf7a3e1a..0b0a55bd2b66ee32560704e02ef7b29766e64a47 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 @@ -24,7 +24,7 @@ #include <string.h> //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- void diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h index 2ee7d040ab36b65b0a617dacd8a24e69aa34d996..c69fd3766e4554e043598825f3f61ca68b3de987 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h @@ -55,7 +55,7 @@ //----------------------------------------------------------------------------- #include "platform_types.h" #include "platform_constants.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" /*! \struct rlc_am_info_t 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 d0b5b52395417f9e01e6581402111ec51d2c05de..83b0dfd46b86b583eedf242c09fe8671818610ce 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 @@ -30,7 +30,7 @@ #include "rlc.h" #include "rlc_am.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +//#include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" #include "msc.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c index b1facdfb023671b9e948280b6031c1ade079e285..be4b43d1a075db6c89e0dc0dd8b2539fbaae2ba6 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c @@ -28,7 +28,7 @@ #include "rlc.h" #include "rlc_am.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c index 9e1db8a95bb07d58a4f582c302088156425c8f0e..42e84986238fd9d669e06061222a6492eb74a674 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -26,7 +26,7 @@ //----------------------------------------------------------------------------- #include "rlc_am.h" #include "rlc.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c index dc1ed2116341ed9d395a9546c103b61f022c25e3..c0ce57708b0cf3033f0ced09a5857f8a54e2268a 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c @@ -27,7 +27,7 @@ #include "assertions.h" #include "list.h" #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h index d2f0740b33de9530a97e531f442f955562ba2d42..9dcc75223dc6d543f1be05dfdfc43af51473760b 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h @@ -56,7 +56,7 @@ //----------------------------------------------------------------------------- #include "platform_types.h" #include "platform_constants.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" //----------------------------------------------------------------------------- /*! \fn rlc_am_rx_pdu_status_t rlc_am_rx_list_check_duplicate_insert_pdu(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t* const rlc_pP,mem_block_t* const tb_pP) 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 c16e897bb6f67fdadddb2111694cb95e7ad11097..fe99e137a43bfc413f31b0e93ce5ebf03906f71d 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 @@ -29,7 +29,7 @@ #include "msc.h" #include "list.h" #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 092c7c65f135f05827e36fcf46bc5c56f4d72a86..3ace3cc51f827022f0ee136092d0568c36385229 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -32,7 +32,6 @@ #include "assertions.h" #include "list.h" #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" # if ENABLE_ITTI diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h index e09189fcd6060c9b303c59b6b3a6a75cd98df10a..41f214d7c6cc54c87d4fcc6b5aefeece7ebd6efc 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h @@ -55,7 +55,7 @@ //----------------------------------------------------------------------------- #include "platform_types.h" #include "platform_constants.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" //----------------------------------------------------------------------------- /*! \fn uint16_t rlc_am_read_bit_field (uint8_t** dataP, unsigned int* bit_posP, const signed int bits_to_readP) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c index 0b88e7c650fe4e3d4b9fb23e93eb7fbfb45c9f00..1e3b8b916d5d4b0392fe15282920aeb4360b2b06 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c @@ -27,7 +27,7 @@ #include "platform_constants.h" //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c index b9383980a4231cd9f84dba7b276bf7c1787dd3be..fd0feceeb0d13181b2545e04e089aafb6daad358 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c @@ -26,7 +26,7 @@ #include "platform_constants.h" //----------------------------------------------------------------------------- #include "rlc_am.h" -# include "LAYER2/MAC/extern.h" +# include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c index 13d4205c2800cd1f7de367f46547ce928e9efe53..84c0edbefd52730a8b73d4c36af1611bf8115062 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c @@ -26,7 +26,7 @@ #include "platform_constants.h" //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c index ee2ff57c1eae1a9a48d9e4013a1abe76907ec9bc..23a4d0eb0478c9aab4e00880f9428d121fafe5e6 100644 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c @@ -29,7 +29,7 @@ #include "mac_primitives.h" #include "rlc_primitives.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" //----------------------------------------------------------------------------- void rlc_tm_send_sdu ( 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 15dc90f175a183dab9d247afeb081aad21db975a..70c1f37221d6d2193e1a29b6f659a5d7976ec51e 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 @@ -23,7 +23,7 @@ #define RLC_TM_INIT_C 1 //----------------------------------------------------------------------------- #include "rlc_tm.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" //----------------------------------------------------------------------------- void config_req_rlc_tm ( const protocol_ctxt_t* const ctxt_pP, 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 7bd0da83a903e40f909f8538a73d5f1c7c192232..0be2ef168644dbf1575a3f29d071d3fbeb5e557b 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -35,7 +35,7 @@ #include "list.h" #include "rlc_primitives.h" #include "mac_primitives.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" 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 895015dc883778e9255638a71981c995602c39c3..d8b79a98c1a753047552fedab657c0d10473b51a 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 @@ -28,7 +28,7 @@ #include "rlc_primitives.h" #include "list.h" #include "rrm_config_structs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "rlc_um_control_primitives.h" diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c index 758630b3cce88476ea49df4a253a60d7d36c9879..bc61ed302ecda6cc92a3502114ff0fbc3e2b5cb3 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c @@ -24,7 +24,7 @@ #include "platform_types.h" //----------------------------------------------------------------------------- #include "rlc_um.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" 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 91e1ba66d1bfa662eb29f75cdd286260c48e5147..65aaadb9fa38106defed77ef211b9f497c327e5d 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 @@ -33,7 +33,7 @@ #include "rlc_um.h" #include "rlc_primitives.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index 637512d54d9605dc7b6fcf5a23f05306b3c1c1af..69c63329e2708cf3c698c882f36761b2f7762a8e 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -29,7 +29,7 @@ #define RLC_C #include "rlc.h" #include "mem_block.h" -#include "../MAC/extern.h" +#include "../MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/OCG/OCG_vars.h" #include "UTIL/LOG/vcd_signal_dumper.h" @@ -624,7 +624,7 @@ rlc_module_init (void) rlc_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, rb_free_rlc_union); AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed"); - for (module_id1=0; module_id1 < NUMBER_OF_UE_MAX; module_id1++) { + for (module_id1=0; module_id1 < MAX_MOBILES_PER_ENB; module_id1++) { #if defined(Rel10) || defined(Rel14) for (k=0; k < RLC_MAX_MBMS_LC; k++) { diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index a804278dc5b1c626ede9055ff67f1a76a3891a38..339d9c60bb4d80614c53ec7bd71ddd0059d27ed0 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -47,7 +47,7 @@ # include "asn1_constants.h" # include "UTIL/LOG/log.h" # include "mem_block.h" -# include "PHY/defs.h" +//# include "PHY/defs.h" # include "RLC-Config.h" # include "DRB-ToAddMod.h" # include "DRB-ToAddModList.h" @@ -174,7 +174,7 @@ typedef struct { //----------------------------------------------------------------------------- #define RLC_MAX_MBMS_LC (maxSessionPerPMCH * maxServiceCount) -#define RLC_MAX_LC ((max_val_DRB_Identity+1)* NUMBER_OF_UE_MAX) +#define RLC_MAX_LC ((max_val_DRB_Identity+1)* MAX_MOBILES_PER_ENB) protected_rlc(void (*rlc_rrc_data_ind)( const protocol_ctxt_t* const ctxtP, @@ -234,10 +234,10 @@ typedef struct rlc_mbms_id_s { # define maxSessionPerPMCH 1 # endif #endif -//public_rlc(rlc_mbms_t rlc_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +//public_rlc(rlc_mbms_t rlc_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h //public_rlc(rlc_mbms_t rlc_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h -public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_ue[NUMBER_OF_UE_MAX][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h -public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[NUMBER_OF_eNB_MAX][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_ue[MAX_MOBILES_PER_ENB][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[MAX_eNB][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h #define rlc_mbms_enb_get_lcid_by_rb_id(Enb_mOD,rB_iD) rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD] ; @@ -253,8 +253,8 @@ public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[NUMBER_OF_e rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD] = lOG_cH_iD; \ } while (0); -public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_ue [NUMBER_OF_UE_MAX][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_eNB[NUMBER_OF_eNB_MAX][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ +public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_ue [MAX_MOBILES_PER_ENB][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ +public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_eNB[MAX_eNB][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ #define RLC_COLL_KEY_VALUE(eNB_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 29fa5e8cb1868fb48bec921268db3a48c3fa7dbd..c4fc2872c682a87f1fd3a1cf23634f518d946124 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -30,7 +30,7 @@ //----------------------------------------------------------------------------- #define RLC_MAC_C #include "rlc.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/OCG/OCG_vars.h" #include "hashtable.h" diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index bb2abb560f2929c12f664c2beb4992cdaef6c613..60ac4964e1a244c52add5ffff59c7019e4cb0f99 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -43,7 +43,7 @@ #include "PMCH-InfoList-r9.h" #endif -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "assertions.h" //----------------------------------------------------------------------------- rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c index f66d1142abf5c668f240de1fcda9bc2aa65337ff..0c884a806ce85d35b0d80fe0ee32e8598558de4c 100644 --- a/openair2/LAYER2/openair2_proc.c +++ b/openair2/LAYER2/openair2_proc.c @@ -32,8 +32,8 @@ #include <inttypes.h> #include "LAYER2/RLC/rlc.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" #include "UTIL/LOG/log.h" #include "common/ran_context.h" diff --git a/openair2/NETWORK_DRIVER/UE_IP/constant.h b/openair2/NETWORK_DRIVER/UE_IP/constant.h index faff970dcdb3cb32e8ade1d2a3e8ee0cae1e3600..0746651d073f8a0b108be6c8f9bfdbfd42e5a76b 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/constant.h +++ b/openair2/NETWORK_DRIVER/UE_IP/constant.h @@ -52,7 +52,7 @@ -#define UE_IP_NB_INSTANCES_MAX NUMBER_OF_UE_MAX +#define UE_IP_NB_INSTANCES_MAX MAX_MOBILES_PER_ENB #endif diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index d0b8e5755858bbaf3ac64711016a8debce09b04c..6d9fe013a5bd6c108671c72e5d3b8e8520b7e18c 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -1,8 +1,8 @@ -#include "openair1/PHY/defs.h" +#include "openair1/PHY/defs_eNB.h" #include "openair2/PHY_INTERFACE/IF_Module.h" -#include "openair1/PHY/extern.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" +#include "openair1/PHY/phy_extern.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" #include "common/ran_context.h" #define MAX_IF_MODULES 100 diff --git a/openair2/PHY_INTERFACE/IF_Module.h b/openair2/PHY_INTERFACE/IF_Module.h index 3b1c88dda03b5857f99c40a3a724b1a072a469e5..ccce490c75584b6f02261844503d9e3cab5db8ed 100644 --- a/openair2/PHY_INTERFACE/IF_Module.h +++ b/openair2/PHY_INTERFACE/IF_Module.h @@ -34,9 +34,10 @@ #include <stdint.h> -#include "openair1/PHY/LTE_TRANSPORT/defs.h" +//#include "openair1/PHY/LTE_TRANSPORT/transport_eNB.h" #include "nfapi_interface.h" - +#include "platform_constants.h" +#include "platform_types.h" #define MAX_NUM_DL_PDU 100 #define MAX_NUM_UL_PDU 100 diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h deleted file mode 100644 index deb07443f18fcddf3a1555821fece15ca0acd7c4..0000000000000000000000000000000000000000 --- a/openair2/PHY_INTERFACE/defs.h +++ /dev/null @@ -1,373 +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 PHY_INTERFACE/defs.h -* \brief mac phy interface primitives -* \author Raymond Knopp and Navid Nikaein -* \date 2011 -* \version 0.5 -* \mail navid.nikaein@eurecom.fr or openair_tech@eurecom.fr -*/ - -#ifndef __MAC_PHY_PRIMITIVES_H__ -# define __MAC_PHY_PRIMITIVES_H__ - -#include "LAYER2/MAC/defs.h" - - -#define MAX_NUMBER_OF_MAC_INSTANCES 16 - -#define NULL_PDU 255 -#define DCI 0 -#define DLSCH 1 -#define ULSCH 2 - -#define mac_exit_wrapper(sTRING) \ -do { \ - char temp[300]; \ - snprintf(temp, sizeof(temp), "%s in file "__FILE__" at line %d\n", sTRING, __LINE__); \ - mac_xface->macphy_exit(temp); \ -} while(0) - -/** @defgroup _phy_if MAC-PHY interface - * @ingroup _oai2 - * @{ - */ -/*! \brief MACPHY Interface */ -/* -typedef struct { - /// Pointer function that initializes L2 - int (*macphy_init)(int eMBMS_active, char *uecap_xer, uint8_t CBA_active,uint8_t HO_active); - - /// Pointer function that stops the low-level scheduler due an exit condition - void (*macphy_exit)(const char *); - - // eNB functions - /// Invoke dlsch/ulsch scheduling procedure for new subframe - void (*eNB_dlsch_ulsch_scheduler)(module_id_t Mod_id,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP);//, int calibration_flag); - - /// Fill random access response sdu, passing timing advance - uint16_t (*fill_rar)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t *dlsch_buffer,uint16_t N_RB_UL, uint8_t input_buffer_length); - - /// Initiate the RA procedure upon reception (hypothetical) of a valid preamble - void (*initiate_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframe,uint8_t f_id); - - /// cancel an ongoing RA procedure - void (*cancel_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble); - - /// Inform MAC layer that an uplink is scheduled for Msg3 in given subframe. - /// This is used so that the MAC scheduler marks as busy the RBs used by the Msg3. - void (*set_msg3_subframe)(module_id_t Mod_id, - int CC_id, - int frame, - int subframe, - int rnti, - int Msg3_frame, - int Msg3_subframe); - - /// Get DCI for current subframe from MAC - DCI_PDU* (*get_dci_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe); - - /// Get DLSCH sdu for particular RNTI and Transport block index - uint8_t* (*get_dlsch_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,uint8_t TB_index); - - /// Send ULSCH sdu to MAC for given rnti - void (*rx_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP, sub_frame_t sub_frameP,rnti_t rnti, uint8_t *sdu,uint16_t sdu_len, int harq_pid,uint8_t *msg3_flag); - - /// Indicate failure to synch to external source - void (*mrbch_phy_sync_failure) (module_id_t Mod_id,frame_t frameP, uint8_t free_eNB_index); - - /// Indicate Scheduling Request from UE - void (*SR_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe); - /// Indicate UL Failure to eNodeB MAC - void (*UL_failure_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe); - - /// Configure Common PHY parameters from SIB1 - void (*phy_config_mib_eNB)(module_id_t Mod_id,int CC_id, - int eutra_band, - int N_RB_DL, - PHICH_Config_t *phich_Config, - int Nid_cell, - int Ncp, - int p_eNB, - uint32_t dl_CarrierFreq, - uint32_t ul_CarrierFreq); - - /// Configure Common PHY parameters from SIB1 - void (*phy_config_sib1_eNB)(module_id_t Mod_id,int CC_id, - TDD_Config_t *tdd_config, - uint8_t SIwindowsize, - uint16_t SIperiod); - - /// Configure Common PHY parameters from SIB2 - void (*phy_config_sib2_eNB)(module_id_t Mod_id, int CC_id, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - ARFCN_ValueEUTRA_t *ul_CArrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList); - -#if defined(Rel10) || defined(Rel14) - /// Configure Common PHY parameters from SIB13 - void (*phy_config_sib13_eNB)(module_id_t Mod_id,int CC_id, int mbsfn_Area_idx, - long mbsfn_AreaId_r9); - - void (*phy_config_dedicated_scell_eNB)(uint8_t Mod_id, - uint16_t rnti, - SCellToAddMod_r10_t *sCellToAddMod_r10, - int CC_id); -#endif - - /// PHY-Config-Dedicated eNB - void (*phy_config_dedicated_eNB)(module_id_t Mod_id,int CC_id,rnti_t rnti, - struct PhysicalConfigDedicated *physicalConfigDedicated); - -#if defined(Rel10) || defined(Rel14) - /// Get MCH sdu and corresponding MCS for particular MBSFN subframe - MCH_PDU* (*get_mch_sdu)(module_id_t Mod_id, int CC_id, frame_t frameP,sub_frame_t subframe); -#endif - // configure the cba rnti at the physical layer - void (*phy_config_cba_rnti)(module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, uint16_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups); - /// get delta mcs for fast UL AMC - int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs); - - int (*mac_phy_remove_ue)(module_id_t Mod_idP,rnti_t rntiP); - /// UE functions - - /// reset the ue phy - void (*phy_reset_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Indicate loss of synchronization of PBCH for this eNB to MAC layer - void (*out_of_sync_ind)(module_id_t Mod_id,frame_t frameP,uint16_t eNB_index); - - /// Send a received SI sdu - void (*ue_decode_si)(module_id_t Mod_id,int CC_id,frame_t frameP, uint8_t CH_index, void *pdu, uint16_t len); - - /// Send a received Paging sdu - void (*ue_decode_p)(module_id_t Mod_id,int CC_id,frame_t frameP, uint8_t CH_index, void *pdu, uint16_t len); - - /// Send a received DLSCH sdu to MAC - void (*ue_send_sdu)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,sub_frame_t subframe,uint8_t *sdu,uint16_t sdu_len,uint8_t CH_index); - -#if defined(Rel10) || defined(Rel14) - /// Send a received MCH sdu to MAC - void (*ue_send_mch_sdu)(module_id_t Mod_id,uint8_t CC_id, frame_t frameP,uint8_t *sdu,uint16_t sdu_len,uint8_t eNB_index,uint8_t sync_area); - - /// Function to check if UE PHY needs to decode MCH for MAC - /// get the sync area id, and return MCS value if need to decode, otherwise -1 - int (*ue_query_mch)(module_id_t Mod_id, uint8_t CC_id,frame_t frameP,sub_frame_t subframe,uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active); -#endif - - /// Retrieve ULSCH sdu from MAC - void (*ue_get_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe, uint8_t CH_index,uint8_t *ulsch_buffer,uint16_t buflen,uint8_t *access_mode); - - /// Retrieve RRCConnectionReq from MAC - PRACH_RESOURCES_t* (*ue_get_rach)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t Msg3_flag,sub_frame_t subframe); - - /// Process Random-Access Response - uint16_t (*ue_process_rar)(module_id_t Mod_id,int CC_id,frame_t frameP, uint16_t ra_rnti, uint8_t *dlsch_buffer, uint16_t *t_crnti,uint8_t preamble_index, uint8_t* selected_rar_buffer); - - /// Get SR payload (0,1) from UE MAC - uint32_t (*ue_get_SR)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe); - - /// Indicate synchronization with valid PBCH - void (*dl_phy_sync_success) (module_id_t Mod_id,frame_t frameP, uint8_t CH_index,uint8_t first_sync); - - /// Only calls the PDCP for now - UE_L2_STATE_t (*ue_scheduler)(module_id_t Mod_id, frame_t rxFrameP,sub_frame_t rxSubframe, frame_t txFrameP,sub_frame_t txSubframe, lte_subframe_t direction, uint8_t eNB_id, int CC_id); - - /// PHY-Config-Dedicated UE - void (*phy_config_dedicated_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - struct PhysicalConfigDedicated *physicalConfigDedicated); - - /// PHY-Config-harq UE - void (*phy_config_harq_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - uint16_t max_harq_tx); - /// Configure Common PHY parameters from SIB1 - void (*phy_config_sib1_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - TDD_Config_t *tdd_config, - uint8_t SIwindowsize, - uint16_t SIperiod); - - /// Configure Common PHY parameters from SIB2 - void (*phy_config_sib2_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - ARFCN_ValueEUTRA_t *ul_CArrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList); - -#if defined(Rel10) || defined(Rel14) - /// Configure Common PHY parameters from SIB13 - void (*phy_config_sib13_ue)(uint8_t Mod_id,int CC_id, uint8_t eNB_index,int mbsfn_Area_idx, - long mbsfn_AreaId_r9); - - void (*phy_config_dedicated_scell_ue)(uint8_t Mod_id, - uint8_t eNB_index, - SCellToAddMod_r10_t *sCellToAddMod_r10, - int CC_id); -#endif - /// Configure Common PHY parameters from mobilityControlInfo - void (*phy_config_afterHO_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t CH_index, - MobilityControlInfo_t *mobilityControlInfo, - uint8_t ho_failed); - - /// Function to indicate failure of contention resolution or RA procedure - void (*ra_failed)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index); - - /// Function to indicate success of contention resolution or RA procedure - void (*ra_succeeded)(module_id_t Mod_id,uint8_t CC_id, uint8_t eNB_index); - - /// Function to indicate the transmission of msg1/rach to MAC - void (*Msg1_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id); - - /// Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer - void (*Msg3_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id); - - /// Function to pass inter-cell measurement parameters to PHY (cell Ids) - void (*phy_config_meas_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,uint32_t *adj_cell_id); - - // PHY Helper Functions - - /// RIV computation from PHY - uint16_t (*computeRIV)(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); - - /// Downlink TBS table lookup from PHY - uint32_t (*get_TBS_DL)(uint8_t mcs, uint16_t nb_rb); - - /// Uplink TBS table lookup from PHY - uint32_t (*get_TBS_UL)(uint8_t mcs, uint16_t nb_rb); - - /// Function to retrieve the HARQ round index for a particular UL/DLSCH and harq_pid - int (*get_ue_active_harq_pid)(module_id_t Mod_id, uint8_t CC_id,rnti_t rnti, int frame, uint8_t subframe, uint8_t *harq_pid, uint8_t *round, uint8_t ul_flag); - - /// Function to retrieve number of CCE - uint16_t (*get_nCCE_max)(module_id_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int 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); - - /// Function to retrieve number of PRB in an rb_alloc - uint32_t (*get_nb_rb)(uint8_t ra_header, uint32_t rb_alloc, int n_rb_dl); - - /// Function to convert VRB to PRB for distributed allocation - uint32_t (*get_prb)(int N_RB_DL,int odd_slot,int vrb,int Ngap); - - /// Function to retrieve transmission mode for UE - uint8_t (*get_transmission_mode)(module_id_t Mod_id,uint8_t CC_id,rnti_t rnti); - - /// Function to retrieve rb_alloc bitmap from dci rballoc field and VRB type - uint32_t (*get_rballoc)(vrb_t vrb_type, uint16_t rb_alloc_dci); - - /// Function for UE MAC to retrieve current PHY connectivity mode (PRACH,RA_RESPONSE,PUSCH) - UE_MODE_t (*get_ue_mode)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to retrieve measured Path Loss - int16_t (*get_PL)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to retrieve the rssi - uint32_t (*get_RSSI)(uint8_t Mod_id,uint8_t CC_id); - - /// Function for UE MAC to retrieve the total gain - uint32_t (*get_rx_total_gain_dB)(uint8_t Mod_id,uint8_t CC_id); - - /// Function for UE MAC to retrieve the number of adjustent cells - uint8_t (*get_n_adj_cells)(uint8_t Mod_id,uint8_t CC_id); - - /// Function for UE MAC to retrieve RSRP/RSRQ measurements - uint32_t (*get_RSRP)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to retrieve RSRP/RSRQ measurements - uint32_t (*get_RSRQ)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements - uint8_t (*set_RSRP_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp); - - /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements - uint8_t (*set_RSRQ_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp); - - /// Function for UE/eNB MAC to retrieve number of PRACH in TDD - uint8_t (*get_num_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms); - - /// Function for UE/eNB MAC to retrieve f_id of particular PRACH resource in TDD - uint8_t (*get_fid_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms,uint8_t tdd_map_index); - - /// Function for eNB MAC to retrieve subframe direction - lte_subframe_t (*get_subframe_direction)(module_id_t Mod_id, uint8_t CC_id, uint8_t subframe); - - // MAC Helper functions - /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (Po_NOMINAL_PUSCH parameter) - int8_t (*get_Po_NOMINAL_PUSCH)(module_id_t Mod_id,uint8_t CC_id); - - /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (deltaP_rampup parameter) - int8_t (*get_deltaP_rampup)(module_id_t Mod_id,uint8_t CC_id); - - /// Function for UE/PHY to compute PHR - int8_t (*get_PHR)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE to process the timing advance command - void (*process_timing_advance)(module_id_t Mod_id,uint8_t CC_id, int16_t timing_advance); - - /// Function for MAC to get the UE stats from the PHY - LTE_eNB_UE_stats* (*get_eNB_UE_stats)(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); - - /// get the frame parameters from the PHY - LTE_DL_FRAME_PARMS* (*get_lte_frame_parms)(module_id_t Mod_id, uint8_t CC_id); - - /// get the Multiuser mimo mode - MU_MIMO_mode* (*get_mu_mimo_mode) (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); - - /// get the delta TF for Uplink Power Control Calculation - int16_t (*get_hundred_times_delta_TF) (module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid); - /// get target PUSCH received power - int16_t (*get_target_pusch_rx_power) (module_id_t module_idP, uint8_t CC_id); - /// get target PUSCH received power - int16_t (*get_target_pucch_rx_power) (module_id_t module_idP, uint8_t CC_id); - - unsigned char is_cluster_head; - unsigned char is_primary_cluster_head; - unsigned char is_secondary_cluster_head; - unsigned char cluster_head_index; - - /// PHY Frame Configuration - LTE_DL_FRAME_PARMS *frame_parms; - - uint8_t (*get_prach_prb_offset)(LTE_DL_FRAME_PARMS *frame_parms, uint8_t tdd_mapindex, uint16_t Nf); - - int (*is_prach_subframe)(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe); - - /// ICIC algos - uint8_t (*get_SB_size)(uint8_t n_rb_dl); - ///end ALU's algo - -} MAC_xface; - -*/ - -#endif - - -/** @} */ diff --git a/openair2/PHY_INTERFACE/phy_interface.h b/openair2/PHY_INTERFACE/phy_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..f275e91ec1b619059f81be20977c215c6345d922 --- /dev/null +++ b/openair2/PHY_INTERFACE/phy_interface.h @@ -0,0 +1,55 @@ +/* + * 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_INTERFACE/defs.h +* \brief mac phy interface primitives +* \author Raymond Knopp and Navid Nikaein +* \date 2011 +* \version 0.5 +* \mail navid.nikaein@eurecom.fr or openair_tech@eurecom.fr +*/ + +#ifndef __PHY_INTERFACE_H__ +# define __PHY_INTERFACE_H__ + +#include "LAYER2/MAC/mac.h" + + +#define MAX_NUMBER_OF_MAC_INSTANCES 16 + +#define NULL_PDU 255 +#define DCI 0 +#define DLSCH 1 +#define ULSCH 2 + +#define mac_exit_wrapper(sTRING) \ +do { \ + char temp[300]; \ + snprintf(temp, sizeof(temp), "%s in file "__FILE__" at line %d\n", sTRING, __LINE__); \ + mac_xface->macphy_exit(temp); \ +} while(0) + + + +#endif + + +/** @} */ diff --git a/openair2/PHY_INTERFACE/extern.h b/openair2/PHY_INTERFACE/phy_interface_extern.h similarity index 100% rename from openair2/PHY_INTERFACE/extern.h rename to openair2/PHY_INTERFACE/phy_interface_extern.h diff --git a/openair2/PHY_INTERFACE/vars.h b/openair2/PHY_INTERFACE/phy_interface_vars.h similarity index 98% rename from openair2/PHY_INTERFACE/vars.h rename to openair2/PHY_INTERFACE/phy_interface_vars.h index 566f4347b6e5e264ff19a5a28193b1c96258ab97..5f205d302443ddc84274a7cb33e6dc9f8477c197 100644 --- a/openair2/PHY_INTERFACE/vars.h +++ b/openair2/PHY_INTERFACE/phy_interface_vars.h @@ -23,7 +23,7 @@ #define __PHY_INTERFACE_VARS_H__ //#include "SIMULATION/PHY_EMULATION/spec_defs.h" -#include "defs.h" +#include "phy_interface.h" #ifdef PHY_EMUL #include "SIMULATION/PHY_EMULATION/DEVICE_DRIVER/defs.h" diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index f24c113c175b1a07f8c19540ce7ed282685c21cc..984b4cb56d3ca46c04fff39817514cef24a9e07a 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -2,11 +2,11 @@ //#include "openair1/PHY/defs.h" //#include "openair2/PHY_INTERFACE/IF_Module.h" //#include "openair1/PHY/extern.h" -#include "openair2/LAYER2/MAC/extern.h" -#include "openair2/LAYER2/MAC/defs.h" -#include "openair2/LAYER2/MAC/proto.h" +#include "openair2/LAYER2/MAC/mac_extern.h" +#include "openair2/LAYER2/MAC/mac.h" +#include "openair2/LAYER2/MAC/mac_proto.h" //#include "openair2/LAYER2/MAC/vars.h" -#include "openair1/SCHED/defs.h" +#include "openair1/SCHED_UE/sched_UE.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/RRC/LITE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c similarity index 98% rename from openair2/RRC/LITE/L2_interface.c rename to openair2/RRC/LTE/L2_interface.c index 91834d9c9d64f4742cec1cd2b9d538a8ca9b8065..b21cf77f4df76d15d10938cabeacca0c9ae3924c 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -29,26 +29,14 @@ */ #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 "rrc_defs.h" +#include "rrc_extern.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 diff --git a/openair2/RRC/LITE/L2_interface_common.c b/openair2/RRC/LTE/L2_interface_common.c similarity index 94% rename from openair2/RRC/LITE/L2_interface_common.c rename to openair2/RRC/LTE/L2_interface_common.c index 1b832521528ec231b8b8dc9d016e62584ff97191..d72cc2f5bee1aa2d10fbb61838c9fda1eac997c8 100644 --- a/openair2/RRC/LITE/L2_interface_common.c +++ b/openair2/RRC/LTE/L2_interface_common.c @@ -29,26 +29,14 @@ */ #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 "rrc_defs.h" +#include "rrc_extern.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 diff --git a/openair2/RRC/LITE/L2_interface_ue.c b/openair2/RRC/LTE/L2_interface_ue.c similarity index 98% rename from openair2/RRC/LITE/L2_interface_ue.c rename to openair2/RRC/LTE/L2_interface_ue.c index 4c85c2d2478219001b9980da86a1ce0b19984c1e..980494fda6a59d723e5fa4251b3ecdd61683bb43 100644 --- a/openair2/RRC/LITE/L2_interface_ue.c +++ b/openair2/RRC/LTE/L2_interface_ue.c @@ -29,13 +29,8 @@ */ #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 "rrc_defs.h" +#include "rrc_extern.h" #include "UTIL/LOG/log.h" #include "rrc_eNB_UE_context.h" #include "pdcp.h" diff --git a/openair2/RRC/LITE/MESSAGES/Makefile.inc b/openair2/RRC/LTE/MESSAGES/Makefile.inc similarity index 100% rename from openair2/RRC/LITE/MESSAGES/Makefile.inc rename to openair2/RRC/LTE/MESSAGES/Makefile.inc diff --git a/openair2/RRC/LITE/MESSAGES/README.txt b/openair2/RRC/LTE/MESSAGES/README.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/README.txt rename to openair2/RRC/LTE/MESSAGES/README.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c similarity index 99% rename from openair2/RRC/LITE/MESSAGES/asn1_msg.c rename to openair2/RRC/LTE/MESSAGES/asn1_msg.c index 6b076d27bc1024c72a091526a00e256a29e5fe04..d818d1bdf63c89ca5688146c82b7b22e4f659933 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -57,8 +57,8 @@ //#define MRB1 1 #endif -#include "RRC/LITE/defs.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_defs.h" +#include "RRC/LTE/rrc_extern.h" #include "RRCConnectionSetupComplete.h" #include "RRCConnectionReconfigurationComplete.h" #include "RRCConnectionReconfiguration.h" @@ -73,7 +73,7 @@ #include "SBCCH-SL-BCH-MessageType.h" #include "SBCCH-SL-BCH-Message.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" #include "MeasObjectToAddModList.h" #include "ReportConfigToAddModList.h" diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h similarity index 99% rename from openair2/RRC/LITE/MESSAGES/asn1_msg.h rename to openair2/RRC/LTE/MESSAGES/asn1_msg.h index efb1c85b48270e8ad612fb75e2c714035db6454c..8bfd32ca10e2a529a8ec8b3f0f74bd856f2874d0 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -39,7 +39,7 @@ #include <asn_application.h> #include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */ -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "SL-DestinationInfoList-r12.h" /* diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c similarity index 99% rename from openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c rename to openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c index 43721bbfd55f0ee6d03f2c90e618dcf92571e63d..2d91828861c4e4c07a92f12677abf3c2a9d224ae 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c @@ -53,7 +53,7 @@ #include "RRCConnectionSetup-NB.h" #include "SRB-ToAddModList-NB-r13.h" #include "DRB-ToAddModList-NB-r13.h" -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" #include "RRCConnectionSetupComplete-NB.h" #include "RRCConnectionReconfigurationComplete-NB.h" #include "RRCConnectionReconfiguration-NB.h" diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h rename to openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h diff --git a/openair2/RRC/LITE/MESSAGES/asn1_patch b/openair2/RRC/LTE/MESSAGES/asn1_patch similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1_patch rename to openair2/RRC/LTE/MESSAGES/asn1_patch diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-860.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-860.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-860.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-860.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-a20.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-a20.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-a20.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-a20.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-c60.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-c60.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-c60.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-c60.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl diff --git a/openair2/RRC/LITE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h similarity index 99% rename from openair2/RRC/LITE/defs_NB_IoT.h rename to openair2/RRC/LTE/defs_NB_IoT.h index c8565d52bd59beed4d64b822ef04bea122acfc39..a4e4938814a11a2c4c94eb510f64fe6e613eb1bf 100644 --- a/openair2/RRC/LITE/defs_NB_IoT.h +++ b/openair2/RRC/LTE/defs_NB_IoT.h @@ -88,7 +88,7 @@ /*I will change the name of the structure for compile purposes--> hope not to undo this process*/ typedef unsigned int uid_NB_IoT_t; -#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((NUMBER_OF_UE_MAX_NB_IoT/8)/sizeof(unsigned int)) + 1) +#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((MAX_MOBILES_PER_ENB_NB_IoT/8)/sizeof(unsigned int)) + 1) typedef struct uid_linear_allocator_NB_IoT_s { unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT]; @@ -150,7 +150,7 @@ typedef struct UE_RRC_INFO_NB_IoT_s { // HO_STATE is not supported by NB-IoT -//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG +//#define MAX_MOBILES_PER_ENB MAX_MOBILES_PER_RG #define RRM_FREE(p) if ( (p) != NULL) { free(p) ; p=NULL ; } #define RRM_MALLOC(t,n) (t *) malloc16( sizeof(t) * n ) #define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n) diff --git a/openair2/RRC/LITE/extern_NB_IoT.h b/openair2/RRC/LTE/extern_NB_IoT.h similarity index 98% rename from openair2/RRC/LITE/extern_NB_IoT.h rename to openair2/RRC/LTE/extern_NB_IoT.h index f5e2f325756006d2841bb81f674d778ea68515f8..f136b57b4787613605ad3f579f779b6005963598 100644 --- a/openair2/RRC/LITE/extern_NB_IoT.h +++ b/openair2/RRC/LTE/extern_NB_IoT.h @@ -30,7 +30,7 @@ #ifndef __OPENAIR_RRC_EXTERN_NB_IOT_H__ #define __OPENAIR_RRC_EXTERN_NB_IOT_H__ -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" #include "PHY_INTERFACE/IF_Module_NB_IoT.h" #include "LAYER2/RLC/rlc.h" #include "LogicalChannelConfig-NB-r13.h" diff --git a/openair2/RRC/LITE/plmn_data.h b/openair2/RRC/LTE/plmn_data.h similarity index 100% rename from openair2/RRC/LITE/plmn_data.h rename to openair2/RRC/LTE/plmn_data.h diff --git a/openair2/RRC/LITE/proto_NB_IoT.h b/openair2/RRC/LTE/proto_NB_IoT.h similarity index 99% rename from openair2/RRC/LITE/proto_NB_IoT.h rename to openair2/RRC/LTE/proto_NB_IoT.h index b2218517fc8761da2f7311554e25821f02f9f06a..de09d39fab7b100b9335489cae95a513068baea2 100644 --- a/openair2/RRC/LITE/proto_NB_IoT.h +++ b/openair2/RRC/LTE/proto_NB_IoT.h @@ -30,7 +30,7 @@ * @{ */ -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" #include "pdcp.h" #include "rlc.h" #include "extern_NB_IoT.h" diff --git a/openair2/RRC/LITE/rrc_2_rrm_msg.c b/openair2/RRC/LTE/rrc_2_rrm_msg.c similarity index 100% rename from openair2/RRC/LITE/rrc_2_rrm_msg.c rename to openair2/RRC/LTE/rrc_2_rrm_msg.c diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c similarity index 99% rename from openair2/RRC/LITE/rrc_UE.c rename to openair2/RRC/LTE/rrc_UE.c index e907f1a8f9e0756be97f131e87262606e768975b..e1cc615ae68e3c172a90a13949638c4cb45014cd 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -35,16 +35,16 @@ #include "assertions.h" #include "hashtable.h" #include "asn1_conversions.h" -#include "defs.h" -#include "PHY/TOOLS/dB_routines.h" -#include "extern.h" +#include "rrc_defs.h" +#include "rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "openair1/PHY/LTE_ESTIMATION/lte_estimation.h" #include "LAYER2/RLC/rlc.h" #include "COMMON/mac_rrc_primitives.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #ifndef CELLULAR -#include "RRC/LITE/MESSAGES/asn1_msg.h" +#include "RRC/LTE/MESSAGES/asn1_msg.h" #endif #include "RRCConnectionRequest.h" #include "RRCConnectionReconfiguration.h" @@ -81,7 +81,9 @@ # include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus + +#include "openair2/LAYER2/MAC/mac_extern.h" #ifdef Rel14 #include "SL-Preconfiguration-r12.h" @@ -94,18 +96,12 @@ int slrb_id; int send_ue_information = 0; #endif -#ifdef PHY_EMUL -extern EMULATION_VARS *Emul_vars; -#endif -extern eNB_MAC_INST *eNB_mac_inst; -extern UE_MAC_INST *UE_mac_inst; -#ifdef BIGPHYSAREA -extern void *bigphys_malloc(int); -#endif +// for malloc_clear +#include "PHY/defs_UE.h" //#define XER_PRINT -//extern int8_t dB_fixed2(uint32_t x,uint32_t y); + extern void pdcp_config_set_security( const protocol_ctxt_t* const ctxt_pP, diff --git a/openair2/RRC/LITE/rrc_UE_ral.c b/openair2/RRC/LTE/rrc_UE_ral.c similarity index 100% rename from openair2/RRC/LITE/rrc_UE_ral.c rename to openair2/RRC/LTE/rrc_UE_ral.c diff --git a/openair2/RRC/LITE/rrc_UE_ral.h b/openair2/RRC/LTE/rrc_UE_ral.h similarity index 100% rename from openair2/RRC/LITE/rrc_UE_ral.h rename to openair2/RRC/LTE/rrc_UE_ral.h diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LTE/rrc_common.c similarity index 90% rename from openair2/RRC/LITE/rrc_common.c rename to openair2/RRC/LTE/rrc_common.c index a6a2bbb613b8f2d46a554b422ca2cab4f78bbaac..0acb0d77010a41c8753b3fae87cafa014bf34be2 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LTE/rrc_common.c @@ -28,9 +28,9 @@ * \email: navid.nikaein@eurecom.fr and raymond.knopp@eurecom.fr */ -#include "defs.h" -#include "extern.h" -#include "LAYER2/MAC/extern.h" +#include "rrc_defs.h" +#include "rrc_extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "COMMON/openair_defs.h" #include "COMMON/platform_types.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" @@ -43,10 +43,6 @@ #include "rrc_eNB_UE_context.h" #include "common/ran_context.h" -#ifdef LOCALIZATION -#include <sys/time.h> -#endif - #define DEBUG_RRC 1 extern RAN_CONTEXT_t RC; extern UE_MAC_INST *UE_mac_inst; @@ -61,33 +57,6 @@ rrc_init_global_param( //----------------------------------------------------------------------------- { - // Rrc_xface = (RRC_XFACE*)malloc16(sizeof(RRC_XFACE)); - - // Rrc_xface->openair_rrc_top_init = openair_rrc_top_init; - // Rrc_xface->openair_rrc_eNB_init = openair_rrc_eNB_init; - // Rrc_xface->openair_rrc_UE_init = openair_rrc_ue_init; - // Rrc_xface->mac_rrc_data_ind = mac_rrc_data_ind; - //Rrc_xface->mac_rrc_data_req = mac_rrc_data_req; - // Rrc_xface->rrc_data_indP = (void *)rlcrrc_data_ind; - // Rrc_xface->rrc_rx_tx = rrc_rx_tx; - // Rrc_xface->mac_rrc_meas_ind = mac_rrc_meas_ind; - // Rrc_xface->get_rrc_status = get_rrc_status; - - //Rrc_xface->rrc_get_status = ... - - // Mac_rlc_xface->mac_out_of_sync_ind=mac_out_of_sync_ind; - -#ifndef NO_RRM - // Rrc_xface->fn_rrc=fn_rrc; -#endif - // LOG_D(RRC, "[RRC]INIT_GLOBAL_PARAM: Mac_rlc_xface %p, rrc_rlc_register %p,rlcrrc_data_ind%p\n",Mac_rlc_xface,Mac_rlc_xface->rrc_rlc_register_rrc,rlcrrc_data_ind); - /* - if((Mac_rlc_xface==NULL) || (Mac_rlc_xface->rrc_rlc_register_rrc==NULL) || - (rlcrrc_data_ind==NULL)) { - LOG_E(RRC,"Data structured is not initialized \n"); - return -1; - } - */ rrc_rlc_register_rrc (rrc_data_ind, NULL); //register with rlc DCCH_LCHAN_DESC.transport_block_size = 4; diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LTE/rrc_defs.h similarity index 98% rename from openair2/RRC/LITE/defs.h rename to openair2/RRC/LTE/rrc_defs.h index 4c69c4c4eea734fbef6b13b56dc87f141afcdcb2..bc3c6293a9e3c5122dfc4428fbaf4b6a481624f4 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -/*! \file RRC/LITE/defs.h +/*! \file RRC/LTE/defs.h * \brief RRC struct definitions and function prototypes * \author Navid Nikaein and Raymond Knopp * \date 2010 - 2014 @@ -37,13 +37,13 @@ #include "collection/tree.h" #include "rrc_types.h" -#include "PHY/defs.h" +//#include "PHY/phy_defs.h" #include "LAYER2/RLC/rlc.h" #include "COMMON/platform_constants.h" #include "COMMON/platform_types.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" //for D2D #define DEBUG_CTRL_SOCKET @@ -298,7 +298,7 @@ void *send_UE_status_notification(void *); //-------- typedef unsigned int uid_t; -#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_UE_MAX/8)/sizeof(unsigned int)) + 1) +#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((MAX_MOBILES_PER_ENB/8)/sizeof(unsigned int)) + 1) typedef struct uid_linear_allocator_s { unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE]; } uid_allocator_t; @@ -361,7 +361,7 @@ typedef enum SL_TRIGGER_e { SL_REQUEST_DISCOVERY_RECEPTION_GAPS } SL_TRIGGER_t; -//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG +//#define MAX_MOBILES_PER_ENB MAX_MOBILES_PER_RG #define RRM_FREE(p) if ( (p) != NULL) { free(p) ; p=NULL ; } #define RRM_MALLOC(t,n) (t *) malloc16( sizeof(t) * n ) #define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n) @@ -668,8 +668,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]; + uint8_t *paging[MAX_MOBILES_PER_ENB]; + uint32_t sizeof_paging[MAX_MOBILES_PER_ENB]; } rrc_eNB_carrier_data_t; typedef struct eNB_RRC_INST_s { @@ -840,7 +840,7 @@ typedef struct UE_PF_PO_s { uint32_t T; /* DRX cycle */ } UE_PF_PO_t; -#include "proto.h" +#include "rrc_proto.h" #endif /** @} */ diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c similarity index 99% rename from openair2/RRC/LITE/rrc_eNB.c rename to openair2/RRC/LTE/rrc_eNB.c index f54b20dc4d9ca377c7b026523e2f52ec187bab2c..a214ccf1339f53f14c0314f015762fe7169950f1 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -30,17 +30,17 @@ #define RRC_ENB #define RRC_ENB_C -#include "defs.h" -#include "extern.h" +#include "rrc_defs.h" +#include "rrc_extern.h" #include "assertions.h" #include "common/ran_context.h" #include "asn1_conversions.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "LAYER2/RLC/rlc.h" -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "COMMON/mac_rrc_primitives.h" -#include "RRC/LITE/MESSAGES/asn1_msg.h" +#include "RRC/LTE/MESSAGES/asn1_msg.h" #include "RRCConnectionRequest.h" #include "RRCConnectionReestablishmentRequest.h" //#include "ReestablishmentCause.h" @@ -52,7 +52,6 @@ #include "TDD-Config.h" #include "HandoverCommand.h" #include "rlc.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" #include "rrc_eNB_UE_context.h" #include "platform_types.h" #include "msc.h" @@ -96,7 +95,7 @@ # include "rrc_eNB_ral.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus //#define XER_PRINT @@ -594,7 +593,7 @@ rrc_eNB_get_next_transaction_identifier( // // AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB index invalid (%d/%d)!", enb_mod_idP, NB_eNB_INST); // -// for (i = 0; i < NUMBER_OF_UE_MAX; i++) { +// for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { // if (RC.rrc[enb_mod_idP]->Info.UE_list[i] == UE_identity) { // // UE_identity already registered // reg = TRUE; @@ -934,14 +933,14 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* #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++) { + for (i=0; i<MAX_MOBILES_PER_ENB; 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++) { + for (i=0; i<MAX_MOBILES_PER_ENB; i++) { dlsch = eNB_PHY->dlsch[i][0]; if((dlsch != NULL) && (dlsch->rnti == rnti)){ LOG_I(RRC, "clean_eNb_dlsch UE %x \n", rnti); @@ -1894,7 +1893,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( 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++) { + for (int i=0; i<MAX_MOBILES_PER_ENB; 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); @@ -5810,11 +5809,11 @@ openair_rrc_eNB_init( } #endif AssertFatal(RC.rrc[enb_mod_idP] != NULL, "RC.rrc not initialized!"); - AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); + AssertFatal(MAX_MOBILES_PER_ENB < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); #ifdef ENABLE_ITTI AssertFatal(configuration!=NULL,"configuration input is null\n"); #endif - // for (j = 0; j < NUMBER_OF_UE_MAX; j++) + // for (j = 0; j < MAX_MOBILES_PER_ENB; j++) // RC.rrc[ctxt.module_id].Info.UE[j].Status = RRC_IDLE; //CH_READY; // //#if defined(ENABLE_USE_MME) @@ -5823,7 +5822,7 @@ openair_rrc_eNB_init( //#endif // { // /* Init security parameters */ - // for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + // for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { // RC.rrc[ctxt.module_id].ciphering_algorithm[j] = SecurityAlgorithmConfig__cipheringAlgorithm_eea0; // RC.rrc[ctxt.module_id].integrity_algorithm[j] = SecurityAlgorithmConfig__integrityProtAlgorithm_eia2; // rrc_eNB_init_security(enb_mod_idP, j); @@ -5837,13 +5836,13 @@ openair_rrc_eNB_init( uid_linear_allocator_init(&RC.rrc[ctxt.module_id]->uid_allocator); RB_INIT(&RC.rrc[ctxt.module_id]->rrc_ue_head); - // for (j = 0; j < (NUMBER_OF_UE_MAX + 1); j++) { + // for (j = 0; j < (MAX_MOBILES_PER_ENB + 1); j++) { // RC.rrc[enb_mod_idP]->Srb2[j].Active = 0; // } - RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); - RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); + RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL); + RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL); memcpy(&RC.rrc[ctxt.module_id]->configuration,configuration,sizeof(RrcConfigurationReq)); @@ -5899,7 +5898,7 @@ openair_rrc_eNB_init( , configuration #endif ); - for (int ue_id = 0; ue_id < NUMBER_OF_UE_MAX; ue_id++) { + for (int ue_id = 0; ue_id < MAX_MOBILES_PER_ENB; 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); } @@ -6143,7 +6142,7 @@ rrc_eNB_decode_ccch( ue_context_p->ue_context.ue_release_timer = 0; // insert C-RNTI to map - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (reestablish_rnti_map[i][0] == 0) { reestablish_rnti_map[i][0] = ctxt_pP->rnti; reestablish_rnti_map[i][1] = c_rnti; @@ -6769,7 +6768,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { 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++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; 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( diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c similarity index 97% rename from openair2/RRC/LITE/rrc_eNB_GTPV1U.c rename to openair2/RRC/LTE/rrc_eNB_GTPV1U.c index e5f2c5aaae1c469c4da1ffbcda1a41a0d7c264d4..135c6fea8d82e5279036ad7c11ae08df8d3d8683 100644 --- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c @@ -28,9 +28,9 @@ */ #if defined(ENABLE_USE_MME) -# include "defs.h" -# include "extern.h" -# include "RRC/LITE/MESSAGES/asn1_msg.h" +# include "rrc_defs.h" +# include "rrc_extern.h" +# include "RRC/LTE/MESSAGES/asn1_msg.h" # include "rrc_eNB_GTPV1U.h" # include "rrc_eNB_UE_context.h" # include "msc.h" diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.h b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_GTPV1U.h rename to openair2/RRC/LTE/rrc_eNB_GTPV1U.h diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c similarity index 99% rename from openair2/RRC/LITE/rrc_eNB_S1AP.c rename to openair2/RRC/LTE/rrc_eNB_S1AP.c index 80ae1c9ba57e9e276f5f4581c6dea7c9c7e49bec..153b5d693dfc5da9d574b7023f0915a86c7ef202 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -27,13 +27,11 @@ * \company Eurecom * \email: navid.nikaein@eurecom.fr */ - #if defined(ENABLE_USE_MME) -# include "defs.h" -# include "extern.h" +# include "rrc_defs.h" +# include "rrc_extern.h" # include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -# include "RRC/LITE/MESSAGES/asn1_msg.h" -# include "RRC/LITE/defs.h" +# include "RRC/LTE/MESSAGES/asn1_msg.h" # include "rrc_eNB_UE_context.h" # include "rrc_eNB_S1AP.h" # include "enb_config.h" @@ -57,7 +55,7 @@ #include "UERadioAccessCapabilityInformation.h" #include "gtpv1u_eNB_task.h" -#include "RRC/LITE/rrc_eNB_GTPV1U.h" +#include "RRC/LTE/rrc_eNB_GTPV1U.h" #include "TLVDecoder.h" #include "S1ap-NAS-PDU.h" @@ -1996,7 +1994,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance /* 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++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; 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) */ diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.h b/openair2/RRC/LTE/rrc_eNB_S1AP.h similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_S1AP.h rename to openair2/RRC/LTE/rrc_eNB_S1AP.h diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.c b/openair2/RRC/LTE/rrc_eNB_UE_context.c similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_UE_context.c rename to openair2/RRC/LTE/rrc_eNB_UE_context.c diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.h b/openair2/RRC/LTE/rrc_eNB_UE_context.h similarity index 98% rename from openair2/RRC/LITE/rrc_eNB_UE_context.h rename to openair2/RRC/LTE/rrc_eNB_UE_context.h index 0e813cdee526819145296ff477ee620f39b00b1d..289b4d69d69275e75659a819a17b57d85fb2861c 100644 --- a/openair2/RRC/LITE/rrc_eNB_UE_context.h +++ b/openair2/RRC/LTE/rrc_eNB_UE_context.h @@ -30,7 +30,7 @@ #ifndef __RRC_ENB_UE_CONTEXT_H__ #include "collection/tree.h" #include "COMMON/platform_types.h" -#include "defs.h" +#include "rrc_defs.h" void diff --git a/openair2/RRC/LITE/rrc_eNB_ral.c b/openair2/RRC/LTE/rrc_eNB_ral.c similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_ral.c rename to openair2/RRC/LTE/rrc_eNB_ral.c diff --git a/openair2/RRC/LITE/rrc_eNB_ral.h b/openair2/RRC/LTE/rrc_eNB_ral.h similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_ral.h rename to openair2/RRC/LTE/rrc_eNB_ral.h diff --git a/openair2/RRC/LITE/extern.h b/openair2/RRC/LTE/rrc_extern.h similarity index 91% rename from openair2/RRC/LITE/extern.h rename to openair2/RRC/LTE/rrc_extern.h index b45dbd11e9557db9667b6c2ea24f1906eb67f774..6c19fa9c7076202b934664657e2e9cc3c3c1508a 100644 --- a/openair2/RRC/LITE/extern.h +++ b/openair2/RRC/LTE/rrc_extern.h @@ -30,15 +30,13 @@ #ifndef __OPENAIR_RRC_EXTERN_H__ #define __OPENAIR_RRC_EXTERN_H__ -#include "defs.h" +#include "rrc_defs.h" #include "COMMON/mac_rrc_primitives.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" #include "LAYER2/RLC/rlc.h" extern UE_RRC_INST *UE_rrc_inst; -#include "LAYER2/MAC/extern.h" extern uint8_t DRB2LCHAN[8]; @@ -77,10 +75,10 @@ extern uint32_t timeToTrigger_ms[16]; extern float RSRP_meas_mapping[98]; extern float RSRQ_meas_mapping[35]; -extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; extern pthread_mutex_t ue_pf_po_mutex; -extern uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2]; +extern uint16_t reestablish_rnti_map[MAX_MOBILES_PER_ENB][2]; #endif diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LTE/rrc_proto.h similarity index 99% rename from openair2/RRC/LITE/proto.h rename to openair2/RRC/LTE/rrc_proto.h index e692668370e9e25aabadb125a0545e01cc39617f..9ae467967176879ba3dcc3544c80b89d4518a231 100644 --- a/openair2/RRC/LITE/proto.h +++ b/openair2/RRC/LTE/rrc_proto.h @@ -31,7 +31,7 @@ * @{ */ -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "flexran_agent_extern.h" diff --git a/openair2/RRC/LITE/rrc_rrm_interface.c b/openair2/RRC/LTE/rrc_rrm_interface.c similarity index 100% rename from openair2/RRC/LITE/rrc_rrm_interface.c rename to openair2/RRC/LTE/rrc_rrm_interface.c diff --git a/openair2/RRC/LITE/rrc_rrm_interface.h b/openair2/RRC/LTE/rrc_rrm_interface.h similarity index 100% rename from openair2/RRC/LITE/rrc_rrm_interface.h rename to openair2/RRC/LTE/rrc_rrm_interface.h diff --git a/openair2/RRC/LITE/rrc_types.h b/openair2/RRC/LTE/rrc_types.h similarity index 100% rename from openair2/RRC/LITE/rrc_types.h rename to openair2/RRC/LTE/rrc_types.h diff --git a/openair2/RRC/LITE/rrc_types_NB_IoT.h b/openair2/RRC/LTE/rrc_types_NB_IoT.h similarity index 100% rename from openair2/RRC/LITE/rrc_types_NB_IoT.h rename to openair2/RRC/LTE/rrc_types_NB_IoT.h diff --git a/openair2/RRC/LITE/vars.h b/openair2/RRC/LTE/rrc_vars.h similarity index 95% rename from openair2/RRC/LITE/vars.h rename to openair2/RRC/LTE/rrc_vars.h index e3bab5f5eb48aa577400a62d92d1397ab2ed25cf..dcd608a76a719cda6c2963d5df51d4a018efc6b0 100644 --- a/openair2/RRC/LITE/vars.h +++ b/openair2/RRC/LTE/rrc_vars.h @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -/*! \file vars.hles +/*! \file rrc_vars.h * \brief rrc variables * \author Raymond Knopp and Navid Nikaein * \date 2013 @@ -31,15 +31,15 @@ #ifndef __OPENAIR_RRC_VARS_H__ #define __OPENAIR_RRC_VARS_H__ -#include "defs.h" +#include "rrc_defs.h" #include "LAYER2/RLC/rlc.h" #include "COMMON/mac_rrc_primitives.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" -UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; pthread_mutex_t ue_pf_po_mutex; UE_RRC_INST *UE_rrc_inst; -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #define MAX_U32 0xFFFFFFFF uint8_t DRB2LCHAN[8]; @@ -242,6 +242,6 @@ float RSRQ_meas_mapping[35] = { // [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}}; +uint16_t reestablish_rnti_map[MAX_MOBILES_PER_ENB][2] = {{0}}; #endif diff --git a/openair2/RRC/LITE/rrm_2_rrc_msg.c b/openair2/RRC/LTE/rrm_2_rrc_msg.c similarity index 100% rename from openair2/RRC/LITE/rrm_2_rrc_msg.c rename to openair2/RRC/LTE/rrm_2_rrc_msg.c diff --git a/openair2/RRC/LITE/utils.c b/openair2/RRC/LTE/utils.c similarity index 100% rename from openair2/RRC/LITE/utils.c rename to openair2/RRC/LTE/utils.c diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c index 9c3a50467a785f4f218d3f2eef034e327d5dde78..39447001fab293832c874cfe2957c30476b7ac26 100644 --- a/openair2/UTIL/MEM/mem_block.c +++ b/openair2/UTIL/MEM/mem_block.c @@ -33,8 +33,8 @@ #include "mem_block.h" #include "mem_pool.h" #include "list.h" -#include "LAYER2/MAC/extern.h" - +#include "LAYER2/MAC/mac_extern.h" +#include "assertions.h" /* all function calls are protected by a mutex * to ensure that many threads calling them at * the same time don't mess up. diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h index 855b7a99fdde30ef25bfb70c7c78c8a523104a2b..0495b139ce363e548346c83d9d22213ea32647e3 100644 --- a/openair2/UTIL/OCG/OCG.h +++ b/openair2/UTIL/OCG/OCG.h @@ -36,7 +36,7 @@ #ifndef __OCG_H__ #define __OCG_H__ -#include "PHY/defs.h" +#include "PHY/defs_common.h" #include "PHY/impl_defs_top.h" #include "platform_types.h" diff --git a/openair2/UTIL/OTG/otg_defs.h b/openair2/UTIL/OTG/otg_defs.h index fad0d9510ece3fc190b76889f819cb71aab4d080..6c9944014fd99f08e01e53f2ef4e4330446bf8e3 100644 --- a/openair2/UTIL/OTG/otg_defs.h +++ b/openair2/UTIL/OTG/otg_defs.h @@ -33,7 +33,7 @@ #ifndef __OTG_DEFS_H__ # define __OTG_DEFS_H__ -/* \brief To define the NUMBER_OF_eNB_MAX and NUMBER_OF_UE_MAX */ +/* \brief To define the NUMBER_OF_eNB_MAX and MAX_MOBILES_PER_ENB */ #if STANDALONE==1 #include "openairinterface5g_limits.h" #else @@ -313,13 +313,13 @@ typedef struct { /*this structure constitutes a whole bg-stream with multiple bg typedef struct { int application_type[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION]; /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/ - int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; - int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ - int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ + int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ + int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ - int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Inter Departure Time distribution */ + int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Inter Departure Time distribution */ int idt_min[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION]; /*!\brief Min Inter Departure Time, for uniform distrib */ int idt_max[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION]; /*!\brief idt, Max Inter Departure Time, for uniform distrib */ @@ -338,69 +338,69 @@ typedef struct { */ typedef struct { int max_nb_frames; /*!< \brief Max Number of frames*/ - int application_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/ + int application_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/ /*!\header info */ - int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Transport Protocol*/ - int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Ip version */ + int trans_proto[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Transport Protocol*/ + int ip_v[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Ip version */ //int header_compression; /*!\brief Specify if header compression is used or not */ int num_nodes; /*!\brief Number of used nodes in the simulation */ int packet_gen_type; /*!\brief define how the payload is generated: fixed, predefined, random position, random see ALPHABET_GEN */ - unsigned int background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief enable or disable background traffic */ - unsigned int aggregation_level[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /* define packet aggregation level for the case of gateway*/ + unsigned int background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief enable or disable background traffic */ + unsigned int aggregation_level[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /* define packet aggregation level for the case of gateway*/ // src id , dst id, and state // think to the case of several streams per node !!!!! - int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Inter Departure Time distribution */ - int idt_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Inter Departure Time, for uniform distrib */ - int idt_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Max Inter Departure Time, for uniform distrib */ + int idt_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Inter Departure Time distribution */ + int idt_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Inter Departure Time, for uniform distrib */ + int idt_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Max Inter Departure Time, for uniform distrib */ - double idt_std_dev[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Standard Deviation, for guassian distrib */ - double idt_lambda[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, lambda, for exponential/poisson distrib */ - double idt_scale[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ - double idt_shape[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ + double idt_std_dev[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Standard Deviation, for guassian distrib */ + double idt_lambda[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, lambda, for exponential/poisson distrib */ + double idt_scale[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ + double idt_shape[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ - int size_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Paylolad size distribution */ - int size_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Payload size, for uniform distrib */ - int size_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Max Inter Departure Time, for uniform distrib */ - double size_std_dev[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Standard Deviation, for guassian distrib */ - double size_lambda[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, lambda, for exponential/poisson distrib */ + int size_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Paylolad size distribution */ + int size_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Payload size, for uniform distrib */ + int size_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Max Inter Departure Time, for uniform distrib */ + double size_std_dev[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Standard Deviation, for guassian distrib */ + double size_lambda[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, lambda, for exponential/poisson distrib */ - double size_scale[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution */ - double size_shape[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ + double size_scale[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution */ + double size_shape[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ // info for state-based traffic gen - int num_state [NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Number of states for source node*/ - // int state_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_TRAFFIC_STATE]; /*!\brief States distribution */ - double state_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_TRAFFIC_STATE]; /*!\brief State probablity: prob to move from one state to the other one */ + int num_state [NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Number of states for source node*/ + // int state_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_TRAFFIC_STATE]; /*!\brief States distribution */ + double state_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_TRAFFIC_STATE]; /*!\brief State probablity: prob to move from one state to the other one */ // num stream for each src - // int stream [NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; // this requires multi thread for parallel stream for a givcen src + // int stream [NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; // this requires multi thread for parallel stream for a givcen src // emu info - int flow_start_flag[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow start time flag for traffic generation or use the emuulation time instead */ - int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow start time of traffic generation or use the emuulation time instead */ - int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow duration of traffic generation or use the emuulation time instead */ + int flow_start_flag[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow start time flag for traffic generation or use the emuulation time instead */ + int flow_start[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow start time of traffic generation or use the emuulation time instead */ + int flow_duration[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow duration of traffic generation or use the emuulation time instead */ int seed; /*!\brief The seed used to generate the random positions*/ - int dst_port[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Destination port number, for the socket mode*/ - char *dst_ip[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Destination IP address, for the socket mode*/ + int dst_port[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Destination port number, for the socket mode*/ + char *dst_ip[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Destination IP address, for the socket mode*/ - int trans_proto_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief define the transport protocol and IP version for background traffic*/ + int trans_proto_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief define the transport protocol and IP version for background traffic*/ - double prob_off_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_off_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_off_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_pu_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_pu_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_ed_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_ed_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_off_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_off_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_off_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int pu_size_pkts[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int ed_size_pkts[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int m2m[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + double prob_off_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_off_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_off_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_pu_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_pu_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_ed_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_ed_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_off_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_off_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_off_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int pu_size_pkts[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int ed_size_pkts[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int m2m[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; unsigned int throughput_metric; @@ -409,7 +409,7 @@ typedef struct { unsigned int curve; unsigned int owd_radio_access; unsigned int background_stats; - unsigned int application_idx[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + unsigned int application_idx[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; } otg_t; @@ -485,8 +485,8 @@ typedef struct { unsigned int rx_total_bytes_dl; /*TARMA parameteres*/ - tarmaStream_t *mtarma_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - tarmaVideo_t *mtarma_video[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + tarmaStream_t *mtarma_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + tarmaVideo_t *mtarma_video[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; } otg_multicast_info_t; @@ -505,71 +505,71 @@ typedef struct { int ctime; /*!< \brief Simulation time in ms*/ int ptime_background_ul; /*!< \brief time of last sent background UL data (time in ms)*/ int ptime_background_dl; /*!< \brief time of last sent background DL data (time in ms)*/ - int ptime[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief time of last sent data (time in ms)*/ - int seq_num[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the sender */ - int seq_num_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief the sequence number for background traffic of the sender */ - int seq_num_rx[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the receiver */ - int seq_num_rx_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief the sequence number for background traffic of the receiver */ + int ptime[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief time of last sent data (time in ms)*/ + int seq_num[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the sender */ + int seq_num_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief the sequence number for background traffic of the sender */ + int seq_num_rx[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the receiver */ + int seq_num_rx_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief the sequence number for background traffic of the receiver */ - int idt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Inter Departure Time for background traffic in ms*/ - int size_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief payload size for background traffic*/ - int idt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief Inter Departure Time in ms*/ - int header_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Define the type of header: Transport layer + IP version*/ + int idt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Inter Departure Time for background traffic in ms*/ + int size_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief payload size for background traffic*/ + int idt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief Inter Departure Time in ms*/ + int header_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Define the type of header: Transport layer + IP version*/ /*!< \brief Statics part: vars updated at each iteration of otg_tx */ - int tx_num_pkt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the tx*/ - int tx_num_bytes[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the tx*/ // get the size and calculate the avg throughput + int tx_num_pkt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the tx*/ + int tx_num_bytes[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the tx*/ // get the size and calculate the avg throughput // vars updated at each iteration of otg_rx - int rx_num_pkt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the rx */ - int rx_num_bytes[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the rx */ - float rx_pkt_owd[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ - float rx_owd_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_owd_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_pkt_owd_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ - float rx_owd_min_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_owd_max_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_pkt_owd_history[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ - float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ - float rx_pkt_jitter[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime */ - float rx_jitter_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_jitter_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_jitter_avg[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_pkt_jitter_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime */ - float rx_jitter_min_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_jitter_max_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_jitter_avg_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - int rx_jitter_sample[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - int nb_loss_pkts_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for UL*/ - int nb_loss_pkts_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for DL*/ - float owd_const[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief One way delay constant*/ + int rx_num_pkt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the rx */ + int rx_num_bytes[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the rx */ + float rx_pkt_owd[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ + float rx_owd_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_owd_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_pkt_owd_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ + float rx_owd_min_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_owd_max_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_pkt_owd_history[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ + float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ + float rx_pkt_jitter[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime */ + float rx_jitter_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_jitter_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_jitter_avg[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_pkt_jitter_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime */ + float rx_jitter_min_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_jitter_max_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_jitter_avg_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + int rx_jitter_sample[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + int nb_loss_pkts_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for UL*/ + int nb_loss_pkts_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for DL*/ + float owd_const[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief One way delay constant*/ /*!< \brief KPI part: calculate the KPIs, total */ - double tx_throughput[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ - double rx_goodput[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Rx goodput: (size of received data)/ctime*/ - float rx_loss_rate[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ - //int rx_latency[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Rx Latency */ + double tx_throughput[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ + double rx_goodput[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Rx goodput: (size of received data)/ctime*/ + float rx_loss_rate[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ + //int rx_latency[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Rx Latency */ /*!< \brief Background traffic part: SATS + KPIs */ - int tx_num_pkt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background data packet in the rx */ - int tx_num_bytes_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background bytes in the rx */ - int rx_num_pkt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background data packet in the tx */ - int rx_num_bytes_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background bytes in the tx */ - int nb_loss_pkts_background_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background packets losses for UL*/ - int nb_loss_pkts_background_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background packets losses for DL*/ - double tx_throughput_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ - double rx_goodput_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Rx goodput: (size of received data)/ctime*/ - float rx_loss_rate_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ - - float radio_access_delay[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - int nb_loss_pkts_otg[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int aggregation_level[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - - unsigned int state[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief current state of src node */ - float state_transition_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_holding_time_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + int tx_num_pkt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background data packet in the rx */ + int tx_num_bytes_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background bytes in the rx */ + int rx_num_pkt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background data packet in the tx */ + int rx_num_bytes_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background bytes in the tx */ + int nb_loss_pkts_background_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background packets losses for UL*/ + int nb_loss_pkts_background_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background packets losses for DL*/ + double tx_throughput_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ + double rx_goodput_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Rx goodput: (size of received data)/ctime*/ + float rx_loss_rate_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ + + float radio_access_delay[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + int nb_loss_pkts_otg[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int aggregation_level[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + + unsigned int state[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief current state of src node */ + float state_transition_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_holding_time_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; unsigned int tx_total_bytes_dl; unsigned int tx_total_bytes_ul; unsigned int rx_total_bytes_dl; @@ -582,32 +582,32 @@ typedef struct { float average_jitter_ul_e2e; /* VOIP tarffic parameters*/ - float voip_transition_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int voip_state[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_voip_silence[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_silence[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_voip_talk[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_talk[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int silence_time[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int simple_talk_time[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + float voip_transition_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int voip_state[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_voip_silence[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_silence[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_voip_talk[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_talk[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int silence_time[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int simple_talk_time[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*TARMA parameteres*/ - tarmaStream_t *tarma_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - tarmaVideo_t *tarma_video[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + tarmaStream_t *tarma_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + tarmaVideo_t *tarma_video[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*BACKGROUND_USERS parameters*/ - backgroundStream_t *background_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - - unsigned int header_size_app[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int header_size[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int m2m_aggregation[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int flow_id[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int traffic_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int traffic_type_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + backgroundStream_t *background_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + + unsigned int header_size_app[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int header_size[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int m2m_aggregation[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int flow_id[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int traffic_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int traffic_type_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; // unsigned int traffic_type_multicast[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX]; - unsigned int hdr_size[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int header_type_app[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; ; + unsigned int hdr_size[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int header_type_app[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; ; unsigned int gen_pkts; - unsigned int header_size_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + unsigned int header_size_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; } otg_info_t; @@ -640,14 +640,14 @@ typedef struct { int init_forms; int is_data_plot_ul; int is_data_plot_dl; - float data_owd_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_throughput_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_ctime_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - int idx_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - float data_owd_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_throughput_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_ctime_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - int idx_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + float data_owd_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_throughput_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_ctime_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + int idx_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + float data_owd_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_throughput_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_ctime_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + int idx_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; } otg_forms_info_t; diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 04c503cb361d38c8d953ea89a4681200beef4ec2..391e448deb590584e9a4b917edd4a6210b1fa1a5 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -36,7 +36,7 @@ # include "lteRALue.h" # include "lteRALenb.h" # endif -# include "RRC/LITE/defs.h" +# include "RRC/LTE/rrc_defs.h" # endif # include "enb_app.h" diff --git a/targets/COMMON/create_tasks_ue.c b/targets/COMMON/create_tasks_ue.c index bd36511b524a093504730643748f55bea95254ff..db531b0e9ddd73294530a337909d04c8878039fd 100644 --- a/targets/COMMON/create_tasks_ue.c +++ b/targets/COMMON/create_tasks_ue.c @@ -36,7 +36,7 @@ # include "lteRALue.h" # include "lteRALenb.h" # endif -# include "RRC/LITE/defs.h" +# include "RRC/LTE/rrc_defs.h" # endif # include "enb_app.h" diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.100PRB.usrpx310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.100PRB.usrpx310.conf new file mode 100644 index 0000000000000000000000000000000000000000..38e471ac545b36c4ee469867efa646d0e3d24780 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.100PRB.usrpx310.conf @@ -0,0 +1,175 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + mobile_network_code = "92"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 38; + downlink_frequency = 2600000000L; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 100; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 32; + rx_gain = 116; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -16; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -90; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -108; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + + ENB_INTERFACE_NAME_FOR_S1U = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + log_config : + { + global_log_level ="debug"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + 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/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.usrpx310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.usrpx310.conf new file mode 100644 index 0000000000000000000000000000000000000000..2c11ea318701019d3e7a2e81b4889890b4f426a2 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.usrpx310.conf @@ -0,0 +1,175 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + mobile_network_code = "92"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 38; + downlink_frequency = 2600000000L; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 32; + rx_gain = 116; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -16; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -90; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -108; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + + ENB_INTERFACE_NAME_FOR_S1U = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + log_config : + { + global_log_level ="debug"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + 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/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index c269bcbe3bf01539aca22b1893ccda4793eb7334..578a4d5f3117c514483829e34adbecea7a54e77e 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -44,7 +44,12 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/INIT/phy_init.h" + +#include "PHY/defs_eNB.h" +#include "SCHED/sched_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" + #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all @@ -55,22 +60,14 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/extern.h" - -#include "../../SIMU/USER/init_lte.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" -#include "PHY_INTERFACE/defs.h" -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif +#include "PHY/phy_extern.h" + + +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" @@ -78,7 +75,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 "PHY/TOOLS/time_meas.h" + #ifndef OPENAIR2 #include "UTIL/OTG/otg_extern.h" @@ -222,7 +219,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // UE-specific RX processing for subframe n if (nfapi_mode == 0 || nfapi_mode == 1) { - phy_procedures_eNB_uespec_RX(eNB, proc, no_relay ); + phy_procedures_eNB_uespec_RX(eNB, proc); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 ); @@ -248,10 +245,9 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); if(oai_exit) return(-1); if(get_nprocs() <= 4){ - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + phy_procedures_eNB_TX(eNB, proc, 1); } - stop_meas( &softmodem_stats_rxtx_sf ); 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); @@ -329,7 +325,7 @@ static void* tx_thread(void* param) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_ENB,proc->frame_tx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx); - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + phy_procedures_eNB_TX(eNB, proc, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; pthread_mutex_lock( &proc->mutex_rxtx ); @@ -423,7 +419,7 @@ static void* eNB_thread_rxtx( void* param ) { if(get_nprocs() >= 8) wakeup_tx(eNB,eNB->proc.ru_proc); else { - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + phy_procedures_eNB_TX(eNB, proc, 1); wakeup_txfh(proc,eNB->proc.ru_proc); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 1cbe73c3090a93eadd8577b498c7787345539c4e..d8971f5da641c712be4fd74099e1db1a0856dbb2 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -60,7 +60,7 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_common.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all @@ -70,22 +70,19 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/extern.h" +#include "PHY/phy_extern.h" +#include "LAYER2/MAC/mac_extern.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/INIT/phy_init.h" -#include "../../SIMU/USER/init_lte.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" - -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 50b868ae1d1205747d5730548977db3782e0786e..7163d8bd7dc1ab8a9bdb6b5ac0d17de484c20683 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -47,7 +47,7 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "common/ran_context.h" #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" @@ -59,17 +59,14 @@ //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "PHY/vars.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" +#include "PHY/phy_vars.h" +#include "SCHED/sched_common_vars.h" +#include "LAYER2/MAC/mac_vars.h" -#include "../../SIMU/USER/init_lte.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/vars.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/vars.h" -#include "PHY_INTERFACE/vars.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_vars.h" +#include "PHY_INTERFACE/phy_interface_vars.h" #ifdef SMBV #include "PHY/TOOLS/smbv.h" @@ -93,6 +90,8 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "create_tasks.h" #endif +#include "PHY/INIT/phy_init.h" + #include "system.h" #ifdef XFORMS @@ -145,7 +144,8 @@ static int8_t threequarter_fs=0; uint32_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; - +// This is a dummy declaration (dlsch_demodulation.c is no longer compiled for eNodeB) +int16_t dlsch_demod_shift = 0; #if defined(ENABLE_ITTI) static char *itti_dump_file = NULL; @@ -1096,7 +1096,7 @@ int main( int argc, char **argv ) // 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); + memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs); mlockall(MCL_CURRENT | MCL_FUTURE); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index bd6596f75c73c651ddcfcd743229f783f7e4b174..c375d28106cdf04de3d65d37644d3a7dd5cc3a58 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -28,7 +28,8 @@ #include "assertions.h" #include "msc.h" #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "flexran_agent.h" @@ -140,17 +141,18 @@ {"emul-iface", CONFIG_HLP_EMULIFACE, 0, strptr:&emul_iface, defstrval:"lo", TYPE_STRING, 100}, \ {"L2-emul", NULL, 0, u8ptr:&nfapi_mode, defuintval:3, TYPE_UINT8, 0}, \ {"num-ues", NULL, 0, u8ptr:&(NB_UE_INST), defuintval:1, TYPE_UINT8, 0}, \ -{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0} \ +{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \ +{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ } #define DEFAULT_DLF 2680000000 -extern int16_t dlsch_demod_shift; + /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters common to eNodeB and UE */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_PARAMS_DESC { \ -{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)},\ +{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ {"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ @@ -183,7 +185,7 @@ extern int16_t dlsch_demod_shift; {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \ {"codingw" , CONFIG_HLP_CODINGW, PARAMFLAG_BOOL, iptr:&codingw, defintval:0, TYPE_INT, 0}, \ {"fepw" , CONFIG_HLP_FEPW, PARAMFLAG_BOOL, iptr:&fepw, defintval:0, TYPE_INT, 0}, \ -{"nbiot-disable", CONFIG_HLP_DISABLNBIOT,PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \ +{"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \ } #define CONFIG_HLP_FLOG "Enable online log \n" diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 84e77c1ef829f5da1946a37a11ba86db27bc59c5..f5921053ebfb006b51c72ccd6901eec0f5ed55ef 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -33,23 +33,18 @@ #include "rt_wrapper.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "RRC/LITE/extern.h" -#endif +#include "LAYER2/MAC/mac.h" +#include "RRC/LTE/rrc_extern.h" #include "PHY_INTERFACE/phy_stub_UE.h" -#include "PHY_INTERFACE/extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "PHY/extern.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" +#include "PHY/phy_extern_ue.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" #include <inttypes.h> -//#include "openair2/PHY_INTERFACE/phy_stub_UE.h" - #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index c178dd3c2378c9ff253990680c7a3a00fc792896..40075429182531d06d61b1654ec9cd9ad7765d9a 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -47,7 +47,7 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" #include "common/ran_context.h" #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" @@ -59,22 +59,18 @@ //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "PHY/vars.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" - +#include "PHY/phy_vars_ue.h" +#include "PHY/LTE_TRANSPORT/transport_vars.h" +#include "SCHED/sched_common_vars.h" +#include "PHY/MODULATION/modulation_vars.h" #include "../../SIMU/USER/init_lte.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/vars.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/vars.h" -#include "PHY_INTERFACE/vars.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_vars.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_vars.h" +#include "PHY_INTERFACE/phy_interface_vars.h" -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" @@ -101,6 +97,8 @@ unsigned short config_frames[4] = {2,9,11,13}; #endif #include "lte-softmodem.h" +RAN_CONTEXT_t RC; + /* temporary compilation wokaround (UE/eNB split */ uint16_t sf_ahead; #ifdef XFORMS @@ -398,7 +396,7 @@ static void *scope_thread(void *arg) { #endif while (!oai_exit) { - dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm); + // dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm); //fl_set_object_label(form_stats->stats_text, stats_buffer); fl_clear_browser(form_stats->stats_text); fl_add_browser_line(form_stats->stats_text, stats_buffer); @@ -470,6 +468,7 @@ void *l2l1_task(void *arg) { } #endif +extern int16_t dlsch_demod_shift; static void get_options(void) { int CC_id; diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index 49fbed625672f9b4b9cc1e1defcb83381ca235c9..443d183068e634ab97e751d7ed5f448edd820732 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -45,7 +45,7 @@ #include "rt_wrapper.h" #include <errno.h> -#include "openair1/PHY/defs.h" +#include "openair1/PHY/defs_common.h" static int latency_target_fd = -1; static int32_t latency_target_value = 0; diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index 553d4807824625f102c74a4850822a2c5d50ae66..3018dbe1fb10e7565303323d9e599daf072b38c5 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -26,32 +26,24 @@ #include <stdio.h> #include <time.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/phy_extern_ue.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log_if.h" #include "UTIL/LOG/log_extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OPT/opt.h" // to test OPT -#endif #include "UTIL/FIFO/types.h" -#ifdef IFFT_FPGA -#include "PHY/LTE_REFSIG/mod_table.h" -#endif - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - #ifdef XFORMS #include "forms.h" #include "phy_procedures_sim_form.h" diff --git a/targets/SIMU/USER/init_lte.c b/targets/SIMU/USER/init_lte.c index 0818629727c7e4e2fc6b2c74e7dd0971c4bb4de9..13b9026640786664904fc326bf4bef6968bd3ece 100644 --- a/targets/SIMU/USER/init_lte.c +++ b/targets/SIMU/USER/init_lte.c @@ -29,12 +29,12 @@ #include "init_lte.h" -#include "PHY/extern.h" +#include "PHY/phy_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log_if.h" -#include "PHY_INTERFACE/extern.h" +#include "PHY_INTERFACE/phy_interface.h" /* diff --git a/targets/SIMU/USER/init_lte.h b/targets/SIMU/USER/init_lte.h index 6f0aa0a6eb5ea8840a6b587bd7f18d6563d251b3..fee6c974b84d0e7c2c5761eaae24e7c7a51e1d2d 100644 --- a/targets/SIMU/USER/init_lte.h +++ b/targets/SIMU/USER/init_lte.h @@ -20,7 +20,7 @@ */ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, @@ -32,10 +32,6 @@ PHY_VARS_UE* init_lte_UE(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); -PHY_VARS_RN* init_lte_RN(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t RN_id, - uint8_t eMBMS_active_state); - void init_lte_vars(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs], uint8_t frame_type, uint8_t tdd_config, diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 71436347634e00e060c1ae3b193e5153f6aa8ce3..1847db1d7185627b15ca36e9d80385fb5e5961c4 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -41,24 +41,23 @@ #include <execinfo.h> #include "event_handler.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/vars.h" - -#include "SIMULATION/ETH_TRANSPORT/proto.h" - -//#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/vars.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/phy_vars.h" +#include "PHY/phy_vars_ue.h" +#include "SCHED/sched_common_vars.h" + +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_vars.h" #include "pdcp.h" -#include "RRC/LITE/vars.h" +#include "RRC/LTE/rrc_vars.h" #include "RRC/NAS/nas_config.h" -#include "SCHED/defs.h" -#include "SCHED/vars.h" #include "system.h" @@ -101,6 +100,7 @@ char smbv_ip[16]; #if defined(ENABLE_ITTI) # include "intertask_interface.h" # include "create_tasks.h" +# include "intertask_interface_init.h" #endif #include "T.h" @@ -627,12 +627,8 @@ l2l1_task (void *args_p) } #endif - module_id_t UE_id; + - if (abstraction_flag == 1) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) - dl_phy_sync_success (UE_id, 0, 0,1); //UE_id%NB_eNB_INST); - } start_meas (&oaisim_stats); @@ -701,8 +697,8 @@ l2l1_task (void *args_p) //oai_emulation.info.time_ms += 1; oai_emulation.info.time_s += 0.01; // emu time in s, each frame lasts for 10 ms // JNote: TODO check the coherency of the time and frame (I corrected it to 10 (instead of 0.01) - update_omg (frame); // frequency is defined in the omg_global params configurable by the user - update_omg_ocm (); + //update_omg (frame); // frequency is defined in the omg_global params configurable by the user + //update_omg_ocm (); #ifdef OPENAIR2 @@ -796,15 +792,6 @@ l2l1_task (void *args_p) PHY_vars_eNB_g[eNB_inst][0]->frame_parms.Nid_cell); */ -#ifdef OPENAIR2 - //Application: traffic gen - update_otg_eNB (eNB_inst, oai_emulation.info.time_ms); - - //IP/OTG to PDCP and PDCP to IP operation - // pdcp_run (frame, 1, 0, eNB_inst); //PHY_vars_eNB_g[eNB_id]->Mod_id -#endif - - #ifdef PRINT_STATS if((sf==9) && frame%10==0) @@ -874,7 +861,7 @@ l2l1_task (void *args_p) } - update_ocm (); + //update_ocm (); /* if ((frame >= 10) && (frame <= 11) && (abstraction_flag == 0) #ifdef PROC @@ -1110,6 +1097,7 @@ int main (int argc, char **argv) oai_emulation.info.n_frames = MAX_FRAME_NUMBER; //1024; //10; oai_emulation.info.n_frames_flag = 0; //fixme snr_dB = 30; + NB_UE_INST = 1; //Default values if not changed by the user in get_simulation_options(); pdcp_period = 1; @@ -1126,7 +1114,7 @@ int main (int argc, char **argv) // start thread for log gen log_thread_init (); - init_oai_emulation (); // to initialize everything !!! + //init_oai_emulation (); // to initialize everything !!! // get command-line options get_simulation_options (argc, argv); //Command-line options @@ -1163,7 +1151,37 @@ int main (int argc, char **argv) #endif // configure oaisim with OCG - oaisim_config (); // config OMG and OCG, OPT, OTG, OLG + //oaisim_config (); // config OMG and OCG, OPT, OTG, OLG + logInit(); + +#if defined(ENABLE_ITTI) + itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, oai_emulation.info.itti_dump_file); + MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); +#endif + + set_glog(LOG_INFO, 0x15); + + + //set_log(OCG, LOG_DEBUG, 1); + //set_log(EMU, LOG_INFO, 20); + set_log(MAC, LOG_DEBUG, 1); + set_log(RLC, LOG_TRACE, 1); + //set_log(PHY, LOG_DEBUG, 1); + set_log(PDCP, LOG_TRACE, 1); + set_log(RRC, LOG_DEBUG, 1); + //set_log(OCM, LOG_INFO, 20); + //set_log(OTG, LOG_INFO, 1); + set_comp_log(OCG, LOG_ERR, 0x15,1); + set_comp_log(EMU, LOG_DEBUG, 0x15,20); + set_comp_log(MAC, LOG_TRACE, 0x15,1); + set_comp_log(RLC, LOG_TRACE, 0x15,1); + set_comp_log(PHY, LOG_TRACE, 0x15, 1); + set_comp_log(PDCP, LOG_DEBUG, 0x15,1); + set_comp_log(RRC, LOG_DEBUG, 0x15,1); + set_comp_log(OCM, LOG_DEBUG, 0x15,20); + set_comp_log(OTG, LOG_DEBUG, 0x15,1); + set_comp_log(OMG, LOG_NOTICE, 0x15,1); + set_comp_log(OPT, LOG_ERR, 0x15,1); if (ue_connection_test == 1) { snr_direction = -snr_step; @@ -1175,15 +1193,11 @@ int main (int argc, char **argv) pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&subframe_mutex, NULL); -#ifdef OPENAIR2 - init_omv (); -#endif //Before this call, NB_UE_INST and NB_eNB_INST are not set correctly check_and_adjust_params (); set_seed = oai_emulation.emulation_config.seed.value; - init_otg_pdcp_buffer (); init_seed (set_seed); @@ -1198,7 +1212,7 @@ int main (int argc, char **argv) - if (create_tasks_ue(oai_emulation.info.nb_ue_local) < 0) + if (create_tasks_ue(NB_UE_INST) < 0) exit(-1); // need a softer mode @@ -1211,6 +1225,7 @@ int main (int argc, char **argv) init_ocm (); + printf("Sending sync to all threads\n"); @@ -1219,12 +1234,6 @@ int main (int argc, char **argv) pthread_cond_broadcast(&sync_cond); pthread_mutex_unlock(&sync_mutex); -#ifdef SMBV - // Rohde&Schwarz SMBV100A vector signal generator - smbv_init_config(smbv_fname, smbv_nframes); - smbv_write_config_from_frame_parms(smbv_fname, &PHY_vars_eNB_g[0][0]->frame_parms); -#endif - /* #if defined (FLEXRAN_AGENT_SB_IF) flexran_agent_start(); #endif */ @@ -1733,11 +1742,6 @@ oai_shutdown (void) #endif - //Perform KPI measurements - if (oai_emulation.info.otg_enabled == 1){ - LOG_N(EMU,"calling OTG kpi gen .... \n"); - kpi_gen (); - } if (oai_emulation.info.opp_enabled == 1) print_opp_meas_oaisim (); @@ -1793,15 +1797,6 @@ oai_shutdown (void) } //End of PHY abstraction changes - // stop OMG - stop_mobility_generator (omg_param_list); //omg_param_list.mobility_type -#ifdef OPENAIR2 - - if (oai_emulation.info.omv_enabled == 1) - omv_end (pfd[1], omv_data); - -#endif - if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0) && (ShaF != NULL)) { destroyMat (ShaF, map1, map2); @@ -1811,9 +1806,6 @@ oai_shutdown (void) if (opt_enabled == 1) terminate_opt (); - if (oai_emulation.info.cli_enabled) - cli_server_cleanup (); - for (int i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++) if (oai_emulation.info.oai_ifup[i] == 1) { char interfaceName[8]; diff --git a/targets/SIMU/USER/oaisim.h b/targets/SIMU/USER/oaisim.h index 0fdc4002e47cd053fd8ffe56a4b4d7d5f2bd94d8..1ddc09398322cbb2cd91463e818a5d12ae4efc0f 100644 --- a/targets/SIMU/USER/oaisim.h +++ b/targets/SIMU/USER/oaisim.h @@ -26,15 +26,16 @@ #include <stdio.h> #include <time.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "oaisim_config.h" #include "init_lte.h" #ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/OMV/structures.h" #endif diff --git a/targets/SIMU/USER/oaisim_config.h b/targets/SIMU/USER/oaisim_config.h index fe1309b7a48531033474e6bf7413bd54a9b0642c..a403252d06430f214ba3c30e521f1e4652e8f000 100644 --- a/targets/SIMU/USER/oaisim_config.h +++ b/targets/SIMU/USER/oaisim_config.h @@ -49,10 +49,8 @@ The current sturcture of oaisim is shown by the figure. #include "UTIL/OPT/opt.h" // to test OPT #include "UTIL/OMG/omg.h" #include "UTIL/CLI/cli_if.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/ETH_TRANSPORT/defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" /** @defgroup _init_oai Initial oaisim * @ingroup _fn diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index 5900170480ed339009e85baef66d303d6535eff2..2bddfdd8fc23d9e4f15ae4ae2a36f0d26219f69c 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -43,29 +43,22 @@ #include "assertions.h" #include "oaisim_functions.h" -#include "PHY/extern.h" -#include "LAYER2/MAC/extern.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/proto.h" -#endif +#include "PHY/phy_extern.h" +#include "PHY/phy_extern_ue.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" #include "LAYER2/PDCP_v10.1.0/pdcp_primitives.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "PHY_INTERFACE/extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" //#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h" -#include "SCHED/extern.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "UTIL/OCG/OCG_extern.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "UTIL/OTG/otg_config.h" #include "UTIL/OTG/otg_tx.h" -#if ENABLE_RAL -#include "lteRALenb.h" -#include "lteRALue.h" -#endif - #include "cor_SF_sim.h" #include "enb_config.h" @@ -83,11 +76,6 @@ #include "ENB_APP/enb_paramdef.h" #include "common/config/config_userapi.h" -#ifdef SMBV -extern uint8_t config_smbv; -extern char smbv_ip[16]; -#endif - //constant for OAISIM soft realtime calibration #define SF_DEVIATION_OFFSET_NS 100000 //= 0.1ms : should be as a number of UE #define SLEEP_STEP_US 100 // = 0.01ms could be adaptive, should be as a number of UE @@ -137,34 +125,14 @@ int sleep_time_us = 0; int phy_test = 0; -#ifdef OPENAIR2 -// omv related info -//pid_t omv_pid; -char full_name[200]; -extern int pfd[2]; // fd for omv : fixme: this could be a local var -char fdstr[10]; -char frames[10]; -char num_enb[10]; -char num_ue[10]; -//area_x, area_y and area_z for omv -char x_area[20]; -char y_area[20]; -char z_area[20]; -char nb_antenna[20]; -char frame_type[10]; -char tdd_config[10]; -#endif - -Packet_OTG_List_t *otg_pdcp_buffer = NULL; - extern node_desc_t *enb_data[NUMBER_OF_RU_MAX]; -extern node_desc_t *ue_data[NUMBER_OF_UE_MAX]; -extern channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; -extern channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; +extern node_desc_t *ue_data[MAX_MOBILES_PER_ENB]; +extern channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; +extern channel_desc_t *UE2RU[MAX_MOBILES_PER_ENB][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; extern mapping small_scale_names[]; #if defined(Rel10) || defined(Rel14) -extern pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH]; +extern pdcp_mbms_t pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH]; extern pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH]; #endif @@ -701,7 +669,7 @@ void get_simulation_options(int argc, char *argv[]) break; case 'u': - oai_emulation.info.nb_ue_local = atoi (optarg); + NB_UE_INST = atoi (optarg); break; case 'U': @@ -870,13 +838,13 @@ void check_and_adjust_params(void) int32_t ret; //int i,j; - if (oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local > NUMBER_OF_UE_MAX) { - LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_UE_MAX); + if (oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local > MAX_MOBILES_PER_ENB) { + LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the MAX_MOBILES_PER_ENB\n", MAX_MOBILES_PER_ENB); exit(EXIT_FAILURE); } if (oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local > NUMBER_OF_eNB_MAX) { - LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX); + LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the MAX_MOBILES_PER_ENB\n", NUMBER_OF_eNB_MAX); exit(EXIT_FAILURE); } @@ -931,79 +899,14 @@ void check_and_adjust_params(void) } // ethernet flag */ // - NB_UE_INST = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_ue_remote; - NB_eNB_INST = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_enb_remote; - NB_RN_INST = oai_emulation.info.nb_rn_local + oai_emulation.info.nb_rn_remote; - NB_RU = oai_emulation.info.nb_ru_local + oai_emulation.info.nb_ru_remote; + + NB_RU = RC.nb_RU; #if defined(PDCP_USE_NETLINK_QUEUES) && defined(OPENAIR2) pdcp_netlink_init(); #endif - if (NB_RN_INST > 0 ) { - LOG_N(EMU,"Total number of RN %d (local %d, remote %d) mobility (the same as eNB) %s \n", NB_RN_INST,oai_emulation.info.nb_rn_local,oai_emulation.info.nb_rn_remote, - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); - - LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ", - NB_eNB_INST, NB_eNB_INST+NB_RN_INST, - NB_UE_INST, NB_UE_INST+NB_RN_INST); - NB_eNB_INST+=NB_RN_INST; - NB_UE_INST+=NB_RN_INST; - } - - LOG_I(EMU,"Total number of UE %d (first local %d , num local %d, remote %d, relay %d) mobility %s \n", - NB_UE_INST,oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local,oai_emulation.info.nb_ue_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option); - - LOG_I(EMU,"Total number of eNB %d (local %d, remote %d, relay %d) mobility %s \n", - NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); - -} - -#ifdef OPENAIR2 -void init_omv(void) -{ - if (oai_emulation.info.omv_enabled == 1) { - - if(pipe(pfd) == -1) - perror("pipe error \n"); - - snprintf( full_name, sizeof(full_name), "%s/UTIL/OMV/OMV",getenv("OPENAIR2_DIR") ); - LOG_I(EMU,"Stating the OMV path %s pfd[0] %d pfd[1] %d \n", full_name, pfd[0],pfd[1]); - - switch(fork()) { - case -1 : - perror("fork failed \n"); - break; - - case 0 : // child is going to be the omv, it is the reader - if(close(pfd[1]) == -1 ) // we close the write desc. - perror("close on write\n" ); - - sprintf(fdstr, "%d", pfd[0] ); - sprintf(num_enb, "%d", NB_eNB_INST); - sprintf(num_ue, "%d", NB_UE_INST); - sprintf(x_area, "%f", oai_emulation.topology_config.area.x_m ); - sprintf(y_area, "%f", oai_emulation.topology_config.area.y_m ); - sprintf(z_area, "%f", 200.0 ); - sprintf(frames, "%d", oai_emulation.info.n_frames); - sprintf(nb_antenna, "%d", 4); - sprintf(frame_type, "%s", (oai_emulation.info.frame_type[0] == 0) ? "FDD" : "TDD"); - sprintf(tdd_config, "%d", oai_emulation.info.tdd_config[0]); - // execl is used to launch the visualisor - execl(full_name,"OMV", fdstr, frames, num_enb, num_ue, x_area, y_area, z_area, nb_antenna, frame_type, tdd_config,NULL ); - perror( "error in execl the OMV" ); - } - - //parent - if(close( pfd[0] ) == -1 ) // we close the write desc. - perror("close on read\n" ); - } } -#endif void init_seed(uint8_t set_seed) { @@ -1020,9 +923,9 @@ void init_seed(uint8_t set_seed) } openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -openair0_timestamp current_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; +openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -openair0_timestamp last_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; +openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; int ru_trx_start(openair0_device *device) { return(0); @@ -1369,63 +1272,16 @@ void init_ocm(void) //char* frame_type = "unknown"; LTE_DL_FRAME_PARMS *fp = &RC.ru[0]->frame_parms; -#if 0 - switch (fp->frame_type) { - case FDD: - frame_type = "FDD"; - break; - - case TDD: - frame_type = "TDD"; - break; - } -#endif - - if (abstraction_flag) { - - get_beta_map(); - get_MIESM_param(); - - //load_pbch_desc(); - } - - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - enb_data[ru_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_enb(enb_data[ru_id],oai_emulation.environment_system_config.antenna.eNB_antenna); - } - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - ue_data[UE_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_ue(ue_data[UE_id],oai_emulation.environment_system_config.antenna.UE_antenna); - } - - if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 ) && - (oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m>0) && - (oai_emulation.environment_system_config.fading.shadowing.variance_dB>0)) { - - // init SF map here!!! - map1 =(int)oai_emulation.topology_config.area.x_m; - map2 =(int)oai_emulation.topology_config.area.y_m; - ShaF = init_SF(map1,map2,oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m,oai_emulation.environment_system_config.fading.shadowing.variance_dB); - - // size of area to generate shadow fading map - LOG_D(EMU,"Simulation area x=%f, y=%f\n", - oai_emulation.topology_config.area.x_m, - oai_emulation.topology_config.area.y_m); - } - - if (abstraction_flag == 0) - init_channel_vars (fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); + init_channel_vars (fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); // initialize channel descriptors + LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST); 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_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); - + LOG_I(PHY,"Initializing channel descriptors (RU %d, UE %d) for N_RB_DL %d\n",ru_id,UE_id, + RC.ru[ru_id]->frame_parms.N_RB_DL); RU2UE[ru_id][UE_id][CC_id] = new_channel_desc_scm(RC.ru[ru_id]->nb_tx, PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, @@ -1454,22 +1310,29 @@ void init_ocm(void) // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id]; - } - } - } -} -void init_otg_pdcp_buffer(void) -{ - module_id_t i; - otg_pdcp_buffer = malloc((NB_UE_INST + NB_eNB_INST) * sizeof(Packet_OTG_List_t)); + AssertFatal(RU2UE[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; + UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; + } else { + RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; + UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; + } + + LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, + RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, + RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower,snr_dB); + - for (i = 0; i < NB_UE_INST + NB_eNB_INST; i++) { - pkt_list_init(&(otg_pdcp_buffer[i])); - //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", i, pkt_list_get_head(&(otg_pdcp_buffer[i]))); + } + } } } +/* void update_omg (frame_t frameP) { module_id_t UE_id, eNB_id; @@ -1515,7 +1378,7 @@ void update_ocm() - /* check if the openair channel model is activated used for PHY abstraction : path loss*/ + // check if the openair channel model is activated used for PHY abstraction : path loss if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 )) { for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) @@ -1533,9 +1396,6 @@ void update_ocm() // if (oai_emulation.info.omg_model_ue == TRACE) //extract_position(ue_node_list, ue_data, NB_UE_INST); - /* if (frame % 50 == 0) - LOG_N(OCM,"Path loss for TTI %d : \n", frame); - */ for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { @@ -1550,10 +1410,10 @@ void update_ocm() //dx = enb_data[ru_id]->x - ue_data[UE_id]->x; //dy = enb_data[ru_id]->y - ue_data[UE_id]->y; //distance = sqrt(dx * dx + dy * dy); - /*LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n", - ru_id, enb_data[ru_id]->x,enb_data[ru_id]->y, - UE_id, ue_data[UE_id]->x,ue_data[UE_id]->y, - distance);*/ + ///LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n", + // ru_id, enb_data[ru_id]->x,enb_data[ru_id]->y, + // UE_id, ue_data[UE_id]->x,ue_data[UE_id]->y, + // distance); } } } @@ -1585,6 +1445,7 @@ void update_ocm() } } + #ifdef OPENAIR2 void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) { @@ -1592,13 +1453,12 @@ 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; Packet_otg_elt_t *otg_pkt; - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { + for (dst_id = 0; dst_id < MAX_MOBILES_PER_ENB; dst_id++) { for_times += 1; // generate traffic if the ue is rrc reconfigured state @@ -1663,9 +1523,9 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) otg_pkt=NULL; } -*/ + // old version - /* // MBSM multicast traffic + // MBSM multicast traffic #if defined(Rel10) || defined(Rel14) if (frame >= 46) {// only generate when UE can receive MTCH (need to control this value) for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount @@ -1688,15 +1548,15 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) } } // end multicast traffic #endif - */ -/* + + } } } } // end multicast traffic -*/ + #endif } @@ -1706,7 +1566,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) if (otg_enabled==1) { ctime = frame * 100; - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { + for (dst_id = 0; dst_id < MAX_MOBILES_PER_ENB; dst_id++) { if (mac_get_rrc_status(eNB_index, eNB_flag, dst_id ) > 2) { otg_pkt = malloc (sizeof(Packet_otg_elt_t)); (otg_pkt->otg_pkt).sdu_buffer = packet_gen(module_instP, dst_id, ctime, &pkt_size); @@ -1735,6 +1595,7 @@ void update_otg_UE(module_id_t ue_mod_idP, unsigned int ctime) { } #endif +*/ int init_slot_isr(void) { diff --git a/targets/SIMU/USER/sinr_sim.c b/targets/SIMU/USER/sinr_sim.c index 7c752ce432f2b268cc7d11b2efd1f770a2c2482b..2dc86b844301977c9983430ac51e7f89b2725072 100644 --- a/targets/SIMU/USER/sinr_sim.c +++ b/targets/SIMU/USER/sinr_sim.c @@ -27,27 +27,26 @@ #include <time.h> #include <cblas.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern.h" #include "oaisim_config.h" #ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log_if.h" #include "UTIL/LOG/log_extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OMG/omg.h" #include "UTIL/OPT/opt.h" // to test OPT #endif -#include "SCHED/defs.h" -#include "SCHED/extern.h" #include "oaisim.h"